From 4d19b03fd5ac18ead6cbed7a0d9ae12580ada35b Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 17 Nov 2020 20:48:42 -0500 Subject: [PATCH] Fix Gmail undo state. We forced all notifications to have an expanded state, but the Gmail undo notification is totally broken in that case. This check exempts an obviosuly bad expanded state from having to exist, fixing Gmail's undo flow in the process. Fixes: 173774694 Bug: 163626038 Bug: 173550917 Test: manual Change-Id: I8973907ceb06ccf06c0a685fc0f2a2d283794fe5 --- core/java/android/app/Notification.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index e40247ba2d9a6..0ccd07a3a53e2 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5520,7 +5520,7 @@ public class Notification implements Parcelable result = mStyle.makeBigContentView(); hideLine1Text(result); } - if (result == null) { + if (result == null && bigContentViewRequired()) { result = applyStandardTemplateWithActions(getBigBaseLayoutResource(), StandardTemplateParams.VIEW_TYPE_BIG, null /* result */); } @@ -5528,6 +5528,16 @@ public class Notification implements Parcelable return result; } + private boolean bigContentViewRequired() { + // If the big content view has no content, we can exempt the app from having to show it. + // TODO(b/173550917): add an UNDO style then force this requirement on apps targeting S + boolean exempt = mN.contentView != null && mN.bigContentView == null + && mStyle == null && mActions.size() == 0 + && mN.extras.getCharSequence(EXTRA_TITLE) == null + && mN.extras.getCharSequence(EXTRA_TEXT) == null; + return !exempt; + } + /** * Construct a RemoteViews for the final notification header only. This will not be * colorized.