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

Commit e0138fc3 authored by wilsonshih's avatar wilsonshih
Browse files

Start activity under screenshot.

Provides an internal API for start activity with initially under
screenshot, the screenshot will be removed either when transition start
or abort.

Bug: 326143814
Test: try launch app with internal api, verify screenshot will occur
before transition ready.

Change-Id: Ia96dfc71974ca20cd760c0412aa875284de9b71e
parent 12e867a9
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -414,6 +414,7 @@ class ActivityStarter {
        int filterCallingUid;
        PendingIntentRecord originatingPendingIntent;
        BackgroundStartPrivileges forcedBalByPiSender;
        boolean freezeScreen;

        final StringBuilder logMessage = new StringBuilder();

@@ -477,6 +478,7 @@ class ActivityStarter {
            filterCallingUid = UserHandle.USER_NULL;
            originatingPendingIntent = null;
            forcedBalByPiSender = BackgroundStartPrivileges.NONE;
            freezeScreen = false;
            errorCallbackToken = null;
        }

@@ -520,6 +522,7 @@ class ActivityStarter {
            filterCallingUid = request.filterCallingUid;
            originatingPendingIntent = request.originatingPendingIntent;
            forcedBalByPiSender = request.forcedBalByPiSender;
            freezeScreen = request.freezeScreen;
            errorCallbackToken = request.errorCallbackToken;
        }

@@ -1520,6 +1523,18 @@ class ActivityStarter {
        Transition newTransition = transitionController.isShellTransitionsEnabled()
                ? transitionController.createAndStartCollecting(TRANSIT_OPEN) : null;
        RemoteTransition remoteTransition = r.takeRemoteTransition();
        // Create a display snapshot as soon as possible.
        if (newTransition != null && mRequest.freezeScreen) {
            final TaskDisplayArea tda = mLaunchParams.hasPreferredTaskDisplayArea()
                    ? mLaunchParams.mPreferredTaskDisplayArea
                    : mRootWindowContainer.getDefaultTaskDisplayArea();
            final DisplayContent dc = mRootWindowContainer.getDisplayContentOrCreate(
                    tda.getDisplayId());
            if (dc != null) {
                transitionController.collect(dc);
                transitionController.collectVisibleChange(dc);
            }
        }
        try {
            mService.deferWindowLayout();
            transitionController.collect(r);
@@ -3263,6 +3278,11 @@ class ActivityStarter {
        return this;
    }

    ActivityStarter setFreezeScreen(boolean freezeScreen) {
        mRequest.freezeScreen = freezeScreen;
        return this;
    }

    ActivityStarter setErrorCallbackToken(@Nullable IBinder errorCallbackToken) {
        mRequest.errorCallbackToken = errorCallbackToken;
        return this;
+13 −0
Original line number Diff line number Diff line
@@ -274,6 +274,19 @@ public abstract class ActivityTaskManagerInternal {
            @Nullable String callingFeatureId, Intent intent, @Nullable IBinder resultTo,
            int startFlags, @Nullable Bundle options, int userId);

    /**
     * Start activity {@code intent} with initially under screenshot. The screen of launching
     * display will be frozen before transition occur.
     *
     * - DO NOT call it with the calling UID cleared.
     * - The caller must do the calling user ID check.
     *
     * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
     */
    public abstract int startActivityWithScreenshot(@NonNull Intent intent,
            @NonNull String callingPackage, int callingUid, int callingPid,
            @Nullable IBinder resultTo, @Nullable Bundle options, int userId);

    /**
     * Called after virtual display Id is updated by
     * {@link com.android.server.vr.Vr2dDisplay} with a specific
+18 −0
Original line number Diff line number Diff line
@@ -6013,6 +6013,24 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    false /*validateIncomingUser*/);
        }

        @Override
        public int startActivityWithScreenshot(@NonNull Intent intent,
                @NonNull String callingPackage, int callingUid, int callingPid,
                @Nullable IBinder resultTo, @Nullable Bundle options, int userId) {
            return getActivityStartController()
                    .obtainStarter(intent, "startActivityWithScreenshot")
                    .setCallingUid(callingUid)
                    .setCallingPid(callingPid)
                    .setCallingPackage(callingPackage)
                    .setResultTo(resultTo)
                    .setActivityOptions(createSafeActivityOptionsWithBalAllowed(options))
                    .setRealCallingUid(Binder.getCallingUid())
                    .setUserId(userId)
                    .setBackgroundStartPrivileges(BackgroundStartPrivileges.ALLOW_BAL)
                    .setFreezeScreen(true)
                    .execute();
        }

        /**
         * Called after virtual display Id is updated by
         * {@link com.android.server.vr.Vr2dDisplay} with a specific