Merge up to AOSP marshmallow-release

In order to maintain compatibility with older trees, we now have
minadbd.old and minui.old. I had to use a TARGET_GLOBAL_CFLAG to
handle ifdef issues in minui/minui.d because healthd includes
minui/minui.h and there was no other alternative to make minui.h
compatible with older trees without having to modify healthd rules
which is outside of TWRP.

Note that the new minui does not currently have support for qcom
overlay graphics. Support for this graphics mode will likely be
added in a later patch set. If you are building in a 6.0 tree and
have a device that needs qcom overlay graphics, be warned, as off
mode charging may not work properly. A dead battery in this case
could potentially brick your device if it is unable to charge as
healthd handles charging duties.

Update rules for building toolbox and add rules for making toybox

Use permissive.sh in init.rc which will follow symlinks so we do
not have to worry about what binary is supplying the setenforce
functionality (toolbox, toybox, or busybox).

Fix a few warnings in the main recovery binary source code.

Fix a few includes that were missing that prevented compiling in
6.0

Change-Id: Ia67aa2107d260883da5e365475a19bea538e8b97
diff --git a/pigz/yarn.c b/pigz/yarn.c
index 5e557f3..74db3fb 100644
--- a/pigz/yarn.c
+++ b/pigz/yarn.c
@@ -31,6 +31,7 @@
 #include <stdio.h>      /* fprintf(), stderr */
 #include <stdlib.h>     /* exit(), malloc(), free(), NULL */
 #include <pthread.h>    /* pthread_t, pthread_create(), pthread_join(), */
+#include <signal.h>     /* sigaction, SIGUSR1 */
     /* pthread_attr_t, pthread_attr_init(), pthread_attr_destroy(),
        PTHREAD_CREATE_JOINABLE, pthread_attr_setdetachstate(),
        pthread_self(), pthread_equal(),
@@ -39,6 +40,7 @@
        pthread_cond_t, PTHREAD_COND_INITIALIZER, pthread_cond_init(),
        pthread_cond_broadcast(), pthread_cond_wait(), pthread_cond_destroy() */
 #include <errno.h>      /* ENOMEM, EAGAIN, EINVAL */
+#include <string.h>     /* memset */
 
 /* interface definition */
 #include "yarn.h"
@@ -50,6 +52,11 @@
 char *yarn_prefix = "yarn";
 void (*yarn_abort)(int) = NULL;
 
+void thread_exit_handler(int sig)
+{ 
+    printf("this signal is %d \n", sig);
+    pthread_exit(0);
+}
 
 /* immediately exit -- use for errors that shouldn't ever happen */
 local void fail(int err)
@@ -263,6 +270,13 @@
     thread *th;
     struct capsule *capsule;
     pthread_attr_t attr;
+    struct sigaction actions;
+
+    memset(&actions, 0, sizeof(actions)); 
+    sigemptyset(&actions.sa_mask);
+    actions.sa_flags = 0; 
+    actions.sa_handler = thread_exit_handler;
+    ret = sigaction(SIGUSR1,&actions,NULL);
 
     /* construct the requested call and argument for the ignition() routine
        (allocated instead of automatic so that we're sure this will still be
@@ -369,7 +383,7 @@
 {
     int ret;
 
-    if ((ret = pthread_cancel(off_course->id)) != 0)
+    if ((ret = pthread_kill(off_course->id, SIGUSR1)) != 0)
         fail(ret);
     join(off_course);
 }