From 3e376ab5d119f706b43ee891cc281d5921b8ff13 Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Mon, 4 May 2020 17:40:52 +0000 Subject: [PATCH] Revert "Add isUidActiveOrForeground() for camera/audio to use." Revert "Add isUidActiveOrForeground for camera/audio to use." Revert submission 10829580-isUidForeground Reason for revert: In CameraService.cpp, before this change, around "am.isUidActive", there was up to 300 ms retry. After this change, the code could move forward fast without retry, but at "mAppOpsManager->startOpNoThrow" call, for the same reason as uid is not updated fast enough, "mAppOpsManager->startOpNoThrow" could also fail. This CL does not really fix the root cause, but it changes the timing and now the code fails at "mAppOpsManager->startOpNoThrow" call. Also the timing change may also cause recent multiple CTS test failures. Bug: 154570809, 155032617, 154849083 Reverted Changes: Iffed63293:Add isUidActiveOrForeground() for camera/audio to ... I3685e0c8d:Add isUidActiveOrForeground() for camera/audio to ... I51ed1fe78:Add isUidActiveOrForeground for camera/audio to us... Change-Id: I07cbf45949d14489404cb304c80c9ba4276ebe63 --- core/java/android/app/IActivityManager.aidl | 1 - .../server/am/ActivityManagerService.java | 21 ------------------- 2 files changed, 22 deletions(-) diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index 7fc10ed090c8f..b8221b4efa2f2 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -99,7 +99,6 @@ interface IActivityManager { void unregisterUidObserver(in IUidObserver observer); boolean isUidActive(int uid, String callingPackage); int getUidProcessState(int uid, in String callingPackage); - boolean isUidActiveOrForeground(int uid, String callingPackage); // =============== End of transactions used on native side as well ============================ // Special low-level communication with activity manager. diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 8b2976d0e878a..4cfcd2b218d11 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -8779,27 +8779,6 @@ public class ActivityManagerService extends IActivityManager.Stub return uidRecord != null && !uidRecord.setIdle; } - @Override - public boolean isUidActiveOrForeground(int uid, String callingPackage) { - if (!hasUsageStatsPermission(callingPackage)) { - enforceCallingPermission(android.Manifest.permission.PACKAGE_USAGE_STATS, - "isUidActiveOrForeground"); - } - synchronized (this) { - final boolean isActive = isUidActiveLocked(uid); - if (isActive) { - return true; - } - } - final boolean isForeground = mAtmInternal.isUidForeground(uid); - if (isForeground) { - Slog.wtf(TAG, "isUidActiveOrForeground: isUidActive false but " - + " isUidForeground true, uid:" + uid - + " callingPackage:" + callingPackage); - } - return isForeground; - } - @Override public void setPersistentVrThread(int tid) { mActivityTaskManager.setPersistentVrThread(tid);