summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/power
diff options
context:
space:
mode:
authorChristoph Studer <chstuder@google.com>2014-06-26 16:50:09 +0200
committerChristoph Studer <chstuder@google.com>2014-06-27 12:56:35 +0200
commit65fa0a923c2613cc2a10a97b9eee4d21ed744e0b (patch)
tree33da43fc2689c0f70592bc80b5d26e8313a3e7a8 /packages/SystemUI/src/com/android/systemui/power
parent7b79c17c1b469a09dd2d346d1cab579438ea0f63 (diff)
downloadframeworks_base-65fa0a923c2613cc2a10a97b9eee4d21ed744e0b.zip
frameworks_base-65fa0a923c2613cc2a10a97b9eee4d21ed744e0b.tar.gz
frameworks_base-65fa0a923c2613cc2a10a97b9eee4d21ed744e0b.tar.bz2
Avoid upranking battery level/saver notifications
Bug: 15884933 Change-Id: Ia1a61c8b3d3f70feaa0a68702c1a8902b0c15bb7
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/power')
-rw-r--r--packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index 41b1f75..186b570 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -81,6 +81,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
private long mScreenOffTime;
private int mShowing;
+ private long mBucketDroppedNegativeTimeMs;
+
private boolean mSaver;
private int mSaverTriggerLevel;
private boolean mWarning;
@@ -108,6 +110,11 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
@Override
public void update(int batteryLevel, int bucket, long screenOffTime) {
mBatteryLevel = batteryLevel;
+ if (bucket >= 0) {
+ mBucketDroppedNegativeTimeMs = 0;
+ } else if (bucket < mBucket) {
+ mBucketDroppedNegativeTimeMs = System.currentTimeMillis();
+ }
mBucket = bucket;
mScreenOffTime = screenOffTime;
mFallbackDialogs.update(batteryLevel, bucket, screenOffTime);
@@ -146,6 +153,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
private void showInvalidChargerNotification() {
final Notification.Builder nb = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_power_low)
+ .setWhen(0)
.setShowWhen(false)
.setOngoing(true)
.setContentTitle(mContext.getString(R.string.invalid_charger_title))
@@ -166,6 +174,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
: R.string.battery_low_percent_format;
final Notification.Builder nb = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_power_low)
+ // Bump the notification when the bucket dropped.
+ .setWhen(mBucketDroppedNegativeTimeMs)
.setShowWhen(false)
.setContentTitle(mContext.getString(R.string.battery_low_title))
.setContentText(mContext.getString(textRes, mBatteryLevel))
@@ -198,6 +208,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
.setContentTitle(mContext.getString(R.string.battery_saver_notification_title))
.setContentText(mContext.getString(R.string.battery_saver_notification_text))
.setOngoing(true)
+ .setWhen(0)
.setShowWhen(false)
.setCategory(Notification.CATEGORY_SYSTEM)
.setVisibility(Notification.VISIBILITY_PUBLIC);