Adjust low battery notification

- Make low battery notification as ongoing notification and remove the
   delete intent since ongoing notification can not been remove
 - Remove unused attr
 Screenshot: https://screenshot.googleplex.com/gj5xYDik5Ct2WQb.png

Bug: 207470943
Test: atest SystemUITests
Change-Id: I9cfdc8deb455bb5f6707c08ffff3ff3405e99f2b
This commit is contained in:
Wesley Wang
2022-03-04 18:52:49 +08:00
parent aafb696be7
commit 249490f7dd
3 changed files with 10 additions and 9 deletions

View File

@@ -66,7 +66,10 @@
<string name="battery_saver_confirmation_ok">Turn on</string>
<!-- Battery saver notification action [CHAR LIMIT=NONE]-->
<string name="battery_saver_start_action">Turn on Battery Saver</string>
<string name="battery_saver_start_action">Turn on</string>
<!-- Battery saver notification dismiss action: Do not turn on battery saver. [CHAR LIMIT=NONE]-->
<string name="battery_saver_dismiss_action">No thanks</string>
<!-- Name of the button that links to the Settings app. [CHAR LIMIT=NONE] -->

View File

@@ -120,8 +120,6 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
private static final String ACTION_ENABLE_SEVERE_BATTERY_DIALOG = "PNW.enableSevereDialog";
private static final String SETTINGS_ACTION_OPEN_BATTERY_SAVER_SETTING =
"android.settings.BATTERY_SAVER_SETTINGS";
public static final String BATTERY_SAVER_SCHEDULE_SCREEN_INTENT_ACTION =
"com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS";
@@ -140,6 +138,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Receiver mReceiver = new Receiver();
private final Intent mOpenBatterySettings = settings(Intent.ACTION_POWER_USAGE_SUMMARY);
private final boolean mUseSevereDialog;
private int mBatteryLevel;
private int mBucket;
@@ -170,6 +169,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
mKeyguard = mContext.getSystemService(KeyguardManager.class);
mReceiver.init();
mActivityStarter = activityStarter;
mUseSevereDialog = mContext.getResources().getBoolean(R.bool.config_severe_battery_dialog);
}
@Override
@@ -283,7 +283,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
.setContentText(contentText)
.setContentTitle(title)
.setOnlyAlertOnce(true)
.setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_WARNING))
.setOngoing(true)
.setStyle(new Notification.BigTextStyle().bigText(contentText))
.setVisibility(Notification.VISIBILITY_PUBLIC);
if (hasBatterySettings()) {
@@ -298,6 +298,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
}
if (!mPowerMan.isPowerSaveMode()) {
nb.addAction(0, mContext.getString(R.string.battery_saver_dismiss_action),
pendingBroadcast(ACTION_DISMISSED_WARNING));
nb.addAction(0,
mContext.getString(R.string.battery_saver_start_action),
pendingBroadcast(ACTION_START_SAVER));
@@ -312,9 +314,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
private boolean showSevereLowBatteryDialog() {
final boolean isSevereState = !mCurrentBatterySnapshot.isHybrid() || mBucket < -1;
final boolean useSevereDialog = mContext.getResources().getBoolean(
R.bool.config_severe_battery_dialog);
return isSevereState && useSevereDialog;
return isSevereState && mUseSevereDialog;
}
private void showAutoSaverSuggestionNotification() {

View File

@@ -51,7 +51,6 @@ import com.android.systemui.statusbar.phone.CentralSurfaces;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.time.Duration;
import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.Future;
@@ -70,7 +69,6 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks {
private static final int MAX_RECENT_TEMPS = 125; // TEMPERATURE_LOGGING_INTERVAL plus a buffer
static final long THREE_HOURS_IN_MILLIS = DateUtils.HOUR_IN_MILLIS * 3;
private static final int CHARGE_CYCLE_PERCENT_RESET = 30;
private static final long SIX_HOURS_MILLIS = Duration.ofHours(6).toMillis();
public static final int NO_ESTIMATE_AVAILABLE = -1;
private static final String BOOT_COUNT_KEY = "boot_count";
private static final String PREFS = "powerui_prefs";