sm8350-common: Add wifi mac generator shell script

Change-Id: I95593db840dc4a668f899d248b2c8e03d4ebbc3e
This commit is contained in:
LuK1337 2019-07-08 15:47:03 +02:00
parent 83d0538609
commit 72da964f9a
6 changed files with 75 additions and 0 deletions

View file

@ -520,6 +520,7 @@ PRODUCT_PACKAGES += \
vendor.qti.hardware.wifi.hostapd@1.2.vendor \
vendor.qti.hardware.wifi.supplicant@2.0.vendor \
vendor.qti.hardware.wifi.supplicant@2.1.vendor \
wifi-mac-generator \
WifiResCommon \
wpa_supplicant \
wpa_supplicant.conf

View file

@ -1,6 +1,7 @@
# Binaries
/(vendor|system/vendor)/bin/opf-service u:object_r:opf_exec:s0
/(vendor|system/vendor)/bin/tri-state-key_daemon u:object_r:tri-state-key_daemon_exec:s0
/(vendor|system/vendor)/bin/wifi-mac-generator u:object_r:wifi-mac-generator_exec:s0
/(vendor|system/vendor)/bin/wlchgd u:object_r:wlchgd_exec:s0
# Block devices

12
sepolicy/vendor/wifi-mac-generator.te vendored Normal file
View file

@ -0,0 +1,12 @@
type wifi-mac-generator, domain;
type wifi-mac-generator_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(wifi-mac-generator)
allow wifi-mac-generator vendor_shell_exec:file rx_file_perms;
allow wifi-mac-generator vendor_toolbox_exec:file rx_file_perms;
r_dir_file(wifi-mac-generator, vendor_data_file)
allow wifi-mac-generator mnt_vendor_file:dir search;
allow wifi-mac-generator mnt_vendor_file:file w_file_perms;

View file

@ -0,0 +1,9 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := wifi-mac-generator
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES)
LOCAL_SRC_FILES := wifi-mac-generator.sh
LOCAL_INIT_RC := wifi-mac-generator.rc
include $(BUILD_PREBUILT)

View file

@ -0,0 +1,9 @@
service vendor.wifi-mac-generator /vendor/bin/wifi-mac-generator
class main
user wifi
group wifi
oneshot
disabled
on post-fs-data
start vendor.wifi-mac-generator

View file

@ -0,0 +1,43 @@
#!/vendor/bin/sh
WLAN_MAC_VENDOR_PREFIX="C0EEFB"
WLAN_MAC_PERSIST_PATH="/mnt/vendor/persist/wlan_mac.bin"
function wait_for_file() {
retries=0
while [ ! -f "${1}" ]; do
retries=$((retries + 1))
if [ "${retries}" -eq 10 ]; then
return 1
fi
sleep 1
done
return 0
}
if [[ ! -f "${WLAN_MAC_PERSIST_PATH}" ]] || [[ ! -s "${WLAN_MAC_PERSIST_PATH}" ]]; then
MAC_0_PATH="/data/vendor/oemnvitems/4678_0"
if ! wait_for_file "${MAC_0_PATH}"; then
MAC_0="${WLAN_MAC_VENDOR_PREFIX}`xxd -l 3 -p /dev/urandom | tr '[:lower:]' '[:upper:]'`"
else
MAC_0=`xxd -p "${MAC_0_PATH}" | tr '[:lower:]' '[:upper:]'`
fi
MAC_1_PATH="/data/vendor/oemnvitems/4678_1"
if ! wait_for_file "${MAC_1_PATH}"; then
MAC_1="${WLAN_MAC_VENDOR_PREFIX}`xxd -l 3 -p /dev/urandom | tr '[:lower:]' '[:upper:]'`"
else
MAC_1=`xxd -p "${MAC_1_PATH}" | tr '[:lower:]' '[:upper:]'`
fi
echo "Intf0MacAddress=${MAC_0}" > "${WLAN_MAC_PERSIST_PATH}"
echo "Intf1MacAddress=${MAC_1}" >> "${WLAN_MAC_PERSIST_PATH}"
echo "Intf2MacAddress=000AF58989FD" >> "${WLAN_MAC_PERSIST_PATH}"
echo "Intf3MacAddress=000AF58989FC" >> "${WLAN_MAC_PERSIST_PATH}"
echo "END" >> "${WLAN_MAC_PERSIST_PATH}"
fi