From 66eb980ce012145cc97779b6628a4099335cba6d Mon Sep 17 00:00:00 2001 From: Chandru S Date: Wed, 5 Feb 2025 22:46:21 +0000 Subject: Add a flow that can be used to determine whether cross window blur is enabled/supported right now. CrossWindowBlurListeners handles the following checks for blur: 1. whether the device supports blur or not (ro.surface_flinger.supports_background_blur property) 2. whether battery saver is enabled or not 3. whether critical thermal status has reached or not 4. whether blur is disabled in dev settings or not 5. whether multimedia tunneling is enabled or not. Repository adds two additional checks: 1. whether persist.sysui.disableBlur is set or not (used by tests) 2. whether ActivityManager.isHighEndGfx is true or not, BlurUtils has this check before enabling or disabling blur. Bug: 391409723 Test: Tried adding unit tests but it might be flakey because of ActivityManager.isHighEndGfx check, it is unclear how this can be mocked Flag: com.android.systemui.bouncer_ui_revamp Change-Id: Ie4ec36e132fef04a40bd3e0c054065554be1b302 --- .../src/com/android/systemui/shade/ShadeModule.kt | 6 ++- .../window/dagger/WindowRootViewBlurModule.kt | 35 +++++++++++++ .../dagger/WindowRootViewBlurNotSupportedModule.kt | 35 +++++++++++++ .../repository/NoopWindowRootViewBlurRepository.kt | 28 ++++++++++ .../repository/WindowRootViewBlurRepository.kt | 60 ++++++++++++++++++++-- .../interactor/WindowRootViewBlurInteractor.kt | 6 +++ .../WindowRootViewBlurRepositoryKosmos.kt | 13 ++++- 7 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurModule.kt create mode 100644 packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurNotSupportedModule.kt create mode 100644 packages/SystemUI/src/com/android/systemui/window/data/repository/NoopWindowRootViewBlurRepository.kt diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt index b9df9f868dc3..7d4b0ed6304c 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt @@ -45,13 +45,17 @@ import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractorImpl import com.android.systemui.shade.domain.interactor.ShadeModeInteractor import com.android.systemui.shade.domain.interactor.ShadeModeInteractorImpl +import com.android.systemui.window.dagger.WindowRootViewBlurModule import dagger.Binds import dagger.Module import dagger.Provides import javax.inject.Provider /** Module for classes related to the notification shade. */ -@Module(includes = [StartShadeModule::class, ShadeViewProviderModule::class]) +@Module( + includes = + [StartShadeModule::class, ShadeViewProviderModule::class, WindowRootViewBlurModule::class] +) abstract class ShadeModule { companion object { @Provides diff --git a/packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurModule.kt b/packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurModule.kt new file mode 100644 index 000000000000..95b3b68fa1ca --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurModule.kt @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.window.dagger + +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.window.data.repository.WindowRootViewBlurRepository +import com.android.systemui.window.data.repository.WindowRootViewBlurRepositoryImpl +import dagger.Binds +import dagger.Module + +/** + * Module that can be installed in sysui variants where we support cross window blur. + */ +@Module +interface WindowRootViewBlurModule { + @Binds + @SysUISingleton + fun bindWindowRootViewBlurRepository( + windowRootViewBlurRepositoryImpl: WindowRootViewBlurRepositoryImpl + ): WindowRootViewBlurRepository +} diff --git a/packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurNotSupportedModule.kt b/packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurNotSupportedModule.kt new file mode 100644 index 000000000000..ae917e072ff3 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/window/dagger/WindowRootViewBlurNotSupportedModule.kt @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.window.dagger + +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.window.data.repository.NoopWindowRootViewBlurRepository +import com.android.systemui.window.data.repository.WindowRootViewBlurRepository +import dagger.Binds +import dagger.Module + +/** + * Module that can be installed in sysui variants where we don't support cross window blur. + */ +@Module +interface WindowRootViewBlurNotSupportedModule { + @Binds + @SysUISingleton + fun bindWindowRootViewBlurRepository( + windowRootViewBlurRepositoryImpl: NoopWindowRootViewBlurRepository + ): WindowRootViewBlurRepository +} diff --git a/packages/SystemUI/src/com/android/systemui/window/data/repository/NoopWindowRootViewBlurRepository.kt b/packages/SystemUI/src/com/android/systemui/window/data/repository/NoopWindowRootViewBlurRepository.kt new file mode 100644 index 000000000000..80aa11a71569 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/window/data/repository/NoopWindowRootViewBlurRepository.kt @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.window.data.repository + +import com.android.systemui.window.data.repository.WindowRootViewBlurRepository +import javax.inject.Inject +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow + +class NoopWindowRootViewBlurRepository @Inject constructor() : WindowRootViewBlurRepository { + override val blurRadius: MutableStateFlow = MutableStateFlow(0) + override val isBlurOpaque: MutableStateFlow = MutableStateFlow(true) + override val isBlurSupported: StateFlow = MutableStateFlow(false) +} \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt b/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt index 22a74c86e0f1..2f6535b91c8e 100644 --- a/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt @@ -16,14 +16,68 @@ package com.android.systemui.window.data.repository +import android.app.ActivityManager +import android.os.SystemProperties +import android.view.CrossWindowBlurListeners +import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.dagger.qualifiers.Application +import com.android.systemui.dagger.qualifiers.Main +import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow +import java.util.concurrent.Executor import javax.inject.Inject +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.stateIn /** Repository that maintains state for the window blur effect. */ +interface WindowRootViewBlurRepository { + val blurRadius: MutableStateFlow + val isBlurOpaque: MutableStateFlow + + /** Is blur supported based on settings toggle and battery power saver mode. */ + val isBlurSupported: StateFlow +} + @SysUISingleton -class WindowRootViewBlurRepository @Inject constructor() { - val blurRadius = MutableStateFlow(0) +class WindowRootViewBlurRepositoryImpl +@Inject +constructor( + crossWindowBlurListeners: CrossWindowBlurListeners, + @Main private val executor: Executor, + @Application private val scope: CoroutineScope, +) : WindowRootViewBlurRepository { + override val blurRadius = MutableStateFlow(0) + + override val isBlurOpaque = MutableStateFlow(false) + + override val isBlurSupported: StateFlow = + conflatedCallbackFlow { + val sendUpdate = { value: Boolean -> + trySendWithFailureLogging( + !isBlurExplicitlyDisabled() && value, + TAG, + "unable to send blur enabled/disable state change", + ) + } + crossWindowBlurListeners.addListener(executor, sendUpdate) + sendUpdate(crossWindowBlurListeners.isCrossWindowBlurEnabled) + + awaitClose { crossWindowBlurListeners.removeListener(sendUpdate) } + } // stateIn because this is backed by a binder call. + .stateIn(scope, SharingStarted.WhileSubscribed(), false) + + private fun isBlurExplicitlyDisabled(): Boolean { + return !ActivityManager.isHighEndGfx() || + SystemProperties.getBoolean(DISABLE_BLUR_PROPERTY, false) + } - val isBlurOpaque = MutableStateFlow(false) + companion object { + const val TAG = "WindowRootViewBlurRepository" + // property that can be used to disable the cross window blur for tests + private const val DISABLE_BLUR_PROPERTY = "persist.sysui.disableBlur" + } } diff --git a/packages/SystemUI/src/com/android/systemui/window/domain/interactor/WindowRootViewBlurInteractor.kt b/packages/SystemUI/src/com/android/systemui/window/domain/interactor/WindowRootViewBlurInteractor.kt index 9e369347dea5..7a88a2ef966b 100644 --- a/packages/SystemUI/src/com/android/systemui/window/domain/interactor/WindowRootViewBlurInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/window/domain/interactor/WindowRootViewBlurInteractor.kt @@ -75,6 +75,12 @@ constructor( _onBlurAppliedEvent.emit(appliedBlurRadius) } + /** + * Whether blur is enabled or not based on settings toggle, critical thermal state, battery save + * state and multimedia tunneling state. + */ + val isBlurCurrentlySupported: StateFlow = repository.isBlurSupported + /** Radius of blur to be applied on the window root view. */ val blurRadius: StateFlow = repository.blurRadius.asStateFlow() diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepositoryKosmos.kt index 7281e03a5ea4..96992233375d 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepositoryKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepositoryKosmos.kt @@ -17,5 +17,16 @@ package com.android.systemui.window.data.repository import com.android.systemui.kosmos.Kosmos +import kotlinx.coroutines.flow.MutableStateFlow -val Kosmos.windowRootViewBlurRepository by Kosmos.Fixture { WindowRootViewBlurRepository() } +val Kosmos.fakeWindowRootViewBlurRepository: FakeWindowRootViewBlurRepository by + Kosmos.Fixture { FakeWindowRootViewBlurRepository() } + +val Kosmos.windowRootViewBlurRepository: WindowRootViewBlurRepository by + Kosmos.Fixture { fakeWindowRootViewBlurRepository } + +class FakeWindowRootViewBlurRepository : WindowRootViewBlurRepository { + override val blurRadius: MutableStateFlow = MutableStateFlow(0) + override val isBlurOpaque: MutableStateFlow = MutableStateFlow(false) + override val isBlurSupported: MutableStateFlow = MutableStateFlow(false) +} -- cgit v1.2.3-59-g8ed1b From fc8a6a7efea114c9b799c43539029d49bfee98e3 Mon Sep 17 00:00:00 2001 From: Chandru S Date: Wed, 5 Feb 2025 23:12:52 +0000 Subject: Disable transparent bouncer and scrims when blur is not supported or disabled Bug: 391409723 Flag: com.android.systemui.bouncer_ui_revamp Test: verified manually bouncer background is not transparent when blur is disabled. Change-Id: I453d88a79f5d33a139fc42e84f7c172f161ec427 --- .../KeyguardSecurityContainerControllerTest.kt | 7 ++-- .../keyguard/KeyguardSecurityContainer.java | 23 +++++++++--- .../KeyguardSecurityContainerController.java | 42 +++++++++++++++++++++- .../systemui/statusbar/phone/ScrimController.java | 41 +++++++++++++++++---- .../systemui/statusbar/phone/ScrimState.java | 17 +++++---- .../repository/WindowRootViewBlurRepository.kt | 21 +++++++---- .../statusbar/phone/ScrimControllerTest.java | 6 ++-- .../android/systemui/kosmos/KosmosJavaAdapter.kt | 2 ++ 8 files changed, 127 insertions(+), 32 deletions(-) diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt index fe665e658feb..24b9e847d621 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt @@ -84,6 +84,7 @@ import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.time.FakeSystemClock +import com.android.systemui.window.domain.interactor.windowRootViewBlurInteractor import com.google.common.truth.Truth import junit.framework.Assert import kotlinx.coroutines.flow.MutableStateFlow @@ -280,9 +281,9 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { kosmos.keyguardDismissTransitionInteractor, { primaryBouncerInteractor }, executor, - ) { - deviceEntryInteractor - } + { deviceEntryInteractor }, + { kosmos.windowRootViewBlurInteractor }, + ) } @Test diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index 335a910eb106..73dc28230e65 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -98,7 +98,6 @@ import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardSecurityModel.SecurityMode; import com.android.settingslib.Utils; import com.android.settingslib.drawable.CircleFramedDrawable; -import com.android.systemui.Flags; import com.android.systemui.FontStyles; import com.android.systemui.Gefingerpoken; import com.android.systemui.classifier.FalsingA11yDelegate; @@ -121,6 +120,7 @@ public class KeyguardSecurityContainer extends ConstraintLayout { static final int USER_TYPE_PRIMARY = 1; static final int USER_TYPE_WORK_PROFILE = 2; static final int USER_TYPE_SECONDARY_USER = 3; + private boolean mTransparentModeEnabled = false; @IntDef({MODE_UNINITIALIZED, MODE_DEFAULT, MODE_ONE_HANDED, MODE_USER_SWITCHER}) public @interface Mode {} @@ -814,15 +814,30 @@ public class KeyguardSecurityContainer extends ConstraintLayout { mDisappearAnimRunning = false; } + /** + * Make the bouncer background transparent + */ + public void enableTransparentMode() { + mTransparentModeEnabled = true; + reloadBackgroundColor(); + } + + /** + * Make the bouncer background opaque + */ + public void disableTransparentMode() { + mTransparentModeEnabled = false; + reloadBackgroundColor(); + } + private void reloadBackgroundColor() { - if (Flags.bouncerUiRevamp()) { - // Keep the background transparent, otherwise the background color looks like a box - // while scaling the bouncer for back animation or while transitioning to the bouncer. + if (mTransparentModeEnabled) { setBackgroundColor(Color.TRANSPARENT); } else { setBackgroundColor( getContext().getColor(com.android.internal.R.color.materialColorSurfaceDim)); } + invalidate(); } void reloadColors() { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index ff7b2b025539..d10fce416150 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -70,6 +70,7 @@ import com.android.keyguard.KeyguardSecurityContainer.SwipeListener; import com.android.keyguard.KeyguardSecurityModel.SecurityMode; import com.android.keyguard.dagger.KeyguardBouncerScope; import com.android.settingslib.utils.ThreadUtils; +import com.android.systemui.Flags; import com.android.systemui.Gefingerpoken; import com.android.systemui.biometrics.FaceAuthAccessibilityDelegate; import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor; @@ -96,6 +97,8 @@ import com.android.systemui.user.domain.interactor.SelectedUserInteractor; import com.android.systemui.util.ViewController; import com.android.systemui.util.kotlin.JavaAdapter; import com.android.systemui.util.settings.GlobalSettings; +import com.android.systemui.window.data.repository.WindowRootViewBlurRepository; +import com.android.systemui.window.domain.interactor.WindowRootViewBlurInteractor; import dagger.Lazy; @@ -134,6 +137,7 @@ public class KeyguardSecurityContainerController extends ViewController mRootViewBlurInteractor; private int mTranslationY; private final KeyguardDismissTransitionInteractor mKeyguardDismissTransitionInteractor; private final DevicePolicyManager mDevicePolicyManager; @@ -431,6 +435,7 @@ public class KeyguardSecurityContainerController extends ViewController primaryBouncerInteractor, @Background Executor bgExecutor, - Provider deviceEntryInteractor + Provider deviceEntryInteractor, + Lazy rootViewBlurInteractorProvider ) { super(view); + mRootViewBlurInteractor = rootViewBlurInteractorProvider; view.setAccessibilityDelegate(faceAuthAccessibilityDelegate); mLockPatternUtils = lockPatternUtils; mUpdateMonitor = keyguardUpdateMonitor; @@ -539,6 +546,32 @@ public class KeyguardSecurityContainerController extends ViewController mScrimStateListener; private final LargeScreenShadeInterpolator mLargeScreenShadeInterpolator; private final BlurConfig mBlurConfig; + private final Lazy mWindowRootViewBlurInteractor; private Consumer mScrimVisibleListener; private boolean mBlankScreen; private boolean mScreenBlankingCallbackCalled; @@ -339,14 +343,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump KeyguardInteractor keyguardInteractor, @Main CoroutineDispatcher mainDispatcher, LargeScreenShadeInterpolator largeScreenShadeInterpolator, - BlurConfig blurConfig) { + BlurConfig blurConfig, + Lazy windowRootViewBlurInteractor) { mScrimStateListener = lightBarController::setScrimState; mLargeScreenShadeInterpolator = largeScreenShadeInterpolator; mBlurConfig = blurConfig; - // All scrims default alpha need to match bouncer background alpha to make sure the - // transitions involving the bouncer are smooth and don't overshoot the bouncer alpha. - mDefaultScrimAlpha = - Flags.bouncerUiRevamp() ? TRANSPARENT_BOUNCER_SCRIM_ALPHA : BUSY_SCRIM_ALPHA; + mWindowRootViewBlurInteractor = windowRootViewBlurInteractor; + mDefaultScrimAlpha = BUSY_SCRIM_ALPHA; mKeyguardStateController = keyguardStateController; mDarkenWhileDragging = !mKeyguardStateController.canDismissLockScreen(); @@ -407,7 +410,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump final ScrimState[] states = ScrimState.values(); for (int i = 0; i < states.length; i++) { - states[i].init(mScrimInFront, mScrimBehind, mDozeParameters, mDockManager, mBlurConfig); + states[i].init(mScrimInFront, mScrimBehind, mDozeParameters, mDockManager); states[i].setScrimBehindAlphaKeyguard(mScrimBehindAlphaKeyguard); states[i].setDefaultScrimAlpha(mDefaultScrimAlpha); } @@ -485,6 +488,30 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump Edge.Companion.create(Scenes.Communal, LOCKSCREEN), Edge.Companion.create(GLANCEABLE_HUB, LOCKSCREEN)), mGlanceableHubConsumer, mMainDispatcher); + + if (Flags.bouncerUiRevamp()) { + collectFlow(behindScrim, + mWindowRootViewBlurInteractor.get().isBlurCurrentlySupported(), + this::handleBlurSupportedChanged); + } + } + + private void updateDefaultScrimAlpha(float alpha) { + mDefaultScrimAlpha = alpha; + for (ScrimState state : ScrimState.values()) { + state.setDefaultScrimAlpha(mDefaultScrimAlpha); + } + applyAndDispatchState(); + } + + private void handleBlurSupportedChanged(boolean isBlurSupported) { + if (isBlurSupported) { + updateDefaultScrimAlpha(TRANSPARENT_BOUNCER_SCRIM_ALPHA); + ScrimState.BOUNCER_SCRIMMED.setNotifBlurRadius(mBlurConfig.getMaxBlurRadiusPx()); + } else { + ScrimState.BOUNCER_SCRIMMED.setNotifBlurRadius(0f); + updateDefaultScrimAlpha(BUSY_SCRIM_ALPHA); + } } // TODO(b/270984686) recompute scrim height accurately, based on shade contents. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java index 5f423cf35edd..071a57a8b298 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java @@ -17,14 +17,12 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.statusbar.phone.ScrimController.BUSY_SCRIM_ALPHA; -import static com.android.systemui.statusbar.phone.ScrimController.TRANSPARENT_BOUNCER_SCRIM_ALPHA; import android.graphics.Color; import com.android.app.tracing.coroutines.TrackTracer; import com.android.systemui.Flags; import com.android.systemui.dock.DockManager; -import com.android.systemui.keyguard.ui.transitions.BlurConfig; import com.android.systemui.res.R; import com.android.systemui.scrim.ScrimView; import com.android.systemui.shade.ui.ShadeColors; @@ -116,8 +114,8 @@ public enum ScrimState { @Override public void prepare(ScrimState previousState) { if (Flags.bouncerUiRevamp()) { - mBehindAlpha = mClipQsScrim ? 0.0f : TRANSPARENT_BOUNCER_SCRIM_ALPHA; - mNotifAlpha = mClipQsScrim ? TRANSPARENT_BOUNCER_SCRIM_ALPHA : 0; + mBehindAlpha = mDefaultScrimAlpha; + mNotifAlpha = 0f; mBehindTint = mNotifTint = mSurfaceColor; mFrontAlpha = 0f; return; @@ -153,12 +151,11 @@ public enum ScrimState { if (previousState == SHADE_LOCKED) { mBehindAlpha = previousState.getBehindAlpha(); mNotifAlpha = previousState.getNotifAlpha(); - mNotifBlurRadius = mBlurConfig.getMaxBlurRadiusPx(); } else { mNotifAlpha = 0f; mBehindAlpha = 0f; } - mFrontAlpha = TRANSPARENT_BOUNCER_SCRIM_ALPHA; + mFrontAlpha = mDefaultScrimAlpha; mFrontTint = mSurfaceColor; return; } @@ -403,7 +400,6 @@ public enum ScrimState { DozeParameters mDozeParameters; DockManager mDockManager; boolean mDisplayRequiresBlanking; - protected BlurConfig mBlurConfig; boolean mLaunchingAffordanceWithPreview; boolean mOccludeAnimationPlaying; boolean mWakeLockScreenSensorActive; @@ -417,7 +413,7 @@ public enum ScrimState { protected float mNotifBlurRadius = 0.0f; public void init(ScrimView scrimInFront, ScrimView scrimBehind, DozeParameters dozeParameters, - DockManager dockManager, BlurConfig blurConfig) { + DockManager dockManager) { mBackgroundColor = scrimBehind.getContext().getColor(R.color.shade_scrim_background_dark); mScrimInFront = scrimInFront; mScrimBehind = scrimBehind; @@ -425,7 +421,6 @@ public enum ScrimState { mDozeParameters = dozeParameters; mDockManager = dockManager; mDisplayRequiresBlanking = dozeParameters.getDisplayNeedsBlanking(); - mBlurConfig = blurConfig; } /** Prepare state for transition. */ @@ -536,4 +531,8 @@ public enum ScrimState { public float getNotifBlurRadius() { return mNotifBlurRadius; } + + public void setNotifBlurRadius(float value) { + mNotifBlurRadius = value; + } } diff --git a/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt b/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt index 2f6535b91c8e..41ceda033bdf 100644 --- a/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt @@ -24,6 +24,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow +import com.android.systemui.window.data.repository.WindowRootViewBlurRepository.Companion.isDisableBlurSysPropSet import java.util.concurrent.Executor import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -40,6 +41,17 @@ interface WindowRootViewBlurRepository { /** Is blur supported based on settings toggle and battery power saver mode. */ val isBlurSupported: StateFlow + + companion object { + /** + * Whether the `persist.sysui.disableBlur` is set, this is used to disable blur for tests. + */ + @JvmStatic + fun isDisableBlurSysPropSet() = SystemProperties.getBoolean(DISABLE_BLUR_PROPERTY, false) + + // property that can be used to disable the cross window blur for tests + private const val DISABLE_BLUR_PROPERTY = "persist.sysui.disableBlur" + } } @SysUISingleton @@ -58,7 +70,7 @@ constructor( conflatedCallbackFlow { val sendUpdate = { value: Boolean -> trySendWithFailureLogging( - !isBlurExplicitlyDisabled() && value, + isBlurAllowed() && value, TAG, "unable to send blur enabled/disable state change", ) @@ -70,14 +82,11 @@ constructor( } // stateIn because this is backed by a binder call. .stateIn(scope, SharingStarted.WhileSubscribed(), false) - private fun isBlurExplicitlyDisabled(): Boolean { - return !ActivityManager.isHighEndGfx() || - SystemProperties.getBoolean(DISABLE_BLUR_PROPERTY, false) + private fun isBlurAllowed(): Boolean { + return ActivityManager.isHighEndGfx() && !isDisableBlurSysPropSet() } companion object { const val TAG = "WindowRootViewBlurRepository" - // property that can be used to disable the cross window blur for tests - private const val DISABLE_BLUR_PROPERTY = "persist.sysui.disableBlur" } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java index a5234883ed77..14a1233045bb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java @@ -290,7 +290,8 @@ public class ScrimControllerTest extends SysuiTestCase { mKeyguardInteractor, mKosmos.getTestDispatcher(), mLinearLargeScreenShadeInterpolator, - new BlurConfig(0.0f, 0.0f)); + new BlurConfig(0.0f, 0.0f), + mKosmos::getWindowRootViewBlurInteractor); mScrimController.setScrimVisibleListener(visible -> mScrimVisibility = visible); mScrimController.attachViews(mScrimBehind, mNotificationsScrim, mScrimInFront); mScrimController.setAnimatorListener(mAnimatorListener); @@ -1204,7 +1205,8 @@ public class ScrimControllerTest extends SysuiTestCase { mKeyguardInteractor, mKosmos.getTestDispatcher(), mLinearLargeScreenShadeInterpolator, - new BlurConfig(0.0f, 0.0f)); + new BlurConfig(0.0f, 0.0f), + mKosmos::getWindowRootViewBlurInteractor); mScrimController.setScrimVisibleListener(visible -> mScrimVisibility = visible); mScrimController.attachViews(mScrimBehind, mNotificationsScrim, mScrimInFront); mScrimController.setAnimatorListener(mAnimatorListener); diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt index 446e10671afb..60b371aa8afb 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt @@ -90,6 +90,7 @@ import com.android.systemui.statusbar.policy.domain.interactor.deviceProvisionin import com.android.systemui.statusbar.ui.viewmodel.keyguardStatusBarViewModel import com.android.systemui.util.time.systemClock import com.android.systemui.volume.domain.interactor.volumeDialogInteractor +import com.android.systemui.window.domain.interactor.windowRootViewBlurInteractor /** * Helper for using [Kosmos] from Java. @@ -192,4 +193,5 @@ class KosmosJavaAdapter() { val disableFlagsInteractor by lazy { kosmos.disableFlagsInteractor } val fakeDisableFlagsRepository by lazy { kosmos.fakeDisableFlagsRepository } val mockWindowRootViewProvider by lazy { kosmos.mockWindowRootViewProvider } + val windowRootViewBlurInteractor by lazy { kosmos.windowRootViewBlurInteractor } } -- cgit v1.2.3-59-g8ed1b