Skip to content

Commit 9d1dfa0

Browse files
Skip logging error when service name doesn't match vintf format
VINTF services are expected to have a specific format for their names. We now build an AidlName for each service so we can check for them in the manifest files. In these cases we don't want to produce a log when the format doesn't match because these services are not all vintf services. Test: m Bug: 355053763 Change-Id: I76a12985495892809d3319963a9c020d60fd4084
1 parent 7bbb484 commit 9d1dfa0

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

cmds/servicemanager/ServiceManager.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ struct AidlName {
112112
std::string iface;
113113
std::string instance;
114114

115-
static bool fill(const std::string& name, AidlName* aname) {
115+
static bool fill(const std::string& name, AidlName* aname, bool logError) {
116116
size_t firstSlash = name.find('/');
117117
size_t lastDot = name.rfind('.', firstSlash);
118118
if (firstSlash == std::string::npos || lastDot == std::string::npos) {
119-
ALOGE("VINTF HALs require names in the format type/instance (e.g. "
120-
"some.package.foo.IFoo/default) but got: %s",
121-
name.c_str());
119+
if (logError) {
120+
ALOGE("VINTF HALs require names in the format type/instance (e.g. "
121+
"some.package.foo.IFoo/default) but got: %s",
122+
name.c_str());
123+
}
122124
return false;
123125
}
124126
aname->package = name.substr(0, lastDot);
@@ -151,7 +153,7 @@ static bool isVintfDeclared(const Access::CallingContext& ctx, const std::string
151153
}
152154

153155
AidlName aname;
154-
if (!AidlName::fill(name, &aname)) return false;
156+
if (!AidlName::fill(name, &aname, true)) return false;
155157

156158
bool found = forEachManifest([&](const ManifestWithDescription& mwd) {
157159
if (mwd.manifest->hasAidlInstance(aname.package, aname.iface, aname.instance)) {
@@ -209,7 +211,7 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name)
209211
}
210212

211213
AidlName aname;
212-
if (!AidlName::fill(name, &aname)) return std::nullopt;
214+
if (!AidlName::fill(name, &aname, true)) return std::nullopt;
213215

214216
std::optional<std::string> updatableViaApex;
215217

@@ -251,7 +253,7 @@ static std::vector<std::string> getVintfUpdatableNames(const std::string& apexNa
251253

252254
static std::optional<std::string> getVintfAccessorName(const std::string& name) {
253255
AidlName aname;
254-
if (!AidlName::fill(name, &aname)) return std::nullopt;
256+
if (!AidlName::fill(name, &aname, false)) return std::nullopt;
255257

256258
std::optional<std::string> accessor;
257259
forEachManifest([&](const ManifestWithDescription& mwd) {
@@ -270,7 +272,7 @@ static std::optional<std::string> getVintfAccessorName(const std::string& name)
270272

271273
static std::optional<ConnectionInfo> getVintfConnectionInfo(const std::string& name) {
272274
AidlName aname;
273-
if (!AidlName::fill(name, &aname)) return std::nullopt;
275+
if (!AidlName::fill(name, &aname, true)) return std::nullopt;
274276

275277
std::optional<std::string> ip;
276278
std::optional<uint64_t> port;

0 commit comments

Comments
 (0)