DO NOT MERGE: resync to AOSP

mirror-aosp-master and stage-aosp-master should be identical,
but they're not. Pull all missing changes from AOSP into
stage.

Bug: 18224704
Change-Id: Ibe42d00fa1c0b0f81e6c9a3becca338989d6eabc
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 48bc59d..72bb7be 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -33,6 +33,8 @@
 
 BOARD_HAL_STATIC_LIBRARIES := libdumpstate.grouper
 
+TARGET_RECOVERY_UI_LIB := librecovery_ui_grouper
+
 TARGET_RELEASETOOLS_EXTENSIONS := device/asus/grouper
 
 -include vendor/asus/grouper/BoardConfigVendor.mk
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index a071e4d..12b4d9e 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -90,7 +90,7 @@
         device.te \
         domain.te \
         drmserver.te \
-        init_shell.te \
+        touch_fw_update.te \
         file.te \
         gpsd.te \
         keystore.te \
@@ -103,4 +103,5 @@
         system_app.te \
         system_server.te \
         ueventd.te \
-        vold.te
+        vold.te \
+        radio.te
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 53daadb..bcec532 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -49,8 +49,7 @@
 #define OUT_SAMPLING_RATE 44100
 
 #define IN_PERIOD_SIZE 1024
-#define IN_PERIOD_SIZE_LOW_LATENCY 512
-#define IN_PERIOD_COUNT 2
+#define IN_PERIOD_COUNT 4
 #define IN_SAMPLING_RATE 44100
 
 #define SCO_PERIOD_SIZE 256
@@ -87,16 +86,6 @@
     .stop_threshold = (IN_PERIOD_SIZE * IN_PERIOD_COUNT),
 };
 
-struct pcm_config pcm_config_in_low_latency = {
-    .channels = 2,
-    .rate = IN_SAMPLING_RATE,
-    .period_size = IN_PERIOD_SIZE_LOW_LATENCY,
-    .period_count = IN_PERIOD_COUNT,
-    .format = PCM_FORMAT_S16_LE,
-    .start_threshold = 1,
-    .stop_threshold = (IN_PERIOD_SIZE_LOW_LATENCY * IN_PERIOD_COUNT),
-};
-
 struct pcm_config pcm_config_sco = {
     .channels = 1,
     .rate = SCO_SAMPLING_RATE,
@@ -146,8 +135,7 @@
 
     pthread_mutex_t lock; /* see note below on mutex acquisition order */
     struct pcm *pcm;
-    struct pcm_config *pcm_config;          /* current configuration */
-    struct pcm_config *pcm_config_non_sco;  /* configuration to return after SCO is done */
+    struct pcm_config *pcm_config;
     bool standby;
 
     unsigned int requested_rate;
@@ -350,7 +338,7 @@
         in->pcm_config = &pcm_config_sco;
     } else {
         device = PCM_DEVICE;
-        in->pcm_config = in->pcm_config_non_sco;
+        in->pcm_config = &pcm_config_in;
     }
 
     /*
@@ -475,7 +463,7 @@
         if (in->resampler != NULL) {
             in->resampler->resample_from_provider(in->resampler,
                     (int16_t *)((char *)buffer +
-                            frames_wr * audio_stream_in_frame_size(&in->stream)),
+                            frames_wr * audio_stream_frame_size(&in->stream.common)),
                     &frames_rd);
         } else {
             struct resampler_buffer buf = {
@@ -485,9 +473,9 @@
             get_next_buffer(&in->buf_provider, &buf);
             if (buf.raw != NULL) {
                 memcpy((char *)buffer +
-                           frames_wr * audio_stream_in_frame_size(&in->stream),
+                           frames_wr * audio_stream_frame_size(&in->stream.common),
                         buf.raw,
-                        buf.frame_count * audio_stream_in_frame_size(&in->stream));
+                        buf.frame_count * audio_stream_frame_size(&in->stream.common));
                 frames_rd = buf.frame_count;
             }
             release_buffer(&in->buf_provider, &buf);
@@ -517,7 +505,7 @@
 static size_t out_get_buffer_size(const struct audio_stream *stream)
 {
     return pcm_config_out.period_size *
-               audio_stream_out_frame_size((const struct audio_stream_out *)stream);
+               audio_stream_frame_size((struct audio_stream *)stream);
 }
 
 static uint32_t out_get_channels(const struct audio_stream *stream)
@@ -626,7 +614,7 @@
     int ret = 0;
     struct stream_out *out = (struct stream_out *)stream;
     struct audio_device *adev = out->dev;
-    size_t frame_size = audio_stream_out_frame_size(stream);
+    size_t frame_size = audio_stream_frame_size(&out->stream.common);
     int16_t *in_buffer = (int16_t *)buffer;
     size_t in_frames = bytes / frame_size;
     size_t out_frames;
@@ -673,7 +661,7 @@
     }
 
     /* Reduce number of channels, if necessary */
-    if (audio_channel_count_from_out_mask(out_get_channels(&stream->common)) >
+    if (popcount(out_get_channels(&stream->common)) >
                  (int)out->pcm_config->channels) {
         unsigned int i;
 
@@ -768,7 +756,7 @@
     pthread_mutex_unlock(&out->lock);
 
     if (ret != 0) {
-        usleep(bytes * 1000000 / audio_stream_out_frame_size(&stream->common) /
+        usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) /
                out_get_sample_rate(&stream->common));
     }
 
@@ -849,7 +837,7 @@
             in->pcm_config->rate;
     size = ((size + 15) / 16) * 16;
 
-    return size * audio_stream_in_frame_size(&in->stream);
+    return size * audio_stream_frame_size((struct audio_stream *)stream);
 }
 
 static uint32_t in_get_channels(const struct audio_stream *stream)
@@ -940,7 +928,7 @@
     int ret = 0;
     struct stream_in *in = (struct stream_in *)stream;
     struct audio_device *adev = in->dev;
