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

Commit 53a1eff9 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove confused parameters of snapshot controller

- Remove allowSnapshotHome: the caller should decide whether
  to include home before calling it. Now the path of transition
  and animation skip snapshot for home explicitly.
- Remove pixelFormat: currently it is always unknown
  and it can be specified from builder.

Bug: 264551777
Test: TaskSnapshotControllerTest
Change-Id: Ia51e7e9b51579632ca5583327a66f4a418a7bcb8
parent 6c29a6fb
Loading
Loading
Loading
Loading
+31 −36
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
 */
package com.android.server.wm;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREENSHOT;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -137,18 +140,14 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
    protected abstract boolean use16BitFormat();

    /**
     * This is different than {@link #recordSnapshotInner(TYPE, boolean)} because it doesn't store
     * This is different than {@link #recordSnapshotInner(TYPE)} because it doesn't store
     * the snapshot to the cache and returns the TaskSnapshot immediately.
     *
     * This is only used for testing so the snapshot content can be verified.
     */
    // TODO(b/264551777): clean up the "snapshotHome" argument
    @VisibleForTesting
    TaskSnapshot captureSnapshot(TYPE source, boolean snapshotHome) {
    TaskSnapshot captureSnapshot(TYPE source) {
        final TaskSnapshot snapshot;
        if (snapshotHome) {
            snapshot = snapshot(source);
        } else {
        switch (getSnapshotMode(source)) {
            case SNAPSHOT_MODE_NONE:
                return null;
@@ -162,16 +161,14 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
                snapshot = null;
                break;
        }
        }
        return snapshot;
    }

    final TaskSnapshot recordSnapshotInner(TYPE source, boolean allowSnapshotHome) {
    final TaskSnapshot recordSnapshotInner(TYPE source) {
        if (shouldDisableSnapshots()) {
            return null;
        }
        final boolean snapshotHome = allowSnapshotHome && source.isActivityTypeHome();
        final TaskSnapshot snapshot = captureSnapshot(source, snapshotHome);
        final TaskSnapshot snapshot = captureSnapshot(source);
        if (snapshot == null) {
            return null;
        }
@@ -189,25 +186,24 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,

    @VisibleForTesting
    int getSnapshotMode(TYPE source) {
        final ActivityRecord topChild = getTopActivity(source);
        if (!source.isActivityTypeStandardOrUndefined() && !source.isActivityTypeAssistant()) {
        final int type = source.getActivityType();
        if (type == ACTIVITY_TYPE_RECENTS || type == ACTIVITY_TYPE_DREAM) {
            return SNAPSHOT_MODE_NONE;
        } else if (topChild != null && topChild.shouldUseAppThemeSnapshot()) {
            return SNAPSHOT_MODE_APP_THEME;
        } else {
        }
        if (type == ACTIVITY_TYPE_HOME) {
            return SNAPSHOT_MODE_REAL;
        }
        final ActivityRecord topChild = getTopActivity(source);
        if (topChild != null && topChild.shouldUseAppThemeSnapshot()) {
            return SNAPSHOT_MODE_APP_THEME;
        }

    @Nullable
    TaskSnapshot snapshot(TYPE source) {
        return snapshot(source, PixelFormat.UNKNOWN);
        return SNAPSHOT_MODE_REAL;
    }

    @Nullable
    TaskSnapshot snapshot(TYPE source, int pixelFormat) {
    TaskSnapshot snapshot(TYPE source) {
        TaskSnapshot.Builder builder = new TaskSnapshot.Builder();
        if (!prepareTaskSnapshot(source, pixelFormat, builder)) {
        if (!prepareTaskSnapshot(source, builder)) {
            // Failed some pre-req. Has been logged.
            return null;
        }
@@ -305,14 +301,12 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
     * information from the task and populates the builder.
     *
     * @param source the window to capture
     * @param pixelFormat the desired pixel format, or {@link PixelFormat#UNKNOWN} to
     *                    automatically select
     * @param builder the snapshot builder to populate
     *
     * @return true if the state of the task is ok to proceed
     */
    @VisibleForTesting
    boolean prepareTaskSnapshot(TYPE source, int pixelFormat, TaskSnapshot.Builder builder) {
    boolean prepareTaskSnapshot(TYPE source, TaskSnapshot.Builder builder) {
        final Pair<ActivityRecord, WindowState> result = checkIfReadyToSnapshot(source);
        if (result == null) {
            return false;
@@ -329,6 +323,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        builder.setLetterboxInsets(letterboxInsets);
        final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE;
        final boolean isShowWallpaper = mainWindow.hasWallpaper();
        int pixelFormat = builder.getPixelFormat();
        if (pixelFormat == PixelFormat.UNKNOWN) {
            pixelFormat = use16BitFormat() && activity.fillsParent()
                    && !(isWindowTranslucent && isShowWallpaper)
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ class ActivitySnapshotController extends AbsAppSnapshotController<ActivityRecord
        if (DEBUG) {
            Slog.d(TAG, "ActivitySnapshotController#recordSnapshot " + activity);
        }
        final TaskSnapshot snapshot = recordSnapshotInner(activity, false /* allowSnapshotHome */);
        final TaskSnapshot snapshot = recordSnapshotInner(activity);
        if (snapshot != null) {
            final int code = getSystemHashCode(activity);
            addUserSavedFile(code, activity.mUserId, snapshot);
+2 −4
Original line number Diff line number Diff line
@@ -3855,11 +3855,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    return null;
                }
                if (updateCache) {
                    return mWindowManager.mTaskSnapshotController.recordSnapshot(task,
                            true /* snapshotHome */);
                    return mWindowManager.mTaskSnapshotController.recordSnapshot(task);
                } else {
                    return mWindowManager.mTaskSnapshotController.captureSnapshot(task,
                            true /* snapshotHome */);
                    return mWindowManager.mTaskSnapshotController.captureSnapshot(task);
                }
            }
        } finally {
+2 −1
Original line number Diff line number Diff line
@@ -901,7 +901,8 @@ public class RecentsAnimationController implements DeathRecipient {
        for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
            final TaskAnimationAdapter adapter = mPendingAnimations.get(i);
            final Task task = adapter.mTask;
            snapshotController.recordSnapshot(task, false /* allowSnapshotHome */);
            if (task.isActivityTypeHome()) continue;
            snapshotController.recordSnapshot(task);
            final TaskSnapshot snapshot = snapshotController.getSnapshot(task.mTaskId, task.mUserId,
                    false /* restoreFromDisk */, false /* isLowResolution */);
            if (snapshot != null) {
+1 −2
Original line number Diff line number Diff line
@@ -2174,8 +2174,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                // Record the snapshot now, it will be later fetched for content-pip animation.
                // We do this early in the process to make sure the right snapshot is used for
                // entering content-pip animation.
                mWindowManager.mTaskSnapshotController.recordSnapshot(
                        task, false /* allowSnapshotHome */);
                mWindowManager.mTaskSnapshotController.recordSnapshot(task);
                rootTask.setBounds(r.pictureInPictureArgs.getSourceRectHint());
            }
            rootTask.setDeferTaskAppear(false);
Loading