summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2019-10-23 10:16:16 -0700
committer android-build-merger <android-build-merger@google.com> 2019-10-23 10:16:16 -0700
commitf7ead637fb43f04a3c36c2ae57315cd1dadb6541 (patch)
tree9f33deed65cc91d15ca8eb8ecf7223ced2c37011
parente18eefc96f207dca7879a4560c24ffcfda2c0658 (diff)
parent6d4d056d6b37b064a324ad48ef5bba509b253e62 (diff)
Merge changes from topic "orthogonal-sm-retrieval"
am: 6d4d056d6b Change-Id: Ief93aae77ce9cd4971275cd3dcc870cc60b95a6d
-rw-r--r--cmds/servicemanager/ServiceManager.cpp2
-rw-r--r--cmds/servicemanager/main.cpp11
-rw-r--r--libs/binder/Android.bp13
-rw-r--r--libs/binder/ndk/test/Android.bp1
-rw-r--r--libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp19
5 files changed, 42 insertions, 4 deletions
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp
index 934436847e..934646da41 100644
--- a/cmds/servicemanager/ServiceManager.cpp
+++ b/cmds/servicemanager/ServiceManager.cpp
@@ -165,7 +165,7 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi
#endif // !VENDORSERVICEMANAGER
// 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;
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
}
diff --git a/cmds/servicemanager/main.cpp b/cmds/servicemanager/main.cpp
index 11d43a6ee3..4b12fc6e72 100644
--- a/cmds/servicemanager/main.cpp
+++ b/cmds/servicemanager/main.cpp
@@ -23,11 +23,12 @@
#include "Access.h"
#include "ServiceManager.h"
-using ::android::sp;
-using ::android::ProcessState;
+using ::android::Access;
using ::android::IPCThreadState;
+using ::android::ProcessState;
using ::android::ServiceManager;
-using ::android::Access;
+using ::android::os::IServiceManager;
+using ::android::sp;
int main(int argc, char** argv) {
if (argc > 2) {
@@ -41,6 +42,10 @@ int main(int argc, char** argv) {
ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY);
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);
ps->becomeContextManager(nullptr, nullptr);
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index 643a956b4a..2a140f4507 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -164,3 +164,16 @@ filegroup {
],
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,
+ },
+ },
+}
diff --git a/libs/binder/ndk/test/Android.bp b/libs/binder/ndk/test/Android.bp
index 1c5dba3736..ebd08b2f71 100644
--- a/libs/binder/ndk/test/Android.bp
+++ b/libs/binder/ndk/test/Android.bp
@@ -77,6 +77,7 @@ cc_test {
static_libs: [
"IBinderVendorDoubleLoadTest-cpp",
"IBinderVendorDoubleLoadTest-ndk_platform",
+ "libbinder_aidl_test_stub-ndk_platform",
],
shared_libs: [
"libbase",
diff --git a/libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp b/libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp
index f72dc36cfd..d3ccdc2878 100644
--- a/libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp
+++ b/libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp
@@ -16,6 +16,7 @@
#include <BnBinderVendorDoubleLoadTest.h>
#include <aidl/BnBinderVendorDoubleLoadTest.h>
+#include <aidl/android/os/IServiceManager.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/strings.h>
@@ -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() {
// Explicitly instantiated with the same driver that system would use.
// __ANDROID_VNDK__ right now uses /dev/vndbinder by default.