-    size_t frames_rq = bytes / audio_stream_in_frame_size(stream);
+    size_t frames_rq = bytes / audio_stream_frame_size(&stream->common);
 
     /*
      * acquiring hw device mutex systematically is useful if a low
@@ -993,7 +981,7 @@
 
 exit:
     if (ret < 0)
-        usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) /
+        usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) /
                in_get_sample_rate(&stream->common));
 
     pthread_mutex_unlock(&in->lock);
@@ -1023,8 +1011,7 @@
                                    audio_devices_t devices,
                                    audio_output_flags_t flags,
                                    struct audio_config *config,
-                                   struct audio_stream_out **stream_out,
-                                   const char *address __unused)
+                                   struct audio_stream_out **stream_out)
 {
     struct audio_device *adev = (struct audio_device *)dev;
     struct stream_out *out;
@@ -1184,7 +1171,7 @@
     size = (pcm_config_in.period_size * config->sample_rate) / pcm_config_in.rate;
     size = ((size + 15) / 16) * 16;
 
-    return (size * audio_channel_count_from_in_mask(config->channel_mask) *
+    return (size * popcount(config->channel_mask) *
                 audio_bytes_per_sample(config->format));
 }
 
@@ -1192,10 +1179,7 @@
                                   audio_io_handle_t handle,
                                   audio_devices_t devices,
                                   struct audio_config *config,
-                                  struct audio_stream_in **stream_in,
-                                  audio_input_flags_t flags,
-                                  const char *address __unused,
-                                  audio_source_t source __unused)
+                                  struct audio_stream_in **stream_in)
 {
     struct audio_device *adev = (struct audio_device *)dev;
     struct stream_in *in;
@@ -1232,10 +1216,7 @@
     in->dev = adev;
     in->standby = true;
     in->requested_rate = config->sample_rate;
-    /* default PCM config */
-    in->pcm_config = (config->sample_rate == IN_SAMPLING_RATE) && (flags & AUDIO_INPUT_FLAG_FAST) ?
-            &pcm_config_in_low_latency : &pcm_config_in;
-    in->pcm_config_non_sco = in->pcm_config;
+    in->pcm_config = &pcm_config_in; /* default PCM config */
 
     *stream_in = &in->stream;
     return 0;
diff --git a/audio_policy.conf b/audio_policy.conf
index ed5b00a..3cc637d 100644
--- a/audio_policy.conf
+++ b/audio_policy.conf
@@ -58,18 +58,10 @@
         devices AUDIO_DEVICE_OUT_USB_ACCESSORY
       }
       usb_device {
-        sampling_rates dynamic
+        sampling_rates 44100
         channel_masks AUDIO_CHANNEL_OUT_STEREO
-        formats dynamic
-        devices AUDIO_DEVICE_OUT_USB_DEVICE
-      }
-    }
-    inputs {
-      usb_device {
-        sampling_rates dynamic
-        channel_masks AUDIO_CHANNEL_IN_STEREO
         formats AUDIO_FORMAT_PCM_16_BIT
-        devices AUDIO_DEVICE_IN_USB_DEVICE
+        devices AUDIO_DEVICE_OUT_USB_DEVICE
       }
     }
   }
diff --git a/device-common.mk b/device-common.mk
index 92806a8..fbb87e2 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -30,10 +30,6 @@
     tf.enable=y \
     drm.service.enabled=true
 
-# libhwui flags
-PRODUCT_PROPERTY_OVERRIDES += \
-    debug.hwui.render_dirty_regions=false
-
 # Set default USB interface
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     persist.sys.usb.config=mtp
@@ -44,7 +40,8 @@
     $(LOCAL_KERNEL):kernel \
     device/asus/grouper/ueventd.grouper.rc:root/ueventd.grouper.rc \
     device/asus/grouper/init.grouper.usb.rc:root/init.grouper.usb.rc \
-    device/asus/grouper/gps.conf:system/etc/gps.conf
+    device/asus/grouper/gps.conf:system/etc/gps.conf \
+    device/asus/grouper/touch_fw_update.sh:system/bin/touch_fw_update.sh
 
 ifneq ($(TARGET_PREBUILT_WIFI_MODULE),)
 PRODUCT_COPY_FILES += \
@@ -71,13 +68,6 @@
     device/asus/grouper/gpio-keys.kl:system/usr/keylayout/gpio-keys.kl
 
 PRODUCT_PACKAGES := \
-    libwpa_client \
-    hostapd \
-    dhcpcd.conf \
-    wpa_supplicant \
-    wpa_supplicant.conf
-
-PRODUCT_PACKAGES += \
     lights.grouper \
     audio.primary.grouper \
     power.grouper \
@@ -85,6 +75,7 @@
     audio.usb.default \
     audio.r_submix.default \
     librs_jni \
+    setup_fs \
     l2ping \
     hcitool \
     bttest \
@@ -97,12 +88,8 @@
 PRODUCT_PACKAGES += \
     nfc.grouper \
     Nfc \
-    Tag
-
-# Filesystem management tools
-PRODUCT_PACKAGES += \
-    e2fsck \
-    setup_fs
+    Tag \
+    com.android.nfc_extras
 
 PRODUCT_CHARACTERISTICS := tablet,nosdcard
 
@@ -115,9 +102,6 @@
 
 # media codec config xml file
 PRODUCT_COPY_FILES += \
-    frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
-    frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
-    frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
     device/asus/grouper/media_codecs.xml:system/etc/media_codecs.xml
 
 # audio mixer paths
@@ -130,7 +114,17 @@
 
 PRODUCT_COPY_FILES += \
     frameworks/native/data/etc/com.nxp.mifare.xml:system/etc/permissions/com.nxp.mifare.xml \
+    frameworks/native/data/etc/com.android.nfc_extras.xml:system/etc/permissions/com.android.nfc_extras.xml \
     frameworks/native/data/etc/android.hardware.nfc.xml:system/etc/permissions/android.hardware.nfc.xml
 
+# NFCEE access control
+ifeq ($(TARGET_BUILD_VARIANT),user)
+    NFCEE_ACCESS_PATH := device/asus/grouper/nfcee_access.xml
+else
+    NFCEE_ACCESS_PATH := device/asus/grouper/nfcee_access_debug.xml
+endif
+PRODUCT_COPY_FILES += \
+    $(NFCEE_ACCESS_PATH):system/etc/nfcee_access.xml
+
 WIFI_BAND := 802_11_BG
  $(call inherit-product-if-exists, hardware/broadcom/wlan/bcmdhd/firmware/bcm4330/device-bcm.mk)
diff --git a/fstab.grouper b/fstab.grouper
index 3948ebf..c1bddbc 100644
--- a/fstab.grouper
+++ b/fstab.grouper
@@ -5,8 +5,8 @@
 
 
 /dev/block/platform/sdhci-tegra.3/by-name/APP           /system             ext4      ro                                                            wait
-/dev/block/platform/sdhci-tegra.3/by-name/CAC           /cache              ext4      noatime,nosuid,nodev,nomblk_io_submit,errors=panic    wait,check
-/dev/block/platform/sdhci-tegra.3/by-name/UDA           /data               ext4      noatime,nosuid,nodev,nomblk_io_submit,errors=panic    wait,check,encryptable=/dev/block/platform/sdhci-tegra.3/by-name/MDA
+/dev/block/platform/sdhci-tegra.3/by-name/CAC           /cache              ext4      noatime,nosuid,nodev,nomblk_io_submit,errors=panic    wait
+/dev/block/platform/sdhci-tegra.3/by-name/UDA           /data               ext4      noatime,nosuid,nodev,nomblk_io_submit,errors=panic    wait,encryptable=/dev/block/platform/sdhci-tegra.3/by-name/MDA
 /dev/block/platform/sdhci-tegra.3/by-name/MSC           /misc               emmc      defaults                                                      defaults
 /dev/block/platform/sdhci-tegra.3/by-name/LNX           /boot               emmc      defaults                                                      defaults
 /dev/block/platform/sdhci-tegra.3/by-name/SOS           /recovery           emmc      defaults                                                      defaults
