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

Commit 0a2a2280 authored by Kimi Hsu's avatar Kimi Hsu
Browse files

Showing face auth animation in debug mode

Bug: 305897028
Test: adb shell cmd statusbar screen-decor --debug true --faceAuthScreen 0
Flag: EXEMPT debug mechanism

Change-Id: I5f2891ab49bd65687e58d251c96bd7888f332f31
parent af1d9519
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -129,6 +129,11 @@ class CameraAvailabilityListener(
        listeners.remove(callback)
    }

    fun debugFaceAuth(id: Int) {
        val info = cameraProtectionInfoList?.getOrNull(id)
        if (info != null) notifyCameraActive(info)
    }

    private fun isExcluded(packageId: String): Boolean {
        return excludedPackageIds.contains(packageId)
    }
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ class FaceScanningOverlay(

    override fun enableShowProtection(isCameraActive: Boolean) {
        val scanningAnimationRequiredWhenCameraActive =
                keyguardUpdateMonitor.isFaceDetectionRunning || authController.isShowing
                keyguardUpdateMonitor.isFaceDetectionRunning || authController.isShowing || mDebug
        val faceAuthSucceeded = keyguardUpdateMonitor.isFaceAuthenticated
        val showScanningAnimationNow = scanningAnimationRequiredWhenCameraActive && isCameraActive
        if (showScanningAnimationNow == showScanningAnim) {
+21 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ public class ScreenDecorations implements

    @VisibleForTesting
    protected void showCameraProtection(@NonNull Path protectionPath, @NonNull Rect bounds) {
        if (mFaceScanningFactory.shouldShowFaceScanningAnim()) {
        if (mDebug || mFaceScanningFactory.shouldShowFaceScanningAnim()) {
            DisplayCutoutView overlay = (DisplayCutoutView) getOverlayView(
                    mFaceScanningViewId);
            if (overlay != null) {
@@ -395,6 +395,12 @@ public class ScreenDecorations implements
                setupDecorations();
            });
        }

        if (cmd.getFaceAuthScreen() != null) {
            mExecutor.execute(() -> {
                debugTriggerFaceAuth(cmd.getFaceAuthScreen());
            });
        }
    };

    @Override
@@ -630,6 +636,15 @@ public class ScreenDecorations implements
        }
    }

    private void debugTriggerFaceAuth(int screen) {
        DisplayCutoutView overlay = (DisplayCutoutView) getOverlayView(
                mFaceScanningViewId);
        if (overlay != null) {
            overlay.setDebug(true);
            mCameraListener.debugFaceAuth(screen);
        }
    }

    private void setupDecorations() {
        Trace.beginSection("ScreenDecorations#setupDecorations");
        setupDecorationsInner();
@@ -1360,6 +1375,7 @@ public class ScreenDecorations implements
        final List<Rect> mBounds = new ArrayList();
        final Rect mBoundingRect = new Rect();
        Rect mTotalBounds = new Rect();
        boolean mDebug = false;

        private int mColor = Color.BLACK;
        private int mRotation;
@@ -1378,6 +1394,10 @@ public class ScreenDecorations implements
            }
        }

        public void setDebug(boolean debug) {
            mDebug = debug;
        }

        public void setColor(int color) {
            if (color == mColor) {
                return;
+9 −0
Original line number Diff line number Diff line
@@ -53,6 +53,14 @@ class ScreenDecorCommand(
    val roundedBottom: RoundedCornerSubCommand? by
        subCommand(RoundedCornerSubCommand("rounded-bottom"))

    val faceAuthScreen: Int? by
        param(
            longName = "faceAuthScreen",
            description =
                "Specify a screen to show face auth animation. 0:outer(default screen), 1:inner",
            valueParser = Type.Int,
        )

    override fun execute(pw: PrintWriter) {
        callback.onExecute(this, pw)
    }
@@ -61,6 +69,7 @@ class ScreenDecorCommand(
        return "ScreenDecorCommand(" +
            "debug=$debug, " +
            "color=$color, " +
            "faceAuthScreen=$faceAuthScreen, " +
            "roundedTop=$roundedTop, " +
            "roundedBottom=$roundedBottom)"
    }