Merge "Add auto-join API for Passpoint configurations"

This commit is contained in:
Etan Cohen
2020-01-08 23:33:18 +00:00
committed by Android (Google) Code Review
7 changed files with 85 additions and 2 deletions

View File

@@ -5929,6 +5929,7 @@ package android.net.wifi {
public class WifiManager {
method @RequiresPermission(android.Manifest.permission.WIFI_UPDATE_USABILITY_STATS_SCORE) public void addOnWifiUsabilityStatsListener(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.OnWifiUsabilityStatsListener);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void allowAutojoin(int, boolean);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void allowAutojoinPasspoint(@NonNull String, boolean);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void connect(@NonNull android.net.wifi.WifiConfiguration, @Nullable android.net.wifi.WifiManager.ActionListener);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void connect(int, @Nullable android.net.wifi.WifiManager.ActionListener);
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void disable(int, @Nullable android.net.wifi.WifiManager.ActionListener);
@@ -6294,6 +6295,10 @@ package android.net.wifi.hotspot2 {
field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.hotspot2.OsuProvider> CREATOR;
}
public final class PasspointConfiguration implements android.os.Parcelable {
method public boolean isAutoJoinEnabled();
}
public abstract class ProvisioningCallback {
ctor public ProvisioningCallback();
method public abstract void onProvisioningComplete();

View File

@@ -90,6 +90,8 @@ interface IWifiManager
void allowAutojoin(int netId, boolean choice);
void allowAutojoinPasspoint(String fqdn, boolean enableAutoJoin);
boolean startScan(String packageName, String featureId);
List<ScanResult> getScanResults(String callingPackage, String callingFeatureId);

View File

@@ -4109,6 +4109,23 @@ public class WifiManager {
}
}
/**
* Configure auto-join settings for a Passpoint profile.
*
* @param fqdn the FQDN (fully qualified domain name) of the passpoint profile.
* @param enableAutoJoin true to enable autojoin, false to disable autojoin.
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
public void allowAutojoinPasspoint(@NonNull String fqdn, boolean enableAutoJoin) {
try {
mService.allowAutojoinPasspoint(fqdn, enableAutoJoin);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Disable an ephemeral network.
*

View File

@@ -17,6 +17,7 @@
package android.net.wifi.hotspot2;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import android.net.wifi.hotspot2.pps.Policy;
@@ -422,6 +423,41 @@ public final class PasspointConfiguration implements Parcelable {
return mCarrierId;
}
/**
* The auto-join configuration specifies whether or not the Passpoint Configuration is
* considered for auto-connection. If true then yes, if false then it isn't considered as part
* of auto-connection - but can still be manually connected to.
*/
private boolean mIsAutoJoinEnabled = 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
* indicates that only manual connection will work - the framework will not auto-associate to
* this Passpoint network.
*
* @param autoJoinEnabled true to be considered for framework auto-connection, false otherwise.
* @hide
*/
public void setAutoJoinEnabled(boolean autoJoinEnabled) {
mIsAutoJoinEnabled = autoJoinEnabled;
}
/**
* 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
* cannot. However, even when auto-connection is not possible manual connection by the user is
* possible.
*
* @return the auto-join configuration: true for auto-connection (or join) enabled, false
* otherwise.
* @hide
*/
@SystemApi
public boolean isAutoJoinEnabled() {
return mIsAutoJoinEnabled;
}
/**
* Constructor for creating PasspointConfiguration with default values.
*/
@@ -464,6 +500,7 @@ public final class PasspointConfiguration implements Parcelable {
mServiceFriendlyNames = source.mServiceFriendlyNames;
mAaaServerTrustedNames = source.mAaaServerTrustedNames;
mCarrierId = source.mCarrierId;
mIsAutoJoinEnabled = source.mIsAutoJoinEnabled;
}
@Override
@@ -493,6 +530,7 @@ public final class PasspointConfiguration implements Parcelable {
(HashMap<String, String>) mServiceFriendlyNames);
dest.writeBundle(bundle);
dest.writeInt(mCarrierId);
dest.writeBoolean(mIsAutoJoinEnabled);
}
@Override
@@ -523,6 +561,7 @@ public final class PasspointConfiguration implements Parcelable {
&& mUsageLimitDataLimit == that.mUsageLimitDataLimit
&& mUsageLimitTimeLimitInMinutes == that.mUsageLimitTimeLimitInMinutes
&& mCarrierId == that.mCarrierId
&& mIsAutoJoinEnabled == that.mIsAutoJoinEnabled
&& (mServiceFriendlyNames == null ? that.mServiceFriendlyNames == null
: mServiceFriendlyNames.equals(that.mServiceFriendlyNames));
}
@@ -533,7 +572,7 @@ public final class PasspointConfiguration implements Parcelable {
mUpdateIdentifier, mCredentialPriority, mSubscriptionCreationTimeInMillis,
mSubscriptionExpirationTimeInMillis, mUsageLimitUsageTimePeriodInMinutes,
mUsageLimitStartTimeInMillis, mUsageLimitDataLimit, mUsageLimitTimeLimitInMinutes,
mServiceFriendlyNames, mCarrierId);
mServiceFriendlyNames, mCarrierId, mIsAutoJoinEnabled);
}
@Override
@@ -587,6 +626,7 @@ public final class PasspointConfiguration implements Parcelable {
builder.append("ServiceFriendlyNames: ").append(mServiceFriendlyNames);
}
builder.append("CarrierId:" + mCarrierId);
builder.append("IsAutoJoinEnabled:" + mIsAutoJoinEnabled);
return builder.toString();
}
@@ -692,6 +732,7 @@ public final class PasspointConfiguration implements Parcelable {
"serviceFriendlyNames");
config.setServiceFriendlyNames(friendlyNamesMap);
config.mCarrierId = in.readInt();
config.mIsAutoJoinEnabled = in.readBoolean();
return config;
}

View File

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

View File

@@ -1672,9 +1672,21 @@ public class WifiManagerTest {
@Test
public void testAllowAutojoin() throws Exception {
mWifiManager.allowAutojoin(1, true);
verify(mWifiService).allowAutojoin(eq(1), eq(true));
verify(mWifiService).allowAutojoin(1, true);
}
/**
* Test behavior of {@link WifiManager#allowAutojoinPasspoint(String, boolean)}
* @throws Exception
*/
@Test
public void testAllowAutojoinPasspoint() throws Exception {
final String fqdn = "FullyQualifiedDomainName";
mWifiManager.allowAutojoinPasspoint(fqdn, true);
verify(mWifiService).allowAutojoinPasspoint(fqdn, true);
}
/**
* Test behavior of {@link WifiManager#disconnect()}
*/

View File

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