Change mac random key to network key
Change the name based on function. Bug: 142035508 Test: atest android.net.wifi Change-Id: I01358799327f2d24993fe75f2e4a503d965f2246
This commit is contained in:
@@ -2736,17 +2736,18 @@ public class WifiConfiguration implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a key for this WifiConfig to generate Persist random Mac Address.
|
||||
* Get a unique key which represent this Wi-Fi network. If two profiles are for
|
||||
* the same Wi-Fi network, but from different provider, they would have the same key.
|
||||
* @hide
|
||||
*/
|
||||
public String getMacRandomKey() {
|
||||
public String getNetworkKey() {
|
||||
// Passpoint ephemeral networks have their unique identifier set. Return it as is to be
|
||||
// able to match internally.
|
||||
if (mPasspointUniqueId != null) {
|
||||
return mPasspointUniqueId;
|
||||
}
|
||||
|
||||
String key = getSsidAndSecurityTypeString();
|
||||
String key = SSID + getDefaultSecurityType();
|
||||
if (!shared) {
|
||||
key += "-" + UserHandle.getUserHandleForUid(creatorUid).getIdentifier();
|
||||
}
|
||||
|
||||
@@ -426,11 +426,11 @@ public class WifiConfigurationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that getMacRandomKey returns the correct String for networks of
|
||||
* Verifies that getNetworkKey returns the correct String for networks of
|
||||
* various different security types, the result should be stable.
|
||||
*/
|
||||
@Test
|
||||
public void testGetMacRandomKeyString() {
|
||||
public void testGetNetworkKeyString() {
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
final String mSsid = "TestAP";
|
||||
config.SSID = mSsid;
|
||||
@@ -438,23 +438,23 @@ public class WifiConfigurationTest {
|
||||
// Test various combinations
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WPA_PSK],
|
||||
config.getMacRandomKey());
|
||||
config.getNetworkKey());
|
||||
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WPA_EAP],
|
||||
config.getMacRandomKey());
|
||||
config.getNetworkKey());
|
||||
|
||||
config.wepKeys[0] = "TestWep";
|
||||
config.allowedKeyManagement.clear();
|
||||
assertEquals(mSsid + "WEP", config.getMacRandomKey());
|
||||
assertEquals(mSsid + "WEP", config.getNetworkKey());
|
||||
|
||||
// set WEP key and give a valid index.
|
||||
config.wepKeys[0] = null;
|
||||
config.wepKeys[2] = "TestWep";
|
||||
config.wepTxKeyIndex = 2;
|
||||
config.allowedKeyManagement.clear();
|
||||
assertEquals(mSsid + "WEP", config.getMacRandomKey());
|
||||
assertEquals(mSsid + "WEP", config.getNetworkKey());
|
||||
|
||||
// set WEP key but does not give a valid index.
|
||||
config.wepKeys[0] = null;
|
||||
@@ -462,40 +462,40 @@ public class WifiConfigurationTest {
|
||||
config.wepTxKeyIndex = 0;
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.OWE);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.OWE], config.getMacRandomKey());
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.OWE], config.getNetworkKey());
|
||||
|
||||
config.wepKeys[0] = null;
|
||||
config.wepTxKeyIndex = 0;
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.OWE);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.OWE], config.getMacRandomKey());
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.OWE], config.getNetworkKey());
|
||||
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.SAE);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.SAE], config.getMacRandomKey());
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.SAE], config.getNetworkKey());
|
||||
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.SUITE_B_192],
|
||||
config.getMacRandomKey());
|
||||
config.getNetworkKey());
|
||||
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.NONE], config.getMacRandomKey());
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.NONE], config.getNetworkKey());
|
||||
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.WAPI_PSK);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WAPI_PSK],
|
||||
config.getMacRandomKey());
|
||||
config.getNetworkKey());
|
||||
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedKeyManagement.set(KeyMgmt.WAPI_CERT);
|
||||
assertEquals(mSsid + KeyMgmt.strings[KeyMgmt.WAPI_CERT],
|
||||
config.getMacRandomKey());
|
||||
config.getNetworkKey());
|
||||
|
||||
config.allowedKeyManagement.clear();
|
||||
config.setPasspointUniqueId(TEST_PASSPOINT_UNIQUE_ID);
|
||||
assertEquals(TEST_PASSPOINT_UNIQUE_ID, config.getMacRandomKey());
|
||||
assertEquals(TEST_PASSPOINT_UNIQUE_ID, config.getNetworkKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user