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

Commit e5408b76 authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Session Transfer Uri API Changes

Makes the following changes to the session transfer Uri API:
1. Changes the API from an extra to a setter/getter method in order to
   match AssistContent#setWebUri.
2. Renames the URI to AssistContent#setSessionTransferUri (removing the
   word web) in order to prevent developers from believing that this Uri
   will help with authentication.

Bug: 384877505
Flag:com.android.window.flags.enable_desktop_windowing_app_to_web_education
Test: atest DesktopModeWindowDecorationTests
API-Coverage-Bug: 388044324

Change-Id: Ia3eddca7bb61102b0e80c97667b7d2b8d0eeb4db
parent 6d8ad4db
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -8947,18 +8947,19 @@ package android.app.assist {
    method public android.content.ClipData getClipData();
    method public android.os.Bundle getExtras();
    method public android.content.Intent getIntent();
    method @FlaggedApi("com.android.window.flags.enable_desktop_windowing_app_to_web_education") @Nullable public android.net.Uri getSessionTransferUri();
    method public String getStructuredData();
    method public android.net.Uri getWebUri();
    method public boolean isAppProvidedIntent();
    method public boolean isAppProvidedWebUri();
    method public void setClipData(android.content.ClipData);
    method public void setIntent(android.content.Intent);
    method @FlaggedApi("com.android.window.flags.enable_desktop_windowing_app_to_web_education") public void setSessionTransferUri(@Nullable android.net.Uri);
    method public void setStructuredData(String);
    method public void setWebUri(android.net.Uri);
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.assist.AssistContent> CREATOR;
    field @FlaggedApi("android.app.appfunctions.flags.enable_app_function_manager") public static final String EXTRA_APP_FUNCTION_DATA = "android.app.assist.extra.APP_FUNCTION_DATA";
    field @FlaggedApi("com.android.window.flags.enable_desktop_windowing_app_to_web_education") public static final String EXTRA_SESSION_TRANSFER_WEB_URI = "android.app.assist.extra.SESSION_TRANSFER_WEB_URI";
  }
  public class AssistStructure implements android.os.Parcelable {
+4 −4
Original line number Diff line number Diff line
@@ -1273,8 +1273,8 @@ public class Activity extends ContextThemeWrapper
     * Requests to show the “Open in browser” education. “Open in browser” is a feature
     * within the app header that allows users to switch from an app to the web. The feature
     * is made available when an application is opened by a user clicking a link or when a
     * link is provided by an application. Links can be provided by utilizing
     * {@link AssistContent#EXTRA_AUTHENTICATING_USER_WEB_URI} or
     * link is provided by an application. Links can be provided by calling
     * {@link AssistContent#setSessionTransferUri} or
     * {@link AssistContent#setWebUri}.
     *
     * <p>This method should be utilized when an activity wants to nudge the user to switch
@@ -1287,7 +1287,7 @@ public class Activity extends ContextThemeWrapper
     * disruptive to the user to show the education and when it is optimal to switch the user to a
     * browser session. Before requesting to show the education, developers should assert that they
     * have set a link that can be used by the "Open in browser" feature through either
     * {@link AssistContent#EXTRA_AUTHENTICATING_USER_WEB_URI} or
     * {@link AssistContent#setSessionTransferUri} or
     * {@link AssistContent#setWebUri} so that users are navigated to a relevant page if they choose
     * to switch to the browser. If a URI is not set using either method, "Open in browser" will
     * utilize a generic link if available which will direct users to the homepage of the site
@@ -1296,7 +1296,7 @@ public class Activity extends ContextThemeWrapper
     * the user will not be provided with the option to switch to the browser and the education will
     * not be shown if requested.
     *
     * @see android.app.assist.AssistContent#EXTRA_SESSION_TRANSFER_WEB_URI
     * @see android.app.assist.AssistContent#setSessionTransferUri
     */
    @FlaggedApi(com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB_EDUCATION)
    public final void requestOpenInBrowserEducation() {
+46 −25
Original line number Diff line number Diff line
package android.app.assist;

import android.annotation.FlaggedApi;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ClipData;
import android.content.Intent;
@@ -30,31 +31,6 @@ public class AssistContent implements Parcelable {
    public static final String EXTRA_APP_FUNCTION_DATA =
            "android.app.assist.extra.APP_FUNCTION_DATA";

    /**
     * This extra can be optionally supplied in the {@link #getExtras} bundle to provide a
     * {@link Uri} which will be utilized when transitioning a user's session to another surface.
     *
     * <p>If provided, instead of using the URI provided in {@link #setWebUri}, the
     * "Open in browser" feature will use this URI to transition the current session from one
     * surface to the other. Apps may choose to encode session or user information into this
     * URI in order to provide a better session transfer experience.
     *
     * <p>Unlike {@link #setWebUri}, this URI will not be used for features where the user might
     * accidentally share it with another user. However, developers should not encode
     * authentication credentials into this URI, because it will be surfaced in the browser URL
     * bar and may be copied and shared from there.
     *
     * <p>When providing this extra, developers should still continue to provide
     * {@link #setWebUri} for backwards compatibility with features such as
     * <a href="https://developer.android.com/guide/components/activities/recents#url-sharing">
     * recents URL sharing</a> which do not benefit from a session-transfer web URI.
     *
     * @see android.app.Activity#requestOpenInBrowserEducation()
     */
    @FlaggedApi(com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB_EDUCATION)
    public static final String EXTRA_SESSION_TRANSFER_WEB_URI =
            "android.app.assist.extra.SESSION_TRANSFER_WEB_URI";

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private boolean mIsAppProvidedIntent = false;
    private boolean mIsAppProvidedWebUri = false;
@@ -66,6 +42,7 @@ public class AssistContent implements Parcelable {
    private ClipData mClipData;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private Uri mUri;
    private Uri mSessionTransferUri;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private final Bundle mExtras;

@@ -199,6 +176,41 @@ public class AssistContent implements Parcelable {
        return mIsAppProvidedWebUri;
    }

    /**
     * This method can be used to provide a {@link Uri} which will be utilized when transitioning a
     * user's session to another surface.
     *
     * <p>If provided, instead of using the URI provided in {@link #setWebUri}, the
     * "Open in browser" feature will use this URI to transition the current session from one
     * surface to the other. Apps may choose to encode session or user information into this
     * URI in order to provide a better session transfer experience. However, while this URI will
     * only be available to the system and not other applications, developers should not encode
     * authentication credentials into this URI, because it will be surfaced in the browser URL bar
     * and may be copied and shared from there.
     *
     * <p>When providing this URI, developers should still continue to provide
     * {@link #setWebUri} for backwards compatibility with features such as
     * <a href="https://developer.android.com/guide/components/activities/recents#url-sharing">
     * recents URL sharing</a> which facilitate link sharing with other users and would not benefit
     * from a session-transfer URI.
     *
     * @see android.app.Activity#requestOpenInBrowserEducation()
     */
    @FlaggedApi(com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB_EDUCATION)
    public void setSessionTransferUri(@Nullable Uri uri) {
        mSessionTransferUri = uri;
    }

    /**
     * Return the content's session transfer web URI as per
     * {@link #setSessionTransferUri(android.net.Uri)}, or null if there is none.
     */
    @FlaggedApi(com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB_EDUCATION)
    @Nullable
    public Uri getSessionTransferUri() {
        return mSessionTransferUri;
    }

    /**
     * Return Bundle for extra vendor-specific data that can be modified and examined.
     */
@@ -217,6 +229,9 @@ public class AssistContent implements Parcelable {
        if (in.readInt() != 0) {
            mUri = Uri.CREATOR.createFromParcel(in);
        }
        if (in.readInt() != 0) {
            mSessionTransferUri = Uri.CREATOR.createFromParcel(in);
        }
        if (in.readInt() != 0) {
            mStructuredData = in.readString();
        }
@@ -245,6 +260,12 @@ public class AssistContent implements Parcelable {
        } else {
            dest.writeInt(0);
        }
        if (mSessionTransferUri != null) {
            dest.writeInt(1);
            mSessionTransferUri.writeToParcel(dest, flags);
        } else {
            dest.writeInt(0);
        }
        if (mStructuredData != null) {
            dest.writeInt(1);
            dest.writeString(mStructuredData);