binder: add an isHandlingTransaction method

This method is needed for aosp/1806578 because, although asynchronous
binder calls normally need to be offloaded to a separate thread, this is
not the case for such calls that happen during the handling of another
binder transaction.

The implementation of this method was based on the Java JNI binder
interface in `frameworks/base/core/jni/android_util_Binder.cpp`.

Test: m
Change-Id: Ia6d59f3f466911a27243476714cc5acf2eb4c629
diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp
index 81aa551..8ffa735 100644
--- a/libs/binder/ndk/ibinder.cpp
+++ b/libs/binder/ndk/ibinder.cpp
@@ -555,6 +555,10 @@
     return ::android::IPCThreadState::self()->getCallingPid();
 }
 
+bool AIBinder_isHandlingTransaction() {
+    return ::android::IPCThreadState::self()->getServingStackPointer() != nullptr;
+}
+
 void AIBinder_incStrong(AIBinder* binder) {
     if (binder == nullptr) {
         return;