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