Snapshot to 6cfc880236a05b22f25353b22132f1ea64a56dee
diff --git a/BoardConfig.mk b/BoardConfig.mk
index b548a76..8713d86 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -31,7 +31,7 @@
 USE_CAMERA_STUB := true
 USE_PROPRIETARY_AUDIO_EXTENSIONS := false
 
-BOARD_LIB_DUMPSTATE := libdumpstate.grouper
+BOARD_HAL_STATIC_LIBRARIES := libdumpstate.grouper
 
 TARGET_RECOVERY_UI_LIB := librecovery_ui_grouper
 
@@ -50,7 +50,6 @@
         genfs_contexts \
         app.te \
         btmacreader.te \
-        compatibility.te \
         device.te \
         drmserver.te \
         init_shell.te \
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 0e75dbe..f427bf4 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -48,4 +48,5 @@
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 $(call add-clean-step, rm -rf $(TARGET_OUT)/etc/permissions/android.hardware.bluetooth_le.xml)
diff --git a/audio_policy.conf b/audio_policy.conf
index 1da8157..aac5c66 100644
--- a/audio_policy.conf
+++ b/audio_policy.conf
@@ -5,7 +5,7 @@
 global_configuration {
   attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
   default_output_device AUDIO_DEVICE_OUT_SPEAKER
-  attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC
+  attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX
 }
 
 # audio hardware module section: contains descriptors for all audio hw modules present on the
@@ -65,4 +65,22 @@
       }
     }
   }
+  r_submix {
+    outputs {
+      submix {
+        sampling_rates 44100|48000
+        channel_masks AUDIO_CHANNEL_OUT_STEREO
+        formats AUDIO_FORMAT_PCM_16_BIT
+        devices AUDIO_DEVICE_OUT_REMOTE_SUBMIX
+      }
+    }
+    inputs {
+      submix {
+        sampling_rates 44100|48000
+        channel_masks AUDIO_CHANNEL_IN_STEREO
+        formats AUDIO_FORMAT_PCM_16_BIT
+        devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
+      }
+    }
+  }
 }
diff --git a/bluetooth/bdroid_buildcfg.h b/bluetooth/bdroid_buildcfg.h
index 3a0fbe1..6bb11fb 100644
--- a/bluetooth/bdroid_buildcfg.h
+++ b/bluetooth/bdroid_buildcfg.h
@@ -25,7 +25,7 @@
 #define BTA_DM_COD {0x1A, 0x01, 0x14}
 
 #define BTIF_HF_SERVICES (BTA_HSP_SERVICE_MASK)
-#define BTIF_HF_SERVICE_NAMES  { BTIF_HSAG_SERVICE_NAME }
+#define BTIF_HF_SERVICE_NAMES  { BTIF_HSAG_SERVICE_NAME, NULL }
 #define PAN_NAP_DISABLED TRUE
 #define BLE_INCLUDED FALSE
 #define BTA_GATT_INCLUDED FALSE
diff --git a/device-common.mk b/device-common.mk
index da4a424..c76e48c 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -72,6 +72,7 @@
     power.grouper \
     audio.a2dp.default \
     audio.usb.default \
+    audio.r_submix.default \
     librs_jni \
     setup_fs \
     l2ping \
@@ -102,10 +103,6 @@
 PRODUCT_COPY_FILES += \
     device/asus/grouper/media_codecs.xml:system/etc/media_codecs.xml
 
-# Bluetooth config file
-PRODUCT_COPY_FILES += \
-    system/bluetooth/data/main.nonsmartphone.conf:system/etc/bluetooth/main.conf \
-
 # audio mixer paths
 PRODUCT_COPY_FILES += \
     device/asus/grouper/mixer_paths.xml:system/etc/mixer_paths.xml
