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

Commit cd18a4a6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "libbinder_ndk: AIBinder_setInheritRt"

parents a98ef807 454a26ac
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -799,3 +799,12 @@ AIBinder* AIBinder_fromPlatformBinder(const android::sp<android::IBinder>& binde
void AIBinder_setMinSchedulerPolicy(AIBinder* binder, int policy, int priority) {
    binder->asABBinder()->setMinSchedulerPolicy(policy, priority);
}

void AIBinder_setInheritRt(AIBinder* binder, bool inheritRt) {
    ABBinder* localBinder = binder->asABBinder();
    if (localBinder == nullptr) {
        LOG(FATAL) << "AIBinder_setInheritRt must be called on a local binder";
    }

    localBinder->setInheritRt(inheritRt);
}
+11 −0
Original line number Diff line number Diff line
@@ -68,4 +68,15 @@ __attribute__((weak, warn_unused_result)) const char* AIBinder_getCallingSid() _
 */
void AIBinder_setMinSchedulerPolicy(AIBinder* binder, int policy, int priority) __INTRODUCED_IN(33);

/**
 * Allow the binder to inherit realtime scheduling policies from its caller.
 *
 * This must be called before the object is sent to another process. Not thread
 * safe.
 *
 * \param inheritRt whether to inherit realtime scheduling policies (default is
 *     false).
 */
void AIBinder_setInheritRt(AIBinder* binder, bool inheritRt) __INTRODUCED_IN(33);

__END_DECLS
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ LIBBINDER_NDK33 { # introduced=33
    AIBinder_Class_disableInterfaceTokenHeader;
    AIBinder_DeathRecipient_setOnUnlinked;
    AIBinder_isHandlingTransaction;
    AIBinder_setInheritRt; # llndk
    AIBinder_setMinSchedulerPolicy; # llndk
    AParcel_marshal;
    AParcel_unmarshal;
+25 −0
Original line number Diff line number Diff line
@@ -505,6 +505,31 @@ class MyTestFoo : public IFoo {
    }
};

TEST(NdkBinder, SetInheritRt) {
    // functional test in binderLibTest
    sp<IFoo> foo = sp<MyTestFoo>::make();
    AIBinder* binder = foo->getBinder();

    // does not abort
    AIBinder_setInheritRt(binder, true);
    AIBinder_setInheritRt(binder, false);
    AIBinder_setInheritRt(binder, true);

    AIBinder_decStrong(binder);
}

TEST(NdkBinder, SetInheritRtNonLocal) {
    AIBinder* binder = AServiceManager_getService(kExistingNonNdkService);
    ASSERT_NE(binder, nullptr);

    ASSERT_TRUE(AIBinder_isRemote(binder));

    EXPECT_DEATH(AIBinder_setInheritRt(binder, true), "");
    EXPECT_DEATH(AIBinder_setInheritRt(binder, false), "");

    AIBinder_decStrong(binder);
}

TEST(NdkBinder, AddNullService) {
    EXPECT_EQ(EX_ILLEGAL_ARGUMENT, AServiceManager_addService(nullptr, "any-service-name"));
}