• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define LOG_TAG "hwservicemanager"
2 //#define LOG_NDEBUG 0
3 
4 #include "Vintf.h"
5 
6 #include <android-base/logging.h>
7 #include <hidl-util/FQName.h>
8 #include <vintf/parse_string.h>
9 #include <vintf/VintfObject.h>
10 
11 namespace android {
12 namespace hardware {
13 
getTransportFromManifest(const FQName & fqName,const std::string & instanceName,const std::shared_ptr<const vintf::HalManifest> & vm)14 vintf::Transport getTransportFromManifest(
15         const FQName &fqName, const std::string &instanceName,
16         const std::shared_ptr<const vintf::HalManifest>& vm) {
17     if (vm == nullptr) {
18         return vintf::Transport::EMPTY;
19     }
20     return vm->getTransport(fqName.package(),
21             vintf::Version{fqName.getPackageMajorVersion(), fqName.getPackageMinorVersion()},
22             fqName.name(), instanceName);
23 }
24 
getTransport(const std::string & interfaceName,const std::string & instanceName)25 vintf::Transport getTransport(const std::string &interfaceName, const std::string &instanceName) {
26     FQName fqName(interfaceName);
27     if (!fqName.isValid()) {
28         LOG(ERROR) << __FUNCTION__ << ": " << interfaceName
29                    << " is not a valid fully-qualified name ";
30         return vintf::Transport::EMPTY;
31     }
32     if (!fqName.hasVersion()) {
33         LOG(ERROR) << __FUNCTION__ << ": " << fqName.string()
34                    << " does not specify a version.";
35         return vintf::Transport::EMPTY;
36     }
37     if (fqName.name().empty()) {
38         LOG(ERROR) << __FUNCTION__ << ": " << fqName.string()
39                    << " does not specify an interface name.";
40         return vintf::Transport::EMPTY;
41     }
42 
43     vintf::Transport tr = getTransportFromManifest(fqName, instanceName,
44             vintf::VintfObject::GetFrameworkHalManifest());
45     if (tr != vintf::Transport::EMPTY) {
46         return tr;
47     }
48     tr = getTransportFromManifest(fqName, instanceName,
49             vintf::VintfObject::GetDeviceHalManifest());
50     if (tr != vintf::Transport::EMPTY) {
51         return tr;
52     }
53 
54     LOG(WARNING) << __FUNCTION__ << ": Cannot find entry "
55                  << fqName.string() << "/" << instanceName
56                  << " in either framework or device manifest.";
57     return vintf::Transport::EMPTY;
58 }
59 
60 }  // hardware
61 }  // android
62