Loading api/current.txt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -5229,6 +5229,7 @@ package android.app { ctor public Notification(android.os.Parcel); ctor public Notification(android.os.Parcel); method public android.app.Notification clone(); method public android.app.Notification clone(); method public int describeContents(); method public int describeContents(); method public boolean getAllowSystemGeneratedContextualActions(); method public android.app.PendingIntent getAppOverlayIntent(); method public android.app.PendingIntent getAppOverlayIntent(); method public int getBadgeIconType(); method public int getBadgeIconType(); method public java.lang.String getChannelId(); method public java.lang.String getChannelId(); Loading Loading @@ -5460,6 +5461,7 @@ package android.app { method public android.app.Notification.Style getStyle(); method public android.app.Notification.Style getStyle(); method public static android.app.Notification.Builder recoverBuilder(android.content.Context, android.app.Notification); method public static android.app.Notification.Builder recoverBuilder(android.content.Context, android.app.Notification); method public android.app.Notification.Builder setActions(android.app.Notification.Action...); method public android.app.Notification.Builder setActions(android.app.Notification.Action...); method public android.app.Notification.Builder setAllowSystemGeneratedContextualActions(boolean); method public android.app.Notification.Builder setAppOverlayIntent(android.app.PendingIntent); method public android.app.Notification.Builder setAppOverlayIntent(android.app.PendingIntent); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setBadgeIconType(int); method public android.app.Notification.Builder setBadgeIconType(int); core/java/android/app/Notification.java +23 −0 Original line number Original line Diff line number Diff line Loading @@ -1337,6 +1337,11 @@ public class Notification implements Parcelable public static final int BADGE_ICON_LARGE = 2; public static final int BADGE_ICON_LARGE = 2; private int mBadgeIcon = BADGE_ICON_NONE; private int mBadgeIcon = BADGE_ICON_NONE; /** * Determines whether the platform can generate contextual actions for a notification. */ private boolean mAllowSystemGeneratedContextualActions = true; /** /** * Structure to encapsulate a named action that can be shown as part of this notification. * Structure to encapsulate a named action that can be shown as part of this notification. * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is Loading Loading @@ -2238,6 +2243,8 @@ public class Notification implements Parcelable if (parcel.readInt() != 0) { if (parcel.readInt() != 0) { mAppOverlayIntent = PendingIntent.CREATOR.createFromParcel(parcel); mAppOverlayIntent = PendingIntent.CREATOR.createFromParcel(parcel); } } mAllowSystemGeneratedContextualActions = parcel.readBoolean(); } } @Override @Override Loading Loading @@ -2353,6 +2360,7 @@ public class Notification implements Parcelable that.mSettingsText = this.mSettingsText; that.mSettingsText = this.mSettingsText; that.mGroupAlertBehavior = this.mGroupAlertBehavior; that.mGroupAlertBehavior = this.mGroupAlertBehavior; that.mAppOverlayIntent = this.mAppOverlayIntent; that.mAppOverlayIntent = this.mAppOverlayIntent; that.mAllowSystemGeneratedContextualActions = this.mAllowSystemGeneratedContextualActions; if (!heavy) { if (!heavy) { that.lightenPayload(); // will clean out extras that.lightenPayload(); // will clean out extras Loading Loading @@ -2681,6 +2689,8 @@ public class Notification implements Parcelable parcel.writeInt(0); parcel.writeInt(0); } } parcel.writeBoolean(mAllowSystemGeneratedContextualActions); // mUsesStandardHeader is not written because it should be recomputed in listeners // mUsesStandardHeader is not written because it should be recomputed in listeners } } Loading Loading @@ -3101,6 +3111,10 @@ public class Notification implements Parcelable return mAppOverlayIntent; return mAppOverlayIntent; } } public boolean getAllowSystemGeneratedContextualActions() { return mAllowSystemGeneratedContextualActions; } /** /** * The small icon representing this notification in the status bar and content view. * The small icon representing this notification in the status bar and content view. * * Loading Loading @@ -5656,6 +5670,15 @@ public class Notification implements Parcelable return new Builder(builderContext, n); return new Builder(builderContext, n); } } /** * Determines whether the platform can generate contextual actions for a notification. * By default this is true. */ public Builder setAllowSystemGeneratedContextualActions(boolean allowed) { mN.mAllowSystemGeneratedContextualActions = allowed; return this; } /** /** * @deprecated Use {@link #build()} instead. * @deprecated Use {@link #build()} instead. */ */ Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -55,6 +55,7 @@ import com.android.systemui.statusbar.policy.RemoteInputView; import com.android.systemui.statusbar.policy.SmartReplyConstants; import com.android.systemui.statusbar.policy.SmartReplyConstants; import com.android.systemui.statusbar.policy.SmartReplyView; import com.android.systemui.statusbar.policy.SmartReplyView; import java.util.Collections; import java.util.List; import java.util.List; /** /** Loading Loading @@ -1322,6 +1323,10 @@ public class NotificationContentView extends FrameLayout { List<Notification.Action> appGeneratedSmartActions = notification.getContextualActions(); List<Notification.Action> appGeneratedSmartActions = notification.getContextualActions(); boolean appGeneratedSmartActionsExist = !appGeneratedSmartActions.isEmpty(); boolean appGeneratedSmartActionsExist = !appGeneratedSmartActions.isEmpty(); List<Notification.Action> sysGeneratedSmartActions = notification.getAllowSystemGeneratedContextualActions() ? entry.systemGeneratedSmartActions : Collections.emptyList(); if (appGeneratedSmartRepliesExist) { if (appGeneratedSmartRepliesExist) { return new SmartRepliesAndActions(remoteInputActionPair.first, return new SmartRepliesAndActions(remoteInputActionPair.first, remoteInputActionPair.second.actionIntent, remoteInputActionPair.second.actionIntent, Loading @@ -1338,11 +1343,11 @@ public class NotificationContentView extends FrameLayout { return new SmartRepliesAndActions(freeformRemoteInputActionPair.first, return new SmartRepliesAndActions(freeformRemoteInputActionPair.first, freeformRemoteInputActionPair.second.actionIntent, freeformRemoteInputActionPair.second.actionIntent, entry.smartReplies, entry.smartReplies, entry.systemGeneratedSmartActions, sysGeneratedSmartActions, freeformRemoteInputActionPair); freeformRemoteInputActionPair); } } // App didn't generate anything, and there are no NAS-generated smart replies. // App didn't generate anything, and there are no NAS-generated smart replies. return new SmartRepliesAndActions(null, null, null, entry.systemGeneratedSmartActions, return new SmartRepliesAndActions(null, null, null, sysGeneratedSmartActions, freeformRemoteInputActionPair); freeformRemoteInputActionPair); } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -106,7 +106,8 @@ public class NotificationContentViewTest extends SysuiTestCase { mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight()); mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight()); // Smart replies // Smart replies and actions when(mNotification.getAllowSystemGeneratedContextualActions()).thenReturn(true); when(mStatusBarNotification.getNotification()).thenReturn(mNotification); when(mStatusBarNotification.getNotification()).thenReturn(mNotification); mEntry = new NotificationData.Entry(mStatusBarNotification); mEntry = new NotificationData.Entry(mStatusBarNotification); when(mSmartReplyConstants.isEnabled()).thenReturn(true); when(mSmartReplyConstants.isEnabled()).thenReturn(true); Loading Loading @@ -299,6 +300,23 @@ public class NotificationContentViewTest extends SysuiTestCase { assertThat(repliesAndActions.smartActions, equalTo(appGenSmartActions)); assertThat(repliesAndActions.smartActions, equalTo(appGenSmartActions)); } } @Test public void chooseSmartRepliesAndActions_disallowSysGenSmartActions() { // Pass a null-array as app-generated smart replies, so that we use NAS-generated smart // actions. setupAppGeneratedReplies(null); when(mNotification.getAllowSystemGeneratedContextualActions()).thenReturn(false); mEntry.systemGeneratedSmartActions = createActions(new String[] {"Sys Smart Action 1", "Sys Smart Action 2"}); NotificationContentView.SmartRepliesAndActions repliesAndActions = NotificationContentView.chooseSmartRepliesAndActions(mSmartReplyConstants, mEntry); assertThat(repliesAndActions.smartReplies, equalTo(null)); assertThat(repliesAndActions.smartActions, is(empty())); } private Notification.Action.Builder createActionBuilder(String actionTitle) { private Notification.Action.Builder createActionBuilder(String actionTitle) { PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(TEST_ACTION), 0); new Intent(TEST_ACTION), 0); Loading Loading
api/current.txt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -5229,6 +5229,7 @@ package android.app { ctor public Notification(android.os.Parcel); ctor public Notification(android.os.Parcel); method public android.app.Notification clone(); method public android.app.Notification clone(); method public int describeContents(); method public int describeContents(); method public boolean getAllowSystemGeneratedContextualActions(); method public android.app.PendingIntent getAppOverlayIntent(); method public android.app.PendingIntent getAppOverlayIntent(); method public int getBadgeIconType(); method public int getBadgeIconType(); method public java.lang.String getChannelId(); method public java.lang.String getChannelId(); Loading Loading @@ -5460,6 +5461,7 @@ package android.app { method public android.app.Notification.Style getStyle(); method public android.app.Notification.Style getStyle(); method public static android.app.Notification.Builder recoverBuilder(android.content.Context, android.app.Notification); method public static android.app.Notification.Builder recoverBuilder(android.content.Context, android.app.Notification); method public android.app.Notification.Builder setActions(android.app.Notification.Action...); method public android.app.Notification.Builder setActions(android.app.Notification.Action...); method public android.app.Notification.Builder setAllowSystemGeneratedContextualActions(boolean); method public android.app.Notification.Builder setAppOverlayIntent(android.app.PendingIntent); method public android.app.Notification.Builder setAppOverlayIntent(android.app.PendingIntent); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setBadgeIconType(int); method public android.app.Notification.Builder setBadgeIconType(int);
core/java/android/app/Notification.java +23 −0 Original line number Original line Diff line number Diff line Loading @@ -1337,6 +1337,11 @@ public class Notification implements Parcelable public static final int BADGE_ICON_LARGE = 2; public static final int BADGE_ICON_LARGE = 2; private int mBadgeIcon = BADGE_ICON_NONE; private int mBadgeIcon = BADGE_ICON_NONE; /** * Determines whether the platform can generate contextual actions for a notification. */ private boolean mAllowSystemGeneratedContextualActions = true; /** /** * Structure to encapsulate a named action that can be shown as part of this notification. * Structure to encapsulate a named action that can be shown as part of this notification. * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is Loading Loading @@ -2238,6 +2243,8 @@ public class Notification implements Parcelable if (parcel.readInt() != 0) { if (parcel.readInt() != 0) { mAppOverlayIntent = PendingIntent.CREATOR.createFromParcel(parcel); mAppOverlayIntent = PendingIntent.CREATOR.createFromParcel(parcel); } } mAllowSystemGeneratedContextualActions = parcel.readBoolean(); } } @Override @Override Loading Loading @@ -2353,6 +2360,7 @@ public class Notification implements Parcelable that.mSettingsText = this.mSettingsText; that.mSettingsText = this.mSettingsText; that.mGroupAlertBehavior = this.mGroupAlertBehavior; that.mGroupAlertBehavior = this.mGroupAlertBehavior; that.mAppOverlayIntent = this.mAppOverlayIntent; that.mAppOverlayIntent = this.mAppOverlayIntent; that.mAllowSystemGeneratedContextualActions = this.mAllowSystemGeneratedContextualActions; if (!heavy) { if (!heavy) { that.lightenPayload(); // will clean out extras that.lightenPayload(); // will clean out extras Loading Loading @@ -2681,6 +2689,8 @@ public class Notification implements Parcelable parcel.writeInt(0); parcel.writeInt(0); } } parcel.writeBoolean(mAllowSystemGeneratedContextualActions); // mUsesStandardHeader is not written because it should be recomputed in listeners // mUsesStandardHeader is not written because it should be recomputed in listeners } } Loading Loading @@ -3101,6 +3111,10 @@ public class Notification implements Parcelable return mAppOverlayIntent; return mAppOverlayIntent; } } public boolean getAllowSystemGeneratedContextualActions() { return mAllowSystemGeneratedContextualActions; } /** /** * The small icon representing this notification in the status bar and content view. * The small icon representing this notification in the status bar and content view. * * Loading Loading @@ -5656,6 +5670,15 @@ public class Notification implements Parcelable return new Builder(builderContext, n); return new Builder(builderContext, n); } } /** * Determines whether the platform can generate contextual actions for a notification. * By default this is true. */ public Builder setAllowSystemGeneratedContextualActions(boolean allowed) { mN.mAllowSystemGeneratedContextualActions = allowed; return this; } /** /** * @deprecated Use {@link #build()} instead. * @deprecated Use {@link #build()} instead. */ */ Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -55,6 +55,7 @@ import com.android.systemui.statusbar.policy.RemoteInputView; import com.android.systemui.statusbar.policy.SmartReplyConstants; import com.android.systemui.statusbar.policy.SmartReplyConstants; import com.android.systemui.statusbar.policy.SmartReplyView; import com.android.systemui.statusbar.policy.SmartReplyView; import java.util.Collections; import java.util.List; import java.util.List; /** /** Loading Loading @@ -1322,6 +1323,10 @@ public class NotificationContentView extends FrameLayout { List<Notification.Action> appGeneratedSmartActions = notification.getContextualActions(); List<Notification.Action> appGeneratedSmartActions = notification.getContextualActions(); boolean appGeneratedSmartActionsExist = !appGeneratedSmartActions.isEmpty(); boolean appGeneratedSmartActionsExist = !appGeneratedSmartActions.isEmpty(); List<Notification.Action> sysGeneratedSmartActions = notification.getAllowSystemGeneratedContextualActions() ? entry.systemGeneratedSmartActions : Collections.emptyList(); if (appGeneratedSmartRepliesExist) { if (appGeneratedSmartRepliesExist) { return new SmartRepliesAndActions(remoteInputActionPair.first, return new SmartRepliesAndActions(remoteInputActionPair.first, remoteInputActionPair.second.actionIntent, remoteInputActionPair.second.actionIntent, Loading @@ -1338,11 +1343,11 @@ public class NotificationContentView extends FrameLayout { return new SmartRepliesAndActions(freeformRemoteInputActionPair.first, return new SmartRepliesAndActions(freeformRemoteInputActionPair.first, freeformRemoteInputActionPair.second.actionIntent, freeformRemoteInputActionPair.second.actionIntent, entry.smartReplies, entry.smartReplies, entry.systemGeneratedSmartActions, sysGeneratedSmartActions, freeformRemoteInputActionPair); freeformRemoteInputActionPair); } } // App didn't generate anything, and there are no NAS-generated smart replies. // App didn't generate anything, and there are no NAS-generated smart replies. return new SmartRepliesAndActions(null, null, null, entry.systemGeneratedSmartActions, return new SmartRepliesAndActions(null, null, null, sysGeneratedSmartActions, freeformRemoteInputActionPair); freeformRemoteInputActionPair); } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -106,7 +106,8 @@ public class NotificationContentViewTest extends SysuiTestCase { mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight()); mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight()); // Smart replies // Smart replies and actions when(mNotification.getAllowSystemGeneratedContextualActions()).thenReturn(true); when(mStatusBarNotification.getNotification()).thenReturn(mNotification); when(mStatusBarNotification.getNotification()).thenReturn(mNotification); mEntry = new NotificationData.Entry(mStatusBarNotification); mEntry = new NotificationData.Entry(mStatusBarNotification); when(mSmartReplyConstants.isEnabled()).thenReturn(true); when(mSmartReplyConstants.isEnabled()).thenReturn(true); Loading Loading @@ -299,6 +300,23 @@ public class NotificationContentViewTest extends SysuiTestCase { assertThat(repliesAndActions.smartActions, equalTo(appGenSmartActions)); assertThat(repliesAndActions.smartActions, equalTo(appGenSmartActions)); } } @Test public void chooseSmartRepliesAndActions_disallowSysGenSmartActions() { // Pass a null-array as app-generated smart replies, so that we use NAS-generated smart // actions. setupAppGeneratedReplies(null); when(mNotification.getAllowSystemGeneratedContextualActions()).thenReturn(false); mEntry.systemGeneratedSmartActions = createActions(new String[] {"Sys Smart Action 1", "Sys Smart Action 2"}); NotificationContentView.SmartRepliesAndActions repliesAndActions = NotificationContentView.chooseSmartRepliesAndActions(mSmartReplyConstants, mEntry); assertThat(repliesAndActions.smartReplies, equalTo(null)); assertThat(repliesAndActions.smartActions, is(empty())); } private Notification.Action.Builder createActionBuilder(String actionTitle) { private Notification.Action.Builder createActionBuilder(String actionTitle) { PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(TEST_ACTION), 0); new Intent(TEST_ACTION), 0); Loading