summaryrefslogtreecommitdiff
path: root/wifi
diff options
context:
space:
mode:
Diffstat (limited to 'wifi')
-rw-r--r--wifi/Android.bp3
-rw-r--r--wifi/java/android/net/wifi/IScoreChangeCallback.aidl4
-rw-r--r--wifi/java/android/net/wifi/IWifiManager.aidl6
-rw-r--r--wifi/java/android/net/wifi/SoftApConfiguration.java3
-rw-r--r--wifi/java/android/net/wifi/WifiConfiguration.java214
-rw-r--r--wifi/java/android/net/wifi/WifiEnterpriseConfig.java4
-rw-r--r--wifi/java/android/net/wifi/WifiFrameworkInitializer.java17
-rw-r--r--wifi/java/android/net/wifi/WifiInfo.java34
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java121
-rw-r--r--wifi/java/android/net/wifi/WifiNetworkAgentSpecifier.java56
-rw-r--r--wifi/java/android/net/wifi/WifiNetworkSpecifier.java71
-rw-r--r--wifi/java/android/net/wifi/WifiNetworkSuggestion.java24
-rwxr-xr-xwifi/java/android/net/wifi/WifiOemMigrationHook.java (renamed from wifi/java/android/net/wifi/WifiOemConfigStoreMigrationHook.java)63
-rw-r--r--wifi/java/android/net/wifi/WifiScanner.java42
-rw-r--r--wifi/java/android/net/wifi/aware/WifiAwareAgentNetworkSpecifier.java6
-rw-r--r--wifi/java/android/net/wifi/aware/WifiAwareManager.java7
-rw-r--r--wifi/java/android/net/wifi/aware/WifiAwareNetworkSpecifier.java35
-rw-r--r--wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java42
-rw-r--r--wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java8
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pConfig.java14
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pGroup.java18
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java6
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pManager.java31
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java25
-rw-r--r--wifi/java/android/net/wifi/wificond/NativeScanResult.java153
-rw-r--r--wifi/java/android/net/wifi/wificond/NativeWifiClient.java34
-rw-r--r--wifi/java/android/net/wifi/wificond/PnoSettings.java15
-rw-r--r--wifi/java/android/net/wifi/wificond/RadioChainInfo.java4
-rw-r--r--wifi/java/android/net/wifi/wificond/WifiCondManager.java105
-rw-r--r--wifi/java/com/android/server/wifi/BaseWifiService.java641
-rw-r--r--wifi/tests/src/android/net/wifi/SoftApConfigurationTest.java40
-rw-r--r--wifi/tests/src/android/net/wifi/WifiConfigurationTest.java14
-rw-r--r--wifi/tests/src/android/net/wifi/WifiManagerTest.java23
-rw-r--r--wifi/tests/src/android/net/wifi/WifiNetworkAgentSpecifierTest.java94
-rw-r--r--wifi/tests/src/android/net/wifi/WifiNetworkSpecifierTest.java63
-rw-r--r--wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java16
-rw-r--r--wifi/tests/src/android/net/wifi/aware/WifiAwareAgentNetworkSpecifierTest.java13
-rw-r--r--wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java2
-rw-r--r--wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java95
-rw-r--r--wifi/tests/src/android/net/wifi/p2p/WifiP2pDeviceTest.java2
-rw-r--r--wifi/tests/src/android/net/wifi/p2p/WifiP2pWfdInfoTest.java4
-rw-r--r--wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java3
-rw-r--r--wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java9
43 files changed, 903 insertions, 1281 deletions
diff --git a/wifi/Android.bp b/wifi/Android.bp
index dae04c6c3a25..1763975e7770 100644
--- a/wifi/Android.bp
+++ b/wifi/Android.bp
@@ -47,7 +47,7 @@ filegroup {
// framework-wifi.jar. This is not a good idea, should move WifiNetworkScoreCache
// to a separate package.
"java/android/net/wifi/WifiNetworkScoreCache.java",
- "java/android/net/wifi/WifiOemConfigStoreMigrationHook.java",
+ "java/android/net/wifi/WifiOemMigrationHook.java",
"java/android/net/wifi/wificond/*.java",
":libwificond_ipc_aidl",
],
@@ -63,7 +63,6 @@ test_access_hidden_api_whitelist = [
"//frameworks/base/wifi/tests",
"//frameworks/opt/net/wifi/tests/wifitests:__subpackages__",
- "//frameworks/opt/net/wifi/libs/WifiTrackerLib/tests",
"//external/robolectric-shadows:__subpackages__",
"//frameworks/base/packages/SettingsLib/tests/integ",
"//external/sl4a:__subpackages__",
diff --git a/wifi/java/android/net/wifi/IScoreChangeCallback.aidl b/wifi/java/android/net/wifi/IScoreChangeCallback.aidl
index fd236107bc6e..462a97844d76 100644
--- a/wifi/java/android/net/wifi/IScoreChangeCallback.aidl
+++ b/wifi/java/android/net/wifi/IScoreChangeCallback.aidl
@@ -16,6 +16,8 @@
package android.net.wifi;
+import android.net.NetworkScore;
+
/**
* Interface for Wi-Fi network score callback.
*
@@ -23,7 +25,7 @@ package android.net.wifi;
*/
oneway interface IScoreChangeCallback
{
- void onStatusChange(int sessionId, boolean exiting);
+ void onScoreChange(int sessionId, in NetworkScore score);
void onTriggerUpdateOfWifiUsabilityStats(int sessionId);
}
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 1f1c0c12cf21..d4e024dbe0c7 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -266,4 +266,10 @@ interface IWifiManager
* Return the Map of {@link WifiNetworkSuggestion} and the list of <ScanResult>
*/
Map getMatchingScanResults(in List<WifiNetworkSuggestion> networkSuggestions, in List<ScanResult> scanResults, String callingPackage, String callingFeatureId);
+
+ void setScanThrottleEnabled(boolean enable);
+
+ boolean isScanThrottleEnabled();
+
+ Map getAllMatchingPasspointProfilesForScanResults(in List<ScanResult> scanResult);
}
diff --git a/wifi/java/android/net/wifi/SoftApConfiguration.java b/wifi/java/android/net/wifi/SoftApConfiguration.java
index c8fd2434e64f..0db3313ae137 100644
--- a/wifi/java/android/net/wifi/SoftApConfiguration.java
+++ b/wifi/java/android/net/wifi/SoftApConfiguration.java
@@ -519,6 +519,9 @@ public final class SoftApConfiguration implements Parcelable {
case BAND_5GHZ:
wifiConfig.apBand = WifiConfiguration.AP_BAND_5GHZ;
break;
+ case BAND_2GHZ | BAND_5GHZ:
+ wifiConfig.apBand = WifiConfiguration.AP_BAND_ANY;
+ break;
case BAND_ANY:
wifiConfig.apBand = WifiConfiguration.AP_BAND_ANY;
break;
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 0ef224a5f8ee..a720236689d3 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -373,6 +373,7 @@ public class WifiConfiguration implements Parcelable {
* ECDHE_ECDSA
* ECDHE_RSA
* </pre>
+ * @hide
*/
public static class SuiteBCipher {
private SuiteBCipher() { }
@@ -567,14 +568,12 @@ public class WifiConfiguration implements Parcelable {
* 2GHz band.
* @hide
*/
- @SystemApi
public static final int AP_BAND_2GHZ = 0;
/**
* 5GHz band.
* @hide
*/
- @SystemApi
public static final int AP_BAND_5GHZ = 1;
/**
@@ -582,7 +581,6 @@ public class WifiConfiguration implements Parcelable {
* operating country code and current radio conditions.
* @hide
*/
- @SystemApi
public static final int AP_BAND_ANY = -1;
/**
@@ -592,7 +590,7 @@ public class WifiConfiguration implements Parcelable {
*
* @hide
*/
- @SystemApi
+ @UnsupportedAppUsage
@ApBand
public int apBand = AP_BAND_2GHZ;
@@ -715,8 +713,8 @@ public class WifiConfiguration implements Parcelable {
public BitSet allowedGroupManagementCiphers;
/**
* The set of SuiteB ciphers supported by this configuration.
- * To be used for WPA3-Enterprise mode.
- * See {@link SuiteBCipher} for descriptions of the values.
+ * To be used for WPA3-Enterprise mode. Set automatically by the framework based on the
+ * certificate type that is used in this configuration.
*/
@NonNull
public BitSet allowedSuiteBCiphers;
@@ -1251,8 +1249,8 @@ public class WifiConfiguration implements Parcelable {
/** @hide */
@Retention(RetentionPolicy.SOURCE)
- @IntDef(value = {
- NETWORK_SELECTION_ENABLE,
+ @IntDef(prefix = "DISABLED_", value = {
+ DISABLED_NONE,
DISABLED_ASSOCIATION_REJECTION,
DISABLED_AUTHENTICATION_FAILURE,
DISABLED_DHCP_FAILURE,
@@ -1266,7 +1264,7 @@ public class WifiConfiguration implements Parcelable {
// Quality Network disabled reasons
/** Default value. Means not disabled. */
- public static final int NETWORK_SELECTION_ENABLE = 0;
+ public static final int DISABLED_NONE = 0;
/**
* The starting index for network selection disabled reasons.
* @hide
@@ -1303,10 +1301,34 @@ public class WifiConfiguration implements Parcelable {
public static final int DISABLED_BY_WRONG_PASSWORD = 8;
/** This network is disabled because service is not subscribed. */
public static final int DISABLED_AUTHENTICATION_NO_SUBSCRIPTION = 9;
- /** All other disable reasons should be strictly less than this value. */
+ /**
+ * All other disable reasons should be strictly less than this value.
+ * @hide
+ */
public static final int NETWORK_SELECTION_DISABLED_MAX = 10;
/**
+ * Get an integer that is equal to the maximum integer value of all the
+ * DISABLED_* reasons
+ * e.g. {@link #DISABLED_NONE}, {@link #DISABLED_ASSOCIATION_REJECTION}, etc.
+ *
+ * All DISABLED_* constants will be contiguous in the range
+ * 0, 1, 2, 3, ..., getMaxNetworkSelectionDisableReasons()
+ *
+ * <br />
+ * For example, this can be used to iterate through all the network selection
+ * disable reasons like so:
+ * <pre>{@code
+ * for (int reason = 0; reason <= getMaxNetworkSelectionDisableReasons(); reason++) {
+ * ...
+ * }
+ * }</pre>
+ */
+ public static int getMaxNetworkSelectionDisableReason() {
+ return NETWORK_SELECTION_DISABLED_MAX - 1;
+ }
+
+ /**
* Contains info about disable reasons.
* @hide
*/
@@ -1355,7 +1377,7 @@ public class WifiConfiguration implements Parcelable {
private static SparseArray<DisableReasonInfo> buildDisableReasonInfos() {
SparseArray<DisableReasonInfo> reasons = new SparseArray<>();
- reasons.append(NETWORK_SELECTION_ENABLE,
+ reasons.append(DISABLED_NONE,
new DisableReasonInfo(
// Note that these strings are persisted in
// XmlUtil.NetworkSelectionStatusXmlUtil#writeToXml,
@@ -1609,7 +1631,7 @@ public class WifiConfiguration implements Parcelable {
}
/** True if the device has ever connected to this network, false otherwise. */
- public boolean getHasEverConnected() {
+ public boolean hasEverConnected() {
return mHasEverConnected;
}
@@ -1649,7 +1671,7 @@ public class WifiConfiguration implements Parcelable {
/**
*
* Set the current network's disable reason.
- * One of the {@link #NETWORK_SELECTION_ENABLE} or DISABLED_* constants.
+ * One of the {@link #DISABLED_NONE} or DISABLED_* constants.
* e.g. {@link #DISABLED_ASSOCIATION_REJECTION}.
* @see NetworkSelectionStatus#getNetworkSelectionDisableReason()
*/
@@ -1673,7 +1695,7 @@ public class WifiConfiguration implements Parcelable {
/**
* Get the network disable reason string for a reason code (for debugging).
- * @param reason specific error reason. One of the {@link #NETWORK_SELECTION_ENABLE} or
+ * @param reason specific error reason. One of the {@link #DISABLED_NONE} or
* DISABLED_* constants e.g. {@link #DISABLED_ASSOCIATION_REJECTION}.
* @return network disable reason string, or null if the reason is invalid.
*/
@@ -1708,7 +1730,10 @@ public class WifiConfiguration implements Parcelable {
return mStatus;
}
- /** True if the current network is enabled to join network selection, false otherwise. */
+ /**
+ * True if the current network is enabled to join network selection, false otherwise.
+ * @hide
+ */
public boolean isNetworkEnabled() {
return mStatus == NETWORK_SELECTION_ENABLED;
}
@@ -1721,7 +1746,10 @@ public class WifiConfiguration implements Parcelable {
return mStatus == NETWORK_SELECTION_TEMPORARY_DISABLED;
}
- /** True if the current network is permanently disabled, false otherwise. */
+ /**
+ * True if the current network is permanently disabled, false otherwise.
+ * @hide
+ */
public boolean isNetworkPermanentlyDisabled() {
return mStatus == NETWORK_SELECTION_PERMANENTLY_DISABLED;
}
@@ -1739,7 +1767,7 @@ public class WifiConfiguration implements Parcelable {
/**
* Returns the current network's disable reason.
- * One of the {@link #NETWORK_SELECTION_ENABLE} or DISABLED_* constants
+ * One of the {@link #DISABLED_NONE} or DISABLED_* constants
* e.g. {@link #DISABLED_ASSOCIATION_REJECTION}.
*/
@NetworkSelectionDisableReason
@@ -1779,13 +1807,13 @@ public class WifiConfiguration implements Parcelable {
/**
* Get the disable counter of a specific reason.
- * @param reason specific failure reason. One of the {@link #NETWORK_SELECTION_ENABLE} or
+ * @param reason specific failure reason. One of the {@link #DISABLED_NONE} or
* DISABLED_* constants e.g. {@link #DISABLED_ASSOCIATION_REJECTION}.
* @exception IllegalArgumentException for invalid reason
* @return counter number for specific error reason.
*/
public int getDisableReasonCounter(@NetworkSelectionDisableReason int reason) {
- if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ if (reason >= DISABLED_NONE && reason < NETWORK_SELECTION_DISABLED_MAX) {
return mNetworkSeclectionDisableCounter[reason];
} else {
throw new IllegalArgumentException("Illegal reason value: " + reason);
@@ -1800,7 +1828,7 @@ public class WifiConfiguration implements Parcelable {
* @hide
*/
public void setDisableReasonCounter(int reason, int value) {
- if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ if (reason >= DISABLED_NONE && reason < NETWORK_SELECTION_DISABLED_MAX) {
mNetworkSeclectionDisableCounter[reason] = value;
} else {
throw new IllegalArgumentException("Illegal reason value: " + reason);
@@ -1814,7 +1842,7 @@ public class WifiConfiguration implements Parcelable {
* @hide
*/
public void incrementDisableReasonCounter(int reason) {
- if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ if (reason >= DISABLED_NONE && reason < NETWORK_SELECTION_DISABLED_MAX) {
mNetworkSeclectionDisableCounter[reason]++;
} else {
throw new IllegalArgumentException("Illegal reason value: " + reason);
@@ -1828,8 +1856,8 @@ public class WifiConfiguration implements Parcelable {
* @hide
*/
public void clearDisableReasonCounter(int reason) {
- if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
- mNetworkSeclectionDisableCounter[reason] = NETWORK_SELECTION_ENABLE;
+ if (reason >= DISABLED_NONE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ mNetworkSeclectionDisableCounter[reason] = DISABLED_NONE;
} else {
throw new IllegalArgumentException("Illegal reason value: " + reason);
}
@@ -1840,7 +1868,7 @@ public class WifiConfiguration implements Parcelable {
* @hide
*/
public void clearDisableReasonCounter() {
- Arrays.fill(mNetworkSeclectionDisableCounter, NETWORK_SELECTION_ENABLE);
+ Arrays.fill(mNetworkSeclectionDisableCounter, DISABLED_NONE);
}
/**
@@ -1870,7 +1898,7 @@ public class WifiConfiguration implements Parcelable {
public void copy(NetworkSelectionStatus source) {
mStatus = source.mStatus;
mNetworkSelectionDisableReason = source.mNetworkSelectionDisableReason;
- for (int index = NETWORK_SELECTION_ENABLE; index < NETWORK_SELECTION_DISABLED_MAX;
+ for (int index = DISABLED_NONE; index < NETWORK_SELECTION_DISABLED_MAX;
index++) {
mNetworkSeclectionDisableCounter[index] =
source.mNetworkSeclectionDisableCounter[index];
@@ -1881,14 +1909,14 @@ public class WifiConfiguration implements Parcelable {
setCandidate(source.getCandidate());
setCandidateScore(source.getCandidateScore());
setConnectChoice(source.getConnectChoice());
- setHasEverConnected(source.getHasEverConnected());
+ setHasEverConnected(source.hasEverConnected());
}
/** @hide */
public void writeToParcel(Parcel dest) {
dest.writeInt(getNetworkSelectionStatus());
dest.writeInt(getNetworkSelectionDisableReason());
- for (int index = NETWORK_SELECTION_ENABLE; index < NETWORK_SELECTION_DISABLED_MAX;
+ for (int index = DISABLED_NONE; index < NETWORK_SELECTION_DISABLED_MAX;
index++) {
dest.writeInt(getDisableReasonCounter(index));
}
@@ -1900,14 +1928,14 @@ public class WifiConfiguration implements Parcelable {
} else {
dest.writeInt(CONNECT_CHOICE_NOT_EXISTS);
}
- dest.writeInt(getHasEverConnected() ? 1 : 0);
+ dest.writeInt(hasEverConnected() ? 1 : 0);
}
/** @hide */
public void readFromParcel(Parcel in) {
setNetworkSelectionStatus(in.readInt());
setNetworkSelectionDisableReason(in.readInt());
- for (int index = NETWORK_SELECTION_ENABLE; index < NETWORK_SELECTION_DISABLED_MAX;
+ for (int index = DISABLED_NONE; index < NETWORK_SELECTION_DISABLED_MAX;
index++) {
setDisableReasonCounter(index, in.readInt());
}
@@ -1929,54 +1957,38 @@ public class WifiConfiguration implements Parcelable {
private NetworkSelectionStatus mNetworkSelectionStatus = new NetworkSelectionStatus();
/**
- * @hide
* This class is intended to store extra failure reason information for the most recent
* connection attempt, so that it may be surfaced to the settings UI
+ * @hide
*/
- @SystemApi
+ // TODO(b/148626966): called by SUW via reflection, remove once SUW is updated
public static class RecentFailure {
private RecentFailure() {}
- /** @hide */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(value = {NONE, STATUS_AP_UNABLE_TO_HANDLE_NEW_STA})
- public @interface AssociationStatus {}
-
- /**
- * No recent failure, or no specific reason given for the recent connection failure
- */
- public static final int NONE = 0;
- /**
- * Connection to this network recently failed due to Association Rejection Status 17
- * (AP is full)
- */
- public static final int STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17;
/**
* Association Rejection Status code (NONE for success/non-association-rejection-fail)
*/
- @AssociationStatus
- private int mAssociationStatus = NONE;
+ @RecentFailureReason
+ private int mAssociationStatus = RECENT_FAILURE_NONE;
/**
* @param status the association status code for the recent failure
- * @hide
*/
- public void setAssociationStatus(@AssociationStatus int status) {
+ public void setAssociationStatus(@RecentFailureReason int status) {
mAssociationStatus = status;
}
/**
* Sets the RecentFailure to NONE
- * @hide
*/
public void clear() {
- mAssociationStatus = NONE;
+ mAssociationStatus = RECENT_FAILURE_NONE;
}
/**
- * Get the recent failure code. One of {@link #NONE} or
- * {@link #STATUS_AP_UNABLE_TO_HANDLE_NEW_STA}.
+ * Get the recent failure code. One of {@link #RECENT_FAILURE_NONE} or
+ * {@link #RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA}.
*/
- @AssociationStatus
+ @RecentFailureReason
public int getAssociationStatus() {
return mAssociationStatus;
}
@@ -1986,10 +1998,47 @@ public class WifiConfiguration implements Parcelable {
* RecentFailure member
* @hide
*/
+ // TODO(b/148626966): called by SUW via reflection, once SUW is updated, make private and
+ // rename to mRecentFailure
@NonNull
- @SystemApi
public final RecentFailure recentFailure = new RecentFailure();
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = "RECENT_FAILURE_", value = {
+ RECENT_FAILURE_NONE,
+ RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA})
+ public @interface RecentFailureReason {}
+
+ /**
+ * No recent failure, or no specific reason given for the recent connection failure
+ * @hide
+ */
+ @SystemApi
+ public static final int RECENT_FAILURE_NONE = 0;
+ /**
+ * Connection to this network recently failed due to Association Rejection Status 17
+ * (AP is full)
+ * @hide
+ */
+ @SystemApi
+ public static final int RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA = 17;
+
+ /**
+ * Get the failure reason for the most recent connection attempt, or
+ * {@link #RECENT_FAILURE_NONE} if there was no failure.
+ *
+ * Failure reasons include:
+ * {@link #RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA}
+ *
+ * @hide
+ */
+ @RecentFailureReason
+ @SystemApi
+ public int getRecentFailureReason() {
+ return recentFailure.getAssociationStatus();
+ }
+
/**
* Get the network selection status.
* @hide
@@ -2063,7 +2112,8 @@ public class WifiConfiguration implements Parcelable {
return !TextUtils.isEmpty(FQDN)
&& !TextUtils.isEmpty(providerFriendlyName)
&& enterpriseConfig != null
- && enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE;
+ && enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE
+ && !TextUtils.isEmpty(mPasspointUniqueId);
}
/**
@@ -2129,8 +2179,8 @@ public class WifiConfiguration implements Parcelable {
sbuf.append(" mNetworkSelectionDisableReason ")
.append(mNetworkSelectionStatus.getNetworkDisableReasonString() + "\n");
- for (int index = mNetworkSelectionStatus.NETWORK_SELECTION_ENABLE;
- index < mNetworkSelectionStatus.NETWORK_SELECTION_DISABLED_MAX; index++) {
+ for (int index = NetworkSelectionStatus.DISABLED_NONE;
+ index < NetworkSelectionStatus.NETWORK_SELECTION_DISABLED_MAX; index++) {
if (mNetworkSelectionStatus.getDisableReasonCounter(index) != 0) {
sbuf.append(NetworkSelectionStatus.getNetworkDisableReasonString(index)
+ " counter:" + mNetworkSelectionStatus.getDisableReasonCounter(index)
@@ -2142,7 +2192,7 @@ public class WifiConfiguration implements Parcelable {
sbuf.append(" connect choice: ").append(mNetworkSelectionStatus.getConnectChoice());
}
sbuf.append(" hasEverConnected: ")
- .append(mNetworkSelectionStatus.getHasEverConnected()).append("\n");
+ .append(mNetworkSelectionStatus.hasEverConnected()).append("\n");
if (this.numAssociation > 0) {
sbuf.append(" numAssociation ").append(this.numAssociation).append("\n");
@@ -2445,12 +2495,17 @@ public class WifiConfiguration implements Parcelable {
*/
@NonNull
public String getKey() {
- String key = providerFriendlyName == null
- ? getSsidAndSecurityTypeString()
- : FQDN + KeyMgmt.strings[KeyMgmt.WPA_EAP];
+ // 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();
if (!shared) {
key += "-" + UserHandle.getUserHandleForUid(creatorUid).getIdentifier();
}
+
return key;
}
@@ -2511,7 +2566,7 @@ public class WifiConfiguration implements Parcelable {
* @hide
*/
@Nullable
- @SystemApi
+ @UnsupportedAppUsage
public StaticIpConfiguration getStaticIpConfiguration() {
return mIpConfiguration.getStaticIpConfiguration();
}
@@ -2527,7 +2582,7 @@ public class WifiConfiguration implements Parcelable {
* @hide
*/
@NonNull
- @SystemApi
+ @UnsupportedAppUsage
public IpConfiguration.IpAssignment getIpAssignment() {
return mIpConfiguration.getIpAssignment();
}
@@ -2543,7 +2598,7 @@ public class WifiConfiguration implements Parcelable {
* @hide
*/
@NonNull
- @SystemApi
+ @UnsupportedAppUsage
public IpConfiguration.ProxySettings getProxySettings() {
return mIpConfiguration.getProxySettings();
}
@@ -2606,7 +2661,7 @@ public class WifiConfiguration implements Parcelable {
* Set the {@link ProxySettings} and {@link ProxyInfo} for this network.
* @hide
*/
- @SystemApi
+ @UnsupportedAppUsage
public void setProxy(@NonNull ProxySettings settings, @NonNull ProxyInfo proxy) {
mIpConfiguration.setProxySettings(settings);
mIpConfiguration.setHttpProxy(proxy);
@@ -2705,6 +2760,7 @@ public class WifiConfiguration implements Parcelable {
requirePMF = source.requirePMF;
updateIdentifier = source.updateIdentifier;
carrierId = source.carrierId;
+ mPasspointUniqueId = source.mPasspointUniqueId;
}
}
@@ -2777,6 +2833,7 @@ public class WifiConfiguration implements Parcelable {
dest.writeInt(osu ? 1 : 0);
dest.writeLong(randomizedMacExpirationTimeMs);
dest.writeInt(carrierId);
+ dest.writeString(mPasspointUniqueId);
}
/** Implement the Parcelable interface {@hide} */
@@ -2851,6 +2908,7 @@ public class WifiConfiguration implements Parcelable {
config.osu = in.readInt() != 0;
config.randomizedMacExpirationTimeMs = in.readLong();
config.carrierId = in.readInt();
+ config.mPasspointUniqueId = in.readString();
return config;
}
@@ -2858,4 +2916,28 @@ public class WifiConfiguration implements Parcelable {
return new WifiConfiguration[size];
}
};
+
+ /**
+ * Passpoint Unique identifier
+ * @hide
+ */
+ private String mPasspointUniqueId = null;
+
+ /**
+ * Set the Passpoint unique identifier
+ * @param uniqueId Passpoint unique identifier to be set
+ * @hide
+ */
+ public void setPasspointUniqueId(String uniqueId) {
+ mPasspointUniqueId = uniqueId;
+ }
+
+ /**
+ * Set the Passpoint unique identifier
+ * @hide
+ */
+ public String getPasspointUniqueId() {
+ return mPasspointUniqueId;
+ }
+
}
diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
index 04016b606b96..db0d36e5c086 100644
--- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
+++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
@@ -60,13 +60,13 @@ public class WifiEnterpriseConfig implements Parcelable {
"android.net.wifi.extra.WAPI_AS_CERTIFICATE_DATA";
/**
- * Intent extra: name for WAPI AS certificates
+ * Intent extra: name for WAPI USER certificates
*/
public static final String EXTRA_WAPI_USER_CERTIFICATE_NAME =
"android.net.wifi.extra.WAPI_USER_CERTIFICATE_NAME";
/**
- * Intent extra: data for WAPI AS certificates
+ * Intent extra: data for WAPI USER certificates
*/
public static final String EXTRA_WAPI_USER_CERTIFICATE_DATA =
"android.net.wifi.extra.WAPI_USER_CERTIFICATE_DATA";
diff --git a/wifi/java/android/net/wifi/WifiFrameworkInitializer.java b/wifi/java/android/net/wifi/WifiFrameworkInitializer.java
index 002820b1bcc8..1507199b0264 100644
--- a/wifi/java/android/net/wifi/WifiFrameworkInitializer.java
+++ b/wifi/java/android/net/wifi/WifiFrameworkInitializer.java
@@ -102,15 +102,6 @@ public class WifiFrameworkInitializer {
}
);
SystemServiceRegistry.registerContextAwareService(
- Context.WIFI_RTT_SERVICE,
- RttManager.class,
- (context, serviceBinder) -> {
- IWifiRttManager service = IWifiRttManager.Stub.asInterface(serviceBinder);
- WifiRttManager wifiRttManager = new WifiRttManager(context, service);
- return new RttManager(context, wifiRttManager);
- }
- );
- SystemServiceRegistry.registerContextAwareService(
Context.WIFI_RTT_RANGING_SERVICE,
WifiRttManager.class,
(context, serviceBinder) -> {
@@ -118,5 +109,13 @@ public class WifiFrameworkInitializer {
return new WifiRttManager(context, service);
}
);
+ SystemServiceRegistry.registerContextAwareService(
+ Context.WIFI_RTT_SERVICE,
+ RttManager.class,
+ context -> {
+ WifiRttManager wifiRttManager = context.getSystemService(WifiRttManager.class);
+ return new RttManager(context, wifiRttManager);
+ }
+ );
}
}
diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java
index 7c031eaaeaf4..0c306b4fb8cc 100644
--- a/wifi/java/android/net/wifi/WifiInfo.java
+++ b/wifi/java/android/net/wifi/WifiInfo.java
@@ -291,6 +291,11 @@ public class WifiInfo implements Parcelable {
*/
private boolean mMeteredHint;
+ /**
+ * Passpoint unique key
+ */
+ private String mPasspointUniqueId;
+
/** @hide */
@UnsupportedAppUsage
public WifiInfo() {
@@ -322,6 +327,7 @@ public class WifiInfo implements Parcelable {
setRequestingPackageName(null);
setFQDN(null);
setProviderFriendlyName(null);
+ setPasspointUniqueId(null);
txBad = 0;
txSuccess = 0;
rxSuccess = 0;
@@ -370,6 +376,7 @@ public class WifiInfo implements Parcelable {
mWifiStandard = source.mWifiStandard;
mMaxSupportedTxLinkSpeed = source.mMaxSupportedTxLinkSpeed;
mMaxSupportedRxLinkSpeed = source.mMaxSupportedRxLinkSpeed;
+ mPasspointUniqueId = source.mPasspointUniqueId;
}
}
@@ -449,9 +456,8 @@ public class WifiInfo implements Parcelable {
* <p>
* If the SSID can be decoded as UTF-8, it will be returned surrounded by double
* quotation marks. Otherwise, it is returned as a string of hex digits.
- * The SSID may be
- * <lt>&lt;unknown ssid&gt;, if there is no network currently connected or if the caller has
- * insufficient permissions to access the SSID.<lt>
+ * The SSID may be {@link WifiManager#UNKNOWN_SSID}, if there is no network currently connected
+ * or if the caller has insufficient permissions to access the SSID.
* </p>
* <p>
* Prior to {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, this method
@@ -978,6 +984,7 @@ public class WifiInfo implements Parcelable {
dest.writeInt(mWifiStandard);
dest.writeInt(mMaxSupportedTxLinkSpeed);
dest.writeInt(mMaxSupportedRxLinkSpeed);
+ dest.writeString(mPasspointUniqueId);
}
/** Implement the Parcelable interface {@hide} */
@@ -1022,6 +1029,7 @@ public class WifiInfo implements Parcelable {
info.mWifiStandard = in.readInt();
info.mMaxSupportedTxLinkSpeed = in.readInt();
info.mMaxSupportedRxLinkSpeed = in.readInt();
+ info.mPasspointUniqueId = in.readString();
return info;
}
@@ -1029,4 +1037,24 @@ public class WifiInfo implements Parcelable {
return new WifiInfo[size];
}
};
+
+ /**
+ * Set the Passpoint unique identifier for the current connection
+ *
+ * @param passpointUniqueId Unique identifier
+ * @hide
+ */
+ public void setPasspointUniqueId(@Nullable String passpointUniqueId) {
+ mPasspointUniqueId = passpointUniqueId;
+ }
+
+ /**
+ * Get the Passpoint unique identifier for the current connection
+ *
+ * @return Passpoint unique identifier
+ * @hide
+ */
+ public @Nullable String getPasspointUniqueId() {
+ return mPasspointUniqueId;
+ }
}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 76f97164032c..fb30910c17b1 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -38,6 +38,7 @@ import android.net.ConnectivityManager;
import android.net.DhcpInfo;
import android.net.MacAddress;
import android.net.Network;
+import android.net.NetworkScore;
import android.net.NetworkStack;
import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
@@ -256,12 +257,12 @@ public class WifiManager {
* - {@link #EXTRA_SCAN_AVAILABLE}
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_WIFI_SCAN_AVAILABLE =
- "android.net.wifi.action.WIFI_SCAN_AVAILABLE";
+ public static final String ACTION_WIFI_SCAN_AVAILABILITY_CHANGED =
+ "android.net.wifi.action.WIFI_SCAN_AVAILABILITY_CHANGED";
/**
* A boolean extra indicating whether scanning is currently available.
- * Sent in the broadcast {@link #ACTION_WIFI_SCAN_AVAILABLE}.
+ * Sent in the broadcast {@link #ACTION_WIFI_SCAN_AVAILABILITY_CHANGED}.
* Its value is true if scanning is currently available, false otherwise.
*/
public static final String EXTRA_SCAN_AVAILABLE = "android.net.wifi.extra.SCAN_AVAILABLE";
@@ -1399,8 +1400,7 @@ public class WifiManager {
List<Pair<WifiConfiguration, Map<Integer, List<ScanResult>>>> configs = new ArrayList<>();
try {
Map<String, Map<Integer, List<ScanResult>>> results =
- mService.getAllMatchingFqdnsForScanResults(
- scanResults);
+ mService.getAllMatchingPasspointProfilesForScanResults(scanResults);
if (results.isEmpty()) {
return configs;
}
@@ -1408,8 +1408,8 @@ public class WifiManager {
mService.getWifiConfigsForPasspointProfiles(
new ArrayList<>(results.keySet()));
for (WifiConfiguration configuration : wifiConfigurations) {
- Map<Integer, List<ScanResult>> scanResultsPerNetworkType = results.get(
- configuration.FQDN);
+ Map<Integer, List<ScanResult>> scanResultsPerNetworkType =
+ results.get(configuration.getKey());
if (scanResultsPerNetworkType != null) {
configs.add(Pair.create(configuration, scanResultsPerNetworkType));
}
@@ -1961,9 +1961,11 @@ public class WifiManager {
* for connecting to Passpoint networks that are operated by the Passpoint
* service provider specified in the configuration.
*
- * Each configuration is uniquely identified by its FQDN (Fully Qualified Domain
- * Name). In the case when there is an existing configuration with the same
- * FQDN, the new configuration will replace the existing configuration.
+ * Each configuration is uniquely identified by a unique key which depends on the contents of
+ * the configuration. This allows the caller to install multiple profiles with the same FQDN
+ * (Fully qualified domain name). Therefore, in order to update an existing profile, it is
+ * first required to remove it using {@link WifiManager#removePasspointConfiguration(String)}.
+ * Otherwise, a new profile will be added with both configuration.
*
* @param config The Passpoint configuration to be added
* @throws IllegalArgumentException if configuration is invalid or Passpoint is not enabled on
@@ -2624,8 +2626,8 @@ public class WifiManager {
public void getWifiActivityEnergyInfoAsync(
@NonNull @CallbackExecutor Executor executor,
@NonNull OnWifiActivityEnergyInfoListener listener) {
- if (executor == null) throw new IllegalArgumentException("executor cannot be null");
- if (listener == null) throw new IllegalArgumentException("listener cannot be null");
+ Objects.requireNonNull(executor, "executor cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
try {
mService.getWifiActivityEnergyInfoAsync(
new OnWifiActivityEnergyInfoProxy(executor, listener));
@@ -2981,7 +2983,7 @@ public class WifiManager {
}
/**
- * Start Soft AP (hotspot) mode with the specified configuration.
+ * Start Soft AP (hotspot) mode for tethering purposes with the specified configuration.
* Note that starting Soft AP mode may disable station mode operation if the device does not
* support concurrency.
* @param wifiConfig SSID, security and channel details as part of WifiConfiguration, or null to
@@ -3277,7 +3279,7 @@ public class WifiManager {
}
/**
- * Gets the Wi-Fi enabled state.
+ * Gets the tethered Wi-Fi hotspot enabled state.
* @return One of {@link #WIFI_AP_STATE_DISABLED},
* {@link #WIFI_AP_STATE_DISABLING}, {@link #WIFI_AP_STATE_ENABLED},
* {@link #WIFI_AP_STATE_ENABLING}, {@link #WIFI_AP_STATE_FAILED}
@@ -3296,8 +3298,8 @@ public class WifiManager {
}
/**
- * Return whether Wi-Fi AP is enabled or disabled.
- * @return {@code true} if Wi-Fi AP is enabled
+ * Return whether tethered Wi-Fi AP is enabled or disabled.
+ * @return {@code true} if tethered Wi-Fi AP is enabled
* @see #getWifiApState()
*
* @hide
@@ -3309,7 +3311,7 @@ public class WifiManager {
}
/**
- * Gets the Wi-Fi AP Configuration.
+ * Gets the tethered Wi-Fi AP Configuration.
* @return AP details in WifiConfiguration
*
* Note that AP detail may contain configuration which is cannot be represented
@@ -3331,7 +3333,7 @@ public class WifiManager {
}
/**
- * Gets the Wi-Fi AP Configuration.
+ * Gets the Wi-Fi tethered AP Configuration.
* @return AP details in {@link SoftApConfiguration}
*
* @hide
@@ -3348,7 +3350,7 @@ public class WifiManager {
}
/**
- * Sets the Wi-Fi AP Configuration.
+ * Sets the tethered Wi-Fi AP Configuration.
* @return {@code true} if the operation succeeded, {@code false} otherwise
*
* @deprecated This API is deprecated. Use {@link #setSoftApConfiguration(SoftApConfiguration)}
@@ -3367,9 +3369,9 @@ public class WifiManager {
}
/**
- * Sets the Wi-Fi AP Configuration.
+ * Sets the tethered Wi-Fi AP Configuration.
*
- * If the API is called while the soft AP is enabled, the configuration will apply to
+ * If the API is called while the tethered soft AP is enabled, the configuration will apply to
* the current soft AP if the new configuration only includes
* {@link SoftApConfiguration.Builder#setMaxNumberOfClients(int)}
* or {@link SoftApConfiguration.Builder#setShutdownTimeoutMillis(int)}
@@ -4308,16 +4310,16 @@ public class WifiManager {
}
/**
- * Allows the OEM to enable/disable auto-join globally.
+ * Enable/disable auto-join globally.
*
- * @param choice true to allow autojoin, false to disallow autojoin
+ * @param allowAutojoin true to allow auto-join, false to disallow auto-join
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
- public void allowAutojoinGlobal(boolean choice) {
+ public void allowAutojoinGlobal(boolean allowAutojoin) {
try {
- mService.allowAutojoinGlobal(choice);
+ mService.allowAutojoinGlobal(allowAutojoin);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -4329,15 +4331,15 @@ public class WifiManager {
* The updated choice will be made available through the updated config supplied by the
* CONFIGURED_NETWORKS_CHANGED broadcast.
*
- * @param netId the id of the network to allow/disallow autojoin for.
- * @param choice true to allow autojoin, false to disallow autojoin
+ * @param netId the id of the network to allow/disallow auto-join for.
+ * @param allowAutojoin true to allow auto-join, false to disallow auto-join
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
- public void allowAutojoin(int netId, boolean choice) {
+ public void allowAutojoin(int netId, boolean allowAutojoin) {
try {
- mService.allowAutojoin(netId, choice);
+ mService.allowAutojoin(netId, allowAutojoin);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -4347,14 +4349,14 @@ 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.
+ * @param allowAutojoin true to enable auto-join, false to disable auto-join.
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
- public void allowAutojoinPasspoint(@NonNull String fqdn, boolean enableAutoJoin) {
+ public void allowAutojoinPasspoint(@NonNull String fqdn, boolean allowAutojoin) {
try {
- mService.allowAutojoinPasspoint(fqdn, enableAutoJoin);
+ mService.allowAutojoinPasspoint(fqdn, allowAutojoin);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -5948,10 +5950,11 @@ public class WifiManager {
*
* @param sessionId The ID to indicate current Wi-Fi network connection obtained from
* {@link WifiConnectedNetworkScorer#start(int)}.
- * @param isUsable The bit to indicate whether current Wi-Fi network is usable or not.
- * Populated by connected network scorer in applications.
+ * @param score The {@link android.net.NetworkScore} object representing the
+ * characteristics of current Wi-Fi network. Populated by connected network
+ * scorer in applications.
*/
- void onStatusChange(int sessionId, boolean isUsable);
+ void onScoreChange(int sessionId, @NonNull NetworkScore score);
/**
* Called by applications to trigger an update of {@link WifiUsabilityStatsEntry}.
@@ -5977,9 +5980,9 @@ public class WifiManager {
}
@Override
- public void onStatusChange(int sessionId, boolean isUsable) {
+ public void onScoreChange(int sessionId, @NonNull NetworkScore score) {
try {
- mScoreChangeCallback.onStatusChange(sessionId, isUsable);
+ mScoreChangeCallback.onScoreChange(sessionId, score);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -6116,4 +6119,48 @@ public class WifiManager {
throw e.rethrowFromSystemServer();
}
}
+
+ /**
+ * Enable/disable wifi scan throttling from 3rd party apps.
+ *
+ * <p>
+ * The throttling limits for apps are described in
+ * <a href="Wi-Fi Scan Throttling">
+ * https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling</a>
+ * </p>
+ *
+ * @param enable true to allow scan throttling, false to disallow scan throttling.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
+ public void setScanThrottleEnabled(boolean enable) {
+ try {
+ mService.setScanThrottleEnabled(enable);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Get the persisted Wi-Fi scan throttle state. Defaults to true, unless changed by the user via
+ * Developer options.
+ *
+ * <p>
+ * The throttling limits for apps are described in
+ * <a href="Wi-Fi Scan Throttling">
+ * https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling</a>
+ * </p>
+ *
+ * @return true to indicate that scan throttling is enabled, false to indicate that scan
+ * throttling is disabled.
+ */
+ @RequiresPermission(ACCESS_WIFI_STATE)
+ public boolean isScanThrottleEnabled() {
+ try {
+ return mService.isScanThrottleEnabled();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
}
diff --git a/wifi/java/android/net/wifi/WifiNetworkAgentSpecifier.java b/wifi/java/android/net/wifi/WifiNetworkAgentSpecifier.java
index 04d2e1a8b5dd..6632c162fcf9 100644
--- a/wifi/java/android/net/wifi/WifiNetworkAgentSpecifier.java
+++ b/wifi/java/android/net/wifi/WifiNetworkAgentSpecifier.java
@@ -27,7 +27,6 @@ import android.net.NetworkRequest;
import android.net.NetworkSpecifier;
import android.os.Parcel;
import android.os.Parcelable;
-import android.text.TextUtils;
import java.util.Objects;
@@ -41,33 +40,10 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
*/
private final WifiConfiguration mWifiConfiguration;
- /**
- * The UID of the app that requested a specific wifi network using {@link WifiNetworkSpecifier}.
- *
- * Will only be filled when the device connects to a wifi network as a result of a
- * {@link NetworkRequest} with {@link WifiNetworkSpecifier}. Will be set to -1 if the device
- * auto-connected to a wifi network.
- */
- private final int mOriginalRequestorUid;
-
- /**
- * The package name of the app that requested a specific wifi network using
- * {@link WifiNetworkSpecifier}.
- *
- * Will only be filled when the device connects to a wifi network as a result of a
- * {@link NetworkRequest} with {@link WifiNetworkSpecifier}. Will be set to null if the device
- * auto-connected to a wifi network.
- */
- private final String mOriginalRequestorPackageName;
-
- public WifiNetworkAgentSpecifier(@NonNull WifiConfiguration wifiConfiguration,
- int originalRequestorUid,
- @Nullable String originalRequestorPackageName) {
+ public WifiNetworkAgentSpecifier(@NonNull WifiConfiguration wifiConfiguration) {
checkNotNull(wifiConfiguration);
mWifiConfiguration = wifiConfiguration;
- mOriginalRequestorUid = originalRequestorUid;
- mOriginalRequestorPackageName = originalRequestorPackageName;
}
/**
@@ -78,10 +54,7 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
@Override
public WifiNetworkAgentSpecifier createFromParcel(@NonNull Parcel in) {
WifiConfiguration wifiConfiguration = in.readParcelable(null);
- int originalRequestorUid = in.readInt();
- String originalRequestorPackageName = in.readString();
- return new WifiNetworkAgentSpecifier(
- wifiConfiguration, originalRequestorUid, originalRequestorPackageName);
+ return new WifiNetworkAgentSpecifier(wifiConfiguration);
}
@Override
@@ -98,8 +71,6 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeParcelable(mWifiConfiguration, flags);
- dest.writeInt(mOriginalRequestorUid);
- dest.writeString(mOriginalRequestorPackageName);
}
@Override
@@ -149,12 +120,6 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
this.mWifiConfiguration.allowedKeyManagement)) {
return false;
}
- if (ns.requestorUid != this.mOriginalRequestorUid) {
- return false;
- }
- if (!TextUtils.equals(ns.requestorPackageName, this.mOriginalRequestorPackageName)) {
- return false;
- }
return true;
}
@@ -163,9 +128,7 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
return Objects.hash(
mWifiConfiguration.SSID,
mWifiConfiguration.BSSID,
- mWifiConfiguration.allowedKeyManagement,
- mOriginalRequestorUid,
- mOriginalRequestorPackageName);
+ mWifiConfiguration.allowedKeyManagement);
}
@Override
@@ -180,10 +143,7 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
return Objects.equals(this.mWifiConfiguration.SSID, lhs.mWifiConfiguration.SSID)
&& Objects.equals(this.mWifiConfiguration.BSSID, lhs.mWifiConfiguration.BSSID)
&& Objects.equals(this.mWifiConfiguration.allowedKeyManagement,
- lhs.mWifiConfiguration.allowedKeyManagement)
- && mOriginalRequestorUid == lhs.mOriginalRequestorUid
- && TextUtils.equals(mOriginalRequestorPackageName,
- lhs.mOriginalRequestorPackageName);
+ lhs.mWifiConfiguration.allowedKeyManagement);
}
@Override
@@ -192,19 +152,11 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
sb.append("WifiConfiguration=")
.append(", SSID=").append(mWifiConfiguration.SSID)
.append(", BSSID=").append(mWifiConfiguration.BSSID)
- .append(", mOriginalRequestorUid=").append(mOriginalRequestorUid)
- .append(", mOriginalRequestorPackageName=").append(mOriginalRequestorPackageName)
.append("]");
return sb.toString();
}
@Override
- public void assertValidFromUid(int requestorUid) {
- throw new IllegalStateException("WifiNetworkAgentSpecifier should never be used "
- + "for requests.");
- }
-
- @Override
public NetworkSpecifier redact() {
return null;
}
diff --git a/wifi/java/android/net/wifi/WifiNetworkSpecifier.java b/wifi/java/android/net/wifi/WifiNetworkSpecifier.java
index 444e1ef041e8..3d946c9f887d 100644
--- a/wifi/java/android/net/wifi/WifiNetworkSpecifier.java
+++ b/wifi/java/android/net/wifi/WifiNetworkSpecifier.java
@@ -20,7 +20,6 @@ import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.app.Application;
import android.net.MacAddress;
import android.net.MatchAllNetworkSpecifier;
import android.net.NetworkRequest;
@@ -28,13 +27,9 @@ import android.net.NetworkSpecifier;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PatternMatcher;
-import android.os.Process;
import android.text.TextUtils;
-import android.util.Log;
import android.util.Pair;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
@@ -438,24 +433,7 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
return new WifiNetworkSpecifier(
mSsidPatternMatcher,
mBssidPatternMatcher,
- buildWifiConfiguration(),
- Process.myUid(),
- getCurrentApplicationReflectively().getApplicationContext().getOpPackageName());
- }
-
- // TODO(b/144102365): Remove once refactor is complete
- private static Application getCurrentApplicationReflectively() {
- try {
- // reflection for static method android.app.ActivityThread#currentApplication()
- Class<?> klass = Class.forName("android.app.ActivityThread");
- Method currentApplicationMethod = klass.getDeclaredMethod("currentApplication");
- Object result = currentApplicationMethod.invoke(null);
- return (Application) result;
- } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException
- | InvocationTargetException e) {
- Log.e(TAG, "Failed to call ActivityThread#currentApplication() reflectively!", e);
- throw new RuntimeException(e);
- }
+ buildWifiConfiguration());
}
}
@@ -483,20 +461,6 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
*/
public final WifiConfiguration wifiConfiguration;
- /**
- * The UID of the process initializing this network specifier. Validated by receiver using
- * checkUidIfNecessary() and is used by satisfiedBy() to determine whether the specifier
- * matches the offered network.
- * @hide
- */
- public final int requestorUid;
-
- /**
- * The package name of the app initializing this network specifier.
- * @hide
- */
- public final String requestorPackageName;
-
/** @hide */
public WifiNetworkSpecifier() throws IllegalAccessException {
throw new IllegalAccessException("Use the builder to create an instance");
@@ -505,18 +469,14 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
/** @hide */
public WifiNetworkSpecifier(@NonNull PatternMatcher ssidPatternMatcher,
@NonNull Pair<MacAddress, MacAddress> bssidPatternMatcher,
- @NonNull WifiConfiguration wifiConfiguration,
- int requestorUid, @NonNull String requestorPackageName) {
+ @NonNull WifiConfiguration wifiConfiguration) {
checkNotNull(ssidPatternMatcher);
checkNotNull(bssidPatternMatcher);
checkNotNull(wifiConfiguration);
- checkNotNull(requestorPackageName);
this.ssidPatternMatcher = ssidPatternMatcher;
this.bssidPatternMatcher = bssidPatternMatcher;
this.wifiConfiguration = wifiConfiguration;
- this.requestorUid = requestorUid;
- this.requestorPackageName = requestorPackageName;
}
public static final @NonNull Creator<WifiNetworkSpecifier> CREATOR =
@@ -529,10 +489,8 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
Pair<MacAddress, MacAddress> bssidPatternMatcher =
Pair.create(baseAddress, mask);
WifiConfiguration wifiConfiguration = in.readParcelable(null);
- int requestorUid = in.readInt();
- String requestorPackageName = in.readString();
return new WifiNetworkSpecifier(ssidPatternMatcher, bssidPatternMatcher,
- wifiConfiguration, requestorUid, requestorPackageName);
+ wifiConfiguration);
}
@Override
@@ -552,18 +510,13 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
dest.writeParcelable(bssidPatternMatcher.first, flags);
dest.writeParcelable(bssidPatternMatcher.second, flags);
dest.writeParcelable(wifiConfiguration, flags);
- dest.writeInt(requestorUid);
- dest.writeString(requestorPackageName);
}
@Override
public int hashCode() {
return Objects.hash(
- ssidPatternMatcher.getPath(),
- ssidPatternMatcher.getType(),
- bssidPatternMatcher,
- wifiConfiguration.allowedKeyManagement,
- requestorUid, requestorPackageName);
+ ssidPatternMatcher.getPath(), ssidPatternMatcher.getType(), bssidPatternMatcher,
+ wifiConfiguration.allowedKeyManagement);
}
@Override
@@ -582,9 +535,7 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
&& Objects.equals(this.bssidPatternMatcher,
lhs.bssidPatternMatcher)
&& Objects.equals(this.wifiConfiguration.allowedKeyManagement,
- lhs.wifiConfiguration.allowedKeyManagement)
- && requestorUid == lhs.requestorUid
- && TextUtils.equals(requestorPackageName, lhs.requestorPackageName);
+ lhs.wifiConfiguration.allowedKeyManagement);
}
@Override
@@ -595,8 +546,6 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
.append(", BSSID Match pattern=").append(bssidPatternMatcher)
.append(", SSID=").append(wifiConfiguration.SSID)
.append(", BSSID=").append(wifiConfiguration.BSSID)
- .append(", requestorUid=").append(requestorUid)
- .append(", requestorPackageName=").append(requestorPackageName)
.append("]")
.toString();
}
@@ -618,12 +567,4 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
// not make much sense!
return equals(other);
}
-
- /** @hide */
- @Override
- public void assertValidFromUid(int requestorUid) {
- if (this.requestorUid != requestorUid) {
- throw new SecurityException("mismatched UIDs");
- }
- }
}
diff --git a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
index 6085eae252ef..a854a4ba3ae5 100644
--- a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
+++ b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
@@ -126,7 +126,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
/**
* Whether this network is initialized with auto-join enabled (the default) or not.
*/
- private boolean mIsInitialAutoJoinEnabled;
+ private boolean mIsInitialAutojoinEnabled;
/**
* Pre-shared key for use with WAPI-PSK networks.
@@ -159,7 +159,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
mIsMetered = false;
mIsSharedWithUser = true;
mIsSharedWithUserSet = false;
- mIsInitialAutoJoinEnabled = true;
+ mIsInitialAutojoinEnabled = true;
mPriority = UNASSIGNED_PRIORITY;
mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
mWapiPskPassphrase = null;
@@ -467,10 +467,10 @@ public final class WifiNetworkSuggestion implements Parcelable {
*
* @param enabled true for initializing with auto-join enabled (the default), false to
* initializing with auto-join disabled.
- * @return Instance of (@link {@link Builder} to enable chaining of the builder method.
+ * @return Instance of {@link Builder} to enable chaining of the builder method.
*/
- public @NonNull Builder setIsInitialAutoJoinEnabled(boolean enabled) {
- mIsInitialAutoJoinEnabled = enabled;
+ public @NonNull Builder setIsInitialAutojoinEnabled(boolean enabled) {
+ mIsInitialAutojoinEnabled = enabled;
return this;
}
@@ -569,6 +569,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
private WifiConfiguration buildWifiConfigurationForPasspoint() {
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.FQDN = mPasspointConfiguration.getHomeSp().getFqdn();
+ wifiConfiguration.setPasspointUniqueId(mPasspointConfiguration.getUniqueId());
wifiConfiguration.priority = mPriority;
wifiConfiguration.meteredOverride =
mIsMetered ? WifiConfiguration.METERED_OVERRIDE_METERED
@@ -664,10 +665,10 @@ public final class WifiNetworkSuggestion implements Parcelable {
mIsSharedWithUser = false;
}
}
- if (!mIsSharedWithUser && !mIsInitialAutoJoinEnabled) {
+ if (!mIsSharedWithUser && !mIsInitialAutojoinEnabled) {
throw new IllegalStateException("Should have not a network with both "
+ "setCredentialSharedWithUser and "
- + "setIsAutoJoinEnabled set to false");
+ + "setIsAutojoinEnabled set to false");
}
if (mIsNetworkUntrusted) {
if (mIsSharedWithUserSet && mIsSharedWithUser) {
@@ -683,7 +684,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
mIsAppInteractionRequired,
mIsUserInteractionRequired,
mIsSharedWithUser,
- mIsInitialAutoJoinEnabled,
+ mIsInitialAutojoinEnabled,
mIsNetworkUntrusted);
}
}
@@ -774,7 +775,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
in.readBoolean(), // isAppInteractionRequired
in.readBoolean(), // isUserInteractionRequired
in.readBoolean(), // isSharedCredentialWithUser
- in.readBoolean(), // isAutoJoinEnabled
+ in.readBoolean(), // isAutojoinEnabled
in.readBoolean()
);
}
@@ -804,7 +805,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
@Override
public int hashCode() {
return Objects.hash(wifiConfiguration.SSID, wifiConfiguration.BSSID,
- wifiConfiguration.allowedKeyManagement, wifiConfiguration.FQDN);
+ wifiConfiguration.allowedKeyManagement, wifiConfiguration.getKey());
}
/**
@@ -827,7 +828,8 @@ public final class WifiNetworkSuggestion implements Parcelable {
&& TextUtils.equals(this.wifiConfiguration.BSSID, lhs.wifiConfiguration.BSSID)
&& Objects.equals(this.wifiConfiguration.allowedKeyManagement,
lhs.wifiConfiguration.allowedKeyManagement)
- && TextUtils.equals(this.wifiConfiguration.FQDN, lhs.wifiConfiguration.FQDN);
+ && TextUtils.equals(this.wifiConfiguration.getKey(),
+ lhs.wifiConfiguration.getKey());
}
@Override
diff --git a/wifi/java/android/net/wifi/WifiOemConfigStoreMigrationHook.java b/wifi/java/android/net/wifi/WifiOemMigrationHook.java
index 642dcb9211ae..22d778637101 100755
--- a/wifi/java/android/net/wifi/WifiOemConfigStoreMigrationHook.java
+++ b/wifi/java/android/net/wifi/WifiOemMigrationHook.java
@@ -28,30 +28,17 @@ import java.util.List;
/**
* Class used to provide one time hooks for existing OEM devices to migrate their config store
- * data to the wifi mainline module.
- * <p>
- * Note:
- * <li> OEM's need to implement {@link #load()} only if their
- * existing config store format or file locations differs from the vanilla AOSP implementation (
- * which is what the wifi mainline module understands).
- * </li>
- * <li> The wifi mainline module will invoke {@link #load()} method on every bootup, its
- * the responsibility of the OEM implementation to ensure that this method returns non-null data
- * only on the first bootup. Once the migration is done, the OEM can safely delete their config
- * store files and then return null on any subsequent reboots. The first & only relevant invocation
- * of {@link #load()} occurs when a previously released device upgrades to the wifi
- * mainline module from an OEM implementation of the wifi stack.
- * </li>
+ * data and other settings to the wifi mainline module.
* @hide
*/
@SystemApi
-public final class WifiOemConfigStoreMigrationHook {
+public final class WifiOemMigrationHook {
/**
* Container for all the wifi config data to migrate.
*/
- public static final class MigrationData implements Parcelable {
+ public static final class ConfigStoreMigrationData implements Parcelable {
/**
- * Builder to create instance of {@link MigrationData}.
+ * Builder to create instance of {@link ConfigStoreMigrationData}.
*/
public static final class Builder {
private List<WifiConfiguration> mUserSavedNetworkConfigurations;
@@ -92,39 +79,40 @@ public final class WifiOemConfigStoreMigrationHook {
}
/**
- * Build an instance of {@link MigrationData}.
+ * Build an instance of {@link ConfigStoreMigrationData}.
*
- * @return Instance of {@link MigrationData}.
+ * @return Instance of {@link ConfigStoreMigrationData}.
*/
- public @NonNull MigrationData build() {
- return new MigrationData(mUserSavedNetworkConfigurations, mUserSoftApConfiguration);
+ public @NonNull ConfigStoreMigrationData build() {
+ return new ConfigStoreMigrationData(
+ mUserSavedNetworkConfigurations, mUserSoftApConfiguration);
}
}
private final List<WifiConfiguration> mUserSavedNetworkConfigurations;
private final SoftApConfiguration mUserSoftApConfiguration;
- private MigrationData(
+ private ConfigStoreMigrationData(
@Nullable List<WifiConfiguration> userSavedNetworkConfigurations,
@Nullable SoftApConfiguration userSoftApConfiguration) {
mUserSavedNetworkConfigurations = userSavedNetworkConfigurations;
mUserSoftApConfiguration = userSoftApConfiguration;
}
- public static final @NonNull Parcelable.Creator<MigrationData> CREATOR =
- new Parcelable.Creator<MigrationData>() {
+ public static final @NonNull Parcelable.Creator<ConfigStoreMigrationData> CREATOR =
+ new Parcelable.Creator<ConfigStoreMigrationData>() {
@Override
- public MigrationData createFromParcel(Parcel in) {
+ public ConfigStoreMigrationData createFromParcel(Parcel in) {
List<WifiConfiguration> userSavedNetworkConfigurations =
in.readArrayList(null);
SoftApConfiguration userSoftApConfiguration = in.readParcelable(null);
- return new MigrationData(
+ return new ConfigStoreMigrationData(
userSavedNetworkConfigurations, userSoftApConfiguration);
}
@Override
- public MigrationData[] newArray(int size) {
- return new MigrationData[size];
+ public ConfigStoreMigrationData[] newArray(int size) {
+ return new ConfigStoreMigrationData[size];
}
};
@@ -164,16 +152,29 @@ public final class WifiOemConfigStoreMigrationHook {
}
}
- private WifiOemConfigStoreMigrationHook() { }
+ private WifiOemMigrationHook() { }
/**
* Load data from OEM's config store.
+ * <p>
+ * Note:
+ * <li> OEM's need to implement {@link #loadFromConfigStore()} ()} only if their
+ * existing config store format or file locations differs from the vanilla AOSP implementation (
+ * which is what the wifi mainline module understands).
+ * </li>
+ * <li> The wifi mainline module will invoke {@link #loadFromConfigStore()} method on every
+ * bootup, its the responsibility of the OEM implementation to ensure that this method returns
+ * non-null data only on the first bootup. Once the migration is done, the OEM can safely delete
+ * their config store files and then return null on any subsequent reboots. The first & only
+ * relevant invocation of {@link #loadFromConfigStore()} occurs when a previously released
+ * device upgrades to the wifi mainline module from an OEM implementation of the wifi stack.
+ * </li>
*
- * @return Instance of {@link MigrationData} for migrating data, null if no
+ * @return Instance of {@link ConfigStoreMigrationData} for migrating data, null if no
* migration is necessary.
*/
@Nullable
- public static MigrationData load() {
+ public static ConfigStoreMigrationData loadFromConfigStore() {
// Note: OEM's should add code to parse data from their config store format here!
return null;
}
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index 6f01350d8af4..b4eb30b8cfe6 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -293,26 +293,34 @@ public class WifiScanner {
public final List<HiddenNetwork> hiddenNetworks = new ArrayList<>();
/**
* period of background scan; in millisecond, 0 => single shot scan
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This
+ * support may not be present on newer devices. Use {@link #startScan(ScanSettings,
+ * ScanListener)} instead for single scans.
*/
@Deprecated
public int periodInMs;
/**
* must have a valid REPORT_EVENT value
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This
+ * support may not be present on newer devices. Use {@link #startScan(ScanSettings,
+ * ScanListener)} instead for single scans.
*/
@Deprecated
public int reportEvents;
/**
* defines number of bssids to cache from each scan
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This
+ * support may not be present on newer devices. Use {@link #startScan(ScanSettings,
+ * ScanListener)} instead for single scans.
*/
@Deprecated
public int numBssidsPerScan;
/**
* defines number of scans to cache; use it with REPORT_EVENT_AFTER_BUFFER_FULL
* to wake up at fixed interval
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This
+ * support may not be present on newer devices. Use {@link #startScan(ScanSettings,
+ * ScanListener)} instead for single scans.
*/
@Deprecated
public int maxScansToCache;
@@ -321,14 +329,18 @@ public class WifiScanner {
* a truncated binary exponential backoff bucket and the scan period will grow
* exponentially as per formula: actual_period(N) = period * (2 ^ (N/stepCount))
* to maxPeriodInMs
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This
+ * support may not be present on newer devices. Use {@link #startScan(ScanSettings,
+ * ScanListener)} instead for single scans.
*/
@Deprecated
public int maxPeriodInMs;
/**
* for truncated binary exponential back off bucket, number of scans to perform
* for a given period
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This
+ * support may not be present on newer devices. Use {@link #startScan(ScanSettings,
+ * ScanListener)} instead for single scans.
*/
@Deprecated
public int stepCount;
@@ -806,7 +818,9 @@ public class WifiScanner {
/**
* Framework co-ordinates scans across multiple apps; so it may not give exactly the
* same period requested. If period of a scan is changed; it is reported by this event.
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This
+ * support may not be present on newer devices. Use {@link #startScan(ScanSettings,
+ * ScanListener)} instead for single scans.
*/
@Deprecated
public void onPeriodChanged(int periodInMs);
@@ -836,6 +850,8 @@ public class WifiScanner {
* Enable/Disable wifi scanning.
*
* @param enable set to true to enable scanning, set to false to disable all types of scanning.
+ *
+ * @see WifiManager#ACTION_WIFI_SCAN_AVAILABILITY_CHANGED
* {@hide}
*/
@SystemApi
@@ -911,7 +927,9 @@ public class WifiScanner {
* @param listener specifies the object to report events to. This object is also treated as a
* key for this scan, and must also be specified to cancel the scan. Multiple
* scans should also not share this object.
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This support
+ * may not be present on newer devices. Use {@link #startScan(ScanSettings, ScanListener)}
+ * instead for single scans.
*/
@Deprecated
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
@@ -933,7 +951,9 @@ public class WifiScanner {
* stop an ongoing wifi scan
* @param listener specifies which scan to cancel; must be same object as passed in {@link
* #startBackgroundScan}
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This support
+ * may not be present on newer devices. Use {@link #startScan(ScanSettings, ScanListener)}
+ * instead for single scans.
*/
@Deprecated
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
@@ -951,7 +971,9 @@ public class WifiScanner {
/**
* reports currently available scan results on appropriate listeners
* @return true if all scan results were reported correctly
- * @deprecated Background scan support is removed.
+ * @deprecated Background scan support has always been hardware vendor dependent. This support
+ * may not be present on newer devices. Use {@link #startScan(ScanSettings, ScanListener)}
+ * instead for single scans.
*/
@Deprecated
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
diff --git a/wifi/java/android/net/wifi/aware/WifiAwareAgentNetworkSpecifier.java b/wifi/java/android/net/wifi/aware/WifiAwareAgentNetworkSpecifier.java
index c66733472d0e..a4b3e86398a8 100644
--- a/wifi/java/android/net/wifi/aware/WifiAwareAgentNetworkSpecifier.java
+++ b/wifi/java/android/net/wifi/aware/WifiAwareAgentNetworkSpecifier.java
@@ -143,12 +143,6 @@ public class WifiAwareAgentNetworkSpecifier extends NetworkSpecifier implements
}
@Override
- public void assertValidFromUid(int requestorUid) {
- throw new SecurityException(
- "WifiAwareAgentNetworkSpecifier should not be used in network requests");
- }
-
- @Override
public NetworkSpecifier redact() {
return null;
}
diff --git a/wifi/java/android/net/wifi/aware/WifiAwareManager.java b/wifi/java/android/net/wifi/aware/WifiAwareManager.java
index 81bf81e40199..2ebaa1805b2b 100644
--- a/wifi/java/android/net/wifi/aware/WifiAwareManager.java
+++ b/wifi/java/android/net/wifi/aware/WifiAwareManager.java
@@ -34,7 +34,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
-import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
@@ -447,8 +446,7 @@ public class WifiAwareManager {
pmk,
passphrase,
0, // no port info for deprecated IB APIs
- -1, // no transport info for deprecated IB APIs
- Process.myUid());
+ -1); // no transport info for deprecated IB APIs
}
/** @hide */
@@ -488,8 +486,7 @@ public class WifiAwareManager {
pmk,
passphrase,
0, // no port info for OOB APIs
- -1, // no transport protocol info for OOB APIs
- Process.myUid());
+ -1); // no transport protocol info for OOB APIs
}
private static class WifiAwareEventCallbackProxy extends IWifiAwareEventCallback.Stub {
diff --git a/wifi/java/android/net/wifi/aware/WifiAwareNetworkSpecifier.java b/wifi/java/android/net/wifi/aware/WifiAwareNetworkSpecifier.java
index 5a4ed3c2f5e3..65ac1ab26064 100644
--- a/wifi/java/android/net/wifi/aware/WifiAwareNetworkSpecifier.java
+++ b/wifi/java/android/net/wifi/aware/WifiAwareNetworkSpecifier.java
@@ -23,7 +23,6 @@ import android.annotation.NonNull;
import android.net.NetworkSpecifier;
import android.os.Parcel;
import android.os.Parcelable;
-import android.os.Process;
import android.text.TextUtils;
import java.util.Arrays;
@@ -144,19 +143,9 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
*/
public final int transportProtocol;
- /**
- * The UID of the process initializing this network specifier. Validated by receiver using
- * checkUidIfNecessary() and is used by satisfiedBy() to determine whether matches the
- * offered network.
- *
- * @hide
- */
- public final int requestorUid;
-
/** @hide */
public WifiAwareNetworkSpecifier(int type, int role, int clientId, int sessionId, int peerId,
- byte[] peerMac, byte[] pmk, String passphrase, int port, int transportProtocol,
- int requestorUid) {
+ byte[] peerMac, byte[] pmk, String passphrase, int port, int transportProtocol) {
this.type = type;
this.role = role;
this.clientId = clientId;
@@ -167,7 +156,6 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
this.passphrase = passphrase;
this.port = port;
this.transportProtocol = transportProtocol;
- this.requestorUid = requestorUid;
}
public static final @android.annotation.NonNull Creator<WifiAwareNetworkSpecifier> CREATOR =
@@ -184,8 +172,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
in.createByteArray(), // pmk
in.readString(), // passphrase
in.readInt(), // port
- in.readInt(), // transportProtocol
- in.readInt()); // requestorUid
+ in.readInt()); // transportProtocol
}
@Override
@@ -221,7 +208,6 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
dest.writeString(passphrase);
dest.writeInt(port);
dest.writeInt(transportProtocol);
- dest.writeInt(requestorUid);
}
/** @hide */
@@ -238,7 +224,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
@Override
public int hashCode() {
return Objects.hash(type, role, clientId, sessionId, peerId, Arrays.hashCode(peerMac),
- Arrays.hashCode(pmk), passphrase, port, transportProtocol, requestorUid);
+ Arrays.hashCode(pmk), passphrase, port, transportProtocol);
}
/** @hide */
@@ -263,8 +249,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
&& Arrays.equals(pmk, lhs.pmk)
&& Objects.equals(passphrase, lhs.passphrase)
&& port == lhs.port
- && transportProtocol == lhs.transportProtocol
- && requestorUid == lhs.requestorUid;
+ && transportProtocol == lhs.transportProtocol;
}
/** @hide */
@@ -283,19 +268,11 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
// masking PII
.append(", passphrase=").append((passphrase == null) ? "<null>" : "<non-null>")
.append(", port=").append(port).append(", transportProtocol=")
- .append(transportProtocol).append(", requestorUid=").append(requestorUid)
+ .append(transportProtocol)
.append("]");
return sb.toString();
}
- /** @hide */
- @Override
- public void assertValidFromUid(int requestorUid) {
- if (this.requestorUid != requestorUid) {
- throw new SecurityException("mismatched UIDs");
- }
- }
-
/**
* A builder class for a Wi-Fi Aware network specifier to set up an Aware connection with a
* peer.
@@ -463,7 +440,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
return new WifiAwareNetworkSpecifier(
WifiAwareNetworkSpecifier.NETWORK_SPECIFIER_TYPE_IB, role,
mDiscoverySession.mClientId, mDiscoverySession.mSessionId, mPeerHandle.peerId,
- null, mPmk, mPskPassphrase, mPort, mTransportProtocol, Process.myUid());
+ null, mPmk, mPskPassphrase, mPort, mTransportProtocol);
}
}
}
diff --git a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java
index 3a0d080594c8..9f581849efca 100644
--- a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java
+++ b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java
@@ -19,6 +19,7 @@ package android.net.wifi.hotspot2;
import static android.net.wifi.WifiConfiguration.METERED_OVERRIDE_NONE;
import static android.net.wifi.WifiConfiguration.MeteredOverride;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.net.wifi.hotspot2.pps.Credential;
@@ -431,7 +432,7 @@ public final class PasspointConfiguration implements Parcelable {
* 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;
+ private boolean mIsAutojoinEnabled = true;
/**
* The mac randomization setting specifies whether a randomized or device MAC address will
@@ -458,11 +459,11 @@ public final class PasspointConfiguration implements Parcelable {
* 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.
+ * @param autojoinEnabled true to be considered for framework auto-connection, false otherwise.
* @hide
*/
- public void setAutoJoinEnabled(boolean autoJoinEnabled) {
- mIsAutoJoinEnabled = autoJoinEnabled;
+ public void setAutojoinEnabled(boolean autojoinEnabled) {
+ mIsAutojoinEnabled = autojoinEnabled;
}
/**
@@ -498,8 +499,8 @@ public final class PasspointConfiguration implements Parcelable {
* @hide
*/
@SystemApi
- public boolean isAutoJoinEnabled() {
- return mIsAutoJoinEnabled;
+ public boolean isAutojoinEnabled() {
+ return mIsAutojoinEnabled;
}
/**
@@ -569,7 +570,7 @@ public final class PasspointConfiguration implements Parcelable {
mServiceFriendlyNames = source.mServiceFriendlyNames;
mAaaServerTrustedNames = source.mAaaServerTrustedNames;
mCarrierId = source.mCarrierId;
- mIsAutoJoinEnabled = source.mIsAutoJoinEnabled;
+ mIsAutojoinEnabled = source.mIsAutojoinEnabled;
mIsMacRandomizationEnabled = source.mIsMacRandomizationEnabled;
mMeteredOverride = source.mMeteredOverride;
}
@@ -601,7 +602,7 @@ public final class PasspointConfiguration implements Parcelable {
(HashMap<String, String>) mServiceFriendlyNames);
dest.writeBundle(bundle);
dest.writeInt(mCarrierId);
- dest.writeBoolean(mIsAutoJoinEnabled);
+ dest.writeBoolean(mIsAutojoinEnabled);
dest.writeBoolean(mIsMacRandomizationEnabled);
dest.writeInt(mMeteredOverride);
}
@@ -634,7 +635,7 @@ public final class PasspointConfiguration implements Parcelable {
&& mUsageLimitDataLimit == that.mUsageLimitDataLimit
&& mUsageLimitTimeLimitInMinutes == that.mUsageLimitTimeLimitInMinutes
&& mCarrierId == that.mCarrierId
- && mIsAutoJoinEnabled == that.mIsAutoJoinEnabled
+ && mIsAutojoinEnabled == that.mIsAutojoinEnabled
&& mIsMacRandomizationEnabled == that.mIsMacRandomizationEnabled
&& mMeteredOverride == that.mMeteredOverride
&& (mServiceFriendlyNames == null ? that.mServiceFriendlyNames == null
@@ -647,7 +648,7 @@ public final class PasspointConfiguration implements Parcelable {
mUpdateIdentifier, mCredentialPriority, mSubscriptionCreationTimeInMillis,
mSubscriptionExpirationTimeInMillis, mUsageLimitUsageTimePeriodInMinutes,
mUsageLimitStartTimeInMillis, mUsageLimitDataLimit, mUsageLimitTimeLimitInMinutes,
- mServiceFriendlyNames, mCarrierId, mIsAutoJoinEnabled, mIsMacRandomizationEnabled,
+ mServiceFriendlyNames, mCarrierId, mIsAutojoinEnabled, mIsMacRandomizationEnabled,
mMeteredOverride);
}
@@ -702,7 +703,7 @@ public final class PasspointConfiguration implements Parcelable {
builder.append("ServiceFriendlyNames: ").append(mServiceFriendlyNames);
}
builder.append("CarrierId:" + mCarrierId);
- builder.append("IsAutoJoinEnabled:" + mIsAutoJoinEnabled);
+ builder.append("IsAutojoinEnabled:" + mIsAutojoinEnabled);
builder.append("mIsMacRandomizationEnabled:" + mIsMacRandomizationEnabled);
builder.append("mMeteredOverride:" + mMeteredOverride);
return builder.toString();
@@ -810,7 +811,7 @@ public final class PasspointConfiguration implements Parcelable {
"serviceFriendlyNames");
config.setServiceFriendlyNames(friendlyNamesMap);
config.mCarrierId = in.readInt();
- config.mIsAutoJoinEnabled = in.readBoolean();
+ config.mIsAutojoinEnabled = in.readBoolean();
config.mIsMacRandomizationEnabled = in.readBoolean();
config.mMeteredOverride = in.readInt();
return config;
@@ -895,4 +896,21 @@ public final class PasspointConfiguration implements Parcelable {
public boolean isOsuProvisioned() {
return getUpdateIdentifier() != Integer.MIN_VALUE;
}
+
+ /**
+ * Get a unique identifier for a PasspointConfiguration object.
+ *
+ * @return A unique identifier
+ * @throws IllegalStateException if Credential or HomeSP nodes are not initialized
+ */
+ public @NonNull String getUniqueId() throws IllegalStateException {
+ if (mCredential == null || mHomeSp == null || TextUtils.isEmpty(mHomeSp.getFqdn())) {
+ throw new IllegalStateException("Credential or HomeSP are not initialized");
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(String.format("%s_%x%x", mHomeSp.getFqdn(), mHomeSp.hashCode(),
+ mCredential.hashCode()));
+ return sb.toString();
+ }
}
diff --git a/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java b/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java
index 49a76c33d209..a5de3318f454 100644
--- a/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java
+++ b/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java
@@ -16,8 +16,8 @@
package android.net.wifi.hotspot2.pps;
-import android.os.Parcelable;
import android.os.Parcel;
+import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
@@ -299,8 +299,10 @@ public final class HomeSp implements Parcelable {
@Override
public int hashCode() {
- return Objects.hash(mFqdn, mFriendlyName, mIconUrl, mHomeNetworkIds, mMatchAllOis,
- mMatchAnyOis, mOtherHomePartners, mRoamingConsortiumOis);
+ return Objects.hash(mFqdn, mFriendlyName, mIconUrl,
+ mHomeNetworkIds, Arrays.hashCode(mMatchAllOis),
+ Arrays.hashCode(mMatchAnyOis), Arrays.hashCode(mOtherHomePartners),
+ Arrays.hashCode(mRoamingConsortiumOis));
}
@Override
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
index 9562f95ac162..d47989235f0b 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
@@ -17,6 +17,7 @@
package android.net.wifi.p2p;
import android.annotation.IntDef;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
@@ -133,16 +134,17 @@ public class WifiP2pConfig implements Parcelable {
*
* By default this field is set to {@link #GROUP_OWNER_INTENT_AUTO}.
*/
+ @IntRange(from = 0, to = 15)
public int groupOwnerIntent = GROUP_OWNER_INTENT_AUTO;
/** @hide */
@UnsupportedAppUsage
- public int netId = WifiP2pGroup.PERSISTENT_NET_ID;
+ public int netId = WifiP2pGroup.NETWORK_ID_PERSISTENT;
/**
* Get the network ID of this P2P configuration.
- * @return either a non-negative network ID, or one of {@link WifiP2pGroup#PERSISTENT_NET_ID} or
- * {@link WifiP2pGroup#TEMPORARY_NET_ID}.
+ * @return either a non-negative network ID, or one of
+ * {@link WifiP2pGroup#NETWORK_ID_PERSISTENT} or {@link WifiP2pGroup#NETWORK_ID_TEMPORARY}.
*/
public int getNetworkId() {
return netId;
@@ -280,7 +282,7 @@ public class WifiP2pConfig implements Parcelable {
private String mPassphrase = "";
private int mGroupOperatingBand = GROUP_OWNER_BAND_AUTO;
private int mGroupOperatingFrequency = GROUP_OWNER_BAND_AUTO;
- private int mNetId = WifiP2pGroup.TEMPORARY_NET_ID;
+ private int mNetId = WifiP2pGroup.NETWORK_ID_TEMPORARY;
/**
* Specify the peer's MAC address. If not set, the device will
@@ -460,9 +462,9 @@ public class WifiP2pConfig implements Parcelable {
*/
public @NonNull Builder enablePersistentMode(boolean persistent) {
if (persistent) {
- mNetId = WifiP2pGroup.PERSISTENT_NET_ID;
+ mNetId = WifiP2pGroup.NETWORK_ID_PERSISTENT;
} else {
- mNetId = WifiP2pGroup.TEMPORARY_NET_ID;
+ mNetId = WifiP2pGroup.NETWORK_ID_TEMPORARY;
}
return this;
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java b/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java
index 21f6704be0bb..e497b22d7769 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java
@@ -41,7 +41,15 @@ public class WifiP2pGroup implements Parcelable {
* The temporary network id.
* @see #getNetworkId()
*/
- public static final int TEMPORARY_NET_ID = -1;
+ public static final int NETWORK_ID_TEMPORARY = -1;
+
+ /**
+ * The temporary network id.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public static final int TEMPORARY_NET_ID = NETWORK_ID_TEMPORARY;
/**
* The persistent network id.
@@ -49,7 +57,7 @@ public class WifiP2pGroup implements Parcelable {
* Otherwise, create a new persistent profile.
* @see #getNetworkId()
*/
- public static final int PERSISTENT_NET_ID = -2;
+ public static final int NETWORK_ID_PERSISTENT = -2;
/** The network name */
private String mNetworkName;
@@ -130,13 +138,13 @@ public class WifiP2pGroup implements Parcelable {
mPassphrase = match.group(4);
mOwner = new WifiP2pDevice(match.group(5));
if (match.group(6) != null) {
- mNetId = PERSISTENT_NET_ID;
+ mNetId = NETWORK_ID_PERSISTENT;
} else {
- mNetId = TEMPORARY_NET_ID;
+ mNetId = NETWORK_ID_TEMPORARY;
}
} else if (tokens[0].equals("P2P-INVITATION-RECEIVED")) {
String sa = null;
- mNetId = PERSISTENT_NET_ID;
+ mNetId = NETWORK_ID_PERSISTENT;
for (String token : tokens) {
String[] nameValue = token.split("=");
if (nameValue.length != 2) continue;
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java b/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java
index cdb2806af0b1..8a86311defca 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java
@@ -22,7 +22,9 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.util.LruCache;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
@@ -78,8 +80,8 @@ public final class WifiP2pGroupList implements Parcelable {
* Get the list of P2P groups.
*/
@NonNull
- public Collection<WifiP2pGroup> getGroupList() {
- return mGroups.snapshot().values();
+ public List<WifiP2pGroup> getGroupList() {
+ return new ArrayList<>(mGroups.snapshot().values());
}
/**
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 3459c9496595..9c2cad99614d 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -326,6 +326,12 @@ public class WifiP2pManager {
/**
* Broadcast intent action indicating that remembered persistent groups have changed.
+ *
+ * You can <em>not</em> receive this through components declared
+ * in manifests, only by explicitly registering for it with
+ * {@link android.content.Context#registerReceiver(android.content.BroadcastReceiver,
+ * android.content.IntentFilter) Context.registerReceiver()}.
+ *
* @hide
*/
@SystemApi
@@ -1293,7 +1299,7 @@ public class WifiP2pManager {
@RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
public void createGroup(Channel c, ActionListener listener) {
checkChannel(c);
- c.mAsyncChannel.sendMessage(CREATE_GROUP, WifiP2pGroup.PERSISTENT_NET_ID,
+ c.mAsyncChannel.sendMessage(CREATE_GROUP, WifiP2pGroup.NETWORK_ID_PERSISTENT,
c.putListener(listener));
}
@@ -1347,20 +1353,33 @@ public class WifiP2pManager {
}
/**
- * Force p2p to enter or exit listen state
+ * Force p2p to enter listen state
*
* @param c is the channel created at {@link #initialize(Context, Looper, ChannelListener)}
- * @param enable enables or disables listening
* @param listener for callbacks on success or failure. Can be null.
*
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
- public void listen(@NonNull Channel c, boolean enable, @Nullable ActionListener listener) {
+ public void startListening(@NonNull Channel c, @Nullable ActionListener listener) {
checkChannel(c);
- c.mAsyncChannel.sendMessage(enable ? START_LISTEN : STOP_LISTEN,
- 0, c.putListener(listener));
+ c.mAsyncChannel.sendMessage(START_LISTEN, 0, c.putListener(listener));
+ }
+
+ /**
+ * Force p2p to exit listen state
+ *
+ * @param c is the channel created at {@link #initialize(Context, Looper, ChannelListener)}
+ * @param listener for callbacks on success or failure. Can be null.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
+ public void stopListening(@NonNull Channel c, @Nullable ActionListener listener) {
+ checkChannel(c);
+ c.mAsyncChannel.sendMessage(STOP_LISTEN, 0, c.putListener(listener));
}
/**
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java b/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java
index 5484d248429f..e399b5b9afa6 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pWfdInfo.java
@@ -17,6 +17,7 @@
package android.net.wifi.p2p;
import android.annotation.IntDef;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
@@ -34,7 +35,7 @@ import java.util.Locale;
*/
public final class WifiP2pWfdInfo implements Parcelable {
- private boolean mWfdEnabled;
+ private boolean mEnabled;
/** Device information bitmap */
private int mDeviceInfo;
@@ -85,15 +86,15 @@ public final class WifiP2pWfdInfo implements Parcelable {
/** @hide */
@UnsupportedAppUsage
public WifiP2pWfdInfo(int devInfo, int ctrlPort, int maxTput) {
- mWfdEnabled = true;
+ mEnabled = true;
mDeviceInfo = devInfo;
mCtrlPort = ctrlPort;
mMaxThroughput = maxTput;
}
/** Returns true is Wifi Display is enabled, false otherwise. */
- public boolean isWfdEnabled() {
- return mWfdEnabled;
+ public boolean isEnabled() {
+ return mEnabled;
}
/**
@@ -101,8 +102,8 @@ public final class WifiP2pWfdInfo implements Parcelable {
*
* @param enabled true to enable Wifi Display, false to disable
*/
- public void setWfdEnabled(boolean enabled) {
- mWfdEnabled = enabled;
+ public void setEnabled(boolean enabled) {
+ mEnabled = enabled;
}
/**
@@ -177,12 +178,12 @@ public final class WifiP2pWfdInfo implements Parcelable {
}
/** Sets the TCP port at which the WFD Device listens for RTSP messages. */
- public void setControlPort(int port) {
+ public void setControlPort(@IntRange(from = 0) int port) {
mCtrlPort = port;
}
/** Sets the maximum average throughput capability of the WFD Device, in megabits/second. */
- public void setMaxThroughput(int maxThroughput) {
+ public void setMaxThroughput(@IntRange(from = 0) int maxThroughput) {
mMaxThroughput = maxThroughput;
}
@@ -200,7 +201,7 @@ public final class WifiP2pWfdInfo implements Parcelable {
@Override
public String toString() {
StringBuffer sbuf = new StringBuffer();
- sbuf.append("WFD enabled: ").append(mWfdEnabled);
+ sbuf.append("WFD enabled: ").append(mEnabled);
sbuf.append("WFD DeviceInfo: ").append(mDeviceInfo);
sbuf.append("\n WFD CtrlPort: ").append(mCtrlPort);
sbuf.append("\n WFD MaxThroughput: ").append(mMaxThroughput);
@@ -215,7 +216,7 @@ public final class WifiP2pWfdInfo implements Parcelable {
/** Copy constructor. */
public WifiP2pWfdInfo(@Nullable WifiP2pWfdInfo source) {
if (source != null) {
- mWfdEnabled = source.mWfdEnabled;
+ mEnabled = source.mEnabled;
mDeviceInfo = source.mDeviceInfo;
mCtrlPort = source.mCtrlPort;
mMaxThroughput = source.mMaxThroughput;
@@ -225,14 +226,14 @@ public final class WifiP2pWfdInfo implements Parcelable {
/** Implement the Parcelable interface */
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(mWfdEnabled ? 1 : 0);
+ dest.writeInt(mEnabled ? 1 : 0);
dest.writeInt(mDeviceInfo);
dest.writeInt(mCtrlPort);
dest.writeInt(mMaxThroughput);
}
private void readFromParcel(Parcel in) {
- mWfdEnabled = (in.readInt() == 1);
+ mEnabled = (in.readInt() == 1);
mDeviceInfo = in.readInt();
mCtrlPort = in.readInt();
mMaxThroughput = in.readInt();
diff --git a/wifi/java/android/net/wifi/wificond/NativeScanResult.java b/wifi/java/android/net/wifi/wificond/NativeScanResult.java
index 6ed17081bdb5..bd99476afe43 100644
--- a/wifi/java/android/net/wifi/wificond/NativeScanResult.java
+++ b/wifi/java/android/net/wifi/wificond/NativeScanResult.java
@@ -16,15 +16,21 @@
package android.net.wifi.wificond;
+import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.net.MacAddress;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
-import java.util.BitSet;
+import java.util.Arrays;
import java.util.List;
/**
@@ -34,7 +40,7 @@ import java.util.List;
*/
@SystemApi
public final class NativeScanResult implements Parcelable {
- private static final int CAPABILITY_SIZE = 16;
+ private static final String TAG = "NativeScanResult";
/** @hide */
@VisibleForTesting
@@ -56,7 +62,7 @@ public final class NativeScanResult implements Parcelable {
public long tsf;
/** @hide */
@VisibleForTesting
- public BitSet capability;
+ @BssCapabilityBits public int capability;
/** @hide */
@VisibleForTesting
public boolean associated;
@@ -74,14 +80,17 @@ public final class NativeScanResult implements Parcelable {
}
/**
- * Returns raw bytes representing the MAC address (BSSID) of the AP represented by this scan
- * result.
+ * Returns the MAC address (BSSID) of the AP represented by this scan result.
*
- * @return a byte array, possibly null or containing the incorrect number of bytes for a MAC
- * address.
+ * @return a MacAddress or null on error.
*/
- @NonNull public byte[] getBssid() {
- return bssid;
+ @Nullable public MacAddress getBssid() {
+ try {
+ return MacAddress.fromBytes(bssid);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + Arrays.toString(bssid), e);
+ return null;
+ }
}
/**
@@ -130,31 +139,103 @@ public final class NativeScanResult implements Parcelable {
return associated;
}
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true, prefix = {"BSS_CAPABILITY_"},
+ value = {BSS_CAPABILITY_ESS,
+ BSS_CAPABILITY_IBSS,
+ BSS_CAPABILITY_CF_POLLABLE,
+ BSS_CAPABILITY_CF_POLL_REQUEST,
+ BSS_CAPABILITY_PRIVACY,
+ BSS_CAPABILITY_SHORT_PREAMBLE,
+ BSS_CAPABILITY_PBCC,
+ BSS_CAPABILITY_CHANNEL_AGILITY,
+ BSS_CAPABILITY_SPECTRUM_MANAGEMENT,
+ BSS_CAPABILITY_QOS,
+ BSS_CAPABILITY_SHORT_SLOT_TIME,
+ BSS_CAPABILITY_APSD,
+ BSS_CAPABILITY_RADIO_MANAGEMENT,
+ BSS_CAPABILITY_DSSS_OFDM,
+ BSS_CAPABILITY_DELAYED_BLOCK_ACK,
+ BSS_CAPABILITY_IMMEDIATE_BLOCK_ACK
+ })
+ public @interface BssCapabilityBits { }
+
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): ESS.
+ */
+ public static final int BSS_CAPABILITY_ESS = 0x1 << 0;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): IBSS.
+ */
+ public static final int BSS_CAPABILITY_IBSS = 0x1 << 1;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): CF Pollable.
+ */
+ public static final int BSS_CAPABILITY_CF_POLLABLE = 0x1 << 2;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): CF-Poll Request.
+ */
+ public static final int BSS_CAPABILITY_CF_POLL_REQUEST = 0x1 << 3;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Privacy.
+ */
+ public static final int BSS_CAPABILITY_PRIVACY = 0x1 << 4;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Short Preamble.
+ */
+ public static final int BSS_CAPABILITY_SHORT_PREAMBLE = 0x1 << 5;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): PBCC.
+ */
+ public static final int BSS_CAPABILITY_PBCC = 0x1 << 6;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Channel Agility.
+ */
+ public static final int BSS_CAPABILITY_CHANNEL_AGILITY = 0x1 << 7;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Spectrum Management.
+ */
+ public static final int BSS_CAPABILITY_SPECTRUM_MANAGEMENT = 0x1 << 8;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): QoS.
+ */
+ public static final int BSS_CAPABILITY_QOS = 0x1 << 9;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Short Slot Time.
+ */
+ public static final int BSS_CAPABILITY_SHORT_SLOT_TIME = 0x1 << 10;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): APSD.
+ */
+ public static final int BSS_CAPABILITY_APSD = 0x1 << 11;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Radio Management.
+ */
+ public static final int BSS_CAPABILITY_RADIO_MANAGEMENT = 0x1 << 12;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): DSSS-OFDM.
+ */
+ public static final int BSS_CAPABILITY_DSSS_OFDM = 0x1 << 13;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Delayed Block Ack.
+ */
+ public static final int BSS_CAPABILITY_DELAYED_BLOCK_ACK = 0x1 << 14;
+ /**
+ * BSS capability bit (see IEEE Std 802.11: 9.4.1.4): Immediate Block Ack.
+ */
+ public static final int BSS_CAPABILITY_IMMEDIATE_BLOCK_ACK = 0x1 << 15;
+
/**
* Returns the capabilities of the AP repseresented by this scan result as advertised in the
* received probe response or beacon.
*
- * This is a bit mask describing the capabilities of a BSS. See IEEE Std 802.11: 8.4.1.4:
- * Bit 0 - ESS
- * Bit 1 - IBSS
- * Bit 2 - CF Pollable
- * Bit 3 - CF-Poll Request
- * Bit 4 - Privacy
- * Bit 5 - Short Preamble
- * Bit 6 - PBCC
- * Bit 7 - Channel Agility
- * Bit 8 - Spectrum Mgmt
- * Bit 9 - QoS
- * Bit 10 - Short Slot Time
- * Bit 11 - APSD
- * Bit 12 - Radio Measurement
- * Bit 13 - DSSS-OFDM
- * Bit 14 - Delayed Block Ack
- * Bit 15 - Immediate Block Ack
+ * This is a bit mask describing the capabilities of a BSS. See IEEE Std 802.11: 9.4.1.4: one
+ * of the {@code BSS_CAPABILITY_*} flags.
*
* @return a bit mask of capabilities.
*/
- @NonNull public BitSet getCapabilities() {
+ @BssCapabilityBits public int getCapabilities() {
return capability;
}
@@ -169,7 +250,7 @@ public final class NativeScanResult implements Parcelable {
}
/**
- * @hide
+ * Construct an empty native scan result.
*/
public NativeScanResult() { }
@@ -188,13 +269,7 @@ public final class NativeScanResult implements Parcelable {
out.writeInt(frequency);
out.writeInt(signalMbm);
out.writeLong(tsf);
- int capabilityInt = 0;
- for (int i = 0; i < CAPABILITY_SIZE; i++) {
- if (capability.get(i)) {
- capabilityInt |= 1 << i;
- }
- }
- out.writeInt(capabilityInt);
+ out.writeInt(capability);
out.writeInt(associated ? 1 : 0);
out.writeTypedList(radioChainInfos);
}
@@ -220,13 +295,7 @@ public final class NativeScanResult implements Parcelable {
result.frequency = in.readInt();
result.signalMbm = in.readInt();
result.tsf = in.readLong();
- int capabilityInt = in.readInt();
- result.capability = new BitSet(CAPABILITY_SIZE);
- for (int i = 0; i < CAPABILITY_SIZE; i++) {
- if ((capabilityInt & (1 << i)) != 0) {
- result.capability.set(i);
- }
- }
+ result.capability = in.readInt();
result.associated = (in.readInt() != 0);
result.radioChainInfos = new ArrayList<>();
in.readTypedList(result.radioChainInfos, RadioChainInfo.CREATOR);
diff --git a/wifi/java/android/net/wifi/wificond/NativeWifiClient.java b/wifi/java/android/net/wifi/wificond/NativeWifiClient.java
index 554f9295ef0d..9ad2a2769add 100644
--- a/wifi/java/android/net/wifi/wificond/NativeWifiClient.java
+++ b/wifi/java/android/net/wifi/wificond/NativeWifiClient.java
@@ -17,11 +17,13 @@
package android.net.wifi.wificond;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.net.MacAddress;
import android.os.Parcel;
import android.os.Parcelable;
-import java.util.Arrays;
+import java.util.Objects;
/**
* Structure providing information about clients (STAs) associated with a SoftAp.
@@ -30,17 +32,21 @@ import java.util.Arrays;
*/
@SystemApi
public final class NativeWifiClient implements Parcelable {
+ private final MacAddress mMacAddress;
+
/**
- * The raw bytes of the MAC address of the client (STA) represented by this object.
+ * The MAC address of the client (STA) represented by this object. The MAC address may be null
+ * in case of an error.
*/
- @NonNull public final byte[] macAddress;
+ @Nullable public MacAddress getMacAddress() {
+ return mMacAddress;
+ }
/**
- * public constructor
- * @hide
+ * Construct a native Wi-Fi client.
*/
- public NativeWifiClient(@NonNull byte[] macAddress) {
- this.macAddress = macAddress;
+ public NativeWifiClient(@Nullable MacAddress macAddress) {
+ this.mMacAddress = macAddress;
}
/** override comparator */
@@ -51,13 +57,13 @@ public final class NativeWifiClient implements Parcelable {
return false;
}
NativeWifiClient other = (NativeWifiClient) rhs;
- return Arrays.equals(macAddress, other.macAddress);
+ return Objects.equals(mMacAddress, other.mMacAddress);
}
/** override hash code */
@Override
public int hashCode() {
- return Arrays.hashCode(macAddress);
+ return mMacAddress.hashCode();
}
/** implement Parcelable interface */
@@ -72,7 +78,7 @@ public final class NativeWifiClient implements Parcelable {
*/
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
- out.writeByteArray(macAddress);
+ out.writeByteArray(mMacAddress.toByteArray());
}
/** implement Parcelable interface */
@@ -80,9 +86,11 @@ public final class NativeWifiClient implements Parcelable {
new Parcelable.Creator<NativeWifiClient>() {
@Override
public NativeWifiClient createFromParcel(Parcel in) {
- byte[] macAddress = in.createByteArray();
- if (macAddress == null) {
- macAddress = new byte[0];
+ MacAddress macAddress;
+ try {
+ macAddress = MacAddress.fromBytes(in.createByteArray());
+ } catch (IllegalArgumentException e) {
+ macAddress = null;
}
return new NativeWifiClient(macAddress);
}
diff --git a/wifi/java/android/net/wifi/wificond/PnoSettings.java b/wifi/java/android/net/wifi/wificond/PnoSettings.java
index 57c9ca5fd302..533d37d3a23a 100644
--- a/wifi/java/android/net/wifi/wificond/PnoSettings.java
+++ b/wifi/java/android/net/wifi/wificond/PnoSettings.java
@@ -16,6 +16,7 @@
package android.net.wifi.wificond;
+import android.annotation.DurationMillisLong;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
@@ -33,7 +34,7 @@ import java.util.Objects;
*/
@SystemApi
public final class PnoSettings implements Parcelable {
- private int mIntervalMs;
+ private long mIntervalMs;
private int mMin2gRssi;
private int mMin5gRssi;
private int mMin6gRssi;
@@ -47,17 +48,17 @@ public final class PnoSettings implements Parcelable {
*
* @return An interval in milliseconds.
*/
- public int getIntervalMillis() {
+ public @DurationMillisLong long getIntervalMillis() {
return mIntervalMs;
}
/**
* Set the requested PNO scan interval in milliseconds.
*
- * @param intervalMs An interval in milliseconds.
+ * @param intervalMillis An interval in milliseconds.
*/
- public void setIntervalMillis(int intervalMs) {
- this.mIntervalMs = intervalMs;
+ public void setIntervalMillis(@DurationMillisLong long intervalMillis) {
+ this.mIntervalMs = intervalMillis;
}
/**
@@ -176,7 +177,7 @@ public final class PnoSettings implements Parcelable {
**/
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
- out.writeInt(mIntervalMs);
+ out.writeLong(mIntervalMs);
out.writeInt(mMin2gRssi);
out.writeInt(mMin5gRssi);
out.writeInt(mMin6gRssi);
@@ -189,7 +190,7 @@ public final class PnoSettings implements Parcelable {
@Override
public PnoSettings createFromParcel(Parcel in) {
PnoSettings result = new PnoSettings();
- result.mIntervalMs = in.readInt();
+ result.mIntervalMs = in.readLong();
result.mMin2gRssi = in.readInt();
result.mMin5gRssi = in.readInt();
result.mMin6gRssi = in.readInt();
diff --git a/wifi/java/android/net/wifi/wificond/RadioChainInfo.java b/wifi/java/android/net/wifi/wificond/RadioChainInfo.java
index 64102dde94c0..97c0ee9d1c2c 100644
--- a/wifi/java/android/net/wifi/wificond/RadioChainInfo.java
+++ b/wifi/java/android/net/wifi/wificond/RadioChainInfo.java
@@ -61,7 +61,9 @@ public final class RadioChainInfo implements Parcelable {
return level;
}
- /** @hide */
+ /**
+ * Construct a RadioChainInfo.
+ */
public RadioChainInfo(int chainId, int level) {
this.chainId = chainId;
this.level = level;
diff --git a/wifi/java/android/net/wifi/wificond/WifiCondManager.java b/wifi/java/android/net/wifi/wificond/WifiCondManager.java
index 4847640b1418..61f18e0b7191 100644
--- a/wifi/java/android/net/wifi/wificond/WifiCondManager.java
+++ b/wifi/java/android/net/wifi/wificond/WifiCondManager.java
@@ -368,7 +368,7 @@ public class WifiCondManager {
public void onConnectedClientsChanged(NativeWifiClient client, boolean isConnected) {
if (mVerboseLoggingEnabled) {
Log.d(TAG, "onConnectedClientsChanged called with "
- + client.macAddress + " isConnected: " + isConnected);
+ + client.getMacAddress() + " isConnected: " + isConnected);
}
Binder.clearCallingIdentity();
@@ -493,22 +493,17 @@ public class WifiCondManager {
}
/**
- * Initializes WifiCondManager & registers a death notification for the WifiCondManager which
- * acts as a proxy for the wificond daemon (i.e. the death listener will be called when and if
- * the wificond daemon dies).
- *
- * Note: This method clears any existing state in wificond daemon.
+ * Register a death notification for the WifiCondManager which acts as a proxy for the
+ * wificond daemon (i.e. the death listener will be called when and if the wificond daemon
+ * dies).
*
* @param deathEventHandler A {@link Runnable} to be called whenever the wificond daemon dies.
- * @return Returns true on success.
*/
- public boolean initialize(@NonNull Runnable deathEventHandler) {
+ public void setOnServiceDeadCallback(@NonNull Runnable deathEventHandler) {
if (mDeathEventHandler != null) {
Log.e(TAG, "Death handler already present");
}
mDeathEventHandler = deathEventHandler;
- tearDownInterfaces();
- return true;
}
/**
@@ -600,11 +595,12 @@ public class WifiCondManager {
}
/**
- * Tear down a specific client (STA) interface, initially configured using
+ * Tear down a specific client (STA) interface configured using
* {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}.
*
* @param ifaceName Name of the interface to tear down.
- * @return Returns true on success.
+ * @return Returns true on success, false on failure (e.g. when called before an interface was
+ * set up).
*/
public boolean tearDownClientInterface(@NonNull String ifaceName) {
if (getClientInterface(ifaceName) == null) {
@@ -678,11 +674,12 @@ public class WifiCondManager {
}
/**
- * Tear down a Soft AP interface initially configured using
+ * Tear down a Soft AP interface configured using
* {@link #setupInterfaceForSoftApMode(String)}.
*
* @param ifaceName Name of the interface to tear down.
- * @return Returns true on success.
+ * @return Returns true on success, false on failure (e.g. when called before an interface was
+ * set up).
*/
public boolean tearDownSoftApInterface(@NonNull String ifaceName) {
if (getApInterface(ifaceName) == null) {
@@ -747,9 +744,13 @@ public class WifiCondManager {
/**
* Request signal polling.
*
- * @param ifaceName Name of the interface on which to poll.
+ * @param ifaceName Name of the interface on which to poll. The interface must have been
+ * already set up using
+ *{@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @return A {@link SignalPollResult} object containing interface statistics, or a null on
- * error.
+ * error (e.g. the interface hasn't been set up yet).
*/
@Nullable public SignalPollResult signalPoll(@NonNull String ifaceName) {
IClientInterface iface = getClientInterface(ifaceName);
@@ -773,10 +774,14 @@ public class WifiCondManager {
}
/**
- * Get current transmit (Tx) packet counters of the specified interface.
+ * Get current transmit (Tx) packet counters of the specified interface. The interface must
+ * have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
*
* @param ifaceName Name of the interface.
- * @return {@link TxPacketCounters} of the current interface or null on error.
+ * @return {@link TxPacketCounters} of the current interface or null on error (e.g. when
+ * called before the interface has been set up).
*/
@Nullable public TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) {
IClientInterface iface = getClientInterface(ifaceName);
@@ -810,10 +815,15 @@ public class WifiCondManager {
* be done using {@link #startScan(String, int, Set, List)} or
* {@link #startPnoScan(String, PnoSettings, Executor, PnoScanRequestCallback)}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface.
* @param scanType The type of scan result to be returned, can be
* {@link #SCAN_TYPE_SINGLE_SCAN} or {@link #SCAN_TYPE_PNO_SCAN}.
- * @return Returns an array of {@link NativeScanResult} or an empty array on failure.
+ * @return Returns an array of {@link NativeScanResult} or an empty array on failure (e.g. when
+ * called before the interface has been set up).
*/
@NonNull public List<NativeScanResult> getScanResults(@NonNull String ifaceName,
@ScanResultType int scanType) {
@@ -866,13 +876,19 @@ public class WifiCondManager {
* The latest scans can be obtained using {@link #getScanResults(String, int)} and using a
* {@link #SCAN_TYPE_SINGLE_SCAN} for the {@code scanType}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface on which to initiate the scan.
* @param scanType Type of scan to perform, can be any of
* {@link WifiScanner#SCAN_TYPE_HIGH_ACCURACY}, {@link WifiScanner#SCAN_TYPE_LOW_POWER}, or
* {@link WifiScanner#SCAN_TYPE_LOW_LATENCY}.
* @param freqs list of frequencies to scan for, if null scan all supported channels.
- * @param hiddenNetworkSSIDs List of hidden networks to be scanned for.
- * @return Returns true on success.
+ * @param hiddenNetworkSSIDs List of hidden networks to be scanned for, a null indicates that
+ * no hidden frequencies will be scanned for.
+ * @return Returns true on success, false on failure (e.g. when called before the interface
+ * has been set up).
*/
public boolean startScan(@NonNull String ifaceName, @WifiAnnotations.ScanType int scanType,
@Nullable Set<Integer> freqs, @Nullable List<byte[]> hiddenNetworkSSIDs) {
@@ -928,11 +944,16 @@ public class WifiCondManager {
* The latest PNO scans can be obtained using {@link #getScanResults(String, int)} with the
* {@code scanType} set to {@link #SCAN_TYPE_PNO_SCAN}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface on which to request a PNO.
* @param pnoSettings PNO scan configuration.
* @param executor The Executor on which to execute the callback.
* @param callback Callback for the results of the offload request.
- * @return true on success.
+ * @return true on success, false on failure (e.g. when called before the interface has been set
+ * up).
*/
public boolean startPnoScan(@NonNull String ifaceName, @NonNull PnoSettings pnoSettings,
@NonNull @CallbackExecutor Executor executor,
@@ -966,8 +987,13 @@ public class WifiCondManager {
* Stop PNO scan configured with
* {@link #startPnoScan(String, PnoSettings, Executor, PnoScanRequestCallback)}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface on which the PNO scan was configured.
- * @return true on success.
+ * @return true on success, false on failure (e.g. when called before the interface has been
+ * set up).
*/
public boolean stopPnoScan(@NonNull String ifaceName) {
IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
@@ -984,7 +1010,13 @@ public class WifiCondManager {
}
/**
- * Abort ongoing single scan started with {@link #startScan(String, int, Set, List)}.
+ * Abort ongoing single scan started with {@link #startScan(String, int, Set, List)}. No failure
+ * callback, e.g. {@link ScanEventCallback#onScanFailed()}, is triggered by this operation.
+ *
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}. If the interface has not been set up then
+ * this method has no impact.
*
* @param ifaceName Name of the interface on which the scan was started.
*/
@@ -1052,7 +1084,14 @@ public class WifiCondManager {
}
/**
- * Get the device phy capabilities for a given interface
+ * Get the device phy capabilities for a given interface.
+ *
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
+ * @return DeviceWiphyCapabilities or null on error (e.g. when called on an interface which has
+ * not been set up).
*/
@Nullable public DeviceWiphyCapabilities getDeviceWiphyCapabilities(@NonNull String ifaceName) {
if (mWificond == null) {
@@ -1068,13 +1107,19 @@ public class WifiCondManager {
}
/**
- * Register the provided callback handler for SoftAp events. Note that the Soft AP itself is
- * configured using {@link #setupInterfaceForSoftApMode(String)}.
+ * Register the provided callback handler for SoftAp events. The interface must first be created
+ * using {@link #setupInterfaceForSoftApMode(String)}. The callback registration is valid until
+ * the interface is deleted using {@link #tearDownSoftApInterface(String)} (no deregistration
+ * method is provided).
+ * <p>
+ * Note that only one callback can be registered at a time - any registration overrides previous
+ * registrations.
*
* @param ifaceName Name of the interface on which to register the callback.
* @param executor The Executor on which to execute the callbacks.
* @param callback Callback for AP events.
- * @return true on success, false otherwise.
+ * @return true on success, false on failure (e.g. when called on an interface which has not
+ * been set up).
*/
public boolean registerApCallback(@NonNull String ifaceName,
@NonNull @CallbackExecutor Executor executor,
@@ -1110,6 +1155,10 @@ public class WifiCondManager {
* Send a management frame on the specified interface at the specified rate. Useful for probing
* the link with arbitrary frames.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName The interface on which to send the frame.
* @param frame The raw byte array of the management frame to tramit.
* @param mcs The MCS (modulation and coding scheme), i.e. rate, at which to transmit the
diff --git a/wifi/java/com/android/server/wifi/BaseWifiService.java b/wifi/java/com/android/server/wifi/BaseWifiService.java
deleted file mode 100644
index 060c85cac209..000000000000
--- a/wifi/java/com/android/server/wifi/BaseWifiService.java
+++ /dev/null
@@ -1,641 +0,0 @@
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License") {
- * throw new UnsupportedOperationException();
- }
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.wifi;
-
-import android.content.pm.ParceledListSlice;
-import android.net.DhcpInfo;
-import android.net.Network;
-import android.net.wifi.IActionListener;
-import android.net.wifi.IDppCallback;
-import android.net.wifi.ILocalOnlyHotspotCallback;
-import android.net.wifi.INetworkRequestMatchCallback;
-import android.net.wifi.IOnWifiActivityEnergyInfoListener;
-import android.net.wifi.IOnWifiUsabilityStatsListener;
-import android.net.wifi.IScanResultsCallback;
-import android.net.wifi.ISoftApCallback;
-import android.net.wifi.ISuggestionConnectionStatusListener;
-import android.net.wifi.ITrafficStateCallback;
-import android.net.wifi.ITxPacketCountListener;
-import android.net.wifi.IWifiConnectedNetworkScorer;
-import android.net.wifi.IWifiManager;
-import android.net.wifi.ScanResult;
-import android.net.wifi.SoftApConfiguration;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WifiNetworkSuggestion;
-import android.net.wifi.hotspot2.IProvisioningCallback;
-import android.net.wifi.hotspot2.OsuProvider;
-import android.net.wifi.hotspot2.PasspointConfiguration;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.os.ResultReceiver;
-import android.os.WorkSource;
-import android.os.connectivity.WifiActivityEnergyInfo;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Empty concrete class implementing IWifiManager with stub methods throwing runtime exceptions.
- *
- * This class is meant to be extended by real implementations of IWifiManager in order to facilitate
- * cross-repo changes to WiFi internal APIs, including the introduction of new APIs, the removal of
- * deprecated APIs, or the migration of existing API signatures.
- *
- * When an existing API is scheduled for removal, it can be removed from IWifiManager.aidl
- * immediately and marked as @Deprecated first in this class. Children inheriting this class are
- * then given a short grace period to update themselves before the @Deprecated stub is removed for
- * good. If the API scheduled for removal has a replacement or an overload (signature change),
- * these should be introduced before the stub is removed to allow children to migrate.
- *
- * When a new API is added to IWifiManager.aidl, a stub should be added in BaseWifiService as
- * well otherwise compilation will fail.
- */
-public class BaseWifiService extends IWifiManager.Stub {
-
- private static final String TAG = BaseWifiService.class.getSimpleName();
-
- @Override
- public long getSupportedFeatures() {
- throw new UnsupportedOperationException();
- }
-
- /** @deprecated use {@link #getWifiActivityEnergyInfoAsync} instead */
- @Deprecated
- public WifiActivityEnergyInfo reportActivityInfo() {
- throw new UnsupportedOperationException();
- }
-
- /** @deprecated use {@link #getWifiActivityEnergyInfoAsync} instead */
- @Deprecated
- public void requestActivityInfo(ResultReceiver result) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void getWifiActivityEnergyInfoAsync(IOnWifiActivityEnergyInfoListener listener) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ParceledListSlice getConfiguredNetworks(String packageName, String featureId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ParceledListSlice getPrivilegedConfiguredNetworks(String packageName, String featureId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Map<String, Map<Integer, List<ScanResult>>> getAllMatchingFqdnsForScanResults(
- List<ScanResult> scanResults) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Map<OsuProvider, List<ScanResult>> getMatchingOsuProviders(
- List<ScanResult> scanResults) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Map<OsuProvider, PasspointConfiguration> getMatchingPasspointConfigsForOsuProviders(
- List<OsuProvider> osuProviders) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int addOrUpdateNetwork(WifiConfiguration config, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addOrUpdatePasspointConfiguration(
- PasspointConfiguration config, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean removePasspointConfiguration(String fqdn, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<PasspointConfiguration> getPasspointConfigurations(String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<WifiConfiguration> getWifiConfigsForPasspointProfiles(List<String> fqdnList) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void queryPasspointIcon(long bssid, String fileName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int matchProviderWithCurrentNetwork(String fqdn) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void deauthenticateNetwork(long holdoff, boolean ess) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean removeNetwork(int netId, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean enableNetwork(int netId, boolean disableOthers, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean disableNetwork(int netId, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void allowAutojoinGlobal(boolean choice) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void allowAutojoin(int netId, boolean choice) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void allowAutojoinPasspoint(String fqdn, boolean enableAutoJoin) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setMacRandomizationSettingPasspointEnabled(String fqdn, boolean enable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setMeteredOverridePasspoint(String fqdn, int meteredOverride) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean startScan(String packageName, String featureId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<ScanResult> getScanResults(String callingPackage, String callingFeatureId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean disconnect(String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean reconnect(String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean reassociate(String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public WifiInfo getConnectionInfo(String callingPackage, String callingFeatureId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean setWifiEnabled(String packageName, boolean enable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getWifiEnabledState() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getCountryCode() {
- throw new UnsupportedOperationException();
- }
-
- /** @deprecated use {@link #is5GHzBandSupported} instead */
- @Deprecated
- public boolean isDualBandSupported() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean is5GHzBandSupported() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean is6GHzBandSupported() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isWifiStandardSupported(int standard) {
- throw new UnsupportedOperationException();
- }
-
- /** @deprecated use {@link WifiManager#isStaApConcurrencySupported()} */
- @Deprecated
- public boolean needs5GHzToAnyApBandConversion() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DhcpInfo getDhcpInfo() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isScanAlwaysAvailable() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean acquireWifiLock(IBinder lock, int lockType, String tag, WorkSource ws) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateWifiLockWorkSource(IBinder lock, WorkSource ws) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean releaseWifiLock(IBinder lock) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void initializeMulticastFiltering() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isMulticastEnabled() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void acquireMulticastLock(IBinder binder, String tag) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void releaseMulticastLock(String tag) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateInterfaceIpState(String ifaceName, int mode) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean startSoftAp(WifiConfiguration wifiConfig) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean startTetheredHotspot(SoftApConfiguration softApConfig) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean stopSoftAp() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startLocalOnlyHotspot(ILocalOnlyHotspotCallback callback, String packageName,
- String featureId, SoftApConfiguration customConfig) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void stopLocalOnlyHotspot() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void startWatchLocalOnlyHotspot(ILocalOnlyHotspotCallback callback) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void stopWatchLocalOnlyHotspot() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getWifiApEnabledState() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public WifiConfiguration getWifiApConfiguration() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SoftApConfiguration getSoftApConfiguration() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean setWifiApConfiguration(WifiConfiguration wifiConfig, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean setSoftApConfiguration(SoftApConfiguration softApConfig, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void notifyUserOfApBandConversion(String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void enableTdls(String remoteIPAddress, boolean enable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getCurrentNetworkWpsNfcConfigurationToken() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void enableVerboseLogging(int verbose) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getVerboseLoggingLevel() {
- throw new UnsupportedOperationException();
- }
-
- /** @deprecated use {@link #allowAutojoinGlobal(boolean)} instead */
- @Deprecated
- public void enableWifiConnectivityManager(boolean enabled) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void disableEphemeralNetwork(String SSID, String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void factoryReset(String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Network getCurrentNetwork() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public byte[] retrieveBackupData() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void restoreBackupData(byte[] data) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public byte[] retrieveSoftApBackupData() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SoftApConfiguration restoreSoftApBackupData(byte[] data) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void restoreSupplicantBackupData(byte[] supplicantData, byte[] ipConfigData) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void startSubscriptionProvisioning(
- OsuProvider provider, IProvisioningCallback callback) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void registerSoftApCallback(
- IBinder binder, ISoftApCallback callback, int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void unregisterSoftApCallback(int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void registerTrafficStateCallback(
- IBinder binder, ITrafficStateCallback callback, int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void unregisterTrafficStateCallback(int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void registerNetworkRequestMatchCallback(
- IBinder binder, INetworkRequestMatchCallback callback, int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void unregisterNetworkRequestMatchCallback(int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int addNetworkSuggestions(
- List<WifiNetworkSuggestion> networkSuggestions, String callingPackageName,
- String callingFeatureId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int removeNetworkSuggestions(
- List<WifiNetworkSuggestion> networkSuggestions, String callingPackageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<WifiNetworkSuggestion> getNetworkSuggestions(String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String[] getFactoryMacAddresses() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setDeviceMobilityState(int state) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void startDppAsConfiguratorInitiator(IBinder binder, String enrolleeUri,
- int selectedNetworkId, int netRole, IDppCallback callback) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void startDppAsEnrolleeInitiator(IBinder binder, String configuratorUri,
- IDppCallback callback) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void stopDppSession() throws RemoteException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addOnWifiUsabilityStatsListener(
- IBinder binder, IOnWifiUsabilityStatsListener listener, int listenerIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void removeOnWifiUsabilityStatsListener(int listenerIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateWifiUsabilityScore(int seqNum, int score, int predictionHorizonSec) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void connect(WifiConfiguration config, int netId, IBinder binder,
- IActionListener callback, int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void save(WifiConfiguration config, IBinder binder, IActionListener callback,
- int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void forget(int netId, IBinder binder, IActionListener callback,
- int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void getTxPacketCount(String packageName, IBinder binder,
- ITxPacketCountListener callback, int callbackIdentifier) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void registerScanResultsCallback(IScanResultsCallback callback) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void unregisterScanResultsCallback(IScanResultsCallback callback) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void registerSuggestionConnectionStatusListener(IBinder binder,
- ISuggestionConnectionStatusListener listener,
- int listenerIdentifier, String packageName, String featureId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void unregisterSuggestionConnectionStatusListener(int listenerIdentifier,
- String packageName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int calculateSignalLevel(int rssi) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<WifiConfiguration> getWifiConfigForMatchedNetworkSuggestionsSharedWithUser(
- List<ScanResult> scanResults) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean setWifiConnectedNetworkScorer(IBinder binder,
- IWifiConnectedNetworkScorer scorer) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clearWifiConnectedNetworkScorer() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Map<WifiNetworkSuggestion, List<ScanResult>> getMatchingScanResults(
- List<WifiNetworkSuggestion> networkSuggestions,
- List<ScanResult> scanResults,
- String callingPackage, String callingFeatureId) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/wifi/tests/src/android/net/wifi/SoftApConfigurationTest.java b/wifi/tests/src/android/net/wifi/SoftApConfigurationTest.java
index 2efdd97543a9..d9584885a045 100644
--- a/wifi/tests/src/android/net/wifi/SoftApConfigurationTest.java
+++ b/wifi/tests/src/android/net/wifi/SoftApConfigurationTest.java
@@ -287,17 +287,43 @@ public class SoftApConfigurationTest {
@Test
public void testToWifiConfigurationWithSupportedParameter() {
- SoftApConfiguration softApConfig = new SoftApConfiguration.Builder()
+ SoftApConfiguration softApConfig_2g = new SoftApConfiguration.Builder()
+ .setPassphrase("secretsecret",
+ SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)
+ .setChannel(11, SoftApConfiguration.BAND_2GHZ)
+ .setHiddenSsid(true)
+ .build();
+ WifiConfiguration wifiConfig_2g = softApConfig_2g.toWifiConfiguration();
+ assertThat(wifiConfig_2g.getAuthType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
+ assertThat(wifiConfig_2g.preSharedKey).isEqualTo("secretsecret");
+ assertThat(wifiConfig_2g.apBand).isEqualTo(WifiConfiguration.AP_BAND_2GHZ);
+ assertThat(wifiConfig_2g.apChannel).isEqualTo(11);
+ assertThat(wifiConfig_2g.hiddenSSID).isEqualTo(true);
+
+ SoftApConfiguration softApConfig_5g = new SoftApConfiguration.Builder()
.setPassphrase("secretsecret",
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)
.setChannel(149, SoftApConfiguration.BAND_5GHZ)
.setHiddenSsid(true)
.build();
- WifiConfiguration wifiConfig = softApConfig.toWifiConfiguration();
- assertThat(wifiConfig.getAuthType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
- assertThat(wifiConfig.preSharedKey).isEqualTo("secretsecret");
- assertThat(wifiConfig.apBand).isEqualTo(WifiConfiguration.AP_BAND_5GHZ);
- assertThat(wifiConfig.apChannel).isEqualTo(149);
- assertThat(wifiConfig.hiddenSSID).isEqualTo(true);
+ WifiConfiguration wifiConfig_5g = softApConfig_5g.toWifiConfiguration();
+ assertThat(wifiConfig_5g.getAuthType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
+ assertThat(wifiConfig_5g.preSharedKey).isEqualTo("secretsecret");
+ assertThat(wifiConfig_5g.apBand).isEqualTo(WifiConfiguration.AP_BAND_5GHZ);
+ assertThat(wifiConfig_5g.apChannel).isEqualTo(149);
+ assertThat(wifiConfig_5g.hiddenSSID).isEqualTo(true);
+
+ SoftApConfiguration softApConfig_2g5g = new SoftApConfiguration.Builder()
+ .setPassphrase("secretsecret",
+ SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)
+ .setBand(SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ)
+ .setHiddenSsid(true)
+ .build();
+ WifiConfiguration wifiConfig_2g5g = softApConfig_2g5g.toWifiConfiguration();
+ assertThat(wifiConfig_2g5g.getAuthType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
+ assertThat(wifiConfig_2g5g.preSharedKey).isEqualTo("secretsecret");
+ assertThat(wifiConfig_2g5g.apBand).isEqualTo(WifiConfiguration.AP_BAND_ANY);
+ assertThat(wifiConfig_2g5g.apChannel).isEqualTo(0);
+ assertThat(wifiConfig_2g5g.hiddenSSID).isEqualTo(true);
}
}
diff --git a/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java b/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java
index 8023160a811e..05a3dce44022 100644
--- a/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java
@@ -336,6 +336,20 @@ public class WifiConfigurationTest {
}
/**
+ * Ensure that {@link NetworkSelectionStatus#getMaxNetworkSelectionDisableReason()} returns
+ * the maximum disable reason.
+ */
+ @Test
+ public void testNetworkSelectionGetMaxNetworkSelectionDisableReason() {
+ int maxReason = Integer.MIN_VALUE;
+ for (int i = 0; i < NetworkSelectionStatus.DISABLE_REASON_INFOS.size(); i++) {
+ int reason = NetworkSelectionStatus.DISABLE_REASON_INFOS.keyAt(i);
+ maxReason = Math.max(maxReason, reason);
+ }
+ assertEquals(maxReason, NetworkSelectionStatus.getMaxNetworkSelectionDisableReason());
+ }
+
+ /**
* Ensure that {@link WifiConfiguration#setSecurityParams(int)} sets up the
* {@link WifiConfiguration} object correctly for SAE security type.
* @throws Exception
diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
index a189d507a32a..847040ca914a 100644
--- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
@@ -1551,14 +1551,15 @@ public class WifiManagerTest {
*/
@Test
public void testGetAllMatchingWifiConfigs() throws Exception {
- Map<String, List<ScanResult>> fqdns = new HashMap<>();
- fqdns.put("www.test.com", new ArrayList<>());
- when(mWifiService.getAllMatchingFqdnsForScanResults(any(List.class))).thenReturn(fqdns);
+ Map<String, List<ScanResult>> passpointProfiles = new HashMap<>();
+ passpointProfiles.put("www.test.com_987a69bca26", new ArrayList<>());
+ when(mWifiService.getAllMatchingPasspointProfilesForScanResults(
+ any(List.class))).thenReturn(passpointProfiles);
InOrder inOrder = inOrder(mWifiService);
mWifiManager.getAllMatchingWifiConfigs(new ArrayList<>());
- inOrder.verify(mWifiService).getAllMatchingFqdnsForScanResults(any(List.class));
+ inOrder.verify(mWifiService).getAllMatchingPasspointProfilesForScanResults(any(List.class));
inOrder.verify(mWifiService).getWifiConfigsForPasspointProfiles(any(List.class));
}
@@ -1867,7 +1868,7 @@ public class WifiManagerTest {
* Tests that passing a null Executor to {@link WifiManager#getWifiActivityEnergyInfoAsync}
* throws an exception.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testGetWifiActivityInfoNullExecutor() throws Exception {
mWifiManager.getWifiActivityEnergyInfoAsync(null, mOnWifiActivityEnergyInfoListener);
}
@@ -1876,7 +1877,7 @@ public class WifiManagerTest {
* Tests that passing a null listener to {@link WifiManager#getWifiActivityEnergyInfoAsync}
* throws an exception.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testGetWifiActivityInfoNullListener() throws Exception {
mWifiManager.getWifiActivityEnergyInfoAsync(mExecutor, null);
}
@@ -2380,4 +2381,14 @@ public class WifiManagerTest {
verify(mWifiConnectedNetworkScorer).start(0);
verify(mWifiConnectedNetworkScorer).stop(10);
}
+
+ @Test
+ public void testScanThrottle() throws Exception {
+ mWifiManager.setScanThrottleEnabled(true);
+ verify(mWifiService).setScanThrottleEnabled(true);
+
+ when(mWifiService.isScanThrottleEnabled()).thenReturn(false);
+ assertFalse(mWifiManager.isScanThrottleEnabled());
+ verify(mWifiService).isScanThrottleEnabled();
+ }
}
diff --git a/wifi/tests/src/android/net/wifi/WifiNetworkAgentSpecifierTest.java b/wifi/tests/src/android/net/wifi/WifiNetworkAgentSpecifierTest.java
index adc41f0df4b4..0233ee2e2785 100644
--- a/wifi/tests/src/android/net/wifi/WifiNetworkAgentSpecifierTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiNetworkAgentSpecifierTest.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
import android.net.MacAddress;
import android.net.MatchAllNetworkSpecifier;
-import android.net.NetworkRequest;
import android.os.Parcel;
import android.os.PatternMatcher;
import android.util.Pair;
@@ -36,10 +35,6 @@ import org.junit.Test;
*/
@SmallTest
public class WifiNetworkAgentSpecifierTest {
- private static final int TEST_UID = 5;
- private static final int TEST_UID_1 = 8;
- private static final String TEST_PACKAGE = "com.test";
- private static final String TEST_PACKAGE_1 = "com.test.1";
private static final String TEST_SSID = "Test123";
private static final String TEST_SSID_PATTERN = "Test";
private static final String TEST_SSID_1 = "456test";
@@ -71,16 +66,6 @@ public class WifiNetworkAgentSpecifierTest {
}
/**
- * Validate that the NetworkAgentSpecifier cannot be used in a {@link NetworkRequest} by apps.
- */
- @Test(expected = IllegalStateException.class)
- public void testWifiNetworkAgentSpecifierNotUsedInNetworkRequest() {
- WifiNetworkAgentSpecifier specifier = createDefaultNetworkAgentSpecifier();
-
- specifier.assertValidFromUid(TEST_UID);
- }
-
- /**
* Validate NetworkAgentSpecifier equals with itself.
* a) Create network agent specifier 1 for WPA_PSK network
* b) Create network agent specifier 2 with the same params as specifier 1.
@@ -105,15 +90,13 @@ public class WifiNetworkAgentSpecifierTest {
WifiConfiguration wifiConfiguration1 = createDefaultWifiConfiguration();
WifiNetworkAgentSpecifier specifier1 =
new WifiNetworkAgentSpecifier(
- wifiConfiguration1,
- TEST_UID, TEST_PACKAGE);
+ wifiConfiguration1);
WifiConfiguration wifiConfiguration2 = new WifiConfiguration(wifiConfiguration1);
wifiConfiguration2.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiNetworkAgentSpecifier specifier2 =
new WifiNetworkAgentSpecifier(
- wifiConfiguration2,
- TEST_UID, TEST_PACKAGE);
+ wifiConfiguration2);
assertFalse(specifier2.equals(specifier1));
}
@@ -129,15 +112,13 @@ public class WifiNetworkAgentSpecifierTest {
WifiConfiguration wifiConfiguration1 = createDefaultWifiConfiguration();
WifiNetworkAgentSpecifier specifier1 =
new WifiNetworkAgentSpecifier(
- wifiConfiguration1,
- TEST_UID, TEST_PACKAGE);
+ wifiConfiguration1);
WifiConfiguration wifiConfiguration2 = new WifiConfiguration(wifiConfiguration1);
wifiConfiguration2.SSID = TEST_SSID_1;
WifiNetworkAgentSpecifier specifier2 =
new WifiNetworkAgentSpecifier(
- wifiConfiguration2,
- TEST_UID, TEST_PACKAGE);
+ wifiConfiguration2);
assertFalse(specifier2.equals(specifier1));
}
@@ -153,15 +134,13 @@ public class WifiNetworkAgentSpecifierTest {
WifiConfiguration wifiConfiguration1 = createDefaultWifiConfiguration();
WifiNetworkAgentSpecifier specifier1 =
new WifiNetworkAgentSpecifier(
- wifiConfiguration1,
- TEST_UID, TEST_PACKAGE);
+ wifiConfiguration1);
WifiConfiguration wifiConfiguration2 = new WifiConfiguration(wifiConfiguration1);
wifiConfiguration2.BSSID = TEST_BSSID_1;
WifiNetworkAgentSpecifier specifier2 =
new WifiNetworkAgentSpecifier(
- wifiConfiguration2,
- TEST_UID, TEST_PACKAGE);
+ wifiConfiguration2);
assertFalse(specifier2.equals(specifier1));
}
@@ -215,8 +194,7 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
ssidPattern,
bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID, TEST_PACKAGE);
+ wificonfigurationNetworkSpecifier);
assertTrue(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
assertTrue(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
@@ -244,8 +222,7 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
ssidPattern,
bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID, TEST_PACKAGE);
+ wificonfigurationNetworkSpecifier);
assertTrue(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
assertTrue(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
@@ -273,8 +250,7 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
ssidPattern,
bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID, TEST_PACKAGE);
+ wificonfigurationNetworkSpecifier);
assertTrue(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
assertTrue(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
@@ -293,8 +269,7 @@ public class WifiNetworkAgentSpecifierTest {
wifiConfigurationNetworkAgent.SSID = "\"" + TEST_SSID_1 + "\"";
WifiNetworkAgentSpecifier wifiNetworkAgentSpecifier =
new WifiNetworkAgentSpecifier(
- wifiConfigurationNetworkAgent,
- TEST_UID, TEST_PACKAGE);
+ wifiConfigurationNetworkAgent);
PatternMatcher ssidPattern =
new PatternMatcher(TEST_SSID_PATTERN, PatternMatcher.PATTERN_PREFIX);
@@ -306,8 +281,7 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
ssidPattern,
bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID, TEST_PACKAGE);
+ wificonfigurationNetworkSpecifier);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
@@ -326,8 +300,7 @@ public class WifiNetworkAgentSpecifierTest {
wifiConfigurationNetworkAgent.BSSID = TEST_BSSID_1;
WifiNetworkAgentSpecifier wifiNetworkAgentSpecifier =
new WifiNetworkAgentSpecifier(
- wifiConfigurationNetworkAgent,
- TEST_UID, TEST_PACKAGE);
+ wifiConfigurationNetworkAgent);
PatternMatcher ssidPattern =
new PatternMatcher(".*", PatternMatcher.PATTERN_SIMPLE_GLOB);
@@ -340,8 +313,7 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
ssidPattern,
bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID, TEST_PACKAGE);
+ wificonfigurationNetworkSpecifier);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
@@ -360,8 +332,7 @@ public class WifiNetworkAgentSpecifierTest {
wifiConfigurationNetworkAgent.BSSID = TEST_BSSID_1;
WifiNetworkAgentSpecifier wifiNetworkAgentSpecifier =
new WifiNetworkAgentSpecifier(
- wifiConfigurationNetworkAgent,
- TEST_UID, TEST_PACKAGE);
+ wifiConfigurationNetworkAgent);
PatternMatcher ssidPattern =
new PatternMatcher(TEST_SSID_PATTERN, PatternMatcher.PATTERN_PREFIX);
@@ -374,8 +345,7 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
ssidPattern,
bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID, TEST_PACKAGE);
+ wificonfigurationNetworkSpecifier);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
@@ -402,41 +372,12 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
ssidPattern,
bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID, TEST_PACKAGE);
+ wificonfigurationNetworkSpecifier);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
}
- /**
- * Validate {@link WifiNetworkAgentSpecifier} with {@link WifiNetworkSpecifier} matching.
- * a) Create network agent specifier for WPA_PSK network
- * b) Create network specifier with matching SSID and BSSID pattern, but different UID.
- * c) Ensure that the agent specifier is not satisfied by specifier.
- */
- @Test
- public void
- testWifiNetworkAgentSpecifierDoesNotSatisfyNetworkSpecifierWithDifferentUid() {
- WifiNetworkAgentSpecifier wifiNetworkAgentSpecifier = createDefaultNetworkAgentSpecifier();
-
- PatternMatcher ssidPattern =
- new PatternMatcher(TEST_SSID_PATTERN, PatternMatcher.PATTERN_PREFIX);
- Pair<MacAddress, MacAddress> bssidPattern =
- Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
- MacAddress.fromString(TEST_BSSID_OUI_MASK));
- WifiConfiguration wificonfigurationNetworkSpecifier = new WifiConfiguration();
- wificonfigurationNetworkSpecifier.allowedKeyManagement
- .set(WifiConfiguration.KeyMgmt.WPA_PSK);
- WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier(
- ssidPattern,
- bssidPattern,
- wificonfigurationNetworkSpecifier,
- TEST_UID_1, TEST_PACKAGE_1);
-
- assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier));
- assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier));
- }
private WifiConfiguration createDefaultWifiConfiguration() {
WifiConfiguration wifiConfiguration = new WifiConfiguration();
@@ -448,8 +389,7 @@ public class WifiNetworkAgentSpecifierTest {
}
private WifiNetworkAgentSpecifier createDefaultNetworkAgentSpecifier() {
- return new WifiNetworkAgentSpecifier(createDefaultWifiConfiguration(), TEST_UID,
- TEST_PACKAGE);
+ return new WifiNetworkAgentSpecifier(createDefaultWifiConfiguration());
}
}
diff --git a/wifi/tests/src/android/net/wifi/WifiNetworkSpecifierTest.java b/wifi/tests/src/android/net/wifi/WifiNetworkSpecifierTest.java
index 16197443b9d9..3b6723613c50 100644
--- a/wifi/tests/src/android/net/wifi/WifiNetworkSpecifierTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiNetworkSpecifierTest.java
@@ -29,7 +29,6 @@ import android.net.MatchAllNetworkSpecifier;
import android.net.NetworkSpecifier;
import android.os.Parcel;
import android.os.PatternMatcher;
-import android.os.Process;
import android.util.Pair;
import androidx.test.filters.SmallTest;
@@ -41,8 +40,6 @@ import org.junit.Test;
*/
@SmallTest
public class WifiNetworkSpecifierTest {
- private static final int TEST_UID = 5;
- private static final String TEST_PACKAGE_NAME = "com.test";
private static final String TEST_SSID = "Test123";
private static final String TEST_BSSID_OUI_BASE_ADDRESS = "12:12:12:00:00:00";
private static final String TEST_BSSID_OUI_MASK = "ff:ff:ff:00:00:00";
@@ -62,7 +59,6 @@ public class WifiNetworkSpecifierTest {
assertTrue(specifier instanceof WifiNetworkSpecifier);
WifiNetworkSpecifier wifiNetworkSpecifier = (WifiNetworkSpecifier) specifier;
- assertEquals(Process.myUid(), wifiNetworkSpecifier.requestorUid);
assertEquals(TEST_SSID, wifiNetworkSpecifier.ssidPatternMatcher.getPath());
assertEquals(PATTERN_PREFIX, wifiNetworkSpecifier.ssidPatternMatcher.getType());
assertEquals(WifiManager.ALL_ZEROS_MAC_ADDRESS,
@@ -367,8 +363,7 @@ public class WifiNetworkSpecifierTest {
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration);
Parcel parcelW = Parcel.obtain();
specifier.writeToParcel(parcelW, 0);
@@ -399,8 +394,7 @@ public class WifiNetworkSpecifierTest {
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration);
assertTrue(specifier.satisfiedBy(null));
assertTrue(specifier.satisfiedBy(new MatchAllNetworkSpecifier()));
@@ -422,15 +416,13 @@ public class WifiNetworkSpecifierTest {
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration);
WifiNetworkSpecifier specifier2 =
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration);
assertTrue(specifier2.satisfiedBy(specifier1));
}
@@ -451,8 +443,7 @@ public class WifiNetworkSpecifierTest {
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration1,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration1);
WifiConfiguration wifiConfiguration2 = new WifiConfiguration();
wifiConfiguration2.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
@@ -460,8 +451,7 @@ public class WifiNetworkSpecifierTest {
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration2,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration2);
assertFalse(specifier2.satisfiedBy(specifier1));
}
@@ -482,15 +472,13 @@ public class WifiNetworkSpecifierTest {
new WifiNetworkSpecifier(new PatternMatcher("", PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration);
WifiNetworkSpecifier specifier2 =
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration);
assertFalse(specifier2.satisfiedBy(specifier1));
}
@@ -511,44 +499,13 @@ public class WifiNetworkSpecifierTest {
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
+ wifiConfiguration);
WifiNetworkSpecifier specifier2 =
new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
Pair.create(WifiManager.ALL_ZEROS_MAC_ADDRESS,
WifiManager.ALL_ZEROS_MAC_ADDRESS),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
-
- assertFalse(specifier2.satisfiedBy(specifier1));
- }
-
- /**
- * Validate NetworkSpecifier matching.
- * a) Create network specifier 1 for WPA_PSK network
- * b) Create network specifier 2 with different package name .
- * c) Ensure that the specifier 2 is not satisfied by specifier 1.
- */
- @Test
- public void testWifiNetworkSpecifierDoesNotSatisfyWhenPackageNameDifferent() {
- WifiConfiguration wifiConfiguration = new WifiConfiguration();
- wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
- wifiConfiguration.preSharedKey = TEST_PRESHARED_KEY;
-
- WifiNetworkSpecifier specifier1 =
- new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
- Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
- MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME);
-
- WifiNetworkSpecifier specifier2 =
- new WifiNetworkSpecifier(new PatternMatcher(TEST_SSID, PATTERN_LITERAL),
- Pair.create(MacAddress.fromString(TEST_BSSID_OUI_BASE_ADDRESS),
- MacAddress.fromString(TEST_BSSID_OUI_MASK)),
- wifiConfiguration,
- TEST_UID, TEST_PACKAGE_NAME + "blah");
+ wifiConfiguration);
assertFalse(specifier2.satisfiedBy(specifier1));
}
diff --git a/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java b/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java
index 15accc337429..af6fb5c1cd22 100644
--- a/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java
@@ -105,7 +105,7 @@ public class WifiNetworkSuggestionTest {
.setSsid(TEST_SSID)
.setWpa2Passphrase(TEST_PRESHARED_KEY)
.setIsUserInteractionRequired(true)
- .setIsInitialAutoJoinEnabled(false)
+ .setIsInitialAutojoinEnabled(false)
.setIsMetered(true)
.build();
@@ -155,7 +155,7 @@ public class WifiNetworkSuggestionTest {
.setSsid(TEST_SSID)
.setWpa3Passphrase(TEST_PRESHARED_KEY)
.setCredentialSharedWithUser(true)
- .setIsInitialAutoJoinEnabled(false)
+ .setIsInitialAutojoinEnabled(false)
.build();
assertEquals("\"" + TEST_SSID + "\"", suggestion.wifiConfiguration.SSID);
@@ -732,20 +732,20 @@ public class WifiNetworkSuggestionTest {
/**
* Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception
- * when {@link WifiNetworkSuggestion.Builder#setIsInitialAutoJoinEnabled(boolean)} to
+ * when {@link WifiNetworkSuggestion.Builder#setIsInitialAutojoinEnabled(boolean)} to
* false on a open network suggestion.
*/
@Test(expected = IllegalStateException.class)
public void testSetIsAutoJoinDisabledWithOpenNetwork() {
new WifiNetworkSuggestion.Builder()
.setSsid(TEST_SSID)
- .setIsInitialAutoJoinEnabled(false)
+ .setIsInitialAutojoinEnabled(false)
.build();
}
/**
* Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception
- * when set both {@link WifiNetworkSuggestion.Builder#setIsInitialAutoJoinEnabled(boolean)}
+ * when set both {@link WifiNetworkSuggestion.Builder#setIsInitialAutojoinEnabled(boolean)}
* and {@link WifiNetworkSuggestion.Builder#setCredentialSharedWithUser(boolean)} (boolean)}
* to false on a network suggestion.
*/
@@ -755,7 +755,7 @@ public class WifiNetworkSuggestionTest {
.setSsid(TEST_SSID)
.setWpa2Passphrase(TEST_PRESHARED_KEY)
.setCredentialSharedWithUser(false)
- .setIsInitialAutoJoinEnabled(false)
+ .setIsInitialAutojoinEnabled(false)
.build();
}
@@ -808,7 +808,7 @@ public class WifiNetworkSuggestionTest {
/**
* Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception
- * when set both {@link WifiNetworkSuggestion.Builder#setIsInitialAutoJoinEnabled(boolean)}
+ * when set both {@link WifiNetworkSuggestion.Builder#setIsInitialAutojoinEnabled(boolean)}
* and {@link WifiNetworkSuggestion.Builder#setCredentialSharedWithUser(boolean)} (boolean)}
* to false on a passpoint suggestion.
*/
@@ -818,7 +818,7 @@ public class WifiNetworkSuggestionTest {
new WifiNetworkSuggestion.Builder()
.setPasspointConfig(passpointConfiguration)
.setCredentialSharedWithUser(false)
- .setIsInitialAutoJoinEnabled(false)
+ .setIsInitialAutojoinEnabled(false)
.build();
}
}
diff --git a/wifi/tests/src/android/net/wifi/aware/WifiAwareAgentNetworkSpecifierTest.java b/wifi/tests/src/android/net/wifi/aware/WifiAwareAgentNetworkSpecifierTest.java
index c3b62854f12c..81b02fa5f801 100644
--- a/wifi/tests/src/android/net/wifi/aware/WifiAwareAgentNetworkSpecifierTest.java
+++ b/wifi/tests/src/android/net/wifi/aware/WifiAwareAgentNetworkSpecifierTest.java
@@ -162,17 +162,6 @@ public class WifiAwareAgentNetworkSpecifierTest {
collector.checkThat("Match unexpected", oldNs.satisfiedBy(newNs), equalTo(false));
}
- /**
- * Validate that agent network specifier cannot be used as in network requests - i.e. that
- * throws an exception when queried for UID validity.
- */
- @Test(expected = SecurityException.class)
- public void testNoUsageInRequest() {
- WifiAwareAgentNetworkSpecifier dut = new WifiAwareAgentNetworkSpecifier();
-
- dut.assertValidFromUid(0);
- }
-
// utilities
/**
@@ -182,6 +171,6 @@ public class WifiAwareAgentNetworkSpecifierTest {
WifiAwareNetworkSpecifier getDummyNetworkSpecifier(int clientId) {
return new WifiAwareNetworkSpecifier(WifiAwareNetworkSpecifier.NETWORK_SPECIFIER_TYPE_OOB,
WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, clientId, 0, 0, new byte[6],
- null, null, 10, 5, 0);
+ null, null, 10, 5);
}
}
diff --git a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java
index 65fbf5b099d4..c5f98045082b 100644
--- a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java
@@ -1564,7 +1564,7 @@ public class WifiAwareManagerTest {
WifiAwareNetworkSpecifier ns = new WifiAwareNetworkSpecifier(NETWORK_SPECIFIER_TYPE_IB,
WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, 5, 568, 334,
HexEncoding.decode("000102030405".toCharArray(), false),
- "01234567890123456789012345678901".getBytes(), "blah blah", 666, 4, 10001);
+ "01234567890123456789012345678901".getBytes(), "blah blah", 666, 4);
Parcel parcelW = Parcel.obtain();
ns.writeToParcel(parcelW, 0);
diff --git a/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java b/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java
index 654154d77b0d..8f6beb19091b 100644
--- a/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java
+++ b/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java
@@ -18,9 +18,13 @@ package android.net.wifi.hotspot2;
import static android.net.wifi.WifiConfiguration.METERED_OVERRIDE_NONE;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
+import android.net.wifi.hotspot2.pps.Credential;
+import android.net.wifi.hotspot2.pps.HomeSp;
import android.os.Parcel;
import androidx.test.filters.SmallTest;
@@ -173,7 +177,7 @@ public class PasspointConfigurationTest {
assertFalse(config.validate());
assertFalse(config.validateForR2());
- assertTrue(config.isAutoJoinEnabled());
+ assertTrue(config.isAutojoinEnabled());
assertTrue(config.isMacRandomizationEnabled());
assertTrue(config.getMeteredOverride() == METERED_OVERRIDE_NONE);
}
@@ -364,4 +368,93 @@ public class PasspointConfigurationTest {
assertTrue(config.validateForR2());
assertTrue(config.isOsuProvisioned());
}
+
+ /**
+ * Verify that the unique identifier generated is identical for two instances
+ *
+ * @throws Exception
+ */
+ @Test
+ public void validateUniqueId() throws Exception {
+ PasspointConfiguration config1 = PasspointTestUtils.createConfig();
+ PasspointConfiguration config2 = PasspointTestUtils.createConfig();
+
+ assertEquals(config1.getUniqueId(), config2.getUniqueId());
+ }
+
+ /**
+ * Verify that the unique identifier generated is different for two instances with different
+ * HomeSp node
+ *
+ * @throws Exception
+ */
+ @Test
+ public void validateUniqueIdDifferentHomeSp() throws Exception {
+ PasspointConfiguration config1 = PasspointTestUtils.createConfig();
+
+ // Modify config2's RCOIs to a different set of values
+ PasspointConfiguration config2 = PasspointTestUtils.createConfig();
+ HomeSp homeSp = config2.getHomeSp();
+ homeSp.setRoamingConsortiumOis(new long[] {0xaa, 0xbb});
+ config2.setHomeSp(homeSp);
+
+ assertNotEquals(config1.getUniqueId(), config2.getUniqueId());
+ }
+
+ /**
+ * Verify that the unique identifier generated is different for two instances with different
+ * Credential node
+ *
+ * @throws Exception
+ */
+ @Test
+ public void validateUniqueIdDifferentCredential() throws Exception {
+ PasspointConfiguration config1 = PasspointTestUtils.createConfig();
+
+ // Modify config2's RCOIs to a different set of values
+ PasspointConfiguration config2 = PasspointTestUtils.createConfig();
+ Credential credential = config2.getCredential();
+ credential.setRealm("realm2.example.com");
+ credential.getSimCredential().setImsi("350460*");
+ config2.setCredential(credential);
+
+ assertNotEquals(config1.getUniqueId(), config2.getUniqueId());
+ }
+
+ /**
+ * Verify that the unique identifier API generates an exception if HomeSP is not initialized.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void validateUniqueIdExceptionWithEmptyHomeSp() throws Exception {
+ PasspointConfiguration config = PasspointTestUtils.createConfig();
+ config.setHomeSp(null);
+ boolean exceptionCaught = false;
+ try {
+ String uniqueId = config.getUniqueId();
+ } catch (IllegalStateException e) {
+ exceptionCaught = true;
+ }
+ assertTrue(exceptionCaught);
+ }
+
+ /**
+ * Verify that the unique identifier API generates an exception if Credential is not
+ * initialized.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void validateUniqueIdExceptionWithEmptyCredential() throws Exception {
+ PasspointConfiguration config = PasspointTestUtils.createConfig();
+ config.setCredential(null);
+ boolean exceptionCaught = false;
+ try {
+ String uniqueId = config.getUniqueId();
+ } catch (IllegalStateException e) {
+ exceptionCaught = true;
+ }
+ assertTrue(exceptionCaught);
+ }
}
diff --git a/wifi/tests/src/android/net/wifi/p2p/WifiP2pDeviceTest.java b/wifi/tests/src/android/net/wifi/p2p/WifiP2pDeviceTest.java
index 17ee75594c2f..6edc287068e8 100644
--- a/wifi/tests/src/android/net/wifi/p2p/WifiP2pDeviceTest.java
+++ b/wifi/tests/src/android/net/wifi/p2p/WifiP2pDeviceTest.java
@@ -45,7 +45,7 @@ public class WifiP2pDeviceTest {
assertEquals(devA.groupCapability, devB.groupCapability);
assertEquals(devA.status, devB.status);
if (devA.wfdInfo != null) {
- assertEquals(devA.wfdInfo.isWfdEnabled(), devB.wfdInfo.isWfdEnabled());
+ assertEquals(devA.wfdInfo.isEnabled(), devB.wfdInfo.isEnabled());
assertEquals(devA.wfdInfo.getDeviceInfoHex(), devB.wfdInfo.getDeviceInfoHex());
assertEquals(devA.wfdInfo.getControlPort(), devB.wfdInfo.getControlPort());
assertEquals(devA.wfdInfo.getMaxThroughput(), devB.wfdInfo.getMaxThroughput());
diff --git a/wifi/tests/src/android/net/wifi/p2p/WifiP2pWfdInfoTest.java b/wifi/tests/src/android/net/wifi/p2p/WifiP2pWfdInfoTest.java
index 15a0aacf6e5b..2a9b36b47172 100644
--- a/wifi/tests/src/android/net/wifi/p2p/WifiP2pWfdInfoTest.java
+++ b/wifi/tests/src/android/net/wifi/p2p/WifiP2pWfdInfoTest.java
@@ -55,8 +55,8 @@ public class WifiP2pWfdInfoTest {
public void testSettersGetters() throws Exception {
WifiP2pWfdInfo info = new WifiP2pWfdInfo();
- info.setWfdEnabled(true);
- assertTrue(info.isWfdEnabled());
+ info.setEnabled(true);
+ assertTrue(info.isEnabled());
info.setDeviceType(WifiP2pWfdInfo.DEVICE_TYPE_WFD_SOURCE);
assertEquals(WifiP2pWfdInfo.DEVICE_TYPE_WFD_SOURCE, info.getDeviceType());
diff --git a/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java b/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
index 06f12f7f37ea..0df170f8786c 100644
--- a/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
+++ b/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
@@ -28,7 +28,6 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.BitSet;
/**
* Unit tests for {@link android.net.wifi.wificond.NativeScanResult}.
@@ -46,7 +45,7 @@ public class NativeScanResultTest {
private static final int TEST_FREQUENCY = 2456;
private static final int TEST_SIGNAL_MBM = -45;
private static final long TEST_TSF = 34455441;
- private static final BitSet TEST_CAPABILITY = new BitSet(16) {{ set(2); set(5); }};
+ private static final int TEST_CAPABILITY = (0x1 << 2) | (0x1 << 5);
private static final boolean TEST_ASSOCIATED = true;
private static final int[] RADIO_CHAIN_IDS = { 0, 1 };
private static final int[] RADIO_CHAIN_LEVELS = { -56, -65 };
diff --git a/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java b/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java
index f262268d7179..b745a341b459 100644
--- a/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.when;
import android.app.AlarmManager;
import android.app.test.TestAlarmManager;
import android.content.Context;
+import android.net.MacAddress;
import android.net.wifi.ScanResult;
import android.net.wifi.SoftApInfo;
import android.net.wifi.WifiConfiguration;
@@ -119,7 +120,8 @@ public class WifiCondManagerTest {
private static final String TEST_QUOTED_SSID_2 = "\"testSsid2\"";
private static final int[] TEST_FREQUENCIES_1 = {};
private static final int[] TEST_FREQUENCIES_2 = {2500, 5124};
- private static final byte[] TEST_RAW_MAC_BYTES = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
+ private static final MacAddress TEST_RAW_MAC_BYTES = MacAddress.fromBytes(
+ new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05});
private static final List<byte[]> SCAN_HIDDEN_NETWORK_SSID_LIST =
new ArrayList<byte[]>() {{
@@ -718,8 +720,7 @@ public class WifiCondManagerTest {
@Test
public void testRegisterDeathHandler() throws Exception {
Runnable deathHandler = mock(Runnable.class);
- assertTrue(mWificondControl.initialize(deathHandler));
- verify(mWificond).tearDownInterfaces();
+ mWificondControl.setOnServiceDeadCallback(deathHandler);
mWificondControl.binderDied();
mLooper.dispatchAll();
verify(deathHandler).run();
@@ -732,7 +733,7 @@ public class WifiCondManagerTest {
@Test
public void testDeathHandling() throws Exception {
Runnable deathHandler = mock(Runnable.class);
- assertTrue(mWificondControl.initialize(deathHandler));
+ mWificondControl.setOnServiceDeadCallback(deathHandler);
testSetupInterfaceForClientMode();