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

Commit 1ab944ca authored by Austin Delgado's avatar Austin Delgado Committed by Automerger Merge Worker
Browse files

Merge "Prevent alternateBouncer from consuming touches in new UdfpsOverlay"...

Merge "Prevent alternateBouncer from consuming touches in new UdfpsOverlay" into udc-dev am: 88c2ae44

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21793134



Change-Id: Iaf804b538f6def6791ae9db5150f14784f282a95
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents caa6eee0 88c2ae44
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;

import com.android.settingslib.udfps.UdfpsOverlayParams;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.biometrics.AuthController;
@@ -778,7 +779,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
        }

        @Override
        public void onUdfpsLocationChanged() {
        public void onUdfpsLocationChanged(UdfpsOverlayParams udfpsOverlayParams) {
            updateUdfpsConfig();
        }
    };
+9 −5
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
    @NonNull private final WindowManager mWindowManager;
    @NonNull private final DisplayManager mDisplayManager;
    @Nullable private UdfpsController mUdfpsController;
    @Nullable private UdfpsOverlayParams mUdfpsOverlayParams;
    @Nullable private IUdfpsRefreshRateRequestCallback mUdfpsRefreshRateRequestCallback;
    @Nullable private SideFpsController mSideFpsController;
    @Nullable private UdfpsLogger mUdfpsLogger;
@@ -806,6 +807,8 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
            final FingerprintSensorPropertiesInternal udfpsProp = mUdfpsProps.get(0);

            final Rect previousUdfpsBounds = mUdfpsBounds;
            final UdfpsOverlayParams previousUdfpsOverlayParams = mUdfpsOverlayParams;

            mUdfpsBounds = udfpsProp.getLocation().getRect();
            mUdfpsBounds.scale(mScaleFactor);

@@ -815,7 +818,7 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
                    mCachedDisplayInfo.getNaturalWidth(), /* right */
                    mCachedDisplayInfo.getNaturalHeight() /* botom */);

            final UdfpsOverlayParams overlayParams = new UdfpsOverlayParams(
            mUdfpsOverlayParams = new UdfpsOverlayParams(
                    mUdfpsBounds,
                    overlayBounds,
                    mCachedDisplayInfo.getNaturalWidth(),
@@ -823,10 +826,11 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
                    mScaleFactor,
                    mCachedDisplayInfo.rotation);

            mUdfpsController.updateOverlayParams(udfpsProp, overlayParams);
            if (!Objects.equals(previousUdfpsBounds, mUdfpsBounds)) {
            mUdfpsController.updateOverlayParams(udfpsProp, mUdfpsOverlayParams);
            if (!Objects.equals(previousUdfpsBounds, mUdfpsBounds) || !Objects.equals(
                    previousUdfpsOverlayParams, mUdfpsOverlayParams)) {
                for (Callback cb : mCallbacks) {
                    cb.onUdfpsLocationChanged();
                    cb.onUdfpsLocationChanged(mUdfpsOverlayParams);
                }
            }
        }
@@ -1336,7 +1340,7 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
         * On devices with UDFPS, this is always called alongside
         * {@link #onFingerprintLocationChanged}.
         */
        default void onUdfpsLocationChanged() {}
        default void onUdfpsLocationChanged(UdfpsOverlayParams udfpsOverlayParams) {}

        /**
         * Called when the location of the face unlock sensor (typically the front facing camera)
+2 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.keyguard.logging.KeyguardLogger
import com.android.settingslib.Utils
import com.android.settingslib.udfps.UdfpsOverlayParams
import com.android.systemui.R
import com.android.systemui.animation.Interpolators
import com.android.systemui.flags.FeatureFlags
@@ -326,7 +327,7 @@ class AuthRippleController @Inject constructor(
                updateUdfpsDependentParams()
            }

            override fun onUdfpsLocationChanged() {
            override fun onUdfpsLocationChanged(udfpsOverlayParams: UdfpsOverlayParams) {
                updateUdfpsDependentParams()
            }
        }
+11 −5
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@ import com.android.systemui.util.concurrency.Execution;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.util.time.SystemClock;

import kotlin.Unit;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
@@ -110,8 +112,6 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Provider;

import kotlin.Unit;

/**
 * Shows and hides the under-display fingerprint sensor (UDFPS) overlay, handles UDFPS touch events,
 * and toggles the UDFPS display mode.
@@ -598,14 +598,20 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                mFalsingManager.isFalseTouch(UDFPS_AUTHENTICATION);
                break;

            case UNCHANGED:
                if (!isWithinSensorArea(mOverlay.getOverlayView(), event.getX(), event.getY(),
                        true) && mActivePointerId == MotionEvent.INVALID_POINTER_ID
                        && event.getActionMasked() == MotionEvent.ACTION_DOWN
                        && mAlternateBouncerInteractor.isVisibleState()) {
                    // No pointer on sensor, forward to keyguard if alternateBouncer is visible
                    mKeyguardViewManager.onTouch(event);
                }

            default:
                break;
        }
        logBiometricTouch(processedTouch.getEvent(), data);

        // We should only consume touches that are within the sensor. By returning "false" for
        // touches outside of the sensor, we let other UI components consume these events and act on
        // them appropriately.
        return processedTouch.getTouchData().isWithinSensor(mOverlayParams.getNativeSensorBounds());
    }

+71 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.biometrics.domain.interactor

import android.view.MotionEvent
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.settingslib.udfps.UdfpsOverlayParams
import com.android.systemui.biometrics.AuthController
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.stateIn

/** Encapsulates business logic for interacting with the UDFPS overlay. */
@SysUISingleton
class UdfpsOverlayInteractor
@Inject
constructor(private val authController: AuthController, @Application scope: CoroutineScope) {

    /** Whether a touch should be intercepted or allowed to pass to the UdfpsOverlay */
    fun canInterceptTouchInUdfpsBounds(ev: MotionEvent): Boolean {
        val isUdfpsEnrolled = authController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser())
        val isWithinUdfpsOverlayBounds =
            udfpsOverlayParams.value.overlayBounds.contains(ev.rawX.toInt(), ev.rawY.toInt())
        return !isUdfpsEnrolled || !isWithinUdfpsOverlayBounds
    }

    /** Returns the current udfpsOverlayParams */
    val udfpsOverlayParams: StateFlow<UdfpsOverlayParams> =
        ConflatedCallbackFlow.conflatedCallbackFlow {
                val callback =
                    object : AuthController.Callback {
                        override fun onUdfpsLocationChanged(
                            udfpsOverlayParams: UdfpsOverlayParams
                        ) {
                            trySendWithFailureLogging(
                                udfpsOverlayParams,
                                TAG,
                                "update udfpsOverlayParams"
                            )
                        }
                    }
                authController.addCallback(callback)
                awaitClose { authController.removeCallback(callback) }
            }
            .stateIn(scope, started = SharingStarted.Eagerly, initialValue = UdfpsOverlayParams())

    companion object {
        private const val TAG = "UdfpsOverlayInteractor"
    }
}
Loading