utils: bdaddr: skip setting bdaddr for 5.4 kernel version am: a565a8f7a8
Original change: https://android-review.googlesource.com/c/device/linaro/dragonboard/+/2894624
Change-Id: I59c6424bdc6db56c20b197f2b752e7c8f4ce2e11
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/sepolicy/set_bdaddr.te b/sepolicy/set_bdaddr.te
index c7fa166..1540d47 100644
--- a/sepolicy/set_bdaddr.te
+++ b/sepolicy/set_bdaddr.te
@@ -4,6 +4,7 @@
# audit2allow
allow set_bdaddr proc_cmdline:file { open read };
+allow set_bdaddr proc_version:file { open read getattr };
allow set_bdaddr proc_bootconfig:file { open read };
allow set_bdaddr rootfs:dir { open read };
allow set_bdaddr self:bluetooth_socket { bind create read write };
diff --git a/shared/utils/bdaddr/set_bdaddr.sh b/shared/utils/bdaddr/set_bdaddr.sh
index e59fa39..2e4ff48 100644
--- a/shared/utils/bdaddr/set_bdaddr.sh
+++ b/shared/utils/bdaddr/set_bdaddr.sh
@@ -26,6 +26,19 @@
# Format the output in xx:xx:xx:xx:xx:xx format for the
# "bdaddr" command to work.
+if /vendor/bin/grep -o 'Linux version 5.4.' /proc/version; then
+ # for 5.4 kernels, setting the bdaddr would cause
+ # bluetooth::StackManager::StartUp crash like reported here:
+ # https://issuetracker.google.com/issues/318404233
+ # so skipping it here.
+ # It's possible to not integrate this script at building time,
+ # but that way would make 5.4 and other kernel versions use different
+ # super.img files, for development convenience doing the check
+ # at runtime here, so that only boot.img/vendor_boot.img are
+ # necessary for different versions
+ exit 0
+fi
+
BTADDR=`/vendor/bin/cat /proc/cmdline | /vendor/bin/grep -o serialno.* |\
/vendor/bin/cut -f2 -d'=' | /vendor/bin/awk '{printf("c0%010s\n", $1)}' |\
/vendor/bin/sed 's/\(..\)/\1:/g' | /vendor/bin/sed '$s/:$//'`