Merge "fix the problem that testNetworkSettingsPermission case can not detect all apps whose holding the NETWORK_SETTINGS permission"
am: 9228a471cc
Change-Id: I32edc7a87d1c0b49a44806c89407a2f644b94110
This commit is contained in:
@@ -49,6 +49,7 @@ import androidx.test.InstrumentationRegistry;
|
||||
|
||||
import com.android.compatibility.common.util.SystemUtil;
|
||||
|
||||
import java.lang.StringBuilder;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.security.MessageDigest;
|
||||
@@ -770,6 +771,7 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
|
||||
android.Manifest.permission.NETWORK_SETTINGS
|
||||
}, PackageManager.MATCH_UNINSTALLED_PACKAGES);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (PackageInfo pi : holding) {
|
||||
String packageName = pi.packageName;
|
||||
|
||||
@@ -784,10 +786,13 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
continue;
|
||||
}
|
||||
if (!allowedUIDs.contains(uid)) {
|
||||
fail("The NETWORK_SETTINGS permission must not be held by " + packageName
|
||||
+ ":" + uid + " and must be revoked for security reasons");
|
||||
stringBuilder.append("The NETWORK_SETTINGS permission must not be held by "
|
||||
+ packageName + ":" + uid + " and must be revoked for security reasons\n");
|
||||
}
|
||||
}
|
||||
if (stringBuilder.length() > 0) {
|
||||
fail(stringBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user