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

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

Merge "[PB] Do not show snapshot if uiMode has changed." into main

parents 9addfc84 f68351c7
Loading
Loading
Loading
Loading
+25 −3
Original line number Original line Diff line number Diff line
@@ -72,6 +72,7 @@ public class TaskSnapshot implements Parcelable {
    int mAppearance;
    int mAppearance;
    private final boolean mIsTranslucent;
    private final boolean mIsTranslucent;
    private final boolean mHasImeSurface;
    private final boolean mHasImeSurface;
    private final int mUiMode;
    // Must be one of the named color spaces, otherwise, always use SRGB color space.
    // Must be one of the named color spaces, otherwise, always use SRGB color space.
    private final ColorSpace mColorSpace;
    private final ColorSpace mColorSpace;
    private int mInternalReferences;
    private int mInternalReferences;
@@ -96,7 +97,7 @@ public class TaskSnapshot implements Parcelable {
            Rect contentInsets, Rect letterboxInsets, boolean isLowResolution,
            Rect contentInsets, Rect letterboxInsets, boolean isLowResolution,
            boolean isRealSnapshot, int windowingMode,
            boolean isRealSnapshot, int windowingMode,
            @WindowInsetsController.Appearance int appearance, boolean isTranslucent,
            @WindowInsetsController.Appearance int appearance, boolean isTranslucent,
            boolean hasImeSurface) {
            boolean hasImeSurface, int uiMode) {
        mId = id;
        mId = id;
        mCaptureTime = captureTime;
        mCaptureTime = captureTime;
        mTopActivityComponent = topActivityComponent;
        mTopActivityComponent = topActivityComponent;
@@ -114,6 +115,7 @@ public class TaskSnapshot implements Parcelable {
        mAppearance = appearance;
        mAppearance = appearance;
        mIsTranslucent = isTranslucent;
        mIsTranslucent = isTranslucent;
        mHasImeSurface = hasImeSurface;
        mHasImeSurface = hasImeSurface;
        mUiMode = uiMode;
    }
    }


    private TaskSnapshot(Parcel source) {
    private TaskSnapshot(Parcel source) {
@@ -136,6 +138,7 @@ public class TaskSnapshot implements Parcelable {
        mAppearance = source.readInt();
        mAppearance = source.readInt();
        mIsTranslucent = source.readBoolean();
        mIsTranslucent = source.readBoolean();
        mHasImeSurface = source.readBoolean();
        mHasImeSurface = source.readBoolean();
        mUiMode = source.readInt();
    }
    }


    /**
    /**
@@ -273,6 +276,13 @@ public class TaskSnapshot implements Parcelable {
        return mAppearance;
        return mAppearance;
    }
    }


    /**
     * @return The uiMode the screenshot was taken in.
     */
    public int getUiMode() {
        return mUiMode;
    }

    @Override
    @Override
    public int describeContents() {
    public int describeContents() {
        return 0;
        return 0;
@@ -295,6 +305,7 @@ public class TaskSnapshot implements Parcelable {
        dest.writeInt(mAppearance);
        dest.writeInt(mAppearance);
        dest.writeBoolean(mIsTranslucent);
        dest.writeBoolean(mIsTranslucent);
        dest.writeBoolean(mHasImeSurface);
        dest.writeBoolean(mHasImeSurface);
        dest.writeInt(mUiMode);
    }
    }


    @Override
    @Override
@@ -318,7 +329,8 @@ public class TaskSnapshot implements Parcelable {
                + " mAppearance=" + mAppearance
                + " mAppearance=" + mAppearance
                + " mIsTranslucent=" + mIsTranslucent
                + " mIsTranslucent=" + mIsTranslucent
                + " mHasImeSurface=" + mHasImeSurface
                + " mHasImeSurface=" + mHasImeSurface
                + " mInternalReferences=" + mInternalReferences;
                + " mInternalReferences=" + mInternalReferences
                + " mUiMode=" + Integer.toHexString(mUiMode);
    }
    }


    /**
    /**
@@ -370,6 +382,7 @@ public class TaskSnapshot implements Parcelable {
        private boolean mIsTranslucent;
        private boolean mIsTranslucent;
        private boolean mHasImeSurface;
        private boolean mHasImeSurface;
        private int mPixelFormat;
        private int mPixelFormat;
        private int mUiMode;


        public Builder setId(long id) {
        public Builder setId(long id) {
            mId = id;
            mId = id;
@@ -452,6 +465,14 @@ public class TaskSnapshot implements Parcelable {
            return this;
            return this;
        }
        }


        /**
         * Sets the original uiMode while capture
         */
        public Builder setUiMode(int uiMode) {
            mUiMode = uiMode;
            return this;
        }

        public int getPixelFormat() {
        public int getPixelFormat() {
            return mPixelFormat;
            return mPixelFormat;
        }
        }
@@ -481,7 +502,8 @@ public class TaskSnapshot implements Parcelable {
                    mWindowingMode,
                    mWindowingMode,
                    mAppearance,
                    mAppearance,
                    mIsTranslucent,
                    mIsTranslucent,
                    mHasImeSurface);
                    mHasImeSurface,
                    mUiMode);


        }
        }
    }
    }
