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

Commit 89143cda authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Add api to trigger App-to-web education

Some applications will want to control when the App-to-web education
should be shown based on the satte of the application and whether the
web will provide the user will a better experience. This api allows
activities to request for the education to be shown.

Test: m
Bug: 373680430
API-Coverage-Bug: 376903053
Flag: com.android.window.flags.enable_desktop_windowing_app_to_web_education
Change-Id: Iba51662825b7272711792422c7cc5a002009915f
parent f723deaa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4601,6 +4601,7 @@ package android.app {
    method public void reportFullyDrawn();
    method public android.view.DragAndDropPermissions requestDragAndDropPermissions(android.view.DragEvent);
    method public void requestFullscreenMode(int, @Nullable android.os.OutcomeReceiver<java.lang.Void,java.lang.Throwable>);
    method @FlaggedApi("com.android.window.flags.enable_desktop_windowing_app_to_web_education") public final void requestOpenInBrowserEducation();
    method public final void requestPermissions(@NonNull String[], int);
    method @FlaggedApi("android.permission.flags.device_aware_permission_apis_enabled") public final void requestPermissions(@NonNull String[], int, int);
    method public final void requestShowKeyboardShortcuts();
@@ -4626,7 +4627,6 @@ package android.app {
    method public void setInheritShowWhenLocked(boolean);
    method public void setIntent(android.content.Intent);
    method @FlaggedApi("android.security.content_uri_permission_apis") public void setIntent(@Nullable android.content.Intent, @Nullable android.app.ComponentCaller);
    method @FlaggedApi("com.android.window.flags.enable_desktop_windowing_app_to_web_education") public final void setLimitSystemEducationDialogs(boolean);
    method public void setLocusContext(@Nullable android.content.LocusId, @Nullable android.os.Bundle);
    method public final void setMediaController(android.media.session.MediaController);
    method public void setPictureInPictureParams(@NonNull android.app.PictureInPictureParams);
+12 −17
Original line number Diff line number Diff line
@@ -1270,27 +1270,22 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * To make users aware of system features such as the app header menu and its various
     * functionalities, educational dialogs are shown to demonstrate how to find and utilize these
     * features. Using this method, an activity can specify if it wants these educational dialogs to
     * be shown. When set to {@code true}, these dialogs are not completely blocked; however, the
     * system will be notified that they should not be shown unless necessary. If this API is not
     * called, the system's educational dialogs are not limited by default.
     *
     * <p>This method can be utilized when activities have states where showing an
     * educational dialog would be disruptive to the user. For example, if a game application is
     * expecting prompt user input, this method can be used to limit educational dialogs such as the
     * dialogs that showcase the app header's features which, in this instance, would disrupt the
     * user's experience if shown.</p>
     *
     * <p>Note that educational dialogs may be shown soon after this activity is launched, so
     * this method must be called early if the intent is to limit the dialogs from the start.</p>
     * 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 AssistContent#setWebUri}.
     *
     * <p>This method should be utilized when an activity wants to nudge the user to switch
     * to the web application in cases where the web may provide the user with a better
     * experience. Note that this method does not guarantee that the education will be shown.</p>
     */
    @FlaggedApi(com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB_EDUCATION)
    public final void setLimitSystemEducationDialogs(boolean limitSystemEducationDialogs) {
    public final void requestOpenInBrowserEducation() {
        try {
            ActivityTaskManager
                  .getService().setLimitSystemEducationDialogs(mToken, limitSystemEducationDialogs);
                  .getService().requestOpenInBrowserEducation(mToken);
        } catch (RemoteException e) {
            // Empty
        }
+2 −2
Original line number Diff line number Diff line
@@ -242,8 +242,8 @@ interface IActivityTaskManager {

    boolean supportsLocalVoiceInteraction();

    // Sets whether system educational dialogs should be limited
    void setLimitSystemEducationDialogs(IBinder appToken, boolean limitSystemEducationDialogs);
    // Requests the "Open in browser" education to be shown
    void requestOpenInBrowserEducation(IBinder appToken);

    // Get device configuration
    ConfigurationInfo getDeviceConfigurationInfo();
+8 −8
Original line number Diff line number Diff line
@@ -340,10 +340,10 @@ public class TaskInfo {
    public int requestedVisibleTypes;

    /**
     * Whether the top activity has requested to limit educational dialogs shown by the system.
     * The timestamp of the top activity's last request to show the "Open in Browser" education.
     * @hide
     */
    public boolean isTopActivityLimitSystemEducationDialogs;
    public long topActivityRequestOpenInBrowserEducationTimestamp;

    /**
     * Encapsulate specific App Compat information.
@@ -493,8 +493,8 @@ public class TaskInfo {
                && Objects.equals(capturedLink, that.capturedLink)
                && capturedLinkTimestamp == that.capturedLinkTimestamp
                && requestedVisibleTypes == that.requestedVisibleTypes
                && isTopActivityLimitSystemEducationDialogs
                    == that.isTopActivityLimitSystemEducationDialogs
                && topActivityRequestOpenInBrowserEducationTimestamp
                    == that.topActivityRequestOpenInBrowserEducationTimestamp
                && appCompatTaskInfo.equalsForTaskOrganizer(that.appCompatTaskInfo)
                && Objects.equals(topActivityMainWindowFrame, that.topActivityMainWindowFrame);
    }
@@ -571,7 +571,7 @@ public class TaskInfo {
        capturedLink = source.readTypedObject(Uri.CREATOR);
        capturedLinkTimestamp = source.readLong();
        requestedVisibleTypes = source.readInt();
        isTopActivityLimitSystemEducationDialogs = source.readBoolean();
        topActivityRequestOpenInBrowserEducationTimestamp = source.readLong();
        appCompatTaskInfo = source.readTypedObject(AppCompatTaskInfo.CREATOR);
        topActivityMainWindowFrame = source.readTypedObject(Rect.CREATOR);
    }
@@ -627,7 +627,7 @@ public class TaskInfo {
        dest.writeTypedObject(capturedLink, flags);
        dest.writeLong(capturedLinkTimestamp);
        dest.writeInt(requestedVisibleTypes);
        dest.writeBoolean(isTopActivityLimitSystemEducationDialogs);
        dest.writeLong(topActivityRequestOpenInBrowserEducationTimestamp);
        dest.writeTypedObject(appCompatTaskInfo, flags);
        dest.writeTypedObject(topActivityMainWindowFrame, flags);
    }
@@ -672,8 +672,8 @@ public class TaskInfo {
                + " capturedLink=" + capturedLink
                + " capturedLinkTimestamp=" + capturedLinkTimestamp
                + " requestedVisibleTypes=" + requestedVisibleTypes
                + " isTopActivityLimitSystemEducationDialogs="
                + isTopActivityLimitSystemEducationDialogs
                + " topActivityRequestOpenInBrowserEducationTimestamp="
                + topActivityRequestOpenInBrowserEducationTimestamp
                + " appCompatTaskInfo=" + appCompatTaskInfo
                + " topActivityMainWindowFrame=" + topActivityMainWindowFrame
                + "}";
+4 −5
Original line number Diff line number Diff line
@@ -630,8 +630,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    // The locusId associated with this activity, if set.
    private LocusId mLocusId;

    // Whether the activity is requesting to limit the system's educational dialogs
    public boolean mShouldLimitSystemEducationDialogs;
    // The timestamp of the last request to show the "Open in browser" education
    public long mRequestOpenInBrowserEducationTimestamp;

    // Whether the activity was launched from a bubble.
    private boolean mLaunchedFromBubble;
@@ -7326,9 +7326,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return mLocusId;
    }

    void setLimitSystemEducationDialogs(boolean limitSystemEducationDialogs) {
        if (mShouldLimitSystemEducationDialogs == limitSystemEducationDialogs) return;
        mShouldLimitSystemEducationDialogs = limitSystemEducationDialogs;
    void requestOpenInBrowserEducation() {
        mRequestOpenInBrowserEducationTimestamp = System.currentTimeMillis();
        final Task task = getTask();
        if (task != null) {
            final boolean force = isVisibleRequested() && this == task.getTopNonFinishingActivity();
Loading