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

Commit 12e867a9 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Do not capture letterbox for activity snapshot." into main

parents f9e12500 fb5f9153
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
    @Nullable
    protected abstract ActivityRecord findAppTokenForSnapshot(TYPE source);
    protected abstract boolean use16BitFormat();
    protected abstract Rect getLetterboxInsets(ActivityRecord topActivity);

    /**
     * This is different than {@link #recordSnapshotInner(TYPE)} because it doesn't store
@@ -309,7 +310,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        final WindowState mainWindow = result.second;
        final Rect contentInsets = getSystemBarInsets(mainWindow.getFrame(),
                mainWindow.getInsetsStateWithVisibilityOverride());
        final Rect letterboxInsets = activity.getLetterboxInsets();
        final Rect letterboxInsets = getLetterboxInsets(activity);
        InsetUtils.addInsets(contentInsets, letterboxInsets);
        builder.setIsRealSnapshot(true);
        builder.setId(System.currentTimeMillis());
@@ -335,22 +336,27 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        final Configuration taskConfig = activity.getTask().getConfiguration();
        final int displayRotation = taskConfig.windowConfiguration.getDisplayRotation();
        final Rect outCrop = new Rect();
        final Point taskSize = new Point();
        final Transition.ChangeInfo changeInfo = mCurrentChangeInfo;
        if (changeInfo != null && changeInfo.mRotation != displayRotation) {
            // For example, the source is closing and display rotation changes at the same time.
            // The snapshot should record the state in previous rotation.
            outCrop.set(changeInfo.mAbsoluteBounds);
            taskSize.set(changeInfo.mAbsoluteBounds.right, changeInfo.mAbsoluteBounds.bottom);
            builder.setRotation(changeInfo.mRotation);
            builder.setOrientation(changeInfo.mAbsoluteBounds.height()
                    >= changeInfo.mAbsoluteBounds.width()
                    ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE);
        } else {
            outCrop.set(taskConfig.windowConfiguration.getBounds());
            final Configuration srcConfig = source.getConfiguration();
            outCrop.set(srcConfig.windowConfiguration.getBounds());
            final Rect taskBounds = taskConfig.windowConfiguration.getBounds();
            taskSize.set(taskBounds.width(), taskBounds.height());
            builder.setRotation(displayRotation);
            builder.setOrientation(taskConfig.orientation);
            builder.setOrientation(srcConfig.orientation);
        }
        outCrop.offsetTo(0, 0);
        builder.setTaskSize(new Point(outCrop.right, outCrop.bottom));
        builder.setTaskSize(taskSize);
        return outCrop;
    }

@@ -438,7 +444,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
            return null;
        }
        final Rect contentInsets = new Rect(systemBarInsets);
        final Rect letterboxInsets = topActivity.getLetterboxInsets();
        final Rect letterboxInsets = getLetterboxInsets(topActivity);
        InsetUtils.addInsets(contentInsets, letterboxInsets);
        // Note, the app theme snapshot is never translucent because we enforce a non-translucent
        // color above
+7 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.graphics.Rect;
import android.os.Environment;
import android.os.SystemProperties;
import android.os.Trace;
@@ -617,6 +618,12 @@ class ActivitySnapshotController extends AbsAppSnapshotController<ActivityRecord
        return mPersistInfoProvider.use16BitFormat();
    }

    @Override
    protected Rect getLetterboxInsets(ActivityRecord topActivity) {
        // Do not capture letterbox for ActivityRecord
        return Letterbox.EMPTY_RECT;
    }

    @NonNull
    private SparseArray<UserSavedFile> getUserFiles(int userId) {
        if (mUserSavedFiles.get(userId) == null) {
+17 −17
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_PREDICT_BACK;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.ResourceId;
import android.graphics.Point;
import android.graphics.Rect;
@@ -1065,8 +1066,9 @@ class BackNavigationController {

            if (mOpenActivities != null) {
                for (int i = mOpenActivities.length - 1; i >= 0; --i) {
                    if (mOpenActivities[i].mLaunchTaskBehind) {
                        restoreLaunchBehind(mOpenActivities[i]);
                    final ActivityRecord resetActivity = mOpenActivities[i];
                    if (resetActivity.mLaunchTaskBehind) {
                        restoreLaunchBehind(resetActivity);
                    }
                }
            }
@@ -1233,8 +1235,7 @@ class BackNavigationController {
                        represent.allowEnterPip);
            }

            void createStartingSurface(@NonNull WindowContainer closeWindow,
                    ActivityRecord[] visibleOpenActivities) {
            void createStartingSurface(ActivityRecord[] visibleOpenActivities) {
                if (mAdaptors[0].mSwitchType == DIALOG_CLOSE) {
                    return;
                }
@@ -1253,12 +1254,15 @@ class BackNavigationController {
                    return;
                }
                final TaskSnapshot snapshot = getSnapshot(mainOpen, visibleOpenActivities);
                // If there is only one adaptor, attach the windowless window to top activity,
                // because fixed rotation only applies on activity.
                // Note that embedded activity won't use fixed rotation.
                final Configuration openConfig = mAdaptors.length == 1
                        ? mainActivity.getConfiguration() : openTask.getConfiguration();
                mRequestedStartingSurfaceId = openTask.mAtmService.mTaskOrganizerController
                        .addWindowlessStartingSurface(openTask, mainActivity,
                        // Choose configuration from closeWindow, because the configuration
                        // of opening target may not update before resume, so the starting
                        // surface should occlude it entirely.
                        mRemoteAnimationTarget.leash, snapshot, closeWindow.getConfiguration(),
                                mAdaptors.length == 1 ? mainActivity.getSurfaceControl()
                                        : mRemoteAnimationTarget.leash, snapshot, openConfig,
                            new IWindowlessStartingSurfaceCallback.Stub() {
                            // Once the starting surface has been created in shell, it will call
                            // onSurfaceAdded to pass the created surface to core, so if a
@@ -1290,10 +1294,7 @@ class BackNavigationController {
                if (mStartingSurface != null && mStartingSurface.isValid()) {
                    SurfaceControl.Transaction transaction = reparentTransaction != null
                            ? reparentTransaction : mAdaptors[0].mTarget.getPendingTransaction();
                    if (mAdaptors.length == 1) {
                        transaction.reparent(mStartingSurface,
                                        mAdaptors[0].mTarget.getSurfaceControl());
                    } else {
                    if (mAdaptors.length != 1) {
                        // More than one opening window, reparent starting surface to leaf task.
                        final WindowContainer wc = mAdaptors[0].mTarget;
                        final Task task = wc.asActivityRecord() != null
@@ -1499,16 +1500,15 @@ class BackNavigationController {

            /**
             * Apply preview strategy on the opening target
             * @param closeWindow The close window, where it's configuration should cover all
             *                    open target(s).
             *
             * @param openAnimationAdaptor The animator who can create starting surface.
             * @param visibleOpenActivities  The visible activities in opening targets.
             */
            private void applyPreviewStrategy(@NonNull WindowContainer closeWindow,
            private void applyPreviewStrategy(
                    @NonNull BackWindowAnimationAdaptorWrapper openAnimationAdaptor,
                    @NonNull ActivityRecord[] visibleOpenActivities) {
                if (isSupportWindowlessSurface() && mShowWindowlessSurface && !mIsLaunchBehind) {
                    openAnimationAdaptor.createStartingSurface(closeWindow, visibleOpenActivities);
                    openAnimationAdaptor.createStartingSurface(visibleOpenActivities);
                } else {
                    for (int i = visibleOpenActivities.length - 1; i >= 0; --i) {
                        setLaunchBehind(visibleOpenActivities[i]);
@@ -1539,7 +1539,7 @@ class BackNavigationController {
                }
                mCloseTarget.mTransitionController.mSnapshotController
                        .mActivitySnapshotController.clearOnBackPressedActivities();
                applyPreviewStrategy(mCloseTarget, mOpenAnimAdaptor, openingActivities);
                applyPreviewStrategy(mOpenAnimAdaptor, openingActivities);

                final IBackAnimationFinishedCallback callback = makeAnimationFinishedCallback();
                final RemoteAnimationTarget[] targets = getAnimationTargets();
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import java.util.function.Supplier;
 */
public class Letterbox {

    private static final Rect EMPTY_RECT = new Rect();
    static final Rect EMPTY_RECT = new Rect();
    private static final Point ZERO_POINT = new Point(0, 0);

    private final Supplier<SurfaceControl.Builder> mSurfaceControlFactory;
+5 −0
Original line number Diff line number Diff line
@@ -270,6 +270,11 @@ class TaskSnapshotController extends AbsAppSnapshotController<Task, TaskSnapshot
        return source.getTaskDescription();
    }

    @Override
    protected Rect getLetterboxInsets(ActivityRecord topActivity) {
        return topActivity.getLetterboxInsets();
    }

    void getClosingTasksInner(Task task, ArraySet<Task> outClosingTasks) {
        // Since RecentsAnimation will handle task snapshot while switching apps with the
        // best capture timing (e.g. IME window capture),