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.