Loading packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +6 −0 Original line number Diff line number Diff line Loading @@ -271,6 +271,12 @@ constructor( } companion object { /** * The user activity timeout which should be used when the communal hub is opened. A value * of -1 means that the user's chosen screen timeout will be used instead. */ const val AWAKE_INTERVAL_MS = -1 /** * Calculates the content size dynamically based on the total number of contents of that * type. Loading packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowControllerImpl.java +30 −7 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.Dumpable; import com.android.systemui.biometrics.AuthController; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.communal.domain.interactor.CommunalInteractor; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; Loading Loading @@ -118,6 +119,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW private final Lazy<SelectedUserInteractor> mUserInteractor; private final Lazy<ShadeInteractor> mShadeInteractorLazy; private final SceneContainerFlags mSceneContainerFlags; private final Lazy<CommunalInteractor> mCommunalInteractor; private ViewGroup mWindowRootView; private LayoutParams mLp; private boolean mHasTopUi; Loading Loading @@ -165,7 +167,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW ShadeWindowLogger logger, Lazy<SelectedUserInteractor> userInteractor, UserTracker userTracker, SceneContainerFlags sceneContainerFlags) { SceneContainerFlags sceneContainerFlags, Lazy<CommunalInteractor> communalInteractor) { mContext = context; mWindowRootViewComponentFactory = windowRootViewComponentFactory; mWindowManager = windowManager; Loading @@ -184,6 +187,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW mAuthController = authController; mUserInteractor = userInteractor; mSceneContainerFlags = sceneContainerFlags; mCommunalInteractor = communalInteractor; mLastKeyguardRotationAllowed = mKeyguardStateController.isKeyguardScreenRotationAllowed(); mLockScreenDisplayTimeout = context.getResources() .getInteger(R.integer.config_lockScreenDisplayTimeout); Loading Loading @@ -325,6 +329,11 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW mShadeInteractorLazy.get().isQsExpanded(), this::onQsExpansionChanged ); collectFlow( mWindowRootView, mCommunalInteractor.get().isCommunalShowing(), this::onCommunalShowingChanged ); } @Override Loading Loading @@ -501,15 +510,22 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW } private void applyUserActivityTimeout(NotificationShadeWindowState state) { if (state.isKeyguardShowingAndNotOccluded() final Boolean communalShowing = state.isCommunalShowingAndNotOccluded(); final Boolean keyguardShowing = state.isKeyguardShowingAndNotOccluded(); long timeout = -1; if ((communalShowing || keyguardShowing) && state.statusBarState == StatusBarState.KEYGUARD && !state.qsExpanded) { mLpChanged.userActivityTimeout = state.bouncerShowing ? KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS : mLockScreenDisplayTimeout; } else { mLpChanged.userActivityTimeout = -1; if (state.bouncerShowing) { timeout = KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS; } else if (communalShowing) { timeout = CommunalInteractor.AWAKE_INTERVAL_MS; } else if (keyguardShowing) { timeout = mLockScreenDisplayTimeout; } } mLpChanged.userActivityTimeout = timeout; } private void applyInputFeatures(NotificationShadeWindowState state) { if (state.isKeyguardShowingAndNotOccluded() Loading Loading @@ -607,7 +623,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW state.forcePluginOpen, state.dozing, state.scrimsVisibility, state.backgroundBlurRadius state.backgroundBlurRadius, state.communalShowing ); } Loading Loading @@ -731,6 +748,12 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW apply(mCurrentState); } @VisibleForTesting void onCommunalShowingChanged(Boolean showing) { mCurrentState.communalShowing = showing; apply(mCurrentState); } @Override public void setForceUserActivity(boolean forceUserActivity) { mCurrentState.forceUserActivity = forceUserActivity; Loading packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowState.kt +11 −2 Original line number Diff line number Diff line Loading @@ -58,12 +58,17 @@ class NotificationShadeWindowState( @JvmField var dreaming: Boolean = false, @JvmField var scrimsVisibility: Int = 0, @JvmField var backgroundBlurRadius: Int = 0, @JvmField var communalShowing: Boolean = false, ) { fun isKeyguardShowingAndNotOccluded(): Boolean { return keyguardShowing && !keyguardOccluded } fun isCommunalShowingAndNotOccluded(): Boolean { return communalShowing && !keyguardOccluded } /** List of [String] to be used as a [Row] with [DumpsysTableLogger]. */ val asStringList: List<String> by lazy { listOf( Loading Loading @@ -93,7 +98,8 @@ class NotificationShadeWindowState( forcePluginOpen.toString(), dozing.toString(), scrimsVisibility.toString(), backgroundBlurRadius.toString() backgroundBlurRadius.toString(), communalShowing.toString(), ) } Loading Loading @@ -134,6 +140,7 @@ class NotificationShadeWindowState( dozing: Boolean, scrimsVisibility: Int, backgroundBlurRadius: Int, communalShowing: Boolean, ) { buffer.advance().apply { this.keyguardShowing = keyguardShowing Loading Loading @@ -165,6 +172,7 @@ class NotificationShadeWindowState( this.dozing = dozing this.scrimsVisibility = scrimsVisibility this.backgroundBlurRadius = backgroundBlurRadius this.communalShowing = communalShowing } } Loading Loading @@ -209,7 +217,8 @@ class NotificationShadeWindowState( "forcePluginOpen", "dozing", "scrimsVisibility", "backgroundBlurRadius" "backgroundBlurRadius", "communalShowing" ) } } packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ import com.android.systemui.flags.Flags; import com.android.systemui.flags.SystemPropertiesHelper; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.log.SessionTracker; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.scene.FakeWindowRootViewComponent; Loading Loading @@ -150,6 +151,7 @@ import kotlinx.coroutines.test.TestScope; @TestableLooper.RunWithLooper @SmallTest public class KeyguardViewMediatorTest extends SysuiTestCase { private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this); private KeyguardViewMediator mViewMediator; private final TestScope mTestScope = TestScopeProvider.getTestScope(); Loading Loading @@ -265,7 +267,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mShadeWindowLogger, () -> mSelectedUserInteractor, mUserTracker, mSceneContainerFlags); mSceneContainerFlags, mKosmos::getCommunalInteractor); mFeatureFlags = new FakeFeatureFlags(); mFeatureFlags.set(Flags.KEYGUARD_WM_STATE_REFACTOR, false); mSetFlagsRule.enableFlags(FLAG_REFACTOR_GET_CURRENT_USER); Loading packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -301,7 +301,8 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { mShadeWindowLogger, () -> mSelectedUserInteractor, mUserTracker, mSceneContainerFlags) { mSceneContainerFlags, () -> communalInteractor) { @Override protected boolean isDebuggable() { return false; Loading Loading @@ -448,6 +449,24 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) != 0).isTrue(); } @Test public void setCommunalShowing_userTimeout() { setKeyguardShowing(); clearInvocations(mWindowManager); mNotificationShadeWindowController.onCommunalShowingChanged(true); verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); assertThat(mLayoutParameters.getValue().userActivityTimeout) .isEqualTo(CommunalInteractor.AWAKE_INTERVAL_MS); clearInvocations(mWindowManager); // Bouncer showing over communal overrides communal value mNotificationShadeWindowController.setBouncerShowing(true); verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); assertThat(mLayoutParameters.getValue().userActivityTimeout) .isEqualTo(KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS); } @Test public void setKeyguardShowing_notFocusable_byDefault() { mNotificationShadeWindowController.setKeyguardShowing(false); Loading Loading
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +6 −0 Original line number Diff line number Diff line Loading @@ -271,6 +271,12 @@ constructor( } companion object { /** * The user activity timeout which should be used when the communal hub is opened. A value * of -1 means that the user's chosen screen timeout will be used instead. */ const val AWAKE_INTERVAL_MS = -1 /** * Calculates the content size dynamically based on the total number of contents of that * type. Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowControllerImpl.java +30 −7 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.Dumpable; import com.android.systemui.biometrics.AuthController; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.communal.domain.interactor.CommunalInteractor; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; Loading Loading @@ -118,6 +119,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW private final Lazy<SelectedUserInteractor> mUserInteractor; private final Lazy<ShadeInteractor> mShadeInteractorLazy; private final SceneContainerFlags mSceneContainerFlags; private final Lazy<CommunalInteractor> mCommunalInteractor; private ViewGroup mWindowRootView; private LayoutParams mLp; private boolean mHasTopUi; Loading Loading @@ -165,7 +167,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW ShadeWindowLogger logger, Lazy<SelectedUserInteractor> userInteractor, UserTracker userTracker, SceneContainerFlags sceneContainerFlags) { SceneContainerFlags sceneContainerFlags, Lazy<CommunalInteractor> communalInteractor) { mContext = context; mWindowRootViewComponentFactory = windowRootViewComponentFactory; mWindowManager = windowManager; Loading @@ -184,6 +187,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW mAuthController = authController; mUserInteractor = userInteractor; mSceneContainerFlags = sceneContainerFlags; mCommunalInteractor = communalInteractor; mLastKeyguardRotationAllowed = mKeyguardStateController.isKeyguardScreenRotationAllowed(); mLockScreenDisplayTimeout = context.getResources() .getInteger(R.integer.config_lockScreenDisplayTimeout); Loading Loading @@ -325,6 +329,11 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW mShadeInteractorLazy.get().isQsExpanded(), this::onQsExpansionChanged ); collectFlow( mWindowRootView, mCommunalInteractor.get().isCommunalShowing(), this::onCommunalShowingChanged ); } @Override Loading Loading @@ -501,15 +510,22 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW } private void applyUserActivityTimeout(NotificationShadeWindowState state) { if (state.isKeyguardShowingAndNotOccluded() final Boolean communalShowing = state.isCommunalShowingAndNotOccluded(); final Boolean keyguardShowing = state.isKeyguardShowingAndNotOccluded(); long timeout = -1; if ((communalShowing || keyguardShowing) && state.statusBarState == StatusBarState.KEYGUARD && !state.qsExpanded) { mLpChanged.userActivityTimeout = state.bouncerShowing ? KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS : mLockScreenDisplayTimeout; } else { mLpChanged.userActivityTimeout = -1; if (state.bouncerShowing) { timeout = KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS; } else if (communalShowing) { timeout = CommunalInteractor.AWAKE_INTERVAL_MS; } else if (keyguardShowing) { timeout = mLockScreenDisplayTimeout; } } mLpChanged.userActivityTimeout = timeout; } private void applyInputFeatures(NotificationShadeWindowState state) { if (state.isKeyguardShowingAndNotOccluded() Loading Loading @@ -607,7 +623,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW state.forcePluginOpen, state.dozing, state.scrimsVisibility, state.backgroundBlurRadius state.backgroundBlurRadius, state.communalShowing ); } Loading Loading @@ -731,6 +748,12 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW apply(mCurrentState); } @VisibleForTesting void onCommunalShowingChanged(Boolean showing) { mCurrentState.communalShowing = showing; apply(mCurrentState); } @Override public void setForceUserActivity(boolean forceUserActivity) { mCurrentState.forceUserActivity = forceUserActivity; Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowState.kt +11 −2 Original line number Diff line number Diff line Loading @@ -58,12 +58,17 @@ class NotificationShadeWindowState( @JvmField var dreaming: Boolean = false, @JvmField var scrimsVisibility: Int = 0, @JvmField var backgroundBlurRadius: Int = 0, @JvmField var communalShowing: Boolean = false, ) { fun isKeyguardShowingAndNotOccluded(): Boolean { return keyguardShowing && !keyguardOccluded } fun isCommunalShowingAndNotOccluded(): Boolean { return communalShowing && !keyguardOccluded } /** List of [String] to be used as a [Row] with [DumpsysTableLogger]. */ val asStringList: List<String> by lazy { listOf( Loading Loading @@ -93,7 +98,8 @@ class NotificationShadeWindowState( forcePluginOpen.toString(), dozing.toString(), scrimsVisibility.toString(), backgroundBlurRadius.toString() backgroundBlurRadius.toString(), communalShowing.toString(), ) } Loading Loading @@ -134,6 +140,7 @@ class NotificationShadeWindowState( dozing: Boolean, scrimsVisibility: Int, backgroundBlurRadius: Int, communalShowing: Boolean, ) { buffer.advance().apply { this.keyguardShowing = keyguardShowing Loading Loading @@ -165,6 +172,7 @@ class NotificationShadeWindowState( this.dozing = dozing this.scrimsVisibility = scrimsVisibility this.backgroundBlurRadius = backgroundBlurRadius this.communalShowing = communalShowing } } Loading Loading @@ -209,7 +217,8 @@ class NotificationShadeWindowState( "forcePluginOpen", "dozing", "scrimsVisibility", "backgroundBlurRadius" "backgroundBlurRadius", "communalShowing" ) } }
packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ import com.android.systemui.flags.Flags; import com.android.systemui.flags.SystemPropertiesHelper; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.log.SessionTracker; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.scene.FakeWindowRootViewComponent; Loading Loading @@ -150,6 +151,7 @@ import kotlinx.coroutines.test.TestScope; @TestableLooper.RunWithLooper @SmallTest public class KeyguardViewMediatorTest extends SysuiTestCase { private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this); private KeyguardViewMediator mViewMediator; private final TestScope mTestScope = TestScopeProvider.getTestScope(); Loading Loading @@ -265,7 +267,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mShadeWindowLogger, () -> mSelectedUserInteractor, mUserTracker, mSceneContainerFlags); mSceneContainerFlags, mKosmos::getCommunalInteractor); mFeatureFlags = new FakeFeatureFlags(); mFeatureFlags.set(Flags.KEYGUARD_WM_STATE_REFACTOR, false); mSetFlagsRule.enableFlags(FLAG_REFACTOR_GET_CURRENT_USER); Loading
packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -301,7 +301,8 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { mShadeWindowLogger, () -> mSelectedUserInteractor, mUserTracker, mSceneContainerFlags) { mSceneContainerFlags, () -> communalInteractor) { @Override protected boolean isDebuggable() { return false; Loading Loading @@ -448,6 +449,24 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) != 0).isTrue(); } @Test public void setCommunalShowing_userTimeout() { setKeyguardShowing(); clearInvocations(mWindowManager); mNotificationShadeWindowController.onCommunalShowingChanged(true); verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); assertThat(mLayoutParameters.getValue().userActivityTimeout) .isEqualTo(CommunalInteractor.AWAKE_INTERVAL_MS); clearInvocations(mWindowManager); // Bouncer showing over communal overrides communal value mNotificationShadeWindowController.setBouncerShowing(true); verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); assertThat(mLayoutParameters.getValue().userActivityTimeout) .isEqualTo(KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS); } @Test public void setKeyguardShowing_notFocusable_byDefault() { mNotificationShadeWindowController.setKeyguardShowing(false); Loading