initial brax3 device makefiles

* boots and works fine

Signed-off-by: erascape <erascape@proton.me>
This commit is contained in:
erascape 2025-09-24 08:37:41 +00:00
commit 59281ccd87
67 changed files with 3271 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/out
/workdir
/build

5
build.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
set -xe
[ -d build ] || git clone https://gitlab.com/ubports/community-ports/halium-generic-adaptation-build-tools build
./build/build.sh "$@"

22
deviceinfo Normal file
View file

@ -0,0 +1,22 @@
deviceinfo_name="BraX3"
deviceinfo_manufacturer="BraX"
deviceinfo_codename="prithvi"
deviceinfo_arch="aarch64"
deviceinfo_kernel_source="https://git.os-source.co/UbuntuTouchOs/kernel-brax3-ubuntu-touch.git"
deviceinfo_kernel_source_branch="ubuntu-focal"
deviceinfo_kernel_defconfig="gki_defconfig mgk.config entry_level.config halium.config"
deviceinfo_kernel_cmdline="bootopt=64S3,32N2,64N2 systempart=/dev/mapper/system"
deviceinfo_kernel_clang_compile="true"
deviceinfo_kernel_llvm_compile="true"
deviceinfo_prebuilt_boot_ramdisk_source="https://github.com/halium/initramfs-tools-halium/releases/download/dynparts/initrd.img-touch-arm64"
deviceinfo_ramdisk_compression="lz4"
deviceinfo_flash_pagesize="4096"
deviceinfo_bootimg_qcdt="false"
deviceinfo_bootimg_header_version="4"
# Needed for AVB footer, fine as long as it is less or the same
deviceinfo_bootimg_partition_size="33554432"
deviceinfo_bootimg_os_version="13"
deviceinfo_bootimg_os_patch_level="2023-05"
deviceinfo_bootimg_has_init_boot_partition="true"
deviceinfo_rootfs_image_sector_size="4096"
deviceinfo_halium_version="13"

View file

@ -0,0 +1 @@
AETHERCAST_I_FRAME_INTERVAL=-1

View file

@ -0,0 +1 @@
export MIR_ANDROID_FORCE_HWC2=1

View file

@ -0,0 +1,7 @@
IDVENDOR=0E8D
IDPRODUCT_MTP=2008
IDPRODUCT_MTP_ADB=201D
IDPRODUCT_RNDIS=2004
IDPRODUCT_RNDIS_ADB=2005
# Disable usb-moded's rescue mode.
USB_MODED_ARGS=

View file

@ -0,0 +1,12 @@
prithvi:
Vendor: BraX
PrettyName: BraX3
DeviceType: phone
GridUnit: 14
SupportedOrientations:
- Portrait
- Landscape
- InvertedLandscape
OfonoPlugin: binder
OfonoImplementsIms: true
VibrateDurationExtraMs: 40

View file

@ -0,0 +1,2 @@
[General]
ApiLevel = 33

View file

@ -0,0 +1,25 @@
# ofono binder driver configuration for MTK devices
[Settings]
ExpectSlots = slot1,slot2
3GLTEHandover = false
MaxNonDataMode = none
Device=/dev/binder
InterfaceType = aidl
#radioInterface = aidl
emptyPinQuery = false
useDataProfiles = true
mmsDataProfileId = 1001
# RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND
rilRequestOnSetUdub = 13
#extPlugin = mtk
[slot1]
path = /ril_0
slot = 0
[slot2]
path = /ril_1
slot = 1

View file

@ -0,0 +1,26 @@
# Ofono configuration for MTK devices
[Settings]
#EmptyConfig=false
#Identity=radio:radio
#3GLTEHandover=true
Device=/dev/binder
InterfaceType = aidl
emptyPinQuery=false
radioPowerCycle=false
confirmRadioPowerOn=false
networkSelectionManual0=false
cellInfoIntervalShortMs=0
useDataProfiles=true
mmsDataProfileId=1001
# RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND
rilRequestOnSetUdub=13
[ril_0]
transport=binder:name=slot1;interface=android.hardware.radio.modem.IRadioModem
name=slot1
[ril_1]
transport=binder:name=slot2;interface=android.hardware.radio.modem.IRadioModem
#;interface=radio
name=slot2

View file

@ -0,0 +1,2 @@
### Load Pulseaudio Droid module built for API 30
load-module module-droid-card-30 output_deep_buffer=false hw_volume=false rate=48000

View file

@ -0,0 +1 @@
/dev/null

View file

@ -0,0 +1 @@
/usr/lib/systemd/user/umtprd-manager.service

View file

@ -0,0 +1 @@
/dev/null

View file

@ -0,0 +1,46 @@
#
# uMTP Responder config file
#
# UBports: Don't show hidden files
show_hidden_files 0
# UBports: Use phablet user as default for all storage file operations
default_uid 32011
default_gid 32011
# Add home folder as default "internal storage" entry
storage "/home/phablet" "Internal Storage" "rw,locked"
# Set the USB strings visible to host systems
manufacturer "BraX"
product "BraX3"
# FIXME: set to something proper!
serial "UT2004"
# Set the MTP firmware version
firmware_version "Rev A"
# Set the USB interface string. Should be always "MTP"
interface "MTP"
# Set the USB Vendor ID, Product ID and class
# FIXME: set to something proper!
usb_vendor_id 0x1D6B # Linux Foundation
usb_product_id 0x0100 # PTP Gadget
usb_class 0x6 # Image
usb_subclass 0x1 # Still Imaging device
usb_protocol 0x1 #
# Device version
usb_dev_version 0x3008
# Generic FunctionFS Mode
usb_functionfs_mode 0x1
usb_dev_path "/dev/usb-ffs/mtp/ep0"
usb_epin_path "/dev/usb-ffs/mtp/ep1"
usb_epout_path "/dev/usb-ffs/mtp/ep2"
usb_epint_path "/dev/usb-ffs/mtp/ep3"
usb_max_packet_size 0x200

View file

@ -0,0 +1,6 @@
[configfs]
function_mtp = ffs.mtp
gadget_udc_device = musb-hdrc
[udev]
extcon_tracking = 1

View file

@ -0,0 +1,9 @@
[mode]
name = mtp
module = none
appsync = 1 # Launches uMTP-Responder as needed
[options]
# sysfs_value = comma separated list of functions to enable in this mode
sysfs_value = mtp
idProduct = $IDPRODUCT_MTP

View file

@ -0,0 +1,13 @@
[mode]
name = mtp_adb
module = none
# Launches ADBD
# Launches uMTP-Responder as needed
appsync = 1
[options]
# sysfs_value = comma separated list of functions to enable in this mode
sysfs_value = mtp,adb
android_extra_sysfs_path = /sys/class/android_usb/android0/f_ffs/aliases
android_extra_sysfs_value = adb
idProduct = $IDPRODUCT_MTP_ADB

View file

@ -0,0 +1,5 @@
[info]
mode = mtp
systemd = 1
name = umtprd.service
systemd_wait = 1

View file

@ -0,0 +1,5 @@
[info]
mode = mtp_adb
systemd = 1
name = umtprd.service
systemd_wait = 1

BIN
overlay/system/usr/bin/umtprd Executable file

Binary file not shown.

View file

@ -0,0 +1,136 @@
#!/bin/bash
####
# Default profile
USB_IDVENDOR=0FCE
USB_IDPRODUCT=7169
USB_IPRODUCT="Unknown"
USB_ISERIAL="Unknown"
USB_IMANUFACTURER="GNU/Linux Device"
USB_IFACE=""
####
# Override profile
if [ -f /etc/default/hybris-device ]; then
source /etc/default/hybris-device
fi
ANDROID_USB=/sys/class/android_usb/android0
USB_FUNCTIONS=rndis
LOCAL_IP=10.15.19.82
GADGET_DIR=/sys/kernel/config/usb_gadget
write() {
echo -n "$2" > "$1"
}
# This sets up the USB with whatever USB_FUNCTIONS are set to via configfs
usb_setup_configfs() {
G_USB_ISERIAL=$GADGET_DIR/g1/strings/0x409/serialnumber
mkdir $GADGET_DIR/g1
write $GADGET_DIR/g1/idVendor "0x$USB_IDVENDOR"
write $GADGET_DIR/g1/idProduct "0x$USB_IDPRODUCT"
mkdir $GADGET_DIR/g1/strings/0x409
write $GADGET_DIR/g1/strings/0x409/serialnumber "$USB_ISERIAL"
write $GADGET_DIR/g1/strings/0x409/manufacturer "$USB_IMANUFACTURER"
write $GADGET_DIR/g1/strings/0x409/product "$USB_IPRODUCT"
if echo $USB_FUNCTIONS | grep -q "rndis"; then
mkdir $GADGET_DIR/g1/functions/rndis.usb0
mkdir $GADGET_DIR/g1/functions/rndis_bam.rndis
fi
echo $USB_FUNCTIONS | grep -q "mass_storage" && mkdir $GADGET_DIR/g1/functions/storage.0
mkdir $GADGET_DIR/g1/configs/c.1
mkdir $GADGET_DIR/g1/configs/c.1/strings/0x409
write $GADGET_DIR/g1/configs/c.1/strings/0x409/configuration "$USB_FUNCTIONS"
if echo $USB_FUNCTIONS | grep -q "rndis"; then
ln -s $GADGET_DIR/g1/functions/rndis.usb0 $GADGET_DIR/g1/configs/c.1
ln -s $GADGET_DIR/g1/functions/rndis_bam.rndis $GADGET_DIR/g1/configs/c.1
fi
echo $USB_FUNCTIONS | grep -q "mass_storage" && ln -s $GADGET_DIR/g1/functions/storage.0 $GADGET_DIR/g1/configs/c.1
# ls /sys/class/udc > $GADGET_DIR/g1/UDC
ls /sys/class/udc | grep -v dummy | head -1 > $GADGET_DIR/g1/UDC
}
# This sets up the USB with whatever USB_FUNCTIONS are set to via android_usb
usb_setup_android_usb() {
G_USB_ISERIAL=$ANDROID_USB/iSerial
write $ANDROID_USB/enable 0
write $ANDROID_USB/functions ""
write $ANDROID_USB/enable 1
usleep 500000 # 0.5 delay to attempt to remove rndis function
write $ANDROID_USB/enable 0
write $ANDROID_USB/idVendor $USB_IDVENDOR
write $ANDROID_USB/idProduct $USB_IDPRODUCT
write $ANDROID_USB/iManufacturer "$USB_IMANUFACTURER"
write $ANDROID_USB/iProduct "$USB_IPRODUCT"
write $ANDROID_USB/iSerial "$USB_ISERIAL"
write $ANDROID_USB/functions $USB_FUNCTIONS
write $ANDROID_USB/enable 1
}
# This determines which USB setup method is going to be used
usb_setup() {
mount -t configfs none /sys/kernel/config || true
if [ -d $ANDROID_USB ]; then
usb_setup_android_usb
elif [ -d $GADGET_DIR ]; then
usb_setup_configfs
fi
}
usb_info() {
sleep 1
write $G_USB_ISERIAL "$1"
echo "$1" >> /var/log/usb_info.log
}
ip_setup() {
local candidate
if [ -n "$USB_IFACE" ]; then
# If the specified interface fails, fallback to auto-detection.
ip link set dev "$USB_IFACE" up || USB_IFACE=""
fi
if [ -z "$USB_IFACE" ]; then
# Prioritise usb0 over rndis0. On some devices (e.g. Sony Xperia X),
# both would show up but only usb0 is usable. If, on some device, the
# opposite happens, then I don't know what to do.
for candidate in usb0 rndis0; do
if ip link set dev "$candidate" up; then
USB_IFACE="$candidate"
break
fi
done
fi
if [ -z "$USB_IFACE" ]; then
usb_info "could not setup USB tethering!"
return 1
fi
ip address add "${LOCAL_IP}/24" dev "$USB_IFACE"
usb_info "$USB_IMANUFACTURER on $USB_IFACE $LOCAL_IP"
}
dhcpd_start() {
mkdir -p /run/hybris-usb
touch /run/hybris-usb/dhcpd4.leases
/usr/sbin/dhcpd -4 -q \
-cf /etc/hybris-usb/dhcpd.conf \
-pf /run/hybris-usb/dhcpd4.pid \
-lf /run/hybris-usb/dhcpd4.leases \
"$USB_IFACE"
}
usb_setup
ip_setup && dhcpd_start
exit $?

View file

@ -0,0 +1,11 @@
[Unit]
Description=uMTP-Responder
[Service]
Type=notify
ExecStartPre=/usr/libexec/usb-moded/umtprd-functionfs.sh
ExecStart=/usr/bin/umtprd
ExecStopPost=/bin/umount mtp
Restart=on-failure
# No WantedBy; should be triggered by usb-moded.

View file

@ -0,0 +1,20 @@
[Unit]
Description=Manages uMTP-Responder storages at runtime
After=lomiri-full-greeter.service
After=lomiri-full-shell.service
After=lomiri-greeter.service
After=lomiri-shell.service
After=umtprd.service
Before=ubuntu-touch-session.target
PartOf=ubuntu-touch-session.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/libexec/umtprd-manager
[Install]
WantedBy=ubuntu-touch-session.target

View file

