Enable GKI_PTHREAD_JOINABLE

Improve NFC Off time by 1 second

Bug: 243601426
Test: atest NfcNciInstrumentationTests
Change-Id: I15f5a4daf10ed5f7a84a3d7e18847b2a908c4669
diff --git a/src/Android.bp b/src/Android.bp
index af3ac8d..df46aaa 100644
--- a/src/Android.bp
+++ b/src/Android.bp
@@ -39,6 +39,7 @@
     cflags: [
         "-DDYN_ALLOC=1",
         "-DBUILDCFG=1",
+        "-DGKI_PTHREAD_JOINABLE",
         "-Wall",
         "-Werror",
         "-Wimplicit-fallthrough",
diff --git a/src/gki/ulinux/gki_ulinux.cc b/src/gki/ulinux/gki_ulinux.cc
index c7dd7bc..6459c02 100644
--- a/src/gki/ulinux/gki_ulinux.cc
+++ b/src/gki/ulinux/gki_ulinux.cc
@@ -300,11 +300,16 @@
       while ((gki_cb.com.OSWaitEvt[task_id - 1] != 0) && (++i < 10))
         usleep(100 * 1000);
 #else
-      /* wait for proper Arnold Schwarzenegger task state */
-      result = pthread_join(gki_cb.os.thread_id[task_id - 1], NULL);
-      if (result < 0) {
-        DLOG_IF(INFO, nfc_debug_enabled)
-            << StringPrintf("FAILED: result: %d", result);
+      /* Skip BTU_TASK due to BTU_TASK is used for GKI_run() and it terminates
+       * after GKI_shutdown().
+       */
+      if ((task_id - 1) != BTU_TASK) {
+        /* wait for proper Arnold Schwarzenegger task state */
+        result = pthread_join(gki_cb.os.thread_id[task_id - 1], NULL);
+        if (result < 0) {
+          DLOG_IF(INFO, nfc_debug_enabled)
+              << StringPrintf("FAILED: result: %d", result);
+        }
       }
 #endif
       DLOG_IF(INFO, nfc_debug_enabled)