blob: 78f4fbc4b6d4d63346eda188a2e72fb41b6c88a1 [file] [log] [blame]
David Zeuthen81603152020-02-11 22:04:24 -05001/*
2 * Copyright 2019, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "android.hardware.identity-service"
18
19#include <android-base/logging.h>
20#include <android/binder_manager.h>
21#include <android/binder_process.h>
22
23#include "IdentityCredentialStore.h"
24
David Zeuthen630de2a2020-05-11 14:04:54 -040025#include "FakeSecureHardwareProxy.h"
26
27using ::android::sp;
David Zeuthena8ed82c2020-05-08 10:03:28 -040028using ::android::base::InitLogging;
29using ::android::base::StderrLogger;
30
David Zeuthen630de2a2020-05-11 14:04:54 -040031using ::aidl::android::hardware::identity::IdentityCredentialStore;
32using ::android::hardware::identity::FakeSecureHardwareProxyFactory;
33using ::android::hardware::identity::SecureHardwareProxyFactory;
David Zeuthen81603152020-02-11 22:04:24 -050034
David Zeuthena8ed82c2020-05-08 10:03:28 -040035int main(int /*argc*/, char* argv[]) {
Seth Moore5502a1f2022-01-25 22:44:24 +000036 InitLogging(argv, StderrLogger);
David Zeuthena8ed82c2020-05-08 10:03:28 -040037
David Zeuthen630de2a2020-05-11 14:04:54 -040038 sp<SecureHardwareProxyFactory> hwProxyFactory = new FakeSecureHardwareProxyFactory();
39
David Zeuthen81603152020-02-11 22:04:24 -050040 ABinderProcess_setThreadPoolMaxThreadCount(0);
41 std::shared_ptr<IdentityCredentialStore> store =
Seth Moorebe321132022-01-25 22:44:24 +000042 ndk::SharedRefBase::make<IdentityCredentialStore>(hwProxyFactory);
David Zeuthen81603152020-02-11 22:04:24 -050043
44 const std::string instance = std::string() + IdentityCredentialStore::descriptor + "/default";
David Zeuthen81603152020-02-11 22:04:24 -050045 binder_status_t status = AServiceManager_addService(store->asBinder().get(), instance.c_str());
Steven Morelandffb03992021-12-14 01:45:47 +000046 CHECK_EQ(status, STATUS_OK);
David Zeuthen81603152020-02-11 22:04:24 -050047
48 ABinderProcess_joinThreadPool();
49 return EXIT_FAILURE; // should not reach
50}