summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2019-10-04 09:19:51 -0700
committerPhilip P. Moltmann <moltmann@google.com>2019-11-08 14:50:46 -0800
commitb380b4739da60242500d9bede8b18a802bd62fda (patch)
tree92664adb55d0731d95807d310aab90c0d97b41f6
parentd8b3d7c285b24a1b1e22721631c7bdb3c31ef3e1 (diff)
Pipe through featureId from app-context to wifi location checking code.
Bug: 136595429 Test: atest FrameworksWifiTests Change-Id: I3f4bde2e8f74a1a572acbe90e6ac7eaff13db893
-rw-r--r--service/java/com/android/server/wifi/NetworkSuggestionStoreData.java7
-rw-r--r--service/java/com/android/server/wifi/ScoredNetworkEvaluator.java4
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java32
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java50
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareClientState.java12
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java25
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareStateManager.java20
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java37
-rw-r--r--service/java/com/android/server/wifi/rtt/RttServiceImpl.java29
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java32
-rw-r--r--service/java/com/android/server/wifi/util/WifiPermissionsUtil.java76
-rw-r--r--tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java11
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java198
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java126
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java16
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java16
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java33
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java201
-rw-r--r--tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java423
-rw-r--r--tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java80
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java38
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java112
23 files changed, 930 insertions, 656 deletions
diff --git a/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java b/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java
index e880b66c2..810600b68 100644
--- a/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java
+++ b/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java
@@ -65,6 +65,7 @@ public class NetworkSuggestionStoreData implements WifiConfigStore.StoreData {
private static final String XML_TAG_IS_USER_INTERACTION_REQUIRED = "IsUserInteractionRequired";
private static final String XML_TAG_SUGGESTOR_UID = "SuggestorUid";
private static final String XML_TAG_SUGGESTOR_PACKAGE_NAME = "SuggestorPackageName";
+ private static final String XML_TAG_SUGGESTOR_FEATURE_ID = "SuggestorFeatureId";
private static final String XML_TAG_SUGGESTOR_HAS_USER_APPROVED = "SuggestorHasUserApproved";
private static final String XML_TAG_SUGGESTOR_MAX_SIZE = "SuggestorMaxSize";
private static final String XML_TAG_SECTION_HEADER_PASSPOINT_CONFIGURATION =
@@ -160,12 +161,14 @@ public class NetworkSuggestionStoreData implements WifiConfigStore.StoreData {
}
for (Entry<String, PerAppInfo> entry : networkSuggestionsMap.entrySet()) {
String packageName = entry.getKey();
+ String featureId = entry.getValue().featureId;
boolean hasUserApproved = entry.getValue().hasUserApproved;
int maxSize = entry.getValue().maxSize;
Set<ExtendedWifiNetworkSuggestion> networkSuggestions =
entry.getValue().extNetworkSuggestions;
XmlUtil.writeNextSectionStart(out, XML_TAG_SECTION_HEADER_NETWORK_SUGGESTION_PER_APP);
XmlUtil.writeNextValue(out, XML_TAG_SUGGESTOR_PACKAGE_NAME, packageName);
+ XmlUtil.writeNextValue(out, XML_TAG_SUGGESTOR_FEATURE_ID, featureId);
XmlUtil.writeNextValue(out, XML_TAG_SUGGESTOR_HAS_USER_APPROVED, hasUserApproved);
XmlUtil.writeNextValue(out, XML_TAG_SUGGESTOR_MAX_SIZE, maxSize);
serializeExtNetworkSuggestions(out, networkSuggestions, encryptionUtil);
@@ -252,10 +255,12 @@ public class NetworkSuggestionStoreData implements WifiConfigStore.StoreData {
try {
String packageName =
(String) XmlUtil.readNextValueWithName(in, XML_TAG_SUGGESTOR_PACKAGE_NAME);
+ String featureId =
+ (String) XmlUtil.readNextValueWithName(in, XML_TAG_SUGGESTOR_FEATURE_ID);
boolean hasUserApproved = (boolean) XmlUtil.readNextValueWithName(in,
XML_TAG_SUGGESTOR_HAS_USER_APPROVED);
int maxSize = (int) XmlUtil.readNextValueWithName(in, XML_TAG_SUGGESTOR_MAX_SIZE);
- PerAppInfo perAppInfo = new PerAppInfo(packageName);
+ PerAppInfo perAppInfo = new PerAppInfo(packageName, featureId);
Set<ExtendedWifiNetworkSuggestion> extNetworkSuggestions =
parseExtNetworkSuggestions(
in, outerTagDepth + 1, version, encryptionUtil, perAppInfo);
diff --git a/service/java/com/android/server/wifi/ScoredNetworkEvaluator.java b/service/java/com/android/server/wifi/ScoredNetworkEvaluator.java
index 2eba64199..6cd5692ea 100644
--- a/service/java/com/android/server/wifi/ScoredNetworkEvaluator.java
+++ b/service/java/com/android/server/wifi/ScoredNetworkEvaluator.java
@@ -114,7 +114,9 @@ public class ScoredNetworkEvaluator implements WifiNetworkSelector.NetworkEvalua
if (networkScorerAppData == null || packageName == null) return false;
int uid = networkScorerAppData.packageUid;
try {
- mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, uid);
+ // TODO moltmann: Can we set a featureID here instead of null?
+ mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, null, uid,
+ null);
return true;
} catch (SecurityException e) {
return false;
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index a59461310..b94f91da4 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -124,6 +124,10 @@ public class WifiNetworkSuggestionsManager {
*/
public final String packageName;
/**
+ * First Feature in the package that registered the suggestion
+ */
+ public final String featureId;
+ /**
* Set of active network suggestions provided by the app.
*/
public final Set<ExtendedWifiNetworkSuggestion> extNetworkSuggestions = new HashSet<>();
@@ -135,8 +139,9 @@ public class WifiNetworkSuggestionsManager {
/** Stores the max size of the {@link #extNetworkSuggestions} list ever for this app */
public int maxSize = 0;
- public PerAppInfo(@NonNull String packageName) {
+ public PerAppInfo(@NonNull String packageName, @Nullable String featureId) {
this.packageName = packageName;
+ this.featureId = featureId;
}
// This is only needed for comparison in unit tests.
@@ -599,7 +604,8 @@ public class WifiNetworkSuggestionsManager {
* Add the provided list of network suggestions from the corresponding app's active list.
*/
public @WifiManager.NetworkSuggestionsStatusCode int add(
- List<WifiNetworkSuggestion> networkSuggestions, int uid, String packageName) {
+ List<WifiNetworkSuggestion> networkSuggestions, int uid, String packageName,
+ @Nullable String featureId) {
if (mVerboseLoggingEnabled) {
Log.v(TAG, "Adding " + networkSuggestions.size() + " networks from " + packageName);
}
@@ -612,7 +618,7 @@ public class WifiNetworkSuggestionsManager {
}
PerAppInfo perAppInfo = mActiveNetworkSuggestionsPerApp.get(packageName);
if (perAppInfo == null) {
- perAppInfo = new PerAppInfo(packageName);
+ perAppInfo = new PerAppInfo(packageName, featureId);
mActiveNetworkSuggestionsPerApp.put(packageName, perAppInfo);
if (mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(uid)) {
Log.i(TAG, "Setting the carrier provisioning app approved");
@@ -1096,10 +1102,11 @@ public class WifiNetworkSuggestionsManager {
* Helper method to send the post connection broadcast to specified package.
*/
private void sendPostConnectionBroadcastIfAllowed(
- String packageName, WifiNetworkSuggestion matchingSuggestion) {
+ String packageName, String featureId, WifiNetworkSuggestion matchingSuggestion,
+ @NonNull String message) {
try {
mWifiPermissionsUtil.enforceCanAccessScanResults(
- packageName, matchingSuggestion.suggestorUid);
+ packageName, featureId, matchingSuggestion.suggestorUid, message);
} catch (SecurityException se) {
Log.w(TAG, "Permission denied for sending post connection broadcast to " + packageName);
return;
@@ -1148,7 +1155,10 @@ public class WifiNetworkSuggestionsManager {
: matchingExtNetworkSuggestionsWithReqAppInteraction) {
sendPostConnectionBroadcastIfAllowed(
matchingExtNetworkSuggestion.perAppInfo.packageName,
- matchingExtNetworkSuggestion.wns);
+ matchingExtNetworkSuggestion.perAppInfo.featureId,
+ matchingExtNetworkSuggestion.wns,
+ "Connected to " + matchingExtNetworkSuggestion.wns.wifiConfiguration.SSID
+ + ". featureId is first feature of the app using network suggestions");
}
}
@@ -1177,6 +1187,7 @@ public class WifiNetworkSuggestionsManager {
for (ExtendedWifiNetworkSuggestion matchingExtNetworkSuggestion
: matchingExtNetworkSuggestions) {
sendConnectionFailureIfAllowed(matchingExtNetworkSuggestion.perAppInfo.packageName,
+ matchingExtNetworkSuggestion.perAppInfo.featureId,
matchingExtNetworkSuggestion.wns, failureCode);
}
}
@@ -1218,12 +1229,12 @@ public class WifiNetworkSuggestionsManager {
/**
* Send network connection failure event to app when an connection attempt failure.
* @param packageName package name to send event
+ * @param featureId The feature in the package
* @param matchingSuggestion suggestion on this connection failure
* @param connectionEvent connection failure code
*/
- private void sendConnectionFailureIfAllowed(String packageName,
- @NonNull WifiNetworkSuggestion matchingSuggestion,
- int connectionEvent) {
+ private void sendConnectionFailureIfAllowed(String packageName, @Nullable String featureId,
+ @NonNull WifiNetworkSuggestion matchingSuggestion, int connectionEvent) {
ExternalCallbackTracker<ISuggestionConnectionStatusListener> listenersTracker =
mSuggestionStatusListenerPerApp.get(packageName);
if (listenersTracker == null || listenersTracker.getNumCallbacks() == 0) {
@@ -1231,7 +1242,8 @@ public class WifiNetworkSuggestionsManager {
}
try {
mWifiPermissionsUtil.enforceCanAccessScanResults(
- packageName, matchingSuggestion.suggestorUid);
+ packageName, featureId, matchingSuggestion.suggestorUid,
+ "Connection failure");
} catch (SecurityException se) {
Log.w(TAG, "Permission denied for sending connection failure event to " + packageName);
return;
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 9b759dc11..6195ada1d 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -392,9 +392,10 @@ public class WifiServiceImpl extends BaseWifiService {
* See {@link android.net.wifi.WifiManager#startScan}
*
* @param packageName Package name of the app that requests wifi scan.
+ * @param featureId The feature in the package
*/
@Override
- public boolean startScan(String packageName) {
+ public boolean startScan(String packageName, String featureId) {
if (enforceChangePermission(packageName) != MODE_ALLOWED) {
return false;
}
@@ -417,7 +418,8 @@ public class WifiServiceImpl extends BaseWifiService {
}
}
try {
- mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, callingUid);
+ mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, featureId, callingUid,
+ null);
Boolean scanSuccess = mWifiThreadRunner.call(() ->
mScanRequestProxy.startScan(callingUid, packageName), null);
if (scanSuccess == null) {
@@ -489,7 +491,7 @@ public class WifiServiceImpl extends BaseWifiService {
// Someone requested a scan while we were idle; do a full scan now.
// A security check of the caller's identity was made when the request arrived via
// Binder. Now we'll pass the current process's identity to startScan().
- startScan(mContext.getOpPackageName());
+ startScan(mContext.getOpPackageName(), mContext.getFeatureId());
}
}
@@ -622,8 +624,8 @@ public class WifiServiceImpl extends BaseWifiService {
"ConnectivityService");
}
- private void enforceLocationPermission(String pkgName, int uid) {
- mWifiPermissionsUtil.enforceLocationPermission(pkgName, uid);
+ private void enforceLocationPermission(String pkgName, @Nullable String featureId, int uid) {
+ mWifiPermissionsUtil.enforceLocationPermission(pkgName, featureId, uid);
}
/**
@@ -1378,6 +1380,7 @@ public class WifiServiceImpl extends BaseWifiService {
*
* @param callback Callback to communicate with WifiManager and allow cleanup if the app dies.
* @param packageName String name of the calling package.
+ * @param featureId The feature in the package
* @param customConfig Custom configuration to be applied to the hotspot, or null for a shared
* hotspot with framework-generated config.
*
@@ -1390,7 +1393,7 @@ public class WifiServiceImpl extends BaseWifiService {
*/
@Override
public int startLocalOnlyHotspot(ILocalOnlyHotspotCallback callback, String packageName,
- SoftApConfiguration customConfig) {
+ String featureId, SoftApConfiguration customConfig) {
// first check if the caller has permission to start a local only hotspot
// need to check for WIFI_STATE_CHANGE and location permission
final int uid = Binder.getCallingUid();
@@ -1403,7 +1406,7 @@ public class WifiServiceImpl extends BaseWifiService {
if (enforceChangePermission(packageName) != MODE_ALLOWED) {
return LocalOnlyHotspotCallback.ERROR_GENERIC;
}
- enforceLocationPermission(packageName, uid);
+ enforceLocationPermission(packageName, featureId, uid);
long ident = Binder.clearCallingIdentity();
try {
// also need to verify that Locations services are enabled.
@@ -1742,17 +1745,20 @@ public class WifiServiceImpl extends BaseWifiService {
* see {@link android.net.wifi.WifiManager#getConfiguredNetworks()}
*
* @param packageName String name of the calling package
+ * @param featureId The feature in the package
* @return the list of configured networks
*/
@Override
- public ParceledListSlice<WifiConfiguration> getConfiguredNetworks(String packageName) {
+ public ParceledListSlice<WifiConfiguration> getConfiguredNetworks(String packageName,
+ String featureId) {
enforceAccessPermission();
int callingUid = Binder.getCallingUid();
// bypass shell: can get varioud pkg name
if (callingUid != Process.SHELL_UID && callingUid != Process.ROOT_UID) {
long ident = Binder.clearCallingIdentity();
try {
- mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, callingUid);
+ mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, featureId,
+ callingUid, null);
} catch (SecurityException e) {
Log.e(TAG, "Permission violation - getConfiguredNetworks not allowed for uid="
+ callingUid + ", packageName=" + packageName + ", reason=" + e);
@@ -1803,17 +1809,19 @@ public class WifiServiceImpl extends BaseWifiService {
* see {@link android.net.wifi.WifiManager#getPrivilegedConfiguredNetworks()}
*
* @param packageName String name of the calling package
+ * @param featureId The feature in the package
* @return the list of configured networks with real preSharedKey
*/
@Override
public ParceledListSlice<WifiConfiguration> getPrivilegedConfiguredNetworks(
- String packageName) {
+ String packageName, String featureId) {
enforceReadCredentialPermission();
enforceAccessPermission();
int callingUid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
try {
- mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, callingUid);
+ mWifiPermissionsUtil.enforceCanAccessScanResults(packageName, featureId, callingUid,
+ null);
} catch (SecurityException e) {
Log.e(TAG, "Permission violation - getPrivilegedConfiguredNetworks not allowed for"
+ " uid=" + callingUid + ", packageName=" + packageName + ", reason=" + e);
@@ -2135,7 +2143,7 @@ public class WifiServiceImpl extends BaseWifiService {
* @return the Wi-Fi information, contained in {@link WifiInfo}.
*/
@Override
- public WifiInfo getConnectionInfo(String callingPackage) {
+ public WifiInfo getConnectionInfo(String callingPackage, String callingFeatureId) {
enforceAccessPermission();
int uid = Binder.getCallingUid();
if (mVerboseLoggingEnabled) {
@@ -2152,7 +2160,8 @@ public class WifiServiceImpl extends BaseWifiService {
== PERMISSION_GRANTED) {
hideDefaultMacAddress = false;
}
- mWifiPermissionsUtil.enforceCanAccessScanResults(callingPackage, uid);
+ mWifiPermissionsUtil.enforceCanAccessScanResults(callingPackage, callingFeatureId,
+ uid, null);
hideBssidSsidAndNetworkId = false;
} catch (SecurityException ignored) {
}
@@ -2182,7 +2191,7 @@ public class WifiServiceImpl extends BaseWifiService {
* @return the list of results
*/
@Override
- public List<ScanResult> getScanResults(String callingPackage) {
+ public List<ScanResult> getScanResults(String callingPackage, String callingFeatureId) {
enforceAccessPermission();
int uid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
@@ -2190,7 +2199,8 @@ public class WifiServiceImpl extends BaseWifiService {
mLog.info("getScanResults uid=%").c(uid).flush();
}
try {
- mWifiPermissionsUtil.enforceCanAccessScanResults(callingPackage, uid);
+ mWifiPermissionsUtil.enforceCanAccessScanResults(callingPackage, callingFeatureId,
+ uid, null);
List<ScanResult> scanResults = mWifiThreadRunner.call(
mScanRequestProxy::getScanResults, Collections.emptyList());
return scanResults;
@@ -3135,12 +3145,14 @@ public class WifiServiceImpl extends BaseWifiService {
*
* @param networkSuggestions List of network suggestions to be added.
* @param callingPackageName Package Name of the app adding the suggestions.
+ * @param callingFeatureId Feature in the calling package
* @throws SecurityException if the caller does not have permission.
* @return One of status codes from {@link WifiManager.NetworkSuggestionsStatusCode}.
*/
@Override
public int addNetworkSuggestions(
- List<WifiNetworkSuggestion> networkSuggestions, String callingPackageName) {
+ List<WifiNetworkSuggestion> networkSuggestions, String callingPackageName,
+ String callingFeatureId) {
if (enforceChangePermission(callingPackageName) != MODE_ALLOWED) {
return WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED;
}
@@ -3150,7 +3162,7 @@ public class WifiServiceImpl extends BaseWifiService {
int callingUid = Binder.getCallingUid();
int success = mWifiThreadRunner.call(() -> mWifiNetworkSuggestionsManager.add(
- networkSuggestions, callingUid, callingPackageName),
+ networkSuggestions, callingUid, callingPackageName, callingFeatureId),
WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL);
if (success != WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS) {
Log.e(TAG, "Failed to add network suggestions");
@@ -3526,7 +3538,7 @@ public class WifiServiceImpl extends BaseWifiService {
*/
public void registerSuggestionConnectionStatusListener(IBinder binder,
@NonNull ISuggestionConnectionStatusListener listener,
- int listenerIdentifier, String packageName) {
+ int listenerIdentifier, String packageName, @Nullable String featureId) {
if (binder == null) {
throw new IllegalArgumentException("Binder must not be null");
}
@@ -3535,7 +3547,7 @@ public class WifiServiceImpl extends BaseWifiService {
}
final int uid = Binder.getCallingUid();
enforceAccessPermission();
- enforceLocationPermission(packageName, uid);
+ enforceLocationPermission(packageName, featureId, uid);
if (mVerboseLoggingEnabled) {
mLog.info("registerSuggestionConnectionStatusListener uid=%").c(uid).flush();
}
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareClientState.java b/service/java/com/android/server/wifi/aware/WifiAwareClientState.java
index 28a97b815..fb982699f 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareClientState.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareClientState.java
@@ -16,6 +16,7 @@
package com.android.server.wifi.aware;
+import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.content.Context;
import android.net.wifi.aware.ConfigRequest;
@@ -58,6 +59,7 @@ public class WifiAwareClientState {
private final int mUid;
private final int mPid;
private final String mCallingPackage;
+ private final @Nullable String mCallingFeatureId;
private final boolean mNotifyIdentityChange;
private final WifiPermissionsUtil mWifiPermissionsUtil;
@@ -68,7 +70,8 @@ public class WifiAwareClientState {
private byte[] mLastDiscoveryInterfaceMac = ALL_ZERO_MAC;
public WifiAwareClientState(Context context, int clientId, int uid, int pid,
- String callingPackage, IWifiAwareEventCallback callback, ConfigRequest configRequest,
+ String callingPackage, @Nullable String callingFeatureId,
+ IWifiAwareEventCallback callback, ConfigRequest configRequest,
boolean notifyIdentityChange, long creationTime,
WifiPermissionsUtil wifiPermissionsUtil) {
mContext = context;
@@ -76,6 +79,7 @@ public class WifiAwareClientState {
mUid = uid;
mPid = pid;
mCallingPackage = callingPackage;
+ mCallingFeatureId = callingFeatureId;
mCallback = callback;
mConfigRequest = configRequest;
mNotifyIdentityChange = notifyIdentityChange;
@@ -223,7 +227,8 @@ public class WifiAwareClientState {
if (mNotifyIdentityChange && !Arrays.equals(mac, mLastDiscoveryInterfaceMac)) {
try {
boolean hasPermission = mWifiPermissionsUtil.checkCallersLocationPermission(
- mCallingPackage, mUid, /* coarseForTargetSdkLessThanQ */ true);
+ mCallingPackage, mCallingFeatureId, mUid,
+ /* coarseForTargetSdkLessThanQ */ true, null);
if (VDBG) Log.v(TAG, "hasPermission=" + hasPermission);
mCallback.onIdentityChanged(hasPermission ? mac : ALL_ZERO_MAC);
} catch (RemoteException e) {
@@ -258,7 +263,8 @@ public class WifiAwareClientState {
mLastDiscoveryInterfaceMac)) {
try {
boolean hasPermission = mWifiPermissionsUtil.checkCallersLocationPermission(
- mCallingPackage, mUid, /* coarseForTargetSdkLessThanQ */ true);
+ mCallingPackage, mCallingFeatureId, mUid,
+ /* coarseForTargetSdkLessThanQ */ true, null);
if (VDBG) Log.v(TAG, "hasPermission=" + hasPermission);
mCallback.onIdentityChanged(
hasPermission ? currentDiscoveryInterfaceMac : ALL_ZERO_MAC);
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
index a0f937d33..f30e74005 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
@@ -173,7 +173,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
}
@Override
- public void connect(final IBinder binder, String callingPackage,
+ public void connect(final IBinder binder, String callingPackage, String callingFeatureId,
IWifiAwareEventCallback callback, ConfigRequest configRequest,
boolean notifyOnIdentityChanged) {
enforceAccessPermission();
@@ -190,7 +190,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
}
if (notifyOnIdentityChanged) {
- enforceLocationPermission(callingPackage, getMockableCallingUid());
+ enforceLocationPermission(callingPackage, callingFeatureId, getMockableCallingUid());
}
if (configRequest != null) {
@@ -245,8 +245,8 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
mUidByClientId.put(clientId, uid);
}
- mStateManager.connect(clientId, uid, pid, callingPackage, callback, configRequest,
- notifyOnIdentityChanged);
+ mStateManager.connect(clientId, uid, pid, callingPackage, callingFeatureId, callback,
+ configRequest, notifyOnIdentityChanged);
}
@Override
@@ -290,15 +290,15 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
}
@Override
- public void publish(String callingPackage, int clientId, PublishConfig publishConfig,
- IWifiAwareDiscoverySessionCallback callback) {
+ public void publish(String callingPackage, String callingFeatureId, int clientId,
+ PublishConfig publishConfig, IWifiAwareDiscoverySessionCallback callback) {
enforceAccessPermission();
enforceChangePermission();
int uid = getMockableCallingUid();
mAppOps.checkPackage(uid, callingPackage);
- enforceLocationPermission(callingPackage, getMockableCallingUid());
+ enforceLocationPermission(callingPackage, callingFeatureId, getMockableCallingUid());
if (callback == null) {
throw new IllegalArgumentException("Callback must not be null");
@@ -340,15 +340,15 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
}
@Override
- public void subscribe(String callingPackage, int clientId, SubscribeConfig subscribeConfig,
- IWifiAwareDiscoverySessionCallback callback) {
+ public void subscribe(String callingPackage, String callingFeatureId, int clientId,
+ SubscribeConfig subscribeConfig, IWifiAwareDiscoverySessionCallback callback) {
enforceAccessPermission();
enforceChangePermission();
int uid = getMockableCallingUid();
mAppOps.checkPackage(uid, callingPackage);
- enforceLocationPermission(callingPackage, getMockableCallingUid());
+ enforceLocationPermission(callingPackage, callingFeatureId, getMockableCallingUid());
if (callback == null) {
throw new IllegalArgumentException("Callback must not be null");
@@ -469,8 +469,9 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CHANGE_WIFI_STATE, TAG);
}
- private void enforceLocationPermission(String callingPackage, int uid) {
- mWifiPermissionsUtil.enforceLocationPermission(callingPackage, uid);
+ private void enforceLocationPermission(String callingPackage, String callingFeatureId,
+ int uid) {
+ mWifiPermissionsUtil.enforceLocationPermission(callingPackage, callingFeatureId, uid);
}
private void enforceNetworkStackPermission() {
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
index 072788081..042bbe21d 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
@@ -16,6 +16,7 @@
package com.android.server.wifi.aware;
+import android.annotation.Nullable;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -188,6 +189,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
private static final String MESSAGE_BUNDLE_KEY_UID = "uid";
private static final String MESSAGE_BUNDLE_KEY_PID = "pid";
private static final String MESSAGE_BUNDLE_KEY_CALLING_PACKAGE = "calling_package";
+ private static final String MESSAGE_BUNDLE_KEY_CALLING_FEATURE_ID = "calling_feature_id";
private static final String MESSAGE_BUNDLE_KEY_SENT_MESSAGE = "send_message";
private static final String MESSAGE_BUNDLE_KEY_MESSAGE_ARRIVAL_SEQ = "message_arrival_seq";
private static final String MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE = "notify_identity_chg";
@@ -567,8 +569,8 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
* Place a request for a new client connection on the state machine queue.
*/
public void connect(int clientId, int uid, int pid, String callingPackage,
- IWifiAwareEventCallback callback, ConfigRequest configRequest,
- boolean notifyOnIdentityChanged) {
+ @Nullable String callingFeatureId, IWifiAwareEventCallback callback,
+ ConfigRequest configRequest, boolean notifyOnIdentityChanged) {
Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND);
msg.arg1 = COMMAND_TYPE_CONNECT;
msg.arg2 = clientId;
@@ -577,6 +579,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
msg.getData().putInt(MESSAGE_BUNDLE_KEY_UID, uid);
msg.getData().putInt(MESSAGE_BUNDLE_KEY_PID, pid);
msg.getData().putString(MESSAGE_BUNDLE_KEY_CALLING_PACKAGE, callingPackage);
+ msg.getData().putString(MESSAGE_BUNDLE_KEY_CALLING_FEATURE_ID, callingFeatureId);
msg.getData().putBoolean(MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE,
notifyOnIdentityChanged);
mSm.sendMessage(msg);
@@ -1569,11 +1572,14 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
int pid = msg.getData().getInt(MESSAGE_BUNDLE_KEY_PID);
String callingPackage = msg.getData().getString(
MESSAGE_BUNDLE_KEY_CALLING_PACKAGE);
+ String callingFeatureId = msg.getData().getString(
+ MESSAGE_BUNDLE_KEY_CALLING_FEATURE_ID);
boolean notifyIdentityChange = msg.getData().getBoolean(
MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE);
waitForResponse = connectLocal(mCurrentTransactionId, clientId, uid, pid,
- callingPackage, callback, configRequest, notifyIdentityChange);
+ callingPackage, callingFeatureId, callback, configRequest,
+ notifyIdentityChange);
break;
}
case COMMAND_TYPE_DISCONNECT: {
@@ -2179,7 +2185,8 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
*/
private boolean connectLocal(short transactionId, int clientId, int uid, int pid,
- String callingPackage, IWifiAwareEventCallback callback, ConfigRequest configRequest,
+ String callingPackage, @Nullable String callingFeatureId,
+ IWifiAwareEventCallback callback, ConfigRequest configRequest,
boolean notifyIdentityChange) {
if (VDBG) {
Log.v(TAG, "connectLocal(): transactionId=" + transactionId + ", clientId=" + clientId
@@ -2231,7 +2238,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
Log.w(TAG, "connectLocal onConnectSuccess(): RemoteException (FYI): " + e);
}
WifiAwareClientState client = new WifiAwareClientState(mContext, clientId, uid, pid,
- callingPackage, callback, configRequest, notifyIdentityChange,
+ callingPackage, callingFeatureId, callback, configRequest, notifyIdentityChange,
SystemClock.elapsedRealtime(), mWifiPermissionsUtil);
client.mDbg = mDbg;
client.onInterfaceAddressChange(mCurrentDiscoveryInterfaceMac);
@@ -2592,9 +2599,10 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
boolean notifyIdentityChange = data.getBoolean(
MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE);
String callingPackage = data.getString(MESSAGE_BUNDLE_KEY_CALLING_PACKAGE);
+ String callingFeatureId = data.getString(MESSAGE_BUNDLE_KEY_CALLING_FEATURE_ID);
WifiAwareClientState client = new WifiAwareClientState(mContext, clientId, uid, pid,
- callingPackage, callback, configRequest, notifyIdentityChange,
+ callingPackage, callingFeatureId, callback, configRequest, notifyIdentityChange,
SystemClock.elapsedRealtime(), mWifiPermissionsUtil);
client.mDbg = mDbg;
mClients.put(clientId, client);
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 2a808bee2..06e009326 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -16,6 +16,7 @@
package com.android.server.wifi.p2p;
+import android.annotation.Nullable;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -1059,7 +1060,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.REQUEST_PEERS:
replyToMessage(message, WifiP2pManager.RESPONSE_PEERS,
getPeers(getCallingPkgName(message.sendingUid, message.replyTo),
- message.sendingUid));
+ getCallingFeatureId(message.sendingUid, message.replyTo),
+ message.sendingUid));
break;
case WifiP2pManager.REQUEST_CONNECTION_INFO:
replyToMessage(message, WifiP2pManager.RESPONSE_CONNECTION_INFO,
@@ -1068,6 +1070,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.REQUEST_GROUP_INFO:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, false)) {
replyToMessage(message, WifiP2pManager.RESPONSE_GROUP_INFO, null);
// remain at this state.
@@ -1202,6 +1205,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
Bundle bundle = (Bundle) message.obj;
String pkgName = bundle.getString(WifiP2pManager.CALLING_PACKAGE);
+ String featureId = bundle.getString(WifiP2pManager.CALLING_FEATURE_ID);
IBinder binder = bundle.getBinder(WifiP2pManager.CALLING_BINDER);
try {
mWifiPermissionsUtil.checkPackage(message.sendingUid, pkgName);
@@ -1213,11 +1217,13 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
mClientChannelList.put(binder, message.replyTo);
ClientInfo clientInfo = getClientInfo(message.replyTo, true);
clientInfo.mPackageName = pkgName;
+ clientInfo.mFeatureId = featureId;
}
break;
case WifiP2pManager.REQUEST_DEVICE_INFO:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, false)) {
replyToMessage(message, WifiP2pManager.RESPONSE_DEVICE_INFO, null);
break;
@@ -1529,6 +1535,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.DISCOVER_PEERS:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, true)) {
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
WifiP2pManager.ERROR);
@@ -1565,6 +1572,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.DISCOVER_SERVICES:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, true)) {
replyToMessage(message, WifiP2pManager.DISCOVER_SERVICES_FAILED,
WifiP2pManager.ERROR);
@@ -1615,6 +1623,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.ADD_LOCAL_SERVICE:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, false)) {
replyToMessage(message, WifiP2pManager.ADD_LOCAL_SERVICE_FAILED);
// remain at this state.
@@ -1768,6 +1777,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.CONNECT:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, false)) {
replyToMessage(message, WifiP2pManager.CONNECT_FAILED);
// remain at this state.
@@ -1927,6 +1937,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.CREATE_GROUP:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, false)) {
replyToMessage(message, WifiP2pManager.CREATE_GROUP_FAILED,
WifiP2pManager.ERROR);
@@ -2771,6 +2782,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.CONNECT:
if (!mWifiPermissionsUtil.checkCanAccessWifiDirect(
getCallingPkgName(message.sendingUid, message.replyTo),
+ getCallingFeatureId(message.sendingUid, message.replyTo),
message.sendingUid, false)) {
replyToMessage(message, WifiP2pManager.CONNECT_FAILED);
// remain at this state.
@@ -4083,14 +4095,15 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
/**
* Enforces permissions on the caller who is requesting for P2p Peers
- * @param pkg Bundle containing the calling package string
+ * @param pkgName Package name of the caller
+ * @param featureId Feature in the package of the caller
* @param uid of the caller
* @return WifiP2pDeviceList the peer list
*/
- private WifiP2pDeviceList getPeers(String pkgName, int uid) {
+ private WifiP2pDeviceList getPeers(String pkgName, @Nullable String featureId, int uid) {
// getPeers() is guaranteed to be invoked after Wifi Service is up
// This ensures getInstance() will return a non-null object now
- if (mWifiPermissionsUtil.checkCanAccessWifiDirect(pkgName, uid, true)) {
+ if (mWifiPermissionsUtil.checkCanAccessWifiDirect(pkgName, featureId, uid, true)) {
return new WifiP2pDeviceList(mPeers);
} else {
return new WifiP2pDeviceList();
@@ -4158,7 +4171,21 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
if (uid == Process.SYSTEM_UID) return mContext.getOpPackageName();
return null;
+ }
+ /**
+ * Get calling feature id from Client HashMap
+ *
+ * @param uid The uid of the caller
+ * @param replyMessenger AsyncChannel handler in caller
+ */
+ private String getCallingFeatureId(int uid, Messenger replyMessenger) {
+ ClientInfo clientInfo = mClientInfoList.get(replyMessenger);
+ if (clientInfo != null) {
+ return clientInfo.mFeatureId;
+ }
+ if (uid == Process.SYSTEM_UID) return mContext.getFeatureId();
+ return null;
}
/**
@@ -4182,6 +4209,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// The response of this request is notified to WifiP2pManager.Channel handler
private Messenger mMessenger;
private String mPackageName;
+ private @Nullable String mFeatureId;
// A service discovery request list.
@@ -4193,6 +4221,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
private ClientInfo(Messenger m) {
mMessenger = m;
mPackageName = null;
+ mFeatureId = null;
mReqList = new SparseArray();
mServList = new ArrayList<WifiP2pServiceInfo>();
}
diff --git a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
index b3c2f42c6..341459f84 100644
--- a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
+++ b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
@@ -406,8 +406,9 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
* to be posted to handler thread.
*/
@Override
- public void startRanging(IBinder binder, String callingPackage, WorkSource workSource,
- RangingRequest request, IRttCallback callback) throws RemoteException {
+ public void startRanging(IBinder binder, String callingPackage, String callingFeatureId,
+ WorkSource workSource, RangingRequest request, IRttCallback callback)
+ throws RemoteException {
if (VDBG) {
Log.v(TAG, "startRanging: binder=" + binder + ", callingPackage=" + callingPackage
+ ", workSource=" + workSource + ", request=" + request + ", callback="
@@ -446,7 +447,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
// permission checks
enforceAccessPermission();
enforceChangePermission();
- mWifiPermissionsUtil.enforceFineLocationPermission(callingPackage, uid);
+ mWifiPermissionsUtil.enforceFineLocationPermission(callingPackage, callingFeatureId, uid);
if (workSource != null) {
enforceLocationHardware();
// We only care about UIDs in the incoming worksources and not their associated
@@ -483,7 +484,8 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
sourceToUse = new WorkSource(uid);
}
mRttServiceSynchronized.queueRangingRequest(uid, sourceToUse, binder, dr,
- callingPackage, request, callback, isCalledFromPrivilegedContext);
+ callingPackage, callingFeatureId, request, callback,
+ isCalledFromPrivilegedContext);
});
}
@@ -692,8 +694,9 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
}
private void queueRangingRequest(int uid, WorkSource workSource, IBinder binder,
- IBinder.DeathRecipient dr, String callingPackage, RangingRequest request,
- IRttCallback callback, boolean isCalledFromPrivilegedContext) {
+ IBinder.DeathRecipient dr, String callingPackage, String callingFeatureId,
+ RangingRequest request, IRttCallback callback,
+ boolean isCalledFromPrivilegedContext) {
mRttMetrics.recordRequest(workSource, request);
if (isRequestorSpamming(workSource)) {
@@ -716,6 +719,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
newRequest.binder = binder;
newRequest.dr = dr;
newRequest.callingPackage = callingPackage;
+ newRequest.callingFeatureId = callingFeatureId;
newRequest.request = request;
newRequest.callback = callback;
newRequest.isCalledFromPrivilegedContext = isCalledFromPrivilegedContext;
@@ -1088,8 +1092,8 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
}
boolean permissionGranted = mWifiPermissionsUtil.checkCallersLocationPermission(
- topOfQueueRequest.callingPackage,
- topOfQueueRequest.uid, /* coarseForTargetSdkLessThanQ */ false)
+ topOfQueueRequest.callingPackage, topOfQueueRequest.callingFeatureId,
+ topOfQueueRequest.uid, /* coarseForTargetSdkLessThanQ */ false, null)
&& mWifiPermissionsUtil.isLocationModeEnabled();
try {
if (permissionGranted) {
@@ -1222,6 +1226,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
public IBinder binder;
public IBinder.DeathRecipient dr;
public String callingPackage;
+ public String callingFeatureId;
public RangingRequest request;
public IRttCallback callback;
public boolean isCalledFromPrivilegedContext;
@@ -1235,10 +1240,10 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
return new StringBuilder("RttRequestInfo: uid=").append(uid).append(
", workSource=").append(workSource).append(", binder=").append(binder).append(
", dr=").append(dr).append(", callingPackage=").append(callingPackage).append(
- ", request=").append(request.toString()).append(", callback=").append(
- callback).append(", cmdId=").append(cmdId).append(
- ", peerHandlesTranslated=").append(peerHandlesTranslated).append(
- ", isCalledFromPrivilegedContext=").append(
+ ", callingFeatureId=").append(callingFeatureId).append(", request=").append(
+ request.toString()).append(", callback=").append(callback).append(
+ ", cmdId=").append(cmdId).append(", peerHandlesTranslated=").append(
+ peerHandlesTranslated).append(", isCalledFromPrivilegedContext=").append(
isCalledFromPrivilegedContext).toString();
}
}
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
index 63b7c95fb..ec2da71b1 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
@@ -112,8 +112,9 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
}
@Override
- public Bundle getAvailableChannels(@WifiBand int band, String packageName) {
- enforcePermission(Binder.getCallingUid(), packageName, false, false, false);
+ public Bundle getAvailableChannels(@WifiBand int band, String packageName,
+ @Nullable String featureId) {
+ enforcePermission(Binder.getCallingUid(), packageName, featureId, false, false, false);
mChannelHelper.updateChannels();
ChannelSpec[] channelSpecs = mChannelHelper.getAvailableScanChannels(band);
@@ -158,6 +159,17 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
return bundle.getString(WifiScanner.REQUEST_PACKAGE_NAME_KEY);
}
+ // For non-privileged requests, retrieve the bundled featureId name for app-op & permission
+ // checks.
+ private String getFeatureId(Message msg) {
+ if (!(msg.obj instanceof Bundle)) {
+ return null;
+ }
+ Bundle bundle = (Bundle) msg.obj;
+ return bundle.getString(WifiScanner.REQUEST_FEATURE_ID_KEY);
+ }
+
+
// Check if we should ignore location settings if this is a single scan request.
private boolean shouldIgnoreLocationSettingsForSingleScan(Message msg) {
if (msg.what != WifiScanner.CMD_START_SINGLE_SCAN) return false;
@@ -177,11 +189,11 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
}
/**
- * @see #enforcePermission(int, String, boolean, boolean, boolean)
+ * @see #enforcePermission(int, String, String, boolean, boolean, boolean)
*/
private void enforcePermission(int uid, Message msg) throws SecurityException {
- enforcePermission(uid, getPackageName(msg), isPrivilegedMessage(msg.what),
- shouldIgnoreLocationSettingsForSingleScan(msg),
+ enforcePermission(uid, getPackageName(msg), getFeatureId(msg),
+ isPrivilegedMessage(msg.what), shouldIgnoreLocationSettingsForSingleScan(msg),
shouldHideFromAppsForSingleScan(msg));
}
@@ -193,12 +205,14 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
* b) Can never make one of the privileged requests.
* @param uid uid of the client
* @param packageName package name of the client
+ * @param featureId The feature in the package of the client
* @param isPrivilegedRequest whether we are checking for a privileged request
* @param shouldIgnoreLocationSettings override to ignore location settings
* @param shouldHideFromApps override to hide request from AppOps
*/
- private void enforcePermission(int uid, String packageName, boolean isPrivilegedRequest,
- boolean shouldIgnoreLocationSettings, boolean shouldHideFromApps) {
+ private void enforcePermission(int uid, String packageName, @Nullable String featureId,
+ boolean isPrivilegedRequest, boolean shouldIgnoreLocationSettings,
+ boolean shouldHideFromApps) {
try {
// Wifi stack issued requests.
enforceWifiStackPermission(uid);
@@ -208,8 +222,8 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
// Privileged message, only requests from clients with NETWORK_STACK allowed!
throw e;
}
- mWifiPermissionsUtil.enforceCanAccessScanResultsForWifiScanner(packageName, uid,
- shouldIgnoreLocationSettings, shouldHideFromApps);
+ mWifiPermissionsUtil.enforceCanAccessScanResultsForWifiScanner(packageName, featureId,
+ uid, shouldIgnoreLocationSettings, shouldHideFromApps);
}
}
diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
index 6e5074358..957e2abea 100644
--- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
+++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
@@ -74,10 +74,12 @@ public class WifiPermissionsUtil {
* Check and enforce Coarse or Fine Location permission (depending on target SDK).
*
* @param pkgName PackageName of the application requesting access
+ * @param featureId The feature in the package
* @param uid The uid of the package
*/
- public void enforceLocationPermission(String pkgName, int uid) {
- if (!checkCallersLocationPermission(pkgName, uid, /* coarseForTargetSdkLessThanQ */ true)) {
+ public void enforceLocationPermission(String pkgName, @Nullable String featureId, int uid) {
+ if (!checkCallersLocationPermission(pkgName, featureId,
+ uid, /* coarseForTargetSdkLessThanQ */ true, null)) {
throw new SecurityException(
"UID " + uid + " does not have Coarse/Fine Location permission");
}
@@ -111,12 +113,15 @@ public class WifiPermissionsUtil {
* and a corresponding app op is allowed for this package and uid.
*
* @param pkgName PackageName of the application requesting access
+ * @param featureId The feature in the package
* @param uid The uid of the package
* @param coarseForTargetSdkLessThanQ If true and the targetSDK < Q then will check for COARSE
* else (false or targetSDK >= Q) then will check for FINE
+ * @param message A message describing why the permission was checked. Only needed if this is
+ * not inside of a two-way binder call from the data receiver
*/
- public boolean checkCallersLocationPermission(String pkgName, int uid,
- boolean coarseForTargetSdkLessThanQ) {
+ public boolean checkCallersLocationPermission(String pkgName, @Nullable String featureId,
+ int uid, boolean coarseForTargetSdkLessThanQ, @Nullable String message) {
boolean isTargetSdkLessThanQ = isTargetSdkLessThan(pkgName, Build.VERSION_CODES.Q, uid);
String permissionType = Manifest.permission.ACCESS_FINE_LOCATION;
@@ -132,12 +137,13 @@ public class WifiPermissionsUtil {
// Always checking FINE - even if will not enforce. This will record the request for FINE
// so that a location request by the app is surfaced to the user.
boolean isFineLocationAllowed = noteAppOpAllowed(
- AppOpsManager.OPSTR_FINE_LOCATION, pkgName, uid);
+ AppOpsManager.OPSTR_FINE_LOCATION, pkgName, featureId, uid, message);
if (isFineLocationAllowed) {
return true;
}
if (coarseForTargetSdkLessThanQ && isTargetSdkLessThanQ) {
- return noteAppOpAllowed(AppOpsManager.OPSTR_COARSE_LOCATION, pkgName, uid);
+ return noteAppOpAllowed(AppOpsManager.OPSTR_COARSE_LOCATION, pkgName, featureId, uid,
+ message);
}
return false;
}
@@ -146,10 +152,12 @@ public class WifiPermissionsUtil {
* Check and enforce Fine Location permission.
*
* @param pkgName PackageName of the application requesting access
+ * @param featureId The feature in the package
* @param uid The uid of the package
*/
- public void enforceFineLocationPermission(String pkgName, int uid) {
- if (!checkCallersFineLocationPermission(pkgName, uid, false)) {
+ public void enforceFineLocationPermission(String pkgName, @Nullable String featureId,
+ int uid) {
+ if (!checkCallersFineLocationPermission(pkgName, featureId, uid, false)) {
throw new SecurityException("UID " + uid + " does not have Fine Location permission");
}
}
@@ -159,12 +167,14 @@ public class WifiPermissionsUtil {
* and a corresponding app op is allowed for this package and uid.
*
* @param pkgName PackageName of the application requesting access
+ * @param featureId The feature in the package
* @param uid The uid of the package
* @param hideFromAppOps True to invoke {@link AppOpsManager#checkOp(int, int, String)}, false
- * to invoke {@link AppOpsManager#noteOp(String, int, String, String)}.
+ * to invoke {@link AppOpsManager#noteOp(String, int, String, String,
+ * String)}.
*/
- private boolean checkCallersFineLocationPermission(String pkgName, int uid,
- boolean hideFromAppOps) {
+ private boolean checkCallersFineLocationPermission(String pkgName, @Nullable String featureId,
+ int uid, boolean hideFromAppOps) {
// Having FINE permission implies having COARSE permission (but not the reverse)
if (mWifiPermissionsWrapper.getUidPermission(
Manifest.permission.ACCESS_FINE_LOCATION, uid)
@@ -175,7 +185,8 @@ public class WifiPermissionsUtil {
// Don't note the operation, just check if the app is allowed to perform the operation.
return checkAppOpAllowed(AppOpsManager.OPSTR_FINE_LOCATION, pkgName, uid);
} else {
- return noteAppOpAllowed(AppOpsManager.OPSTR_FINE_LOCATION, pkgName, uid);
+ return noteAppOpAllowed(AppOpsManager.OPSTR_FINE_LOCATION, pkgName, featureId, uid,
+ null);
}
}
@@ -193,9 +204,14 @@ public class WifiPermissionsUtil {
* API to determine if the caller has permissions to get scan results. Throws SecurityException
* if the caller has no permission.
* @param pkgName package name of the application requesting access
+ * @param featureId The feature in the package
* @param uid The uid of the package
+ * @param message A message describing why the permission was checked. Only needed if this is
+ * not inside of a two-way binder call from the data receiver
*/
- public void enforceCanAccessScanResults(String pkgName, int uid) throws SecurityException {
+ public void enforceCanAccessScanResults(String pkgName, @Nullable String featureId, int uid,
+ @Nullable String message)
+ throws SecurityException {
checkPackage(uid, pkgName);
// Apps with NETWORK_SETTINGS, NETWORK_SETUP_WIZARD, NETWORK_MANAGED_PROVISIONING,
@@ -216,8 +232,8 @@ public class WifiPermissionsUtil {
boolean canCallingUidAccessLocation = checkCallerHasPeersMacAddressPermission(uid);
// LocationAccess by App: caller must have Coarse/Fine Location permission to have access to
// location information.
- boolean canAppPackageUseLocation = checkCallersLocationPermission(pkgName,
- uid, /* coarseForTargetSdkLessThanQ */ true);
+ boolean canAppPackageUseLocation = checkCallersLocationPermission(pkgName, featureId,
+ uid, /* coarseForTargetSdkLessThanQ */ true, message);
// If neither caller or app has location access, there is no need to check
// any other permissions. Deny access to scan results.
@@ -225,7 +241,7 @@ public class WifiPermissionsUtil {
throw new SecurityException("UID " + uid + " has no location permission");
}
// Check if Wifi Scan request is an operation allowed for this App.
- if (!isScanAllowedbyApps(pkgName, uid)) {
+ if (!isScanAllowedbyApps(pkgName, featureId, uid)) {
throw new SecurityException("UID " + uid + " has no wifi scan permission");
}
// If the User or profile is current, permission is granted
@@ -239,6 +255,7 @@ public class WifiPermissionsUtil {
* API to determine if the caller has permissions to get scan results. Throws SecurityException
* if the caller has no permission.
* @param pkgName package name of the application requesting access
+ * @param featureId The feature in the package
* @param uid The uid of the package
* @param ignoreLocationSettings Whether this request can bypass location settings.
* @param hideFromAppOps Whether to note the request in app-ops logging or not.
@@ -246,9 +263,9 @@ public class WifiPermissionsUtil {
* Note: This is to be used for checking permissions in the internal WifiScanner API surface
* for requests coming from system apps.
*/
- public void enforceCanAccessScanResultsForWifiScanner(
- String pkgName, int uid, boolean ignoreLocationSettings, boolean hideFromAppOps)
- throws SecurityException {
+ public void enforceCanAccessScanResultsForWifiScanner(String pkgName,
+ @Nullable String featureId, int uid, boolean ignoreLocationSettings,
+ boolean hideFromAppOps) throws SecurityException {
checkPackage(uid, pkgName);
// Location mode must be enabled
@@ -262,12 +279,12 @@ public class WifiPermissionsUtil {
}
// LocationAccess by App: caller must have fine & hardware Location permission to have
// access to location information.
- if (!checkCallersFineLocationPermission(pkgName, uid, hideFromAppOps)
+ if (!checkCallersFineLocationPermission(pkgName, featureId, uid, hideFromAppOps)
|| !checkCallersHardwareLocationPermission(uid)) {
throw new SecurityException("UID " + uid + " has no location permission");
}
// Check if Wifi Scan request is an operation allowed for this App.
- if (!isScanAllowedbyApps(pkgName, uid)) {
+ if (!isScanAllowedbyApps(pkgName, featureId, uid)) {
throw new SecurityException("UID " + uid + " has no wifi scan permission");
}
}
@@ -278,12 +295,13 @@ public class WifiPermissionsUtil {
* and a corresponding app op is allowed for this package and uid
*
* @param pkgName package name of the application requesting access
+ * @param featureId The feature in the package
* @param uid The uid of the package
* @param needLocationModeEnabled indicates location mode must be enabled.
*
* @return true if caller has permission, false otherwise
*/
- public boolean checkCanAccessWifiDirect(String pkgName, int uid,
+ public boolean checkCanAccessWifiDirect(String pkgName, @Nullable String featureId, int uid,
boolean needLocationModeEnabled) {
try {
checkPackage(uid, pkgName);
@@ -305,8 +323,8 @@ public class WifiPermissionsUtil {
// LocationAccess by App: caller must have Fine Location permission to have access to
// location information.
- if (!checkCallersLocationPermission(pkgName, uid,
- /* coarseForTargetSdkLessThanQ */ false)) {
+ if (!checkCallersLocationPermission(pkgName, featureId, uid,
+ /* coarseForTargetSdkLessThanQ */ false, null)) {
Log.e(TAG, "UID " + uid + " has no location permission");
return false;
}
@@ -341,8 +359,8 @@ public class WifiPermissionsUtil {
* Returns true if Wifi scan operation is allowed for this caller
* and package.
*/
- private boolean isScanAllowedbyApps(String pkgName, int uid) {
- return noteAppOpAllowed(AppOpsManager.OPSTR_WIFI_SCAN, pkgName, uid);
+ private boolean isScanAllowedbyApps(String pkgName, @Nullable String featureId, int uid) {
+ return noteAppOpAllowed(AppOpsManager.OPSTR_WIFI_SCAN, pkgName, featureId, uid, null);
}
/**
@@ -365,9 +383,9 @@ public class WifiPermissionsUtil {
|| mUserManager.isSameProfileGroup(currentUser, callingUser);
}
- private boolean noteAppOpAllowed(String op, String pkgName, int uid) {
- // TODO moltmann: Set correct featureId
- return mAppOps.noteOp(op, uid, pkgName, null, null) == AppOpsManager.MODE_ALLOWED;
+ private boolean noteAppOpAllowed(String op, String pkgName, @Nullable String featureId,
+ int uid, @Nullable String message) {
+ return mAppOps.noteOp(op, uid, pkgName, featureId, message) == AppOpsManager.MODE_ALLOWED;
}
private boolean checkAppOpAllowed(String op, String pkgName, int uid) {
diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java
index c636bc566..e03d932df 100644
--- a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java
@@ -54,6 +54,7 @@ public class NetworkSuggestionStoreDataTest extends WifiBaseTest {
private static final int TEST_UID_2 = 14536;
private static final String TEST_PACKAGE_NAME_1 = "com.android.test.1";
private static final String TEST_PACKAGE_NAME_2 = "com.android.test.2";
+ private static final String TEST_FEATURE_ID = "com.android.feature.1";
private static final String TEST_CORRUPT_DATA_INVALID_SSID =
"<NetworkSuggestionPerApp>\n"
+ "<string name=\"SuggestorPackageName\">com.android.test.1</string>\n"
@@ -153,7 +154,7 @@ public class NetworkSuggestionStoreDataTest extends WifiBaseTest {
public void serializeDeserializeSingleNetworkSuggestionFromSingleApp() throws Exception {
Map<String, PerAppInfo> networkSuggestionsMap = new HashMap<>();
- PerAppInfo appInfo = new PerAppInfo(TEST_PACKAGE_NAME_1);
+ PerAppInfo appInfo = new PerAppInfo(TEST_PACKAGE_NAME_1, TEST_FEATURE_ID);
WifiConfiguration configuration = WifiConfigurationTestUtil.createEapNetwork();
configuration.enterpriseConfig =
@@ -187,7 +188,7 @@ public class NetworkSuggestionStoreDataTest extends WifiBaseTest {
public void serializeDeserializeSingleNetworkSuggestionFromMultipleApps() throws Exception {
Map<String, PerAppInfo> networkSuggestionsMap = new HashMap<>();
- PerAppInfo appInfo1 = new PerAppInfo(TEST_PACKAGE_NAME_1);
+ PerAppInfo appInfo1 = new PerAppInfo(TEST_PACKAGE_NAME_1, TEST_FEATURE_ID);
WifiNetworkSuggestion networkSuggestion1 = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, false, false, TEST_UID_1,
TEST_PACKAGE_NAME_1);
@@ -196,7 +197,7 @@ public class NetworkSuggestionStoreDataTest extends WifiBaseTest {
ExtendedWifiNetworkSuggestion.fromWns(networkSuggestion1, appInfo1));
networkSuggestionsMap.put(TEST_PACKAGE_NAME_1, appInfo1);
- PerAppInfo appInfo2 = new PerAppInfo(TEST_PACKAGE_NAME_2);
+ PerAppInfo appInfo2 = new PerAppInfo(TEST_PACKAGE_NAME_2, TEST_FEATURE_ID);
WifiNetworkSuggestion networkSuggestion2 = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, true, false, TEST_UID_2,
TEST_PACKAGE_NAME_2);
@@ -215,7 +216,7 @@ public class NetworkSuggestionStoreDataTest extends WifiBaseTest {
public void serializeDeserializeMultipleNetworkSuggestionFromMultipleApps() throws Exception {
Map<String, PerAppInfo> networkSuggestionsMap = new HashMap<>();
- PerAppInfo appInfo1 = new PerAppInfo(TEST_PACKAGE_NAME_1);
+ PerAppInfo appInfo1 = new PerAppInfo(TEST_PACKAGE_NAME_1, TEST_FEATURE_ID);
WifiNetworkSuggestion networkSuggestion1 = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, false, true, TEST_UID_1,
TEST_PACKAGE_NAME_1);
@@ -229,7 +230,7 @@ public class NetworkSuggestionStoreDataTest extends WifiBaseTest {
ExtendedWifiNetworkSuggestion.fromWns(networkSuggestion2, appInfo1));
networkSuggestionsMap.put(TEST_PACKAGE_NAME_1, appInfo1);
- PerAppInfo appInfo2 = new PerAppInfo(TEST_PACKAGE_NAME_2);
+ PerAppInfo appInfo2 = new PerAppInfo(TEST_PACKAGE_NAME_2, TEST_FEATURE_ID);
WifiNetworkSuggestion networkSuggestion3 = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, true, false, TEST_UID_2,
TEST_PACKAGE_NAME_2);
diff --git a/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java
index 7c60fead0..bff45c99b 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScoredNetworkEvaluatorTest.java
@@ -237,7 +237,7 @@ public class ScoredNetworkEvaluatorTest extends WifiBaseTest {
int[] levels = {mThresholdQualifiedRssi2G + 8, mThresholdQualifiedRssi2G + 10};
doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
- any(), anyInt());
+ any(), any(), anyInt(), any());
ScanDetailsAndWifiConfigs scanDetailsAndConfigs = WifiNetworkSelectorTestUtil
.setupScanDetailsAndConfigStore(
@@ -247,7 +247,7 @@ public class ScoredNetworkEvaluatorTest extends WifiBaseTest {
verify(mNetworkScoreManager, never()).requestScores(any());
verify(mWifiPermissionsUtil).enforceCanAccessScanResults(
- eq(TEST_PACKAGE_NAME), eq(TEST_UID));
+ eq(TEST_PACKAGE_NAME), eq(null), eq(TEST_UID), nullable(String.class));
}
@Test
@@ -260,7 +260,7 @@ public class ScoredNetworkEvaluatorTest extends WifiBaseTest {
int[] levels = {mThresholdQualifiedRssi2G + 8, mThresholdQualifiedRssi2G + 10};
doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
- any(), anyInt());
+ any(), any(), anyInt(), any());
ScanDetailsAndWifiConfigs scanDetailsAndConfigs = WifiNetworkSelectorTestUtil
.setupScanDetailsAndConfigStore(
@@ -270,7 +270,7 @@ public class ScoredNetworkEvaluatorTest extends WifiBaseTest {
verify(mNetworkScoreManager, never()).requestScores(any());
verify(mWifiPermissionsUtil).enforceCanAccessScanResults(
- eq(TEST_PACKAGE_NAME), eq(TEST_UID));
+ eq(TEST_PACKAGE_NAME), eq(null), eq(TEST_UID), nullable(String.class));
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index faccb1aec..02ea0e3c5 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -89,6 +89,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
private static final String TEST_PACKAGE_2 = "com.test54321";
private static final String TEST_APP_NAME_1 = "test12345";
private static final String TEST_APP_NAME_2 = "test54321";
+ private static final String TEST_FEATURE = "testFeature";
private static final String TEST_BSSID = "00:11:22:33:44:55";
private static final String TEST_FQDN = "FQDN";
private static final int TEST_UID_1 = 5667;
@@ -217,10 +218,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
anyInt(), anyString(), eq(true))).thenReturn(true);
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
verify(mPasspointManager).addOrUpdateProvider(
passpointConfiguration, TEST_UID_2, TEST_PACKAGE_2, true);
@@ -271,10 +272,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
anyInt(), anyString(), eq(true))).thenReturn(true);
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_1,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
// Now remove all of them.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
@@ -327,10 +328,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
anyInt(), anyString(), eq(true))).thenReturn(true);
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
// Now remove all of them by sending an empty list.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
@@ -360,13 +361,13 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.remove(networkSuggestionList1, TEST_UID_1,
TEST_PACKAGE_1));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
Set<WifiNetworkSuggestion> allNetworkSuggestions =
mWifiNetworkSuggestionsManager.getAllNetworkSuggestions();
@@ -392,7 +393,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
// Modify the original suggestion.
networkSuggestion.wifiConfiguration.meteredOverride =
@@ -401,7 +402,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Replace attempt should success.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiConfiguration.METERED_OVERRIDE_METERED,
mWifiNetworkSuggestionsManager
.get(TEST_PACKAGE_1).get(0).wifiConfiguration.meteredOverride);
@@ -422,7 +423,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// The first add should succeed.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
List<WifiNetworkSuggestion> originalNetworkSuggestionsList = networkSuggestionList;
// Now add 3 more.
@@ -435,7 +436,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// The second add should fail.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
// Now remove 3 of the initially added ones.
networkSuggestionList = new ArrayList<>();
@@ -457,7 +458,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// This add should now succeed.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
}
/**
@@ -482,7 +483,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
// Remove should fail because the network list is different.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID,
mWifiNetworkSuggestionsManager.remove(networkSuggestionList2, TEST_UID_1,
@@ -508,7 +509,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
.thenReturn(true);
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
ScanDetail scanDetail = createScanDetailForNetwork(networkSuggestion.wifiConfiguration);
@@ -535,7 +536,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
ScanDetail scanDetail = createScanDetailForNetwork(networkSuggestion.wifiConfiguration);
@@ -574,10 +575,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
@@ -611,7 +612,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
Set<WifiNetworkSuggestion> matchingNetworkSuggestions =
@@ -651,10 +652,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
@@ -695,7 +696,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
Set<WifiNetworkSuggestion> matchingNetworkSuggestions =
@@ -738,10 +739,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
@@ -782,7 +783,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertFalse(mWifiNetworkSuggestionsManager.hasUserApprovedForApp(TEST_PACKAGE_1));
ScanDetail scanDetail = createScanDetailForNetwork(networkSuggestion.wifiConfiguration);
@@ -808,7 +809,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// add the suggestion & ensure lookup works.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
assertNotNull(mWifiNetworkSuggestionsManager.getNetworkSuggestionsForScanDetail(
scanDetail));
@@ -834,7 +835,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
// Create a scan result corresponding to a different network.
@@ -866,7 +867,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
// Simulate connecting to the network.
@@ -881,8 +882,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
verify(mWifiMetrics).incrementNetworkSuggestionApiNumConnectSuccess();
// Verify that the correct broadcast was sent out.
- mInorder.verify(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(TEST_PACKAGE_1, TEST_UID_1);
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(eq(TEST_PACKAGE_1),
+ eq(TEST_FEATURE), eq(TEST_UID_1), nullable(String.class));
validatePostConnectionBroadcastSent(TEST_PACKAGE_1, networkSuggestion);
// Verify no more broadcast were sent out.
@@ -907,7 +908,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
// Simulate binder was died.
drCaptor.getValue().binderDied();
@@ -925,8 +926,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
verify(mWifiMetrics).incrementNetworkSuggestionApiNumConnectFailure();
// Verify no connection failure event was sent out.
- mInorder.verify(mWifiPermissionsUtil, never())
- .enforceCanAccessScanResults(TEST_PACKAGE_1, TEST_UID_1);
+ mInorder.verify(mWifiPermissionsUtil, never()).enforceCanAccessScanResults(
+ eq(TEST_PACKAGE_1), eq(TEST_FEATURE), eq(TEST_UID_1), nullable(String.class));
verify(mListener, never()).onConnectionStatus(any(), anyInt());
// Verify no more broadcast were sent out.
@@ -956,7 +957,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
WifiConfiguration connectNetwork =
new WifiConfiguration(networkSuggestion.wifiConfiguration);
@@ -968,8 +969,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
WifiMetrics.ConnectionEvent.FAILURE_DHCP, connectNetwork, TEST_BSSID);
// Verify right callback were sent out.
- mInorder.verify(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(TEST_PACKAGE_1, TEST_UID_1);
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(eq(TEST_PACKAGE_1),
+ eq(TEST_FEATURE), eq(TEST_UID_1), nullable(String.class));
verify(mListener)
.onConnectionStatus(networkSuggestion,
WifiManager.STATUS_SUGGESTION_CONNECTION_FAILURE_IP_PROVISIONING);
@@ -1007,10 +1008,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
@@ -1029,9 +1030,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify that the correct broadcasts were sent out.
for (int i = 0; i < 2; i++) {
ArgumentCaptor<String> packageNameCaptor = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> featureIdCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Integer> uidCaptor = ArgumentCaptor.forClass(Integer.class);
- mInorder.verify(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(packageNameCaptor.capture(), uidCaptor.capture());
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(
+ packageNameCaptor.capture(), featureIdCaptor.capture(), uidCaptor.capture(),
+ nullable(String.class));
+ assertEquals(TEST_FEATURE, featureIdCaptor.getValue());
if (packageNameCaptor.getValue().equals(TEST_PACKAGE_1)) {
assertEquals(Integer.valueOf(TEST_UID_1), uidCaptor.getValue());
validatePostConnectionBroadcastSent(TEST_PACKAGE_1, networkSuggestion1);
@@ -1075,10 +1079,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
WifiConfiguration connectNetwork =
@@ -1095,9 +1099,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify that the correct broadcasts were sent out.
for (int i = 0; i < 2; i++) {
ArgumentCaptor<String> packageNameCaptor = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> featureIdCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Integer> uidCaptor = ArgumentCaptor.forClass(Integer.class);
- mInorder.verify(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(packageNameCaptor.capture(), uidCaptor.capture());
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(
+ packageNameCaptor.capture(), featureIdCaptor.capture(), uidCaptor.capture(),
+ nullable(String.class));
+ assertEquals(TEST_FEATURE, featureIdCaptor.getValue());
if (packageNameCaptor.getValue().equals(TEST_PACKAGE_1)) {
assertEquals(Integer.valueOf(TEST_UID_1), uidCaptor.getValue());
validatePostConnectionBroadcastSent(TEST_PACKAGE_1, networkSuggestion1);
@@ -1142,10 +1149,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
@@ -1164,9 +1171,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify that the correct broadcasts were sent out.
for (int i = 0; i < 2; i++) {
ArgumentCaptor<String> packageNameCaptor = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> featureIdCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Integer> uidCaptor = ArgumentCaptor.forClass(Integer.class);
- mInorder.verify(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(packageNameCaptor.capture(), uidCaptor.capture());
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(
+ packageNameCaptor.capture(), featureIdCaptor.capture(), uidCaptor.capture(),
+ nullable(String.class));
+ assertEquals(TEST_FEATURE, featureIdCaptor.getValue());
if (packageNameCaptor.getValue().equals(TEST_PACKAGE_1)) {
assertEquals(Integer.valueOf(TEST_UID_1), uidCaptor.getValue());
validatePostConnectionBroadcastSent(TEST_PACKAGE_1, networkSuggestion1);
@@ -1201,7 +1211,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
verify(mWifiPermissionsUtil, times(2))
.checkNetworkCarrierProvisioningPermission(TEST_UID_1);
assertFalse(mWifiNetworkSuggestionsManager.hasUserApprovedForApp(TEST_PACKAGE_1));
@@ -1218,7 +1228,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify no broadcast was sent out.
mInorder.verify(mWifiPermissionsUtil, never()).enforceCanAccessScanResults(
- anyString(), anyInt());
+ anyString(), nullable(String.class), anyInt(), nullable(String.class));
mInorder.verify(mContext, never()).sendBroadcastAsUser(
any(), any());
}
@@ -1241,7 +1251,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
verify(mWifiPermissionsUtil, times(2))
.checkNetworkCarrierProvisioningPermission(TEST_UID_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
@@ -1258,7 +1268,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify no broadcast was sent out.
mInorder.verify(mWifiPermissionsUtil, never()).enforceCanAccessScanResults(
- anyString(), anyInt());
+ anyString(), nullable(String.class), anyInt(), nullable(String.class));
mInorder.verify(mContext, never()).sendBroadcastAsUser(
any(), any());
}
@@ -1281,13 +1291,13 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
verify(mWifiPermissionsUtil, times(2))
.checkNetworkCarrierProvisioningPermission(TEST_UID_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
- doThrow(new SecurityException())
- .when(mWifiPermissionsUtil).enforceCanAccessScanResults(TEST_PACKAGE_1, TEST_UID_1);
+ doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
+ eq(TEST_PACKAGE_1), eq(TEST_FEATURE), eq(TEST_UID_1), nullable(String.class));
WifiConfiguration connectNetwork =
new WifiConfiguration(networkSuggestion.wifiConfiguration);
@@ -1299,8 +1309,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
mWifiNetworkSuggestionsManager.handleConnectionAttemptEnded(
WifiMetrics.ConnectionEvent.FAILURE_NONE, connectNetwork, TEST_BSSID);
- mInorder.verify(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(TEST_PACKAGE_1, TEST_UID_1);
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(eq(TEST_PACKAGE_1),
+ eq(TEST_FEATURE), eq(TEST_UID_1), nullable(String.class));
// Verify no broadcast was sent out.
mInorder.verifyNoMoreInteractions();
@@ -1321,7 +1331,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
// Verify config store interactions.
verify(mWifiConfigManager).saveToStore(true);
@@ -1363,7 +1373,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.remove(networkSuggestionList, TEST_UID_1,
TEST_PACKAGE_1));
@@ -1395,7 +1405,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
passpointConfiguration.setHomeSp(homeSp);
WifiConfiguration dummyConfiguration = new WifiConfiguration();
dummyConfiguration.FQDN = TEST_FQDN;
- PerAppInfo appInfo = new PerAppInfo(TEST_PACKAGE_1);
+ PerAppInfo appInfo = new PerAppInfo(TEST_PACKAGE_1, TEST_FEATURE);
appInfo.hasUserApproved = true;
WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, false, false, TEST_UID_1,
@@ -1449,7 +1459,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testNetworkSuggestionsConfigStoreLoadAfterUserSwitch() {
// Read the store initially.
- PerAppInfo appInfo1 = new PerAppInfo(TEST_PACKAGE_1);
+ PerAppInfo appInfo1 = new PerAppInfo(TEST_PACKAGE_1, TEST_FEATURE);
appInfo1.hasUserApproved = true;
WifiNetworkSuggestion networkSuggestion1 = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, false, false, TEST_UID_1,
@@ -1463,7 +1473,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Now simulate user switch.
mDataSource.reset();
- PerAppInfo appInfo2 = new PerAppInfo(TEST_PACKAGE_2);
+ PerAppInfo appInfo2 = new PerAppInfo(TEST_PACKAGE_2, TEST_FEATURE);
appInfo2.hasUserApproved = true;
WifiNetworkSuggestion networkSuggestion2 = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, false, false, TEST_UID_1,
@@ -1513,7 +1523,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
// Simulate connecting to the network.
WifiConfiguration connectNetwork =
@@ -1548,7 +1558,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
// Simulate connecting to the network.
WifiConfiguration connectNetwork =
@@ -1592,10 +1602,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
@@ -1633,7 +1643,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
// Simulate connecting to some other network.
@@ -1661,7 +1671,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
WifiConfiguration connectNetwork =
new WifiConfiguration(networkSuggestion.wifiConfiguration);
@@ -1709,14 +1719,14 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Watch app-ops changes on first add.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mInorder.verify(mAppOpsManager).startWatchingMode(eq(OPSTR_CHANGE_WIFI_STATE),
eq(TEST_PACKAGE_1), mAppOpChangedListenerCaptor.capture());
// Nothing happens on second add.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
// Now remove first add, nothing happens.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
@@ -1747,7 +1757,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
Set<WifiNetworkSuggestion> allNetworkSuggestions =
mWifiNetworkSuggestionsManager.getAllNetworkSuggestions();
@@ -1788,7 +1798,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
*/
@Test
public void testAppOpsChangeAfterConfigStoreLoad() {
- PerAppInfo appInfo = new PerAppInfo(TEST_PACKAGE_1);
+ PerAppInfo appInfo = new PerAppInfo(TEST_PACKAGE_1, TEST_FEATURE);
WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createOpenNetwork(), null, false, false, TEST_UID_1,
TEST_PACKAGE_1);
@@ -1846,7 +1856,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
Set<WifiNetworkSuggestion> allNetworkSuggestions =
mWifiNetworkSuggestionsManager.getAllNetworkSuggestions();
@@ -1897,10 +1907,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
// Remove all suggestions from TEST_PACKAGE_1 & TEST_PACKAGE_2, we should continue to track.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
@@ -1963,10 +1973,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
// Remove all suggestions from TEST_PACKAGE_1 & TEST_PACKAGE_2, we should continue to track.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
@@ -2011,7 +2021,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
validateUserApprovalNotification(TEST_APP_NAME_1);
// Simulate user dismissal notification.
sendBroadcastForUserAction(
@@ -2052,7 +2062,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
validateUserApprovalNotification(TEST_APP_NAME_1);
// Simulate user dismissal notification.
@@ -2098,7 +2108,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
verify(mAppOpsManager).startWatchingMode(eq(OPSTR_CHANGE_WIFI_STATE),
eq(TEST_PACKAGE_1), mAppOpChangedListenerCaptor.capture());
validateUserApprovalNotification(TEST_APP_NAME_1);
@@ -2143,7 +2153,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Assuming the user re-enabled the app again & added the same suggestions back.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
// We should resend the notification when the network is again found in scan results.
mWifiNetworkSuggestionsManager.getNetworkSuggestionsForScanDetail(
@@ -2167,7 +2177,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
// Simulate finding the network in scan results.
mWifiNetworkSuggestionsManager.getNetworkSuggestionsForScanDetail(
@@ -2216,7 +2226,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
networkSuggestionList.add(networkSuggestion4);
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
storedNetworkSuggestionListPerApp =
mWifiNetworkSuggestionsManager.get(TEST_PACKAGE_1);
@@ -2258,10 +2268,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
- TEST_PACKAGE_2));
+ TEST_PACKAGE_2, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(false, TEST_PACKAGE_2);
List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworks =
@@ -2285,7 +2295,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
validateUserApprovalNotification(TEST_APP_NAME_1);
// Simulate user clicking on allow in the notification.
@@ -2320,7 +2330,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}};
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
verify(mAppOpsManager).startWatchingMode(eq(OPSTR_CHANGE_WIFI_STATE),
eq(TEST_PACKAGE_1), mAppOpChangedListenerCaptor.capture());
validateUserApprovalNotification(TEST_APP_NAME_1);
@@ -2354,7 +2364,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Assuming the user re-enabled the app again & added the same suggestions back.
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
validateUserApprovalNotification(TEST_APP_NAME_1);
verifyNoMoreInteractions(mNotificationManger);
}
@@ -2386,7 +2396,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
.thenReturn(true);
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1));
+ TEST_PACKAGE_1, TEST_FEATURE));
mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
@@ -2402,8 +2412,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
verify(mWifiMetrics).incrementNetworkSuggestionApiNumConnectSuccess();
// Verify that the correct broadcast was sent out.
- mInorder.verify(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(TEST_PACKAGE_1, TEST_UID_1);
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(eq(TEST_PACKAGE_1),
+ eq(TEST_FEATURE), eq(TEST_UID_1), nullable(String.class));
validatePostConnectionBroadcastSent(TEST_PACKAGE_1, networkSuggestion);
// Verify no more broadcast were sent out.
@@ -2482,7 +2492,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
.thenReturn(true);
int status = mWifiNetworkSuggestionsManager
- .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1);
+ .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1, TEST_FEATURE);
assertEquals(status, WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS);
@@ -2501,7 +2511,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
.thenReturn(false);
int status = mWifiNetworkSuggestionsManager
- .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1);
+ .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1, TEST_FEATURE);
assertEquals(status,
WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED);
@@ -2519,7 +2529,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
.thenReturn(false);
int status = mWifiNetworkSuggestionsManager
- .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1);
+ .add(networkSuggestionList, TEST_UID_1, TEST_APP_NAME_1, TEST_FEATURE);
assertEquals(status, WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index ddf6819e3..f69df49cc 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -46,6 +46,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.AdditionalAnswers.returnsSecondArg;
import static org.mockito.ArgumentMatchers.notNull;
+import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
@@ -172,6 +173,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
private static final int DEFAULT_VERBOSE_LOGGING = 0;
private static final String ANDROID_SYSTEM_PACKAGE = "android";
private static final String TEST_PACKAGE_NAME = "TestPackage";
+ private static final String TEST_FEATURE_ID = "TestFeature";
private static final String SYSUI_PACKAGE_NAME = "com.android.systemui";
private static final int TEST_PID = 6789;
private static final int TEST_PID2 = 9876;
@@ -346,6 +348,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
// Create an OSU provider that can be provisioned via an open OSU AP
mOsuProvider = PasspointProvisioningTestUtil.generateOsuProvider(true);
when(mContext.getOpPackageName()).thenReturn(TEST_PACKAGE_NAME);
+ when(mContext.getFeatureId()).thenReturn(TEST_FEATURE_ID);
when(mContext.checkPermission(eq(android.Manifest.permission.NETWORK_SETTINGS),
anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED);
when(mContext.checkPermission(eq(android.Manifest.permission.NETWORK_SETUP_WIZARD),
@@ -438,7 +441,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testRemoveNetworkFailureAppBelowQSdk() {
doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager)
- .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME);
+ .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, null);
when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(),
eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true);
when(mWifiConfigManager.removeNetwork(anyInt(), anyInt(), anyString())).thenReturn(false);
@@ -1174,7 +1178,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
doReturn(AppOpsManager.MODE_IGNORED).when(mAppOpsManager)
.noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), SCAN_PACKAGE_NAME);
mLooper.startAutoDispatch();
- assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME));
+ assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME);
}
@@ -1185,9 +1189,10 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testStartScanFailureInCanAccessScanResultsPermission() {
doThrow(new SecurityException()).when(mWifiPermissionsUtil)
- .enforceCanAccessScanResults(SCAN_PACKAGE_NAME, Process.myUid());
+ .enforceCanAccessScanResults(SCAN_PACKAGE_NAME, TEST_FEATURE_ID, Process.myUid(),
+ null);
mLooper.startAutoDispatch();
- assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME));
+ assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME);
}
@@ -1200,7 +1205,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
mWifiServiceImpl = makeWifiServiceImplWithMockRunnerWhichTimesOut();
mLooper.startAutoDispatch();
- assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME));
+ assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mScanRequestProxy, never()).startScan(anyInt(), eq(SCAN_PACKAGE_NAME));
}
@@ -1213,7 +1218,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
when(mScanRequestProxy.startScan(anyInt(), anyString())).thenReturn(false);
mLooper.startAutoDispatch();
- assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME));
+ assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mScanRequestProxy).startScan(Binder.getCallingUid(), SCAN_PACKAGE_NAME);
}
@@ -1241,9 +1246,9 @@ public class WifiServiceImplTest extends WifiBaseTest {
setupForGetConnectionInfo();
doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
- anyString(), anyInt());
+ anyString(), nullable(String.class), anyInt(), nullable(String.class));
- WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE);
+ WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE, TEST_FEATURE_ID);
assertEquals(WifiSsid.NONE, connectionInfo.getSSID());
assertEquals(WifiInfo.DEFAULT_MAC_ADDRESS, connectionInfo.getBSSID());
@@ -1259,9 +1264,9 @@ public class WifiServiceImplTest extends WifiBaseTest {
setupForGetConnectionInfo();
doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
- anyString(), anyInt());
+ anyString(), nullable(String.class), anyInt(), nullable(String.class));
- WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE);
+ WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE, TEST_FEATURE_ID);
assertEquals(WifiSsid.NONE, connectionInfo.getSSID());
assertEquals(WifiInfo.DEFAULT_MAC_ADDRESS, connectionInfo.getBSSID());
@@ -1276,7 +1281,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
public void testConnectedIdsAreVisibleFromPermittedApp() throws Exception {
setupForGetConnectionInfo();
- WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE);
+ WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE, TEST_FEATURE_ID);
assertEquals(TEST_SSID_WITH_QUOTES, connectionInfo.getSSID());
assertEquals(TEST_BSSID, connectionInfo.getBSSID());
@@ -1297,7 +1302,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS);
ParceledListSlice<WifiConfiguration> configs =
- mWifiServiceImpl.getConfiguredNetworks(TEST_PACKAGE);
+ mWifiServiceImpl.getConfiguredNetworks(TEST_PACKAGE, TEST_FEATURE_ID);
assertEquals(0, configs.getList().size());
}
@@ -1312,10 +1317,10 @@ public class WifiServiceImplTest extends WifiBaseTest {
.thenReturn(TEST_WIFI_CONFIGURATION_LIST);
doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
- anyString(), anyInt());
+ anyString(), nullable(String.class), anyInt(), nullable(String.class));
ParceledListSlice<WifiConfiguration> configs =
- mWifiServiceImpl.getConfiguredNetworks(TEST_PACKAGE);
+ mWifiServiceImpl.getConfiguredNetworks(TEST_PACKAGE, TEST_FEATURE_ID);
assertEquals(0, configs.getList().size());
@@ -1337,7 +1342,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
mLooper.startAutoDispatch();
ParceledListSlice<WifiConfiguration> configs =
- mWifiServiceImpl.getConfiguredNetworks(TEST_PACKAGE);
+ mWifiServiceImpl.getConfiguredNetworks(TEST_PACKAGE, TEST_FEATURE_ID);
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mWifiConfigManager).getSavedNetworks(eq(Process.WIFI_UID));
@@ -1356,11 +1361,11 @@ public class WifiServiceImplTest extends WifiBaseTest {
.thenReturn(TEST_WIFI_CONFIGURATION_LIST);
doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
- anyString(), anyInt());
+ anyString(), nullable(String.class), anyInt(), nullable(String.class));
mLooper.startAutoDispatch();
ParceledListSlice<WifiConfiguration> configs =
- mWifiServiceImpl.getPrivilegedConfiguredNetworks(TEST_PACKAGE);
+ mWifiServiceImpl.getPrivilegedConfiguredNetworks(TEST_PACKAGE, TEST_FEATURE_ID);
mLooper.stopAutoDispatchAndIgnoreExceptions();
assertNull(configs);
@@ -1376,11 +1381,11 @@ public class WifiServiceImplTest extends WifiBaseTest {
.thenReturn(TEST_WIFI_CONFIGURATION_LIST);
doThrow(new SecurityException()).when(mWifiPermissionsUtil).enforceCanAccessScanResults(
- anyString(), anyInt());
+ anyString(), nullable(String.class), anyInt(), nullable(String.class));
mLooper.startAutoDispatch();
ParceledListSlice<WifiConfiguration> configs =
- mWifiServiceImpl.getPrivilegedConfiguredNetworks(TEST_PACKAGE);
+ mWifiServiceImpl.getPrivilegedConfiguredNetworks(TEST_PACKAGE, TEST_FEATURE_ID);
mLooper.stopAutoDispatchAndIgnoreExceptions();
assertNull(configs);
@@ -1397,7 +1402,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
mLooper.startAutoDispatch();
ParceledListSlice<WifiConfiguration> configs =
- mWifiServiceImpl.getPrivilegedConfiguredNetworks(TEST_PACKAGE);
+ mWifiServiceImpl.getPrivilegedConfiguredNetworks(TEST_PACKAGE, TEST_FEATURE_ID);
mLooper.stopAutoDispatchAndIgnoreExceptions();
WifiConfigurationTestUtil.assertConfigurationsEqualForBackup(
@@ -1417,8 +1422,10 @@ public class WifiServiceImplTest extends WifiBaseTest {
when(mScanRequestProxy.getScanResults()).thenReturn(scanResultList);
String packageName = "test.com";
+ String featureId = "test.com.featureId";
mLooper.startAutoDispatch();
- List<ScanResult> retrievedScanResultList = mWifiServiceImpl.getScanResults(packageName);
+ List<ScanResult> retrievedScanResultList = mWifiServiceImpl.getScanResults(packageName,
+ featureId);
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mScanRequestProxy).getScanResults();
@@ -1441,8 +1448,10 @@ public class WifiServiceImplTest extends WifiBaseTest {
when(mScanRequestProxy.getScanResults()).thenReturn(scanResultList);
String packageName = "test.com";
+ String featureId = "test.com.featureId";
mLooper.startAutoDispatch();
- List<ScanResult> retrievedScanResultList = mWifiServiceImpl.getScanResults(packageName);
+ List<ScanResult> retrievedScanResultList = mWifiServiceImpl.getScanResults(packageName,
+ featureId);
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mScanRequestProxy, never()).getScanResults();
@@ -1459,7 +1468,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
private void registerLOHSRequestFull() {
setupLohsPermissions();
- int result = mWifiServiceImpl.startLocalOnlyHotspot(mLohsCallback, TEST_PACKAGE_NAME, null);
+ int result = mWifiServiceImpl.startLocalOnlyHotspot(mLohsCallback, TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, null);
assertEquals(LocalOnlyHotspotCallback.REQUEST_REGISTERED, result);
verifyCheckChangePermission(TEST_PACKAGE_NAME);
}
@@ -1493,6 +1503,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
public void testStartLocalOnlyHotspotThrowsSecurityExceptionWithoutLocationPermission() {
doThrow(new SecurityException())
.when(mWifiPermissionsUtil).enforceLocationPermission(eq(TEST_PACKAGE_NAME),
+ eq(TEST_FEATURE_ID),
anyInt());
mWifiServiceImpl.startLocalOnlyHotspot(mLohsCallback, TEST_PACKAGE_NAME);
}
@@ -1718,7 +1729,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
// set up basic permissions, but not NETWORK_SETUP_WIZARD
setupLohsPermissions();
setupWardenForCustomLohs();
- mWifiServiceImpl.startLocalOnlyHotspot(mLohsCallback, TEST_PACKAGE_NAME, customConfig);
+ mWifiServiceImpl.startLocalOnlyHotspot(mLohsCallback, TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ customConfig);
}
private static void nopDeathCallback(LocalOnlyHotspotRequestInfo requestor) {
@@ -1735,9 +1747,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
setupForCustomLohs();
mWifiServiceImpl.registerLOHSForTest(mPid, new LocalOnlyHotspotRequestInfo(
sharedCallback, WifiServiceImplTest::nopDeathCallback, null));
- assertThat(mWifiServiceImpl.startLocalOnlyHotspot(
- exclusiveCallback, TEST_PACKAGE_NAME, exclusiveConfig))
- .isEqualTo(ERROR_GENERIC);
+ assertThat(mWifiServiceImpl.startLocalOnlyHotspot(exclusiveCallback, TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, exclusiveConfig)).isEqualTo(ERROR_GENERIC);
mLooper.dispatchAll();
assertThat(sharedCallback.mIsStarted).isTrue();
@@ -1755,9 +1766,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
setupForCustomLohs();
mWifiServiceImpl.registerLOHSForTest(mPid, new LocalOnlyHotspotRequestInfo(
exclusiveCallback, WifiServiceImplTest::nopDeathCallback, exclusiveConfig));
- assertThat(mWifiServiceImpl.startLocalOnlyHotspot(
- sharedCallback, TEST_PACKAGE_NAME, null))
- .isEqualTo(ERROR_GENERIC);
+ assertThat(mWifiServiceImpl.startLocalOnlyHotspot(sharedCallback, TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, null)).isEqualTo(ERROR_GENERIC);
mLooper.dispatchAll();
assertThat(exclusiveCallback.mIsStarted).isTrue();
@@ -1773,8 +1783,9 @@ public class WifiServiceImplTest extends WifiBaseTest {
FakeLohsCallback callback = new FakeLohsCallback();
setupForCustomLohs();
- assertThat(mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, config))
- .isEqualTo(REQUEST_REGISTERED);
+ assertThat(
+ mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ config)).isEqualTo(REQUEST_REGISTERED);
mLooper.dispatchAll();
assertThat(callback.mIsStarted).isTrue();
@@ -1791,8 +1802,9 @@ public class WifiServiceImplTest extends WifiBaseTest {
FakeLohsCallback callback = new FakeLohsCallback();
setupForCustomLohs();
- assertThat(mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, config))
- .isEqualTo(REQUEST_REGISTERED);
+ assertThat(
+ mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ config)).isEqualTo(REQUEST_REGISTERED);
mLooper.dispatchAll();
assertThat(callback.mIsStarted).isTrue();
@@ -1809,8 +1821,9 @@ public class WifiServiceImplTest extends WifiBaseTest {
FakeLohsCallback callback = new FakeLohsCallback();
setupForCustomLohs();
- assertThat(mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, config))
- .isEqualTo(REQUEST_REGISTERED);
+ assertThat(
+ mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ config)).isEqualTo(REQUEST_REGISTERED);
mLooper.dispatchAll();
assertThat(callback.mIsStarted).isTrue();
@@ -1825,8 +1838,9 @@ public class WifiServiceImplTest extends WifiBaseTest {
FakeLohsCallback callback = new FakeLohsCallback();
setupForCustomLohs();
- assertThat(mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, config))
- .isEqualTo(REQUEST_REGISTERED);
+ assertThat(
+ mWifiServiceImpl.startLocalOnlyHotspot(callback, TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ config)).isEqualTo(REQUEST_REGISTERED);
mLooper.dispatchAll();
assertThat(callback.mIsStarted).isTrue();
@@ -3016,7 +3030,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
TestUtil.sendIdleModeChanged(mBroadcastReceiverCaptor.getValue(), mContext);
// Send a scan request while the device is idle.
- assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME));
+ assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID));
// No scans must be made yet as the device is idle.
verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME);
@@ -3035,7 +3049,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
// Send another scan request. The device is not idle anymore, so it must be executed
// immediately.
mLooper.startAutoDispatch();
- assertTrue(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME));
+ assertTrue(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mScanRequestProxy).startScan(Process.myUid(), SCAN_PACKAGE_NAME);
}
@@ -3798,22 +3812,25 @@ public class WifiServiceImplTest extends WifiBaseTest {
*/
@Test
public void testAddNetworkSuggestions() {
- when(mWifiNetworkSuggestionsManager.add(any(), anyInt(), anyString()))
- .thenReturn(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS);
+ when(mWifiNetworkSuggestionsManager.add(any(), anyInt(), anyString(),
+ nullable(String.class))).thenReturn(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS);
mLooper.startAutoDispatch();
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
- mWifiServiceImpl.addNetworkSuggestions(mock(List.class), TEST_PACKAGE_NAME));
+ mWifiServiceImpl.addNetworkSuggestions(mock(List.class), TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
- when(mWifiNetworkSuggestionsManager.add(any(), anyInt(), anyString()))
- .thenReturn(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE);
+ when(mWifiNetworkSuggestionsManager.add(any(), anyInt(), anyString(),
+ nullable(String.class))).thenReturn(
+ WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE);
mLooper.startAutoDispatch();
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE,
- mWifiServiceImpl.addNetworkSuggestions(mock(List.class), TEST_PACKAGE_NAME));
+ mWifiServiceImpl.addNetworkSuggestions(mock(List.class), TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
verify(mWifiNetworkSuggestionsManager, times(2)).add(
- any(), eq(Binder.getCallingUid()), eq(TEST_PACKAGE_NAME));
+ any(), eq(Binder.getCallingUid()), eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID));
}
/**
@@ -3826,11 +3843,12 @@ public class WifiServiceImplTest extends WifiBaseTest {
mLooper.startAutoDispatch();
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL,
- mWifiServiceImpl.addNetworkSuggestions(mock(List.class), TEST_PACKAGE_NAME));
+ mWifiServiceImpl.addNetworkSuggestions(mock(List.class), TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID));
mLooper.stopAutoDispatchAndIgnoreExceptions();
- verify(mWifiNetworkSuggestionsManager, never()).add(
- any(), eq(Binder.getCallingUid()), eq(TEST_PACKAGE_NAME));
+ verify(mWifiNetworkSuggestionsManager, never()).add(any(), eq(Binder.getCallingUid()),
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID));
}
/**
@@ -4401,7 +4419,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
eq(android.Manifest.permission.ACCESS_WIFI_STATE), eq("WifiService"));
mWifiServiceImpl.registerSuggestionConnectionStatusListener(mAppBinder,
- mSuggestionConnectionStatusListener, NETWORK_CALLBACK_ID, TEST_PACKAGE_NAME);
+ mSuggestionConnectionStatusListener, NETWORK_CALLBACK_ID, TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID);
}
/**
@@ -4410,7 +4429,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test(expected = IllegalArgumentException.class)
public void testRegisterSuggestionNetworkCallbackWithIllegalArgument() {
mWifiServiceImpl.registerSuggestionConnectionStatusListener(mAppBinder, null,
- NETWORK_CALLBACK_ID, TEST_PACKAGE_NAME);
+ NETWORK_CALLBACK_ID, TEST_PACKAGE_NAME, TEST_FEATURE_ID);
}
/**
@@ -4430,7 +4449,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testRegisterUnregisterSuggestionNetworkCallback() throws Exception {
mWifiServiceImpl.registerSuggestionConnectionStatusListener(mAppBinder,
- mSuggestionConnectionStatusListener, NETWORK_CALLBACK_ID, TEST_PACKAGE_NAME);
+ mSuggestionConnectionStatusListener, NETWORK_CALLBACK_ID, TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID);
mLooper.dispatchAll();
verify(mWifiNetworkSuggestionsManager).registerSuggestionConnectionStatusListener(
eq(mAppBinder), eq(mSuggestionConnectionStatusListener), eq(NETWORK_CALLBACK_ID),
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
index b803dd515..a488baf2a 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
@@ -1615,7 +1615,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
InOrder inOrderS = inOrder(mockAwareService, mockCallback, mockSessionCallback);
mgr.attach(mMockLooperHandler, configRequest, mockCallback, null);
- inOrderS.verify(mockAwareService).connect(any(), any(),
+ inOrderS.verify(mockAwareService).connect(any(), any(), any(),
clientProxyCallback.capture(), eq(configRequest), eq(false));
IWifiAwareEventCallback iwaec = clientProxyCallback.getValue();
iwaec.onConnectSuccess(clientId);
@@ -1624,13 +1624,13 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
if (doPublish) {
sessionCaptor.getValue().publish(publishConfig, mockSessionCallback,
mMockLooperHandler);
- inOrderS.verify(mockAwareService).publish(any(), eq(clientId), eq(publishConfig),
+ inOrderS.verify(mockAwareService).publish(any(), any(), eq(clientId), eq(publishConfig),
sessionProxyCallback.capture());
} else {
sessionCaptor.getValue().subscribe(subscribeConfig, mockSessionCallback,
mMockLooperHandler);
- inOrderS.verify(mockAwareService).subscribe(any(), eq(clientId), eq(subscribeConfig),
- sessionProxyCallback.capture());
+ inOrderS.verify(mockAwareService).subscribe(any(), any(), eq(clientId),
+ eq(subscribeConfig), sessionProxyCallback.capture());
}
sessionProxyCallback.getValue().onSessionStarted(sessionId);
mMockLooper.dispatchAll();
@@ -1693,7 +1693,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
AttachCallback mockCallback = mock(AttachCallback.class);
mgr.attach(mMockLooperHandler, configRequest, mockCallback, null);
- verify(mockAwareService).connect(any(), any(),
+ verify(mockAwareService).connect(any(), any(), any(),
clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
@@ -1773,6 +1773,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
throws Exception {
final int pid = 2000;
final String callingPackage = "com.android.somePackage";
+ final String callingFeatureId = "com.android.someFeature";
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class);
@@ -1803,9 +1804,8 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
}
// (3) create client
- mDut.connect(clientId, Process.myUid(), pid, callingPackage, mMockCallback,
- configRequest,
- false);
+ mDut.connect(clientId, Process.myUid(), pid, callingPackage, callingFeatureId,
+ mMockCallback, configRequest, false);
mMockLooper.dispatchAll();
if (startUpSequence) {
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java
index 65edbbb79..b0db9646e 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareMetricsTest.java
@@ -239,25 +239,25 @@ public class WifiAwareMetricsTest extends WifiBaseTest {
// uid1: session 1
clients.put(10,
- new WifiAwareClientState(mMockContext, 10, uid1, 0, null, null, null, false,
+ new WifiAwareClientState(mMockContext, 10, uid1, 0, null, null, null, null, false,
mClock.getElapsedSinceBootMillis(), mWifiPermissionsUtil));
mDut.recordAttachSession(uid1, false, clients);
// uid1: session 2
clients.put(11,
- new WifiAwareClientState(mMockContext, 11, uid1, 0, null, null, null, false,
+ new WifiAwareClientState(mMockContext, 11, uid1, 0, null, null, null, null, false,
mClock.getElapsedSinceBootMillis(), mWifiPermissionsUtil));
mDut.recordAttachSession(uid1, false, clients);
// uid2: session 1
clients.put(12,
- new WifiAwareClientState(mMockContext, 12, uid2, 0, null, null, null, false,
+ new WifiAwareClientState(mMockContext, 12, uid2, 0, null, null, null, null, false,
mClock.getElapsedSinceBootMillis(), mWifiPermissionsUtil));
mDut.recordAttachSession(uid2, false, clients);
// uid2: session 2
clients.put(13,
- new WifiAwareClientState(mMockContext, 13, uid2, 0, null, null, null, true,
+ new WifiAwareClientState(mMockContext, 13, uid2, 0, null, null, null, null, true,
mClock.getElapsedSinceBootMillis(), mWifiPermissionsUtil));
mDut.recordAttachSession(uid2, true, clients);
@@ -273,7 +273,7 @@ public class WifiAwareMetricsTest extends WifiBaseTest {
// uid2: session 3
clients.put(14,
- new WifiAwareClientState(mMockContext, 14, uid2, 0, null, null, null, false,
+ new WifiAwareClientState(mMockContext, 14, uid2, 0, null, null, null, null, false,
mClock.getElapsedSinceBootMillis(), mWifiPermissionsUtil));
mDut.recordAttachSession(uid2, false, clients);
@@ -317,11 +317,11 @@ public class WifiAwareMetricsTest extends WifiBaseTest {
setTime(5);
WifiAwareClientState client1 = new WifiAwareClientState(mMockContext, 10, uid1, 0, null,
- null, null, false, 0, mWifiPermissionsUtil);
+ null, null, null, false, 0, mWifiPermissionsUtil);
WifiAwareClientState client2 = new WifiAwareClientState(mMockContext, 11, uid2, 0, null,
- null, null, false, 0, mWifiPermissionsUtil);
+ null, null, null, false, 0, mWifiPermissionsUtil);
WifiAwareClientState client3 = new WifiAwareClientState(mMockContext, 12, uid3, 0, null,
- null, null, false, 0, mWifiPermissionsUtil);
+ null, null, null, false, 0, mWifiPermissionsUtil);
clients.put(10, client1);
clients.put(11, client2);
clients.put(12, client3);
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java
index 95b7b0b14..1dd3ff8a7 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java
@@ -78,6 +78,7 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
private WifiAwareServiceImplSpy mDut;
private int mDefaultUid = 1500;
private String mPackageName = "some.package";
+ private String mFeatureId = "some.feature";
private TestLooper mMockLooper;
@Mock
@@ -182,12 +183,13 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
public void testConnectWithConfig() {
ConfigRequest configRequest = new ConfigRequest.Builder().setMasterPreference(55).build();
String callingPackage = "com.google.somePackage";
+ String callingFeatureId = "com.google.someFeature";
- mDut.connect(mBinderMock, callingPackage, mCallbackMock,
+ mDut.connect(mBinderMock, callingPackage, callingFeatureId, mCallbackMock,
configRequest, false);
- verify(mAwareStateManagerMock).connect(anyInt(), anyInt(), anyInt(),
- eq(callingPackage), eq(mCallbackMock), eq(configRequest), eq(false));
+ verify(mAwareStateManagerMock).connect(anyInt(), anyInt(), anyInt(), eq(callingPackage),
+ eq(callingFeatureId), eq(mCallbackMock), eq(configRequest), eq(false));
}
/**
@@ -257,7 +259,7 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName("valid.value")
.build();
- mDut.publish(mPackageName, clientId, publishConfig, mSessionCallbackMock);
+ mDut.publish(mPackageName, mFeatureId, clientId, publishConfig, mSessionCallbackMock);
verify(mAwareStateManagerMock).publish(clientId, publishConfig, mSessionCallbackMock);
assertTrue("SecurityException for invalid access from wrong UID thrown", failsAsExpected);
@@ -277,7 +279,7 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);
- mDut.publish(mPackageName, clientId, publishConfig, mockCallback);
+ mDut.publish(mPackageName, mFeatureId, clientId, publishConfig, mockCallback);
}
/**
@@ -294,7 +296,7 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);
- mDut.subscribe(mPackageName, clientId, subscribeConfig, mockCallback);
+ mDut.subscribe(mPackageName, mFeatureId, clientId, subscribeConfig, mockCallback);
}
@@ -326,9 +328,9 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
int prevId = 0;
for (int i = 0; i < loopCount; ++i) {
- mDut.connect(mBinderMock, "", mCallbackMock, null, false);
+ mDut.connect(mBinderMock, "", "", mCallbackMock, null, false);
inOrder.verify(mAwareStateManagerMock).connect(clientIdCaptor.capture(), anyInt(),
- anyInt(), any(), eq(mCallbackMock), any(), eq(false));
+ anyInt(), any(), any(), eq(mCallbackMock), any(), eq(false));
int id = clientIdCaptor.getValue();
if (i != 0) {
assertTrue("Client ID incrementing", id > prevId);
@@ -361,7 +363,7 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);
- mDut.publish(mPackageName, clientId, publishConfig, mockCallback);
+ mDut.publish(mPackageName, mFeatureId, clientId, publishConfig, mockCallback);
verify(mAwareStateManagerMock).publish(clientId, publishConfig, mockCallback);
}
@@ -456,7 +458,7 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);
- mDut.subscribe(mPackageName, clientId, subscribeConfig, mockCallback);
+ mDut.subscribe(mPackageName, mFeatureId, clientId, subscribeConfig, mockCallback);
verify(mAwareStateManagerMock).subscribe(clientId, subscribeConfig, mockCallback);
}
@@ -642,7 +644,7 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);
- mDut.publish(mPackageName, clientId, publishConfig, mockCallback);
+ mDut.publish(mPackageName, mFeatureId, clientId, publishConfig, mockCallback);
verify(mAwareStateManagerMock).publish(clientId, publishConfig, mockCallback);
}
@@ -658,20 +660,21 @@ public class WifiAwareServiceImplTest extends WifiBaseTest {
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);
- mDut.subscribe(mPackageName, clientId, subscribeConfig, mockCallback);
+ mDut.subscribe(mPackageName, mFeatureId, clientId, subscribeConfig, mockCallback);
verify(mAwareStateManagerMock).subscribe(clientId, subscribeConfig, mockCallback);
}
private int doConnect() {
String callingPackage = "com.google.somePackage";
+ String callingFeatureId = "com.google.someFeature";
- mDut.connect(mBinderMock, callingPackage, mCallbackMock, null, false);
+ mDut.connect(mBinderMock, callingPackage, callingFeatureId, mCallbackMock, null, false);
ArgumentCaptor<Integer> clientId = ArgumentCaptor.forClass(Integer.class);
verify(mAwareStateManagerMock).connect(clientId.capture(), anyInt(), anyInt(),
- eq(callingPackage), eq(mCallbackMock), eq(new ConfigRequest.Builder().build()),
- eq(false));
+ eq(callingPackage), eq(callingFeatureId), eq(mCallbackMock),
+ eq(new ConfigRequest.Builder().build()), eq(false));
return clientId.getValue();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
index d5948282d..5522d1918 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
@@ -30,7 +30,6 @@ import static org.mockito.ArgumentMatchers.anyByte;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyShort;
-import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.inOrder;
@@ -235,6 +234,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int pid1 = 2000;
final int pid2 = 2001;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String serviceName = "some-service-name";
final byte subscribeId1 = 15;
final byte subscribeId2 = 16;
@@ -268,7 +268,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect 2 clients
- mDut.connect(clientId1, uid1, pid1, callingPackage, mockCallback1, configRequest, false);
+ mDut.connect(clientId1, uid1, pid1, callingPackage, callingFeature, mockCallback1,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -276,7 +277,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
inOrder.verify(mockCallback1).onConnectSuccess(clientId1);
- mDut.connect(clientId2, uid2, pid2, callingPackage, mockCallback2, configRequest, false);
+ mDut.connect(clientId2, uid2, pid2, callingPackage, callingFeature, mockCallback2,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2).onConnectSuccess(clientId2);
@@ -349,6 +351,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class);
@@ -366,7 +369,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
collector.checkThat("usage enabled", mDut.isUsageEnabled(), equalTo(true));
// (2) connect (enable Aware)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -395,6 +399,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class);
@@ -421,7 +426,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
// (3) try connecting and validate that get failure callback (though app should be aware of
// non-availability through state change broadcast and/or query API)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onConnectFail(anyInt());
@@ -439,6 +445,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class);
@@ -459,7 +466,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
collector.checkThat("usage enabled", mDut.isUsageEnabled(), equalTo(true));
// (2) connect (successfully)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -485,7 +493,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
inOrderM.verify(mAwareMetricsMock).recordDisableAware();
// (4) try connecting again and validate that get a failure
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onConnectFail(anyInt());
inOrderM.verify(mAwareMetricsMock).recordAttachStatus(NanStatusType.INTERNAL_FAILURE);
@@ -503,7 +512,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
validateCorrectAwareStatusChangeBroadcast(inOrder);
// (7) connect (should be successful)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -526,6 +536,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class);
@@ -544,7 +555,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (2) connect with HAL failure
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -568,6 +580,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int reason = NanStatusType.INTERNAL_FAILURE;
final byte[] someMac = HexEncoding.decode("000102030405".toCharArray(), false);
final byte[] someMac2 = HexEncoding.decode("060708090A0B".toCharArray(), false);
@@ -588,7 +601,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect 1st and 2nd clients
- mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest, false);
+ mDut.connect(clientId1, uid, pid, callingPackage, callingFeature, mockCallback1,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionIdCapture.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -597,7 +611,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
inOrder.verify(mockCallback1).onConnectSuccess(clientId1);
- mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest, true);
+ mDut.connect(clientId2, uid, pid, callingPackage, callingFeature, mockCallback2,
+ configRequest, true);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionIdCapture.capture(),
eq(configRequest), eq(true), eq(false), eq(true), eq(false));
@@ -626,8 +641,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (5) deliver new identity - with LOCATIONING permission
- when(mWifiPermissionsUtil.checkCallersLocationPermission(anyString(), anyInt(),
- anyBoolean())).thenReturn(true);
+ when(mWifiPermissionsUtil.checkCallersLocationPermission(eq(callingPackage),
+ eq(callingFeature), eq(uid), anyBoolean(), any())).thenReturn(true);
mDut.onInterfaceAddressChangeNotification(someMac);
mMockLooper.dispatchAll();
@@ -655,6 +670,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
final PublishConfig publishConfig = new PublishConfig.Builder().build();
@@ -673,7 +689,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect (successfully)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -717,6 +734,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int reasonFail = NanStatusType.INTERNAL_FAILURE;
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -737,7 +755,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -786,6 +805,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int reasonTerminate = NanStatusType.SUCCESS;
final byte publishId = 15;
@@ -808,7 +828,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -868,6 +889,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final byte publishId = 15;
final int reasonFail = NanStatusType.INTERNAL_FAILURE;
@@ -890,7 +912,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -980,6 +1003,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final byte publishId = 15;
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -1000,7 +1024,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1046,6 +1071,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int reasonFail = NanStatusType.INTERNAL_FAILURE;
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -1066,7 +1092,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1116,6 +1143,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int reasonTerminate = NanStatusType.SUCCESS;
final byte subscribeId = 15;
@@ -1138,7 +1166,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1196,6 +1225,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final byte subscribeId = 15;
final int reasonFail = NanStatusType.INTERNAL_FAILURE;
final int rangeMax = 10;
@@ -1220,7 +1250,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1293,6 +1324,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final byte subscribeId = 15;
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -1311,7 +1343,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1352,6 +1385,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String serviceName = "some-service-name";
final String ssi = "some much longer and more arbitrary data";
final int reasonFail = NanStatusType.INTERNAL_FAILURE;
@@ -1392,7 +1426,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -1480,6 +1515,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int clusterLow = 7;
final int clusterHigh = 7;
final int masterPref = 0;
@@ -1518,7 +1554,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1585,6 +1622,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int clusterLow = 7;
final int clusterHigh = 7;
final int masterPref = 0;
@@ -1620,7 +1658,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1686,6 +1725,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String ssi = "some much longer and more arbitrary data";
final byte subscribeId = 15;
final int requestorId = 22;
@@ -1712,7 +1752,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1755,6 +1796,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String ssi = "some much longer and more arbitrary data";
final byte subscribeId = 15;
final int requestorId = 22;
@@ -1781,7 +1823,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1880,6 +1923,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String ssi = "some much longer and more arbitrary data";
final byte subscribeId = 15;
final int requestorId = 22;
@@ -1907,7 +1951,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -1967,6 +2012,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String ssi = "some much longer and more arbitrary data";
final byte subscribeId = 15;
final int requestorId = 22;
@@ -1994,7 +2040,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -2054,6 +2101,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String serviceName = "some-service-name";
final byte subscribeId = 15;
final int requestorId = 22;
@@ -2082,7 +2130,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -2153,6 +2202,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int pid2 = 3000;
final String callingPackage1 = "com.google.somePackage1";
final String callingPackage2 = "com.google.somePackage2";
+ final String callingFeature = "com.google.someFeature";
final String serviceName1 = "some-service-name1";
final String serviceName2 = "some-service-name2";
final byte subscribeId1 = 15;
@@ -2194,7 +2244,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId1, uid1, pid1, callingPackage1, mockCallback, configRequest1, false);
+ mDut.connect(clientId1, uid1, pid1, callingPackage1, callingFeature, mockCallback,
+ configRequest1, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest1), eq(false), eq(true), eq(true), eq(false));
@@ -2202,7 +2253,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onConnectSuccess(clientId1);
- mDut.connect(clientId2, uid2, pid2, callingPackage2, mockCallback, configRequest2, false);
+ mDut.connect(clientId2, uid2, pid2, callingPackage2, callingFeature, mockCallback,
+ configRequest2, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onConnectSuccess(clientId2);
@@ -2298,6 +2350,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String serviceName = "some-service-name";
final byte subscribeId = 15;
final int requestorId = 22;
@@ -2326,7 +2379,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -2427,6 +2481,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final String serviceName = "some-service-name";
final String ssi = "some much longer and more arbitrary data";
final byte subscribeId = 15;
@@ -2458,7 +2513,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -2643,6 +2699,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int masterPref1 = 111;
final int masterPref3 = 115;
final int dwInterval1Band24 = 2;
@@ -2687,7 +2744,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) config1 (valid)
- mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest1, false);
+ mDut.connect(clientId1, uid, pid, callingPackage, callingFeature, mockCallback1,
+ configRequest1, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
crCapture.capture(), eq(false), eq(true), eq(true), eq(false));
@@ -2697,13 +2755,15 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
inOrder.verify(mockCallback1).onConnectSuccess(clientId1);
// (2) config2 (incompatible with config1)
- mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2, false);
+ mDut.connect(clientId2, uid, pid, callingPackage, callingFeature, mockCallback2,
+ configRequest2, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2).onConnectFail(NanStatusType.INTERNAL_FAILURE);
validateInternalClientInfoCleanedUp(clientId2);
// (3) config3 (compatible with config1)
- mDut.connect(clientId3, uid, pid, callingPackage, mockCallback3, configRequest3, true);
+ mDut.connect(clientId3, uid, pid, callingPackage, callingFeature, mockCallback3,
+ configRequest3, true);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
crCapture.capture(), eq(true), eq(false), eq(true), eq(false));
@@ -2758,6 +2818,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class);
IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class);
@@ -2773,7 +2834,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) attach w/o identity
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
any(ConfigRequest.class), eq(false), eq(true), eq(true), eq(false));
@@ -2783,13 +2845,15 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
// (2) attach w/o identity
++clientId;
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onConnectSuccess(clientId);
// (3) attach w/ identity
++clientId;
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, true);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, true);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
any(ConfigRequest.class), eq(true), eq(false), eq(true), eq(false));
@@ -2799,13 +2863,15 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
// (4) attach w/o identity
++clientId;
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onConnectSuccess(clientId);
// (5) attach w/ identity
++clientId;
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, true);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, true);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onConnectSuccess(clientId);
@@ -2821,6 +2887,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int clusterLow = 5;
final int clusterHigh = 100;
final int masterPref = 111;
@@ -2848,7 +2915,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -2897,6 +2965,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final int clusterLow = 15;
final int clusterHigh = 192;
final int masterPref = 234;
@@ -2923,7 +2992,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -2951,6 +3021,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -2967,7 +3038,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect (no response)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -2987,6 +3059,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -3001,7 +3074,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect and succeed
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -3037,6 +3111,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final byte publishId = 25;
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -3057,7 +3132,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(false), eq(true), eq(true), eq(false));
@@ -3092,6 +3168,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final byte subscribeId = 25;
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -3112,7 +3189,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -3146,6 +3224,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
int loopCount = 100;
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -3165,7 +3244,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -3202,6 +3282,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -3219,7 +3300,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -3263,6 +3345,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
setSettableParam(WifiAwareStateManager.PARAM_ON_IDLE_DISABLE_AWARE, Integer.toString(1),
true);
@@ -3284,7 +3367,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
inOrder.verify(mMockNativeManager).releaseAware();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNativeManager).tryToGetAware();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
@@ -3341,6 +3425,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -3359,7 +3444,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
inOrder.verify(mMockNativeManager).releaseAware();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNativeManager).tryToGetAware();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
@@ -3412,6 +3498,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
ConfigRequest configRequest = new ConfigRequest.Builder().build();
@@ -3430,7 +3517,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
inOrder.verify(mMockNativeManager).releaseAware();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNativeManager).tryToGetAware();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
@@ -3483,6 +3571,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
+ final String callingFeature = "com.google.someFeature";
final ConfigRequest configRequest = new ConfigRequest.Builder().build();
IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class);
@@ -3499,7 +3588,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
collector.checkThat("usage enabled", mDut.isUsageEnabled(), equalTo(true));
// (1) connect client
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
@@ -3514,7 +3604,8 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
validateCorrectAwareStatusChangeBroadcast(inOrder);
// (3) try reconnect client
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
+ mDut.connect(clientId, uid, pid, callingPackage, callingFeature, mockCallback,
+ configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(false), eq(true), eq(true), eq(false));
diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
index bc51b6d4b..e5d1c3e68 100644
--- a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.annotation.Nullable;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -234,15 +235,17 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
* Mock send WifiP2pManager.UPDATE_CHANNEL_INFO
*
* @param pkgName package name used for p2p channel init
+ * @param featureId The feature in the package
* @param binder client binder used for p2p channel init
* @param replyMessenger for checking replied message.
*/
- private void sendChannelInfoUpdateMsg(String pkgName, Binder binder,
- Messenger replyMessenger) throws Exception {
+ private void sendChannelInfoUpdateMsg(String pkgName, @Nullable String featureId,
+ Binder binder, Messenger replyMessenger) throws Exception {
Message msg = Message.obtain();
msg.what = WifiP2pManager.UPDATE_CHANNEL_INFO;
Bundle bundle = new Bundle();
bundle.putString(WifiP2pManager.CALLING_PACKAGE, pkgName);
+ bundle.putString(WifiP2pManager.CALLING_FEATURE_ID, featureId);
bundle.putBinder(WifiP2pManager.CALLING_BINDER, binder);
msg.obj = bundle;
msg.replyTo = replyMessenger;
@@ -879,7 +882,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddLocalServiceMsg(mClientMessenger);
assertTrue(mClientHandler.hasMessages(WifiP2pManager.ADD_LOCAL_SERVICE_FAILED));
verify(mWifiNative, never()).p2pServiceAdd(any());
@@ -894,13 +897,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
when(mWifiPermissionsUtil.checkCanAccessWifiDirect(
- anyString(), anyInt(), anyBoolean())).thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ anyString(), anyString(), anyInt(), anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddLocalServiceMsg(mClientMessenger);
assertTrue(mClientHandler.hasMessages(WifiP2pManager.ADD_LOCAL_SERVICE_FAILED));
verify(mWifiNative, never()).p2pServiceAdd(any());
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
}
/**
@@ -909,15 +912,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testAddLocalServiceSuccess() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pServiceAdd(any())).thenReturn(true);
sendAddLocalServiceMsg(mClientMessenger);
verify(mWifiNative).p2pServiceAdd(any());
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.ADD_LOCAL_SERVICE_SUCCEEDED));
}
@@ -927,15 +930,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testAddLocalServiceFailureWhenNativeCallFailure() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pServiceAdd(any())).thenReturn(false);
sendAddLocalServiceMsg(mClientMessenger);
verify(mWifiNative).p2pServiceAdd(any());
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.ADD_LOCAL_SERVICE_FAILED));
}
@@ -961,7 +964,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendConnectMsgWithConfigValidAsGroup(mClientMessenger);
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CONNECT_FAILED));
verify(mWifiNative, never()).p2pGroupAdd(any(), anyBoolean());
@@ -975,14 +978,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testConnectWithConfigValidAsGroupFailureWhenPermissionDenied() throws Exception {
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendConnectMsgWithConfigValidAsGroup(mClientMessenger);
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CONNECT_FAILED));
verify(mWifiNative, never()).p2pGroupAdd(any(), anyBoolean());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
}
/**
@@ -991,14 +994,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testConnectWithConfigValidAsGroupSuccess() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
when(mWifiNative.p2pGroupAdd(any(), eq(true))).thenReturn(true);
sendConnectMsgWithConfigValidAsGroup(mClientMessenger);
verify(mWifiNative).p2pGroupAdd(any(), eq(true));
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CONNECT_SUCCEEDED));
}
@@ -1008,14 +1011,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testConnectWithConfigValidAsGroupFailureWhenNativeCallFailure() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
when(mWifiNative.p2pGroupAdd(any(), eq(true))).thenReturn(false);
sendConnectMsgWithConfigValidAsGroup(mClientMessenger);
verify(mWifiNative).p2pGroupAdd(any(), eq(true));
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CONNECT_FAILED));
}
@@ -1043,7 +1046,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendCreateGroupMsgWithConfigValidAsGroup(mClientMessenger);
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CREATE_GROUP_FAILED));
verify(mWifiNative, never()).p2pGroupAdd(anyBoolean());
@@ -1059,15 +1062,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
throws Exception {
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendCreateGroupMsgWithConfigValidAsGroup(mClientMessenger);
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CREATE_GROUP_FAILED));
verify(mWifiNative, never()).p2pGroupAdd(anyBoolean());
verify(mWifiNative, never()).p2pGroupAdd(any(), anyBoolean());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
}
/**
@@ -1076,14 +1079,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testCreateGroupWithConfigValidAsGroupSuccess() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
when(mWifiNative.p2pGroupAdd(any(), eq(false))).thenReturn(true);
sendCreateGroupMsgWithConfigValidAsGroup(mClientMessenger);
verify(mWifiNative).p2pGroupAdd(any(), eq(false));
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CREATE_GROUP_SUCCEEDED));
}
@@ -1094,14 +1097,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testCreateGroupWithConfigValidAsGroupFailureWhenNativeCallFailure()
throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
when(mWifiNative.p2pGroupAdd(any(), eq(false))).thenReturn(false);
sendCreateGroupMsgWithConfigValidAsGroup(mClientMessenger);
verify(mWifiNative).p2pGroupAdd(any(), eq(false));
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.CREATE_GROUP_FAILED));
}
@@ -1126,7 +1129,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendDiscoverPeersMsg(mClientMessenger);
verify(mWifiNative, never()).p2pFind(anyInt());
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_PEERS_FAILED));
@@ -1140,13 +1143,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testDiscoverPeersFailureWhenPermissionDenied() throws Exception {
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendDiscoverPeersMsg(mClientMessenger);
verify(mWifiNative, never()).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_PEERS_FAILED));
}
@@ -1158,15 +1161,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testDiscoverPeersFailureWhenLocationModeDisabled() throws Exception {
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), eq(false)))
- .thenReturn(true);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), eq(true)))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ eq(false))).thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ eq(true))).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendDiscoverPeersMsg(mClientMessenger);
verify(mWifiNative, never()).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_PEERS_FAILED));
}
@@ -1176,14 +1179,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testDiscoverPeersSuccess() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pFind(anyInt())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendDiscoverPeersMsg(mClientMessenger);
verify(mWifiNative).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_PEERS_SUCCEEDED));
}
@@ -1193,14 +1196,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testDiscoverPeersFailureWhenNativeCallFailure() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pFind(anyInt())).thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendDiscoverPeersMsg(mClientMessenger);
verify(mWifiNative).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_PEERS_FAILED));
}
@@ -1230,7 +1233,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
sendDiscoverServiceMsg(mClientMessenger);
verify(mWifiNative, never()).p2pServDiscReq(anyString(), anyString());
@@ -1248,15 +1251,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
.thenReturn("mServiceDiscReqId");
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
sendDiscoverServiceMsg(mClientMessenger);
verify(mWifiNative, never()).p2pServDiscReq(anyString(), anyString());
verify(mWifiNative, never()).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_SERVICES_FAILED));
}
@@ -1270,17 +1273,17 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
.thenReturn("mServiceDiscReqId");
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), eq(false)))
- .thenReturn(true);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), eq(true)))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ eq(false))).thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ eq(true))).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
sendDiscoverServiceMsg(mClientMessenger);
verify(mWifiNative, never()).p2pServDiscReq(anyString(), anyString());
verify(mWifiNative, never()).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_SERVICES_FAILED));
}
@@ -1293,15 +1296,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
.thenReturn("mServiceDiscReqId");
when(mWifiNative.p2pFind(anyInt())).thenReturn(true);
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
sendDiscoverServiceMsg(mClientMessenger);
verify(mWifiNative).p2pServDiscReq(anyString(), anyString());
verify(mWifiNative).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_SERVICES_SUCCEEDED));
}
@@ -1312,15 +1315,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testDiscoverServicesFailureWhenAddServiceRequestFailure() throws Exception {
when(mWifiNative.p2pServDiscReq(anyString(), anyString())).thenReturn(null);
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
sendDiscoverServiceMsg(mClientMessenger);
verify(mWifiNative).p2pServDiscReq(anyString(), anyString());
verify(mWifiNative, never()).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_SERVICES_FAILED));
}
@@ -1333,15 +1336,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
.thenReturn("mServiceDiscReqId");
when(mWifiNative.p2pFind(anyInt())).thenReturn(false);
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
sendDiscoverServiceMsg(mClientMessenger);
verify(mWifiNative).p2pServDiscReq(anyString(), anyString());
verify(mWifiNative).p2pFind(anyInt());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
assertTrue(mClientHandler.hasMessages(WifiP2pManager.DISCOVER_SERVICES_FAILED));
}
@@ -1371,7 +1374,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
mockPeersList();
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestPeersMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
WifiP2pDeviceList peers = (WifiP2pDeviceList) mMessageCaptor.getValue().obj;
@@ -1388,13 +1391,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
mockPeersList();
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestPeersMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
WifiP2pDeviceList peers = (WifiP2pDeviceList) mMessageCaptor.getValue().obj;
assertEquals(WifiP2pManager.RESPONSE_PEERS, mMessageCaptor.getValue().what);
assertNull(peers.get(mTestWifiP2pDevice.deviceAddress));
@@ -1410,15 +1413,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
mockPeersList();
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), eq(false)))
- .thenReturn(true);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), eq(true)))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ eq(false))).thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ eq(true))).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestPeersMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
WifiP2pDeviceList peers = (WifiP2pDeviceList) mMessageCaptor.getValue().obj;
assertEquals(WifiP2pManager.RESPONSE_PEERS, mMessageCaptor.getValue().what);
assertNull(peers.get(mTestWifiP2pDevice.deviceAddress));
@@ -1433,13 +1436,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testRequestPeersSuccess() throws Exception {
forceP2pEnabled(mClient1);
mockPeersList();
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestPeersMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
WifiP2pDeviceList peers = (WifiP2pDeviceList) mMessageCaptor.getValue().obj;
assertEquals(WifiP2pManager.RESPONSE_PEERS, mMessageCaptor.getValue().what);
assertNotEquals(null, peers.get(mTestWifiP2pDevice.deviceAddress));
@@ -1469,7 +1472,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
sendGroupStartedMsg(mTestWifiP2pGroup);
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestGroupInfoMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
assertEquals(WifiP2pManager.RESPONSE_GROUP_INFO, mMessageCaptor.getValue().what);
@@ -1485,13 +1488,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestGroupInfoMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
assertEquals(WifiP2pManager.RESPONSE_GROUP_INFO, mMessageCaptor.getValue().what);
assertNull(mMessageCaptor.getValue().obj);
}
@@ -1506,13 +1509,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
when(mWifiPermissionsUtil.checkLocalMacAddressPermission(anyInt())).thenReturn(false);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestGroupInfoMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
assertEquals(WifiP2pManager.RESPONSE_GROUP_INFO, mMessageCaptor.getValue().what);
WifiP2pGroup wifiP2pGroup = (WifiP2pGroup) mMessageCaptor.getValue().obj;
assertEquals(mTestWifiP2pGroup.getNetworkName(), wifiP2pGroup.getNetworkName());
@@ -1530,13 +1533,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
when(mWifiPermissionsUtil.checkLocalMacAddressPermission(anyInt())).thenReturn(true);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendRequestGroupInfoMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
assertEquals(WifiP2pManager.RESPONSE_GROUP_INFO, mMessageCaptor.getValue().what);
WifiP2pGroup wifiP2pGroup = (WifiP2pGroup) mMessageCaptor.getValue().obj;
assertEquals(thisDeviceMac, wifiP2pGroup.getOwner().deviceAddress);
@@ -1694,14 +1697,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testPeerScanMetricWhenSendDiscoverPeers() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pFind(anyInt())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendDiscoverPeersMsg(mClientMessenger);
verify(mWifiP2pMetrics).incrementPeerScans();
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
}
/**
@@ -1714,14 +1717,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
.thenReturn("mServiceDiscReqId");
when(mWifiNative.p2pFind(anyInt())).thenReturn(true);
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
sendDiscoverServiceMsg(mClientMessenger);
verify(mWifiP2pMetrics).incrementServiceScans();
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(true));
}
/**
@@ -1731,7 +1734,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testPersistentGroupMetricWhenSendFactoryReset() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
// permissions for factory reset
when(mWifiPermissionsUtil.checkNetworkSettingsPermission(anyInt()))
@@ -1760,7 +1763,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testPersistentGroupMetricWhenSendP2pGroupStartedEvent() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
ArgumentCaptor<WifiP2pGroupList> groupsCaptor =
ArgumentCaptor.forClass(WifiP2pGroupList.class);
@@ -1781,7 +1784,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testPersistentGroupMetricWhenSendDeletePersistentGroup() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
ArgumentCaptor<WifiP2pGroupList> groupsCaptor =
ArgumentCaptor.forClass(WifiP2pGroupList.class);
@@ -1801,7 +1804,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testGroupEventMetric() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendGroupStartedMsg(mTestWifiP2pNewPersistentGoGroup);
@@ -1821,14 +1824,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testStartFreshConnectionEventWhenSendConnect() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
mockPeersList();
sendConnectMsg(mClientMessenger, mTestWifiP2pPeerConfig);
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
ArgumentCaptor<WifiP2pConfig> configCaptor =
ArgumentCaptor.forClass(WifiP2pConfig.class);
@@ -1844,19 +1847,19 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testStartReinvokeConnectionEventWhenSendConnect() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pGroupAdd(anyInt()))
.thenReturn(true);
when(mTestWifiP2pDevice.isGroupOwner()).thenReturn(true);
when(mWifiNative.p2pGetSsid(eq(mTestWifiP2pDevice.deviceAddress)))
.thenReturn(mTestWifiP2pGroup.getNetworkName());
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
mockPeersList();
sendConnectMsg(mClientMessenger, mTestWifiP2pPeerConfig);
verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ .checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"), anyInt(), eq(false));
ArgumentCaptor<WifiP2pConfig> configCaptor =
ArgumentCaptor.forClass(WifiP2pConfig.class);
@@ -1877,13 +1880,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testStartReinvokeConnectionEventWhenCreateGroup()
throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendCreateGroupMsg(mClientMessenger, WifiP2pGroup.PERSISTENT_NET_ID, null);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
verify(mWifiP2pMetrics).startConnectionEvent(
eq(P2pConnectionEvent.CONNECTION_REINVOKE),
@@ -1897,9 +1900,9 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testStartLocalConnectionWhenCreateGroup() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
// permissions for factory reset
when(mWifiPermissionsUtil.checkNetworkSettingsPermission(anyInt()))
@@ -1914,8 +1917,8 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
sendSimpleMsg(mClientMessenger, WifiP2pManager.FACTORY_RESET);
sendCreateGroupMsg(mClientMessenger, WifiP2pGroup.PERSISTENT_NET_ID, null);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
verify(mWifiP2pMetrics).startConnectionEvent(
eq(P2pConnectionEvent.CONNECTION_LOCAL),
@@ -1929,13 +1932,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testStartLocalConnectionEventWhenCreateTemporaryGroup() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendCreateGroupMsg(mClientMessenger, WifiP2pGroup.TEMPORARY_NET_ID, null);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
verify(mWifiP2pMetrics).startConnectionEvent(
eq(P2pConnectionEvent.CONNECTION_LOCAL),
@@ -1950,14 +1953,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testStartFastConnectionEventWhenSendConnectWithConfig()
throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pGroupAdd(any(), eq(true))).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendConnectMsg(mClientMessenger, mTestWifiP2pFastConnectionConfig);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
ArgumentCaptor<WifiP2pConfig> configCaptor =
ArgumentCaptor.forClass(WifiP2pConfig.class);
@@ -1976,13 +1979,13 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testStartFastConnectionEventWhenCreateGroupWithConfig()
throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendCreateGroupMsg(mClientMessenger, 0, mTestWifiP2pFastConnectionConfig);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
ArgumentCaptor<WifiP2pConfig> configCaptor =
ArgumentCaptor.forClass(WifiP2pConfig.class);
@@ -1999,7 +2002,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testEndConnectionEventWhenGroupFormed() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
WifiP2pGroup group = new WifiP2pGroup();
group.setNetworkId(WifiP2pGroup.PERSISTENT_NET_ID);
@@ -2017,14 +2020,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testEndConnectionEventWhenTimeout() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pGroupAdd(anyBoolean())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
mockEnterGroupNegotiationState();
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
mLooper.moveTimeForward(120 * 1000 * 2);
mLooper.dispatchAll();
@@ -2039,14 +2042,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testEndConnectionEventWhenCancel() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pGroupAdd(anyBoolean())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
mockEnterGroupNegotiationState();
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
sendSimpleMsg(mClientMessenger, WifiP2pManager.CANCEL_CONNECT);
@@ -2060,14 +2063,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testEndConnectionEventWhenProvDiscFailure() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pGroupAdd(anyBoolean())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
mockEnterProvisionDiscoveryState();
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
sendSimpleMsg(null, WifiP2pMonitor.P2P_PROV_DISC_FAILURE_EVENT);
@@ -2081,14 +2084,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testEndConnectionEventWhenGroupRemoval() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pGroupAdd(anyBoolean())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
mockEnterGroupNegotiationState();
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
sendSimpleMsg(null, WifiP2pMonitor.P2P_GROUP_REMOVED_EVENT);
@@ -2102,14 +2105,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testEndConnectionEventWhenInvitationFailure() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
when(mWifiNative.p2pGroupAdd(anyBoolean())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
mockEnterGroupNegotiationState();
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
sendInvitationResultMsg(WifiP2pServiceImpl.P2pStatus.UNKNOWN);
@@ -2125,12 +2128,12 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testRequestDeviceInfoFailureWhenPermissionDenied() throws Exception {
forceP2pEnabled(mClient1);
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(false);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(false);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendSimpleMsg(mClientMessenger, WifiP2pManager.REQUEST_DEVICE_INFO);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
assertEquals(WifiP2pManager.RESPONSE_DEVICE_INFO, mMessageCaptor.getValue().what);
assertNull(mMessageCaptor.getValue().obj);
@@ -2143,12 +2146,12 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testRequestDeviceInfoSuccessWhenP2pEnabled() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendSimpleMsg(mClientMessenger, WifiP2pManager.REQUEST_DEVICE_INFO);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
assertEquals(WifiP2pManager.RESPONSE_DEVICE_INFO, mMessageCaptor.getValue().what);
WifiP2pDevice wifiP2pDevice = (WifiP2pDevice) mMessageCaptor.getValue().obj;
@@ -2162,12 +2165,12 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
*/
@Test
public void testRequestDeviceInfoReturnEmptyWifiP2pDeviceWhenP2pDisabled() throws Exception {
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendSimpleMsg(mClientMessenger, WifiP2pManager.REQUEST_DEVICE_INFO);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
assertEquals(WifiP2pManager.RESPONSE_DEVICE_INFO, mMessageCaptor.getValue().what);
WifiP2pDevice wifiP2pDevice = (WifiP2pDevice) mMessageCaptor.getValue().obj;
@@ -2183,12 +2186,12 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testRequestDeviceInfoReturnsActualMacForNetworkSettingsApp() throws Exception {
forceP2pEnabled(mClient1);
when(mWifiPermissionsUtil.checkLocalMacAddressPermission(anyInt())).thenReturn(true);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyInt(), anyBoolean()))
- .thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
+ anyBoolean())).thenReturn(true);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendSimpleMsg(mClientMessenger, WifiP2pManager.REQUEST_DEVICE_INFO);
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(false));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(false));
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
assertEquals(WifiP2pManager.RESPONSE_DEVICE_INFO, mMessageCaptor.getValue().what);
WifiP2pDevice wifiP2pDevice = (WifiP2pDevice) mMessageCaptor.getValue().obj;
@@ -3426,14 +3429,14 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testRequestDiscoveryStateWhenStarted() throws Exception {
forceP2pEnabled(mClient1);
- when(mWifiPermissionsUtil.checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), anyBoolean()))
- .thenReturn(true);
+ when(mWifiPermissionsUtil.checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), anyBoolean())).thenReturn(true);
when(mWifiNative.p2pFind(anyInt())).thenReturn(true);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendDiscoverPeersMsg(mClientMessenger);
verify(mWifiNative).p2pFind(anyInt());
- verify(mWifiPermissionsUtil)
- .checkCanAccessWifiDirect(eq("testPkg1"), anyInt(), eq(true));
+ verify(mWifiPermissionsUtil).checkCanAccessWifiDirect(eq("testPkg1"), eq("testFeature"),
+ anyInt(), eq(true));
sendSimpleMsg(mClientMessenger, WifiP2pManager.REQUEST_DISCOVERY_STATE);
@@ -3619,7 +3622,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Test
public void testAddServiceRequestSuccessWithoutServiceDiscover() throws Exception {
forceP2pEnabled(mClient1);
- sendChannelInfoUpdateMsg("testPkg1", mClient1, mClientMessenger);
+ sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendAddServiceRequestMsg(mClientMessenger);
diff --git a/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
index 76f8b0f63..a355540ff 100644
--- a/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
@@ -29,6 +29,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
@@ -110,6 +111,7 @@ public class RttServiceImplTest extends WifiBaseTest {
private BroadcastReceiver mLocationModeReceiver;
private final String mPackageName = "some.package.name.for.rtt.app";
+ private final String mFeatureId = "some.feature.name.for.rtt.app";
private int mDefaultUid = 1500;
private WorkSource mDefaultWs = new WorkSource(mDefaultUid);
@@ -205,8 +207,8 @@ public class RttServiceImplTest extends WifiBaseTest {
when(mockActivityManager.getUidImportance(anyInt())).thenReturn(
ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE);
- when(mockPermissionUtil.checkCallersLocationPermission(eq(mPackageName),
- anyInt(), anyBoolean())).thenReturn(true);
+ when(mockPermissionUtil.checkCallersLocationPermission(eq(mPackageName), eq(mFeatureId),
+ anyInt(), anyBoolean(), nullable(String.class))).thenReturn(true);
when(mockPermissionUtil.isLocationModeEnabled()).thenReturn(true);
when(mockNative.isReady()).thenReturn(true);
when(mockNative.rangeRequest(anyInt(), any(RangingRequest.class), anyBoolean())).thenReturn(
@@ -265,7 +267,8 @@ public class RttServiceImplTest extends WifiBaseTest {
// (1) request 10 ranging operations
for (int i = 0; i < numIter; ++i) {
- mDut.startRanging(mockIbinder, mPackageName, null, requests[i], mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, requests[i],
+ mockCallback);
}
mMockLooper.dispatchAll();
@@ -324,7 +327,7 @@ public class RttServiceImplTest extends WifiBaseTest {
doAnswer(answer).when(mockAwareManagerBinder).requestMacAddresses(anyInt(), any(), any());
// issue request
- mDut.startRanging(mockIbinder, mPackageName, null, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback);
mMockLooper.dispatchAll();
// verify that requested with MAC address translated from the PeerHandle issued to Native
@@ -386,13 +389,14 @@ public class RttServiceImplTest extends WifiBaseTest {
// (1) request 10 ranging operations: fail the first one
when(mockNative.rangeRequest(anyInt(), any(RangingRequest.class), anyBoolean())).thenReturn(
false);
- mDut.startRanging(mockIbinder, mPackageName, null, requests[0], mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, requests[0], mockCallback);
mMockLooper.dispatchAll();
when(mockNative.rangeRequest(anyInt(), any(RangingRequest.class), anyBoolean())).thenReturn(
true);
for (int i = 1; i < numIter; ++i) {
- mDut.startRanging(mockIbinder, mPackageName, null, requests[i], mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, requests[i],
+ mockCallback);
}
mMockLooper.dispatchAll();
@@ -444,7 +448,7 @@ public class RttServiceImplTest extends WifiBaseTest {
RttTestUtils.getDummyRangingResults(request);
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, null, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback);
mMockLooper.dispatchAll();
// (2) verify that request issued to native
@@ -452,8 +456,8 @@ public class RttServiceImplTest extends WifiBaseTest {
verifyWakeupSet(true, 0);
// (3) native calls back with result - should get a FAILED callback
- when(mockPermissionUtil.checkCallersLocationPermission(eq(mPackageName),
- anyInt(), anyBoolean())).thenReturn(false);
+ when(mockPermissionUtil.checkCallersLocationPermission(eq(mPackageName), eq(mFeatureId),
+ anyInt(), anyBoolean(), nullable(String.class))).thenReturn(false);
mDut.onRangingResults(mIntCaptor.getValue(), results.second);
mMockLooper.dispatchAll();
@@ -489,7 +493,8 @@ public class RttServiceImplTest extends WifiBaseTest {
// (1) request 10 ranging operations: even/odd with different UIDs
for (int i = 0; i < numIter; ++i) {
mDut.fakeUid = mDefaultUid + i % 2;
- mDut.startRanging(mockIbinder, mPackageName, null, requests[i], mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, requests[i],
+ mockCallback);
}
mMockLooper.dispatchAll();
@@ -564,7 +569,7 @@ public class RttServiceImplTest extends WifiBaseTest {
RttTestUtils.getDummyRangingResults(request);
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, ws, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, ws, request, mockCallback);
mMockLooper.dispatchAll();
verify(mockIbinder).linkToDeath(mDeathRecipientCaptor.capture(), anyInt());
@@ -614,7 +619,8 @@ public class RttServiceImplTest extends WifiBaseTest {
RttTestUtils.getDummyRangingResults(request);
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, worksourceRequest, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, worksourceRequest, request,
+ mockCallback);
mMockLooper.dispatchAll();
// (2) verify that request issued to native
@@ -660,7 +666,8 @@ public class RttServiceImplTest extends WifiBaseTest {
RttTestUtils.getDummyRangingResults(request);
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, worksourceRequest, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, worksourceRequest, request,
+ mockCallback);
mMockLooper.dispatchAll();
// (2) verify that request issued to native
@@ -698,7 +705,7 @@ public class RttServiceImplTest extends WifiBaseTest {
RttTestUtils.getDummyRangingResults(request);
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, null, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback);
mMockLooper.dispatchAll();
// (2) verify that request issued to native
@@ -749,7 +756,7 @@ public class RttServiceImplTest extends WifiBaseTest {
null, null, null, 0));
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, null, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback);
mMockLooper.dispatchAll();
// (2) verify that request issued to native
@@ -792,7 +799,7 @@ public class RttServiceImplTest extends WifiBaseTest {
}
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, null, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback);
mMockLooper.dispatchAll();
// (2) verify that request issued to native
@@ -845,7 +852,7 @@ public class RttServiceImplTest extends WifiBaseTest {
PackageManager.PERMISSION_DENIED);
// (1) request ranging operation
- mDut.startRanging(mockIbinder, mPackageName, null, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback);
mMockLooper.dispatchAll();
// (2) verify that request issued to native
@@ -885,8 +892,8 @@ public class RttServiceImplTest extends WifiBaseTest {
RttTestUtils.getDummyRangingResults(request2);
// (1) request 2 ranging operation
- mDut.startRanging(mockIbinder, mPackageName, null, request1, mockCallback);
- mDut.startRanging(mockIbinder, mPackageName, null, request2, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request1, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request2, mockCallback);
mMockLooper.dispatchAll();
// verify that request 1 issued to native
@@ -957,7 +964,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// (1) issue a request at time t1: should be dispatched since first one!
clock.time = 100;
- mDut.startRanging(mockIbinder, mPackageName, null, request1, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request1, mockCallback);
mMockLooper.dispatchAll();
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request1), eq(true));
@@ -972,14 +979,14 @@ public class RttServiceImplTest extends WifiBaseTest {
// (2) issue a request at time t2 = t1 + 0.5 gap: should be rejected (throttled)
clock.time = 100 + BACKGROUND_PROCESS_EXEC_GAP_MS / 2;
- mDut.startRanging(mockIbinder, mPackageName, null, request2, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request2, mockCallback);
mMockLooper.dispatchAll();
cbInorder.verify(mockCallback).onRangingFailure(RangingResultCallback.STATUS_CODE_FAIL);
// (3) issue a request at time t3 = t1 + 1.1 gap: should be dispatched since enough time
clock.time = 100 + BACKGROUND_PROCESS_EXEC_GAP_MS * 11 / 10;
- mDut.startRanging(mockIbinder, mPackageName, null, request3, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request3, mockCallback);
mMockLooper.dispatchAll();
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request3), eq(true));
@@ -997,7 +1004,7 @@ public class RttServiceImplTest extends WifiBaseTest {
ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND);
clock.time = clock.time + 5;
- mDut.startRanging(mockIbinder, mPackageName, null, request4, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request4, mockCallback);
mMockLooper.dispatchAll();
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request4), eq(true));
@@ -1015,7 +1022,7 @@ public class RttServiceImplTest extends WifiBaseTest {
ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE);
clock.time = clock.time + 5;
- mDut.startRanging(mockIbinder, mPackageName, null, request5, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request5, mockCallback);
mMockLooper.dispatchAll();
cbInorder.verify(mockCallback).onRangingFailure(RangingResultCallback.STATUS_CODE_FAIL);
@@ -1088,7 +1095,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// (1) issue a request at time t1 for {10}: should be dispatched since first one!
clock.time = 100;
- mDut.startRanging(mockIbinder, mPackageName, wsReq1, request1, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, wsReq1, request1, mockCallback);
mMockLooper.dispatchAll();
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request1), eq(true));
@@ -1104,7 +1111,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// (2) issue a request at time t2 = t1 + 0.5 gap for {10,20}: should be dispatched since
// uid=20 should not be throttled
clock.time = 100 + BACKGROUND_PROCESS_EXEC_GAP_MS / 2;
- mDut.startRanging(mockIbinder, mPackageName, wsReq2, request2, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, wsReq2, request2, mockCallback);
mMockLooper.dispatchAll();
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request2), eq(true));
@@ -1119,7 +1126,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// (3) issue a request at t3 = t1 + 1.1 * gap for {10}: should be rejected (throttled)
clock.time = 100 + BACKGROUND_PROCESS_EXEC_GAP_MS * 11 / 10;
- mDut.startRanging(mockIbinder, mPackageName, wsReq1, request3, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, wsReq1, request3, mockCallback);
mMockLooper.dispatchAll();
cbInorder.verify(mockCallback).onRangingFailure(RangingResultCallback.STATUS_CODE_FAIL);
@@ -1173,7 +1180,7 @@ public class RttServiceImplTest extends WifiBaseTest {
WorkSource ws = new WorkSource(10);
// 1. issue a request
- mDut.startRanging(mockIbinder, mPackageName, ws, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, ws, request, mockCallback);
mMockLooper.dispatchAll();
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request), eq(true));
@@ -1183,7 +1190,8 @@ public class RttServiceImplTest extends WifiBaseTest {
for (int i = 0; i < RttServiceImpl.MAX_QUEUED_PER_UID + 10; ++i) {
WorkSource wsExtra = new WorkSource(ws);
wsExtra.add(11 + i);
- mDut.startRanging(mockIbinder, mPackageName, wsExtra, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, wsExtra, request,
+ mockCallback);
}
mMockLooper.dispatchAll();
@@ -1239,7 +1247,8 @@ public class RttServiceImplTest extends WifiBaseTest {
InOrder nativeInorder = inOrder(mockNative);
// 1. issue a request
- mDut.startRanging(mockIbinder, mPackageName, useUids ? null : ws, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, useUids ? null : ws, request,
+ mockCallback);
mMockLooper.dispatchAll();
nativeInorder.verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request), eq(true));
@@ -1247,7 +1256,7 @@ public class RttServiceImplTest extends WifiBaseTest {
// 2. issue FLOOD LEVEL requests + 10: should get 11 failures (10 extra + 1 original)
for (int i = 0; i < RttServiceImpl.MAX_QUEUED_PER_UID + 10; ++i) {
- mDut.startRanging(mockIbinder, mPackageName, useUids ? null : ws, request,
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, useUids ? null : ws, request,
mockCallback);
}
mMockLooper.dispatchAll();
@@ -1266,7 +1275,8 @@ public class RttServiceImplTest extends WifiBaseTest {
verifyWakeupSet(true, 0);
// 4. issue a request: don't expect a failure
- mDut.startRanging(mockIbinder, mPackageName, useUids ? null : ws, request, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, useUids ? null : ws, request,
+ mockCallback);
mMockLooper.dispatchAll();
// 5. clear queue
@@ -1338,8 +1348,8 @@ public class RttServiceImplTest extends WifiBaseTest {
IRttCallback mockCallback3 = mock(IRttCallback.class);
// (1) request 2 ranging operations: request 1 should be sent to HAL
- mDut.startRanging(mockIbinder, mPackageName, null, request1, mockCallback);
- mDut.startRanging(mockIbinder, mPackageName, null, request2, mockCallback2);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request1, mockCallback);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request2, mockCallback2);
mMockLooper.dispatchAll();
verify(mockNative).rangeRequest(mIntCaptor.capture(), eq(request1), eq(true));
@@ -1367,7 +1377,7 @@ public class RttServiceImplTest extends WifiBaseTest {
verifyWakeupCancelled();
// (3) issue another request: it should fail
- mDut.startRanging(mockIbinder, mPackageName, null, request3, mockCallback3);
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request3, mockCallback3);
mMockLooper.dispatchAll();
verify(mockCallback3).onRangingFailure(
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
index 397c61d2d..666028a98 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -29,8 +29,7 @@ import static com.android.server.wifi.ScanTestUtil.channelsToSpec;
import static com.android.server.wifi.ScanTestUtil.computeSingleScanNativeSettings;
import static com.android.server.wifi.ScanTestUtil.createRequest;
import static com.android.server.wifi.ScanTestUtil.createSingleScanNativeSettingsForChannels;
-import static com.android.server.wifi.scanner.WifiScanningServiceImpl.WifiSingleScanStateMachine
- .CACHED_SCAN_RESULTS_MAX_AGE_IN_MILLIS;
+import static com.android.server.wifi.scanner.WifiScanningServiceImpl.WifiSingleScanStateMachine.CACHED_SCAN_RESULTS_MAX_AGE_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -122,6 +121,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
private static final int TEST_MAX_SCAN_BUCKETS_IN_CAPABILITIES = 8;
private static final String TEST_PACKAGE_NAME = "com.test.123";
+ private static final String TEST_FEATURE_ID = "test.feature";
private static final String TEST_IFACE_NAME_0 = "wlan0";
private static final String TEST_IFACE_NAME_1 = "wlan1";
private static final WifiScanner.ScanData DUMMY_SCAN_DATA =
@@ -2690,7 +2690,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Location permission or mode check fail.
doThrow(new SecurityException()).when(mWifiPermissionsUtil)
- .enforceCanAccessScanResultsForWifiScanner(any(), eq(Binder.getCallingUid()),
+ .enforceCanAccessScanResultsForWifiScanner(any(), any(), eq(Binder.getCallingUid()),
eq(false), eq(false));
Handler handler = mock(Handler.class);
@@ -2751,6 +2751,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
+ bundle.putString(WifiScanner.REQUEST_FEATURE_ID_KEY, TEST_FEATURE_ID);
WifiScanner.ScanSettings scanSettings = new WifiScanner.ScanSettings();
// send single scan request (ignoreLocationSettings == true).
@@ -2764,7 +2765,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Verify the permission check params (ignoreLocationSettings == true).
verify(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- eq(TEST_PACKAGE_NAME), eq(Binder.getCallingUid()), eq(true), eq(false));
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), eq(Binder.getCallingUid()), eq(true),
+ eq(false));
// send single scan request (ignoreLocationSettings == false).
scanSettings.ignoreLocationSettings = false;
@@ -2777,7 +2779,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Verify the permission check params (ignoreLocationSettings == true).
verify(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- eq(TEST_PACKAGE_NAME), eq(Binder.getCallingUid()), eq(false), eq(false));
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), eq(Binder.getCallingUid()), eq(false),
+ eq(false));
// send background scan request (ignoreLocationSettings == true).
scanSettings.ignoreLocationSettings = true;
@@ -2790,7 +2793,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Verify the permission check params (ignoreLocationSettings == false), the field
// is ignored for any requests other than single scan.
verify(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- eq(TEST_PACKAGE_NAME), eq(Binder.getCallingUid()), eq(false), eq(false));
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), eq(Binder.getCallingUid()), eq(false),
+ eq(false));
}
/**
@@ -2815,6 +2819,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
+ bundle.putString(WifiScanner.REQUEST_FEATURE_ID_KEY, TEST_FEATURE_ID);
WifiScanner.ScanSettings scanSettings = new WifiScanner.ScanSettings();
// send single scan request (hideFromAppOps == true).
@@ -2828,7 +2833,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Verify the permission check params (hideFromAppOps == true).
verify(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- eq(TEST_PACKAGE_NAME), eq(Binder.getCallingUid()), eq(false), eq(true));
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), eq(Binder.getCallingUid()), eq(false),
+ eq(true));
// send single scan request (hideFromAppOps == false).
scanSettings.hideFromAppOps = false;
@@ -2841,7 +2847,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Verify the permission check params (hideFromAppOps == false).
verify(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- eq(TEST_PACKAGE_NAME), eq(Binder.getCallingUid()), eq(false), eq(false));
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), eq(Binder.getCallingUid()), eq(false),
+ eq(false));
// send background scan request (hideFromAppOps == true).
scanSettings.hideFromAppOps = true;
@@ -2854,7 +2861,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Verify the permission check params (hideFromAppOps == false), the field
// is ignored for any requests other than single scan.
verify(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- eq(TEST_PACKAGE_NAME), eq(Binder.getCallingUid()), eq(false), eq(false));
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), eq(Binder.getCallingUid()), eq(false),
+ eq(false));
}
/**
@@ -2878,6 +2886,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
+ bundle.putString(WifiScanner.REQUEST_FEATURE_ID_KEY, TEST_FEATURE_ID);
WifiScanner.ScanSettings scanSettings = new WifiScanner.ScanSettings();
// send single scan request (hideFromAppOps == true, ignoreLocationSettings = true).
@@ -2892,7 +2901,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Verify that we didn't invoke the location permission check.
verify(mWifiPermissionsUtil, never()).enforceCanAccessScanResultsForWifiScanner(
- eq(TEST_PACKAGE_NAME), eq(Binder.getCallingUid()), anyBoolean(), anyBoolean());
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), eq(Binder.getCallingUid()),
+ anyBoolean(), anyBoolean());
}
/**
@@ -3508,10 +3518,10 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Location permission or mode check fail.
doThrow(new SecurityException())
.when(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- TEST_PACKAGE_NAME, Binder.getCallingUid(), false, false);
+ TEST_PACKAGE_NAME, TEST_FEATURE_ID, Binder.getCallingUid(), false, false);
mWifiScanningServiceImpl.getAvailableChannels(WifiScanner.WIFI_BAND_24_GHZ,
- TEST_PACKAGE_NAME);
+ TEST_PACKAGE_NAME, TEST_FEATURE_ID);
}
/**
@@ -3529,10 +3539,10 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// has access scan results permission
doNothing().when(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(
- TEST_PACKAGE_NAME, Binder.getCallingUid(), false, false);
+ TEST_PACKAGE_NAME, TEST_FEATURE_ID, Binder.getCallingUid(), false, false);
Bundle bundle = mWifiScanningServiceImpl.getAvailableChannels(
- WifiScanner.WIFI_BAND_24_GHZ, TEST_PACKAGE_NAME);
+ WifiScanner.WIFI_BAND_24_GHZ, TEST_PACKAGE_NAME, TEST_FEATURE_ID);
List<Integer> actual = bundle.getIntegerArrayList(GET_AVAILABLE_CHANNELS_EXTRA);
List<Integer> expected = Arrays.asList(2400, 2450);
diff --git a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
index 8e3c1bb71..9bd3fe6f6 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
@@ -83,6 +84,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
private static final String TEST_WIFI_STACK_APK_NAME = "com.android.wifi";
private static final String TEST_PACKAGE_NAME = "com.google.somePackage";
+ private static final String TEST_FEATURE_ID = "com.google.someFeature";
private static final String INVALID_PACKAGE = "BAD_PACKAGE";
private static final int MANAGED_PROFILE_UID = 1100000;
private static final int OTHER_USER_UID = 1200000;
@@ -177,7 +179,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -199,7 +201,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -216,7 +218,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -243,7 +246,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -264,7 +267,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -288,7 +292,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -314,7 +319,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -335,7 +340,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -363,7 +369,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -395,7 +402,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -428,7 +436,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -464,7 +473,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -499,7 +509,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -532,7 +542,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -567,7 +578,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -599,7 +610,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -631,7 +642,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -663,7 +674,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid, null);
}
/**
@@ -676,7 +687,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceCanAccessScanResults(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid,
+ null);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -698,7 +710,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid);
// verify that checking FINE for legacy apps!
verify(mMockAppOps).noteOp(eq(AppOpsManager.OPSTR_FINE_LOCATION), anyInt(), anyString(),
@@ -721,7 +733,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid);
verify(mMockAppOps)
.noteOp(eq(AppOpsManager.OPSTR_FINE_LOCATION), anyInt(), anyString(), any(), any());
}
@@ -745,7 +757,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid);
fail("Expected SecurityException not thrown");
} catch (SecurityException e) {
// empty
@@ -937,7 +949,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, mUid);
+ codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, TEST_FEATURE_ID, mUid);
}
/**
@@ -960,13 +972,13 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ mUid, CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
verify(mMockAppOps, never())
.unsafeCheckOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME);
- verify(mMockAppOps)
- .noteOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null, null);
+ verify(mMockAppOps).noteOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, null);
}
/**
@@ -990,8 +1002,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- IGNORE_LOCATION_SETTINGS, HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ mUid, IGNORE_LOCATION_SETTINGS, HIDE_FROM_APP_OPS);
verify(mMockAppOps).unsafeCheckOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid,
TEST_PACKAGE_NAME);
@@ -1022,8 +1034,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, mUid, CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -1050,8 +1062,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, mUid, CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -1079,8 +1091,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, mUid, CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -1107,8 +1119,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, mUid, CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -1135,8 +1147,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, mUid, CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -1163,8 +1175,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
setupTestCase();
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- IGNORE_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, TEST_FEATURE_ID,
+ mUid, IGNORE_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
}
/**
@@ -1188,8 +1200,8 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper,
mMockContext, mMockUserManager, mWifiInjector);
try {
- codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME, mUid,
- CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
+ codeUnderTest.enforceCanAccessScanResultsForWifiScanner(TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, mUid, CHECK_LOCATION_SETTINGS, DONT_HIDE_FROM_APP_OPS);
fail("Expected SecurityException is not thrown");
} catch (SecurityException e) {
}
@@ -1217,12 +1229,14 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
when(mMockPkgMgr.getApplicationInfoAsUser(eq(TEST_PACKAGE_NAME), eq(0), any()))
.thenReturn(mMockApplInfo);
when(mMockContext.getPackageManager()).thenReturn(mMockPkgMgr);
- when(mMockAppOps.noteOp(AppOpsManager.OPSTR_WIFI_SCAN, mUid, TEST_PACKAGE_NAME, null, null))
- .thenReturn(mWifiScanAllowApps);
- when(mMockAppOps.noteOp(AppOpsManager.OPSTR_COARSE_LOCATION, mUid, TEST_PACKAGE_NAME, null,
- null)).thenReturn(mAllowCoarseLocationApps);
- when(mMockAppOps.noteOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null,
- null)).thenReturn(mAllowFineLocationApps);
+ when(mMockAppOps.noteOp(AppOpsManager.OPSTR_WIFI_SCAN, mUid, TEST_PACKAGE_NAME,
+ TEST_FEATURE_ID, null)).thenReturn(mWifiScanAllowApps);
+ when(mMockAppOps.noteOp(eq(AppOpsManager.OPSTR_COARSE_LOCATION), eq(mUid),
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), nullable(String.class)))
+ .thenReturn(mAllowCoarseLocationApps);
+ when(mMockAppOps.noteOp(eq(AppOpsManager.OPSTR_FINE_LOCATION), eq(mUid),
+ eq(TEST_PACKAGE_NAME), eq(TEST_FEATURE_ID), nullable(String.class)))
+ .thenReturn(mAllowFineLocationApps);
when(mMockAppOps.unsafeCheckOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME))
.thenReturn(mAllowFineLocationApps);
if (mThrowSecurityException) {