xref: /aosp_15_r20/system/gsid/libgsid.cpp (revision 4e2b41f188908a2ae9d9a2089f1f10779d080021)
1*4e2b41f1SAndroid Build Coastguard Worker //
2*4e2b41f1SAndroid Build Coastguard Worker // Copyright (C) 2019 The Android Open Source Project
3*4e2b41f1SAndroid Build Coastguard Worker //
4*4e2b41f1SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
5*4e2b41f1SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
6*4e2b41f1SAndroid Build Coastguard Worker // You may obtain a copy of the License at
7*4e2b41f1SAndroid Build Coastguard Worker //
8*4e2b41f1SAndroid Build Coastguard Worker //      http://www.apache.org/licenses/LICENSE-2.0
9*4e2b41f1SAndroid Build Coastguard Worker //
10*4e2b41f1SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
11*4e2b41f1SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
12*4e2b41f1SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4e2b41f1SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
14*4e2b41f1SAndroid Build Coastguard Worker // limitations under the License.
15*4e2b41f1SAndroid Build Coastguard Worker //
16*4e2b41f1SAndroid Build Coastguard Worker 
17*4e2b41f1SAndroid Build Coastguard Worker #include <android-base/logging.h>
18*4e2b41f1SAndroid Build Coastguard Worker #include <android/gsi/IGsiService.h>
19*4e2b41f1SAndroid Build Coastguard Worker #include <binder/IServiceManager.h>
20*4e2b41f1SAndroid Build Coastguard Worker #include <libgsi/libgsid.h>
21*4e2b41f1SAndroid Build Coastguard Worker 
22*4e2b41f1SAndroid Build Coastguard Worker namespace android {
23*4e2b41f1SAndroid Build Coastguard Worker namespace gsi {
24*4e2b41f1SAndroid Build Coastguard Worker 
25*4e2b41f1SAndroid Build Coastguard Worker using android::sp;
26*4e2b41f1SAndroid Build Coastguard Worker 
GetGsiService()27*4e2b41f1SAndroid Build Coastguard Worker sp<IGsiService> GetGsiService() {
28*4e2b41f1SAndroid Build Coastguard Worker     auto sm = android::defaultServiceManager();
29*4e2b41f1SAndroid Build Coastguard Worker     auto name = android::String16(kGsiServiceName);
30*4e2b41f1SAndroid Build Coastguard Worker     static android::sp<android::IBinder> res = sm->waitForService(name);
31*4e2b41f1SAndroid Build Coastguard Worker     if (res) {
32*4e2b41f1SAndroid Build Coastguard Worker         return android::interface_cast<IGsiService>(res);
33*4e2b41f1SAndroid Build Coastguard Worker     }
34*4e2b41f1SAndroid Build Coastguard Worker     LOG(ERROR) << "Unable to GetGsiService";
35*4e2b41f1SAndroid Build Coastguard Worker     return nullptr;
36*4e2b41f1SAndroid Build Coastguard Worker }
37*4e2b41f1SAndroid Build Coastguard Worker 
38*4e2b41f1SAndroid Build Coastguard Worker }  // namespace gsi
39*4e2b41f1SAndroid Build Coastguard Worker }  // namespace android
40