Loading core/jni/android_app_NativeActivity.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ #include <surfaceflinger/Surface.h> #include <ui/egl/android_natives.h> #include <ui/InputTransport.h> #include <utils/PollLoop.h> #include <utils/Looper.h> #include "JNIHelp.h" #include "android_os_MessageQueue.h" Loading Loading @@ -128,17 +128,17 @@ AInputQueue::~AInputQueue() { } void AInputQueue::attachLooper(ALooper* looper, int ident, ALooper_callbackFunc* callback, void* data) { mPollLoop = static_cast<android::PollLoop*>(looper); mPollLoop->setLooperCallback(mConsumer.getChannel()->getReceivePipeFd(), ident, POLLIN, callback, data); mPollLoop->setLooperCallback(mDispatchKeyRead, ident, POLLIN, callback, data); ALooper_callbackFunc callback, void* data) { mLooper = static_cast<android::Looper*>(looper); mLooper->addFd(mConsumer.getChannel()->getReceivePipeFd(), ident, ALOOPER_EVENT_INPUT, callback, data); mLooper->addFd(mDispatchKeyRead, ident, ALOOPER_EVENT_INPUT, callback, data); } void AInputQueue::detachLooper() { mPollLoop->removeCallback(mConsumer.getChannel()->getReceivePipeFd()); mPollLoop->removeCallback(mDispatchKeyRead); mLooper->removeFd(mConsumer.getChannel()->getReceivePipeFd()); mLooper->removeFd(mDispatchKeyRead); } int32_t AInputQueue::hasEvents() { Loading Loading @@ -440,8 +440,8 @@ struct NativeCode : public ANativeActivity { if (env != NULL && clazz != NULL) { env->DeleteGlobalRef(clazz); } if (pollLoop != NULL && mainWorkRead >= 0) { pollLoop->removeCallback(mainWorkRead); if (looper != NULL && mainWorkRead >= 0) { looper->removeFd(mainWorkRead); } if (nativeInputQueue != NULL) { nativeInputQueue->mWorkWrite = -1; Loading Loading @@ -509,7 +509,7 @@ struct NativeCode : public ANativeActivity { // These are used to wake up the main thread to process work. int mainWorkRead; int mainWorkWrite; sp<PollLoop> pollLoop; sp<Looper> looper; }; void android_NativeActivity_setWindowFormat( Loading Loading @@ -541,15 +541,15 @@ void android_NativeActivity_hideSoftInput( /* * Callback for handling native events on the application's main thread. */ static bool mainWorkCallback(int fd, int events, void* data) { static int mainWorkCallback(int fd, int events, void* data) { NativeCode* code = (NativeCode*)data; if ((events & POLLIN) == 0) { return true; return 1; } ActivityWork work; if (!read_work(code->mainWorkRead, &work)) { return true; return 1; } LOG_TRACE("mainWorkCallback: cmd=%d", work.cmd); Loading Loading @@ -593,7 +593,7 @@ static bool mainWorkCallback(int fd, int events, void* data) { break; } return true; return 1; } // ------------------------------------------------------------------------ Loading Loading @@ -621,9 +621,9 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQ return 0; } code->pollLoop = android_os_MessageQueue_getPollLoop(env, messageQueue); if (code->pollLoop == NULL) { LOGW("Unable to retrieve MessageQueue's PollLoop"); code->looper = android_os_MessageQueue_getLooper(env, messageQueue); if (code->looper == NULL) { LOGW("Unable to retrieve MessageQueue's Looper"); delete code; return 0; } Loading @@ -642,7 +642,7 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQ result = fcntl(code->mainWorkWrite, F_SETFL, O_NONBLOCK); SLOGW_IF(result != 0, "Could not make main work write pipe " "non-blocking: %s", strerror(errno)); code->pollLoop->setCallback(code->mainWorkRead, POLLIN, mainWorkCallback, code); code->looper->addFd(code->mainWorkRead, 0, ALOOPER_EVENT_INPUT, mainWorkCallback, code); code->ANativeActivity::callbacks = &code->callbacks; if (env->GetJavaVM(&code->vm) < 0) { Loading core/jni/android_hardware_SensorManager.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ sensors_module_get_next_sensor(JNIEnv *env, jobject clazz, jobject sensor, jint Sensor const* const* sensorList; size_t count = mgr.getSensorList(&sensorList); if (next >= count) if (size_t(next) >= count) return -1; Sensor const* const list = sensorList[next]; Loading @@ -78,7 +78,7 @@ sensors_module_get_next_sensor(JNIEnv *env, jobject clazz, jobject sensor, jint env->SetIntField(sensor, sensorOffsets.minDelay, list->getMinDelay()); next++; return next<count ? next : 0; return size_t(next) < count ? next : 0; } //---------------------------------------------------------------------------- Loading core/jni/android_os_MessageQueue.cpp +11 −11 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ #include "JNIHelp.h" #include <utils/PollLoop.h> #include <utils/Looper.h> #include <utils/Log.h> #include "android_os_MessageQueue.h" Loading @@ -39,22 +39,22 @@ public: NativeMessageQueue(); ~NativeMessageQueue(); inline sp<PollLoop> getPollLoop() { return mPollLoop; } inline sp<Looper> getLooper() { return mLooper; } bool pollOnce(int timeoutMillis); void wake(); private: sp<PollLoop> mPollLoop; sp<Looper> mLooper; }; // ---------------------------------------------------------------------------- NativeMessageQueue::NativeMessageQueue() { mPollLoop = PollLoop::getForThread(); if (mPollLoop == NULL) { mPollLoop = new PollLoop(false); PollLoop::setForThread(mPollLoop); mLooper = Looper::getForThread(); if (mLooper == NULL) { mLooper = new Looper(false); Looper::setForThread(mLooper); } } Loading @@ -62,11 +62,11 @@ NativeMessageQueue::~NativeMessageQueue() { } bool NativeMessageQueue::pollOnce(int timeoutMillis) { return mPollLoop->pollOnce(timeoutMillis) != PollLoop::POLL_TIMEOUT; return mLooper->pollOnce(timeoutMillis) != ALOOPER_POLL_TIMEOUT; } void NativeMessageQueue::wake() { mPollLoop->wake(); mLooper->wake(); } // ---------------------------------------------------------------------------- Loading @@ -83,10 +83,10 @@ static void android_os_MessageQueue_setNativeMessageQueue(JNIEnv* env, jobject m reinterpret_cast<jint>(nativeMessageQueue)); } sp<PollLoop> android_os_MessageQueue_getPollLoop(JNIEnv* env, jobject messageQueueObj) { sp<Looper> android_os_MessageQueue_getLooper(JNIEnv* env, jobject messageQueueObj) { NativeMessageQueue* nativeMessageQueue = android_os_MessageQueue_getNativeMessageQueue(env, messageQueueObj); return nativeMessageQueue != NULL ? nativeMessageQueue->getPollLoop() : NULL; return nativeMessageQueue != NULL ? nativeMessageQueue->getLooper() : NULL; } static void android_os_MessageQueue_nativeInit(JNIEnv* env, jobject obj) { Loading core/jni/android_os_MessageQueue.h +2 −2 Original line number Diff line number Diff line Loading @@ -21,9 +21,9 @@ namespace android { class PollLoop; class Looper; extern sp<PollLoop> android_os_MessageQueue_getPollLoop(JNIEnv* env, jobject messageQueueObj); extern sp<Looper> android_os_MessageQueue_getLooper(JNIEnv* env, jobject messageQueueObj); } // namespace android Loading core/jni/android_view_InputQueue.cpp +21 −21 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> #include <utils/PollLoop.h> #include <utils/Looper.h> #include <utils/KeyedVector.h> #include <utils/threads.h> #include <ui/InputTransport.h> Loading Loading @@ -77,7 +77,7 @@ private: }; Connection(uint16_t id, const sp<InputChannel>& inputChannel, const sp<PollLoop>& pollLoop); const sp<InputChannel>& inputChannel, const sp<Looper>& looper); inline const char* getInputChannelName() const { return inputChannel->getName().string(); } Loading @@ -88,7 +88,7 @@ private: sp<InputChannel> inputChannel; InputConsumer inputConsumer; sp<PollLoop> pollLoop; sp<Looper> looper; jobject inputHandlerObjGlobal; PreallocatedInputEventFactory inputEventFactory; Loading @@ -110,7 +110,7 @@ private: static void handleInputChannelDisposed(JNIEnv* env, jobject inputChannelObj, const sp<InputChannel>& inputChannel, void* data); static bool handleReceiveCallback(int receiveFd, int events, void* data); static int handleReceiveCallback(int receiveFd, int events, void* data); static jlong generateFinishedToken(int32_t receiveFd, uint16_t connectionId, uint16_t messageSeqNum); Loading Loading @@ -141,7 +141,7 @@ status_t NativeInputQueue::registerInputChannel(JNIEnv* env, jobject inputChanne LOGD("channel '%s' - Registered", inputChannel->getName().string()); #endif sp<PollLoop> pollLoop = android_os_MessageQueue_getPollLoop(env, messageQueueObj); sp<Looper> looper = android_os_MessageQueue_getLooper(env, messageQueueObj); { // acquire lock AutoMutex _l(mLock); Loading @@ -153,7 +153,7 @@ status_t NativeInputQueue::registerInputChannel(JNIEnv* env, jobject inputChanne } uint16_t connectionId = mNextConnectionId++; sp<Connection> connection = new Connection(connectionId, inputChannel, pollLoop); sp<Connection> connection = new Connection(connectionId, inputChannel, looper); status_t result = connection->inputConsumer.initialize(); if (result) { LOGW("Failed to initialize input consumer for input channel '%s', status=%d", Loading @@ -166,7 +166,7 @@ status_t NativeInputQueue::registerInputChannel(JNIEnv* env, jobject inputChanne int32_t receiveFd = inputChannel->getReceivePipeFd(); mConnectionsByReceiveFd.add(receiveFd, connection); pollLoop->setCallback(receiveFd, POLLIN, handleReceiveCallback, this); looper->addFd(receiveFd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this); } // release lock android_view_InputChannel_setDisposeCallback(env, inputChannelObj, Loading Loading @@ -201,7 +201,7 @@ status_t NativeInputQueue::unregisterInputChannel(JNIEnv* env, jobject inputChan connection->status = Connection::STATUS_ZOMBIE; connection->pollLoop->removeCallback(inputChannel->getReceivePipeFd()); connection->looper->removeFd(inputChannel->getReceivePipeFd()); env->DeleteGlobalRef(connection->inputHandlerObjGlobal); connection->inputHandlerObjGlobal = NULL; Loading Loading @@ -293,7 +293,7 @@ void NativeInputQueue::handleInputChannelDisposed(JNIEnv* env, q->unregisterInputChannel(env, inputChannelObj); } bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* data) { int NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* data) { NativeInputQueue* q = static_cast<NativeInputQueue*>(data); JNIEnv* env = AndroidRuntime::getJNIEnv(); Loading @@ -308,33 +308,33 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da if (connectionIndex < 0) { LOGE("Received spurious receive callback for unknown input channel. " "fd=%d, events=0x%x", receiveFd, events); return false; // remove the callback return 0; // remove the callback } connection = q->mConnectionsByReceiveFd.valueAt(connectionIndex); if (events & (POLLERR | POLLHUP | POLLNVAL)) { if (events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP)) { LOGE("channel '%s' ~ Publisher closed input channel or an error occurred. " "events=0x%x", connection->getInputChannelName(), events); return false; // remove the callback return 0; // remove the callback } if (! (events & POLLIN)) { if (! (events & ALOOPER_EVENT_INPUT)) { LOGW("channel '%s' ~ Received spurious callback for unhandled poll event. " "events=0x%x", connection->getInputChannelName(), events); return true; return 1; } status_t status = connection->inputConsumer.receiveDispatchSignal(); if (status) { LOGE("channel '%s' ~ Failed to receive dispatch signal. status=%d", connection->getInputChannelName(), status); return false; // remove the callback return 0; // remove the callback } if (connection->messageInProgress) { LOGW("channel '%s' ~ Publisher sent spurious dispatch signal.", connection->getInputChannelName()); return true; return 1; } status = connection->inputConsumer.consume(& connection->inputEventFactory, & inputEvent); Loading @@ -342,7 +342,7 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da LOGW("channel '%s' ~ Failed to consume input event. status=%d", connection->getInputChannelName(), status); connection->inputConsumer.sendFinishedSignal(); return true; return 1; } connection->messageInProgress = true; Loading Loading @@ -394,7 +394,7 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da connection->getInputChannelName()); env->DeleteLocalRef(inputHandlerObjLocal); q->finished(env, finishedToken, false); return true; return 1; } #if DEBUG_DISPATCH_CYCLE Loading @@ -417,7 +417,7 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da env->DeleteLocalRef(inputEventObj); env->DeleteLocalRef(inputHandlerObjLocal); return true; return 1; } jlong NativeInputQueue::generateFinishedToken(int32_t receiveFd, uint16_t connectionId, Loading @@ -435,9 +435,9 @@ void NativeInputQueue::parseFinishedToken(jlong finishedToken, // ---------------------------------------------------------------------------- NativeInputQueue::Connection::Connection(uint16_t id, const sp<InputChannel>& inputChannel, const sp<PollLoop>& pollLoop) : const sp<InputChannel>& inputChannel, const sp<Looper>& looper) : id(id), status(STATUS_NORMAL), inputChannel(inputChannel), inputConsumer(inputChannel), pollLoop(pollLoop), inputHandlerObjGlobal(NULL), looper(looper), inputHandlerObjGlobal(NULL), messageSeqNum(0), messageInProgress(false) { } Loading Loading
core/jni/android_app_NativeActivity.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ #include <surfaceflinger/Surface.h> #include <ui/egl/android_natives.h> #include <ui/InputTransport.h> #include <utils/PollLoop.h> #include <utils/Looper.h> #include "JNIHelp.h" #include "android_os_MessageQueue.h" Loading Loading @@ -128,17 +128,17 @@ AInputQueue::~AInputQueue() { } void AInputQueue::attachLooper(ALooper* looper, int ident, ALooper_callbackFunc* callback, void* data) { mPollLoop = static_cast<android::PollLoop*>(looper); mPollLoop->setLooperCallback(mConsumer.getChannel()->getReceivePipeFd(), ident, POLLIN, callback, data); mPollLoop->setLooperCallback(mDispatchKeyRead, ident, POLLIN, callback, data); ALooper_callbackFunc callback, void* data) { mLooper = static_cast<android::Looper*>(looper); mLooper->addFd(mConsumer.getChannel()->getReceivePipeFd(), ident, ALOOPER_EVENT_INPUT, callback, data); mLooper->addFd(mDispatchKeyRead, ident, ALOOPER_EVENT_INPUT, callback, data); } void AInputQueue::detachLooper() { mPollLoop->removeCallback(mConsumer.getChannel()->getReceivePipeFd()); mPollLoop->removeCallback(mDispatchKeyRead); mLooper->removeFd(mConsumer.getChannel()->getReceivePipeFd()); mLooper->removeFd(mDispatchKeyRead); } int32_t AInputQueue::hasEvents() { Loading Loading @@ -440,8 +440,8 @@ struct NativeCode : public ANativeActivity { if (env != NULL && clazz != NULL) { env->DeleteGlobalRef(clazz); } if (pollLoop != NULL && mainWorkRead >= 0) { pollLoop->removeCallback(mainWorkRead); if (looper != NULL && mainWorkRead >= 0) { looper->removeFd(mainWorkRead); } if (nativeInputQueue != NULL) { nativeInputQueue->mWorkWrite = -1; Loading Loading @@ -509,7 +509,7 @@ struct NativeCode : public ANativeActivity { // These are used to wake up the main thread to process work. int mainWorkRead; int mainWorkWrite; sp<PollLoop> pollLoop; sp<Looper> looper; }; void android_NativeActivity_setWindowFormat( Loading Loading @@ -541,15 +541,15 @@ void android_NativeActivity_hideSoftInput( /* * Callback for handling native events on the application's main thread. */ static bool mainWorkCallback(int fd, int events, void* data) { static int mainWorkCallback(int fd, int events, void* data) { NativeCode* code = (NativeCode*)data; if ((events & POLLIN) == 0) { return true; return 1; } ActivityWork work; if (!read_work(code->mainWorkRead, &work)) { return true; return 1; } LOG_TRACE("mainWorkCallback: cmd=%d", work.cmd); Loading Loading @@ -593,7 +593,7 @@ static bool mainWorkCallback(int fd, int events, void* data) { break; } return true; return 1; } // ------------------------------------------------------------------------ Loading Loading @@ -621,9 +621,9 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQ return 0; } code->pollLoop = android_os_MessageQueue_getPollLoop(env, messageQueue); if (code->pollLoop == NULL) { LOGW("Unable to retrieve MessageQueue's PollLoop"); code->looper = android_os_MessageQueue_getLooper(env, messageQueue); if (code->looper == NULL) { LOGW("Unable to retrieve MessageQueue's Looper"); delete code; return 0; } Loading @@ -642,7 +642,7 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQ result = fcntl(code->mainWorkWrite, F_SETFL, O_NONBLOCK); SLOGW_IF(result != 0, "Could not make main work write pipe " "non-blocking: %s", strerror(errno)); code->pollLoop->setCallback(code->mainWorkRead, POLLIN, mainWorkCallback, code); code->looper->addFd(code->mainWorkRead, 0, ALOOPER_EVENT_INPUT, mainWorkCallback, code); code->ANativeActivity::callbacks = &code->callbacks; if (env->GetJavaVM(&code->vm) < 0) { Loading
core/jni/android_hardware_SensorManager.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ sensors_module_get_next_sensor(JNIEnv *env, jobject clazz, jobject sensor, jint Sensor const* const* sensorList; size_t count = mgr.getSensorList(&sensorList); if (next >= count) if (size_t(next) >= count) return -1; Sensor const* const list = sensorList[next]; Loading @@ -78,7 +78,7 @@ sensors_module_get_next_sensor(JNIEnv *env, jobject clazz, jobject sensor, jint env->SetIntField(sensor, sensorOffsets.minDelay, list->getMinDelay()); next++; return next<count ? next : 0; return size_t(next) < count ? next : 0; } //---------------------------------------------------------------------------- Loading
core/jni/android_os_MessageQueue.cpp +11 −11 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ #include "JNIHelp.h" #include <utils/PollLoop.h> #include <utils/Looper.h> #include <utils/Log.h> #include "android_os_MessageQueue.h" Loading @@ -39,22 +39,22 @@ public: NativeMessageQueue(); ~NativeMessageQueue(); inline sp<PollLoop> getPollLoop() { return mPollLoop; } inline sp<Looper> getLooper() { return mLooper; } bool pollOnce(int timeoutMillis); void wake(); private: sp<PollLoop> mPollLoop; sp<Looper> mLooper; }; // ---------------------------------------------------------------------------- NativeMessageQueue::NativeMessageQueue() { mPollLoop = PollLoop::getForThread(); if (mPollLoop == NULL) { mPollLoop = new PollLoop(false); PollLoop::setForThread(mPollLoop); mLooper = Looper::getForThread(); if (mLooper == NULL) { mLooper = new Looper(false); Looper::setForThread(mLooper); } } Loading @@ -62,11 +62,11 @@ NativeMessageQueue::~NativeMessageQueue() { } bool NativeMessageQueue::pollOnce(int timeoutMillis) { return mPollLoop->pollOnce(timeoutMillis) != PollLoop::POLL_TIMEOUT; return mLooper->pollOnce(timeoutMillis) != ALOOPER_POLL_TIMEOUT; } void NativeMessageQueue::wake() { mPollLoop->wake(); mLooper->wake(); } // ---------------------------------------------------------------------------- Loading @@ -83,10 +83,10 @@ static void android_os_MessageQueue_setNativeMessageQueue(JNIEnv* env, jobject m reinterpret_cast<jint>(nativeMessageQueue)); } sp<PollLoop> android_os_MessageQueue_getPollLoop(JNIEnv* env, jobject messageQueueObj) { sp<Looper> android_os_MessageQueue_getLooper(JNIEnv* env, jobject messageQueueObj) { NativeMessageQueue* nativeMessageQueue = android_os_MessageQueue_getNativeMessageQueue(env, messageQueueObj); return nativeMessageQueue != NULL ? nativeMessageQueue->getPollLoop() : NULL; return nativeMessageQueue != NULL ? nativeMessageQueue->getLooper() : NULL; } static void android_os_MessageQueue_nativeInit(JNIEnv* env, jobject obj) { Loading
core/jni/android_os_MessageQueue.h +2 −2 Original line number Diff line number Diff line Loading @@ -21,9 +21,9 @@ namespace android { class PollLoop; class Looper; extern sp<PollLoop> android_os_MessageQueue_getPollLoop(JNIEnv* env, jobject messageQueueObj); extern sp<Looper> android_os_MessageQueue_getLooper(JNIEnv* env, jobject messageQueueObj); } // namespace android Loading
core/jni/android_view_InputQueue.cpp +21 −21 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> #include <utils/PollLoop.h> #include <utils/Looper.h> #include <utils/KeyedVector.h> #include <utils/threads.h> #include <ui/InputTransport.h> Loading Loading @@ -77,7 +77,7 @@ private: }; Connection(uint16_t id, const sp<InputChannel>& inputChannel, const sp<PollLoop>& pollLoop); const sp<InputChannel>& inputChannel, const sp<Looper>& looper); inline const char* getInputChannelName() const { return inputChannel->getName().string(); } Loading @@ -88,7 +88,7 @@ private: sp<InputChannel> inputChannel; InputConsumer inputConsumer; sp<PollLoop> pollLoop; sp<Looper> looper; jobject inputHandlerObjGlobal; PreallocatedInputEventFactory inputEventFactory; Loading @@ -110,7 +110,7 @@ private: static void handleInputChannelDisposed(JNIEnv* env, jobject inputChannelObj, const sp<InputChannel>& inputChannel, void* data); static bool handleReceiveCallback(int receiveFd, int events, void* data); static int handleReceiveCallback(int receiveFd, int events, void* data); static jlong generateFinishedToken(int32_t receiveFd, uint16_t connectionId, uint16_t messageSeqNum); Loading Loading @@ -141,7 +141,7 @@ status_t NativeInputQueue::registerInputChannel(JNIEnv* env, jobject inputChanne LOGD("channel '%s' - Registered", inputChannel->getName().string()); #endif sp<PollLoop> pollLoop = android_os_MessageQueue_getPollLoop(env, messageQueueObj); sp<Looper> looper = android_os_MessageQueue_getLooper(env, messageQueueObj); { // acquire lock AutoMutex _l(mLock); Loading @@ -153,7 +153,7 @@ status_t NativeInputQueue::registerInputChannel(JNIEnv* env, jobject inputChanne } uint16_t connectionId = mNextConnectionId++; sp<Connection> connection = new Connection(connectionId, inputChannel, pollLoop); sp<Connection> connection = new Connection(connectionId, inputChannel, looper); status_t result = connection->inputConsumer.initialize(); if (result) { LOGW("Failed to initialize input consumer for input channel '%s', status=%d", Loading @@ -166,7 +166,7 @@ status_t NativeInputQueue::registerInputChannel(JNIEnv* env, jobject inputChanne int32_t receiveFd = inputChannel->getReceivePipeFd(); mConnectionsByReceiveFd.add(receiveFd, connection); pollLoop->setCallback(receiveFd, POLLIN, handleReceiveCallback, this); looper->addFd(receiveFd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this); } // release lock android_view_InputChannel_setDisposeCallback(env, inputChannelObj, Loading Loading @@ -201,7 +201,7 @@ status_t NativeInputQueue::unregisterInputChannel(JNIEnv* env, jobject inputChan connection->status = Connection::STATUS_ZOMBIE; connection->pollLoop->removeCallback(inputChannel->getReceivePipeFd()); connection->looper->removeFd(inputChannel->getReceivePipeFd()); env->DeleteGlobalRef(connection->inputHandlerObjGlobal); connection->inputHandlerObjGlobal = NULL; Loading Loading @@ -293,7 +293,7 @@ void NativeInputQueue::handleInputChannelDisposed(JNIEnv* env, q->unregisterInputChannel(env, inputChannelObj); } bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* data) { int NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* data) { NativeInputQueue* q = static_cast<NativeInputQueue*>(data); JNIEnv* env = AndroidRuntime::getJNIEnv(); Loading @@ -308,33 +308,33 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da if (connectionIndex < 0) { LOGE("Received spurious receive callback for unknown input channel. " "fd=%d, events=0x%x", receiveFd, events); return false; // remove the callback return 0; // remove the callback } connection = q->mConnectionsByReceiveFd.valueAt(connectionIndex); if (events & (POLLERR | POLLHUP | POLLNVAL)) { if (events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP)) { LOGE("channel '%s' ~ Publisher closed input channel or an error occurred. " "events=0x%x", connection->getInputChannelName(), events); return false; // remove the callback return 0; // remove the callback } if (! (events & POLLIN)) { if (! (events & ALOOPER_EVENT_INPUT)) { LOGW("channel '%s' ~ Received spurious callback for unhandled poll event. " "events=0x%x", connection->getInputChannelName(), events); return true; return 1; } status_t status = connection->inputConsumer.receiveDispatchSignal(); if (status) { LOGE("channel '%s' ~ Failed to receive dispatch signal. status=%d", connection->getInputChannelName(), status); return false; // remove the callback return 0; // remove the callback } if (connection->messageInProgress) { LOGW("channel '%s' ~ Publisher sent spurious dispatch signal.", connection->getInputChannelName()); return true; return 1; } status = connection->inputConsumer.consume(& connection->inputEventFactory, & inputEvent); Loading @@ -342,7 +342,7 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da LOGW("channel '%s' ~ Failed to consume input event. status=%d", connection->getInputChannelName(), status); connection->inputConsumer.sendFinishedSignal(); return true; return 1; } connection->messageInProgress = true; Loading Loading @@ -394,7 +394,7 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da connection->getInputChannelName()); env->DeleteLocalRef(inputHandlerObjLocal); q->finished(env, finishedToken, false); return true; return 1; } #if DEBUG_DISPATCH_CYCLE Loading @@ -417,7 +417,7 @@ bool NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* da env->DeleteLocalRef(inputEventObj); env->DeleteLocalRef(inputHandlerObjLocal); return true; return 1; } jlong NativeInputQueue::generateFinishedToken(int32_t receiveFd, uint16_t connectionId, Loading @@ -435,9 +435,9 @@ void NativeInputQueue::parseFinishedToken(jlong finishedToken, // ---------------------------------------------------------------------------- NativeInputQueue::Connection::Connection(uint16_t id, const sp<InputChannel>& inputChannel, const sp<PollLoop>& pollLoop) : const sp<InputChannel>& inputChannel, const sp<Looper>& looper) : id(id), status(STATUS_NORMAL), inputChannel(inputChannel), inputConsumer(inputChannel), pollLoop(pollLoop), inputHandlerObjGlobal(NULL), looper(looper), inputHandlerObjGlobal(NULL), messageSeqNum(0), messageInProgress(false) { } Loading