diff --git a/gpio-keys.kl b/gpio-keys.kl
index 9bc6891..95287bc 100644
--- a/gpio-keys.kl
+++ b/gpio-keys.kl
@@ -1,4 +1,4 @@
-key 116   POWER
-key 115   VOLUME_UP
-key 114   VOLUME_DOWN
+key 116   POWER             WAKE
+key 115   VOLUME_UP         WAKE_DROPPED
+key 114   VOLUME_DOWN       WAKE_DROPPED
 
diff --git a/init.grouper.rc b/init.grouper.rc
index 76ee074..e6b1e9f 100644
--- a/init.grouper.rc
+++ b/init.grouper.rc
@@ -305,6 +305,7 @@
 service wpa_supplicant /system/bin/wpa_supplicant \
     -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
     -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+    -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
@@ -317,7 +318,8 @@
 
 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 \
+    -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+    -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 \
@@ -384,7 +386,8 @@
 
 # bugreport is triggered by the VOLUME-DOWN and VOLUME-UP keys
 service bugreport /system/bin/dumpstate -d -p -B \
-        -o /data/data/com.android.shell/files/bugreports/bugreport
+        -o /data/data/com.android.shell/files/bugreports/bugreport \
+        -b /system/media/audio/ui/Dock.ogg -e /system/media/audio/ui/Undock.ogg
     class main
     disabled
     oneshot
@@ -427,7 +430,7 @@
     group root
     oneshot
 
-service touch_fw_update /system/bin/sh -c "echo /system/etc/firmware/touch_fw.ekt > /sys/bus/i2c/drivers/elan-ktf3k/1-0010/update_fw"
+service touch_fw_update /system/bin/touch_fw_update.sh
     class main
     disabled
     user root
diff --git a/keymaster/keymaster_grouper.cpp b/keymaster/keymaster_grouper.cpp
index 7037ffd..365b2e1 100644
--- a/keymaster/keymaster_grouper.cpp
+++ b/keymaster/keymaster_grouper.cpp
@@ -36,7 +36,7 @@
 #include <cryptoki.h>
 #include <pkcs11.h>
 
-#include <UniquePtr.h>
+#include <utils/UniquePtr.h>
 
 
 /** The size of a key ID in bytes */
@@ -910,7 +910,6 @@
     dev->common.version = 1;
     dev->common.module = (struct hw_module_t*) module;
     dev->common.close = tee_close;
-    dev->flags = 0;
 
     dev->generate_keypair = tee_generate_keypair;
     dev->import_keypair = tee_import_keypair;
