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

Commit 536bf4c8 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "BpBinder: hide 'handle' API" am: e7539dd4

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1533425

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I333a065624653a1143f4d679633d0221b3eff081
parents 57b18d54 e7539dd4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -494,7 +494,7 @@ ssize_t ServiceManager::Service::getNodeStrongRefCount() {
    sp<BpBinder> bpBinder = binder->remoteBinder();
    if (bpBinder == nullptr) return -1;

    return ProcessState::self()->getStrongRefCountForNodeByHandle(bpBinder->handle());
    return ProcessState::self()->getStrongRefCountForNode(bpBinder);
}

void ServiceManager::handleClientCallbacks() {
+1 −1
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder)
            if (proxy == nullptr) {
                ALOGE("null proxy");
            }
            const int32_t handle = proxy ? proxy->handle() : 0;
            const int32_t handle = proxy ? proxy->getPrivateAccessorForHandle().handle() : 0;
            obj.hdr.type = BINDER_TYPE_HANDLE;
            obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */
            obj.handle = handle;
+2 −2
Original line number Diff line number Diff line
@@ -204,11 +204,11 @@ ssize_t ProcessState::getKernelReferences(size_t buf_count, uintptr_t* buf)
// 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) {
ssize_t ProcessState::getStrongRefCountForNode(const sp<BpBinder>& binder) {
    binder_node_info_for_ref info;
    memset(&info, 0, sizeof(binder_node_info_for_ref));

    info.handle = handle;
    info.handle = binder->getPrivateAccessorForHandle().handle();

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

+17 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ namespace android {
namespace internal {
class Stability;
}
class ProcessState;

using binder_proxy_limit_callback = void(*)(int);

@@ -37,8 +38,6 @@ class BpBinder : public IBinder
public:
    static BpBinder*    create(int32_t handle);

    int32_t             handle() const;

    virtual const String16&    getInterfaceDescriptor() const;
    virtual bool        isBinderAlive() const;
    virtual status_t    pingBinder();
@@ -109,7 +108,23 @@ public:
        KeyedVector<const void*, entry_t> mObjects;
    };

    class PrivateAccessorForHandle {
    private:
        friend BpBinder;
        friend ::android::Parcel;
        friend ::android::ProcessState;
        explicit PrivateAccessorForHandle(const BpBinder* binder) : mBinder(binder) {}
        int32_t handle() const { return mBinder->handle(); }
        const BpBinder* mBinder;
    };
    const PrivateAccessorForHandle getPrivateAccessorForHandle() const {
        return PrivateAccessorForHandle(this);
    }

private:
    friend PrivateAccessorForHandle;

    int32_t             handle() const;
                        BpBinder(int32_t handle,int32_t trackedUid);
    virtual             ~BpBinder();
    virtual void        onFirstRef();
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public:
                                // 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);
            ssize_t             getStrongRefCountForNode(const sp<BpBinder>& binder);

            enum class CallRestriction {
                // all calls okay
Loading