[Ongoing Call Chip] Call Chronometer#stop to prevent leaks.
See http://cs/android/frameworks/base/core/java/android/widget/Chronometer.java?l=241&rcl=fb11b7b3ffb2ad771d32a08a2c4238be197f13c5. Test: Manual Bug: 183229367 Fixes: 192243808 Change-Id: I7ea44b985d404184c99ca2a7afbf12e19f2bd5ed
This commit is contained in:
@@ -25,6 +25,7 @@ import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Chronometer
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import com.android.internal.jank.InteractionJankMonitor
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.animation.ActivityLaunchAnimator
|
||||
@@ -122,6 +123,7 @@ class OngoingCallController @Inject constructor(
|
||||
* Should only be called from [CollapsedStatusBarFragment].
|
||||
*/
|
||||
fun setChipView(chipView: View) {
|
||||
tearDownChipView()
|
||||
this.chipView = chipView
|
||||
if (hasOngoingCall()) {
|
||||
updateChip()
|
||||
@@ -165,8 +167,7 @@ class OngoingCallController @Inject constructor(
|
||||
val currentCallNotificationInfo = callNotificationInfo ?: return
|
||||
|
||||
val currentChipView = chipView
|
||||
val timeView =
|
||||
currentChipView?.findViewById<Chronometer>(R.id.ongoing_call_chip_time)
|
||||
val timeView = currentChipView?.getTimeView()
|
||||
val backgroundView =
|
||||
currentChipView?.findViewById<View>(R.id.ongoing_call_chip_background)
|
||||
|
||||
@@ -248,12 +249,19 @@ class OngoingCallController @Inject constructor(
|
||||
|
||||
private fun removeChip() {
|
||||
callNotificationInfo = null
|
||||
tearDownChipView()
|
||||
mListeners.forEach { l -> l.onOngoingCallStateChanged(animate = true) }
|
||||
if (uidObserver != null) {
|
||||
iActivityManager.unregisterUidObserver(uidObserver)
|
||||
}
|
||||
}
|
||||
|
||||
/** Tear down anything related to the chip view to prevent leaks. */
|
||||
@VisibleForTesting
|
||||
fun tearDownChipView() = chipView?.getTimeView()?.stop()
|
||||
|
||||
private fun View.getTimeView(): Chronometer? = this.findViewById(R.id.ongoing_call_chip_time)
|
||||
|
||||
private data class CallNotificationInfo(
|
||||
val key: String,
|
||||
val callStartTime: Long,
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.android.systemui.util.concurrency.FakeExecutor
|
||||
import com.android.systemui.util.mockito.any
|
||||
import com.android.systemui.util.time.FakeSystemClock
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -117,6 +118,11 @@ class OngoingCallControllerTest : SysuiTestCase() {
|
||||
.thenReturn(PROC_STATE_INVISIBLE)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
controller.tearDownChipView()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onEntryUpdated_isOngoingCallNotif_listenerNotified() {
|
||||
notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
|
||||
|
||||
Reference in New Issue
Block a user