Loading core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -7038,4 +7038,7 @@ If the gesture is completed faster than this, we assume it's not performed by human and the event gets ignored. --> <integer name="config_defaultMinEmergencyGestureTapDurationMillis">200</integer> <!-- Whether the system uses auto-suspend mode. --> <bool name="config_useAutoSuspend">true</bool> </resources> core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5424,4 +5424,7 @@ <!-- Back swipe thresholds --> <java-symbol type="dimen" name="navigation_edge_action_progress_threshold" /> <java-symbol type="dimen" name="back_progress_non_linear_factor" /> <!-- For PowerManagerService to determine whether to use auto-suspend mode --> <java-symbol type="bool" name="config_useAutoSuspend" /> </resources> services/core/java/com/android/server/power/PowerManagerService.java +10 −0 Original line number Diff line number Diff line Loading @@ -444,6 +444,9 @@ public final class PowerManagerService extends SystemService // Refer to autosuspend.h. private boolean mHalAutoSuspendModeEnabled; // True if the device uses auto-suspend mode. private final boolean mUseAutoSuspend; // True if interactive mode is enabled. // Refer to power.h. private boolean mHalInteractiveModeEnabled; Loading Loading @@ -1203,6 +1206,9 @@ public final class PowerManagerService extends SystemService mPowerGroupWakefulnessChangeListener = new PowerGroupWakefulnessChangeListener(); mUseAutoSuspend = mContext.getResources().getBoolean(com.android.internal.R.bool .config_useAutoSuspend); // Save brightness values: // Get float values from config. // Store float if valid Loading Loading @@ -3918,6 +3924,9 @@ public final class PowerManagerService extends SystemService @GuardedBy("mLock") private void setHalAutoSuspendModeLocked(boolean enable) { if (!mUseAutoSuspend) { return; } if (enable != mHalAutoSuspendModeEnabled) { if (DEBUG) { Slog.d(TAG, "Setting HAL auto-suspend mode to " + enable); Loading Loading @@ -4661,6 +4670,7 @@ public final class PowerManagerService extends SystemService pw.println(" mEnhancedDischargePredictionIsPersonalized=" + mEnhancedDischargePredictionIsPersonalized); } pw.println(" mUseAutoSuspend=" + mUseAutoSuspend); pw.println(" mHalAutoSuspendModeEnabled=" + mHalAutoSuspendModeEnabled); pw.println(" mHalInteractiveModeEnabled=" + mHalInteractiveModeEnabled); pw.println(" mWakeLockSummary=0x" + Integer.toHexString(mWakeLockSummary)); Loading services/tests/powerservicetests/src/com/android/server/power/PowerManagerServiceTest.java +42 −0 Original line number Diff line number Diff line Loading @@ -3241,6 +3241,48 @@ public class PowerManagerServiceTest { } } @Test public void testHalAutoSuspendMode_enabledByConfiguration() { AtomicReference<DisplayManagerInternal.DisplayPowerCallbacks> callback = new AtomicReference<>(); doAnswer((Answer<Void>) invocation -> { callback.set(invocation.getArgument(0)); return null; }).when(mDisplayManagerInternalMock).initPowerManagement(any(), any(), any()); when(mResourcesSpy.getBoolean( com.android.internal.R.bool.config_powerDecoupleAutoSuspendModeFromDisplay)) .thenReturn(false); when(mResourcesSpy.getBoolean(com.android.internal.R.bool.config_useAutoSuspend)) .thenReturn(true); createService(); startSystem(); callback.get().onDisplayStateChange(/* allInactive= */ true, /* allOff= */ true); verify(mNativeWrapperMock).nativeSetAutoSuspend(true); } @Test public void testHalAutoSuspendMode_disabledByConfiguration() { AtomicReference<DisplayManagerInternal.DisplayPowerCallbacks> callback = new AtomicReference<>(); doAnswer((Answer<Void>) invocation -> { callback.set(invocation.getArgument(0)); return null; }).when(mDisplayManagerInternalMock).initPowerManagement(any(), any(), any()); when(mResourcesSpy.getBoolean( com.android.internal.R.bool.config_powerDecoupleAutoSuspendModeFromDisplay)) .thenReturn(false); when(mResourcesSpy.getBoolean(com.android.internal.R.bool.config_useAutoSuspend)) .thenReturn(false); createService(); startSystem(); callback.get().onDisplayStateChange(/* allInactive= */ true, /* allOff= */ true); verify(mNativeWrapperMock, never()).nativeSetAutoSuspend(true); } private void setCachedUidProcState(int uid) { mService.updateUidProcStateInternal(uid, PROCESS_STATE_TOP_SLEEPING); } Loading Loading
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -7038,4 +7038,7 @@ If the gesture is completed faster than this, we assume it's not performed by human and the event gets ignored. --> <integer name="config_defaultMinEmergencyGestureTapDurationMillis">200</integer> <!-- Whether the system uses auto-suspend mode. --> <bool name="config_useAutoSuspend">true</bool> </resources>
core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5424,4 +5424,7 @@ <!-- Back swipe thresholds --> <java-symbol type="dimen" name="navigation_edge_action_progress_threshold" /> <java-symbol type="dimen" name="back_progress_non_linear_factor" /> <!-- For PowerManagerService to determine whether to use auto-suspend mode --> <java-symbol type="bool" name="config_useAutoSuspend" /> </resources>
services/core/java/com/android/server/power/PowerManagerService.java +10 −0 Original line number Diff line number Diff line Loading @@ -444,6 +444,9 @@ public final class PowerManagerService extends SystemService // Refer to autosuspend.h. private boolean mHalAutoSuspendModeEnabled; // True if the device uses auto-suspend mode. private final boolean mUseAutoSuspend; // True if interactive mode is enabled. // Refer to power.h. private boolean mHalInteractiveModeEnabled; Loading Loading @@ -1203,6 +1206,9 @@ public final class PowerManagerService extends SystemService mPowerGroupWakefulnessChangeListener = new PowerGroupWakefulnessChangeListener(); mUseAutoSuspend = mContext.getResources().getBoolean(com.android.internal.R.bool .config_useAutoSuspend); // Save brightness values: // Get float values from config. // Store float if valid Loading Loading @@ -3918,6 +3924,9 @@ public final class PowerManagerService extends SystemService @GuardedBy("mLock") private void setHalAutoSuspendModeLocked(boolean enable) { if (!mUseAutoSuspend) { return; } if (enable != mHalAutoSuspendModeEnabled) { if (DEBUG) { Slog.d(TAG, "Setting HAL auto-suspend mode to " + enable); Loading Loading @@ -4661,6 +4670,7 @@ public final class PowerManagerService extends SystemService pw.println(" mEnhancedDischargePredictionIsPersonalized=" + mEnhancedDischargePredictionIsPersonalized); } pw.println(" mUseAutoSuspend=" + mUseAutoSuspend); pw.println(" mHalAutoSuspendModeEnabled=" + mHalAutoSuspendModeEnabled); pw.println(" mHalInteractiveModeEnabled=" + mHalInteractiveModeEnabled); pw.println(" mWakeLockSummary=0x" + Integer.toHexString(mWakeLockSummary)); Loading
services/tests/powerservicetests/src/com/android/server/power/PowerManagerServiceTest.java +42 −0 Original line number Diff line number Diff line Loading @@ -3241,6 +3241,48 @@ public class PowerManagerServiceTest { } } @Test public void testHalAutoSuspendMode_enabledByConfiguration() { AtomicReference<DisplayManagerInternal.DisplayPowerCallbacks> callback = new AtomicReference<>(); doAnswer((Answer<Void>) invocation -> { callback.set(invocation.getArgument(0)); return null; }).when(mDisplayManagerInternalMock).initPowerManagement(any(), any(), any()); when(mResourcesSpy.getBoolean( com.android.internal.R.bool.config_powerDecoupleAutoSuspendModeFromDisplay)) .thenReturn(false); when(mResourcesSpy.getBoolean(com.android.internal.R.bool.config_useAutoSuspend)) .thenReturn(true); createService(); startSystem(); callback.get().onDisplayStateChange(/* allInactive= */ true, /* allOff= */ true); verify(mNativeWrapperMock).nativeSetAutoSuspend(true); } @Test public void testHalAutoSuspendMode_disabledByConfiguration() { AtomicReference<DisplayManagerInternal.DisplayPowerCallbacks> callback = new AtomicReference<>(); doAnswer((Answer<Void>) invocation -> { callback.set(invocation.getArgument(0)); return null; }).when(mDisplayManagerInternalMock).initPowerManagement(any(), any(), any()); when(mResourcesSpy.getBoolean( com.android.internal.R.bool.config_powerDecoupleAutoSuspendModeFromDisplay)) .thenReturn(false); when(mResourcesSpy.getBoolean(com.android.internal.R.bool.config_useAutoSuspend)) .thenReturn(false); createService(); startSystem(); callback.get().onDisplayStateChange(/* allInactive= */ true, /* allOff= */ true); verify(mNativeWrapperMock, never()).nativeSetAutoSuspend(true); } private void setCachedUidProcState(int uid) { mService.updateUidProcStateInternal(uid, PROCESS_STATE_TOP_SLEEPING); } Loading