Merge "Allow set MAC randomization setting for passpoint"

This commit is contained in:
Oscar Shu
2020-01-16 23:52:27 +00:00
committed by Android (Google) Code Review
7 changed files with 77 additions and 1 deletions

View File

@@ -6246,6 +6246,7 @@ package android.net.wifi {
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveSoftApBackupData();
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void save(@NonNull android.net.wifi.WifiConfiguration, @Nullable android.net.wifi.WifiManager.ActionListener);
method @RequiresPermission(android.Manifest.permission.WIFI_SET_DEVICE_MOBILITY_STATE) public void setDeviceMobilityState(int);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void setMacRandomizationSettingPasspointEnabled(@NonNull String, boolean);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public boolean setSoftApConfiguration(@NonNull android.net.wifi.SoftApConfiguration);
method @Deprecated @RequiresPermission(android.Manifest.permission.CHANGE_WIFI_STATE) public boolean setWifiApConfiguration(android.net.wifi.WifiConfiguration);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startEasyConnectAsConfiguratorInitiator(@NonNull String, int, int, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.EasyConnectStatusCallback);
@@ -6595,6 +6596,7 @@ package android.net.wifi.hotspot2 {
public final class PasspointConfiguration implements android.os.Parcelable {
method public boolean isAutoJoinEnabled();
method public boolean isMacRandomizationEnabled();
}
public abstract class ProvisioningCallback {

View File

@@ -92,6 +92,8 @@ interface IWifiManager
void allowAutojoinPasspoint(String fqdn, boolean enableAutoJoin);
void setMacRandomizationSettingPasspointEnabled(String fqdn, boolean enable);
boolean startScan(String packageName, String featureId);
List<ScanResult> getScanResults(String callingPackage, String callingFeatureId);

View File

@@ -4242,6 +4242,24 @@ public class WifiManager {
}
}
/**
* Configure MAC randomization setting for a Passpoint profile.
* MAC randomization is enabled by default.
*
* @param fqdn the FQDN (fully qualified domain name) of the passpoint profile.
* @param enable true to enable MAC randomization, false to disable MAC randomization.
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
public void setMacRandomizationSettingPasspointEnabled(@NonNull String fqdn, boolean enable) {
try {
mService.setMacRandomizationSettingPasspointEnabled(fqdn, enable);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Disable an ephemeral network.
*

View File

@@ -430,6 +430,13 @@ public final class PasspointConfiguration implements Parcelable {
*/
private boolean mIsAutoJoinEnabled = true;
/**
* The mac randomization setting specifies whether a randomized or device MAC address will
* be used to connect to the passpoint network. If true, a randomized MAC will be used.
* Otherwise, the device MAC address will be used.
*/
private boolean mIsMacRandomizationEnabled = true;
/**
* Configures the auto-association status of this Passpoint configuration. A value of true
* indicates that the configuration will be considered for auto-connection, a value of false
@@ -443,6 +450,18 @@ public final class PasspointConfiguration implements Parcelable {
mIsAutoJoinEnabled = autoJoinEnabled;
}
/**
* Configures the MAC randomization setting for this Passpoint configuration.
* If set to true, the framework will use a randomized MAC address to connect to this Passpoint
* network. Otherwise, the framework will use the device MAC address.
*
* @param enabled true to use randomized MAC address, false to use device MAC address.
* @hide
*/
public void setMacRandomizationEnabled(boolean enabled) {
mIsMacRandomizationEnabled = enabled;
}
/**
* Indicates whether the Passpoint configuration may be auto-connected to by the framework. A
* value of true indicates that auto-connection can happen, a value of false indicates that it
@@ -458,6 +477,19 @@ public final class PasspointConfiguration implements Parcelable {
return mIsAutoJoinEnabled;
}
/**
* Indicates whether a randomized MAC address or device MAC address will be used for
* connections to this Passpoint network. If true, a randomized MAC address will be used.
* Otherwise, the device MAC address will be used.
*
* @return true for MAC randomization enabled. False for disabled.
* @hide
*/
@SystemApi
public boolean isMacRandomizationEnabled() {
return mIsMacRandomizationEnabled;
}
/**
* Constructor for creating PasspointConfiguration with default values.
*/
@@ -501,6 +533,7 @@ public final class PasspointConfiguration implements Parcelable {
mAaaServerTrustedNames = source.mAaaServerTrustedNames;
mCarrierId = source.mCarrierId;
mIsAutoJoinEnabled = source.mIsAutoJoinEnabled;
mIsMacRandomizationEnabled = source.mIsMacRandomizationEnabled;
}
@Override
@@ -531,6 +564,7 @@ public final class PasspointConfiguration implements Parcelable {
dest.writeBundle(bundle);
dest.writeInt(mCarrierId);
dest.writeBoolean(mIsAutoJoinEnabled);
dest.writeBoolean(mIsMacRandomizationEnabled);
}
@Override
@@ -562,6 +596,7 @@ public final class PasspointConfiguration implements Parcelable {
&& mUsageLimitTimeLimitInMinutes == that.mUsageLimitTimeLimitInMinutes
&& mCarrierId == that.mCarrierId
&& mIsAutoJoinEnabled == that.mIsAutoJoinEnabled
&& mIsMacRandomizationEnabled == that.mIsMacRandomizationEnabled
&& (mServiceFriendlyNames == null ? that.mServiceFriendlyNames == null
: mServiceFriendlyNames.equals(that.mServiceFriendlyNames));
}
@@ -572,7 +607,7 @@ public final class PasspointConfiguration implements Parcelable {
mUpdateIdentifier, mCredentialPriority, mSubscriptionCreationTimeInMillis,
mSubscriptionExpirationTimeInMillis, mUsageLimitUsageTimePeriodInMinutes,
mUsageLimitStartTimeInMillis, mUsageLimitDataLimit, mUsageLimitTimeLimitInMinutes,
mServiceFriendlyNames, mCarrierId, mIsAutoJoinEnabled);
mServiceFriendlyNames, mCarrierId, mIsAutoJoinEnabled, mIsMacRandomizationEnabled);
}
@Override
@@ -627,6 +662,7 @@ public final class PasspointConfiguration implements Parcelable {
}
builder.append("CarrierId:" + mCarrierId);
builder.append("IsAutoJoinEnabled:" + mIsAutoJoinEnabled);
builder.append("mIsMacRandomizationEnabled:" + mIsMacRandomizationEnabled);
return builder.toString();
}
@@ -733,6 +769,7 @@ public final class PasspointConfiguration implements Parcelable {
config.setServiceFriendlyNames(friendlyNamesMap);
config.mCarrierId = in.readInt();
config.mIsAutoJoinEnabled = in.readBoolean();
config.mIsMacRandomizationEnabled = in.readBoolean();
return config;
}

