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

Commit 751a3079 authored by Hao Dong's avatar Hao Dong Committed by Android (Google) Code Review
Browse files

Merge "Add onUdfpsUiEvent() and callbacks on overlay shown in FingerprintManager." into udc-qpr-dev

parents 74ba9601 c7fe1ddb
Loading
Loading
Loading
Loading
+44 −7
Original line number Original line Diff line number Diff line
@@ -103,6 +103,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    private static final int MSG_UDFPS_POINTER_DOWN = 108;
    private static final int MSG_UDFPS_POINTER_DOWN = 108;
    private static final int MSG_UDFPS_POINTER_UP = 109;
    private static final int MSG_UDFPS_POINTER_UP = 109;
    private static final int MSG_POWER_BUTTON_PRESSED = 110;
    private static final int MSG_POWER_BUTTON_PRESSED = 110;
    private static final int MSG_UDFPS_OVERLAY_SHOWN = 111;


    /**
    /**
     * @hide
     * @hide
@@ -120,6 +121,24 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface EnrollReason {}
    public @interface EnrollReason {}


    /**
     * Udfps ui event of overlay is shown on the screen.
     * @hide
     */
    public static final int UDFPS_UI_OVERLAY_SHOWN = 1;
    /**
     * Udfps ui event of the udfps UI being ready (e.g. HBM illumination is enabled).
     * @hide
     */
    public static final int UDFPS_UI_READY = 2;

    /**
     * @hide
     */
    @IntDef({UDFPS_UI_OVERLAY_SHOWN, UDFPS_UI_READY})
    @Retention(RetentionPolicy.SOURCE)
    public @interface UdfpsUiEvent{}

    /**
    /**
     * Request authentication with any single sensor.
     * Request authentication with any single sensor.
     * @hide
     * @hide
@@ -475,12 +494,17 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        /**
        /**
         * Called when a pointer down event has occurred.
         * Called when a pointer down event has occurred.
         */
         */
        public void onPointerDown(int sensorId){ }
        public void onUdfpsPointerDown(int sensorId){ }


        /**
        /**
         * Called when a pointer up event has occurred.
         * Called when a pointer up event has occurred.
         */
         */
        public void onPointerUp(int sensorId){ }
        public void onUdfpsPointerUp(int sensorId){ }

        /**
         * Called when udfps overlay is shown.
         */
        public void onUdfpsOverlayShown() { }
    }
    }


    /**
    /**
@@ -1112,14 +1136,14 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
     * @hide
     * @hide
     */
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void onUiReady(long requestId, int sensorId) {
    public void onUdfpsUiEvent(@UdfpsUiEvent int event, long requestId, int sensorId) {
        if (mService == null) {
        if (mService == null) {
            Slog.w(TAG, "onUiReady: no fingerprint service");
            Slog.w(TAG, "onUdfpsUiEvent: no fingerprint service");
            return;
            return;
        }
        }


        try {
        try {
            mService.onUiReady(requestId, sensorId);
            mService.onUdfpsUiEvent(event, requestId, sensorId);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1365,6 +1389,8 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
                case MSG_POWER_BUTTON_PRESSED:
                case MSG_POWER_BUTTON_PRESSED:
                    sendPowerPressed();
                    sendPowerPressed();
                    break;
                    break;
                case MSG_UDFPS_OVERLAY_SHOWN:
                    sendUdfpsOverlayShown();
                default:
                default:
                    Slog.w(TAG, "Unknown message: " + msg.what);
                    Slog.w(TAG, "Unknown message: " + msg.what);


@@ -1489,7 +1515,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        }
        }


        if (mEnrollmentCallback != null) {
        if (mEnrollmentCallback != null) {
            mEnrollmentCallback.onPointerDown(sensorId);
            mEnrollmentCallback.onUdfpsPointerDown(sensorId);
        }
        }
    }
    }


@@ -1500,7 +1526,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
            mAuthenticationCallback.onUdfpsPointerUp(sensorId);
            mAuthenticationCallback.onUdfpsPointerUp(sensorId);
        }
        }
        if (mEnrollmentCallback != null) {
        if (mEnrollmentCallback != null) {
            mEnrollmentCallback.onPointerUp(sensorId);
            mEnrollmentCallback.onUdfpsPointerUp(sensorId);
        }
        }
    }
    }


