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

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

Snap for 13374957 from 6d08892b to 25Q3-release

Change-Id: I22d25463568049e36a41f005fdb0762827c07e94
parents d0bebd3d 6d08892b
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -86,11 +86,28 @@ interface DisplayRepository {
    /**
     * Given a display ID int, return the corresponding Display object, or null if none exist.
     *
     * This method is guaranteed to not result in any binder call.
     * This method will not result in a binder call in most cases. The only exception is if there is
     * an existing binder call ongoing to get the [Display] instance already. In that case, this
     * will wait for the end of the binder call.
     */
    fun getDisplay(displayId: Int): Display? =
    fun getDisplay(displayId: Int): Display?

    /**
     * As [getDisplay], but it's always guaranteed to not block on any binder call.
     *
     * This might return null if the display id was not mapped to a [Display] object yet.
     */
    fun getCachedDisplay(displayId: Int): Display? =
        displays.value.firstOrNull { it.displayId == displayId }

    /**
     * Returns whether the given displayId is in the set of enabled displays.
     *
     * This is guaranteed to not cause a binder call. Use this instead of [getDisplay] (see its docs
     * for why)
     */
    fun containsDisplay(displayId: Int): Boolean = displayIds.value.contains(displayId)

    /** Represents a connected display that has not been enabled yet. */
    interface PendingDisplay {
        /** Id of the pending display. */
@@ -375,6 +392,24 @@ constructor(
            .map { defaultDisplay.state == Display.STATE_OFF }
            .distinctUntilChanged()

    override fun getDisplay(displayId: Int): Display? {
        val cachedDisplay = getCachedDisplay(displayId)
        if (cachedDisplay != null) return cachedDisplay
        // cachedDisplay could be null for 2 reasons:
        // 1. the displayId is being mapped to a display in the background, but the binder call is
        // not done
        // 2. the display is not there
        // In case of option one, let's get it synchronously from display manager to make sure for
        // this to be consistent.
        return if (displayIds.value.contains(displayId)) {
            traceSection("$TAG#getDisplayFallbackToDisplayManager") {
                getDisplayFromDisplayManager(displayId)
            }
        } else {
            null
        }
    }

    private fun <T> Flow<T>.debugLog(flowName: String): Flow<T> {
        return if (DEBUG) {
            traceEach(flowName, logcat = true, traceEmissionCount = true)
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ constructor(
    }

    override fun get(displayId: Int): T? {
        if (displayRepository.getDisplay(displayId) == null) {
        if (!displayRepository.containsDisplay(displayId)) {
            Log.e(TAG, "<$debugName: Display with id $displayId doesn't exist.")
            return null
        }
+0 −3
Original line number Diff line number Diff line
@@ -27,7 +27,4 @@
    <string name="calendar_component_name" translatable="false"></string>
    <string name="clock_component_name" translatable="false"></string>

    <!-- Configures whether to enable forced theme icon, disabled by default -->
    <bool name="enable_forced_themed_icon">false</bool>

</resources>
 No newline at end of file
+0 −12
Original line number Diff line number Diff line
@@ -103,8 +103,6 @@ public class BaseIconFactory implements AutoCloseable {

    private static int PLACEHOLDER_BACKGROUND_COLOR = Color.rgb(245, 245, 245);

    private final boolean mShouldForceThemeIcon;

    protected BaseIconFactory(Context context, int fullResIconDpi, int iconBitmapSize,
            boolean unused) {
        this(context, fullResIconDpi, iconBitmapSize);
@@ -120,9 +118,6 @@ public class BaseIconFactory implements AutoCloseable {
        mCanvas = new Canvas();
        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(DITHER_FLAG, FILTER_BITMAP_FLAG));
        clear();

        mShouldForceThemeIcon = mContext.getResources().getBoolean(
                R.bool.enable_forced_themed_icon);
    }

    protected void clear() {
@@ -272,13 +267,6 @@ public class BaseIconFactory implements AutoCloseable {
        return op;
    }

    /**
     * @return True if forced theme icon is enabled
     */
    public boolean shouldForceThemeIcon() {
        return mShouldForceThemeIcon;
    }

    @NonNull
    protected UserIconInfo getUserInfo(@NonNull UserHandle user) {
        int key = user.hashCode();
+3 −2
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ import java.nio.ByteBuffer

@TargetApi(Build.VERSION_CODES.TIRAMISU)
class MonoIconThemeController(
    private val colorProvider: (Context) -> IntArray = ThemedIconDrawable.Companion::getColors
    private val shouldForceThemeIcon: Boolean = false,
    private val colorProvider: (Context) -> IntArray = ThemedIconDrawable.Companion::getColors,
) : IconThemeController {

    override val themeID = "with-theme"
@@ -63,7 +64,7 @@ class MonoIconThemeController(
                info,
                factory.getShapePath(icon, Rect(0, 0, info.icon.width, info.icon.height)),
                sourceHint?.isFileDrawable ?: false,
                factory.shouldForceThemeIcon(),
                shouldForceThemeIcon,
            )
        if (mono != null) {
            return MonoThemedBitmap(
Loading