[automerge] Fix printing duplicate logs to save on battery 2p: efdf00bff9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17411804 Bug: 202092164 Change-Id: Ieea568ac2aaf9737ce077dd6037c25221a6ce73a
This commit is contained in:
@@ -1486,6 +1486,10 @@ public final class PermissionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only warn once for assuming that root or system UID has a permission
|
||||||
|
// to reduce duplicate logcat output.
|
||||||
|
private static volatile boolean sShouldWarnMissingActivityManager = true;
|
||||||
|
|
||||||
/* @hide */
|
/* @hide */
|
||||||
private static int checkPermissionUncached(@Nullable String permission, int pid, int uid) {
|
private static int checkPermissionUncached(@Nullable String permission, int pid, int uid) {
|
||||||
final IActivityManager am = ActivityManager.getService();
|
final IActivityManager am = ActivityManager.getService();
|
||||||
@@ -1495,8 +1499,11 @@ public final class PermissionManager {
|
|||||||
// permission this is.
|
// permission this is.
|
||||||
final int appId = UserHandle.getAppId(uid);
|
final int appId = UserHandle.getAppId(uid);
|
||||||
if (appId == Process.ROOT_UID || appId == Process.SYSTEM_UID) {
|
if (appId == Process.ROOT_UID || appId == Process.SYSTEM_UID) {
|
||||||
Slog.w(LOG_TAG, "Missing ActivityManager; assuming " + uid + " holds "
|
if (sShouldWarnMissingActivityManager) {
|
||||||
+ permission);
|
Slog.w(LOG_TAG, "Missing ActivityManager; assuming " + uid + " holds "
|
||||||
|
+ permission);
|
||||||
|
sShouldWarnMissingActivityManager = false;
|
||||||
|
}
|
||||||
return PackageManager.PERMISSION_GRANTED;
|
return PackageManager.PERMISSION_GRANTED;
|
||||||
}
|
}
|
||||||
Slog.w(LOG_TAG, "Missing ActivityManager; assuming " + uid + " does not hold "
|
Slog.w(LOG_TAG, "Missing ActivityManager; assuming " + uid + " does not hold "
|
||||||
@@ -1504,6 +1511,7 @@ public final class PermissionManager {
|
|||||||
return PackageManager.PERMISSION_DENIED;
|
return PackageManager.PERMISSION_DENIED;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
sShouldWarnMissingActivityManager = true;
|
||||||
return am.checkPermission(permission, pid, uid);
|
return am.checkPermission(permission, pid, uid);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
|
|||||||
Reference in New Issue
Block a user