diff --git a/factory-images/generate-factory-images-package.sh b/factory-images/generate-factory-images-package.sh
index 9b17240..a462da4 100755
--- a/factory-images/generate-factory-images-package.sh
+++ b/factory-images/generate-factory-images-package.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Copyright (C) 2011 The Android Open Source Project
+# Copyright 2011 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -38,16 +38,24 @@
 # start jb-mr1.1-dev
 # 551245 = JDP82
 # 573038 = JDQ39
-# end jb-mr1.-dev
+# end jb-mr1.1-dev
+# start jb-mr2-dev
+# 683083 = JWR51
+# 689345 = JWR58
+# 690834 = JWR59
+# 704243 = JWR66G
+# 711294 = JWR66N
+# 737497 = JWR66V
+# end jb-mr2-dev
 
 source ../../../common/clear-factory-images-variables.sh
-BUILD=573038
+BUILD=737497
 DEVICE=grouper
 PRODUCT=nakasi
-VERSION=jdq39
+VERSION=jwr66v
 SRCPREFIX=signed-
 BOOTLOADERFILE=bootloader.bin
-BOOTLOADER=4.18
+BOOTLOADER=4.23
 SLEEPDURATION=10
 UNLOCKBOOTLOADER=true
 ERASEALL=true
diff --git a/init.grouper.rc b/init.grouper.rc
index b28ed51..ee94ed9 100644
--- a/init.grouper.rc
+++ b/init.grouper.rc
@@ -308,7 +308,8 @@
 service wpa_supplicant /system/bin/wpa_supplicant \
     -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
     -I/system/etc/wifi/wpa_supplicant_overlay.conf \
-    -e/data/misc/wifi/entropy.bin
+    -O/data/misc/wifi/sockets \
+    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
     #   we will start as root and wpa_supplicant will switch to user wifi
     #   after setting up the capabilities required for WEXT
     #   user wifi
@@ -320,10 +321,12 @@
 
 service p2p_supplicant /system/bin/wpa_supplicant \
     -iwlan0 -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf \
-    -I/system/etc/wifi/wpa_supplicant_overlay.conf -N \
-    -ip2p0 -Dnl80211 -c /data/misc/wifi/p2p_supplicant.conf \
     -I/system/etc/wifi/wpa_supplicant_overlay.conf \
-    -e/data/misc/wifi/entropy.bin -puse_p2p_group_interface=1
+    -O/data/misc/wifi/sockets -N \
+    -ip2p0 -Dnl80211 -c /data/misc/wifi/p2p_supplicant.conf \
+    -I/system/etc/wifi/p2p_supplicant_overlay.conf \
+    -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin \
+    -g@android:wpa_wlan0
 #   we will start as root and wpa_supplicant will switch to user wifi
 #   after setting up the capabilities required for WEXT
 #   user wifi
@@ -381,7 +384,7 @@
 #Sensor load calibration files end
 
 # virtual sdcard daemon running as media_rw (1023)
-service sdcard /system/bin/sdcard /data/media /mnt/shell/emulated 1023 1023
+service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
     class late_start
 
 # bugreport is triggered by the VOLUME-DOWN and VOLUME-UP keys
diff --git a/kernel b/kernel
index b816093..e9b43bf 100644
--- a/kernel
+++ b/kernel
Binary files differ
diff --git a/media_codecs.xml b/media_codecs.xml
index a6f013d..c55db6e 100644
--- a/media_codecs.xml
+++ b/media_codecs.xml
@@ -95,7 +95,8 @@
         <MediaCodec name="OMX.google.mpeg4.decoder" type="video/mp4v-es" />
         <MediaCodec name="OMX.google.h263.decoder" type="video/3gpp" />
         <MediaCodec name="OMX.google.h264.decoder" type="video/avc" />
-        <MediaCodec name="OMX.google.vpx.decoder" type="video/x-vnd.on2.vp8" />
+        <MediaCodec name="OMX.google.vp8.decoder" type="video/x-vnd.on2.vp8" />
+        <MediaCodec name="OMX.google.vp9.decoder" type="video/x-vnd.on2.vp9" />
     </Decoders>
 
     <Encoders>
