diff options
author | Selim Cinek <cinek@google.com> | 2015-06-04 17:08:35 +0200 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2015-06-04 17:08:35 +0200 |
commit | b18a20f13cc5fc36b84f19bb89a9e479bb1fb4ea (patch) | |
tree | 3d477366e8832458778e384c411325f900c5d0d9 | |
parent | ab06923576d4a49bc84c94badfcebcb7f6b103a8 (diff) | |
download | frameworks_base-b18a20f13cc5fc36b84f19bb89a9e479bb1fb4ea.zip frameworks_base-b18a20f13cc5fc36b84f19bb89a9e479bb1fb4ea.tar.gz frameworks_base-b18a20f13cc5fc36b84f19bb89a9e479bb1fb4ea.tar.bz2 |
Fixed a bug with HUNS and dreams
When a notification came in dreamMode and would become a HUN
we were firing its fullscreen intent imediatelly. If that notification
got updated again a moment later, it would also show an additional
HUN even though we just launched the fullscreen intent. This is very
troublesome to handle on the app level, as the notification state
is the same. We are now introducing a cooldown for HUNs when it just
launched a fullscreen intent.
Bug: 19377091
Change-Id: Ib32341c8983f0e977354432ea8d8e98909a13829
3 files changed, 21 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index fa172a4..f23efe5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -1904,7 +1904,7 @@ public abstract class BaseStatusBar extends SystemUI implements logUpdate(entry, n); } boolean applyInPlace = shouldApplyInPlace(entry, n); - boolean shouldInterrupt = shouldInterrupt(notification); + boolean shouldInterrupt = shouldInterrupt(entry); boolean alertAgain = alertAgain(entry, n); entry.notification = notification; @@ -2075,7 +2075,8 @@ public abstract class BaseStatusBar extends SystemUI implements || (newNotification.flags & Notification.FLAG_ONLY_ALERT_ONCE) == 0; } - protected boolean shouldInterrupt(StatusBarNotification sbn) { + protected boolean shouldInterrupt(Entry entry) { + StatusBarNotification sbn = entry.notification; if (mNotificationData.shouldFilterOut(sbn)) { if (DEBUG) { Log.d(TAG, "Skipping HUN check for " + sbn.getKey() + " since it's filtered out."); @@ -2100,10 +2101,12 @@ public abstract class BaseStatusBar extends SystemUI implements Notification.HEADS_UP_ALLOWED) != Notification.HEADS_UP_NEVER; boolean accessibilityForcesLaunch = isFullscreen && mAccessibilityManager.isTouchExplorationEnabled(); + boolean justLaunchedFullScreenIntent = entry.hasJustLaunchedFullScreenIntent(); boolean interrupt = (isFullscreen || (isHighPriority && (isNoisy || hasTicker))) && isAllowed && !accessibilityForcesLaunch + && !justLaunchedFullScreenIntent && mPowerManager.isScreenOn() && (!mStatusBarKeyguardViewManager.isShowing() || mStatusBarKeyguardViewManager.isOccluded()) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java index 2a8b4ac..dbabe3f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java @@ -17,6 +17,7 @@ package com.android.systemui.statusbar; import android.app.Notification; +import android.os.SystemClock; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.NotificationListenerService.RankingMap; @@ -41,6 +42,8 @@ public class NotificationData { private HeadsUpManager mHeadsUpManager; public static final class Entry { + private static final long LAUNCH_COOLDOWN = 2000; + private static final long NOT_LAUNCHED_YET = -LAUNCH_COOLDOWN; public String key; public StatusBarNotification notification; public StatusBarIconView icon; @@ -49,6 +52,7 @@ public class NotificationData { public boolean autoRedacted; // whether the redacted notification was generated by us public boolean legacy; // whether the notification has a legacy, dark background public int targetSdk; + private long lastFullScreenIntentLaunchTime = NOT_LAUNCHED_YET; public Entry(StatusBarNotification n, StatusBarIconView ic) { this.key = n.getKey(); @@ -72,6 +76,7 @@ public class NotificationData { // We should fix this at some point. autoRedacted = false; legacy = false; + lastFullScreenIntentLaunchTime = NOT_LAUNCHED_YET; if (row != null) { row.reset(); } @@ -92,6 +97,14 @@ public class NotificationData { public View getPublicContentView() { return row.getPublicLayout().getContractedChild(); } + + public void notifyFullScreenIntentLaunched() { + lastFullScreenIntentLaunchTime = SystemClock.elapsedRealtime(); + } + + public boolean hasJustLaunchedFullScreenIntent() { + return SystemClock.elapsedRealtime() < lastFullScreenIntentLaunchTime + LAUNCH_COOLDOWN; + } } private final ArrayMap<String, Entry> mEntries = new ArrayMap<>(); 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 1e4aa61..ff3f35b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1132,7 +1132,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (shadeEntry == null) { return; } - boolean isHeadsUped = mUseHeadsUp && shouldInterrupt(notification); + boolean isHeadsUped = mUseHeadsUp && shouldInterrupt(shadeEntry); if (isHeadsUped) { mHeadsUpManager.showNotification(shadeEntry); // Mark as seen immediately @@ -1150,6 +1150,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, notification.getKey()); notification.getNotification().fullScreenIntent.send(); + shadeEntry.notifyFullScreenIntentLaunched(); } catch (PendingIntent.CanceledException e) { } } @@ -2014,6 +2015,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, sbn.getKey()); notification.fullScreenIntent.send(); + entry.entry.notifyFullScreenIntentLaunched(); } catch (PendingIntent.CanceledException e) { } } |