Merge "Enforce permission when disabling API checks." into pi-dev

This commit is contained in:
Mathew Inwood
2018-04-23 08:02:32 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 3 deletions

View File

@@ -3943,6 +3943,11 @@
<permission android:name="android.permission.OPEN_APPLICATION_DETAILS_OPEN_BY_DEFAULT_PAGE"
android:protectionLevel="signature" />
<!-- Allows hidden API checks to be disabled when starting a process.
@hide <p>Not for use by third-party applications. -->
<permission android:name="android.permission.DISABLE_HIDDEN_API_CHECKS"
android:protectionLevel="signature" />
<application android:process="system"
android:persistent="true"
android:hasCode="false"

View File

@@ -130,6 +130,7 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.SET_TIME" />
<uses-permission android:name="android.permission.SET_TIME_ZONE" />
<uses-permission android:name="android.permission.DISABLE_HIDDEN_API_CHECKS" />
<!-- Permission needed to rename bugreport notifications (so they're not shown as Shell) -->
<uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />
<!-- Permission needed to hold a wakelock in dumpstate.cpp (drop_root_user()) -->

View File

@@ -22080,6 +22080,13 @@ public class ActivityManagerService extends IActivityManager.Stub
activeInstr.mUiAutomationConnection = uiAutomationConnection;
activeInstr.mResultClass = className;
boolean disableHiddenApiChecks =
(flags & INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
if (disableHiddenApiChecks) {
enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS,
"disable hidden API checks");
}
final long origId = Binder.clearCallingIdentity();
// Instrumentation can kill and relaunch even persistent processes
forceStopPackageLocked(ii.targetPackage, -1, true, false, true, true, false, userId,
@@ -22089,9 +22096,6 @@ public class ActivityManagerService extends IActivityManager.Stub
mUsageStatsService.reportEvent(ii.targetPackage, userId,
UsageEvents.Event.SYSTEM_INTERACTION);
}
boolean disableHiddenApiChecks =
(flags & INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
// TODO: Temporary whitelist of packages which need to be exempt from hidden API
// checks. Remove this as soon as the testing infrastructure allows to set
// the flag in AndroidTest.xml.