Loading libs/binder/ndk/AIBinder.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,22 @@ bool AIBinder_isRemote(const AIBinder* binder) { return binder->isRemote(); } bool AIBinder_isAlive(const AIBinder* binder) { if (binder == nullptr) { return false; } return const_cast<AIBinder*>(binder)->getBinder()->isBinderAlive(); } binder_status_t AIBinder_ping(AIBinder* binder) { if (binder == nullptr) { return EX_NULL_POINTER; } return binder->getBinder()->pingBinder(); } void AIBinder_incStrong(AIBinder* binder) { if (binder == nullptr) { LOG(ERROR) << __func__ << ": on null binder"; Loading libs/binder/ndk/include_ndk/android/binder_ibinder.h +16 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,22 @@ __attribute__((warn_unused_result)) AIBinder* AIBinder_new(const AIBinder_Class* */ bool AIBinder_isRemote(const AIBinder* binder); /** * If this binder is known to be alive. This will not send a transaction to a remote process and * returns a result based on the last known information. That is, whenever a transaction is made, * this is automatically updated to reflect the current alive status of this binder. This will be * updated as the result of a transaction made using AIBinder_transact, but it will also be updated * based on the results of bookkeeping or other transactions made internally. */ bool AIBinder_isAlive(const AIBinder* binder); /** * Built-in transaction for all binder objects. This sends a transaction which will immediately * return. Usually this is used to make sure that a binder is alive, as a placeholder call, or as a * sanity check. */ binder_status_t AIBinder_ping(AIBinder* binder); /** * This can only be called if a strong reference to this object already exists in process. */ Loading libs/binder/ndk/test/main_client.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,10 @@ TEST(NdkBinder, DoubleNumber) { TEST(NdkBinder, RetrieveNonNdkService) { AIBinder* binder = AServiceManager_getService(kExistingNonNdkService); ASSERT_NE(nullptr, binder); EXPECT_TRUE(AIBinder_isRemote(binder)); EXPECT_TRUE(AIBinder_isAlive(binder)); EXPECT_EQ(EX_NONE, AIBinder_ping(binder)); AIBinder_decStrong(binder); } Loading Loading
libs/binder/ndk/AIBinder.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,22 @@ bool AIBinder_isRemote(const AIBinder* binder) { return binder->isRemote(); } bool AIBinder_isAlive(const AIBinder* binder) { if (binder == nullptr) { return false; } return const_cast<AIBinder*>(binder)->getBinder()->isBinderAlive(); } binder_status_t AIBinder_ping(AIBinder* binder) { if (binder == nullptr) { return EX_NULL_POINTER; } return binder->getBinder()->pingBinder(); } void AIBinder_incStrong(AIBinder* binder) { if (binder == nullptr) { LOG(ERROR) << __func__ << ": on null binder"; Loading
libs/binder/ndk/include_ndk/android/binder_ibinder.h +16 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,22 @@ __attribute__((warn_unused_result)) AIBinder* AIBinder_new(const AIBinder_Class* */ bool AIBinder_isRemote(const AIBinder* binder); /** * If this binder is known to be alive. This will not send a transaction to a remote process and * returns a result based on the last known information. That is, whenever a transaction is made, * this is automatically updated to reflect the current alive status of this binder. This will be * updated as the result of a transaction made using AIBinder_transact, but it will also be updated * based on the results of bookkeeping or other transactions made internally. */ bool AIBinder_isAlive(const AIBinder* binder); /** * Built-in transaction for all binder objects. This sends a transaction which will immediately * return. Usually this is used to make sure that a binder is alive, as a placeholder call, or as a * sanity check. */ binder_status_t AIBinder_ping(AIBinder* binder); /** * This can only be called if a strong reference to this object already exists in process. */ Loading
libs/binder/ndk/test/main_client.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,10 @@ TEST(NdkBinder, DoubleNumber) { TEST(NdkBinder, RetrieveNonNdkService) { AIBinder* binder = AServiceManager_getService(kExistingNonNdkService); ASSERT_NE(nullptr, binder); EXPECT_TRUE(AIBinder_isRemote(binder)); EXPECT_TRUE(AIBinder_isAlive(binder)); EXPECT_EQ(EX_NONE, AIBinder_ping(binder)); AIBinder_decStrong(binder); } Loading