Merge "WifiManagerTest: Test for new privileged permission"
This commit is contained in:
@@ -881,6 +881,30 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the {@link android.Manifest.permission#NETWORK_CARRIER_PROVISIONING} permission
|
||||
* is held by at most one application.
|
||||
*/
|
||||
public void testNetworkCarrierProvisioningPermission() {
|
||||
final PackageManager pm = getContext().getPackageManager();
|
||||
|
||||
final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
|
||||
android.Manifest.permission.NETWORK_CARRIER_PROVISIONING
|
||||
}, PackageManager.MATCH_UNINSTALLED_PACKAGES);
|
||||
|
||||
List<String> uniquePackageNames = holding
|
||||
.stream()
|
||||
.map(pi -> pi.packageName)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (uniquePackageNames.size() > 1) {
|
||||
fail("The NETWORK_CARRIER_PROVISIONING permission must not be held by more than one "
|
||||
+ "application, but is held by " + uniquePackageNames.size() + " applications: "
|
||||
+ String.join(", ", uniquePackageNames));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the {@link android.Manifest.permission#WIFI_UPDATE_USABILITY_STATS_SCORE}
|
||||
* permission is held by at most one application.
|
||||
|
||||
Reference in New Issue
Block a user