Add WifiConfiguration.shared flag
* Add boolean WifiConfiguration.shared, which indicates whether a network is shared (visible to and usable by all users) or private (visible to and usable only by the user who created it) * Extend WifiConfiguration.configKey(...) so that when two users create private configurations for the same network, their configurationKeys will be different. * Make AccessPoint.matches(...) take into account the shared flag BUG=25600871 Change-Id: I4a4335fa3b4b4f850e16748583a29ab66992ddc8
This commit is contained in:
@@ -234,10 +234,13 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
}
|
||||
|
||||
public boolean matches(WifiConfiguration config) {
|
||||
if (config.isPasspoint() && mConfig != null && mConfig.isPasspoint())
|
||||
if (config.isPasspoint() && mConfig != null && mConfig.isPasspoint()) {
|
||||
return config.FQDN.equals(mConfig.providerFriendlyName);
|
||||
else
|
||||
return ssid.equals(removeDoubleQuotes(config.SSID)) && security == getSecurity(config);
|
||||
} else {
|
||||
return ssid.equals(removeDoubleQuotes(config.SSID))
|
||||
&& security == getSecurity(config)
|
||||
&& (mConfig == null || mConfig.shared == config.shared);
|
||||
}
|
||||
}
|
||||
|
||||
public WifiConfiguration getConfig() {
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.net.ProxyInfo;
|
||||
import android.net.StaticIpConfiguration;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -325,6 +326,13 @@ public class WifiConfiguration implements Parcelable {
|
||||
*/
|
||||
public long[] roamingConsortiumIds;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* This network configuration is visible to and usable by other users on the
|
||||
* same device.
|
||||
*/
|
||||
public boolean shared;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -1103,6 +1111,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
mIpConfiguration = new IpConfiguration();
|
||||
lastUpdateUid = -1;
|
||||
creatorUid = -1;
|
||||
shared = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1488,6 +1497,9 @@ public class WifiConfiguration implements Parcelable {
|
||||
key = mCachedConfigKey;
|
||||
} else if (providerFriendlyName != null) {
|
||||
key = FQDN + KeyMgmt.strings[KeyMgmt.WPA_EAP];
|
||||
if (!shared) {
|
||||
key += "-" + Integer.toString(UserHandle.getUserId(creatorUid));
|
||||
}
|
||||
} else {
|
||||
if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
|
||||
key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK];
|
||||
@@ -1499,6 +1511,9 @@ public class WifiConfiguration implements Parcelable {
|
||||
} else {
|
||||
key = SSID + KeyMgmt.strings[KeyMgmt.NONE];
|
||||
}
|
||||
if (!shared) {
|
||||
key += "-" + Integer.toString(UserHandle.getUserId(creatorUid));
|
||||
}
|
||||
mCachedConfigKey = key;
|
||||
}
|
||||
return key;
|
||||
@@ -1511,27 +1526,6 @@ public class WifiConfiguration implements Parcelable {
|
||||
return configKey(false);
|
||||
}
|
||||
|
||||
/** @hide
|
||||
* return the config key string based on a scan result
|
||||
*/
|
||||
static public String configKey(ScanResult result) {
|
||||
String key = "\"" + result.SSID + "\"";
|
||||
|
||||
if (result.capabilities.contains("WEP")) {
|
||||
key = key + "-WEP";
|
||||
}
|
||||
|
||||
if (result.capabilities.contains("PSK")) {
|
||||
key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_PSK];
|
||||
}
|
||||
|
||||
if (result.capabilities.contains("EAP")) {
|
||||
key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_EAP];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public IpConfiguration getIpConfiguration() {
|
||||
return mIpConfiguration;
|
||||
@@ -1593,6 +1587,11 @@ public class WifiConfiguration implements Parcelable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean isVisibleToUser(int userId) {
|
||||
return shared || (UserHandle.getUserId(creatorUid) == userId);
|
||||
}
|
||||
|
||||
/** copy constructor {@hide} */
|
||||
public WifiConfiguration(WifiConfiguration source) {
|
||||
if (source != null) {
|
||||
@@ -1676,6 +1675,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
noInternetAccessExpected = source.noInternetAccessExpected;
|
||||
creationTime = source.creationTime;
|
||||
updateTime = source.updateTime;
|
||||
shared = source.shared;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1747,6 +1747,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
dest.writeInt(userApproved);
|
||||
dest.writeInt(numNoInternetAccessReports);
|
||||
dest.writeInt(noInternetAccessExpected ? 1 : 0);
|
||||
dest.writeInt(shared ? 1 : 0);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@@ -1814,6 +1815,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
config.userApproved = in.readInt();
|
||||
config.numNoInternetAccessReports = in.readInt();
|
||||
config.noInternetAccessExpected = in.readInt() != 0;
|
||||
config.shared = in.readInt() != 0;
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user