Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WifiInfo.getMacAddress() returns 02:00:00:00:00:00 aways in Android 6.0 device

Tags:

android

I have learned that since the Android 6.0:

Android removes programmatic access to the device’s local hardware
identifier for apps using the Wi-Fi and Bluetooth APIs. The
WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress()
methods now return a constant value of 02:00:00:00:00:00。

But,what I confused is when my targetSdkVersion is lower than 23 it still returns the constant in android 6.0 device. In my opinion, I think it should return an unique hardware identifier because of the Application forward compatibility. Whay did not system enable any compatibility behaviors ? This is my uses-sdk:

 android:minSdkVersion="8"
 android:targetSdkVersion="22"

This is my method:

WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String macAddress = wifiInfo.getMacAddress();

Thanks.Forgive my broken English.

like image 286
sanmianti Avatar asked Sep 06 '25 03:09

sanmianti


1 Answers

Why did not system enable any compatibility behaviors ?

For sake of data protection, we are not entitled to this kind of forward compatibility. Your app still runs , right? So it is forward compatible. but security loopholes must be addressed even if it hurts someone's legitimate purpose.

And sending a constant value 02:00:00:00:00:00 is a compatibility behavior otherwise they would have just return null value

like image 164
Amit K. Saha Avatar answered Sep 07 '25 21:09

Amit K. Saha