@@ -1512,6 +1538,12 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        }
        }
    }
    }


    private void sendUdfpsOverlayShown() {
        if (mEnrollmentCallback != null) {
            mEnrollmentCallback.onUdfpsOverlayShown();
        }
    }

    /**
    /**
     * @hide
     * @hide
     */
     */
@@ -1787,6 +1819,11 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        public void onUdfpsPointerUp(int sensorId) {
        public void onUdfpsPointerUp(int sensorId) {
            mHandler.obtainMessage(MSG_UDFPS_POINTER_UP, sensorId, 0).sendToTarget();
            mHandler.obtainMessage(MSG_UDFPS_POINTER_UP, sensorId, 0).sendToTarget();
        }
        }

        @Override
        public void onUdfpsOverlayShown() {
            mHandler.obtainMessage(MSG_UDFPS_OVERLAY_SHOWN).sendToTarget();
        }
    };
    };


}
}
+5 −0
Original line number Original line Diff line number Diff line
@@ -75,4 +75,9 @@ public class FingerprintServiceReceiver extends IFingerprintServiceReceiver.Stub
    public void onUdfpsPointerUp(int sensorId) throws RemoteException {
    public void onUdfpsPointerUp(int sensorId) throws RemoteException {


    }
    }

    @Override
    public void onUdfpsOverlayShown() throws RemoteException {

    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -193,7 +193,7 @@ interface IFingerprintService {


    // Notifies about the fingerprint UI being ready (e.g. HBM illumination is enabled).
    // Notifies about the fingerprint UI being ready (e.g. HBM illumination is enabled).
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void onUiReady(long requestId, int sensorId);
    void onUdfpsUiEvent(int event, long requestId, int sensorId);


    // Sets the controller for managing the UDFPS overlay.
    // Sets the controller for managing the UDFPS overlay.
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
+1 −0
Original line number Original line Diff line number Diff line
@@ -32,4 +32,5 @@ oneway interface IFingerprintServiceReceiver {
    void onChallengeGenerated(int sensorId, int userId, long challenge);
    void onChallengeGenerated(int sensorId, int userId, long challenge);
    void onUdfpsPointerDown(int sensorId);
    void onUdfpsPointerDown(int sensorId);
    void onUdfpsPointerUp(int sensorId);
    void onUdfpsPointerUp(int sensorId);
    void onUdfpsOverlayShown();
}
}
+8 −2
Original line number Original line Diff line number Diff line
@@ -356,7 +356,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                UdfpsController.this.mAlternateTouchProvider.onUiReady();
                UdfpsController.this.mAlternateTouchProvider.onUiReady();
            } else {
            } else {
                final long requestId = (mOverlay != null) ? mOverlay.getRequestId() : 0L;
                final long requestId = (mOverlay != null) ? mOverlay.getRequestId() : 0L;
                UdfpsController.this.mFingerprintManager.onUiReady(requestId, sensorId);
                UdfpsController.this.mFingerprintManager.onUdfpsUiEvent(
                        FingerprintManager.UDFPS_UI_READY, requestId, sensorId);
            }
            }
        }
        }
    }
    }
@@ -956,6 +957,10 @@ public class UdfpsController implements DozeReceiver, Dumpable {
            mOnFingerDown = false;
            mOnFingerDown = false;
            mAttemptedToDismissKeyguard = false;
            mAttemptedToDismissKeyguard = false;
            mOrientationListener.enable();
            mOrientationListener.enable();
            if (mFingerprintManager != null) {
                mFingerprintManager.onUdfpsUiEvent(FingerprintManager.UDFPS_UI_OVERLAY_SHOWN,
                        overlay.getRequestId(), mSensorProps.sensorId);
            }
        } else {
        } else {
            Log.v(TAG, "showUdfpsOverlay | the overlay is already showing");
            Log.v(TAG, "showUdfpsOverlay | the overlay is already showing");
        }
        }
@@ -1097,7 +1102,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
                mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
            });
            });
        } else {
        } else {
            mFingerprintManager.onUiReady(requestId, mSensorProps.sensorId);
            mFingerprintManager.onUdfpsUiEvent(FingerprintManager.UDFPS_UI_READY, requestId,
                    mSensorProps.sensorId);
            mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
            mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
        }
        }
    }
    }
Loading