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

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

Merge "Support to record multiple activities in the same task as one snapshot." into main

parents 81e415e3 9a8fc252
Loading
Loading
Loading
Loading
+24 −13
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ 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;
@@ -180,17 +181,9 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        if (snapshot == null) {
            return null;
        }
        final HardwareBuffer buffer = snapshot.getHardwareBuffer();
        if (buffer.getWidth() == 0 || buffer.getHeight() == 0) {
            buffer.close();
            Slog.e(TAG, "Invalid snapshot dimensions " + buffer.getWidth() + "x"
                    + buffer.getHeight());
            return null;
        } else {
        mCache.putSnapshot(source, snapshot);
        return snapshot;
    }
    }

    @VisibleForTesting
    int getSnapshotMode(TYPE source) {
@@ -210,6 +203,11 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,

    @Nullable
    TaskSnapshot snapshot(TYPE source) {
        return snapshot(source, mHighResSnapshotScale);
    }

    @Nullable
    TaskSnapshot snapshot(TYPE source, float scale) {
        TaskSnapshot.Builder builder = new TaskSnapshot.Builder();
        final Rect crop = prepareTaskSnapshot(source, builder);
        if (crop == null) {
@@ -218,7 +216,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        }
        Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "createSnapshot");
        final ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer = createSnapshot(source,
                mHighResSnapshotScale, crop, builder);
                scale, crop, builder);
        Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
        if (screenshotBuffer == null) {
            // Failed to acquire image. Has been logged.
@@ -227,7 +225,19 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        builder.setCaptureTime(SystemClock.elapsedRealtimeNanos());
        builder.setSnapshot(screenshotBuffer.getHardwareBuffer());
        builder.setColorSpace(screenshotBuffer.getColorSpace());
        return builder.build();
        final TaskSnapshot snapshot = builder.build();
        return validateSnapshot(snapshot);
    }

    private static TaskSnapshot validateSnapshot(@NonNull TaskSnapshot snapshot) {
        final HardwareBuffer buffer = snapshot.getHardwareBuffer();
        if (buffer.getWidth() == 0 || buffer.getHeight() == 0) {
            buffer.close();
            Slog.e(TAG, "Invalid snapshot dimensions " + buffer.getWidth() + "x"
                    + buffer.getHeight());
            return null;
        }
        return snapshot;
    }

    @Nullable
@@ -432,7 +442,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        InsetUtils.addInsets(contentInsets, letterboxInsets);
        // Note, the app theme snapshot is never translucent because we enforce a non-translucent
        // color above
        return new TaskSnapshot(
        final TaskSnapshot taskSnapshot = new TaskSnapshot(
                System.currentTimeMillis() /* id */,
                SystemClock.elapsedRealtimeNanos() /* captureTime */,
                topActivity.mActivityComponent, hwBitmap.getHardwareBuffer(),
@@ -441,6 +451,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
                contentInsets, letterboxInsets, false /* isLowResolution */,
                false /* isRealSnapshot */, source.getWindowingMode(),
                getAppearance(source), false /* isTranslucent */, false /* hasImeSurface */);
        return validateSnapshot(taskSnapshot);
    }

    static Rect getSystemBarInsets(Rect frame, InsetsState state) {
+269 −85

File changed.

Preview size limit exceeded, changes collapsed.

+9 −5
Original line number Diff line number Diff line
@@ -1327,7 +1327,8 @@ class BackNavigationController {
                return mAnimationTarget;
            }

            void createStartingSurface(@NonNull WindowContainer closeWindow) {
            void createStartingSurface(@NonNull WindowContainer closeWindow,
                    @NonNull ActivityRecord[] visibleOpenActivities) {
                if (!mIsOpen) {
                    return;
                }
@@ -1346,7 +1347,7 @@ class BackNavigationController {
                if (mainActivity == null) {
                    return;
                }
                final TaskSnapshot snapshot = getSnapshot(mTarget);
                final TaskSnapshot snapshot = getSnapshot(mTarget, visibleOpenActivities);
                mRequestedStartingSurfaceId = openTask.mAtmService.mTaskOrganizerController
                        .addWindowlessStartingSurface(openTask, mainActivity,
                                // Choose configuration from closeWindow, because the configuration
@@ -1489,7 +1490,8 @@ class BackNavigationController {
                        // Try to draw two snapshot within a WindowlessStartingWindow, or find
                        // another key for StartingWindowRecordManager.
                        && openAnimationAdaptor.length == 1) {
                    openAnimationAdaptor[0].createStartingSurface(closeWindow);
                    openAnimationAdaptor[0].createStartingSurface(closeWindow,
                            visibleOpenActivities);
                } else {
                    for (int i = visibleOpenActivities.length - 1; i >= 0; --i) {
                        setLaunchBehind(visibleOpenActivities[i]);
@@ -1671,7 +1673,8 @@ class BackNavigationController {
        mPendingAnimationBuilder = null;
    }

    static TaskSnapshot getSnapshot(@NonNull WindowContainer w) {
    static TaskSnapshot getSnapshot(@NonNull WindowContainer w,
            ActivityRecord[] visibleOpenActivities) {
        if (w.asTask() != null) {
            final Task task = w.asTask();
            return task.mRootWindowContainer.mWindowManager.mTaskSnapshotController.getSnapshot(
@@ -1681,7 +1684,8 @@ class BackNavigationController {

        if (w.asActivityRecord() != null) {
            final ActivityRecord ar = w.asActivityRecord();
            return ar.mWmService.mSnapshotController.mActivitySnapshotController.getSnapshot(ar);
            return ar.mWmService.mSnapshotController.mActivitySnapshotController
                    .getSnapshot(visibleOpenActivities);
        }
        return null;
    }
+1 −3
Original line number Diff line number Diff line
@@ -160,9 +160,7 @@ class SnapshotController {
                if (!allOpensOptInOnBackInvoked() || mCloseActivities.isEmpty()) {
                    return;
                }
                for (int i = mCloseActivities.size() - 1; i >= 0; --i) {
                    controller.recordSnapshot(mCloseActivities.get(i));
                }
                controller.recordSnapshot(mCloseActivities);
            }
        }
    }
+3 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading