Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d4d056d authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge changes from topic "orthogonal-sm-retrieval"

* changes:
  libbinder_ndk: test vendor/system stability
  servicemanager: self-register
parents dbaed0ac 82c97cf3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }
+8 −3
Original line number Diff line number Diff line
@@ -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);

+13 −0
Original line number Diff line number Diff line
@@ -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,
        },
    },
}
+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ cc_test {
    static_libs: [
        "IBinderVendorDoubleLoadTest-cpp",
        "IBinderVendorDoubleLoadTest-ndk_platform",
        "libbinder_aidl_test_stub-ndk_platform",
    ],
    shared_libs: [
        "libbase",
+19 −0
Original line number Diff line number Diff line
@@ -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.