blob: 1ff52f9773936cbdd90b2a0a034a90e26a7d2dd8 [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;
Seth Moore3fc3c4c2022-01-25 23:04:37 +000029using ::android::base::LogdLogger;
30using ::android::base::LogId;
31using ::android::base::LogSeverity;
David Zeuthena8ed82c2020-05-08 10:03:28 -040032using ::android::base::StderrLogger;
33
David Zeuthen630de2a2020-05-11 14:04:54 -040034using ::aidl::android::hardware::identity::IdentityCredentialStore;
35using ::android::hardware::identity::FakeSecureHardwareProxyFactory;
36using ::android::hardware::identity::SecureHardwareProxyFactory;
David Zeuthen81603152020-02-11 22:04:24 -050037
Seth Moore3fc3c4c2022-01-25 23:04:37 +000038void ComboLogger(LogId id, LogSeverity severity, const char* tag, const char* file,
39 unsigned int line, const char* message) {
40 StderrLogger(id, severity, tag, file, line, message);
41
42 static LogdLogger logdLogger;
43 logdLogger(id, severity, tag, file, line, message);
44}
45
David Zeuthena8ed82c2020-05-08 10:03:28 -040046int main(int /*argc*/, char* argv[]) {
Seth Moore3fc3c4c2022-01-25 23:04:37 +000047 InitLogging(argv, ComboLogger);
David Zeuthena8ed82c2020-05-08 10:03:28 -040048
David Zeuthen630de2a2020-05-11 14:04:54 -040049 sp<SecureHardwareProxyFactory> hwProxyFactory = new FakeSecureHardwareProxyFactory();
50
David Zeuthen81603152020-02-11 22:04:24 -050051 ABinderProcess_setThreadPoolMaxThreadCount(0);
52 std::shared_ptr<IdentityCredentialStore> store =
Seth Moorebe321132022-01-25 22:44:24 +000053 ndk::SharedRefBase::make<IdentityCredentialStore>(hwProxyFactory);
David Zeuthen81603152020-02-11 22:04:24 -050054
55 const std::string instance = std::string() + IdentityCredentialStore::descriptor + "/default";
David Zeuthen81603152020-02-11 22:04:24 -050056 binder_status_t status = AServiceManager_addService(store->asBinder().get(), instance.c_str());
Steven Morelandffb03992021-12-14 01:45:47 +000057 CHECK_EQ(status, STATUS_OK);
David Zeuthen81603152020-02-11 22:04:24 -050058
59 ABinderProcess_joinThreadPool();
60 return EXIT_FAILURE; // should not reach
61}