@@ -107,6 +108,6 @@
         <MediaCodec name="OMX.google.amrwb.encoder" type="audio/amr-wb" />
         <MediaCodec name="OMX.google.aac.encoder" type="audio/mp4a-latm" />
         <MediaCodec name="OMX.google.flac.encoder" type="audio/flac" />
-        <MediaCodec name="OMX.google.vpx.encoder" type="video/x-vnd.on2.vp8" />
+        <MediaCodec name="OMX.google.vp8.encoder" type="video/x-vnd.on2.vp8" />
     </Encoders>
 </MediaCodecs>
diff --git a/self-extractors/generate-packages.sh b/self-extractors/generate-packages.sh
index 89331b3..a0be66c 100755
--- a/self-extractors/generate-packages.sh
+++ b/self-extractors/generate-packages.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Copyright (C) 2010 The Android Open Source Project
+# Copyright 2010 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -38,7 +38,24 @@
 # 551245 = JDP82
 # 573038 = JDQ39
 # end jb-mr1.1-dev
-BRANCH=jb-mr1.1-dev
+# start jb-mr2-dev
+# 638589 = JWR11D
+# 681336 = JWR50
+# 683083 = JWR51
+# 684634 = JWR52
+# 686185 = JWR53
+# 689345 = JWR58
+# 690834 = JWR59
+# 692263 = JWR60
+# 695489 = JWR64
+# 699533 = JWR66
+# 701448 = JWR66C
+# 704243 = JWR66G
+# 711294 = JWR66N
+# 736095 = JWR66U
+# 737497 = JWR66V
+# end jb-mr2-dev
+BRANCH=jb-mr2-dev
 if test $BRANCH = jb-dev
 then
   ZIP=nakasi-ota-485486.zip
@@ -54,6 +71,11 @@
   ZIP=nakasi-ota-573038.zip
   BUILD=jdq39
 fi # jb-mr1.1-dev
+if test $BRANCH = jb-mr2-dev
+then
+  ZIP=nakasi-ota-737497
+  BUILD=jwr66v
+fi # jb-mr2-dev
 ROOTDEVICE=grouper
 DEVICE=grouper
 MANUFACTURER=asus
diff --git a/self-extractors/nvidia/staging/keymaster/Android.mk b/self-extractors/nvidia/staging/keymaster/Android.mk
index 906dcfe..2e88dc3 100644
--- a/self-extractors/nvidia/staging/keymaster/Android.mk
+++ b/self-extractors/nvidia/staging/keymaster/Android.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 ifeq ($(TARGET_ARCH),arm)
-ifeq (grouper,$(TARGET_DEVICE)))
+ifeq ($(TARGET_DEVICE),grouper)
 
 LOCAL_PATH := $(call my-dir)
 
