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

Commit 8af5e1a2 authored by Robin Lee's avatar Robin Lee
Browse files

Switch Notification Shade zoom to leverage DoF

Test: atest AppZoomOutControllerTest
Test: atest NotificationShadeDepthControllerTest
Bug: 391463550
Flag: com.android.systemui.spatial_model_pushback_in_shader
Change-Id: I59b5f7331464b8dce13c90466f63c544f00f17aa
parent 4011ec32
Loading
Loading
Loading
Loading
+28 −9
Original line number Original line Diff line number Diff line
@@ -39,11 +39,12 @@ public class SyncRtSurfaceTransactionApplier {
    public static final int FLAG_LAYER = 1 << 3;
    public static final int FLAG_LAYER = 1 << 3;
    public static final int FLAG_CORNER_RADIUS = 1 << 4;
    public static final int FLAG_CORNER_RADIUS = 1 << 4;
    public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5;
    public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5;
    public static final int FLAG_VISIBILITY = 1 << 6;
    public static final int FLAG_BACKGROUND_BLUR_SCALE = 1 << 6;
    public static final int FLAG_TRANSACTION = 1 << 7;
    public static final int FLAG_VISIBILITY = 1 << 7;
    public static final int FLAG_EARLY_WAKEUP_START = 1 << 8;
    public static final int FLAG_TRANSACTION = 1 << 8;
    public static final int FLAG_EARLY_WAKEUP_END = 1 << 9;
    public static final int FLAG_EARLY_WAKEUP_START = 1 << 9;
    public static final int FLAG_OPAQUE = 1 << 10;
    public static final int FLAG_EARLY_WAKEUP_END = 1 << 10;
    public static final int FLAG_OPAQUE = 1 << 11;


    private SurfaceControl mTargetSc;
    private SurfaceControl mTargetSc;
    private final ViewRootImpl mTargetViewRootImpl;
    private final ViewRootImpl mTargetViewRootImpl;
@@ -128,6 +129,9 @@ public class SyncRtSurfaceTransactionApplier {
        if ((params.flags & FLAG_BACKGROUND_BLUR_RADIUS) != 0) {
        if ((params.flags & FLAG_BACKGROUND_BLUR_RADIUS) != 0) {
            t.setBackgroundBlurRadius(params.surface, params.backgroundBlurRadius);
            t.setBackgroundBlurRadius(params.surface, params.backgroundBlurRadius);
        }
        }
        if ((params.flags & FLAG_BACKGROUND_BLUR_SCALE) != 0) {
            t.setBackgroundBlurScale(params.surface, params.backgroundBlurScale);
        }
        if ((params.flags & FLAG_VISIBILITY) != 0) {
        if ((params.flags & FLAG_VISIBILITY) != 0) {
            if (params.visible) {
            if (params.visible) {
                t.show(params.surface);
                t.show(params.surface);
@@ -183,6 +187,7 @@ public class SyncRtSurfaceTransactionApplier {
            float alpha;
            float alpha;
            float cornerRadius;
            float cornerRadius;
            int backgroundBlurRadius;
            int backgroundBlurRadius;
            float backgroundBlurScale;
            Matrix matrix;
            Matrix matrix;
            Rect windowCrop;
            Rect windowCrop;
            int layer;
            int layer;
@@ -252,12 +257,22 @@ public class SyncRtSurfaceTransactionApplier {
             * @param radius the Radius for blur to apply to the background surfaces.
             * @param radius the Radius for blur to apply to the background surfaces.
             * @return this Builder
             * @return this Builder
             */
             */
            public Builder withBackgroundBlur(int radius) {
            public Builder withBackgroundBlurRadius(int radius) {
                this.backgroundBlurRadius = radius;
                this.backgroundBlurRadius = radius;
                flags |= FLAG_BACKGROUND_BLUR_RADIUS;
                flags |= FLAG_BACKGROUND_BLUR_RADIUS;
                return this;
                return this;
            }
            }


            /**
             * @param scale the Scale for blur to apply to the background surfaces.
             * @return this Builder
             */
            public Builder withBackgroundBlurScale(float scale) {
                this.backgroundBlurScale = scale;
                flags |= FLAG_BACKGROUND_BLUR_SCALE;
                return this;
            }

            /**
            /**
             * @param visible The visibility to apply to the surface.
             * @param visible The visibility to apply to the surface.
             * @return this Builder
             * @return this Builder
@@ -315,14 +330,14 @@ public class SyncRtSurfaceTransactionApplier {
             */
             */
            public SurfaceParams build() {
            public SurfaceParams build() {
                return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer,
                return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer,
                        cornerRadius, backgroundBlurRadius, visible, mergeTransaction,
                        cornerRadius, backgroundBlurRadius, backgroundBlurScale, visible,
                        opaque, earlyWakeupInfo);
                        mergeTransaction, opaque, earlyWakeupInfo);
            }
            }
        }
        }


        private SurfaceParams(SurfaceControl surface, int params, float alpha, Matrix matrix,
        private SurfaceParams(SurfaceControl surface, int params, float alpha, Matrix matrix,
                Rect windowCrop, int layer, float cornerRadius,
                Rect windowCrop, int layer, float cornerRadius,
                int backgroundBlurRadius, boolean visible,
                int backgroundBlurRadius, float backgroundBlurScale, boolean visible,
                Transaction mergeTransaction, boolean opaque, EarlyWakeupInfo earlyWakeupInfo) {
                Transaction mergeTransaction, boolean opaque, EarlyWakeupInfo earlyWakeupInfo) {
            this.flags = params;
            this.flags = params;
            this.surface = surface;
            this.surface = surface;
@@ -332,6 +347,7 @@ public class SyncRtSurfaceTransactionApplier {
            this.layer = layer;
            this.layer = layer;
            this.cornerRadius = cornerRadius;
            this.cornerRadius = cornerRadius;
            this.backgroundBlurRadius = backgroundBlurRadius;
            this.backgroundBlurRadius = backgroundBlurRadius;
            this.backgroundBlurScale = backgroundBlurScale;
            this.visible = visible;
            this.visible = visible;
            this.mergeTransaction = mergeTransaction;
            this.mergeTransaction = mergeTransaction;
            this.opaque = opaque;
            this.opaque = opaque;
@@ -352,6 +368,9 @@ public class SyncRtSurfaceTransactionApplier {
        @VisibleForTesting
        @VisibleForTesting
        public final int backgroundBlurRadius;
        public final int backgroundBlurRadius;


        @VisibleForTesting
        public final float backgroundBlurScale;

        @VisibleForTesting
        @VisibleForTesting
        public final Matrix matrix;
        public final Matrix matrix;


+4 −1
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;


import static com.android.systemui.Flags.spatialModelAppPushback;
import static com.android.systemui.Flags.spatialModelAppPushback;
import static com.android.systemui.Flags.spatialModelPushbackInShader;
import static com.android.systemui.shared.Flags.enableLppAssistInvocationEffect;
import static com.android.systemui.shared.Flags.enableLppAssistInvocationEffect;


import android.app.ActivityManager;
import android.app.ActivityManager;
@@ -127,8 +128,10 @@ public class AppZoomOutController implements RemoteCallable<AppZoomOutController
    }
    }


    public void setProgress(float progress) {
    public void setProgress(float progress) {
        if (!spatialModelPushbackInShader()) {
            mAppDisplayAreaOrganizer.setProgress(progress);
            mAppDisplayAreaOrganizer.setProgress(progress);
        }
        }
    }


    /**
    /**
     * Scales all content on the screen belonging to
     * Scales all content on the screen belonging to
+16 −16
Original line number Original line Diff line number Diff line
@@ -248,7 +248,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        )
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -311,7 +311,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    fun setFullShadeTransition_appliesBlur() {
    fun setFullShadeTransition_appliesBlur() {
        notificationShadeDepthController.transitionToFullShadeProgress = 1f
        notificationShadeDepthController.transitionToFullShadeProgress = 1f
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -320,7 +320,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {


        statusBarStateListener.onDozeAmountChanged(1f, 1f)
        statusBarStateListener.onDozeAmountChanged(1f, 1f)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), eq(0), eq(false))
        verify(blurUtils).applyBlur(any(), eq(0), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -329,7 +329,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {


        statusBarStateListener.onDozeAmountChanged(1f, 1f)
        statusBarStateListener.onDozeAmountChanged(1f, 1f)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -346,7 +346,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {


        notificationShadeDepthController.transitionToFullShadeProgress = 1f
        notificationShadeDepthController.transitionToFullShadeProgress = 1f
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), eq(0), eq(false))
        verify(blurUtils).applyBlur(any(), eq(0), eq(false), anyFloat())
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
    }
    }


@@ -355,7 +355,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.addListener(listener)
        notificationShadeDepthController.addListener(listener)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(wallpaperController).setNotificationShadeZoom(anyFloat())
        verify(wallpaperController).setNotificationShadeZoom(anyFloat())
        verify(blurUtils).applyBlur(any(), anyInt(), eq(false))
        verify(blurUtils).applyBlur(any(), anyInt(), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -391,7 +391,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    fun updateBlurCallback_setsOpaque_whenScrim() {
    fun updateBlurCallback_setsOpaque_whenScrim() {
        scrimVisibilityCaptor.value.accept(ScrimController.OPAQUE)
        scrimVisibilityCaptor.value.accept(ScrimController.OPAQUE)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), anyInt(), eq(true))
        verify(blurUtils).applyBlur(any(), anyInt(), eq(true), anyFloat())
    }
    }


    @Test
    @Test
@@ -401,7 +401,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        )
        )
        `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
        `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -412,7 +412,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
        `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
        notificationShadeDepthController.blursDisabledForAppLaunch = true
        notificationShadeDepthController.blursDisabledForAppLaunch = true
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(blurUtils).applyBlur(any(), eq(0), eq(false))
        verify(blurUtils).applyBlur(any(), eq(0), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -428,7 +428,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP)
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP)
    fun ignoreShadeBlurUntilHidden_requestsBlur_windowBlurFlag() {
    fun ignoreShadeBlurUntilHidden_requestsBlur_windowBlurFlag() {
        notificationShadeDepthController.blursDisabledForAppLaunch = true
        notificationShadeDepthController.blursDisabledForAppLaunch = true
        verify(windowRootViewBlurInteractor).requestBlurForShade(anyInt())
        verify(windowRootViewBlurInteractor).requestBlurForShade(anyInt(), anyFloat())
    }
    }


    @Test
    @Test
@@ -445,7 +445,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {


        // Since we are ignoring blurs for unlock, we should be applying blur = 0 despite setting it
        // Since we are ignoring blurs for unlock, we should be applying blur = 0 despite setting it
        // to maxBlur above.
        // to maxBlur above.
        verify(blurUtils).applyBlur(any(), eq(0), eq(false))
        verify(blurUtils).applyBlur(any(), eq(0), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -462,7 +462,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {


        // Since we are not ignoring blurs for unlock (or app launch), we should apply the blur we
        // Since we are not ignoring blurs for unlock (or app launch), we should apply the blur we
        // returned above (maxBlur).
        // returned above (maxBlur).
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
        verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -496,7 +496,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -515,7 +515,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false), anyFloat())
    }
    }


    @Test
    @Test
@@ -533,7 +533,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(0)
        verify(windowRootViewBlurInteractor).requestBlurForShade(eq(0), eq(1f))
    }
    }


    @Test
    @Test
@@ -550,7 +550,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(0)
        verify(windowRootViewBlurInteractor).requestBlurForShade(eq(0), eq(1f))
    }
    }


    @Test
    @Test
+1 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,6 @@ class WindowRootViewBlurInteractorTest : SysuiTestCase() {
        testScope.runTest {
        testScope.runTest {
            kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(true)
            kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(true)


            assertThat(underTest.requestBlurForShade(30)).isFalse()
            assertThat(underTest.requestBlurForShade(30, 1.0f)).isFalse()
        }
        }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -366,7 +366,7 @@ public class DreamOverlayContainerViewController extends
        if (!bouncerUiRevamp()) {
        if (!bouncerUiRevamp()) {
            mBlurUtils.applyBlur(mView.getViewRootImpl(),
            mBlurUtils.applyBlur(mView.getViewRootImpl(),
                    (int) mBlurUtils.blurRadiusOfRatio(
                    (int) mBlurUtils.blurRadiusOfRatio(
                            1 - aboutToShowBouncerProgress(bouncerHideAmount)), false);
                            1 - aboutToShowBouncerProgress(bouncerHideAmount)), false, 1.0f);
        }
        }
    }
    }


Loading