summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Wren <cwren@android.com> 2014-06-12 13:50:54 -0400
committer Chris Wren <cwren@android.com> 2014-06-12 13:51:51 -0400
commit1dafd04247c4f849e05fd1c73118d916b9b67f64 (patch)
treecad47f5e7e9f1e5a656c0b3b89b405e6740dfd11
parent879d8b33087aaa3925fa2c4491c6c067fb160c36 (diff)
Fix notification update path for structural updates.
Similar logic is required for the replacement case, as is already in place for the update case, although the actions are different. Bug: 15588056 Change-Id: I9ad115237c589716772e569fa1979a206b77097b
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java58
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java6
3 files changed, 47 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 7196b62ec5e1..97123fac6143 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -132,7 +132,6 @@ public abstract class BaseStatusBar extends SystemUI implements
// for heads up notifications
protected HeadsUpNotificationView mHeadsUpNotificationView;
protected int mHeadsUpNotificationDecay;
- protected long mInterruptingNotificationTime;
// used to notify status bar for suppressing notification LED
protected boolean mPanelSlightlyVisible;
@@ -1413,6 +1412,9 @@ public abstract class BaseStatusBar extends SystemUI implements
&& !TextUtils.equals(notification.getNotification().tickerText,
oldEntry.notification.getNotification().tickerText);
+ final boolean shouldInterrupt = shouldInterrupt(notification);
+ final boolean alertAgain = alertAgain(oldEntry);
+ boolean updateSuccessful = false;
if (contentsUnchanged && bigContentsUnchanged && headsUpContentsUnchanged
&& publicUnchanged) {
if (DEBUG) Log.d(TAG, "reusing notification for key: " + key);
@@ -1432,8 +1434,6 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
- final boolean shouldInterrupt = shouldInterrupt(notification);
- final boolean alertAgain = alertAgain(oldEntry);
if (wasHeadsUp) {
if (shouldInterrupt) {
updateHeadsUpViews(oldEntry, notification);
@@ -1455,24 +1455,52 @@ public abstract class BaseStatusBar extends SystemUI implements
}
mNotificationData.updateRanking(ranking);
updateNotifications();
+ updateSuccessful = true;
}
catch (RuntimeException e) {
// It failed to add cleanly. Log, and remove the view from the panel.
Log.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e);
- removeNotificationViews(key, ranking);
- addNotificationViews(notification, ranking);
}
- } else {
+ }
+ if (!updateSuccessful) {
if (DEBUG) Log.d(TAG, "not reusing notification for key: " + key);
- if (DEBUG) Log.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed"));
- removeNotificationViews(key, ranking);
- addNotificationViews(notification, ranking);
- final NotificationData.Entry newEntry = mNotificationData.findByKey(key);
- final boolean userChangedExpansion = oldEntry.row.hasUserChangedExpansion();
- if (userChangedExpansion) {
- boolean userExpanded = oldEntry.row.isUserExpanded();
- newEntry.row.setUserExpanded(userExpanded);
- newEntry.row.notifyHeightChanged();
+ if (wasHeadsUp) {
+ if (shouldInterrupt) {
+ if (DEBUG) Log.d(TAG, "rebuilding heads up for key: " + key);
+ Entry newEntry = new Entry(notification, null);
+ ViewGroup holder = mHeadsUpNotificationView.getHolder();
+ if (inflateViewsForHeadsUp(newEntry, holder)) {
+ mHeadsUpNotificationView.showNotification(newEntry);
+ if (alertAgain) {
+ resetHeadsUpDecayTimer();
+ }
+ } else {
+ Log.w(TAG, "Couldn't create new updated headsup for package "
+ + contentView.getPackage());
+ }
+ } else {
+ if (DEBUG) Log.d(TAG, "releasing heads up for key: " + key);
+ oldEntry.notification = notification;
+ mHeadsUpNotificationView.releaseAndClose();
+ return;
+ }
+ } else {
+ if (shouldInterrupt && alertAgain) {
+ if (DEBUG) Log.d(TAG, "reposting to invoke heads up for key: " + key);
+ removeNotificationViews(key, ranking);
+ addNotificationInternal(notification, ranking); //this will pop the headsup
+ } else {
+ if (DEBUG) Log.d(TAG, "rebuilding update in place for key: " + key);
+ removeNotificationViews(key, ranking);
+ addNotificationViews(notification, ranking);
+ final NotificationData.Entry newEntry = mNotificationData.findByKey(key);
+ final boolean userChangedExpansion = oldEntry.row.hasUserChangedExpansion();
+ if (userChangedExpansion) {
+ boolean userExpanded = oldEntry.row.isUserExpanded();
+ newEntry.row.setUserExpanded(userExpanded);
+ newEntry.row.notifyHeightChanged();
+ }
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index d413f63297b5..8a57ce66d7c3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1081,8 +1081,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
Entry interruptionCandidate = new Entry(notification, null);
ViewGroup holder = mHeadsUpNotificationView.getHolder();
if (inflateViewsForHeadsUp(interruptionCandidate, holder)) {
- mInterruptingNotificationTime = System.currentTimeMillis();
-
// 1. Populate mHeadsUpNotificationView
mHeadsUpNotificationView.showNotification(interruptionCandidate);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 0f6c4b254231..0a48e34b16cf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -78,8 +78,10 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
}
public boolean showNotification(NotificationData.Entry headsUp) {
- // bump any previous heads up back to the shade
- release();
+ if (mHeadsUp != null && headsUp != null && !mHeadsUp.key.equals(headsUp.key)) {
+ // bump any previous heads up back to the shade
+ release();
+ }
mHeadsUp = headsUp;
if (mContentHolder != null) {