Merge "Get rid of manually created IKeystoreService in gatekeeper.cpp"
diff --git a/gatekeeperd/gatekeeperd.cpp b/gatekeeperd/gatekeeperd.cpp
index 61c8804..5781765 100644
--- a/gatekeeperd/gatekeeperd.cpp
+++ b/gatekeeperd/gatekeeperd.cpp
@@ -25,14 +25,15 @@
#include <unistd.h>
#include <memory>
+#include <android/security/IKeystoreService.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/PermissionCache.h>
#include <gatekeeper/password_handle.h> // for password_handle_t
#include <hardware/gatekeeper.h>
#include <hardware/hw_auth_token.h>
-#include <keystore/IKeystoreService.h>
#include <keystore/keystore.h> // For error code
+#include <keystore/keystore_return_types.h>
#include <log/log.h>
#include <utils/Log.h>
#include <utils/String16.h>
@@ -315,11 +316,15 @@
// TODO: cache service?
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder = sm->getService(String16("android.security.keystore"));
- sp<IKeystoreService> service = interface_cast<IKeystoreService>(binder);
+ sp<security::IKeystoreService> service =
+ interface_cast<security::IKeystoreService>(binder);
if (service != NULL) {
- auto ret = service->addAuthToken(*auth_token, *auth_token_length);
- if (!ret.isOk()) {
- ALOGE("Failure sending auth token to KeyStore: %" PRId32, int32_t(ret));
+ std::vector<uint8_t> auth_token_vector(*auth_token,
+ (*auth_token) + *auth_token_length);
+ int result = 0;
+ auto binder_result = service->addAuthToken(auth_token_vector, &result);
+ if (!binder_result.isOk() || !keystore::KeyStoreServiceReturnCode(result).isOk()) {
+ ALOGE("Failure sending auth token to KeyStore: %" PRId32, result);
}
} else {
ALOGE("Unable to communicate with KeyStore");