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

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

Merge "Remove need for libbinderthreadstate."

parents c02c9230 39d887d3
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
               cmds/idlcli/
               cmds/idlcli/
               include/input/
               include/input/
               libs/binder/ndk/
               libs/binder/ndk/
               libs/binderthreadstate/
               libs/graphicsenv/
               libs/graphicsenv/
               libs/gui/
               libs/gui/
               libs/input/
               libs/input/
+0 −1
Original line number Original line Diff line number Diff line
@@ -138,7 +138,6 @@ cc_library {
        "liblog",
        "liblog",
        "libcutils",
        "libcutils",
        "libutils",
        "libutils",
        "libbinderthreadstate",
    ],
    ],


    header_libs: [
    header_libs: [
+7 −8
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
#define LOG_TAG "IPCThreadState"
#define LOG_TAG "IPCThreadState"


#include <binder/IPCThreadState.h>
#include <binder/IPCThreadState.h>
#include <binderthreadstate/IPCThreadStateBase.h>


#include <binder/Binder.h>
#include <binder/Binder.h>
#include <binder/BpBinder.h>
#include <binder/BpBinder.h>
@@ -803,6 +802,7 @@ status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy)


IPCThreadState::IPCThreadState()
IPCThreadState::IPCThreadState()
    : mProcess(ProcessState::self()),
    : mProcess(ProcessState::self()),
      mServingStackPointer(nullptr),
      mWorkSource(kUnsetWorkSource),
      mWorkSource(kUnsetWorkSource),
      mPropagateWorkSource(false),
      mPropagateWorkSource(false),
      mStrictModePolicy(0),
      mStrictModePolicy(0),
@@ -813,7 +813,6 @@ IPCThreadState::IPCThreadState()
    clearCaller();
    clearCaller();
    mIn.setDataCapacity(256);
    mIn.setDataCapacity(256);
    mOut.setDataCapacity(256);
    mOut.setDataCapacity(256);
    mIPCThreadStateBase = IPCThreadStateBase::self();
}
}


IPCThreadState::~IPCThreadState()
IPCThreadState::~IPCThreadState()
@@ -1163,9 +1162,6 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
                "Not enough command data for brTRANSACTION");
                "Not enough command data for brTRANSACTION");
            if (result != NO_ERROR) break;
            if (result != NO_ERROR) break;


            //Record the fact that we're in a binder call.
            mIPCThreadStateBase->pushCurrentState(
                IPCThreadStateBase::CallState::BINDER);
            Parcel buffer;
            Parcel buffer;
            buffer.ipcSetDataReference(
            buffer.ipcSetDataReference(
                reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
                reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
@@ -1173,6 +1169,9 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
                reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
                reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
                tr.offsets_size/sizeof(binder_size_t), freeBuffer, this);
                tr.offsets_size/sizeof(binder_size_t), freeBuffer, this);


            const void* origServingStackPointer = mServingStackPointer;
            mServingStackPointer = &origServingStackPointer; // anything on the stack

            const pid_t origPid = mCallingPid;
            const pid_t origPid = mCallingPid;
            const char* origSid = mCallingSid;
            const char* origSid = mCallingSid;
            const uid_t origUid = mCallingUid;
            const uid_t origUid = mCallingUid;
@@ -1223,7 +1222,6 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
                error = the_context_object->transact(tr.code, buffer, &reply, tr.flags);
                error = the_context_object->transact(tr.code, buffer, &reply, tr.flags);
            }
            }


            mIPCThreadStateBase->popCurrentState();
            //ALOGI("<<<< TRANSACT from pid %d restore pid %d sid %s uid %d\n",
            //ALOGI("<<<< TRANSACT from pid %d restore pid %d sid %s uid %d\n",
            //     mCallingPid, origPid, (origSid ? origSid : "<N/A>"), origUid);
            //     mCallingPid, origPid, (origSid ? origSid : "<N/A>"), origUid);


