Add functions to query #threads and looper state.

Can't submit until we can make ABI changes to libhwbinder.

Bug: 35117173
Test: boots
Change-Id: I10eeb128998e94b583be50c9968603ab656f0f28
diff --git a/IPCThreadState.cpp b/IPCThreadState.cpp
index 428866a..feaef3b 100644
--- a/IPCThreadState.cpp
+++ b/IPCThreadState.cpp
@@ -502,6 +502,7 @@
     mOut.writeInt32(isMain ? BC_ENTER_LOOPER : BC_REGISTER_LOOPER);
 
     status_t result;
+    mIsLooper = true;
     do {
         processPendingDerefs();
         // now get the next command to be processed, waiting if necessary
@@ -524,6 +525,7 @@
         (void*)pthread_self(), getpid(), result);
 
     mOut.writeInt32(BC_EXIT_LOOPER);
+    mIsLooper = false;
     talkWithDriver(false);
 }
 
@@ -962,6 +964,11 @@
     mContextObject = obj;
 }
 
+bool IPCThreadState::isLooperThread()
+{
+    return mIsLooper;
+}
+
 status_t IPCThreadState::executeCommand(int32_t cmd)
 {
     BHwBinder* obj;
diff --git a/ProcessState.cpp b/ProcessState.cpp
index 16bbd4d..ad7e422 100644
--- a/ProcessState.cpp
+++ b/ProcessState.cpp
@@ -321,6 +321,10 @@
     return result;
 }
 
+size_t ProcessState::getMaxThreads() {
+    return mMaxThreads;
+}
+
 void ProcessState::giveThreadPoolName() {
     androidSetThreadName( makeBinderThreadName().string() );
 }
diff --git a/include/hwbinder/IPCThreadState.h b/include/hwbinder/IPCThreadState.h
index fde1562..757e09e 100644
--- a/include/hwbinder/IPCThreadState.h
+++ b/include/hwbinder/IPCThreadState.h
@@ -91,6 +91,8 @@
 
             // Service manager registration
             void                setTheContextObject(sp<BHwBinder> obj);
+
+            bool                isLooperThread();
 private:
                                 IPCThreadState();
                                 ~IPCThreadState();
@@ -130,6 +132,7 @@
             int32_t             mStrictModePolicy;
             int32_t             mLastTransactionBinderFlags;
             sp<BHwBinder>         mContextObject;
+            bool                mIsLooper;
 };
 
 }; // namespace hardware
diff --git a/include/hwbinder/ProcessState.h b/include/hwbinder/ProcessState.h
index 5441b75..305ee11 100644
--- a/include/hwbinder/ProcessState.h
+++ b/include/hwbinder/ProcessState.h
@@ -64,6 +64,7 @@
             void                spawnPooledThread(bool isMain);
 
             status_t            setThreadPoolConfiguration(size_t maxThreads, bool callerJoinsPool);
+            size_t              getMaxThreads();
             void                giveThreadPoolName();
 
             ssize_t             getKernelReferences(size_t count, uintptr_t* buf);