Loading wifi/java/android/net/wifi/WifiConfiguration.java +25 −16 Original line number Original line Diff line number Diff line Loading @@ -2190,10 +2190,24 @@ public class WifiConfiguration implements Parcelable { key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); } } } else { } else { key = getSsidAndSecurityTypeString(); if (!shared) { key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); } mCachedConfigKey = key; } return key; } /** @hide * return the SSID + security type in String format. */ public String getSsidAndSecurityTypeString() { String key; if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK]; key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK]; } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP) || } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP) allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { || allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { key = SSID + KeyMgmt.strings[KeyMgmt.WPA_EAP]; key = SSID + KeyMgmt.strings[KeyMgmt.WPA_EAP]; } else if (wepKeys[0] != null) { } else if (wepKeys[0] != null) { key = SSID + "WEP"; key = SSID + "WEP"; Loading @@ -2206,11 +2220,6 @@ public class WifiConfiguration implements Parcelable { } else { } else { key = SSID + KeyMgmt.strings[KeyMgmt.NONE]; key = SSID + KeyMgmt.strings[KeyMgmt.NONE]; } } if (!shared) { key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); } mCachedConfigKey = key; } return key; return key; } } Loading wifi/tests/src/android/net/wifi/WifiConfigurationTest.java +43 −0 Original line number Original line Diff line number Diff line Loading @@ -348,4 +348,47 @@ public class WifiConfigurationTest { } } assertTrue(exceptionThrown); assertTrue(exceptionThrown); } } /** * Verifies that getSsidAndSecurityTypeString returns the correct String for networks of * various different security types */ @Test public void testGetSsidAndSecurityTypeString() { WifiConfiguration config = new WifiConfiguration(); final String mSsid = "TestAP"; config.SSID = mSsid; // Test various combinations config.allowedKeyManagement.set(KeyMgmt.WPA_PSK); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WPA_PSK], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.WPA_EAP); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WPA_EAP], config.getSsidAndSecurityTypeString()); config.wepKeys[0] = "TestWep"; config.allowedKeyManagement.clear(); assertEquals(mSsid + "WEP", config.getSsidAndSecurityTypeString()); config.wepKeys[0] = null; config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.OWE); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.OWE], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.SAE); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.SAE], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.SUITE_B_192], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.NONE); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.NONE], config.getSsidAndSecurityTypeString()); } } } Loading
wifi/java/android/net/wifi/WifiConfiguration.java +25 −16 Original line number Original line Diff line number Diff line Loading @@ -2190,10 +2190,24 @@ public class WifiConfiguration implements Parcelable { key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); } } } else { } else { key = getSsidAndSecurityTypeString(); if (!shared) { key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); } mCachedConfigKey = key; } return key; } /** @hide * return the SSID + security type in String format. */ public String getSsidAndSecurityTypeString() { String key; if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK]; key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK]; } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP) || } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP) allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { || allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { key = SSID + KeyMgmt.strings[KeyMgmt.WPA_EAP]; key = SSID + KeyMgmt.strings[KeyMgmt.WPA_EAP]; } else if (wepKeys[0] != null) { } else if (wepKeys[0] != null) { key = SSID + "WEP"; key = SSID + "WEP"; Loading @@ -2206,11 +2220,6 @@ public class WifiConfiguration implements Parcelable { } else { } else { key = SSID + KeyMgmt.strings[KeyMgmt.NONE]; key = SSID + KeyMgmt.strings[KeyMgmt.NONE]; } } if (!shared) { key += "-" + Integer.toString(UserHandle.getUserId(creatorUid)); } mCachedConfigKey = key; } return key; return key; } } Loading
wifi/tests/src/android/net/wifi/WifiConfigurationTest.java +43 −0 Original line number Original line Diff line number Diff line Loading @@ -348,4 +348,47 @@ public class WifiConfigurationTest { } } assertTrue(exceptionThrown); assertTrue(exceptionThrown); } } /** * Verifies that getSsidAndSecurityTypeString returns the correct String for networks of * various different security types */ @Test public void testGetSsidAndSecurityTypeString() { WifiConfiguration config = new WifiConfiguration(); final String mSsid = "TestAP"; config.SSID = mSsid; // Test various combinations config.allowedKeyManagement.set(KeyMgmt.WPA_PSK); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WPA_PSK], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.WPA_EAP); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WPA_EAP], config.getSsidAndSecurityTypeString()); config.wepKeys[0] = "TestWep"; config.allowedKeyManagement.clear(); assertEquals(mSsid + "WEP", config.getSsidAndSecurityTypeString()); config.wepKeys[0] = null; config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.OWE); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.OWE], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.SAE); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.SAE], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.SUITE_B_192], config.getSsidAndSecurityTypeString()); config.allowedKeyManagement.clear(); config.allowedKeyManagement.set(KeyMgmt.NONE); assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.NONE], config.getSsidAndSecurityTypeString()); } } }