diff --git a/sepolicy/compatibility.te b/sepolicy/compatibility.te
deleted file mode 100644
index 2f6c079..0000000
--- a/sepolicy/compatibility.te
+++ /dev/null
@@ -1,111 +0,0 @@
-# This file contains autogenerated policy based on
-# denials seen in the wild.
-#
-# As a general rule, you should not add policy to
-# this file. You SHOULD treat this policy very
-# skeptically- while it does preserve compatibility,
-# it is also extremely overbroad.
-#
-# Over time this list should trend to size 0. Your
-# assistance in bringing it to 0 is highly appreciated.
-
-#============= adbd ==============
-allow adbd app_data_file:dir { write add_name };
-allow adbd app_data_file:file { write create open setattr };
-allow adbd proc:file write;
-allow adbd system_data_file:file open;
-
-#============= drmserver ==============
-allow drmserver init:unix_stream_socket { read write };
-
-#============= init ==============
-allow init node:rawip_socket node_bind;
-
-#============= keystore ==============
-allow keystore init:unix_stream_socket { read write };
-
-#============= media_app ==============
-allow media_app system_data_file:file append;
-
-#============= mediaserver ==============
-allow mediaserver init:unix_stream_socket { read write };
-allow mediaserver system_data_file:file open;
-
-#============= nfc ==============
-allow nfc system_data_file:file append;
-
-#============= ping ==============
-allow ping adbd:process sigchld;
-
-#============= platform_app ==============
-allow platform_app init:unix_stream_socket { read write };
-#allow platform_app system_data_file:file append;
-allow platform_app unlabeled:file { read getattr open };
-
-#============= radio ==============
-allow radio init:unix_stream_socket { read write };
-allow radio system_data_file:file append;
-
-#============= release_app ==============
-allow release_app init:unix_stream_socket { read write };
-allow release_app system_data_file:file append;
-
-#============= shared_app ==============
-allow shared_app init:unix_stream_socket { read write };
-#allow shared_app system_data_file:file append;
-allow shared_app unlabeled:file { read getattr open };
-
-#============= shell ==============
-allow shell apk_private_data_file:dir getattr;
-allow shell asec_image_file:dir getattr;
-allow shell backup_data_file:dir getattr;
-allow shell device:sock_file write;
-allow shell drm_data_file:dir getattr;
-allow shell gps_data_file:dir getattr;
-allow shell rootfs:file getattr;
-allow shell sdcard_internal:dir { create rmdir };
-#allow shell self:capability { fowner fsetid dac_override };
-#allow shell self:capability2 syslog;
-#allow shell system_data_file:dir { write add_name };
-#allow shell system_data_file:file { write create setattr };
-allow shell vold:unix_stream_socket connectto;
-allow shell vold_socket:sock_file write;
-
-#============= surfaceflinger ==============
-allow surfaceflinger adbd:binder call;
-allow surfaceflinger init:unix_stream_socket { read write };
-allow surfaceflinger nfc:binder call;
-allow surfaceflinger sysfs:file write;
-
-#============= system ==============
-allow system adbd_socket:sock_file write;
-allow system init:unix_stream_socket { read write };
-allow system proc:file write;
-allow system security_file:lnk_file read;
-allow system unlabeled:file { read getattr open };
-
-#============= system_app ==============
-allow system_app unlabeled:file { read getattr open };
-
-#============= untrusted_app ==============
-allow untrusted_app init:dir { getattr search };
-allow untrusted_app init:file { read getattr open };
-allow untrusted_app init:unix_stream_socket { read write };
-allow untrusted_app kernel:dir { search getattr };
-allow untrusted_app kernel:file { read getattr open };
-allow untrusted_app servicemanager:dir { search getattr };
-allow untrusted_app servicemanager:file { read getattr open };
-allow untrusted_app shared_app:fifo_file write;
-#allow untrusted_app system_data_file:file append;
-allow untrusted_app unlabeled:dir getattr;
-allow untrusted_app unlabeled:file { read getattr open };
-
-#============= vold ==============
-allow vold unlabeled:dir { read getattr open };
-
-#============= wpa ==============
-allow wpa init:unix_dgram_socket sendto;
-allow wpa wifi_data_file:sock_file write;
-
-#============= zygote ==============
-allow zygote security_file:lnk_file read;
diff --git a/system.prop b/system.prop
index 79b5203..befcf94 100644
--- a/system.prop
+++ b/system.prop
@@ -11,3 +11,6 @@
 
 # set default lcd density to TVDPI
 ro.sf.lcd_density=213
+
+# don't preload OpenGL in Zygote, the Tegra drivers do not like it
+ro.zygote.disable_gl_preload=true
diff --git a/vendorsetup.sh b/vendorsetup.sh
index 749ec76..aa3e953 100644
--- a/vendorsetup.sh
+++ b/vendorsetup.sh
@@ -20,4 +20,4 @@
 # In particular, you can add lunch options with the add_lunch_combo
 # function: add_lunch_combo generic-eng
 
-add_lunch_combo full_grouper-userdebug
+add_lunch_combo aosp_grouper-userdebug