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

Commit 4dadff8b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add confirmation UI protocol to Keystore AIDL definition"

parents 7f1e49f2 7dacad8d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -243,6 +243,7 @@ java_library {
        "core/java/android/os/storage/IStorageEventListener.aidl",
        "core/java/android/os/storage/IStorageShutdownObserver.aidl",
        "core/java/android/os/storage/IObbActionListener.aidl",
        "core/java/android/security/IConfirmationPromptCallback.aidl",
        "core/java/android/security/IKeystoreService.aidl",
        "core/java/android/security/keymaster/IKeyAttestationApplicationIdProvider.aidl",
        "core/java/android/service/autofill/IAutoFillService.aidl",
+2 −1
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@ filegroup {
// only used by key_store_service
cc_library_shared {
    name: "libkeystore_aidl",
    srcs: ["android/security/IKeystoreService.aidl"],
    srcs: ["android/security/IKeystoreService.aidl",
           "android/security/IConfirmationPromptCallback.aidl"],
    aidl: {
        export_aidl_headers: true,
        include_dirs: [
+27 −0
Original line number Diff line number Diff line
/**
 * 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.security;

/**
 * This must be kept manually in sync with system/security/keystore until AIDL
 * can generate both Java and C++ bindings.
 *
 * @hide
 */
interface IConfirmationPromptCallback {
    oneway void onConfirmationPromptCompleted(in int result, in byte[] dataThatWasConfirmed);
}
+3 −0
Original line number Diff line number Diff line
@@ -81,4 +81,7 @@ interface IKeystoreService {
        in String wrappingKeyAlias, in byte[] maskingKey, in KeymasterArguments arguments,
        in long rootSid, in long fingerprintSid,
        out KeyCharacteristics characteristics);
    int presentConfirmationPrompt(IBinder listener, String promptText, in byte[] extraData,
        in String locale, in int uiOptionsAsFlags);
    int cancelConfirmationPrompt(IBinder listener);
}
+52 −0
Original line number Diff line number Diff line
@@ -731,6 +731,58 @@ public class KeyStore {
        }
    }

    // Keep in sync with confirmationui/1.0/types.hal.
    public static final int CONFIRMATIONUI_OK = 0;
    public static final int CONFIRMATIONUI_CANCELED = 1;
    public static final int CONFIRMATIONUI_ABORTED = 2;
    public static final int CONFIRMATIONUI_OPERATION_PENDING = 3;
    public static final int CONFIRMATIONUI_IGNORED = 4;
    public static final int CONFIRMATIONUI_SYSTEM_ERROR = 5;
    public static final int CONFIRMATIONUI_UNIMPLEMENTED = 6;
    public static final int CONFIRMATIONUI_UNEXPECTED = 7;
    public static final int CONFIRMATIONUI_UIERROR = 0x10000;
    public static final int CONFIRMATIONUI_UIERROR_MISSING_GLYPH = 0x10001;
    public static final int CONFIRMATIONUI_UIERROR_MESSAGE_TOO_LONG = 0x10002;
    public static final int CONFIRMATIONUI_UIERROR_MALFORMED_UTF8_ENCODING = 0x10003;

    /**
     * Requests keystore call into the confirmationui HAL to display a prompt.
     *
     * @param listener the binder to use for callbacks.
     * @param promptText the prompt to display.
     * @param extraData extra data / nonce from application.
     * @param locale the locale as a BCP 47 langauge tag.
     * @param uiOptionsAsFlags the UI options to use, as flags.
     * @return one of the {@code CONFIRMATIONUI_*} constants, for
     * example {@code KeyStore.CONFIRMATIONUI_OK}.
     */
    public int presentConfirmationPrompt(IBinder listener, String promptText, byte[] extraData,
                                         String locale, int uiOptionsAsFlags) {
        try {
            return mBinder.presentConfirmationPrompt(listener, promptText, extraData, locale,
                                                     uiOptionsAsFlags);
        } catch (RemoteException e) {
            Log.w(TAG, "Cannot connect to keystore", e);
            return CONFIRMATIONUI_SYSTEM_ERROR;
        }
    }

    /**
     * Requests keystore call into the confirmationui HAL to cancel displaying a prompt.
     *
     * @param listener the binder passed to the {@link #presentConfirmationPrompt} method.
     * @return one of the {@code CONFIRMATIONUI_*} constants, for
     * example {@code KeyStore.CONFIRMATIONUI_OK}.
     */
    public int cancelConfirmationPrompt(IBinder listener) {
        try {
            return mBinder.cancelConfirmationPrompt(listener);
        } catch (RemoteException e) {
            Log.w(TAG, "Cannot connect to keystore", e);
            return CONFIRMATIONUI_SYSTEM_ERROR;
        }
    }

    /**
     * Returns a {@link KeyStoreException} corresponding to the provided keystore/keymaster error
     * code.