Merge "[Ongoing Call] Always unregister the UidObserver." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3d1c180320
@@ -218,6 +218,10 @@ class OngoingCallController @Inject constructor(
|
|||||||
isCallAppVisible = isProcessVisibleToUser(
|
isCallAppVisible = isProcessVisibleToUser(
|
||||||
iActivityManager.getUidProcessState(currentCallNotificationInfo.uid, null))
|
iActivityManager.getUidProcessState(currentCallNotificationInfo.uid, null))
|
||||||
|
|
||||||
|
if (uidObserver != null) {
|
||||||
|
iActivityManager.unregisterUidObserver(uidObserver)
|
||||||
|
}
|
||||||
|
|
||||||
uidObserver = object : IUidObserver.Stub() {
|
uidObserver = object : IUidObserver.Stub() {
|
||||||
override fun onUidStateChanged(
|
override fun onUidStateChanged(
|
||||||
uid: Int, procState: Int, procStateSeq: Long, capability: Int) {
|
uid: Int, procState: Int, procStateSeq: Long, capability: Int) {
|
||||||
|
|||||||
@@ -184,6 +184,21 @@ class OngoingCallControllerTest : SysuiTestCase() {
|
|||||||
.isGreaterThan(0)
|
.isGreaterThan(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Regression test for b/194731244. */
|
||||||
|
@Test
|
||||||
|
fun onEntryUpdated_calledManyTimes_uidObserverUnregisteredManyTimes() {
|
||||||
|
val numCalls = 4
|
||||||
|
|
||||||
|
for (i in 0 until numCalls) {
|
||||||
|
// Re-create the notification each time so that it's considered a different object and
|
||||||
|
// observers will get re-registered (and hopefully unregistered).
|
||||||
|
notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
|
||||||
|
}
|
||||||
|
|
||||||
|
// There should be 1 observer still registered, so we should unregister n-1 times.
|
||||||
|
verify(mockIActivityManager, times(numCalls - 1)).unregisterUidObserver(any())
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a call notification is never added before #onEntryRemoved is called, then the listener
|
* If a call notification is never added before #onEntryRemoved is called, then the listener
|
||||||
* should never be notified.
|
* should never be notified.
|
||||||
|
|||||||
Reference in New Issue
Block a user