Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd70c64f authored by Adam Skory's avatar Adam Skory
Browse files

Record provision of custom Intents in AssistContent

Simplifies behavior wrt automatically setting the
web URI for ACTION_VIEW Intents, by not doing so
for custom Intents.

Adds a boolean isAppProvidedIntent() as a signal for
recepients of the AssistContent that a custom Intent
was provided. Custom Intents are more likely to be
relevant.

Change-Id: Ibe4bfa040eba904411b9820ab4ddfcf509413829
parent c554b77b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
@@ -24488,10 +24489,10 @@ package android.provider {
  public final class AlarmClock {
    ctor public AlarmClock();
    field public static final java.lang.String ACTION_DISMISS_ALARM = "android.intent.action.DISMISS_ALARM";
    field public static final java.lang.String ACTION_SET_ALARM = "android.intent.action.SET_ALARM";
    field public static final java.lang.String ACTION_SET_TIMER = "android.intent.action.SET_TIMER";
    field public static final java.lang.String ACTION_SHOW_ALARMS = "android.intent.action.SHOW_ALARMS";
    field public static final java.lang.String ACTION_DISMISS_ALARM = "android.intent.action.DISMISS_ALARM";
    field public static final java.lang.String ACTION_SNOOZE_ALARM = "android.intent.action.SNOOZE_ALARM";
    field public static final java.lang.String ALARM_SEARCH_MODE_ALL = "android.all";
    field public static final java.lang.String ALARM_SEARCH_MODE_LABEL = "android.label";
+2 −1
Original line number Diff line number Diff line
@@ -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);
@@ -26418,10 +26419,10 @@ package android.provider {
  public final class AlarmClock {
    ctor public AlarmClock();
    field public static final java.lang.String ACTION_DISMISS_ALARM = "android.intent.action.DISMISS_ALARM";
    field public static final java.lang.String ACTION_SET_ALARM = "android.intent.action.SET_ALARM";
    field public static final java.lang.String ACTION_SET_TIMER = "android.intent.action.SET_TIMER";
    field public static final java.lang.String ACTION_SHOW_ALARMS = "android.intent.action.SHOW_ALARMS";
    field public static final java.lang.String ACTION_DISMISS_ALARM = "android.intent.action.DISMISS_ALARM";
    field public static final java.lang.String ACTION_SNOOZE_ALARM = "android.intent.action.SNOOZE_ALARM";
    field public static final java.lang.String ALARM_SEARCH_MODE_ALL = "android.all";
    field public static final java.lang.String ALARM_SEARCH_MODE_LABEL = "android.label";
+2 −2
Original line number Diff line number Diff line
@@ -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);
            }
+31 −9
Original line number Diff line number Diff line
@@ -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}.
     *
     * <p>Automatically populates {@link #mUri} if that Intent is an {@link Intent#ACTION_VIEW}
     * of a web (http or https scheme) URI.</p>
     */
    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.
     *
     * <p>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.</p>
     */
    public void setWebUri(Uri uri) {
        mUri = uri;