aboutsummaryrefslogtreecommitdiff
path: root/rootdir/bin/init.mi.btmac.sh
diff options
context:
space:
mode:
authorkleidione Freitas <kleidione@gmail.com>2022-03-24 09:16:43 -0300
committerkleidione <kleidione@gmail.com>2022-11-09 17:29:16 -0300
commit44d5c9e2cf9f1ce0670be5bedd1e415cd5c3e739 (patch)
tree4516fedba0c65fda9e795d8737d08a7746d41e40 /rootdir/bin/init.mi.btmac.sh
parent15eeafbf239f393fcb6ed1a719398e5b7bbd6a19 (diff)
veux: Merge common tree to veux
- Ref: https://github.com/xiaomi-sm6375-devs/android_device_xiaomi_sm6375-common Signed-off-by: kleidione <kleidione@gmail.com>
Diffstat (limited to 'rootdir/bin/init.mi.btmac.sh')
-rwxr-xr-xrootdir/bin/init.mi.btmac.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/rootdir/bin/init.mi.btmac.sh b/rootdir/bin/init.mi.btmac.sh
new file mode 100755
index 0000000..66ec4b2
--- /dev/null
+++ b/rootdir/bin/init.mi.btmac.sh
@@ -0,0 +1,21 @@
+#!/vendor/bin/sh
+# Copyright (C) 2021 KudProject Development
+# SPDX-License-Identifier: GPL-3.0-or-later OR Apache-2.0
+
+LOG_TAG="MiSetBtMac"
+logi () { log -t "$LOG_TAG" -p i "$@"; }
+
+# hex binary containing mac address
+BT_MAC_HEX_PATH="/data/vendor/mac_addr/bt.mac";
+if [ ! -f "$BT_MAC_HEX_PATH" ]; then
+ logi "bt.mac file not found, exiting"
+ exit
+fi
+
+# raw mac address without colons
+RAW_MAC=$(xxd -p "$BT_MAC_HEX_PATH");
+# convert it into format recognized by bluetooth hal
+DEC_MAC=$(echo "$RAW_MAC" | sed 's!^M$!!;s!\-!!g;s!\.!!g;s!\(..\)!\1:!g;s!:$!!')
+# set the mac address using persist property
+setprop persist.vendor.service.bdroid.bdaddr "$DEC_MAC"
+logi "bt.mac file found, setting mac addr"