Merge "Fix text appearances not working in colored button styles" into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index 67d9b4a0..10f3284 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -34571,7 +34571,7 @@
 
 package android.service.notification {
 
-  public class Condition implements android.os.Parcelable {
+  public final class Condition implements android.os.Parcelable {
     ctor public Condition(android.net.Uri, java.lang.String, int);
     ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int, int, int);
     ctor public Condition(android.os.Parcel);
@@ -34608,7 +34608,7 @@
     method public void onRequestConditions(int);
     method public abstract void onSubscribe(android.net.Uri);
     method public abstract void onUnsubscribe(android.net.Uri);
-    field public static final java.lang.String EXTRA_RULE_ID = "android.content.automatic.ruleId";
+    field public static final java.lang.String EXTRA_RULE_ID = "android.service.notification.extra.RULE_ID";
     field public static final java.lang.String META_DATA_CONFIGURATION_ACTIVITY = "android.service.zen.automatic.configurationActivity";
     field public static final java.lang.String META_DATA_RULE_INSTANCE_LIMIT = "android.service.zen.automatic.ruleInstanceLimit";
     field public static final java.lang.String META_DATA_RULE_TYPE = "android.service.zen.automatic.ruleType";
diff --git a/api/system-current.txt b/api/system-current.txt
index 2d9d466..1d49652 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -37294,7 +37294,7 @@
     field public static final java.lang.String NEEDS_AUTOGROUPING_KEY = "autogroup_needed";
   }
 
-  public class Condition implements android.os.Parcelable {
+  public final class Condition implements android.os.Parcelable {
     ctor public Condition(android.net.Uri, java.lang.String, int);
     ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int, int, int);
     ctor public Condition(android.os.Parcel);
@@ -37331,7 +37331,7 @@
     method public void onRequestConditions(int);
     method public abstract void onSubscribe(android.net.Uri);
     method public abstract void onUnsubscribe(android.net.Uri);
-    field public static final java.lang.String EXTRA_RULE_ID = "android.content.automatic.ruleId";
+    field public static final java.lang.String EXTRA_RULE_ID = "android.service.notification.extra.RULE_ID";
     field public static final java.lang.String META_DATA_CONFIGURATION_ACTIVITY = "android.service.zen.automatic.configurationActivity";
     field public static final java.lang.String META_DATA_RULE_INSTANCE_LIMIT = "android.service.zen.automatic.ruleInstanceLimit";
     field public static final java.lang.String META_DATA_RULE_TYPE = "android.service.zen.automatic.ruleType";
diff --git a/api/test-current.txt b/api/test-current.txt
index 9e5b991..fea382f 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -34648,7 +34648,7 @@
 
 package android.service.notification {
 
-  public class Condition implements android.os.Parcelable {
+  public final class Condition implements android.os.Parcelable {
     ctor public Condition(android.net.Uri, java.lang.String, int);
     ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int, int, int);
     ctor public Condition(android.os.Parcel);
@@ -34685,7 +34685,7 @@
     method public void onRequestConditions(int);
     method public abstract void onSubscribe(android.net.Uri);
     method public abstract void onUnsubscribe(android.net.Uri);
-    field public static final java.lang.String EXTRA_RULE_ID = "android.content.automatic.ruleId";
+    field public static final java.lang.String EXTRA_RULE_ID = "android.service.notification.extra.RULE_ID";
     field public static final java.lang.String META_DATA_CONFIGURATION_ACTIVITY = "android.service.zen.automatic.configurationActivity";
     field public static final java.lang.String META_DATA_RULE_INSTANCE_LIMIT = "android.service.zen.automatic.ruleInstanceLimit";
     field public static final java.lang.String META_DATA_RULE_TYPE = "android.service.zen.automatic.ruleType";
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index a672d80..63afdd8 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2191,7 +2191,8 @@
      * <em>Note: This API has been limited as of {@link android.os.Build.VERSION_CODES#N} for
      * device admins that are not device owner and not profile owner.
      * The password can now only be changed if there is currently no password set.  Device owner
-     * and profile owner can still do this.</em>
+     * and profile owner can still do this when user is unlocked and does not have a managed
+     * profile.</em>
      * <p>
      * The given password must be sufficient for the current password quality and length constraints
      * as returned by {@link #getPasswordQuality(ComponentName)} and
@@ -2217,6 +2218,7 @@
      *         current constraints or if the user has not been decrypted yet.
      * @throws SecurityException if the calling application does not own an active administrator
      *             that uses {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD}
+     * @throws IllegalStateException if the calling user is locked or has a managed profile.
      */
     public boolean resetPassword(String password, int flags) {
         throwIfParentInstance("resetPassword");
diff --git a/core/java/android/service/notification/Condition.java b/core/java/android/service/notification/Condition.java
index 0163b47..447afe6 100644
--- a/core/java/android/service/notification/Condition.java
+++ b/core/java/android/service/notification/Condition.java
@@ -33,7 +33,7 @@
  * {@link ConditionProviderService} that owns the rule. Used to tell the system to enter Do Not
  * Disturb mode and request that the system exit Do Not Disturb mode.
  */
-public class Condition implements Parcelable {
+public final class Condition implements Parcelable {
 
     @SystemApi
     public static final String SCHEME = "condition";
diff --git a/core/java/android/service/notification/ConditionProviderService.java b/core/java/android/service/notification/ConditionProviderService.java
index 44c3887e..9d4b0a4 100644
--- a/core/java/android/service/notification/ConditionProviderService.java
+++ b/core/java/android/service/notification/ConditionProviderService.java
@@ -95,7 +95,7 @@
     /**
      * A String rule id extra passed to {@link #META_DATA_CONFIGURATION_ACTIVITY}.
      */
-    public static final String EXTRA_RULE_ID = "android.content.automatic.ruleId";
+    public static final String EXTRA_RULE_ID = "android.service.notification.extra.RULE_ID";
 
     /**
      * Called when this service is connected.
diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java
index 66896ab..ac44033 100644
--- a/core/java/android/widget/CalendarView.java
+++ b/core/java/android/widget/CalendarView.java
@@ -16,6 +16,8 @@
 
 package android.widget;
 
+import com.android.internal.R;
+
 import android.annotation.AttrRes;
 import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
@@ -27,17 +29,16 @@
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
+import android.icu.util.Calendar;
+import android.icu.util.TimeZone;
 import android.util.AttributeSet;
 import android.util.Log;
-import com.android.internal.R;
 
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
 import java.util.Date;
 import java.util.Locale;
-import java.util.TimeZone;
 
 /**
  * This class is a calendar widget for displaying and selecting dates. The
diff --git a/core/java/android/widget/CalendarViewLegacyDelegate.java b/core/java/android/widget/CalendarViewLegacyDelegate.java
index f540479..2b91713 100644
--- a/core/java/android/widget/CalendarViewLegacyDelegate.java
+++ b/core/java/android/widget/CalendarViewLegacyDelegate.java
@@ -27,6 +27,7 @@
 import android.graphics.Paint;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
+import android.icu.util.Calendar;
 import android.text.format.DateUtils;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
@@ -37,7 +38,6 @@
 import android.view.View;
 import android.view.ViewGroup;
 
-import java.util.Calendar;
 import java.util.Locale;
 
 import libcore.icu.LocaleData;
diff --git a/core/java/android/widget/CalendarViewMaterialDelegate.java b/core/java/android/widget/CalendarViewMaterialDelegate.java
index 0ed75d5..07b2000 100644
--- a/core/java/android/widget/CalendarViewMaterialDelegate.java
+++ b/core/java/android/widget/CalendarViewMaterialDelegate.java
@@ -18,11 +18,10 @@
 
 import android.annotation.StyleRes;
 import android.content.Context;
+import android.icu.util.Calendar;
 import android.util.AttributeSet;
 import android.widget.DayPickerView.OnDaySelectedListener;
 
-import java.util.Calendar;
-
 class CalendarViewMaterialDelegate extends CalendarView.AbstractCalendarViewDelegate {
     private final DayPickerView mDayPickerView;
 
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 0c5edc5..8613f99 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -16,11 +16,15 @@
 
 package android.widget;
 
+import com.android.internal.R;
+
 import android.annotation.Nullable;
 import android.annotation.Widget;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
+import android.icu.util.Calendar;
+import android.icu.util.TimeZone;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.util.AttributeSet;
@@ -28,11 +32,7 @@
 import android.view.View;
 import android.view.accessibility.AccessibilityEvent;
 
-import com.android.internal.R;
-
-import java.util.Calendar;
 import java.util.Locale;
-import java.util.TimeZone;
 
 /**
  * Provides a widget for selecting a date.
diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java
index 0a23b34..2c80f28 100755
--- a/core/java/android/widget/DatePickerCalendarDelegate.java
+++ b/core/java/android/widget/DatePickerCalendarDelegate.java
@@ -26,6 +26,7 @@
 import android.content.res.TypedArray;
 import android.icu.text.DisplayContext;
 import android.icu.text.SimpleDateFormat;
+import android.icu.util.Calendar;
 import android.os.Parcelable;
 import android.text.format.DateFormat;
 import android.text.format.DateUtils;
@@ -40,7 +41,6 @@
 import android.widget.DayPickerView.OnDaySelectedListener;
 import android.widget.YearPickerView.OnYearSelectedListener;
 
-import java.util.Calendar;
 import java.util.Locale;
 
 /**
diff --git a/core/java/android/widget/DatePickerSpinnerDelegate.java b/core/java/android/widget/DatePickerSpinnerDelegate.java
index d8a3c56..17af014 100644
--- a/core/java/android/widget/DatePickerSpinnerDelegate.java
+++ b/core/java/android/widget/DatePickerSpinnerDelegate.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
+import android.icu.util.Calendar;
 import android.os.Parcelable;
 import android.text.InputType;
 import android.text.TextUtils;
@@ -37,7 +38,6 @@
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
-import java.util.Calendar;
 import java.util.Locale;
 
 import libcore.icu.ICU;
diff --git a/core/java/android/widget/DayPickerPagerAdapter.java b/core/java/android/widget/DayPickerPagerAdapter.java
index 97936e7..9f02b44 100644
--- a/core/java/android/widget/DayPickerPagerAdapter.java
+++ b/core/java/android/widget/DayPickerPagerAdapter.java
@@ -25,14 +25,13 @@
 import android.content.Context;
 import android.content.res.ColorStateList;
 import android.content.res.TypedArray;
+import android.icu.util.Calendar;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.SimpleMonthView.OnDayClickListener;
 
-import java.util.Calendar;
-
 /**
  * An adapter for a list of {@link android.widget.SimpleMonthView} items.
  */
diff --git a/core/java/android/widget/DayPickerView.java b/core/java/android/widget/DayPickerView.java
index dc772fb..ab89c1f 100644
--- a/core/java/android/widget/DayPickerView.java
+++ b/core/java/android/widget/DayPickerView.java
@@ -24,6 +24,7 @@
 import android.content.Context;
 import android.content.res.ColorStateList;
 import android.content.res.TypedArray;
+import android.icu.util.Calendar;
 import android.util.AttributeSet;
 import android.util.MathUtils;
 import android.view.LayoutInflater;
@@ -31,7 +32,6 @@
 import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityManager;
 
-import java.util.Calendar;
 import java.util.Locale;
 
 import libcore.icu.LocaleData;
diff --git a/core/java/android/widget/SimpleMonthView.java b/core/java/android/widget/SimpleMonthView.java
index 97d834a..588425f 100644
--- a/core/java/android/widget/SimpleMonthView.java
+++ b/core/java/android/widget/SimpleMonthView.java
@@ -32,6 +32,7 @@
 import android.graphics.Typeface;
 import android.icu.text.DisplayContext;
 import android.icu.text.SimpleDateFormat;
+import android.icu.util.Calendar;
 import android.os.Bundle;
 import android.text.TextPaint;
 import android.text.format.DateFormat;
@@ -48,7 +49,6 @@
 import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
 
 import java.text.NumberFormat;
-import java.util.Calendar;
 import java.util.Locale;
 
 import libcore.icu.LocaleData;
diff --git a/core/java/android/widget/YearPickerView.java b/core/java/android/widget/YearPickerView.java
index 96624d2..a3f5a67 100644
--- a/core/java/android/widget/YearPickerView.java
+++ b/core/java/android/widget/YearPickerView.java
@@ -16,18 +16,17 @@
 
 package android.widget;
 
+import com.android.internal.R;
+
 import android.content.Context;
 import android.content.res.Resources;
+import android.icu.util.Calendar;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityEvent;
 
-import java.util.Calendar;
-
-import com.android.internal.R;
-
 /**
  * Displays a selectable list of years.
  */
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index a5485da..70941b6 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -141,6 +141,9 @@
     // consider it a complex PIN/password.
     public static final int MAX_ALLOWED_SEQUENCE = 3;
 
+    public static final String PROFILE_KEY_NAME_ENCRYPT = "profile_key_name_encrypt_";
+    public static final String PROFILE_KEY_NAME_DECRYPT = "profile_key_name_decrypt_";
+
     private final Context mContext;
     private final ContentResolver mContentResolver;
     private DevicePolicyManager mDevicePolicyManager;
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index 30e23f5..e190bd1 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -22,296 +22,120 @@
     <!-- Do not translate. These are all of the drawable resources that should be preloaded by
          the zygote process before it starts forking application processes. -->
     <array name="preloaded_drawables">
-       <item>@drawable/toast_frame</item>
-       <item>@drawable/btn_check_on_pressed_holo_light</item>
-       <item>@drawable/btn_check_on_pressed_holo_dark</item>
-       <item>@drawable/btn_check_on_holo_light</item>
-       <item>@drawable/btn_check_on_holo_dark</item>
-       <item>@drawable/btn_check_on_focused_holo_light</item>
-       <item>@drawable/btn_check_on_focused_holo_dark</item>
-       <item>@drawable/btn_check_on_disabled_holo_light</item>
-       <item>@drawable/btn_check_on_disabled_holo_dark</item>
-       <item>@drawable/btn_check_on_disabled_focused_holo_light</item>
-       <item>@drawable/btn_check_on_disabled_focused_holo_dark</item>
-       <item>@drawable/btn_check_off_pressed_holo_light</item>
-       <item>@drawable/btn_check_off_pressed_holo_dark</item>
-       <item>@drawable/btn_check_off_holo_light</item>
-       <item>@drawable/btn_check_off_holo_dark</item>
-       <item>@drawable/btn_check_off_focused_holo_light</item>
-       <item>@drawable/btn_check_off_focused_holo_dark</item>
-       <item>@drawable/btn_check_off_disabled_holo_light</item>
-       <item>@drawable/btn_check_off_disabled_holo_dark</item>
-       <item>@drawable/btn_check_off_disabled_focused_holo_light</item>
-       <item>@drawable/btn_check_off_disabled_focused_holo_dark</item>
-       <item>@drawable/btn_check_holo_light</item>
-       <item>@drawable/btn_check_holo_dark</item>
-       <item>@drawable/btn_radio_on_pressed_holo_light</item>
-       <item>@drawable/btn_radio_on_pressed_holo_dark</item>
-       <item>@drawable/btn_radio_on_holo_light</item>
-       <item>@drawable/btn_radio_on_holo_dark</item>
-       <item>@drawable/btn_radio_on_focused_holo_light</item>
-       <item>@drawable/btn_radio_on_focused_holo_dark</item>
-       <item>@drawable/btn_radio_on_disabled_holo_light</item>
-       <item>@drawable/btn_radio_on_disabled_holo_dark</item>
-       <item>@drawable/btn_radio_on_disabled_focused_holo_light</item>
-       <item>@drawable/btn_radio_on_disabled_focused_holo_dark</item>
-       <item>@drawable/btn_radio_off_pressed_holo_light</item>
-       <item>@drawable/btn_radio_off_pressed_holo_dark</item>
-       <item>@drawable/btn_radio_off_holo_light</item>
-       <item>@drawable/btn_radio_off_holo_dark</item>
-       <item>@drawable/btn_radio_off_focused_holo_light</item>
-       <item>@drawable/btn_radio_off_focused_holo_dark</item>
-       <item>@drawable/btn_radio_off_disabled_holo_light</item>
-       <item>@drawable/btn_radio_off_disabled_holo_dark</item>
-       <item>@drawable/btn_radio_off_disabled_focused_holo_light</item>
-       <item>@drawable/btn_radio_off_disabled_focused_holo_dark</item>
-       <item>@drawable/btn_default_pressed_holo_light</item>
-       <item>@drawable/btn_default_pressed_holo_dark</item>
-       <item>@drawable/btn_default_normal_holo_light</item>
-       <item>@drawable/btn_default_normal_holo_dark</item>
-       <item>@drawable/btn_default_focused_holo_light</item>
-       <item>@drawable/btn_default_focused_holo_dark</item>
-       <item>@drawable/btn_default_disabled_holo_light</item>
-       <item>@drawable/btn_default_disabled_holo_dark</item>
-       <item>@drawable/btn_default_disabled_focused_holo_light</item>
-       <item>@drawable/btn_default_disabled_focused_holo_dark</item>
-       <item>@drawable/btn_default_holo_dark</item>
-       <item>@drawable/btn_default_holo_light</item>
-       <item>@drawable/edit_text_holo_light</item>
-       <item>@drawable/edit_text_holo_dark</item>
-       <item>@drawable/text_cursor_holo_light</item>
-       <item>@drawable/text_cursor_holo_dark</item>
-       <item>@drawable/text_edit_paste_window</item>
-       <item>@drawable/expander_close_holo_dark</item>
-       <item>@drawable/expander_close_holo_light</item>
-       <item>@drawable/expander_group_holo_dark</item>
-       <item>@drawable/expander_group_holo_light</item>
-       <item>@drawable/list_selector_holo_dark</item>
-       <item>@drawable/list_selector_holo_light</item>
-       <item>@drawable/list_section_divider_holo_light</item>
-       <item>@drawable/list_section_divider_holo_dark</item>
-       <item>@drawable/menu_dropdown_panel_holo_light</item>
-       <item>@drawable/menu_dropdown_panel_holo_dark</item>
-       <item>@drawable/menu_panel_holo_light</item>
-       <item>@drawable/menu_panel_holo_dark</item>
-       <item>@drawable/spinner_16_outer_holo</item>
-       <item>@drawable/spinner_16_inner_holo</item>
-       <item>@drawable/spinner_48_outer_holo</item>
-       <item>@drawable/spinner_48_inner_holo</item>
-       <item>@drawable/progress_bg_holo_dark</item>
-       <item>@drawable/progress_bg_holo_light</item>
-       <item>@drawable/progress_horizontal_holo_dark</item>
-       <item>@drawable/progress_horizontal_holo_light</item>
-       <item>@drawable/progress_large_holo</item>
-       <item>@drawable/progress_medium_holo</item>
-       <item>@drawable/progress_primary_holo_dark</item>
-       <item>@drawable/progress_primary_holo_light</item>
-       <item>@drawable/progress_secondary_holo_dark</item>
-       <item>@drawable/progress_secondary_holo_light</item>
-       <item>@drawable/progress_small_holo</item>
-       <item>@drawable/scrubber_progress_horizontal_holo_dark</item>
-       <item>@drawable/scrubber_progress_horizontal_holo_light</item>
-       <item>@drawable/background_holo_light</item>
-       <item>@drawable/background_holo_dark</item>
-       <item>@drawable/screen_background_dark</item>
-       <item>@drawable/screen_background_dark_transparent</item>
-       <item>@drawable/screen_background_light</item>
-       <item>@drawable/screen_background_light_transparent</item>
-       <item>@drawable/screen_background_selector_dark</item>
-       <item>@drawable/screen_background_selector_light</item>
-       <item>@drawable/scrollbar_handle_holo_dark</item>
-       <item>@drawable/scrollbar_handle_holo_light</item>
-       <item>@drawable/spinner_background_holo_dark</item>
-       <item>@drawable/spinner_background_holo_light</item>
-       <item>@drawable/spinner_ab_default_holo_dark</item>
-       <item>@drawable/spinner_ab_default_holo_light</item>
-       <item>@drawable/spinner_ab_disabled_holo_dark</item>
-       <item>@drawable/spinner_ab_disabled_holo_light</item>
-       <item>@drawable/spinner_ab_focused_holo_dark</item>
-       <item>@drawable/spinner_ab_focused_holo_light</item>
-       <item>@drawable/spinner_ab_pressed_holo_dark</item>
-       <item>@drawable/spinner_ab_pressed_holo_light</item>
-       <item>@drawable/spinner_ab_holo_dark</item>
-       <item>@drawable/spinner_ab_holo_light</item>
-       <item>@drawable/spinner_default_holo_dark</item>
-       <item>@drawable/spinner_default_holo_light</item>
-       <item>@drawable/spinner_disabled_holo_dark</item>
-       <item>@drawable/spinner_disabled_holo_light</item>
-       <item>@drawable/spinner_focused_holo_dark</item>
-       <item>@drawable/spinner_focused_holo_light</item>
-       <item>@drawable/spinner_pressed_holo_dark</item>
-       <item>@drawable/spinner_pressed_holo_light</item>
-       <item>@drawable/cab_background_bottom_holo_dark</item>
-       <item>@drawable/cab_background_top_holo_light</item>
-       <item>@drawable/cab_background_bottom_holo_light</item>
-       <item>@drawable/ic_cab_done_holo_dark</item>
-       <item>@drawable/cab_background_top_holo_dark</item>
-       <item>@drawable/ic_cab_done_holo_light</item>
-       <item>@drawable/btn_cab_done_default_holo_dark</item>
-       <item>@drawable/btn_cab_done_focused_holo_light</item>
-       <item>@drawable/btn_cab_done_default_holo_light</item>
-       <item>@drawable/btn_cab_done_pressed_holo_dark</item>
-       <item>@drawable/btn_cab_done_focused_holo_dark</item>
-       <item>@drawable/btn_cab_done_pressed_holo_light</item>
-       <item>@drawable/btn_cab_done_holo_light</item>
-       <item>@drawable/btn_cab_done_holo_dark</item>
-       <item>@drawable/ic_menu_close_clear_cancel</item>
-       <item>@drawable/ic_menu_copy_holo_dark</item>
-       <item>@drawable/ic_menu_copy_holo_light</item>
-       <item>@drawable/ic_menu_cut_holo_dark</item>
-       <item>@drawable/ic_menu_cut_holo_light</item>
-       <item>@drawable/ic_menu_more</item>
-       <item>@drawable/ic_menu_moreoverflow_holo_dark</item>
-       <item>@drawable/ic_menu_moreoverflow_holo_light</item>
-       <item>@drawable/ic_menu_paste_holo_dark</item>
-       <item>@drawable/ic_menu_paste_holo_light</item>
-       <item>@drawable/ic_menu_selectall_holo_light</item>
-       <item>@drawable/ic_menu_selectall_holo_dark</item>
-       <item>@drawable/ic_clear</item>
-       <item>@drawable/ic_clear_disabled</item>
-       <item>@drawable/ic_clear_normal</item>
-       <item>@drawable/ic_search_api_holo_dark</item>
-       <item>@drawable/ic_search_api_holo_light</item>
-       <item>@drawable/ic_go</item>
-       <item>@drawable/ic_voice_search_api_holo_dark</item>
-       <item>@drawable/ic_voice_search_api_holo_light</item>
-       <item>@drawable/dialog_bottom_holo_dark</item>
-       <item>@drawable/dialog_bottom_holo_light</item>
-       <item>@drawable/dialog_middle_holo_dark</item>
-       <item>@drawable/dialog_middle_holo_light</item>
-       <item>@drawable/dialog_top_holo_dark</item>
-       <item>@drawable/dialog_top_holo_light</item>
-       <item>@drawable/ic_dialog_alert_holo_dark</item>
-       <item>@drawable/ic_dialog_alert_holo_light</item>
-       <item>@drawable/list_divider_holo_dark</item>
-       <item>@drawable/list_divider_holo_light</item>
-       <item>@drawable/list_divider_holo_light</item>
-       <item>@drawable/ab_transparent_dark_holo</item>
-       <item>@drawable/ab_stacked_transparent_dark_holo</item>
-       <item>@drawable/ab_bottom_transparent_dark_holo</item>
-       <item>@drawable/ab_solid_dark_holo</item>
-       <item>@drawable/ab_stacked_solid_dark_holo</item>
-       <item>@drawable/ab_bottom_solid_dark_holo</item>
-       <item>@drawable/ab_transparent_light_holo</item>
-       <item>@drawable/ab_stacked_transparent_light_holo</item>
-       <item>@drawable/ab_bottom_transparent_light_holo</item>
-       <item>@drawable/ab_solid_light_holo</item>
-       <item>@drawable/ab_stacked_solid_light_holo</item>
-       <item>@drawable/ab_bottom_solid_light_holo</item>
-       <item>@drawable/ab_solid_shadow_holo</item>
-       <item>@drawable/item_background_holo_dark</item>
-       <item>@drawable/item_background_holo_light</item>
-       <item>@drawable/fastscroll_thumb_holo</item>
-       <item>@drawable/fastscroll_thumb_pressed_holo</item>
-       <item>@drawable/fastscroll_thumb_default_holo</item>
-       <item>@drawable/fastscroll_track_holo_dark</item>
-       <item>@drawable/fastscroll_track_pressed_holo_dark</item>
-       <item>@drawable/fastscroll_track_default_holo_dark</item>
-       <item>@drawable/fastscroll_track_holo_light</item>
-       <item>@drawable/fastscroll_track_pressed_holo_light</item>
-       <item>@drawable/fastscroll_track_default_holo_light</item>
-       <item>@drawable/editbox_dropdown_background_dark</item>
-       <item>@drawable/textfield_searchview_holo_dark</item>
-       <item>@drawable/textfield_searchview_right_holo_dark</item>
-       <item>@drawable/textfield_searchview_holo_light</item>
-       <item>@drawable/textfield_searchview_right_holo_light</item>
-       <item>@drawable/textfield_search_selected_holo_dark</item>
-       <item>@drawable/textfield_search_default_holo_dark</item>
-       <item>@drawable/textfield_search_right_selected_holo_dark</item>
-       <item>@drawable/textfield_search_right_default_holo_dark</item>
-       <item>@drawable/textfield_search_selected_holo_light</item>
-       <item>@drawable/textfield_search_default_holo_light</item>
-       <item>@drawable/textfield_search_right_selected_holo_light</item>
-       <item>@drawable/textfield_search_right_default_holo_light</item>
-       <item>@drawable/tab_indicator_holo</item>
-       <item>@drawable/tab_unselected_holo</item>
-       <item>@drawable/tab_selected_holo</item>
-       <item>@drawable/tab_unselected_focused_holo</item>
-       <item>@drawable/tab_selected_focused_holo</item>
-       <item>@drawable/tab_unselected_pressed_holo</item>
-       <item>@drawable/tab_selected_pressed_holo</item>
-       <item>@drawable/quickcontact_badge_overlay_dark</item>
-       <item>@drawable/quickcontact_badge_overlay_normal_dark</item>
-       <item>@drawable/quickcontact_badge_overlay_pressed_dark</item>
-       <item>@drawable/quickcontact_badge_overlay_light</item>
-       <item>@drawable/quickcontact_badge_overlay_normal_light</item>
-       <item>@drawable/quickcontact_badge_overlay_pressed_light</item>
-
-       <!-- Material assets -->
-       <item>@drawable/ab_share_pack_material</item>
-       <item>@drawable/ab_solid_shadow_material</item>
-       <item>@drawable/activated_background_material</item>
-       <item>@drawable/btn_borderless_material</item>
-       <item>@drawable/btn_check_material_anim</item>
-       <item>@drawable/btn_default_material</item>
-       <item>@drawable/btn_radio_material_anim</item>
-       <item>@drawable/btn_star_material</item>
-       <item>@drawable/btn_toggle_material</item>
-       <item>@drawable/cab_background_bottom_material</item>
-       <item>@drawable/cab_background_top_material</item>
-       <item>@drawable/dialog_background_material</item>
-       <item>@drawable/edit_text_material</item>
-       <item>@drawable/expander_group_material</item>
-       <item>@drawable/fastscroll_label_left_material</item>
-       <item>@drawable/fastscroll_label_right_material</item>
-       <item>@drawable/fastscroll_thumb_material</item>
-       <item>@drawable/fastscroll_track_material</item>
-       <item>@drawable/floating_popup_background_dark</item>
-       <item>@drawable/floating_popup_background_light</item>
-       <item>@drawable/ic_ab_back_material</item>
-       <item>@drawable/ic_ab_back_material_dark</item>
-       <item>@drawable/ic_ab_back_material_light</item>
-       <item>@drawable/ic_clear_material</item>
-       <item>@drawable/ic_commit_search_api_material</item>
-       <item>@drawable/ic_dialog_alert_material</item>
-       <item>@drawable/ic_find_next_material</item>
-       <item>@drawable/ic_find_previous_material</item>
-       <item>@drawable/ic_go_search_api_material</item>
-       <item>@drawable/ic_media_route_connecting_material</item>
-       <item>@drawable/ic_media_route_material</item>
-       <item>@drawable/ic_menu_copy_material</item>
-       <item>@drawable/ic_menu_cut_material</item>
-       <item>@drawable/ic_menu_find_material</item>
-       <item>@drawable/ic_menu_moreoverflow_material</item>
-       <item>@drawable/ic_menu_paste_material</item>
-       <item>@drawable/ic_menu_search_material</item>
-       <item>@drawable/ic_menu_selectall_material</item>
-       <item>@drawable/ic_menu_share_material</item>
-       <item>@drawable/ic_search_api_material</item>
-       <item>@drawable/ic_voice_search_api_material</item>
-       <item>@drawable/item_background_borderless_material</item>
-       <item>@drawable/item_background_borderless_material_dark</item>
-       <item>@drawable/item_background_borderless_material_light</item>
-       <item>@drawable/item_background_material</item>
-       <item>@drawable/item_background_material_dark</item>
-       <item>@drawable/item_background_material_light</item>
-       <item>@drawable/list_divider_material</item>
-       <item>@drawable/list_section_divider_material</item>
-       <item>@drawable/notification_material_action_background</item>
-       <item>@drawable/notification_material_media_action_background</item>
-       <item>@drawable/popup_background_material</item>
-       <item>@drawable/progress_horizontal_material</item>
-       <item>@drawable/progress_indeterminate_horizontal_material</item>
-       <item>@drawable/progress_large_material</item>
-       <item>@drawable/progress_medium_material</item>
-       <item>@drawable/progress_small_material</item>
-       <item>@drawable/ratingbar_material</item>
-       <item>@drawable/ratingbar_small_material</item>
-       <item>@drawable/ratingbar_indicator_material</item>
-       <item>@drawable/scrollbar_handle_material</item>
-       <item>@drawable/seekbar_thumb_material_anim</item>
-       <item>@drawable/seekbar_track_material</item>
-       <item>@drawable/spinner_background_material</item>
-       <item>@drawable/spinner_textfield_background_material</item>
-       <item>@drawable/switch_thumb_material_anim</item>
-       <item>@drawable/switch_track_material</item>
-       <item>@drawable/tab_indicator_material</item>
-       <item>@drawable/text_cursor_material</item>
-       <item>@drawable/textfield_search_material</item>
-       <item>@drawable/text_select_handle_left_material</item>
-       <item>@drawable/text_select_handle_middle_material</item>
-       <item>@drawable/text_select_handle_right_material</item>
-       <item>@drawable/ic_account_circle</item>
+        <item>@drawable/ab_share_pack_material</item>
+        <item>@drawable/ab_solid_shadow_material</item>
+        <item>@drawable/action_bar_item_background_material</item>
+        <item>@drawable/activated_background_material</item>
+        <item>@drawable/btn_borderless_material</item>
+        <item>@drawable/btn_check_material_anim</item>
+        <item>@drawable/btn_colored_material</item>
+        <item>@drawable/btn_default_material</item>
+        <item>@drawable/btn_group_holo_dark</item>
+        <item>@drawable/btn_group_holo_light</item>
+        <item>@drawable/btn_radio_material_anim</item>
+        <item>@drawable/btn_star_material</item>
+        <item>@drawable/btn_toggle_material</item>
+        <item>@drawable/button_inset</item>
+        <item>@drawable/cab_background_bottom_material</item>
+        <item>@drawable/cab_background_top_material</item>
+        <item>@drawable/control_background_32dp_material</item>
+        <item>@drawable/control_background_40dp_material</item>
+        <item>@drawable/dialog_background_material</item>
+        <item>@drawable/editbox_dropdown_background_dark</item>
+        <item>@drawable/edit_text_material</item>
+        <item>@drawable/expander_group_material</item>
+        <item>@drawable/fastscroll_label_left_material</item>
+        <item>@drawable/fastscroll_label_right_material</item>
+        <item>@drawable/fastscroll_thumb_material</item>
+        <item>@drawable/fastscroll_track_material</item>
+        <item>@drawable/floating_popup_background_dark</item>
+        <item>@drawable/floating_popup_background_light</item>
+        <item>@drawable/gallery_item_background</item>
+        <item>@drawable/ic_ab_back_material</item>
+        <item>@drawable/ic_ab_back_material_dark</item>
+        <item>@drawable/ic_ab_back_material_light</item>
+        <item>@drawable/ic_account_circle</item>
+        <item>@drawable/ic_arrow_drop_right_black_24dp</item>
+        <item>@drawable/ic_clear</item>
+        <item>@drawable/ic_clear_disabled</item>
+        <item>@drawable/ic_clear_material</item>
+        <item>@drawable/ic_clear_normal</item>
+        <item>@drawable/ic_commit_search_api_material</item>
+        <item>@drawable/ic_dialog_alert_material</item>
+        <item>@drawable/ic_find_next_material</item>
+        <item>@drawable/ic_find_previous_material</item>
+        <item>@drawable/ic_go</item>
+        <item>@drawable/ic_go_search_api_material</item>
+        <item>@drawable/ic_media_route_connecting_material</item>
+        <item>@drawable/ic_media_route_material</item>
+        <item>@drawable/ic_menu_close_clear_cancel</item>
+        <item>@drawable/ic_menu_copy_material</item>
+        <item>@drawable/ic_menu_cut_material</item>
+        <item>@drawable/ic_menu_find_material</item>
+        <item>@drawable/ic_menu_more</item>
+        <item>@drawable/ic_menu_moreoverflow_material</item>
+        <item>@drawable/ic_menu_paste_material</item>
+        <item>@drawable/ic_menu_search_material</item>
+        <item>@drawable/ic_menu_selectall_material</item>
+        <item>@drawable/ic_menu_share_material</item>
+        <item>@drawable/ic_search_api_material</item>
+        <item>@drawable/ic_voice_search_api_material</item>
+        <item>@drawable/indicator_check_mark_dark</item>
+        <item>@drawable/indicator_check_mark_light</item>
+        <item>@drawable/item_background_borderless_material</item>
+        <item>@drawable/item_background_borderless_material_dark</item>
+        <item>@drawable/item_background_borderless_material_light</item>
+        <item>@drawable/item_background_material</item>
+        <item>@drawable/item_background_material_dark</item>
+        <item>@drawable/item_background_material_light</item>
+        <item>@drawable/list_choice_background_material</item>
+        <item>@drawable/list_divider_material</item>
+        <item>@drawable/list_section_divider_material</item>
+        <item>@drawable/menu_background_fill_parent_width</item>
+        <item>@drawable/notification_material_action_background</item>
+        <item>@drawable/notification_material_media_action_background</item>
+        <item>@drawable/number_picker_divider_material</item>
+        <item>@drawable/popup_background_material</item>
+        <item>@drawable/popup_inline_error_above_holo_dark</item>
+        <item>@drawable/popup_inline_error_above_holo_light</item>
+        <item>@drawable/popup_inline_error_holo_dark</item>
+        <item>@drawable/popup_inline_error_holo_light</item>
+        <item>@drawable/progress_horizontal_material</item>
+        <item>@drawable/progress_indeterminate_horizontal_material</item>
+        <item>@drawable/progress_large_material</item>
+        <item>@drawable/progress_medium_material</item>
+        <item>@drawable/progress_small_material</item>
+        <item>@drawable/quickcontact_badge_overlay_dark</item>
+        <item>@drawable/quickcontact_badge_overlay_light</item>
+        <item>@drawable/quickcontact_badge_overlay_normal_dark</item>
+        <item>@drawable/quickcontact_badge_overlay_normal_light</item>
+        <item>@drawable/quickcontact_badge_overlay_pressed_dark</item>
+        <item>@drawable/quickcontact_badge_overlay_pressed_light</item>
+        <item>@drawable/ratingbar_indicator_material</item>
+        <item>@drawable/ratingbar_material</item>
+        <item>@drawable/ratingbar_small_material</item>
+        <item>@drawable/screen_background_dark</item>
+        <item>@drawable/screen_background_dark_transparent</item>
+        <item>@drawable/screen_background_light</item>
+        <item>@drawable/screen_background_light_transparent</item>
+        <item>@drawable/screen_background_selector_dark</item>
+        <item>@drawable/screen_background_selector_light</item>
+        <item>@drawable/scrollbar_handle_material</item>
+        <item>@drawable/seekbar_thumb_material_anim</item>
+        <item>@drawable/seekbar_tick_mark_material</item>
+        <item>@drawable/seekbar_track_material</item>
+        <item>@drawable/spinner_background_material</item>
+        <item>@drawable/spinner_textfield_background_material</item>
+        <item>@drawable/switch_thumb_material_anim</item>
+        <item>@drawable/switch_track_material</item>
+        <item>@drawable/tab_indicator_material</item>
+        <item>@drawable/text_cursor_material</item>
+        <item>@drawable/text_edit_paste_window</item>
+        <item>@drawable/textfield_search_material</item>
+        <item>@drawable/text_select_handle_left_material</item>
+        <item>@drawable/text_select_handle_middle_material</item>
+        <item>@drawable/text_select_handle_right_material</item>
+        <item>@drawable/toast_frame</item>
     </array>
 
     <!-- Do not translate. These are all of the color state list resources that should be
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 45ee778..2232942 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -4318,6 +4318,6 @@
     <string name="audit_safemode_notification_details">Touch to learn more.</string>
 
     <!-- Accessibilty string added to a widget that has been suspended [CHAR LIMIT=20] -->
-    <string name="suspended_widget_accessibility">Suspended <xliff:g id="label" example="Calendar">%1$s</xliff:g></string>
+    <string name="suspended_widget_accessibility">Disabled <xliff:g id="label" example="Calendar">%1$s</xliff:g></string>
 
 </resources>
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index c67b008..1864206 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -104,6 +104,9 @@
     private Rect mHotspotBounds;
     private boolean mMutated;
 
+    private boolean mSuspendChildInvalidation;
+    private boolean mChildRequestedInvalidation;
+
     /**
      * Creates a new layer drawable with the list of specified layers.
      *
@@ -944,9 +947,37 @@
       return mLayerState.mPaddingMode;
     }
 
+    /**
+     * Temporarily suspends child invalidation.
+     *
+     * @see #resumeChildInvalidation()
+     */
+    private void suspendChildInvalidation() {
+        mSuspendChildInvalidation = true;
+    }
+
+    /**
+     * Resumes child invalidation after suspension, immediately performing an
+     * invalidation if one was requested by a child during suspension.
+     *
+     * @see #suspendChildInvalidation()
+     */
+    private void resumeChildInvalidation() {
+        mSuspendChildInvalidation = false;
+
+        if (mChildRequestedInvalidation) {
+            mChildRequestedInvalidation = false;
+            invalidateSelf();
+        }
+    }
+
     @Override
     public void invalidateDrawable(@NonNull Drawable who) {
-        invalidateSelf();
+        if (mSuspendChildInvalidation) {
+            mChildRequestedInvalidation = true;
+        } else {
+            invalidateSelf();
+        }
     }
 
     @Override
@@ -1482,6 +1513,15 @@
     }
 
     private void updateLayerBounds(Rect bounds) {
+        try {
+            suspendChildInvalidation();
+            updateLayerBoundsInternal(bounds);
+        } finally {
+            resumeChildInvalidation();
+        }
+    }
+
+    private void updateLayerBoundsInternal(Rect bounds) {
         int paddingL = 0;
         int paddingT = 0;
         int paddingR = 0;
diff --git a/libs/hwui/FrameBuilder.cpp b/libs/hwui/FrameBuilder.cpp
index 746e99a..cb8e55f 100644
--- a/libs/hwui/FrameBuilder.cpp
+++ b/libs/hwui/FrameBuilder.cpp
@@ -878,11 +878,49 @@
 
     restoreForLayer();
 
+    // saveLayer will clip & translate the draw contents, so we need
+    // to translate the drawLayer by how much the contents was translated
+    // TODO: Unify this with beginLayerOp so we don't have to calculate this
+    // twice
+    uint32_t layerWidth = (uint32_t) beginLayerOp.unmappedBounds.getWidth();
+    uint32_t layerHeight = (uint32_t) beginLayerOp.unmappedBounds.getHeight();
+
+    auto previous = mCanvasState.currentSnapshot();
+    Vector3 lightCenter = previous->getRelativeLightCenter();
+
+    // Combine all transforms used to present saveLayer content:
+    // parent content transform * canvas transform * bounds offset
+    Matrix4 contentTransform(*(previous->transform));
+    contentTransform.multiply(beginLayerOp.localMatrix);
+    contentTransform.translate(beginLayerOp.unmappedBounds.left,
+            beginLayerOp.unmappedBounds.top);
+
+    Matrix4 inverseContentTransform;
+    inverseContentTransform.loadInverse(contentTransform);
+
+    // map the light center into layer-relative space
+    inverseContentTransform.mapPoint3d(lightCenter);
+
+    // Clip bounds of temporary layer to parent's clip rect, so:
+    Rect saveLayerBounds(layerWidth, layerHeight);
+    //     1) transform Rect(width, height) into parent's space
+    //        note: left/top offsets put in contentTransform above
+    contentTransform.mapRect(saveLayerBounds);
+    //     2) intersect with parent's clip
+    saveLayerBounds.doIntersect(previous->getRenderTargetClip());
+    //     3) and transform back
+    inverseContentTransform.mapRect(saveLayerBounds);
+    saveLayerBounds.doIntersect(Rect(layerWidth, layerHeight));
+    saveLayerBounds.roundOut();
+
+    Matrix4 localMatrix(beginLayerOp.localMatrix);
+    localMatrix.translate(saveLayerBounds.left, saveLayerBounds.top);
+
     // record the draw operation into the previous layer's list of draw commands
     // uses state from the associated beginLayerOp, since it has all the state needed for drawing
     LayerOp* drawLayerOp = mAllocator.create_trivial<LayerOp>(
             beginLayerOp.unmappedBounds,
-            beginLayerOp.localMatrix,
+            localMatrix,
             beginLayerOp.localClip,
             beginLayerOp.paint,
             &(mLayerBuilders[finishedLayerIndex]->offscreenBuffer));
diff --git a/libs/hwui/OpDumper.cpp b/libs/hwui/OpDumper.cpp
index cab93e8..ec9ffde 100644
--- a/libs/hwui/OpDumper.cpp
+++ b/libs/hwui/OpDumper.cpp
@@ -45,5 +45,9 @@
     }
 }
 
+const char* OpDumper::opName(const RecordedOp& op) {
+    return sOpNameLut[op.opId];
+}
+
 } // namespace uirenderer
 } // namespace android
diff --git a/libs/hwui/OpDumper.h b/libs/hwui/OpDumper.h
index c99b517..a82289c 100644
--- a/libs/hwui/OpDumper.h
+++ b/libs/hwui/OpDumper.h
@@ -26,6 +26,7 @@
 class OpDumper {
 public:
     static void dump(const RecordedOp& op, std::ostream& output, int level = 0);
+    static const char* opName(const RecordedOp& op);
 };
 
 }; // namespace uirenderer
diff --git a/libs/hwui/tests/unit/FrameBuilderTests.cpp b/libs/hwui/tests/unit/FrameBuilderTests.cpp
index 0f16b15..af1fbd8 100644
--- a/libs/hwui/tests/unit/FrameBuilderTests.cpp
+++ b/libs/hwui/tests/unit/FrameBuilderTests.cpp
@@ -2025,6 +2025,7 @@
     uint32_t layerHeight = 0;
     Rect rectClippedBounds;
     Matrix4 rectMatrix;
+    Matrix4 drawLayerMatrix;
 };
 /**
  * Constructs a view to hit the temporary layer alpha property implementation:
@@ -2060,6 +2061,7 @@
         }
         void onLayerOp(const LayerOp& op, const BakedOpState& state) override {
             EXPECT_EQ(3, mIndex++);
+            mOutData->drawLayerMatrix = state.computedState.transform;
         }
         void recycleTemporaryLayer(OffscreenBuffer* offscreenBuffer) override {
             EXPECT_EQ(4, mIndex++);
@@ -2108,6 +2110,9 @@
     expected.loadTranslate(0, -2000, 0);
     EXPECT_MATRIX_APPROX_EQ(expected, observedData.rectMatrix)
             << "expect content to be translated as part of being clipped";
+    expected.loadTranslate(10, 0, 0);
+    EXPECT_MATRIX_APPROX_EQ(expected, observedData.drawLayerMatrix)
+                << "expect drawLayer to be translated as part of being clipped";
 }
 
 RENDERTHREAD_TEST(FrameBuilder, renderPropSaveLayerAlphaRotate) {
diff --git a/packages/SystemUI/res/layout/qs_customize_panel_content.xml b/packages/SystemUI/res/layout/qs_customize_panel_content.xml
index 6438564..ca0248e 100644
--- a/packages/SystemUI/res/layout/qs_customize_panel_content.xml
+++ b/packages/SystemUI/res/layout/qs_customize_panel_content.xml
@@ -35,6 +35,7 @@
         android:importantForAccessibility="no" />
 
     <View
+        android:id="@+id/nav_bar_background"
         android:layout_width="match_parent"
         android:layout_height="@dimen/navigation_bar_size"
         android:layout_gravity="bottom"
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
index 61933b4..4bf85c7 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
@@ -19,6 +19,7 @@
 import android.animation.Animator.AnimatorListener;
 import android.animation.AnimatorListenerAdapter;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.support.v7.widget.DefaultItemAnimator;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
@@ -103,6 +104,17 @@
         mRecyclerView.setItemAnimator(animator);
     }
 
+    @Override
+    protected void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        View navBackdrop = findViewById(R.id.nav_bar_background);
+        if (navBackdrop != null) {
+            boolean shouldShow = newConfig.smallestScreenWidthDp >= 600
+                    || newConfig.orientation != Configuration.ORIENTATION_LANDSCAPE;
+            navBackdrop.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
+        }
+    }
+
     public void setHost(QSTileHost host) {
         mHost = host;
         mPhoneStatusBar = host.getPhoneStatusBar();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
index 61a92b4..60c24d0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
@@ -286,10 +286,11 @@
     private void selectPosition(int position, View v) {
         // Remove the placeholder.
         mAccessibilityMoving = false;
-        move(mAccessibilityFromIndex, position, v);
-        mTiles.remove(mEditIndex);
+        mTiles.remove(mEditIndex--);
         notifyItemRemoved(mEditIndex - 1);
+        move(mAccessibilityFromIndex, position, v);
         updateDividerLocations();
+        notifyDataSetChanged();
         saveSpecs(mHost);
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
index 212f179..16b1158 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
@@ -81,6 +81,8 @@
     private IQSService mService;
     private boolean mUnbindImmediate;
     private TileChangeListener mChangeListener;
+    // Return value from bindServiceAsUser, determines whether safe to call unbind.
+    private boolean mIsBound;
 
     public TileLifecycleManager(Handler handler, Context context, Intent intent, UserHandle user) {
         mContext = context;
@@ -132,7 +134,7 @@
             }
             if (DEBUG) Log.d(TAG, "Binding service " + mIntent + " " + mUser);
             mBindTryCount++;
-            mContext.bindServiceAsUser(mIntent, this,
+            mIsBound = mContext.bindServiceAsUser(mIntent, this,
                     Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
                     mUser);
         } else {
@@ -140,7 +142,10 @@
             // Give it another chance next time it needs to be bound, out of kindness.
             mBindTryCount = 0;
             mWrapper = null;
-            mContext.unbindService(this);
+            if (mIsBound) {
+                mContext.unbindService(this);
+                mIsBound = false;
+            }
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 6a37099..522f250 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -220,6 +220,20 @@
         super.onFinishInflate();
         mKeyguardStatusBar = (KeyguardStatusBarView) findViewById(R.id.keyguard_header);
         mKeyguardStatusView = (KeyguardStatusView) findViewById(R.id.keyguard_status_view);
+        mClockView = (TextView) findViewById(R.id.clock_view);
+
+        mNotificationContainerParent = (NotificationsQuickSettingsContainer)
+                findViewById(R.id.notification_container_parent);
+        mNotificationStackScroller = (NotificationStackScrollLayout)
+                findViewById(R.id.notification_stack_scroller);
+        mNotificationStackScroller.setOnHeightChangedListener(this);
+        mNotificationStackScroller.setOverscrollTopChangedListener(this);
+        mNotificationStackScroller.setOnEmptySpaceClickListener(this);
+        mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
+        mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim);
+        mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext());
+        mLastOrientation = getResources().getConfiguration().orientation;
+
         mQsAutoReinflateContainer =
                 (AutoReinflateContainer) findViewById(R.id.qs_auto_reinflate_container);
         mQsAutoReinflateContainer.addInflateListener(new InflateListener() {
@@ -229,32 +243,20 @@
                 mQsContainer.setPanelView(NotificationPanelView.this);
                 mQsContainer.getHeader().findViewById(R.id.expand_indicator)
                         .setOnClickListener(NotificationPanelView.this);
-            }
-        });
-        mClockView = (TextView) findViewById(R.id.clock_view);
-        mNotificationContainerParent = (NotificationsQuickSettingsContainer)
-                findViewById(R.id.notification_container_parent);
-        mNotificationStackScroller = (NotificationStackScrollLayout)
-                findViewById(R.id.notification_stack_scroller);
-        mNotificationStackScroller.setOnHeightChangedListener(this);
-        mNotificationStackScroller.setOverscrollTopChangedListener(this);
-        mNotificationStackScroller.setOnEmptySpaceClickListener(this);
-        mNotificationStackScroller.setQsContainer(mQsContainer);
-        mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
-        mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim);
-        mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext());
-        mLastOrientation = getResources().getConfiguration().orientation;
 
-        // recompute internal state when qspanel height changes
-        mQsContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() {
-            @Override
-            public void onLayoutChange(View v, int left, int top, int right, int bottom,
-                    int oldLeft, int oldTop, int oldRight, int oldBottom) {
-                final int height = bottom - top;
-                final int oldHeight = oldBottom - oldTop;
-                if (height != oldHeight) {
-                    onQsHeightChanged();
-                }
+                // recompute internal state when qspanel height changes
+                mQsContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() {
+                    @Override
+                    public void onLayoutChange(View v, int left, int top, int right, int bottom,
+                            int oldLeft, int oldTop, int oldRight, int oldBottom) {
+                        final int height = bottom - top;
+                        final int oldHeight = oldBottom - oldTop;
+                        if (height != oldHeight) {
+                            onQsHeightChanged();
+                        }
+                    }
+                });
+                mNotificationStackScroller.setQsContainer(mQsContainer);
             }
         });
     }
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index 4477e8b..1d8bb6b 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -43,6 +43,7 @@
 import android.database.sqlite.SQLiteDatabase;
 import android.os.Binder;
 import android.os.Bundle;
+import android.os.Handler;
 import android.os.IBinder;
 import android.os.IProgressListener;
 import android.os.Parcel;
@@ -111,13 +112,12 @@
     private static final int FBE_ENCRYPTED_NOTIFICATION = 0;
     private static final boolean DEBUG = false;
 
-    private static final String PROFILE_KEY_NAME_ENCRYPT = "profile_key_name_encrypt_";
-    private static final String PROFILE_KEY_NAME_DECRYPT = "profile_key_name_decrypt_";
     private static final int PROFILE_KEY_IV_SIZE = 12;
     private static final String SEPARATE_PROFILE_CHALLENGE_KEY = "lockscreen.profilechallenge";
     private final Object mSeparateChallengeLock = new Object();
 
     private final Context mContext;
+    private final Handler mHandler;
     private final LockSettingsStorage mStorage;
     private final LockSettingsStrongAuth mStrongAuth;
     private final SynchronizedStrongAuthTracker mStrongAuthTracker;
@@ -244,6 +244,7 @@
 
     public LockSettingsService(Context context) {
         mContext = context;
+        mHandler = new Handler();
         mStrongAuth = new LockSettingsStrongAuth(context);
         // Open the database
 
@@ -367,10 +368,20 @@
         hideEncryptionNotification(new UserHandle(userId));
     }
 
-    public void onUnlockUser(int userId) {
+    public void onUnlockUser(final int userId) {
         // Hide notification first, as tie managed profile lock takes time
         hideEncryptionNotification(new UserHandle(userId));
-        tieManagedProfileLockIfNecessary(userId, null);
+
+        if (mUserManager.getUserInfo(userId).isManagedProfile()) {
+            // As tieManagedProfileLockIfNecessary() may try to unlock user, we should not do it
+            // in onUnlockUser() synchronously, otherwise it may cause a deadlock
+            mHandler.post(new Runnable() {
+                @Override
+                public void run() {
+                    tieManagedProfileLockIfNecessary(userId, null);
+                }
+            });
+        }
 
         // Now we have unlocked the parent user we should show notifications
         // about any profiles that exist.
@@ -687,7 +698,7 @@
         java.security.KeyStore keyStore = java.security.KeyStore.getInstance("AndroidKeyStore");
         keyStore.load(null);
         SecretKey decryptionKey = (SecretKey) keyStore.getKey(
-                PROFILE_KEY_NAME_DECRYPT + userId, null);
+                LockPatternUtils.PROFILE_KEY_NAME_DECRYPT + userId, null);
 
         Cipher cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/"
                 + KeyProperties.BLOCK_MODE_GCM + "/" + KeyProperties.ENCRYPTION_PADDING_NONE);
@@ -734,12 +745,6 @@
             }
         };
 
-        // Turn off quite mode if it's enabled, only managed profile can return true for now, it
-        // will return false if it is not a managed profile.
-        if (mUserManager.isQuietModeEnabled(new UserHandle(userId))) {
-            mUserManager.setQuietModeEnabled(userId, false);
-        }
-
         try {
             ActivityManagerNative.getDefault().unlockUser(userId, token, secret, listener);
         } catch (RemoteException e) {
@@ -758,7 +763,6 @@
                     // Unlock managed profile with unified lock
                     if (pi.isManagedProfile()
                             && !mLockPatternUtils.isSeparateProfileChallengeEnabled(pi.id)
-                            && !pi.isQuietModeEnabled()
                             && mStorage.hasChildProfileLock(pi.id)) {
                         unlockChildProfile(pi.id);
                     }
@@ -976,14 +980,14 @@
             java.security.KeyStore keyStore = java.security.KeyStore.getInstance("AndroidKeyStore");
             keyStore.load(null);
             keyStore.setEntry(
-                    PROFILE_KEY_NAME_ENCRYPT + userId,
+                    LockPatternUtils.PROFILE_KEY_NAME_ENCRYPT + userId,
                     new java.security.KeyStore.SecretKeyEntry(secretKey),
                     new KeyProtection.Builder(KeyProperties.PURPOSE_ENCRYPT)
                             .setBlockModes(KeyProperties.BLOCK_MODE_GCM)
                             .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
                             .build());
             keyStore.setEntry(
-                    PROFILE_KEY_NAME_DECRYPT + userId,
+                    LockPatternUtils.PROFILE_KEY_NAME_DECRYPT + userId,
                     new java.security.KeyStore.SecretKeyEntry(secretKey),
                     new KeyProtection.Builder(KeyProperties.PURPOSE_DECRYPT)
                             .setBlockModes(KeyProperties.BLOCK_MODE_GCM)
@@ -994,7 +998,7 @@
 
             // Key imported, obtain a reference to it.
             SecretKey keyStoreEncryptionKey = (SecretKey) keyStore.getKey(
-                    PROFILE_KEY_NAME_ENCRYPT + userId, null);
+                    LockPatternUtils.PROFILE_KEY_NAME_ENCRYPT + userId, null);
             // The original key can now be discarded.
 
             Cipher cipher = Cipher.getInstance(
@@ -1393,8 +1397,8 @@
         try {
             java.security.KeyStore keyStore = java.security.KeyStore.getInstance("AndroidKeyStore");
             keyStore.load(null);
-            keyStore.deleteEntry(PROFILE_KEY_NAME_ENCRYPT + targetUserId);
-            keyStore.deleteEntry(PROFILE_KEY_NAME_DECRYPT + targetUserId);
+            keyStore.deleteEntry(LockPatternUtils.PROFILE_KEY_NAME_ENCRYPT + targetUserId);
+            keyStore.deleteEntry(LockPatternUtils.PROFILE_KEY_NAME_DECRYPT + targetUserId);
         } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException
                 | IOException e) {
             // We have tried our best to remove all keys
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 595d086..67f96d8 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -938,6 +938,17 @@
     boolean unlockUserCleared(final int userId, byte[] token, byte[] secret,
             IProgressListener listener) {
         synchronized (mService) {
+            // TODO Move this block outside of synchronized if it causes lock contention
+            if (!StorageManager.isUserKeyUnlocked(userId)) {
+                final UserInfo userInfo = getUserInfo(userId);
+                final IMountService mountService = getMountService();
+                try {
+                    // We always want to unlock user storage, even user is not started yet
+                    mountService.unlockUserKey(userId, userInfo.serialNumber, token, secret);
+                } catch (RemoteException | RuntimeException e) {
+                    Slog.w(TAG, "Failed to unlock: " + e.getMessage());
+                }
+            }
             // Bail if user isn't actually running, otherwise register the given
             // listener to watch for unlock progress
             final UserState uss = mStartedUsers.get(userId);
@@ -948,19 +959,6 @@
                 uss.mUnlockProgress.addListener(listener);
             }
 
-            // TODO Move this block outside of synchronized if it causes lock contention
-            if (!StorageManager.isUserKeyUnlocked(userId)) {
-                final UserInfo userInfo = getUserInfo(userId);
-                final IMountService mountService = getMountService();
-                try {
-                    mountService.unlockUserKey(userId, userInfo.serialNumber, token, secret);
-                } catch (RemoteException | RuntimeException e) {
-                    Slog.w(TAG, "Failed to unlock: " + e.getMessage());
-                    notifyFinished(userId, listener);
-                    return false;
-                }
-            }
-
             finishUserUnlocking(uss);
 
             // We just unlocked a user, so let's now attempt to unlock any
diff --git a/services/core/java/com/android/server/notification/ScheduleConditionProvider.java b/services/core/java/com/android/server/notification/ScheduleConditionProvider.java
index 15a63ec..e3dcf14 100644
--- a/services/core/java/com/android/server/notification/ScheduleConditionProvider.java
+++ b/services/core/java/com/android/server/notification/ScheduleConditionProvider.java
@@ -36,6 +36,7 @@
 import com.android.server.notification.NotificationManagerService.DumpFilter;
 
 import java.io.PrintWriter;
+import java.util.Calendar;
 import java.util.TimeZone;
 
 /**
@@ -237,6 +238,14 @@
         @Override
         public void onReceive(Context context, Intent intent) {
             if (DEBUG) Slog.d(TAG, "onReceive " + intent.getAction());
+            if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
+                for (Uri conditionId : mSubscriptions.keySet()) {
+                    final ScheduleCalendar cal = mSubscriptions.get(conditionId);
+                    if (cal != null) {
+                        cal.setTimeZone(Calendar.getInstance().getTimeZone());
+                    }
+                }
+            }
             evaluateSubscriptions();
         }
     };
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index b773a4e..f57e83aa 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -451,6 +451,16 @@
         destroySurfaces();
     }
 
+    void markSavedSurfaceExiting() {
+        for (int i = allAppWindows.size() - 1; i >= 0; i--) {
+            final WindowState w = allAppWindows.get(i);
+            if (w.isAnimatingInvisibleWithSavedSurface()) {
+                w.mAnimatingExit = true;
+                w.mWinAnimator.mAnimating = true;
+            }
+        }
+    }
+
     void restoreSavedSurfaces() {
         if (!canRestoreSurfaces()) {
             clearVisibleBeforeClientHidden();
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index aaed8ca..d363712 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2277,6 +2277,19 @@
         }
     }
 
+    private void setupWindowForRemoveOnExit(WindowState win) {
+        win.mRemoveOnExit = true;
+        win.setDisplayLayoutNeeded();
+        // Request a focus update as this window's input channel is already gone. Otherwise
+        // we could have no focused window in input manager.
+        final boolean focusChanged = updateFocusedWindowLocked(
+                UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/);
+        mWindowPlacerLocked.performSurfacePlacement();
+        if (focusChanged) {
+            mInputMonitor.updateInputWindowsLw(false /*force*/);
+        }
+    }
+
     public void removeWindow(Session session, IWindow client) {
         synchronized(mWindowMap) {
             WindowState win = windowForClientLocked(session, client, false);
@@ -2358,14 +2371,7 @@
                 // Do not set mAnimatingExit to true here, it will cause the surface to be hidden
                 // immediately after the enter animation is done. If the app is not yet drawn then
                 // it will show up as a flicker.
-                win.mRemoveOnExit = true;
-                // Request a focus update as this window's input channel is already gone. Otherwise
-                // we could have no focused window in input manager.
-                final boolean focusChanged = updateFocusedWindowLocked(
-                        UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/);
-                if (focusChanged) {
-                    mInputMonitor.updateInputWindowsLw(false /*force*/);
-                }
+                setupWindowForRemoveOnExit(win);
                 Binder.restoreCallingIdentity(origId);
                 return;
             }
@@ -2417,17 +2423,10 @@
                 // The exit animation is running or should run... wait for it!
                 if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                         "Not removing " + win + " due to exit animation ");
