summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-01-31 11:26:30 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-31 11:26:30 +0000
commit2ac2eff798c1c04fbfc483a82cc6b5b45bf41126 (patch)
tree946e2876bf69b656ba9b37356d5765eaab59175b
parentdb19aa43d0efd2cda1e62a10fb42feb6df148bab (diff)
parent1ee9c9d0b5f15f52446341c30c82ac00579dec94 (diff)
Merge "Make the smart-replies 'enabled' key control both actions and replies."
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java13
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java22
2 files changed, 29 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
index 77cdbb921273..0a04f4d11a6f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
@@ -1334,16 +1334,21 @@ public class NotificationContentView extends FrameLayout {
static SmartRepliesAndActions chooseSmartRepliesAndActions(
SmartReplyConstants smartReplyConstants,
final NotificationEntry entry) {
- boolean enableAppGeneratedSmartReplies = (smartReplyConstants.isEnabled()
- && (!smartReplyConstants.requiresTargetingP()
- || entry.targetSdk >= Build.VERSION_CODES.P));
-
Notification notification = entry.notification.getNotification();
Pair<RemoteInput, Notification.Action> remoteInputActionPair =
notification.findRemoteInputActionPair(false /* freeform */);
Pair<RemoteInput, Notification.Action> freeformRemoteInputActionPair =
notification.findRemoteInputActionPair(true /* freeform */);
+ if (!smartReplyConstants.isEnabled()) {
+ return new SmartRepliesAndActions(null, null, freeformRemoteInputActionPair != null);
+ }
+ // Only use smart replies from the app if they target P or above. We have this check because
+ // the smart reply API has been used for other things (Wearables) in the past. The API to
+ // add smart actions is new in Q so it doesn't require a target-sdk check.
+ boolean enableAppGeneratedSmartReplies = (!smartReplyConstants.requiresTargetingP()
+ || entry.targetSdk >= Build.VERSION_CODES.P);
+
boolean appGeneratedSmartRepliesExist =
enableAppGeneratedSmartReplies
&& remoteInputActionPair != null
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
index d94bf845ca5b..c36fec28459d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
@@ -193,14 +193,32 @@ public class NotificationContentViewTest extends SysuiTestCase {
}
@Test
- public void chooseSmartRepliesAndActions_smartRepliesOff_noAppGeneratedSmartReplies() {
- setupAppGeneratedReplies(new String[] {"Reply1", "Reply2"});
+ public void chooseSmartRepliesAndActions_smartRepliesOff_noAppGeneratedSmartSuggestions() {
+ CharSequence[] smartReplies = new String[] {"Reply1", "Reply2"};
+ List<Notification.Action> smartActions =
+ createActions(new String[] {"Test Action 1", "Test Action 2"});
+ setupAppGeneratedSuggestions(smartReplies, smartActions);
+ when(mSmartReplyConstants.isEnabled()).thenReturn(false);
+
+ NotificationContentView.SmartRepliesAndActions repliesAndActions =
+ NotificationContentView.chooseSmartRepliesAndActions(mSmartReplyConstants, mEntry);
+
+ assertThat(repliesAndActions.smartReplies).isNull();
+ assertThat(repliesAndActions.smartActions).isNull();
+ }
+
+ @Test
+ public void chooseSmartRepliesAndActions_smartRepliesOff_noSystemGeneratedSmartSuggestions() {
+ mEntry.smartReplies = new String[] {"Sys Smart Reply 1", "Sys Smart Reply 2"};
+ mEntry.systemGeneratedSmartActions =
+ createActions(new String[] {"Sys Smart Action 1", "Sys Smart Action 2"});
when(mSmartReplyConstants.isEnabled()).thenReturn(false);
NotificationContentView.SmartRepliesAndActions repliesAndActions =
NotificationContentView.chooseSmartRepliesAndActions(mSmartReplyConstants, mEntry);
assertThat(repliesAndActions.smartReplies).isNull();
+ assertThat(repliesAndActions.smartActions).isNull();
}
@Test