Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -204,14 +204,14 @@ class CommunalInteractorTest : SysuiTestCase() { } @Test fun isCommunalAvailable_whenDreaming_true() = fun isCommunalAvailable_whenKeyguardShowing_true() = testScope.runTest { val isAvailable by collectLastValue(underTest.isCommunalAvailable) assertThat(isAvailable).isFalse() keyguardRepository.setIsEncryptedOrLockdown(false) userRepository.setSelectedUserInfo(mainUser) keyguardRepository.setDreaming(true) keyguardRepository.setKeyguardShowing(true) assertThat(isAvailable).isTrue() } Loading packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +1 −2 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.UserTracker import com.android.systemui.smartspace.data.repository.SmartspaceRepository import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.BooleanFlowOperators.not import com.android.systemui.util.kotlin.emitOnStart import javax.inject.Inject Loading Loading @@ -130,7 +129,7 @@ constructor( allOf( communalSettingsInteractor.isCommunalEnabled, not(keyguardInteractor.isEncryptedOrLockdown), anyOf(keyguardInteractor.isKeyguardShowing, keyguardInteractor.isDreaming) keyguardInteractor.isKeyguardShowing ) .distinctUntilChanged() .onEach { available -> Loading packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt +2 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ constructor( uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_CANCEL) } val isIdleOnCommunal: StateFlow<Boolean> = communalInteractor.isIdleOnCommunal /** Launch the widget picker activity using the given {@link ActivityResultLauncher}. */ suspend fun onOpenWidgetPicker( resources: Resources, Loading packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt +20 −4 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.Logger import com.android.systemui.log.dagger.CommunalLog import javax.inject.Inject import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch /** An Activity for editing the widgets that appear in hub mode. */ Loading @@ -69,6 +70,8 @@ constructor( private var shouldOpenWidgetPickerOnStart = false private var lockOnDestroy = false private val addWidgetActivityLauncher: ActivityResultLauncher<Intent> = registerForActivityResult(StartActivityForResult()) { result -> when (result.resultCode) { Loading Loading @@ -149,15 +152,18 @@ constructor( } private fun onEditDone() { try { lifecycleScope.launch { communalViewModel.changeScene( CommunalScenes.Communal, CommunalTransitionKeys.SimpleFade ) checkNotNull(windowManagerService).lockNow(/* options */ null) // Wait for the current scene to be idle on communal. communalViewModel.isIdleOnCommunal.first { it } // Then finish the activity (this helps to avoid a flash of lockscreen when locking // in onDestroy()). lockOnDestroy = true finish() } catch (e: RemoteException) { Log.e(TAG, "Couldn't lock the device as WindowManager is dead.") } } Loading Loading @@ -190,5 +196,15 @@ constructor( override fun onDestroy() { super.onDestroy() communalViewModel.setEditModeOpen(false) if (lockOnDestroy) lockNow() } private fun lockNow() { try { checkNotNull(windowManagerService).lockNow(/* options */ null) } catch (e: RemoteException) { Log.e(TAG, "Couldn't lock the device as WindowManager is dead.") } } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -204,14 +204,14 @@ class CommunalInteractorTest : SysuiTestCase() { } @Test fun isCommunalAvailable_whenDreaming_true() = fun isCommunalAvailable_whenKeyguardShowing_true() = testScope.runTest { val isAvailable by collectLastValue(underTest.isCommunalAvailable) assertThat(isAvailable).isFalse() keyguardRepository.setIsEncryptedOrLockdown(false) userRepository.setSelectedUserInfo(mainUser) keyguardRepository.setDreaming(true) keyguardRepository.setKeyguardShowing(true) assertThat(isAvailable).isTrue() } Loading
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +1 −2 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.UserTracker import com.android.systemui.smartspace.data.repository.SmartspaceRepository import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.BooleanFlowOperators.not import com.android.systemui.util.kotlin.emitOnStart import javax.inject.Inject Loading Loading @@ -130,7 +129,7 @@ constructor( allOf( communalSettingsInteractor.isCommunalEnabled, not(keyguardInteractor.isEncryptedOrLockdown), anyOf(keyguardInteractor.isKeyguardShowing, keyguardInteractor.isDreaming) keyguardInteractor.isKeyguardShowing ) .distinctUntilChanged() .onEach { available -> Loading
packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt +2 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ constructor( uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_CANCEL) } val isIdleOnCommunal: StateFlow<Boolean> = communalInteractor.isIdleOnCommunal /** Launch the widget picker activity using the given {@link ActivityResultLauncher}. */ suspend fun onOpenWidgetPicker( resources: Resources, Loading
packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt +20 −4 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.Logger import com.android.systemui.log.dagger.CommunalLog import javax.inject.Inject import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch /** An Activity for editing the widgets that appear in hub mode. */ Loading @@ -69,6 +70,8 @@ constructor( private var shouldOpenWidgetPickerOnStart = false private var lockOnDestroy = false private val addWidgetActivityLauncher: ActivityResultLauncher<Intent> = registerForActivityResult(StartActivityForResult()) { result -> when (result.resultCode) { Loading Loading @@ -149,15 +152,18 @@ constructor( } private fun onEditDone() { try { lifecycleScope.launch { communalViewModel.changeScene( CommunalScenes.Communal, CommunalTransitionKeys.SimpleFade ) checkNotNull(windowManagerService).lockNow(/* options */ null) // Wait for the current scene to be idle on communal. communalViewModel.isIdleOnCommunal.first { it } // Then finish the activity (this helps to avoid a flash of lockscreen when locking // in onDestroy()). lockOnDestroy = true finish() } catch (e: RemoteException) { Log.e(TAG, "Couldn't lock the device as WindowManager is dead.") } } Loading Loading @@ -190,5 +196,15 @@ constructor( override fun onDestroy() { super.onDestroy() communalViewModel.setEditModeOpen(false) if (lockOnDestroy) lockNow() } private fun lockNow() { try { checkNotNull(windowManagerService).lockNow(/* options */ null) } catch (e: RemoteException) { Log.e(TAG, "Couldn't lock the device as WindowManager is dead.") } } }