Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt +14 −4 Original line number Diff line number Diff line Loading @@ -201,11 +201,8 @@ class OngoingCallController @Inject constructor( statusBarWindowController.ifPresent { it.setOngoingProcessRequiresStatusBarVisible(true) } // TODO(b/195839150): Only listen for the gesture when in immersive mode. swipeStatusBarAwayGestureHandler.ifPresent { it.addOnGestureDetectedCallback(TAG, this::onSwipeAwayGestureDetected) } } updateGestureListening() mListeners.forEach { l -> l.onOngoingCallStateChanged(animate = true) } } else { // If we failed to update the chip, don't store the call info. Then [hasOngoingCall] Loading Loading @@ -293,6 +290,18 @@ class OngoingCallController @Inject constructor( return procState <= ActivityManager.PROCESS_STATE_TOP } private fun updateGestureListening() { if (callNotificationInfo == null || callNotificationInfo?.statusBarSwipedAway == true || !isFullscreen) { swipeStatusBarAwayGestureHandler.ifPresent { it.removeOnGestureDetectedCallback(TAG) } } else { swipeStatusBarAwayGestureHandler.ifPresent { it.addOnGestureDetectedCallback(TAG, this::onSwipeAwayGestureDetected) } } } private fun removeChip() { callNotificationInfo = null tearDownChipView() Loading Loading @@ -335,6 +344,7 @@ class OngoingCallController @Inject constructor( override fun onFullscreenStateChanged(isFullscreen: Boolean) { this@OngoingCallController.isFullscreen = isFullscreen updateChipClickListener() updateGestureListening() } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt +64 −19 Original line number Diff line number Diff line Loading @@ -149,14 +149,6 @@ class OngoingCallControllerTest : SysuiTestCase() { verify(mockStatusBarWindowController).setOngoingProcessRequiresStatusBarVisible(true) } @Test fun onEntryUpdated_isOngoingCallNotif_swipeGestureCallbackAdded() { notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) verify(mockSwipeStatusBarAwayGestureHandler) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun onEntryUpdated_notOngoingCallNotif_listenerNotNotified() { notifCollectionListener.onEntryUpdated(createNotCallNotifEntry()) Loading Loading @@ -258,17 +250,6 @@ class OngoingCallControllerTest : SysuiTestCase() { verify(mockStatusBarWindowController).setOngoingProcessRequiresStatusBarVisible(false) } @Test fun onEntryUpdated_callNotifAddedThenRemoved_swipeGestureCallbackRemoved() { val ongoingCallNotifEntry = createOngoingCallNotifEntry() notifCollectionListener.onEntryAdded(ongoingCallNotifEntry) notifCollectionListener.onEntryRemoved(ongoingCallNotifEntry, REASON_USER_STOPPED) verify(mockSwipeStatusBarAwayGestureHandler) .removeOnGestureDetectedCallback(anyString()) } /** Regression test for b/188491504. */ @Test fun onEntryRemoved_removedNotifHasSameKeyAsAddedNotif_listenerNotified() { Loading Loading @@ -509,6 +490,70 @@ class OngoingCallControllerTest : SysuiTestCase() { assertThat(chipView.hasOnClickListeners()).isTrue() } // Swipe gesture tests @Test fun callStartedInImmersiveMode_swipeGestureCallbackAdded() { getStateListener().onFullscreenStateChanged(true) notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) verify(mockSwipeStatusBarAwayGestureHandler) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun callStartedNotInImmersiveMode_swipeGestureCallbackNotAdded() { getStateListener().onFullscreenStateChanged(false) notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) verify(mockSwipeStatusBarAwayGestureHandler, never()) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun transitionToImmersiveMode_swipeGestureCallbackAdded() { notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) getStateListener().onFullscreenStateChanged(true) verify(mockSwipeStatusBarAwayGestureHandler) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun transitionOutOfImmersiveMode_swipeGestureCallbackRemoved() { getStateListener().onFullscreenStateChanged(true) notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) reset(mockSwipeStatusBarAwayGestureHandler) getStateListener().onFullscreenStateChanged(false) verify(mockSwipeStatusBarAwayGestureHandler) .removeOnGestureDetectedCallback(anyString()) } @Test fun callEndedWhileInImmersiveMode_swipeGestureCallbackRemoved() { getStateListener().onFullscreenStateChanged(true) val ongoingCallNotifEntry = createOngoingCallNotifEntry() notifCollectionListener.onEntryAdded(ongoingCallNotifEntry) reset(mockSwipeStatusBarAwayGestureHandler) notifCollectionListener.onEntryRemoved(ongoingCallNotifEntry, REASON_USER_STOPPED) verify(mockSwipeStatusBarAwayGestureHandler) .removeOnGestureDetectedCallback(anyString()) } // TODO(b/195839150): Add test // swipeGesturedTriggeredPreviously_entersImmersiveModeAgain_callbackNotAdded(). That's // difficult to add now because we have no way to trigger [SwipeStatusBarAwayGestureHandler]'s // callbacks in test. // END swipe gesture tests private fun createOngoingCallNotifEntry() = createCallNotifEntry(ongoingCallStyle) private fun createScreeningCallNotifEntry() = createCallNotifEntry(screeningCallStyle) Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt +14 −4 Original line number Diff line number Diff line Loading @@ -201,11 +201,8 @@ class OngoingCallController @Inject constructor( statusBarWindowController.ifPresent { it.setOngoingProcessRequiresStatusBarVisible(true) } // TODO(b/195839150): Only listen for the gesture when in immersive mode. swipeStatusBarAwayGestureHandler.ifPresent { it.addOnGestureDetectedCallback(TAG, this::onSwipeAwayGestureDetected) } } updateGestureListening() mListeners.forEach { l -> l.onOngoingCallStateChanged(animate = true) } } else { // If we failed to update the chip, don't store the call info. Then [hasOngoingCall] Loading Loading @@ -293,6 +290,18 @@ class OngoingCallController @Inject constructor( return procState <= ActivityManager.PROCESS_STATE_TOP } private fun updateGestureListening() { if (callNotificationInfo == null || callNotificationInfo?.statusBarSwipedAway == true || !isFullscreen) { swipeStatusBarAwayGestureHandler.ifPresent { it.removeOnGestureDetectedCallback(TAG) } } else { swipeStatusBarAwayGestureHandler.ifPresent { it.addOnGestureDetectedCallback(TAG, this::onSwipeAwayGestureDetected) } } } private fun removeChip() { callNotificationInfo = null tearDownChipView() Loading Loading @@ -335,6 +344,7 @@ class OngoingCallController @Inject constructor( override fun onFullscreenStateChanged(isFullscreen: Boolean) { this@OngoingCallController.isFullscreen = isFullscreen updateChipClickListener() updateGestureListening() } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt +64 −19 Original line number Diff line number Diff line Loading @@ -149,14 +149,6 @@ class OngoingCallControllerTest : SysuiTestCase() { verify(mockStatusBarWindowController).setOngoingProcessRequiresStatusBarVisible(true) } @Test fun onEntryUpdated_isOngoingCallNotif_swipeGestureCallbackAdded() { notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) verify(mockSwipeStatusBarAwayGestureHandler) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun onEntryUpdated_notOngoingCallNotif_listenerNotNotified() { notifCollectionListener.onEntryUpdated(createNotCallNotifEntry()) Loading Loading @@ -258,17 +250,6 @@ class OngoingCallControllerTest : SysuiTestCase() { verify(mockStatusBarWindowController).setOngoingProcessRequiresStatusBarVisible(false) } @Test fun onEntryUpdated_callNotifAddedThenRemoved_swipeGestureCallbackRemoved() { val ongoingCallNotifEntry = createOngoingCallNotifEntry() notifCollectionListener.onEntryAdded(ongoingCallNotifEntry) notifCollectionListener.onEntryRemoved(ongoingCallNotifEntry, REASON_USER_STOPPED) verify(mockSwipeStatusBarAwayGestureHandler) .removeOnGestureDetectedCallback(anyString()) } /** Regression test for b/188491504. */ @Test fun onEntryRemoved_removedNotifHasSameKeyAsAddedNotif_listenerNotified() { Loading Loading @@ -509,6 +490,70 @@ class OngoingCallControllerTest : SysuiTestCase() { assertThat(chipView.hasOnClickListeners()).isTrue() } // Swipe gesture tests @Test fun callStartedInImmersiveMode_swipeGestureCallbackAdded() { getStateListener().onFullscreenStateChanged(true) notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) verify(mockSwipeStatusBarAwayGestureHandler) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun callStartedNotInImmersiveMode_swipeGestureCallbackNotAdded() { getStateListener().onFullscreenStateChanged(false) notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) verify(mockSwipeStatusBarAwayGestureHandler, never()) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun transitionToImmersiveMode_swipeGestureCallbackAdded() { notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) getStateListener().onFullscreenStateChanged(true) verify(mockSwipeStatusBarAwayGestureHandler) .addOnGestureDetectedCallback(anyString(), any()) } @Test fun transitionOutOfImmersiveMode_swipeGestureCallbackRemoved() { getStateListener().onFullscreenStateChanged(true) notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry()) reset(mockSwipeStatusBarAwayGestureHandler) getStateListener().onFullscreenStateChanged(false) verify(mockSwipeStatusBarAwayGestureHandler) .removeOnGestureDetectedCallback(anyString()) } @Test fun callEndedWhileInImmersiveMode_swipeGestureCallbackRemoved() { getStateListener().onFullscreenStateChanged(true) val ongoingCallNotifEntry = createOngoingCallNotifEntry() notifCollectionListener.onEntryAdded(ongoingCallNotifEntry) reset(mockSwipeStatusBarAwayGestureHandler) notifCollectionListener.onEntryRemoved(ongoingCallNotifEntry, REASON_USER_STOPPED) verify(mockSwipeStatusBarAwayGestureHandler) .removeOnGestureDetectedCallback(anyString()) } // TODO(b/195839150): Add test // swipeGesturedTriggeredPreviously_entersImmersiveModeAgain_callbackNotAdded(). That's // difficult to add now because we have no way to trigger [SwipeStatusBarAwayGestureHandler]'s // callbacks in test. // END swipe gesture tests private fun createOngoingCallNotifEntry() = createCallNotifEntry(ongoingCallStyle) private fun createScreeningCallNotifEntry() = createCallNotifEntry(screeningCallStyle) Loading