Merge "New AndroidKeyStore API in android.security.keystore." into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index 06bc66d..fac703e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3572,7 +3572,6 @@
     method public int getMemoryClass();
     method public void getMemoryInfo(android.app.ActivityManager.MemoryInfo);
     method public static void getMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo);
-    method public int getPackageImportance(java.lang.String);
     method public android.os.Debug.MemoryInfo[] getProcessMemoryInfo(int[]);
     method public java.util.List<android.app.ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState();
     method public deprecated java.util.List<android.app.ActivityManager.RecentTaskInfo> getRecentTasks(int, int) throws java.lang.SecurityException;
@@ -5750,7 +5749,7 @@
     method public void setCameraDisabled(android.content.ComponentName, boolean);
     method public void setCertInstallerPackage(android.content.ComponentName, java.lang.String) throws java.lang.SecurityException;
     method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
-    method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
+    method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
     method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
     method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
     method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
@@ -15340,6 +15339,7 @@
     method public final void reset();
     method public void setCallback(android.media.MediaCodec.Callback, android.os.Handler);
     method public void setCallback(android.media.MediaCodec.Callback);
+    method public void setInputSurface(android.view.Surface);
     method public void setOnFrameRenderedListener(android.media.MediaCodec.OnFrameRenderedListener, android.os.Handler);
     method public final void setParameters(android.os.Bundle);
     method public void setSurface(android.view.Surface);
@@ -15347,7 +15347,6 @@
     method public final void signalEndOfInputStream();
     method public final void start();
     method public final void stop();
-    method public void usePersistentInputSurface(android.view.Surface);
     field public static final int BUFFER_FLAG_CODEC_CONFIG = 2; // 0x2
     field public static final int BUFFER_FLAG_END_OF_STREAM = 4; // 0x4
     field public static final int BUFFER_FLAG_KEY_FRAME = 1; // 0x1
@@ -16196,6 +16195,7 @@
     method public void setAudioSource(int) throws java.lang.IllegalStateException;
     method public deprecated void setCamera(android.hardware.Camera);
     method public void setCaptureRate(double);
+    method public void setInputSurface(android.view.Surface);
     method public void setLocation(float, float);
     method public void setMaxDuration(int) throws java.lang.IllegalArgumentException;
     method public void setMaxFileSize(long) throws java.lang.IllegalArgumentException;
@@ -16214,7 +16214,6 @@
     method public void setVideoSource(int) throws java.lang.IllegalStateException;
     method public void start() throws java.lang.IllegalStateException;
     method public void stop() throws java.lang.IllegalStateException;
-    method public void usePersistentSurface(android.view.Surface);
     field public static final int MEDIA_ERROR_SERVER_DIED = 100; // 0x64
     field public static final int MEDIA_RECORDER_ERROR_UNKNOWN = 1; // 0x1
     field public static final int MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800; // 0x320
diff --git a/api/system-current.txt b/api/system-current.txt
index 64793bc..2318704 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3660,7 +3660,6 @@
     method public int getMemoryClass();
     method public void getMemoryInfo(android.app.ActivityManager.MemoryInfo);
     method public static void getMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo);
-    method public int getPackageImportance(java.lang.String);
     method public android.os.Debug.MemoryInfo[] getProcessMemoryInfo(int[]);
     method public java.util.List<android.app.ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState();
     method public deprecated java.util.List<android.app.ActivityManager.RecentTaskInfo> getRecentTasks(int, int) throws java.lang.SecurityException;
@@ -5856,7 +5855,7 @@
     method public void setCameraDisabled(android.content.ComponentName, boolean);
     method public void setCertInstallerPackage(android.content.ComponentName, java.lang.String) throws java.lang.SecurityException;
     method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
-    method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
+    method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
     method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
     method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
     method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
@@ -16574,6 +16573,7 @@
     method public final void reset();
     method public void setCallback(android.media.MediaCodec.Callback, android.os.Handler);
     method public void setCallback(android.media.MediaCodec.Callback);
+    method public void setInputSurface(android.view.Surface);
     method public void setOnFrameRenderedListener(android.media.MediaCodec.OnFrameRenderedListener, android.os.Handler);
     method public final void setParameters(android.os.Bundle);
     method public void setSurface(android.view.Surface);
@@ -16581,7 +16581,6 @@
     method public final void signalEndOfInputStream();
     method public final void start();
     method public final void stop();
-    method public void usePersistentInputSurface(android.view.Surface);
     field public static final int BUFFER_FLAG_CODEC_CONFIG = 2; // 0x2
     field public static final int BUFFER_FLAG_END_OF_STREAM = 4; // 0x4
     field public static final int BUFFER_FLAG_KEY_FRAME = 1; // 0x1
@@ -17431,6 +17430,7 @@
     method public void setAudioSource(int) throws java.lang.IllegalStateException;
     method public deprecated void setCamera(android.hardware.Camera);
     method public void setCaptureRate(double);
+    method public void setInputSurface(android.view.Surface);
     method public void setLocation(float, float);
     method public void setMaxDuration(int) throws java.lang.IllegalArgumentException;
     method public void setMaxFileSize(long) throws java.lang.IllegalArgumentException;
@@ -17449,7 +17449,6 @@
     method public void setVideoSource(int) throws java.lang.IllegalStateException;
     method public void start() throws java.lang.IllegalStateException;
     method public void stop() throws java.lang.IllegalStateException;
-    method public void usePersistentSurface(android.view.Surface);
     field public static final int MEDIA_ERROR_SERVER_DIED = 100; // 0x64
     field public static final int MEDIA_RECORDER_ERROR_UNKNOWN = 1; // 0x1
     field public static final int MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800; // 0x320
diff --git a/cmds/sm/src/com/android/commands/sm/Sm.java b/cmds/sm/src/com/android/commands/sm/Sm.java
index 4d83610..4a8cf08 100644
--- a/cmds/sm/src/com/android/commands/sm/Sm.java
+++ b/cmds/sm/src/com/android/commands/sm/Sm.java
@@ -18,8 +18,10 @@
 
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import android.os.SystemProperties;
 import android.os.storage.DiskInfo;
 import android.os.storage.IMountService;
+import android.os.storage.StorageManager;
 import android.os.storage.VolumeInfo;
 import android.util.Log;
 
@@ -65,6 +67,8 @@
             runListDisks();
         } else if ("list-volumes".equals(op)) {
             runListVolumes();
+        } else if ("has-adoptable".equals(op)) {
+            runHasAdoptable();
         } else if ("get-primary-storage-uuid".equals(op)) {
             runGetPrimaryStorageUuid();
         } else if ("partition".equals(op)) {
@@ -111,7 +115,12 @@
         }
     }
 
