• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 #include <android-base/logging.h>
18 #include <hidl/HidlTransportSupport.h>
19 #include <utils/StrongPointer.h>
20 
21 #include <application.h>
22 #include <nos/CitadeldProxyClient.h>
23 
24 #include <AuthSecret.h>
25 
26 using ::android::OK;
27 using ::android::sp;
28 using ::android::status_t;
29 using ::android::hardware::configureRpcThreadpool;
30 using ::android::hardware::joinRpcThreadpool;
31 
32 using ::android::hardware::authsecret::AuthSecret;
33 
34 using ::nos::CitadeldProxyClient;
35 
main()36 int main() {
37     LOG(INFO) << "AuthSecret HAL service starting";
38 
39     // Connect to citadeld
40     CitadeldProxyClient citadeldProxy;
41     citadeldProxy.Open();
42     if (!citadeldProxy.IsOpen()) {
43         LOG(FATAL) << "Failed to open citadeld client";
44     }
45 
46     // This thread will become the only thread of the daemon
47     constexpr bool thisThreadWillJoinPool = true;
48     configureRpcThreadpool(1, thisThreadWillJoinPool);
49 
50     // Start the HAL service
51     sp<AuthSecret> authsecret = new AuthSecret(citadeldProxy);
52     const status_t status = authsecret->registerAsService();
53     if (status != OK) {
54       LOG(FATAL) << "Failed to register AuthSecret as a service (status: " << status << ")";
55     }
56 
57     joinRpcThreadpool();
58     return -1; // Should never be reached
59 }
60