diff options
author | David Zeuthen <zeuthen@google.com> | 2018-02-26 11:00:30 -0500 |
---|---|---|
committer | David Zeuthen <zeuthen@google.com> | 2018-02-26 11:00:30 -0500 |
commit | 1a49231d4a31d3a8a42ef345f03063852c19de2f (patch) | |
tree | 6dcf0f578a9401f094d0dbd47a39de46b5e97530 | |
parent | cee5f1213d41f352ac54b1f437e6aadca12e81a5 (diff) | |
download | security-1a49231d4a31d3a8a42ef345f03063852c19de2f.tar.gz |
Add isConfirmationPromptSupported() method.
This will be used by the android.security.ConfirmationDialog.isSupported() and
is intended so that apps can know ahead of time whether the device implements
the ConfirmationUI HAL.
Bug: 63928580
Test: Manually tested.
Change-Id: I6347824b4e2330a93b7a7ffd7cf5b206009a564e
-rw-r--r-- | keystore/binder/android/security/IKeystoreService.aidl | 1 | ||||
-rw-r--r-- | keystore/confirmation_manager.cpp | 13 | ||||
-rw-r--r-- | keystore/confirmation_manager.h | 3 | ||||
-rw-r--r-- | keystore/key_store_service.cpp | 4 | ||||
-rw-r--r-- | keystore/key_store_service.h | 1 |
5 files changed, 22 insertions, 0 deletions
diff --git a/keystore/binder/android/security/IKeystoreService.aidl b/keystore/binder/android/security/IKeystoreService.aidl index 738eb686..1c8f9266 100644 --- a/keystore/binder/android/security/IKeystoreService.aidl +++ b/keystore/binder/android/security/IKeystoreService.aidl @@ -84,4 +84,5 @@ interface IKeystoreService { int presentConfirmationPrompt(IBinder listener, String promptText, in byte[] extraData, in String locale, in int uiOptionsAsFlags); int cancelConfirmationPrompt(IBinder listener); + boolean isConfirmationPromptSupported(); } diff --git a/keystore/confirmation_manager.cpp b/keystore/confirmation_manager.cpp index d8c53784..acca3045 100644 --- a/keystore/confirmation_manager.cpp +++ b/keystore/confirmation_manager.cpp @@ -115,6 +115,19 @@ Status ConfirmationManager::cancelConfirmationPrompt(const sp<IBinder>& listener return Status::ok(); } +// Called by keystore main thread. +Status ConfirmationManager::isConfirmationPromptSupported(bool* aidl_return) { + sp<IConfirmationUI> confirmationUI = IConfirmationUI::tryGetService(); + if (confirmationUI == nullptr) { + ALOGW("Error getting confirmationUI service\n"); + *aidl_return = false; + return Status::ok(); + } + + *aidl_return = true; + return Status::ok(); +} + void ConfirmationManager::finalizeTransaction(ConfirmationResponseCode responseCode, hidl_vec<uint8_t> dataThatWasConfirmed, bool callAbortOnHal) { diff --git a/keystore/confirmation_manager.h b/keystore/confirmation_manager.h index 4bf4b8d6..b92dedaf 100644 --- a/keystore/confirmation_manager.h +++ b/keystore/confirmation_manager.h @@ -61,6 +61,9 @@ class ConfirmationManager : public android::hardware::hidl_death_recipient, Status cancelConfirmationPrompt(const android::sp<android::IBinder>& listener, int32_t* aidl_return); + // Checks if the confirmationUI HAL is available. + Status isConfirmationPromptSupported(bool* aidl_return); + // Gets the latest confirmation token received from the ConfirmationUI HAL. hidl_vec<uint8_t> getLatestConfirmationToken(); diff --git a/keystore/key_store_service.cpp b/keystore/key_store_service.cpp index d59966f4..d808c57f 100644 --- a/keystore/key_store_service.cpp +++ b/keystore/key_store_service.cpp @@ -1787,6 +1787,10 @@ Status KeyStoreService::cancelConfirmationPrompt(const sp<IBinder>& listener, return mConfirmationManager->cancelConfirmationPrompt(listener, aidl_return); } +Status KeyStoreService::isConfirmationPromptSupported(bool* aidl_return) { + return mConfirmationManager->isConfirmationPromptSupported(aidl_return); +} + /** * Prune the oldest pruneable operation. */ diff --git a/keystore/key_store_service.h b/keystore/key_store_service.h index ce809f87..70a56ca3 100644 --- a/keystore/key_store_service.h +++ b/keystore/key_store_service.h @@ -175,6 +175,7 @@ class KeyStoreService : public android::security::BnKeystoreService, ::android::binder::Status cancelConfirmationPrompt(const ::android::sp<::android::IBinder>& listener, int32_t* _aidl_return) override; + ::android::binder::Status isConfirmationPromptSupported(bool* _aidl_return) override; private: static const int32_t UID_SELF = -1; |