Loading apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java +3 −6 Original line number Diff line number Diff line Loading @@ -32,12 +32,8 @@ public interface DeviceIdleInternal { void exitIdle(String reason); // duration in milliseconds void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, String reason); void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); /** Loading @@ -49,10 +45,11 @@ public interface DeviceIdleInternal { * @param sync * @param reasonCode one of {@link ReasonCode} * @param reason * @param callingUid UID of app who added this temp-allowlist. */ void addPowerSaveTempWhitelistAppDirect(int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); @Nullable String reason, int callingUid); // duration in milliseconds long getNotificationAllowlistDuration(); Loading apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +14 −19 Original line number Diff line number Diff line Loading @@ -1943,19 +1943,11 @@ public class DeviceIdleController extends SystemService } // duration in milliseconds @Deprecated @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, duration, userId, sync, REASON_UNKNOWN, reason); } @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, duration, addPowerSaveTempAllowlistAppInternal(callingUid, packageName, durationMs, userId, sync, reasonCode, reason); } Loading @@ -1963,8 +1955,8 @@ public class DeviceIdleController extends SystemService @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempWhitelistAppDirectInternal(0, uid, duration, type, sync, @Nullable String reason, int callingUid) { addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, type, sync, reasonCode, reason); } Loading Loading @@ -2741,6 +2733,16 @@ public class DeviceIdleController extends SystemService void addPowerSaveTempAllowlistAppInternal(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { synchronized (this) { int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId >= Process.FIRST_APPLICATION_UID) { if (!mPowerSaveWhitelistSystemAppIds.get(callingAppId)) { throw new SecurityException( "Calling app " + UserHandle.formatUid(callingUid) + " is not on whitelist"); } } } try { int uid = getContext().getPackageManager().getPackageUidAsUser(packageName, userId); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, Loading @@ -2760,13 +2762,6 @@ public class DeviceIdleController extends SystemService boolean informWhitelistChanged = false; int appId = UserHandle.getAppId(uid); synchronized (this) { int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId >= Process.FIRST_APPLICATION_UID) { if (!mPowerSaveWhitelistSystemAppIds.get(callingAppId)) { throw new SecurityException("Calling app " + UserHandle.formatUid(callingUid) + " is not on whitelist"); } } duration = Math.min(duration, mConstants.MAX_TEMP_APP_ALLOWLIST_DURATION_MS); Pair<MutableLong, String> entry = mTempWhitelistAppIdEndTimes.get(appId); final boolean newEntry = entry == null; Loading core/proto/android/server/activitymanagerservice.proto +1 −0 Original line number Diff line number Diff line Loading @@ -628,6 +628,7 @@ message ActivityManagerServiceDumpProcessesProto { optional string tag = 3; optional int32 type = 4; optional int32 reason_code = 5; optional int32 calling_uid = 6; } repeated PendingTempWhitelist pending_temp_whitelist = 26; Loading services/core/java/com/android/server/am/ActivityManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL; import static android.os.IServiceManager.DUMP_FLAG_PROTO; import static android.os.PowerWhitelistManager.REASON_SYSTEM_ALLOW_LISTED; import static android.os.PowerWhitelistManager.REASON_UNKNOWN; import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED; import static android.os.Process.BLUETOOTH_UID; import static android.os.Process.FIRST_APPLICATION_UID; Loading Loading @@ -1178,14 +1177,16 @@ public class ActivityManagerService extends IActivityManager.Stub final String tag; final int type; final @ReasonCode int reasonCode; final int callingUid; PendingTempAllowlist(int targetUid, long duration, @ReasonCode int reasonCode, String tag, int type) { int type, int callingUid) { this.targetUid = targetUid; this.duration = duration; this.tag = tag; this.type = type; this.reasonCode = reasonCode; this.callingUid = callingUid; } void dumpDebug(ProtoOutputStream proto, long fieldId) { Loading @@ -1198,6 +1199,8 @@ public class ActivityManagerService extends IActivityManager.Stub proto.write(ActivityManagerServiceDumpProcessesProto.PendingTempWhitelist.TYPE, type); proto.write(ActivityManagerServiceDumpProcessesProto.PendingTempWhitelist.REASON_CODE, reasonCode); proto.write(ActivityManagerServiceDumpProcessesProto.PendingTempWhitelist.CALLING_UID, callingUid); proto.end(token); } } Loading Loading @@ -9231,6 +9234,8 @@ public class ActivityManagerService extends IActivityManager.Stub pw.print(ptw.type); pw.print(" "); pw.print(ptw.reasonCode); pw.print(" "); pw.print(ptw.callingUid); } } } Loading Loading @@ -14510,7 +14515,8 @@ public class ActivityManagerService extends IActivityManager.Stub String reason, int type, int callingUid) { synchronized (mProcLock) { mPendingTempAllowlist.put(targetUid, new PendingTempAllowlist(targetUid, duration, reasonCode, reason, type)); new PendingTempAllowlist(targetUid, duration, reasonCode, reason, type, callingUid)); setUidTempAllowlistStateLSP(targetUid, true); mUiHandler.obtainMessage(PUSH_TEMP_ALLOWLIST_UI_MSG).sendToTarget(); Loading Loading @@ -14541,7 +14547,8 @@ public class ActivityManagerService extends IActivityManager.Stub for (int i = 0; i < N; i++) { PendingTempAllowlist ptw = list[i]; mLocalDeviceIdleController.addPowerSaveTempWhitelistAppDirect(ptw.targetUid, ptw.duration, ptw.type, true, ptw.reasonCode, ptw.tag); ptw.duration, ptw.type, true, ptw.reasonCode, ptw.tag, ptw.callingUid); } } services/core/java/com/android/server/am/BroadcastQueue.java +2 −0 Original line number Diff line number Diff line Loading @@ -930,6 +930,8 @@ public final class BroadcastQueue { } else if (r.intent.getData() != null) { b.append(r.intent.getData()); } b.append(",reason:"); b.append(reason); if (DEBUG_BROADCAST) { Slog.v(TAG, "Broadcast temp allowlist uid=" + uid + " duration=" + duration + " type=" + type + " : " + b.toString()); Loading Loading
apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java +3 −6 Original line number Diff line number Diff line Loading @@ -32,12 +32,8 @@ public interface DeviceIdleInternal { void exitIdle(String reason); // duration in milliseconds void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, String reason); void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); /** Loading @@ -49,10 +45,11 @@ public interface DeviceIdleInternal { * @param sync * @param reasonCode one of {@link ReasonCode} * @param reason * @param callingUid UID of app who added this temp-allowlist. */ void addPowerSaveTempWhitelistAppDirect(int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); @Nullable String reason, int callingUid); // duration in milliseconds long getNotificationAllowlistDuration(); Loading
apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +14 −19 Original line number Diff line number Diff line Loading @@ -1943,19 +1943,11 @@ public class DeviceIdleController extends SystemService } // duration in milliseconds @Deprecated @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, duration, userId, sync, REASON_UNKNOWN, reason); } @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, duration, addPowerSaveTempAllowlistAppInternal(callingUid, packageName, durationMs, userId, sync, reasonCode, reason); } Loading @@ -1963,8 +1955,8 @@ public class DeviceIdleController extends SystemService @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempWhitelistAppDirectInternal(0, uid, duration, type, sync, @Nullable String reason, int callingUid) { addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, type, sync, reasonCode, reason); } Loading Loading @@ -2741,6 +2733,16 @@ public class DeviceIdleController extends SystemService void addPowerSaveTempAllowlistAppInternal(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { synchronized (this) { int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId >= Process.FIRST_APPLICATION_UID) { if (!mPowerSaveWhitelistSystemAppIds.get(callingAppId)) { throw new SecurityException( "Calling app " + UserHandle.formatUid(callingUid) + " is not on whitelist"); } } } try { int uid = getContext().getPackageManager().getPackageUidAsUser(packageName, userId); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, Loading @@ -2760,13 +2762,6 @@ public class DeviceIdleController extends SystemService boolean informWhitelistChanged = false; int appId = UserHandle.getAppId(uid); synchronized (this) { int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId >= Process.FIRST_APPLICATION_UID) { if (!mPowerSaveWhitelistSystemAppIds.get(callingAppId)) { throw new SecurityException("Calling app " + UserHandle.formatUid(callingUid) + " is not on whitelist"); } } duration = Math.min(duration, mConstants.MAX_TEMP_APP_ALLOWLIST_DURATION_MS); Pair<MutableLong, String> entry = mTempWhitelistAppIdEndTimes.get(appId); final boolean newEntry = entry == null; Loading
core/proto/android/server/activitymanagerservice.proto +1 −0 Original line number Diff line number Diff line Loading @@ -628,6 +628,7 @@ message ActivityManagerServiceDumpProcessesProto { optional string tag = 3; optional int32 type = 4; optional int32 reason_code = 5; optional int32 calling_uid = 6; } repeated PendingTempWhitelist pending_temp_whitelist = 26; Loading
services/core/java/com/android/server/am/ActivityManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL; import static android.os.IServiceManager.DUMP_FLAG_PROTO; import static android.os.PowerWhitelistManager.REASON_SYSTEM_ALLOW_LISTED; import static android.os.PowerWhitelistManager.REASON_UNKNOWN; import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED; import static android.os.Process.BLUETOOTH_UID; import static android.os.Process.FIRST_APPLICATION_UID; Loading Loading @@ -1178,14 +1177,16 @@ public class ActivityManagerService extends IActivityManager.Stub final String tag; final int type; final @ReasonCode int reasonCode; final int callingUid; PendingTempAllowlist(int targetUid, long duration, @ReasonCode int reasonCode, String tag, int type) { int type, int callingUid) { this.targetUid = targetUid; this.duration = duration; this.tag = tag; this.type = type; this.reasonCode = reasonCode; this.callingUid = callingUid; } void dumpDebug(ProtoOutputStream proto, long fieldId) { Loading @@ -1198,6 +1199,8 @@ public class ActivityManagerService extends IActivityManager.Stub proto.write(ActivityManagerServiceDumpProcessesProto.PendingTempWhitelist.TYPE, type); proto.write(ActivityManagerServiceDumpProcessesProto.PendingTempWhitelist.REASON_CODE, reasonCode); proto.write(ActivityManagerServiceDumpProcessesProto.PendingTempWhitelist.CALLING_UID, callingUid); proto.end(token); } } Loading Loading @@ -9231,6 +9234,8 @@ public class ActivityManagerService extends IActivityManager.Stub pw.print(ptw.type); pw.print(" "); pw.print(ptw.reasonCode); pw.print(" "); pw.print(ptw.callingUid); } } } Loading Loading @@ -14510,7 +14515,8 @@ public class ActivityManagerService extends IActivityManager.Stub String reason, int type, int callingUid) { synchronized (mProcLock) { mPendingTempAllowlist.put(targetUid, new PendingTempAllowlist(targetUid, duration, reasonCode, reason, type)); new PendingTempAllowlist(targetUid, duration, reasonCode, reason, type, callingUid)); setUidTempAllowlistStateLSP(targetUid, true); mUiHandler.obtainMessage(PUSH_TEMP_ALLOWLIST_UI_MSG).sendToTarget(); Loading Loading @@ -14541,7 +14547,8 @@ public class ActivityManagerService extends IActivityManager.Stub for (int i = 0; i < N; i++) { PendingTempAllowlist ptw = list[i]; mLocalDeviceIdleController.addPowerSaveTempWhitelistAppDirect(ptw.targetUid, ptw.duration, ptw.type, true, ptw.reasonCode, ptw.tag); ptw.duration, ptw.type, true, ptw.reasonCode, ptw.tag, ptw.callingUid); } }
services/core/java/com/android/server/am/BroadcastQueue.java +2 −0 Original line number Diff line number Diff line Loading @@ -930,6 +930,8 @@ public final class BroadcastQueue { } else if (r.intent.getData() != null) { b.append(r.intent.getData()); } b.append(",reason:"); b.append(reason); if (DEBUG_BROADCAST) { Slog.v(TAG, "Broadcast temp allowlist uid=" + uid + " duration=" + duration + " type=" + type + " : " + b.toString()); Loading