diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-06-18 07:03:45 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-18 07:03:45 +0000 |
commit | 6fa6d1997cd27c582d6cfe6aed6e8f9491f4dd2a (patch) | |
tree | aa0a502b1c4e7ceca8450e4ab0469e935f62581b /libs | |
parent | 34d756ffb47e3782319308daa64c90c7ac685a14 (diff) | |
parent | 9f55a68611cdb7f0805af803f3f8f7487c9b208d (diff) |
Merge changes I098b9210,I884b4bee into rvc-dev am: 9f55a68611
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/wifi/+/11900235
Change-Id: I077e0ac712880cd7a62b17fe93dcd8fe03010f8f
Diffstat (limited to 'libs')
6 files changed, 16 insertions, 103 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java index 89d780eba..134ceef96 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java @@ -199,21 +199,6 @@ class OsuWifiEntry extends WifiEntry { } @Override - public String getQrCodeString() { - return null; - } - - @Override - public boolean canSetPassword() { - return false; - } - - @Override - public void setPassword(@NonNull String password) { - // Do nothing. - } - - @Override @MeteredChoice public int getMeteredChoice() { // Metered choice is meaningless for OSU entries diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java index 20a87e760..d873c25e5 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 @@ -393,21 +401,6 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry } @Override - public String getQrCodeString() { - return null; - } - - @Override - public boolean canSetPassword() { - return false; - } - - @Override - public void setPassword(@NonNull String password) { - // Do nothing. - } - - @Override @MeteredChoice public int getMeteredChoice() { if (mMeteredOverride == WifiConfiguration.METERED_OVERRIDE_METERED) { @@ -420,7 +413,7 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry @Override public boolean canSetMeteredChoice() { - return mPasspointConfig != null; + return !isSuggestion() && mPasspointConfig != null; } @Override @@ -449,7 +442,7 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry @Override public boolean canSetPrivacy() { - return mPasspointConfig != null; + return !isSuggestion() && mPasspointConfig != null; } @Override diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java index 2a3a71cb3..19c2619bc 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java @@ -161,7 +161,6 @@ public class StandardWifiEntry extends WifiEntry { @NonNull String key, @NonNull WifiManager wifiManager, @NonNull WifiNetworkScoreCache scoreCache, boolean forSavedNetworksPage) { - // TODO: second argument (isSaved = false) is bogus in this context super(callbackHandler, wifiManager, scoreCache, forSavedNetworksPage); mContext = context; @@ -305,7 +304,6 @@ public class StandardWifiEntry extends WifiEntry { @Override @Security public int getSecurity() { - // TODO(b/70983952): Fill this method in return mSecurity; } @@ -498,23 +496,6 @@ public class StandardWifiEntry extends WifiEntry { } @Override - public String getQrCodeString() { - // TODO(b/70983952): Fill this method in - return null; - } - - @Override - public boolean canSetPassword() { - // TODO(b/70983952): Fill this method in - return false; - } - - @Override - public void setPassword(@NonNull String password) { - // TODO(b/70983952): Fill this method in - } - - @Override @MeteredChoice public int getMeteredChoice() { if (getWifiConfiguration() != null) { @@ -904,7 +885,6 @@ public class StandardWifiEntry extends WifiEntry { } description.append("=").append(scanResult.frequency); description.append(",").append(scanResult.level); - // TODO(b/70983952): Append speed of the ScanResult here. final int ageSeconds = (int) (nowMs - scanResult.timestamp / 1000) / 1000; description.append(",").append(ageSeconds).append("s"); description.append("}"); diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java index e800e4832..c7dc5c4da 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java @@ -304,12 +304,6 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { @Security public abstract int getSecurity(); - /** Returns the string representation of the security of the WifiEntry. */ - public String getSecurityString() { - // TODO (b/70983952) Implement this - return null; - } - /** Returns the MAC address of the connection */ public abstract String getMacAddress(); @@ -393,16 +387,9 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { public abstract boolean canShare(); /** Returns whether the user can use Easy Connect to onboard a device to the network */ public abstract boolean canEasyConnect(); - /** Returns the QR code string for the network */ - public abstract String getQrCodeString(); // Modifiable settings - /** Returns whether the entry should show a password input */ - public abstract boolean canSetPassword(); - /** Sets the user's password to a network */ - public abstract void setPassword(@NonNull String password); - /** * Returns the user's choice whether to treat a network as metered, * defined by the METERED_CHOICE constants @@ -770,7 +757,6 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { } } - // TODO (b/70983952) Come up with a sorting scheme that does the right thing. @Override public int compareTo(@NonNull WifiEntry other) { if (getLevel() != WIFI_LEVEL_UNREACHABLE && other.getLevel() == WIFI_LEVEL_UNREACHABLE) { diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardNetworkDetailsTrackerTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardNetworkDetailsTrackerTest.java index a7aa20a6b..964a900ca 100644 --- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardNetworkDetailsTrackerTest.java +++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardNetworkDetailsTrackerTest.java @@ -23,7 +23,6 @@ import static com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_UNREACHABLE; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -105,36 +104,6 @@ public class StandardNetworkDetailsTrackerTest { } /** - * Tests that a key without the correct prefix throws an error in the constructor. - */ - @Test - public void testConstructor_malformedPrefix_throwsError() { - final String key = "IncorrectPrefix:ssid,0"; - try { - final StandardNetworkDetailsTracker tracker = - createTestStandardNetworkDetailsTracker(key); - fail("Incorrect prefix in key argument should throw an error!"); - } catch (IllegalArgumentException e) { - // Test Succeeded - } - } - - /** - * Tests that a key without a security type throws an error in the constructor. - */ - @Test - public void testConstructor_malformedSecurity_throwsError() { - final String key = StandardWifiEntry.KEY_PREFIX + "ssid"; - try { - final StandardNetworkDetailsTracker tracker = - createTestStandardNetworkDetailsTracker(key); - fail("Incorrect security type in key argument should throw an error!"); - } catch (IllegalArgumentException e) { - // Test Succeeded - } - } - - /** * Tests that the key of the created WifiEntry matches the key passed into the constructor. */ @Test diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java index f59e34499..feec984bf 100644 --- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java +++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java @@ -115,7 +115,7 @@ public class WifiPickerTrackerTest { when(mMockWifiManager.getScanResults()).thenReturn(new ArrayList<>()); when(mMockWifiManager.getConnectionInfo()).thenReturn(mMockWifiInfo); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mMockNetworkInfo); + when(mMockConnectivityManager.getNetworkInfo(any())).thenReturn(mMockNetworkInfo); when(mMockClock.millis()).thenReturn(START_MILLIS); when(mMockWifiInfo.getNetworkId()).thenReturn(WifiConfiguration.INVALID_NETWORK_ID); when(mMockWifiInfo.getRssi()).thenReturn(WifiInfo.INVALID_RSSI); |