Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03b4106c authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Automerger Merge Worker
Browse files

Merge "[Ongoing Call Chip] Call Chronometer#stop to prevent leaks." into...

Merge "[Ongoing Call Chip] Call Chronometer#stop to prevent leaks." into sc-dev am: 8a57c76a am: 0c86fa28

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15084010

Change-Id: I3a459afc6141c5ae1d669339372620e31004a534
parents b0a2c537 0c86fa28
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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,
+6 −0
Original line number Diff line number Diff line
@@ -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())