Loading apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server; import android.annotation.Nullable; import android.os.PowerWhitelistManager; import android.os.PowerWhitelistManager.ReasonCode; import android.os.PowerWhitelistManager.TempAllowListType; Loading @@ -32,10 +33,21 @@ public interface DeviceIdleInternal { void exitIdle(String reason); /** * Same as {@link #addPowerSaveTempWhitelistApp(int, String, long, int, boolean, int, String)} * with {@link PowerWhitelistManager#TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED}. */ void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); /** * Put a package in the temp-allowlist. */ void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, @TempAllowListType int tempAllowListType, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); /** * Called by ActivityManagerService to directly add UID to DeviceIdleController's temp * allowlist. Loading apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +23 −15 Original line number Diff line number Diff line Loading @@ -1942,22 +1942,29 @@ public class DeviceIdleController extends SystemService exitIdleInternal(reason); } // duration in milliseconds @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, durationMs, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, userId, sync, reasonCode, reason); } // duration in milliseconds @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, @TempAllowListType int tempAllowListType, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, durationMs, tempAllowListType, userId, sync, reasonCode, reason); } @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long durationMs, @TempAllowListType int tempAllowListType, boolean sync, @ReasonCode int reasonCode, @Nullable String reason, int callingUid) { addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, type, sync, reasonCode, reason); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, durationMs, tempAllowListType, sync, reasonCode, reason); } // duration in milliseconds Loading Loading @@ -2699,7 +2706,8 @@ public class DeviceIdleController extends SystemService final long token = Binder.clearCallingIdentity(); try { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, duration, userId, true, reasonCode, reason); packageName, duration, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, userId, true, reasonCode, reason); } finally { Binder.restoreCallingIdentity(token); } Loading Loading @@ -2731,8 +2739,8 @@ public class DeviceIdleController extends SystemService * app an exemption to access network and acquire wakelocks. */ void addPowerSaveTempAllowlistAppInternal(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { long durationMs, @TempAllowListType int tempAllowListType, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { synchronized (this) { int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId >= Process.FIRST_APPLICATION_UID) { Loading @@ -2745,8 +2753,8 @@ public class DeviceIdleController extends SystemService } try { int uid = getContext().getPackageManager().getPackageUidAsUser(packageName, userId); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, sync, reasonCode, reason); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, durationMs, tempAllowListType, sync, reasonCode, reason); } catch (NameNotFoundException e) { } } Loading @@ -2756,8 +2764,8 @@ public class DeviceIdleController extends SystemService * app an exemption to access network and acquire wakelocks. */ void addPowerSaveTempWhitelistAppDirectInternal(int callingUid, int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { long duration, @TempAllowListType int tempAllowListType, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { final long timeNow = SystemClock.elapsedRealtime(); boolean informWhitelistChanged = false; int appId = UserHandle.getAppId(uid); Loading @@ -2782,8 +2790,8 @@ public class DeviceIdleController extends SystemService } catch (RemoteException e) { } postTempActiveTimeoutMessage(uid, duration); updateTempWhitelistAppIdsLocked(uid, true, duration, type, reasonCode, reason, callingUid); updateTempWhitelistAppIdsLocked(uid, true, duration, tempAllowListType, reasonCode, reason, callingUid); if (sync) { informWhitelistChanged = true; } else { Loading services/core/java/com/android/server/content/SyncManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.content; import static android.os.PowerWhitelistManager.REASON_SYNC_MANAGER; import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED; import static com.android.server.content.SyncLogger.logSafe; Loading Loading @@ -1672,6 +1673,7 @@ public class SyncManager { dic.addPowerSaveTempWhitelistApp(Process.SYSTEM_UID, syncOperation.owningPackage, mConstants.getKeyExemptionTempWhitelistDurationInSeconds() * 1000, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED, UserHandle.getUserId(syncOperation.owningUid), /* sync=*/ false, REASON_SYNC_MANAGER, "sync by top app"); } Loading Loading
apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server; import android.annotation.Nullable; import android.os.PowerWhitelistManager; import android.os.PowerWhitelistManager.ReasonCode; import android.os.PowerWhitelistManager.TempAllowListType; Loading @@ -32,10 +33,21 @@ public interface DeviceIdleInternal { void exitIdle(String reason); /** * Same as {@link #addPowerSaveTempWhitelistApp(int, String, long, int, boolean, int, String)} * with {@link PowerWhitelistManager#TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED}. */ void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); /** * Put a package in the temp-allowlist. */ void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, @TempAllowListType int tempAllowListType, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason); /** * Called by ActivityManagerService to directly add UID to DeviceIdleController's temp * allowlist. Loading
apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +23 −15 Original line number Diff line number Diff line Loading @@ -1942,22 +1942,29 @@ public class DeviceIdleController extends SystemService exitIdleInternal(reason); } // duration in milliseconds @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, durationMs, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, userId, sync, reasonCode, reason); } // duration in milliseconds @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long durationMs, @TempAllowListType int tempAllowListType, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, durationMs, tempAllowListType, userId, sync, reasonCode, reason); } @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long durationMs, @TempAllowListType int tempAllowListType, boolean sync, @ReasonCode int reasonCode, @Nullable String reason, int callingUid) { addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, type, sync, reasonCode, reason); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, durationMs, tempAllowListType, sync, reasonCode, reason); } // duration in milliseconds Loading Loading @@ -2699,7 +2706,8 @@ public class DeviceIdleController extends SystemService final long token = Binder.clearCallingIdentity(); try { addPowerSaveTempAllowlistAppInternal(callingUid, packageName, duration, userId, true, reasonCode, reason); packageName, duration, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, userId, true, reasonCode, reason); } finally { Binder.restoreCallingIdentity(token); } Loading Loading @@ -2731,8 +2739,8 @@ public class DeviceIdleController extends SystemService * app an exemption to access network and acquire wakelocks. */ void addPowerSaveTempAllowlistAppInternal(int callingUid, String packageName, long duration, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { long durationMs, @TempAllowListType int tempAllowListType, int userId, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { synchronized (this) { int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId >= Process.FIRST_APPLICATION_UID) { Loading @@ -2745,8 +2753,8 @@ public class DeviceIdleController extends SystemService } try { int uid = getContext().getPackageManager().getPackageUidAsUser(packageName, userId); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, duration, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, sync, reasonCode, reason); addPowerSaveTempWhitelistAppDirectInternal(callingUid, uid, durationMs, tempAllowListType, sync, reasonCode, reason); } catch (NameNotFoundException e) { } } Loading @@ -2756,8 +2764,8 @@ public class DeviceIdleController extends SystemService * app an exemption to access network and acquire wakelocks. */ void addPowerSaveTempWhitelistAppDirectInternal(int callingUid, int uid, long duration, @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { long duration, @TempAllowListType int tempAllowListType, boolean sync, @ReasonCode int reasonCode, @Nullable String reason) { final long timeNow = SystemClock.elapsedRealtime(); boolean informWhitelistChanged = false; int appId = UserHandle.getAppId(uid); Loading @@ -2782,8 +2790,8 @@ public class DeviceIdleController extends SystemService } catch (RemoteException e) { } postTempActiveTimeoutMessage(uid, duration); updateTempWhitelistAppIdsLocked(uid, true, duration, type, reasonCode, reason, callingUid); updateTempWhitelistAppIdsLocked(uid, true, duration, tempAllowListType, reasonCode, reason, callingUid); if (sync) { informWhitelistChanged = true; } else { Loading
services/core/java/com/android/server/content/SyncManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.content; import static android.os.PowerWhitelistManager.REASON_SYNC_MANAGER; import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED; import static com.android.server.content.SyncLogger.logSafe; Loading Loading @@ -1672,6 +1673,7 @@ public class SyncManager { dic.addPowerSaveTempWhitelistApp(Process.SYSTEM_UID, syncOperation.owningPackage, mConstants.getKeyExemptionTempWhitelistDurationInSeconds() * 1000, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED, UserHandle.getUserId(syncOperation.owningUid), /* sync=*/ false, REASON_SYNC_MANAGER, "sync by top app"); } Loading