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
diff --git a/keystore/binder/android/security/IKeystoreService.aidl b/keystore/binder/android/security/IKeystoreService.aidl
index 738eb68..1c8f926 100644
--- a/keystore/binder/android/security/IKeystoreService.aidl
+++ b/keystore/binder/android/security/IKeystoreService.aidl
@@ -84,4 +84,5 @@
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 d8c5378..acca304 100644
--- a/keystore/confirmation_manager.cpp
+++ b/keystore/confirmation_manager.cpp
@@ -115,6 +115,19 @@
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 4bf4b8d..b92deda 100644
--- a/keystore/confirmation_manager.h
+++ b/keystore/confirmation_manager.h
@@ -61,6 +61,9 @@
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 d59966f..d808c57 100644
--- a/keystore/key_store_service.cpp
+++ b/keystore/key_store_service.cpp
@@ -1787,6 +1787,10 @@
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 ce809f8..70a56ca 100644
--- a/keystore/key_store_service.h
+++ b/keystore/key_store_service.h
@@ -175,6 +175,7 @@
::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;