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 <aidl/Vintf.h> 18 19 #include <android-base/logging.h> 20 #include <vintf/VintfObject.h> 21 22 namespace android { 23 24 std::vector<std::string> getAidlHalInstanceNames(const std::string& descriptor) { 25 size_t lastDot = descriptor.rfind('.'); 26 CHECK(lastDot != std::string::npos) << "Invalid descriptor: " << descriptor; 27 const std::string package = descriptor.substr(0, lastDot); 28 const std::string iface = descriptor.substr(lastDot + 1); 29 30 std::vector<std::string> ret; 31 32 auto deviceManifest = vintf::VintfObject::GetDeviceHalManifest(); 33 for (const std::string& instance : deviceManifest->getAidlInstances(package, iface)) { 34 ret.push_back(descriptor + "/" + instance); 35 } 36 37 auto frameworkManifest = vintf::VintfObject::GetFrameworkHalManifest(); 38 for (const std::string& instance : frameworkManifest->getAidlInstances(package, iface)) { 39 ret.push_back(descriptor + "/" + instance); 40 } 41 42 return ret; 43 } 44 45 std::vector<std::string> getAidlHalInstanceNames(const String16& descriptor) { 46 return getAidlHalInstanceNames(String8(descriptor).c_str()); 47 } 48 49 } // namespace android 50