Cameraserver: Use multiple hwbinder threads

Some interactions between camera service and hwservicemanager require
multiple threads to execute without deadlocks, such as calling
getService() from within an onRegistered() callback.

Increase thread count to 3 to accomodate.

Also switch the order of listener registration and legacy provider
addition back to what it was originally.

Test: No deadlock when camera service is restarted
Bug: 35096594
Change-Id: I6def961d5765958fef284c0a1820e903abc851ef
diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk
index 1548e64..f0a0db0 100644
--- a/camera/cameraserver/Android.mk
+++ b/camera/cameraserver/Android.mk
@@ -25,6 +25,7 @@
 	libutils \
 	libui \
 	libbinder \
+	libhidltransport \
 	android.hardware.camera.common@1.0 \
 	android.hardware.camera.provider@2.4 \
 	android.hardware.camera.device@1.0 \
diff --git a/camera/cameraserver/main_cameraserver.cpp b/camera/cameraserver/main_cameraserver.cpp
index f4be468..3972436 100644
--- a/camera/cameraserver/main_cameraserver.cpp
+++ b/camera/cameraserver/main_cameraserver.cpp
@@ -17,8 +17,8 @@
 #define LOG_TAG "cameraserver"
 //#define LOG_NDEBUG 0
 
-// from LOCAL_C_INCLUDES
 #include "CameraService.h"
+#include <hidl/HidlTransportSupport.h>
 
 using namespace android;
 
@@ -26,6 +26,9 @@
 {
     signal(SIGPIPE, SIG_IGN);
 
+    // Set 3 threads for HIDL calls
+    hardware::configureRpcThreadpool(3, /*willjoin*/ false);
+
     sp<ProcessState> proc(ProcessState::self());
     sp<IServiceManager> sm = defaultServiceManager();
     ALOGI("ServiceManager: %p", sm.get());