• 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 vintf::HalManifest * vm)14 vintf::Transport getTransportFromManifest(
15         const FQName &fqName, const std::string &instanceName,
16         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(DEBUG) << "getTransport: " << interfaceName << " is not a valid fully-qualified name.";
29         return vintf::Transport::EMPTY;
30     }
31     if (!fqName.hasVersion()) {
32         LOG(DEBUG) << "getTransport: " << fqName.string()
33                    << " does not specify a version. Using default transport.";
34         return vintf::Transport::EMPTY;
35     }
36     if (fqName.name().empty()) {
37         LOG(DEBUG) << "getTransport: " << fqName.string()
38                    << " does not specify an interface name. Using default transport.";
39         return vintf::Transport::EMPTY;
40     }
41 
42     vintf::Transport tr = getTransportFromManifest(fqName, instanceName,
43             vintf::VintfObject::GetFrameworkHalManifest());
44     if (tr != vintf::Transport::EMPTY) {
45         return tr;
46     }
47     tr = getTransportFromManifest(fqName, instanceName,
48             vintf::VintfObject::GetDeviceHalManifest());
49     if (tr != vintf::Transport::EMPTY) {
50         return tr;
51     }
52 
53     LOG(WARNING) << "getTransportFromManifest: Cannot find entry "
54                  << fqName.string()
55                  << " in either framework or device manifest, using default transport.";
56     return vintf::Transport::EMPTY;
57 }
58 
59 }  // hardware
60 }  // android
61