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

Commit 5038cdcb authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Android (Google) Code Review
Browse files

Merge "Add API to limit system promos" into main

parents c2533bef d8d8e6d2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4618,6 +4618,7 @@ 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);
+27 −0
Original line number Diff line number Diff line
@@ -1262,6 +1262,33 @@ 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>
     */
    @FlaggedApi(com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB_EDUCATION)
    public final void setLimitSystemEducationDialogs(boolean limitSystemEducationDialogs) {
        try {
            ActivityTaskManager
                  .getService().setLimitSystemEducationDialogs(mToken, limitSystemEducationDialogs);
        } catch (RemoteException e) {
            // Empty
        }
    }

    /** Return the application that owns this activity. */
    public final Application getApplication() {
        return mApplication;
+3 −0
Original line number Diff line number Diff line
@@ -242,6 +242,9 @@ interface IActivityTaskManager {

    boolean supportsLocalVoiceInteraction();

    // Sets whether system educational dialogs should be limited
    void setLimitSystemEducationDialogs(IBinder appToken, boolean limitSystemEducationDialogs);

    // Get device configuration
    ConfigurationInfo getDeviceConfigurationInfo();

+12 −0
Original line number Diff line number Diff line
@@ -339,6 +339,12 @@ public class TaskInfo {
    @WindowInsets.Type.InsetsType
    public int requestedVisibleTypes;

    /**
     * Whether the top activity has requested to limit educational dialogs shown by the system.
     * @hide
     */
    public boolean isTopActivityLimitSystemEducationDialogs;

    /**
     * Encapsulate specific App Compat information.
     * @hide
@@ -486,6 +492,8 @@ public class TaskInfo {
                && Objects.equals(capturedLink, that.capturedLink)
                && capturedLinkTimestamp == that.capturedLinkTimestamp
                && requestedVisibleTypes == that.requestedVisibleTypes
                && isTopActivityLimitSystemEducationDialogs
                    == that.isTopActivityLimitSystemEducationDialogs
                && appCompatTaskInfo.equalsForTaskOrganizer(that.appCompatTaskInfo)
                && Objects.equals(topActivityMainWindowFrame, that.topActivityMainWindowFrame);
    }
@@ -562,6 +570,7 @@ public class TaskInfo {
        capturedLink = source.readTypedObject(Uri.CREATOR);
        capturedLinkTimestamp = source.readLong();
        requestedVisibleTypes = source.readInt();
        isTopActivityLimitSystemEducationDialogs = source.readBoolean();
        appCompatTaskInfo = source.readTypedObject(AppCompatTaskInfo.CREATOR);
        topActivityMainWindowFrame = source.readTypedObject(Rect.CREATOR);
    }
@@ -616,6 +625,7 @@ public class TaskInfo {
        dest.writeTypedObject(capturedLink, flags);
        dest.writeLong(capturedLinkTimestamp);
        dest.writeInt(requestedVisibleTypes);
        dest.writeBoolean(isTopActivityLimitSystemEducationDialogs);
        dest.writeTypedObject(appCompatTaskInfo, flags);
        dest.writeTypedObject(topActivityMainWindowFrame, flags);
    }
@@ -660,6 +670,8 @@ public class TaskInfo {
                + " capturedLink=" + capturedLink
                + " capturedLinkTimestamp=" + capturedLinkTimestamp
                + " requestedVisibleTypes=" + requestedVisibleTypes
                + " isTopActivityLimitSystemEducationDialogs="
                + isTopActivityLimitSystemEducationDialogs
                + " appCompatTaskInfo=" + appCompatTaskInfo
                + " topActivityMainWindowFrame=" + topActivityMainWindowFrame
                + "}";
+13 −0
Original line number Diff line number Diff line
@@ -629,6 +629,9 @@ 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;

    // Whether the activity was launched from a bubble.
    private boolean mLaunchedFromBubble;

@@ -7300,6 +7303,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return mLocusId;
    }

    void setLimitSystemEducationDialogs(boolean limitSystemEducationDialogs) {
        if (mShouldLimitSystemEducationDialogs == limitSystemEducationDialogs) return;
        mShouldLimitSystemEducationDialogs = limitSystemEducationDialogs;
        final Task task = getTask();
        if (task != null) {
            final boolean force = isVisibleRequested() && this == task.getTopNonFinishingActivity();
            getTask().dispatchTaskInfoChangedIfNeeded(force);
        }
    }

    public void reportScreenCaptured() {
        if (mCaptureCallbacks != null) {
            final int n = mCaptureCallbacks.beginBroadcast();
Loading