@@ -970,8 +969,8 @@
 __attribute__ ((visibility ("default"))) = {
     common: {
         tag: HARDWARE_MODULE_TAG,
-        module_api_version: KEYMASTER_MODULE_API_VERSION_0_3,
-        hal_api_version: HARDWARE_HAL_API_VERSION,
+        version_major: 1,
+        version_minor: 0,
         id: KEYSTORE_HARDWARE_MODULE_ID,
         name: "Keymaster TEE HAL",
         author: "The Android Open Source Project",
diff --git a/media_codecs.xml b/media_codecs.xml
index 3b8fc45..c55db6e 100644
--- a/media_codecs.xml
+++ b/media_codecs.xml
@@ -16,12 +16,10 @@
 
 <!--
 <!DOCTYPE MediaCodecs [
-<!ELEMENT Include EMPTY>
-<!ATTLIST Include href CDATA #REQUIRED>
-<!ELEMENT MediaCodecs (Decoders|Encoders|Include)*>
-<!ELEMENT Decoders (MediaCodec|Include)*>
-<!ELEMENT Encoders (MediaCodec|Include)*>
-<!ELEMENT MediaCodec (Type|Quirk|Include)*>
+<!ELEMENT MediaCodecs (Decoders,Encoders)>
+<!ELEMENT Decoders (MediaCodec*)>
+<!ELEMENT Encoders (MediaCodec*)>
+<!ELEMENT MediaCodec (Type*,Quirk*)>
 <!ATTLIST MediaCodec name CDATA #REQUIRED>
 <!ATTLIST MediaCodec type CDATA>
 <!ELEMENT Type EMPTY>
@@ -78,73 +76,38 @@
 -->
 
 <MediaCodecs>
-    <Include href="media_codecs_google_audio.xml" />
-    <Include href="media_codecs_google_telephony.xml" />
     <Decoders>
-        <MediaCodec name="OMX.Nvidia.mp4.decode" type="video/mp4v-es" >
-            <Limit name="size" min="32x32" max="1920x1088" />
-            <Limit name="alignment" value="2x2" />
-            <Limit name="block-size" value="16x16" />
-            <Limit name="blocks-per-second" min="1" max="244800" />
-            <Limit name="bitrate" range="1-10000000" />
-            <Feature name="adaptive-playback" />
-        </MediaCodec>
-        <MediaCodec name="OMX.Nvidia.h263.decode" type="video/3gpp" >
-            <Limit name="size" min="32x32" max="720x576" />
-            <Limit name="alignment" value="2x2" />
-            <Feature name="adaptive-playback" />
-        </MediaCodec>
-        <MediaCodec name="OMX.Nvidia.h264.decode" type="video/avc" >
-            <Limit name="size" min="32x32" max="1920x1088" />
-            <Limit name="alignment" value="2x2" />
-            <Limit name="block-size" value="16x16" />
-            <Limit name="blocks-per-second" min="1" max="244800" />
-            <Limit name="bitrate" range="1-40000000" />
-            <Feature name="adaptive-playback" />
-        </MediaCodec>
-        <MediaCodec name="OMX.Nvidia.h264.decode.secure" type="video/avc" >
-            <Limit name="size" min="32x32" max="1920x1088" />
-            <Limit name="alignment" value="2x2" />
-            <Limit name="block-size" value="16x16" />
-            <Limit name="blocks-per-second" min="1" max="244800" />
-            <Limit name="bitrate" range="1-40000000" />
-            <Feature name="adaptive-playback" />
-            <Feature name="secure-playback" required="true" />
-        </MediaCodec>
-        <MediaCodec name="OMX.Nvidia.mpeg2v.decode" type="video/mpeg2" >
-            <Limit name="size" min="32x32" max="1920x1088" />
-            <Limit name="alignment" value="2x2" />
-            <Limit name="block-size" value="16x16" />
-            <Limit name="blocks-per-second" min="1" max="244800" />
-            <Limit name="bitrate" range="1-40000000" />
-            <Feature name="adaptive-playback" />
-        </MediaCodec>
-        <MediaCodec name="OMX.Nvidia.mp2.decoder" type="audio/mpeg-L2" >
-            <Limit name="channel-count" max="6" />
-            <Limit name="sample-rate" ranges="16000,22050,24000,32000,44100,48000" />
-            <Limit name="bitrate" range="8000-384000" />
-        </MediaCodec>
+        <MediaCodec name="OMX.Nvidia.mp4.decode" type="video/mp4v-es" />
+        <MediaCodec name="OMX.Nvidia.h263.decode" type="video/3gpp" />
+        <MediaCodec name="OMX.Nvidia.h264.decode" type="video/avc" />
+        <MediaCodec name="OMX.Nvidia.mpeg2v.decode" type="video/mpeg2" />
+        <MediaCodec name="OMX.Nvidia.mp2.decoder" type="audio/mpeg-L2" />
+
+        <MediaCodec name="OMX.google.mp3.decoder" type="audio/mpeg" />
+        <MediaCodec name="OMX.google.amrnb.decoder" type="audio/3gpp" />
+        <MediaCodec name="OMX.google.amrwb.decoder" type="audio/amr-wb" />
+        <MediaCodec name="OMX.google.aac.decoder" type="audio/mp4a-latm" />
+        <MediaCodec name="OMX.google.g711.alaw.decoder" type="audio/g711-alaw" />
+        <MediaCodec name="OMX.google.g711.mlaw.decoder" type="audio/g711-mlaw" />
+        <MediaCodec name="OMX.google.vorbis.decoder" type="audio/vorbis" />
+        <MediaCodec name="OMX.google.gsm.decoder" type="audio/gsm" />
+
+        <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.vp8.decoder" type="video/x-vnd.on2.vp8" />
+        <MediaCodec name="OMX.google.vp9.decoder" type="video/x-vnd.on2.vp9" />
     </Decoders>
 
     <Encoders>
-        <MediaCodec name="OMX.Nvidia.mp4.encoder" type="video/mp4v-es" >
-            <Limit name="size" min="48x48" max="1920x1088" />
-            <Limit name="alignment" value="2x2" />
-            <Limit name="block-size" value="16x16" />
-            <Limit name="blocks-per-second" min="1" max="195840" />
-            <Limit name="bitrate" range="1-14000000" />
-        </MediaCodec>
-        <MediaCodec name="OMX.Nvidia.h263.encoder" type="video/3gpp" >
-            <Limit name="size" min="48x48" max="720x576" />
-            <Limit name="alignment" value="2x2" />
-        </MediaCodec>
-        <MediaCodec name="OMX.Nvidia.h264.encoder" type="video/avc" >
-            <Limit name="size" min="48x48" max="1920x1088" />
-            <Limit name="alignment" value="2x2" />
-            <Limit name="block-size" value="16x16" />
-            <Limit name="blocks-per-second" min="1" max="195840" />
-            <Limit name="bitrate" range="1-14000000" />
-        </MediaCodec>
+        <MediaCodec name="OMX.Nvidia.mp4.encoder" type="video/mp4v-es" />
+        <MediaCodec name="OMX.Nvidia.h263.encoder" type="video/3gpp" />
+        <MediaCodec name="OMX.Nvidia.h264.encoder" type="video/avc" />
+
+        <MediaCodec name="OMX.google.amrnb.encoder" type="audio/3gpp" />
+        <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.vp8.encoder" type="video/x-vnd.on2.vp8" />
     </Encoders>
-    <Include href="media_codecs_google_video.xml" />
 </MediaCodecs>
diff --git a/nfcee_access.xml b/nfcee_access.xml
new file mode 100644
index 0000000..02e12fd
--- /dev/null
+++ b/nfcee_access.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- Applications granted NFCEE access on user builds
+
+    See packages/apps/Nfc/etc/sample_nfcee_access.xml for full documentation.
+     -->
+
+    <!--  Google wallet release signature -->
+    <signer android:signature="3082044c30820334a003020102020900a8cd17c93da5d990300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303635335a170d3338303830393031303635335a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100c30f88add9b492096a2c586a5a9a80356bfa026958f8ff0c5dfaf59f49268ad870dee821a53e1f5b170fc96245a3c982a7cb4527053be35e34f396d24b2291ec0c528d6e26927465e06875ea621f7ff98c40e3345b204907cc9354743acdaace65565f48ba74cd4121cdc876df3522badb095c20d934c56a3e5c393ee5f0e02f8fe0621f918d1f35a82489252c6fa6b63392a7686b3e48612d06a9cf6f49bff11d5d96289c9dfe14ac5762439697dd29eafdb9810de3263513a905ac8e8eaf20907e46750a5ab7bf9a77262f47b03f5a3c6e6d7b51343f69c7f725f70bcc1b4ad592250b705a86e6e83ee2ae37fe5701bcbdb26feefdfff60f6a5bdfb5b64793020103a381dc3081d9301d0603551d0e041604141ccece0eea4dc1121fc7515f0d0a0c72e08cc96d3081a90603551d230481a130819e80141ccece0eea4dc1121fc7515f0d0a0c72e08cc96da17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900a8cd17c93da5d990300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100a470c728e1d31b06d9af6ae768b565046c57806b9843724931d75d4ca10c321520d33ccfed2aa65462234c9ef9b6f910cc676b99cb7f9895d6c06763574fbb78331275dc5cf38fbaa918d7938c051ffba2ade8f303cde8d9e68a048d1fdb9e7c9f2a49b222c68fff422bf15569b85eeeedb04aa30873dbe64b9c9e74f8f2c2f6c40124aaa8d1780d18512b540add28b3e9581971a4170dd868cf5f31e44712b2c23bb51037d7ef9f87a6e5bdb35e2ceb6bb022636c17a56a96bc7a50258c0bd2ed7b31555a18452e17321a0d52838c82f63f742d74ff79586a5cbb7faf7198a84bcf744310e9e927597f00a23dd00660800c2238d90b2fb372dfdbba75bd852e" />
+
+</resources>
diff --git a/nfcee_access_debug.xml b/nfcee_access_debug.xml
new file mode 100644
index 0000000..a96a2d1
--- /dev/null
+++ b/nfcee_access_debug.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- Applications granted NFCEE access on userdebug/eng builds
+
+    See packages/apps/Nfc/etc/sample_nfcee_access.xml for full documentation.
+     -->
+
+    <!-- Google Wallet dev signature -->
+    <signer android:signature="3082044c30820334a003020102020900de7695041d7650c0300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303332345a170d3338303830393031303332345a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100e6ff3defe92aa10d71eb0fa6408bc036b7e243eeed68a6a4763dc7a52a31757cdac61fe510bb73c716e4000104265b347fcecef4c42bf1e1379dd0a876f028227fbbc1f9bdd5d713b2f6a935a379d2cba9c96f92d2d0787c11f1eb19548008a6a072b34b91836cfa0ae1276780e9007530166986a11c9cef46cef7c704806dde9431fb60284d120ab0e7de1d633f07687d468c51139afffdc6bc9a207ca904b8be1da0aa7b4e97756f43606488be5cae3c68e8bb7942cdf51607c930a2fcda655b75d0759cba89ad06e739bd0ba29b1f404296c2c0a85a847f5ab0d067c6c3ec9c49212042ac63a7e53b546c65b46080b4e3e680e23e1f77cfe7f6de744b1a65020103a381dc3081d9301d0603551d0e04160414a2e89064b05d08865c34db930a9d840050117aec3081a90603551d230481a130819e8014a2e89064b05d08865c34db930a9d840050117aeca17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900de7695041d7650c0300c0603551d13040530030101ff300d06092a864886f70d010105050003820101003771870ce87c3c52ea84899230c6e962d94b4d5f1293c25d88261541fd90b5555d1285cef3b8312c3f5df691a8aae04cb981b305e427fd1d2d9e1987e1d29078f13c8452990f1821980263d8d4bd36519348d8d8ba26d8b99fbf09f5fd3ebb0ea3c2f0c9376f1e1fca76f3a6a405429d081b752a7a90b756e9ab44da41abc8e1e8f88ac2758da743fb73e650719a57840ccb6b7add21b99fc681e456e1872c223d5c074adf55f6abda268c2d8b64ea0a8845eecd968f92b493127e75c753c3ff30cbc678b51c9f52961472f17da20a0dc6274aa2463434c1a9b614df697d8ff5ca8101e7a25c7db3fb055d65569c04b01d389cabba57b3a1703ec2e74a88d334" />
+
+    <!-- Google wallet release signature -->
+    <signer android:signature="3082044c30820334a003020102020900a8cd17c93da5d990300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303635335a170d3338303830393031303635335a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100c30f88add9b492096a2c586a5a9a80356bfa026958f8ff0c5dfaf59f49268ad870dee821a53e1f5b170fc96245a3c982a7cb4527053be35e34f396d24b2291ec0c528d6e26927465e06875ea621f7ff98c40e3345b204907cc9354743acdaace65565f48ba74cd4121cdc876df3522badb095c20d934c56a3e5c393ee5f0e02f8fe0621f918d1f35a82489252c6fa6b63392a7686b3e48612d06a9cf6f49bff11d5d96289c9dfe14ac5762439697dd29eafdb9810de3263513a905ac8e8eaf20907e46750a5ab7bf9a77262f47b03f5a3c6e6d7b51343f69c7f725f70bcc1b4ad592250b705a86e6e83ee2ae37fe5701bcbdb26feefdfff60f6a5bdfb5b64793020103a381dc3081d9301d0603551d0e041604141ccece0eea4dc1121fc7515f0d0a0c72e08cc96d3081a90603551d230481a130819e80141ccece0eea4dc1121fc7515f0d0a0c72e08cc96da17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900a8cd17c93da5d990300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100a470c728e1d31b06d9af6ae768b565046c57806b9843724931d75d4ca10c321520d33ccfed2aa65462234c9ef9b6f910cc676b99cb7f9895d6c06763574fbb78331275dc5cf38fbaa918d7938c051ffba2ade8f303cde8d9e68a048d1fdb9e7c9f2a49b222c68fff422bf15569b85eeeedb04aa30873dbe64b9c9e74f8f2c2f6c40124aaa8d1780d18512b540add28b3e9581971a4170dd868cf5f31e44712b2c23bb51037d7ef9f87a6e5bdb35e2ceb6bb022636c17a56a96bc7a50258c0bd2ed7b31555a18452e17321a0d52838c82f63f742d74ff79586a5cbb7faf7198a84bcf744310e9e927597f00a23dd00660800c2238d90b2fb372dfdbba75bd852e" />
+
+    <!-- Platform dev-keys signature -->
+    <signer android:signature="308204a830820390a003020102020900bcdfe81405d5c69e300d06092a864886f70d0101050500308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d301e170d3131303931393230303634325a170d3339303230343230303634325a308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d30820120300d06092a864886f70d01010105000382010d00308201080282010100ef7a8a34d8151d0479a239903261fe5026c520d5d88cd65920c98e096d2770f49636da9ffc4e80c472b05bd62a435f8266912aa2a34a18f6f4856f9ef52c10b88c267627136726823e8f3389b051ba92920e10bbaae0e38879efbe681b05863b655d81a6f3b75a85eb230b38b23ea4ef56f2161ff01652ae2049881adbe60d3bf8b5386a81f7404c0cf0c111c0a35ab0a9760426e4af12add73327ec433e047e3517f47a2d3674c2b819354d56eb7fd6c9aa67dd05b4bb1ca8a7e1946c2494e9364ea677a25481ac81f434bff3dd56e93e59fccef0e24a753461cd1cf15f22b62251d07416057ac5ca3e03a24f7f4eca876bacc5a1828acbde04c5cfdb608c47020103a381fc3081f9301d0603551d0e0416041402f997668541fa74693bea699a5766893a362a5d3081c90603551d230481c13081be801402f997668541fa74693bea699a5766893a362a5da1819aa48197308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d820900bcdfe81405d5c69e300c0603551d13040530030101ff300d06092a864886f70d0101050500038201010047d6fb32cadeae4444c379b3441ff9ba10990c23d10472c54fb7ebd9c33b2a173836337e1c175c980847a8894f6a99782e9c2e2133629254295fe52749f93ec1e39d213dd06d0ba99de3b6b5d4d856fafe74e08113b7b23a1b56f4918ed41218a03b9564456480b665200267d3770a9463db413c6a47bd81d725cb7d39c9d0941693c59cbe727d40415f0815c3c8363fb8fa2e028ceeb3bbfbc6b119db5b72f0edb0bb417bfcbf74d9fa069de22afe56a50bcde7ea1078749bb9ec0adc0e6de045641ee3a82c576645160b4ab9710d3cb3201f23957da8de9084c0bec93ad1c8c2054195f13c926db07c8bdf15673acf6d791ec1d3a0d7e1b3470447acd95873" />
+
+</resources>
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index ab21b67..5b5a7a0 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -84,8 +84,6 @@
     The default represents a dual-mode smartphone -->
     <string translatable="false" name="config_wifi_p2p_device_type">1-0050F204-1</string>
 
-    <bool name="config_ui_enableFadingMarquee">true</bool>
-
     <!-- List of file paths for USB host busses to exclude from USB host support.
          For example, if the first USB bus on the device is used to communicate
          with the modem or some other restricted hardware, add "/dev/bus/usb/001/"
@@ -232,8 +230,6 @@
 
     <!--  Maximum number of supported users -->
     <integer name="config_multiuserMaximumUsers">8</integer>
-    <!-- Whether UI for multi user should be shown -->
-    <bool name="config_enableMultiUserUI">true</bool>
 
     <!-- reference volume index for music stream to limit headphone volume and display warning -->
     <integer name="config_safe_media_volume_index">6</integer>
diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
deleted file mode 100644
index 5aaaa57..0000000
--- a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2014 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.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License
-  -->
-
-<resources>
-    <!-- Defines the implementation of the velocity tracker to be used for the panel expansion. Can
-         be 'platform' or 'noisy' (i.e. for noisy touch screens). -->
-    <string name="velocity_tracker_impl" translatable="false">noisy</string>
-
-    <!-- Show camera affordance on Keyguard -->
-    <bool name="config_keyguardShowCameraAffordance">false</bool>
-
-    <!-- Disable expensive shadows -->
-    <bool name="config_recents_fake_shadows">true</bool>
-
-    <!-- Use hardware layers in recents -->
-    <bool name="config_recents_use_hardware_layers">true</bool>
-</resources>
diff --git a/overlay/packages/apps/Nfc/res/values/provisioning.xml b/overlay/packages/apps/Nfc/res/values/provisioning.xml
index c996eb5..1ca59e3 100644
--- a/overlay/packages/apps/Nfc/res/values/provisioning.xml
+++ b/overlay/packages/apps/Nfc/res/values/provisioning.xml
@@ -17,10 +17,12 @@
 <!-- NFC resources that may need to be customized
      for different hardware or product builds. -->
 <resources>
+    <!-- Whether the device can receive NFC data in setup wizard -->
+    <bool name="enable_nfc_provisioning">true</bool>
+
     <!-- The accepted mime-types when NFC is enabled in setup wizard.
          Mime-types must be lower case, wildcards are *not* accepted. -->
     <string-array name="provisioning_mime_types">
         <item>application/vnd.com.google.android.nfcprovision</item>
-        <item>application/com.android.managedprovisioning</item>
     </string-array>
 </resources>
diff --git a/power/power.c b/power/power.c
index 654d73a..687fe0b 100644
--- a/power/power.c
+++ b/power/power.c
@@ -18,13 +18,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <sys/socket.h>
-#include <cutils/uevent.h>
-#include <sys/poll.h>
-#include <pthread.h>
-#include <linux/netlink.h>
-#include <stdlib.h>
-#include <stdbool.h>
 
 #define LOG_TAG "Grouper PowerHAL"
 #include <utils/Log.h>
@@ -33,36 +26,10 @@
 #include <hardware/power.h>
 
 #define BOOST_PATH      "/sys/devices/system/cpu/cpufreq/interactive/boost"
-#define UEVENT_MSG_LEN 2048
-#define TOTAL_CPUS 4
-#define RETRY_TIME_CHANGING_FREQ 20
-#define SLEEP_USEC_BETWN_RETRY 200
-#define LOW_POWER_MAX_FREQ "640000"
-#define LOW_POWER_MIN_FREQ "51000"
-#define NORMAL_MAX_FREQ "1300000"
-#define UEVENT_STRING "online@/devices/system/cpu/"
-
 static int boost_fd = -1;
 static int boost_warned;
 
-static struct pollfd pfd;
-static char *cpu_path_min[] = {
-    "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",
-    "/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq",
-    "/sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq",
-    "/sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq",
-};
-static char *cpu_path_max[] = {
-    "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
-    "/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq",
-    "/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq",
-    "/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq",
-};
-static bool freq_set[TOTAL_CPUS];
-static bool low_power_mode = false;
-static pthread_mutex_t low_power_mode_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static int sysfs_write(char *path, char *s)
+static void sysfs_write(char *path, char *s)
 {
     char buf[80];
     int len;
@@ -71,115 +38,19 @@
     if (fd < 0) {
         strerror_r(errno, buf, sizeof(buf));
         ALOGE("Error opening %s: %s\n", path, buf);
-        return -1;
+        return;
     }
 
     len = write(fd, s, strlen(s));
     if (len < 0) {
         strerror_r(errno, buf, sizeof(buf));
         ALOGE("Error writing to %s: %s\n", path, buf);
-        return -1;
     }
 
     close(fd);
-    return 0;
 }
 
-static int uevent_event()
-{
-    char msg[UEVENT_MSG_LEN];
-    char *cp;
-    int n, cpu, ret, retry = RETRY_TIME_CHANGING_FREQ;
-
-    n = recv(pfd.fd, msg, UEVENT_MSG_LEN, MSG_DONTWAIT);
-    if (n <= 0) {
-        return -1;
-    }
-    if (n >= UEVENT_MSG_LEN) {   /* overflow -- discard */
-        return -1;
-    }
-
-    cp = msg;
-
-    if (strstr(cp, UEVENT_STRING)) {
-        n = strlen(cp);
-        errno = 0;
-        cpu = strtol(cp + n - 1, NULL, 10);
-
-        if (errno == EINVAL || errno == ERANGE || cpu < 0 || cpu >= TOTAL_CPUS) {
-            return -1;
-        }
-
-        pthread_mutex_lock(&low_power_mode_lock);
-        if (low_power_mode && !freq_set[cpu]) {
-            while (retry) {
-                sysfs_write(cpu_path_min[cpu], LOW_POWER_MIN_FREQ);
-                ret = sysfs_write(cpu_path_max[cpu], LOW_POWER_MAX_FREQ);
-                if (!ret) {
-                    freq_set[cpu] = true;
-                    break;
-                }
-                usleep(SLEEP_USEC_BETWN_RETRY);
-                retry--;
-           }
-        } else if (!low_power_mode && freq_set[cpu]) {
-             while (retry) {
-                  ret = sysfs_write(cpu_path_max[cpu], NORMAL_MAX_FREQ);
-                  if (!ret) {
-                      freq_set[cpu] = false;
-                      break;
-                  }
-                  usleep(SLEEP_USEC_BETWN_RETRY);
-                  retry--;
-             }
-        }
-        pthread_mutex_unlock(&low_power_mode_lock);
-    }
-    return 0;
-}
-
-void *thread_uevent(__attribute__((unused)) void *x)
-{
-    while (1) {
-        int nevents, ret;
-
-        nevents = poll(&pfd, 1, -1);
-
-        if (nevents == -1) {
-            if (errno == EINTR)
-                continue;
-            ALOGE("powerhal: thread_uevent: poll_wait failed\n");
-            break;
-        }
-        ret = uevent_event();
-        if (ret < 0)
-            ALOGE("Error processing the uevent event");
-    }
-    return NULL;
-}
-
-
-static void uevent_init()
-{
-    struct sockaddr_nl client;
-    pthread_t tid;
-    pfd.fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
-
-    if (pfd.fd < 0) {
-        ALOGE("%s: failed to open: %s", __func__, strerror(errno));
-        return;
-    }
-    memset(&client, 0, sizeof(struct sockaddr_nl));
-    pthread_create(&tid, NULL, thread_uevent, NULL);
-    client.nl_family = AF_NETLINK;
-    client.nl_pid = tid;
-    client.nl_groups = -1;
-    pfd.events = POLLIN;
-    bind(pfd.fd, (void *)&client, sizeof(struct sockaddr_nl));
-    return;
-}
-
-static void grouper_power_init( __attribute__((unused)) struct power_module *module)
+static void grouper_power_init(struct power_module *module)
 {
     /*
      * cpufreq interactive governor: timer 20ms, min sample 100ms,
@@ -196,10 +67,9 @@
 		"0");
     sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/input_boost",
 		"1");
-    uevent_init();
 }
 
-static void grouper_power_set_interactive( __attribute__((unused)) struct power_module *module, int on)
+static void grouper_power_set_interactive(struct power_module *module, int on)
 {
     /*
      * Lower maximum frequency when screen is off.  CPU 0 and 1 share a
@@ -217,38 +87,16 @@
 
 }
 
-static void grouper_power_hint(__attribute__((unused)) struct power_module *module, power_hint_t hint,
+static void grouper_power_hint(struct power_module *module, power_hint_t hint,
                             void *data)
 {
     char buf[80];
-    int len, cpu, ret;
+    int len;
 
     switch (hint) {
     case POWER_HINT_VSYNC:
         break;
 
-    case POWER_HINT_LOW_POWER:
-        pthread_mutex_lock(&low_power_mode_lock);
-        if (data) {
-            low_power_mode = true;
-            for (cpu = 0; cpu < TOTAL_CPUS; cpu++) {
-                sysfs_write(cpu_path_min[cpu], LOW_POWER_MIN_FREQ);
-                ret = sysfs_write(cpu_path_max[cpu], LOW_POWER_MAX_FREQ);
-                if (!ret) {
-                    freq_set[cpu] = true;
-                }
-            }
-        } else {
-            low_power_mode = false;
-            for (cpu = 0; cpu < TOTAL_CPUS; cpu++) {
-                ret = sysfs_write(cpu_path_max[cpu], NORMAL_MAX_FREQ);
-                if (!ret) {
-                    freq_set[cpu] = false;
-                }
-            }
-        }
-        pthread_mutex_unlock(&low_power_mode_lock);
-        break;
     default:
             break;
     }
diff --git a/recovery/Android.mk b/recovery/Android.mk
new file mode 100644
index 0000000..21383ce
--- /dev/null
+++ b/recovery/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := eng
+LOCAL_C_INCLUDES += bootable/recovery
+LOCAL_SRC_FILES := recovery_ui.cpp
+
+# should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk
+LOCAL_MODULE := librecovery_ui_grouper
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
diff --git a/recovery/recovery_ui.cpp b/recovery/recovery_ui.cpp
new file mode 100644
index 0000000..ec3a05d
--- /dev/null
+++ b/recovery/recovery_ui.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <linux/input.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+
+#include "common.h"
+#include "device.h"
+#include "screen_ui.h"
+
+const char* HEADERS[] = { "Volume up/down to move highlight;",
+                          "power button to select.",
+                          "",
+                          NULL };
+
+const char* ITEMS[] = { "reboot system now",
+                        "apply update from ADB",
+                        "wipe data/factory reset",
+                        "wipe cache partition",
+                        NULL };
+
+class GrouperUI : public ScreenRecoveryUI {
+  public:
+    GrouperUI() :
+        consecutive_power_keys(0) {
+    }
+
+    virtual KeyAction CheckKey(int key) {
+        if (IsKeyPressed(KEY_POWER) && key == KEY_VOLUMEUP) {
+            return TOGGLE;
+        }
+        if (key == KEY_POWER) {
+            ++consecutive_power_keys;
+            if (consecutive_power_keys >= 7) {
+                return REBOOT;
+            }
+        } else {
+            consecutive_power_keys = 0;
+        }
+        return ENQUEUE;
+    }
+
+  private:
+    int consecutive_power_keys;
+};
+
+
+class GrouperDevice : public Device {
+  public:
+    GrouperDevice() :
+        ui(new GrouperUI) {
+    }
+
+    RecoveryUI* GetUI() { return ui; }
+
+    int HandleMenuKey(int key_code, int visible) {
+        if (visible) {
+            switch (key_code) {
+              case KEY_DOWN:
+              case KEY_VOLUMEDOWN:
+                return kHighlightDown;
+
+              case KEY_UP:
+              case KEY_VOLUMEUP:
+                return kHighlightUp;
+
+              case KEY_POWER:
+                return kInvokeItem;
+            }
+        }
+
+        return kNoAction;
+    }
+
+    BuiltinAction InvokeMenuItem(int menu_position) {
+        switch (menu_position) {
+          case 0: return REBOOT;
+          case 1: return APPLY_ADB_SIDELOAD;
+          case 2: return WIPE_DATA;
+          case 3: return WIPE_CACHE;
+          default: return NO_ACTION;
+        }
+    }
+
+    const char* const* GetMenuHeaders() { return HEADERS; }
+    const char* const* GetMenuItems() { return ITEMS; }
+
+  private:
+    RecoveryUI* ui;
+};
+
+Device* make_device() {
+    return new GrouperDevice;
+}
diff --git a/self-extractors/extract-lists.txt b/self-extractors/extract-lists.txt
deleted file mode 100644
index 65ba040..0000000
--- a/self-extractors/extract-lists.txt
+++ /dev/null
@@ -1,103 +0,0 @@
-  asus)
-    TO_EXTRACT="\
-            system/bin/sensors-config \
-            system/lib/hw/camera.tegra3.so \
-            system/lib/hw/sensors.grouper.so \
-            system/lib/libsensors.lightsensor.so \
-            system/vendor/lib/drm/libdrmwvmplugin.so \
-            system/vendor/lib/libwvm.so \
-            "
-    ;;
-  broadcom)
-    TO_EXTRACT="\
-            system/bin/glgps \
-            system/etc/firmware/bcm4330.hcd \
-            system/etc/gps/gpsconfig.xml \
-            system/lib/hw/gps.tegra3.so \
-            "
-    ;;
-  elan)
-    TO_EXTRACT="\
-            system/etc/firmware/touch_fw.ekt \
-            "
-    ;;
-  invensense)
-    TO_EXTRACT="\
-            system/lib/libinvensense_hal.so \
-            system/lib/libmllite.so \
-            system/lib/libmplmpu.so \
-            "
-    ;;
-  nvidia)
-    TO_EXTRACT="\
-            system/bin/tf_daemon \
-            system/etc/firmware/nvavp_os_00001000.bin \
-            system/etc/firmware/nvavp_os_0ff00000.bin \
-            system/etc/firmware/nvavp_os_e0000000.bin \
-            system/etc/firmware/nvavp_os_eff00000.bin \
-            system/etc/firmware/nvavp_vid_ucode_alt.bin \
-            system/etc/nvcamera.conf \
-            system/etc/nvram.txt \
-            system/lib/egl/libEGL_tegra.so \
-            system/lib/egl/libGLESv1_CM_tegra.so \
-            system/lib/egl/libGLESv2_tegra.so \
-            system/lib/hw/gralloc.tegra3.so \
-            system/lib/hw/hwcomposer.tegra3.so \
-            system/lib/libardrv_dynamic.so \
-            system/lib/libcgdrv.so \
-            system/lib/libnvapputil.so \
-            system/lib/libnvasfparserhal.so \
-            system/lib/libnvaviparserhal.so \
-            system/lib/libnvavp.so \
-            system/lib/libnvcamerahdr.so \
-            system/lib/libnvddk_2d.so \
-            system/lib/libnvddk_2d_v2.so \
-            system/lib/libnvdispmgr_d.so \
-            system/lib/libnvmm.so \
-            system/lib/libnvmmlite.so \
-            system/lib/libnvmmlite_audio.so \
-            system/lib/libnvmmlite_image.so \
-            system/lib/libnvmmlite_utils.so \
-            system/lib/libnvmmlite_video.so \
-            system/lib/libnvmm_audio.so \
-            system/lib/libnvmm_camera.so \
-            system/lib/libnvmm_contentpipe.so \
-            system/lib/libnvmm_image.so \
-            system/lib/libnvmm_manager.so \
-            system/lib/libnvmm_misc.so \
-            system/lib/libnvmm_parser.so \
-            system/lib/libnvmm_service.so \
-            system/lib/libnvmm_utils.so \
-            system/lib/libnvmm_video.so \
-            system/lib/libnvmm_writer.so \
-            system/lib/libnvodm_dtvtuner.so \
-            system/lib/libnvodm_hdmi.so \
-            system/lib/libnvodm_imager.so \
-            system/lib/libnvodm_misc.so \
-            system/lib/libnvodm_query.so \
-            system/lib/libnvomx.so \
-            system/lib/libnvomxilclient.so \
-            system/lib/libnvos.so \
-            system/lib/libnvparser.so \
-            system/lib/libnvrm.so \
-            system/lib/libnvrm_graphics.so \
-            system/lib/libnvsm.so \
-            system/lib/libnvtvmr.so \
-            system/lib/libnvwinsys.so \
-            system/lib/libnvwsi.so \
-            system/lib/libstagefrighthw.so \
-            system/lib/libtf_crypto_sst.so \
-            "
-    ;;
-  nxp)
-    TO_EXTRACT="\
-            system/vendor/firmware/libpn544_fw.so \
-            "
-    ;;
-  widevine)
-    TO_EXTRACT="\
-            system/lib/libdrmdecrypt.so \
-            system/vendor/lib/libwvdrm_L1.so \
-            system/vendor/lib/libWVStreamControlAPI_L1.so
-            "
-    ;;
diff --git a/self-extractors/nvidia/staging/keymaster/keymaster_grouper.cpp b/self-extractors/nvidia/staging/keymaster/keymaster_grouper.cpp
index 978c5be..365b2e1 100644
--- a/self-extractors/nvidia/staging/keymaster/keymaster_grouper.cpp
+++ b/self-extractors/nvidia/staging/keymaster/keymaster_grouper.cpp
@@ -36,7 +36,7 @@
 #include <cryptoki.h>
 #include <pkcs11.h>
 
-#include <UniquePtr.h>
+#include <utils/UniquePtr.h>
 
 
 /** The size of a key ID in bytes */
diff --git a/sepolicy/device.te b/sepolicy/device.te
index 0ec95ae..9e9c177 100644
--- a/sepolicy/device.te
+++ b/sepolicy/device.te
@@ -2,3 +2,4 @@
 type nvhost_device, dev_type;
 type elan_ip_device, dev_type;
 type diag_device, dev_type;
+type baseband_log_device, dev_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 0ede414..854efcd 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -12,6 +12,7 @@
 /dev/ttyHS1                       u:object_r:gps_device:s0
 /dev/ttyHS2                       u:object_r:hci_attach_dev:s0
 /dev/ttyACM0                      u:object_r:radio_device:s0
+/dev/ttyACM1                      u:object_r:baseband_log_device:s0
 
 /data/amit(/.*)?                  u:object_r:sensors_data_file:s0
 /data/calibration(/.*)?           u:object_r:sensors_data_file:s0
@@ -23,6 +24,7 @@
 /system/bin/glgps              -- u:object_r:gpsd_exec:s0
 /system/bin/sensors-config     -- u:object_r:sensors_config_exec:s0
 /system/bin/setup_fs           -- u:object_r:setup_fs_exec:s0
+/system/bin/touch_fw_update.sh -- u:object_r:touch_fw_update_exec:s0
 
 /sys/devices/tegradc\.0(/.*)?                u:object_r:sysfs_devices_tegradc:s0
 /sys/devices/tegradc\.1(/.*)?                u:object_r:sysfs_devices_tegradc:s0
diff --git a/sepolicy/init_shell.te b/sepolicy/init_shell.te
deleted file mode 100644
index 8b83b9a..0000000
--- a/sepolicy/init_shell.te
+++ /dev/null
@@ -1,5 +0,0 @@
-allow init_shell sysfs_firmware_writable:file w_file_perms;
-
-# Kernel bug for Linux < 3.3: sysfs inodes can lose their security context
-# and revert to the base sysfs type.
-allow init_shell sysfs:file write;
diff --git a/sepolicy/radio.te b/sepolicy/radio.te
new file mode 100644
index 0000000..14edd20
--- /dev/null
+++ b/sepolicy/radio.te
@@ -0,0 +1,4 @@
+userdebug_or_eng(`
+  unix_socket_connect(radio, rild_debug, rild)
+  allow radio baseband_log_device:chr_file rw_file_perms;
+')
diff --git a/sepolicy/sensors_config.te b/sepolicy/sensors_config.te
index 1a42a44..9b81253 100644
--- a/sepolicy/sensors_config.te
+++ b/sepolicy/sensors_config.te
@@ -12,12 +12,14 @@
 allow sensors_config system_file:file execute_no_trans;
 
 # Mount /dev/block/platform/sdhci-tegra.3/by-name/PER
+# We would mount this with a context= mount option and
+# a context other than vfat if we could change sensors-config.
 allow sensors_config sensors_data_file:dir mounton;
-allow sensors_config sdcard_external:filesystem { mount unmount };
-allow sensors_config { sdcard_external block_device }:dir search;
+allow sensors_config vfat:filesystem { mount unmount };
+allow sensors_config { vfat block_device }:dir search;
 
 # Read from the mounted PER partition
-allow sensors_config sdcard_external:file r_file_perms;
+allow sensors_config vfat:file r_file_perms;
 
 # Need to chmod and chown files (/data/lightsensor, /data/sensors)
 allow sensors_config self:capability { chown fowner };
diff --git a/sepolicy/touch_fw_update.te b/sepolicy/touch_fw_update.te
new file mode 100644
index 0000000..1e292b2
--- /dev/null
+++ b/sepolicy/touch_fw_update.te
@@ -0,0 +1,7 @@
+type touch_fw_update, domain;
+type touch_fw_update_exec, exec_type, file_type;
+
+init_daemon_domain(touch_fw_update)
+
+allow touch_fw_update shell_exec:file rx_file_perms;
+allow touch_fw_update sysfs_firmware_writable:file w_file_perms;
diff --git a/touch_fw_update.sh b/touch_fw_update.sh
new file mode 100644
index 0000000..e298aa8
--- /dev/null
+++ b/touch_fw_update.sh
@@ -0,0 +1,3 @@
+#!/system/bin/sh
+
+echo /system/etc/firmware/touch_fw.ekt > /sys/bus/i2c/drivers/elan-ktf3k/1-0010/update_fw