Merge "Block FullScreenIntent while device is in use if notification has a silencing GroupAlertBehavior." into qt-dev am: b38c650ea9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19346142

Change-Id: If6faade37cf6df1dcd7a1574b341b4fc9f3dabbd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jeff DeCew
2022-08-02 12:22:05 +00:00
committed by Automerger Merge Worker

View File

@@ -201,6 +201,89 @@ public class NotificationInterruptionStateProvider {
return true;
}
public boolean shouldLaunchFullScreenIntentWhenAdded(NotificationEntry entry) {
if (entry.notification.getNotification().fullScreenIntent == null) {
return false;
}
// Never show FSI when suppressed by DND
if (entry.shouldSuppressFullScreenIntent()) {
if (DEBUG) {
Log.d(TAG, "No FullScreenIntent: Suppressed by DND: " + entry.key);
}
return false;
}
// Never show FSI if importance is not HIGH
if (entry.importance < NotificationManager.IMPORTANCE_HIGH) {
if (DEBUG) {
Log.d(TAG, "No FullScreenIntent: Not important enough: " + entry.key);
}
return false;
}
// If the notification has suppressive GroupAlertBehavior, block FSI and warn.
StatusBarNotification sbn = entry.notification;
if (sbn.isGroup() && sbn.getNotification().suppressAlertingDueToGrouping()) {
// b/231322873: Detect and report an event when a notification has both an FSI and a
// suppressive groupAlertBehavior, and now correctly block the FSI from firing.
final int uid = entry.notification.getUid();
android.util.EventLog.writeEvent(0x534e4554, "231322873", uid, "groupAlertBehavior");
if (DEBUG) {
Log.w(TAG, "No FullScreenIntent: WARNING: GroupAlertBehavior will prevent HUN: "
+ entry.key);
}
return false;
}
// If the screen is off, then launch the FullScreenIntent
if (!mPowerManager.isInteractive()) {
if (DEBUG) {
Log.d(TAG, "FullScreenIntent: Device is not interactive: " + entry.key);
}
return true;
}
// If the device is currently dreaming, then launch the FullScreenIntent
if (isDreaming()) {
if (DEBUG) {
Log.d(TAG, "FullScreenIntent: Device is dreaming: " + entry.key);
}
return true;
}
// If the keyguard is showing, then launch the FullScreenIntent
if (mStatusBarStateController.getState() == StatusBarState.KEYGUARD) {
if (DEBUG) {
Log.d(TAG, "FullScreenIntent: Keyguard is showing: " + entry.key);
}
return true;
}
// If the notification should HUN, then we don't need FSI
if (shouldHeadsUp(entry)) {
if (DEBUG) {
Log.d(TAG, "No FullScreenIntent: Expected to HUN: " + entry.key);
}
return false;
}
// If the notification won't HUN for some other reason (DND/snooze/etc), launch FSI.
if (DEBUG) {
Log.d(TAG, "FullScreenIntent: Expected not to HUN: " + entry.key);
}
return true;
}
private boolean isDreaming() {
try {
return mDreamManager.isDreaming();
} catch (RemoteException e) {
Log.e(TAG, "Failed to query dream manager.", e);
return false;
}
}
/**
* Whether the notification should peek in from the top and alert the user.
*
@@ -256,13 +339,7 @@ public class NotificationInterruptionStateProvider {
return false;
}
boolean isDreaming = false;
try {
isDreaming = mDreamManager.isDreaming();
} catch (RemoteException e) {
Log.e(TAG, "Failed to query dream manager.", e);
}
boolean inUse = mPowerManager.isScreenOn() && !isDreaming;
boolean inUse = mPowerManager.isScreenOn() && !isDreaming();
if (!inUse) {
if (DEBUG_HEADS_UP) {