From 5ec743f65fe48a6098ab5a564eeba012405634d7 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Wed, 18 Jan 2023 01:02:06 +0000 Subject: 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 --- libs/binder/BpBinder.cpp | 2 +- libs/binder/tests/binderRpcTest.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp index 1c470a11d3..d03326eb04 100644 --- a/libs/binder/BpBinder.cpp +++ b/libs/binder/BpBinder.cpp @@ -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) { diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index 8afa49b911..8470f82bdf 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -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& /* who */) override {} @@ -692,8 +692,7 @@ TEST_P(BinderRpc, DeathRecipientFatalWithoutIncoming) { {.numThreads = 1, .numSessions = 1, .numIncomingConnections = 0}); auto dr = sp::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) { -- cgit v1.2.3-59-g8ed1b