@@ -1235,6 +1233,7 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
                LOG_ONEWAY("NOT sending reply to %d!", mCallingPid);
                LOG_ONEWAY("NOT sending reply to %d!", mCallingPid);
            }
            }


            mServingStackPointer = origServingStackPointer;
            mCallingPid = origPid;
            mCallingPid = origPid;
            mCallingSid = origSid;
            mCallingSid = origSid;
            mCallingUid = origUid;
            mCallingUid = origUid;
@@ -1290,8 +1289,8 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
    return result;
    return result;
}
}


bool IPCThreadState::isServingCall() const {
const void* IPCThreadState::getServingStackPointer() const {
    return mIPCThreadStateBase->getCurrentBinderCallState() == IPCThreadStateBase::CallState::BINDER;
     return mServingStackPointer;
}
}


void IPCThreadState::threadDestructor(void *st)
void IPCThreadState::threadDestructor(void *st)
+3 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,9 @@
    },
    },
    {
    {
      "name": "aidl_lazy_test"
      "name": "aidl_lazy_test"
    },
    {
      "name": "libbinderthreadstateutils_test"
    }
    }
  ]
  ]
}
}
+6 −27
Original line number Original line Diff line number Diff line
@@ -29,8 +29,6 @@ typedef int uid_t;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
namespace android {
namespace android {


class IPCThreadStateBase;

class IPCThreadState
class IPCThreadState
{
{
public:
public:
@@ -113,31 +111,12 @@ public:
            // Service manager registration
            // Service manager registration
            void                setTheContextObject(sp<BBinder> obj);
            void                setTheContextObject(sp<BBinder> obj);


            // Is this thread currently serving a binder call. This method
            // WARNING: DO NOT USE THIS API
            // returns true if while traversing backwards from the function call
            // stack for this thread, we encounter a function serving a binder
            // call before encountering a hwbinder call / hitting the end of the
            // call stack.
            // Eg: If thread T1 went through the following call pattern
            //     1) T1 receives and executes hwbinder call H1.
            //     2) While handling H1, T1 makes binder call B1.
            //     3) The handler of B1, calls into T1 with a callback B2.
            // If isServingCall() is called during H1 before 3), this method
            // will return false, else true.
            //
            //  ----
            // | B2 | ---> While callback B2 is being handled, during 3).
            //  ----
            // | H1 | ---> While H1 is being handled.
            //  ----
            // Fig: Thread Call stack while handling B2
            //
            //
            // This is since after 3), while traversing the thread call stack,
            // Returns a pointer to the stack from the last time a transaction
            // we hit a binder call before a hwbinder call / end of stack. This
            // was initiated by the kernel. Used to compare when making nested
            // method may be typically used to determine whether to use
            // calls between multiple different transports.
            // hardware::IPCThreadState methods or IPCThreadState methods to
            const void*         getServingStackPointer() const;
            // infer information about thread state.
            bool                isServingCall() const;


            // The work source represents the UID of the process we should attribute the transaction
            // The work source represents the UID of the process we should attribute the transaction
            // to. We use -1 to specify that the work source was not set using #setWorkSource.
            // to. We use -1 to specify that the work source was not set using #setWorkSource.
@@ -181,6 +160,7 @@ private:
            Parcel              mIn;
            Parcel              mIn;
            Parcel              mOut;
            Parcel              mOut;
            status_t            mLastError;
            status_t            mLastError;
            const void*         mServingStackPointer;
            pid_t               mCallingPid;
            pid_t               mCallingPid;
            const char*         mCallingSid;
            const char*         mCallingSid;
            uid_t               mCallingUid;
            uid_t               mCallingUid;
@@ -191,7 +171,6 @@ private:
            bool                mPropagateWorkSource;
            bool                mPropagateWorkSource;
            int32_t             mStrictModePolicy;
            int32_t             mStrictModePolicy;
            int32_t             mLastTransactionBinderFlags;
            int32_t             mLastTransactionBinderFlags;
            IPCThreadStateBase  *mIPCThreadStateBase;


            ProcessState::CallRestriction mCallRestriction;
            ProcessState::CallRestriction mCallRestriction;
};
};
Loading