/* * Copyright (C) 2017 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 android.accessibilityservice; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Handler; import android.os.RemoteException; import android.util.ArrayMap; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; /** * An {@link AccessibilityService} can capture gestures performed on a device's fingerprint * sensor, as long as the device has a sensor capable of detecting gestures. *
* This capability must be declared by the service as * {@link AccessibilityServiceInfo#CAPABILITY_CAN_CAPTURE_FINGERPRINT_GESTURES}. It also requires * the permission {@link android.Manifest.permission#USE_FINGERPRINT}. *
* Because capturing fingerprint gestures may have side effects, services with the capability only * capture gestures when {@link AccessibilityServiceInfo#FLAG_CAPTURE_FINGERPRINT_GESTURES} is set. *
* Note: The fingerprint sensor is used for authentication in critical use cases, * so services must carefully design their user's experience when performing gestures on the sensor. * When the sensor is in use by an app, for example, when authenticating or enrolling a user, * the sensor will not detect gestures. Services need to ensure that users understand when the * sensor is in-use for authentication to prevent users from authenticating unintentionally when * trying to interact with the service. They can use * {@link FingerprintGestureCallback#onGestureDetectionAvailabilityChanged(boolean)} to learn when * gesture detection becomes unavailable. *
* Multiple accessibility services may listen for fingerprint gestures simultaneously, so services * should provide a way for the user to disable the use of this feature so multiple services don't * conflict with each other. *
* {@see android.hardware.fingerprint.FingerprintManager#isHardwareDetected}
*/
public final class FingerprintGestureController {
/** Identifier for a swipe right on the fingerprint sensor */
public static final int FINGERPRINT_GESTURE_SWIPE_RIGHT = 0x00000001;
/** Identifier for a swipe left on the fingerprint sensor */
public static final int FINGERPRINT_GESTURE_SWIPE_LEFT = 0x00000002;
/** Identifier for a swipe up on the fingerprint sensor */
public static final int FINGERPRINT_GESTURE_SWIPE_UP = 0x00000004;
/** Identifier for a swipe down on the fingerprint sensor */
public static final int FINGERPRINT_GESTURE_SWIPE_DOWN = 0x00000008;
private static final String LOG_TAG = "FingerprintGestureController";
private final Object mLock = new Object();
private final IAccessibilityServiceConnection mAccessibilityServiceConnection;
private final ArrayMap