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

Commit 5ec743f6 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder: softer error for linkToDeath lack of threads

Most code will be handling an error condition here, and we don't
necessarily want to rewrite corresponding client code when we use
RPC binder.

Change-Id: Ia6cb1900dc55092625e02a734960fb5b0023340a
Fixes: 264477724
Test: N/A
parent bcb91683
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ status_t BpBinder::linkToDeath(
{
    if (isRpcBinder()) {
        if (rpcSession()->getMaxIncomingThreads() < 1) {
            LOG_ALWAYS_FATAL("Cannot register a DeathRecipient without any incoming connections.");
            ALOGE("Cannot register a DeathRecipient without any incoming connections.");
            return INVALID_OPERATION;
        }
    } else if constexpr (!kEnableKernelIpc) {
+2 −3
Original line number Diff line number Diff line
@@ -682,7 +682,7 @@ TEST_P(BinderRpc, SingleDeathRecipientOnShutdown) {
    proc.expectAlreadyShutdown = true;
}

TEST_P(BinderRpc, DeathRecipientFatalWithoutIncoming) {
TEST_P(BinderRpc, DeathRecipientFailsWithoutIncoming) {
    class MyDeathRec : public IBinder::DeathRecipient {
    public:
        void binderDied(const wp<IBinder>& /* who */) override {}
@@ -692,8 +692,7 @@ TEST_P(BinderRpc, DeathRecipientFatalWithoutIncoming) {
            {.numThreads = 1, .numSessions = 1, .numIncomingConnections = 0});

    auto dr = sp<MyDeathRec>::make();
    EXPECT_DEATH(proc.rootBinder->linkToDeath(dr, (void*)1, 0),
                 "Cannot register a DeathRecipient without any incoming connections.");
    EXPECT_EQ(INVALID_OPERATION, proc.rootBinder->linkToDeath(dr, (void*)1, 0));
}

TEST_P(BinderRpc, UnlinkDeathRecipient) {