Merge "tempAllowList duration can be updated if an UID is already temp allowlisted." into sc-qpr1-dev

This commit is contained in:
Hui Yu
2021-09-20 21:54:30 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 11 deletions

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);
}