779828ff23
The idea is to allow us to not depend on stock QTI Bluetooth HAL, as MAC addresses fetched from NVRAM by nv_mac script will be saved as hex-encoded files. We can decode back saved files to then the Bluetooth one be set using persist property so it can be read by Bluetooth HAL. This is loosely based on similar techniques used on Mi 9 and ZenFone Max Pro M2. Signed-off-by: Albert I <kras@raphielgang.org> Change-Id: I74d07c3c3125a04962c37fe8bfcc8385d1fd3398
22 lines
708 B
Bash
22 lines
708 B
Bash
#!/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"
|