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

Commit b305b3a5 authored by Devin Moore's avatar Devin Moore
Browse files

Add the ndk API AIBinder_setMinRpcThreads

Wraps the underlying IBinder::setMinRpcThreads.

Flag: EXEMPT new API - not using it
Test: atest libbinder_ndk_unit_test
Bug: 430314963

Change-Id: Ib17f6d56236923e1f8445c44a91ed9c05db86620
parent 6b31ef27
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1004,3 +1004,10 @@ void AIBinder_setInheritRt(AIBinder* binder, bool inheritRt) {

    localBinder->setInheritRt(inheritRt);
}

binder_status_t AIBinder_setMinRpcThreads(AIBinder* binder, uint16_t min) {
    if (min == 0) return STATUS_BAD_VALUE;
    if (binder == nullptr) return STATUS_UNEXPECTED_NULL;
    binder->getBinder()->setMinRpcThreads(min);
    return STATUS_OK;
}
+17 −0
Original line number Diff line number Diff line
@@ -883,6 +883,23 @@ AIBinder_Weak* AIBinder_Weak_clone(const AIBinder_Weak* weak) __INTRODUCED_IN(31
 */
bool AIBinder_Weak_lt(const AIBinder_Weak* lhs, const AIBinder_Weak* rhs) __INTRODUCED_IN(31);

/**
 * Set the minimum number of RPC threads required to service this binder.
 *
 * This value is used to ensure there are enough threads for the RPC binder
 * connections.
 *
 * This is not related to the ProcessState binder threadpool.
 *
 * \param binder the local AIBinder (ABBinder) to set this minimum on.
 * \param min number of threads required to service the binder, must be at least 1
 *
 * \return STATUS_UNEXPECTED_NULL if binder is nullptr
 *         STATUS_BAD_VALUE if min is 0
 *         STATUS_OK otherwise
 */
binder_status_t AIBinder_setMinRpcThreads(AIBinder* binder, uint16_t min) __INTRODUCED_IN(37);

__END_DECLS

/** @} */
+1 −0
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ LIBBINDER_NDK36 { # introduced=36
LIBBINDER_NDK37 { # introduced=37
  global:
    AServiceManager_checkServiceAccess; # systemapi llndk
    AIBinder_setMinRpcThreads; # systemapi
};

LIBBINDER_NDK_PLATFORM {
+13 −0
Original line number Diff line number Diff line
@@ -1120,6 +1120,19 @@ TEST(NdkBinder, InvalidCheckServiceAccessArgs) {
                 "nullptr");
}

TEST(NdkBinder, SetMinThreads) {
    ndk::SpAIBinder binder = ndk::SharedRefBase::make<MyBinderNdkUnitTest>()->asBinder();
    EXPECT_EQ(STATUS_OK, AIBinder_setMinRpcThreads(binder.get(), 10));
}

TEST(NdkBinder, SetMinThreadsNull) {
    EXPECT_EQ(STATUS_UNEXPECTED_NULL, AIBinder_setMinRpcThreads(nullptr, 10));
}

TEST(NdkBinder, SetMinThreadsZero) {
    EXPECT_EQ(STATUS_BAD_VALUE, AIBinder_setMinRpcThreads(nullptr, 0));
}

static void addOne(int* to) {
    if (!to) return;
    ++(*to);