diff --git a/core/api/system-current.txt b/core/api/system-current.txt index cec2f98ec87b0..79c8035410e3b 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -197,6 +197,7 @@ package android { field public static final String READ_INSTALL_SESSIONS = "android.permission.READ_INSTALL_SESSIONS"; field public static final String READ_NETWORK_USAGE_HISTORY = "android.permission.READ_NETWORK_USAGE_HISTORY"; field public static final String READ_OEM_UNLOCK_STATE = "android.permission.READ_OEM_UNLOCK_STATE"; + field public static final String READ_PEOPLE_DATA = "android.permission.READ_PEOPLE_DATA"; field public static final String READ_PRINT_SERVICES = "android.permission.READ_PRINT_SERVICES"; field public static final String READ_PRINT_SERVICE_RECOMMENDATIONS = "android.permission.READ_PRINT_SERVICE_RECOMMENDATIONS"; field public static final String READ_PRIVILEGED_PHONE_STATE = "android.permission.READ_PRIVILEGED_PHONE_STATE"; @@ -1275,6 +1276,14 @@ package android.app.job { } +package android.app.people { + + public final class PeopleManager { + method @RequiresPermission(android.Manifest.permission.READ_PEOPLE_DATA) public boolean isConversation(@NonNull String, @NonNull String); + } + +} + package android.app.prediction { public final class AppPredictionContext implements android.os.Parcelable { diff --git a/core/java/android/app/people/IPeopleManager.aidl b/core/java/android/app/people/IPeopleManager.aidl index ebe9f60dc1507..d000f3b0b01da 100644 --- a/core/java/android/app/people/IPeopleManager.aidl +++ b/core/java/android/app/people/IPeopleManager.aidl @@ -49,6 +49,9 @@ interface IPeopleManager { /** Removes all the recent conversations and uncaches their cached shortcuts. */ void removeAllRecentConversations(); + /** Returns whether the shortcutId is backed by a Conversation in People Service. */ + boolean isConversation(in String packageName, int userId, in String shortcutId); + /** * Returns the last interaction with the specified conversation. If the * conversation can't be found or no interactions have been recorded, returns 0L. diff --git a/core/java/android/app/people/PeopleManager.java b/core/java/android/app/people/PeopleManager.java index de7ba622ae88b..d348edb6dfbf5 100644 --- a/core/java/android/app/people/PeopleManager.java +++ b/core/java/android/app/people/PeopleManager.java @@ -17,6 +17,8 @@ package android.app.people; import android.annotation.NonNull; +import android.annotation.RequiresPermission; +import android.annotation.SystemApi; import android.annotation.SystemService; import android.content.Context; import android.content.pm.ParceledListSlice; @@ -53,6 +55,33 @@ public final class PeopleManager { Context.PEOPLE_SERVICE)); } + /** + * Returns whether a shortcut has a conversation associated. + * + *
Requires android.permission.READ_PEOPLE_DATA permission. + * + *
This method may return different results for the same shortcut over time, as an app adopts
+ * conversation features or if a user hasn't communicated with the conversation associated to
+ * the shortcut in a while, so the result should not be stored and relied on indefinitely by
+ * clients.
+ *
+ * @param packageName name of the package the conversation is part of
+ * @param shortcutId the shortcut id backing the conversation
+ * @return whether the {@shortcutId} is backed by a Conversation.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PEOPLE_DATA)
+ public boolean isConversation(@NonNull String packageName, @NonNull String shortcutId) {
+ Preconditions.checkStringNotEmpty(packageName);
+ Preconditions.checkStringNotEmpty(shortcutId);
+ try {
+ return mService.isConversation(packageName, mContext.getUserId(), shortcutId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
/**
* Sets or updates a {@link ConversationStatus} for a conversation.
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 6456e4e2a59ae..e268fde4b66d1 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -5496,6 +5496,12 @@