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

Commit 82c97cf3 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_ndk: test vendor/system stability

A vendor stability binder shouldn't be able to call into a system
stability binder. Before, we were missing a negative test.

Bug: 136027762
Test: binderVendorDoubleLoadTest
Change-Id: I4944c5c61d42873798dac9c132b743469a80dd63
parent 46f380b9
Loading
Loading
Loading
Loading
+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.