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

Commit 0af71e16 authored by Evan Laird's avatar Evan Laird Committed by Automerger Merge Worker
Browse files

Merge changes Ia0ce4c06,I68fbe1a7,Ibc19ae82,If9f3e28c into udc-qpr-dev am: 3e9e20c2

parents dbe6e1a7 3e9e20c2
Loading
Loading
Loading
Loading
+9 −10
Original line number Original line Diff line number Diff line
@@ -49,8 +49,11 @@ import kotlin.math.floor
 * When the HWC of the device supports Composition.DISPLAY_DECORATION, we use this layer to draw
 * When the HWC of the device supports Composition.DISPLAY_DECORATION, we use this layer to draw
 * screen decorations.
 * screen decorations.
 */
 */
class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDecorationSupport) :
class ScreenDecorHwcLayer(
        DisplayCutoutBaseView(context) {
    context: Context,
    displayDecorationSupport: DisplayDecorationSupport,
    private val debug: Boolean,
) : DisplayCutoutBaseView(context) {
    val colorMode: Int
    val colorMode: Int
    private val useInvertedAlphaColor: Boolean
    private val useInvertedAlphaColor: Boolean
    private val color: Int
    private val color: Int
@@ -74,7 +77,7 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec
            throw IllegalArgumentException("Attempting to use unsupported mode " +
            throw IllegalArgumentException("Attempting to use unsupported mode " +
                    "${PixelFormat.formatToString(displayDecorationSupport.format)}")
                    "${PixelFormat.formatToString(displayDecorationSupport.format)}")
        }
        }
        if (DEBUG_COLOR) {
        if (debug) {
            color = Color.GREEN
            color = Color.GREEN
            bgColor = Color.TRANSPARENT
            bgColor = Color.TRANSPARENT
            colorMode = ActivityInfo.COLOR_MODE_DEFAULT
            colorMode = ActivityInfo.COLOR_MODE_DEFAULT
@@ -106,7 +109,7 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec
    override fun onAttachedToWindow() {
    override fun onAttachedToWindow() {
        super.onAttachedToWindow()
        super.onAttachedToWindow()
        parent.requestTransparentRegion(this)
        parent.requestTransparentRegion(this)
        if (!DEBUG_COLOR) {
        if (!debug) {
            viewRootImpl.setDisplayDecoration(true)
            viewRootImpl.setDisplayDecoration(true)
        }
        }


@@ -143,12 +146,12 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec
    override fun gatherTransparentRegion(region: Region?): Boolean {
    override fun gatherTransparentRegion(region: Region?): Boolean {
        region?.let {
        region?.let {
            calculateTransparentRect()
            calculateTransparentRect()
            if (DEBUG_COLOR) {
            if (debug) {
                // Since we're going to draw a rectangle where the layer would
                // Since we're going to draw a rectangle where the layer would
                // normally be transparent, treat the transparent region as
                // normally be transparent, treat the transparent region as
                // empty. We still want this method to be called, though, so
                // empty. We still want this method to be called, though, so
                // that it calculates the transparent rect at the right time
                // that it calculates the transparent rect at the right time
                // to match !DEBUG_COLOR.
                // to match ![debug]
                region.setEmpty()
                region.setEmpty()
            } else {
            } else {
                region.op(transparentRect, Region.Op.INTERSECT)
                region.op(transparentRect, Region.Op.INTERSECT)
@@ -421,8 +424,4 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec
        ipw.println("roundedCornerBottomSize=$roundedCornerBottomSize")
        ipw.println("roundedCornerBottomSize=$roundedCornerBottomSize")
        ipw.decreaseIndent()
        ipw.decreaseIndent()
    }
    }

    companion object {
        private val DEBUG_COLOR = ScreenDecorations.DEBUG_COLOR
    }
}
}
+118 −88

File changed.

Preview size limit exceeded, changes collapsed.

+198 −0

File added.

Preview size limit exceeded, changes collapsed.

+28 −35
Original line number Original line Diff line number Diff line
@@ -27,44 +27,50 @@ import com.android.systemui.Dumpable
import com.android.systemui.R
import com.android.systemui.R
import java.io.PrintWriter
import java.io.PrintWriter


class RoundedCornerResDelegate(
interface RoundedCornerResDelegate {
    val hasTop: Boolean
    val topRoundedDrawable: Drawable?
    val topRoundedSize: Size

    val hasBottom: Boolean
    val bottomRoundedDrawable: Drawable?
    val bottomRoundedSize: Size

    var physicalPixelDisplaySizeRatio: Float

    fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?)
}

/**
 * Delegate for the device-default rounded corners. These will always be loaded from the config
 * values `R.array.config_roundedCornerTopDrawableArray` and `R.drawable.rounded_corner_top`
 */
class RoundedCornerResDelegateImpl(
    private val res: Resources,
    private val res: Resources,
    private var displayUniqueId: String?
    private var displayUniqueId: String?
) : Dumpable {
) : RoundedCornerResDelegate, Dumpable {

    private val density: Float
        get() = res.displayMetrics.density


    private var reloadToken: Int = 0
    private var reloadToken: Int = 0


    var hasTop: Boolean = false
    override var hasTop: Boolean = false
        private set
        private set


    var hasBottom: Boolean = false
    override var hasBottom: Boolean = false
        private set
        private set


    var topRoundedDrawable: Drawable? = null
    override var topRoundedDrawable: Drawable? = null
        private set
        private set


    var bottomRoundedDrawable: Drawable? = null
    override var bottomRoundedDrawable: Drawable? = null
        private set
        private set


    var topRoundedSize = Size(0, 0)
    override var topRoundedSize = Size(0, 0)
        private set
        private set


    var bottomRoundedSize = Size(0, 0)
    override var bottomRoundedSize = Size(0, 0)
        private set
        private set


    var tuningSizeFactor: Int? = null
    override var physicalPixelDisplaySizeRatio: Float = 1f
        set(value) {
            if (field == value) {
                return
            }
            field = value
            reloadMeasures()
        }

    var physicalPixelDisplaySizeRatio: Float = 1f
        set(value) {
        set(value) {
            if (field == value) {
            if (field == value) {
                return
                return
@@ -78,7 +84,7 @@ class RoundedCornerResDelegate(
        reloadMeasures()
        reloadMeasures()
    }
    }


    fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
    override fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
        if (displayUniqueId != newDisplayUniqueId) {
        if (displayUniqueId != newDisplayUniqueId) {
            displayUniqueId = newDisplayUniqueId
            displayUniqueId = newDisplayUniqueId
            newReloadToken ?.let { reloadToken = it }
            newReloadToken ?.let { reloadToken = it }
@@ -122,19 +128,6 @@ class RoundedCornerResDelegate(
            bottomRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight)
            bottomRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight)
        }
        }


        tuningSizeFactor?.let {
            if (it <= 0) {
                return
            }
            val length: Int = (it * density).toInt()
            if (topRoundedSize.width > 0) {
                topRoundedSize = Size(length, length)
            }
            if (bottomRoundedSize.width > 0) {
                bottomRoundedSize = Size(length, length)
            }
        }

        if (physicalPixelDisplaySizeRatio != 1f) {
        if (physicalPixelDisplaySizeRatio != 1f) {
            if (topRoundedSize.width != 0) {
            if (topRoundedSize.width != 0) {
                topRoundedSize = Size(
                topRoundedSize = Size(
+46 −1
Original line number Original line Diff line number Diff line
@@ -21,9 +21,9 @@ import android.graphics.Rect
import android.graphics.RectF
import android.graphics.RectF
import androidx.core.graphics.toRectF
import androidx.core.graphics.toRectF
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel.DEBUG
import com.android.systemui.log.LogLevel.DEBUG
import com.android.systemui.log.LogLevel.ERROR
import com.android.systemui.log.LogLevel.ERROR
import com.android.systemui.log.LogLevel.INFO
import com.android.systemui.log.dagger.ScreenDecorationsLog
import com.android.systemui.log.dagger.ScreenDecorationsLog
import com.google.errorprone.annotations.CompileTimeConstant
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject
import javax.inject.Inject
@@ -164,4 +164,49 @@ constructor(
    fun cameraProtectionEvent(@CompileTimeConstant cameraProtectionEvent: String) {
    fun cameraProtectionEvent(@CompileTimeConstant cameraProtectionEvent: String) {
        logBuffer.log(TAG, DEBUG, cameraProtectionEvent)
        logBuffer.log(TAG, DEBUG, cameraProtectionEvent)
    }
    }

    fun logRotationChangeDeferred(currentRot: Int, newRot: Int) {
        logBuffer.log(
            TAG,
            INFO,
            {
                int1 = currentRot
                int2 = newRot
            },
            { "Rotation changed, deferring $int2, staying at $int2" },
        )
    }

    fun logRotationChanged(oldRot: Int, newRot: Int) {
        logBuffer.log(
            TAG,
            INFO,
            {
                int1 = oldRot
                int2 = newRot
            },
            { "Rotation changed from $int1 to $int2" }
        )
    }

    fun logDisplayModeChanged(currentMode: Int, newMode: Int) {
        logBuffer.log(
            TAG,
            INFO,
            {
                int1 = currentMode
                int2 = newMode
            },
            { "Resolution changed, deferring mode change to $int2, staying at $int1" },
        )
    }

    fun logUserSwitched(newUser: Int) {
        logBuffer.log(
            TAG,
            DEBUG,
            { int1 = newUser },
            { "UserSwitched newUserId=$int1. Updating color inversion setting" },
        )
    }
}
}
Loading