Solution to the problem that the random macaddress is not completely disabled and the saved network cannot be connected

Scan the code to pay attention, learn together The
Insert picture description here
device has disabled the random macaddress function, and does not support the simultaneous opening of WiFi and hotspots.

The conditions for the problem are:
1. Turn on WiFi and connect to the AP
2. Turn on the hotspot, and the WiFi will be automatically turned off at this time.
3. Manually turn on the WiFi and the hotspot will automatically turn off.
4. Observe the WiFi and find that the AP just connected does not automatically reset. even

Grabbing the log found that the connection to the AP failed the second time when the WiFi was turned on, and the macaddress was unexpectedly different from before. However, the random macaddress function has indeed been cancelled. How to continue searching for random mac-related settings in the code and found the following.

Define a WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION identifier.
/hardware/interfaces/wifi/1.3/default/Android.mk

ifdef WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION
LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION
endif

Then reorganized the code and brushed the machine, and found that the bug was solved.

Guess you like

Origin blog.csdn.net/qq_43804080/article/details/106497362