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

Commit c0946145 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13572966 from 527b0d11 to 25Q3-release

Change-Id: I5026d20a1d097a34783b98333ca601e840c0413d
parents 8bf4d743 527b0d11
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.app.displaylib

import com.android.app.tracing.TraceUtils.traceAsync
import com.android.internal.annotations.GuardedBy
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
@@ -52,7 +53,6 @@ constructor(
    private val bgApplicationScope: CoroutineScope,
    private val displayRepository: DisplaysWithDecorationsRepository,
) {

    private val mutex = Mutex()
    private var collectorJob: Job? = null
    private val displayDecorationListenersWithDispatcher =
@@ -69,15 +69,18 @@ constructor(
        listener: DisplayDecorationListener,
        dispatcher: CoroutineDispatcher,
    ) {
        var initialDisplayIdsForListener: Set<Int> = emptySet()
        bgApplicationScope.launch {
            mutex.withLock {
                displayDecorationListenersWithDispatcher[listener] = dispatcher
                initialDisplayIdsForListener =
                    displayRepository.displayIdsWithSystemDecorations.value
                startCollectingIfNeeded(initialDisplayIdsForListener)
            }
            // Emit all the existing displays with decorations when registering.
                displayRepository.displayIdsWithSystemDecorations.value.forEach { displayId ->
            initialDisplayIdsForListener.forEach { displayId ->
                withContext(dispatcher) { listener.onDisplayAddSystemDecorations(displayId) }
            }
                startCollectingIfNeeded()
            }
        }
    }

@@ -100,11 +103,11 @@ constructor(
    }

    @GuardedBy("mutex")
    private fun startCollectingIfNeeded() {
    private fun startCollectingIfNeeded(lastDisplaysWithDecorations: Set<Int>) {
        if (collectorJob?.isActive == true) {
            return
        }
        var oldDisplays: Set<Int> = displayRepository.displayIdsWithSystemDecorations.value
        var oldDisplays: Set<Int> = lastDisplaysWithDecorations
        collectorJob =
            bgApplicationScope.launch {
                displayRepository.displayIdsWithSystemDecorations.collect { currentDisplays ->
+6 −0
Original line number Diff line number Diff line
@@ -60,6 +60,12 @@ interface IconThemeController {
        sourceHint: SourceHint,
    ): ThemedBitmap

    /**
     * Creates an adaptive icon representation of the themed bitmap for various surface effects. The
     * controller can return the [originalIcon] for using an un-themed icon for these effects or
     * null to disable any surface effects in which can the static themed icon will be used without
     * any additional effects.
     */
    fun createThemedAdaptiveIcon(
        context: Context,
        originalIcon: AdaptiveIconDrawable,
+2 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ class MonoIconThemeController(
        context: Context,
        originalIcon: AdaptiveIconDrawable,
        info: BitmapInfo?,
    ): AdaptiveIconDrawable? {
    ): AdaptiveIconDrawable {
        val colors = colorProvider(context)
        originalIcon.mutate()
        var monoDrawable = originalIcon.monochrome?.apply { setTint(colors[1]) }
@@ -146,6 +146,7 @@ class MonoIconThemeController(
        }

        return monoDrawable?.let { AdaptiveIconDrawable(ColorDrawable(colors[0]), it) }
            ?: originalIcon
    }

    class ClippedMonoDrawable(base: Drawable?, private val shapePath: Path) :