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

Commit 091d8151 authored by Jon Spivack's avatar Jon Spivack Committed by android-build-merger
Browse files

Merge "Add getStrongRefCountForNodeByHandle to ProcessState"

am: 73c91ae7

Change-Id: I96a71b7a888dac84188d7e546b0bfb9082711da8
parents f7ead637 73c91ae7
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -188,6 +188,30 @@ ssize_t ProcessState::getKernelReferences(size_t buf_count, uintptr_t* buf)
    return count;
    return count;
}
}


// Queries the driver for the current strong reference count of the node
// that the handle points to. Can only be used by the servicemanager.
//
// Returns -1 in case of failure, otherwise the strong reference count.
ssize_t ProcessState::getStrongRefCountForNodeByHandle(int32_t handle) {
    binder_node_info_for_ref info;
    memset(&info, 0, sizeof(binder_node_info_for_ref));

    info.handle = handle;

    status_t result = ioctl(mDriverFD, BINDER_GET_NODE_INFO_FOR_REF, &info);

    if (result != OK) {
        static bool logged = false;
        if (!logged) {
          ALOGW("Kernel does not support BINDER_GET_NODE_INFO_FOR_REF.");
          logged = true;
        }
        return -1;
    }

    return info.strong_count;
}

void ProcessState::setCallRestriction(CallRestriction restriction) {
void ProcessState::setCallRestriction(CallRestriction restriction) {
    LOG_ALWAYS_FATAL_IF(IPCThreadState::selfOrNull() != nullptr,
    LOG_ALWAYS_FATAL_IF(IPCThreadState::selfOrNull() != nullptr,
        "Call restrictions must be set before the threadpool is started.");
        "Call restrictions must be set before the threadpool is started.");
+8 −0
Original line number Original line Diff line number Diff line
@@ -69,6 +69,14 @@ public:


            ssize_t             getKernelReferences(size_t count, uintptr_t* buf);
            ssize_t             getKernelReferences(size_t count, uintptr_t* buf);


                                // Only usable by the context manager.
                                // This refcount includes:
                                // 1. Strong references to the node by this and other processes
                                // 2. Temporary strong references held by the kernel during a
                                //    transaction on the node.
                                // It does NOT include local strong references to the node
            ssize_t             getStrongRefCountForNodeByHandle(int32_t handle);

            enum class CallRestriction {
            enum class CallRestriction {
                // all calls okay
                // all calls okay
                NONE,
                NONE,