Merge "liblog: deprecate export of LOGGER_LOG_* defines"
diff --git a/adb/adb.c b/adb/adb.c
index 41270f9..66e4953 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -1335,12 +1335,11 @@
         ** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump)
         ** AID_SDCARD_R to allow reading from the SD card
         ** AID_SDCARD_RW to allow writing to the SD card
-        ** AID_MOUNT to allow unmounting the SD card before rebooting
         ** AID_NET_BW_STATS to read out qtaguid statistics
         */
         gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
                            AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW,
-                           AID_MOUNT, AID_NET_BW_STATS };
+                           AID_NET_BW_STATS };
         if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
             exit(1);
         }
diff --git a/adb/services.c b/adb/services.c
index 95cd7d0..be0cc72 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -116,23 +116,10 @@
 {
     char buf[100];
     char property_val[PROPERTY_VALUE_MAX];
-    int pid, ret;
+    int ret;
 
     sync();
 
-    /* Attempt to unmount the SD card first.
-     * No need to bother checking for errors.
-     */
-    pid = fork();
-    if (pid == 0) {
-        /* ask vdc to unmount it */
-        execl("/system/bin/vdc", "/system/bin/vdc", "volume", "unmount",
-                getenv("EXTERNAL_STORAGE"), "force", NULL);
-    } else if (pid > 0) {
-        /* wait until vdc succeeds or fails */
-        waitpid(pid, &ret, 0);
-    }
-
     ret = snprintf(property_val, sizeof(property_val), "reboot,%s", (char *) arg);
     if (ret >= (int) sizeof(property_val)) {
         snprintf(buf, sizeof(buf), "reboot string too long. length=%d\n", ret);
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 73a6e56..7d26c6f 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -889,6 +889,7 @@
         {"kernel_offset", required_argument, 0, 'k'},
         {"page_size", required_argument, 0, 'n'},
         {"ramdisk_offset", required_argument, 0, 'r'},
+        {"tags_offset", required_argument, 0, 't'},
         {"help", 0, 0, 'h'},
         {0, 0, 0, 0}
     };
@@ -897,7 +898,7 @@
 
     while (1) {
         int option_index = 0;
-        c = getopt_long(argc, argv, "wub:k:n:r:s:S:lp:c:i:m:h", longopts, NULL);
+        c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:h", longopts, NULL);
         if (c < 0) {
             break;
         }
@@ -938,6 +939,9 @@
         case 'r':
             ramdisk_offset = strtoul(optarg, 0, 16);
             break;
+        case 't':
+            tags_offset = strtoul(optarg, 0, 16);
+            break;
         case 's':
             serial = optarg;
             break;
diff --git a/fastbootd/commands/partitions.c b/fastbootd/commands/partitions.c
index de80ea3..74232e6 100644
--- a/fastbootd/commands/partitions.c
+++ b/fastbootd/commands/partitions.c
@@ -42,6 +42,7 @@
 #include <sys/ioctl.h>
 #include <stdlib.h>
 #include <cutils/config_utils.h>
+#include <inttypes.h>
 
 #include "partitions.h"
 #include "debug.h"
@@ -80,7 +81,7 @@
 
     uint64_t sz = get_file_size64(fd);
     if (sz < size + location) {
-        D(ERR, "the location of mapping area is outside of the device size %lld", sz);
+        D(ERR, "the location of mapping area is outside of the device size %" PRId64, sz);
         return 1;
     }
     location = ALIGN_DOWN(location, PAGE_SIZE);
@@ -89,7 +90,7 @@
 
     if (mapping->map_ptr == MAP_FAILED) {
         mapping->ptr = MAP_FAILED;
-        D(ERR, "map failed %d", (int) mapping->map_ptr);
+        D(ERR, "map failed: %s", strerror(errno));
         return 1;
     }
 
diff --git a/fastbootd/other/gptedit.c b/fastbootd/other/gptedit.c
index 16d34a5..d423529 100644
--- a/fastbootd/other/gptedit.c
+++ b/fastbootd/other/gptedit.c
@@ -29,9 +29,10 @@
  * SUCH DAMAGE.
  */
 
+#include <getopt.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <getopt.h>
 #include <unistd.h>
 
 #include <cutils/klog.h>
@@ -185,7 +186,7 @@
             name[m] = entry->name[m] & 127;
         }
         name[m] = 0;
-        printf("#%03d %13lld %13lld %s\n",
+        printf("#%03d %13"PRId64" %13"PRId64" %s\n",
             n + 1, entry->first_lba, entry->last_lba, name);
     }
 }
