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

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

Merge changes from topic "binder-polling"

* changes:
  libbinder_ndk: APIs for polling
  libbinder: setupPolling returns status_t
parents 09f7bc11 23d058f7
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -614,7 +614,7 @@ void IPCThreadState::joinThreadPool(bool isMain)
    talkWithDriver(false);
    talkWithDriver(false);
}
}


int IPCThreadState::setupPolling(int* fd)
status_t IPCThreadState::setupPolling(int* fd)
{
{
    if (mProcess->mDriverFD < 0) {
    if (mProcess->mDriverFD < 0) {
        return -EBADF;
        return -EBADF;
+2 −2
Original line number Original line Diff line number Diff line
@@ -86,7 +86,7 @@ public:
            // Restores PID/UID (not SID)
            // Restores PID/UID (not SID)
            void                restoreCallingIdentity(int64_t token);
            void                restoreCallingIdentity(int64_t token);


            int                 setupPolling(int* fd);
            status_t            setupPolling(int* fd);
            status_t            handlePolledCommands();
            status_t            handlePolledCommands();
            void                flushCommands();
            void                flushCommands();


+28 −0
Original line number Original line Diff line number Diff line
@@ -19,10 +19,15 @@
#include <stdint.h>
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/cdefs.h>


#include <android/binder_status.h>

__BEGIN_DECLS
__BEGIN_DECLS


/**
/**
 * This creates a threadpool for incoming binder transactions if it has not already been created.
 * This creates a threadpool for incoming binder transactions if it has not already been created.
 *
 * When using this, it is expected that ABinderProcess_setupPolling and
 * ABinderProcess_handlePolledCommands are not used.
 */
 */
void ABinderProcess_startThreadPool();
void ABinderProcess_startThreadPool();
/**
/**
@@ -37,4 +42,27 @@ bool ABinderProcess_setThreadPoolMaxThreadCount(uint32_t numThreads);
 */
 */
void ABinderProcess_joinThreadPool();
void ABinderProcess_joinThreadPool();


/**
 * This gives you an fd to wait on. Whenever data is available on the fd,
 * ABinderProcess_handlePolledCommands can be called to handle binder queries.
 * This is expected to be used in a single threaded process which waits on
 * events from multiple different fds.
 *
 * When using this, it is expected ABinderProcess_startThreadPool and
 * ABinderProcess_joinThreadPool are not used.
 *
 * \param fd out param corresponding to the binder domain opened in this
 * process.
 * \return STATUS_OK on success
 */
__attribute__((weak)) binder_status_t ABinderProcess_setupPolling(int* fd) __INTRODUCED_IN(31);

/**
 * This will handle all queued binder commands in this process and then return.
 * It is expected to be called whenever there is data on the fd.
 *
 * \return STATUS_OK on success
 */
__attribute__((weak)) binder_status_t ABinderProcess_handlePolledCommands() __INTRODUCED_IN(31);

__END_DECLS
__END_DECLS
+2 −0
Original line number Original line Diff line number Diff line
@@ -113,6 +113,8 @@ LIBBINDER_NDK30 { # introduced=30


LIBBINDER_NDK31 { # introduced=31
LIBBINDER_NDK31 { # introduced=31
  global:
  global:
    ABinderProcess_handlePolledCommands; # apex
    ABinderProcess_setupPolling; # apex
    AIBinder_getCallingSid; # apex
    AIBinder_getCallingSid; # apex
    AIBinder_setRequestingSid; # apex
    AIBinder_setRequestingSid; # apex
};
};
+8 −0
Original line number Original line Diff line number Diff line
@@ -34,3 +34,11 @@ bool ABinderProcess_setThreadPoolMaxThreadCount(uint32_t numThreads) {
void ABinderProcess_joinThreadPool() {
void ABinderProcess_joinThreadPool() {
    IPCThreadState::self()->joinThreadPool();
    IPCThreadState::self()->joinThreadPool();
}
}

binder_status_t ABinderProcess_setupPolling(int* fd) {
    return IPCThreadState::self()->setupPolling(fd);
}

binder_status_t ABinderProcess_handlePolledCommands() {
    return IPCThreadState::self()->handlePolledCommands();
}
Loading