summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-11-27 19:51:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-11-27 19:51:55 +0000
commit20dbbf22b8ef69a9556ae729c2c60a12c60a3d8f (patch)
tree82dcd2554bc3719d834213a93c21242de9feaf35 /core/java/android
parentd30510904ed2297f3eb2381b59c0dc5cab0a3d5e (diff)
parent299967040661f0722585c9a3a180069cdfb14d75 (diff)
Merge "Add onSuggestedReplySent in NotificationAssistantService"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/service/notification/INotificationListener.aidl1
-rw-r--r--core/java/android/service/notification/NotificationAssistantService.java38
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java5
3 files changed, 44 insertions, 0 deletions
diff --git a/core/java/android/service/notification/INotificationListener.aidl b/core/java/android/service/notification/INotificationListener.aidl
index 0988510f5503..ab94f432968c 100644
--- a/core/java/android/service/notification/INotificationListener.aidl
+++ b/core/java/android/service/notification/INotificationListener.aidl
@@ -49,4 +49,5 @@ oneway interface INotificationListener
void onNotificationsSeen(in List<String> keys);
void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded);
void onNotificationDirectReply(String key);
+ void onSuggestedReplySent(String key, in CharSequence reply, int source);
}
diff --git a/core/java/android/service/notification/NotificationAssistantService.java b/core/java/android/service/notification/NotificationAssistantService.java
index 90f4792face9..68da83f9e7d8 100644
--- a/core/java/android/service/notification/NotificationAssistantService.java
+++ b/core/java/android/service/notification/NotificationAssistantService.java
@@ -16,6 +16,9 @@
package android.service.notification;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import android.annotation.IntDef;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -33,6 +36,7 @@ import android.util.Log;
import com.android.internal.os.SomeArgs;
+import java.lang.annotation.Retention;
import java.util.List;
/**
@@ -63,6 +67,13 @@ import java.util.List;
public abstract class NotificationAssistantService extends NotificationListenerService {
private static final String TAG = "NotificationAssistants";
+ /** @hide */
+ @Retention(SOURCE)
+ @IntDef({SOURCE_FROM_APP, SOURCE_FROM_ASSISTANT})
+ public @interface Source {}
+ public static final int SOURCE_FROM_APP = 0;
+ public static final int SOURCE_FROM_ASSISTANT = 1;
+
/**
* The {@link Intent} that must be declared as handled by the service.
*/
@@ -175,6 +186,14 @@ public abstract class NotificationAssistantService extends NotificationListenerS
public void onNotificationDirectReply(String key) {}
/**
+ * Implement this to know when a suggested reply is sent.
+ * @param key the notification key
+ * @param reply the reply that is just sent
+ * @param source the source of the reply, e.g. SOURCE_FROM_APP
+ */
+ public void onSuggestedReplySent(String key, CharSequence reply, @Source int source) {}
+
+ /**
* Updates a notification. N.B. this won’t cause
* an existing notification to alert, but might allow a future update to
* this notification to alert.
@@ -289,6 +308,15 @@ public abstract class NotificationAssistantService extends NotificationListenerS
mHandler.obtainMessage(MyHandler.MSG_ON_NOTIFICATION_DIRECT_REPLY_SENT, args)
.sendToTarget();
}
+
+ @Override
+ public void onSuggestedReplySent(String key, CharSequence reply, int source) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = key;
+ args.arg2 = reply;
+ args.argi2 = source;
+ mHandler.obtainMessage(MyHandler.MSG_ON_SUGGESTED_REPLY_SENT, args).sendToTarget();
+ }
}
private final class MyHandler extends Handler {
@@ -297,6 +325,7 @@ public abstract class NotificationAssistantService extends NotificationListenerS
public static final int MSG_ON_NOTIFICATIONS_SEEN = 3;
public static final int MSG_ON_NOTIFICATION_EXPANSION_CHANGED = 4;
public static final int MSG_ON_NOTIFICATION_DIRECT_REPLY_SENT = 5;
+ public static final int MSG_ON_SUGGESTED_REPLY_SENT = 6;
public MyHandler(Looper looper) {
super(looper, null, false);
@@ -357,6 +386,15 @@ public abstract class NotificationAssistantService extends NotificationListenerS
onNotificationDirectReply(key);
break;
}
+ case MSG_ON_SUGGESTED_REPLY_SENT: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ String key = (String) args.arg1;
+ CharSequence reply = (CharSequence) args.arg2;
+ int source = args.argi2;
+ args.recycle();
+ onSuggestedReplySent(key, reply, source);
+ break;
+ }
}
}
}
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index a4db4517bd9a..756a7c6a54b0 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -1377,6 +1377,11 @@ public abstract class NotificationListenerService extends Service {
}
@Override
+ public void onSuggestedReplySent(String key, CharSequence reply, int source) {
+ // no-op in the listener
+ }
+
+ @Override
public void onNotificationChannelModification(String pkgName, UserHandle user,
NotificationChannel channel,
@ChannelOrGroupModificationTypes int modificationType) {