summaryrefslogtreecommitdiff
path: root/cmds/servicemanager/ServiceManager.cpp
diff options
context:
space:
mode:
author Alice Wang <aliceywang@google.com> 2025-01-02 11:53:05 +0000
committer Alice Wang <aliceywang@google.com> 2025-01-08 08:58:39 +0000
commit2b61344ddd35ceb216a836157a10769cbfaac0fa (patch)
tree5511a7b748d718e125d1b65c1ed45b2440ac7499 /cmds/servicemanager/ServiceManager.cpp
parent1656f6ba8334eeba3823f0669eccd07a464d1654 (diff)
[native] Restore ServiceManager#checkService() to return IBinder
This fixes crashes in 3p libraries. A new API ServiceManager#checkService2() has been introduced to work with the Service enum type. Bug: 387175643 Test: atest servicemanager_test Change-Id: I647f4a11469717c54111afab562a0be2d5260044
Diffstat (limited to 'cmds/servicemanager/ServiceManager.cpp')
-rw-r--r--cmds/servicemanager/ServiceManager.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp
index 38a125bb54..59c4d53bc0 100644
--- a/cmds/servicemanager/ServiceManager.cpp
+++ b/cmds/servicemanager/ServiceManager.cpp
@@ -410,7 +410,16 @@ Status ServiceManager::getService2(const std::string& name, os::Service* outServ
return Status::ok();
}
-Status ServiceManager::checkService(const std::string& name, os::Service* outService) {
+Status ServiceManager::checkService(const std::string& name, sp<IBinder>* outBinder) {
+ SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS(
+ PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str())));
+
+ *outBinder = tryGetBinder(name, false).service;
+ // returns ok regardless of result for legacy reasons
+ return Status::ok();
+}
+
+Status ServiceManager::checkService2(const std::string& name, os::Service* outService) {
SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS(
PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str())));