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

Commit 43c4511b authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Migrate the insetsRoundedCornerFrame to InsetsFrameProvider

The server side has moved the InsetsRoundedCornerFrame into
InsetsFrameProvider as it is actually using a given type of insets frame
to calculate the new rounded corner information and moving it into the
corresponding provider would make it cleaner.

To make sure it can be updated and accessed properly,
TaskbarInsetsController is now holding the nav bar insets provider to
make the update. It will be used always even if the height has been
updated. Other necessary changes are made to reflect the change.

Test: DisplayPolicyInsetsTests
Test: m
Bug: 274724339
Change-Id: Iec6804a01bafbbaed8591694490f29c97ea7e7fc
parent 14734d3a
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.os.Binder
import android.os.IBinder
import android.view.InsetsFrameProvider
import android.view.InsetsFrameProvider.SOURCE_DISPLAY
import android.view.InsetsSource.FLAG_INSETS_ROUNDED_CORNER
import android.view.InsetsSource.FLAG_SUPPRESS_SCRIM
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME
@@ -83,11 +84,23 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
    }

    fun onTaskbarWindowHeightOrInsetsChanged() {
        val tappableHeight = controllers.taskbarStashController.tappableHeightToReportToApps
        // We only report tappableElement height for unstashed, persistent taskbar,
        // which is also when we draw the rounded corners above taskbar.
        val insetsRoundedCornerFlag =
            if (tappableHeight > 0) {
                FLAG_INSETS_ROUNDED_CORNER
            } else {
                0
            }
        if (context.isGestureNav) {
            windowLayoutParams.providedInsets =
                arrayOf(
                    InsetsFrameProvider(insetsOwner, 0, navigationBars())
                        .setFlags(FLAG_SUPPRESS_SCRIM, FLAG_SUPPRESS_SCRIM),
                        .setFlags(
                            FLAG_SUPPRESS_SCRIM or insetsRoundedCornerFlag,
                            FLAG_SUPPRESS_SCRIM or FLAG_INSETS_ROUNDED_CORNER
                        ),
                    InsetsFrameProvider(insetsOwner, 0, tappableElement()),
                    InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures()),
                    InsetsFrameProvider(insetsOwner, INDEX_LEFT, systemGestures())
@@ -98,7 +111,11 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
        } else {
            windowLayoutParams.providedInsets =
                arrayOf(
                    InsetsFrameProvider(insetsOwner, 0, navigationBars()),
                    InsetsFrameProvider(insetsOwner, 0, navigationBars())
                        .setFlags(
                            insetsRoundedCornerFlag,
                            (FLAG_SUPPRESS_SCRIM or FLAG_INSETS_ROUNDED_CORNER)
                        ),
                    InsetsFrameProvider(insetsOwner, 0, tappableElement()),
                    InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures())
                )
@@ -112,7 +129,6 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
            windowLayoutParams.height
        )
        val contentHeight = controllers.taskbarStashController.contentHeightToReportToApps
        val tappableHeight = controllers.taskbarStashController.tappableHeightToReportToApps
        val res = context.resources
        for (provider in windowLayoutParams.providedInsets) {
            if (provider.type == navigationBars() || provider.type == mandatorySystemGestures()) {
@@ -162,10 +178,6 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
            }
        }

        // We only report tappableElement height for unstashed, persistent taskbar,
        // which is also when we draw the rounded corners above taskbar.
        windowLayoutParams.insetsRoundedCornerFrame = tappableHeight > 0

        context.notifyUpdateLayoutParams()
    }