This commit is contained in:
Tad 2017-06-01 16:44:52 -04:00
parent 65320ccc2d
commit d9c0a95a3c
2 changed files with 35 additions and 21 deletions

View File

@ -2,7 +2,7 @@
#Goal: Remove as many proprietary blobs without breaking core functionality
#Outcome: Increased battery/performance/privacy/security, Decreased ROM size
#TODO: Clean init*.rc files, Create TWRP version, Remove more variants
#TODO: Clean init*.rc files, Create TWRP version, Modularize, Remove more variants
#
#Device Status (Tested under LineageOS 14.1 and 11.0)
@ -134,8 +134,11 @@ export base;
#Thermal Throttling [Qualcomm]
#blobs=$blobs"|libthermalclient.so|libthermalioctl.so|thermal-engine";
#Time Service [Qualcomm] XXX: Requires that https://github.com/LineageOS/android_hardware_sony_timekeep be included in repo manifest
#blobs=$blobs"|libtime_genoff.so"; #The radio needs this
#Time Service [Qualcomm]
#XXX: Requires that https://github.com/LineageOS/android_hardware_sony_timekeep be included in repo manifest
#XXX: This is another aggressive change and might be disabled in the future
#XXX: Time seems to be set properly with these blobs removed without Sony TimeKeep, so there may be more shenanigans here
#blobs=$blobs"|libtime_genoff.so"; #XXX: Breaks radio
blobs=$blobs"|libTimeService.so|time_daemon|TimeService.apk";
#Venus (Hardware Video Decoding) [Qualcomm]
@ -173,6 +176,9 @@ export base;
deblobDevice() {
devicePath=$1;
cd $base$devicePath;
if [ "${PWD##*/}" == "flo" ] || [ "${PWD##*/}" == "mako" ]; then #Older devices don't seem to use time_daemon TODO: Automate or extend this
replaceTime="false";
fi;
if [ -f Android.mk ]; then
sed -i '/ALL_DEFAULT_INSTALLED_MODULES/s/$(CMN_SYMLINKS)//' Android.mk; #Remove CMN firmware
sed -i '/ALL_DEFAULT_INSTALLED_MODULES/s/$(DXHDCP2_SYMLINKS)//' Android.mk; #Remove Discretix firmware
@ -182,24 +188,30 @@ deblobDevice() {
sed -i '/ALL_DEFAULT_INSTALLED_MODULES/s/$(WV_SYMLINKS)//' Android.mk; #Remove Google Widevine firmware
fi;
if [ -f BoardConfig.mk ]; then
sed -i 's/BOARD_USES_QC_TIME_SERVICES := true/BOARD_USES_QC_TIME_SERVICES := false/' BoardConfig.mk; #Switch to Sony TimeKeep
if ! grep -q "BOARD_USES_QC_TIME_SERVICES := false" BoardConfig.mk; then echo "BOARD_USES_QC_TIME_SERVICES := false" >> BoardConfig.mk; fi; #Switch to Sony TimeKeep
if [ -z "$replaceTime" ]; then
sed -i 's/BOARD_USES_QC_TIME_SERVICES := true/BOARD_USES_QC_TIME_SERVICES := false/' BoardConfig.mk; #Switch to Sony TimeKeep
if ! grep -q "BOARD_USES_QC_TIME_SERVICES := false" BoardConfig.mk; then echo "BOARD_USES_QC_TIME_SERVICES := false" >> BoardConfig.mk; fi; #Switch to Sony TimeKeep
fi;
sed -i 's/BOARD_USES_QCNE := true/BOARD_USES_QCNE := false/' BoardConfig.mk; #Disable CNE
sed -i 's/BOARD_USES_WIPOWER := true/BOARD_USES_WIPOWER := false/' BoardConfig.mk; #Disable WiPower
fi;
if [ -f device.mk ]; then
awk -i inplace '!/'$makes'/' device.mk; #Remove all shim references from device makefile
#Switch to Sony TimeKeep
echo "PRODUCT_PACKAGES += \\" >> device.mk;
echo " timekeep \\" >> device.mk;
echo " TimeKeep" >> device.mk;
if [ -z "$replaceTime" ]; then
#Switch to Sony TimeKeep
echo "PRODUCT_PACKAGES += \\" >> device.mk;
echo " timekeep \\" >> device.mk;
echo " TimeKeep" >> device.mk;
fi;
fi;
if [ -f "${PWD##*/}".mk ] && [ "${PWD##*/}".mk != "sepolicy" ]; then
awk -i inplace '!/'$makes'/' "${PWD##*/}".mk; #Remove all shim references from device makefile
#Switch to Sony TimeKeep
echo "PRODUCT_PACKAGES += \\" >> device.mk;
echo " timekeep \\" >> device.mk;
echo " TimeKeep" >> device.mk;
if [ -z "$replaceTime" ]; then
#Switch to Sony TimeKeep
echo "PRODUCT_PACKAGES += \\" >> "${PWD##*/}".mk;
echo " timekeep \\" >> "${PWD##*/}".mk;
echo " TimeKeep" >> "${PWD##*/}".mk;
fi;
fi;
if [ -f system.prop ]; then
sed -i 's/drm.service.enabled=true/drm.service.enabled=false/' system.prop;
@ -207,7 +219,7 @@ deblobDevice() {
sed -i 's/persist.bt.enableAptXHD=true/persist.bt.enableAptXHD=false/' system.prop; #Disable aptX
sed -i 's/persist.cne.feature=./persist.cne.feature=0/' system.prop; #Disable CNE
sed -i 's/persist.dpm.feature=./persist.dpm.feature=0/' system.prop; #Disable DPM
sed -i 's/persist.gps.qc_nlp_in_use=1/persist.gps.qc_nlp_in_use=0/' system.prop; #Disable QC Location Provider
sed -i 's/persist.gps.qc_nlp_in_use=./persist.gps.qc_nlp_in_use=0/' system.prop; #Disable QC Location Provider
sed -i 's/persist.sys.dpmd.nsrm=./persist.sys.dpmd.nsrm=0/' system.prop; #Disable DPM
sed -i 's/ro.bluetooth.emb_wp_mode=true/ro.bluetooth.emb_wp_mode=false/' system.prop; #Disable WiPower
sed -i 's/ro.bluetooth.wipower=true/ro.bluetooth.wipower=false/' system.prop; #Disable WiPower
@ -244,13 +256,15 @@ deblobDevice() {
sed -i 's|<bool name="config_device_vt_available">true</bool>|<bool name="config_device_vt_available">false</bool>|' overlay/frameworks/base/core/res/res/values/config.xml;
sed -i 's|<bool name="config_device_wfc_ims_available">true</bool>|<bool name="config_device_wfc_ims_available">false</bool>|' overlay/frameworks/base/core/res/res/values/config.xml;
fi;
if [ -d sepolicy ] && [ "${PWD##*/}".mk != "flo" ]; then
#Switch to Sony TimeKeep
echo "allow system_app time_data_file:dir { create_dir_perms search };" >> sepolicy/system_app.te;
echo "allow system_app time_data_file:file create_file_perms;" >> sepolicy/system_app.te;
if [ -d sepolicy ]; then
if [ -z "$replaceTime" ]; then
#Switch to Sony TimeKeep
echo "allow system_app time_data_file:dir { create_dir_perms search };" >> sepolicy/system_app.te;
echo "allow system_app time_data_file:file create_file_perms;" >> sepolicy/system_app.te;
fi;
fi;
sed -i 's|service time_daemon /system/bin/time_daemon|service timekeep /system/bin/timekeep restore\n oneshot|' init.*.rc rootdir/init.*.rc rootdir/etc/init.*.rc &> /dev/null || true; #Switch to Sony TimeKeep
rm -f rootdir/etc/init.qti.ims.sh #Remove IMS startup script
if [ -z "$replaceTime" ]; then sed -i 's|service time_daemon /system/bin/time_daemon|service timekeep /system/bin/timekeep restore\n oneshot|' init.*.rc rootdir/init.*.rc rootdir/etc/init.*.rc &> /dev/null || true; fi; #Switch to Sony TimeKeep
rm -f rootdir/etc/init.qti.ims.sh rootdir/init.qti.ims.sh init.qti.ims.sh; #Remove IMS startup script
rm -rf IMSEnabler; #Remove IMS compatibility module
rm -rf data-ipa-cfg-mgr; #Remove IPACM
rm -rf libshimwvm; #Remove Google Widevine compatibility module

View File

@ -23,7 +23,7 @@ ANDROID_HOME="/home/$USER/Android/Sdk"
mkdir -p /tmp/ar
cd /tmp/ar
wget https://spotco.us/hosts -N #XXX: /hosts is built from non-commercial use files, switch to /hsc for release
wget https://github.com/Ranks/emojione/raw/master/extras/fonts/emojione-android.ttf -N #XXX: Requires attribuition
wget https://github.com/emojione/emojione/raw/master/extras/fonts/emojione-android.ttf -N #XXX: Requires attribuition
#Accept all SDK licences, not normally needed but Gradle managed apps fail without it
mkdir -p "$ANDROID_HOME/licenses"