summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java7
-rw-r--r--core/java/android/app/ActivityManagerInternal.java3
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java17
3 files changed, 16 insertions, 11 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java
index 9eb7bb7149ef..84d05c8b4144 100644
--- a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java
+++ b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java
@@ -2918,6 +2918,13 @@ public class DeviceIdleController extends SystemService
reasonCode, reason).sendToTarget();
}
reportTempWhitelistChangedLocked(uid, true);
+ } else {
+ // The uid is already temp allowlisted, only need to update AMS for temp allowlist
+ // duration.
+ if (mLocalActivityManager != null) {
+ mLocalActivityManager.updateDeviceIdleTempAllowlist(null, uid, true,
+ duration, tempAllowListType, reasonCode, reason, callingUid);
+ }
}
}
if (informWhitelistChanged) {
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index 0d68df48c316..4e8480c4e113 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -156,6 +156,7 @@ public abstract class ActivityManagerInternal {
/**
* Update information about which app IDs are on the temp allowlist.
* @param appids the updated list of appIds in temp allowlist.
+ * If null, it is to update only changingUid.
* @param changingUid uid to add or remove to temp allowlist.
* @param adding true to add to temp allowlist, false to remove from temp allowlist.
* @param durationMs when adding is true, the duration to be in temp allowlist.
@@ -165,7 +166,7 @@ public abstract class ActivityManagerInternal {
* @param callingUid the callingUid that setup this temp allowlist, only valid when param adding
* is true.
*/
- public abstract void updateDeviceIdleTempAllowlist(int[] appids, int changingUid,
+ public abstract void updateDeviceIdleTempAllowlist(@Nullable int[] appids, int changingUid,
boolean adding, long durationMs, @TempAllowListType int type,
@ReasonCode int reasonCode,
@Nullable String reason, int callingUid);
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 953e6e24236f..8f2afdba5251 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -15404,12 +15404,14 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public void updateDeviceIdleTempAllowlist(int[] appids, int changingUid, boolean adding,
- long durationMs, @TempAllowListType int type, @ReasonCode int reasonCode,
- @Nullable String reason, int callingUid) {
+ public void updateDeviceIdleTempAllowlist(@Nullable int[] appids, int changingUid,
+ boolean adding, long durationMs, @TempAllowListType int type,
+ @ReasonCode int reasonCode, @Nullable String reason, int callingUid) {
synchronized (ActivityManagerService.this) {
synchronized (mProcLock) {
- mDeviceIdleTempAllowlist = appids;
+ if (appids != null) {
+ mDeviceIdleTempAllowlist = appids;
+ }
if (adding) {
if (type == TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED) {
// Note, the device idle temp-allowlist are by app-ids, but here
@@ -15419,12 +15421,7 @@ public class ActivityManagerService extends IActivityManager.Stub
callingUid));
}
} else {
- // Note in the removing case, we need to remove all the UIDs matching
- // the appId, because DeviceIdle's temp-allowlist are based on AppIds,
- // not UIDs.
- // For eacmple, "cmd deviceidle tempallowlist -r PACKAGE" will
- // not only remove this app for user 0, but for all users.
- mFgsStartTempAllowList.removeAppId(UserHandle.getAppId(changingUid));
+ mFgsStartTempAllowList.removeUid(changingUid);
}
setAppIdTempAllowlistStateLSP(changingUid, adding);
}