OSDN Git Service

Flush Binder commands in ndk looper.
authorJeff Brown <jeffbrown@google.com>
Mon, 10 Jan 2011 22:36:37 +0000 (14:36 -0800)
committerJeff Brown <jeffbrown@google.com>
Mon, 10 Jan 2011 22:37:46 +0000 (14:37 -0800)
Bug: 3258183
Change-Id: I943808d6297a442b84ec95643e88ceb125f8c0c6

native/android/looper.cpp

index 9f5cda9..615493f 100644 (file)
 
 #include <android/looper.h>
 #include <utils/Looper.h>
+#include <binder/IPCThreadState.h>
 
 using android::Looper;
 using android::sp;
+using android::IPCThreadState;
 
 ALooper* ALooper_forThread() {
     return Looper::getForThread().get();
@@ -46,6 +48,7 @@ int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outDa
         return ALOOPER_POLL_ERROR;
     }
 
+    IPCThreadState::self()->flushCommands();
     return looper->pollOnce(timeoutMillis, outFd, outEvents, outData);
 }
 
@@ -55,7 +58,8 @@ int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outDat
         LOGE("ALooper_pollAll: No looper for this thread!");
         return ALOOPER_POLL_ERROR;
     }
-    
+
+    IPCThreadState::self()->flushCommands();
     return looper->pollAll(timeoutMillis, outFd, outEvents, outData);
 }