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
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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<>();
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user