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

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

Snap for 13709264 from 3c1bde99 to 25Q4-release

Change-Id: I4587d6bb8e239c13bbe62be75dda213443646eb7
parents 64776a2c 3c1bde99
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -89,6 +89,25 @@ interface PerDisplayRepository<T> {
    /** Gets the cached instance or create a new one for a given display. */
    operator fun get(displayId: Int): T?

    /**
     * Gets the cached instance or create a new one for a given display. If the given display
     * doesn't exist, returns an instance for the default display.
     */
    fun getOrDefault(displayId: Int): T {
        val instance = get(displayId)
        if (instance == null) {
            Log.e(
                "PerDisplayRepository",
                """<$debugName> getOrDefault: instance for display with id $displayId returned 
                    |null. The display likely doesn't exist anymore. Returning an instance for the 
                    |default display."""
                    .trimMargin(),
            )
            return get(DEFAULT_DISPLAY)!!
        }
        return instance
    }

    /** Debug name for this repository, mainly for tracing and logging. */
    val debugName: String