summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2019-12-27 22:19:20 -0800
committerEtan Cohen <etancohen@google.com>2020-01-08 12:48:26 -0800
commit90c52617707c1a04388f2f6f5589c45e65c22858 (patch)
treed60252400ba7777b074e62722339d3092cedc2e4 /service
parent8ada790fa4f48bbd5acd7ac89571b21ed06f6975 (diff)
Add auto-join API for Passpoint configurations
Add API to enable/disable the auto-join configurations for Passpoint profiles. Bug: 139199957 Test: atest android.net.wifi Test: atest com.android.server.wifi Change-Id: I6401d264cee602ca4d3749499cf18b83fd2ab183
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java18
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java20
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java3
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointProvider.java17
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointXmlUtils.java5
5 files changed, 62 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 8b3a3213f..3ef49e61a 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -2344,6 +2344,24 @@ public class WifiServiceImpl extends BaseWifiService {
}
/**
+ * See {@link android.net.wifi.WifiManager#allowAutojoinPasspoint(String, boolean)}
+ * @param fqdn the FQDN that identifies the passpoint configuration
+ * @param enableAutojoin true to enable auto-join, false to disable
+ */
+ @Override
+ public void allowAutojoinPasspoint(String fqdn, boolean enableAutojoin) {
+ enforceNetworkSettingsPermission();
+ if (fqdn == null) {
+ throw new IllegalArgumentException("FQDN cannot be null");
+ }
+
+ int callingUid = Binder.getCallingUid();
+ mLog.info("allowAutojoinPasspoint=% uid=%").c(enableAutojoin).c(callingUid).flush();
+ mWifiThreadRunner.post(
+ () -> mPasspointManager.enableAutojoin(fqdn, enableAutojoin));
+ }
+
+ /**
* See {@link android.net.wifi.WifiManager#getConnectionInfo()}
* @return the Wi-Fi information, contained in {@link WifiInfo}.
*/
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index 25ba078d1..3778151c5 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -486,6 +486,26 @@ public class PasspointManager {
}
/**
+ * Enable or disable the auto-join configuration. Auto-join controls whether or not the
+ * passpoint configuration is used for auto connection (network selection). Note that even
+ * when auto-join is disabled the configuration can still be used for manual connection.
+ *
+ * @param fqdn The FQDN of the configuration.
+ * @param enableAutojoin true to enable auto-join, false to disable.
+ * @return true on success, false otherwise (e.g. if no such provider exists).
+ */
+ public boolean enableAutojoin(@NonNull String fqdn, boolean enableAutojoin) {
+ PasspointProvider provider = mProviders.get(fqdn);
+ if (provider == null) {
+ Log.e(TAG, "Config doesn't exist");
+ return false;
+ }
+ provider.setAutoJoinEnabled(enableAutojoin);
+ mWifiConfigManager.saveToStore(true);
+ return true;
+ }
+
+ /**
* Return the installed Passpoint provider configurations.
* An empty list will be returned when no provider is installed.
*
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java
index 84d1b7d5b..af72eec08 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java
@@ -148,6 +148,9 @@ public class PasspointNetworkNominateHelper {
if (matchedProvider.first.isFromSuggestion() != isFromSuggestion) {
continue;
}
+ if (!matchedProvider.first.isAutoJoinEnabled()) {
+ continue;
+ }
List<PasspointNetworkCandidate> candidates = candidatesPerProvider
.computeIfAbsent(matchedProvider.first, k -> new ArrayList<>());
candidates.add(new PasspointNetworkCandidate(matchedProvider.first,
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
index c305c8354..08eb34b87 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
@@ -103,7 +103,6 @@ public class PasspointProvider {
private boolean mIsShared;
private boolean mIsFromSuggestion;
-
public PasspointProvider(PasspointConfiguration config, WifiKeyStore keyStore,
TelephonyUtil telephonyUtil, long providerId, int creatorUid, String packageName,
boolean isFromSuggestion) {
@@ -192,6 +191,17 @@ public class PasspointProvider {
}
/**
+ * Enable/disable the auto-join configuration of the corresponding passpoint configuration.
+ */
+ public void setAutoJoinEnabled(boolean autoJoinEnabled) {
+ mConfig.setAutoJoinEnabled(autoJoinEnabled);
+ }
+
+ public boolean isAutoJoinEnabled() {
+ return mConfig.isAutoJoinEnabled();
+ }
+
+ /**
* Install certificates and key based on current configuration.
* Note: the certificates and keys in the configuration will get cleared once
* they're installed in the keystore.
@@ -542,6 +552,11 @@ public class PasspointProvider {
StringBuilder builder = new StringBuilder();
builder.append("ProviderId: ").append(mProviderId).append("\n");
builder.append("CreatorUID: ").append(mCreatorUid).append("\n");
+ builder.append("Best guess Carrier ID: ").append(mBestGuessCarrierId).append("\n");
+ builder.append("Ever connected: ").append(mHasEverConnected).append("\n");
+ builder.append("Shared: ").append(mIsShared).append("\n");
+ builder.append("Suggestion: ").append(mIsFromSuggestion).append("\n");
+
if (mPackageName != null) {
builder.append("PackageName: ").append(mPackageName).append("\n");
}
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointXmlUtils.java b/service/java/com/android/server/wifi/hotspot2/PasspointXmlUtils.java
index 71eba0908..7accf84c8 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointXmlUtils.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointXmlUtils.java
@@ -111,6 +111,7 @@ public class PasspointXmlUtils {
private static final String XML_TAG_USAGE_LIMIT_DATA_LIMIT = "UsageLimitDataLimit";
private static final String XML_TAG_USAGE_LIMIT_TIME_LIMIT = "UsageLimitTimeLimit";
private static final String XML_TAG_CARRIER_ID = "CarrierId";
+ private static final String XML_TAG_IS_AUTO_JOIN = "AutoJoinEnabled";
/**
* Serialize a {@link PasspointConfiguration} to the output stream as a XML block.
@@ -148,6 +149,7 @@ public class PasspointXmlUtils {
config.getServiceFriendlyNames());
}
XmlUtil.writeNextValue(out, XML_TAG_CARRIER_ID, config.getCarrierId());
+ XmlUtil.writeNextValue(out, XML_TAG_IS_AUTO_JOIN, config.isAutoJoinEnabled());
}
/**
@@ -204,6 +206,9 @@ public class PasspointXmlUtils {
case XML_TAG_CARRIER_ID:
config.setCarrierId((int) value);
break;
+ case XML_TAG_IS_AUTO_JOIN:
+ config.setAutoJoinEnabled((boolean) value);
+ break;
default:
throw new XmlPullParserException("Unknown value under "
+ "PasspointConfiguration: " + in.getName());