Loading cmds/servicemanager/ServiceManager.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -165,7 +165,7 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi #endif // !VENDORSERVICEMANAGER #endif // !VENDORSERVICEMANAGER // implicitly unlinked when the binder is removed // implicitly unlinked when the binder is removed if (OK != binder->linkToDeath(this)) { if (binder->remoteBinder() != nullptr && binder->linkToDeath(this) != OK) { LOG(ERROR) << "Could not linkToDeath when adding " << name; LOG(ERROR) << "Could not linkToDeath when adding " << name; return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE); return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE); } } Loading cmds/servicemanager/main.cpp +8 −3 Original line number Original line Diff line number Diff line Loading @@ -23,11 +23,12 @@ #include "Access.h" #include "Access.h" #include "ServiceManager.h" #include "ServiceManager.h" using ::android::sp; using ::android::Access; using ::android::ProcessState; using ::android::IPCThreadState; using ::android::IPCThreadState; using ::android::ProcessState; using ::android::ServiceManager; using ::android::ServiceManager; using ::android::Access; using ::android::os::IServiceManager; using ::android::sp; int main(int argc, char** argv) { int main(int argc, char** argv) { if (argc > 2) { if (argc > 2) { Loading @@ -41,6 +42,10 @@ int main(int argc, char** argv) { ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY); ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY); sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>()); sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>()); if (!manager->addService("manager", manager, false /*allowIsolated*/, IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk()) { LOG(ERROR) << "Could not self register servicemanager"; } IPCThreadState::self()->setTheContextObject(manager); IPCThreadState::self()->setTheContextObject(manager); ps->becomeContextManager(nullptr, nullptr); ps->becomeContextManager(nullptr, nullptr); Loading libs/binder/Android.bp +13 −0 Original line number Original line Diff line number Diff line Loading @@ -164,3 +164,16 @@ filegroup { ], ], path: "aidl", path: "aidl", } } aidl_interface { name: "libbinder_aidl_test_stub", local_include_dir: "aidl", srcs: [":libbinder_aidl"], visibility: [":__subpackages__"], vendor_available: true, backend: { java: { enabled: false, }, }, } libs/binder/ndk/test/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,7 @@ cc_test { static_libs: [ static_libs: [ "IBinderVendorDoubleLoadTest-cpp", "IBinderVendorDoubleLoadTest-cpp", "IBinderVendorDoubleLoadTest-ndk_platform", "IBinderVendorDoubleLoadTest-ndk_platform", "libbinder_aidl_test_stub-ndk_platform", ], ], shared_libs: [ shared_libs: [ "libbase", "libbase", Loading libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp +19 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <BnBinderVendorDoubleLoadTest.h> #include <BnBinderVendorDoubleLoadTest.h> #include <aidl/BnBinderVendorDoubleLoadTest.h> #include <aidl/BnBinderVendorDoubleLoadTest.h> #include <aidl/android/os/IServiceManager.h> #include <android-base/logging.h> #include <android-base/logging.h> #include <android-base/properties.h> #include <android-base/properties.h> #include <android-base/strings.h> #include <android-base/strings.h> Loading Loading @@ -109,6 +110,24 @@ TEST(DoubleBinder, CallIntoNdk) { } } } } TEST(DoubleBinder, CallIntoSystemStabilityNdk) { // picking an arbitrary system service SpAIBinder binder = SpAIBinder(AServiceManager_checkService("manager")); ASSERT_NE(nullptr, binder.get()); // can make stable transaction to system server EXPECT_EQ(STATUS_OK, AIBinder_ping(binder.get())); using aidl::android::os::IServiceManager; std::shared_ptr<IServiceManager> manager = IServiceManager::fromBinder(binder); ASSERT_NE(nullptr, manager.get()); std::vector<std::string> services; ASSERT_EQ( STATUS_BAD_TYPE, manager->listServices(IServiceManager::DUMP_FLAG_PRIORITY_ALL, &services).getStatus()); } void initDrivers() { void initDrivers() { // Explicitly instantiated with the same driver that system would use. // Explicitly instantiated with the same driver that system would use. // __ANDROID_VNDK__ right now uses /dev/vndbinder by default. // __ANDROID_VNDK__ right now uses /dev/vndbinder by default. Loading Loading
cmds/servicemanager/ServiceManager.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -165,7 +165,7 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi #endif // !VENDORSERVICEMANAGER #endif // !VENDORSERVICEMANAGER // implicitly unlinked when the binder is removed // implicitly unlinked when the binder is removed if (OK != binder->linkToDeath(this)) { if (binder->remoteBinder() != nullptr && binder->linkToDeath(this) != OK) { LOG(ERROR) << "Could not linkToDeath when adding " << name; LOG(ERROR) << "Could not linkToDeath when adding " << name; return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE); return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE); } } Loading
cmds/servicemanager/main.cpp +8 −3 Original line number Original line Diff line number Diff line Loading @@ -23,11 +23,12 @@ #include "Access.h" #include "Access.h" #include "ServiceManager.h" #include "ServiceManager.h" using ::android::sp; using ::android::Access; using ::android::ProcessState; using ::android::IPCThreadState; using ::android::IPCThreadState; using ::android::ProcessState; using ::android::ServiceManager; using ::android::ServiceManager; using ::android::Access; using ::android::os::IServiceManager; using ::android::sp; int main(int argc, char** argv) { int main(int argc, char** argv) { if (argc > 2) { if (argc > 2) { Loading @@ -41,6 +42,10 @@ int main(int argc, char** argv) { ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY); ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY); sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>()); sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>()); if (!manager->addService("manager", manager, false /*allowIsolated*/, IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk()) { LOG(ERROR) << "Could not self register servicemanager"; } IPCThreadState::self()->setTheContextObject(manager); IPCThreadState::self()->setTheContextObject(manager); ps->becomeContextManager(nullptr, nullptr); ps->becomeContextManager(nullptr, nullptr); Loading
libs/binder/Android.bp +13 −0 Original line number Original line Diff line number Diff line Loading @@ -164,3 +164,16 @@ filegroup { ], ], path: "aidl", path: "aidl", } } aidl_interface { name: "libbinder_aidl_test_stub", local_include_dir: "aidl", srcs: [":libbinder_aidl"], visibility: [":__subpackages__"], vendor_available: true, backend: { java: { enabled: false, }, }, }
libs/binder/ndk/test/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,7 @@ cc_test { static_libs: [ static_libs: [ "IBinderVendorDoubleLoadTest-cpp", "IBinderVendorDoubleLoadTest-cpp", "IBinderVendorDoubleLoadTest-ndk_platform", "IBinderVendorDoubleLoadTest-ndk_platform", "libbinder_aidl_test_stub-ndk_platform", ], ], shared_libs: [ shared_libs: [ "libbase", "libbase", Loading
libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp +19 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <BnBinderVendorDoubleLoadTest.h> #include <BnBinderVendorDoubleLoadTest.h> #include <aidl/BnBinderVendorDoubleLoadTest.h> #include <aidl/BnBinderVendorDoubleLoadTest.h> #include <aidl/android/os/IServiceManager.h> #include <android-base/logging.h> #include <android-base/logging.h> #include <android-base/properties.h> #include <android-base/properties.h> #include <android-base/strings.h> #include <android-base/strings.h> Loading Loading @@ -109,6 +110,24 @@ TEST(DoubleBinder, CallIntoNdk) { } } } } TEST(DoubleBinder, CallIntoSystemStabilityNdk) { // picking an arbitrary system service SpAIBinder binder = SpAIBinder(AServiceManager_checkService("manager")); ASSERT_NE(nullptr, binder.get()); // can make stable transaction to system server EXPECT_EQ(STATUS_OK, AIBinder_ping(binder.get())); using aidl::android::os::IServiceManager; std::shared_ptr<IServiceManager> manager = IServiceManager::fromBinder(binder); ASSERT_NE(nullptr, manager.get()); std::vector<std::string> services; ASSERT_EQ( STATUS_BAD_TYPE, manager->listServices(IServiceManager::DUMP_FLAG_PRIORITY_ALL, &services).getStatus()); } void initDrivers() { void initDrivers() { // Explicitly instantiated with the same driver that system would use. // Explicitly instantiated with the same driver that system would use. // __ANDROID_VNDK__ right now uses /dev/vndbinder by default. // __ANDROID_VNDK__ right now uses /dev/vndbinder by default. Loading