@ -0,0 +1,144 @@
ACTION=="add", KERNEL=="null", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="zero", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="full", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="ptmx", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="tty", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="random", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="urandom", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="ashmem*", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="binder", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="hwbinder", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="vndbinder", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="pmsg0", OWNER="root", GROUP="log", MODE="0222"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system-uncached", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system-secure", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", KERNEL=="dri/*", OWNER="root", GROUP="android_graphics", MODE="0666"
ACTION=="add", KERNEL=="uhid", OWNER="uhid", GROUP="uhid", MODE="0660"
ACTION=="add", KERNEL=="uinput", OWNER="root", GROUP="plugdev", MODE="0660"
ACTION=="add", KERNEL=="rtc0", OWNER="system", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="tty0", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="graphics/*", OWNER="root", GROUP="android_graphics", MODE="0660"
ACTION=="add", KERNEL=="input/*", OWNER="root", GROUP="input", MODE="0660"
ACTION=="add", KERNEL=="v4l-touch*", OWNER="root", GROUP="input", MODE="0660"
ACTION=="add", KERNEL=="snd/*", OWNER="system", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="bus/usb/*", OWNER="root", GROUP="usb", MODE="0660"
ACTION=="add", KERNEL=="mtp_usb", OWNER="root", GROUP="plugdev", MODE="0660"
ACTION=="add", KERNEL=="usb_accessory", OWNER="root", GROUP="usb", MODE="0660"
ACTION=="add", KERNEL=="tun", OWNER="system", GROUP="vpn", MODE="0660"
ACTION=="add", KERNEL=="ppp", OWNER="radio", GROUP="vpn", MODE="0660"
ACTION=="add", KERNEL=="kvm", OWNER="virtmanager", GROUP="root", MODE="0600"
ACTION=="add", KERNEL=="vhost-vsock", OWNER="virtmanager", GROUP="root", MODE="0600"
ACTION=="add", KERNEL=="block/mmcblk0", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/mmcblk0boot0", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/mmcblk0boot1", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="misc-sd", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/sda", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/sdb", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/sdc", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/misc2", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/boot", OWNER="root", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="block/by-name/recovery", OWNER="root", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="block/by-name/secro", OWNER="root", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="block/by-name/seccfg", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/proinfo", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/nvram", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/para", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/logo", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/frp", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/md1img", OWNER="root", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="block/by-name/md1img_a", OWNER="root", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="block/by-name/md1img_b", OWNER="root", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="block/by-name/md1dsp", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/boot_para", OWNER="root", GROUP="system", MODE="0640"
ACTION=="add", KERNEL=="otp", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/by-name/otp", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="stpwmt", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="wmtdetect", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="fw_log_wmt", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="conninfra_dev", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="conn_pwr_dev", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="stpbt", OWNER="bluetooth", GROUP="bluetooth", MODE="0660"
ACTION=="add", KERNEL=="fw_log_bt", OWNER="bluetooth", GROUP="bluetooth", MODE="0660"
ACTION=="add", KERNEL=="gpsdl0", OWNER="gps", GROUP="gps", MODE="0660"
ACTION=="add", KERNEL=="gpsdl1", OWNER="gps", GROUP="gps", MODE="0660"
ACTION=="add", KERNEL=="stpgps", OWNER="gps", GROUP="gps", MODE="0660"
ACTION=="add", KERNEL=="gps", OWNER="gps", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="gps_emi", OWNER="gps", GROUP="gps", MODE="0660"
ACTION=="add", KERNEL=="gps2scp", OWNER="gps", GROUP="gps", MODE="0660"
ACTION=="add", KERNEL=="gps_pwr", OWNER="gps", GROUP="gps", MODE="0660"
ACTION=="add", KERNEL=="fw_log_gps", OWNER="gps", GROUP="gps", MODE="0660"
ACTION=="add", KERNEL=="stpant", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="wmtWifi", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="fw_log_wifi", OWNER="wifi", GROUP="wifi", MODE="0660"
ACTION=="add", KERNEL=="fm", OWNER="media", GROUP="media", MODE="0660"
ACTION=="add", KERNEL=="spidev1.0", OWNER="system", GROUP="system", MODE="0666"
ACTION=="add", KERNEL=="st21nfc", OWNER="nfc", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="st54spi", OWNER="secure_element", GROUP="secure_element", MODE="0660"
ACTION=="add", KERNEL=="btif", OWNER="system", GROUP="system", MODE="0600"
ACTION=="add", KERNEL=="trusty-ipc-dev0", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="nebula-ipc-dev0", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="block/mmcblk0rpmb", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="mobicore", OWNER="system", GROUP="system", MODE="0600"
ACTION=="add", KERNEL=="mobicore-user", OWNER="system", GROUP="system", MODE="0666"
ACTION=="add", KERNEL=="t-base-tui", OWNER="system", GROUP="system", MODE="0666"
ACTION=="add", KERNEL=="teeperf", OWNER="system", GROUP="system", MODE="0666"
ACTION=="add", KERNEL=="video*", OWNER="camera", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="media*", OWNER="camera", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="v4l-subdev*", OWNER="camera", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="vcu", OWNER="camera", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="mtk_hcp", OWNER="camera", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="dri/card0", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="mddp", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="bus/usb/*", OWNER="root", GROUP="usb", MODE="0660"
ACTION=="add", KERNEL=="ttyUSB0", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="ttyUSB1", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="ttyUSB2", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="ttyUSB3", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="ttyUSB4", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="log/ksystem", OWNER="root", GROUP="log", MODE="0600"
ACTION=="add", KERNEL=="ccci*", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="ttyC*", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="eemcs*", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="emd*", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="ccci_pcm_rx", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="ccci_pcm_tx", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="ccci_aud", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="ccci2_aud", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="ccci3_aud", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="ccci_raw_audio", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="ccci3_raw_audio", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="eemcs_aud", OWNER="audio", GROUP="audio", MODE="0660"
ACTION=="add", KERNEL=="irtx", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="lirc*", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="ir-learning", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="pvrsrvkm", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="pvr_sync", OWNER="root", GROUP="root", MODE="0666"
ACTION=="add", KERNEL=="mtgpio", OWNER="radio", GROUP="root", MODE="0600"
ACTION=="add", KERNEL=="camera_eeprom*", OWNER="system", GROUP="camera", MODE="0660"
ACTION=="add", KERNEL=="ttySDIO*", OWNER="radio", GROUP="sdcard_rw", MODE="0660"
ACTION=="add", KERNEL=="ttyRB*", OWNER="radio", GROUP="radio", MODE="0660"
ACTION=="add", KERNEL=="mali0", OWNER="system", GROUP="android_graphics", MODE="0666"
ACTION=="add", KERNEL=="ion", OWNER="system", GROUP="android_graphics", MODE="0666"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_mm", OWNER="system", GROUP="android_graphics", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_mm-uncached", OWNER="system", GROUP="android_graphics", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_svp_page-uncached", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_prot_page-uncached", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_svp_region", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_svp_region-aligned", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_prot_region", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_prot_region-aligned", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_2d_fr_region", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_2d_fr_region-aligned", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_wfd_region", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_wfd_region-aligned", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_wfd_page-uncached", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_data_shm_region", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_data_shm_region-aligned", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_engine_shm_region", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_engine_shm_region-aligned", OWNER="system", GROUP="system", MODE="0444"
ACTION=="add", KERNEL=="touch", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="hotknot", OWNER="root", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="RT_Monitor", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="kick_powerkey", OWNER="system", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="ttyACM0", OWNER="radio", GROUP="radio", MODE="0660"

View file

@ -0,0 +1,2 @@
# ignore second Wi-Fi interface in NetworkManager
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan1", ENV{NM_UNMANAGED}="1"

View file

@ -0,0 +1,2 @@
# mmcblk0 is the SD card, not internal storage (unlike /usr/lib/udev/rules.d/99-android.rules specifies)
ACTION=="add|change", KERNEL=="mmcblk0*", ENV{UDISKS_SYSTEM}=""

View file

@ -0,0 +1,112 @@
#!/usr/bin/python3
# Copyright (C) 2022 UBports Foundation.
# SPDX-License-Identifier: GPL-3.0-or-later
# This Python script exists because there's no convienient way for usb-moded, a
# system service, to tell a user's systemd to start something. So, the control
# is inverted: this script sits in user systemd & listen for a signal that emits
# from usb-moded, and then start or stop the service as needed.
# This was further modified from /usr/libexec/mtp-server-usb-moded-watcher to
# unlock access to MTP storage devices if/when the device gets unlocked itself.
from gi.repository import GLib, Gio
from subprocess import run
is_greeter_active = True
already_unlocked_storage = False
mtp_enabled = False
old_usb_mode = "undefined"
def handle_unlock():
global already_unlocked_storage
print(f"handle_unlock(): mtp_enabled={mtp_enabled}, already_unlocked_storage={already_unlocked_storage}, is_greeter_active={is_greeter_active}")
if not mtp_enabled or already_unlocked_storage or is_greeter_active:
# We only care about unlocking locked storage when MTP is enabled and not on lockscreen.
return
run(["umtprd", "-cmd:unlock"])
already_unlocked_storage = True
def handle_current_mode(mode: str):
global mtp_enabled, old_usb_mode, already_unlocked_storage
if mode == "busy":
# This mode is transient, and a signal should be sent when the final
# mode is reached.
return
if mode != old_usb_mode:
# Act like MTP wasn't enabled as it won't be when switching between
# "mtp" and "mtp_adb" for example.
already_unlocked_storage = False
print(f"handle_current_mode(): {old_usb_mode} -> {mode}")
old_usb_mode = mode
mtp_enabled = mode in ("mtp", "mtp_adb") # FIXME: better way for this list?
handle_unlock()
def handle_dbus_properties_signal(
obj, sender_name: str, signal_name: str, parameters: GLib.Variant
):
global is_greeter_active
if signal_name != "PropertiesChanged":
return
is_greeter_active = bool(parameters.get_child_value(1).get_child_value(0).get_child_value(1))
handle_unlock()
def handle_usb_moded_signal(
obj, sender_name: str, signal_name: str, parameters: GLib.Variant
):
if signal_name != "sig_usb_current_state_ind":
return
mode = parameters.get_child_value(0).get_string()
handle_current_mode(mode)
dbus_properties = Gio.DBusProxy.new_for_bus_sync(
Gio.BusType.SESSION,
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES,
None, # DBusInterfaceInfo
"com.lomiri.LomiriGreeter",
"/com/lomiri/LomiriGreeter",
"org.freedesktop.DBus.Properties",
None, # Cancellable
)
is_greeter_active = bool(dbus_properties.call_sync(
"Get",
GLib.Variant("(ss)", ("com.lomiri.LomiriGreeter", "IsActive")), # interface_name, property_name
Gio.DBusCallFlags.NONE,
500, # TimeoutMsec
None, # Cancellable
).get_child_value(0))
# TODO: don't track locked state when cable unplugged?
dbus_properties.connect("g-signal", handle_dbus_properties_signal)
usb_moded = Gio.DBusProxy.new_for_bus_sync(
Gio.BusType.SYSTEM,
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES,
None, # DBusInterfaceInfo
"com.meego.usb_moded",
"/com/meego/usb_moded",
"com.meego.usb_moded",
None, # Cancellable
)
usb_moded.connect("g-signal", handle_usb_moded_signal)
current_mode = usb_moded.call_sync(
"mode_request",
None, # Parameters
Gio.DBusCallFlags.NONE,
500, # TimeoutMsec
None, # Cancellable
).get_child_value(0).get_string()
handle_current_mode(current_mode)
# TODO: keep track of removable disks via UDisks2 (HintSystem=false) with MountPoints[0]
# and IdLabel/IdUUID used for e.g.
# - umtprd '-cmd:addstorage:"/media/phablet/1234-5678" "1234-5678" rw'
# - umtprd '-cmd:rmstorage:"1234-5678"'
loop = GLib.MainLoop(None)
loop.run()

View file

@ -0,0 +1,18 @@
#!/bin/sh
set -e
USB_GADGET=/sys/kernel/config/usb_gadget
if [ -d "${USB_GADGET}/g1" ]; then
# The USB function must exists for functionfs to be available for mounting.
mkdir -p "${USB_GADGET}/g1/functions/ffs.mtp"
fi
mkdir -p /dev/usb-ffs
chmod 0770 /dev/usb-ffs
chown phablet:phablet /dev/usb-ffs
mkdir -p /dev/usb-ffs/mtp
chmod 0770 /dev/usb-ffs/mtp
chown phablet:phablet /dev/usb-ffs/mtp
/bin/mount -t functionfs mtp /dev/usb-ffs/mtp -o uid=phablet,gid=phablet
exit 0

Binary file not shown.

BIN
overlay/system/usr/sbin/usb_moded Executable file

Binary file not shown.

View file

@ -0,0 +1,2 @@
# Video decoding
/dev/dma_heap/mtk_mm r,

View file

@ -0,0 +1,141 @@
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)
# This script is specific to Ubuntu Touch
# Needed to avoid conflicting policies with desktop
.fail
### Automatically restore the volume of streams
load-module module-stream-restore restore_device=false restore_muted=false fallback_table=/etc/pulse/touch-stream-restore.table
### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties
### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available
### Switch when connected by default
load-module module-switch-on-connect
### Fake sink and source used by HSP
### (loaded before Droid to avoid automatically switching to these sink/source)
load-module module-null-sink sink_name=sink.fake.sco rate=8000 channels=1
load-module module-null-source source_name=source.fake.sco rate=8000 channels=1
### Allow PulseAudio Droid configuration part to be customized per-device
.ifexists /etc/pulse/droid_card_custom.pa
.include /etc/pulse/droid_card_custom.pa
.else
### Automatically load the Pulseaudio Droid
load-module module-droid-discover voice_virtual_stream=true hidl_args='helper=false'
.endif
### Automatically load the trust-store module
.ifexists module-trust-store.so
load-module module-trust-store
.endif
### Automatically load driver modules depending on the hardware available
#.ifexists module-udev-detect.so
#load-module module-udev-detect
#.endif
### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif
### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif
.ifexists module-bluez5-discover.so
load-module module-bluez5-discover profile=a2dp_sink sco_sink=sink.fake.sco sco_source=source.fake.sco
.endif
### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix
### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish
### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv
### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor
### Load additional modules from GConf settings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gconf.so
.nofail
load-module module-gconf
.fail
.endif
### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink
### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle
### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif
### Enable positioned event sounds
load-module module-position-event-sounds
### Cork music/video streams when a phone stream is active
load-module module-role-cork trigger_roles=phone,alarm cork_roles=alarm,multimedia global=true
### Ducking streams when certain roles are active
load-module module-role-ducking trigger_roles=alert ducking_roles=multimedia volume=-20dB
### Load DBus protocol
.ifexists module-dbus-protocol.so
load-module module-dbus-protocol
.endif
### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

View file

@ -0,0 +1,10 @@
# Model for libdeviceinfo
ro.product.vendor.device=prithvi
# Camera model for taken pictures
ro.product.model=BraX3
# MTP device name
ro.product.vendor.model=BraX3
# Manufacturer in host dmesg
ro.product.vendor.manufacturer=BraX
# Use Mali GLES directly instead of hacky/semi-broken MediaTek MEOW wrapper
ro.hardware.egl=mali

View file

@ -0,0 +1,39 @@
#!/bin/sh
# Allow ayatana-indicator-power to toggle torchlight
chmod g+w /sys/class/flashlight_core/flashlight/flashlight_torch
chgrp phablet /sys/class/flashlight_core/flashlight/flashlight_torch
# Wait for the property system to be up.
while [ ! -e /dev/socket/property_service ]; do sleep 0.1; done
# Wait for nvram to be loaded.
while [ "$(getprop vendor.service.nvram_init)" != "Ready" ]; do sleep 0.2; done
while [ "$(getprop vendor.mtk.nvram.ready)" != "1" ]; do sleep 0.2; done
# set wifi.interface property since urfkill.conf expects that
setprop wifi.interface wlan0
# Wait for /dev/wmtWifi to exist..
while [ ! -c /dev/wmtWifi ]; do sleep 0.2; done
# Silence all wlan debug logging down to just errors/warnings
printf '0xFF:0x03' > /proc/net/wlan/dbgLevel
# Finally enable the adapter in P2P mode
echo P > /dev/wmtWifi
# enables wireless display support
setprop debug.stagefright.c2inputsurface 1
setprop ubuntu.widi.supported 1
# Enable WoWLAN to avoid network disconnect before suspend
while [ ! -e /sys/class/ieee80211/phy0 ]; do sleep 1; done
iw phy phy0 wowlan enable magic-packet
# Disable graphics.allocator service in Waydroid as it should use the host one
if [ ! -e /var/lib/waydroid/overlay/vendor/etc/init/android.hardware.graphics.allocator@2.0-service.rc ]; then
mkdir -p /var/lib/waydroid/overlay/vendor/etc/init
ln -sf /dev/null /var/lib/waydroid/overlay/vendor/etc/init/android.hardware.graphics.allocator@2.0-service.rc
fi

View file

@ -0,0 +1,296 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<audioPolicyConfiguration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- version section contains a “version” tag in the form “major.minor” e.g version=”1.0” -->
<!-- Global configuration Decalaration -->
<globalConfiguration speaker_drc_enabled="false" call_screen_mode_supported="true"/>
<!-- Modules section:
There is one section per audio HW module present on the platform.
Each module section will contains two mandatory tags for audio HAL “halVersion” and “name”.
The module names are the same as in current .conf file:
“primary”, “A2DP”, “remote_submix”, “USB”
Each module will contain the following sections:
“devicePorts”: a list of device descriptors for all input and output devices accessible via this
module.
This contains both permanently attached devices and removable devices.
“mixPorts”: listing all output and input streams exposed by the audio HAL
“routes”: list of possible connections between input and output devices or between stream and
devices.
"route": is defined by an attribute:
-"type": <mux|mix> means all sources are mutual exclusive (mux) or can be mixed (mix)
-"sink": the sink involved in this route
-"sources": all the sources than can be connected to the sink via vis route
“attachedDevices”: permanently attached devices.
The attachedDevices section is a list of devices names. The names correspond to device names
defined in <devicePorts> section.
“defaultOutputDevice”: device to be used by default when no policy rule applies
-->
<modules>
<!-- Primary Audio HAL -->
<module name="primary" halVersion="3.0">
<attachedDevices>
<item>Speaker</item>
<item>Earpiece</item>
<item>Built-In Mic</item>
<item>Built-In Back Mic</item>
<item>FM Tuner In</item>
<item>Voice Call In</item>
<item>Echo Ref In</item>
<item>Telephony Tx</item>
</attachedDevices>
<defaultOutputDevice>Speaker</defaultOutputDevice>
<mixPorts>
<mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="deep_buffer" role="source" flags="AUDIO_OUTPUT_FLAG_DEEP_BUFFER">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="voip_rx" role="source" flags="AUDIO_OUTPUT_FLAG_VOIP_RX">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="16000,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="16000,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="incall_music_uplink" role="source" flags="AUDIO_OUTPUT_FLAG_INCALL_MUSIC">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="primary input" role="sink" maxOpenCount="1" maxActiveCount="1">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</mixPort>
<mixPort name="voice tx" role="sink" maxOpenCount="1" maxActiveCount="1">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO"/>
</mixPort>
<mixPort name="FM Tuner input" role="sink" maxOpenCount="1" maxActiveCount="1">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</mixPort>
<mixPort name="voip_tx" role="sink" flags="AUDIO_INPUT_FLAG_VOIP_TX" maxOpenCount="1" maxActiveCount="1">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</mixPort>
<mixPort name="fast input" role="sink" flags="AUDIO_INPUT_FLAG_FAST" maxOpenCount="1" maxActiveCount="1">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</mixPort>
<mixPort name="hifi_playback" role="source"/>
<mixPort name="hifi_input" role="sink"/>
</mixPorts>
<devicePorts>
<!-- Output devices declaration, i.e. Sink DEVICE PORT -->
<devicePort tagName="Earpiece" type="AUDIO_DEVICE_OUT_EARPIECE" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
</devicePort>
<devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Wired Headset" type="AUDIO_DEVICE_OUT_WIRED_HEADSET" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Wired Headphones" type="AUDIO_DEVICE_OUT_WIRED_HEADPHONE" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="BT SCO" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="BT SCO Car Kit" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Analog Dock Headset" type="AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Digital Dock Headset" type="AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="FM Tuner Out" type="AUDIO_DEVICE_OUT_FM" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="USB Primary Out" type="AUDIO_DEVICE_OUT_BUS" role="sink" address="usb_phone_call">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Telephony Tx" type="AUDIO_DEVICE_OUT_TELEPHONY_TX" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
</devicePort>
<devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="Built-In Back Mic" type="AUDIO_DEVICE_IN_BACK_MIC" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="Wired Headset Mic" type="AUDIO_DEVICE_IN_WIRED_HEADSET" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
</devicePort>
<devicePort tagName="AUX Digital In" type="AUDIO_DEVICE_IN_AUX_DIGITAL" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="FM Tuner In" type="AUDIO_DEVICE_IN_FM_TUNER" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="Echo Ref In" type="AUDIO_DEVICE_IN_ECHO_REFERENCE" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="USB Primary In" type="AUDIO_DEVICE_IN_BUS" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="Voice Call In" type="AUDIO_DEVICE_IN_VOICE_CALL" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO"/>
<gains>
<gain name="gain_1" mode="AUDIO_GAIN_MODE_JOINT"
minValueMB="-8400"
maxValueMB="4000"
defaultValueMB="0"
stepValueMB="100"/>
</gains>
</devicePort>
</devicePorts>
<!-- route declaration, i.e. list all available sources for a given sink -->
<routes>
<route type="mix" sink="Earpiece"
sources="primary output,deep_buffer,voip_rx,Voice Call In"/>
<route type="mix" sink="Speaker"
sources="primary output,deep_buffer,FM Tuner In,voip_rx,Voice Call In"/>
<route type="mix" sink="Wired Headset"
sources="primary output,deep_buffer,FM Tuner In,voip_rx,Voice Call In"/>
<route type="mix" sink="Wired Headphones"
sources="primary output,deep_buffer,FM Tuner In,voip_rx,Voice Call In"/>
<route type="mix" sink="BT SCO"
sources="primary output,deep_buffer,voip_rx,Voice Call In"/>
<route type="mix" sink="BT SCO Headset"
sources="primary output,deep_buffer,voip_rx,Voice Call In"/>
<route type="mix" sink="BT SCO Car Kit"
sources="primary output,deep_buffer,voip_rx,Voice Call In"/>
<route type="mix" sink="Analog Dock Headset"
sources="primary output"/>
<route type="mix" sink="Digital Dock Headset"
sources="primary output"/>
<route type="mix" sink="FM Tuner Out"
sources="primary output"/>
<route type="mix" sink="USB Primary Out"
sources="primary output,Voice Call In"/>
<route type="mix" sink="Telephony Tx"
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,USB Primary In,incall_music_uplink"/>
<route type="mix" sink="primary input"
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,AUX Digital In,USB Primary In"/>
<route type="mix" sink="voice tx"
sources="Voice Call In"/>
<route type="mix" sink="FM Tuner input"
sources="FM Tuner In,Echo Ref In"/>
<route type="mix" sink="hifi_input"
sources="USB Primary In"/>
<route type="mix" sink="voip_tx"
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,AUX Digital In,USB Primary In"/>
<route type="mix" sink="fast input"
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,AUX Digital In,USB Primary In"/>
</routes>
</module>
<!-- BT Audio HAL -->
<xi:include href="bluetooth_audio_policy_configuration.xml"/>
<!-- A2dp Input Audio HAL -->
<xi:include href="a2dp_in_audio_policy_configuration.xml"/>
<!-- Usb Audio HAL -->
<xi:include href="usb_audio_accessory_only_policy_configuration.xml"/>
<!-- Remote Submix Audio HAL -->
<xi:include href="r_submix_audio_policy_configuration.xml"/>
</modules>
<!-- End of Modules section -->
<!-- Volume section -->
<xi:include href="audio_policy_volumes.xml"/>
<xi:include href="default_volume_tables.xml"/>
<!-- End of Volume section -->
</audioPolicyConfiguration>

View file

@ -0,0 +1,10 @@
service vndservicemanager /vendor/bin/vndservicemanager /dev/vndbinder
setenv LD_PRELOAD libselinux_stubs.so
class core
user system
group system readproc
writepid /dev/cpuset/system-background/tasks
onrestart class_restart main
onrestart class_restart hal
onrestart class_restart early_hal
shutdown critical

View file

@ -0,0 +1 @@
/dev/null

View file

@ -0,0 +1 @@
/dev/null

View file

@ -0,0 +1,381 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright (c) 2009, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<!-- These resources are around just to allow their values to be customized
for different hardware and product builds. Do not translate. -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Controls the navigation bar interaction mode:
0: 3 button mode (back, home, overview buttons)
1: 2 button mode (back, home buttons + swipe up for overview)
2: gestures only for back, home and overview -->
<integer name="config_navBarInteractionMode">0</integer>
<!-- If true, the screen can be rotated via the accelerometer in all 4
rotations as the default behavior. -->
<bool name="config_allowAllRotations">true</bool>
<!-- Flag indicating whether the we should enable the automatic brightness in Settings.
Software implementation will be used if config_hardware_auto_brightness_available is not set -->
<bool name="config_automatic_brightness_available">true</bool>
<!-- Flag specifying whether VoLTE should be available for carrier: independent of
carrier provisioning. If false: hard disabled. If true: then depends on carrier
provisioning, availability etc -->
<bool name="config_carrier_volte_available">true</bool>
<bool name="config_carrier_volte_tty_supported">true</bool>
<!-- Flag specifying whether WFC over IMS should be available for carrier: independent of
carrier provisioning. If false: hard disabled. If true: then depends on carrier
provisioning, availability etc -->
<bool name="config_carrier_wfc_ims_available">true</bool>
<!-- Set to true to add links to Cell Broadcast app from Settings and MMS app. -->
<bool name="config_cellBroadcastAppLinks">true</bool>
<!-- Flag specifying whether VoLTE is available on device -->
<bool name="config_device_volte_available">true</bool>
<!-- Flag specifying whether VT is available on device -->
<bool name="config_device_vt_available">true</bool>
<!-- Flag specifying whether WFC over IMS is available on device -->
<bool name="config_device_wfc_ims_available">true</bool>
<!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
<bool name="config_intrusiveNotificationLed">true</bool>
<!-- Default files to pin via Pinner Service -->
<string-array name="config_defaultPinnerServiceFiles">
<item>/system/framework/framework.jar</item>
<item>/system/framework/services.jar</item>
<item>/apex/com.android.media/javalib/updatable-media.jar</item>
<item>/apex/com.android.art/javalib/core-oj.jar</item>
<item>/apex/com.android.art/javalib/core-libart.jar</item>
<item>/system_ext/priv-app/SystemUI/SystemUI.apk</item>
<item>/system/bin/surfaceflinger</item>
<item>/system/lib64/libRS.so</item>
<item>/system/lib64/libRSCpuRef.so</item>
<item>/system/lib64/libRSDriver.so</item>
<item>/system/lib64/libRS_internal.so</item>
<item>/system/lib64/libRScpp.so</item>
<item>/system/lib64/libbcinfo.so</item>
<item>/system/lib64/libblas.so</item>
</string-array>
<!-- Enable Zram writeback feature to allow unused pages in zram be written to flash. -->
<bool name="config_zramWriteback">true</bool>
<!-- These are system packages exempted from privacy indicator -->
<string-array name="config_locationExtraPackageNames" translatable="false">
<!-- ImsService -->
<item>com.mediatek.ims</item>
</string-array>
<!-- Should the pinner service pin the Camera application? -->
<bool name="config_pinnerCameraApp">true</bool>
<!-- Should the pinner service pin the Home application? -->
<bool name="config_pinnerHomeApp">true</bool>
<!-- Power Management: Specifies whether to decouple the auto-suspend state of the
device from the display on/off state.
When false, autosuspend_disable() will be called before the display is turned on
and autosuspend_enable() will be called after the display is turned off.
This mode provides best compatibility for devices using legacy power management
features such as early suspend / late resume.
When true, autosuspend_display() and autosuspend_enable() will be called
independently of whether the display is being turned on or off. This mode
enables the power manager to suspend the application processor while the
display is on.
This resource should be set to "true" when a doze component has been specified
to maximize power savings but not all devices support it.
Refer to autosuspend.h for details.
-->
<bool name="config_powerDecoupleAutoSuspendModeFromDisplay">false</bool>
<!-- Power Management: Specifies whether to decouple the interactive state of the
device from the display on/off state.
When false, setInteractive(..., true) will be called before the display is turned on
and setInteractive(..., false) will be called after the display is turned off.
This mode provides best compatibility for devices that expect the interactive
state to be tied to the display state.
When true, setInteractive(...) will be called independently of whether the display
is being turned on or off. This mode enables the power manager to reduce
clocks and disable the touch controller while the display is on.
This resource should be set to "true" when a doze component has been specified
to maximize power savings but not all devices support it.
Refer to power.h for details.
-->
<bool name="config_powerDecoupleInteractiveModeFromDisplay">false</bool>
<!-- Boolean indicating whether the HWC setColorTransform function can be performed efficiently in hardware. -->
<bool name="config_setColorTransformAccelerated">true</bool>
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
<bool name="config_showNavigationBar">true</bool>
<!-- Indicate whether to allow the device to suspend when the screen is off
due to the proximity sensor. This resource should only be set to true
if the sensor HAL correctly handles the proximity sensor as a wake-up source.
Otherwise, the device may fail to wake out of suspend reliably.
The default is false. -->
<bool name="config_suspendWhenScreenOffDueToProximity">false</bool>
<!-- Is the device capable of hot swapping an UICC Card -->
<bool name="config_hotswapCapable">true</bool>
<!-- Configure mobile tcp buffer sizes in the form:
rat-name:rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max
If no value is found for the rat-name in use, the system default will be applied.
-->
<string-array name="config_mobile_tcp_buffers">
<item>gprs:4092,8760,48000,4096,8760,48000</item>
<item>edge:4093,26280,70800,4096,16384,70800</item>
<item>umts:58254,1398100,4194304,58254,1398100,4194304</item>
<item>1xrtt:16384,32768,131072,4096,16384,102400</item>
<item>evdo:4094,87380,262144,4096,16384,262144</item>
<item>ehrpd:131072,262144,1048576,4096,16384,524288</item>
<item>hsdpa:58254,1398100,4194304,58254,1398100,4194304</item>
<item>hspa:58254,1398100,4194304,58254,1398100,4194304</item>
<item>lte:2097152,4194304,8388608,262144,524288,1048576</item>
<item>hspap:58254,1398100,4194304,58254,1398100,4194304</item>
</string-array>
<!-- Amount of time it takes for the light sensor to warm up in milliseconds.
For this time after the screen turns on, the Power Manager
will not debounce light sensor readings -->
<integer name="config_lightSensorWarmupTime">200</integer>
<!-- Config determines whether to update phone object when voice registration
state changes. Voice radio tech change will always trigger an update of
phone object irrespective of this config -->
<bool name="config_switch_phone_on_voice_reg_state_change">false</bool>
<!-- If this is true, the screen will come on when you unplug usb/power/whatever. -->
<bool name="config_unplugTurnsOnScreen">true</bool>
<!-- Indicate whether closing the lid causes the device to go to sleep and opening
it causes the device to wake up.
The default is false. -->
<bool name="config_lidControlsSleep">true</bool>
<!-- When true use the linux /dev/input/event subsystem to detect the switch changes
on the headphone/microphone jack. When false use the older uevent framework. -->
<bool name="config_useDevInputEventForAudioJack">true</bool>
<!-- The maximum range of gamma adjustment possible using the screen
auto-brightness adjustment setting. -->
<fraction name="config_autoBrightnessAdjustmentMaxGamma">300.0%</fraction>
<!-- User activity timeout: Maximum screen dim duration as a percentage of screen off timeout.
This resource is similar to config_maximumScreenDimDuration but the maximum
screen dim duration is defined as a ratio of the overall screen off timeout
instead of as an absolute value in milliseconds. This is useful for reducing
the dim duration when the screen off timeout is very short.
When computing the screen dim duration, the power manager uses the lesser
of the effective durations expressed by config_maximumScreenDimDuration and
config_maximumScreenDimRatio.
This value must be between 0% and 100%. If the value is zero, the screen will not
dim before the device goes to sleep.
-->
<fraction name="config_maximumScreenDimRatio">20.000004%</fraction>
<!-- Stability requirements in milliseconds for accepting a new brightness level. This is used
for debouncing the light sensor. Different constants are used to debounce the light sensor
when adapting to brighter or darker environments. This parameter controls how quickly
brightness changes occur in response to an observed change in light level that exceeds the
hysteresis threshold. -->
<integer name="config_autoBrightnessBrighteningLightDebounce">4000</integer>
<integer name="config_autoBrightnessDarkeningLightDebounce">8000</integer>
<!-- Light sensor event rate in milliseconds for automatic brightness control. -->
<integer name="config_autoBrightnessLightSensorRate">250</integer>
<!-- Operating volatage for bluetooth controller. 0 by default-->
<integer name="config_bluetooth_operating_voltage_mv">0</integer>
<!-- Fast brightness animation ramp rate in brightness units per second-->
<integer name="config_brightness_ramp_rate_fast">180</integer>
<!-- Slow brightness animation ramp rate in brightness units per second-->
<integer name="config_brightness_ramp_rate_slow">60</integer>
<!-- Maximum color temperature, in Kelvin, supported by display white balance. -->
<integer name="config_displayWhiteBalanceColorTemperatureMax">8000</integer>
<!-- Minimum color temperature, in Kelvin, supported by display white balance. -->
<integer name="config_displayWhiteBalanceColorTemperatureMin">4000</integer>
<!-- Number of physical SIM slots on the device. This includes both eSIM and pSIM slots, and
is not necessarily the same as the number of phones/logical modems supported by the device.
For example, a multi-sim device can have 2 phones/logical modems, but 3 physical slots,
or a single SIM device can have 1 phones/logical modems, but 2 physical slots (one eSIM
and one pSIM) -->
<integer name="config_num_physical_slots">2</integer>
<!-- Whether WiFi display is supported by this device.
There are many prerequisites for this feature to work correctly.
Here are a few of them:
* The WiFi radio must support WiFi P2P.
* The WiFi radio must support concurrent connections to the WiFi display and
to an access point.
* The Audio Flinger audio_policy.conf file must specify a rule for the "r_submix"
remote submix module. This module is used to record and stream system
audio output to the WiFi display encoder in the media server.
* The remote submix module "audio.r_submix.default" must be installed on the device.
* The device must be provisioned with HDCP keys (for protected content).
-->
<bool name="config_enableWifiDisplay">true</bool>
<!-- Screen brightness used to dim the screen when the user activity
timeout expires. May be less than the minimum allowed brightness setting
that can be set by the user. -->
<integer name="config_screenBrightnessDim">10</integer>
<!-- Screen brightness used to dim the screen while dozing in a very low power state.
May be less than the minimum allowed brightness setting
that can be set by the user. -->
<integer name="config_screenBrightnessDoze">5</integer>
<!-- Default screen brightness setting.
Must be in the range specified by minimum and maximum. -->
<item name="config_screenBrightnessSettingDefaultFloat" format="float" type="dimen">0.51</item>
<!-- Maximum screen brightness allowed by the power manager.
-2 is invalid so setting will resort to int value specified above.
Set this to 1.0 for maximum brightness range.
The user is forbidden from setting the brightness above this level. -->
<item name="config_screenBrightnessSettingMaximumFloat" format="float" type="dimen">1.0</item>
<!-- Minimum screen brightness setting allowed by the power manager.
The user is forbidden from setting the brightness below this level. -->
<item name="config_screenBrightnessSettingMinimumFloat" format="float" type="dimen">0.03</item>
<integer-array name="config_autoBrightnessLcdBacklightValues">
<item>8</item>
<item>64</item>
<item>98</item>
<item>104</item>
<item>110</item>
<item>116</item>
<item>122</item>
<item>128</item>
<item>134</item>
<item>182</item>
<item>255</item>
<item>255</item>
<item>255</item>
<item>255</item>
<item>255</item>
<item>255</item>
<item>255</item>
<item>255</item>
</integer-array>
<integer-array name="config_autoBrightnessLevels">
<item>128</item>
<item>256</item>
<item>384</item>
<item>512</item>
<item>640</item>
<item>768</item>
<item>896</item>
<item>1024</item>
<item>2048</item>
<item>4096</item>
<item>6144</item>
<item>8192</item>
<item>10240</item>
<item>12288</item>
<item>14336</item>
<item>16384</item>
<item>18432</item>
</integer-array>
<!-- Vibrator pattern for feedback about a long screen/key press -->
<integer-array name="config_longPressVibePattern">
<item>0</item>
<item>30</item>
</integer-array>
<!-- Vibrator pattern for feedback about touching a virtual key -->
<integer-array name="config_virtualKeyVibePattern">
<item>0</item>
<item>20</item>
</integer-array>
<!-- An Array of "[Connection name],[ConnectivityManager.TYPE_xxxx],
[associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet] -->
<!-- the 5th element "resore-time" indicates the number of milliseconds to delay
before automatically restore the default connection. Set -1 if the connection
does not require auto-restore. -->
<!-- the 6th element indicates boot-time dependency-met value. -->
<string-array name="networkAttributes">
<item>wifi,1,1,1,-1,true</item>
<item>mobile,0,0,0,-1,true</item>
<item>mobile_mms,2,0,2,300000,true</item>
<item>mobile_supl,3,0,2,60000,true</item>
<item>mobile_dun,4,0,2,60000,true</item>
<item>mobile_hipri,5,0,3,60000,true</item>
<item>mobile_fota,10,0,2,60000,true</item>
<item>mobile_ims,11,0,-1,-1,true</item>
<item>mobile_cbs,12,0,2,60000,true</item>
<item>bluetooth,7,7,2,-1,true</item>
<item>ethernet,9,9,4,-1,true</item>
<item>wifi_p2p,13,1,0,-1,true</item>
<item>mobile_ia,14,0,2,-1,true</item>
<item>mobile_emergency,15,0,2,-1,true</item>
<item>mobile_dm,20,0,3,60000,true</item>
<item>mobile_wap,21,0,3,60000,true</item>
<item>mobile_net,22,0,3,60000,true</item>
<item>mobile_cmmail,23,0,3,60000,true</item>
<item>mobile_rcse,24,0,3,60000,true</item>
<item>mobile_xcap,25,0,3,60000,true</item>
<item>mobile_rcs,26,0,3,60000,true</item>
<item>mobile_bip,27,0,3,60000,true</item>
<item>mobile_vsim,28,0,-1,60000,true</item>
<item>mobile_preempt,29,0,9,60000,true</item>
<item>wifi_slave,40,1,0,-1,true</item>
</string-array>
<!-- This string array should be overridden by the device to present a list of radio
attributes. This is used by the connectivity manager to decide which networks can coexist
based on the hardware -->
<!-- An Array of "[ConnectivityManager connectionType],
[# simultaneous connection types]" -->
<string-array name="radioAttributes">
<item>1,1</item>
<item>0,1</item>
<item>7,1</item>
<item>9,1</item>
</string-array>
<!-- Vertical position of a center of the letterboxed app window.
0 corresponds to the upper side of the screen and 1 to the lower side. If given value < 0
or > 1 it is ignored and for non-tabletop mode central position is used (0.5); for
tabletop mode top (0.0) is used. -->
<item name="config_letterboxVerticalPositionMultiplier" format="float" type="dimen">0.5</item>
</resources>

View file

@ -0,0 +1,769 @@
# Local filesystem mounting -*- shell-script -*-
_log_msg() {
if [ "$quiet" = "y" ]; then return; fi
printf "$@" > /dev/kmsg || true
}
pre_mountroot() {
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && log_end_msg
}
tell_kmsg() {
# Echos a string into /dev/kmsg, ignoring errors.
echo "initrd: $1" >/dev/kmsg || true
}
halium_panic() {
# Puts panic reason into kmsg and then starts the panic handlers
REASON="$1"
tell_kmsg "PANIC for reason: $REASON"
panic $REASON
}
identify_boot_mode() {
# Our current list of supported boot modes:
## BOOT_MODE = halium and android
BOOT_MODE='halium'
# The boot reason is exported via /proc/cmdline
# The standard method is using androidboot.mode parameter.
for x in $(cat /proc/cmdline); do
case ${x} in
androidboot.mode=*)
android_bootmode=${x#*=}
;;
# Android 9 system-as-root
skip_initramfs)
normal_boot="y"
;;
# Android 10+ recovery-as-boot
androidboot.force_normal_boot=1)
normal_boot="y"
;;
# Android 12+ (GKI 2.0+) recovery-as-boot
bootconfig)
if grep -q 'androidboot.force_normal_boot = "1"' /proc/bootconfig; then
normal_boot="y"
fi
;;
esac
done
if echo "$android_bootmode" | grep charger; then
BOOT_MODE="android"
fi
## Some devices may be using 'bootreason', others 'boot_reason'
## XXX: Find a better way to handle device specifics here
# Krillin
if [ -f /sys/class/BOOT/BOOT/boot/boot_mode ]; then
boot_reason=$(cat /sys/class/BOOT/BOOT/boot/boot_mode)
case "${boot_reason}" in
1) BOOT_MODE="android" ;; # Meta
4) BOOT_MODE="android" ;; # Factory
8) BOOT_MODE="android" ;; # Power off charging
9) BOOT_MODE="android" ;; # Low power charging
esac
fi
# System-as-root or a device without dedicated recovery partition
if [ -f /ramdisk-recovery.img ] && [ -z "$normal_boot" ]; then
BOOT_MODE="recovery"
fi
# On Android 8+ devices the 'android' boot mode is broken and should be avoided.
# This behavior can be overridden with the cmdline flag 'halium_no_avoid_android_mode'
# List of API levels and referred Android versions: https://source.android.com/setup/start/build-numbers
if ! grep -wq halium_no_avoid_android_mode /proc/cmdline; then
api_level=$(sed -n 's/^ro.build.version.sdk=//p' /android-system/build.prop) # e.g. 26 for Android 8.0
[ -z "$api_level" ] && api_level=0
tell_kmsg "Android system image API level is $api_level"
if [ "$BOOT_MODE" = "android" ] && [ $api_level -ge 26 ]; then
tell_kmsg "Android 8+ device detected! Charging is to be handled by rootfs, continue boot normally"
BOOT_MODE='halium'
fi
fi
tell_kmsg "boot mode: $BOOT_MODE"
}
identify_android_image() {
# Checks for the provided Android image. If it's called system.img, it
# should be mounted at Android's /system. If it's called android-rootfs.img,
# it should be mounted at Android's /.
# Sets $ANDROID_IMAGE_MODE to:
# * "rootfs" if the image should be mounted at '/android/'
# * "system" if the image should be mounted at '/android/system/'
# * "unknown" if neither is found
[ -f /tmpmnt/system.img ] && ANDROID_IMAGE_MODE="system"
[ -f /tmpmnt/android-rootfs.img ] && ANDROID_IMAGE_MODE="rootfs"
[ -f /halium-system/var/lib/lxc/android/system.img ] && ANDROID_IMAGE_MODE="system"
[ -f /halium-system/var/lib/lxc/android/android-rootfs.img ] && ANDROID_IMAGE_MODE="rootfs"
[ -z $ANDROID_IMAGE_MODE ] && ANDROID_IMAGE_MODE="unknown"
}
set_halium_version_properties() {
halium_system=$1
android_data=$2
channel_ini=$1/etc/system-image/channel.ini
def_language=$1/custom/default_language
halium="unknown"
device="unknown"
custom="unknown"
version="unknown"
channel="unknown"
def_lang="unknown"
if [ -f "$channel_ini" ]; then
IFS=','
for i in $(grep version_detail $channel_ini | awk -F ' ' '{print $2}'); do
id=${i%=*}
case $id in
halium) halium=${i#halium=} ;;
device) device=${i#device=} ;;
custom) custom=${i#custom=} ;;
version) version=${i#version=} ;;
esac
done
unset IFS
channel=$(grep channel $channel_ini | awk -F ' ' '{print $2}')
fi
if [ -f "$def_language" ]; then
lang=$(cat $def_language)
if [ -n "$lang" ]; then
def_lang=$lang
fi
fi
# Write down so the android property system can load them automatically
mkdir -p $android_data/property
chmod 700 $android_data/property
echo -n "$halium" >$android_data/property/persist.halium.version.rootfs
echo -n "$device" >$android_data/property/persist.halium.version.device
echo -n "$custom" >$android_data/property/persist.halium.version.custom
echo -n "$channel" >$android_data/property/persist.halium.version.channel
echo -n "$version" >$android_data/property/persist.halium.version
echo -n "$def_lang" >$android_data/property/persist.halium.default_language
chmod 600 $android_data/property/persist.halium*
}
mount_android_partitions() {
fstab=$1
mount_root=$2
real_userdata=$3
tell_kmsg "checking fstab $fstab for additional mount points"
# On systems with A/B partition layout, current slot is provided via cmdline parameter.
ab_slot_suffix=$(grep -o 'androidboot\.slot_suffix=..' /proc/cmdline | tail -1 | cut -d "=" -f2)
[ ! -z "$ab_slot_suffix" ] && tell_kmsg "A/B slot system detected! Slot suffix is $ab_slot_suffix"
cat ${fstab} | while read line; do
set -- $line
# stop processing if we hit the "#endhalium" comment in the file
echo $1 | egrep -q "^#endhalium" && break
# Skip any unwanted entry
echo $1 | egrep -q "^#" && continue
([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]) && continue
([ "$2" = "/system" ] || [ "$2" = "/data" ] || [ "$2" = "/" ]) && continue
label=$(echo $1 | awk -F/ '{print $NF}')
[ -z "$label" ] && continue
tell_kmsg "checking mount label $label"
# In case fstab provides /dev/mmcblk0p* lines
path="/dev/$label"
for dir in by-partlabel by-name by-label by-path by-uuid by-partuuid by-id; do
# On A/B systems not all of the partitions are duplicated, so we have to check with and without suffix
if [ -e "/dev/disk/$dir/$label$ab_slot_suffix" ]; then
path="/dev/disk/$dir/$label$ab_slot_suffix"
break
elif [ -e "/dev/disk/$dir/$label" ]; then
path="/dev/disk/$dir/$label"
break
fi
done
[ ! -e "$path" ] && continue
mkdir -p ${mount_root}/$2
tell_kmsg "mounting $path as ${mount_root}/$2"
mount $path ${mount_root}/$2 -t $3 -o $4
done
# Provide a bind mount from /cache to /userdata/cache on systems without a dedicated cache partition
if [ ! -e ${mount_root}/cache ] || ! grep -q "${mount_root}/cache" /proc/mounts; then
if [ ! -d ${real_userdata}/cache ]; then
mkdir ${real_userdata}/cache
fi
mkdir ${mount_root}/cache
mount -o bind ${real_userdata}/cache ${mount_root}/cache
fi
# Create an appropriate symlink for vendor files
if [ ! -e ${mount_root}/vendor ]; then
ln -sf system/vendor ${mount_root}/vendor
fi
}
mount_halium_overlay() {
source=$1
target=$2
if [ -d ${source} ]; then
OLD_PWD=$PWD
cd ${source}
for overlay in $(find . -type f); do
[ -f ${target}/${overlay} ] && mount --bind ${source}/${overlay} ${target}/${overlay}
done
cd $OLD_PWD
fi
}
sync_dirs() {
base=$1
source=$2
target=$3
OLD_PWD=$PWD
cd $base
for file in $source/*; do
# Skip empty directories
[ ! -e "$base/$file" -a ! -L "$base/$file" ] && continue
# If the target already exists as a file or link, there's nothing we can do
[ -e "$target/$file" -o -L "$target/$file" ] && [ ! -d "$target/$file" ] && continue
# If the target doesn't exist, just copy it over
if [ ! -e "$target/$file" -a ! -L "$target/$file" ]; then
cp -Ra "$base/$file" "$target/$file"
continue
fi
# That leaves us with directories and a recursive call
[ -d $file ] && sync_dirs $base $file $target
done
cd $OLD_PWD
}
resize_userdata_if_needed() {
# See if the filesystem on the userdata partition needs resizing (usually on first boot).
# If the difference between the partition size and the filesystem size is above a small
# threshold, assume it needs resizing to fill the partition.
path=$1
# Partition size in 1k blocks
case $path in
/dev/mmcblk*)
pblocks=$(grep ${path#/dev/*} /proc/partitions | awk {'print $3'})
;;
/dev/disk*)
pblocks=$(grep $(basename $(readlink $path)) /proc/partitions | awk {'print $3'})
;;
esac
# Filesystem size in 4k blocks
fsblocks=$(dumpe2fs -h $path | grep "Block count" | awk {'print $3'})
# Difference between the reported sizes in 1k blocks
dblocks=$((pblocks - 4 * fsblocks))
if [ $dblocks -gt 10000 ]; then
resize2fs -f $path
tell_kmsg "resized userdata filesystem to fill $path"
fi
}
identify_file_layout() {
# Determine if we have a Halium rootfs.img & system.img
# $file_layout = "halium" means there is a separate rootfs.img and system.img on userdata
#
# = "partition" means the rootfs is located on the device's system partition
# and will contain /var/lib/lxc/android/system.img
#
# = "subdir" means the rootfs is located in a folder on the device's userdata partition
# and will contain /var/lib/lxc/android/system.img
if [ -e /tmpmnt/rootfs.img ]; then
imagefile=/tmpmnt/rootfs.img
file_layout="halium"
elif [ -e /tmpmnt/ubuntu.img ]; then
imagefile=/tmpmnt/ubuntu.img
file_layout="legacy"
elif [ -d /tmpmnt/halium-rootfs ]; then
imagefile=/tmpmnt/halium-rootfs
file_layout="subdir"
else
file_layout="partition"
fi
}
process_bind_mounts() {
# Goes over /etc/system-image/writable-paths to create the correct fstab for
# the bind-mounts. Writes them into ${rootmnt}/run/image.fstab which is
# bind-mounted to /etc/fstab
if [ ! -e ${rootmnt}/etc/system-image/writable-paths ]; then
tell_kmsg "This rootfs does not have any writable-paths defined"
return 0
fi
# Mount a tmpfs in /run of rootfs to put the future image.fstab
mount -o rw,nosuid,noexec,relatime,mode=755 -t tmpfs tmpfs ${rootmnt}/run
# Prepare the fstab
FSTAB=${rootmnt}/etc/fstab
touch ${rootmnt}/run/image.fstab
mount -o bind ${rootmnt}/run/image.fstab $FSTAB ||halium_panic "Could not bind-mount fstab"
echo "/dev/root / rootfs defaults,ro 0 0" >>$FSTAB
tell_kmsg "Adding bind-mounts to $FSTAB"
# Process the list of bind-mounts
# (but don't mount them, mountall will do it)
cat ${rootmnt}/etc/system-image/writable-paths | while read line; do
set -- $line
# Skip invalid/commented entries
([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]) && continue
[ "$1" = "#" ] && continue
# Skip invalid mount points
dstpath="${rootmnt}/$1"
[ ! -e "$dstpath" ] && continue
if [ "$3" = "temporary" ]; then
# Temporary entries are simple, just mount a tmpfs
echo "tmpfs $1 tmpfs $5 0 0" >>$FSTAB
elif [ "$3" = "persistent" ] || [ "$3" = "synced" ]; then
# Figure out the source path
if [ "$2" = "auto" ]; then
srcpath="${rootmnt}/userdata/system-data/$1"
path="/userdata/system-data/$1"
else
srcpath="${rootmnt}/userdata/$2"
path="/userdata/$2"
fi
if [ ! -e "$srcpath" ]; then
# Process new persistent or synced paths
dstown=$(stat -c "%u:%g" $dstpath)
dstmode=$(stat -c "%a" $dstpath)
mkdir -p ${srcpath%/*}
if [ ! -d "$dstpath" ]; then
# Deal with redirected files
if [ "$4" = "transition" ]; then
cp -a $dstpath $srcpath
else
touch $srcpath
chown $dstown $srcpath
chmod $dstmode $srcpath
fi
else
# Deal with redirected directories
if [ "$4" = "transition" ] || [ "$3" = "synced" ]; then
cp -aR $dstpath $srcpath
else
mkdir $srcpath
chown $dstown $srcpath
chmod $dstmode $srcpath
fi
fi
elif [ "$3" = "synced" ]; then
# Process existing synced paths
sync_dirs $dstpath . $srcpath
fi
if [ "$5" = "none" ]; then
mount_opts="bind"
else
mount_opts="bind,$5"
fi
# mount all /etc dirs right now, not later when fstab is
# processed, as it will cause races (e.g. /etc/machine-id).
case "$1" in
/etc/*)
mount -o "$mount_opts" "$srcpath" "$dstpath"
;;
*)
echo "$path $1 none $mount_opts 0 0" >>$FSTAB
;;
esac
else
continue
fi
done
}
extract_android_ramdisk() {
# Extracts the ramdisk from /android-system/boot/android-ramdisk.img to
# /android-rootfs
# NOTE: we should find a faster way of doing that or cache it
tell_kmsg "extracting android ramdisk"
OLD_CWD=$(pwd)
mount -n -t tmpfs tmpfs /android-rootfs
cd /android-rootfs
cat /android-system/boot/android-ramdisk.img | gzip -d | cpio -i
cd $OLD_CWD
}
mount_kernel_modules() {
# Bind-mount /lib/modules from Android
[ -e ${rootmnt}/android/system/lib/modules ] && mount --bind ${rootmnt}/android/system/lib/modules ${rootmnt}/lib/modules
}
load_kernel_modules() {
mkdir -p /lib/modules
cd /lib/modules
ln -sf /lib/modules "/lib/modules/$(uname -r)"
tell_kmsg "Loading kernel modules from $(pwd)"
cat modules.load | while read line; do
set -- $line
# Skip commented entries
[ "$1" = "#" ] && continue
modprobe -a "$1"
done
cd -
}
mountroot() {
# list of possible userdata partition names
partlist="userdata UDA DATAFS USERDATA"
pre_mountroot
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
[ "$quiet" != "y" ] && log_end_msg
# Put all of this script's output into /dev/kmsg
exec &>/dev/kmsg
load_kernel_modules
tell_kmsg "Finished loading kernel modules"
sleep 1
# busybox mdev -s
# udevadm trigger
# Mount root
#
# Create a temporary mountpoint for the bindmount
mkdir -p /tmpmnt
# Make sure the device has been created by udev before we try to mount
udevadm settle
# find the right partition
for partname in $partlist; do
part=$(find /dev -name $partname | tail -1)
[ -z "$part" ] && continue
path=$(readlink -f $part)
[ -n "$path" ] && break
done
# On systems with A/B partition layout, current slot is provided via cmdline parameter.
ab_slot_suffix=$(grep -o 'androidboot\.slot_suffix=..' /proc/cmdline | tail -1 | cut -d "=" -f2)
if [ -z "$path" ] && [ ! -z "$ab_slot_suffix" ] ; then
tell_kmsg "Searching for A/B data partition on slot $ab_slot_suffix."
for partname in $partlist; do
part=$(find /dev -name "$partname$ab_slot_suffix" | tail -1)
[ -z "$part" ] && continue
path=$(readlink -f $part)
[ -n "$path" ] && break
done
fi
# override with a possible cmdline parameter
if grep -q datapart= /proc/cmdline; then
for x in $(cat /proc/cmdline); do
case ${x} in
datapart=*)
path=${x#*=}
;;
esac
done
fi
if [ -z "$path" ]; then
halium_panic "Couldn't find data partition."
fi
tell_kmsg "checking filesystem integrity for the userdata partition"
# Mounting and umounting first, let the kernel handle the journal and
# orphaned inodes (faster than e2fsck). Then, just run e2fsck forcing -y.
# Also check the amount of time used by to check the filesystem.
fsck_start=$(date +%s)
mount -o errors=remount-ro $path /tmpmnt
umount /tmpmnt
e2fsck -y $path >/run/e2fsck.out 2>&1
fsck_end=$(date +%s)
tell_kmsg "checking filesystem for userdata took (including e2fsck) $((fsck_end - fsck_start)) seconds"
resize_userdata_if_needed ${path}
tell_kmsg "mounting $path"
# Mount the data partition to a temporary mount point
# FIXME: data=journal used on ext4 as a workaround for bug 1387214
[ `blkid $path -o value -s TYPE` = "ext4" ] && OPTIONS="data=journal,"
mount -o discard,$OPTIONS $path /tmpmnt
# setup super partition if exists
if [ -n "/dev/disk/by-partlabel/super" ]; then
tell_kmsg "trying to parse and dmsetup subpartitions from super partition"
/sbin/parse-android-dynparts /dev/disk/by-partlabel/super | sh
dmsetup mknodes
fi
# Set $_syspart if it is specified as systempart= on the command line
if grep -q systempart= /proc/cmdline; then
for x in $(cat /proc/cmdline); do
case ${x} in
systempart=*)
_syspart=${x#*=}
if [ -z ${_syspart##*:*} ]; then
_syspart_options=${_syspart##*:}
_syspart=${_syspart%%:*}
fi
;;
esac
done
if [ -z "$_syspart_options" ]; then
_syspart_options=rw
fi
fi
identify_file_layout
# Default to /dev/mapper/system if no image file is found
[ -z "$imagefile" ] && [ -z "$_syspart" ] && _syspart=/dev/mapper/system
# We need to add the slot suffix to $_syspart for A/B devices
if [ -n "$_syspart" ] && [ ! -e "$_syspart" ]; then
[ -z "$ab_slot_suffix" ] && ab_slot_suffix=_a
tell_kmsg "A/B slot system detected! Slot suffix is $ab_slot_suffix"
_syspart="${_syspart}${ab_slot_suffix}"
tell_kmsg "system partition is at $_syspart"
fi
# If both $imagefile and $_syspart are set, something is wrong. The strange
# output from this could be a clue in that situation.
tell_kmsg "Halium rootfs is $imagefile $_syspart"
# Prepare the root filesystem
# NOTE: We mount it read-write in all cases, then remount read-only.
# This is to workaround a behaviour change in busybox which now
# uses read-only loops if the fs is initially mounted read-only.
# An alternative implementation would be to add losetup support
# to busybox and do the mount in two steps (rw loop, ro fs).
mkdir -p /halium-system
tell_kmsg "mounting system rootfs at /halium-system"
if [ -n "$_syspart" ]; then
mount -o "$_syspart_options" $_syspart /halium-system
elif [ -f "$imagefile" ]; then
# Rootfs is an image file
mount -o loop,rw $imagefile /halium-system
elif [ -d "$imagefile" ]; then
# Rootfs is a directory
mount -o bind /tmpmnt/halium-rootfs /halium-system
fi
# Identify image mode: either "rootfs" or "system"
mkdir -p /android-rootfs
mkdir -p /android-system
identify_android_image
[ $ANDROID_IMAGE_MODE = "unknown" ] && tell_kmsg "WARNING: Android system image not found."
if { [ -n "$_syspart_options" ] && [ -z "${_syspart_options##*ro*}" ]; } || [ -e /tmpmnt/.writable_image_overlay ] || [ -e /halium-system/.writable_image_overlay ]; then
# If systempart had to be mounted ro, mount rw overlayfs on top
mkdir -p /tmpmnt/rootfs-overlay /tmpmnt/rootfs-overlay-workdir
mount -t overlay rootfs -o lowerdir=/halium-system,upperdir=/tmpmnt/rootfs-overlay,workdir=/tmpmnt/rootfs-overlay-workdir /halium-system
fi
# If either (android) /data/.writable_image or (on rootfs)
# /.writable_image exist, mount the rootfs as rw
if [ -e /tmpmnt/.writable_image ] || [ -e /halium-system/.writable_image ]; then
tell_kmsg "mounting $_syspart $imagefile (image developer mode)"
mountroot_status="$?"
else
# Neither of those exist, remount read-only
tell_kmsg "mounting $_syspart $imagefile (user mode)"
mount -o remount,ro /halium-system
mountroot_status="$?"
fi
# Mount the android system partition to a temporary location
MOUNT="ro"
MOUNT_LOCATION="/android-$ANDROID_IMAGE_MODE"
[ $ANDROID_IMAGE_MODE = "system" ] && ANDROID_IMAGE="system.img" || ANDROID_IMAGE="android-rootfs.img"
[ -e /tmpmnt/.writable_device_image -o -e /halium-system/.writable_device_image ] && MOUNT="rw"
tell_kmsg "mounting android system image (/tmpmnt/$ANDROID_IMAGE) $MOUNT, in $MOUNT_LOCATION ($ANDROID_IMAGE_MODE mode)"
if [ $file_layout = "halium" ]; then
# rootfs.img and Android system.img are separate
tell_kmsg "mounting android system image from userdata partition"
mount -o loop,$MOUNT "/tmpmnt/$ANDROID_IMAGE" $MOUNT_LOCATION
else
# Android system.img is inside rootfs
tell_kmsg "mounting android system image from system rootfs"
mount -o loop,$MOUNT "/halium-system/var/lib/lxc/android/$ANDROID_IMAGE" $MOUNT_LOCATION
fi
[ $? -eq 0 ] || tell_kmsg "WARNING: Failed to mount Android system.img."
[ $ANDROID_IMAGE_MODE = "rootfs" ] && mount -o bind $MOUNT_LOCATION/system /android-system
[ $ANDROID_IMAGE_MODE = "system" ] && extract_android_ramdisk
identify_boot_mode
# Determine whether we should boot to rootfs or Android
if [ "$BOOT_MODE" = "recovery" ]; then
tell_kmsg "Recovery boot mode for system-as-root devices"
# Clean up mounted partitions so recovery can manage them
umount -d /android-system /android-rootfs /halium-system /tmpmnt
dmsetup remove_all
mount -n -t tmpfs tmpfs ${rootmnt}
cd ${rootmnt}
if [ -d /lib/modules ]; then
mkdir -p lib/modules
mv /lib/modules/* lib/modules/
fi
cat /ramdisk-recovery.img | gzip -d | cpio -i
cd -
mkdir -p ${rootmnt}/sbin
ln -s ../init ${rootmnt}/sbin/init
elif ([ -e $imagefile ] || [ -n "$_syspart" ]) && [ "$BOOT_MODE" = "android" ]; then
# Bootloader says this is factory or charger mode, boot into Android.
tell_kmsg "Android boot mode for factory or charger mode"
mount --move /android-rootfs ${rootmnt}
[ $ANDROID_IMAGE_MODE = "system" ] && mount --move /android-system ${rootmnt}/system
# Mount all the Android partitions
mount_android_partitions "${rootmnt}/fstab*" ${rootmnt} /tmpmnt
mkdir -p ${rootmnt}/halium-system
mount --move /halium-system ${rootmnt}/halium-system
# Mounting userdata
mkdir -p ${rootmnt}/data
mkdir -p /tmpmnt/android-data
mount -o bind /tmpmnt/android-data ${rootmnt}/data
# Set halium version properties
set_halium_version_properties ${rootmnt}/halium-system ${rootmnt}/data
# Make sure we're booting into android's init
ln -s ../init ${rootmnt}/sbin/init
ln -s ../init ${rootmnt}/sbin/recovery
tell_kmsg "booting android..."
elif [ -e $imagefile ] || [ -n "$_syspart" ]; then
# Regular image boot
tell_kmsg "Normal boot"
mount --move /halium-system ${rootmnt}
mkdir -p ${rootmnt}/android
# Mounting userdata outside of /android, to avoid having LXC container access it
mkdir -p ${rootmnt}/userdata
mount --move /tmpmnt ${rootmnt}/userdata
mount --move /android-rootfs ${rootmnt}/var/lib/lxc/android/rootfs
[ $ANDROID_IMAGE_MODE = "system" ] && mount -o rw,size=4096 -t tmpfs none ${rootmnt}/android
[ $ANDROID_IMAGE_MODE = "rootfs" ] && mount -o bind ${rootmnt}/var/lib/lxc/android/rootfs ${rootmnt}/android
mkdir -p ${rootmnt}/android/data ${rootmnt}/android/system
# Create a fake android data, shared by rootfs and LXC container
mkdir -p ${rootmnt}/userdata/android-data
mount -o bind ${rootmnt}/userdata/android-data ${rootmnt}/android/data
[ ! -h ${rootmnt}/data ] && ln -sf /android/data ${rootmnt}/data
set_halium_version_properties ${rootmnt} ${rootmnt}/userdata/android-data
# Get device information
device=$(grep ^ro.product.device= /android-system/build.prop | sed -e 's/.*=//')
[ -z "$device" ] && device="unknown" && tell_kmsg "WARNING: Didn't find a device name. Is the Android system image mounted correctly?"
tell_kmsg "device is $device"
process_bind_mounts
# Mount all the Android partitions
mount_android_partitions "${rootmnt}/var/lib/lxc/android/rootfs/fstab*" ${rootmnt}/android ${rootmnt}/userdata
# system is a special case
tell_kmsg "moving Android system to /android/system"
mount --move /android-system ${rootmnt}/android/system
# halium overlay available in the Android system image (hardware specific configs)
if [ -e ${rootmnt}/android/system/halium ]; then
mount_halium_overlay ${rootmnt}/android/system/halium ${rootmnt}
fi
# Apply device-specific udev rules
if [ -e ${rootmnt}/usr/lib/lxc-android-config/70-$device.rules ] &&
[ ! -f ${rootmnt}/android/system/halium/lib/udev/rules.d/70-android.rules ] &&
[ "$device" != "unknown" ]; then
mount --bind ${rootmnt}/usr/lib/lxc-android-config/70-$device.rules ${rootmnt}/lib/udev/rules.d/70-android.rules
fi
# Bind-mount /lib/modules from Android
mount_kernel_modules
# Bind-mount /var/lib/ureadahead if available on persistent storage
# this is required because ureadahead runs before mountall
if [ -e ${rootmnt}/userdata/system-data/var/lib/ureadahead ] &&
[ -e ${rootmnt}/var/lib/ureadahead ]; then
mount --bind ${rootmnt}/userdata/system-data/var/lib/ureadahead ${rootmnt}/var/lib/ureadahead
fi
# Setup the swap device
[ -e ${rootmnt}/userdata/SWAP.img ] && swapon ${rootmnt}/userdata/SWAP.img
# Apply customized content
for user in ${rootmnt}/userdata/user-data/*; do
if [ -d ${rootmnt}/custom/home ] && [ ! -e "$user/.customized" ]; then
tell_kmsg "copying custom content tp "
cp -Rap ${rootmnt}/custom/home/* "$user/"
cp -Rap ${rootmnt}/custom/home/.[a-zA-Z0-9]* "$user/"
touch "$user/.customized"
dstown=$(stat -c "%u:%g" "$user")
chown -R $dstown "$user/"
fi
done
else
# Possibly a re-partitioned device
halium_panic "Couldn't find a system partition."
fi
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && log_end_msg
}

View file

@ -0,0 +1,167 @@
#!/bin/sh
PREREQ=""
prereqs() {
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
USB_FUNCTIONS=rndis
ANDROID_USB=/sys/class/android_usb/android0
GADGET_DIR=/config/usb_gadget
LOCAL_IP=192.168.2.15
EXPLICIT_BUSYBOX="/bin/busybox"
TELNET_DEBUG_PORT=23
write() {
echo -n "$2" >"$1"
}
# This sets up the USB with whatever USB_FUNCTIONS are set to via configfs
usb_setup_configfs() {
G_USB_ISERIAL=$GADGET_DIR/g1/strings/0x409/serialnumber
mkdir $GADGET_DIR/g1
write $GADGET_DIR/g1/idVendor "0x18D1"
write $GADGET_DIR/g1/idProduct "0xD001"
mkdir $GADGET_DIR/g1/strings/0x409
write $GADGET_DIR/g1/strings/0x409/serialnumber "$1"
write $GADGET_DIR/g1/strings/0x409/manufacturer "Halium initrd"
write $GADGET_DIR/g1/strings/0x409/product "Failed to boot"
if echo $USB_FUNCTIONS | grep -q "rndis"; then
NETWORK_FUNCTION=""
for function in ncm.usb0 rndis.usb0 rndis_bam.rndis; do
if mkdir $GADGET_DIR/g1/functions/$function; then
NETWORK_FUNCTION=$function
break
fi
done
if [ -z "$NETWORK_FUNCTION" ]; then
echo "Error: No USB network gadget function available" >&2
exit 1
fi
fi
echo $USB_FUNCTIONS | grep -q "mass_storage" && mkdir $GADGET_DIR/g1/functions/storage.0
mkdir $GADGET_DIR/g1/configs/c.1
mkdir $GADGET_DIR/g1/configs/c.1/strings/0x409
write $GADGET_DIR/g1/configs/c.1/strings/0x409/configuration "$USB_FUNCTIONS"
if echo $USB_FUNCTIONS | grep -q "rndis"; then
ln -s $GADGET_DIR/g1/functions/$NETWORK_FUNCTION $GADGET_DIR/g1/configs/c.1
fi
echo $USB_FUNCTIONS | grep -q "mass_storage" && ln -s $GADGET_DIR/g1/functions/storage.0 $GADGET_DIR/g1/configs/c.1
echo "$(ls /sys/class/udc | grep -v dummy | head -1)" > $GADGET_DIR/g1/UDC
}
# This sets up the USB with whatever USB_FUNCTIONS are set to via android_usb
usb_setup_android_usb() {
G_USB_ISERIAL=$ANDROID_USB/iSerial
write $ANDROID_USB/enable 0
write $ANDROID_USB/functions ""
write $ANDROID_USB/enable 1
usleep 500000 # 0.5 delay to attempt to remove rndis function
write $ANDROID_USB/enable 0
write $ANDROID_USB/idVendor 18D1
write $ANDROID_USB/idProduct D001
write $ANDROID_USB/iManufacturer "Halium initrd"
write $ANDROID_USB/iProduct "Failed to boot"
write $ANDROID_USB/iSerial "$1"
write $ANDROID_USB/functions $USB_FUNCTIONS
write $ANDROID_USB/enable 1
}
# This determines which USB setup method is going to be used
usb_setup() {
mkdir /config || true
mount -t configfs none /config || true
if [ -d $ANDROID_USB ]; then
usb_setup_android_usb $1
elif [ -d $GADGET_DIR ]; then
usb_setup_configfs $1
fi
}
usb_info() {
# make sure USB is settled
echo "########################## usb_info: $1"
sleep 1
write $G_USB_ISERIAL "$1"
}
inject_loop() {
INJ_DIR=/init-ctl
INJ_STDIN=$INJ_DIR/stdin
mkdir $INJ_DIR
mkfifo $INJ_STDIN
echo "This entire directory is for debugging init - it can safely be removed" >$INJ_DIR/README
echo "########################## Beginning inject loop"
while :; do
while read IN; do
if [ "$IN" = "continue" ]; then break 2; fi
$IN
done <$INJ_STDIN
done
rm -rf $INJ_DIR # Clean up if we exited nicely
echo "########################## inject loop done"
}
usb_setup "halium-initrd telnet 192.168.2.15"
USB_IFACE=notfound
/sbin/ifconfig rndis0 $LOCAL_IP && USB_IFACE=rndis0
if [ x$USB_IFACE = xnotfound ]; then
/sbin/ifconfig usb0 $LOCAL_IP && USB_IFACE=usb0
fi
# Report for the logs
/sbin/ifconfig -a
# Unable to set up USB interface? Reboot.
if [ x$USB_IFACE = xnotfound ]; then
usb_info "Halium initrd Debug: ERROR: could not setup USB as usb0 or rndis0"
dmesg
sleep 60 # plenty long enough to check usb on host
reboot -f
fi
# Create /etc/udhcpd.conf file.
echo "start 192.168.2.20" >/etc/udhcpd.conf
echo "end 192.168.2.90" >>/etc/udhcpd.conf
echo "lease_file /var/udhcpd.leases" >>/etc/udhcpd.conf
echo "interface $USB_IFACE" >>/etc/udhcpd.conf
echo "option subnet 255.255.255.0" >>/etc/udhcpd.conf
# Be explicit about busybox so this works in a rootfs too
echo "########################## starting dhcpd"
$EXPLICIT_BUSYBOX udhcpd
# Non-blocking telnetd
echo "########################## starting telnetd"
# We run telnetd on different ports pre/post-switch_root This
# avoids problems with an unterminated pre-switch_root telnetd
# hogging the port
$EXPLICIT_BUSYBOX telnetd -b ${LOCAL_IP}:${TELNET_DEBUG_PORT} -l /bin/sh
# For some reason this does not work in rootfs
usb_info "Halium initrd Debug telnet on port $TELNET_DEBUG_PORT on $USB_IFACE $LOCAL_IP - also running udhcpd"
ps -wlT
ps -ef
netstat -lnp
cat /proc/mounts
sync
# Run command injection loop = can be exited via 'continue'
inject_loop

View file

@ -0,0 +1,23 @@
import /init.recovery.project.rc
on init
setprop sys.usb.configfs 1
setprop sys.usb.ffs.aio_compat 0
# TODO: touchscreen doesn't work even though driver built-in, needs firmware?
on fs && property:ro.debuggable=0
# distinguish USB shoulde connect or not, i.e. CDP vs SDP
write /sys/class/udc/musb-hdrc/device/cmode 2
# set charging free due to it wait for USB activation
start adbd
# TODO: add symlinks for preloader etc?
#on post-fs
on post-fs-data
start setup_fake_cache
wait_for_prop halium.datamount.done 1
service setup_fake_cache /bin/sh /setup_fake_cache.sh
disabled
oneshot

View file

@ -0,0 +1,2 @@
# The device has dynamic partitions
ro.boot.dynamic_partitions=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

View file

@ -0,0 +1,26 @@
#!/system/bin/sh
DATA_MOUNT_CODE=1
RETRY_COUNTER=0
while [ "$DATA_MOUNT_CODE" != "0" ]; do
if [ "$RETRY_COUNTER" -gt "3" ]; then
echo "setup_fake_cache.sh - reached maximum number of retries" > /dev/kmsg
setprop halium.datamount.done 1
exit 1
fi
RETRY_COUNTER=$((RETRY_COUNTER+1))
mount /dev/block/by-name/userdata /data > /dev/kmsg
DATA_MOUNT_CODE=$?
sleep 1
done
if [ "$DATA_MOUNT_CODE" == "0" ]; then
mkdir /data/cache > /dev/kmsg
mount -o bind /data/cache /cache > /dev/kmsg
fi
setprop halium.datamount.done 1
exit 0

View file

@ -0,0 +1,619 @@
#!/system/bin/sh
set -e
echo "System Image Upgrader for Ubuntu Touch"
echo "Preparing command file"
if [ ! -e "$1" ]; then
echo "Command file doesn't exist: $1"
exit 1
fi
mv $1 $1.applying
COMMAND_FILE=$1.applying
REMOVE_LIST="$COMMAND_FILE"
# Used as a security check to see if we would change the password
DATA_FORMAT=0
# System Mountpoint
SYSTEM_MOUNTPOINT=/cache/system
echo "Starting image upgrader"
# Functions
check_filesystem() {
# $1 => image to check (partition or device img)
if [ ! -e $1 ]; then
echo "Partition/image not found: $1"
return 1
fi
# It's fine for e2fsck to return something different than 0
set +e
e2fsck -yf $1
ret=$?
# From e2fsck man page:
# 0 - No errors
# 1 - File system errors corrected
if [ $ret -ne 0 ] && [ $ret -ne 1 ]; then
echo "e2fsck is unable to fix partition/image $1, aborting (return code $ret)"
exit 1
fi
set -e
}
verify_signature() {
# HACK: ignore all signatures for allowing messing around with
#return 0
# $1 => validation keyring name
# $2 => path to validate
if [ ! -e $2 ]; then
echo "File doesn't exist: $2"
return 1
fi
# Check against the blacklist
if [ -e /tmp/system-image/blacklist/pubring.gpg ]; then
export GNUPGHOME=/tmp/system-image/blacklist/
if gpg --ignore-time-conflict --verify $2 >/dev/null 2>&1; then
echo "File signed by a blacklisted key: $2"
return 1
fi
fi
# Check against the keyring
export GNUPGHOME=/tmp/system-image/$1/
if [ ! -e "$GNUPGHOME" ]; then
echo "Keyring doesn't exist: $1"
return 1
fi
if gpg --ignore-time-conflict --verify $2 >/dev/null 2>&1; then
return 0
fi
return 1
}
install_keyring() {
# $1 => full path to tarball
# $2 => full path to signature
# Some basic checks
if [ ! -e "$1" ] || [ ! -e "$2" ]; then
echo "Missing keyring files: $1 => $2"
return 1
fi
# Unpacking
TMPDIR=$(mktemp -d -p /tmp/system-image/ tmp.XXXXXXXXXX)
cd $TMPDIR
busybox xzcat $1 | busybox tar --numeric-owner -xf -
if [ ! -e keyring.json ] || [ ! -e keyring.gpg ]; then
rm -Rf $TMPDIR
echo "Invalid keyring: $1"
return 1
fi
# Extract the expiry
keyring_expiry=$(grep "^ \"expiry\": " keyring.json | cut -d: -f2 | sed -e "s/[ \",]//g")
if [ -n "$keyring_expiry" ] && [ "$keyring_expiry" -lt "$(date +%s)" ]; then
rm -Rf $TMPDIR
echo "Keyring expired: $1"
return 1
fi
# Extract the keyring type
keyring_type=$(grep "^ \"type\": " keyring.json | cut -d: -f2 | sed -e "s/[, \"]//g")
if [ -z "$keyring_type" ]; then
rm -Rf $TMPDIR
echo "Missing keyring type: $1"
return 1
fi
if [ -e /tmp/system-image/$keyring_type ]; then
rm -Rf $TMPDIR
echo "Keyring already loaded: $1"
return 1
fi
signer="unknown"
case "$keyring_type" in
archive-master)
signer=""
;;
image-master)
signer="archive-master"
;;
image-signing|blacklist)
signer="image-master"
;;
device-signing)
signer="image-signing"
;;
esac
if [ -n "$signer" ] && ! verify_signature $signer $2; then
rm -Rf $TMPDIR
echo "Invalid signature: $1"
return 1
fi
mkdir /tmp/system-image/$keyring_type
chmod 700 /tmp/system-image/$keyring_type
mv $TMPDIR/keyring.gpg /tmp/system-image/$keyring_type/pubring.gpg
chmod 600 /tmp/system-image/$keyring_type/pubring.gpg
chown 0:0 /tmp/system-image/$keyring_type/pubring.gpg
rm -Rf $TMPDIR
return 0
}
property_write() {
prop="$1"
prop_value="$2"
prop_dir="/data/android-data/property"
# everything is wiped after a format, let's get a skeleton going
mkdir -p "$prop_dir"
chown 0:0 "$prop_dir"
chmod 700 "$prop_dir"
echo -n "$prop_value" > "$prop_dir/$prop"
# properties won't be read if they aren't ro root
chown 0:0 "$prop_dir/$prop"
chmod 600 "$prop_dir/$prop"
}
adb_onlock() {
if [ "$DATA_FORMAT" -eq 0 ]; then
return 1
fi
flag="/data/.adb_onlock"
# if the param != "true" we just delete the flag
case $1 in
true)
touch "$flag"
;;
false)
rm -f "$flag"
;;
*)
echo "Unkown parameter $1, disabling"
rm -f "$flag"
;;
esac
}
set_password() {
if [ "$DATA_FORMAT" -eq 0 ]; then
return 1
fi
user="phablet"
password="$1"
if [ -z "$password" ]; then
return 1
fi
path=/bin:/usr/bin:/sbin:/usr/sbin
PATH=$path chroot "$SYSTEM_MOUNTPOINT" /bin/sh -c "echo -n "$user:$password" | chpasswd"
return 0
}
unset_password() {
if [ "$DATA_FORMAT" -eq 0 ]; then
return 1
fi
# Needs implementation
}
usb_enable() {
prop_dir="/data/android-data/property"
prop="persist.sys.usb.config"
prop_val="$1"
# Property value ordering is important here
grep -q -s mtp "$prop_dir/$prop" && [ "$prop_val" == "adb" ] && prop_val="mtp,adb"
grep -q -s adb "$prop_dir/$prop" && [ "$prop_val" == "mtp" ] && prop_val="mtp,adb"
property_write "$prop" "$prop_val"
}
usb_disable() {
prop_dir="/data/android-data/property"
prop="persist.sys.usb.config"
prop_val="$1"
remain_prop=""
# Property value ordering is important here
grep -q -s mtp "$prop_dir/$prop" && [ "$prop_val" == "adb" ] && remain_prop="mtp"
grep -q -s adb "$prop_dir/$prop" && [ "$prop_val" == "mtp" ] && remain_prop="adb"
# we should not allow empty properties for the usb config
[ "$remain_prop" == "" ] && remain_prop="adb"
property_write "$prop" "$remain_prop"
}
factory_wipe() {
# only set this flag if coming from a data wipe
if [ "$DATA_FORMAT" -eq 0 ]; then
return 1
fi
flag="/data/.factory_wipe"
# if the param != "true" we just delete the flag
case $1 in
true)
touch "$flag"
;;
false)
rm -f "$flag"
;;
*)
echo "Unkown parameter $1, disabling"
rm -f "$flag"
;;
esac
}
# Initialize GPG
rm -Rf /tmp/system-image
mkdir -p /tmp/system-image
if [ -e /etc/system-image/archive-master.tar.xz ]; then
echo "Loading keyring: archive-master.tar.xz"
install_keyring /etc/system-image/archive-master.tar.xz /etc/system-image/archive-master.tar.xz.asc
fi
# Check the kernel command line to see whether Ubuntu should be installed to a partition
# or in a file that is loop mounted.
#if grep -q systempart= /proc/cmdline; then
# USE_SYSTEM_PARTITION=1
#else
# USE_SYSTEM_PARTITION=0
#fi
# Force usage of system partition for now, the existance of Android 9.0 devices
# with a too small system partition is questionable at this point.
USE_SYSTEM_PARTITION=1
# However, do not use the block device name in the kernel command line, as that is not consistently
# named in booting normal and recovery modes. Expect fstab to have a system mountpoint or use a fallback.
if [ "$USE_SYSTEM_PARTITION" -eq 1 ];then
SYSTEM_PARTITION=$(grep "^[^#]" /etc/fstab | grep -e "\(/mnt\)*/system\(_root\)*" | cut -f 1 -d\ )
#Fall back to emmc@android if there's no system in fstab
if [ "$SYSTEM_PARTITION" == "" ]; then
SYSTEM_PARTITION="emmc@android"
fi
fi
# If we are not using the system partition, ensure that /data is mounted
if [ "$USE_SYSTEM_PARTITION" -eq 0 ]; then
mount /data
fi
# Process the command file
FULL_IMAGE=0
echo "Processing command file"
while read line
do
set -- $line
case "$1" in
format)
echo "Formatting: $2"
case "$2" in
system)
FULL_IMAGE=1
# Cleanup files left from halium-install
rm -f /data/system.img
rm -f /data/android-rootfs.img
rm -f /data/rootfs.img
# Delete ubuntu.img if present. Either its a leftover, or we recreate it
rm -f /data/ubuntu.img
if [ "$USE_SYSTEM_PARTITION" -eq 1 ];then
echo "system partition: $SYSTEM_PARTITION"
umount /mnt/system || true
mkfs.ext4 $SYSTEM_PARTITION
else
# We need to use legacy image name here, halium-boot needs this to decide file layout
dd if=/dev/zero of=/data/ubuntu.img seek=3M bs=1024 count=0
mkfs.ext2 -F /data/ubuntu.img
fi
;;
data)
if [ "$USE_SYSTEM_PARTITION" -eq 1 ]; then
mount /data || true
fi
for entry in /data/* /data/.writable_image /data/.factory_wipe; do
if [ "$USE_SYSTEM_PARTITION" -eq 0 ]; then
if [[ ( "$entry" == "/data/ubuntu.img" ) || ( "$entry" == "/data/rootfs.img" ) || ( "$entry" == "/data/system.img" ) || ( "$entry" == "/data/android-rootfs.img" ) ]]; then
continue
fi
fi
# Some devices use /data as /cache, so avoid removing
# files that are essential to flashing and upgrading
if [ "$entry" == "/data/cache" ]; then
continue
fi
# If this is android-data, inspect closer as we need the
# cache "partition" to stay functioning during use of the
# system-image-upgrader script. It is bind mounted
# and leads to premature cancellation otherwise.
if [ "$entry" == "/data/android-data" ]; then
for android_data_entry in /data/android-data/*; do
if [ "$android_data_entry" != "/data/android-data/cache" ]; then
# recursively unset immutable attribute set to few files
# by vendor services before removal
#chattr -R -i $android_data_entry
rm -Rf $android_data_entry
fi
done
else
rm -Rf $entry
fi
done
# mtp is always enabled by default
usb_enable mtp
DATA_FORMAT=1
if [ "$USE_SYSTEM_PARTITION" -eq 1 ]; then
umount /data
fi
;;
*)
echo "Unknown format target: $2"
;;
esac
;;
enable)
echo "Enabling: $2"
case "$2" in
developer_mode)
usb_enable adb
;;
mtp)
usb_enable mtp
;;
default_password)
set_password $3
;;
adb_onlock)
adb_onlock true
;;
factory_wipe)
factory_wipe true
;;
*)
echo "Unknown enable target: $2"
;;
esac
;;
disable)
echo "Disabling: $2"
case "$2" in
developer_mode)
usb_disable adb
;;
mtp)
usb_disable mtp
;;
default_password)
unset_password
;;
adb_onlock)
adb_onlock false
;;
factory_wipe)
factory_wipe false
;;
*)
echo "Unknown disable target: $2"
;;
esac
;;
load_keyring)
if [ ! -e "/cache/recovery/$2" ] || [ ! -e "/cache/recovery/$3" ]; then
echo "Skipping missing file: $2"
continue
fi
REMOVE_LIST="$REMOVE_LIST /cache/recovery/$2 /cache/recovery/$3"
echo "Loading keyring: $2"
install_keyring /cache/recovery/$2 /cache/recovery/$3
if [ -e /tmp/system-image/image-master/pubring.gpg ] && \
[ ! -e /tmp/system-image/blacklist/pubring.gpg ] && \
[ -e /data/system-data/var/lib/system-image/blacklist.tar.xz ] && \
[ -e /data/system-data/var/lib/system-image/blacklist.tar.xz.asc ]; then
echo "Loading blacklist keyring"
install_keyring /data/system-data/var/lib/system-image/blacklist.tar.xz /data/system-data/var/lib/system-image/blacklist.tar.xz.asc
fi
;;
mount)
case "$2" in
system)
mkdir -p "$SYSTEM_MOUNTPOINT"
if [ "$USE_SYSTEM_PARTITION" -eq 1 ];then
umount $SYSTEM_PARTITION || true
umount $SYSTEM_MOUNTPOINT || true
umount /mnt/system || true
check_filesystem $SYSTEM_PARTITION
mount $SYSTEM_PARTITION "$SYSTEM_MOUNTPOINT"
else
check_filesystem /data/ubuntu.img
mount -o loop /data/ubuntu.img "$SYSTEM_MOUNTPOINT/"
fi
;;
*)
echo "Unknown mount target: $2"
;;
esac
;;
unmount)
case "$2" in
system)
umount "$SYSTEM_MOUNTPOINT"
rmdir "$SYSTEM_MOUNTPOINT"
;;
*)
echo "Unknown mount target: $2"
;;
esac
;;
update)
if [ ! -e "/cache/recovery/$2" ] || [ ! -e "/cache/recovery/$3" ]; then
echo "Skipping missing file: $2"
continue
fi
REMOVE_LIST="$REMOVE_LIST /cache/recovery/$3"
if ! verify_signature device-signing /cache/recovery/$3 && \
! verify_signature image-signing /cache/recovery/$3; then
echo "Invalid signature"
exit 1
fi
echo "Applying update: $2"
cd /cache
rm -Rf partitions
rm -Rf data || true
# Start by removing any file listed in "removed"
if [ "$FULL_IMAGE" != "1" ]; then
busybox xzcat recovery/$2 | busybox tar --numeric-owner -xf - removed >/dev/null 2>&1 || true
if [ -e removed ]; then
while read file; do
rm -Rf $file
done < removed
fi
rm -f removed
fi
# Unpack everything else on top of the system partition
busybox xzcat recovery/$2 | busybox tar --numeric-owner -xf -
rm -f removed
# WORKAROUND: fix erroneous vendor symlink
if [ -h "$SYSTEM_MOUNTPOINT/vendor" ]; then
VENDOR_SYMLINK_PATH=$(readlink $SYSTEM_MOUNTPOINT/vendor)
if [ "$VENDOR_SYMLINK_PATH" == "/android/system/vendor" ]; then
rm $SYSTEM_MOUNTPOINT/vendor
ln -s /android/vendor $SYSTEM_MOUNTPOINT/vendor
fi
fi
# Move things to data
if [ -d data ]; then
mv data/* /data/ || true
rm -Rf data || true
fi
# Process partition images
grep "^/dev" /etc/fstab | while read line; do
set -- $line
part=${2##/}
path=$1
if [ -e partitions/${part}.img ] && [ -e $path ]; then
if simgtest partitions/${part}.img 2>/dev/null; then
echo "Flashing sparse ${part} at ${path}"
simg2img partitions/${part}.img ${path}
else
echo "Checking if ${part} at ${path} needs updating..."
new_size=$(wc -c < partitions/${part}.img)
if ! head -c ${new_size} ${path} | cmp -s partitions/${part}.img; then
echo " Flashing (binary content differs up to ${new_size} bytes)..."
cat partitions/${part}.img > ${path}
else
echo " Already up-to-date"
fi
fi
sync
rm partitions/${part}.img
fi
done
# Remove tarball to free up space, since device tarballs
# extract partitions/blobs that might fill up cache,
# this way we ensure we got space for the partitions/blobs
rm -f recovery/$2
;;
"#")
# We are processing a command in the script, ignore it
;;
*)
echo "Unknown command: $1"
;;
esac
done < $COMMAND_FILE
# Remove the update files
for file in $REMOVE_LIST; do
rm -f $file
done
# If a previous SWAP of 512MB is available, remove
if [ -e /data/SWAP.img ]; then
echo "Removing obsolete SWAP.img"
rm -f /data/SWAP.img
fi
# Ensure we have sane permissions
if [ "$USE_SYSTEM_PARTITION" -eq 0 ];then
chmod 600 /data/ubuntu.img
chown 0:0 /data/ubuntu.img
fi
touch /data/.last_update || true
sync
echo "Done upgrading..."
# Make sure there are always 5% reserved in /data for root usage
# else filling $HOME can make the system unusable since writable
# files and dirs share the space with $HOME and android does not
# reserve root space in /data for ext4.
# Devices with f2fs can reserve space with setting the
# "reserve_root" mount option.
if [ "$USE_SYSTEM_PARTITION" -eq 1 ]; then
mount /data
fi
DATA_FS_TYPE=$(grep "/data " /proc/mounts| cut -d ' ' -f3)
if [ "$DATA_FS_TYPE" == "ext4" ]; then
tune2fs -m 5 $(grep "/data " /proc/mounts| sed -e 's/ .*$//')
fi
# Always unmount unconditionally
umount /data
sync

View file

@ -0,0 +1,146 @@
# 1 "vendor/mediatek/proprietary/hardware/fstab/mt6835/fstab.in.mt6835"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 356 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "vendor/mediatek/proprietary/hardware/fstab/mt6835/fstab.in.mt6835" 2
# 132 "vendor/mediatek/proprietary/hardware/fstab/mt6835/fstab.in.mt6835"
system /system erofs ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey
system /system ext4 ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey
system_ext /system_ext erofs ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey
system_ext /system_ext ext4 ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey
vendor /vendor erofs ro wait,slotselect,avb,logical,first_stage_mount
vendor /vendor ext4 ro wait,slotselect,avb,logical,first_stage_mount
product /product erofs ro wait,slotselect,avb,logical,first_stage_mount
product /product ext4 ro wait,slotselect,avb,logical,first_stage_mount
vendor_dlkm /vendor_dlkm erofs ro wait,slotselect,avb,logical,first_stage_mount
vendor_dlkm /vendor_dlkm ext4 ro wait,slotselect,avb,logical,first_stage_mount
odm_dlkm /odm_dlkm erofs ro wait,slotselect,avb,logical,first_stage_mount
odm_dlkm /odm_dlkm ext4 ro wait,slotselect,avb,logical,first_stage_mount
system_dlkm /system_dlkm erofs ro wait,slotselect,avb,logical,first_stage_mount
system_dlkm /system_dlkm ext4 ro wait,slotselect,avb,logical,first_stage_mount
/dev/block/by-name/metadata /metadata f2fs noatime,nosuid,nodev,discard wait,check,formattable,first_stage_mount
/dev/block/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,noflush_merge,fsync_mode=nobarrier,reserve_root=134217,resgid=1065,inlinecrypt wait,check,formattable,quota,latemount,resize,reservedsize=128m,checkpoint=fs,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,fsverity
/dev/block/by-name/protect1 /mnt/vendor/protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable
/dev/block/by-name/protect2 /mnt/vendor/protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable
/dev/block/by-name/nvdata /mnt/vendor/nvdata ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable
/dev/block/by-name/nvcfg /mnt/vendor/nvcfg ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable
/dev/block/by-name/persist /mnt/vendor/persist ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable
/devices/platform/soc/11240000.mmc* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
/devices/platform/usb_xhci* auto vfat defaults voldmanaged=usbotg:auto
/devices/platform/soc/11201000.usb0/11200000.xhci* auto vfat defaults voldmanaged=usbotg:auto
/dev/block/by-name/frp /persistent emmc defaults defaults
/dev/block/by-name/nvram /nvram emmc defaults defaults
/dev/block/by-name/proinfo /proinfo emmc defaults defaults
/dev/block/by-name/lk1 /lk1 emmc defaults defaults
/dev/block/by-name/bootloader2 /bootloader2 emmc defaults defaults
/dev/block/by-name/para /para emmc defaults defaults
/dev/block/by-name/misc /misc emmc defaults defaults
/dev/block/by-name/init_boot /init_boot emmc defaults defaults
/dev/block/by-name/boot /boot emmc defaults first_stage_mount,nofail,slotselect
/dev/block/by-name/vbmeta_vendor /vbmeta_vendor emmc defaults first_stage_mount,nofail,slotselect
/dev/block/by-name/vbmeta_system /vbmeta_system emmc defaults first_stage_mount,nofail,slotselect,avb=vbmeta
/dev/block/by-name/logo /logo emmc defaults defaults
/dev/block/by-name/expdb /expdb emmc defaults defaults
/dev/block/by-name/seccfg /seccfg emmc defaults defaults
/dev/block/by-name/tee1 /tee1 emmc defaults defaults
/dev/block/by-name/tee2 /tee2 emmc defaults defaults
/dev/block/by-name/scp1 /scp1 emmc defaults defaults
/dev/block/by-name/scp2 /scp2 emmc defaults defaults
/dev/block/by-name/sspm1 /sspm1 emmc defaults defaults
/dev/block/by-name/sspm2 /sspm2 emmc defaults defaults
/dev/block/by-name/dpm1 /dpm1 emmc defaults defaults
/dev/block/by-name/dpm2 /dpm2 emmc defaults defaults
/dev/block/by-name/mcupm1 /mcupm1 emmc defaults defaults
/dev/block/by-name/mcupm2 /mcupm2 emmc defaults defaults
/dev/block/by-name/md1img /md1img emmc defaults defaults
/dev/block/by-name/md1dsp /md1dsp emmc defaults defaults
/dev/block/by-name/md1arm7 /md1arm7 emmc defaults defaults
/dev/block/by-name/md3img /md3img emmc defaults defaults
/dev/block/by-name/gz1 /gz1 emmc defaults defaults
/dev/block/by-name/gz2 /gz2 emmc defaults defaults
/dev/block/by-name/ccu /ccu emmc defaults defaults
/dev/block/by-name/vcp /vcp emmc defaults defaults
/dev/block/by-name/gpueb /gpueb emmc defaults defaults
/dev/block/by-name/mcf_ota /mcf_ota emmc defaults defaults
/dev/block/by-name/vendor_boot /vendor_boot emmc defaults defaults
/dev/block/by-name/mvpu_algo1 /mvpu_algo1 emmc defaults defaults
/dev/block/by-name/mvpu_algo2 /mvpu_algo2 emmc defaults defaults
/dev/block/by-name/apusys1 /apusys1 emmc defaults defaults
/dev/block/by-name/apusys2 /apusys2 emmc defaults defaults
/dev/block/by-name/spmfw /spmfw emmc defaults defaults
/dev/block/by-name/pi_img /pi_img emmc defaults defaults
/dev/block/by-name/boot_para /boot_para emmc defaults defaults
/dev/block/by-name/odmdtbo /odmdtbo emmc defaults defaults
/dev/block/by-name/dtbo /dtbo emmc defaults defaults
/dev/block/by-name/connsys_wifi /connsys_wifi emmc defaults defaults
/dev/block/by-name/connsys_bt /connsys_bt emmc defaults defaults
/dev/block/by-name/otp /otp emmc defaults defaults
/dev/block/by-name/vbmeta /vbmeta emmc defaults defaults