diff --git a/api/current.txt b/api/current.txt index aec29fd91d29a..0878e7e666445 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4000,6 +4000,7 @@ package android.app { ctor public AssistContent(); method public android.content.ClipData getClipData(); method public android.net.Uri getWebUri(); + method public boolean isAppProvidedIntent(); method public void setClipData(android.content.ClipData); method public void setIntent(android.content.Intent); method public void setWebUri(android.net.Uri); diff --git a/api/system-current.txt b/api/system-current.txt index 3cceadc9812e2..198393664a6d1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4096,6 +4096,7 @@ package android.app { ctor public AssistContent(); method public android.content.ClipData getClipData(); method public android.net.Uri getWebUri(); + method public boolean isAppProvidedIntent(); method public void setClipData(android.content.ClipData); method public void setIntent(android.content.Intent); method public void setWebUri(android.net.Uri); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 10d76f750ac5c..3d26ccd6cc806 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -2584,9 +2584,9 @@ public final class ActivityThread { intent.setFlags(intent.getFlags() & ~(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)); intent.removeUnsafeExtras(); - content.setIntent(intent); + content.setDefaultIntent(intent); } else { - content.setIntent(new Intent()); + content.setDefaultIntent(new Intent()); } r.activity.onProvideAssistContent(content); } diff --git a/core/java/android/app/AssistContent.java b/core/java/android/app/AssistContent.java index 4cb89a81005eb..8c98aa9d76059 100644 --- a/core/java/android/app/AssistContent.java +++ b/core/java/android/app/AssistContent.java @@ -31,6 +31,7 @@ import android.os.Parcelable; */ @Deprecated public class AssistContent { + private boolean mIsAppProvidedIntent = false; private Intent mIntent; private ClipData mClipData; private Uri mUri; @@ -55,12 +56,14 @@ public class AssistContent { } /** - * Sets the Intent associated with the content, describing the current top-level context of - * the activity. If this contains a reference to a piece of data related to the activity, - * be sure to set {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} so the accessibility - * service can access it. + * @hide + * Called by {@link android.app.ActivityThread} to set the default Intent based on + * {@link android.app.Activity#getIntent Activity.getIntent}. + * + *

Automatically populates {@link #mUri} if that Intent is an {@link Intent#ACTION_VIEW} + * of a web (http or https scheme) URI.

*/ - public void setIntent(Intent intent) { + public void setDefaultIntent(Intent intent) { mIntent = intent; setWebUri(null); if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { @@ -72,13 +75,35 @@ public class AssistContent { } /** - * Return the current {@link #setIntent}, which you can modify in-place. + * Sets the Intent associated with the content, describing the current top-level context of + * the activity. If this contains a reference to a piece of data related to the activity, + * be sure to set {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} so the accessibility + * service can access it. + */ + public void setIntent(Intent intent) { + mIsAppProvidedIntent = true; + mIntent = intent; + } + + /** + * Returns the current {@link #setIntent} if one is set, else the default Intent obtained from + * {@link android.app.Activity#getIntent Activity.getIntent}. Can be modified in-place. * @hide */ public Intent getIntent() { return mIntent; } + /** + * Returns whether or not the current Intent was explicitly provided in + * {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}. If not, + * the Intent was automatically set based on + * {@link android.app.Activity#getIntent Activity.getIntent}. + */ + public boolean isAppProvidedIntent() { + return mIsAppProvidedIntent; + } + /** * Optional additional content items that are involved with * the current UI. Access to this content will be granted to the assistant as if you @@ -103,9 +128,6 @@ public class AssistContent { * off the device into other environments to acesss the same data as is currently * being shown in the app; if the app does not have such a representation, it should * leave the null and only report the local intent and clip data. - * - *

This will be automatically populated for you from {@link #setIntent} if that Intent - * is an {@link Intent#ACTION_VIEW} of a web (http or https scheme) URI.

*/ public void setWebUri(Uri uri) { mUri = uri;