Merge "Keep RemoteInputView visible when focused" into nyc-dev
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index cf2ef45..9383394 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -557,8 +557,9 @@
                 return;
             }
             try {
+                int bufferSize = SystemProperties.getInt("debug.traceview-buffer-size-in-mb", 8);
                 VMDebug.startMethodTracing(profileFile, profileFd.getFileDescriptor(),
-                        8 * 1024 * 1024, 0, samplingInterval != 0, samplingInterval);
+                        bufferSize * 1024 * 1024, 0, samplingInterval != 0, samplingInterval);
                 profiling = true;
             } catch (RuntimeException e) {
                 Slog.w(TAG, "Profiling failed on path " + profileFile);
diff --git a/core/java/android/os/health/HealthStats.java b/core/java/android/os/health/HealthStats.java
index f0489e2..90d89c5 100644
--- a/core/java/android/os/health/HealthStats.java
+++ b/core/java/android/os/health/HealthStats.java
@@ -83,6 +83,10 @@
  * returned for UidHealthStats.STATS_PACKAGES, the keys come from the
  * {@link android.os.health.PackageHealthStats}  class.
  *
+ * <p>
+ * The keys that are available are subject to change, depending on what a particular
+ * device or software version is capable of recording. Applications must handle the absence of
+ * data without crashing.
  */
 public class HealthStats {
     // Header fields
diff --git a/core/java/android/os/health/PackageHealthStats.java b/core/java/android/os/health/PackageHealthStats.java
index 2c30d5f..fb52cb6 100644
--- a/core/java/android/os/health/PackageHealthStats.java
+++ b/core/java/android/os/health/PackageHealthStats.java
@@ -37,7 +37,7 @@
      * Key for a map of the number of times that a package's wakeup alarms have fired
      * while the device was on battery.
      *
-     * @see android.app.AlarmManager.
+     * @see android.app.AlarmManager
      */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENTS)
     public static final int MEASUREMENTS_WAKEUP_ALARMS_COUNT = HealthKeys.BASE_PACKAGE + 2;
diff --git a/core/java/android/os/health/PidHealthStats.java b/core/java/android/os/health/PidHealthStats.java
index fe3c02c..0d2a3f1 100644
--- a/core/java/android/os/health/PidHealthStats.java
+++ b/core/java/android/os/health/PidHealthStats.java
@@ -20,18 +20,56 @@
  * Keys for {@link HealthStats} returned from
  * {@link HealthStats#getStats(int) HealthStats.getStats(int)} with the
  * {@link UidHealthStats#STATS_PIDS UidHealthStats.STATS_PIDS} key.
+ * <p>
+ * The values coming from PidHealthStats are a little bit different from
+ * the other HealthStats values.  These values are not aggregate or historical
+ * values, but instead live values from when the snapshot is taken.  These
+ * tend to be more useful in debugging rogue processes than in gathering
+ * aggregate metrics across the fleet of devices.
  */
 public final class PidHealthStats {
 
     private PidHealthStats() {
     }
 
+    /**
+     * Key for a measurement of the current nesting depth of wakelocks for this process.
+     * That is to say, the number of times a nested wakelock has been started but not
+     * stopped.  A high number here indicates an improperly paired wakelock acquire/release
+     * combination.
+     * <p>
+     * More details on the individual wake locks is available
+     * by getting the {@link UidHealthStats#TIMERS_WAKELOCKS_FULL},
+     * {@link UidHealthStats#TIMERS_WAKELOCKS_PARTIAL},
+     * {@link UidHealthStats#TIMERS_WAKELOCKS_WINDOW}
+     * and {@link UidHealthStats#TIMERS_WAKELOCKS_DRAW} keys.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WAKE_NESTING_COUNT = HealthKeys.BASE_PID + 1;
 
+    /**
+     * Key for a measurement of the total number of milleseconds that this process
+     * has held a wake lock.
+     * <p>
+     * More details on the individual wake locks is available
+     * by getting the {@link UidHealthStats#TIMERS_WAKELOCKS_FULL},
+     * {@link UidHealthStats#TIMERS_WAKELOCKS_PARTIAL},
+     * {@link UidHealthStats#TIMERS_WAKELOCKS_WINDOW}
+     * and {@link UidHealthStats#TIMERS_WAKELOCKS_DRAW} keys.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WAKE_SUM_MS = HealthKeys.BASE_PID + 2;
 
+    /**
+     * Key for a measurement of the time in the {@link android.os.SystemClock#elapsedRealtime}
+     * timebase that a wakelock was first acquired in this process.
+     * <p>
+     * More details on the individual wake locks is available
+     * by getting the {@link UidHealthStats#TIMERS_WAKELOCKS_FULL},
+     * {@link UidHealthStats#TIMERS_WAKELOCKS_PARTIAL},
+     * {@link UidHealthStats#TIMERS_WAKELOCKS_WINDOW}
+     * and {@link UidHealthStats#TIMERS_WAKELOCKS_DRAW} keys.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WAKE_START_MS = HealthKeys.BASE_PID + 3;
 
diff --git a/core/java/android/os/health/ProcessHealthStats.java b/core/java/android/os/health/ProcessHealthStats.java
index e004ecb..b3f0dfc 100644
--- a/core/java/android/os/health/ProcessHealthStats.java
+++ b/core/java/android/os/health/ProcessHealthStats.java
@@ -26,21 +26,42 @@
     private ProcessHealthStats() {
     }
 
+    /**
+     * Key for a measurement of number of millseconds the CPU spent running in user space
+     * for this process.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_USER_TIME_MS = HealthKeys.BASE_PROCESS + 1;
 
+    /**
+     * Key for a measurement of number of millseconds the CPU spent running in kernel space
+     * for this process.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_SYSTEM_TIME_MS = HealthKeys.BASE_PROCESS + 2;
 
+    /**
+     * Key for a measurement of the number of times this process was started for any reason.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_STARTS_COUNT = HealthKeys.BASE_PROCESS + 3;
 
+    /**
+     * Key for a measurement of the number of crashes that happened in this process.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_CRASHES_COUNT = HealthKeys.BASE_PROCESS + 4;
 
+    /**
+     * Key for a measurement of the number of ANRs that happened in this process.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_ANR_COUNT = HealthKeys.BASE_PROCESS + 5;
 
+    /**
+     * Key for a measurement of the number of milliseconds this process spent with
+     * an activity in the foreground.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_FOREGROUND_MS = HealthKeys.BASE_PROCESS + 6;
 
diff --git a/core/java/android/os/health/ServiceHealthStats.java b/core/java/android/os/health/ServiceHealthStats.java
index 802ad31..cc48b3e 100644
--- a/core/java/android/os/health/ServiceHealthStats.java
+++ b/core/java/android/os/health/ServiceHealthStats.java
@@ -26,9 +26,20 @@
     private ServiceHealthStats() {
     }
 
+    /**
+     * Key for a measurement of the number of times this service was started due to calls to
+     * {@link android.content.Context#startService startService()}, including re-launches
+     * after crashes.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_START_SERVICE_COUNT = HealthKeys.BASE_SERVICE + 1;
 
+    /**
+     * Key for a measurement of the total number of times this service was started
+     * due to calls to {@link android.content.Context#startService startService()}
+     * or {@link android.content.Context#bindService bindService()} including re-launches
+     * after crashes.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_LAUNCH_COUNT = HealthKeys.BASE_SERVICE + 2;
 
diff --git a/core/java/android/os/health/SystemHealthManager.java b/core/java/android/os/health/SystemHealthManager.java
index 520e84e..7c37fa4 100644
--- a/core/java/android/os/health/SystemHealthManager.java
+++ b/core/java/android/os/health/SystemHealthManager.java
@@ -27,6 +27,11 @@
 /**
  * Provides access to data about how various system resources are used by applications.
  * @more
+ * <p>
+ * If you are going to be using this class to log your application's resource usage,
+ * please consider the amount of resources (battery, network, etc) that will be used
+ * by the logging itself.  It can be substantial.
+ * <p>
  * <b>Battery Usage</b><br>
  * The statistics related to power (battery) usage are recorded since the device
  * was last unplugged. It is expected that applications schedule more work to do
@@ -66,7 +71,7 @@
      * @return A {@link HealthStats} object containing the metrics for the requested
      * application. The keys for this HealthStats object will be from the {@link UidHealthStats}
      * class.
-     * @see Process#myUid()
+     * @see Process#myUid() Process.myUid()
      */
     public HealthStats takeUidSnapshot(int uid) {
         try {
diff --git a/core/java/android/os/health/TimerStat.java b/core/java/android/os/health/TimerStat.java
index b9d8874..6af1faf 100644
--- a/core/java/android/os/health/TimerStat.java
+++ b/core/java/android/os/health/TimerStat.java
@@ -101,14 +101,14 @@
     }
 
     /**
-     * Set the time for this timer.
+     * Set the time for this timer in milliseconds.
      */
     public void setTime(long time) {
         mTime = time;
     }
 
     /**
-     * Get the time for this timer.
+     * Get the time for this timer in milliseconds.
      */
     public long getTime() {
         return mTime;
diff --git a/core/java/android/os/health/UidHealthStats.java b/core/java/android/os/health/UidHealthStats.java
index 337235a..a702cdb 100644
--- a/core/java/android/os/health/UidHealthStats.java
+++ b/core/java/android/os/health/UidHealthStats.java
@@ -74,6 +74,11 @@
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMERS)
     public static final int TIMERS_WAKELOCKS_WINDOW = HealthKeys.BASE_UID + 7;
 
+    /**
+     * Key for a TimerStat for the times a system-defined wakelock was acquired
+     * to allow the application to draw when it otherwise would not be able to
+     * (e.g. on the lock screen or doze screen).
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMERS)
     public static final int TIMERS_WAKELOCKS_DRAW = HealthKeys.BASE_UID + 8;
 
@@ -125,144 +130,316 @@
     @HealthKeys.Constant(type=HealthKeys.TYPE_STATS)
     public static final int STATS_PACKAGES = HealthKeys.BASE_UID + 15;
 
+    /**
+     * Key for a measurement of number of millseconds the wifi controller was
+     * idle but turned on on behalf of this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_IDLE_MS = HealthKeys.BASE_UID + 16;
 
+    /**
+     * Key for a measurement of number of millseconds the wifi transmitter was
+     * receiving data for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_RX_MS = HealthKeys.BASE_UID + 17;
 
+    /**
+     * Key for a measurement of number of millseconds the wifi transmitter was
+     * transmitting data for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_TX_MS = HealthKeys.BASE_UID + 18;
 
+    /**
+     * Key for a measurement of the estimated number of mA*ms used by this uid
+     * for wifi, that is to say the number of milliseconds of wifi activity
+     * times the mA current during that period.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_POWER_MAMS = HealthKeys.BASE_UID + 19;
 
+    /**
+     * Key for a measurement of number of millseconds the bluetooth controller was
+     * idle but turned on on behalf of this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_IDLE_MS = HealthKeys.BASE_UID + 20;
 
+    /**
+     * Key for a measurement of number of millseconds the bluetooth transmitter was
+     * receiving data for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_RX_MS = HealthKeys.BASE_UID + 21;
 
+    /**
+     * Key for a measurement of number of millseconds the bluetooth transmitter was
+     * transmitting data for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_TX_MS = HealthKeys.BASE_UID + 22;
 
+    /**
+     * Key for a measurement of the estimated number of mA*ms used by this uid
+     * for bluetooth, that is to say the number of milliseconds of activity
+     * times the mA current during that period.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_POWER_MAMS = HealthKeys.BASE_UID + 23;
 
+    /**
+     * Key for a measurement of number of millseconds the mobile radio controller was
+     * idle but turned on on behalf of this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_IDLE_MS = HealthKeys.BASE_UID + 24;
 
+    /**
+     * Key for a measurement of number of millseconds the mobile radio transmitter was
+     * receiving data for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_RX_MS = HealthKeys.BASE_UID + 25;
 
+    /**
+     * Key for a measurement of number of millseconds the mobile radio transmitter was
+     * transmitting data for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_TX_MS = HealthKeys.BASE_UID + 26;
 
+    /**
+     * Key for a measurement of the estimated number of mA*ms used by this uid
+     * for mobile data, that is to say the number of milliseconds of activity
+     * times the mA current during that period.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_POWER_MAMS = HealthKeys.BASE_UID + 27;
 
+    /**
+     * Key for a measurement of number of millseconds the wifi controller was
+     * active on behalf of this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_RUNNING_MS = HealthKeys.BASE_UID + 28;
 
+    /**
+     * Key for a measurement of number of millseconds that this uid held a full wifi lock.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_FULL_LOCK_MS = HealthKeys.BASE_UID + 29;
 
+    /**
+     * Key for a timer for the count and duration of wifi scans done by this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_WIFI_SCAN = HealthKeys.BASE_UID + 30;
 
+    /**
+     * Key for a measurement of number of millseconds that this uid was performing
+     * multicast wifi traffic.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_MULTICAST_MS = HealthKeys.BASE_UID + 31;
 
+    /**
+     * Key for a timer for the count and duration of audio playback done by this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_AUDIO = HealthKeys.BASE_UID + 32;
 
+    /**
+     * Key for a timer for the count and duration of video playback done by this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_VIDEO = HealthKeys.BASE_UID + 33;
 
+    /**
+     * Key for a timer for the count and duration this uid had the flashlight turned on.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_FLASHLIGHT = HealthKeys.BASE_UID + 34;
 
+    /**
+     * Key for a timer for the count and duration this uid had the camera turned on.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_CAMERA = HealthKeys.BASE_UID + 35;
 
+    /**
+     * Key for a timer for the count and duration of when an activity from this uid
+     * was the foreground activitiy.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_FOREGROUND_ACTIVITY = HealthKeys.BASE_UID + 36;
 
+    /**
+     * Key for a timer for the count and duration of when this uid was doing bluetooth scans.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_BLUETOOTH_SCAN = HealthKeys.BASE_UID + 37;
 
+    /**
+     * Key for a timer for the count and duration of when this uid was in the "top" process state.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_PROCESS_STATE_TOP_MS = HealthKeys.BASE_UID + 38;
 
+    /**
+     * Key for a timer for the count and duration of when this uid was in the "foreground service"
+     * process state.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_PROCESS_STATE_FOREGROUND_SERVICE_MS = HealthKeys.BASE_UID + 39;
 
+    /**
+     * Key for a timer for the count and duration of when this uid was in the "top sleeping"
+     * process state.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_PROCESS_STATE_TOP_SLEEPING_MS = HealthKeys.BASE_UID + 40;
 
+    /**
+     * Key for a timer for the count and duration of when this uid was in the "foreground"
+     * process state.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_PROCESS_STATE_FOREGROUND_MS = HealthKeys.BASE_UID + 41;
 
+    /**
+     * Key for a timer for the count and duration of when this uid was in the "background"
+     * process state.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_PROCESS_STATE_BACKGROUND_MS = HealthKeys.BASE_UID + 42;
 
+    /**
+     * Key for a timer for the count and duration of when this uid was in the "cached" process
+     * state.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_PROCESS_STATE_CACHED_MS = HealthKeys.BASE_UID + 43;
 
+    /**
+     * Key for a timer for the count and duration this uid had the vibrator turned on.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_VIBRATOR = HealthKeys.BASE_UID + 44;
 
+    /**
+     * Key for a measurement of number of software-generated user activity events caused
+     * by the UID.  Calls to userActivity() reset the user activity countdown timer and
+     * keep the screen on for the user's preferred screen-on setting.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_OTHER_USER_ACTIVITY_COUNT = HealthKeys.BASE_UID + 45;
 
+    /**
+     * Key for a measurement of number of user activity events due to physical button presses caused
+     * by the UID.  Calls to userActivity() reset the user activity countdown timer and
+     * keep the screen on for the user's preferred screen-on setting.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BUTTON_USER_ACTIVITY_COUNT = HealthKeys.BASE_UID + 46;
 
+    /**
+     * Key for a measurement of number of user activity events due to touch events caused
+     * by the UID.  Calls to userActivity() reset the user activity countdown timer and
+     * keep the screen on for the user's preferred screen-on setting.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_TOUCH_USER_ACTIVITY_COUNT = HealthKeys.BASE_UID + 47;
 
+    /**
+     * Key for a measurement of number of bytes received for this uid by the mobile radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_RX_BYTES = HealthKeys.BASE_UID + 48;
 
+    /**
+     * Key for a measurement of number of bytes transmitted for this uid by the mobile radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_TX_BYTES = HealthKeys.BASE_UID + 49;
 
+    /**
+     * Key for a measurement of number of bytes received for this uid by the wifi radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_RX_BYTES = HealthKeys.BASE_UID + 50;
 
+    /**
+     * Key for a measurement of number of bytes transmitted for this uid by the wifi radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_TX_BYTES = HealthKeys.BASE_UID + 51;
 
+    /**
+     * Key for a measurement of number of bytes received for this uid by the bluetooth radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_RX_BYTES = HealthKeys.BASE_UID + 52;
 
+    /**
+     * Key for a measurement of number of bytes transmitted for this uid by the bluetooth radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_TX_BYTES = HealthKeys.BASE_UID + 53;
 
+    /**
+     * Key for a measurement of number of packets received for this uid by the mobile radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_RX_PACKETS = HealthKeys.BASE_UID + 54;
 
+    /**
+     * Key for a measurement of number of packets transmitted for this uid by the mobile radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_MOBILE_TX_PACKETS = HealthKeys.BASE_UID + 55;
 
+    /**
+     * Key for a measurement of number of packets received for this uid by the wifi radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_RX_PACKETS = HealthKeys.BASE_UID + 56;
 
+    /**
+     * Key for a measurement of number of packets transmitted for this uid by the wifi radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_WIFI_TX_PACKETS = HealthKeys.BASE_UID + 57;
 
+    /**
+     * Key for a measurement of number of packets received for this uid by the bluetooth radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_RX_PACKETS = HealthKeys.BASE_UID + 58;
 
+    /**
+     * Key for a measurement of number of packets transmitted for this uid by the bluetooth radio.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_BLUETOOTH_TX_PACKETS = HealthKeys.BASE_UID + 59;
 
+    /**
+     * Key for a timer for the count and duration the mobile radio was turned on for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
     public static final int TIMER_MOBILE_RADIO_ACTIVE = HealthKeys.BASE_UID + 61;
 
+    /**
+     * Key for a measurement of the number of milliseconds spent by the CPU running user space
+     * code for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_USER_CPU_TIME_MS = HealthKeys.BASE_UID + 62;
 
+    /**
+     * Key for a measurement of the number of milliseconds spent by the CPU running kernel
+     * code for this uid.
+     */
     @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
     public static final int MEASUREMENT_SYSTEM_CPU_TIME_MS = HealthKeys.BASE_UID + 63;
 
diff --git a/core/java/android/os/storage/IMountService.java b/core/java/android/os/storage/IMountService.java
index 3915b02..b9bcd1c 100644
--- a/core/java/android/os/storage/IMountService.java
+++ b/core/java/android/os/storage/IMountService.java
@@ -1233,8 +1233,8 @@
             }
 
             @Override
-            public void changeUserKey(int userId, int serialNumber,
-                    byte[] token, byte[] oldSecret, byte[] newSecret) throws RemoteException {
+            public void addUserKeyAuth(int userId, int serialNumber,
+                    byte[] token, byte[] secret) throws RemoteException {
                 Parcel _data = Parcel.obtain();
                 Parcel _reply = Parcel.obtain();
                 try {
@@ -1242,9 +1242,23 @@
                     _data.writeInt(userId);
                     _data.writeInt(serialNumber);
                     _data.writeByteArray(token);
-                    _data.writeByteArray(oldSecret);
-                    _data.writeByteArray(newSecret);
-                    mRemote.transact(Stub.TRANSACTION_changeUserKey, _data, _reply, 0);
+                    _data.writeByteArray(secret);
+                    mRemote.transact(Stub.TRANSACTION_addUserKeyAuth, _data, _reply, 0);
+                    _reply.readException();
+                } finally {
+                    _reply.recycle();
+                    _data.recycle();
+                }
+            }
+
+            @Override
+            public void fixateNewestUserKeyAuth(int userId) throws RemoteException {
+                Parcel _data = Parcel.obtain();
+                Parcel _reply = Parcel.obtain();
+                try {
+                    _data.writeInterfaceToken(DESCRIPTOR);
+                    _data.writeInt(userId);
+                    mRemote.transact(Stub.TRANSACTION_fixateNewestUserKeyAuth, _data, _reply, 0);
                     _reply.readException();
                 } finally {
                     _reply.recycle();
@@ -1489,7 +1503,9 @@
 
         static final int TRANSACTION_mountAppFuse = IBinder.FIRST_CALL_TRANSACTION + 69;
 
-        static final int TRANSACTION_changeUserKey = IBinder.FIRST_CALL_TRANSACTION + 70;
+        static final int TRANSACTION_addUserKeyAuth = IBinder.FIRST_CALL_TRANSACTION + 70;
+
+        static final int TRANSACTION_fixateNewestUserKeyAuth = IBinder.FIRST_CALL_TRANSACTION + 71;
 
         /**
          * Cast an IBinder object into an IMountService interface, generating a
@@ -2069,14 +2085,20 @@
                     reply.writeNoException();
                     return true;
                 }
-                case TRANSACTION_changeUserKey: {
+                case TRANSACTION_addUserKeyAuth: {
                     data.enforceInterface(DESCRIPTOR);
                     int userId = data.readInt();
                     int serialNumber = data.readInt();
                     byte[] token = data.createByteArray();
-                    byte[] oldSecret = data.createByteArray();
-                    byte[] newSecret = data.createByteArray();
-                    changeUserKey(userId, serialNumber, token, oldSecret, newSecret);
+                    byte[] secret = data.createByteArray();
+                    addUserKeyAuth(userId, serialNumber, token, secret);
+                    reply.writeNoException();
+                    return true;
+                }
+                case TRANSACTION_fixateNewestUserKeyAuth: {
+                    data.enforceInterface(DESCRIPTOR);
+                    int userId = data.readInt();
+                    fixateNewestUserKeyAuth(userId);
                     reply.writeNoException();
                     return true;
                 }
@@ -2452,8 +2474,9 @@
     public void createUserKey(int userId, int serialNumber, boolean ephemeral)
             throws RemoteException;
     public void destroyUserKey(int userId) throws RemoteException;
-    public void changeUserKey(int userId, int serialNumber,
-            byte[] token, byte[] oldSecret, byte[] newSecret) throws RemoteException;
+    public void addUserKeyAuth(int userId, int serialNumber,
+            byte[] token, byte[] secret) throws RemoteException;
+    public void fixateNewestUserKeyAuth(int userId) throws RemoteException;
 
     public void unlockUserKey(int userId, int serialNumber,
             byte[] token, byte[] secret) throws RemoteException;
diff --git a/core/jni/android_hardware_location_ContextHubService.cpp b/core/jni/android_hardware_location_ContextHubService.cpp
index 98d6b24..3881d6d 100644
--- a/core/jni/android_hardware_location_ContextHubService.cpp
+++ b/core/jni/android_hardware_location_ContextHubService.cpp
@@ -319,14 +319,27 @@
     }
 
     jbyteArray jmsg = env->NewByteArray(msgLen);
+    if (jmsg == nullptr) {
+        ALOGW("Can't allocate %zu byte array", msgLen);
+        return -1;
+    }
     jintArray jheader = env->NewIntArray(headerLen);
+    if (jheader == nullptr) {
+        env->DeleteLocalRef(jmsg);
+        ALOGW("Can't allocate %zu int array", headerLen);
+        return -1;
+    }
 
     env->SetByteArrayRegion(jmsg, 0, msgLen, (jbyte *)msg);
     env->SetIntArrayRegion(jheader, 0, headerLen, (jint *)header);
 
-    return (env->CallIntMethod(db.jniInfo.jContextHubService,
+    int ret = (env->CallIntMethod(db.jniInfo.jContextHubService,
                           db.jniInfo.contextHubServiceMsgReceiptCallback,
                           jheader, jmsg) != 0);
+    env->DeleteLocalRef(jmsg);
+    env->DeleteLocalRef(jheader);
+
+    return ret;
 }
 
 int handle_query_apps_response(char *msg, int msgLen, uint32_t hubHandle) {
@@ -529,12 +542,15 @@
 
     jstrBuf = env->NewStringUTF(hub->name);
     env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetName, jstrBuf);
+    env->DeleteLocalRef(jstrBuf);
 
     jstrBuf = env->NewStringUTF(hub->vendor);
     env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetVendor, jstrBuf);
+    env->DeleteLocalRef(jstrBuf);
 
     jstrBuf = env->NewStringUTF(hub->toolchain);
     env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetToolchain, jstrBuf);
+    env->DeleteLocalRef(jstrBuf);
 
     env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetPlatformVersion, hub->platform_version);
     env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetToolchainVersion, hub->toolchain_version);
@@ -555,11 +571,13 @@
     jintBuf = env->NewIntArray(array_length(dummyConnectedSensors));
     env->SetIntArrayRegion(jintBuf, 0, hub->num_connected_sensors, dummyConnectedSensors);
     env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetSupportedSensors, jintBuf);
+    env->DeleteLocalRef(jintBuf);
 
     // We are not getting the memory regions from the CH Hal - change this when it is available
     jmemBuf = env->NewObjectArray(0, db.jniInfo.memoryRegionsClass, nullptr);
     // Note the zero size above. We do not need to set any elements
     env->CallVoidMethod(jHub, db.jniInfo.contextHubInfoSetMemoryRegions, jmemBuf);
+    env->DeleteLocalRef(jmemBuf);
 
 
     return jHub;
diff --git a/core/res/res/values-be-rBY/strings.xml b/core/res/res/values-be-rBY/strings.xml
index 7fa9f16..2ef61e8 100644
--- a/core/res/res/values-be-rBY/strings.xml
+++ b/core/res/res/values-be-rBY/strings.xml
@@ -269,7 +269,7 @@
     <string name="capability_title_canRetrieveWindowContent" msgid="3901717936930170320">"Атрымайце змесцiва акна"</string>
     <string name="capability_desc_canRetrieveWindowContent" msgid="3772225008605310672">"Вывучыце змесцiва акна, з якiм вы працуеце."</string>
     <string name="capability_title_canRequestTouchExploration" msgid="3108723364676667320">"Уключыце Explore by Touch"</string>
-    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"Элементы, да якiх дакранулiся, будуць агучаны, а з экранам можна будзе ўзаемадзейнічаць пры дапамозе жэстаў."</string>
+    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"Элементы, да якіх дакрануліся, будуць агучаны, а экранам можна даследаваць пры дапамозе жэстаў."</string>
     <string name="capability_title_canRequestEnhancedWebAccessibility" msgid="1739881766522594073">"Уключыце паляпшэнне вэб-даступнасці"</string>
     <string name="capability_desc_canRequestEnhancedWebAccessibility" msgid="7881063961507511765">"Сцэнарыi могуць быць усталяваны, каб зрабіць змесцiва прыкладання больш даступным."</string>
     <string name="capability_title_canRequestFilterKeyEvents" msgid="2103440391902412174">"Глядзiце, што набiраеце"</string>
@@ -1136,7 +1136,7 @@
     <string name="usb_ptp_notification_title" msgid="1347328437083192112">"USB для перадачы фота"</string>
     <string name="usb_midi_notification_title" msgid="4850904915889144654">"USB для MIDI"</string>
     <string name="usb_accessory_notification_title" msgid="7848236974087653666">"Падключаны да USB-прылады"</string>
-    <string name="usb_notification_message" msgid="3370903770828407960">"Дакраніцеся, каб атрымаць больш параметраў."</string>
+    <string name="usb_notification_message" msgid="3370903770828407960">"Дакраніцеся, каб атрымаць іншыя параметры."</string>
     <string name="adb_active_notification_title" msgid="6729044778949189918">"Прылада адладкі USB падключана"</string>
     <string name="adb_active_notification_message" msgid="4948470599328424059">"Дакраніцеся, каб адключыць адладку USB."</string>
     <string name="taking_remote_bugreport_notification_title" msgid="6742483073875060934">"Стварэнне справаздачы пра памылку…"</string>
@@ -1232,13 +1232,13 @@
     <string name="vpn_lockdown_connecting" msgid="6443438964440960745">"Падключэнне заўсёды ўключанага VPN..."</string>
     <string name="vpn_lockdown_connected" msgid="8202679674819213931">"Заўсёды ўключаны i падключаны VPN"</string>
     <string name="vpn_lockdown_error" msgid="6009249814034708175">"Памылка заўсёды ўключанага VPN"</string>
-    <string name="vpn_lockdown_config" msgid="4655589351146766608">"Дакраніцеся, каб змяніць канфігурацыю"</string>
+    <string name="vpn_lockdown_config" msgid="4655589351146766608">"Дакраніцеся, каб сканфігураваць"</string>
     <string name="upload_file" msgid="2897957172366730416">"Выберыце файл"</string>
     <string name="no_file_chosen" msgid="6363648562170759465">"Файл не выбраны"</string>
     <string name="reset" msgid="2448168080964209908">"Скінуць"</string>
     <string name="submit" msgid="1602335572089911941">"Перадаць"</string>
     <string name="car_mode_disable_notification_title" msgid="3164768212003864316">"Рэжым \"У машыне\" ўключаны"</string>
-    <string name="car_mode_disable_notification_message" msgid="6301524980144350051">"Дакраніцеся, каб выйсці з рэжыму \"Ў аўтамабілі\"."</string>
+    <string name="car_mode_disable_notification_message" msgid="6301524980144350051">"Дакраніцеся, каб выйсці з рэжыму \"У машыне\"."</string>
     <string name="tethered_notification_title" msgid="3146694234398202601">"USB-мадэм або кропка доступу Wi-Fi актыўныя"</string>
     <string name="tethered_notification_message" msgid="2113628520792055377">"Дакраніцеся, каб наладзіць."</string>
     <string name="back_button_label" msgid="2300470004503343439">"Назад"</string>
@@ -1275,7 +1275,7 @@
     <string name="add_account_button_label" msgid="3611982894853435874">"Дадаць уліковы запіс"</string>
     <string name="number_picker_increment_button" msgid="2412072272832284313">"Павялічыць"</string>
     <string name="number_picker_decrement_button" msgid="476050778386779067">"Паменшыць"</string>
-    <string name="number_picker_increment_scroll_mode" msgid="5259126567490114216">"Націсніце і ўтрымлівайце <xliff:g id="VALUE">%s</xliff:g>."</string>
+    <string name="number_picker_increment_scroll_mode" msgid="5259126567490114216">"<xliff:g id="VALUE">%s</xliff:g> – Націсніце і ўтрымлівайце."</string>
     <string name="number_picker_increment_scroll_action" msgid="9101473045891835490">"Правядзіце пальцам уверх, каб павялічыць, або ўніз, каб паменшыць."</string>
     <string name="time_picker_increment_minute_button" msgid="8865885114028614321">"Павялічыць лічбу хвілін."</string>
     <string name="time_picker_decrement_minute_button" msgid="6246834937080684791">"Паменшыць лічбу хвілін."</string>
@@ -1319,7 +1319,7 @@
     <string name="storage_usb" msgid="3017954059538517278">"USB-назапашвальнік"</string>
     <string name="extract_edit_menu_button" msgid="8940478730496610137">"Рэдагаваць"</string>
     <string name="data_usage_warning_title" msgid="1955638862122232342">"Папярэджанне выкарыстання дадзеных"</string>
-    <string name="data_usage_warning_body" msgid="6660692274311972007">"Кран. для прагл. выкар. і налад."</string>
+    <string name="data_usage_warning_body" msgid="6660692274311972007">"Прагляд выкарыстання і налад."</string>
     <string name="data_usage_3g_limit_title" msgid="4361523876818447683">"Дасягнуты ліміт трафіку 2G-3G"</string>
     <string name="data_usage_4g_limit_title" msgid="4609566827219442376">"Дасягнуты ліміт трафіку 4G"</string>
     <string name="data_usage_mobile_limit_title" msgid="557158376602636112">"Дасягн. ліміт маб.перадачы даных"</string>
@@ -1549,8 +1549,8 @@
     <string name="select_year" msgid="7952052866994196170">"Выберыце год"</string>
     <string name="deleted_key" msgid="7659477886625566590">"Выдалена: <xliff:g id="KEY">%1$s</xliff:g>"</string>
     <string name="managed_profile_label_badge" msgid="2355652472854327647">"<xliff:g id="LABEL">%1$s</xliff:g> (праца)"</string>
-    <string name="lock_to_app_toast" msgid="1420543809500606964">"Каб адмацаваць гэты экран, краніце і ўтрымлівайце кнопку \"Назад\"."</string>
-    <string name="lock_to_app_toast_accessible" msgid="2302154926850846096">"Каб адмацаваць гэты экран, краніце і ўтрымлівайце кнопку \"Агляд\"."</string>
+    <string name="lock_to_app_toast" msgid="1420543809500606964">"Каб адмацаваць гэты экран, дакраніцеся і ўтрымлівайце кнопку \"Назад\"."</string>
+    <string name="lock_to_app_toast_accessible" msgid="2302154926850846096">"Каб адмацаваць гэты экран, дакраніцеся і ўтрымлівайце кнопку \"Агляд\"."</string>
     <string name="lock_to_app_toast_locked" msgid="9125176335701699164">"Праграма замацавана: адмацаванне на гэтай прыладзе не дапускаецца."</string>
     <string name="lock_to_app_start" msgid="6643342070839862795">"Экран замацаваны"</string>
     <string name="lock_to_app_exit" msgid="8598219838213787430">"Экран адмацаваны"</string>
diff --git a/core/res/res/values-es/strings.xml b/core/res/res/values-es/strings.xml
index 858cf27..7590ea9 100644
--- a/core/res/res/values-es/strings.xml
+++ b/core/res/res/values-es/strings.xml
@@ -263,7 +263,7 @@
     <string name="capability_title_canRetrieveWindowContent" msgid="3901717936930170320">"Recuperar el contenido de la ventana"</string>
     <string name="capability_desc_canRetrieveWindowContent" msgid="3772225008605310672">"Inspecciona el contenido de una ventana con la que estés interactuando."</string>
     <string name="capability_title_canRequestTouchExploration" msgid="3108723364676667320">"Activar la exploración táctil"</string>
-    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"Los elementos seleccionados se dicen en voz alta y se puede explorar la pantalla mediante gestos."</string>
+    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"Los elementos que tocas se dicen en voz alta y se puede explorar la pantalla mediante gestos."</string>
     <string name="capability_title_canRequestEnhancedWebAccessibility" msgid="1739881766522594073">"Activar la accesibilidad web mejorada"</string>
     <string name="capability_desc_canRequestEnhancedWebAccessibility" msgid="7881063961507511765">"Es posible que se instalen secuencias de comandos para que el contenido de las aplicaciones sea más accesible."</string>
     <string name="capability_title_canRequestFilterKeyEvents" msgid="2103440391902412174">"Observar el texto que escribes"</string>
@@ -662,7 +662,7 @@
     <string name="keyguard_password_enter_puk_code" msgid="4800725266925845333">"Introduce el código PUK y un nuevo código PIN."</string>
     <string name="keyguard_password_enter_puk_prompt" msgid="1341112146710087048">"Código PUK"</string>
     <string name="keyguard_password_enter_pin_prompt" msgid="8027680321614196258">"Nuevo código PIN"</string>
-    <string name="keyguard_password_entry_touch_hint" msgid="2644215452200037944"><font size="17">"Toca para insertar contraseña"</font></string>
+    <string name="keyguard_password_entry_touch_hint" msgid="2644215452200037944"><font size="17">"Toca para escribir contraseña"</font></string>
     <string name="keyguard_password_enter_password_code" msgid="1054721668279049780">"Introduce la contraseña para desbloquear."</string>
     <string name="keyguard_password_enter_pin_password_code" msgid="6391755146112503443">"Introduce el código PIN para desbloquear."</string>
     <string name="keyguard_password_wrong_pin_code" msgid="2422225591006134936">"Código PIN incorrecto"</string>
@@ -1124,7 +1124,7 @@
     <string name="ext_media_new_notification_message" msgid="7589986898808506239">"Nueva <xliff:g id="NAME">%s</xliff:g> detectada"</string>
     <string name="ext_media_ready_notification_message" msgid="4083398150380114462">"Para transferir fotos y multimedia"</string>
     <string name="ext_media_unmountable_notification_title" msgid="8295123366236989588">"Medio externo (<xliff:g id="NAME">%s</xliff:g>) dañado"</string>
-    <string name="ext_media_unmountable_notification_message" msgid="2343202057122495773">"<xliff:g id="NAME">%s</xliff:g> está dañado. Toca para solucionar el problema."</string>
+    <string name="ext_media_unmountable_notification_message" msgid="2343202057122495773">"<xliff:g id="NAME">%s</xliff:g> está en mal estado. Toca para solucionar el problema."</string>
     <string name="ext_media_unsupported_notification_title" msgid="3797642322958803257">"Medio externo (<xliff:g id="NAME">%s</xliff:g>) no admitido"</string>
     <string name="ext_media_unsupported_notification_message" msgid="6121601473787888589">"El dispositivo no admite este medio externo (<xliff:g id="NAME">%s</xliff:g>). Toca para configurarlo con un formato admitido."</string>
     <string name="ext_media_badremoval_notification_title" msgid="3206248947375505416">"Extracción inesperada de <xliff:g id="NAME">%s</xliff:g>"</string>
diff --git a/core/res/res/values-fa/strings.xml b/core/res/res/values-fa/strings.xml
index c32b98c..27aecad 100644
--- a/core/res/res/values-fa/strings.xml
+++ b/core/res/res/values-fa/strings.xml
@@ -310,7 +310,7 @@
     <string name="permdesc_enableCarMode" msgid="4853187425751419467">"‏به برنامه اجازه می‎دهد تا حالت خودرو را فعال کند."</string>
     <string name="permlab_killBackgroundProcesses" msgid="3914026687420177202">"بستن سایر برنامه‌ها"</string>
     <string name="permdesc_killBackgroundProcesses" msgid="4593353235959733119">"به برنامه امکان می‌دهد به فرآیندهای پس‌زمینه سایر برنامه‌ها پایان دهد. این ممکن است باعث شود سایر برنامه‌ها متوقف شوند."</string>
-    <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"ترسیم روی برنامه‌های دیگر"</string>
+    <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"نمایش روی برنامه‌های دیگر"</string>
     <string name="permdesc_systemAlertWindow" msgid="8584678381972820118">"به برنامه اجازه می‌دهد که در بالا یا بخش‌هایی از رابط کاربری دیگر برنامه‌های کاربردی متصل شود. این کار می‌تواند در استفاده شما از رابط هر برنامه کاربردی تداخل ایجاد کند یا آنچه را که به نظر خود در دیگر برنامه‌های کاربردی می‌بینید، تغییر دهد."</string>
     <string name="permlab_persistentActivity" msgid="8841113627955563938">"همیشه برنامه اجرا شود"</string>
     <string name="permdesc_persistentActivity" product="tablet" msgid="8525189272329086137">"به برنامه امکان می‌دهد قسمت‌هایی از خود را در حافظه دائمی کند. این کار حافظه موجود را برای سایر برنامه‌ها محدود کرده و باعث کندی رایانهٔ لوحی می‌شود."</string>
diff --git a/core/res/res/values-gl-rES/strings.xml b/core/res/res/values-gl-rES/strings.xml
index 455632d..cf04177 100644
--- a/core/res/res/values-gl-rES/strings.xml
+++ b/core/res/res/values-gl-rES/strings.xml
@@ -310,7 +310,7 @@
     <string name="permdesc_enableCarMode" msgid="4853187425751419467">"Permite á aplicación activar o modo coche."</string>
     <string name="permlab_killBackgroundProcesses" msgid="3914026687420177202">"pechar outras aplicacións"</string>
     <string name="permdesc_killBackgroundProcesses" msgid="4593353235959733119">"Permite á aplicación finalizar procesos en segundo plano doutras aplicacións. É posible que esta acción provoque que outras aplicacións deixen de funcionar."</string>
-    <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"debuxar sobre outras aplicacións"</string>
+    <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"superpoñerse a outras aplicacións"</string>
     <string name="permdesc_systemAlertWindow" msgid="8584678381972820118">"Permite á aplicación debuxar sobre outras aplicacións ou partes da interface de usuario. É posible que interfiran co teu uso da interface de calquera aplicación ou que cambien o que cres que estás vendo noutras aplicacións."</string>
     <string name="permlab_persistentActivity" msgid="8841113627955563938">"facer que a aplicación se execute sempre"</string>
     <string name="permdesc_persistentActivity" product="tablet" msgid="8525189272329086137">"Permite á aplicación converter partes súas como persistentes na memoria. Esta acción pode limitar a cantidade memoria dispoñible para outras aplicacións e reducir a velocidade de funcionamento do tablet."</string>
diff --git a/core/res/res/values-hy-rAM/strings.xml b/core/res/res/values-hy-rAM/strings.xml
index 260992a..33c8f7c 100644
--- a/core/res/res/values-hy-rAM/strings.xml
+++ b/core/res/res/values-hy-rAM/strings.xml
@@ -263,7 +263,7 @@
     <string name="capability_title_canRetrieveWindowContent" msgid="3901717936930170320">"Առբերել պատուհանի բովանդակությունը"</string>
     <string name="capability_desc_canRetrieveWindowContent" msgid="3772225008605310672">"Ստուգեք պատուհանի բովանդակությունը, որի հետ փոխգործակցում եք:"</string>
     <string name="capability_title_canRequestTouchExploration" msgid="3108723364676667320">"Միացնել Հպման միջոցով հետազոտումը"</string>
-    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"Տարրերը, որոնց հպեք, բարձրաձայն կարտասանվեն, և էկրանը հնարավոր կլինի ուսումնասիրել ժեստերով:"</string>
+    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"Ուսումնաիրեք էկրանը այն շոշափելով։ Այս կամ այն տարրին հպելուց հետո դրանք բարձրաձայն կնկարագրվեն։"</string>
     <string name="capability_title_canRequestEnhancedWebAccessibility" msgid="1739881766522594073">"Միացնել ընդլայնված վեբ մատչելիությունը"</string>
     <string name="capability_desc_canRequestEnhancedWebAccessibility" msgid="7881063961507511765">"Հնարավոր է սկրիպտներ տեղադրվեն` ծրագրի բովանդակությունն ավելի մատչելի դարձնելու համար:"</string>
     <string name="capability_title_canRequestFilterKeyEvents" msgid="2103440391902412174">"Զննել ձեր մուտքագրած տեքստը"</string>
@@ -1124,7 +1124,7 @@
     <string name="ext_media_new_notification_message" msgid="7589986898808506239">"Հայտնաբերվել է նոր <xliff:g id="NAME">%s</xliff:g>"</string>
     <string name="ext_media_ready_notification_message" msgid="4083398150380114462">"Լուսանկարներ և մեդիա ֆայլեր տեղափոխելու համար"</string>
     <string name="ext_media_unmountable_notification_title" msgid="8295123366236989588">"<xliff:g id="NAME">%s</xliff:g>-ը վնասված է"</string>
-    <string name="ext_media_unmountable_notification_message" msgid="2343202057122495773">"<xliff:g id="NAME">%s</xliff:g> անունը վնասված է: Հպեք՝ շտկելու համար:"</string>
+    <string name="ext_media_unmountable_notification_message" msgid="2343202057122495773">"<xliff:g id="NAME">%s</xliff:g>-ը վնասված է: Հպեք՝ շտկելու համար:"</string>
     <string name="ext_media_unsupported_notification_title" msgid="3797642322958803257">"Չապահովվող <xliff:g id="NAME">%s</xliff:g>"</string>
     <string name="ext_media_unsupported_notification_message" msgid="6121601473787888589">"Այս սարքը չի աջակցում այս <xliff:g id="NAME">%s</xliff:g>-ը: Հպեք՝ աջակցվող ձևաչափով կարգավորելու համար:"</string>
     <string name="ext_media_badremoval_notification_title" msgid="3206248947375505416">"<xliff:g id="NAME">%s</xliff:g>-ը հեռացվել է առանց անջատելու"</string>
diff --git a/core/res/res/values-iw/strings.xml b/core/res/res/values-iw/strings.xml
index 316626d..29e6dec5 100644
--- a/core/res/res/values-iw/strings.xml
+++ b/core/res/res/values-iw/strings.xml
@@ -269,7 +269,7 @@
     <string name="capability_title_canRetrieveWindowContent" msgid="3901717936930170320">"אחזור תוכן של חלון"</string>
     <string name="capability_desc_canRetrieveWindowContent" msgid="3772225008605310672">"בדוק את התוכן של חלון שאיתו אתה מבצע אינטראקציה."</string>
     <string name="capability_title_canRequestTouchExploration" msgid="3108723364676667320">"הפעלה של \'גילוי באמצעות מגע\'"</string>
-    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"פריטים שעליהם תקיש ייאמרו בקול, ותוכל לנווט במסך באמצעות תנועות."</string>
+    <string name="capability_desc_canRequestTouchExploration" msgid="7543249041581408313">"פריטים שעליהם תקיש יוקראו בקול, ותוכל לנווט במסך באמצעות תנועות."</string>
     <string name="capability_title_canRequestEnhancedWebAccessibility" msgid="1739881766522594073">"הפעלה של גישה משופרת לאינטרנט"</string>
     <string name="capability_desc_canRequestEnhancedWebAccessibility" msgid="7881063961507511765">"ייתכן שסקריפטים יותקנו על מנת להקל את הגישה אל תוכן של אפליקציות."</string>
     <string name="capability_title_canRequestFilterKeyEvents" msgid="2103440391902412174">"הצגת טקסט בזמן הקלדה"</string>
diff --git a/core/res/res/values-kk-rKZ/strings.xml b/core/res/res/values-kk-rKZ/strings.xml
index 60671ab..984035d 100644
--- a/core/res/res/values-kk-rKZ/strings.xml
+++ b/core/res/res/values-kk-rKZ/strings.xml
@@ -1286,7 +1286,7 @@
     <string name="storage_usb" msgid="3017954059538517278">"USB жады"</string>
     <string name="extract_edit_menu_button" msgid="8940478730496610137">"Өзгерту"</string>
     <string name="data_usage_warning_title" msgid="1955638862122232342">"Дерекқор қолдануға қатысты ескерту"</string>
-    <string name="data_usage_warning_body" msgid="6660692274311972007">"Қолданыс пен параметрлерді көру үшін түртіңіз."</string>
+    <string name="data_usage_warning_body" msgid="6660692274311972007">"Трафик пен параметрлерді көру үшін түртіңіз."</string>
     <string name="data_usage_3g_limit_title" msgid="4361523876818447683">"2G-3G деректер шегіне жеттіңіз"</string>
     <string name="data_usage_4g_limit_title" msgid="4609566827219442376">"4G деректер шегіне жеттіңіз"</string>
     <string name="data_usage_mobile_limit_title" msgid="557158376602636112">"Ұялы деректер шегіне жеттіңіз"</string>
diff --git a/core/res/res/values-sq-rAL/strings.xml b/core/res/res/values-sq-rAL/strings.xml
index 51015f2..52ddeb0 100644
--- a/core/res/res/values-sq-rAL/strings.xml
+++ b/core/res/res/values-sq-rAL/strings.xml
@@ -1242,7 +1242,7 @@
     <string name="add_account_button_label" msgid="3611982894853435874">"Shto llogari"</string>
     <string name="number_picker_increment_button" msgid="2412072272832284313">"Rrit"</string>
     <string name="number_picker_decrement_button" msgid="476050778386779067">"Pakëso"</string>
-    <string name="number_picker_increment_scroll_mode" msgid="5259126567490114216">"Prek dhe mbaj të shtypur te <xliff:g id="VALUE">%s</xliff:g>."</string>
+    <string name="number_picker_increment_scroll_mode" msgid="5259126567490114216">"Prek dhe mbaj të shtypur <xliff:g id="VALUE">%s</xliff:g>."</string>
     <string name="number_picker_increment_scroll_action" msgid="9101473045891835490">"Rrëshqit lart për të rritur dhe poshtë për të pakësuar."</string>
     <string name="time_picker_increment_minute_button" msgid="8865885114028614321">"Rrit vlerat për minutë"</string>
     <string name="time_picker_decrement_minute_button" msgid="6246834937080684791">"Pakëso vlerat për minutë"</string>
@@ -1514,8 +1514,8 @@
     <string name="select_year" msgid="7952052866994196170">"Përzgjidh vitin"</string>
     <string name="deleted_key" msgid="7659477886625566590">"<xliff:g id="KEY">%1$s</xliff:g> u fshi"</string>
     <string name="managed_profile_label_badge" msgid="2355652472854327647">"Puna <xliff:g id="LABEL">%1$s</xliff:g>"</string>
-    <string name="lock_to_app_toast" msgid="1420543809500606964">"Për të hequr gozhdimin e ekranit, prek dhe mbaj të shtypur te \"Prapa\"."</string>
-    <string name="lock_to_app_toast_accessible" msgid="2302154926850846096">"Për të hequr gozhdimin e ekranit, prek dhe mbaj të shtypur te \"Përmbledhja\"."</string>
+    <string name="lock_to_app_toast" msgid="1420543809500606964">"Për të hequr gozhdimin e ekranit, prek dhe mbaj të shtypur \"Prapa\"."</string>
+    <string name="lock_to_app_toast_accessible" msgid="2302154926850846096">"Për të hequr gozhdimin e ekranit, prek dhe mbaj të shtypur \"Përmbledhja\"."</string>
     <string name="lock_to_app_toast_locked" msgid="9125176335701699164">"Ekrani është i gozhduar. Anulimi i mbërthimit nuk lejohet nga organizata jote."</string>
     <string name="lock_to_app_start" msgid="6643342070839862795">"Ekrani u gozhdua"</string>
     <string name="lock_to_app_exit" msgid="8598219838213787430">"Ekrani u hoq nga gozhdimi"</string>
diff --git a/docs/html/_redirects.yaml b/docs/html/_redirects.yaml
index 3a60c2c..f0986aa 100644
--- a/docs/html/_redirects.yaml
+++ b/docs/html/_redirects.yaml
@@ -5,24 +5,22 @@
   to: /about/index.html
 - from: /about/versions/api-levels.html
   to: /guide/topics/manifest/uses-sdk-element.html#ApiLevels
-- from: /sdk/oem-usb.html
-  to: /studio/tools/extras/oem-usb.html
 - from: /sdk/installing.html
   to: /studio/index.html
 - from: /sdk/exploring.html
-  to: /studio/guide/index.html
+  to: /studio/intro/update.html
 - from: /sdk/installing/adding-packages.html
-  to: /studio/tools/help/sdk-manager.html
+  to: /studio/intro/update.html
 - from: /sdk/installing/bundle.html
-  to: /studio/index.html
+  to: /studio/intro/update.html
 - from: /sdk/installing/studio.html
   to: /studio/index.html
 - from: /sdk/installing/studio-debug.html
-  to: /studio/tools/debugging/debugging-studio.html
+  to: /studio/debug/index.html
 - from: /tools/debugging/debugging-devtools.html
-  to: /studio/tools/debugging/index.html
+  to: /studio/debug/index.html
 - from: /tools/debugging/debugging-projects-cmdline.html
-  to: /studio/tools/debugging/index.html
+  to: /studio/debug/index.html
 - from: /sdk/compatibility-library.html
   to: /topic/libraries/support-library/index.html
 - from: /tools/extras/support-library.html
@@ -32,11 +30,11 @@
 - from: /sdk/eclipse-adt.html
   to: /studio/tools/sdk/eclipse-adt.html
 - from: /sdk/RELEASENOTES.html
-  to: /studio/tools/sdk/tools-notes.html
+  to: /studio/releases/sdk-tools.html
 - from: /sdk/tools-notes.html
-  to: /studio/tools/sdk/tools-notes.html
+  to: /studio/releases/sdk-tools.html
 - from: /sdk/adding-components.html
-  to: /studio/tools/help/sdk-manager.html
+  to: /studio/intro/update.html
 - from: /sdk/ndk/overview.html
   to: /ndk/index.html
 - from: /sdk/ndk/
@@ -44,15 +42,15 @@
 - from: /go/vulkan
   to: /ndk/guides/graphics/index.html
 - from: /tools/sdk/win-usb.html
-  to: /studio/guide/run/win-usb.html
+  to: /studio/run/win-usb.html
 - from: /tools/sdk/index.html
   to: /studio/index.html
 - from: /tools/index.html
   to: /tools-moved.html
 - from: /tools/sdk/installing.html
-  to: /studio/sdk/index.html
-- from: /tools/eclipse/installing-adt.html
   to: /studio/index.html
+- from: /tools/eclipse/installing-adt.html
+  to: /studio/tools/help/adt.html
 - from: /sdk/requirements.html
   to: /studio/index.html
 - from: /sdk/installing/next.html
@@ -156,7 +154,7 @@
 - from: /google/play/billing/billing_about.html
   to: /google/play/billing/index.html
 - from: /guide/developing/tools/
-  to: /studio/tools/help/
+  to: /studio/command-line/
 - from: /guide/developing/
   to: /studio/
 - from: /tools/aidl.html
@@ -166,7 +164,7 @@
 - from: /guide/publishing/publishing.html
   to: /distribute/tools/launch-checklist.html
 - from: /guide/publishing/
-  to: /studio/tools/publishing/publishing_overview.html
+  to: /studio/publish/index.html
 - from: /guide/topics/fundamentals.html
   to: /guide/components/fundamentals.html
 - from: /guide/topics/intents/intents-filters.html
@@ -184,21 +182,21 @@
 - from: /guide/topics/connectivity/usb/adk.html
   to: /adk/index.html
 - from: /tools/workflow/publishing/versioning.html
-  to: /studio/tools/publishing/versioning.html
+  to: /studio/publish/versioning.html
 - from: /tools/workflow/publishing/publishing.html
-  to: /studio/tools/publishing/publishing_overview.html
+  to: /studio/publish/index.html
 - from: /tools/workflow/publishing_overview.html
-  to: /studio/tools/publishing/publishing_overview.html
+  to: /studio/publish/index.html
 - from: /tools/workflow/publishing/publishing_overview.html
-  to: /studio/tools/publishing/publishing_overview.html
+  to: /studio/publish/index.html
 - from: /tools/workflow/app-signing.html
-  to: /studio/tools/publishing/app-signing.html
+  to: /studio/publish/app-signing.html
 - from: /tools/adk/aoa.html
   to: https://source.android.com/tech/accessories/aoap/aoa.html
 - from: /tools/adk/aoa2.html
   to: https://source.android.com/tech/accessories/aoap/aoa2.html
 - from: /tools/eclipse/migrate-adt.html
-  to: /studio/installing/migrate.html
+  to: /studio/intro/migrate.html
 - from: /guide/topics/usb
   to: /guide/topics/connectivity/usb
 - from: /guide/appendix/api-levels.html
@@ -216,7 +214,7 @@
 - from: /guide/appendix/market-filters.html
   to: /google/play/filters.html
 - from: /guide/topics/testing/
-  to: /studio/tools/testing/
+  to: /studio/test/
 - from: /guide/topics/graphics/animation.html
   to: /guide/topics/graphics/overview.html
 - from: /guide/topics/graphics/renderscript/compute.html
@@ -507,8 +505,6 @@
   to: /distribute/engage/index.html
 - from: /essentials/best-practices/...
   to: /distribute/googleplay/guide.html
-- from: /tools/index.html
-  to: /distribute/essentials/index.html#tools
 - from: /users/build-buzz.html
   to: /distribute/users/index.html
 - from: /users/build-community.html
@@ -800,47 +796,47 @@
 - from: /2016/03/first-preview-of-android-n-developer.html
   to: http://android-developers.blogspot.com/2016/03/first-preview-of-android-n-developer.html
 - from: /r/studio-ui/vector-asset-studio.html
-  to: /studio/tools/help/vector-asset-studio.html
+  to: /studio/write/vector-asset-studio.html
 - from: /r/studio-ui/image-asset-studio.html
-  to: /studio/tools/help/image-asset-studio.html
+  to: /studio/write/image-asset-studio.html
 - from: /r/studio-ui/project-structure.html
-  to: /studio/tools/help/project-mgmt.html
+  to: /studio/projects/index.html
 - from: /r/studio-ui/android-monitor.html
-  to: /studio/tools/help/android-monitor.html
+  to: /studio/profile/android-monitor.html
 - from: /r/studio-ui/am-logcat.html
-  to: /studio/tools/help/am-logcat.html
+  to: /studio/debug/am-logcat.html
 - from: /r/studio-ui/am-memory.html
-  to: /studio/tools/help/am-memory.html
+  to: /studio/profile/am-memory.html
 - from: /r/studio-ui/am-cpu.html
-  to: /studio/tools/help/am-cpu.html
+  to: /studio/profile/am-cpu.html
 - from: /r/studio-ui/am-gpu.html
-  to: /studio/tools/help/am-gpu.html
+  to: /studio/profile/am-gpu.html
 - from: /r/studio-ui/am-network.html
-  to: /studio/tools/help/am-network.html
+  to: /studio/profile/am-network.html
 - from: /r/studio-ui/am-hprof.html
-  to: /studio/tools/help/am-hprof.html
+  to: /studio/profile/am-hprof.html
 - from: /r/studio-ui/am-allocation.html
-  to: /studio/tools/help/am-allocation.html
+  to: /studio/profile/am-allocation.html
 - from: /r/studio-ui/am-methodtrace.html
-  to: /studio/tools/help/am-methodtrace.html
+  to: /studio/profile/am-methodtrace.html
 - from: /r/studio-ui/am-sysinfo.html
-  to: /studio/tools/help/am-sysinfo.html
+  to: /studio/profile/am-sysinfo.html
 - from: /r/studio-ui/am-screenshot.html
-  to: /studio/tools/help/am-screenshot.html
+  to: /studio/debug/am-screenshot.html
 - from: /r/studio-ui/am-video.html
-  to: /studio/tools/help/am-video.html
+  to: /studio/debug/am-video.html
 - from: /r/studio-ui/avd-manager.html
-  to: /studio/tools/devices/managing-avds.html
+  to: /studio/run/managing-avds.html
 - from: /r/studio-ui/rundebugconfig.html
-  to: /studio/tools/devices/emulator.html
+  to: /studio/run/emulator.html
 - from: /r/studio-ui/devicechooser.html
-  to: /studio/tools/devices/emulator.html
+  to: /studio/run/emulator.html
 - from: /r/studio-ui/virtualdeviceconfig.html
-  to: /studio/tools/devices/emulator.html
+  to: /studio/run/emulator.html
 - from: /r/studio-ui/emulator.html
-  to: /studio/tools/devices/emulator.html
+  to: /studio/run/emulator.html
 - from: /r/studio-ui/instant-run.html
-  to: /studio/tools/building/building-studio.html#instant-run
+  to: /studio/run/index.html#instant-run
 - from: /reference/org/apache/http/...
   to: /about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client
 - from: /shareables/
diff --git a/docs/html/jd_collections.js b/docs/html/jd_collections.js
index f155521..7ed40c0 100644
--- a/docs/html/jd_collections.js
+++ b/docs/html/jd_collections.js
@@ -169,6 +169,22 @@
       "preview/features/tv-recording-api.html"
     ]
   },
+  "wear/preview/landing": {
+    "title": "",
+    "resources": [
+      "preview/api-overview.html",
+      "preview/download.html",
+      "preview/setup-sdk.html"
+    ]
+  },
+  "wear/preview/landing/resources": {
+    "title": "",
+    "resources": [
+      "design/wear/index.html",
+      "training/building-wearables.html",
+      "training/wearables/ui/index.html"
+    ]
+  },
   "google/landing/services": {
     "title": "",
     "resources": [
diff --git a/docs/html/jd_extras_en.js b/docs/html/jd_extras_en.js
index 18e1f99..9c75c7c 100644
--- a/docs/html/jd_extras_en.js
+++ b/docs/html/jd_extras_en.js
@@ -28,6 +28,233 @@
  /* TODO Remove standard resources from here, such as below
  */
   {
+    "title":"Meet Android Studio",
+    "summary":"The basics of working with Android Studio, from projects to build and performance.",
+    "url":"studio/intro/index.html",
+    "image":"studio/images/intro/main-window_2-1_2x.png",
+    "type":"studio",
+    "keywords": ["studio","sdk","tools","firstapp"],
+    "tags": ["studio","sdk","tools","firstapp"],
+    "lang":"en"
+  },
+  {
+    "title":"Configure Your Build",
+    "summary":"Learn about Android Studio's build configuration.",
+    "url":"studio/build/index.html",
+    "image":"images/tools/studio/build-process_2x.png",
+    "type":"studio",
+    "keywords": ["studio","configuration"],
+    "tags": ["studio","configuration"],
+    "lang":"en"
+  },
+  {
+    "title":"Android Studio Features",
+    "summary":"A quick look at key Android Studio features.",
+    "url":"studio/features.html",
+    "image":"images/cards/card-studio-modules_crop_2x.png",
+    "type":"studio",
+    "keywords": ["studio","tools","sdk"],
+    "tags": ["studio"],
+    "lang":"en"
+  },
+  {
+    "title":"Using Code Templates",
+    "summary":"Quickly create Android app projects with various UI or functional components.",
+    "url":"studio/projects/templates.html",
+    "image":"images/cards/card-using-code-templates_16x9_2x.png",
+    "type":"studio",
+    "keywords": ["studio","templates","firstapp"],
+    "tags": ["studio","templates","firstapp"],
+    "lang":"en"
+  },
+  {
+    "title":"Publishing Overview",
+    "summary":"Start here for an overview of publishing options for Android apps.",
+    "url":"studio/publish/index.html",
+    "image":"images/publishing/publishing_overview.png",
+    "type":"studio",
+    "keywords": [],
+    "tags": [],
+    "lang":"en"
+  },
+  {
+    "title":"Preparing for Release",
+    "summary":"Developer documentation on how to build the signed, release-ready APK. This process is the same for all Android apps.",
+    "url":"studio/publish/preparing.html",
+    "image":"images/publishing/publishing_overview_prep.png",
+    "type":"studio",
+    "keywords": [],
+    "tags": [],
+    "lang":"en"
+  },
+  {
+    "title":"Network Monitor",
+    "summary":"The Network Monitor makes it possible to track when your application is making network requests. Using this tool, you can monitor how and when your app transfers data, and optimize the underlying code appropriately. By monitoring the frequency of data\u2026",
+    "url":"studio/profile/am-network.html",
+    "image":"images/tools/thumbnails/am-networkmon.png",
+    "type":"studio",
+    "keywords": ["monitor"],
+    "tags": ["monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"Memory Monitor",
+    "summary":"Android Studio provides a Memory Monitor so you can more easily monitor app performance and memory usage to find deallocated objects, locate memory leaks, and track the amount of memory the connected device is using. The Memory Monitor reports how your\u2026",
+    "url":"studio/profile/am-memory.html",
+    "image":"images/tools/thumbnails/am-memorymon.png",
+    "type":"studio",
+    "keywords": ["monitor"],
+    "tags": ["monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"UI&#47;Application Exerciser Monkey",
+    "summary":"The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you\u2026",
+    "url":"studio/test/monkey.html",
+    "type":"studio",
+    "keywords": [],
+    "tags": [],
+    "lang":"en"
+  },
+  {
+    "title":"CPU Monitor",
+    "summary":"The CPU Monitor lets you easily monitor the central processing unit (CPU) usage of your app. It displays CPU usage in real time and displays the percentage of total CPU time (including all cores) used by user and kernel mode. In user mode, the code must\u2026",
+    "url":"studio/profile/am-cpu.html",
+    "image":"images/tools/thumbnails/am-cpumon.png",
+    "type":"studio",
+    "keywords": ["monitor"],
+    "tags": ["monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"Shrink Your Code and Resources",
+    "summary":"Make your APK file smaller and more secure by shrinking your code and resources.",
+    "url":"studio/build/shrink-code.html",
+    "type":"studio",
+    "keywords": [],
+    "tags": [],
+    "lang":"en"
+  },
+  {
+    "title":"logcat Monitor",
+    "summary":"The Android logging system provides a mechanism for collecting and viewing system debug output. logcat Monitor displays messages that you added to your app by using the Log class, as well as system messages, such as stack traces when the emulator throws\u2026",
+    "url":"studio/debug/am-logcat.html",
+    "image":"images/tools/thumbnails/am-logcatmon.png",
+    "type":"studio",
+    "keywords": ["monitor"],
+    "tags": ["monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"GPU Monitor",
+    "summary":"The GPU Monitor gives you a quick visual representation of how much time it takes to render the frames of a UI window. It profiles the amount of time it takes for the render thread to prepare, process, and execute the draw commands. The GPU Monitor can\u2026",
+    "url":"studio/profile/am-gpu.html",
+    "image":"images/tools/thumbnails/am-gpumon.png",
+    "type":"studio",
+    "keywords": ["monitor"],
+    "tags": ["monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"HPROF Viewer and Analyzer",
+    "summary":"Use the Memory Monitor to dump the Java heap to an HPROF file. The HPROF Viewer displays classes, instances of each class, and a reference tree to help you track memory usage and find memory leaks.",
+    "url":"studio/profile/am-hprof.html",
+    "image":"images/tools/thumbnails/am_hprofviewer.png",
+    "type":"tools",
+    "keywords": ["android","performance","profiling","tools","monitor"],
+    "tags": ["android","performance","profiling","tools","monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"Video Capture",
+    "summary":"Use the Video tool to make a video of the display on a hardware device.",
+    "url":"studio/debug/am-video.html",
+    "image":"images/tools/thumbnails/am_video.png",
+    "type":"tools",
+    "keywords": ["android","performance","profiling","tools","monitor"],
+    "tags": ["android","performance","profiling","tools","monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"Screen Capture",
+    "summary":"Use the Screen Capture tool to take a screenshot of the display on a hardware device or the emulator. Optionally display the screenshot within a graphic of a device.",
+    "url":"studio/debug/am-screenshot.html",
+    "image":"images/tools/thumbnails/am_screenshot.png",
+    "type":"tools",
+    "keywords": ["android","performance","profiling","tools","monitor"],
+    "tags": ["android","performance","profiling","tools","monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"Allocation Tracker",
+    "summary":"Use the Memory Monitor to capture allocation data about your app. The Allocation Tracker displays each method responsible for an allocation, as well as the allocation size and number of instances.",
+    "url":"studio/profile/am-allocation.html",
+    "image":"images/tools/thumbnails/am_alloctracker.png",
+    "type":"tools",
+    "keywords": ["android","performance","profiling","tools","monitor"],
+    "tags": ["android","performance","profiling","tools","monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"Method Trace",
+    "summary":"Use the CPU Monitor to perform a method trace on your app. View call stack and timing information in the method trace display.",
+    "url":"studio/profile/am-methodtrace.html",
+    "image":"images/tools/thumbnails/am_methodtrace.png",
+    "type":"tools",
+    "keywords": ["android","performance","profiling","tools","monitor"],
+    "tags": ["android","performance","profiling","tools","monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"System Information",
+    "summary":"Use the System Information tool to capture <code>dumpsys</code> information about your app. View activity manager, package, memory usage, and graphics state information.",
+    "url":"studio/profile/am-sysinfo.html",
+    "image":"images/tools/thumbnails/am_sysinfo.png",
+    "type":"tools",
+    "keywords": ["android","performance","profiling","tools","monitor"],
+    "tags": ["android","performance","profiling","tools","monitor"],
+    "lang":"en"
+  },
+  {
+    "title":"monkeyrunner",
+    "summary":"The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code. With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends \u2026",
+    "url":"studio/test/monkeyrunner/index.html",
+    "type":"studio",
+    "keywords": [],
+    "tags": [],
+    "lang":"en"
+  },
+  {
+    "title":"Testing from the Command-Line",
+    "summary":"This document describes how to create and run tests directly from the command line. This document assumes that you already know how to create a Android application in your programming environment. You can run tests from the command-line, either with Gradle\u2026",
+    "url":"studio/test/command-line.html",
+    "type":"studio",
+    "keywords": [],
+    "tags": [],
+    "lang":"en"
+  },
+  {
+    "title":"Test Your App",
+    "summary":"This document describes key concepts related to Android app testing. It assumes you have a basic knowledge of the JUnit testing framework. Android testing is based on JUnit. In general, a JUnit test is a method whose statements test a part of the application\u2026",
+    "url":"studio/test/index.html",
+    "image":"images/testing/test_framework.png",
+    "type":"studio",
+    "keywords": [],
+    "tags": [],
+    "lang":"en"
+  },
+  {
+    "title":"Android Studio 2.0",
+    "category":"",
+    "summary":"Android Studio 2.0 is the fastest way to build high quality, performant apps for the Android platform, including phones and tablets, Android Auto, Android Wear, and Android TV. As the official IDE from Google, Android Studio includes everything you…",
+    "url":"http://android-developers.blogspot.com/2016/04/android-studio-2-0.html",
+    "group":"",
+    "keywords": [],
+    "tags": ['studio'],
+    "image":"https://1.bp.blogspot.com/-vxXg6Inv_WA/VwaJ0uzSf_I/AAAAAAAACr4/xzszbcRzWRgSaHXpOpYroG7u6bgsFJjqw/s200/image03.png",
+    "type":"blog"
+  },
+  {
     "title":"Writing More Code by Writing Less Code with Android Studio Live Templates",
     "category":"",
     "summary":"Unless you’re getting paid by the keystroke, no one wants to write repetitive boilerplate code.",
@@ -3413,9 +3640,9 @@
   "develop/landing/mainlinks": {
     "title": "",
     "resources": [
-      "tools/studio/index.html",
+      "studio/index.html",
       "samples/new/index.html",
-      "tools/projects/templates.html"
+      "studio/projects/templates.html"
     ]
   },
   "develop/landing/latest": {
@@ -4368,8 +4595,8 @@
   "distribute/toolsreference/launchchecklist/understanding": {
     "title": "",
     "resources": [
-      "tools/publishing/publishing_overview.html",
-      "tools/publishing/preparing.html"
+      "studio/publish/index.html",
+      "studio/publish/preparing.html"
     ]
   },
   "distribute/toolsreference/launchchecklist/policies": {
@@ -4404,7 +4631,7 @@
     "title": "",
     "resources": [
       "google/play/expansion-files.html",
-      "tools/help/proguard.html"
+      "studio/build/shrink-code.html"
     ]
   },
   "distribute/toolsreference/launchchecklist/platform": {
@@ -4567,6 +4794,22 @@
       "training/wearables/ui/index.html"
     ]
   },
+  "wear/preview/landing": {
+    "title": "",
+    "resources": [
+      "preview/api-overview.html",
+      "preview/download.html",
+      "preview/setup-sdk.html"
+    ]
+  },
+  "wear/preview/landing/resources": {
+    "title": "",
+    "resources": [
+      "design/wear/index.html",
+      "training/building-wearables.html",
+      "training/wearables/ui/index.html"
+    ]
+  },
   "design/auto/auto_ui_guidelines": {
     "title": "",
     "resources": [
@@ -4625,17 +4868,17 @@
     "title": "",
     "resources": [
       "training/testing/start/index.html",
-      "tools/testing/testing_android.html",
+      "studio/test/index.html",
       "https://www.youtube.com/watch?v=vdasFFfXKOY"
     ]
   },
   "training/testing/tools": {
     "title": "",
     "resources": [
-      "tools/testing-support-library/index.html",
-      "tools/help/monkey.html",
-      "tools/help/monkeyrunner_concepts.html",
-      "tools/testing/testing_otheride.html",
+      "topic/libraries/testing-support-library/index.html",
+      "studio/test/monkey.html",
+      "studio/test/monkeyrunner/index.html",
+      "studio/test/command-line.html",
       "https://source.android.com/devices/tech/debug/dumpsys.html"
     ]
   },
@@ -4663,7 +4906,7 @@
       "distribute/essentials/quality/core.html",
       "distribute/essentials/quality/tablets.html",
       "distribute/tools/launch-checklist.html",
-      "tools/publishing/publishing_overview.html",
+      "studio/publish/index.html",
       "distribute/tools/localization-checklist.html"
     ]
   },
@@ -4684,7 +4927,7 @@
       "distribute/tools/promote/device-art.html",
       "distribute/tools/promote/linking.html",
       "distribute/tools/promote/brand.html",
-      "tools/help/proguard.html"
+      "studio/build/shrink-code.html"
     ]
   },
   "overview/4": {
@@ -4719,65 +4962,65 @@
 "tools/help/log": {
     "title": "",
     "resources": [
-       "tools/help/am-logcat.html"
+       "studio/debug/am-logcat.html"
     ]
   },
 "tools/help/monitor": {
     "title": "",
     "resources": [
-       "tools/help/am-memory.html",
-       "tools/help/am-cpu.html",
-       "tools/help/am-gpu.html",
-       "tools/help/am-network.html"
+       "studio/profile/am-memory.html",
+       "studio/profile/am-cpu.html",
+       "studio/profile/am-gpu.html",
+       "studio/profile/am-network.html"
     ]
   },
  "tools/help/data": {
     "title": "",
     "resources": [
-       "tools/help/am-hprof.html",
-       "tools/help/am-allocation.html",
-       "tools/help/am-methodtrace.html",
-       "tools/help/am-sysinfo.html"
+       "studio/profile/am-hprof.html",
+       "studio/profile/am-allocation.html",
+       "studio/profile/am-methodtrace.html",
+       "studio/profile/am-sysinfo.html"
     ]
   },
   "tools/help/shot": {
     "title": "",
     "resources": [
-       "tools/help/am-screenshot.html",
-       "tools/help/am-video.html"
+       "studio/debug/am-screenshot.html",
+       "studio/debug/am-video.html"
     ]
   },
   "tools/performance/rendering": {
     "title": "",
     "resources": [
-      "tools/performance/debug-gpu-overdraw/index.html",
-      "tools/performance/profile-gpu-rendering/index.html",
-      "tools/performance/hierarchy-viewer/setup.html",
-      "tools/performance/hierarchy-viewer/index.html",
-      "tools/performance/hierarchy-viewer/profiling.html"
+      "studio/profile/dev-options-overdraw.html",
+      "studio/profile/dev-options-rendering.html",
+      "studio/profile/hierarchy-viewer-setup.html",
+      "studio/profile/hierarchy-viewer-walkthru.html",
+      "studio/profile/hierarchy-viewer-results-walkthru.html"
     ]
   },
   "tools/performance/memory": {
     "title": "",
     "resources": [
-      "tools/performance/memory-monitor/index.html",
-      "tools/performance/heap-viewer/index.html",
-      "tools/performance/allocation-tracker/index.html",
-      "tools/performance/comparison.html"
+      "studio/tools/performance/memory-monitor/index.html",
+      "studio/profile/heap-viewer-walkthru.html",
+      "studio/profile/allocation-tracker-walkthru.html",
+      "studio/tools/performance/comparison.html"
     ]
   },
   "tools/performance/cpu": {
     "title": "",
     "resources": [
-      "tools/performance/traceview/index.html",
-      "tools/performance/systrace/index.html"
+      "studio/profile/traceview-walkthru.html",
+      "studio/profile/systrace-walkthru.html"
     ]
   },
   "tools/performance/battery": {
     "title": "",
     "resources": [
-      "tools/performance/batterystats-battery-historian/index.html",
-      "tools/performance/batterystats-battery-historian/charts.html"
+      "studio/profile/battery-historian.html",
+      "studio/profile/battery-historian-charts.html"
     ]
   },
   "marshmallow/landing/resources": {
@@ -4830,9 +5073,17 @@
   "tools/landing/resources": {
     "title": "",
     "resources": [
-    "tools/studio/index.html",
-    "tools/studio/studio-features.html",
-    "sdk/installing/studio-tips.html",
+    "studio/features.html",
+    "studio/intro/index.html",
+    "studio/build/index.html",
+    ]
+  },
+  "tools/landing/latest": {
+    "title": "",
+    "resources": [
+    "https://medium.com/google-developers/how-often-should-you-update-android-studio-db25785c488e#.8blbql35x",
+    "http://android-developers.blogspot.com/2016/04/android-studio-2-0.html",
+    "https://medium.com/google-developers/writing-more-code-by-writing-less-code-with-android-studio-live-templates-244f648d17c7#.hczcm02du",
     ]
   },
   "preview/landing/resources": {
diff --git a/docs/html/training/camera/photobasics.jd b/docs/html/training/camera/photobasics.jd
index efac5483..bfea0f7 100644
--- a/docs/html/training/camera/photobasics.jd
+++ b/docs/html/training/camera/photobasics.jd
@@ -175,7 +175,8 @@
 </pre>
 
 <p class="note"><strong>Note:</strong> Files you save in the directories provided by
-{@link android.content.Context#getExternalFilesDir getExternalFilesDir()} are deleted
+{@link android.content.Context#getExternalFilesDir getExternalFilesDir()} or
+{@link android.content.Context#getFilesDir getFilesDir()} are deleted
 when the user uninstalls your app.</p>
 
 <p>Once you decide the directory for the file, you need to create a
@@ -190,8 +191,7 @@
     // Create an image file name
     String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
     String imageFileName = "JPEG_" + timeStamp + "_";
-    File storageDir = Environment.getExternalStoragePublicDirectory(
-            Environment.DIRECTORY_PICTURES);
+    File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
     File image = File.createTempFile(
         imageFileName,  /* prefix */
         ".jpg",         /* suffix */
@@ -225,14 +225,66 @@
         }
         // Continue only if the File was successfully created
         if (photoFile != null) {
-            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
-                    Uri.fromFile(photoFile));
+            Uri photoURI = FileProvider.getUriForFile(this,
+                                                  "com.example.android.fileprovider",
+                                                  photoFile);
+            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
             startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
         }
     }
 }
 </pre>
 
+<p class="note"><strong>Note:</strong> We are using {@link
+android.support.v4.content.FileProvider#getUriForFile} which returns a <code>content://</code>
+URI. For more recent apps targeting Android N and higher, passing a <code>file://</code> URI
+across a package boundary causes a {@link android.os.FileUriExposedException
+FileUriExposedException}.
+Therefore, we now present a more generic way of storing images using a
+{@link android.support.v4.content.FileProvider FileProvider}.
+</p>
+
+Now, you need to configure the {@link android.support.v4.content.FileProvider
+FileProvider}. In your app's manifest, add a provider to your application:
+
+<pre>
+&lt;application&gt;
+   ...
+   &lt;provider
+        android:name="android.support.v4.content.FileProvider"
+        android:authorities="com.example.android.fileprovider"
+        android:exported="false"
+        android:grantUriPermissions="true"&gt;
+        &lt;meta-data
+            android:name="android.support.FILE_PROVIDER_PATHS"
+            android:resource="@xml/file_paths"&gt;&lt;/meta-data&gt;
+    &lt;/provider&gt;
+    ...
+&lt;/application&gt;
+</pre>
+
+Make sure that the authorities string matches the second argument to {@link
+android.support.v4.content.FileProvider#getUriForFile}.
+In the meta-data section of the provider definition, you can see that
+the provider expects eligible paths to be configured in a dedicated resource file,
+<c>res/xml/file_paths.xml</c>. Here is the content required for this particular
+example:
+
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
+    &lt;external-path name="my_images" path="Android/data/com.example.package.name/files/Pictures" /&gt;
+&lt;/paths&gt;
+</pre>
+
+The path component corresponds to the path that is returned by
+{@link android.content.Context#getExternalFilesDir getExternalFilesDir()}
+when called with {@link android.os.Environment#DIRECTORY_PICTURES
+Environment.DIRECTORY_PICTURES}. Make sure that you replace
+<code>com.example.package.name</code> with the actual package name of your
+app. Also, checkout the documentation of {@link android.support.v4.content.FileProvider} for
+an extensive description of path specifiers that you can use besides
+<code>external-path</code>.
 
 <h2 id="TaskGallery">Add the Photo to a Gallery</h2>
 
diff --git a/docs/html/wear/preview/_book.yaml b/docs/html/wear/preview/_book.yaml
new file mode 100644
index 0000000..ddcfc11
--- /dev/null
+++ b/docs/html/wear/preview/_book.yaml
@@ -0,0 +1,25 @@
+toc:
+- title: Wear Developer Preview
+  path: /wear/preview/index.html
+
+- title: Program Overview
+  path: /wear/preview/program.html
+
+- title: API Overview
+  path: /wear/preview/api-overview.html
+  section:
+  - title: Expanded Notifications
+    path: /wear/preview/features/notifications.html
+  - title: Complications
+    path: /wear/preview/features/complications.html
+  - title: Wear Navigation and Actions
+    path: /wear/preview/features/ui-nav-actions.html
+
+- title: Downloads
+  path: /wear/preview/downloads.html
+
+- title: Get Started
+  path: /wear/preview/start.html
+
+- title: License Agreement
+  path: /wear/preview/license.html
diff --git a/docs/html/wear/preview/api-overview.jd b/docs/html/wear/preview/api-overview.jd
new file mode 100644
index 0000000..bf18c16
--- /dev/null
+++ b/docs/html/wear/preview/api-overview.jd
@@ -0,0 +1,124 @@
+page.title=Preview API Overview
+meta.tags="wear", "wear-preview"
+page.tags="wear"
+page.image=images/cards/card-n-apis_2x.png
+@jd:body
+
+
+
+
+<div id="qv-wrapper">
+<div id="qv">
+  <h2>Key developer features</h2>
+  <ol>
+      <ul style="list-style-type:none;">
+        <li><a href="#stand-alone">Stand Alone Devices</a>
+          <ol>
+            <li><a href="#wear-apk">Wear-Specific APKs</a></li>
+            <li><a href="#network">Network Access</a></li>
+            <li><a href="#auth">Authentication</a></li>
+          </ol>
+        </li>
+        <li><a href="#notify">Notifications and Interactions</a>
+          <ol>
+            <li><a href="#appoid">Appoids with Chat Templates</a></li>
+            <li><a href="#smart-replies">Smart Replies</a></li>
+            <li><a href="#remote-input">Remote Input</a></li>
+            <li><a href="#imf">Input Method Framework</a></li>
+          </ol>
+        </li>
+        <li><a href="#ui">User Interface Improvements</a>
+          <ol>
+            <li><a href="#complicatiosn">Complications</a></li>
+            <li><a href="#drawers">Navigation and Action Drawers</a></li>
+            <li><a href="#button-loc">Button Locations</a></li>
+          </ol>
+        </li>
+      </ol>
+</div>
+</div>
+
+
+
+<p>
+  The Android Wear Preview API is still in active development, but you can try
+  it now as part of the Wear 2.0 Developer Preview. The sections below
+  highlight some of the new features for Wear developers.
+</p>
+
+
+<h2 id="stand-alone">Stand Alone Devices</h2>
+
+<p>Description of developer theme</p>
+
+<h3 id="wear-apk">Wear-Specific APKs</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+<h3 id="network">Network Access</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+<h3 id="auth">Authentication</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+
+
+<h2 id="notify">Notifications and Interactions</h2>
+
+<p>Description of developer theme</p>
+
+<h3 id="appoid">Appoids with Chat Templates</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+<h3 id="smart-replies">Smart Replies</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+<h3 id="remote-input">Remote Input</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+<h3 id="imf">Input Method Framework</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+
+
+<h2 id="ui">User Interface Improvements</h2>
+
+<p>Description of developer theme</p>
+
+<h3 id="complicatiosn">Complications</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+<h3 id="drawers">Navigation and Action Drawers</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
+
+<h3 id="button-loc">Button Locations</h3>
+
+<p>Description of feature</p>
+
+<p>Sample implementation of feature</p>
diff --git a/docs/html/wear/preview/downloads.jd b/docs/html/wear/preview/downloads.jd
new file mode 100644
index 0000000..10c1377
--- /dev/null
+++ b/docs/html/wear/preview/downloads.jd
@@ -0,0 +1,457 @@
+page.title=Preview Downloads
+meta.tags="wear-preview", "system image", "download"
+page.tags="wear"
+page.image=images/cards/card-n-downloads_2x.png
+
+@jd:body
+
+<div style="position:relative; min-height:600px">
+
+  <div class="wrap" id="tos" style="position:absolute;display:none;width:inherit;">
+
+    <p class="sdk-terms-intro">Before downloading and installing components of
+      the Android Wear Preview SDK, you must agree to the following terms and
+      conditions.</p>
+
+    <h2 class="norule">Terms and Conditions</h2>
+
+    <div class="sdk-terms" onfocus="this.blur()" style="width:678px">
+This is the Android Wear SDK Preview License Agreement (the “License Agreement”).
+
+1. Introduction
+
+1.1 The Android Wear SDK Preview (referred to in the License Agreement as the “Preview” and specifically including the Android system files, packaged APIs, and Preview library files, if and when they are made available) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the Preview.
+
+1.2 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL: http://source.android.com/, as updated from time to time.
+
+1.3 “Android-compatible” means any Android implemation that (i) complies with the Android Compatibility Definition document, which can be found at the Android compatibility website (http://source.android.com/compatibility) and which may be updated from time to time; and (ii) successfully passes the Android Compatibility Test Suite (CTS).
+
+1.4 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
+
+2. Accepting the License Agreement
+
+2.1 In order to use the Preview, you must first agree to the License Agreement. You may not use the Preview if you do not accept the License Agreement.
+
+2.2 By clicking to accept and/or using the Preview, you hereby agree to the terms of the License Agreement.
+
+2.3 You may not use the Preview and may not accept the License Agreement if you are a person barred from receiving the Preview under the laws of the United States or other countries including the country in which you are resident or from which you use the Preview.
+
+2.4 If you will use the Preview internally within your company or organization you agree to be bound by the License Agreement on behalf of your employer or other entity, and you represent and warrant that you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the Preview on behalf of your employer or other entity.
+
+3. Preview License from Google
+
+3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide, royalty-free, non-assignable, non-exclusive, and non-sublicensable license to use the Preview solely to develop applications for compatible implementations of Android.
+
+3.2 You may not use this Preview to develop applications for other platforms (including non-compatible implementations of Android) or to develop another SDK. You are of course free to develop applications for other platforms, including non-compatible implementations of Android, provided that this Preview is not used for that purpose.
+
+3.3 You agree that Google or third parties owns all legal right, title and interest in and to the Preview, including any Intellectual Property Rights that subsist in the Preview. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
+
+3.4 You may not use the Preview for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not: (a) copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the Preview or any part of the Preview; or (b) load any part of the Preview onto a mobile handset or any other hardware device except a personal computer, combine any part of the Preview with other software, or distribute any software or device incorporating a part of the Preview.
+
+3.5 Use, reproduction and distribution of components of the Preview licensed under an open source software license are governed solely by the terms of that open source software license and not the License Agreement. You agree to remain a licensee in good standing in regard to such open source software licenses under all the rights granted and to refrain from any actions that may terminate, suspend, or breach such rights.
+
+3.6 You agree that the form and nature of the Preview that Google provides may change without prior notice to you and that future versions of the Preview may be incompatible with applications developed on previous versions of the Preview. You agree that Google may stop (permanently or temporarily) providing the Preview (or any features within the Preview) to you or to users generally at Google's sole discretion, without prior notice to you.
+
+3.7 Nothing in the License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
+
+3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the Preview.
+
+4. Use of the Preview by You
+
+4.1 Google agrees that nothing in the License Agreement gives Google any right, title or interest from you (or your licensors) under the License Agreement in or to any software applications that you develop using the Preview, including any intellectual property rights that subsist in those applications.
+
+4.2 You agree to use the Preview and write applications only for purposes that are permitted by (a) the License Agreement, and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
+
+4.3 You agree that if you use the Preview to develop applications, you will protect the privacy and legal rights of users. If users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If users provide you with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, each user has given you permission to do so.
+
+4.4 You agree that you will not engage in any activity with the Preview, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of Google or any third party.
+
+4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Android and/or applications for Android, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.
+
+4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.
+
+4.7 The Preview is in development, and your testing and feedback are an important part of the development process. By using the Preview, you acknowledge that implementation of some features are still under development and that you should not rely on the Preview having the full functionality of a stable release. You agree not to publicly distribute or ship any application using this Preview as this Preview will no longer be supported after the official Android SDK is released.
+
+5. Your Developer Credentials
+
+5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.
+
+6. Privacy and Information
+
+6.1 In order to continually innovate and improve the Preview, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the Preview are being used and how they are being used. Before any of this information is collected, the Preview will notify you and seek your consent. If you withhold consent, the information will not be collected.
+
+6.2 The data collected is examined in the aggregate to improve the Preview and is maintained in accordance with Google's Privacy Policy located at http://www.google.com/policies/privacy/.
+
+7. Third Party Applications
+
+7.1 If you use the Preview to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.
+
+7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.
+
+7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party.
+
+8. Using Google APIs
+
+8.1 Google APIs
+
+8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.
+
+8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so.
+
+9. Terminating the License Agreement
+
+9.1 the License Agreement will continue to apply until terminated by either you or Google as set out below.
+
+9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the Preview and any relevant developer credentials.
+
+9.3 Google may at any time, terminate the License Agreement, with or without cause, upon notice to you.
+
+9.4 The License Agreement will automatically terminate without notice or other action upon the earlier of:
+(A) when Google ceases to provide the Preview or certain parts of the Preview to users in the country in which you are resident or from which you use the service; and
+(B) Google issues a final release version of the Android SDK.
+
+9.5 When the License Agreement is terminated, the license granted to you in the License Agreement will terminate, you will immediately cease all use of the Preview, and the provisions of paragraphs 10, 11, 12 and 14 shall survive indefinitely.
+
+10. DISCLAIMERS
+
+10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE PREVIEW IS AT YOUR SOLE RISK AND THAT THE PREVIEW IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
+
+10.2 YOUR USE OF THE PREVIEW AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE PREVIEW IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. WITHOUT LIMITING THE FOREGOING, YOU UNDERSTAND THAT THE PREVIEW IS NOT A STABLE RELEASE AND MAY CONTAIN ERRORS, DEFECTS AND SECURITY VULNERABILITIES THAT CAN RESULT IN SIGNIFICANT DAMAGE, INCLUDING THE COMPLETE, IRRECOVERABLE LOSS OF USE OF YOUR COMPUTER SYSTEM OR OTHER DEVICE.
+
+10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+
+11. LIMITATION OF LIABILITY
+
+11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
+
+12. Indemnification
+
+12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys’ fees) arising out of or accruing from (a) your use of the Preview, (b) any application you develop on the Preview that infringes any Intellectual Property Rights of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you of the License Agreement.
+
+13. Changes to the License Agreement
+
+13.1 Google may make changes to the License Agreement as it distributes new versions of the Preview. When these changes are made, Google will make a new version of the License Agreement available on the website where the Preview is made available.
+
+14. General Legal Terms
+
+14.1 the License Agreement constitutes the whole legal agreement between you and Google and governs your use of the Preview (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the Preview.
+
+14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.
+
+14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions of the License Agreement will continue to be valid and enforceable.
+
+14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to the License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the License Agreement.
+
+14.5 EXPORT RESTRICTIONS. THE PREVIEW IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE PREVIEW. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
+
+14.6 The License Agreement may not be assigned or transferred by you without the prior written approval of Google, and any attempted assignment without such approval will be void. You shall not delegate your responsibilities or obligations under the License Agreement without the prior written approval of Google.
+
+14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
+  </div><!-- sdk terms -->
+
+
+
+    <div id="sdk-terms-form">
+      <p>
+        <input id="agree" type="checkbox" name="agree" value="1" onclick="onAgreeChecked()" />
+        <label id="agreeLabel" for="agree">I have read and agree with the above terms and conditions</label>
+      </p>
+      <p><a href="" class="button disabled" id="downloadForRealz" onclick="return onDownloadForRealz(this);"></a></p>
+    </div>
+
+
+  </div><!-- end TOS -->
+
+
+  <div id="landing">
+
+<div id="qv-wrapper">
+  <div id="qv">
+    <h2>In this document</h2>
+      <ol>
+        <li><a href="#device-preview">Set up a hardware device</a>
+          <ol>
+            <li><a href="#flash">Flash a device</a></li>
+            <li><a href="#revertDevice">Uninstalling the Preview</a></li>
+          </ol>
+        </li>
+        <li><a href="#setupAVD">Set up an emulator</a></li>
+      </ol>
+  </div>
+</div>
+
+<p>
+  To run and test your app with the Wear Developer Preview, you need to set up
+  a runtime environment. You can do that in either of these ways:
+</p>
+
+<ul>
+  <li>Install a Wear Preview system image on a supported hardware device,</li>
+  <li>Set up an Android emulator running the Wear Developer Preview</li>
+</ul>
+
+<p>
+  If you want an environment for basic compatibility testing of your app on the
+  new platform, all you need is your current APK and a hardware device or
+  emulator. You don't necessarily need to update your full development
+  environment to do basic testing.
+</p>
+
+<p>
+  If you want to modify your app to target the Wear Preview or use the Wear
+  Preview APIs, you need to set up a development environment that's updated
+  to support the Wear Preview. For more information, see
+  <a href="{@docRoot}wear/preview/start.html">Get Started with Wear Preview</a>.
+</p>
+
+
+<h2 id="downloads">Download Files</h2>
+
+
+
+<h3 id="docs-dl">Reference documentation</h3>
+
+<p>
+  Detailed information about the Wear Preview APIs is available in the
+  reference documentation, which you can download from the following table.
+  This package contains an abridged, offline version of the Android developer
+  web site, and includes an updated API reference for the Wear Preview APIs
+  and an API difference report.
+</p>
+
+<table>
+  <tr>
+    <th scope="col">Documentation</th>
+    <th scope="col">Checksums</th>
+  </tr>
+  <tr>
+    <td style="white-space: nowrap">
+    <a href="{@docRoot}shareables/preview/n-preview-1-docs.zip"
+      >n-preview-1-docs.zip</a></td>
+    <td width="100%">
+      MD5: 4ab33ccbe698f46f125cc5b807cf9c2f<br>
+      SHA-1: 6a3880b3ccd19614daae5a4d0698ea6ae11c20a5
+    </td>
+  </tr>
+<table>
+
+<h3 id="images-dl">Device system images</h3>
+
+<p>
+  The following device system images can be used to update a compatible device
+  with the Wear Preview for testing. For information on installing these
+  images, see <a href="#device-preview">Set up a Hardware Device</a>.
+</p>
+
+<table>
+  <tr>
+    <th scope="col">Device</th>
+    <th scope="col">Download / Checksums</th>
+  </tr>
+
+  <tr id="sprat">
+    <td>Gear Live <br>"sprat"</td>
+    <td><a href="#top" onclick="onDownload(this)"
+      >sprat-XXXXX-preview-d86c7559.tgz</a><br>
+      MD5: d84b6c31a7754e505149594887b3481a<br>
+      SHA-1: d86c7559c93724cca6af91040b012c48529f2c94
+    </td>
+  </tr>
+
+</table>
+
+
+
+<h2 id="device-preview">Set up a Hardware Device</h2>
+
+<p>
+  The Wear Developer Preview offers system updates for a range of hardware devices
+  that you can use for testing your app, from phones to tablets and TV.
+</p>
+
+
+
+<h3 id="flash">Flash a device</h3>
+
+<p>
+  At any time you can download the latest Developer Preview system image and
+  manually flash it to your device. See the table below to download the system
+  image for your test device. Manually flashing a device is useful if you need
+  precise control over the test environment or need to reinstall frequently,
+  such as for automated testing.
+</p>
+
+<p>
+  Installing a system image on a device <strong>removes all data from the
+  device</strong>, so you should back up your data first.
+</p>
+
+<p>
+  After you back up your device data and download the system image below that
+  matches your device, follow the instructions at <a href=
+  "https://developers.google.com/android/nexus/images#instructions">developers.google.com/android</a>
+  to flash the image onto your device.
+</p>
+
+
+<h3 id="revertDevice">Uninstalling the Preview</h3>
+
+<p>
+  If you want to uninstall the preview from a device, you can do so in one of
+  these ways: </p>
+  <ul>
+    <li><strong>Obtain a factory spec system image</strong> and then manually
+    flash it to the device.
+      <ul>
+          <li>For <strong>Nexus devices and Pixel C devices</strong>, see
+        the <a href="http://developers.google.com/android/nexus/images">Factory Images
+        for Nexus Devices</a> page for downloads. </li>
+        <li>For <strong>other devices</strong>, please contact the device manufacturer
+        directly. Alternatively, if the device is supported
+        in the Android Beta Program, you can enroll the device in the
+        program and then un-enroll it (see below).</li>
+      </ul>
+    </li>
+    <li><strong>Un-enroll the device from Android Beta Program</strong>. If the
+    device is enrolled in the <a href="https://g.co/androidbeta">Android Beta
+    Program</a>, regardless of device, you can simply un-enroll it from the program.
+  <p>
+    The device will receive an OTA update to the most recent production version
+    of Android available for that device (for example, Android 6.0 Marshmallow).
+    The update requires a full device reset, so user data on the device will be
+    removed. Make sure to <strong>back up important data</strong> before
+    un-enrolling a device.
+  </p>
+  </li>
+</ul>
+
+<p class="note"><strong>Note:</strong>
+  Uninstalling a Developer Preview system image prior to
+  the end of the program requires a full device reset and removes all user data
+  on the device.
+</p>
+
+
+<h2 id="setupAVD">Set up an emulator</h2>
+
+<p>To use the Android Emulator to run the Wear Preview, you need to
+download the Wear Preview SDK and create a virtual device for the
+emulator.</p>
+
+<p>First, download the Wear Preview SDK as follows (if you
+already got it while <a href="{@docRoot}preview/setup-sdk.html">setting up
+to develop for Android N</a>, you can skip this part):
+
+<ol>
+  <li>In Android Studio, open the Settings dialog
+    (<strong>File &gt; Settings</strong> on Windows/Linux, or
+    <strong>Android Studio &gt; Preferences</strong> on Mac). In the left
+    panel, select <strong>Appearance &amp; Behavior &gt;
+  System Settings &gt; Android SDK</strong>.
+
+  <li>Click the <strong>SDK Platforms</strong> tab, then select the
+  <strong>Wear Preview</strong> check box.</li>
+
+  <li>Click the <strong>SDK Tools</strong> tab, then select the
+    <strong>Android SDK Build Tools</strong>, <strong>Android SDK
+    Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check
+    boxes.
+  </li>
+
+  <li>Click <strong>OK</strong> and accept the license
+    agreements for any packages to be installed.
+  </li>
+</ol>
+
+<p>You should now have <strong>Android SDK Built-Tools 24.0 0 rc1</strong>,
+<strong>Platform-Tools 24.0.0 rc1</strong>, and <strong>SDK Tools
+25.0.9</strong>. If you do not update the SDK Tools to 25.0.9, then you won't
+be able to run the x86_64 system images for Android N.</p>
+
+
+<p>Now create a virtual device with the Wear Preview system image:</p>
+
+<ol>
+  <li>Open the AVD Manager by selecting <strong>Tools > Android >
+    AVD Manager</strong>.</li>
+  <li>Click <strong>Create Virtual Device</strong>.</li>
+  <li>Select a device such as Nexus 5X, Nexus 6P, Nexus 9, or Android TV,
+    then click <strong>Next</strong>.</li>
+  <li>Select the <strong>N</strong> system image (with the
+    <strong>x86</strong> ABI), then click <strong>Next</strong>.
+    (Only x86 system images are currently supported with the Android Emulator
+for the Wear Preview.)
+  <li>Complete the rest of the AVD configuration and click
+    <strong>Finish</strong>.</li>
+</ol>
+
+<p>You can now launch the Android Emulator with the Wear Preview AVD.</p>
+
+<p>
+For the best experience in the Android Emulator, install
+Android Studio 2.2 Preview, which supports the <a
+href="http://tools.android.com/tech-docs/emulator">Android Emulator 2.0 Beta</a>
+with much faster performance compared to the Emulator in
+Android Studio 1.5.</p>
+
+<p>For more information about creating virtual devices, see <a href=
+  "{@docRoot}tools/devices/index.html">Managing Virtual Devices</a>.
+</p>
+
+
+
+  </div><!-- landing -->
+
+</div><!-- relative wrapper -->
+
+
+
+<script>
+  var urlRoot = "http://storage.googleapis.com/androiddevelopers/shareables/wear/preview/";
+  function onDownload(link) {
+
+    $("#downloadForRealz").html("Download " + $(link).text());
+    $("#downloadForRealz").attr('href', urlRoot + $(link).text());
+
+    $("#tos").fadeIn('fast');
+    $("#landing").fadeOut('fast');
+
+    return true;
+  }
+
+
+  function onAgreeChecked() {
+    /* verify that the TOS is agreed */
+    if ($("input#agree").is(":checked")) {
+      /* reveal the download button */
+      $("a#downloadForRealz").removeClass('disabled');
+    } else {
+      $("a#downloadForRealz").addClass('disabled');
+    }
+  }
+
+  function onDownloadForRealz(link) {
+    if ($("input#agree").is(':checked')) {
+    /*
+      $("#tos").fadeOut('fast');
+      $("#landing").fadeIn('fast');
+    */
+
+      ga('send', 'event', 'M Preview', 'System Image', $("#downloadForRealz").html());
+
+    /*
+      location.hash = "";
+    */
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  $(window).hashchange( function(){
+    if (location.hash == "") {
+      location.reload();
+    }
+  });
+
+</script>
diff --git a/docs/html/wear/preview/features/complications.jd b/docs/html/wear/preview/features/complications.jd
new file mode 100644
index 0000000..3d88f3a
--- /dev/null
+++ b/docs/html/wear/preview/features/complications.jd
@@ -0,0 +1,7 @@
+page.title=Watch Face Complications
+meta.tags="wear", "wear-preview", "complications"
+page.tags="wear"
+
+@jd:body
+
+<p>stub</p>
\ No newline at end of file
diff --git a/docs/html/wear/preview/features/ime.jd b/docs/html/wear/preview/features/ime.jd
new file mode 100644
index 0000000..dc4adf1
--- /dev/null
+++ b/docs/html/wear/preview/features/ime.jd
@@ -0,0 +1,7 @@
+page.title=Wear Input Method Framework
+meta.tags="wear", "wear-preview", "input-method", "ime"
+page.tags="wear"
+
+@jd:body
+
+<p>stub</p>
\ No newline at end of file
diff --git a/docs/html/wear/preview/features/notifications.jd b/docs/html/wear/preview/features/notifications.jd
new file mode 100644
index 0000000..21a77c2
--- /dev/null
+++ b/docs/html/wear/preview/features/notifications.jd
@@ -0,0 +1,7 @@
+page.title=Expanded Notifications
+meta.tags="wear", "wear-preview", "notifications"
+page.tags="wear"
+
+@jd:body
+
+<p>stub</p>
\ No newline at end of file
diff --git a/docs/html/wear/preview/features/ui-nav-actions.jd b/docs/html/wear/preview/features/ui-nav-actions.jd
new file mode 100644
index 0000000..ad61b98
--- /dev/null
+++ b/docs/html/wear/preview/features/ui-nav-actions.jd
@@ -0,0 +1,7 @@
+page.title=Wear Navigation and Actions
+meta.tags="wear", "wear-preview", "navigation", "action"
+page.tags="wear"
+
+@jd:body
+
+<p>stub</p>
\ No newline at end of file
diff --git a/docs/html/wear/preview/images/hero-1x.png b/docs/html/wear/preview/images/hero-1x.png
new file mode 100644
index 0000000..cde76c3
--- /dev/null
+++ b/docs/html/wear/preview/images/hero-1x.png
Binary files differ
diff --git a/docs/html/wear/preview/images/hero-2x.png b/docs/html/wear/preview/images/hero-2x.png
new file mode 100644
index 0000000..4d542d8
--- /dev/null
+++ b/docs/html/wear/preview/images/hero-2x.png
Binary files differ
diff --git a/docs/html/wear/preview/index.jd b/docs/html/wear/preview/index.jd
new file mode 100644
index 0000000..ff8d5bb
--- /dev/null
+++ b/docs/html/wear/preview/index.jd
@@ -0,0 +1,106 @@
+page.title=Android Wear 2.0 Developer Preview
+page.tags="wear","wear-preview"
+meta.tags="wear","preview"
+fullpage=true
+forcelocalnav=true
+header.hide=1
+footer.hide=1
+@jd:body
+
+<script>
+  $(document).ready(function() {
+    if (useUpdatedTemplates) {
+      $("#useUpdatedTemplates").css("display","block");
+    } else {
+      $("#useOldTemplates").css("display","block");
+    }
+  })
+</script>
+
+<section class="dac-expand dac-hero dac-light" style="background-color:#E1BEE7">
+  <div class="wrap" style="max-width:1100px;margin-top:0">
+    <div class="cols dac-hero-content" style="padding-bottom:1em;">
+
+      <div class="col-7of16 col-push-9of16" style="padding-left:2em">
+        <h1 class="dac-hero-title">Android Wear 2.0 Developer Preview</h1>
+        <p class="dac-hero-description">
+          Get ready for the next version of Android Wear!
+          Support stand-alone Wear devices and apps.
+          Create enhanced user interaction and glanceable experiences.
+          Test your apps on Wear devices.
+        </p>
+
+        <a class="dac-hero-cta" href="{@docRoot}wear/preview/program.html">
+          <span class="dac-sprite dac-auto-chevron"></span>
+          Learn more
+        </a>
+      </div>
+      <div class="col-9of16 col-pull-7of16 dac-hero-figure" style="margin-top:1.5em;padding-right:1.5em;">
+        <img class="dac-hero-image" src="{@docRoot}wear/preview/images/hero-1x.png"
+             srcset="{@docRoot}wear/preview/images/hero-1x.png 1x,
+             {@docRoot}wear/preview/images/hero-2x.png 2x">
+      </div>
+    </div>
+    <div class="dac-section dac-small">
+      <div class="resource-widget resource-flow-layout col-16"
+           data-query="collection:wear/preview/landing"
+           data-cardSizes="6x2"
+           data-maxResults="6"></div>
+    </div>
+  </div>
+</section>
+
+<div id="useUpdatedTemplates" style="display:none" class="dac-section dac-slim dac-gray dac-expand">
+  <div class="wrap dac-offset-parent">
+    <a class="dac-fab dac-scroll-button" data-scroll-button href="#build-apps">
+      <i class="dac-sprite dac-arrow-down-gray"></i>
+    </a>
+    <ul class="dac-actions">
+      <li class="dac-action">
+        <a class="dac-action-link" href="{@docRoot}wear/preview/bug">
+          <i class="dac-action-sprite dac-sprite dac-auto-chevron-large"></i>
+          Report an issue
+        </a>
+      </li>
+      <li class="dac-action">
+        <a class="dac-action-link" href="http://g.co/androidweardev">
+          <i class="dac-action-sprite dac-sprite dac-auto-chevron-large"></i>
+          Join developer community
+        </a>
+      </li>
+    </ul>
+  </div><!-- end .wrap -->
+</div><!-- end .dac-actions -->
+
+<div id="useOldTemplates" style="display:none;color:black" class="actions-bar dac-expand dac-invert">
+  <div class="wrap dac-offset-parent">
+
+    <div class="actions">
+      <div><a href="{@docRoot}wear/preview/bug">
+        <span class="dac-sprite dac-auto-chevron-large"></span>
+        Report an issue
+      </a></div>
+      <div><a href="http://g.co/androidweardev">
+        <span class="dac-sprite dac-auto-chevron-large"></span>
+        Join developer community
+      </a></div>
+    </div><!-- end .actions -->
+  </div><!-- end .wrap -->
+</div>
+
+<section class="dac-section dac-light"><div class="wrap">
+  <h1 class="dac-section-title">Resources</h1>
+  <div class="dac-section-subtitle">
+    Essential information to help you get your apps ready for the next version of Android Wear.
+  </div>
+
+  <div class="resource-widget resource-flow-layout col-16"
+       data-query="collection:wear/preview/landing/resources"
+       data-cardSizes="6x6"
+       data-items-per-page="6"
+       data-maxResults="15"
+       data-initial-results="6"></div>
+
+  </div>
+</section>
+
diff --git a/docs/html/wear/preview/license.jd b/docs/html/wear/preview/license.jd
new file mode 100644
index 0000000..e7a7547
--- /dev/null
+++ b/docs/html/wear/preview/license.jd
@@ -0,0 +1,145 @@
+page.title=License Agreement
+
+@jd:body
+
+<p>
+To get started with the Android Wear SDK Preview, you must agree to the following terms and conditions.
+As described below, please note that this is a preview version of the Android Wear SDK, subject to change, that you use at your own risk.  The Android Wear SDK Preview is not a stable release, and may contain errors and defects that can result in serious damage to your computer systems, devices and data.
+</p>
+
+<p>
+This is the Android Wear SDK Preview License Agreement (the “License Agreement”).
+</p>
+<div class="sdk-terms" style="height:auto;border:0;padding:0;width:700px">
+1. Introduction
+
+1.1 The Android Wear SDK Preview (referred to in the License Agreement as the “Preview” and specifically including the Android system files, packaged APIs, and Preview library files, if and when they are made available) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the Preview.
+
+1.2 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL: http://source.android.com/, as updated from time to time.
+
+1.3 “Android-compatible” means any Android implemation that (i) complies with the Android Compatibility Definition document, which can be found at the Android compatibility website (http://source.android.com/compatibility) and which may be updated from time to time; and (ii) successfully passes the Android Compatibility Test Suite (CTS).
+
+1.4 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
+
+2. Accepting the License Agreement
+
+2.1 In order to use the Preview, you must first agree to the License Agreement. You may not use the Preview if you do not accept the License Agreement.
+
+2.2 By clicking to accept and/or using the Preview, you hereby agree to the terms of the License Agreement.
+
+2.3 You may not use the Preview and may not accept the License Agreement if you are a person barred from receiving the Preview under the laws of the United States or other countries including the country in which you are resident or from which you use the Preview.
+
+2.4 If you will use the Preview internally within your company or organization you agree to be bound by the License Agreement on behalf of your employer or other entity, and you represent and warrant that you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the Preview on behalf of your employer or other entity.
+
+3. Preview License from Google
+
+3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide, royalty-free, non-assignable, non-exclusive, and non-sublicensable license to use the Preview solely to develop applications for compatible implementations of Android.
+
+3.2 You may not use this Preview to develop applications for other platforms (including non-compatible implementations of Android) or to develop another SDK. You are of course free to develop applications for other platforms, including non-compatible implementations of Android, provided that this Preview is not used for that purpose.
+
+3.3 You agree that Google or third parties owns all legal right, title and interest in and to the Preview, including any Intellectual Property Rights that subsist in the Preview. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
+
+3.4 You may not use the Preview for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not: (a) copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the Preview or any part of the Preview; or (b) load any part of the Preview onto a mobile handset or any other hardware device except a personal computer, combine any part of the Preview with other software, or distribute any software or device incorporating a part of the Preview.
+
+3.5 Use, reproduction and distribution of components of the Preview licensed under an open source software license are governed solely by the terms of that open source software license and not the License Agreement. You agree to remain a licensee in good standing in regard to such open source software licenses under all the rights granted and to refrain from any actions that may terminate, suspend, or breach such rights.
+
+3.6 You agree that the form and nature of the Preview that Google provides may change without prior notice to you and that future versions of the Preview may be incompatible with applications developed on previous versions of the Preview. You agree that Google may stop (permanently or temporarily) providing the Preview (or any features within the Preview) to you or to users generally at Google's sole discretion, without prior notice to you.
+
+3.7 Nothing in the License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
+
+3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the Preview.
+
+4. Use of the Preview by You
+
+4.1 Google agrees that nothing in the License Agreement gives Google any right, title or interest from you (or your licensors) under the License Agreement in or to any software applications that you develop using the Preview, including any intellectual property rights that subsist in those applications.
+
+4.2 You agree to use the Preview and write applications only for purposes that are permitted by (a) the License Agreement, and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
+
+4.3 You agree that if you use the Preview to develop applications, you will protect the privacy and legal rights of users. If users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If users provide you with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, each user has given you permission to do so.
+
+4.4 You agree that you will not engage in any activity with the Preview, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of Google or any third party.
+
+4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Android and/or applications for Android, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.
+
+4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.
+
+4.7 The Preview is in development, and your testing and feedback are an important part of the development process. By using the Preview, you acknowledge that implementation of some features are still under development and that you should not rely on the Preview having the full functionality of a stable release. You agree not to publicly distribute or ship any application using this Preview as this Preview will no longer be supported after the official Android SDK is released.
+
+5. Your Developer Credentials
+
+5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.
+
+6. Privacy and Information
+
+6.1 In order to continually innovate and improve the Preview, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the Preview are being used and how they are being used. Before any of this information is collected, the Preview will notify you and seek your consent. If you withhold consent, the information will not be collected.
+
+6.2 The data collected is examined in the aggregate to improve the Preview and is maintained in accordance with Google's Privacy Policy located at http://www.google.com/policies/privacy/.
+
+7. Third Party Applications
+
+7.1 If you use the Preview to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.
+
+7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.
+
+7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party.
+
+8. Using Google APIs
+
+8.1 Google APIs
+
+8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.
+
+8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so.
+
+9. Terminating the License Agreement
+
+9.1 the License Agreement will continue to apply until terminated by either you or Google as set out below.
+
+9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the Preview and any relevant developer credentials.
+
+9.3 Google may at any time, terminate the License Agreement, with or without cause, upon notice to you.
+
+9.4 The License Agreement will automatically terminate without notice or other action upon the earlier of:
+(A) when Google ceases to provide the Preview or certain parts of the Preview to users in the country in which you are resident or from which you use the service; and
+(B) Google issues a final release version of the Android SDK.
+
+9.5 When the License Agreement is terminated, the license granted to you in the License Agreement will terminate, you will immediately cease all use of the Preview, and the provisions of paragraphs 10, 11, 12 and 14 shall survive indefinitely.
+
+10. DISCLAIMERS
+
+10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE PREVIEW IS AT YOUR SOLE RISK AND THAT THE PREVIEW IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
+
+10.2 YOUR USE OF THE PREVIEW AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE PREVIEW IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. WITHOUT LIMITING THE FOREGOING, YOU UNDERSTAND THAT THE PREVIEW IS NOT A STABLE RELEASE AND MAY CONTAIN ERRORS, DEFECTS AND SECURITY VULNERABILITIES THAT CAN RESULT IN SIGNIFICANT DAMAGE, INCLUDING THE COMPLETE, IRRECOVERABLE LOSS OF USE OF YOUR COMPUTER SYSTEM OR OTHER DEVICE.
+
+10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+
+11. LIMITATION OF LIABILITY
+
+11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
+
+12. Indemnification
+
+12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys’ fees) arising out of or accruing from (a) your use of the Preview, (b) any application you develop on the Preview that infringes any Intellectual Property Rights of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you of the License Agreement.
+
+13. Changes to the License Agreement
+
+13.1 Google may make changes to the License Agreement as it distributes new versions of the Preview. When these changes are made, Google will make a new version of the License Agreement available on the website where the Preview is made available.
+
+14. General Legal Terms
+
+14.1 the License Agreement constitutes the whole legal agreement between you and Google and governs your use of the Preview (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the Preview.
+
+14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.
+
+14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions of the License Agreement will continue to be valid and enforceable.
+
+14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to the License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the License Agreement.
+
+14.5 EXPORT RESTRICTIONS. THE PREVIEW IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE PREVIEW. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
+
+14.6 The License Agreement may not be assigned or transferred by you without the prior written approval of Google, and any attempted assignment without such approval will be void. You shall not delegate your responsibilities or obligations under the License Agreement without the prior written approval of Google.
+
+14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
+
+
+</div>
\ No newline at end of file
diff --git a/docs/html/wear/preview/preview_toc.cs b/docs/html/wear/preview/preview_toc.cs
new file mode 100644
index 0000000..f96bf1f
--- /dev/null
+++ b/docs/html/wear/preview/preview_toc.cs
@@ -0,0 +1,132 @@
+<ul id="nav">
+
+  <li class="nav-section">
+    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>preview/overview.html"
+   es-lang="Información general del programa"
+   ja-lang="プログラム概要"
+   ko-lang="프로그램 개요"
+   pt-br-lang="Visão geral do programa"
+   ru-lang="Обзор программы"
+   zh-cn-lang="计划概览"
+   zh-tw-lang="程式總覽">
+   Program Overview</a></div>
+  </li>
+
+
+  <li class="nav-section">
+    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>preview/support.html">
+      Support and Release Notes</a></div>
+  </li>
+  
+  <li class="nav-section">
+    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>preview/setup-sdk.html"
+      es-lang="Configurar el SDK de la versión preliminar"
+      ja-lang="Preview SDK のセットアップ"
+      ko-lang="미리 보기 SDK 설정하기"
+      pt-br-lang="Configuração do Preview SDK"
+      ru-lang="Настройка пакета SDK Preview"
+      zh-cn-lang="设置预览版 SDK"
+      zh-tw-lang="設定預覽版 SDK">
+      Set Up to Develop</a></div>
+  </li>
+  <li class="nav-section">
+    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>preview/download.html">
+      Test on a Device</a></div>
+  </li>
+
+
+  <li class="nav-section">
+    <div class="nav-section-header"><a href="<?cs var:toroot ?>preview/behavior-changes.html"
+      es-lang="Cambios en los comportamientos"
+      ja-lang="動作の変更点"
+      ko-lang="동작 변경"
+      pt-br-lang="Mudanças de comportamento"
+      ru-lang="Изменения в работе"
+      zh-cn-lang="行为变更"
+      zh-tw-lang="行為變更">Behavior Changes
+       </a></div>
+      <ul>
+        <li><a href="<?cs var:toroot ?>preview/features/background-optimization.html"
+        >Background Optimizations</a></li>
+        <li><a href="<?cs var:toroot ?>preview/features/multilingual-support.html"
+        >Language and Locale</a></li>
+      </ul>
+  </li>
+
+  <li class="nav-section">
+    <div class="nav-section-header"><a href="<?cs var:toroot ?>preview/api-overview.html"
+      es-lang="Información general de la API"
+      ja-lang="API の概要"
+      ko-lang="API 개요"
+      pt-br-lang="Visão geral da API"
+      ru-lang="Обзор API-интерфейсов"
+      zh-cn-lang="API 概览"
+      zh-tw-lang="API 總覽">Android N for Developers
+      </a></div>
+      <ul>
+
+        <li><a href="<?cs var:toroot ?>preview/features/multi-window.html"
+        >Multi-Window Support</a></li>
+
+        <li><a href="<?cs var:toroot ?>preview/features/notification-updates.html"
+        >Notifications</a></li>
+
+        <li><a href="<?cs var:toroot ?>preview/features/data-saver.html"
+        >Data Saver</a></li>
+
+        <li><a href="<?cs var:toroot ?>preview/features/tv-recording-api.html"
+        >TV Recording</a></li>
+
+        <li><a href="<?cs var:toroot ?>preview/features/security-config.html"
+        >Network Security Configuration</a></li>
+
+        <li><a href="<?cs var:toroot ?>preview/features/icu4j-framework.html"
+        >ICU4J Support</a></li>
+        
+        <li><a href="<?cs var:toroot ?>preview/j8-jack.html"
+        >Java 8 Language Features</a></li>
+
+        <li><a href="<?cs var:toroot ?>preview/features/afw.html"
+        >Android for Work Updates</a></li>
+      </ul>
+  </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  <li class="nav-section">
+    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>preview/samples.html"
+      es-lang="Ejemplos"
+      ja-lang="サンプル"
+      ko-lang="샘플"
+      pt-br-lang="Exemplos"
+      ru-lang="Примеры"
+      zh-cn-lang="示例"
+      zh-tw-lang="範例">
+      Samples</a></div>
+  </li>
+
+  <li class="nav-section">
+    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>preview/license.html"
+      es-lang="Contrato de licencia"
+      ja-lang="使用許諾契約"
+      ko-lang="라이선스 계약"
+      pt-br-lang="Contrato de licença"
+      ru-lang="Лицензионное соглашение"
+      zh-cn-lang="许可协议"
+      zh-tw-lang="授權協議">
+      License Agreement</a></div>
+  </li>
+
+</ul>
diff --git a/docs/html/wear/preview/program.jd b/docs/html/wear/preview/program.jd
new file mode 100644
index 0000000..17df757
--- /dev/null
+++ b/docs/html/wear/preview/program.jd
@@ -0,0 +1,62 @@
+page.title=Preview Program Overview
+page.metaDescription=Get your apps ready for the next version of Android.
+page.image=images/cards/card-n-overview_2x.png
+meta.tags="wear", "wear-preview"
+page.tags="wear"
+
+@jd:body
+
+
+<p>
+  Welcome to the <strong>Wear Developer Preview</strong>, a program that
+  gives you everything you need to test and optimize your apps for the next
+  version of Android Wear. It's free, and you can get started right away just by
+  downloading the Wear Developer Preview tools.
+</p>
+
+
+
+<h2 id="timeline">Timeline and updates</h2>
+
+<p>
+  Lorem ipsum dolor sit amet, consul graecis gloriatur in cum. Porro noster ea
+  nam, omnes tollit facete ut vix. Ut nibh ancillae mei, unum mollis aliquid an
+  pri. No melius dignissim mel. An eum erant dicit volumus, ut eum animal
+  convenire.
+</p>
+
+
+<h2 id="preview_tools">What's in the Wear Developer Preview?</h2>
+
+<p>
+  Lorem ipsum dolor sit amet, consul graecis gloriatur in cum. Porro noster ea
+  nam, omnes tollit facete ut vix. Ut nibh ancillae mei, unum mollis aliquid an
+  pri. No melius dignissim mel. An eum erant dicit volumus, ut eum animal
+  convenire.
+</p>
+
+
+<h2 id="how_to_get_started">How to get started</h2>
+
+<p>
+  To get started testing your app with the Wear Developer Preview:
+</p>
+
+<ol>
+  <li> Review the <a href="{@docRoot}wear/preview/api-overview.html">API
+  Overview</a> to
+  get an idea of what's new and how it affects your apps.</li>
+  <li>Download the preview API documentation and system images from the
+    <a href="{@docRoot}wear/preview/downloads.html">Preview Downloads</a>
+  </li>
+  <li> Set up your environment by following the instructions for <a
+  href="{@docRoot}wear/preview/start.html">Get Started with Wear Preview</a>
+  and configuring test devices.</li>
+  <li> Join the <a href="http://g.co/androidweardev">Android Wear
+  Developer Community</a> to get the latest news and connect with other
+  developers working with the new platform.</li>
+</ol>
+
+<p>
+  Thank you for participating in the Android Wear Developer Preview program!
+</p>
diff --git a/docs/html/wear/preview/start.jd b/docs/html/wear/preview/start.jd
new file mode 100644
index 0000000..ff11700
--- /dev/null
+++ b/docs/html/wear/preview/start.jd
@@ -0,0 +1,139 @@
+page.title=Get Started with Wear Preview
+meta.keywords="wear-preview"
+page.tags="wear-preview"
+page.image=images/cards/card-n-sdk_2x.png
+
+@jd:body
+
+
+<div id="qv-wrapper">
+  <div id="qv">
+<ol>
+  <li><a href="#get-as22">Get Android Studio 2.2</a></li>
+  <li><a href="#get-sdk">Get the Wear Preview SDK</a></li>
+  <li><a href="#create-update">Update or Create a Project</a></li>
+</ol>
+  </div>
+</div>
+
+<p>
+  To develop apps for the Wear Developer Preview, you need to make some updates
+  to your developer environment. This page describes how to setup for testing
+  the Wear Preview APIs with your app.
+</p>
+
+
+<h2 id="get-as22">Get Android Studio 2.2 (preview)</h2>
+
+<p>
+  Android Studio 2.2 is currently available as a preview in the canary release
+  channel. If you already have Android Studio and don't want to update to the
+  canary channel, you can download Android Studio 2.2 as a separate
+  installation and use it for development with the Wear Developer Preview,
+  leaving your primary Android Studio environment unaffected.
+</p>
+
+<p>
+  To download Android Studio 2.2 as a separate installation, follow these steps
+  (or if you want to receive Android Studio 2.1 as an update to your existing
+  installation, skip to step 4):
+</p>
+
+<ol>
+  <li>Edit the name of your
+  existing Android Studio installation and append the version number. This way,
+  when you install the new version, it will not override the existing one.</li>
+  <li>Download the appropriate ZIP file for your operating system from the
+    <a href="http://tools.android.com/download/studio/canary/latest"
+    >canary channel download page</a>.
+  </li>
+  <li>Unzip the package and move the Android Studio 2.1 contents to the
+    appropriate location for applications on your system, then launch it.</li>
+  <li>Open the Settings dialog
+    (<strong>File &gt; Settings</strong> on Windows/Linux, or
+    <strong>Android Studio &gt; Preferences</strong> on Mac). In the left
+    panel, select <strong>Appearance &amp; Behavior &gt; System Settings &gt;
+    Updates</strong>.
+  </li>
+  <li>On the Updates panel, select the <strong>Automatically
+    check updates for</strong> check box and select
+    <strong>Canary Channel</strong> from the drop-down list.
+  </li>
+</ol>
+
+<p>Keep this settings window open for the next step.</p>
+
+
+<h2 id="get-sdk">Get the Wear Preview SDK</h2>
+
+<p>To start developing with Wear Preview APIs, you need to install the
+Wear Preview SDK in Android Studio as follows:</p>
+
+<ol>
+  <li>While still viewing the Updates panel (step 4 from above),
+  select the <strong>Automatically
+    check updates for Android SDK</strong> check box and select
+    <strong>Preview Channel</strong> from the drop-down list.
+  </li>
+  <li>Click <strong>Check Now</strong>.</li>
+
+  <li>In the left panel, select <strong>Appearance &amp; Behavior &gt;
+  System Settings &gt; Android SDK</strong>.
+
+  <li>Click the <strong>SDK Platforms</strong> tab, then select the
+  <strong>Wear Preview</strong> check box.</li>
+
+  <li>Click the <strong>SDK Tools</strong> tab, then select the
+    <strong>Android SDK Build Tools</strong>, <strong>Android SDK
+    Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check
+    boxes.
+  </li>
+
+  <li>Click <strong>OK</strong>, then accept the licensing
+    agreements for any packages that need to be installed.
+  </li>
+</ol>
+
+
+<h2 id="create-update">Update or Create a Project</h2>
+
+<p>
+  To use the Wear Preview APIs, your project must be configured appropriately.
+</p>
+
+
+<h3 id="update">Update an existing project</h3>
+
+<p>Open the
+  <code>build.gradle</code> file for your module and update the values as
+  follows:
+</p>
+
+<pre>
+android {
+  compileSdkVersion <strong>'23'</strong>
+  buildToolsVersion <strong>'24.0.1-rc1'</strong>
+  ...
+
+  defaultConfig {
+     minSdkVersion <strong>'23'</strong>
+     targetSdkVersion <strong>'23'</strong>
+     ...
+  }
+  ...
+}</pre>
+
+
+<h3 id="create">Create a new project</h3>
+
+<p>To create a new project for development with the Wear Preview SDK:</p>
+
+<ol>
+  <li>Click <strong>File > New Project</strong>. and follow the steps until
+  you reach the Target Android Devices page.
+  </li>
+  <li>On this page, select <strong>Wear</strong> option.</li>
+  <li>Under <strong>Wear</strong> option, in the <strong>Minimum
+    SDK</strong> option list, select
+    <strong>API 23: Android API 6.0 (Wear Preview)</strong>.</li>
+</ol>
diff --git a/docs/html/wear/wear_toc.cs b/docs/html/wear/wear_toc.cs
index 65ac2e9..93f554f 100644
--- a/docs/html/wear/wear_toc.cs
+++ b/docs/html/wear/wear_toc.cs
@@ -1,74 +1,53 @@
 <ul id="nav">
 
   <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/preview/start.html">Get Started
-      </a></div>
+    <div class="nav-section-header empty">
+      <a href="<?cs var:toroot ?>wear/preview/index.html">
+        Wear Developer Preview
+        </a></div>
   </li>
 
   <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/design/user-interface.html">UI Overview
-      </a></div>
+    <div class="nav-section-header empty">
+      <a href="<?cs var:toroot ?>wear/preview/program.html">
+        Program Overview
+        </a></div>
   </li>
 
   <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/design/index.html">Design Principles
-      </a></div>
+    <div class="nav-section-header">
+      <a href="<?cs var:toroot ?>wear/preview/api-overview.html">
+        API Overview
+        </a></div>
+
+      <ul>
+        <li><a href="<?cs var:toroot ?>wear/preview/features/wear-apk.html">
+          Wear APKs</a></li>
+        <li><a href="<?cs var:toroot ?>wear/preview/features/complications.html">
+          Complications</a></li>
+       </ul>
+
   </li>
 
   <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/notifications/creating.html">Creating Notifications for Android Wear
-      </a></div>
+    <div class="nav-section-header empty">
+      <a href="<?cs var:toroot ?>wear/preview/downloads.html">
+        Downloads
+        </a></div>
   </li>
 
   <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/notifications/remote-input.html">Receiving Voice Input from a Notification
-      </a></div>
+    <div class="nav-section-header empty">
+      <a href="<?cs var:toroot ?>wear/preview/start.html">
+        Get Started
+        </a></div>
   </li>
 
   <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/notifications/pages.html">Adding Pages to a Notification
-      </a></div>
+    <div class="nav-section-header empty">
+      <a href="<?cs var:toroot ?>wear/preview/license.html">
+        License Agreement
+        </a></div>
   </li>
 
-  <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/notifications/stacks.html">Stacking Notifications
-      </a></div>
-  </li>
-
-  <li class="nav-section">
-    <div class="nav-section-header"><a href="<?cs var:toroot ?>reference/android/preview/support/package-summary.html">Notification Reference</a></div>
-    <ul class="tree-list-children">
-<li class="nav-section">
-<div class="nav-section-header-ref"><span class="tree-list-subtitle package" title="android.preview.support.v4.app">android.preview.support.v4.app</span></div>
-  <ul>
-<li><a href="<?cs var:toroot ?>reference/android/preview/support/v4/app/NotificationManagerCompat.html">NotificationManagerCompat</a></li>
-  </ul>
-</li>
-
-<li class="nav-section">
-<div class="nav-section-header-ref"><span class="tree-list-subtitle package" title="android.preview.support.wearable.notifications">android.preview.support.wearable.notifications</span></div>
-<ul>
-
-<li><a href="<?cs var:toroot ?>reference/android/preview/support/wearable/notifications/RemoteInput.html">RemoteInput</a></li>
-<li><a href="<?cs var:toroot ?>reference/android/preview/support/wearable/notifications/RemoteInput.Builder.html" >RemoteInput.Builder</a></li>
-
-<li><a href="<?cs var:toroot ?>reference/android/preview/support/wearable/notifications/WearableNotifications.html">WearableNotifications</a></li>
-
-<li><a href="<?cs var:toroot ?>reference/android/preview/support/wearable/notifications/WearableNotifications.Action.html">WearableNotifications.Action</a></li>
-
-<li><a href="<?cs var:toroot ?>reference/android/preview/support/wearable/notifications/WearableNotifications.Action.Builder.html">WearableNotifications.Action.Builder</a></li>
-
-<li><a href="<?cs var:toroot ?>reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html">WearableNotifications.Builder</a></li>
-	</ul>
-  </li>
-</ul>
-</li>
-
-
-
-  <li class="nav-section">
-    <div class="nav-section-header empty"><a href="<?cs var:toroot ?>wear/license.html">License Agreement</a></div>
-  </li>
-
-
 </ul>
diff --git a/media/java/android/media/browse/MediaBrowser.java b/media/java/android/media/browse/MediaBrowser.java
index baa6b0f..79b415f 100644
--- a/media/java/android/media/browse/MediaBrowser.java
+++ b/media/java/android/media/browse/MediaBrowser.java
@@ -476,6 +476,9 @@
         // the service will be told when we connect.
         if (mState == CONNECT_STATE_CONNECTED) {
             try {
+                if (options == null) {
+                    mServiceBinder.addSubscriptionDeprecated(parentId, mServiceCallbacks);
+                }
                 mServiceBinder.addSubscription(parentId, callback.mToken, options,
                         mServiceCallbacks);
             } catch (RemoteException ex) {
@@ -500,6 +503,7 @@
         try {
             if (callback == null) {
                 if (mState == CONNECT_STATE_CONNECTED) {
+                    mServiceBinder.removeSubscriptionDeprecated(parentId, mServiceCallbacks);
                     mServiceBinder.removeSubscription(parentId, null, mServiceCallbacks);
                 }
             } else {
@@ -1070,7 +1074,12 @@
         }
 
         @Override
-        public void onLoadChildren(String parentId, ParceledListSlice list,
+        public void onLoadChildren(String parentId, ParceledListSlice list) {
+            onLoadChildrenWithOptions(parentId, list, null);
+        }
+
+        @Override
+        public void onLoadChildrenWithOptions(String parentId, ParceledListSlice list,
                 final Bundle options) {
             MediaBrowser mediaBrowser = mMediaBrowser.get();
             if (mediaBrowser != null) {
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index 168fcdc..210e62b 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -78,6 +78,8 @@
     private static final boolean DEBUG = false;
     private static final String TAG = "TvInputService";
 
+    private static final int DETACH_OVERLAY_VIEW_TIMEOUT_MS = 5000;
+
     /**
      * This is the interface name that a service implementing a TV input should say that it support
      * -- that is, this is the action it uses for its intent filter. To be supported, the service
@@ -268,7 +270,6 @@
      * Base class for derived classes to implement to provide a TV input session.
      */
     public abstract static class Session implements KeyEvent.Callback {
-        private static final int DETACH_OVERLAY_VIEW_TIMEOUT_MS = 5000;
         private static final int POSITION_UPDATE_INTERVAL_MS = 1000;
 
         private final KeyEvent.DispatcherState mDispatcherState = new KeyEvent.DispatcherState();
@@ -1256,7 +1257,7 @@
             // Creates a container view to check hanging on the overlay view detaching.
             // Adding/removing the overlay view to/from the container make the view attach/detach
             // logic run on the main thread.
-            mOverlayViewContainer = new FrameLayout(mContext);
+            mOverlayViewContainer = new FrameLayout(mContext.getApplicationContext());
             mOverlayViewContainer.addView(mOverlayView);
             // TvView's window type is TYPE_APPLICATION_MEDIA and we want to create
             // an overlay window above the media window but below the application window.
@@ -1496,26 +1497,26 @@
                         POSITION_UPDATE_INTERVAL_MS);
             }
         }
+    }
 
-        private final class OverlayViewCleanUpTask extends AsyncTask<View, Void, Void> {
-            @Override
-            protected Void doInBackground(View... views) {
-                View overlayViewParent = views[0];
-                try {
-                    Thread.sleep(DETACH_OVERLAY_VIEW_TIMEOUT_MS);
-                } catch (InterruptedException e) {
-                    return null;
-                }
-                if (isCancelled()) {
-                    return null;
-                }
-                if (overlayViewParent.isAttachedToWindow()) {
-                    Log.e(TAG, "Time out on releasing overlay view. Killing "
-                            + overlayViewParent.getContext().getPackageName());
-                    Process.killProcess(Process.myPid());
-                }
+    private static final class OverlayViewCleanUpTask extends AsyncTask<View, Void, Void> {
+        @Override
+        protected Void doInBackground(View... views) {
+            View overlayViewParent = views[0];
+            try {
+                Thread.sleep(DETACH_OVERLAY_VIEW_TIMEOUT_MS);
+            } catch (InterruptedException e) {
                 return null;
             }
+            if (isCancelled()) {
+                return null;
+            }
+            if (overlayViewParent.isAttachedToWindow()) {
+                Log.e(TAG, "Time out on releasing overlay view. Killing "
+                        + overlayViewParent.getContext().getPackageName());
+                Process.killProcess(Process.myPid());
+            }
+            return null;
         }
     }
 
diff --git a/media/java/android/service/media/IMediaBrowserService.aidl b/media/java/android/service/media/IMediaBrowserService.aidl
index 6b6a561..84f41f6 100644
--- a/media/java/android/service/media/IMediaBrowserService.aidl
+++ b/media/java/android/service/media/IMediaBrowserService.aidl
@@ -17,8 +17,11 @@
     void connect(String pkg, in Bundle rootHints, IMediaBrowserServiceCallbacks callbacks);
     void disconnect(IMediaBrowserServiceCallbacks callbacks);
 
+    void addSubscriptionDeprecated(String uri, IMediaBrowserServiceCallbacks callbacks);
+    void removeSubscriptionDeprecated(String uri, IMediaBrowserServiceCallbacks callbacks);
+
+    void getMediaItem(String uri, in ResultReceiver cb, IMediaBrowserServiceCallbacks callbacks);
     void addSubscription(String uri, in IBinder token, in Bundle options,
             IMediaBrowserServiceCallbacks callbacks);
     void removeSubscription(String uri, in IBinder token, IMediaBrowserServiceCallbacks callbacks);
-    void getMediaItem(String uri, in ResultReceiver cb, IMediaBrowserServiceCallbacks callbacks);
 }
diff --git a/media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl b/media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl
index dadb025..deeab1a 100644
--- a/media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl
+++ b/media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl
@@ -22,5 +22,6 @@
      */
     void onConnect(String root, in MediaSession.Token session, in Bundle extras);
     void onConnectFailed();
-    void onLoadChildren(String mediaId, in ParceledListSlice list, in Bundle options);
+    void onLoadChildren(String mediaId, in ParceledListSlice list);
+    void onLoadChildrenWithOptions(String mediaId, in ParceledListSlice list, in Bundle options);
 }
diff --git a/media/java/android/service/media/MediaBrowserService.java b/media/java/android/service/media/MediaBrowserService.java
index 4b88926..7eb9188 100644
--- a/media/java/android/service/media/MediaBrowserService.java
+++ b/media/java/android/service/media/MediaBrowserService.java
@@ -249,6 +249,11 @@
         }
 
         @Override
+        public void addSubscriptionDeprecated(String id, IMediaBrowserServiceCallbacks callbacks) {
+            // do-nothing
+        }
+
+        @Override
         public void addSubscription(final String id, final IBinder token, final Bundle options,
                 final IMediaBrowserServiceCallbacks callbacks) {
             mHandler.post(new Runnable() {
@@ -270,6 +275,11 @@
         }
 
         @Override
+        public void removeSubscriptionDeprecated(String id, IMediaBrowserServiceCallbacks callbacks) {
+            // do-nothing
+        }
+
+        @Override
         public void removeSubscription(final String id, final IBinder token,
                 final IMediaBrowserServiceCallbacks callbacks) {
             mHandler.post(new Runnable() {
@@ -632,7 +642,7 @@
                 final ParceledListSlice<MediaBrowser.MediaItem> pls =
                         filteredList == null ? null : new ParceledListSlice<>(filteredList);
                 try {
-                    connection.callbacks.onLoadChildren(parentId, pls, options);
+                    connection.callbacks.onLoadChildrenWithOptions(parentId, pls, options);
                 } catch (RemoteException ex) {
                     // The other side is in the process of crashing.
                     Log.w(TAG, "Calling onLoadChildren() failed for id=" + parentId
diff --git a/packages/DocumentsUI/Android.mk b/packages/DocumentsUI/Android.mk
index 568e200..9d44a6d 100644
--- a/packages/DocumentsUI/Android.mk
+++ b/packages/DocumentsUI/Android.mk
@@ -36,7 +36,7 @@
 
 # Only enable asserts on userdebug/eng builds
 ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
-LOCAL_JACK_FLAGS += -D jack.assert.policy=enable
+LOCAL_JACK_FLAGS += -D jack.assert.policy=always
 endif
 
 LOCAL_PACKAGE_NAME := DocumentsUI
diff --git a/packages/ExtServices/src/android/ext/services/notification/Ranker.java b/packages/ExtServices/src/android/ext/services/notification/Ranker.java
index f3ce355..d43f076 100644
--- a/packages/ExtServices/src/android/ext/services/notification/Ranker.java
+++ b/packages/ExtServices/src/android/ext/services/notification/Ranker.java
@@ -73,13 +73,8 @@
                     mUnbundledNotifications.put(sbn.getPackageName(), notificationsForPackage);
 
                     if (notificationsForPackage.size() >= AUTOBUNDLE_AT_COUNT) {
-                        // Autobundle all but the most recently posted (not updated) notification.
-                        int count = 0;
                         for (String key : notificationsForPackage) {
-                            if (count < notificationsForPackage.size() - 1) {
-                                notificationsToBundle.add(key);
-                            }
-                            count++;
+                            notificationsToBundle.add(key);
                         }
                     }
                 }
diff --git a/packages/MtpDocumentsProvider/Android.mk b/packages/MtpDocumentsProvider/Android.mk
index 0f945ee..c9e7195 100644
--- a/packages/MtpDocumentsProvider/Android.mk
+++ b/packages/MtpDocumentsProvider/Android.mk
@@ -11,7 +11,7 @@
 
 # Only enable asserts on userdebug/eng builds
 ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
-LOCAL_JACK_FLAGS += -D jack.assert.policy=enable
+LOCAL_JACK_FLAGS += -D jack.assert.policy=always
 endif
 
 include $(BUILD_PACKAGE)
diff --git a/packages/SettingsLib/res/values-gl-rES/strings.xml b/packages/SettingsLib/res/values-gl-rES/strings.xml
index 410c7a4..13edd04 100644
--- a/packages/SettingsLib/res/values-gl-rES/strings.xml
+++ b/packages/SettingsLib/res/values-gl-rES/strings.xml
@@ -219,7 +219,7 @@
     <string name="show_hw_screen_updates_summary" msgid="1115593565980196197">"Iluminar vistas das ventás creadas con GPU"</string>
     <string name="show_hw_layers_updates" msgid="5645728765605699821">"Ver actualizacións capas"</string>
     <string name="show_hw_layers_updates_summary" msgid="5296917233236661465">"Iluminar capas hardware en verde ao actualizarse"</string>
-    <string name="debug_hw_overdraw" msgid="2968692419951565417">"Depurar sobredebuxo GPU"</string>
+    <string name="debug_hw_overdraw" msgid="2968692419951565417">"Depurar superposición GPU"</string>
     <string name="disable_overlays" msgid="2074488440505934665">"Desact. superposicións HW"</string>
     <string name="disable_overlays_summary" msgid="3578941133710758592">"Utilizar sempre GPU para a composición da pantalla"</string>
     <string name="simulate_color_space" msgid="6745847141353345872">"Simular o espazo da cor"</string>
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 31058a9..25dc357 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -295,6 +295,7 @@
             android:theme="@style/ForcedResizableTheme"
             android:excludeFromRecents="true"
             android:stateNotNeeded="true"
+            android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
             android:exported="false">
         </activity>
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java
index 160835f..45c1537 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java
@@ -52,7 +52,9 @@
 
         mFocusLoseAnimatorSet = new AnimatorSet();
         mFocusLoseAnimatorSet.playTogether(
-                ObjectAnimator.ofFloat(mView, "alpha", dimAlpha),
+                // Animation doesn't start from the current value (1f) sometimes,
+                // so specify the desired initial value here.
+                ObjectAnimator.ofFloat(mView, "alpha", 1f, dimAlpha),
                 ObjectAnimator.ofFloat(mTitleView, "alpha", 0f));
         mFocusLoseAnimatorSet.setDuration(duration);
         mFocusLoseAnimatorSet.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index eec2070..527d577 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -2184,9 +2184,8 @@
                     == View.VISIBLE;
             boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
             if (suppressedSummary || (isLockscreenPublicMode() && !mShowLockscreenNotifications) ||
-                    (onKeyguard && (visibleNotifications >= maxNotifications
-                            && !childWithVisibleSummary
-                            || !showOnKeyguard))) {
+                    (onKeyguard && !childWithVisibleSummary
+                            && (visibleNotifications >= maxNotifications || !showOnKeyguard))) {
                 entry.row.setVisibility(View.GONE);
                 if (onKeyguard && showOnKeyguard && !childNotification && !suppressedSummary) {
                     mKeyguardIconOverflowContainer.getIconsView().addNotification(entry);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
index ee4a102..4ec36f6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
@@ -67,6 +67,9 @@
     private SparseArray<ButtonDispatcher> mButtonDispatchers;
     private String mCurrentLayout;
 
+    private View mLastRot0;
+    private View mLastRot90;
+
     public NavigationBarInflaterView(Context context, AttributeSet attrs) {
         super(context, attrs);
         mDensity = context.getResources().getConfiguration().densityDpi;
@@ -163,6 +166,7 @@
         String[] start = sets[0].split(BUTTON_SEPARATOR);
         String[] center = sets[1].split(BUTTON_SEPARATOR);
         String[] end = sets[2].split(BUTTON_SEPARATOR);
+        // Inflate these in start to end order or accessibility traversal will be messed up.
         inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group), false);
         inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group), true);
 
@@ -240,6 +244,15 @@
         }
         parent.addView(v);
         addToDispatchers(v);
+        View lastView = landscape ? mLastRot90 : mLastRot0;
+        if (lastView != null) {
+            v.setAccessibilityTraversalAfter(lastView.getId());
+        }
+        if (landscape) {
+            mLastRot90 = v;
+        } else {
+            mLastRot0 = v;
+        }
         return v;
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index a51ee4d..d2326d2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -24,9 +24,13 @@
 import com.android.systemui.statusbar.StatusBarState;
 import com.android.systemui.statusbar.policy.HeadsUpManager;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -69,6 +73,7 @@
 
     public void onEntryRemoved(NotificationData.Entry removed) {
         onEntryRemovedInternal(removed, removed.notification);
+        mIsolatedEntries.remove(removed.key);
     }
 
     /**
@@ -119,11 +124,22 @@
             group.expanded = added.row.areChildrenExpanded();
             updateSuppression(group);
             if (!group.children.isEmpty()) {
+                HashSet<NotificationData.Entry> childrenCopy =
+                        (HashSet<NotificationData.Entry>) group.children.clone();
+                for (NotificationData.Entry child : childrenCopy) {
+                    onEntryBecomingChild(child);
+                }
                 mListener.onGroupCreatedFromChildren(group);
             }
         }
     }
 
+    private void onEntryBecomingChild(NotificationData.Entry entry) {
+        if (entry.row.isHeadsUp()) {
+            onHeadsUpStateChanged(entry, true);
+        }
+    }
+
     public void onEntryBundlingUpdated(final NotificationData.Entry updated,
             final String overrideGroupKey) {
         final StatusBarNotification oldSbn = updated.notification.clone();
@@ -188,6 +204,8 @@
                 updateSuppression(mGroupMap.get(oldKey));
                 updateSuppression(mGroupMap.get(newKey));
             }
+        } else if (!isGroupChild(oldNotification) && isGroupChild(entry.notification)) {
+            onEntryBecomingChild(entry);
         }
     }
 
@@ -222,7 +240,12 @@
     }
 
     public void collapseAllGroups() {
-        for (NotificationGroup group : mGroupMap.values()) {
+        // Because notifications can become isolated when the group becomes suppressed it can
+        // lead to concurrent modifications while looping. We need to make a copy.
+        ArrayList<NotificationGroup> groupCopy = new ArrayList<>(mGroupMap.values());
+        int size = groupCopy.size();
+        for (int i = 0; i < size; i++) {
+            NotificationGroup group =  groupCopy.get(i);
             if (group.expanded) {
                 setGroupExpanded(group, false);
             }
@@ -354,7 +377,6 @@
                 mListener.onGroupsChanged();
             } else {
                 handleSuppressedSummaryHeadsUpped(entry);
-
             }
         } else {
             if (mIsolatedEntries.containsKey(sbn.getKey())) {
@@ -413,6 +435,19 @@
         mHeadsUpManager = headsUpManager;
     }
 
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("GroupManager state:");
+        pw.println("  number of groups: " +  mGroupMap.size());
+        for (Map.Entry<String, NotificationGroup>  entry : mGroupMap.entrySet()) {
+            pw.println("\n    key: " + entry.getKey()); pw.println(entry.getValue());
+        }
+        pw.println("\n    isolated entries: " +  mIsolatedEntries.size());
+        for (Map.Entry<String, StatusBarNotification> entry : mIsolatedEntries.entrySet()) {
+            pw.print("      "); pw.print(entry.getKey());
+            pw.print(", "); pw.println(entry.getValue());
+        }
+    }
+
     public static class NotificationGroup {
         public final HashSet<NotificationData.Entry> children = new HashSet<>();
         public NotificationData.Entry summary;
@@ -421,6 +456,16 @@
          * Is this notification group suppressed, i.e its summary is hidden
          */
         public boolean suppressed;
+
+        @Override
+        public String toString() {
+            String result = "    summary:\n      " + summary.notification;
+            result += "\n    children size: " + children.size();
+            for (NotificationData.Entry child : children) {
+                result += "\n      " + child.notification;
+            }
+            return result;
+        }
     }
 
     public interface OnGroupChangeListener {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 20809ea..3c6e999 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1544,6 +1544,9 @@
             }
             for (int i = 0; i < toRemove.size(); i++) {
                 removeNotification(toRemove.get(i).getStatusBarNotification().getKey(), ranking);
+                // we need to ensure that the view is actually properly removed from the viewstate
+                // as this won't happen anymore when kept in the parent.
+                mStackScroller.removeViewStateForView(toRemove.get(i));
             }
         }
     }
@@ -3150,6 +3153,11 @@
         } else {
             pw.println("  mHeadsUpManager: null");
         }
+        if (mGroupManager != null) {
+            mGroupManager.dump(fd, pw, args);
+        } else {
+            pw.println("  mGroupManager: null");
+        }
         if (KeyguardUpdateMonitor.getInstance(mContext) != null) {
             KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args);
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index c66cfba..33b113a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -2379,9 +2379,9 @@
     }
 
     private void updateHideSensitiveForChild(View child) {
-        if (mAmbientState.isHideSensitive() && child instanceof ExpandableView) {
+        if (child instanceof ExpandableView) {
             ExpandableView expandableView = (ExpandableView) child;
-            expandableView.setHideSensitiveForIntrinsicHeight(true);
+            expandableView.setHideSensitiveForIntrinsicHeight(mAmbientState.isHideSensitive());
         }
     }
 
@@ -2896,7 +2896,7 @@
 
     private void clearTransientViews(ViewGroup viewGroup) {
         while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
-            viewGroup.removeTransientView(getTransientView(0));
+            viewGroup.removeTransientView(viewGroup.getTransientView(0));
         }
     }
 
@@ -3635,6 +3635,15 @@
     }
 
     /**
+     * Remove the a given view from the viewstate. This is currently used when the children are
+     * kept in the parent artificially to have a nicer animation.
+     * @param view the view to remove
+     */
+    public void removeViewStateForView(View view) {
+        mCurrentStackScrollState.removeViewStateForView(view);
+    }
+
+    /**
      * A listener that is notified when some child locations might have changed.
      */
     public interface OnChildLocationsChangedListener {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
index f49067d..e8472ac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
@@ -823,11 +823,6 @@
                     // The position for this child was never generated, let's continue.
                     continue;
                 }
-                if (changingView.getVisibility() == View.GONE) {
-                    // The view was set to gone but the state never removed
-                    finalState.removeViewStateForView(changingView);
-                    continue;
-                }
                 finalState.applyState(changingView, viewState);
                 mNewAddChildren.add(changingView);
 
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index fd4c71e..c417fe8 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -2191,21 +2191,6 @@
     // CATEGORY: SETTINGS
     ACCOUNTS_WORK_PROFILE_SETTINGS = 401;
 
-    // The number of packages optimized during the optimizing apps dialog.
-    OPTIMIZING_APPS_NUM_PKGS_DEXOPTED = 402;
-
-    // The number of packages which did not need optimizing during the optimizing apps dialog.
-    OPTIMIZING_APPS_NUM_PKGS_SKIPPED = 403;
-
-    // The number of packages which failed to optimize during the optimizing apps dialog.
-    OPTIMIZING_APPS_NUM_PKGS_FAILED = 404;
-
-    // The number of optimizable packages in the system.
-    OPTIMIZING_APPS_NUM_PKGS_TOTAL = 405;
-
-    // The total amount of time the user was blocked on the optimizing apps dialog.
-    OPTIMIZING_APPS_TOTAL_TIME_MS = 406;
-
     // Add new aosp constants above this line.
     // END OF AOSP CONSTANTS
   }
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index 7da247a..1edc9b1 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -3067,7 +3067,7 @@
                     }
                 } else {
                     ActivityManagerNative.noteWakeupAlarm(
-                            alarm.operation, -1, alarm.packageName, alarm.statsTag);
+                            alarm.operation, alarm.uid, alarm.packageName, alarm.statsTag);
                 }
             }
         }
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index 434464c..c2a1c50 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -789,10 +789,11 @@
                 if (isSecure) {
                     tieManagedProfileLockIfNecessary(managedUserId, null);
                 } else {
+                    clearUserKeyProtection(managedUserId);
                     getGateKeeperService().clearSecureUserId(managedUserId);
                     mStorage.writePatternHash(null, managedUserId);
                     setKeystorePassword(null, managedUserId);
-                    clearUserKeyProtection(managedUserId);
+                    fixateNewestUserKeyAuth(managedUserId);
                     mStorage.removeChildProfileLock(managedUserId);
                     removeKeystoreProfileKey(managedUserId);
                 }
@@ -827,10 +828,11 @@
         byte[] currentHandle = getCurrentHandle(userId);
 
         if (pattern == null) {
+            clearUserKeyProtection(userId);
             getGateKeeperService().clearSecureUserId(userId);
             mStorage.writePatternHash(null, userId);
             setKeystorePassword(null, userId);
-            clearUserKeyProtection(userId);
+            fixateNewestUserKeyAuth(userId);
             onUserLockChanged(userId);
             return;
         }
@@ -860,8 +862,12 @@
 
         byte[] enrolledHandle = enrollCredential(currentHandle, savedCredential, pattern, userId);
         if (enrolledHandle != null) {
+            CredentialHash willStore
+                = new CredentialHash(enrolledHandle, CredentialHash.VERSION_GATEKEEPER);
+            setUserKeyProtection(userId, pattern,
+                doVerifyPattern(pattern, willStore, true, 0, userId));
             mStorage.writePatternHash(enrolledHandle, userId);
-            setUserKeyProtection(userId, pattern, verifyPattern(pattern, 0, userId));
+            fixateNewestUserKeyAuth(userId);
             onUserLockChanged(userId);
         } else {
             throw new RemoteException("Failed to enroll pattern");
@@ -884,10 +890,11 @@
             throws RemoteException {
         byte[] currentHandle = getCurrentHandle(userId);
         if (password == null) {
+            clearUserKeyProtection(userId);
             getGateKeeperService().clearSecureUserId(userId);
             mStorage.writePasswordHash(null, userId);
             setKeystorePassword(null, userId);
-            clearUserKeyProtection(userId);
+            fixateNewestUserKeyAuth(userId);
             onUserLockChanged(userId);
             return;
         }
@@ -915,8 +922,12 @@
 
         byte[] enrolledHandle = enrollCredential(currentHandle, savedCredential, password, userId);
         if (enrolledHandle != null) {
+            CredentialHash willStore
+                = new CredentialHash(enrolledHandle, CredentialHash.VERSION_GATEKEEPER);
+            setUserKeyProtection(userId, password,
+                doVerifyPassword(password, willStore, true, 0, userId));
             mStorage.writePasswordHash(enrolledHandle, userId);
-            setUserKeyProtection(userId, password, verifyPassword(password, 0, userId));
+            fixateNewestUserKeyAuth(userId);
             onUserLockChanged(userId);
         } else {
             throw new RemoteException("Failed to enroll password");
@@ -1021,11 +1032,11 @@
         if (token == null) {
             throw new RemoteException("Empty payload verifying a credential we just set");
         }
-        changeUserKey(userId, token, secretFromCredential(credential));
+        addUserKeyAuth(userId, token, secretFromCredential(credential));
     }
 
     private void clearUserKeyProtection(int userId) throws RemoteException {
-        changeUserKey(userId, null, null);
+        addUserKeyAuth(userId, null, null);
     }
 
     private static byte[] secretFromCredential(String credential) throws RemoteException {
@@ -1044,18 +1055,23 @@
         }
     }
 
-    private void changeUserKey(int userId, byte[] token, byte[] secret)
+    private void addUserKeyAuth(int userId, byte[] token, byte[] secret)
             throws RemoteException {
         final UserInfo userInfo = UserManager.get(mContext).getUserInfo(userId);
         final IMountService mountService = getMountService();
         final long callingId = Binder.clearCallingIdentity();
         try {
-            mountService.changeUserKey(userId, userInfo.serialNumber, token, null, secret);
+            mountService.addUserKeyAuth(userId, userInfo.serialNumber, token, secret);
         } finally {
             Binder.restoreCallingIdentity(callingId);
         }
     }
 
+    private void fixateNewestUserKeyAuth(int userId)
+            throws RemoteException {
+        getMountService().fixateNewestUserKeyAuth(userId);
+    }
+
     @Override
     public VerifyCredentialResponse checkPattern(String pattern, int userId) throws RemoteException {
         return doVerifyPattern(pattern, false, 0, userId);
@@ -1071,6 +1087,11 @@
             long challenge, int userId) throws RemoteException {
        checkPasswordReadPermission(userId);
        CredentialHash storedHash = mStorage.readPatternHash(userId);
+       return doVerifyPattern(pattern, storedHash, hasChallenge, challenge, userId);
+    }
+
+    private VerifyCredentialResponse doVerifyPattern(String pattern, CredentialHash storedHash,
+            boolean hasChallenge, long challenge, int userId) throws RemoteException {
        boolean shouldReEnrollBaseZero = storedHash != null && storedHash.isBaseZeroPattern;
 
        String patternToVerify;
@@ -1108,7 +1129,6 @@
        }
 
        return response;
-
     }
 
     @Override
@@ -1158,6 +1178,11 @@
             long challenge, int userId) throws RemoteException {
        checkPasswordReadPermission(userId);
        CredentialHash storedHash = mStorage.readPasswordHash(userId);
+       return doVerifyPassword(password, storedHash, hasChallenge, challenge, userId);
+    }
+
+    private VerifyCredentialResponse doVerifyPassword(String password, CredentialHash storedHash,
+            boolean hasChallenge, long challenge, int userId) throws RemoteException {
        return verifyCredential(userId, storedHash, password, hasChallenge, challenge,
                new CredentialUtil() {
                    @Override
diff --git a/services/core/java/com/android/server/LockSettingsStorage.java b/services/core/java/com/android/server/LockSettingsStorage.java
index 9ab6300..ab91a73 100644
--- a/services/core/java/com/android/server/LockSettingsStorage.java
+++ b/services/core/java/com/android/server/LockSettingsStorage.java
@@ -74,7 +74,7 @@
 
     private SparseArray<Integer> mStoredCredentialType;
 
-    class CredentialHash {
+    static class CredentialHash {
         static final int TYPE_NONE = -1;
         static final int TYPE_PATTERN = 1;
         static final int TYPE_PASSWORD = 2;
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index 25ce485..c89b6ea 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -2816,15 +2816,36 @@
         }
     }
 
+    /*
+     * Add this token/secret pair to the set of ways we can recover a disk encryption key.
+     * Changing the token/secret for a disk encryption key is done in two phases: first, adding
+     * a new token/secret pair with this call, then delting all other pairs with
+     * fixateNewestUserKeyAuth. This allows other places where a credential is used, such as
+     * Gatekeeper, to be updated between the two calls.
+     */
     @Override
-    public void changeUserKey(int userId, int serialNumber,
-            byte[] token, byte[] oldSecret, byte[] newSecret) {
+    public void addUserKeyAuth(int userId, int serialNumber, byte[] token, byte[] secret) {
         enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
         waitForReady();
 
         try {
-            mCryptConnector.execute("cryptfs", "change_user_key", userId, serialNumber,
-                encodeBytes(token), encodeBytes(oldSecret), encodeBytes(newSecret));
+            mCryptConnector.execute("cryptfs", "add_user_key_auth", userId, serialNumber,
+                encodeBytes(token), encodeBytes(secret));
+        } catch (NativeDaemonConnectorException e) {
+            throw e.rethrowAsParcelableException();
+        }
+    }
+
+    /*
+     * Delete all disk encryption token/secret pairs except the most recently added one
+     */
+    @Override
+    public void fixateNewestUserKeyAuth(int userId) {
+        enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
+        waitForReady();
+
+        try {
+            mCryptConnector.execute("cryptfs", "fixate_newest_user_key_auth", userId);
         } catch (NativeDaemonConnectorException e) {
             throw e.rethrowAsParcelableException();
         }
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 98b3b08..a9a53a2 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -2237,8 +2237,13 @@
                 }
             }
 
-            new Session(accounts, response, account.type, expectActivityLaunch,
-                    false /* stripAuthTokenFromResult */, account.name,
+            new Session(
+                    accounts,
+                    response,
+                    account.type,
+                    expectActivityLaunch,
+                    false /* stripAuthTokenFromResult */,
+                    account.name,
                     false /* authDetailsRequired */) {
                 @Override
                 protected String toDebugString(long now) {
@@ -2310,6 +2315,15 @@
 
                         Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
                         if (intent != null && notifyOnAuthFailure && !customTokens) {
+                            /*
+                             * Make sure that the supplied intent is owned by the authenticator
+                             * giving it to the system. Otherwise a malicious authenticator could
+                             * have users launching arbitrary activities by tricking users to
+                             * interact with malicious notifications.
+                             */
+                            checkKeyIntent(
+                                    Binder.getCallingUid(),
+                                    intent);
                             doNotification(mAccounts,
                                     account, result.getString(AccountManager.KEY_AUTH_FAILED_MESSAGE),
                                     intent, accounts.userId);
diff --git a/services/core/java/com/android/server/pm/BackgroundDexOptService.java b/services/core/java/com/android/server/pm/BackgroundDexOptService.java
index 0a25402..ee02a99 100644
--- a/services/core/java/com/android/server/pm/BackgroundDexOptService.java
+++ b/services/core/java/com/android/server/pm/BackgroundDexOptService.java
@@ -144,11 +144,18 @@
                     if (DEBUG_DEXOPT) {
                         Log.i(TAG, "Updating package " + pkg);
                     }
+
                     // Update package if needed. Note that there can be no race between concurrent
                     // jobs because PackageDexOptimizer.performDexOpt is synchronized.
+
+                    // checkProfiles is false to avoid merging profiles during boot which
+                    // might interfere with background compilation (b/28612421).
+                    // Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
+                    // behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
+                    // trade-off worth doing to save boot time work.
                     pm.performDexOpt(pkg,
                             /* instruction set */ null,
-                            /* checkProfiles */ true,
+                            /* checkProfiles */ false,
                             PackageManagerService.REASON_BOOT,
                             /* force */ false);
                 }
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index f134e40..89747b5 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -28,6 +28,7 @@
 import android.util.Slog;
 
 import com.android.internal.os.InstallerConnection.InstallerException;
+import com.android.internal.util.IndentingPrintWriter;
 
 import java.io.File;
 import java.io.IOException;
@@ -122,6 +123,32 @@
         return dexoptFlags;
     }
 
+    /**
+     * Dumps the dexopt state of the given package {@code pkg} to the given {@code PrintWriter}.
+     */
+    void dumpDexoptState(IndentingPrintWriter pw, PackageParser.Package pkg) {
+        final String[] instructionSets = getAppDexInstructionSets(pkg.applicationInfo);
+        final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
+
+        final List<String> paths = pkg.getAllCodePathsExcludingResourceOnly();
+
+        for (String instructionSet : dexCodeInstructionSets) {
+             pw.println("Instruction Set: " + instructionSet);
+             pw.increaseIndent();
+             for (String path : paths) {
+                  String status = null;
+                  try {
+                      status = DexFile.getDexFileStatus(path, instructionSet);
+                  } catch (IOException ioe) {
+                      status = "[Exception]: " + ioe.getMessage();
+                  }
+                  pw.println("path: " + path);
+                  pw.println("status: " + status);
+             }
+             pw.decreaseIndent();
+        }
+    }
+
     private int performDexOptLI(PackageParser.Package pkg, String[] sharedLibraries,
             String[] targetInstructionSets, boolean checkProfiles, String targetCompilerFilter) {
         final String[] instructionSets = targetInstructionSets != null ?
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 4adfc3f..2f83ec4 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -226,8 +226,6 @@
 import com.android.internal.app.ResolverActivity;
 import com.android.internal.content.NativeLibraryHelper;
 import com.android.internal.content.PackageHelper;
-import com.android.internal.logging.MetricsLogger;
-import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.internal.os.IParcelFileDescriptorFactory;
 import com.android.internal.os.InstallerConnection.InstallerException;
 import com.android.internal.os.SomeArgs;
@@ -7196,9 +7194,14 @@
                 }
             }
 
+            // checkProfiles is false to avoid merging profiles during boot which
+            // might interfere with background compilation (b/28612421).
+            // Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
+            // behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
+            // trade-off worth doing to save boot time work.
             int dexOptStatus = performDexOptTraced(pkg.packageName,
                     null /* instructionSet */,
-                    true /* checkProfiles */,
+                    false /* checkProfiles */,
                     getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT),
                     false /* force */);
             switch (dexOptStatus) {
@@ -7218,16 +7221,7 @@
         }
 
         final int elapsedTime = (int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
-        MetricsLogger.action(mContext,
-                MetricsEvent.OPTIMIZING_APPS_NUM_PKGS_DEXOPTED, numberOfPackagesOptimized);
-        MetricsLogger.action(mContext,
-                MetricsEvent.OPTIMIZING_APPS_NUM_PKGS_SKIPPED, numberOfPackagesSkipped);
-        MetricsLogger.action(mContext,
-                MetricsEvent.OPTIMIZING_APPS_NUM_PKGS_FAILED, numberOfPackagesFailed);
-        MetricsLogger.action(mContext,
-                MetricsEvent.OPTIMIZING_APPS_NUM_PKGS_TOTAL, getOptimizablePackages().size());
-        MetricsLogger.action(mContext,
-                MetricsEvent.OPTIMIZING_APPS_TOTAL_TIME_MS, elapsedTime);
+        // TODO: Log events using MetricsLogger.histogram / MetricsLogger.count
     }
 
     @Override
@@ -15453,9 +15447,18 @@
         removePackageLI(ps, (flags & REMOVE_CHATTY) != 0);
 
         if ((flags & PackageManager.DELETE_KEEP_DATA) == 0) {
-            destroyAppDataLIF(deletedPkg, UserHandle.USER_ALL,
+            final PackageParser.Package resolvedPkg;
+            if (deletedPkg != null) {
+                resolvedPkg = deletedPkg;
+            } else {
+                // We don't have a parsed package when it lives on an ejected
+                // adopted storage device, so fake something together
+                resolvedPkg = new PackageParser.Package(ps.name);
+                resolvedPkg.setVolumeUuid(ps.volumeUuid);
+            }
+            destroyAppDataLIF(resolvedPkg, UserHandle.USER_ALL,
                     StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE);
-            destroyAppProfilesLIF(deletedPkg);
+            destroyAppProfilesLIF(resolvedPkg);
             if (outInfo != null) {
                 outInfo.dataRemoved = true;
             }
@@ -17773,6 +17776,7 @@
         public static final int DUMP_INTENT_FILTER_VERIFIERS = 1 << 17;
         public static final int DUMP_DOMAIN_PREFERRED = 1 << 18;
         public static final int DUMP_FROZEN = 1 << 19;
+        public static final int DUMP_DEXOPT = 1 << 20;
 
         public static final int OPTION_SHOW_FILTERS = 1 << 0;
 
@@ -17889,6 +17893,7 @@
                 pw.println("    write: write current settings now");
                 pw.println("    installs: details about install sessions");
                 pw.println("    check-permission <permission> <package> [<user>]: does pkg hold perm?");
+                pw.println("    dexopt: dump dexopt state");
                 pw.println("    <package.name>: info about given package");
                 return;
             } else if ("--checkin".equals(opt)) {
@@ -18008,6 +18013,8 @@
                 dumpState.setDump(DumpState.DUMP_INSTALLS);
             } else if ("frozen".equals(cmd)) {
                 dumpState.setDump(DumpState.DUMP_FROZEN);
+            } else if ("dexopt".equals(cmd)) {
+                dumpState.setDump(DumpState.DUMP_DEXOPT);
             } else if ("write".equals(cmd)) {
                 synchronized (mPackages) {
                     mSettings.writeLPr();
@@ -18365,6 +18372,11 @@
                 ipw.decreaseIndent();
             }
 
+            if (!checkin && dumpState.isDumping(DumpState.DUMP_DEXOPT)) {
+                if (dumpState.onTitlePrinted()) pw.println();
+                dumpDexoptStateLPr(pw, packageName);
+            }
+
             if (!checkin && dumpState.isDumping(DumpState.DUMP_MESSAGES) && packageName == null) {
                 if (dumpState.onTitlePrinted()) pw.println();
                 mSettings.dumpReadMessagesLPr(pw, dumpState);
@@ -18403,6 +18415,32 @@
         }
     }
 
+    private void dumpDexoptStateLPr(PrintWriter pw, String packageName) {
+        final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ", 120);
+        ipw.println();
+        ipw.println("Dexopt state:");
+        ipw.increaseIndent();
+        Collection<PackageParser.Package> packages = null;
+        if (packageName != null) {
+            PackageParser.Package targetPackage = mPackages.get(packageName);
+            if (targetPackage != null) {
+                packages = Collections.singletonList(targetPackage);
+            } else {
+                ipw.println("Unable to find package: " + packageName);
+                return;
+            }
+        } else {
+            packages = mPackages.values();
+        }
+
+        for (PackageParser.Package pkg : packages) {
+            ipw.println("[" + pkg.packageName + "]");
+            ipw.increaseIndent();
+            mPackageDexOptimizer.dumpDexoptState(ipw, pkg);
+            ipw.decreaseIndent();
+        }
+    }
+
     private String dumpDomainString(String packageName) {
         List<IntentFilterVerificationInfo> iviList = getIntentFilterVerifications(packageName)
                 .getList();
@@ -19610,6 +19648,7 @@
         final String label;
         final int targetSdkVersion;
         final PackageFreezer freezer;
+        final int[] installedUserIds;
 
         // reader
         synchronized (mPackages) {
@@ -19664,6 +19703,7 @@
             label = String.valueOf(pm.getApplicationLabel(pkg.applicationInfo));
             targetSdkVersion = pkg.applicationInfo.targetSdkVersion;
             freezer = new PackageFreezer(packageName, "movePackageInternal");
+            installedUserIds = ps.queryInstalledUsers(sUserManager.getUserIds(), true);
         }
 
         final Bundle extras = new Bundle();
@@ -19701,10 +19741,12 @@
 
         final PackageStats stats = new PackageStats(null, -1);
         synchronized (mInstaller) {
-            if (!getPackageSizeInfoLI(packageName, -1, stats)) {
-                freezer.close();
-                throw new PackageManagerException(MOVE_FAILED_INTERNAL_ERROR,
-                        "Failed to measure package size");
+            for (int userId : installedUserIds) {
+                if (!getPackageSizeInfoLI(packageName, userId, stats)) {
+                    freezer.close();
+                    throw new PackageManagerException(MOVE_FAILED_INTERNAL_ERROR,
+                            "Failed to measure package size");
+                }
             }
         }
 
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 2636d09..e409299 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -3360,7 +3360,7 @@
                 final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK;
                 if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON)) {
                     mRecentAppsHeldModifiers = shiftlessModifiers;
-                    showRecentApps(true);
+                    showRecentApps(true, false);
                     return -1;
                 }
             }
diff --git a/services/core/java/com/android/server/vr/VrManagerService.java b/services/core/java/com/android/server/vr/VrManagerService.java
index 844b5e6..48c0fee 100644
--- a/services/core/java/com/android/server/vr/VrManagerService.java
+++ b/services/core/java/com/android/server/vr/VrManagerService.java
@@ -16,6 +16,7 @@
 package com.android.server.vr;
 
 import android.Manifest;
+import android.app.ActivityManager;
 import android.app.AppOpsManager;
 import android.app.NotificationManager;
 import android.annotation.NonNull;
@@ -47,6 +48,7 @@
 import android.service.vr.VrListenerService;
 import android.util.ArraySet;
 import android.util.Slog;
+import android.util.SparseArray;
 
 import com.android.internal.R;
 import com.android.server.SystemConfig;
@@ -95,6 +97,7 @@
 
     private static final int PENDING_STATE_DELAY_MS = 300;
     private static final int EVENT_LOG_SIZE = 32;
+    private static final int INVALID_APPOPS_MODE = -1;
 
     private static native void initializeNative();
     private static native void setVrModeNative(boolean enabled);
@@ -114,12 +117,11 @@
     private boolean mGuard;
     private final RemoteCallbackList<IVrStateCallbacks> mRemoteCallbacks =
             new RemoteCallbackList<>();
-    private final ArraySet<String> mPreviousToggledListenerSettings = new ArraySet<>();
-    private String mPreviousNotificationPolicyAccessPackage;
-    private String mPreviousCoarseLocationPackage;
-    private String mPreviousManageOverlayPackage;
+    private int mPreviousCoarseLocationMode = INVALID_APPOPS_MODE;
+    private int mPreviousManageOverlayMode = INVALID_APPOPS_MODE;
     private VrState mPendingState;
     private final ArrayDeque<VrState> mLoggingDeque = new ArrayDeque<>(EVENT_LOG_SIZE);
+    private final NotificationAccessManager mNotifAccessManager = new NotificationAccessManager();
 
     private static final int MSG_VR_STATE_CHANGE = 0;
     private static final int MSG_PENDING_VR_STATE_CHANGE = 1;
@@ -193,6 +195,39 @@
         }
     };
 
+    private final class NotificationAccessManager {
+        private final SparseArray<ArraySet<String>> mAllowedPackages = new SparseArray<>();
+
+        public void update(Collection<String> packageNames) {
+            int currentUserId = ActivityManager.getCurrentUser();
+
+            UserHandle currentUserHandle = new UserHandle(currentUserId);
+
+            ArraySet<String> allowed = mAllowedPackages.get(currentUserId);
+            if (allowed == null) {
+                allowed = new ArraySet<>();
+            }
+
+            for (String pkg : allowed) {
+                if (!packageNames.contains(pkg)) {
+                    revokeNotificationListenerAccess(pkg);
+                    revokeNotificationPolicyAccess(pkg);
+                }
+            }
+            for (String pkg : packageNames) {
+                if (!allowed.contains(pkg)) {
+                    grantNotificationPolicyAccess(pkg);
+                    grantNotificationListenerAccess(pkg, currentUserHandle);
+                }
+            }
+
+            allowed.clear();
+            allowed.addAll(packageNames);
+            mAllowedPackages.put(currentUserId, allowed);
+        }
+    }
+
+
     /**
      * Called when a user, package, or setting changes that could affect whether or not the
      * currently bound VrListenerService is changed.
@@ -200,6 +235,20 @@
     @Override
     public void onEnabledComponentChanged() {
         synchronized (mLock) {
+            int currentUser = ActivityManager.getCurrentUser();
+
+            // Update listeners
+            ArraySet<ComponentName> enabledListeners = mComponentObserver.getEnabled(currentUser);
+
+            ArraySet<String> enabledPackages = new ArraySet<>();
+            for (ComponentName n : enabledListeners) {
+                String pkg = n.getPackageName();
+                if (isDefaultAllowed(pkg)) {
+                    enabledPackages.add(n.getPackageName());
+                }
+            }
+            mNotifAccessManager.update(enabledPackages);
+
             if (mCurrentVrService == null) {
                 return; // No active services
             }
@@ -616,21 +665,18 @@
         } catch (NameNotFoundException e) {
         }
 
-        if (info == null) {
-            Slog.e(TAG, "Couldn't set implied permissions for " + pName + ", no such package.");
+        if (info == null || !(info.isSystemApp() || info.isUpdatedSystemApp())) {
             return;
         }
 
-        if (!(info.isSystemApp() || info.isUpdatedSystemApp())) {
-            return; // Application is not pre-installed, avoid setting implied permissions
-        }
-
         mWasDefaultGranted = true;
-
-        grantCoarseLocationAccess(pName, userId);
-        grantOverlayAccess(pName, userId);
-        grantNotificationPolicyAccess(pName);
-        grantNotificationListenerAccess(pName, userId);
+        AppOpsManager mgr = mContext.getSystemService(AppOpsManager.class);
+        if (mgr == null) {
+            Slog.e(TAG, "No AppOpsManager, failed to set permissions for: " + pName);
+            return;
+        }
+        grantCoarseLocationAccess(mgr, pName, info.uid);
+        grantOverlayAccess(mgr, pName, info.uid);
     }
 
     /**
@@ -657,80 +703,89 @@
 
         String pName = component.getPackageName();
         if (mWasDefaultGranted) {
-            revokeCoarseLocationAccess(userId);
-            revokeOverlayAccess(userId);
-            revokeNotificationPolicyAccess(pName);
-            revokeNotificiationListenerAccess();
+            ApplicationInfo info = null;
+            try {
+                info = pm.getApplicationInfo(pName, PackageManager.GET_META_DATA);
+            } catch (NameNotFoundException e) {
+            }
+
+            if (info != null) {
+                AppOpsManager mgr = mContext.getSystemService(AppOpsManager.class);
+                if (mgr == null) {
+                    Slog.e(TAG, "No AppOpsManager, failed to set permissions for: " + pName);
+                    return;
+                }
+                revokeCoarseLocationAccess(mgr, pName, info.uid);
+                revokeOverlayAccess(mgr, pName, info.uid);
+            }
             mWasDefaultGranted = false;
         }
 
     }
 
-    private void grantCoarseLocationAccess(String pkg, UserHandle userId) {
+    private boolean isDefaultAllowed(String packageName) {
         PackageManager pm = mContext.getPackageManager();
-        boolean prev = (PackageManager.PERMISSION_GRANTED ==
-                pm.checkPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION, pkg));
-        mPreviousCoarseLocationPackage = null;
-        if (!prev) {
-            pm.grantRuntimePermission(pkg, android.Manifest.permission.ACCESS_COARSE_LOCATION,
-                    userId);
-            mPreviousCoarseLocationPackage = pkg;
+
+        ApplicationInfo info = null;
+        try {
+            info = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
+        } catch (NameNotFoundException e) {
+        }
+
+        if (info == null || !(info.isSystemApp() || info.isUpdatedSystemApp())) {
+            return false;
+        }
+        return true;
+    }
+
+    private void grantCoarseLocationAccess(AppOpsManager mgr, String packageName, int uid) {
+        mPreviousCoarseLocationMode = mgr.checkOpNoThrow(AppOpsManager.OP_COARSE_LOCATION, uid,
+                packageName);
+
+        if (mPreviousCoarseLocationMode != AppOpsManager.MODE_ALLOWED) {
+            mgr.setMode(AppOpsManager.OP_COARSE_LOCATION, uid, packageName,
+                    AppOpsManager.MODE_ALLOWED);
         }
     }
 
-    private void revokeCoarseLocationAccess(UserHandle userId) {
-        PackageManager pm = mContext.getPackageManager();
-        if (mPreviousCoarseLocationPackage != null) {
-            pm.revokeRuntimePermission(mPreviousCoarseLocationPackage,
-                    android.Manifest.permission.ACCESS_COARSE_LOCATION, userId);
-            mPreviousCoarseLocationPackage = null;
+    private void revokeCoarseLocationAccess(AppOpsManager mgr, String packageName, int uid) {
+        if (mPreviousCoarseLocationMode != AppOpsManager.MODE_ALLOWED) {
+            mgr.setMode(AppOpsManager.OP_COARSE_LOCATION, uid, packageName,
+                    mPreviousCoarseLocationMode);
+            mPreviousCoarseLocationMode = INVALID_APPOPS_MODE;
         }
     }
 
-    private void grantOverlayAccess(String pkg, UserHandle userId) {
-        PackageManager pm = mContext.getPackageManager();
-        boolean prev = (PackageManager.PERMISSION_GRANTED ==
-                pm.checkPermission(android.Manifest.permission.SYSTEM_ALERT_WINDOW, pkg));
-        mPreviousManageOverlayPackage = null;
-        if (!prev) {
-            pm.grantRuntimePermission(pkg, android.Manifest.permission.SYSTEM_ALERT_WINDOW,
-                    userId);
-            mPreviousManageOverlayPackage = pkg;
+    private void grantOverlayAccess(AppOpsManager mgr, String packageName, int uid) {
+
+        mPreviousManageOverlayMode = mgr.checkOpNoThrow(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid,
+                packageName);
+
+        if (mPreviousManageOverlayMode != AppOpsManager.MODE_ALLOWED) {
+            mgr.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, packageName,
+                    AppOpsManager.MODE_ALLOWED);
         }
     }
 
-    private void revokeOverlayAccess(UserHandle userId) {
-        PackageManager pm = mContext.getPackageManager();
-        if (mPreviousManageOverlayPackage != null) {
-            pm.revokeRuntimePermission(mPreviousManageOverlayPackage,
-                    android.Manifest.permission.SYSTEM_ALERT_WINDOW, userId);
-            mPreviousManageOverlayPackage = null;
+    private void revokeOverlayAccess(AppOpsManager mgr, String packageName, int uid) {
+        if (mPreviousManageOverlayMode != AppOpsManager.MODE_ALLOWED) {
+            mgr.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, packageName,
+                    mPreviousManageOverlayMode);
+            mPreviousManageOverlayMode = INVALID_APPOPS_MODE;
         }
     }
 
     private void grantNotificationPolicyAccess(String pkg) {
         NotificationManager nm = mContext.getSystemService(NotificationManager.class);
-        boolean prev = nm.isNotificationPolicyAccessGrantedForPackage(pkg);
-        mPreviousNotificationPolicyAccessPackage = null;
-        if (!prev) {
-            mPreviousNotificationPolicyAccessPackage = pkg;
-            nm.setNotificationPolicyAccessGranted(pkg, true);
-        }
+        nm.setNotificationPolicyAccessGranted(pkg, true);
     }
 
     private void revokeNotificationPolicyAccess(String pkg) {
         NotificationManager nm = mContext.getSystemService(NotificationManager.class);
-        if (mPreviousNotificationPolicyAccessPackage != null) {
-            if (mPreviousNotificationPolicyAccessPackage.equals(pkg)) {
-                // Remove any DND zen rules possibly created by the package.
-                nm.removeAutomaticZenRules(mPreviousNotificationPolicyAccessPackage);
-                // Remove Notification Policy Access.
-                nm.setNotificationPolicyAccessGranted(mPreviousNotificationPolicyAccessPackage, false);
-                mPreviousNotificationPolicyAccessPackage = null;
-            } else {
-                Slog.e(TAG, "Couldn't remove Notification Policy Access for package: " + pkg);
-            }
-        }
+        // Remove any DND zen rules possibly created by the package.
+        nm.removeAutomaticZenRules(pkg);
+        // Remove Notification Policy Access.
+        nm.setNotificationPolicyAccessGranted(pkg, false);
     }
 
     private void grantNotificationListenerAccess(String pkg, UserHandle userId) {
@@ -742,13 +797,10 @@
 
         ArraySet<String> current = getCurrentNotifListeners(resolver);
 
-        mPreviousToggledListenerSettings.clear();
-
         for (ComponentName c : possibleServices) {
             String flatName = c.flattenToString();
             if (Objects.equals(c.getPackageName(), pkg)
                     && !current.contains(flatName)) {
-                mPreviousToggledListenerSettings.add(flatName);
                 current.add(flatName);
             }
         }
@@ -760,20 +812,25 @@
         }
     }
 
-    private void revokeNotificiationListenerAccess() {
-        if (mPreviousToggledListenerSettings.isEmpty()) {
-            return;
-        }
-
+    private void revokeNotificationListenerAccess(String pkg) {
         ContentResolver resolver = mContext.getContentResolver();
         ArraySet<String> current = getCurrentNotifListeners(resolver);
 
-        current.removeAll(mPreviousToggledListenerSettings);
-        mPreviousToggledListenerSettings.clear();
+        ArrayList<String> toRemove = new ArrayList<>();
+
+        for (String c : current) {
+            ComponentName component = ComponentName.unflattenFromString(c);
+            if (component.getPackageName().equals(pkg)) {
+                toRemove.add(c);
+            }
+        }
+
+        current.removeAll(toRemove);
 
         String flatSettings = formatSettings(current);
         Settings.Secure.putString(resolver, Settings.Secure.ENABLED_NOTIFICATION_LISTENERS,
                 flatSettings);
+
     }
 
     private ArraySet<String> getCurrentNotifListeners(ContentResolver resolver) {
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 5a394d0..be888fe 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -6150,12 +6150,19 @@
 
         WindowState appWin = null;
 
-        boolean appIsImTarget;
+        boolean includeImeInScreenshot;
         synchronized(mWindowMap) {
-            appIsImTarget = mInputMethodTarget != null
-                    && mInputMethodTarget.mAppToken != null
-                    && mInputMethodTarget.mAppToken.appToken != null
-                    && mInputMethodTarget.mAppToken.appToken.asBinder() == appToken;
+            final AppWindowToken imeTargetAppToken =
+                    mInputMethodTarget != null ? mInputMethodTarget.mAppToken : null;
+            // We only include the Ime in the screenshot if the app we are screenshoting is the IME
+            // target and isn't in multi-window mode. We don't screenshot the IME in multi-window
+            // mode because the frame of the IME might not overlap with that of the app.
+            // E.g. IME target app at the top in split-screen mode and the IME at the bottom
+            // overlapping with the bottom app.
+            includeImeInScreenshot = imeTargetAppToken != null
+                    && imeTargetAppToken.appToken != null
+                    && imeTargetAppToken.appToken.asBinder() == appToken
+                    && !mInputMethodTarget.isInMultiWindowMode();
         }
 
         final int aboveAppLayer = (mPolicy.windowTypeToLayerLw(TYPE_APPLICATION) + 1)
@@ -6174,7 +6181,7 @@
                     continue;
                 }
                 if (ws.mIsImWindow) {
-                    if (!appIsImTarget) {
+                    if (!includeImeInScreenshot) {
                         continue;
                     }
                 } else if (ws.mIsWallpaper) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 7341e1e..a89b4aa 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -697,7 +697,7 @@
         // The offset from the layout containing frame to the actual containing frame.
         final int layoutXDiff;
         final int layoutYDiff;
-        if (mInsetFrame.isEmpty() && (fullscreenTask || layoutInParentFrame())) {
+        if (fullscreenTask || layoutInParentFrame()) {
             // We use the parent frame as the containing frame for fullscreen and child windows
             mContainingFrame.set(pf);
             mDisplayFrame.set(df);
@@ -1586,11 +1586,12 @@
                     win.transferDimToReplacement();
                 }
                 win.mWillReplaceWindow = false;
+                final boolean animateReplacingWindow = win.mAnimateReplacingWindow;
                 win.mAnimateReplacingWindow = false;
                 win.mReplacingRemoveRequested = false;
                 win.mReplacingWindow = null;
                 mSkipEnterAnimationForSeamlessReplacement = false;
-                if (win.mAnimatingExit) {
+                if (win.mAnimatingExit || !animateReplacingWindow) {
                     mService.removeWindowInnerLocked(win);
                 }
             }
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index a0784b5..e5f603c 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -322,6 +322,14 @@
         return mAnimation != null;
     }
 
+    /**
+     * Is this window currently waiting to run an opening animation?
+     */
+    boolean isWaitingForOpening() {
+        return mService.mAppTransition.isTransitionSet() && isDummyAnimation()
+                && mService.mOpeningApps.contains(mWin.mAppToken);
+    }
+
     void cancelExitAnimationForNextAnimationLocked() {
         if (DEBUG_ANIM) Slog.d(TAG,
                 "cancelExitAnimationForNextAnimationLocked: " + mWin);
@@ -1448,8 +1456,7 @@
         // the same app again before the app's surface is destroyed or saved, the surface
         // is always ready in the whole process.) If we go ahead here, the opening app
         // will be shown with the full size before the correct animation spec arrives.
-        if (mService.mAppTransition.isTransitionSet() && isDummyAnimation() &&
-                mService.mOpeningApps.contains(w.mAppToken)) {
+        if (isWaitingForOpening()) {
             return;
         }
 
diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
index fb4be30..e20e245 100644
--- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
+++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
@@ -772,7 +772,7 @@
                             }
                         }
                     }
-                    if (!winAnimator.isAnimationStarting()) {
+                    if (!winAnimator.isAnimationStarting() && !winAnimator.isWaitingForOpening()) {
                         // Updates the shown frame before we set up the surface. This is needed
                         // because the resizing could change the top-left position (in addition to
                         // size) of the window. setSurfaceBoundariesLocked uses mShownPosition to
@@ -1236,8 +1236,8 @@
             int topOpeningLayer = 0;
             if (animLp != null) {
                 int layer = -1;
-                for (int j = 0; j < wtoken.windows.size(); j++) {
-                    final WindowState win = wtoken.windows.get(j);
+                for (int j = 0; j < wtoken.allAppWindows.size(); j++) {
+                    final WindowState win = wtoken.allAppWindows.get(j);
                     // Clearing the mAnimatingExit flag before entering animation. It will be set to true
                     // if app window is removed, or window relayout to invisible. We don't want to
                     // clear it out for windows that get replaced, because the animation depends on
@@ -1249,6 +1249,14 @@
                     // they won't eventually be removed by WindowStateAnimator#finishExit.
                     if (!win.mWillReplaceWindow && !win.mRemoveOnExit) {
                         win.mAnimatingExit = false;
+                        // Clear mAnimating flag together with mAnimatingExit. When animation
+                        // changes from exiting to entering, we need to clear this flag until the
+                        // new animation gets applied, so that isAnimationStarting() becomes true
+                        // until then.
+                        // Otherwise applySurfaceChangesTransaction will faill to skip surface
+                        // placement for this window during this period, one or more frame will
+                        // show up with wrong position or scale.
+                        win.mWinAnimator.mAnimating = false;
                     }
                     if (win.mWinAnimator.mAnimLayer > layer) {
                         layer = win.mWinAnimator.mAnimLayer;
diff --git a/services/midi/java/com/android/server/midi/MidiService.java b/services/midi/java/com/android/server/midi/MidiService.java
index 723be24..1c18c9b 100644
--- a/services/midi/java/com/android/server/midi/MidiService.java
+++ b/services/midi/java/com/android/server/midi/MidiService.java
@@ -41,6 +41,7 @@
 import android.os.IBinder;
 import android.os.Process;
 import android.os.RemoteException;
+import android.os.UserHandle;
 import android.util.Log;
 
 import com.android.internal.content.PackageMonitor;
@@ -71,6 +72,13 @@
             mMidiService = new MidiService(getContext());
             publishBinderService(Context.MIDI_SERVICE, mMidiService);
         }
+
+        @Override
+        public void onUnlockUser(int userHandle) {
+            if (userHandle == UserHandle.USER_SYSTEM) {
+                mMidiService.onUnlockUser();
+            }
+        }
     }
 
     private static final String TAG = "MidiService";
@@ -97,7 +105,7 @@
     private final PackageManager mPackageManager;
 
     // UID of BluetoothMidiService
-    private final int mBluetoothServiceUid;
+    private int mBluetoothServiceUid;
 
     // PackageMonitor for listening to package changes
     private final PackageMonitor mPackageMonitor = new PackageMonitor() {
@@ -557,7 +565,12 @@
     public MidiService(Context context) {
         mContext = context;
         mPackageManager = context.getPackageManager();
-        mPackageMonitor.register(context, null, true);
+
+        mBluetoothServiceUid = -1;
+    }
+
+    private void onUnlockUser() {
+        mPackageMonitor.register(mContext, null, true);
 
         Intent intent = new Intent(MidiDeviceService.SERVICE_INTERFACE);
         List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent,
@@ -583,7 +596,7 @@
         } else {
             mBluetoothServiceUid = -1;
         }
-   }
+    }
 
     @Override
     public void registerListener(IBinder token, IMidiDeviceListener listener) {
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
index 27351e4..855a5c4 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
@@ -251,7 +251,8 @@
                         && structureEnabled) {
                     mAssistData.clear();
                     final int count = activityToken != null ? 1 : topActivities.size();
-                    for (int i = 0; i < count; i++) {
+                    // Temp workaround for bug: 28348867  Revert after DP3
+                    for (int i = 0; i < count && i < 1; i++) {
                         IBinder topActivity = count == 1 ? activityToken : topActivities.get(i);
                         try {
                             MetricsLogger.count(mContext, "assist_with_context", 1);