summaryrefslogtreecommitdiffstats
path: root/libs/WifiTrackerLib/src
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-08-11 00:37:03 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-08-11 00:37:03 +0000
commit089661f8ee2488db9e902d5ca4bbb01431f650b0 (patch)
treeb279727496edce9521bc87ed780c3c11498596e1 /libs/WifiTrackerLib/src
parent5bd2709ae3f4026390874482d8441553819870ad (diff)
parent6ee5e95fdd68f75a38f0df8953b547035aff0fc0 (diff)
downloadframeworks_opt_net_wifi-089661f8ee2488db9e902d5ca4bbb01431f650b0.tar.gz
frameworks_opt_net_wifi-089661f8ee2488db9e902d5ca4bbb01431f650b0.tar.bz2
frameworks_opt_net_wifi-089661f8ee2488db9e902d5ca4bbb01431f650b0.zip
Merge "[WifiTrackerLib] Use WifiInfo MAC address if available" into rvc-qpr-dev am: 6ee5e95fdd
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/wifi/+/12337309 Change-Id: I741f3cdb4e2b58174a69155b37a1089d3bcf53e7
Diffstat (limited to 'libs/WifiTrackerLib/src')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java14
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java14
2 files changed, 20 insertions, 8 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
index d873c25e5..71420b9ad 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
@@ -16,6 +16,7 @@
package com.android.wifitrackerlib;
+import static android.net.wifi.WifiInfo.DEFAULT_MAC_ADDRESS;
import static android.net.wifi.WifiInfo.sanitizeSsid;
import static androidx.core.util.Preconditions.checkNotNull;
@@ -277,16 +278,21 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry
@Override
public String getMacAddress() {
+ if (mWifiInfo != null) {
+ final String wifiInfoMac = mWifiInfo.getMacAddress();
+ if (!TextUtils.isEmpty(wifiInfoMac)
+ && !TextUtils.equals(wifiInfoMac, DEFAULT_MAC_ADDRESS)) {
+ return wifiInfoMac;
+ }
+ }
if (mWifiConfig == null || getPrivacy() != PRIVACY_RANDOMIZED_MAC) {
final String[] factoryMacs = mWifiManager.getFactoryMacAddresses();
if (factoryMacs.length > 0) {
return factoryMacs[0];
- } else {
- return null;
}
- } else {
- return mWifiConfig.getRandomizedMacAddress().toString();
+ return null;
}
+ return mWifiConfig.getRandomizedMacAddress().toString();
}
@Override
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
index 6fef5e961..56cd16503 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
@@ -20,6 +20,7 @@ import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.DISABLED
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_NO_CREDENTIALS;
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD;
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
+import static android.net.wifi.WifiInfo.DEFAULT_MAC_ADDRESS;
import static android.net.wifi.WifiInfo.sanitizeSsid;
import static androidx.core.util.Preconditions.checkNotNull;
@@ -312,16 +313,21 @@ public class StandardWifiEntry extends WifiEntry {
@Override
public String getMacAddress() {
+ if (mWifiInfo != null) {
+ final String wifiInfoMac = mWifiInfo.getMacAddress();
+ if (!TextUtils.isEmpty(wifiInfoMac)
+ && !TextUtils.equals(wifiInfoMac, DEFAULT_MAC_ADDRESS)) {
+ return wifiInfoMac;
+ }
+ }
if (mWifiConfig == null || getPrivacy() != PRIVACY_RANDOMIZED_MAC) {
final String[] factoryMacs = mWifiManager.getFactoryMacAddresses();
if (factoryMacs.length > 0) {
return factoryMacs[0];
- } else {
- return null;
}
- } else {
- return mWifiConfig.getRandomizedMacAddress().toString();
+ return null;
}
+ return mWifiConfig.getRandomizedMacAddress().toString();
}
@Override