Tell JVM to not wait for HWUI worker threads upon shutdown

RenderThread is setup as a daemon thread, which allows JVM to
exit without waiting on it. This CL does same setup for HWUI
worker threads, which offload work from the RenderThread.
This fixes an issue exposed by Vulkan pipeline, which is pushing
different loads to the worker threads and causing some java tests
to hang on exit. This is not a Vulkan specific issue, because GL
also hangs if worker thread is started.

Bug: 123374538
Test: Ran DismissDialogsInstrumentation test
Change-Id: Ie4ee94737ced975323a0792f57f8426c958e8056
diff --git a/libs/hwui/thread/TaskManager.cpp b/libs/hwui/thread/TaskManager.cpp
index 26ff6eb..6493d49 100644
--- a/libs/hwui/thread/TaskManager.cpp
+++ b/libs/hwui/thread/TaskManager.cpp
@@ -21,6 +21,7 @@
 #include "TaskManager.h"
 #include "TaskProcessor.h"
 #include "utils/MathUtils.h"
+#include "renderthread/RenderThread.h"
 
 namespace android {
 namespace uirenderer {
@@ -84,6 +85,11 @@
 
 status_t TaskManager::WorkerThread::readyToRun() {
     setpriority(PRIO_PROCESS, 0, PRIORITY_FOREGROUND);
+    auto onStartHook = renderthread::RenderThread::getOnStartHook();
+    if (onStartHook) {
+        onStartHook();
+    }
+
     return NO_ERROR;
 }
 
diff --git a/libs/hwui/thread/TaskManager.h b/libs/hwui/thread/TaskManager.h
index c4c1291..6c67222 100644
--- a/libs/hwui/thread/TaskManager.h
+++ b/libs/hwui/thread/TaskManager.h
@@ -77,7 +77,8 @@
 
     class WorkerThread : public Thread {
     public:
-        explicit WorkerThread(const String8& name) : mSignal(Condition::WAKE_UP_ONE), mName(name) {}
+        explicit WorkerThread(const String8& name)
+                : Thread(false), mSignal(Condition::WAKE_UP_ONE), mName(name) {}
 
         bool addTask(const TaskWrapper& task);
         size_t getTaskCount() const;