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

Commit 173020c2 authored by Winson Chung's avatar Winson Chung
Browse files

Expose the system ui visibility flags and translucent state with snapshot

- Allow SystemUI/Launcher to determine whether the snapshot is of a
  translucent activity (to reduce overdraw by skipping drawing task
  background) and also the sysui visibility flags are (to determine how
  to update the nav bar while animating before the app is started.
- Fixing issue where the recents animation was reporting task fillsparent
  state instead of the app's fillsparent state (as we do in normal remote
  animations)

Bug: 79228291
Bug: 77984778
Bug: 78659249
Test: atest FrameworksServicesTests:TaskSnapshotPersisterLoaderTest
Change-Id: I19bdf7f780e7d94014d6a115bf84fa614b1dffa0
parent 9743fae2
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -2110,9 +2110,12 @@ public class ActivityManager {
        private final boolean mIsRealSnapshot;
        private final int mWindowingMode;
        private final float mScale;
        private final int mSystemUiVisibility;
        private final boolean mIsTranslucent;

        public TaskSnapshot(GraphicBuffer snapshot, int orientation, Rect contentInsets,
                boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode) {
                boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode,
                int systemUiVisibility, boolean isTranslucent) {
            mSnapshot = snapshot;
            mOrientation = orientation;
            mContentInsets = new Rect(contentInsets);
@@ -2120,6 +2123,8 @@ public class ActivityManager {
            mScale = scale;
            mIsRealSnapshot = isRealSnapshot;
            mWindowingMode = windowingMode;
            mSystemUiVisibility = systemUiVisibility;
            mIsTranslucent = isTranslucent;
        }

        private TaskSnapshot(Parcel source) {
@@ -2130,6 +2135,8 @@ public class ActivityManager {
            mScale = source.readFloat();
            mIsRealSnapshot = source.readBoolean();
            mWindowingMode = source.readInt();
            mSystemUiVisibility = source.readInt();
            mIsTranslucent = source.readBoolean();
        }

        /**
@@ -2169,6 +2176,13 @@ public class ActivityManager {
            return mIsRealSnapshot;
        }

        /**
         * @return Whether or not the snapshot is of a translucent app window.
         */
        public boolean isTranslucent() {
            return mIsTranslucent;
        }

        /**
         * @return The windowing mode of the task when this snapshot was taken.
         */
@@ -2176,6 +2190,14 @@ public class ActivityManager {
            return mWindowingMode;
        }

        /**
         * @return The system ui visibility flags for the top most visible fullscreen window at the
         *         time that the snapshot was taken.
         */
        public int getSystemUiVisibility() {
            return mSystemUiVisibility;
        }

        /**
         * @return The scale this snapshot was taken in.
         */
@@ -2197,6 +2219,8 @@ public class ActivityManager {
            dest.writeFloat(mScale);
            dest.writeBoolean(mIsRealSnapshot);
            dest.writeInt(mWindowingMode);
            dest.writeInt(mSystemUiVisibility);
            dest.writeBoolean(mIsTranslucent);
        }

        @Override
@@ -2207,7 +2231,9 @@ public class ActivityManager {
                    + " mOrientation=" + mOrientation
                    + " mContentInsets=" + mContentInsets.toShortString()
                    + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale
                    + " mIsRealSnapshot=" + mIsRealSnapshot + " mWindowingMode=" + mWindowingMode;
                    + " mIsRealSnapshot=" + mIsRealSnapshot + " mWindowingMode=" + mWindowingMode
                    + " mSystemUiVisibility=" + mSystemUiVisibility
                    + " mIsTranslucent=" + mIsTranslucent;
        }

        public static final Creator<TaskSnapshot> CREATOR = new Creator<TaskSnapshot>() {
+6 −0
Original line number Diff line number Diff line
@@ -33,7 +33,9 @@ public class ThumbnailData {
    public Rect insets;
    public boolean reducedResolution;
    public boolean isRealSnapshot;
    public boolean isTranslucent;
    public int windowingMode;
    public int systemUiVisibility;
    public float scale;

    public ThumbnailData() {
@@ -43,7 +45,9 @@ public class ThumbnailData {
        reducedResolution = false;
        scale = 1f;
        isRealSnapshot = true;
        isTranslucent = false;
        windowingMode = WINDOWING_MODE_UNDEFINED;
        systemUiVisibility = 0;
    }

    public ThumbnailData(TaskSnapshot snapshot) {
@@ -53,6 +57,8 @@ public class ThumbnailData {
        reducedResolution = snapshot.isReducedResolution();
        scale = snapshot.getScale();
        isRealSnapshot = snapshot.isRealSnapshot();
        isTranslucent = snapshot.isTranslucent();
        windowingMode = snapshot.getWindowingMode();
        systemUiVisibility = snapshot.getSystemUiVisibility();
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -29,4 +29,6 @@
     int32 inset_bottom = 5;
     bool is_real_snapshot = 6;
     int32 windowing_mode = 7;
     int32 system_ui_visibility = 8;
     bool is_translucent = 9;
 }
 No newline at end of file
+5 −2
Original line number Diff line number Diff line
@@ -558,14 +558,17 @@ public class RecentsAnimationController implements DeathRecipient {
        }

        RemoteAnimationTarget createRemoteAnimationApp() {
            final WindowState mainWindow = mTask.getTopVisibleAppMainWindow();
            final AppWindowToken topApp = mTask.getTopVisibleAppToken();
            final WindowState mainWindow = topApp != null
                    ? topApp.findMainWindow()
                    : null;
            if (mainWindow == null) {
                return null;
            }
            final Rect insets = new Rect(mainWindow.mContentInsets);
            InsetUtils.addInsets(insets, mainWindow.mAppToken.getLetterboxInsets());
            mTarget = new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash,
                    !mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
                    !topApp.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
                    insets, mTask.getPrefixOrderIndex(), mPosition, mBounds,
                    mTask.getWindowConfiguration(), mIsRecentTaskInvisible);
            return mTarget;
+20 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.view.DisplayListCanvas;
import android.view.RenderNode;
import android.view.SurfaceControl;
import android.view.ThreadedRenderer;
import android.view.View;
import android.view.WindowManager.LayoutParams;

import com.android.internal.annotations.VisibleForTesting;
@@ -274,7 +275,8 @@ class TaskSnapshotController {
        }
        return new TaskSnapshot(buffer, top.getConfiguration().orientation,
                getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */,
                true /* isRealSnapshot */, task.getWindowingMode());
                true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task),
                !top.fillsParent());
    }

    private boolean shouldDisableSnapshots() {
@@ -364,7 +366,8 @@ class TaskSnapshotController {
        return new TaskSnapshot(hwBitmap.createGraphicBufferHandle(),
                topChild.getConfiguration().orientation, mainWindow.mStableInsets,
                ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */,
                false /* isRealSnapshot */, task.getWindowingMode());
                false /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task),
                !topChild.fillsParent());
    }

    /**
@@ -429,6 +432,21 @@ class TaskSnapshotController {
        });
    }

    /**
     * @return The SystemUI visibility flags for the top fullscreen window in the given
     *         {@param task}.
     */
    private int getSystemUiVisibility(Task task) {
        final AppWindowToken topFullscreenToken = task.getTopFullscreenAppToken();
        final WindowState topFullscreenWindow = topFullscreenToken != null
                ? topFullscreenToken.getTopFullscreenWindow()
                : null;
        if (topFullscreenWindow != null) {
            return topFullscreenWindow.getSystemUiVisibility();
        }
        return 0;
    }

    void dump(PrintWriter pw, String prefix) {
        mCache.dump(pw, prefix);
    }
Loading