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

Commit aa32a564 authored by Shawn Lin's avatar Shawn Lin
Browse files

Fix cutout not updating when switching cutout emulation

The root cause is that we didn't update the config for cutout change
only case.

Add detection for cutout change in updateConfiguration().

Bug: 256652639
Test: switch between different cutout emulation and observe the result.
Change-Id: Ic169d8d9f305ae2158a6a9f88f7bc5683426a56c
parent 0f3eb727
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
            return
        }
        cutoutPath.reset()
        display.getDisplayInfo(displayInfo)
        context.display?.getDisplayInfo(displayInfo)
        displayInfo.displayCutout?.cutoutPath?.let { path -> cutoutPath.set(path) }
        invalidate()
    }
+8 −2
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
    private Display.Mode mDisplayMode;
    @VisibleForTesting
    protected DisplayInfo mDisplayInfo = new DisplayInfo();
    private DisplayCutout mDisplayCutout;

    @VisibleForTesting
    protected void showCameraProtection(@NonNull Path protectionPath, @NonNull Rect bounds) {
@@ -384,6 +385,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
        mRotation = mDisplayInfo.rotation;
        mDisplayMode = mDisplayInfo.getMode();
        mDisplayUniqueId = mDisplayInfo.uniqueId;
        mDisplayCutout = mDisplayInfo.displayCutout;
        mRoundedCornerResDelegate = new RoundedCornerResDelegate(mContext.getResources(),
                mDisplayUniqueId);
        mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
@@ -1022,7 +1024,8 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
        mRoundedCornerResDelegate.dump(pw, args);
    }

    private void updateConfiguration() {
    @VisibleForTesting
    void updateConfiguration() {
        Preconditions.checkState(mHandler.getLooper().getThread() == Thread.currentThread(),
                "must call on " + mHandler.getLooper().getThread()
                        + ", but was " + Thread.currentThread());
@@ -1033,11 +1036,14 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
            mDotViewController.setNewRotation(newRotation);
        }
        final Display.Mode newMod = mDisplayInfo.getMode();
        final DisplayCutout newCutout = mDisplayInfo.displayCutout;

        if (!mPendingConfigChange
                && (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod))) {
                && (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod)
                || !Objects.equals(newCutout, mDisplayCutout))) {
            mRotation = newRotation;
            mDisplayMode = newMod;
            mDisplayCutout = newCutout;
            mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
                    getPhysicalPixelDisplaySizeRatio());
            if (mScreenDecorHwcLayer != null) {
+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui

import android.content.Context
import android.graphics.Canvas
import android.graphics.Insets
import android.graphics.Path
@@ -48,6 +49,7 @@ class DisplayCutoutBaseViewTest : SysuiTestCase() {
    @Mock private lateinit var mockCanvas: Canvas
    @Mock private lateinit var mockRootView: View
    @Mock private lateinit var mockDisplay: Display
    @Mock private lateinit var mockContext: Context

    private lateinit var cutoutBaseView: DisplayCutoutBaseView
    private val cutout: DisplayCutout = DisplayCutout.Builder()
@@ -168,7 +170,9 @@ class DisplayCutoutBaseViewTest : SysuiTestCase() {
                R.bool.config_fillMainBuiltInDisplayCutout, fillCutout)

        cutoutBaseView = spy(DisplayCutoutBaseView(mContext))
        whenever(cutoutBaseView.display).thenReturn(mockDisplay)

        whenever(cutoutBaseView.context).thenReturn(mockContext)
        whenever(mockContext.display).thenReturn(mockDisplay)
        whenever(mockDisplay.uniqueId).thenReturn("mockDisplayUniqueId")
        whenever(cutoutBaseView.rootView).thenReturn(mockRootView)
        whenever(cutoutBaseView.getPhysicalPixelDisplaySizeRatio()).thenReturn(1f)
+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui

import android.content.Context
import android.graphics.Insets
import android.graphics.PixelFormat
import android.graphics.Rect
@@ -44,6 +45,7 @@ class ScreenDecorHwcLayerTest : SysuiTestCase() {

    @Mock private lateinit var mockDisplay: Display
    @Mock private lateinit var mockRootView: View
    @Mock private lateinit var mockContext: Context

    private val displayWidth = 100
    private val displayHeight = 200
@@ -75,7 +77,8 @@ class ScreenDecorHwcLayerTest : SysuiTestCase() {
        decorHwcLayer = Mockito.spy(ScreenDecorHwcLayer(mContext, decorationSupport))
        whenever(decorHwcLayer.width).thenReturn(displayWidth)
        whenever(decorHwcLayer.height).thenReturn(displayHeight)
        whenever(decorHwcLayer.display).thenReturn(mockDisplay)
        whenever(decorHwcLayer.context).thenReturn(mockContext)
        whenever(mockContext.display).thenReturn(mockDisplay)
        whenever(decorHwcLayer.rootView).thenReturn(mockRootView)
        whenever(mockRootView.left).thenReturn(0)
        whenever(mockRootView.top).thenReturn(0)