From fb7f215d863627f325f101a3356bf2cfc65f7e58 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 15 Jun 2020 19:27:22 -0700 Subject: [WifiTrackerLib] Implement Passpoint isMetered() and getMacAddress() Adds correct functionality for PasspointWifiEntry.isMetered() and getMacAddress(). Bug: 159074196 Test: atest WifiTrackerLibTests Change-Id: I098b9210fb49d2be5f892d3ede3e59dc399e381b --- .../android/wifitrackerlib/PasspointWifiEntry.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'libs') diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java index 3e8db7fcf..c7439301f 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java @@ -277,14 +277,22 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry @Override public String getMacAddress() { - // TODO(b/70983952): Fill this method in - return null; + 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(); + } } @Override public boolean isMetered() { - // TODO(b/70983952): Fill this method in - return false; + return getMeteredChoice() == METERED_CHOICE_METERED + || (mWifiConfig != null && mWifiConfig.meteredHint); } @Override @@ -358,7 +366,7 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry @Override public boolean canForget() { - return mPasspointConfig != null; + return !isSuggestion() && mPasspointConfig != null; } @Override @@ -405,7 +413,7 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry @Override public boolean canSetMeteredChoice() { - return mPasspointConfig != null; + return !isSuggestion() && mPasspointConfig != null; } @Override @@ -434,7 +442,7 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry @Override public boolean canSetPrivacy() { - return mPasspointConfig != null; + return !isSuggestion() && mPasspointConfig != null; } @Override -- cgit v1.2.3