Merge "[Ongoing Call] Only listen for the swipe gesture while in immersive mode." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d4a80732e6
@@ -201,11 +201,8 @@ class OngoingCallController @Inject constructor(
|
|||||||
statusBarWindowController.ifPresent {
|
statusBarWindowController.ifPresent {
|
||||||
it.setOngoingProcessRequiresStatusBarVisible(true)
|
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) }
|
mListeners.forEach { l -> l.onOngoingCallStateChanged(animate = true) }
|
||||||
} else {
|
} else {
|
||||||
// If we failed to update the chip, don't store the call info. Then [hasOngoingCall]
|
// 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
|
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() {
|
private fun removeChip() {
|
||||||
callNotificationInfo = null
|
callNotificationInfo = null
|
||||||
tearDownChipView()
|
tearDownChipView()
|
||||||
@@ -335,6 +344,7 @@ class OngoingCallController @Inject constructor(
|
|||||||
override fun onFullscreenStateChanged(isFullscreen: Boolean) {
|
override fun onFullscreenStateChanged(isFullscreen: Boolean) {
|
||||||
this@OngoingCallController.isFullscreen = isFullscreen
|
this@OngoingCallController.isFullscreen = isFullscreen
|
||||||
updateChipClickListener()
|
updateChipClickListener()
|
||||||
|
updateGestureListening()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,14 +149,6 @@ class OngoingCallControllerTest : SysuiTestCase() {
|
|||||||
verify(mockStatusBarWindowController).setOngoingProcessRequiresStatusBarVisible(true)
|
verify(mockStatusBarWindowController).setOngoingProcessRequiresStatusBarVisible(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun onEntryUpdated_isOngoingCallNotif_swipeGestureCallbackAdded() {
|
|
||||||
notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
|
|
||||||
|
|
||||||
verify(mockSwipeStatusBarAwayGestureHandler)
|
|
||||||
.addOnGestureDetectedCallback(anyString(), any())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onEntryUpdated_notOngoingCallNotif_listenerNotNotified() {
|
fun onEntryUpdated_notOngoingCallNotif_listenerNotNotified() {
|
||||||
notifCollectionListener.onEntryUpdated(createNotCallNotifEntry())
|
notifCollectionListener.onEntryUpdated(createNotCallNotifEntry())
|
||||||
@@ -258,17 +250,6 @@ class OngoingCallControllerTest : SysuiTestCase() {
|
|||||||
verify(mockStatusBarWindowController).setOngoingProcessRequiresStatusBarVisible(false)
|
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. */
|
/** Regression test for b/188491504. */
|
||||||
@Test
|
@Test
|
||||||
fun onEntryRemoved_removedNotifHasSameKeyAsAddedNotif_listenerNotified() {
|
fun onEntryRemoved_removedNotifHasSameKeyAsAddedNotif_listenerNotified() {
|
||||||
@@ -509,6 +490,70 @@ class OngoingCallControllerTest : SysuiTestCase() {
|
|||||||
assertThat(chipView.hasOnClickListeners()).isTrue()
|
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 createOngoingCallNotifEntry() = createCallNotifEntry(ongoingCallStyle)
|
||||||
|
|
||||||
private fun createScreeningCallNotifEntry() = createCallNotifEntry(screeningCallStyle)
|
private fun createScreeningCallNotifEntry() = createCallNotifEntry(screeningCallStyle)
|
||||||
|
|||||||
Reference in New Issue
Block a user