Flush Binder commands in ndk looper.

Bug: 3258183
Change-Id: Id79757d7b5c98333b4d3f39ce79ecc76b7be6941
diff --git a/native/android/looper.cpp b/native/android/looper.cpp
index 9f5cda9..615493f 100644
--- a/native/android/looper.cpp
+++ b/native/android/looper.cpp
@@ -19,9 +19,11 @@
 
 #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 @@
         return ALOOPER_POLL_ERROR;
     }
 
+    IPCThreadState::self()->flushCommands();
     return looper->pollOnce(timeoutMillis, outFd, outEvents, outData);
 }
 
@@ -55,7 +58,8 @@
         LOGE("ALooper_pollAll: No looper for this thread!");
         return ALOOPER_POLL_ERROR;
     }
-    
+
+    IPCThreadState::self()->flushCommands();
     return looper->pollAll(timeoutMillis, outFd, outEvents, outData);
 }