2017-02-15 22:06:25 +00:00
#!/bin/bash
2017-02-15 22:15:00 +00:00
#Goal: Remove as many proprietary blobs without breaking core functionality
#Outcome: Increased battery/performance/privacy/security, Decreased ROM size
2017-03-15 10:22:24 +00:00
#TODO: Automate TimeKeep replacing, Clean init*.rc files, Create TWRP version, Remove more variants
2017-02-15 22:15:00 +00:00
#
#Device Status (Tested under LineageOS 14.1)
#
#Fully Functional: bacon, clark
#LTE Broken (Potentially Unrelated): mako
2017-02-15 22:06:25 +00:00
base = "/home/tad/Android/Build/LineageOS-14.1/" ;
export base;
#
#START OF BLOBS ARRAY
#
blobs = "" ;
2017-02-21 17:24:14 +00:00
#ACDB (Audio Configurations) XXX: Breaks audio output
#blobs=$blobs"acdb";
#ADSP/Hexagon (Hardware Audio Decoding)
#blobs=$blobs"adsprpcd|libadsprpc.so|libadsprpc.so|libfastcvadsp_stub.so|libfastcvopt.so|libadsp_fd_skel.so";
2017-02-19 22:58:45 +00:00
#Alipay (Alibaba Payment Platform)
blobs = $blobs "alipay.b00|alipay.b01|alipay.b02|alipay.b03|alipay.b04|alipay.b05|alipay.b06|alipay.mdt" ;
2017-02-19 22:45:27 +00:00
#aptX (Bluetooth Audio Compression Codec)
2017-02-19 22:58:45 +00:00
blobs = $blobs "|libaptX-1.0.0-rel-Android21-ARMv7A.so|libaptXHD-1.0.0-rel-Android21-ARMv7A.so|libaptXScheduler.so" ;
2017-02-19 22:45:27 +00:00
2017-02-15 22:06:25 +00:00
#ATFWD (Miracast/Wireless Display)
2017-02-19 22:45:27 +00:00
blobs = $blobs "|ATFWD-daemon|atfwd.apk" ;
2017-02-15 22:06:25 +00:00
2017-02-21 20:52:15 +00:00
#AudioFX (Audio Effects)
blobs = $blobs "|libqcbassboost.so|libqcreverb.so|libqcvirt.so" ;
2017-02-21 17:58:19 +00:00
2017-02-21 17:24:14 +00:00
#Camera XXX: I tried, don't waste your time...
2017-02-21 17:58:19 +00:00
#FUN FACT: The Huawei Honor 5x ships with eight-hundred-and-thirty-five (*835*) proprietary camera blobs.
2017-02-21 17:24:14 +00:00
#blobs=$blobs"|";
2017-02-19 22:58:45 +00:00
2017-02-16 01:52:03 +00:00
#Clearkey (DRM)
blobs = $blobs "|libdrmclearkeyplugin.so" ;
2017-02-19 22:58:45 +00:00
#CMN (DRM)
blobs = $blobs "|cmnlib.b00|cmnlib.b01|cmnlib.b02|cmnlib.b03|cmnlib.b04|cmnlib.b05|cmnlib.mdt|cmnlib64.b00|cmnlib64.b01|cmnlib64.b02|cmnlib64.b03|cmnlib64.b04|cmnlib64.b05|cmnlib64.mdt" ;
2017-02-15 22:06:25 +00:00
#CNE (Automatic Cell/Wi-Fi Switching)
2017-02-22 11:28:02 +00:00
#blobs=$blobs"|libcneapiclient.so"; #XXX: Breaks radio
2017-02-15 22:06:25 +00:00
blobs = $blobs "|andsfCne.xml|ATT_profile1.xml|ATT_profile2.xml|ATT_profile3.xml|ATT_profile4.xml|ATT_profiles.xml|cnd|cneapiclient.jar|cneapiclient.xml|CNEService.apk|com.quicinc.cne.jar|com.quicinc.cne.xml|ConnectivityExt.jar|ConnectivityExt.xml|libcneconn.so|libcneqmiutils.so|libcne.so|libNimsWrap.so|libvendorconn.so|libwqe.so|profile1.xml|profile2.xml|profile3.xml|profile4.xml|profile5.xml|ROW_profile1.xml|ROW_profile2.xml|ROW_profile3.xml|ROW_profile4.xml|ROW_profile5.xml|ROW_profiles.xml|SwimConfig.xml|VZW_profile1.xml|VZW_profile2.xml|VZW_profile3.xml|VZW_profile4.xml|VZW_profile5.xml|VZW_profile6.xml|VZW_profiles.xml" ;
#Diagnostics
blobs = $blobs "|[/]diag[/]|diag_callback_client|diag_dci_sample|diag_klog|diag_mdlog|diag_mdlog-getlogs|diag_mdlog-wrap|diag[/]mdm|diag_qshrink4_daemon|diag_socket_log|diag_uart_log|drmdiagapp|ibdrmdiag.so|ssr_diag|test_diag" ;
#Discretix (DRM/HDCP)
blobs = $blobs "|discretix|DxHDCP.cfg|dxhdcp2.b00|dxhdcp2.b01|dxhdcp2.b02|dxhdcp2.b03|dxhdcp2.mdt|libDxHdcp.so" ;
2017-02-22 10:01:46 +00:00
#Display Color Tuning
2017-02-22 07:17:10 +00:00
blobs = $blobs "|libdisp-aba.so|libmm-abl-oem.so|libmm-abl.so|libmm-als.so|libmm-color-convertor.so|libmm-disp-apis.so|libmm-qdcm.so|libsd_sdk_display.so|mm-pp-daemon" ;
2017-02-21 17:58:19 +00:00
2017-02-15 22:06:25 +00:00
#DivX (DRM)
blobs = $blobs "|libDivxDrm.so|libSHIMDivxDrm.so" ;
#DPM (Data Power Management)
blobs = $blobs "|com.qti.dpmframework.jar|com.qti.dpmframework.xml|dpmapi.jar|dpmapi.xml|dpm.conf|dpmd|dpmserviceapp.apk|libdpmctmgr.so|libdpmfdmgr.so|libdpmframework.so|libdpmnsrm.so|libdpmtcm.so|NsrmConfiguration.xml|tcmclient.jar" ;
2017-02-26 04:55:50 +00:00
#DRM
#blobs=$blobs"|libdrmdecrypt.so|libdrmfs.so|libdrmtime.so|libtzdrmgenprov.so"; #XXX: Breaks full disk encryption
blobs = $blobs "|lib-sec-disp.so|libSecureUILib.so|libsecureui.so|libsecureuisvc_jni.so|libsecureui_svcsock.so" ;
2017-02-15 22:06:25 +00:00
#Google Project Fi
blobs = $blobs "|Tycho.apk" ;
#Google Widevine (DRM)
2017-02-19 23:16:41 +00:00
blobs = $blobs "|com.google.widevine.software.drm.jar|com.google.widevine.software.drm.xml|libdrmwvmplugin.so|libwvdrmengine.so|libwvdrm_L1.so|libwvdrm_L3.so|libwvm.so|libWVphoneAPI.so|libWVStreamControlAPI_L1.so|libWVStreamControlAPI_L3.so|tzwidevine.b00|tzwidevine.b01|tzwidevine.b02|tzwidevine.b03|tzwidevine.mdt|widevine.b00|widevine.b01|widevine.b02|widevine.b03|widevine.b04|widevine.b05|widevine.b06|widevine.mbn|widevine.mdt" ;
2017-02-15 22:06:25 +00:00
2017-02-19 23:46:42 +00:00
#GPS
2017-02-15 22:06:25 +00:00
#blobs=$blobs"|flp.conf|flp.default.so|flp.msm8084.so|flp.msm8960.so|gpsd|gps.msm8084.so|gps.msm8960.so|libflp.so|libgps.utils.so|libloc_api_v02.so|libloc_core.so|libloc_ds_api.so|libloc_eng.so|libloc_ext.so";
#HDCP (DRM)
2017-02-19 23:16:41 +00:00
blobs = $blobs "|libmm-hdcpmgr.so|hdcp1.b00|hdcp1.b01|hdcp1.b02|hdcp1.b03|hdcp1.b04|hdcp1.b05|hdcp1.b06|hdcp1.mdt|tzhdcp.b00|tzhdcp.b01|tzhdcp.b02|tzhdcp.b03|tzhdcp.mdt" ;
2017-02-15 22:06:25 +00:00
2017-02-19 22:45:27 +00:00
#HTC
2017-02-20 00:16:10 +00:00
blobs = $blobs "|htc_drmprov.b00|htc_drmprov.b01|htc_drmprov.b02|htc_drmprov.b03|htc_drmprov.b04|htc_drmprov.b05|htc_drmprov.b06|htc_drmprov.mdt|gptauuid.xml|gpsample.mbn" ;
2017-02-19 22:45:27 +00:00
2017-02-22 10:01:46 +00:00
#I/O Prefetcher
2017-02-22 07:17:10 +00:00
blobs = $blobs "|iop|libqti-iop-client.so|libqti-iop.so" ;
2017-02-21 17:58:19 +00:00
2017-02-15 22:06:25 +00:00
#IPACM (Loadbalances traffic between Cell/Wi-Fi)
blobs = $blobs "|ipacm|ipacm-diag" ;
#Location (gpsOne/gpsOneXTRA/IZat/Lumicast/QUIP)
2017-02-19 23:16:41 +00:00
blobs = $blobs "|com.qti.location.sdk.jar|com.qti.location.sdk.xml|com.qualcomm.location.apk|com.qualcomm.location.vzw_library.jar|com.qualcomm.location.vzw_library.xml|com.qualcomm.location.xml|gpsone_daemon|izat.conf|izat.xt.srv.jar|izat.xt.srv.xml|libalarmservice_jni.so|libasn1cper.so|libasn1crt.so|libasn1crtx.so|libdataitems.so|libdrplugin_client.so|libDRPlugin.so|libevent_observer.so|libgdtap.so|libgeofence.so|libizat_core.so|liblbs_core.so|liblocationservice_glue.so|liblocationservice.so|libloc_ext.so|libloc_xtra.so|liblowi_client.so|liblowi_wifihal_nl.so|liblowi_wifihal.so|libquipc_os_api.so|libquipc_ulp_adapter.so|libulp2.so|libxtadapter.so|libxt_native.so|libxtwifi_ulp_adaptor.so|libxtwifi_zpp_adaptor.so|location-mq|loc_launcher|lowi.conf|lowi-server|slim_ap_daemon|slim_daemon|xtra_t_app.apk|xtwifi-client|xtwifi-inet-agent" ;
2017-02-15 22:06:25 +00:00
#Microsoft Playready (DRM)
blobs = $blobs "|playread.b00|playread.b01|playread.b02|playread.b03|playread.mdt" ;
#Misc
2017-02-21 17:04:27 +00:00
blobs = $blobs "|libjni_latinime.so|libuiblur.so|libwifiscanner.so" ;
2017-02-15 22:06:25 +00:00
#Motorola
2017-02-21 17:04:27 +00:00
blobs = $blobs "|AppDirectedSMSProxy.apk|BuaContactAdapter.apk|com.motorola.DirectedSMSProxy.xml|com.motorola.motosignature.jar|com.motorola.motosignature.xml|com.motorola.camera.xml|com.motorola.gallery.xml|com.motorola.triggerenroll.xml|MotoSignatureApp.apk|TriggerEnroll.apk|TriggerTrainingService.apk" ;
2017-02-15 22:06:25 +00:00
2017-02-21 17:58:19 +00:00
#Performance Profiles
#blobs=$blobs"|libqc-opt.so|libqti-perfd-client.so|mpdecision|msm_irqbalance|perfd|perf-profile0.conf|perf-profile1.conf|perf-profile2.conf|perf-profile3.conf|perf-profile4.conf|perf-profile5.conf";
2017-02-15 22:06:25 +00:00
#QTI (Tethering Extensions)
2017-02-19 23:16:41 +00:00
blobs = $blobs "|libQtiTether.so|QtiTetherService.apk" ;
2017-02-15 22:06:25 +00:00
#Sprint
blobs = $blobs "|com.android.omadm.service.xml|ConnMO.apk|CQATest.apk|DCMO.apk|DiagMon.apk|DMConfigUpdate.apk|DMService.apk|GCS.apk|HiddenMenu.apk|libdmengine.so|libdmjavaplugin.so|LifetimeData.apk|SprintDM.apk|SprintHM.apk|whitelist_com.android.omadm.service.xml" ;
2017-02-21 17:58:19 +00:00
#Thermal Throttling
#blobs=$blobs"|libthermalclient.so|libthermalioctl.so|thermal-engine";
2017-02-15 22:06:25 +00:00
#Time Service XXX: Breaks time, can be replaced with https://github.com/LineageOS/android_hardware_sony_timekeep
#blobs=$blobs"|libtime_genoff.so|libTimeService.so|time_daemon|TimeService.apk";
2017-02-19 23:46:42 +00:00
#Venus (Hardware Video Decoding)
#blobs=$blobs"|venus.b00|venus.b01|venus.b02|venus.b03|venus.b04|venus.mbn|venus.mdt";
2017-02-15 22:06:25 +00:00
#Verizon
2017-02-16 04:36:15 +00:00
blobs = $blobs "|com.verizon.apn.xml|com.verizon.embms.xml|com.verizon.provider.xml|VerizonUnifiedSettings.jar|VZWAPNLib.apk|VZWAPNService.apk|VZWAVS.apk|VzwLcSilent.apk|vzw_msdc_api.apk|VzwOmaTrigger.apk|vzw_sso_permissions.xml|com.vzw.vzwapnlib.xml|qti-vzw-ims-internal.xml" ;
2017-02-15 22:06:25 +00:00
#Voice Recognition
2017-02-21 17:24:14 +00:00
blobs = $blobs "|aonvr1.bin|aonvr2.bin|audiomonitor|es305_fw.bin|HotwordEnrollment.apk|libadpcmdec.so|liblistenhardware.so|liblistenjni.so|liblisten.so|liblistensoundmodel.so|librecoglib.so|libsmwrapper.so|libsupermodel.so|libtrainingcheck.so|sound_trigger.primary.msm8916.so|sound_trigger.primary.msm8996.so" ;
2017-02-15 22:06:25 +00:00
export blobs;
#
#END OF BLOBS ARRAY
#
#
#START OF FUNCTIONS
#
deblobDevice( ) {
devicePath = $1 ;
cd $base $devicePath ;
2017-03-15 10:22:24 +00:00
if [ -f Android.mk ] ; then
sed -i 's/$(PLAYREADY_SYMLINKS)//' Android.mk; #Don't ship Microsoft Playready (DRM) firmware
sed -i 's/$(WV_SYMLINKS)//' Android.mk; #Don't ship Google Widevine (DRM) firmware
fi ;
2017-02-15 22:06:25 +00:00
if [ -f BoardConfig.mk ] ; then
2017-02-15 22:15:00 +00:00
sed -i 's/BOARD_USES_QCNE := true/BOARD_USES_QCNE := false/' BoardConfig.mk; #Disable CNE
2017-02-15 22:06:25 +00:00
fi ;
if [ -f system.prop ] ; then
2017-02-19 23:46:42 +00:00
sed -i 's/persist.bt.enableAptXHD=true/persist.bt.enableAptXHD=false/' system.prop; #Disable aptX
2017-02-15 22:15:00 +00:00
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
if ! grep -q "drm.service.enabled=false" system.prop; then echo "drm.service.enabled=false" >> system.prop; fi ; #Disable DRM server
2017-02-15 22:06:25 +00:00
fi ;
rm -rf data-ipa-cfg-mgr; #Remove the second half of IPACM
2017-03-15 10:22:24 +00:00
rm -rf libshimwvm; #Remove the Google Widevine (DRM) compatibility module
2017-02-15 22:06:25 +00:00
if [ -f setup-makefiles.sh ] ; then
awk -i inplace '!/' $blobs '/' *proprietary*.txt; #Remove all blob references from blob manifest
sh -c " cd $base $devicePath && ./setup-makefiles.sh " ; #Update the makefiles
fi ;
cd $base ;
}
export -f deblobDevice;
deblobVendors( ) {
cd $base ;
2017-02-15 22:15:00 +00:00
find vendor -regextype posix-extended -regex '.*(' $blobs ')' -type f -delete; #Delete all blobs
2017-02-15 22:06:25 +00:00
}
deblobVendor( ) {
makefile = $1 ;
cd $base ;
awk -i inplace '!/' $blobs '/' $makefile ; #Remove all blob references from makefile
}
export -f deblobVendor;
#
#END OF FUNCTIONS
#
#
#START OF DEBLOBBING
#
2017-02-22 07:17:10 +00:00
echo "vendor/lib/libcneapiclient.so" >> device/oneplus/bacon/proprietary-files-qc.txt; #Commit b7b6d94529e17ce51566aa6509cebab6436b153d disabled CNE but left this binary in the makefile vendor since NetMgr requires it. Without this line rerunning setup-makefiles.sh breaks cell service, since the resulting build will be missing it.
2017-02-15 22:06:25 +00:00
find device -maxdepth 2 -mindepth 2 -type d -exec bash -c 'deblobDevice "$0"' { } \; #Deblob all device directories
find vendor -name "*vendor*.mk" -type f -exec bash -c 'deblobVendor "$0"' { } \; #Deblob all makefiles
deblobVendors; #Deblob entire vendor directory
2017-02-25 16:26:01 +00:00
rm -rf frameworks/av/drm/mediadrm/plugins/clearkey; #Remove the rest of Clearkey DRM
2017-02-15 22:06:25 +00:00
#
#END OF DEBLOBBING
#