-    public void runGetPrimaryStorageUuid() throws RemoteException{
+    public void runHasAdoptable() {
+        System.out.println(SystemProperties.getBoolean(StorageManager.PROP_HAS_ADOPTABLE, false)
+                || SystemProperties.getBoolean(StorageManager.PROP_FORCE_ADOPTABLE, false));
+    }
+
+    public void runGetPrimaryStorageUuid() throws RemoteException {
         System.out.println(mSm.getPrimaryStorageUuid());
     }
 
@@ -166,6 +175,7 @@
     private static int showUsage() {
         System.err.println("usage: sm list-disks");
         System.err.println("       sm list-volumes [public|private|emulated|all]");
+        System.err.println("       sm has-adoptable");
         System.err.println("       sm get-primary-storage-uuid");
         System.err.println("");
         System.err.println("       sm partition DISK [public|private|mixed] [ratio]");
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 9bbb4be..9c99099 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -2320,6 +2320,8 @@
      * in {@link RunningAppProcessInfo}, giving you the highest importance of all the
      * processes that this package has code running inside of.  If there are no processes
      * running its code, {@link RunningAppProcessInfo#IMPORTANCE_GONE} is returned.
+     *
+     * @hide
      */
     public int getPackageImportance(String packageName) {
         try {
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 6b5239d..e0a30ad 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -945,7 +945,7 @@
                         if (f.mView != null) {
                             // Need to save the current view state if not
                             // done already.
-                            if (!mHost.onShouldSaveFragmentState(f) && f.mSavedViewState == null) {
+                            if (mHost.onShouldSaveFragmentState(f) && f.mSavedViewState == null) {
                                 saveFragmentViewState(f);
                             }
                         }
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 110bdf0..55ff85a 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2523,13 +2523,26 @@
      * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} to be able to call
      * this method; if it has not, a security exception will be thrown.
      *
-     * <p>Calling this from a managed profile will throw a security exception.
+     * <p>Calling this from a managed profile before version
+     * {@link android.os.Build.VERSION_CODES#MNC} will throw a security exception.
+     *
+     * <p>From version {@link android.os.Build.VERSION_CODES#MNC} a profile owner can set:
+     * <ul>
+     * <li>{@link #KEYGUARD_DISABLE_TRUST_AGENTS}, {@link #KEYGUARD_DISABLE_FINGERPRINT}
+     *      these will affect the profile's parent user.
+     * <li>{@link #KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS} this will affect notifications
+     * generated by applications in the managed profile.
+     * </ul>
+     * <p>Requests to disable other features on a managed profile will be ignored. The admin
+     * can check which features have been disabled by calling
+     * {@link #getKeyguardDisabledFeatures(ComponentName)}
      *
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
      * @param which {@link #KEYGUARD_DISABLE_FEATURES_NONE} (default),
      * {@link #KEYGUARD_DISABLE_WIDGETS_ALL}, {@link #KEYGUARD_DISABLE_SECURE_CAMERA},
      * {@link #KEYGUARD_DISABLE_SECURE_NOTIFICATIONS}, {@link #KEYGUARD_DISABLE_TRUST_AGENTS},
-     * {@link #KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS}, {@link #KEYGUARD_DISABLE_FEATURES_ALL}
+     * {@link #KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS}, {@link #KEYGUARD_DISABLE_FINGERPRINT},
+     * {@link #KEYGUARD_DISABLE_FEATURES_ALL}
      */
     public void setKeyguardDisabledFeatures(ComponentName admin, int which) {
         if (mService != null) {
@@ -2793,17 +2806,16 @@
      * @param who Which {@link DeviceAdminReceiver} this request is associated with, or null if not
      *        called by the device owner.
      * @param initializer Which {@link DeviceAdminReceiver} to make device initializer.
-     * @param initializerName The user-visible name of the device initializer.
      * @return whether the component was successfully registered as the device initializer.
      * @throws IllegalArgumentException if the componentname is null or invalid
      * @throws IllegalStateException if the caller is not device owner or the device has
      *         already been provisioned or a device initializer already exists.
      */
-    public boolean setDeviceInitializer(ComponentName who, ComponentName initializer,
-            String initializerName) throws IllegalArgumentException, IllegalStateException {
+    public boolean setDeviceInitializer(ComponentName who, ComponentName initializer)
+            throws IllegalArgumentException, IllegalStateException {
         if (mService != null) {
             try {
-                return mService.setDeviceInitializer(who, initializer, initializerName);
+                return mService.setDeviceInitializer(who, initializer);
             } catch (RemoteException re) {
                 Log.w(TAG, "Failed to set device initializer");
             }
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 481ff62..71d044e 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -213,7 +213,7 @@
     boolean setUserEnabled(in ComponentName who);
     boolean isDeviceInitializer(String packageName);
     void clearDeviceInitializer(in ComponentName who);
-    boolean setDeviceInitializer(in ComponentName who, in ComponentName initializer, String initializerName);
+    boolean setDeviceInitializer(in ComponentName who, in ComponentName initializer);
     String getDeviceInitializer();
     ComponentName getDeviceInitializerComponent();
 
diff --git a/core/java/android/hardware/fingerprint/FingerprintUtils.java b/core/java/android/hardware/fingerprint/FingerprintUtils.java
deleted file mode 100644
index 525f254..0000000
--- a/core/java/android/hardware/fingerprint/FingerprintUtils.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.hardware.fingerprint;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Vibrator;
-import android.provider.Settings;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.internal.util.ArrayUtils;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Utility class for dealing with fingerprints and fingerprint settings.
- * @hide
- */
-public
-class FingerprintUtils {
-    private static final boolean DEBUG = true;
-    private static final String TAG = "FingerprintUtils";
-    private static final long[] FP_ERROR_VIBRATE_PATTERN = new long[] {0, 30, 100, 30};
-    private static final long[] FP_SUCCESS_VIBRATE_PATTERN = new long[] {0, 30};
-
-    private static int[] toIntArray(List<Integer> list) {
-        if (list == null) {
-            return null;
-        }
-        int[] arr = new int[list.size()];
-        int i = 0;
-        for (int elem : list) {
-            arr[i] = elem;
-            i++;
-        }
-        return arr;
-    }
-
-    public static int[] getFingerprintIdsForUser(ContentResolver res, int userId) {
-        String fingerIdsRaw = Settings.Secure.getStringForUser(res,
-                Settings.Secure.USER_FINGERPRINT_IDS, userId);
-        ArrayList<Integer> tmp = new ArrayList<Integer>();
-        if (!TextUtils.isEmpty(fingerIdsRaw)) {
-            String[] fingerStringIds = fingerIdsRaw.replace("[","").replace("]","").split(", ");
-            int length = fingerStringIds.length;
-            for (int i = 0; i < length; i++) {
-                try {
-                    tmp.add(Integer.decode(fingerStringIds[i]));
-                } catch (NumberFormatException e) {
-                    if (DEBUG) Log.w(TAG, "Error parsing finger id: '" + fingerStringIds[i] + "'");
-                }
-            }
-        }
-        return toIntArray(tmp);
-    }
-
-    public static void addFingerprintIdForUser(ContentResolver res, int fingerId, int userId) {
-        // FingerId 0 has special meaning.
-        if (fingerId == 0) {
-            Log.w(TAG, "Tried to add fingerId 0");
-            return;
-        }
-
-        int[] fingerIds = getFingerprintIdsForUser(res, userId);
-
-        // Don't allow dups
-        if (ArrayUtils.contains(fingerIds, fingerId)) {
-            Log.w(TAG, "finger already added " + fingerId);
-            return;
-        }
-        int[] newList = Arrays.copyOf(fingerIds, fingerIds.length + 1);
-        newList[fingerIds.length] = fingerId;
-        Settings.Secure.putStringForUser(res, Settings.Secure.USER_FINGERPRINT_IDS,
-                Arrays.toString(newList), userId);
-    }
-
-    public static boolean removeFingerprintIdForUser(int fingerId, ContentResolver res, int userId)
-    {
-        // FingerId 0 has special meaning. The HAL layer is supposed to remove each finger one
-        // at a time and invoke notify() for each fingerId.  If we get called with 0 here, it means
-        // something bad has happened.
-        if (fingerId == 0) throw new IllegalArgumentException("fingerId can't be 0");
-
-        final int[] fingerIds = getFingerprintIdsForUser(res, userId);
-        if (ArrayUtils.contains(fingerIds, fingerId)) {
-            final int[] result = ArrayUtils.removeInt(fingerIds, fingerId);
-            Settings.Secure.putStringForUser(res, Settings.Secure.USER_FINGERPRINT_IDS,
-                    Arrays.toString(result), userId);
-            return true;
-        }
-        return false;
-    }
-
-    public static void vibrateFingerprintError(Context context) {
-        Vibrator vibrator = context.getSystemService(Vibrator.class);
-        if (vibrator != null) {
-            vibrator.vibrate(FP_ERROR_VIBRATE_PATTERN, -1);
-        }
-    }
-
-    public static void vibrateFingerprintSuccess(Context context) {
-        Vibrator vibrator = context.getSystemService(Vibrator.class);
-        if (vibrator != null) {
-            vibrator.vibrate(FP_SUCCESS_VIBRATE_PATTERN, -1);
-        }
-    }
-
-};
-
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index 3fdabee..8c0bbbf 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -73,6 +73,8 @@
     /** {@hide} */
     public static final String PROP_PRIMARY_PHYSICAL = "ro.vold.primary_physical";
     /** {@hide} */
+    public static final String PROP_HAS_ADOPTABLE = "vold.has_adoptable";
+    /** {@hide} */
     public static final String PROP_FORCE_ADOPTABLE = "persist.fw.force_adoptable";
 
     /** {@hide} */
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index d3a5561..c514180 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4363,12 +4363,6 @@
             "lock_screen_appwidget_ids";
 
         /**
-         * List of enrolled fingerprint identifiers (comma-delimited).
-         * @hide
-         */
-        public static final String USER_FINGERPRINT_IDS = "user_fingerprint_ids";
-
-        /**
          * Id of the appwidget shown on the lock screen when appwidgets are disabled.
          * @hide
          */
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 599ac74..1e42913 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -573,24 +573,34 @@
     }
 
     public static Condition toTimeCondition(Context context, int minutesFromNow, int userHandle) {
+        return toTimeCondition(context, minutesFromNow, userHandle, false /*shortVersion*/);
+    }
+
+    public static Condition toTimeCondition(Context context, int minutesFromNow, int userHandle,
+            boolean shortVersion) {
         final long now = System.currentTimeMillis();
         final long millis = minutesFromNow == 0 ? ZERO_VALUE_MS : minutesFromNow * MINUTES_MS;
-        return toTimeCondition(context, now + millis, minutesFromNow, now, userHandle);
+        return toTimeCondition(context, now + millis, minutesFromNow, now, userHandle,
+                shortVersion);
     }
 
     public static Condition toTimeCondition(Context context, long time, int minutes, long now,
-            int userHandle) {
+            int userHandle, boolean shortVersion) {
         final int num, summaryResId, line1ResId;
         if (minutes < 60) {
             // display as minutes
             num = minutes;
-            summaryResId = R.plurals.zen_mode_duration_minutes_summary;
-            line1ResId = R.plurals.zen_mode_duration_minutes;
+            summaryResId = shortVersion ? R.plurals.zen_mode_duration_minutes_summary_short
+                    : R.plurals.zen_mode_duration_minutes_summary;
+            line1ResId = shortVersion ? R.plurals.zen_mode_duration_minutes_short
+                    : R.plurals.zen_mode_duration_minutes;
         } else {
             // display as hours
             num =  Math.round(minutes / 60f);
-            summaryResId = com.android.internal.R.plurals.zen_mode_duration_hours_summary;
-            line1ResId = com.android.internal.R.plurals.zen_mode_duration_hours;
+            summaryResId = shortVersion ? R.plurals.zen_mode_duration_hours_summary_short
+                    : R.plurals.zen_mode_duration_hours_summary;
+            line1ResId = shortVersion ? R.plurals.zen_mode_duration_hours_short
+                    : R.plurals.zen_mode_duration_hours;
         }
         final String skeleton = DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma";
         final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
@@ -793,17 +803,17 @@
     }
 
     public static String getConditionLine1(Context context, ZenModeConfig config,
-            int userHandle) {
-        return getConditionLine(context, config, userHandle, true /*useLine1*/);
+            int userHandle, boolean shortVersion) {
+        return getConditionLine(context, config, userHandle, true /*useLine1*/, shortVersion);
     }
 
     public static String getConditionSummary(Context context, ZenModeConfig config,
-            int userHandle) {
-        return getConditionLine(context, config, userHandle, false /*useLine1*/);
+            int userHandle, boolean shortVersion) {
+        return getConditionLine(context, config, userHandle, false /*useLine1*/, shortVersion);
     }
 
     private static String getConditionLine(Context context, ZenModeConfig config,
-            int userHandle, boolean useLine1) {
+            int userHandle, boolean useLine1, boolean shortVersion) {
         if (config == null) return "";
         if (config.manualRule != null) {
             final Uri id = config.manualRule.conditionId;
@@ -816,7 +826,7 @@
                 final long now = System.currentTimeMillis();
                 final long span = time - now;
                 c = toTimeCondition(context,
-                        time, Math.round(span / (float) MINUTES_MS), now, userHandle);
+                        time, Math.round(span / (float) MINUTES_MS), now, userHandle, shortVersion);
             }
             final String rt = c == null ? "" : useLine1 ? c.line1 : c.summary;
             return TextUtils.isEmpty(rt) ? "" : rt;
diff --git a/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java b/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java
index ae14149..250932b 100644
--- a/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java
+++ b/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java
@@ -397,6 +397,14 @@
               port,
               autoClose
         );
+        // BEGIN android-added
+        /*
+         * Make sure we have started the handshake before verifying.
+         * Otherwise when we go to the hostname verifier, it directly calls
+         * SSLSocket#getSession() which swallows SSL handshake errors.
+         */
+        sslSocket.startHandshake();
+        // END android-added
         hostnameVerifier.verify(host, sslSocket);
         // verifyHostName() didn't blowup - good!
         return sslSocket;
diff --git a/core/res/res/drawable/ic_perm_device_info.xml b/core/res/res/drawable/ic_perm_device_info.xml
new file mode 100644
index 0000000..ef91c74
--- /dev/null
+++ b/core/res/res/drawable/ic_perm_device_info.xml
@@ -0,0 +1,24 @@
+<!--
+    Copyright (C) 2015 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24.0dp"
+        android:height="24.0dp"
+        android:viewportWidth="48.0"
+        android:viewportHeight="48.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M26.0,14.0l-4.0,0.0l0.0,4.0l4.0,0.0l0.0,-4.0zm0.0,8.0l-4.0,0.0l0.0,12.0l4.0,0.0L26.0,22.0zm8.0,-19.98L14.0,2.0c-2.21,0.0 -4.0,1.79 -4.0,4.0l0.0,36.0c0.0,2.21 1.79,4.0 4.0,4.0l20.0,0.0c2.21,0.0 4.0,-1.79 4.0,-4.0L38.0,6.0c0.0,-2.21 -1.79,-3.98 -4.0,-3.98zM34.0,38.0L14.0,38.0L14.0,10.0l20.0,0.0l0.0,28.0z"/>
+</vector>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 5b564e1..bd4d73d 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1255,6 +1255,9 @@
     <!-- Generic error message shown when the fingerprint hardware can't recognize the fingerprint -->
     <string name="fingerprint_error_unable_to_process">Try again.</string>
 
+    <!-- Template to be used to name enrolled fingerprints by default. -->
+    <string name="fingerprint_name_template">Finger <xliff:g id="fingerId" example="1">%d</xliff:g></string>
+
     <!-- Array containing custom error messages from vendor.  Vendor is expected to add and translate these strings -->
     <string-array name="fingerprint_error_vendor">
     </string-array>
@@ -4031,24 +4034,48 @@
         <item quantity="other">For %1$d minutes (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
     </plurals>
 
+    <!-- Zen mode condition - summary: time duration in minutes (short version). [CHAR LIMIT=NONE] -->
+    <plurals name="zen_mode_duration_minutes_summary_short">
+        <item quantity="one">For 1 min (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
+        <item quantity="other">For %1$d min (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
+    </plurals>
+
     <!-- Zen mode condition - summary: time duration in hours. [CHAR LIMIT=NONE] -->
     <plurals name="zen_mode_duration_hours_summary">
         <item quantity="one">For one hour (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
         <item quantity="other">For %1$d hours (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
     </plurals>
 
+    <!-- Zen mode condition - summary: time duration in hours (short version). [CHAR LIMIT=NONE] -->
+    <plurals name="zen_mode_duration_hours_summary_short">
+        <item quantity="one">For 1 hr (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
+        <item quantity="other">For %1$d hr (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
+    </plurals>
+
     <!-- Zen mode condition - line one: time duration in minutes. [CHAR LIMIT=NONE] -->
     <plurals name="zen_mode_duration_minutes">
         <item quantity="one">For one minute</item>
         <item quantity="other">For %d minutes</item>
     </plurals>
 
+    <!-- Zen mode condition - line one: time duration in minutes (short version). [CHAR LIMIT=NONE] -->
+    <plurals name="zen_mode_duration_minutes_short">
+        <item quantity="one">For 1 min</item>
+        <item quantity="other">For %d min</item>
+    </plurals>
+
     <!-- Zen mode condition - line one: time duration in hours. [CHAR LIMIT=NONE] -->
     <plurals name="zen_mode_duration_hours">
         <item quantity="one">For one hour</item>
         <item quantity="other">For %d hours</item>
     </plurals>
 
+    <!-- Zen mode condition - line one: time duration in hours (short version). [CHAR LIMIT=NONE] -->
+    <plurals name="zen_mode_duration_hours_short">
+        <item quantity="one">For 1 hr</item>
+        <item quantity="other">For %d hr</item>
+    </plurals>
+
     <!-- Zen mode condition - line two: ending time. [CHAR LIMIT=NONE] -->
     <string name="zen_mode_until">Until <xliff:g id="formattedTime" example="10:00 PM">%1$s</xliff:g></string>
 
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 8bb2a04..ea24bae 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2060,6 +2060,10 @@
   <java-symbol type="plurals" name="zen_mode_duration_hours" />
   <java-symbol type="plurals" name="zen_mode_duration_minutes_summary" />
   <java-symbol type="plurals" name="zen_mode_duration_hours_summary" />
+  <java-symbol type="plurals" name="zen_mode_duration_minutes_short" />
+  <java-symbol type="plurals" name="zen_mode_duration_hours_short" />
+  <java-symbol type="plurals" name="zen_mode_duration_minutes_summary_short" />
+  <java-symbol type="plurals" name="zen_mode_duration_hours_summary_short" />
   <java-symbol type="string" name="zen_mode_until" />
   <java-symbol type="string" name="zen_mode_feature_name" />
   <java-symbol type="string" name="zen_mode_downtime_feature_name" />
@@ -2108,6 +2112,7 @@
   <java-symbol type="array" name="fingerprint_acquired_vendor" />
   <java-symbol type="string" name="fingerprint_error_canceled" />
   <java-symbol type="string" name="fingerprint_error_lockout" />
+  <java-symbol type="string" name="fingerprint_name_template" />
 
   <!-- From various Material changes -->
   <java-symbol type="attr" name="titleTextAppearance" />
@@ -2269,4 +2274,5 @@
   <java-symbol type="color" name="chooser_service_row_background_color" />
   <java-symbol type="id" name="target_badge" />
   <java-symbol type="bool" name="config_supportDoubleTapWake" />
+  <java-symbol type="drawable" name="ic_perm_device_info" />
 </resources>
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 20cd9b1..c5d68bd 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -184,12 +184,8 @@
     /** @hide bit mask for the flag enabling vertical rendering for text */
     public static final int VERTICAL_TEXT_FLAG = 0x1000;
 
-
-    /** @hide default flags, even if unspecified */
-    public static final int HIDDEN_DEFAULT_PAINT_FLAGS =
-            DEV_KERN_TEXT_FLAG | EMBEDDED_BITMAP_TEXT_FLAG;
-    /** @hide default flags for no-param constructor */
-    public static final int DEFAULT_PAINT_FLAGS = ANTI_ALIAS_FLAG;
+    // These flags are always set on a new/reset paint, even if flags 0 is passed.
+    static final int HIDDEN_DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG | EMBEDDED_BITMAP_TEXT_FLAG;
 
     /**
      * Font hinter option that disables font hinting.
@@ -419,11 +415,9 @@
 
     /**
      * Create a new paint with default settings.
-     *
-     * As of {@link android.os.Build.VERSION_CODES#MNC}, sets {@link #ANTI_ALIAS_FLAG}.
      */
     public Paint() {
-        this(DEFAULT_PAINT_FLAGS);
+        this(0);
     }
 
     /**
@@ -458,7 +452,7 @@
     /** Restores the paint to its default settings. */
     public void reset() {
         native_reset(mNativePaint);
-        setFlags(DEFAULT_PAINT_FLAGS | HIDDEN_DEFAULT_PAINT_FLAGS);
+        setFlags(HIDDEN_DEFAULT_PAINT_FLAGS);
 
         // TODO: Turning off hinting has undesirable side effects, we need to
         //       revisit hinting once we add support for subpixel positioning
diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java
index 8e91621..5ad31f7 100644
--- a/graphics/java/android/graphics/drawable/ColorDrawable.java
+++ b/graphics/java/android/graphics/drawable/ColorDrawable.java
@@ -43,7 +43,7 @@
  * @attr ref android.R.styleable#ColorDrawable_color
  */
 public class ColorDrawable extends Drawable {
-    private final Paint mPaint = new Paint();
+    private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
 
     @ViewDebug.ExportedProperty(deepExport = true, prefix = "state_")
     private ColorState mColorState;
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index 72198b6..75c4694 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -677,7 +677,7 @@
      * <p>
      * The application is responsible for calling release() on the Surface when done.
      *
-     * @return an input surface that can be used with {@link #usePersistentInputSurface}.
+     * @return an input surface that can be used with {@link #setInputSurface}.
      */
     @NonNull
     public static Surface createPersistentInputSurface() {
@@ -707,17 +707,17 @@
      * @throws IllegalArgumentException if the surface was not created by
      *           {@link #createPersistentInputSurface}.
      */
-    public void usePersistentInputSurface(@NonNull Surface surface) {
+    public void setInputSurface(@NonNull Surface surface) {
         if (!(surface instanceof PersistentSurface)) {
             throw new IllegalArgumentException("not a PersistentSurface");
         }
-        native_usePersistentInputSurface(surface);
+        native_setInputSurface(surface);
     }
 
     @NonNull
     private static native final PersistentSurface native_createPersistentInputSurface();
     private static native final void native_releasePersistentInputSurface(@NonNull Surface surface);
-    private native final void native_usePersistentInputSurface(@NonNull Surface surface);
+    private native final void native_setInputSurface(@NonNull Surface surface);
 
     private native final void native_setCallback(@Nullable Callback cb);
 
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index f27e635..ed2c4cbd 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -156,14 +156,14 @@
      * @see MediaCodec#createPersistentInputSurface
      * @see MediaRecorder.VideoSource
      */
-    public void usePersistentSurface(@NonNull Surface surface) {
+    public void setInputSurface(@NonNull Surface surface) {
         if (!(surface instanceof MediaCodec.PersistentSurface)) {
             throw new IllegalArgumentException("not a PersistentSurface");
         }
-        native_usePersistentSurface(surface);
+        native_setInputSurface(surface);
     }
 
-    private native final void native_usePersistentSurface(@NonNull Surface surface);
+    private native final void native_setInputSurface(@NonNull Surface surface);
 
     /**
      * Sets a Surface to show a preview of recorded media (video). Calls this
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index 31fb37c..93b8ec7 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -272,9 +272,9 @@
     return mCodec->createInputSurface(bufferProducer);
 }
 
-status_t JMediaCodec::usePersistentInputSurface(
+status_t JMediaCodec::setInputSurface(
         const sp<PersistentSurface> &surface) {
-    return mCodec->usePersistentInputSurface(surface);
+    return mCodec->setInputSurface(surface);
 }
 
 status_t JMediaCodec::start() {
@@ -1034,9 +1034,9 @@
     // no need to release surface as it will be released by Surface's jni
 }
 
-static void android_media_MediaCodec_usePersistentInputSurface(
+static void android_media_MediaCodec_setInputSurface(
         JNIEnv* env, jobject thiz, jobject object) {
-    ALOGV("android_media_MediaCodec_usePersistentInputSurface");
+    ALOGV("android_media_MediaCodec_setInputSurface");
 
     sp<JMediaCodec> codec = getMediaCodec(env, thiz);
     if (codec == NULL) {
@@ -1047,7 +1047,7 @@
     sp<PersistentSurface> persistentSurface =
         android_media_MediaCodec_getPersistentInputSurface(env, object);
 
-    status_t err = codec->usePersistentInputSurface(persistentSurface);
+    status_t err = codec->setInputSurface(persistentSurface);
     if (err != NO_ERROR) {
         throwExceptionAsNecessary(env, err);
     }
@@ -1741,8 +1741,8 @@
       "()Landroid/media/MediaCodec$PersistentSurface;",
       (void *)android_media_MediaCodec_createPersistentInputSurface },
 
-    { "native_usePersistentInputSurface", "(Landroid/view/Surface;)V",
-      (void *)android_media_MediaCodec_usePersistentInputSurface },
+    { "native_setInputSurface", "(Landroid/view/Surface;)V",
+      (void *)android_media_MediaCodec_setInputSurface },
 
     { "native_setCallback",
       "(Landroid/media/MediaCodec$Callback;)V",
diff --git a/media/jni/android_media_MediaCodec.h b/media/jni/android_media_MediaCodec.h
index bf61f42..a4ed67b 100644
--- a/media/jni/android_media_MediaCodec.h
+++ b/media/jni/android_media_MediaCodec.h
@@ -58,7 +58,7 @@
             const sp<IGraphicBufferProducer> &surface);
 
     status_t createInputSurface(sp<IGraphicBufferProducer>* bufferProducer);
-    status_t usePersistentInputSurface(const sp<PersistentSurface> &surface);
+    status_t setInputSurface(const sp<PersistentSurface> &surface);
 
     status_t start();
     status_t stop();
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 0044bed..f60af63 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -496,16 +496,16 @@
     android_media_MediaRecorder_release(env, thiz);
 }
 
-void android_media_MediaRecorder_usePersistentSurface(
+void android_media_MediaRecorder_setInputSurface(
         JNIEnv* env, jobject thiz, jobject object) {
-    ALOGV("android_media_MediaRecorder_usePersistentSurface");
+    ALOGV("android_media_MediaRecorder_setInputSurface");
 
     sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
 
     sp<PersistentSurface> persistentSurface = get_persistentSurface(env, object);
 
-    process_media_recorder_call(env, mr->usePersistentSurface(persistentSurface),
-            "java/lang/IllegalArgumentException", "native_usePersistentSurface failed.");
+    process_media_recorder_call(env, mr->setInputSurface(persistentSurface),
+            "java/lang/IllegalArgumentException", "native_setInputSurface failed.");
 }
 
 // ----------------------------------------------------------------------------
@@ -534,7 +534,7 @@
     {"native_setup",         "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V",
                                                                 (void *)android_media_MediaRecorder_native_setup},
     {"native_finalize",      "()V",                             (void *)android_media_MediaRecorder_native_finalize},
-    {"native_usePersistentSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaRecorder_usePersistentSurface },
+    {"native_setInputSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaRecorder_setInputSurface },
 };
 
 // This function only registers the native methods, and is called from
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java
index 563b0f3..35540e3 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java
@@ -252,7 +252,7 @@
             if (persistentSurface != null) {
                 Log.v(TAG, "using persistent surface");
                 surface = persistentSurface;
-                recorder.usePersistentSurface(surface);
+                recorder.setInputSurface(surface);
             }
             recorder.prepare();
             if (persistentSurface == null) {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index d13d71c..1cee642 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -24,7 +24,6 @@
 import android.app.admin.DevicePolicyManager;
 import android.app.trust.TrustManager;
 import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
@@ -56,7 +55,6 @@
 
 import android.hardware.fingerprint.FingerprintManager;
 import android.hardware.fingerprint.FingerprintManager.AuthenticationCallback;
-import android.hardware.fingerprint.FingerprintUtils;
 import android.hardware.fingerprint.FingerprintManager.AuthenticationResult;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
@@ -367,14 +365,8 @@
                 Log.d(TAG, "Fingerprint disabled by DPM for userId: " + userId);
                 return;
             }
-            final ContentResolver res = mContext.getContentResolver();
-            final int ids[] = FingerprintUtils.getFingerprintIdsForUser(res, userId);
-            for (int i = 0; i < ids.length; i++) {
-                // TODO: fix once HAL supports storing group id
-                final boolean isCorrectUser = true || (groupId == userId);
-                if (ids[i] == fingerId && isCorrectUser) {
-                    onFingerprintAuthenticated(userId);
-                }
+            if (groupId == userId) {
+                onFingerprintAuthenticated(groupId);
             }
         } finally {
             setFingerprintRunningDetectionRunning(false);
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/PermissionsInfo.java b/packages/SettingsLib/src/com/android/settingslib/applications/PermissionsInfo.java
index 2606af2..8b38a5f 100644
--- a/packages/SettingsLib/src/com/android/settingslib/applications/PermissionsInfo.java
+++ b/packages/SettingsLib/src/com/android/settingslib/applications/PermissionsInfo.java
@@ -22,7 +22,6 @@
 import android.content.pm.PermissionGroupInfo;
 import android.content.pm.PermissionInfo;
 import android.graphics.drawable.Drawable;
-import android.graphics.drawable.ShapeDrawable;
 import android.os.AsyncTask;
 import android.os.Build;
 import android.os.UserHandle;
@@ -80,7 +79,8 @@
                 if (info.protectionLevel == PermissionInfo.PROTECTION_DANGEROUS) {
                     group = new PermissionGroup();
                     // TODO: Add default permission icon.
-                    group.icon = info.icon != 0 ? info.loadIcon(mPm) : new ShapeDrawable();
+                    group.icon = info.icon != 0 ? info.loadIcon(mPm) : mContext.getDrawable(
+                            com.android.internal.R.drawable.ic_perm_device_info);
                     group.name = info.name;
                     group.packageName = info.packageName;
                     group.label = info.loadLabel(mPm).toString();
@@ -104,7 +104,8 @@
             for (PermissionGroupInfo groupInfo : groups) {
                 PermissionGroup group = new PermissionGroup();
                 // TODO: Add default permission icon.
-                group.icon = groupInfo.icon != 0 ? groupInfo.loadIcon(mPm) : new ShapeDrawable();
+                group.icon = groupInfo.icon != 0 ? groupInfo.loadIcon(mPm) : mContext.getDrawable(
+                        com.android.internal.R.drawable.ic_perm_device_info);
                 group.name = groupInfo.name;
                 group.packageName = groupInfo.packageName;
                 group.label = groupInfo.loadLabel(mPm).toString();
diff --git a/packages/SystemUI/res/layout/volume_zen_footer.xml b/packages/SystemUI/res/layout/volume_zen_footer.xml
index 998741c..eede804 100644
--- a/packages/SystemUI/res/layout/volume_zen_footer.xml
+++ b/packages/SystemUI/res/layout/volume_zen_footer.xml
@@ -26,7 +26,7 @@
         android:layout_height="1dp"
         android:layout_marginBottom="8dp"
         android:layout_marginTop="8dp"
-        android:background="#4dffffff" />
+        android:background="@color/qs_tile_divider" />
 
     <LinearLayout
         android:layout_width="match_parent"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 588ec26..2913c7d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -395,11 +395,6 @@
                                 Toast.LENGTH_SHORT).show();
                     }
                 }
-            } else if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(
-                    action)) {
-                mUsersAllowingPrivateNotifications.clear();
-                updateLockscreenNotificationSetting();
-                updateNotifications();
             } else if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) {
                 NotificationManager noMan = (NotificationManager)
                         mContext.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -419,6 +414,19 @@
         }
     };
 
+    private final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(action) &&
+                    isCurrentProfile(getSendingUserId())) {
+                mUsersAllowingPrivateNotifications.clear();
+                updateLockscreenNotificationSetting();
+                updateNotifications();
+            }
+        }
+    };
+
     private final NotificationListenerService mNotificationListener =
             new NotificationListenerService() {
         @Override
@@ -631,9 +639,13 @@
         filter.addAction(Intent.ACTION_USER_PRESENT);
         filter.addAction(BANNER_ACTION_CANCEL);
         filter.addAction(BANNER_ACTION_SETUP);
-        filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
         mContext.registerReceiver(mBroadcastReceiver, filter);
 
+        IntentFilter allUsersFilter = new IntentFilter();
+        allUsersFilter.addAction(
+                DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
+        mContext.registerReceiverAsUser(mAllUsersReceiver, UserHandle.ALL, allUsersFilter,
+                null, null);
         updateCurrentProfilesCache();
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
index 4bc45df..6e0ca3c 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
@@ -533,8 +533,7 @@
             }
             Util.setVisOrInvis(row.settingsButton, false);
             row.header.setAlpha(mExpanded && isActive ? 1 : 0.5f);
-            row.slider.setProgressTintList(isActive ? mActiveSliderTint : mInactiveSliderTint);
-            row.slider.setThumbTintList(isActive ? mActiveSliderTint : mInactiveSliderTint);
+            updateVolumeRowSliderTintH(row, isActive);
         }
     }
 
@@ -666,8 +665,18 @@
         updateVolumeRowSliderH(row, zenMuted);
     }
 
+    private void updateVolumeRowSliderTintH(VolumeRow row, boolean isActive) {
+        final ColorStateList tint = isActive && row.slider.isEnabled() ? mActiveSliderTint
+                : mInactiveSliderTint;
+        if (tint == row.cachedSliderTint) return;
+        row.cachedSliderTint = tint;
+        row.slider.setProgressTintList(tint);
+        row.slider.setThumbTintList(tint);
+    }
+
     private void updateVolumeRowSliderH(VolumeRow row, boolean zenMuted) {
         row.slider.setEnabled(!zenMuted);
+        updateVolumeRowSliderTintH(row, row.stream == mActiveStream);
         if (row.tracking) {
             return;  // don't update if user is sliding
         }
@@ -1027,6 +1036,7 @@
         private int iconMuteRes;
         private boolean important;
         private int cachedIconRes;
+        private ColorStateList cachedSliderTint;
         private int iconState;  // from Events
         private boolean cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS;
         private int cachedExpandButtonRes;
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
index 66c4993..6d67d11 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
@@ -127,7 +127,7 @@
         Util.setText(mSummaryLine1, line1);
 
         final String line2 = ZenModeConfig.getConditionSummary(mContext, mConfig,
-                mController.getCurrentUser());
+                mController.getCurrentUser(), true /*shortVersion*/);
         Util.setText(mSummaryLine2, line2);
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index b3b6725..8dfa9b0 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -438,7 +438,8 @@
         final long span = time - now;
         if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null;
         return ZenModeConfig.toTimeCondition(context,
-                time, Math.round(span / (float) MINUTES_MS), now, ActivityManager.getCurrentUser());
+                time, Math.round(span / (float) MINUTES_MS), now, ActivityManager.getCurrentUser(),
+                false /*shortVersion*/);
     }
 
     private void handleUpdateConditions(Condition[] conditions) {
@@ -717,7 +718,8 @@
                 if (up && bucketTime > time || !up && bucketTime < time) {
                     mBucketIndex = j;
                     newCondition = ZenModeConfig.toTimeCondition(mContext,
-                            bucketTime, bucketMinutes, now, ActivityManager.getCurrentUser());
+                            bucketTime, bucketMinutes, now, ActivityManager.getCurrentUser(),
+                            false /*shortVersion*/);
                     break;
                 }
             }
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java
index 0faccc6..aa143e4 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
@@ -31,7 +31,6 @@
 
 import com.android.server.SystemService;
 
-import android.hardware.fingerprint.FingerprintUtils;
 import android.hardware.fingerprint.Fingerprint;
 import android.hardware.fingerprint.FingerprintManager;
 import android.hardware.fingerprint.IFingerprintService;
@@ -93,6 +92,7 @@
     private Context mContext;
     private int mHalDeviceId;
     private int mFailedAttempts;
+    private final FingerprintUtils mFingerprintUtils = FingerprintUtils.getInstance();
     private final Runnable mLockoutReset = new Runnable() {
         @Override
         public void run() {
@@ -172,7 +172,6 @@
      * @return true if the operation is done, i.e. authentication completed
      */
     boolean dispatchNotify(ClientMonitor clientMonitor, int type, int arg1, int arg2, int arg3) {
-        ContentResolver contentResolver = mContext.getContentResolver();
         boolean operationCompleted = false;
         int fpId;
         int groupId;
@@ -198,7 +197,7 @@
                 remaining = arg3;
                 operationCompleted = clientMonitor.sendEnrollResult(fpId, groupId, remaining);
                 if (remaining == 0) {
-                    addTemplateForUser(clientMonitor, contentResolver, fpId);
+                    addTemplateForUser(clientMonitor, fpId);
                     operationCompleted = true; // enroll completed
                 }
                 break;
@@ -207,7 +206,7 @@
                 groupId = arg2;
                 operationCompleted = clientMonitor.sendRemoved(fpId, groupId);
                 if (fpId != 0) {
-                    removeTemplateForUser(clientMonitor, contentResolver, fpId);
+                    removeTemplateForUser(clientMonitor, fpId);
                 }
                 break;
         }
@@ -252,16 +251,12 @@
         return false;
     }
 
-    private void removeTemplateForUser(ClientMonitor clientMonitor, ContentResolver contentResolver,
-            final int fingerId) {
-        FingerprintUtils.removeFingerprintIdForUser(fingerId, contentResolver,
-                clientMonitor.userId);
+    private void removeTemplateForUser(ClientMonitor clientMonitor, int fingerId) {
+        mFingerprintUtils.removeFingerprintIdForUser(mContext, fingerId, clientMonitor.userId);
     }
 
-    private void addTemplateForUser(ClientMonitor clientMonitor, ContentResolver contentResolver,
-            final int fingerId) {
-        FingerprintUtils.addFingerprintIdForUser(contentResolver, fingerId,
-                clientMonitor.userId);
+    private void addTemplateForUser(ClientMonitor clientMonitor, int fingerId) {
+        mFingerprintUtils.addFingerprintForUser(mContext, fingerId, clientMonitor.userId);
     }
 
     void startEnrollment(IBinder token, byte[] cryptoToken, int groupId,
@@ -345,24 +340,11 @@
     }
 
     public List<Fingerprint> getEnrolledFingerprints(int groupId) {
-        ContentResolver resolver = mContext.getContentResolver();
-        int[] ids = FingerprintUtils.getFingerprintIdsForUser(resolver, groupId);
-        List<Fingerprint> result = new ArrayList<Fingerprint>();
-        for (int i = 0; i < ids.length; i++) {
-            // TODO: persist names in Settings
-            CharSequence name = "Finger" + ids[i];
-            final int group = 0; // TODO
-            final int fingerId = ids[i];
-            final long deviceId = 0; // TODO
-            Fingerprint item = new Fingerprint(name, 0, ids[i], 0);
-            result.add(item);
-        }
-        return result;
+        return mFingerprintUtils.getFingerprintsForUser(mContext, groupId);
     }
 
     public boolean hasEnrolledFingerprints(int groupId) {
-        ContentResolver resolver = mContext.getContentResolver();
-        return FingerprintUtils.getFingerprintIdsForUser(resolver, groupId).length > 0;
+        return mFingerprintUtils.getFingerprintsForUser(mContext, groupId).size() > 0;
     }
 
     void checkPermission(String permission) {
@@ -596,7 +578,7 @@
             mHandler.post(new Runnable() {
                 @Override
                 public void run() {
-                    Slog.w(TAG, "rename id=" + fingerId + ",gid=" + groupId + ",name=" + name);
+                    mFingerprintUtils.renameFingerprintForUser(mContext, fingerId, groupId, name);
                 }
             });
         }
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintUtils.java b/services/core/java/com/android/server/fingerprint/FingerprintUtils.java
new file mode 100644
index 0000000..1e6e105
--- /dev/null
+++ b/services/core/java/com/android/server/fingerprint/FingerprintUtils.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.fingerprint;
+
+import android.content.Context;
+import android.hardware.fingerprint.Fingerprint;
+import android.os.Vibrator;
+import android.util.SparseArray;
+
+import com.android.internal.annotations.GuardedBy;
+
+import java.util.List;
+
+/**
+ * Utility class for dealing with fingerprints and fingerprint settings.
+ */
+public class FingerprintUtils {
+
+    private static final long[] FP_ERROR_VIBRATE_PATTERN = new long[] {0, 30, 100, 30};
+    private static final long[] FP_SUCCESS_VIBRATE_PATTERN = new long[] {0, 30};
+
+    private static final Object sInstanceLock = new Object();
+    private static FingerprintUtils sInstance;
+
+    @GuardedBy("this")
+    private final SparseArray<FingerprintsUserState> mUsers = new SparseArray<>();
+
+    public static FingerprintUtils getInstance() {
+        synchronized (sInstanceLock) {
+            if (sInstance == null) {
+                sInstance = new FingerprintUtils();
+            }
+        }
+        return sInstance;
+    }
+
+    private FingerprintUtils() {
+    }
+
+    public List<Fingerprint> getFingerprintsForUser(Context ctx, int userId) {
+        return getStateForUser(ctx, userId).getFingerprints();
+    }
+
+    public void addFingerprintForUser(Context ctx, int fingerId, int userId) {
+        getStateForUser(ctx, userId).addFingerprint(fingerId);
+    }
+
+    public void removeFingerprintIdForUser(Context ctx, int fingerId, int userId) {
+        getStateForUser(ctx, userId).removeFingerprint(fingerId);
+    }
+
+    public void renameFingerprintForUser(Context ctx, int fingerId, int userId, CharSequence name) {
+        getStateForUser(ctx, userId).renameFingerprint(fingerId, name);
+    }
+
+    public static void vibrateFingerprintError(Context context) {
+        Vibrator vibrator = context.getSystemService(Vibrator.class);
+        if (vibrator != null) {
+            vibrator.vibrate(FP_ERROR_VIBRATE_PATTERN, -1);
+        }
+    }
+
+    public static void vibrateFingerprintSuccess(Context context) {
+        Vibrator vibrator = context.getSystemService(Vibrator.class);
+        if (vibrator != null) {
+            vibrator.vibrate(FP_SUCCESS_VIBRATE_PATTERN, -1);
+        }
+    }
+
+    private FingerprintsUserState getStateForUser(Context ctx, int userId) {
+        synchronized (this) {
+            FingerprintsUserState state = mUsers.get(userId);
+            if (state == null) {
+                state = new FingerprintsUserState(ctx, userId);
+                mUsers.put(userId, state);
+            }
+            return state;
+        }
+    }
+}
+
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintsUserState.java b/services/core/java/com/android/server/fingerprint/FingerprintsUserState.java
new file mode 100644
index 0000000..33177b4
--- /dev/null
+++ b/services/core/java/com/android/server/fingerprint/FingerprintsUserState.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.server.fingerprint;
+
+import android.content.Context;
+import android.hardware.fingerprint.Fingerprint;
+import android.os.AsyncTask;
+import android.os.Environment;
+import android.util.AtomicFile;
+import android.util.Slog;
+import android.util.Xml;
+
+import com.android.internal.annotations.GuardedBy;
+
+import libcore.io.IoUtils;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class managing the set of fingerprint per user across device reboots.
+ */
+class FingerprintsUserState {
+
+    private static final String TAG = "FingerprintState";
+    private static final String FINGERPRINT_FILE = "settings_fingerprint.xml";
+
+    private static final String TAG_FINGERPRINTS = "fingerprints";
+    private static final String TAG_FINGERPRINT = "fingerprint";
+    private static final String ATTR_NAME = "name";
+    private static final String ATTR_GROUP_ID = "groupId";
+    private static final String ATTR_FINGER_ID = "fingerId";
+    private static final String ATTR_DEVICE_ID = "deviceId";
+
+    private final File mFile;
+
+    @GuardedBy("this")
+    private final ArrayList<Fingerprint> mFingerprints = new ArrayList<>();
+    private final Context mCtx;
+
+    public FingerprintsUserState(Context ctx, int userId) {
+        mFile = getFileForUser(userId);
+        mCtx = ctx;
+        synchronized (this) {
+            readStateSyncLocked();
+        }
+    }
+
+    public void addFingerprint(int fingerId) {
+        synchronized (this) {
+            mFingerprints.add(new Fingerprint(getDefaultFingerprintName(fingerId), 0, fingerId, 0));
+            scheduleWriteStateLocked();
+        }
+    }
+
+    public void removeFingerprint(int fingerId) {
+        synchronized (this) {
+            for (int i = 0; i < mFingerprints.size(); i++) {
+                if (mFingerprints.get(i).getFingerId() == fingerId) {
+                    mFingerprints.remove(i);
+                    scheduleWriteStateLocked();
+                    break;
+                }
+            }
+        }
+    }
+
+    public void renameFingerprint(int fingerId, CharSequence name) {
+        synchronized (this) {
+            for (int i = 0; i < mFingerprints.size(); i++) {
+                if (mFingerprints.get(i).getFingerId() == fingerId) {
+                    Fingerprint old = mFingerprints.get(i);
+                    mFingerprints.set(i, new Fingerprint(name, old.getGroupId(), old.getFingerId(),
+                            old.getDeviceId()));
+                    scheduleWriteStateLocked();
+                    break;
+                }
+            }
+        }
+    }
+
+    public List<Fingerprint> getFingerprints() {
+        synchronized (this) {
+            return getCopy(mFingerprints);
+        }
+    }
+
+    private String getDefaultFingerprintName(int fingerId) {
+        return mCtx.getString(com.android.internal.R.string.fingerprint_name_template, fingerId);
+    }
+
+    private static File getFileForUser(int userId) {
+        return new File(Environment.getUserSystemDirectory(userId), FINGERPRINT_FILE);
+    }
+
+    private final Runnable mWriteStateRunnable = new Runnable() {
+        @Override
+        public void run() {
+            doWriteState();
+        }
+    };
+
+    private void scheduleWriteStateLocked() {
+        AsyncTask.execute(mWriteStateRunnable);
+    }
+
+    private ArrayList<Fingerprint> getCopy(ArrayList<Fingerprint> array) {
+        ArrayList<Fingerprint> result = new ArrayList<>(array.size());
+        for (int i = 0; i < array.size(); i++) {
+            Fingerprint fp = array.get(i);
+            result.add(new Fingerprint(fp.getName(), fp.getGroupId(), fp.getFingerId(),
+                    fp.getDeviceId()));
+        }
+        return result;
+    }
+
+    private void doWriteState() {
+        AtomicFile destination = new AtomicFile(mFile);
+
+        ArrayList<Fingerprint> fingerprints;
+
+        synchronized (this) {
+            fingerprints = getCopy(mFingerprints);
+        }
+
+        FileOutputStream out = null;
+        try {
+            out = destination.startWrite();
+
+            XmlSerializer serializer = Xml.newSerializer();
+            serializer.setOutput(out, "utf-8");
+            serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
+            serializer.startDocument(null, true);
+            serializer.startTag(null, TAG_FINGERPRINTS);
+
+            final int count = fingerprints.size();
+            for (int i = 0; i < count; i++) {
+                Fingerprint fp = fingerprints.get(i);
+                serializer.startTag(null, TAG_FINGERPRINT);
+                serializer.attribute(null, ATTR_FINGER_ID, Integer.toString(fp.getFingerId()));
+                serializer.attribute(null, ATTR_NAME, fp.getName().toString());
+                serializer.attribute(null, ATTR_GROUP_ID, Integer.toString(fp.getGroupId()));
+                serializer.attribute(null, ATTR_DEVICE_ID, Long.toString(fp.getDeviceId()));
+                serializer.endTag(null, TAG_FINGERPRINT);
+            }
+
+            serializer.endTag(null, TAG_FINGERPRINTS);
+            serializer.endDocument();
+            destination.finishWrite(out);
+
+            // Any error while writing is fatal.
+        } catch (Throwable t) {
+            Slog.wtf(TAG, "Failed to write settings, restoring backup", t);
+            destination.failWrite(out);
+            throw new IllegalStateException("Failed to write fingerprints", t);
+        } finally {
+            IoUtils.closeQuietly(out);
+        }
+    }
+
+    private void readStateSyncLocked() {
+        FileInputStream in;
+        if (!mFile.exists()) {
+            return;
+        }
+        try {
+            in = new FileInputStream(mFile);
+        } catch (FileNotFoundException fnfe) {
+            Slog.i(TAG, "No fingerprint state");
+            return;
+        }
+        try {
+            XmlPullParser parser = Xml.newPullParser();
+            parser.setInput(in, null);
+            parseStateLocked(parser);
+
+        } catch (XmlPullParserException | IOException e) {
+            throw new IllegalStateException("Failed parsing settings file: "
+                    + mFile , e);
+        } finally {
+            IoUtils.closeQuietly(in);
+        }
+    }
+
+    private void parseStateLocked(XmlPullParser parser)
+            throws IOException, XmlPullParserException {
+        final int outerDepth = parser.getDepth();
+        int type;
+        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+                continue;
+            }
+
+            String tagName = parser.getName();
+            if (tagName.equals(TAG_FINGERPRINTS)) {
+                parseFingerprintsLocked(parser);
+            }
+        }
+    }
+
+    private void parseFingerprintsLocked(XmlPullParser parser)
+            throws IOException, XmlPullParserException {
+
+        final int outerDepth = parser.getDepth();
+        int type;
+        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+                continue;
+            }
+
+            String tagName = parser.getName();
+            if (tagName.equals(TAG_FINGERPRINT)) {
+                String name = parser.getAttributeValue(null, ATTR_NAME);
+                String groupId = parser.getAttributeValue(null, ATTR_GROUP_ID);
+                String fingerId = parser.getAttributeValue(null, ATTR_FINGER_ID);
+                String deviceId = parser.getAttributeValue(null, ATTR_DEVICE_ID);
+                mFingerprints.add(new Fingerprint(name, Integer.parseInt(groupId),
+                        Integer.parseInt(fingerId), Integer.parseInt(deviceId)));
+            }
+        }
+    }
+
+}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java
index 88bf54e..d5b0804 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java
@@ -116,9 +116,9 @@
     /**
      * Creates an instance of the device owner object with the device initializer set.
      */
-    static DeviceOwner createWithDeviceInitializer(ComponentName admin, String ownerName) {
+    static DeviceOwner createWithDeviceInitializer(ComponentName admin) {
         DeviceOwner owner = new DeviceOwner();
-        owner.mDeviceInitializer = new OwnerInfo(ownerName, admin);
+        owner.mDeviceInitializer = new OwnerInfo(null, admin);
         return owner;
     }
 
@@ -155,12 +155,8 @@
         return mDeviceInitializer != null ? mDeviceInitializer.packageName : null;
     }
 
-    String getDeviceInitializerName() {
-        return mDeviceInitializer != null ? mDeviceInitializer.name : null;
-    }
-
-    void setDeviceInitializer(ComponentName admin, String ownerName) {
-        mDeviceInitializer = new OwnerInfo(ownerName, admin);
+    void setDeviceInitializer(ComponentName admin) {
+        mDeviceInitializer = new OwnerInfo(null, admin);
     }
 
     void clearDeviceInitializer() {
@@ -255,16 +251,15 @@
                     String packageName = parser.getAttributeValue(null, ATTR_PACKAGE);
                     mDeviceOwner = new OwnerInfo(name, packageName);
                 } else if (tag.equals(TAG_DEVICE_INITIALIZER)) {
-                    String name = parser.getAttributeValue(null, ATTR_NAME);
                     String packageName = parser.getAttributeValue(null, ATTR_PACKAGE);
                     String initializerComponentStr =
                             parser.getAttributeValue(null, ATTR_COMPONENT_NAME);
                     ComponentName admin =
                             ComponentName.unflattenFromString(initializerComponentStr);
                     if (admin != null) {
-                        mDeviceInitializer = new OwnerInfo(name, admin);
+                        mDeviceInitializer = new OwnerInfo(null, admin);
                     } else {
-                        mDeviceInitializer = new OwnerInfo(name, packageName);
+                        mDeviceInitializer = new OwnerInfo(null, packageName);
                         Slog.e(TAG, "Error parsing device-owner file. Bad component name " +
                                 initializerComponentStr);
                     }
@@ -334,9 +329,6 @@
             if (mDeviceInitializer != null) {
                 out.startTag(null, TAG_DEVICE_INITIALIZER);
                 out.attribute(null, ATTR_PACKAGE, mDeviceInitializer.packageName);
-                if (mDeviceInitializer.name != null) {
-                    out.attribute(null, ATTR_NAME, mDeviceInitializer.name);
-                }
                 if (mDeviceInitializer.admin != null) {
                     out.attribute(
                             null, ATTR_COMPONENT_NAME, mDeviceInitializer.admin.flattenToString());
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index ba5d666..822ffd3 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -246,6 +246,17 @@
         GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
     }
 
+    // Keyguard features that when set of a profile will affect the profiles
+    // parent user.
+    private static final int PROFILE_KEYGUARD_FEATURES_AFFECT_OWNER =
+            DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS
+            | DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT;
+
+    // Keyguard features that are allowed to be set on a managed profile
+    private static final int PROFILE_KEYGUARD_FEATURES =
+            PROFILE_KEYGUARD_FEATURES_AFFECT_OWNER
+            | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+
     final Context mContext;
     final UserManager mUserManager;
     final PowerManager.WakeLock mWakeLock;
@@ -3957,7 +3968,9 @@
         }
         Preconditions.checkNotNull(who, "ComponentName is null");
         final int userHandle = UserHandle.getCallingUserId();
-        enforceNotManagedProfile(userHandle, "disable keyguard features");
+        if (isManagedProfile(userHandle)) {
+            which = which & PROFILE_KEYGUARD_FEATURES;
+        }
         synchronized (this) {
             ActiveAdmin ap = getActiveAdminForCallerLocked(who,
                     DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES);
@@ -3978,21 +3991,50 @@
             return 0;
         }
         enforceCrossUserPermission(userHandle);
-        synchronized (this) {
-            if (who != null) {
-                ActiveAdmin admin = getActiveAdminUncheckedLocked(who, userHandle);
-                return (admin != null) ? admin.disabledKeyguardFeatures : 0;
-            }
+        long ident = Binder.clearCallingIdentity();
+        try {
+            synchronized (this) {
+                if (who != null) {
+                    ActiveAdmin admin = getActiveAdminUncheckedLocked(who, userHandle);
+                    return (admin != null) ? admin.disabledKeyguardFeatures : 0;
+                }
 
-            // Determine which keyguard features are disabled for any active admins.
-            DevicePolicyData policy = getUserData(userHandle);
-            final int N = policy.mAdminList.size();
-            int which = 0;
-            for (int i = 0; i < N; i++) {
-                ActiveAdmin admin = policy.mAdminList.get(i);
-                which |= admin.disabledKeyguardFeatures;
+                UserInfo user = mUserManager.getUserInfo(userHandle);
+                final List<UserInfo> profiles;
+                if (user.isManagedProfile()) {
+                    // If we are being asked about a managed profile just return
+                    // keyguard features disabled by admins in the profile.
+                    profiles = new ArrayList<UserInfo>(1);
+                    profiles.add(user);
+                } else {
+                    // Otherwise return those set by admins in the user
+                    // and its profiles.
+                    profiles = mUserManager.getProfiles(userHandle);
+                }
+
+                // Determine which keyguard features are disabled by any active admin.
+                int which = 0;
+                for (UserInfo userInfo : profiles) {
+                    DevicePolicyData policy = getUserData(userInfo.id);
+                    final int N = policy.mAdminList.size();
+                    for (int i = 0; i < N; i++) {
+                        ActiveAdmin admin = policy.mAdminList.get(i);
+                        if (userInfo.id == userHandle || !userInfo.isManagedProfile()) {
+                            // If we are being asked explictly about this user
+                            // return all disabled features even if its a managed profile.
+                            which |= admin.disabledKeyguardFeatures;
+                        } else {
+                            // Otherwise a managed profile is only allowed to disable
+                            // some features on the parent user.
+                            which |= (admin.disabledKeyguardFeatures
+                                    & PROFILE_KEYGUARD_FEATURES_AFFECT_OWNER);
+                        }
+                    }
+                }
+                return which;
             }
-            return which;
+        } finally {
+            Binder.restoreCallingIdentity(ident);
         }
     }
 
@@ -4122,8 +4164,7 @@
     }
 
     @Override
-    public boolean setDeviceInitializer(ComponentName who, ComponentName initializer,
-            String ownerName) {
+    public boolean setDeviceInitializer(ComponentName who, ComponentName initializer) {
         if (!mHasFeature) {
             return false;
         }
@@ -4142,10 +4183,10 @@
 
             if (mDeviceOwner == null) {
                 // Device owner state does not exist, create it.
-                mDeviceOwner = DeviceOwner.createWithDeviceInitializer(initializer, ownerName);
+                mDeviceOwner = DeviceOwner.createWithDeviceInitializer(initializer);
             } else {
                 // Device owner already exists, update it.
-                mDeviceOwner.setDeviceInitializer(initializer, ownerName);
+                mDeviceOwner.setDeviceInitializer(initializer);
             }
 
             addDeviceInitializerToLockTaskPackagesLocked(UserHandle.USER_OWNER);
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
index f5ef01b..0c8c0d6 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
@@ -1137,7 +1137,7 @@
     }
 
     private void reset() {
-        mFlags = Paint.DEFAULT_PAINT_FLAGS | Paint.HIDDEN_DEFAULT_PAINT_FLAGS;
+        mFlags = Paint.HIDDEN_DEFAULT_PAINT_FLAGS;
         mColor = 0xFF000000;
         mStyle = Paint.Style.FILL.nativeInt;
         mCap = Paint.Cap.BUTT.nativeInt;