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

Commit 5b47b589 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Remove pieces of device entry flag" into main

parents 8fb027c7 a682fea3
Loading
Loading
Loading
Loading
+19 −43
Original line number Diff line number Diff line
@@ -30,14 +30,10 @@ import androidx.compose.ui.unit.IntRect
import androidx.compose.ui.viewinterop.AndroidView
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneScope
import com.android.keyguard.LockIconView
import com.android.keyguard.LockIconViewController
import com.android.systemui.biometrics.AuthController
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.KeyguardBottomAreaRefactor
import com.android.systemui.keyguard.ui.binder.DeviceEntryIconViewBinder
import com.android.systemui.keyguard.ui.composable.blueprint.BlueprintAlignmentLines
import com.android.systemui.keyguard.ui.view.DeviceEntryIconView
@@ -61,7 +57,6 @@ constructor(
    private val windowManager: WindowManager,
    private val authController: AuthController,
    private val featureFlags: FeatureFlagsClassic,
    private val lockIconViewController: Lazy<LockIconViewController>,
    private val deviceEntryIconViewModel: Lazy<DeviceEntryIconViewModel>,
    private val deviceEntryForegroundViewModel: Lazy<DeviceEntryForegroundViewModel>,
    private val deviceEntryBackgroundViewModel: Lazy<DeviceEntryBackgroundViewModel>,
@@ -71,20 +66,14 @@ constructor(
) {
    @Composable
    fun SceneScope.LockIcon(overrideColor: Color? = null, modifier: Modifier = Modifier) {
        if (!KeyguardBottomAreaRefactor.isEnabled && !DeviceEntryUdfpsRefactor.isEnabled) {
            return
        }

        val context = LocalContext.current

        AndroidView(
            factory = { context ->
                val view =
                    if (DeviceEntryUdfpsRefactor.isEnabled) {
                DeviceEntryIconView(
                        context,
                        null,
                                logger = LongPressHandlingViewLogger(logBuffer, tag = TAG)
                        logger = LongPressHandlingViewLogger(logBuffer, tag = TAG),
                    )
                    .apply {
                        id = R.id.device_entry_icon_view
@@ -99,14 +88,6 @@ constructor(
                            overrideColor,
                        )
                    }
                    } else {
                        // KeyguardBottomAreaRefactor.isEnabled
                        LockIconView(context, null).apply {
                            id = R.id.lock_icon_view
                            lockIconViewController.get().setLockIconView(this)
                        }
                    }
                view
            },
            modifier =
                modifier.element(LockIconElementKey).layout { measurable, _ ->
@@ -141,9 +122,7 @@ constructor(
     * On devices that support UDFPS (under-display fingerprint sensor), the bounds of the icon are
     * the same as the bounds of the sensor.
     */
    private fun lockIconBounds(
        context: Context,
    ): IntRect {
    private fun lockIconBounds(context: Context): IntRect {
        val windowViewBounds = windowManager.currentWindowMetrics.bounds
        var widthPx = windowViewBounds.right.toFloat()
        if (featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)) {
@@ -162,10 +141,7 @@ constructor(
        val (center, radius) =
            if (authController.isUdfpsSupported && udfpsLocation != null) {
                Pair(
                    IntOffset(
                        x = udfpsLocation.x,
                        y = udfpsLocation.y,
                    ),
                    IntOffset(x = udfpsLocation.x, y = udfpsLocation.y),
                    authController.udfpsRadius.toInt(),
                )
            } else {
+48 −94
Original line number Diff line number Diff line
@@ -27,11 +27,8 @@ import android.view.WindowManager
import androidx.annotation.VisibleForTesting
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.android.keyguard.LockIconView
import com.android.keyguard.LockIconViewController
import com.android.systemui.biometrics.AuthController
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.KeyguardBottomAreaRefactor
@@ -66,7 +63,6 @@ constructor(
    private val context: Context,
    private val notificationPanelView: NotificationPanelView,
    private val featureFlags: FeatureFlags,
    private val lockIconViewController: Lazy<LockIconViewController>,
    private val deviceEntryIconViewModel: Lazy<DeviceEntryIconViewModel>,
    private val deviceEntryForegroundViewModel: Lazy<DeviceEntryForegroundViewModel>,
    private val deviceEntryBackgroundViewModel: Lazy<DeviceEntryBackgroundViewModel>,
@@ -78,39 +74,22 @@ constructor(
    private var disposableHandle: DisposableHandle? = null

    override fun addViews(constraintLayout: ConstraintLayout) {
        if (
            !KeyguardBottomAreaRefactor.isEnabled &&
                !MigrateClocksToBlueprint.isEnabled &&
                !DeviceEntryUdfpsRefactor.isEnabled
        ) {
        if (!KeyguardBottomAreaRefactor.isEnabled && !MigrateClocksToBlueprint.isEnabled) {
            return
        }

        notificationPanelView.findViewById<View>(R.id.lock_icon_view).let {
            notificationPanelView.removeView(it)
        }

        val view =
            if (DeviceEntryUdfpsRefactor.isEnabled) {
            DeviceEntryIconView(
                    context,
                    null,
                        logger =
                            LongPressHandlingViewLogger(
                                logBuffer = logBuffer,
                                TAG
                            )
                    logger = LongPressHandlingViewLogger(logBuffer = logBuffer, TAG),
                )
                .apply { id = deviceEntryIconViewId }
            } else {
                // KeyguardBottomAreaRefactor.isEnabled or MigrateClocksToBlueprint.isEnabled
                LockIconView(context, null).apply { id = R.id.lock_icon_view }
            }

        constraintLayout.addView(view)
    }

    override fun bindData(constraintLayout: ConstraintLayout) {
        if (DeviceEntryUdfpsRefactor.isEnabled) {
        constraintLayout.findViewById<DeviceEntryIconView?>(deviceEntryIconViewId)?.let {
            disposableHandle?.dispose()
            disposableHandle =
@@ -124,24 +103,15 @@ constructor(
                    vibratorHelper.get(),
                )
        }
        } else {
            constraintLayout.findViewById<LockIconView?>(R.id.lock_icon_view)?.let {
                lockIconViewController.get().setLockIconView(it)
            }
        }
    }

    override fun applyConstraints(constraintSet: ConstraintSet) {
        val isUdfpsSupported =
            if (DeviceEntryUdfpsRefactor.isEnabled) {
        Log.d(
            "DefaultDeviceEntrySection",
                    "isUdfpsSupported=${deviceEntryIconViewModel.get().isUdfpsSupported.value}"
            "isUdfpsSupported=${deviceEntryIconViewModel.get().isUdfpsSupported.value}",
        )
                deviceEntryIconViewModel.get().isUdfpsSupported.value
            } else {
                authController.isUdfpsSupported
            }
        val isUdfpsSupported = deviceEntryIconViewModel.get().isUdfpsSupported.value

        val scaleFactor: Float = authController.scaleFactor
        val mBottomPaddingPx =
            context.resources.getDimensionPixelSize(R.dimen.lock_icon_margin_bottom)
@@ -160,31 +130,24 @@ constructor(
        val iconRadiusPx = (defaultDensity * 36).toInt()

        if (isUdfpsSupported) {
            if (DeviceEntryUdfpsRefactor.isEnabled) {
            deviceEntryIconViewModel.get().udfpsLocation.value?.let { udfpsLocation ->
                Log.d(
                    "DeviceEntrySection",
                    "udfpsLocation=$udfpsLocation, " +
                        "scaledLocation=(${udfpsLocation.centerX},${udfpsLocation.centerY}), " +
                            "unusedAuthController=${authController.udfpsLocation}"
                        "unusedAuthController=${authController.udfpsLocation}",
                )
                centerIcon(
                    Point(udfpsLocation.centerX.toInt(), udfpsLocation.centerY.toInt()),
                    udfpsLocation.radius,
                        constraintSet
                    constraintSet,
                )
            }
            } else {
                authController.udfpsLocation?.let { udfpsLocation ->
                    Log.d("DeviceEntrySection", "udfpsLocation=$udfpsLocation")
                    centerIcon(udfpsLocation, authController.udfpsRadius, constraintSet)
                }
            }
        } else {
            centerIcon(
                Point(
                    (widthPixels / 2).toInt(),
                    (heightPixels - ((mBottomPaddingPx + iconRadiusPx) * scaleFactor)).toInt()
                    (heightPixels - ((mBottomPaddingPx + iconRadiusPx) * scaleFactor)).toInt(),
                ),
                iconRadiusPx * scaleFactor,
                constraintSet,
@@ -193,12 +156,8 @@ constructor(
    }

    override fun removeViews(constraintLayout: ConstraintLayout) {
        if (DeviceEntryUdfpsRefactor.isEnabled) {
        constraintLayout.removeView(deviceEntryIconViewId)
        disposableHandle?.dispose()
        } else {
            constraintLayout.removeView(R.id.lock_icon_view)
        }
    }

    @VisibleForTesting
@@ -213,12 +172,7 @@ constructor(
                )
            }

        val iconId =
            if (DeviceEntryUdfpsRefactor.isEnabled) {
                deviceEntryIconViewId
            } else {
                R.id.lock_icon_view
            }
        val iconId = deviceEntryIconViewId

        constraintSet.apply {
            constrainWidth(iconId, sensorRect.right - sensorRect.left)
@@ -228,14 +182,14 @@ constructor(
                ConstraintSet.TOP,
                ConstraintSet.PARENT_ID,
                ConstraintSet.TOP,
                sensorRect.top
                sensorRect.top,
            )
            connect(
                iconId,
                ConstraintSet.START,
                ConstraintSet.PARENT_ID,
                ConstraintSet.START,
                sensorRect.left
                sensorRect.left,
            )
        }

@@ -243,8 +197,8 @@ constructor(
        // Without this logic, the lock icon location changes but the KeyguardBottomAreaView is not
        // updated and visible ui layout jank occurs. This is due to AmbientIndicationContainer
        // being in NPVC and laying out prior to the KeyguardRootView.
        // Remove when both DeviceEntryUdfpsRefactor and KeyguardBottomAreaRefactor are enabled.
        if (DeviceEntryUdfpsRefactor.isEnabled && !KeyguardBottomAreaRefactor.isEnabled) {
        // Remove when KeyguardBottomAreaRefactor is enabled.
        if (!KeyguardBottomAreaRefactor.isEnabled) {
            with(notificationPanelView) {
                val isUdfpsSupported = deviceEntryIconViewModel.get().isUdfpsSupported.value
                val bottomAreaViewRight = findViewById<View>(R.id.keyguard_bottom_area)?.right ?: 0
@@ -256,7 +210,7 @@ constructor(
                            ambientLeft,
                            sensorRect.bottom,
                            bottomAreaViewRight - ambientLeft,
                            ambientTop + it.measuredHeight
                            ambientTop + it.measuredHeight,
                        )
                    } else {
                        // make bottom of ambient indication view the top of the lock icon
@@ -264,7 +218,7 @@ constructor(
                            ambientLeft,
                            sensorRect.top - it.measuredHeight,
                            bottomAreaViewRight - ambientLeft,
                            sensorRect.top
                            sensorRect.top,
                        )
                    }
                }
+1 −5
Original line number Diff line number Diff line
@@ -55,11 +55,7 @@ constructor(
                R.id.nssl_placeholder_barrier_bottom,
                Barrier.TOP,
                0,
                *intArrayOf(
                    R.id.device_entry_icon_view,
                    R.id.lock_icon_view,
                    R.id.ambient_indication_container
                )
                *intArrayOf(R.id.device_entry_icon_view, R.id.ambient_indication_container),
            )
            connect(placeHolderId, BOTTOM, R.id.nssl_placeholder_barrier_bottom, TOP)
        }
+2 −47
Original line number Diff line number Diff line
@@ -18,13 +18,11 @@
package com.android.systemui.keyguard.ui.view.layout.sections

import android.graphics.Point
import android.platform.test.annotations.DisableFlags
import android.view.WindowManager
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.keyguard.LegacyLockIconViewController
import com.android.systemui.Flags as AConfigFlags
import com.android.systemui.SysuiTestCase
import com.android.systemui.biometrics.AuthController
@@ -60,7 +58,6 @@ class DefaultDeviceEntrySectionTest : SysuiTestCase() {
    @Mock(answer = Answers.RETURNS_DEEP_STUBS) private lateinit var windowManager: WindowManager
    @Mock private lateinit var notificationPanelView: NotificationPanelView
    private lateinit var featureFlags: FakeFeatureFlags
    @Mock private lateinit var lockIconViewController: LegacyLockIconViewController
    @Mock private lateinit var falsingManager: FalsingManager
    @Mock private lateinit var deviceEntryIconViewModel: DeviceEntryIconViewModel
    private lateinit var underTest: DefaultDeviceEntrySection
@@ -81,7 +78,6 @@ class DefaultDeviceEntrySectionTest : SysuiTestCase() {
                context,
                notificationPanelView,
                featureFlags,
                { lockIconViewController },
                { deviceEntryIconViewModel },
                { mock(DeviceEntryForegroundViewModel::class.java) },
                { mock(DeviceEntryBackgroundViewModel::class.java) },
@@ -102,37 +98,13 @@ class DefaultDeviceEntrySectionTest : SysuiTestCase() {
    @Test
    fun addViewsConditionally_migrateAndRefactorFlagsOn() {
        mSetFlagsRule.enableFlags(AConfigFlags.FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR)
        mSetFlagsRule.enableFlags(AConfigFlags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
        val constraintLayout = ConstraintLayout(context, null)
        underTest.addViews(constraintLayout)
        assertThat(constraintLayout.childCount).isGreaterThan(0)
    }

    @Test
    @DisableFlags(AConfigFlags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
    fun addViewsConditionally_migrateFlagOff() {
        mSetFlagsRule.disableFlags(AConfigFlags.FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR)
        mSetFlagsRule.disableFlags(AConfigFlags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
        val constraintLayout = ConstraintLayout(context, null)
        underTest.addViews(constraintLayout)
        assertThat(constraintLayout.childCount).isEqualTo(0)
    }

    @Test
    fun applyConstraints_udfps_refactor_off() {
        mSetFlagsRule.disableFlags(AConfigFlags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
        val cs = ConstraintSet()
        underTest.applyConstraints(cs)

        val constraint = cs.getConstraint(R.id.lock_icon_view)

        assertThat(constraint.layout.topToTop).isEqualTo(ConstraintSet.PARENT_ID)
        assertThat(constraint.layout.startToStart).isEqualTo(ConstraintSet.PARENT_ID)
    }

    @Test
    fun applyConstraints_udfps_refactor_on() {
        mSetFlagsRule.enableFlags(AConfigFlags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
    fun applyConstraints() {
        whenever(deviceEntryIconViewModel.isUdfpsSupported).thenReturn(MutableStateFlow(false))
        val cs = ConstraintSet()
        underTest.applyConstraints(cs)
@@ -144,24 +116,7 @@ class DefaultDeviceEntrySectionTest : SysuiTestCase() {
    }

    @Test
    fun testCenterIcon_udfps_refactor_off() {
        mSetFlagsRule.disableFlags(AConfigFlags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
        val cs = ConstraintSet()
        underTest.centerIcon(Point(5, 6), 1F, cs)

        val constraint = cs.getConstraint(R.id.lock_icon_view)

        assertThat(constraint.layout.mWidth).isEqualTo(2)
        assertThat(constraint.layout.mHeight).isEqualTo(2)
        assertThat(constraint.layout.topToTop).isEqualTo(ConstraintSet.PARENT_ID)
        assertThat(constraint.layout.startToStart).isEqualTo(ConstraintSet.PARENT_ID)
        assertThat(constraint.layout.topMargin).isEqualTo(5)
        assertThat(constraint.layout.startMargin).isEqualTo(4)
    }

    @Test
    fun testCenterIcon_udfps_refactor_on() {
        mSetFlagsRule.enableFlags(AConfigFlags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
    fun testCenterIcon() {
        val cs = ConstraintSet()
        underTest.centerIcon(Point(5, 6), 1F, cs)