View File

@@ -186,6 +186,11 @@ public class BaseWifiService extends IWifiManager.Stub {
throw new UnsupportedOperationException();
}
@Override
public void setMacRandomizationSettingPasspointEnabled(String fqdn, boolean enable) {
throw new UnsupportedOperationException();
}
@Override
public boolean startScan(String packageName, String featureId) {
throw new UnsupportedOperationException();

View File

@@ -1706,6 +1706,17 @@ public class WifiManagerTest {
verify(mWifiService).allowAutojoinPasspoint(fqdn, true);
}
/**
* Test behavior of
* {@link WifiManager#setMacRandomizationSettingPasspointEnabled(String, boolean)}
*/
@Test
public void testSetMacRandomizationSettingPasspointEnabled() throws Exception {
final String fqdn = "FullyQualifiedDomainName";
mWifiManager.setMacRandomizationSettingPasspointEnabled(fqdn, true);
verify(mWifiService).setMacRandomizationSettingPasspointEnabled(fqdn, true);
}
/**
* Test behavior of {@link WifiManager#disconnect()}

View File

@@ -172,6 +172,7 @@ public class PasspointConfigurationTest {
assertFalse(config.validate());
assertFalse(config.validateForR2());
assertTrue(config.isAutoJoinEnabled());
assertTrue(config.isMacRandomizationEnabled());
}
/**