Port credstore to IdentityCredential AIDL.

Bug: 111446262
Test: atest android.security.identity.cts
Test: VtsHalIdentityTargetTest
Test: android.hardware.identity-support-lib-test
Change-Id: I338b35f57f2bb7345c3f8f0c608c7a6213a0dc6b
diff --git a/identity/CredentialStoreFactory.cpp b/identity/CredentialStoreFactory.cpp
index 947adf3..5c3bf36 100644
--- a/identity/CredentialStoreFactory.cpp
+++ b/identity/CredentialStoreFactory.cpp
@@ -19,28 +19,29 @@
 #include <android-base/logging.h>
 
 #include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
 
-#include "CredentialStore.h"
+//#include "CredentialStore.h"
 #include "CredentialStoreFactory.h"
 
 namespace android {
 namespace security {
 namespace identity {
 
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::identity::V1_0::IIdentityCredentialStore;
-using ::android::hardware::identity::V1_0::Result;
-using ::android::hardware::identity::V1_0::ResultCode;
+using ::android::hardware::identity::IIdentityCredentialStore;
 
 CredentialStoreFactory::CredentialStoreFactory(const std::string& dataPath) : dataPath_(dataPath) {}
 
 CredentialStoreFactory::~CredentialStoreFactory() {}
 
-CredentialStore* CredentialStoreFactory::createCredentialStore(const string& serviceName) {
-    sp<IIdentityCredentialStore> hal = IIdentityCredentialStore::tryGetService(serviceName);
+CredentialStore* CredentialStoreFactory::createCredentialStore(const string& instanceName) {
+    String16 serviceName =
+        IIdentityCredentialStore::descriptor + String16("/") + String16(instanceName.c_str());
+    sp<IIdentityCredentialStore> hal =
+        android::waitForDeclaredService<IIdentityCredentialStore>(serviceName);
     if (hal.get() == nullptr) {
-        LOG(ERROR) << "Error get hal for store with service name '" << serviceName << "'";
+        LOG(ERROR) << "Error getting HAL for IdentityCredentialStore store with service name '"
+                   << serviceName << "'";
         return nullptr;
     }
 
@@ -51,7 +52,6 @@
         delete store;
         return nullptr;
     }
-
     return store;
 }