• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 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 #include <string>
18 
19 #include <android-base/logging.h>
20 
21 #include "../parser.h"
22 #include "../service.h"
23 #include "../service_list.h"
24 #include "../service_parser.h"
25 #include "include/init-test-utils/service_utils.h"
26 
27 namespace android {
28 namespace init {
29 
GetOnDeviceServiceInterfacesMap()30 android::base::Result<ServiceInterfacesMap> GetOnDeviceServiceInterfacesMap() {
31     ServiceList& service_list = ServiceList::GetInstance();
32     Parser parser;
33     parser.AddSectionParser("service",
34                             std::make_unique<ServiceParser>(&service_list, nullptr, std::nullopt));
35     for (const auto& location : {
36                  "/init.rc",
37                  "/system/etc/init",
38                  "/system_ext/etc/init",
39                  "/product/etc/init",
40                  "/odm/etc/init",
41                  "/vendor/etc/init",
42          }) {
43         parser.ParseConfig(location);
44     }
45 
46     ServiceInterfacesMap result;
47     for (const auto& service : service_list) {
48         // Create an entry for all services, including services that may not
49         // have any declared interfaces.
50         result[service->name()] = service->interfaces();
51     }
52     return result;
53 }
54 
55 }  // namespace init
56 }  // namespace android
57