@@ -197,11 +198,11 @@
     char temp_guid[17];
     temp_guid[16] = 0;
 
-    printf("header_lba %lld\n", table->header->current_lba);
-    printf("backup_lba %lld\n", table->header->backup_lba);
-    printf("first_lba %lld\n", table->header->first_usable_lba);
-    printf("last_lba %lld\n", table->header->last_usable_lba);
-    printf("entries_lba %lld\n", table->header->entries_lba);
+    printf("header_lba %"PRId64"\n", table->header->current_lba);
+    printf("backup_lba %"PRId64"\n", table->header->backup_lba);
+    printf("first_lba %"PRId64"\n", table->header->first_usable_lba);
+    printf("last_lba %"PRId64"\n", table->header->last_usable_lba);
+    printf("entries_lba %"PRId64"\n", table->header->entries_lba);
     snprintf(temp_guid, 17, "%s", table->header->disk_guid);
     printf("guid \"%s\"", temp_guid);
 
@@ -220,8 +221,8 @@
         printf("    %s {\n", name);
         snprintf(temp_guid, 17, "%s", entry->partition_guid);
         printf("        guid \"%s\"\n", temp_guid);
-        printf("        first_lba %lld\n", entry->first_lba);
-        printf("        partition_size %lld\n", size);
+        printf("        first_lba %"PRId64"\n", entry->first_lba);
+        printf("        partition_size %"PRId64"\n", size);
         if (entry->flags & GPT_FLAG_SYSTEM)
             printf("        system\n");
         if (entry->flags & GPT_FLAG_BOOTABLE)
