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

Commit 568d3293 authored by joshmccloskey's avatar joshmccloskey Committed by Kevin Chyn
Browse files

Removing old confirm device credential logic

Test: Verified that confirm device credential still works
in the biometricpromptdemo app
Bug: 140128468
Change-Id: I28fc3c0dc16677ad953284ffa9670d7abd34cd40
parent b93899a4
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -86,12 +86,6 @@ public class KeyguardManager {
    public static final String ACTION_CONFIRM_FRP_CREDENTIAL =
            "android.app.action.CONFIRM_FRP_CREDENTIAL";

    /**
     * @hide
     */
    public static final String EXTRA_BIOMETRIC_PROMPT_BUNDLE =
            "android.app.extra.BIOMETRIC_PROMPT_BUNDLE";

    /**
     * A CharSequence dialog title to show to the user when used with a
     * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}.
+0 −50
Original line number Diff line number Diff line
@@ -201,55 +201,5 @@ public class BiometricManager {
        }
    }

    /**
     * TODO(b/123378871): Remove when moved.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void onConfirmDeviceCredentialSuccess() {
        if (mService != null) {
            try {
                mService.onConfirmDeviceCredentialSuccess();
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            Slog.w(TAG, "onConfirmDeviceCredentialSuccess(): Service not connected");
        }
    }

    /**
     * TODO(b/123378871): Remove when moved.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void onConfirmDeviceCredentialError(int error, String message) {
        if (mService != null) {
            try {
                mService.onConfirmDeviceCredentialError(error, message);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            Slog.w(TAG, "onConfirmDeviceCredentialError(): Service not connected");
        }
    }

    /**
     * TODO(b/123378871): Remove when moved.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void registerCancellationCallback(IBiometricConfirmDeviceCredentialCallback callback) {
        if (mService != null) {
            try {
                mService.registerCancellationCallback(callback);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            Slog.w(TAG, "registerCancellationCallback(): Service not connected");
        }
    }
}
+6 −27
Original line number Diff line number Diff line
@@ -82,11 +82,6 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
     * @hide
     */
    public static final String KEY_ALLOW_DEVICE_CREDENTIAL = "allow_device_credential";
    /**
     * @hide
     */
    public static final String KEY_FROM_CONFIRM_DEVICE_CREDENTIAL
            = "from_confirm_device_credential";

    /**
     * Error/help message will show for this amount of time.
@@ -297,17 +292,6 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
            return this;
        }

        /**
         * TODO(123378871): Remove when moved.
         * @return
         * @hide
         */
        @RequiresPermission(USE_BIOMETRIC_INTERNAL)
        @NonNull public Builder setFromConfirmDeviceCredential() {
            mBundle.putBoolean(KEY_FROM_CONFIRM_DEVICE_CREDENTIAL, true);
            return this;
        }

        /**
         * Creates a {@link BiometricPrompt}.
         * @return a {@link BiometricPrompt}
@@ -532,8 +516,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
    public void authenticateUser(@NonNull CancellationSignal cancel,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AuthenticationCallback callback,
            int userId,
            IBiometricConfirmDeviceCredentialCallback confirmDeviceCredentialCallback) {
            int userId) {
        if (cancel == null) {
            throw new IllegalArgumentException("Must supply a cancellation signal");
        }
@@ -543,8 +526,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        if (callback == null) {
            throw new IllegalArgumentException("Must supply a callback");
        }
        authenticateInternal(null /* crypto */, cancel, executor, callback, userId,
                confirmDeviceCredentialCallback);
        authenticateInternal(null /* crypto */, cancel, executor, callback, userId);
    }

    /**
@@ -595,8 +577,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        if (mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL)) {
            throw new IllegalArgumentException("Device credential not supported with crypto");
        }
        authenticateInternal(crypto, cancel, executor, callback, mContext.getUserId(),
                null /* confirmDeviceCredentialCallback */);
        authenticateInternal(crypto, cancel, executor, callback, mContext.getUserId());
    }

    /**
@@ -638,8 +619,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        if (callback == null) {
            throw new IllegalArgumentException("Must supply a callback");
        }
        authenticateInternal(null /* crypto */, cancel, executor, callback, mContext.getUserId(),
                null /* confirmDeviceCredentialCallback */);
        authenticateInternal(null /* crypto */, cancel, executor, callback, mContext.getUserId());
    }

    private void cancelAuthentication() {
@@ -656,8 +636,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
            @NonNull CancellationSignal cancel,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AuthenticationCallback callback,
            int userId,
            IBiometricConfirmDeviceCredentialCallback confirmDeviceCredentialCallback) {
            int userId) {
        try {
            if (cancel.isCanceled()) {
                Log.w(TAG, "Authentication already canceled");
@@ -672,7 +651,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
            final long sessionId = crypto != null ? crypto.getOpId() : 0;
            if (BiometricManager.hasBiometrics(mContext)) {
                mService.authenticate(mToken, sessionId, userId, mBiometricServiceReceiver,
                        mContext.getOpPackageName(), mBundle, confirmDeviceCredentialCallback);
                        mContext.getOpPackageName(), mBundle);
            } else {
                mExecutor.execute(() -> {
                    callback.onAuthenticationError(BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT,
+0 −26
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.hardware.biometrics;

/**
 * Communication channel between ConfirmDeviceCredential / ConfirmLock* and BiometricService.
 * @hide
 */
interface IBiometricConfirmDeviceCredentialCallback {
    // Invoked when authentication should be canceled.
    oneway void cancel();
}
 No newline at end of file
+1 −16
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.hardware.biometrics;

import android.os.Bundle;
import android.hardware.biometrics.IBiometricConfirmDeviceCredentialCallback;
import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback;
import android.hardware.biometrics.IBiometricServiceReceiver;

@@ -31,10 +30,8 @@ import android.hardware.biometrics.IBiometricServiceReceiver;
interface IBiometricService {
    // Requests authentication. The service choose the appropriate biometric to use, and show
    // the corresponding BiometricDialog.
    // TODO(b/123378871): Remove callback when moved.
    void authenticate(IBinder token, long sessionId, int userId,
            IBiometricServiceReceiver receiver, String opPackageName, in Bundle bundle,
            IBiometricConfirmDeviceCredentialCallback callback);
            IBiometricServiceReceiver receiver, String opPackageName, in Bundle bundle);

    // Cancel authentication for the given sessionId
    void cancelAuthentication(IBinder token, String opPackageName);
@@ -57,16 +54,4 @@ interface IBiometricService {

    // Reset the lockout when user authenticates with strong auth (e.g. PIN, pattern or password)
    void resetLockout(in byte [] token);

    // TODO(b/123378871): Remove when moved.
    // CDCA needs to send results to BiometricService if it was invoked using BiometricPrompt's
    // setAllowDeviceCredential method, since there's no way for us to intercept onActivityResult.
    // CDCA is launched from BiometricService (startActivityAsUser) instead of *ForResult.
    void onConfirmDeviceCredentialSuccess();
    // TODO(b/123378871): Remove when moved.
    void onConfirmDeviceCredentialError(int error, String message);
    // TODO(b/123378871): Remove when moved.
    // When ConfirmLock* is invoked from BiometricPrompt, it needs to register a callback so that
    // it can receive the cancellation signal.
    void registerCancellationCallback(IBiometricConfirmDeviceCredentialCallback callback);
}
Loading