[native] Restore ServiceManager#getService() to return IBinder
This fixes a crash in 3p libraries.
A new API ServiceManager#getService2() has been introduced to
work with the Service enum type.
Bug: 354674329
Bug: 355187769
Test: atest servicemanager_test
Test: atest vm_accessor_test
Test: Run the demo app in b/354674329 and check it works
Change-Id: If1e0e9bee6dcd3cfceea69bea58ed5fbe431e81d
diff --git a/libs/binder/servicedispatcher.cpp b/libs/binder/servicedispatcher.cpp
index 201dfbc..be99065 100644
--- a/libs/binder/servicedispatcher.cpp
+++ b/libs/binder/servicedispatcher.cpp
@@ -118,7 +118,12 @@
class ServiceManagerProxyToNative : public android::os::BnServiceManager {
public:
ServiceManagerProxyToNative(const sp<android::os::IServiceManager>& impl) : mImpl(impl) {}
- android::binder::Status getService(const std::string&, android::os::Service*) override {
+ android::binder::Status getService(const std::string&,
+ android::sp<android::IBinder>*) override {
+ // We can't send BpBinder for regular binder over RPC.
+ return android::binder::Status::fromStatusT(android::INVALID_OPERATION);
+ }
+ android::binder::Status getService2(const std::string&, android::os::Service*) override {
// We can't send BpBinder for regular binder over RPC.
return android::binder::Status::fromStatusT(android::INVALID_OPERATION);
}