summaryrefslogtreecommitdiff
path: root/core/java/android/app/Activity.java
diff options
context:
space:
mode:
authorYuliya Kamatkova <yuliyak@google.com>2020-01-09 15:43:25 -0800
committerYuliya Kamatkova <yuliyak@google.com>2020-01-24 11:19:10 -0800
commit48c38076efc3c759b5ee6d2a2e4476fcccd1c08a (patch)
tree779418a73b72636a1ddf77422dcaa2b5cae2a8ae /core/java/android/app/Activity.java
parent6cd07dea190b663be8e71c196d3cde41031d3469 (diff)
Add Activity#setLocusContext API. Plumb LocusID to the System Server.
Add locus update event to the Usage Stats. Test: Build and run on a test device with a test app. Bug: 147594233, 147100454 Change-Id: I1e058ac87244d47719606d8dcfaea2df4bff43d2 Signed-off-by: Yuliya Kamatkova <yuliyak@google.com>
Diffstat (limited to 'core/java/android/app/Activity.java')
-rw-r--r--core/java/android/app/Activity.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index d952be5218a4..d8b5e7f3b5b0 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -45,6 +45,7 @@ import android.content.CursorLoader;
import android.content.IIntentSender;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.LocusId;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
@@ -1025,6 +1026,39 @@ public class Activity extends ContextThemeWrapper
mIntent = newIntent;
}
+ /**
+ * Sets the {@link android.content.LocusId} for this activity. The locus id
+ * helps identify different instances of the same {@code Activity} class.
+ * <p> For example, a locus id based on a specific conversation could be set on a
+ * conversation app's chat {@code Activity}. The system can then use this locus id
+ * along with app's contents to provide ranking signals in various UI surfaces
+ * including sharing, notifications, shortcuts and so on.
+ * <p> It is recommended to set the same locus id in the shortcut's locus id using
+ * {@link android.content.pm.ShortcutInfo.Builder#setLocusId(android.content.LocusId)
+ * setLocusId}
+ * so that the system can learn appropriate ranking signals linking the activity's
+ * locus id with the matching shortcut.
+ *
+ * @param locusId a unique, stable id that identifies this {@code Activity} instance from
+ * others. This can be linked to a shortcut using
+ * {@link android.content.pm.ShortcutInfo.Builder#setLocusId(android.content.LocusId)
+ * setLocusId} with the same locus id string.
+ * @param bundle extras set or updated as part of this locus context. This may help provide
+ * additional metadata such as URLs, conversation participants specific to this
+ * {@code Activity}'s context.
+ *
+ * @see android.view.contentcapture.ContentCaptureManager
+ * @see android.view.contentcapture.ContentCaptureContext
+ */
+ public void setLocusContext(@Nullable LocusId locusId, @Nullable Bundle bundle) {
+ try {
+ ActivityManager.getService().setActivityLocusContext(mComponent, locusId, mToken);
+ } catch (RemoteException re) {
+ re.rethrowFromSystemServer();
+ }
+ // TODO(b/147750355): Pass locusId and bundle to the Content Capture.
+ }
+
/** Return the application that owns this activity. */
public final Application getApplication() {
return mApplication;