-                win.mRemoveOnExit = true;
-                win.setDisplayLayoutNeeded();
-                final boolean focusChanged = updateFocusedWindowLocked(
-                        UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/);
-                mWindowPlacerLocked.performSurfacePlacement();
+                setupWindowForRemoveOnExit(win);
                 if (appToken != null) {
                     appToken.updateReportedVisibilityLocked();
                 }
-                if (focusChanged) {
-                    mInputMonitor.updateInputWindowsLw(false /*force*/);
-                }
                 Binder.restoreCallingIdentity(origId);
                 return;
             }
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index c15afb3..be27c82 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2111,7 +2111,9 @@
     void clearHasSavedSurface() {
         mSurfaceSaved = false;
         mAnimatingWithSavedSurface = false;
-        mWasVisibleBeforeClientHidden = false;
+        if (mWasVisibleBeforeClientHidden) {
+            mAppToken.destroySavedSurfaces();
+        }
     }
 
     boolean clearAnimatingWithSavedSurface() {
diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
index 308b24d..4148cd0 100644
--- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
+++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
@@ -1301,6 +1301,14 @@
         appsCount = mService.mClosingApps.size();
         for (int i = 0; i < appsCount; i++) {
             AppWindowToken wtoken = mService.mClosingApps.valueAt(i);
+
+            // If we still have some windows animating with saved surfaces that's
+            // either invisible or already removed, mark them exiting so that they
+            // are disposed of after the exit animation. These are not supposed to
+            // be shown, or are delayed removal until app is actually drawn (in which
+            // case the window will be removed after the animation).
+            wtoken.markSavedSurfaceExiting();
+
             final AppWindowAnimator appAnimator = wtoken.mAppAnimator;
             if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now closing app " + wtoken);
             appAnimator.clearThumbnail();
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index c1913de..1af9ccb 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3810,14 +3810,13 @@
             // If caller has PO (or DO) it can change the password, so see if that's the case first.
             ActiveAdmin admin = getActiveAdminWithPolicyForUidLocked(
                     null, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER, callingUid);
+            final boolean preN = getTargetSdk(admin.info.getPackageName(),
+                    userHandle) <= android.os.Build.VERSION_CODES.M;
             if (admin == null) {
                 // Otherwise, make sure the caller has any active admin with the right policy.
                 admin = getActiveAdminForCallerLocked(null,
                         DeviceAdminInfo.USES_POLICY_RESET_PASSWORD);
 
-                final boolean preN = getTargetSdk(admin.info.getPackageName(), userHandle)
-                        <= android.os.Build.VERSION_CODES.M;
-
                 // As of N, password resetting to empty/null is not allowed anymore.
                 // TODO Should we allow DO/PO to set an empty password?
                 if (TextUtils.isEmpty(password)) {
@@ -3838,6 +3837,30 @@
                     }
                 }
             }
+            // Do not allow to reset password when current user has a managed profile
+            if (!isManagedProfile(userHandle)) {
+                for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) {
+                    if (userInfo.isManagedProfile()) {
+                        if (!preN) {
+                            throw new IllegalStateException(
+                                    "Cannot reset password on user has managed profile");
+                        } else {
+                            Slog.e(LOG_TAG, "Cannot reset password on user has managed profile");
+                            return false;
+                        }
+                    }
+                }
+            }
+            // Do not allow to reset password when user is locked
+            if (!mUserManager.isUserUnlocked(userHandle)) {
+                if (!preN) {
+                    throw new IllegalStateException("Cannot reset password when user is locked");
+                } else {
+                    Slog.e(LOG_TAG, "Cannot reset password when user is locked");
+                    return false;
+                }
+            }
+
             quality = getPasswordQuality(null, userHandle, /* parent */ false);
             if (quality == DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
                 quality = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index e306d89..eed4351 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -176,7 +176,7 @@
      * visual content.
      */
     private static final int DEFAULT_SYSTEM_THEME =
-            com.android.internal.R.style.Theme_Material_Light_DarkActionBar;
+            com.android.internal.R.style.Theme_DeviceDefault_Light_DarkActionBar;
 
     private final int mFactoryTestMode;
     private Timer mProfilerSnapshotTimer;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
index cbd0415..1afd90d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
@@ -23,6 +23,7 @@
 import com.android.ide.common.rendering.api.StyleResourceValue;
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.android.RenderParamsFlags;
 import com.android.layoutlib.bridge.bars.AppCompatActionBar;
 import com.android.layoutlib.bridge.bars.BridgeActionBar;
 import com.android.layoutlib.bridge.bars.Config;
@@ -232,8 +233,10 @@
 
     private BridgeActionBar createActionBar(@NonNull BridgeContext context,
             @NonNull SessionParams params) {
+        boolean isMenu = "menu".equals(params.getFlag(RenderParamsFlags.FLAG_KEY_ROOT_TAG));
+
         BridgeActionBar actionBar;
-        if (mBuilder.isThemeAppCompat()) {
+        if (mBuilder.isThemeAppCompat() && !isMenu) {
             actionBar = new AppCompatActionBar(context, params);
         } else {
             actionBar = new FrameworkActionBar(context, params);