Loading AconfigFlags.bp +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ aconfig_srcjars = [ ":android.service.autofill.flags-aconfig-java{.generated_srcjars}", ":com.android.net.flags-aconfig-java{.generated_srcjars}", ":device_policy_aconfig_flags_lib{.generated_srcjars}", ":service-jobscheduler-deviceidle.flags-aconfig-java{.generated_srcjars}", ":surfaceflinger_flags_java_lib{.generated_srcjars}", ] Loading apex/jobscheduler/service/aconfig/Android.bp +17 −0 Original line number Diff line number Diff line // Device Idle aconfig_declarations { name: "service-deviceidle.flags-aconfig", package: "com.android.server.deviceidle", srcs: [ "device_idle.aconfig", ], } java_aconfig_library { name: "service-jobscheduler-deviceidle.flags-aconfig-java", aconfig_declarations: "service-deviceidle.flags-aconfig", defaults: ["framework-minus-apex-aconfig-java-defaults"], visibility: ["//frameworks/base:__subpackages__"], } // JobScheduler aconfig_declarations { name: "service-job.flags-aconfig", Loading @@ -15,6 +31,7 @@ java_aconfig_library { } service_jobscheduler_aconfig_srcjars = [ ":service-jobscheduler-deviceidle.flags-aconfig-java{.generated_srcjars}", ":service-jobscheduler-job.flags-aconfig-java{.generated_srcjars}", ] Loading apex/jobscheduler/service/aconfig/device_idle.aconfig 0 → 100644 +8 −0 Original line number Diff line number Diff line package: "com.android.server.deviceidle" flag { name: "disable_wakelocks_in_light_idle" namespace: "backstage_power" description: "Disable wakelocks for background apps while Light Device Idle is active" bug: "299329948" } services/core/java/com/android/server/power/PowerManagerService.java +17 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static android.os.PowerManagerInternal.isInteractive; import static android.os.PowerManagerInternal.wakefulnessToString; import static com.android.internal.util.LatencyTracker.ACTION_TURN_ON_SCREEN; import static com.android.server.deviceidle.Flags.disableWakelocksInLightIdle; import android.annotation.IntDef; import android.annotation.NonNull; Loading Loading @@ -644,9 +645,11 @@ public final class PowerManagerService extends SystemService private boolean mBatteryLevelLow; // True if we are currently in device idle mode. @GuardedBy("mLock") private boolean mDeviceIdleMode; // True if we are currently in light device idle mode. @GuardedBy("mLock") private boolean mLightDeviceIdleMode; // Set of app ids that we will respect the wake locks for while in device idle mode. Loading Loading @@ -4035,6 +4038,9 @@ public final class PowerManagerService extends SystemService synchronized (mLock) { if (mLightDeviceIdleMode != enabled) { mLightDeviceIdleMode = enabled; if (!mDeviceIdleMode && disableWakelocksInLightIdle()) { updateWakeLockDisabledStatesLocked(); } setPowerModeInternal(MODE_DEVICE_IDLE, mDeviceIdleMode || mLightDeviceIdleMode); return true; } Loading @@ -4045,7 +4051,7 @@ public final class PowerManagerService extends SystemService void setDeviceIdleWhitelistInternal(int[] appids) { synchronized (mLock) { mDeviceIdleWhitelist = appids; if (mDeviceIdleMode) { if (doesIdleStateBlockWakeLocksLocked()) { updateWakeLockDisabledStatesLocked(); } } Loading @@ -4054,7 +4060,7 @@ public final class PowerManagerService extends SystemService void setDeviceIdleTempWhitelistInternal(int[] appids) { synchronized (mLock) { mDeviceIdleTempWhitelist = appids; if (mDeviceIdleMode) { if (doesIdleStateBlockWakeLocksLocked()) { updateWakeLockDisabledStatesLocked(); } } Loading Loading @@ -4114,7 +4120,7 @@ public final class PowerManagerService extends SystemService <= ActivityManager.PROCESS_STATE_RECEIVER; state.mProcState = procState; if (state.mNumWakeLocks > 0) { if (mDeviceIdleMode || mLowPowerStandbyActive) { if (doesIdleStateBlockWakeLocksLocked() || mLowPowerStandbyActive) { handleUidStateChangeLocked(); } else if (!state.mActive && oldShouldAllow != (procState <= ActivityManager.PROCESS_STATE_RECEIVER)) { Loading @@ -4134,7 +4140,8 @@ public final class PowerManagerService extends SystemService state.mProcState = ActivityManager.PROCESS_STATE_NONEXISTENT; state.mActive = false; mUidState.removeAt(index); if ((mDeviceIdleMode || mLowPowerStandbyActive) && state.mNumWakeLocks > 0) { if ((doesIdleStateBlockWakeLocksLocked() || mLowPowerStandbyActive) && state.mNumWakeLocks > 0) { handleUidStateChangeLocked(); } } Loading Loading @@ -4168,6 +4175,11 @@ public final class PowerManagerService extends SystemService } } @GuardedBy("mLock") private boolean doesIdleStateBlockWakeLocksLocked() { return mDeviceIdleMode || (mLightDeviceIdleMode && disableWakelocksInLightIdle()); } @GuardedBy("mLock") private void updateWakeLockDisabledStatesLocked() { boolean changed = false; Loading Loading @@ -4207,7 +4219,7 @@ public final class PowerManagerService extends SystemService != ActivityManager.PROCESS_STATE_NONEXISTENT && wakeLock.mUidState.mProcState > ActivityManager.PROCESS_STATE_RECEIVER); } if (mDeviceIdleMode) { if (doesIdleStateBlockWakeLocksLocked()) { // If we are in idle mode, we will also ignore all partial wake locks that are // for application uids that are not allowlisted. final UidState state = wakeLock.mUidState; Loading services/tests/powerservicetests/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ android_test { ], static_libs: [ "flag-junit", "frameworks-base-testutils", "platform-compat-test-rules", "platform-test-annotations", Loading Loading
AconfigFlags.bp +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ aconfig_srcjars = [ ":android.service.autofill.flags-aconfig-java{.generated_srcjars}", ":com.android.net.flags-aconfig-java{.generated_srcjars}", ":device_policy_aconfig_flags_lib{.generated_srcjars}", ":service-jobscheduler-deviceidle.flags-aconfig-java{.generated_srcjars}", ":surfaceflinger_flags_java_lib{.generated_srcjars}", ] Loading
apex/jobscheduler/service/aconfig/Android.bp +17 −0 Original line number Diff line number Diff line // Device Idle aconfig_declarations { name: "service-deviceidle.flags-aconfig", package: "com.android.server.deviceidle", srcs: [ "device_idle.aconfig", ], } java_aconfig_library { name: "service-jobscheduler-deviceidle.flags-aconfig-java", aconfig_declarations: "service-deviceidle.flags-aconfig", defaults: ["framework-minus-apex-aconfig-java-defaults"], visibility: ["//frameworks/base:__subpackages__"], } // JobScheduler aconfig_declarations { name: "service-job.flags-aconfig", Loading @@ -15,6 +31,7 @@ java_aconfig_library { } service_jobscheduler_aconfig_srcjars = [ ":service-jobscheduler-deviceidle.flags-aconfig-java{.generated_srcjars}", ":service-jobscheduler-job.flags-aconfig-java{.generated_srcjars}", ] Loading
apex/jobscheduler/service/aconfig/device_idle.aconfig 0 → 100644 +8 −0 Original line number Diff line number Diff line package: "com.android.server.deviceidle" flag { name: "disable_wakelocks_in_light_idle" namespace: "backstage_power" description: "Disable wakelocks for background apps while Light Device Idle is active" bug: "299329948" }
services/core/java/com/android/server/power/PowerManagerService.java +17 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static android.os.PowerManagerInternal.isInteractive; import static android.os.PowerManagerInternal.wakefulnessToString; import static com.android.internal.util.LatencyTracker.ACTION_TURN_ON_SCREEN; import static com.android.server.deviceidle.Flags.disableWakelocksInLightIdle; import android.annotation.IntDef; import android.annotation.NonNull; Loading Loading @@ -644,9 +645,11 @@ public final class PowerManagerService extends SystemService private boolean mBatteryLevelLow; // True if we are currently in device idle mode. @GuardedBy("mLock") private boolean mDeviceIdleMode; // True if we are currently in light device idle mode. @GuardedBy("mLock") private boolean mLightDeviceIdleMode; // Set of app ids that we will respect the wake locks for while in device idle mode. Loading Loading @@ -4035,6 +4038,9 @@ public final class PowerManagerService extends SystemService synchronized (mLock) { if (mLightDeviceIdleMode != enabled) { mLightDeviceIdleMode = enabled; if (!mDeviceIdleMode && disableWakelocksInLightIdle()) { updateWakeLockDisabledStatesLocked(); } setPowerModeInternal(MODE_DEVICE_IDLE, mDeviceIdleMode || mLightDeviceIdleMode); return true; } Loading @@ -4045,7 +4051,7 @@ public final class PowerManagerService extends SystemService void setDeviceIdleWhitelistInternal(int[] appids) { synchronized (mLock) { mDeviceIdleWhitelist = appids; if (mDeviceIdleMode) { if (doesIdleStateBlockWakeLocksLocked()) { updateWakeLockDisabledStatesLocked(); } } Loading @@ -4054,7 +4060,7 @@ public final class PowerManagerService extends SystemService void setDeviceIdleTempWhitelistInternal(int[] appids) { synchronized (mLock) { mDeviceIdleTempWhitelist = appids; if (mDeviceIdleMode) { if (doesIdleStateBlockWakeLocksLocked()) { updateWakeLockDisabledStatesLocked(); } } Loading Loading @@ -4114,7 +4120,7 @@ public final class PowerManagerService extends SystemService <= ActivityManager.PROCESS_STATE_RECEIVER; state.mProcState = procState; if (state.mNumWakeLocks > 0) { if (mDeviceIdleMode || mLowPowerStandbyActive) { if (doesIdleStateBlockWakeLocksLocked() || mLowPowerStandbyActive) { handleUidStateChangeLocked(); } else if (!state.mActive && oldShouldAllow != (procState <= ActivityManager.PROCESS_STATE_RECEIVER)) { Loading @@ -4134,7 +4140,8 @@ public final class PowerManagerService extends SystemService state.mProcState = ActivityManager.PROCESS_STATE_NONEXISTENT; state.mActive = false; mUidState.removeAt(index); if ((mDeviceIdleMode || mLowPowerStandbyActive) && state.mNumWakeLocks > 0) { if ((doesIdleStateBlockWakeLocksLocked() || mLowPowerStandbyActive) && state.mNumWakeLocks > 0) { handleUidStateChangeLocked(); } } Loading Loading @@ -4168,6 +4175,11 @@ public final class PowerManagerService extends SystemService } } @GuardedBy("mLock") private boolean doesIdleStateBlockWakeLocksLocked() { return mDeviceIdleMode || (mLightDeviceIdleMode && disableWakelocksInLightIdle()); } @GuardedBy("mLock") private void updateWakeLockDisabledStatesLocked() { boolean changed = false; Loading Loading @@ -4207,7 +4219,7 @@ public final class PowerManagerService extends SystemService != ActivityManager.PROCESS_STATE_NONEXISTENT && wakeLock.mUidState.mProcState > ActivityManager.PROCESS_STATE_RECEIVER); } if (mDeviceIdleMode) { if (doesIdleStateBlockWakeLocksLocked()) { // If we are in idle mode, we will also ignore all partial wake locks that are // for application uids that are not allowlisted. final UidState state = wakeLock.mUidState; Loading
services/tests/powerservicetests/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ android_test { ], static_libs: [ "flag-junit", "frameworks-base-testutils", "platform-compat-test-rules", "platform-test-annotations", Loading