summaryrefslogtreecommitdiff
path: root/libs/binder/IServiceManager.cpp
diff options
context:
space:
mode:
author Devin Moore <devinmoore@google.com> 2021-09-09 22:36:33 +0000
committer Devin Moore <devinmoore@google.com> 2021-09-21 21:34:52 +0000
commit5e4c2f1f0958d29b549f08e2c8e7ee7f5b493384 (patch)
tree8c993bed71975a43a342291febd77d5e687245e7 /libs/binder/IServiceManager.cpp
parent20f5a270658bcdff7a4cc4f9f0059c572ca123eb (diff)
Add getConnectionInfo API to service manager
This gets connection info from the vintf manifest for AIDL hals that report it. The hals will have new "ip" and "port" fields in their entries if they are serving the interface from a remote device at that ip address/port combo. Test: tested the IServiceManager API with an internal POC using a remote HAL Test: atest binderStabilityTest Bug: 198207801 Change-Id: I334bebe62afb40e9710b57257f95e37a9c2b8226
Diffstat (limited to 'libs/binder/IServiceManager.cpp')
-rw-r--r--libs/binder/IServiceManager.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index 6e318ea478..aff9e0d48d 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -78,6 +78,7 @@ public:
bool isDeclared(const String16& name) override;
Vector<String16> getDeclaredInstances(const String16& interface) override;
std::optional<String16> updatableViaApex(const String16& name) override;
+ std::optional<IServiceManager::ConnectionInfo> getConnectionInfo(const String16& name) override;
// for legacy ABI
const String16& getInterfaceDescriptor() const override {
@@ -426,6 +427,21 @@ std::optional<String16> ServiceManagerShim::updatableViaApex(const String16& nam
return declared ? std::optional<String16>(String16(declared.value().c_str())) : std::nullopt;
}
+std::optional<IServiceManager::ConnectionInfo> ServiceManagerShim::getConnectionInfo(
+ const String16& name) {
+ std::optional<os::ConnectionInfo> connectionInfo;
+ if (Status status =
+ mTheRealServiceManager->getConnectionInfo(String8(name).c_str(), &connectionInfo);
+ !status.isOk()) {
+ ALOGW("Failed to get ConnectionInfo for %s: %s", String8(name).c_str(),
+ status.toString8().c_str());
+ }
+ return connectionInfo.has_value()
+ ? std::make_optional<IServiceManager::ConnectionInfo>(
+ {connectionInfo->ipAddress, static_cast<unsigned int>(connectionInfo->port)})
+ : std::nullopt;
+}
+
#ifndef __ANDROID__
// ServiceManagerShim for host. Implements the old libbinder android::IServiceManager API.
// The internal implementation of the AIDL interface android::os::IServiceManager calls into