[Ongoing Call] Only listen for the swipe gesture while in immersive
mode. Test: manual: Do a swipe up on the status bar while not in immersive, then open a landscape immersive app and verify the status bar still shows (i.e. it wasn't dismissed by the previous swipe) Test: new unit tests Bug: 195839150 Change-Id: I1913c25c29b635979b0cb89d815b2d2c6cc40530
This commit is contained in:
@@ -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]
|
||||
@@ -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()
|
||||
@@ -335,6 +344,7 @@ class OngoingCallController @Inject constructor(
|
||||
override fun onFullscreenStateChanged(isFullscreen: Boolean) {
|
||||
this@OngoingCallController.isFullscreen = isFullscreen
|
||||
updateChipClickListener()
|
||||
updateGestureListening()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
@@ -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() {
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user