2018-04-10 16:33:33 +00:00
#!/system/bin/sh
2018-09-17 12:04:50 +00:00
vndk = " $( getprop persist.sys.vndk) "
2018-08-16 12:59:26 +00:00
setprop sys.usb.ffs.aio_compat true
2018-08-14 18:02:34 +00:00
2018-05-14 11:34:52 +00:00
fixSPL( ) {
2018-05-19 14:54:30 +00:00
if [ " $( getprop ro.product.cpu.abi) " = = "armeabi-v7a" ] ; then
setprop ro.keymaster.mod 'AOSP on ARM32'
else
setprop ro.keymaster.mod 'AOSP on ARM64'
fi
2018-06-08 17:13:08 +00:00
img = " $( find /dev/block -type l -name kernel$( getprop ro.boot.slot_suffix) | grep by-name | head -n 1) "
[ -z " $img " ] && img = " $( find /dev/block -type l -name boot$( getprop ro.boot.slot_suffix) | grep by-name | head -n 1) "
2018-05-14 11:34:52 +00:00
if [ -n " $img " ] ; then
#Rewrite SPL/Android version if needed
Arelease = " $( getSPL $img android) "
2018-05-19 14:54:30 +00:00
setprop ro.keymaster.xxx.release " $Arelease "
2018-05-14 11:34:52 +00:00
setprop ro.keymaster.xxx.security_patch " $( getSPL $img spl) "
2018-08-20 19:10:00 +00:00
for f in /vendor/lib64/hw/android.hardware.keymaster@3.0-impl-qti.so /vendor/lib/hw/android.hardware.keymaster@3.0-impl-qti.so /system/lib64/vndk-26/libsoftkeymasterdevice.so /vendor/bin/teed /system/lib64/vndk/libsoftkeymasterdevice.so /system/lib/vndk/libsoftkeymasterdevice.so /system/lib/vndk-26/libsoftkeymasterdevice.so; do
2018-05-14 11:34:52 +00:00
[ ! -f $f ] && continue
2018-05-19 14:54:30 +00:00
ctxt = " $( ls -lZ $f | grep -oE 'u:object_r:[^:]*:s0' ) "
2018-05-26 09:26:33 +00:00
b = " $( echo " $f " | tr / _) "
2018-05-14 11:34:52 +00:00
2018-05-19 14:54:30 +00:00
cp -a $f /mnt/phh/$b
sed -i \
-e 's/ro.build.version.release/ro.keymaster.xxx.release/g' \
-e 's/ro.build.version.security_patch/ro.keymaster.xxx.security_patch/g' \
-e 's/ro.product.model/ro.keymaster.mod/g' \
/mnt/phh/$b
chcon " $ctxt " /mnt/phh/$b
mount -o bind /mnt/phh/$b $f
2018-05-14 11:34:52 +00:00
done
2018-05-19 16:43:25 +00:00
if [ " $( getprop init.svc.keymaster-3-0) " = = "running" ] ; then
setprop ctl.restart keymaster-3-0
fi
if [ " $( getprop init.svc.teed) " = = "running" ] ; then
setprop ctl.restart teed
fi
2018-05-14 11:34:52 +00:00
fi
}
2018-09-03 12:58:11 +00:00
changeKeylayout( ) {
cp -a /system/usr/keylayout /mnt/phh/keylayout
changed = false
if getprop ro.vendor.build.fingerprint | \
grep -qE -e ".*(crown|star)[q2]*lte.*" -e ".*(SC-0[23]K|SCV3[89]).*" ; then
changed = true
cp /system/phh/samsung-gpio_keys.kl /mnt/phh/keylayout/gpio_keys.kl
cp /system/phh/samsung-sec_touchscreen.kl /mnt/phh/keylayout/sec_touchscreen.kl
chmod 0644 /mnt/phh/keylayout/gpio_keys.kl /mnt/phh/keylayout/sec_touchscreen.kl
fi
2018-09-16 09:00:49 +00:00
if getprop ro.vendor.build.fingerprint | grep -iq -e xiaomi/polaris -e xiaomi/sirius -e xiaomi/dipper; then
2018-09-03 13:06:54 +00:00
cp /system/phh/empty /mnt/phh/keylayout/uinput-goodix.kl
chmod 0644 /mnt/phh/keylayout/uinput-goodix.kl
changed = true
fi
2018-09-09 22:32:11 +00:00
if [ " $( getprop ro.vendor.product.device) " = = "OnePlus6" ] ; then
cp /system/phh/oneplus6-synaptics_s3320.kl /mnt/phh/keylayout/synaptics_s3320.kl
chmod 0644 /mnt/phh/keylayout/synaptics_s3320.kl
changed = true
fi
2018-09-03 12:58:11 +00:00
if [ " $changed " = = true ] ; then
mount -o bind /mnt/phh/keylayout /system/usr/keylayout
restorecon -R /system/usr/keylayout
fi
}
2018-04-24 20:36:59 +00:00
if mount -o remount,rw /system; then
2018-05-19 20:07:12 +00:00
resize2fs $( grep ' /system ' /proc/mounts | cut -d ' ' -f 1) || true
2018-04-24 20:36:59 +00:00
elif mount -o remount,rw /; then
2018-05-19 20:07:12 +00:00
resize2fs /dev/root || true
2018-04-10 16:33:33 +00:00
fi
2018-05-19 20:07:12 +00:00
mount -o remount,ro /system || true
mount -o remount,ro / || true
2018-04-10 16:33:33 +00:00
2018-08-29 16:30:35 +00:00
mkdir -p /mnt/phh/
mount -t tmpfs -o rw,nodev,relatime,mode= 755,gid= 0 none /mnt/phh || true
2018-09-04 17:35:16 +00:00
mkdir /mnt/phh/empty_dir
2018-05-14 11:34:52 +00:00
fixSPL
2018-04-24 20:36:59 +00:00
2018-09-03 12:58:11 +00:00
changeKeylayout
2018-04-30 11:56:06 +00:00
if grep vendor.huawei.hardware.biometrics.fingerprint /vendor/manifest.xml; then
mount -o bind system/phh/huawei/fingerprint.kl /vendor/usr/keylayout/fingerprint.kl
fi
2018-05-14 11:34:52 +00:00
2018-05-18 13:09:30 +00:00
if ! grep android.hardware.biometrics.fingerprint /vendor/manifest.xml; then
mount -o bind system/phh/empty /system/etc/permissions/android.hardware.fingerprint.xml
fi
2018-06-10 20:54:14 +00:00
if getprop ro.hardware | grep -qF qcom && [ -f /sys/class/backlight/panel0-backlight/max_brightness ] && \
grep -qvE '^255$' /sys/class/backlight/panel0-backlight/max_brightness; then
setprop persist.sys.qcom-brightness $( cat /sys/class/backlight/panel0-backlight/max_brightness)
fi
2018-06-15 13:03:02 +00:00
if [ " $( getprop ro.vendor.product.device) " = = "OnePlus6" ] ; then
resize2fs /dev/block/platform/soc/1d84000.ufshc/by-name/userdata
fi
2018-07-01 21:00:28 +00:00
2018-07-01 22:22:27 +00:00
if getprop ro.vendor.build.fingerprint | grep -q full_k50v1_64 || getprop ro.hardware | grep -q mt6580 ; then
2018-07-01 21:00:28 +00:00
setprop persist.sys.overlay.nightmode false
fi
2018-07-01 21:06:11 +00:00
2018-07-01 22:22:27 +00:00
if getprop ro.wlan.mtk.wifi.5g | grep -q 1; then
2018-07-01 21:06:11 +00:00
setprop persist.sys.overlay.wifi5g true
fi
2018-07-17 16:02:41 +00:00
if grep -qF 'mkdir /data/.fps 0770 system fingerp' vendor/etc/init/hw/init.mmi.rc; then
mkdir -p /data/.fps
chmod 0770 /data/.fps
chown system:9015 /data/.fps
chown system:9015 /sys/devices/soc/soc:fpc_fpc1020/irq
chown system:9015 /sys/devices/soc/soc:fpc_fpc1020/irq_cnt
fi
2018-08-27 08:25:27 +00:00
2018-09-04 18:16:14 +00:00
if getprop ro.vendor.build.fingerprint | grep -q -e Xiaomi/clover/clover -e iaomi/wayne/wayne; then
2018-08-29 14:34:14 +00:00
setprop persist.sys.qcom-brightness $( cat /sys/class/leds/lcd-backlight/max_brightness)
fi
2018-09-07 03:41:57 +00:00
if getprop ro.vendor.build.fingerprint | grep -q -e Xiaomi/beryllium/beryllium -e Xiaomi/sirius/sirius -e Xiaomi/dipper/dipper -e Xiaomi/ursa/ursa -e Xiaomi/polaris/polaris; then
2018-09-08 03:35:40 +00:00
mount -o bind /mnt/phh/empty_dir /vendor/lib64/soundfx
mount -o bind /mnt/phh/empty_dir /vendor/lib/soundfx
2018-09-04 17:35:16 +00:00
fi
2018-08-29 16:30:35 +00:00
for f in /vendor/lib/mtk-ril.so /vendor/lib64/mtk-ril.so; do
[ ! -f $f ] && continue
ctxt = " $( ls -lZ $f | grep -oE 'u:object_r:[^:]*:s0' ) "
b = " $( echo " $f " | tr / _) "
cp -a $f /mnt/phh/$b
sed -i \
-e 's/AT+EAIC=2/AT+EAIC=3/g' \
/mnt/phh/$b
chcon " $ctxt " /mnt/phh/$b
mount -o bind /mnt/phh/$b $f
done
2018-08-27 08:25:27 +00:00
mount -o bind /system/phh/empty /vendor/overlay/SysuiDarkTheme/SysuiDarkTheme.apk || true
2018-09-04 17:35:16 +00:00
2018-09-06 18:46:30 +00:00
if grep -qF 'PowerVR Rogue GE8100' /vendor/lib/egl/GLESv1_CM_mtk.so; then
setprop debug.hwui.renderer opengl
fi
2018-09-04 17:35:16 +00:00
2018-09-09 19:38:33 +00:00
#If we have both Samsung and AOSP power hal, take Samsung's
if [ -f /vendor/bin/hw/vendor.samsung.hardware.miscpower@1.0-service ] ; then
mount -o bind /system/phh/empty /vendor/bin/hw/android.hardware.power@1.0-service
fi
2018-09-17 12:04:50 +00:00
if [ " $vndk " = = 27 -o " $vndk " = = 26 ] ; then
mount -o bind /system/phh/libnfc-nci-oreo.conf /system/etc/libnfc-nci.conf
fi
2018-09-17 14:18:55 +00:00
if busybox_phh unzip -p /vendor/app/ims/ims.apk classes.dex | grep -qF -e Landroid/telephony/ims/feature/MmTelFeature -e Landroid/telephony/ims/feature/MMTelFeature; then
mount -o bind /system/phh/empty /vendor/app/ims/ims.apk
fi