Loading services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java +8 −3 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.server.EventLogTags; import com.android.server.power.BatterySaverStateMachineProto; import java.io.PrintWriter; import java.time.Duration; /** * Decides when to enable / disable battery saver. Loading Loading @@ -106,6 +107,8 @@ public class BatterySaverStateMachine { /** Turn off adaptive battery saver if the device has charged above this level. */ private static final int ADAPTIVE_AUTO_DISABLE_BATTERY_LEVEL = 80; private static final long STICKY_DISABLED_NOTIFY_TIMEOUT_MS = Duration.ofHours(12).toMillis(); private static final int STATE_OFF = BatterySaverStateMachineProto.STATE_OFF; /** Turned on manually by the user. */ Loading Loading @@ -829,7 +832,7 @@ public class BatterySaverStateMachine { buildNotification(DYNAMIC_MODE_NOTIF_CHANNEL_ID, R.string.dynamic_mode_notification_title, R.string.dynamic_mode_notification_summary, Settings.ACTION_BATTERY_SAVER_SETTINGS), Settings.ACTION_BATTERY_SAVER_SETTINGS, 0L), UserHandle.ALL); }); } Loading @@ -847,7 +850,8 @@ public class BatterySaverStateMachine { buildNotification(BATTERY_SAVER_NOTIF_CHANNEL_ID, R.string.battery_saver_off_notification_title, R.string.battery_saver_charged_notification_summary, Settings.ACTION_BATTERY_SAVER_SETTINGS), Settings.ACTION_BATTERY_SAVER_SETTINGS, STICKY_DISABLED_NOTIFY_TIMEOUT_MS), UserHandle.ALL); }); } Loading @@ -862,7 +866,7 @@ public class BatterySaverStateMachine { } private Notification buildNotification(@NonNull String channelId, @StringRes int titleId, @StringRes int summaryId, @NonNull String intentAction) { @StringRes int summaryId, @NonNull String intentAction, long timeoutMs) { Resources res = mContext.getResources(); Intent intent = new Intent(intentAction); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Loading @@ -880,6 +884,7 @@ public class BatterySaverStateMachine { .setStyle(new Notification.BigTextStyle().bigText(summary)) .setOnlyAlertOnce(true) .setAutoCancel(true) .setTimeoutAfter(timeoutMs) .build(); } Loading Loading
services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java +8 −3 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.server.EventLogTags; import com.android.server.power.BatterySaverStateMachineProto; import java.io.PrintWriter; import java.time.Duration; /** * Decides when to enable / disable battery saver. Loading Loading @@ -106,6 +107,8 @@ public class BatterySaverStateMachine { /** Turn off adaptive battery saver if the device has charged above this level. */ private static final int ADAPTIVE_AUTO_DISABLE_BATTERY_LEVEL = 80; private static final long STICKY_DISABLED_NOTIFY_TIMEOUT_MS = Duration.ofHours(12).toMillis(); private static final int STATE_OFF = BatterySaverStateMachineProto.STATE_OFF; /** Turned on manually by the user. */ Loading Loading @@ -829,7 +832,7 @@ public class BatterySaverStateMachine { buildNotification(DYNAMIC_MODE_NOTIF_CHANNEL_ID, R.string.dynamic_mode_notification_title, R.string.dynamic_mode_notification_summary, Settings.ACTION_BATTERY_SAVER_SETTINGS), Settings.ACTION_BATTERY_SAVER_SETTINGS, 0L), UserHandle.ALL); }); } Loading @@ -847,7 +850,8 @@ public class BatterySaverStateMachine { buildNotification(BATTERY_SAVER_NOTIF_CHANNEL_ID, R.string.battery_saver_off_notification_title, R.string.battery_saver_charged_notification_summary, Settings.ACTION_BATTERY_SAVER_SETTINGS), Settings.ACTION_BATTERY_SAVER_SETTINGS, STICKY_DISABLED_NOTIFY_TIMEOUT_MS), UserHandle.ALL); }); } Loading @@ -862,7 +866,7 @@ public class BatterySaverStateMachine { } private Notification buildNotification(@NonNull String channelId, @StringRes int titleId, @StringRes int summaryId, @NonNull String intentAction) { @StringRes int summaryId, @NonNull String intentAction, long timeoutMs) { Resources res = mContext.getResources(); Intent intent = new Intent(intentAction); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Loading @@ -880,6 +884,7 @@ public class BatterySaverStateMachine { .setStyle(new Notification.BigTextStyle().bigText(summary)) .setOnlyAlertOnce(true) .setAutoCancel(true) .setTimeoutAfter(timeoutMs) .build(); } Loading