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

Commit 83513c8a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use new flag for drawables reuse" into main

parents 06ee0061 10206461
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1328,10 +1328,13 @@ flag {
}

flag {
  name: "media_controls_drawables_reuse"
  name: "media_controls_drawables_reuse_bugfix"
  namespace: "systemui"
  description: "Re-use created media drawables for media controls"
  bug: "358402034"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
+7 −7
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.systemui.media.controls.shared

import android.content.Context
import android.graphics.drawable.Drawable
import com.android.systemui.Flags.mediaControlsDrawablesReuse
import com.android.systemui.Flags.mediaControlsDrawablesReuseBugfix
import com.android.systemui.res.R

object MediaControlDrawables {
@@ -34,21 +34,21 @@ object MediaControlDrawables {
    private var homeDevices: Drawable? = null

    fun getNextIcon(context: Context): Drawable? {
        if (!mediaControlsDrawablesReuse()) {
        if (!mediaControlsDrawablesReuseBugfix()) {
            return context.getDrawable(R.drawable.ic_media_next)
        }
        return nextIcon ?: context.getDrawable(R.drawable.ic_media_next).also { nextIcon = it }
    }

    fun getPrevIcon(context: Context): Drawable? {
        if (!mediaControlsDrawablesReuse()) {
        if (!mediaControlsDrawablesReuseBugfix()) {
            return context.getDrawable(R.drawable.ic_media_prev)
        }
        return prevIcon ?: context.getDrawable(R.drawable.ic_media_prev).also { prevIcon = it }
    }

    fun getLeAudioSharing(context: Context): Drawable? {
        if (!mediaControlsDrawablesReuse()) {
        if (!mediaControlsDrawablesReuseBugfix()) {
            return context.getDrawable(com.android.settingslib.R.drawable.ic_bt_le_audio_sharing)
        }
        return leAudioSharing
@@ -58,7 +58,7 @@ object MediaControlDrawables {
    }

    fun getAntenna(context: Context): Drawable? {
        if (!mediaControlsDrawablesReuse()) {
        if (!mediaControlsDrawablesReuseBugfix()) {
            return context.getDrawable(R.drawable.settings_input_antenna)
        }
        return antenna
@@ -66,7 +66,7 @@ object MediaControlDrawables {
    }

    fun getGroupDevice(context: Context): Drawable? {
        if (!mediaControlsDrawablesReuse()) {
        if (!mediaControlsDrawablesReuseBugfix()) {
            return context.getDrawable(com.android.settingslib.R.drawable.ic_media_group_device)
        }
        return groupDevice
@@ -76,7 +76,7 @@ object MediaControlDrawables {
    }

    fun getHomeDevices(context: Context): Drawable? {
        if (!mediaControlsDrawablesReuse()) {
        if (!mediaControlsDrawablesReuseBugfix()) {
            return context.getDrawable(R.drawable.ic_media_home_devices)
        }
        return homeDevices
+2 −2
Original line number Diff line number Diff line
@@ -1522,7 +1522,7 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() {
    }

    @Test
    @EnableFlags(Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE)
    @EnableFlags(Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX)
    fun postWithPlaybackActions_drawablesReused() {
        whenever(notificationLockscreenUserManager.isCurrentProfile(USER_ID)).thenReturn(true)
        whenever(notificationLockscreenUserManager.isProfileAvailable(USER_ID)).thenReturn(true)
@@ -1555,7 +1555,7 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE)
    @DisableFlags(Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX)
    fun postWithPlaybackActions_drawablesNotReused() {
        whenever(notificationLockscreenUserManager.isCurrentProfile(USER_ID)).thenReturn(true)
        whenever(notificationLockscreenUserManager.isProfileAvailable(USER_ID)).thenReturn(true)
+11 −11
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {

        context.orCreateTestableResources.addOverride(
            R.drawable.ic_media_home_devices,
            OTHER_DEVICE_ICON_STUB
            OTHER_DEVICE_ICON_STUB,
        )
    }

@@ -384,7 +384,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
        deviceCallback.onAboutToConnectDeviceAdded(
            "fakeAddress",
            "AboutToConnectDeviceName",
            mock(Drawable::class.java)
            mock(Drawable::class.java),
        )
        // Run and reset the executors and listeners so we only focus on new events.
        fakeBgExecutor.runAllReady()
@@ -423,7 +423,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE)
    @EnableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX)
    fun onMediaDataLoaded_withRemotePlaybackType_usesNonNullRoutingSessionName_drawableReused() {
        whenever(routingSession.name).thenReturn(REMOTE_DEVICE_NAME)
        whenever(routingSession.selectedRoutes).thenReturn(listOf("selectedRoute", "selectedRoute"))
@@ -437,7 +437,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE)
    @DisableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX)
    fun onMediaDataLoaded_withRemotePlaybackType_usesNonNullRoutingSessionName_drawableNotReused() {
        whenever(routingSession.name).thenReturn(REMOTE_DEVICE_NAME)
        whenever(routingSession.selectedRoutes).thenReturn(listOf("selectedRoute", "selectedRoute"))
@@ -479,7 +479,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {

    @Test
    @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS)
    @EnableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE)
    @EnableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX)
    fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_drawableReused() {
        whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE)
        whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null)
@@ -494,7 +494,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {

    @Test
    @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS)
    @DisableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE)
    @DisableFlags(com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX)
    fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_drawableNotReused() {
        whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE)
        whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null)
@@ -856,7 +856,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
    @DisableFlags(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    @EnableFlags(
        Flags.FLAG_ENABLE_LE_AUDIO_SHARING,
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX,
    )
    fun onBroadcastStarted_currentMediaDeviceDataIsBroadcasting_drawablesReused() {
        val broadcastCallback = setupBroadcastCallback()
@@ -874,7 +874,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
    @Test
    @DisableFlags(
        Flags.FLAG_LEGACY_LE_AUDIO_SHARING,
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX,
    )
    @EnableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
    fun onBroadcastStarted_currentMediaDeviceDataIsBroadcasting_drawablesNotReused() {
@@ -893,7 +893,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
    @Test
    @EnableFlags(
        Flags.FLAG_LEGACY_LE_AUDIO_SHARING,
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX,
    )
    @DisableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
    fun onBroadcastStarted_legacy_currentMediaDeviceDataIsNotBroadcasting_drawableReused() {
@@ -913,7 +913,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
    @EnableFlags(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
    @DisableFlags(
        Flags.FLAG_ENABLE_LE_AUDIO_SHARING,
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE
        com.android.systemui.Flags.FLAG_MEDIA_CONTROLS_DRAWABLES_REUSE_BUGFIX,
    )
    fun onBroadcastStarted_legacy_currentMediaDeviceDataIsNotBroadcasting_drawableNotReused() {
        val broadcastCallback = setupBroadcastCallback()
@@ -984,7 +984,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {

                override fun onBroadcastMetadataChanged(
                    broadcastId: Int,
                    metadata: BluetoothLeBroadcastMetadata
                    metadata: BluetoothLeBroadcastMetadata,
                ) {}
            }