+2 −1
Original line number Original line Diff line number Diff line
@@ -93,7 +93,8 @@ public class SnapshotDrawerUtilsTest {
                ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
                ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
                Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
                Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
                false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                0 /* systemUiVisibility */, false /* isTranslucent */, false /* hasImeSurface */);
                0 /* systemUiVisibility */, false /* isTranslucent */, false /* hasImeSurface */,
                0 /* uiMode */);
    }
    }


    private static TaskDescription createTaskDescription(int background,
    private static TaskDescription createTaskDescription(int background,
+3 −11
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.wm.shell.startingsurface;
package com.android.wm.shell.startingsurface;


import static android.graphics.Color.WHITE;
import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SPLASH_SCREEN;
import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SPLASH_SCREEN;


import android.app.ActivityManager;
import android.app.ActivityManager;
@@ -69,8 +68,9 @@ class WindowlessSplashWindowCreator extends AbsSplashWindowCreator {
            // Can't show splash screen on requested display, so skip showing at all.
            // Can't show splash screen on requested display, so skip showing at all.
            return;
            return;
        }
        }
        final int theme = getSplashScreenTheme(0 /* splashScreenThemeResId */, activityInfo);
        final Context myContext = SplashscreenContentDrawer.createContext(mContext, windowInfo,
        final Context myContext = SplashscreenContentDrawer.createContext(mContext, windowInfo,
                0 /* theme */, STARTING_WINDOW_TYPE_SPLASH_SCREEN, mDisplayManager);
                theme, STARTING_WINDOW_TYPE_SPLASH_SCREEN, mDisplayManager);
        if (myContext == null) {
        if (myContext == null) {
            return;
            return;
        }
        }
@@ -86,19 +86,11 @@ class WindowlessSplashWindowCreator extends AbsSplashWindowCreator {
        final Rect windowBounds = taskInfo.configuration.windowConfiguration.getBounds();
        final Rect windowBounds = taskInfo.configuration.windowConfiguration.getBounds();
        lp.width = windowBounds.width();
        lp.width = windowBounds.width();
        lp.height = windowBounds.height();
        lp.height = windowBounds.height();
        final ActivityManager.TaskDescription taskDescription;
        if (taskInfo.taskDescription != null) {
            taskDescription = taskInfo.taskDescription;
        } else {
            taskDescription = new ActivityManager.TaskDescription();
            taskDescription.setBackgroundColor(WHITE);
        }


        final FrameLayout rootLayout = new FrameLayout(
        final FrameLayout rootLayout = new FrameLayout(
                mSplashscreenContentDrawer.createViewContextWrapper(myContext));
                mSplashscreenContentDrawer.createViewContextWrapper(myContext));
        viewHost.setView(rootLayout, lp);
        viewHost.setView(rootLayout, lp);

        final int bgColor = mSplashscreenContentDrawer.estimateTaskBackgroundColor(myContext);
        final int bgColor = taskDescription.getBackgroundColor();
        final SplashScreenView splashScreenView = mSplashscreenContentDrawer
        final SplashScreenView splashScreenView = mSplashscreenContentDrawer
                .makeSimpleSplashScreenContentView(myContext, windowInfo, bgColor);
                .makeSimpleSplashScreenContentView(myContext, windowInfo, bgColor);
        rootLayout.addView(splashScreenView);
        rootLayout.addView(splashScreenView);
+1 −1
Original line number Original line Diff line number Diff line
@@ -370,6 +370,6 @@ public class StartingSurfaceDrawerTests extends ShellTestCase {
                Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
                Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
                false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                0 /* systemUiVisibility */, false /* isTranslucent */,
                0 /* systemUiVisibility */, false /* isTranslucent */,
                hasImeSurface /* hasImeSurface */);
                hasImeSurface /* hasImeSurface */, 0 /* uiMode */);
    }
    }
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -104,6 +104,7 @@ class ActivityTaskManagerThumbnailLoaderTest : SysuiTestCase() {
            WindowConfiguration.WINDOWING_MODE_FULLSCREEN,
            WindowConfiguration.WINDOWING_MODE_FULLSCREEN,
            /* appearance= */ 0,
            /* appearance= */ 0,
            /* isTranslucent= */ false,
            /* isTranslucent= */ false,
            /* hasImeSurface= */ false
            /* hasImeSurface= */ false,
            /* uiMode */ 0
        )
        )
}
}
Loading