diff --git a/fastbootd/utils.c b/fastbootd/utils.c
index fe3f0f8..bef2463 100644
--- a/fastbootd/utils.c
+++ b/fastbootd/utils.c
@@ -169,7 +169,7 @@
     do {
         ret = TEMP_FAILURE_RETRY(write(bulk_in, buf + count, length - count));
         if (ret < 0) {
-            D(WARN, "[ bulk_write failed fd=%d length=%d errno=%d %s ]",
+            D(WARN, "[ bulk_write failed fd=%d length=%zu errno=%d %s ]",
                     bulk_in, length, errno, strerror(errno));
             return -1;
         } else {
@@ -190,13 +190,13 @@
         size_t to_read = (length - n > READ_BUF_SIZE) ? READ_BUF_SIZE : length - n;
         ret = TEMP_FAILURE_RETRY(read(bulk_out, buf + n, to_read));
         if (ret < 0) {
-            D(WARN, "[ bulk_read failed fd=%d length=%d errno=%d %s ]",
+            D(WARN, "[ bulk_read failed fd=%d length=%zu errno=%d %s ]",
                     bulk_out, length, errno, strerror(errno));
             return ret;
         }
         n += ret;
         if (ret < (ssize_t)to_read) {
-            D(VERBOSE, "bulk_read short read, ret=%zd to_read=%u n=%u length=%u",
+            D(VERBOSE, "bulk_read short read, ret=%zd to_read=%zu n=%zu length=%zu",
                     ret, to_read, n, length);
             break;
         }
diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c
index 6d9d20c..24ce806 100644
--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -517,6 +517,7 @@
     int encrypted = 0;
     int ret = -1;
     int mret;
+    int mount_errno;
 
     if (!fstab) {
         return ret;
@@ -560,6 +561,9 @@
             continue;
         }
 
+        /* back up errno as partition_wipe clobbers the value */
+        mount_errno = errno;
+
         /* mount(2) returned an error, check if it's encrypted and deal with it */
         if ((fstab->recs[i].fs_mgr_flags & MF_CRYPT) &&
             !partition_wiped(fstab->recs[i].blk_device)) {
@@ -568,14 +572,16 @@
              */
             if (mount("tmpfs", fstab->recs[i].mount_point, "tmpfs",
                   MS_NOATIME | MS_NOSUID | MS_NODEV, CRYPTO_TMPFS_OPTIONS) < 0) {
-                ERROR("Cannot mount tmpfs filesystem for encrypted fs at %s\n",
-                        fstab->recs[i].mount_point);
+                ERROR("Cannot mount tmpfs filesystem for encrypted fs at %s error: %s\n",
+                        fstab->recs[i].mount_point, strerror(errno));
                 goto out;
             }
             encrypted = 1;
         } else {
-            ERROR("Cannot mount filesystem on %s at %s\n",
-                    fstab->recs[i].blk_device, fstab->recs[i].mount_point);
+            ERROR("Failed to mount an un-encryptable or wiped partition on"
+                    "%s at %s options: %s error: %s\n",
+                    fstab->recs[i].blk_device, fstab->recs[i].mount_point,
+                    fstab->recs[i].fs_options, strerror(mount_errno));
             goto out;
         }
     }
@@ -644,8 +650,8 @@
         }
         if (__mount(n_blk_device, m, fstab->recs[i].fs_type,
                     fstab->recs[i].flags, fstab->recs[i].fs_options)) {
-            ERROR("Cannot mount filesystem on %s at %s\n",
-                    n_blk_device, m);
+            ERROR("Cannot mount filesystem on %s at %s options: %s error: %s\n",
+                n_blk_device, m, fstab->recs[i].fs_options, strerror(errno));
             goto out;
         } else {
             ret = 0;
diff --git a/include/cutils/atomic-aarch64.h b/include/cutils/atomic-aarch64.h
new file mode 100644
index 0000000..927379f
--- /dev/null
+++ b/include/cutils/atomic-aarch64.h
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_CUTILS_ATOMIC_AARCH64_H
+#define ANDROID_CUTILS_ATOMIC_AARCH64_H
+
+#include <stdint.h>
+
+#ifndef ANDROID_ATOMIC_INLINE
+#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
+#endif
+
+/*
+   TODOAArch64: Revisit the below functions and check for potential
+   optimizations using assembly code or otherwise.
+*/
+
+extern ANDROID_ATOMIC_INLINE
+void android_compiler_barrier(void)
+{
+    __asm__ __volatile__ ("" : : : "memory");
+}
+
+#if ANDROID_SMP == 0
+extern ANDROID_ATOMIC_INLINE
+void android_memory_barrier(void)
+{
+    android_compiler_barrier();
+}
+extern ANDROID_ATOMIC_INLINE
+void android_memory_store_barrier(void)
+{
+    android_compiler_barrier();
+}
+#else
+extern ANDROID_ATOMIC_INLINE
+void android_memory_barrier(void)
+{
+    __asm__ __volatile__ ("dmb ish" : : : "memory");
+}
+extern ANDROID_ATOMIC_INLINE
+void android_memory_store_barrier(void)
+{
+    __asm__ __volatile__ ("dmb isht" : : : "memory");
+}
+#endif
+
+extern ANDROID_ATOMIC_INLINE
+int32_t android_atomic_acquire_load(volatile const int32_t *ptr)
+{
+    int32_t value = *ptr;
+    android_memory_barrier();
+    return value;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int64_t android_atomic_acquire_load64(volatile const int64_t *ptr)
+{
+    int64_t value = *ptr;
+    android_memory_barrier();
+    return value;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int32_t android_atomic_release_load(volatile const int32_t *ptr)
+{
+    android_memory_barrier();
+    return *ptr;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int64_t android_atomic_release_load64(volatile const int64_t *ptr)
+{
+    android_memory_barrier();
+    return *ptr;
+}
+
+extern ANDROID_ATOMIC_INLINE
+void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
+{
+    *ptr = value;
+    android_memory_barrier();
+}
+
+extern ANDROID_ATOMIC_INLINE
+void android_atomic_acquire_store64(int64_t value, volatile int64_t *ptr)
+{
+    *ptr = value;
+    android_memory_barrier();
+}
+
+extern ANDROID_ATOMIC_INLINE
+void android_atomic_release_store(int32_t value, volatile int32_t *ptr)
+{
+    android_memory_barrier();
+    *ptr = value;
+}
+
+extern ANDROID_ATOMIC_INLINE
+void android_atomic_release_store64(int64_t value, volatile int64_t *ptr)
+{
+    android_memory_barrier();
+    *ptr = value;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int android_atomic_cas(int32_t old_value, int32_t new_value,
+                       volatile int32_t *ptr)
+{
+    return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int64_t android_atomic_cas64(int64_t old_value, int64_t new_value,
+                             volatile int64_t *ptr)
+{
+    return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int android_atomic_acquire_cas(int32_t old_value, int32_t new_value,
+                               volatile int32_t *ptr)
+{
+    int status = android_atomic_cas(old_value, new_value, ptr);
+    android_memory_barrier();
+    return status;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int64_t android_atomic_acquire_cas64(int64_t old_value, int64_t new_value,
+                                     volatile int64_t *ptr)
+{
+    int status = android_atomic_cas64(old_value, new_value, ptr);
+    android_memory_barrier();
+    return status;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int android_atomic_release_cas(int32_t old_value, int32_t new_value,
+                               volatile int32_t *ptr)
+{
+    android_memory_barrier();
+    return android_atomic_cas(old_value, new_value, ptr);
+}
+
+extern ANDROID_ATOMIC_INLINE
+int64_t android_atomic_release_cas64(int64_t old_value, int64_t new_value,
+                                     volatile int64_t *ptr)
+{
+    android_memory_barrier();
+    return android_atomic_cas64(old_value, new_value, ptr);
+}
+
+extern ANDROID_ATOMIC_INLINE
+int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr)
+{
+    int32_t prev, status;
+    android_memory_barrier();
+    do {
+        prev = *ptr;
+        status = android_atomic_cas(prev, prev + increment, ptr);
+    } while (__builtin_expect(status != 0, 0));
+    return prev;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int32_t android_atomic_inc(volatile int32_t *addr)
+{
+    return android_atomic_add(1, addr);
+}
+
+extern ANDROID_ATOMIC_INLINE
+int32_t android_atomic_dec(volatile int32_t *addr)
+{
+    return android_atomic_add(-1, addr);
+}
+
+extern ANDROID_ATOMIC_INLINE
+int32_t android_atomic_and(int32_t value, volatile int32_t *ptr)
+{
+    int32_t prev, status;
+    android_memory_barrier();
+    do {
+        prev = *ptr;
+        status = android_atomic_cas(prev, prev & value, ptr);
+    } while (__builtin_expect(status != 0, 0));
+    return prev;
+}
+
+extern ANDROID_ATOMIC_INLINE
+int32_t android_atomic_or(int32_t value, volatile int32_t *ptr)
+{
+    int32_t prev, status;
+    android_memory_barrier();
+    do {
+        prev = *ptr;
+        status = android_atomic_cas(prev, prev | value, ptr);
+    } while (__builtin_expect(status != 0, 0));
+    return prev;
+}
+
+#endif /* ANDROID_CUTILS_ATOMIC_AARCH64_H */
diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h
index 0b13138..29a28d5 100644
--- a/include/cutils/atomic-inline.h
+++ b/include/cutils/atomic-inline.h
@@ -43,7 +43,9 @@
 # error "Must define ANDROID_SMP before including atomic-inline.h"
 #endif
 
-#if defined(__arm__)
+#if defined(__aarch64__)
+#include <cutils/atomic-aarch64.h>
+#elif defined(__arm__)
 #include <cutils/atomic-arm.h>
 #elif defined(__i386__) || defined(__x86_64__)
 #include <cutils/atomic-x86.h>
diff --git a/include/cutils/atomic.h b/include/cutils/atomic.h
index ae42eb8..1787e34 100644
--- a/include/cutils/atomic.h
+++ b/include/cutils/atomic.h
@@ -80,6 +80,11 @@
 int32_t android_atomic_acquire_load(volatile const int32_t* addr);
 int32_t android_atomic_release_load(volatile const int32_t* addr);
 
+#if defined (__LP64__)
+int64_t android_atomic_acquire_load64(volatile const int64_t* addr);
+int64_t android_atomic_release_load64(volatile const int64_t* addr);
+#endif
+
 /*
  * Perform an atomic store with "acquire" or "release" ordering.
  *
@@ -89,6 +94,11 @@
 void android_atomic_acquire_store(int32_t value, volatile int32_t* addr);
 void android_atomic_release_store(int32_t value, volatile int32_t* addr);
 
+#if defined (__LP64__)
+void android_atomic_acquire_store64(int64_t value, volatile int64_t* addr);
+void android_atomic_release_store64(int64_t value, volatile int64_t* addr);
+#endif
+
 /*
  * Compare-and-set operation with "acquire" or "release" ordering.
  *
@@ -106,6 +116,13 @@
 int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue,
         volatile int32_t* addr);
 
+#if defined (__LP64__)
+int64_t android_atomic_acquire_cas64(int64_t old_value, int64_t new_value,
+        volatile int64_t *ptr);
+int64_t android_atomic_release_cas64(int64_t old_value, int64_t new_value,
+        volatile int64_t *ptr);
+#endif
+
 /*
  * Aliases for code using an older version of this header.  These are now
  * deprecated and should not be used.  The definitions will be removed
diff --git a/include/system/audio.h b/include/system/audio.h
index aa7ac02..2424baf 100644
--- a/include/system/audio.h
+++ b/include/system/audio.h
@@ -34,11 +34,17 @@
 /* device address used to refer to the standard remote submix */
 #define AUDIO_REMOTE_SUBMIX_DEVICE_ADDRESS "0"
 
+/* AudioFlinger and AudioPolicy services use I/O handles to identify audio sources and sinks */
 typedef int audio_io_handle_t;
+#define AUDIO_IO_HANDLE_NONE    0
 
 /* Audio stream types */
 typedef enum {
+    /* These values must kept in sync with
+     * frameworks/base/media/java/android/media/AudioSystem.java
+     */
     AUDIO_STREAM_DEFAULT          = -1,
+    AUDIO_STREAM_MIN              = 0,
     AUDIO_STREAM_VOICE_CALL       = 0,
     AUDIO_STREAM_SYSTEM           = 1,
     AUDIO_STREAM_RING             = 2,
@@ -55,7 +61,9 @@
 } audio_stream_type_t;
 
 /* Do not change these values without updating their counterparts
- * in media/java/android/media/MediaRecorder.java!
+ * in frameworks/base/media/java/android/media/MediaRecorder.java,
+ * frameworks/av/services/audioflinger/AudioPolicyService.cpp,
+ * and system/media/audio_effects/include/audio_effects/audio_effects_conf.h!
  */
 typedef enum {
     AUDIO_SOURCE_DEFAULT             = 0,
@@ -93,6 +101,13 @@
      * (value must be 0)
      */
     AUDIO_SESSION_OUTPUT_MIX = 0,
+
+    /* application does not specify an explicit session ID to be used,
+     * and requests a new session ID to be allocated
+     * TODO use unique values for AUDIO_SESSION_OUTPUT_MIX and AUDIO_SESSION_ALLOCATE,
+     * after all uses have been updated from 0 to the appropriate symbol, and have been tested.
+     */
+    AUDIO_SESSION_ALLOCATE = 0,
 } audio_session_t;
 
 /* Audio sub formats (see enum audio_format). */
@@ -103,8 +118,11 @@
     AUDIO_FORMAT_PCM_SUB_8_BIT           = 0x2, /* DO NOT CHANGE - PCM unsigned 8 bits */
     AUDIO_FORMAT_PCM_SUB_32_BIT          = 0x3, /* PCM signed .31 fixed point */
     AUDIO_FORMAT_PCM_SUB_8_24_BIT        = 0x4, /* PCM signed 7.24 fixed point */
+    AUDIO_FORMAT_PCM_SUB_FLOAT           = 0x5, /* PCM single-precision floating point */
 } audio_format_pcm_sub_fmt_t;
 
+/* The audio_format_*_sub_fmt_t declarations are not currently used */
+
 /* MP3 sub format field definition : can use 11 LSBs in the same way as MP3
  * frame header to specify bit rate, stereo mode, version...
  */
@@ -129,7 +147,7 @@
     AUDIO_FORMAT_VORBIS_SUB_NONE         = 0x0,
 } audio_format_vorbis_sub_fmt_t;
 
-/* Audio format consists in a main format field (upper 8 bits) and a sub format
+/* Audio format consists of a main format field (upper 8 bits) and a sub format
  * field (lower 24 bits).
  *
  * The main format indicates the main codec type. The sub format field
@@ -153,14 +171,18 @@
     AUDIO_FORMAT_SUB_MASK            = 0x00FFFFFFUL,
 
     /* Aliases */
+    /* note != AudioFormat.ENCODING_PCM_16BIT */
     AUDIO_FORMAT_PCM_16_BIT          = (AUDIO_FORMAT_PCM |
                                         AUDIO_FORMAT_PCM_SUB_16_BIT),
+    /* note != AudioFormat.ENCODING_PCM_8BIT */
     AUDIO_FORMAT_PCM_8_BIT           = (AUDIO_FORMAT_PCM |
                                         AUDIO_FORMAT_PCM_SUB_8_BIT),
     AUDIO_FORMAT_PCM_32_BIT          = (AUDIO_FORMAT_PCM |
                                         AUDIO_FORMAT_PCM_SUB_32_BIT),
     AUDIO_FORMAT_PCM_8_24_BIT        = (AUDIO_FORMAT_PCM |
                                         AUDIO_FORMAT_PCM_SUB_8_24_BIT),
+    AUDIO_FORMAT_PCM_FLOAT           = (AUDIO_FORMAT_PCM |
+                                        AUDIO_FORMAT_PCM_SUB_FLOAT),
 } audio_format_t;
 
 enum {
@@ -266,6 +288,15 @@
 
 typedef uint32_t audio_channel_mask_t;
 
+/* Expresses the convention when stereo audio samples are stored interleaved
+ * in an array.  This should improve readability by allowing code to use
+ * symbolic indices instead of hard-coded [0] and [1].
+ */
+enum {
+    AUDIO_INTERLEAVE_LEFT   = 0,
+    AUDIO_INTERLEAVE_RIGHT  = 1,
+};
+
 typedef enum {
     AUDIO_MODE_INVALID          = -2,
     AUDIO_MODE_CURRENT          = -1,
@@ -278,7 +309,9 @@
     AUDIO_MODE_MAX              = AUDIO_MODE_CNT - 1,
 } audio_mode_t;
 
+/* This enum is deprecated */
 typedef enum {
+    AUDIO_IN_ACOUSTICS_NONE          = 0,
     AUDIO_IN_ACOUSTICS_AGC_ENABLE    = 0x0001,
     AUDIO_IN_ACOUSTICS_AGC_DISABLE   = 0,
     AUDIO_IN_ACOUSTICS_NS_ENABLE     = 0x0002,
@@ -304,9 +337,12 @@
     AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
     AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER    = 0x200,
     AUDIO_DEVICE_OUT_AUX_DIGITAL               = 0x400,
+    /* uses an analog connection (multiplexed over the USB connector pins for instance) */
     AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET         = 0x800,
     AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET         = 0x1000,
+    /* USB accessory mode: your Android device is a USB device and the dock is a USB host */
     AUDIO_DEVICE_OUT_USB_ACCESSORY             = 0x2000,
+    /* USB host mode: your Android device is a USB host and the dock is a USB device */
     AUDIO_DEVICE_OUT_USB_DEVICE                = 0x4000,
     AUDIO_DEVICE_OUT_REMOTE_SUBMIX             = 0x8000,
     AUDIO_DEVICE_OUT_DEFAULT                   = AUDIO_DEVICE_BIT_DEFAULT,
@@ -522,7 +558,7 @@
  */
 static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count)
 {
-    switch(channel_count) {
+    switch (channel_count) {
     case 1:
         return AUDIO_CHANNEL_OUT_MONO;
     case 2:
@@ -562,7 +598,7 @@
     switch (format & AUDIO_FORMAT_MAIN_MASK) {
     case AUDIO_FORMAT_PCM:
         if (format != AUDIO_FORMAT_PCM_16_BIT &&
-                format != AUDIO_FORMAT_PCM_8_BIT) {
+                format != AUDIO_FORMAT_PCM_8_BIT && format != AUDIO_FORMAT_PCM_FLOAT) {
             return false;
         }
     case AUDIO_FORMAT_MP3:
@@ -598,6 +634,9 @@
     case AUDIO_FORMAT_PCM_8_BIT:
         size = sizeof(uint8_t);
         break;
+    case AUDIO_FORMAT_PCM_FLOAT:
+        size = sizeof(float);
+        break;
     default:
         break;
     }
diff --git a/libbacktrace/Android.mk b/libbacktrace/Android.mk
index a6b9c2b..d2fd79e 100644
--- a/libbacktrace/Android.mk
+++ b/libbacktrace/Android.mk
@@ -148,6 +148,11 @@
 	-DGTEST_OS_LINUX_ANDROID \
 	-DGTEST_HAS_STD_STRING \
 
+ifeq ($(TARGET_ARCH),aarch64)
+  $(info TODO: $(LOCAL_PATH)/Android.mk -fstack-protector not yet available for the AArch64 toolchain)
+  LOCAL_CFLAGS += -fno-stack-protector
+endif # aarch64
+
 LOCAL_CONLYFLAGS += \
 	$(common_conlyflags) \
 
@@ -168,18 +173,15 @@
 include $(BUILD_NATIVE_TEST)
 
 #----------------------------------------------------------------------------
-# Only linux-x86 host versions of libbacktrace supported.
+# Only x86 host versions of libbacktrace supported.
 #----------------------------------------------------------------------------
-ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
+ifeq ($(HOST_ARCH),x86)
 
 #----------------------------------------------------------------------------
 # The host libbacktrace library using libcorkscrew
 #----------------------------------------------------------------------------
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES += \
-	$(common_src) \
-	Corkscrew.cpp \
 
 LOCAL_CFLAGS += \
 	$(common_cflags) \
@@ -187,21 +189,12 @@
 LOCAL_CONLYFLAGS += \
 	$(common_conlyflags) \
 
-LOCAL_CPPFLAGS += \
-	$(common_cppflags) \
-
 LOCAL_C_INCLUDES := \
 	$(common_c_includes) \
-	system/core/libcorkscrew \
 
 LOCAL_SHARED_LIBRARIES := \
 	libgccdemangle \
 	liblog \
-	libcorkscrew \
-
-LOCAL_LDLIBS += \
-	-ldl \
-	-lrt \
 
 LOCAL_MODULE := libbacktrace
 LOCAL_MODULE_TAGS := optional
@@ -209,9 +202,38 @@
 LOCAL_ADDITIONAL_DEPENDENCIES := \
 	$(LOCAL_PATH)/Android.mk
 
+ifeq ($(HOST_OS),linux)
+LOCAL_SRC_FILES += \
+	$(common_src) \
+	Corkscrew.cpp \
+
+LOCAL_C_INCLUDES += \
+	system/core/libcorkscrew \
+
+LOCAL_SHARED_LIBRARIES := \
+	libcorkscrew \
+
+LOCAL_CPPFLAGS += \
+	$(common_cppflags) \
+
+LOCAL_LDLIBS += \
+	-ldl \
+	-lrt \
+
+else
+LOCAL_SRC_FILES += \
+	map_info.c \
+
+endif
+
 include $(BUILD_HOST_SHARED_LIBRARY)
 
 #----------------------------------------------------------------------------
+# The host test is only supported on linux.
+#----------------------------------------------------------------------------
+ifeq ($(HOST_OS),linux)
+
+#----------------------------------------------------------------------------
 # libbacktrace host test library, all optimizations turned off
 #----------------------------------------------------------------------------
 include $(CLEAR_VARS)
@@ -263,4 +285,6 @@
 
 include $(BUILD_HOST_NATIVE_TEST)
 
-endif # HOST_OS-HOST_ARCH == linux-x86
+endif # HOST_OS == linux
+
+endif # HOST_ARCH == x86
diff --git a/libbacktrace/Backtrace.cpp b/libbacktrace/Backtrace.cpp
index fa85872..20667e0 100644
--- a/libbacktrace/Backtrace.cpp
+++ b/libbacktrace/Backtrace.cpp
@@ -87,7 +87,7 @@
   if (!func_name.empty()) {
 #if defined(__APPLE__)
     // Mac OS' __cxa_demangle demangles "f" as "float"; last tested on 10.7.
-    if (symbol_name[0] != '_') {
+    if (func_name[0] != '_') {
       return func_name;
     }
 #endif
diff --git a/libbacktrace/BacktraceThread.h b/libbacktrace/BacktraceThread.h
index bcb56c9..a4b6ecb 100644
--- a/libbacktrace/BacktraceThread.h
+++ b/libbacktrace/BacktraceThread.h
@@ -18,7 +18,6 @@
 #define _LIBBACKTRACE_BACKTRACE_THREAD_H
 
 #include <inttypes.h>
-#include <pthread.h>
 #include <sys/types.h>
 
 #include "Backtrace.h"
diff --git a/rootdir/init.environ.rc.in b/rootdir/init.environ.rc.in
index d2f74c0..927c33d 100644
--- a/rootdir/init.environ.rc.in
+++ b/rootdir/init.environ.rc.in
@@ -1,7 +1,6 @@
 # set up the global environment
 on init
     export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
-    export LD_LIBRARY_PATH /vendor/lib:/system/lib
     export ANDROID_BOOTLOGO 1
     export ANDROID_ROOT /system
     export ANDROID_ASSETS /system/app
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 7ee1be9..fc0fc3e 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -231,6 +231,7 @@
     chmod 0660 /data/misc/wifi/wpa_supplicant.conf
     mkdir /data/local 0751 root root
     mkdir /data/misc/media 0700 media media
+    restorecon_recursive /data/misc/media
 
     # Set security context of any pre-existing /data/misc/adb/adb_keys file.
     restorecon /data/misc/adb