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

Commit 4573dddc authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Add new API to set URI on AssistContent." into mnc-dev

parents bf7fe1e0 09d57fe9
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -3997,24 +3997,22 @@ package android.app {
  public class AssistContent implements android.os.Parcelable {
    ctor public AssistContent();
    method public int describeContents();
    method public static android.app.AssistContent getAssistContent(android.os.Bundle);
    method public android.content.ClipData getClipData();
    method public android.content.Intent getIntent();
    method public android.net.Uri getWebUri();
    method public void setClipData(android.content.ClipData);
    method public void setIntent(android.content.Intent);
    method public void setWebUri(android.net.Uri);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final java.lang.String ASSIST_KEY = "android:assist_content";
    field public static final android.os.Parcelable.Creator<android.app.AssistContent> CREATOR;
  }
  public final class AssistStructure implements android.os.Parcelable {
    method public int describeContents();
    method public android.content.ComponentName getActivityComponent();
    method public static android.app.AssistStructure getAssistStructure(android.os.Bundle);
    method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
    method public int getWindowNodeCount();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final java.lang.String ASSIST_KEY = "android:assist_structure";
    field public static final android.os.Parcelable.Creator<android.app.AssistStructure> CREATOR;
  }
@@ -28916,7 +28914,7 @@ package android.service.voice {
    method public android.view.View onCreateContentView();
    method public void onDestroy();
    method public boolean[] onGetSupportedCommands(android.service.voice.VoiceInteractionSession.Caller, java.lang.String[]);
    method public void onHandleAssist(android.os.Bundle);
    method public void onHandleAssist(android.os.Bundle, android.app.AssistStructure, android.app.AssistContent);
    method public void onHide();
    method public boolean onKeyDown(int, android.view.KeyEvent);
    method public boolean onKeyLongPress(int, android.view.KeyEvent);
+3 −5
Original line number Diff line number Diff line
@@ -4092,24 +4092,22 @@ package android.app {
  public class AssistContent implements android.os.Parcelable {
    ctor public AssistContent();
    method public int describeContents();
    method public static android.app.AssistContent getAssistContent(android.os.Bundle);
    method public android.content.ClipData getClipData();
    method public android.content.Intent getIntent();
    method public android.net.Uri getWebUri();
    method public void setClipData(android.content.ClipData);
    method public void setIntent(android.content.Intent);
    method public void setWebUri(android.net.Uri);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final java.lang.String ASSIST_KEY = "android:assist_content";
    field public static final android.os.Parcelable.Creator<android.app.AssistContent> CREATOR;
  }
  public final class AssistStructure implements android.os.Parcelable {
    method public int describeContents();
    method public android.content.ComponentName getActivityComponent();
    method public static android.app.AssistStructure getAssistStructure(android.os.Bundle);
    method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
    method public int getWindowNodeCount();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final java.lang.String ASSIST_KEY = "android:assist_structure";
    field public static final android.os.Parcelable.Creator<android.app.AssistStructure> CREATOR;
  }
@@ -31042,7 +31040,7 @@ package android.service.voice {
    method public android.view.View onCreateContentView();
    method public void onDestroy();
    method public boolean[] onGetSupportedCommands(android.service.voice.VoiceInteractionSession.Caller, java.lang.String[]);
    method public void onHandleAssist(android.os.Bundle);
    method public void onHandleAssist(android.os.Bundle, android.app.AssistStructure, android.app.AssistContent);
    method public void onHide();
    method public boolean onKeyDown(int, android.view.KeyEvent);
    method public boolean onKeyLongPress(int, android.view.KeyEvent);
+7 −3
Original line number Diff line number Diff line
@@ -2193,7 +2193,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            Bundle extras = data.readBundle();
            reportAssistContextExtras(token, extras);
            AssistStructure structure = AssistStructure.CREATOR.createFromParcel(data);
            AssistContent content = AssistContent.CREATOR.createFromParcel(data);
            reportAssistContextExtras(token, extras, structure, content);
            reply.writeNoException();
            return true;
        }
@@ -5359,13 +5361,15 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public void reportAssistContextExtras(IBinder token, Bundle extras)
            throws RemoteException {
    public void reportAssistContextExtras(IBinder token, Bundle extras, AssistStructure structure,
            AssistContent content) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        data.writeBundle(extras);
        structure.writeToParcel(data, 0);
        content.writeToParcel(data, 0);
        mRemote.transact(REPORT_ASSIST_CONTEXT_EXTRAS_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
+9 −7
Original line number Diff line number Diff line
@@ -2562,15 +2562,18 @@ public final class ActivityThread {

    public void handleRequestAssistContextExtras(RequestAssistContextExtras cmd) {
        Bundle data = new Bundle();
        AssistStructure structure = null;
        AssistContent content = new AssistContent();
        ActivityClientRecord r = mActivities.get(cmd.activityToken);
        if (r != null) {
            r.activity.getApplication().dispatchOnProvideAssistData(r.activity, data);
            r.activity.onProvideAssistData(data);
            if (cmd.requestType == ActivityManager.ASSIST_CONTEXT_FULL) {
                data.putParcelable(AssistStructure.ASSIST_KEY, new AssistStructure(r.activity));
                AssistContent content = new AssistContent();
                structure = new AssistStructure(r.activity);
                Intent activityIntent = r.activity.getIntent();
                if (activityIntent != null) {
                if (activityIntent != null && (r.window == null ||
                        (r.window.getAttributes().flags
                                & WindowManager.LayoutParams.FLAG_SECURE) == 0)) {
                    Intent intent = new Intent(activityIntent);
                    intent.setFlags(intent.getFlags() & ~(Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                            | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION));
@@ -2580,15 +2583,14 @@ public final class ActivityThread {
                    content.setIntent(new Intent());
                }
                r.activity.onProvideAssistContent(content);
                data.putParcelable(AssistContent.ASSIST_KEY, content);
            }
        }
        if (data.isEmpty()) {
            data = null;
        if (structure == null) {
            structure = new AssistStructure();
        }
        IActivityManager mgr = ActivityManagerNative.getDefault();
        try {
            mgr.reportAssistContextExtras(cmd.requestToken, data);
            mgr.reportAssistContextExtras(cmd.requestToken, data, structure, content);
        } catch (RemoteException e) {
        }
    }
+44 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import android.content.ClipData;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -30,14 +31,17 @@ import android.os.Parcelable;
public class AssistContent implements Parcelable {
    private Intent mIntent;
    private ClipData mClipData;
    private Uri mUri;

    /**
     * @hide
     * Key name this data structure is stored in the Bundle generated by
     * {@link Activity#onProvideAssistData}.
     */
    public static final String ASSIST_KEY = "android:assist_content";

    /**
     * @hide
     * Retrieve the framework-generated AssistContent that is stored within
     * the Bundle filled in by {@link Activity#onProvideAssistContent}.
     */
@@ -56,6 +60,13 @@ public class AssistContent implements Parcelable {
     */
    public void setIntent(Intent intent) {
        mIntent = intent;
        setWebUri(null);
        if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
            Uri uri = intent.getData();
            if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
                setWebUri(uri);
            }
        }
    }

    /**
@@ -81,6 +92,30 @@ public class AssistContent implements Parcelable {
        return mClipData;
    }

    /**
     * Set a web URI associated with the current data being shown to the user.
     * This URI could be opened in a web browser, or in the app as an
     * {@link Intent#ACTION_VIEW} Intent, to show the same data that is currently
     * being displayed by it.  The URI here should be something that is transportable
     * 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;
    }

    /**
     * Return the content's web URI as per {@link #setWebUri(android.net.Uri)}, or null if
     * there is none.
     */
    public Uri getWebUri() {
        return mUri;
    }

    AssistContent(Parcel in) {
        if (in.readInt() != 0) {
            mIntent = Intent.CREATOR.createFromParcel(in);
@@ -88,6 +123,9 @@ public class AssistContent implements Parcelable {
        if (in.readInt() != 0) {
            mClipData = ClipData.CREATOR.createFromParcel(in);
        }
        if (in.readInt() != 0) {
            mUri = Uri.CREATOR.createFromParcel(in);
        }
    }

    @Override
@@ -109,6 +147,12 @@ public class AssistContent implements Parcelable {
        } else {
            dest.writeInt(0);
        }
        if (mUri != null) {
            dest.writeInt(1);
            mUri.writeToParcel(dest, flags);
        } else {
            dest.writeInt(0);
        }
    }

    public static final Parcelable.Creator<AssistContent> CREATOR
Loading