summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-09-11 20:31:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-09-11 20:31:32 +0000
commitad324a3d7e61981dabc00aab83457b071f35fafd (patch)
tree7ed93c64731acc204ecae5e1a1140665d0eb13c4 /packages/SystemUI/src/com/android/systemui/power/PowerUI.java
parent80743ffc075dc74310f8a12d63644a17d99fe8cd (diff)
parentd57e959e719c13ab842f7a92750d8079f4543fe3 (diff)
Merge "Merge qt-r1-dev-plus-aosp-without-vendor (5817612) into stage-aosp-master" into stage-aosp-master
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/power/PowerUI.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/power/PowerUI.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
index fb8b6c76a35f..75dc39722bcf 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -64,6 +64,8 @@ public class PowerUI extends SystemUI {
private static final int CHARGE_CYCLE_PERCENT_RESET = 45;
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";
private final Handler mHandler = new Handler();
@VisibleForTesting
@@ -118,7 +120,7 @@ public class PowerUI extends SystemUI {
// Check to see if we need to let the user know that the phone previously shut down due
// to the temperature being too high.
- showThermalShutdownDialog();
+ showWarnOnThermalShutdown();
// Register an observer to configure mEnableSkinTemperatureWarning and perform the
// registration of skin thermal event listener upon Settings change.
@@ -542,10 +544,23 @@ public class PowerUI extends SystemUI {
}
}
- private void showThermalShutdownDialog() {
- if (mPowerManager.getLastShutdownReason()
- == PowerManager.SHUTDOWN_REASON_THERMAL_SHUTDOWN) {
- mWarnings.showThermalShutdownWarning();
+ private void showWarnOnThermalShutdown() {
+ int bootCount = -1;
+ int lastReboot = mContext.getSharedPreferences(PREFS, 0).getInt(BOOT_COUNT_KEY, -1);
+ try {
+ bootCount = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.BOOT_COUNT);
+ } catch (Settings.SettingNotFoundException e) {
+ Slog.e(TAG, "Failed to read system boot count from Settings.Global.BOOT_COUNT");
+ }
+ // Only show the thermal shutdown warning when there is a thermal reboot.
+ if (bootCount > lastReboot) {
+ mContext.getSharedPreferences(PREFS, 0).edit().putInt(BOOT_COUNT_KEY,
+ bootCount).apply();
+ if (mPowerManager.getLastShutdownReason()
+ == PowerManager.SHUTDOWN_REASON_THERMAL_SHUTDOWN) {
+ mWarnings.showThermalShutdownWarning();
+ }
}
}