Merge "Scan Optimization: Check set device mobility permission is granted to <= 1 app"
This commit is contained in:
@@ -58,6 +58,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WifiManagerTest extends AndroidTestCase {
|
||||
private static class MySync {
|
||||
@@ -998,6 +999,30 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the {@link android.Manifest.permission#WIFI_SET_DEVICE_MOBILITY_STATE} permission
|
||||
* is held by at most one application.
|
||||
*/
|
||||
public void testWifiSetDeviceMobilityStatePermission() {
|
||||
final PackageManager pm = getContext().getPackageManager();
|
||||
|
||||
final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
|
||||
android.Manifest.permission.WIFI_SET_DEVICE_MOBILITY_STATE
|
||||
}, PackageManager.MATCH_UNINSTALLED_PACKAGES);
|
||||
|
||||
List<String> uniquePackageNames = holding
|
||||
.stream()
|
||||
.map(pi -> pi.packageName)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (uniquePackageNames.size() > 1) {
|
||||
fail("The WIFI_SET_DEVICE_MOBILITY_STATE permission must not be held by more than one "
|
||||
+ "application, but is held by " + uniquePackageNames.size() + " applications: "
|
||||
+ String.join(", ", uniquePackageNames));
|
||||
}
|
||||
}
|
||||
|
||||
private void turnScreenOnNoDelay() throws Exception {
|
||||
mUiDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP");
|
||||
mUiDevice.executeShellCommand("wm dismiss-keyguard");
|
||||
|
||||
Reference in New Issue
Block a user