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

Commit fbb87ef3 authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge "libbinder_ndk: add isAlive/ping"

parents d56b3150 65867d71
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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";
+16 −0
Original line number Diff line number Diff line
@@ -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.
 */
+4 −0
Original line number Diff line number Diff line
@@ -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);
}