From 5463eae0fc2168df21e47356714f409b13aa8b5e Mon Sep 17 00:00:00 2001 From: Davide Garberi Date: Wed, 15 May 2019 17:27:36 +0200 Subject: [PATCH] msm8996-common: Correct BT mac address with non zui blobs Change-Id: Ibc6eed2018314e79f3f18749cedd9852c82a8a66 --- msm8996.mk | 2 +- rootdir/Android.mk | 4 ++-- rootdir/bin/{init.wlan.sh => init.mac.sh} | 8 ++++++++ rootdir/etc/init.qcom.rc | 13 +++++++++---- sepolicy/file_contexts | 2 +- sepolicy/hal_bluetooth_qti.te | 2 ++ sepolicy/property.te | 1 + sepolicy/property_contexts | 3 +++ sepolicy/qti_init_shell.te | 5 +++++ sepolicy/system_app.te | 1 + 10 files changed, 33 insertions(+), 8 deletions(-) rename rootdir/bin/{init.wlan.sh => init.mac.sh} (75%) diff --git a/msm8996.mk b/msm8996.mk index d256e6714..cba163e07 100755 --- a/msm8996.mk +++ b/msm8996.mk @@ -149,7 +149,7 @@ PRODUCT_PACKAGES += \ init.qcom.sh \ init.qcom.power.rc \ init.qcom.usb.rc \ - init.wlan.sh \ + init.mac.sh \ ueventd.qcom.rc # ConfigPanel diff --git a/rootdir/Android.mk b/rootdir/Android.mk index c7b6f0a35..e0b67552a 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -11,10 +11,10 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) include $(BUILD_PREBUILT) include $(CLEAR_VARS) -LOCAL_MODULE := init.wlan.sh +LOCAL_MODULE := init.mac.sh LOCAL_MODULE_TAGS := optional eng LOCAL_MODULE_CLASS := ETC -LOCAL_SRC_FILES := bin/init.wlan.sh +LOCAL_SRC_FILES := bin/init.mac.sh LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) include $(BUILD_PREBUILT) diff --git a/rootdir/bin/init.wlan.sh b/rootdir/bin/init.mac.sh similarity index 75% rename from rootdir/bin/init.wlan.sh rename to rootdir/bin/init.mac.sh index 36c0430bd..fb5bd8cd4 100644 --- a/rootdir/bin/init.wlan.sh +++ b/rootdir/bin/init.mac.sh @@ -22,3 +22,11 @@ if [[ ! -f /persist/wlan_mac.bin ]] || [[ $(cat /persist/wlan_mac.bin | grep Int echo "Intf0MacAddress=$wifi_mac END" > /persist/wlan_mac.bin fi; + +# Set the proper hardware based BT mac address +bt_mac_path="/data/vendor/bluetooth/bdaddr" +bt_mac=$(getprop sys.bt.address); +if [[ ! -f $bt_mac_path ]] || [[ $(echo $bt_mac) != $(cat /data/vendor/bluetooth/bdaddr) ]]; then + echo $bt_mac > $bt_mac_path +fi; +setprop ro.vendor.bt.bdaddr_path $bt_mac_path diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc index 66b14d4a0..b3099b42a 100644 --- a/rootdir/etc/init.qcom.rc +++ b/rootdir/etc/init.qcom.rc @@ -580,16 +580,21 @@ service wcg_mac_tool /vendor/bin/wcg_mac_tool disabled oneshot -service wlan-sh /vendor/bin/init.wlan.sh +service mac-sh /vendor/bin/init.mac.sh class late_start - user root - group root + user root bluetooth + group root bluetooth disabled oneshot on property:sys.boot_completed=1 start wcg_mac_tool - start wlan-sh + start mac-sh + +on property:ro.vendor.bt.bdaddr_path=/data/vendor/bluetooth/bdaddr + # Correct perms for bdaddr + chmod 0644 /data/vendor/bluetooth/bdaddr + chown bluetooth bluetooth /data/vendor/bluetooth/bdaddr on property:init.svc.vendor.hwcomposer-2-1=stopped stop vendor.ppd diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index d0d9c61aa..30cfa438f 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -1,5 +1,5 @@ # Binaries -/(vendor|system/vendor)/bin/init.wlan.sh u:object_r:qti_init_shell_exec:s0 +/(vendor|system/vendor)/bin/init.mac.sh u:object_r:qti_init_shell_exec:s0 /(vendor|system/vendor)/bin/wcg_mac_tool u:object_r:wcg_mac_exec:s0 # Bluetooth diff --git a/sepolicy/hal_bluetooth_qti.te b/sepolicy/hal_bluetooth_qti.te index 429585f1f..ebed0fbcb 100644 --- a/sepolicy/hal_bluetooth_qti.te +++ b/sepolicy/hal_bluetooth_qti.te @@ -1 +1,3 @@ allow hal_bluetooth_qti sysfs_bluetooth_writable:file rw_file_perms; + +get_prop(hal_bluetooth_qti, bt_mac_prop) diff --git a/sepolicy/property.te b/sepolicy/property.te index 87aea8686..e77394a71 100644 --- a/sepolicy/property.te +++ b/sepolicy/property.te @@ -1,2 +1,3 @@ type wcg_prop, property_type; type oem_unlock_prop, property_type; +type bt_mac_prop, property_type; diff --git a/sepolicy/property_contexts b/sepolicy/property_contexts index 469124807..ed4d762ca 100644 --- a/sepolicy/property_contexts +++ b/sepolicy/property_contexts @@ -1,3 +1,6 @@ +# Bluetooth +ro.vendor.bt.bdaddr_path u:object_r:bt_mac_prop:s0 + # Camera persist.camera. u:object_r:camera_prop:s0 diff --git a/sepolicy/qti_init_shell.te b/sepolicy/qti_init_shell.te index c5b83873f..1331cc424 100644 --- a/sepolicy/qti_init_shell.te +++ b/sepolicy/qti_init_shell.te @@ -5,8 +5,13 @@ allow qti_init_shell file_contexts_file:file { getattr open read }; allow qti_init_shell mnt_vendor_file:dir rw_dir_perms; allow qti_init_shell mnt_vendor_file:file create_file_perms; +# Allow qti_init_shell to write and read /data/vendor/bluetooth/bdaddr +allow qti_init_shell vendor_bt_data_file:dir { add_name create search write }; +allow qti_init_shell vendor_bt_data_file:file { create getattr open read write }; + # Allow qti_init_shell to read cmdline allow qti_init_shell proc_cmdline:file { getattr open read }; get_prop(qti_init_shell, wcg_prop) set_prop(qti_init_shell, oem_unlock_prop) +set_prop(qti_init_shell, bt_mac_prop) diff --git a/sepolicy/system_app.te b/sepolicy/system_app.te index 1158907c8..0fbc30e58 100644 --- a/sepolicy/system_app.te +++ b/sepolicy/system_app.te @@ -4,3 +4,4 @@ allow system_app shell_prop:property_service set; binder_call(system_app, wificond); get_prop(system_app, oem_unlock_prop); +get_prop(system_app, bt_mac_prop);