Merge "Add new activity dumpsys command to persist all data." into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index 3ab4ce4..90d63b0 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -409,6 +409,7 @@
     field public static final int colorControlActivated = 16843818; // 0x101042a
     field public static final int colorControlHighlight = 16843820; // 0x101042c
     field public static final int colorControlNormal = 16843817; // 0x1010429
+    field public static final int colorEdgeEffect = 16843982; // 0x10104ce
     field public static final int colorFocusedHighlight = 16843663; // 0x101038f
     field public static final int colorForeground = 16842800; // 0x1010030
     field public static final int colorForegroundInverse = 16843270; // 0x1010206
@@ -10707,9 +10708,6 @@
   public class ColorMatrixColorFilter extends android.graphics.ColorFilter {
     ctor public ColorMatrixColorFilter(android.graphics.ColorMatrix);
     ctor public ColorMatrixColorFilter(float[]);
-    method public android.graphics.ColorMatrix getColorMatrix();
-    method public void setColorMatrix(android.graphics.ColorMatrix);
-    method public void setColorMatrix(float[]);
   }
 
   public class ComposePathEffect extends android.graphics.PathEffect {
@@ -10786,10 +10784,6 @@
 
   public class LightingColorFilter extends android.graphics.ColorFilter {
     ctor public LightingColorFilter(int, int);
-    method public int getColorAdd();
-    method public int getColorMultiply();
-    method public void setColorAdd(int);
-    method public void setColorMultiply(int);
   }
 
   public class LinearGradient extends android.graphics.Shader {
@@ -11295,8 +11289,6 @@
 
   public class PorterDuffColorFilter extends android.graphics.ColorFilter {
     ctor public PorterDuffColorFilter(int, android.graphics.PorterDuff.Mode);
-    method public int getColor();
-    method public android.graphics.PorterDuff.Mode getMode();
   }
 
   public class PorterDuffXfermode extends android.graphics.Xfermode {
@@ -28179,6 +28171,7 @@
   public final class DisconnectCause implements android.os.Parcelable {
     ctor public DisconnectCause(int);
     ctor public DisconnectCause(int, java.lang.String);
+    ctor public DisconnectCause(int, java.lang.CharSequence, java.lang.CharSequence, java.lang.String);
     ctor public DisconnectCause(int, java.lang.CharSequence, java.lang.CharSequence, java.lang.String, int);
     method public int describeContents();
     method public int getCode();
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 5f3ed61..25c4897 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -745,6 +745,11 @@
         public View findViewById(int id) {
             return Activity.this.findViewById(id);
         }
+        @Override
+        public boolean hasView() {
+            Window window = Activity.this.getWindow();
+            return (window != null && window.peekDecorView() != null);
+        }
     };
 
     // Most recent call to requestVisibleBehind().
diff --git a/core/java/android/app/ActivityTransitionCoordinator.java b/core/java/android/app/ActivityTransitionCoordinator.java
index 137f77d..540376e 100644
--- a/core/java/android/app/ActivityTransitionCoordinator.java
+++ b/core/java/android/app/ActivityTransitionCoordinator.java
@@ -219,7 +219,9 @@
 
     protected void viewsReady(ArrayMap<String, View> sharedElements) {
         sharedElements.retainAll(mAllSharedElementNames);
-        mListener.onMapSharedElements(mAllSharedElementNames, sharedElements);
+        if (mListener != null) {
+            mListener.onMapSharedElements(mAllSharedElementNames, sharedElements);
+        }
         mSharedElementNames.addAll(sharedElements.keySet());
         mSharedElements.addAll(sharedElements.values());
         if (getViewsTransition() != null && mTransitioningViews != null) {
@@ -461,7 +463,8 @@
         if (sharedElementState != null) {
             Matrix tempMatrix = new Matrix();
             RectF tempRect = new RectF();
-            for (int i = 0; i < mSharedElementNames.size(); i++) {
+            final int numSharedElements = mSharedElements.size();
+            for (int i = 0; i < numSharedElements; i++) {
                 View sharedElement = mSharedElements.get(i);
                 String name = mSharedElementNames.get(i);
                 SharedElementOriginalState originalState = getOldSharedElementState(sharedElement,
@@ -471,12 +474,16 @@
                         tempMatrix, tempRect, null);
             }
         }
-        mListener.onSharedElementStart(mSharedElementNames, mSharedElements, snapshots);
+        if (mListener != null) {
+            mListener.onSharedElementStart(mSharedElementNames, mSharedElements, snapshots);
+        }
         return originalImageState;
     }
 
     protected void notifySharedElementEnd(ArrayList<View> snapshots) {
-        mListener.onSharedElementEnd(mSharedElementNames, mSharedElements, snapshots);
+        if (mListener != null) {
+            mListener.onSharedElementEnd(mSharedElementNames, mSharedElements, snapshots);
+        }
     }
 
     protected void scheduleSetSharedElementEnd(final ArrayList<View> snapshots) {
@@ -544,7 +551,7 @@
             if (sharedElementBundle != null) {
                 Parcelable parcelable = sharedElementBundle.getParcelable(KEY_SNAPSHOT);
                 View snapshot = null;
-                if (parcelable != null) {
+                if (parcelable != null && mListener != null) {
                     snapshot = mListener.onCreateSnapshotView(context, parcelable);
                 }
                 if (snapshot != null) {
@@ -659,7 +666,11 @@
         sharedElementBundle.putFloat(KEY_TRANSLATION_Z, view.getTranslationZ());
         sharedElementBundle.putFloat(KEY_ELEVATION, view.getElevation());
 
-        Parcelable bitmap = mListener.onCaptureSharedElementSnapshot(view, tempMatrix, tempBounds);
+        Parcelable bitmap = null;
+        if (mListener != null) {
+            bitmap = mListener.onCaptureSharedElementSnapshot(view, tempMatrix, tempBounds);
+        }
+
         if (bitmap != null) {
             sharedElementBundle.putParcelable(KEY_SNAPSHOT, bitmap);
         }
diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java
index 832e1e3..0092ee7 100644
--- a/core/java/android/app/BackStackRecord.java
+++ b/core/java/android/app/BackStackRecord.java
@@ -868,6 +868,9 @@
      */
     private void calculateFragments(SparseArray<Fragment> firstOutFragments,
             SparseArray<Fragment> lastInFragments) {
+        if (!mManager.mContainer.hasView()) {
+            return; // nothing to see, so no transitions
+        }
         Op op = mHead;
         while (op != null) {
             switch (op.cmd) {
@@ -923,6 +926,9 @@
      */
     public void calculateBackFragments(SparseArray<Fragment> firstOutFragments,
             SparseArray<Fragment> lastInFragments) {
+        if (!mManager.mContainer.hasView()) {
+            return; // nothing to see, so no transitions
+        }
         Op op = mHead;
         while (op != null) {
             switch (op.cmd) {
@@ -1104,7 +1110,8 @@
             final Transition enterTransition, final Transition sharedElementTransition,
             final Transition overallTransition, final View container,
             final Fragment inFragment, final Fragment outFragment,
-            final ArrayList<View> hiddenFragmentViews, final boolean isBack) {
+            final ArrayList<View> hiddenFragmentViews, final boolean isBack,
+            final ArrayList<View> sharedElementTargets) {
         if (enterTransition == null && sharedElementTransition == null &&
                 overallTransition == null) {
             return null;
@@ -1123,6 +1130,15 @@
                         ArrayMap<String, View> namedViews = null;
                         if (sharedElementTransition != null) {
                             namedViews = mapSharedElementsIn(state, isBack, inFragment);
+                            removeTargets(sharedElementTransition, sharedElementTargets);
+                            sharedElementTargets.clear();
+                            if (namedViews.isEmpty()) {
+                                sharedElementTargets.add(state.nonExistentView);
+                            } else {
+                                sharedElementTargets.addAll(namedViews.values());
+                            }
+
+                            addTargets(sharedElementTransition, sharedElementTargets);
 
                             setEpicenterIn(namedViews, state);
 
@@ -1203,11 +1219,17 @@
         Transition transition;
         if (overlap) {
             // Regular transition -- do it all together
-            transition = TransitionUtils.mergeTransitions(enterTransition, exitTransition,
-                    sharedElementTransition);
-            if (!(transition instanceof TransitionSet)) {
-                transition = new TransitionSet().addTransition(transition);
+            TransitionSet transitionSet = new TransitionSet();
+            if (enterTransition != null) {
+                transitionSet.addTransition(enterTransition);
             }
+            if (exitTransition != null) {
+                transitionSet.addTransition(exitTransition);
+            }
+            if (sharedElementTransition != null) {
+                transitionSet.addTransition(sharedElementTransition);
+            }
+            transition = transitionSet;
         } else {
             // First do exit, then enter, but allow shared element transition to happen
             // during both.
@@ -1268,8 +1290,15 @@
                 enterTransition.addTarget(state.nonExistentView);
             }
             ArrayMap<String, View> namedViews = null;
+            ArrayList<View> sharedElementTargets = new ArrayList<View>();
             if (sharedElementTransition != null) {
                 namedViews = remapSharedElements(state, outFragment, isBack);
+                if (namedViews.isEmpty()) {
+                    sharedElementTargets.add(state.nonExistentView);
+                } else {
+                    sharedElementTargets.addAll(namedViews.values());
+                }
+                addTargets(sharedElementTransition, sharedElementTargets);
 
                 // Notify the start of the transition.
                 SharedElementCallback callback = isBack ?
@@ -1306,7 +1335,7 @@
                 ArrayList<View> hiddenFragments = new ArrayList<View>();
                 ArrayList<View> enteringViews = addTransitionTargets(state, enterTransition,
                         sharedElementTransition, transition, sceneRoot, inFragment, outFragment,
-                        hiddenFragments, isBack);
+                        hiddenFragments, isBack, sharedElementTargets);
 
                 transition.setNameOverrides(state.nameOverrides);
                 // We want to exclude hidden views later, so we need a non-null list in the
@@ -1318,7 +1347,7 @@
                 // Remove the view targeting after the transition starts
                 removeTargetedViewsFromTransitions(sceneRoot, state.nonExistentView,
                         enterTransition, enteringViews, exitTransition, exitingViews,
-                        transition, hiddenFragments);
+                        sharedElementTransition, sharedElementTargets, transition, hiddenFragments);
             }
         }
     }
@@ -1331,8 +1360,9 @@
             final ViewGroup sceneRoot, final View nonExistingView,
             final Transition enterTransition, final ArrayList<View> enteringViews,
             final Transition exitTransition, final ArrayList<View> exitingViews,
+            final Transition sharedElementTransition, final ArrayList<View> sharedElementTargets,
             final Transition overallTransition, final ArrayList<View> hiddenViews) {
-        if (enterTransition != null || exitTransition != null) {
+        if (overallTransition != null) {
             sceneRoot.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                 @Override
                 public boolean onPreDraw() {
@@ -1344,6 +1374,9 @@
                     if (exitTransition != null) {
                         removeTargets(exitTransition, exitingViews);
                     }
+                    if (sharedElementTransition != null) {
+                        removeTargets(sharedElementTransition, sharedElementTargets);
+                    }
                     int numViews = hiddenViews.size();
                     for (int i = 0; i < numViews; i++) {
                         overallTransition.excludeTarget(hiddenViews.get(i), false);
diff --git a/core/java/android/app/EnterTransitionCoordinator.java b/core/java/android/app/EnterTransitionCoordinator.java
index 16a3575..216d6ba 100644
--- a/core/java/android/app/EnterTransitionCoordinator.java
+++ b/core/java/android/app/EnterTransitionCoordinator.java
@@ -306,7 +306,9 @@
         ArrayList<String> rejectedNames = new ArrayList<String>(mAllSharedElementNames);
         rejectedNames.removeAll(mSharedElementNames);
         ArrayList<View> rejectedSnapshots = createSnapshots(sharedElementState, rejectedNames);
-        mListener.onRejectSharedElements(rejectedSnapshots);
+        if (mListener != null) {
+            mListener.onRejectSharedElements(rejectedSnapshots);
+        }
         startRejectedAnimations(rejectedSnapshots);
 
         // Now start shared element transition
diff --git a/core/java/android/app/ExitTransitionCoordinator.java b/core/java/android/app/ExitTransitionCoordinator.java
index 812dfdb..d4d3eda 100644
--- a/core/java/android/app/ExitTransitionCoordinator.java
+++ b/core/java/android/app/ExitTransitionCoordinator.java
@@ -181,7 +181,10 @@
                 });
         setGhostVisibility(View.INVISIBLE);
         scheduleGhostVisibilityChange(View.INVISIBLE);
-        mListener.onSharedElementEnd(mSharedElementNames, mSharedElements, sharedElementSnapshots);
+        if (mListener != null) {
+            mListener.onSharedElementEnd(mSharedElementNames, mSharedElements,
+                    sharedElementSnapshots);
+        }
         TransitionManager.beginDelayedTransition(decorView, transition);
         scheduleGhostVisibilityChange(View.VISIBLE);
         setGhostVisibility(View.VISIBLE);
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index a95abab..5196834 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -2015,6 +2015,11 @@
                 }
                 return mView.findViewById(id);
             }
+
+            @Override
+            public boolean hasView() {
+                return (mView != null);
+            }
         }, this);
     }
 
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index ef69fdd..fc761fe 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -395,6 +395,7 @@
  */
 interface FragmentContainer {
     public View findViewById(int id);
+    public boolean hasView();
 }
 
 /**
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 13ed8d1..2eba29a 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2408,8 +2408,8 @@
     }
 
     /**
-     * Sets the name of the Managed profile. In the device owner case it sets the name of the user
-     * which it is called from. Only the profile owner or device owner can call this. If this is
+     * Sets the name of the profile. In the device owner case it sets the name of the user
+     * which it is called from. Only a profile owner or device owner can call this. If this is
      * never called by the profile or device owner, the name will be set to default values.
      *
      * @see #isProfileOwnerApp
@@ -2428,9 +2428,9 @@
 }
 
     /**
-     * Used to determine if a particular package is registered as the Profile Owner for the
+     * Used to determine if a particular package is registered as the profile owner for the
      * current user. A profile owner is a special device admin that has additional privileges
-     * within the managed profile.
+     * within the profile.
      *
      * @param packageName The package name of the app to compare with the registered profile owner.
      * @return Whether or not the package is registered as the profile owner.
@@ -2568,12 +2568,10 @@
 
     /**
      * Called by a profile or device owner to set the application restrictions for a given target
-     * application running in the managed profile.
+     * application running in the profile.
      *
      * <p>The provided {@link Bundle} consists of key-value pairs, where the types of values may be
-     * boolean, int, String, or String[]. The recommended format for keys
-     * is "com.example.packagename/example-setting" to avoid naming conflicts with library
-     * components such as {@link android.webkit.WebView}.
+     * boolean, int, String, or String[].
      *
      * <p>The application restrictions are only made visible to the target application and the
      * profile or device owner.
@@ -2645,8 +2643,8 @@
     }
 
     /**
-     * Called by a profile owner to set whether caller-Id information from the managed
-     * profile will be shown for incoming calls.
+     * Called by a profile owner of a managed profile to set whether caller-Id information from
+     * the managed profile will be shown in the parent profile, for incoming calls.
      *
      * <p>The calling device admin must be a profile owner. If it is not, a
      * security exception will be thrown.
@@ -2665,7 +2663,8 @@
     }
 
     /**
-     * Determine whether or not caller-Id information has been disabled.
+     * Called by a profile owner of a managed profile to determine whether or not caller-Id
+     * information has been disabled.
      *
      * <p>The calling device admin must be a profile owner. If it is not, a
      * security exception will be thrown.
@@ -2701,8 +2700,8 @@
     }
 
     /**
-     * Called by the profile owner so that some intents sent in the managed profile can also be
-     * resolved in the parent, or vice versa.
+     * Called by the profile owner of a managed profile so that some intents sent in the managed
+     * profile can also be resolved in the parent, or vice versa.
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
      * @param filter The {@link IntentFilter} the intent has to match to be also resolved in the
      * other profile
@@ -2720,8 +2719,8 @@
     }
 
     /**
-     * Called by a profile owner to remove the cross-profile intent filters that go from the
-     * managed profile to the parent, or from the parent to the managed profile.
+     * Called by a profile owner of a managed profile to remove the cross-profile intent filters
+     * that go from the managed profile to the parent, or from the parent to the managed profile.
      * Only removes those that have been set by the profile owner.
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
      */
@@ -2982,7 +2981,7 @@
 
     /**
      * Called by a profile or device owner to get the application restrictions for a given target
-     * application running in the managed profile.
+     * application running in the profile.
      *
      * <p>The calling device admin must be a profile or device owner; if it is not, a security
      * exception will be thrown.
@@ -3090,8 +3089,7 @@
 
     /**
      * Called by profile or device owner to re-enable a system app that was disabled by default
-     * when the managed profile was created. This can only be called from a profile or device
-     * owner running within a managed profile.
+     * when the user was initialized.
      *
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
      * @param packageName The package to be re-enabled in the current profile.
@@ -3108,8 +3106,7 @@
 
     /**
      * Called by profile or device owner to re-enable system apps by intent that were disabled
-     * by default when the managed profile was created. This can only be called from a profile
-     * or device owner running within a managed profile.
+     * by default when the user was initialized.
      *
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
      * @param intent An intent matching the app(s) to be installed. All apps that resolve for this
@@ -3391,10 +3388,10 @@
     }
 
     /**
-     * Called by the profile owner to enable widget providers from a given package
-     * to be available in the parent profile. As a result the user will be able to
+     * Called by the profile owner of a managed profile to enable widget providers from a
+     * given package to be available in the parent profile. As a result the user will be able to
      * add widgets from the white-listed package running under the profile to a widget
-     * host which runs under the device owner, for example the home screen. Note that
+     * host which runs under the parent profile, for example the home screen. Note that
      * a package may have zero or more provider components, where each component
      * provides a different widget type.
      * <p>
@@ -3420,8 +3417,8 @@
     }
 
     /**
-     * Called by the profile owner to disable widget providers from a given package
-     * to be available in the parent profile. For this method to take effect the
+     * Called by the profile owner of a managed profile to disable widget providers from a given
+     * package to be available in the parent profile. For this method to take effect the
      * package should have been added via {@link #addCrossProfileWidgetProvider(
      * android.content.ComponentName, String)}.
      * <p>
@@ -3448,7 +3445,7 @@
     }
 
     /**
-     * Called by the profile owner to query providers from which packages are
+     * Called by the profile owner of a managed profile to query providers from which packages are
      * available in the parent profile.
      *
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 53912e1..a19fbd3 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -3587,7 +3587,7 @@
      * creating new document tasks.
      *
      * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
-     * {@link #FLAG_ACTIVITY_NEW_TASK} is not also set.
+     * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
      *
      * <p>See
      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index ffde7ce..3364741 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -4675,6 +4675,28 @@
         return ai;
     }
 
+    public static ApplicationInfo generateApplicationInfo(ApplicationInfo ai, int flags,
+            PackageUserState state, int userId) {
+        if (ai == null) return null;
+        if (!checkUseInstalledOrHidden(flags, state)) {
+            return null;
+        }
+        // This is only used to return the ResolverActivity; we will just always
+        // make a copy.
+        ai = new ApplicationInfo(ai);
+        if (userId != 0) {
+            ai.uid = UserHandle.getUid(userId, ai.uid);
+            ai.dataDir = PackageManager.getDataDirForUser(userId, ai.packageName);
+        }
+        if (state.stopped) {
+            ai.flags |= ApplicationInfo.FLAG_STOPPED;
+        } else {
+            ai.flags &= ~ApplicationInfo.FLAG_STOPPED;
+        }
+        updateApplicationInfo(ai, flags, state);
+        return ai;
+    }
+
     public static final PermissionInfo generatePermissionInfo(
             Permission p, int flags) {
         if (p == null) return null;
@@ -4738,6 +4760,19 @@
         return ai;
     }
 
+    public static final ActivityInfo generateActivityInfo(ActivityInfo ai, int flags,
+            PackageUserState state, int userId) {
+        if (ai == null) return null;
+        if (!checkUseInstalledOrHidden(flags, state)) {
+            return null;
+        }
+        // This is only used to return the ResolverActivity; we will just always
+        // make a copy.
+        ai = new ActivityInfo(ai);
+        ai.applicationInfo = generateApplicationInfo(ai.applicationInfo, flags, state, userId);
+        return ai;
+    }
+
     public final static class Service extends Component<ServiceIntentInfo> {
         public final ServiceInfo info;
 
diff --git a/core/java/android/hardware/input/KeyboardLayout.java b/core/java/android/hardware/input/KeyboardLayout.java
index 5402e75..ed51402 100644
--- a/core/java/android/hardware/input/KeyboardLayout.java
+++ b/core/java/android/hardware/input/KeyboardLayout.java
@@ -29,6 +29,7 @@
     private final String mDescriptor;
     private final String mLabel;
     private final String mCollection;
+    private final int mPriority;
 
     public static final Parcelable.Creator<KeyboardLayout> CREATOR =
             new Parcelable.Creator<KeyboardLayout>() {
@@ -40,16 +41,18 @@
         }
     };
 
-    public KeyboardLayout(String descriptor, String label, String collection) {
+    public KeyboardLayout(String descriptor, String label, String collection, int priority) {
         mDescriptor = descriptor;
         mLabel = label;
         mCollection = collection;
+        mPriority = priority;
     }
 
     private KeyboardLayout(Parcel source) {
         mDescriptor = source.readString();
         mLabel = source.readString();
         mCollection = source.readString();
+        mPriority = source.readInt();
     }
 
     /**
@@ -90,11 +93,17 @@
         dest.writeString(mDescriptor);
         dest.writeString(mLabel);
         dest.writeString(mCollection);
+        dest.writeInt(mPriority);
     }
 
     @Override
     public int compareTo(KeyboardLayout another) {
-        int result = mLabel.compareToIgnoreCase(another.mLabel);
+        // Note that these arguments are intentionally flipped since you want higher priority
+        // keyboards to be listed before lower priority keyboards.
+        int result = Integer.compare(another.mPriority, mPriority);
+        if (result == 0) {
+            result = mLabel.compareToIgnoreCase(another.mLabel);
+        }
         if (result == 0) {
             result = mCollection.compareToIgnoreCase(another.mCollection);
         }
@@ -108,4 +117,4 @@
         }
         return mLabel + " - " + mCollection;
     }
-}
\ No newline at end of file
+}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 82016c3..2315c74 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -123,7 +123,8 @@
 
     /**
      * Specifies if a user is disallowed from transferring files over
-     * USB. This can only be set by device owners. The default value is <code>false</code>.
+     * USB. This can only be set by device owners and profile owners on the primary user.
+     * The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -178,8 +179,8 @@
 
     /**
      * Specifies if a user is disallowed from configuring Tethering
-     * & portable hotspots. This can only be set by device owners. The default value is
-     * <code>false</code>.
+     * & portable hotspots. This can only be set by device owners and profile owners on the
+     * primary user. The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -190,8 +191,8 @@
 
     /**
      * Specifies if a user is disallowed from factory resetting
-     * from Settings. This can only be set by device owners. The default value is
-     * <code>false</code>.
+     * from Settings. This can only be set by device owners and profile owners on the primary user.
+     * The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -202,7 +203,8 @@
 
     /**
      * Specifies if a user is disallowed from adding new users and
-     * profiles. This can only be set by device owners. The default value is <code>false</code>.
+     * profiles. This can only be set by device owners and profile owners on the primary user.
+     * The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -224,7 +226,8 @@
 
     /**
      * Specifies if a user is disallowed from configuring cell
-     * broadcasts. This can only be set by device owners. The default value is <code>false</code>.
+     * broadcasts. This can only be set by device owners and profile owners on the primary user.
+     * The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -235,7 +238,8 @@
 
     /**
      * Specifies if a user is disallowed from configuring mobile
-     * networks. This can only be set by device owners. The default value is <code>false</code>.
+     * networks. This can only be set by device owners and profile owners on the primary user.
+     * The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -266,8 +270,8 @@
 
     /**
      * Specifies if a user is disallowed from mounting
-     * physical external media. This can only be set by device owners. The default value is
-     * <code>false</code>.
+     * physical external media. This can only be set by device owners and profile owners on the
+     * primary user. The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -278,8 +282,8 @@
 
     /**
      * Specifies if a user is disallowed from adjusting microphone
-     * volume. If set, the microphone will be muted. This can only be set by device owners.
-     * The default value is <code>false</code>.
+     * volume. If set, the microphone will be muted. This can only be set by device owners
+     * and profile owners on the primary user. The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -290,8 +294,8 @@
 
     /**
      * Specifies if a user is disallowed from adjusting the master
-     * volume. If set, the master volume will be muted. This can only be set by device owners.
-     * The default value is <code>false</code>.
+     * volume. If set, the master volume will be muted. This can only be set by device owners
+     * and profile owners on the primary user. The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -314,7 +318,7 @@
 
     /**
      * Specifies that the user is not allowed to send or receive
-     * SMS messages. This can only be set by device owners. The default value is <code>false</code>.
+     * SMS messages. The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
@@ -333,7 +337,8 @@
      * <li>{@link LayoutParams#TYPE_SYSTEM_ERROR}</li>
      * <li>{@link LayoutParams#TYPE_SYSTEM_OVERLAY}</li>
      *
-     * <p>This can only be set by device owners. The default value is <code>false</code>.
+     * <p>This can only be set by device owners and profile owners on the primary user.
+     * The default value is <code>false</code>.
      *
      * <p/>Key for user restrictions.
      * <p/>Type: Boolean
diff --git a/core/java/android/transition/Transition.java b/core/java/android/transition/Transition.java
index c850f71..6dede46 100644
--- a/core/java/android/transition/Transition.java
+++ b/core/java/android/transition/Transition.java
@@ -1443,9 +1443,9 @@
                 values.targetedTransitions.add(this);
                 capturePropagationValues(values);
                 if (start) {
-                    mStartValues.viewValues.put(view, values);
+                    addViewValues(mStartValues, view, values);
                 } else {
-                    mEndValues.viewValues.put(view, values);
+                    addViewValues(mEndValues, view, values);
                 }
             }
         } else {
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index 5f37042..1546877 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -209,7 +209,7 @@
         mFactory = original.mFactory;
         mFactory2 = original.mFactory2;
         mPrivateFactory = original.mPrivateFactory;
-        mFilter = original.mFilter;
+        setFilter(original.mFilter);
     }
     
     /**
diff --git a/core/java/android/view/inputmethod/InputMethodInfo.java b/core/java/android/view/inputmethod/InputMethodInfo.java
index 0a8e4b9..11d0f4a 100644
--- a/core/java/android/view/inputmethod/InputMethodInfo.java
+++ b/core/java/android/view/inputmethod/InputMethodInfo.java
@@ -27,6 +27,7 @@
 import android.content.pm.ResolveInfo;
 import android.content.pm.ServiceInfo;
 import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
 import android.content.res.TypedArray;
 import android.content.res.XmlResourceParser;
 import android.graphics.drawable.Drawable;
@@ -421,7 +422,7 @@
             }
             final Resources res = context.createPackageContext(getPackageName(), 0).getResources();
             return res.getBoolean(getIsDefaultResourceId());
-        } catch (NameNotFoundException e) {
+        } catch (NameNotFoundException | NotFoundException e) {
             return false;
         }
     }
diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java
index 033b99a..6925756 100644
--- a/core/java/android/widget/EdgeEffect.java
+++ b/core/java/android/widget/EdgeEffect.java
@@ -120,7 +120,7 @@
         final TypedArray a = context.obtainStyledAttributes(
                 com.android.internal.R.styleable.EdgeEffect);
         final int themeColor = a.getColor(
-                com.android.internal.R.styleable.EdgeEffect_colorPrimary, 0xff666666);
+                com.android.internal.R.styleable.EdgeEffect_colorEdgeEffect, 0xff666666);
         a.recycle();
         mPaint.setColor((themeColor & 0xffffff) | 0x33000000);
         mPaint.setStyle(Paint.Style.FILL);
diff --git a/core/java/android/widget/RadialTimePickerView.java b/core/java/android/widget/RadialTimePickerView.java
index 0460282..56f126c 100644
--- a/core/java/android/widget/RadialTimePickerView.java
+++ b/core/java/android/widget/RadialTimePickerView.java
@@ -557,7 +557,7 @@
             if (mIsOnInnerCircle && hour == 0) {
                 // Inner circle is 1 through 12.
                 hour = 12;
-            } else if (hour != 0) {
+            } else if (!mIsOnInnerCircle && hour != 0) {
                 // Outer circle is 13 through 23 and 0.
                 hour += 12;
             }
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 1573106..1f4105f 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -905,6 +905,20 @@
     return result;
 }
 
+/** Create a Java string from an ASCII or Latin-1 string */
+jstring AndroidRuntime::NewStringLatin1(JNIEnv* env, const char* bytes) {
+    if (!bytes) return NULL;
+    int length = strlen(bytes);
+    jchar* buffer = (jchar *)alloca(length * sizeof(jchar));
+    if (!buffer) return NULL;
+    jchar* chp = buffer;
+    for (int i = 0; i < length; i++) {
+        *chp++ = *bytes++;
+    }
+    return env->NewString(buffer, length);
+}
+
+
 /*
  * Start the Android runtime.  This involves starting the virtual machine
  * and calling the "static void main(String[] args)" method in the class
diff --git a/core/res/res/values-mcc204-mnc04/config.xml b/core/res/res/values-mcc204-mnc04/config.xml
index 7a48342..b89a311 100644
--- a/core/res/res/values-mcc204-mnc04/config.xml
+++ b/core/res/res/values-mcc204-mnc04/config.xml
@@ -25,4 +25,9 @@
     -->
     <integer name="config_mobile_mtu">1358</integer>
 
+    <!-- service number convert map in roaming network. -->
+    <!-- [dialstring],[replacement][,optional gid] -->
+    <string-array translatable="false" name="dial_string_replace">
+        <item>"*611:+19085594899,BAE0000000000000"</item>
+    </string-array>
 </resources>
diff --git a/core/res/res/values-mcc311-mnc480/config.xml b/core/res/res/values-mcc311-mnc480/config.xml
index cf19235..d01d9f8 100644
--- a/core/res/res/values-mcc311-mnc480/config.xml
+++ b/core/res/res/values-mcc311-mnc480/config.xml
@@ -44,4 +44,8 @@
     <bool name="config_carrier_volte_vt_available">false</bool>
 
     <bool name="config_auto_attach_data_on_creation">false</bool>
+    <!-- service number convert map in roaming network. -->
+    <string-array translatable="false" name="dial_string_replace">
+        <item>"*611:+19085594899,"</item>
+    </string-array>
 </resources>
diff --git a/core/res/res/values-sw600dp/dimens_material.xml b/core/res/res/values-sw600dp/dimens_material.xml
index e0aac38..2547b7a 100644
--- a/core/res/res/values-sw600dp/dimens_material.xml
+++ b/core/res/res/values-sw600dp/dimens_material.xml
@@ -16,9 +16,9 @@
 <resources>
 
     <!-- Use the default title sizes on tablets. -->
-    <dimen name="text_size_title_material_toolbar">@dimen/text_size_title_material</dimen>
+    <dimen name="text_size_title_material_toolbar">20dp</dimen>
     <!-- Use the default subtitle sizes on tablets. -->
-    <dimen name="text_size_subtitle_material_toolbar">@dimen/text_size_subhead_material</dimen>
+    <dimen name="text_size_subtitle_material_toolbar">16dp</dimen>
     <!-- Default height of an action bar. -->
     <dimen name="action_bar_default_height_material">64dp</dimen>
     <!-- Default padding of an action bar. -->
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 85c1072..90217e5 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -1020,6 +1020,9 @@
         <!-- The color applied to framework switch thumbs in their normal state. -->
         <attr name="colorSwitchThumbNormal" format="color" />
 
+        <!-- The color applied to the edge effect on scrolling containers. -->
+        <attr name="colorEdgeEffect" format="color" />
+
         <!-- =================== -->
         <!-- Lighting properties -->
         <!-- =================== -->
@@ -7435,7 +7438,7 @@
 
     <!-- Used as a filter array on the theme to pull out only the EdgeEffect-relevant bits. -->
     <declare-styleable name="EdgeEffect">
-        <attr name="colorPrimary" />
+        <attr name="colorEdgeEffect" />
     </declare-styleable>
 
     <!-- Use <code>tv-input</code> as the root tag of the XML resource that describes a
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 949c38c..c5d3c57 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1814,4 +1814,9 @@
 
     <!--SIM does not save, but the voice mail number to be changed. -->
     <bool name="editable_voicemailnumber">false</bool>
+
+    <!-- service number convert map in roaming network. -->
+    <!-- [dialstring],[replacement][,optional gid] -->
+    <string-array translatable="false" name="dial_string_replace">
+    </string-array>
 </resources>
diff --git a/core/res/res/values/dimens_material.xml b/core/res/res/values/dimens_material.xml
index ac5890a..9836757 100644
--- a/core/res/res/values/dimens_material.xml
+++ b/core/res/res/values/dimens_material.xml
@@ -42,8 +42,8 @@
     <dimen name="text_size_headline_material">24sp</dimen>
     <dimen name="text_size_title_material">20sp</dimen>
     <dimen name="text_size_subhead_material">16sp</dimen>
-    <dimen name="text_size_title_material_toolbar">@dimen/text_size_title_material</dimen>
-    <dimen name="text_size_subtitle_material_toolbar">@dimen/text_size_subhead_material</dimen>
+    <dimen name="text_size_title_material_toolbar">20dp</dimen>
+    <dimen name="text_size_subtitle_material_toolbar">16dp</dimen>
     <dimen name="text_size_menu_material">16sp</dimen>
     <dimen name="text_size_body_2_material">14sp</dimen>
     <dimen name="text_size_body_1_material">14sp</dimen>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index bbd40a1..a794b62 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2291,6 +2291,7 @@
     <public type="attr" name="strokeAlpha" id="0x010104cb" />
     <public type="attr" name="fillAlpha" id="0x010104cc" />
     <public type="attr" name="windowActivityTransitions" id="0x010104cd" />
+    <public type="attr" name="colorEdgeEffect" id="0x010104ce" />
 
     <public type="id" name="mask" id="0x0102002e" />
     <public type="id" name="statusBarBackground" id="0x0102002f" />
diff --git a/core/res/res/values/removed.xml b/core/res/res/values/removed.xml
deleted file mode 100644
index 8eaca29..0000000
--- a/core/res/res/values/removed.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<!-- Placeholder resources to be removed before release. -->
-<resources>
-    <style name="__removed1" />
-    <attr name="__removed2" />
-    <style name="__removed3" />
-    <style name="__removed4" />
-    <style name="__removed5" />
-    <style name="__removed6" />
-    <style name="__removed7" />
-</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index ed43faf..edcfb8b 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2065,4 +2065,5 @@
   <java-symbol type="integer" name="config_cdma_3waycall_flash_delay"/>
   <java-symbol type="attr" name="windowBackgroundFallback" />
   <java-symbol type="id" name="textSpacerNoButtons" />
+  <java-symbol type="array" name="dial_string_replace" />
 </resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 0577659..3a268a3 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -59,6 +59,7 @@
         <item name="colorControlNormal">@color/legacy_control_normal</item>
         <item name="colorControlHighlight">@color/legacy_button_pressed</item>
         <item name="colorButtonNormal">@color/legacy_button_normal</item>
+        <item name="colorEdgeEffect">?attr/colorPrimary</item>
 
         <item name="disabledAlpha">0.5</item>
         <item name="backgroundDimAmount">0.6</item>
diff --git a/core/res/res/values/themes_holo.xml b/core/res/res/values/themes_holo.xml
index 14853b8..208db97 100644
--- a/core/res/res/values/themes_holo.xml
+++ b/core/res/res/values/themes_holo.xml
@@ -81,6 +81,7 @@
         <item name="colorControlNormal">@color/holo_control_normal</item>
         <item name="colorControlHighlight">@color/holo_button_pressed</item>
         <item name="colorButtonNormal">@color/holo_button_normal</item>
+        <item name="colorEdgeEffect">?attr/colorPrimary</item>
 
         <!-- Text styles -->
         <item name="textAppearance">@style/TextAppearance.Holo</item>
diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml
index ebff965..ebf0571 100644
--- a/core/res/res/values/themes_material.xml
+++ b/core/res/res/values/themes_material.xml
@@ -375,6 +375,7 @@
         <item name="colorPrimaryDark">@color/material_blue_grey_900</item>
         <item name="colorPrimary">@color/material_blue_grey_800</item>
         <item name="colorAccent">@color/material_deep_teal_200</item>
+        <item name="colorEdgeEffect">?attr/colorPrimary</item>
 
         <item name="colorControlNormal">?attr/textColorSecondary</item>
         <item name="colorControlActivated">?attr/colorAccent</item>
@@ -978,6 +979,7 @@
         <item name="listViewStyle">@style/Widget.Material.ListView</item>
         <item name="windowAnimationStyle">@style/Animation.DropDownUp</item>
         <item name="background">@null</item>
+        <item name="windowElevation">@dimen/floating_window_z</item>
     </style>
 
     <style name="Theme.Material.Light.CompactMenu">
@@ -986,6 +988,7 @@
         <item name="listViewStyle">@style/Widget.Material.Light.ListView</item>
         <item name="windowAnimationStyle">@style/Animation.DropDownUp</item>
         <item name="background">@null</item>
+        <item name="windowElevation">@dimen/floating_window_z</item>
     </style>
 
     <!-- Dialog themes for Material -->
diff --git a/graphics/java/android/graphics/ColorMatrixColorFilter.java b/graphics/java/android/graphics/ColorMatrixColorFilter.java
index 7822c41..291c8ff 100644
--- a/graphics/java/android/graphics/ColorMatrixColorFilter.java
+++ b/graphics/java/android/graphics/ColorMatrixColorFilter.java
@@ -58,6 +58,8 @@
      * any effect until you call {@link #setColorMatrix(ColorMatrix)}.
      *
      * @see #setColorMatrix(ColorMatrix)
+     *
+     * @hide
      */
     public ColorMatrix getColorMatrix() {
         return mMatrix;
@@ -73,6 +75,8 @@
      * @see #getColorMatrix()
      * @see android.graphics.ColorMatrix#reset()
      * @see #setColorMatrix(float[])
+     *
+     * @hide
      */
     public void setColorMatrix(ColorMatrix matrix) {
         if (matrix == null) {
@@ -98,6 +102,8 @@
      *
      * @throws ArrayIndexOutOfBoundsException if the specified array's
      *         length is < 20
+     *
+     * @hide
      */
     public void setColorMatrix(float[] array) {
         if (array == null) {
diff --git a/graphics/java/android/graphics/LightingColorFilter.java b/graphics/java/android/graphics/LightingColorFilter.java
index 70a3fe8..ad78430 100644
--- a/graphics/java/android/graphics/LightingColorFilter.java
+++ b/graphics/java/android/graphics/LightingColorFilter.java
@@ -44,9 +44,6 @@
      * Create a colorfilter that multiplies the RGB channels by one color,
      * and then adds a second color. The alpha components of the mul and add
      * arguments are ignored.
-     *
-     * @see #setColorMultiply(int)
-     * @see #setColorAdd(int)
      */
     public LightingColorFilter(int mul, int add) {
         mMul = mul;
@@ -59,6 +56,8 @@
      * color filter is applied.
      *
      * @see #setColorMultiply(int)
+     *
+     * @hide
      */
     public int getColorMultiply() {
         return mMul;
@@ -70,6 +69,8 @@
      * The alpha channel of this color is ignored.
      *
      * @see #getColorMultiply()
+     *
+     * @hide
      */
     public void setColorMultiply(int mul) {
         mMul = mul;
@@ -81,6 +82,8 @@
      * when the color filter is applied.
      *
      * @see #setColorAdd(int)
+     *
+     * @hide
      */
     public int getColorAdd() {
         return mAdd;
@@ -92,6 +95,8 @@
      * The alpha channel of this color is ignored.
      *
      * @see #getColorAdd()
+     *
+     * @hide
      */
     public void setColorAdd(int add) {
         mAdd = add;
diff --git a/graphics/java/android/graphics/PorterDuffColorFilter.java b/graphics/java/android/graphics/PorterDuffColorFilter.java
index ff768b7..fe4f8b8 100644
--- a/graphics/java/android/graphics/PorterDuffColorFilter.java
+++ b/graphics/java/android/graphics/PorterDuffColorFilter.java
@@ -46,6 +46,8 @@
      *
      * @see Color
      * @see #setColor(int)
+     *
+     * @hide
      */
     public int getColor() {
         return mColor;
@@ -74,6 +76,8 @@
      *
      * @see PorterDuff
      * @see #setMode(android.graphics.PorterDuff.Mode)
+     *
+     * @hide
      */
     public PorterDuff.Mode getMode() {
         return mMode;
diff --git a/include/android_runtime/AndroidRuntime.h b/include/android_runtime/AndroidRuntime.h
index f3cfd97..fc33b7e 100644
--- a/include/android_runtime/AndroidRuntime.h
+++ b/include/android_runtime/AndroidRuntime.h
@@ -113,6 +113,9 @@
     /** return a new string corresponding to 'className' with all '.'s replaced by '/'s. */
     static char* toSlashClassName(const char* className);
 
+    /** Create a Java string from an ASCII or Latin-1 string */
+    static jstring NewStringLatin1(JNIEnv* env, const char* bytes);
+
 private:
     static int startReg(JNIEnv* env);
     bool parseRuntimeOption(const char* property,
diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h
index c65efe4..ac5eca08 100644
--- a/include/androidfw/ResourceTypes.h
+++ b/include/androidfw/ResourceTypes.h
@@ -1521,6 +1521,8 @@
 
     bool getResourceName(uint32_t resID, bool allowUtf8, resource_name* outName) const;
 
+    bool getResourceFlags(uint32_t resID, uint32_t* outFlags) const;
+
     /**
      * Retrieve the value of a resource.  If the resource is found, returns a
      * value >= 0 indicating the table it is in (for use with
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 690b1d6..8cef137 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -5393,6 +5393,44 @@
     return NULL;
 }
 
+bool ResTable::getResourceFlags(uint32_t resID, uint32_t* outFlags) const {
+    if (mError != NO_ERROR) {
+        return false;
+    }
+
+    const ssize_t p = getResourcePackageIndex(resID);
+    const int t = Res_GETTYPE(resID);
+    const int e = Res_GETENTRY(resID);
+
+    if (p < 0) {
+        if (Res_GETPACKAGE(resID)+1 == 0) {
+            ALOGW("No package identifier when getting flags for resource number 0x%08x", resID);
+        } else {
+            ALOGW("No known package when getting flags for resource number 0x%08x", resID);
+        }
+        return false;
+    }
+    if (t < 0) {
+        ALOGW("No type identifier when getting flags for resource number 0x%08x", resID);
+        return false;
+    }
+
+    const PackageGroup* const grp = mPackageGroups[p];
+    if (grp == NULL) {
+        ALOGW("Bad identifier when getting flags for resource number 0x%08x", resID);
+        return false;
+    }
+
+    Entry entry;
+    status_t err = getEntry(grp, t, e, NULL, &entry);
+    if (err != NO_ERROR) {
+        return false;
+    }
+
+    *outFlags = entry.specFlags;
+    return true;
+}
+
 status_t ResTable::getEntry(
         const PackageGroup* packageGroup, int typeIndex, int entryIndex,
         const ResTable_config* config,
diff --git a/libs/androidfw/tests/data/basic/build b/libs/androidfw/tests/data/basic/build
index fa4a9fe0..036e468 100755
--- a/libs/androidfw/tests/data/basic/build
+++ b/libs/androidfw/tests/data/basic/build
@@ -1,6 +1,8 @@
 #!/bin/bash
 
-aapt package -M AndroidManifest.xml -S res --split fr,de -F bundle.apk -f && \
+PATH_TO_FRAMEWORK_RES=$(gettop)/prebuilts/sdk/current/android.jar
+
+aapt package -M AndroidManifest.xml -S res -I $PATH_TO_FRAMEWORK_RES --split fr,de -F bundle.apk -f && \
 unzip bundle.apk resources.arsc && \
 mv resources.arsc basic.arsc && \
 xxd -i basic.arsc > basic_arsc.h && \
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 9b0025f..f0bf7b2 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -377,6 +377,7 @@
     }
 
     clearGarbage();
+    glFinish();
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 25ea729..ce1d09f 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -134,6 +134,8 @@
         , mExtensions(Extensions::getInstance())
         , mRenderState(renderState)
         , mScissorOptimizationDisabled(false)
+        , mSuppressTiling(false)
+        , mFirstFrameAfterResize(true)
         , mCountOverdraw(false)
         , mLightCenter((Vector3){FLT_MIN, FLT_MIN, FLT_MIN})
         , mLightRadius(FLT_MIN)
@@ -179,6 +181,7 @@
     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
 
     glEnableVertexAttribArray(Program::kBindingPosition);
+    mFirstFrameAfterResize = true;
 }
 
 void OpenGLRenderer::setupFrameState(float left, float top,
@@ -202,7 +205,9 @@
     // Functors break the tiling extension in pretty spectacular ways
     // This ensures we don't use tiling when a functor is going to be
     // invoked during the frame
-    mSuppressTiling = mCaches.hasRegisteredFunctors();
+    mSuppressTiling = mCaches.hasRegisteredFunctors()
+            || mFirstFrameAfterResize;
+    mFirstFrameAfterResize = false;
 
     startTilingCurrentClip(true);
 
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index e295b1a..47ef1a9 100755
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -1013,6 +1013,7 @@
 
     // No-ops start/endTiling when set
     bool mSuppressTiling;
+    bool mFirstFrameAfterResize;
 
     // If true, this renderer will setup drawing to emulate
     // an increment stencil buffer in the color buffer
diff --git a/libs/hwui/StatefulBaseRenderer.cpp b/libs/hwui/StatefulBaseRenderer.cpp
index 12b8c8d..88d6f68 100644
--- a/libs/hwui/StatefulBaseRenderer.cpp
+++ b/libs/hwui/StatefulBaseRenderer.cpp
@@ -49,6 +49,13 @@
     mHeight = height;
     mFirstSnapshot->initializeViewport(width, height);
     onViewportInitialized();
+
+    // create a temporary 1st snapshot, so old snapshots are released,
+    // and viewport can be queried safely.
+    // TODO: remove, combine viewport + save stack initialization
+    mSnapshot = new Snapshot(mFirstSnapshot,
+            SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
+    mSaveCount = 1;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 832d170..1c416a7 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -119,10 +119,10 @@
     stopDrawing();
 }
 
+// TODO: don't pass viewport size, it's automatic via EGL
 void CanvasContext::setup(int width, int height, const Vector3& lightCenter, float lightRadius,
         uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) {
     if (!mCanvas) return;
-    mCanvas->setViewport(width, height);
     mCanvas->initLight(lightCenter, lightRadius, ambientShadowAlpha, spotShadowAlpha);
 }
 
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index 33cab8f..2b40903 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -146,7 +146,7 @@
     /**
      * Called when the emergency call button is pressed.
      */
-    void onEmergencyCallAction() { }
+    public void onEmergencyCallAction() { }
 
     /**
      * Called when the transport background changes.
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
index a4555f1..f779f87 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
@@ -110,13 +110,13 @@
         mRenderer.close(callback);
     }
 
-    public void destroy() {
+    public void destroy(Runnable callback) {
         throwIfNotClosed();
         mState = STATE_DESTROYED;
         if (DEBUG) {
             Log.i(LOG_TAG, "STATE_DESTROYED");
         }
-        doDestroy();
+        doDestroy(callback);
     }
 
     public void startPreload(int firstShownPage, int lastShownPage) {
@@ -163,19 +163,19 @@
         try {
             if (mState != STATE_DESTROYED) {
                 mCloseGuard.warnIfOpen();
-                doDestroy();
+                doDestroy(null);
             }
         } finally {
             super.finalize();
         }
     }
 
-    private void doDestroy() {
+    private void doDestroy(Runnable callback) {
         mState = STATE_DESTROYED;
         if (DEBUG) {
             Log.i(LOG_TAG, "STATE_DESTROYED");
         }
-        mRenderer.destroy();
+        mRenderer.destroy(callback);
     }
 
     private void throwIfNotOpened() {
@@ -536,7 +536,7 @@
             }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
         }
 
-        public void destroy() {
+        public void destroy(final Runnable callback) {
             new AsyncTask<Void, Void, Void>() {
                 @Override
                 protected Void doInBackground(Void... params) {
@@ -551,6 +551,10 @@
                     }
                     mPageContentCache.invalidate();
                     mPageContentCache.clear();
+                    if (callback != null) {
+                        callback.run();
+                    }
+
                 }
             }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
         }
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
index da8160a..20e774f 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
@@ -488,9 +488,9 @@
         return selectedPages;
     }
 
-    public void destroy() {
+    public void destroy(Runnable callback) {
         throwIfNotClosed();
-        doDestroy();
+        doDestroy(callback);
     }
 
     @Override
@@ -498,7 +498,7 @@
         try {
             if (mState != STATE_DESTROYED) {
                 mCloseGuard.warnIfOpen();
-                doDestroy();
+                doDestroy(null);
             }
         } finally {
             super.finalize();
@@ -745,8 +745,8 @@
         mPageContentRepository.stopPreload();
     }
 
-    private void doDestroy() {
-        mPageContentRepository.destroy();
+    private void doDestroy(Runnable callback) {
+        mPageContentRepository.destroy(callback);
         mCloseGuard.close();
         mState = STATE_DESTROYED;
         if (DEBUG) {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index c4b3262..56497d7 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -1562,12 +1562,18 @@
         if (mState != STATE_INITIALIZING) {
             mProgressMessageController.cancel();
             mPrinterRegistry.setTrackedPrinter(null);
-            mPrintPreviewController.destroy();
             mSpoolerProvider.destroy();
             mPrintedDocument.finish();
             mPrintedDocument.destroy();
+            mPrintPreviewController.destroy(new Runnable() {
+                @Override
+                public void run() {
+                    finish();
+                }
+            });
+        } else {
+            finish();
         }
-        finish();
     }
 
     private final class SpinnerItem<T> {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java
index 0d45352..e4eab10 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java
@@ -192,12 +192,15 @@
         });
     }
 
-    public void destroy() {
+    public void destroy(Runnable callback) {
         if (mPageAdapter.isOpened()) {
-            mPageAdapter.close(null);
+            Message operation = mHandler.obtainMessage(MyHandler.MSG_CLOSE);
+            mHandler.enqueueOperation(operation);
         }
-        mRecyclerView.setAdapter(null);
-        mPageAdapter.destroy();
+
+        Message operation = mHandler.obtainMessage(MyHandler.MSG_DESTROY);
+        operation.obj = callback;
+        mHandler.enqueueOperation(operation);
     }
 
     @Override
@@ -292,7 +295,9 @@
                 } break;
 
                 case MSG_DESTROY: {
-                    mPageAdapter.destroy();
+                    Runnable callback = (Runnable) message.obj;
+                    mRecyclerView.setAdapter(null);
+                    mPageAdapter.destroy(callback);
                     handleNextOperation();
                 } break;
 
diff --git a/packages/SettingsProvider/res/values-af/defaults.xml b/packages/SettingsProvider/res/values-af/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-af/defaults.xml
+++ b/packages/SettingsProvider/res/values-af/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-am/defaults.xml b/packages/SettingsProvider/res/values-am/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-am/defaults.xml
+++ b/packages/SettingsProvider/res/values-am/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-bg/defaults.xml b/packages/SettingsProvider/res/values-bg/defaults.xml
index 5e46120..aee229e 100644
--- a/packages/SettingsProvider/res/values-bg/defaults.xml
+++ b/packages/SettingsProvider/res/values-bg/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s от %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-bn-rBD/defaults.xml b/packages/SettingsProvider/res/values-bn-rBD/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-bn-rBD/defaults.xml
+++ b/packages/SettingsProvider/res/values-bn-rBD/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ca/defaults.xml b/packages/SettingsProvider/res/values-ca/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ca/defaults.xml
+++ b/packages/SettingsProvider/res/values-ca/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-cs/defaults.xml b/packages/SettingsProvider/res/values-cs/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-cs/defaults.xml
+++ b/packages/SettingsProvider/res/values-cs/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-da/defaults.xml b/packages/SettingsProvider/res/values-da/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-da/defaults.xml
+++ b/packages/SettingsProvider/res/values-da/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-de/defaults.xml b/packages/SettingsProvider/res/values-de/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-de/defaults.xml
+++ b/packages/SettingsProvider/res/values-de/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-el/defaults.xml b/packages/SettingsProvider/res/values-el/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-el/defaults.xml
+++ b/packages/SettingsProvider/res/values-el/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-en-rGB/defaults.xml b/packages/SettingsProvider/res/values-en-rGB/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-en-rGB/defaults.xml
+++ b/packages/SettingsProvider/res/values-en-rGB/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-en-rIN/defaults.xml b/packages/SettingsProvider/res/values-en-rIN/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-en-rIN/defaults.xml
+++ b/packages/SettingsProvider/res/values-en-rIN/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-es-rUS/defaults.xml b/packages/SettingsProvider/res/values-es-rUS/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-es-rUS/defaults.xml
+++ b/packages/SettingsProvider/res/values-es-rUS/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-es/defaults.xml b/packages/SettingsProvider/res/values-es/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-es/defaults.xml
+++ b/packages/SettingsProvider/res/values-es/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-et-rEE/defaults.xml b/packages/SettingsProvider/res/values-et-rEE/defaults.xml
index 790297a..71e91ae 100644
--- a/packages/SettingsProvider/res/values-et-rEE/defaults.xml
+++ b/packages/SettingsProvider/res/values-et-rEE/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s, %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-eu-rES/defaults.xml b/packages/SettingsProvider/res/values-eu-rES/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-eu-rES/defaults.xml
+++ b/packages/SettingsProvider/res/values-eu-rES/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-fi/defaults.xml b/packages/SettingsProvider/res/values-fi/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-fi/defaults.xml
+++ b/packages/SettingsProvider/res/values-fi/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-fr-rCA/defaults.xml b/packages/SettingsProvider/res/values-fr-rCA/defaults.xml
index 15da9d2..beba56e 100644
--- a/packages/SettingsProvider/res/values-fr-rCA/defaults.xml
+++ b/packages/SettingsProvider/res/values-fr-rCA/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s de %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-fr/defaults.xml b/packages/SettingsProvider/res/values-fr/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-fr/defaults.xml
+++ b/packages/SettingsProvider/res/values-fr/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-gl-rES/defaults.xml b/packages/SettingsProvider/res/values-gl-rES/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-gl-rES/defaults.xml
+++ b/packages/SettingsProvider/res/values-gl-rES/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-hi/defaults.xml b/packages/SettingsProvider/res/values-hi/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-hi/defaults.xml
+++ b/packages/SettingsProvider/res/values-hi/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-hr/defaults.xml b/packages/SettingsProvider/res/values-hr/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-hr/defaults.xml
+++ b/packages/SettingsProvider/res/values-hr/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-hu/defaults.xml b/packages/SettingsProvider/res/values-hu/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-hu/defaults.xml
+++ b/packages/SettingsProvider/res/values-hu/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-hy-rAM/defaults.xml b/packages/SettingsProvider/res/values-hy-rAM/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-hy-rAM/defaults.xml
+++ b/packages/SettingsProvider/res/values-hy-rAM/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-in/defaults.xml b/packages/SettingsProvider/res/values-in/defaults.xml
index 3627c9b..012a65f 100644
--- a/packages/SettingsProvider/res/values-in/defaults.xml
+++ b/packages/SettingsProvider/res/values-in/defaults.xml
@@ -20,6 +20,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
+    <!-- String.format failed for translation -->
     <!-- no translation found for def_device_name_simple (9037785625140748221) -->
     <skip />
 </resources>
diff --git a/packages/SettingsProvider/res/values-is-rIS/defaults.xml b/packages/SettingsProvider/res/values-is-rIS/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-is-rIS/defaults.xml
+++ b/packages/SettingsProvider/res/values-is-rIS/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-it/defaults.xml b/packages/SettingsProvider/res/values-it/defaults.xml
index 18d0b93..3ea32a1 100644
--- a/packages/SettingsProvider/res/values-it/defaults.xml
+++ b/packages/SettingsProvider/res/values-it/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ja/defaults.xml b/packages/SettingsProvider/res/values-ja/defaults.xml
index 18d0b93..3ea32a1 100644
--- a/packages/SettingsProvider/res/values-ja/defaults.xml
+++ b/packages/SettingsProvider/res/values-ja/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ka-rGE/defaults.xml b/packages/SettingsProvider/res/values-ka-rGE/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ka-rGE/defaults.xml
+++ b/packages/SettingsProvider/res/values-ka-rGE/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-kk-rKZ/defaults.xml b/packages/SettingsProvider/res/values-kk-rKZ/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-kk-rKZ/defaults.xml
+++ b/packages/SettingsProvider/res/values-kk-rKZ/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-km-rKH/defaults.xml b/packages/SettingsProvider/res/values-km-rKH/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-km-rKH/defaults.xml
+++ b/packages/SettingsProvider/res/values-km-rKH/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-kn-rIN/defaults.xml b/packages/SettingsProvider/res/values-kn-rIN/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-kn-rIN/defaults.xml
+++ b/packages/SettingsProvider/res/values-kn-rIN/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ko/defaults.xml b/packages/SettingsProvider/res/values-ko/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ko/defaults.xml
+++ b/packages/SettingsProvider/res/values-ko/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ky-rKG/defaults.xml b/packages/SettingsProvider/res/values-ky-rKG/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ky-rKG/defaults.xml
+++ b/packages/SettingsProvider/res/values-ky-rKG/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-lo-rLA/defaults.xml b/packages/SettingsProvider/res/values-lo-rLA/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-lo-rLA/defaults.xml
+++ b/packages/SettingsProvider/res/values-lo-rLA/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-lt/defaults.xml b/packages/SettingsProvider/res/values-lt/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-lt/defaults.xml
+++ b/packages/SettingsProvider/res/values-lt/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-lv/defaults.xml b/packages/SettingsProvider/res/values-lv/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-lv/defaults.xml
+++ b/packages/SettingsProvider/res/values-lv/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-mk-rMK/defaults.xml b/packages/SettingsProvider/res/values-mk-rMK/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-mk-rMK/defaults.xml
+++ b/packages/SettingsProvider/res/values-mk-rMK/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ml-rIN/defaults.xml b/packages/SettingsProvider/res/values-ml-rIN/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ml-rIN/defaults.xml
+++ b/packages/SettingsProvider/res/values-ml-rIN/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-mn-rMN/defaults.xml b/packages/SettingsProvider/res/values-mn-rMN/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-mn-rMN/defaults.xml
+++ b/packages/SettingsProvider/res/values-mn-rMN/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-mr-rIN/defaults.xml b/packages/SettingsProvider/res/values-mr-rIN/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-mr-rIN/defaults.xml
+++ b/packages/SettingsProvider/res/values-mr-rIN/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ms-rMY/defaults.xml b/packages/SettingsProvider/res/values-ms-rMY/defaults.xml
index 3627c9b..012a65f 100644
--- a/packages/SettingsProvider/res/values-ms-rMY/defaults.xml
+++ b/packages/SettingsProvider/res/values-ms-rMY/defaults.xml
@@ -20,6 +20,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
+    <!-- String.format failed for translation -->
     <!-- no translation found for def_device_name_simple (9037785625140748221) -->
     <skip />
 </resources>
diff --git a/packages/SettingsProvider/res/values-nb/defaults.xml b/packages/SettingsProvider/res/values-nb/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-nb/defaults.xml
+++ b/packages/SettingsProvider/res/values-nb/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ne-rNP/defaults.xml b/packages/SettingsProvider/res/values-ne-rNP/defaults.xml
index 3627c9b..012a65f 100644
--- a/packages/SettingsProvider/res/values-ne-rNP/defaults.xml
+++ b/packages/SettingsProvider/res/values-ne-rNP/defaults.xml
@@ -20,6 +20,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
+    <!-- String.format failed for translation -->
     <!-- no translation found for def_device_name_simple (9037785625140748221) -->
     <skip />
 </resources>
diff --git a/packages/SettingsProvider/res/values-nl/defaults.xml b/packages/SettingsProvider/res/values-nl/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-nl/defaults.xml
+++ b/packages/SettingsProvider/res/values-nl/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-pl/defaults.xml b/packages/SettingsProvider/res/values-pl/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-pl/defaults.xml
+++ b/packages/SettingsProvider/res/values-pl/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-pt-rPT/defaults.xml b/packages/SettingsProvider/res/values-pt-rPT/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-pt-rPT/defaults.xml
+++ b/packages/SettingsProvider/res/values-pt-rPT/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-pt/defaults.xml b/packages/SettingsProvider/res/values-pt/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-pt/defaults.xml
+++ b/packages/SettingsProvider/res/values-pt/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ro/defaults.xml b/packages/SettingsProvider/res/values-ro/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ro/defaults.xml
+++ b/packages/SettingsProvider/res/values-ro/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ru/defaults.xml b/packages/SettingsProvider/res/values-ru/defaults.xml
index 18d0b93..3ea32a1 100644
--- a/packages/SettingsProvider/res/values-ru/defaults.xml
+++ b/packages/SettingsProvider/res/values-ru/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-si-rLK/defaults.xml b/packages/SettingsProvider/res/values-si-rLK/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-si-rLK/defaults.xml
+++ b/packages/SettingsProvider/res/values-si-rLK/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-sk/defaults.xml b/packages/SettingsProvider/res/values-sk/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-sk/defaults.xml
+++ b/packages/SettingsProvider/res/values-sk/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-sl/defaults.xml b/packages/SettingsProvider/res/values-sl/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-sl/defaults.xml
+++ b/packages/SettingsProvider/res/values-sl/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-sr/defaults.xml b/packages/SettingsProvider/res/values-sr/defaults.xml
index 18d0b93..3ea32a1 100644
--- a/packages/SettingsProvider/res/values-sr/defaults.xml
+++ b/packages/SettingsProvider/res/values-sr/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-sv/defaults.xml b/packages/SettingsProvider/res/values-sv/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-sv/defaults.xml
+++ b/packages/SettingsProvider/res/values-sv/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-sw/defaults.xml b/packages/SettingsProvider/res/values-sw/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-sw/defaults.xml
+++ b/packages/SettingsProvider/res/values-sw/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ta-rIN/defaults.xml b/packages/SettingsProvider/res/values-ta-rIN/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ta-rIN/defaults.xml
+++ b/packages/SettingsProvider/res/values-ta-rIN/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-te-rIN/defaults.xml b/packages/SettingsProvider/res/values-te-rIN/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-te-rIN/defaults.xml
+++ b/packages/SettingsProvider/res/values-te-rIN/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-th/defaults.xml b/packages/SettingsProvider/res/values-th/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-th/defaults.xml
+++ b/packages/SettingsProvider/res/values-th/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-tl/defaults.xml b/packages/SettingsProvider/res/values-tl/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-tl/defaults.xml
+++ b/packages/SettingsProvider/res/values-tl/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-tr/defaults.xml b/packages/SettingsProvider/res/values-tr/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-tr/defaults.xml
+++ b/packages/SettingsProvider/res/values-tr/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-uk/defaults.xml b/packages/SettingsProvider/res/values-uk/defaults.xml
index 7da1c93..7655a19 100644
--- a/packages/SettingsProvider/res/values-uk/defaults.xml
+++ b/packages/SettingsProvider/res/values-uk/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%2$s о %1$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-ur-rPK/defaults.xml b/packages/SettingsProvider/res/values-ur-rPK/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-ur-rPK/defaults.xml
+++ b/packages/SettingsProvider/res/values-ur-rPK/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-uz-rUZ/defaults.xml b/packages/SettingsProvider/res/values-uz-rUZ/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-uz-rUZ/defaults.xml
+++ b/packages/SettingsProvider/res/values-uz-rUZ/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-vi/defaults.xml b/packages/SettingsProvider/res/values-vi/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-vi/defaults.xml
+++ b/packages/SettingsProvider/res/values-vi/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-zh-rHK/defaults.xml b/packages/SettingsProvider/res/values-zh-rHK/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-zh-rHK/defaults.xml
+++ b/packages/SettingsProvider/res/values-zh-rHK/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SettingsProvider/res/values-zh-rTW/defaults.xml b/packages/SettingsProvider/res/values-zh-rTW/defaults.xml
index 3627c9b..22443a5 100644
--- a/packages/SettingsProvider/res/values-zh-rTW/defaults.xml
+++ b/packages/SettingsProvider/res/values-zh-rTW/defaults.xml
@@ -20,6 +20,5 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="def_device_name" msgid="6309317409634339402">"%1$s %2$s"</string>
-    <!-- no translation found for def_device_name_simple (9037785625140748221) -->
-    <skip />
+    <string name="def_device_name_simple" msgid="9037785625140748221">"%1$s"</string>
 </resources>
diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml
index 29fec41..6d3f976 100644
--- a/packages/SystemUI/res/layout/super_status_bar.xml
+++ b/packages/SystemUI/res/layout/super_status_bar.xml
@@ -26,7 +26,7 @@
     android:fitsSystemWindows="true"
     android:descendantFocusability="afterDescendants">
 
-    <com.android.systemui.statusbar.AlphaOptimizedFrameLayout
+    <com.android.systemui.statusbar.BackDropView
             android:id="@+id/backdrop"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
@@ -41,9 +41,9 @@
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop"
                    android:visibility="invisible" />
-    </com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
+    </com.android.systemui.statusbar.BackDropView>
 
-    <View android:id="@+id/scrim_behind"
+    <com.android.systemui.statusbar.ScrimView android:id="@+id/scrim_behind"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />
 
@@ -80,7 +80,7 @@
             android:visibility="gone" />
     </com.android.systemui.statusbar.phone.PanelHolder>
 
-    <View android:id="@+id/scrim_in_front"
+    <com.android.systemui.statusbar.ScrimView android:id="@+id/scrim_in_front"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />
 
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
new file mode 100644
index 0000000..3bf86a0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
@@ -0,0 +1,211 @@
+/*
+ * 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 com.android.systemui.doze;
+
+import android.content.Context;
+import android.os.Build;
+import android.util.Log;
+import android.util.TimeUtils;
+
+import com.android.keyguard.KeyguardUpdateMonitor;
+import com.android.keyguard.KeyguardUpdateMonitorCallback;
+
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class DozeLog {
+    private static final String TAG = "DozeLog";
+    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    private static final boolean ENABLED = true;
+    private static final int SIZE = Build.IS_DEBUGGABLE ? 400 : 50;
+    private static final SimpleDateFormat FORMAT = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
+
+    private static long[] sTimes;
+    private static String[] sMessages;
+    private static int sPosition;
+    private static int sCount;
+    private static boolean sPulsing;
+
+    private static long sSince;
+    private static SummaryStats sPickupPulseNearVibrationStats;
+    private static SummaryStats sPickupPulseNotNearVibrationStats;
+    private static SummaryStats sNotificationPulseStats;
+    private static SummaryStats sScreenOnPulsingStats;
+    private static SummaryStats sScreenOnNotPulsingStats;
+    private static SummaryStats sEmergencyCallStats;
+
+    public static void tracePickupPulse(boolean withinVibrationThreshold) {
+        if (!ENABLED) return;
+        log("pickupPulse withinVibrationThreshold=" + withinVibrationThreshold);
+        (withinVibrationThreshold ? sPickupPulseNearVibrationStats
+                : sPickupPulseNotNearVibrationStats).append();
+    }
+
+    public static void tracePulseStart() {
+        if (!ENABLED) return;
+        sPulsing = true;
+        log("pulseStart");
+    }
+
+    public static void tracePulseFinish() {
+        if (!ENABLED) return;
+        sPulsing = false;
+        log("pulseFinish");
+    }
+
+    public static void traceNotificationPulse(long instance) {
+        if (!ENABLED) return;
+        log("notificationPulse instance=" + instance);
+        sNotificationPulseStats.append();
+    }
+
+    public static void traceDozing(Context context, boolean dozing) {
+        if (!ENABLED) return;
+        sPulsing = false;
+        synchronized (DozeLog.class) {
+            if (dozing && sMessages == null) {
+                sTimes = new long[SIZE];
+                sMessages = new String[SIZE];
+                sSince = System.currentTimeMillis();
+                sPickupPulseNearVibrationStats = new SummaryStats();
+                sPickupPulseNotNearVibrationStats = new SummaryStats();
+                sNotificationPulseStats = new SummaryStats();
+                sScreenOnPulsingStats = new SummaryStats();
+                sScreenOnNotPulsingStats = new SummaryStats();
+                sEmergencyCallStats = new SummaryStats();
+                log("init");
+                KeyguardUpdateMonitor.getInstance(context)
+                        .registerCallback(new KeyguardUpdateMonitorCallback() {
+                    @Override
+                    public void onEmergencyCallAction() {
+                        traceEmergencyCall();
+                    }
+                    @Override
+                    public void onKeyguardBouncerChanged(boolean bouncer) {
+                        traceKeyguardBouncerChanged(bouncer);
+                    }
+                    @Override
+                    public void onScreenTurnedOn() {
+                        traceScreenOn();
+                    }
+                    @Override
+                    public void onScreenTurnedOff(int why) {
+                        traceScreenOff(why);
+                    }
+                    @Override
+                    public void onKeyguardVisibilityChanged(boolean showing) {
+                        traceKeyguard(showing);
+                    }
+                });
+            }
+        }
+        log("dozing " + dozing);
+    }
+
+    public static void traceFling(boolean expand, boolean aboveThreshold, boolean thresholdNeeded) {
+        if (!ENABLED) return;
+        log("fling expand=" + expand + " aboveThreshold=" + aboveThreshold + " thresholdNeeded="
+                + thresholdNeeded);
+    }
+
+    public static void traceEmergencyCall() {
+        if (!ENABLED) return;
+        log("emergencyCall");
+    }
+
+    public static void traceKeyguardBouncerChanged(boolean showing) {
+        if (!ENABLED) return;
+        log("bouncer " + showing);
+    }
+
+    public static void traceScreenOn() {
+        if (!ENABLED) return;
+        log("screenOn pulsing=" + sPulsing);
+        (sPulsing ? sScreenOnPulsingStats : sScreenOnNotPulsingStats).append();
+        sPulsing = false;
+    }
+
+    public static void traceScreenOff(int why) {
+        if (!ENABLED) return;
+        log("screenOff why=" + why);
+    }
+
+    public static void traceKeyguard(boolean showing) {
+        if (!ENABLED) return;
+        log("keyguard " + showing);
+        if (!showing) {
+            sPulsing = false;
+        }
+    }
+
+    public static void dump(PrintWriter pw) {
+        synchronized (DozeLog.class) {
+            if (sMessages == null) return;
+            pw.println("  Doze log:");
+            final int start = (sPosition - sCount + SIZE) % SIZE;
+            for (int i = 0; i < sCount; i++) {
+                final int j = (start + i) % SIZE;
+                pw.print("    ");
+                pw.print(FORMAT.format(new Date(sTimes[j])));
+                pw.print(' ');
+                pw.println(sMessages[j]);
+            }
+            pw.print("  Doze summary stats (for ");
+            TimeUtils.formatDuration(System.currentTimeMillis() - sSince, pw);
+            pw.println("):");
+            sPickupPulseNearVibrationStats.dump(pw, "Pickup pulse (near vibration)");
+            sPickupPulseNotNearVibrationStats.dump(pw, "Pickup pulse (not near vibration)");
+            sNotificationPulseStats.dump(pw, "Notification pulse");
+            sScreenOnPulsingStats.dump(pw, "Screen on (pulsing)");
+            sScreenOnNotPulsingStats.dump(pw, "Screen on (not pulsing)");
+            sEmergencyCallStats.dump(pw, "Emergency call");
+        }
+    }
+
+    private static void log(String msg) {
+        synchronized (DozeLog.class) {
+            if (sMessages == null) return;
+            sTimes[sPosition] = System.currentTimeMillis();
+            sMessages[sPosition] = msg;
+            sPosition = (sPosition + 1) % SIZE;
+            sCount = Math.min(sCount + 1, SIZE);
+        }
+        if (DEBUG) Log.d(TAG, msg);
+    }
+
+    private static class SummaryStats {
+        private int mCount;
+
+        public void append() {
+            mCount++;
+        }
+
+        public void dump(PrintWriter pw, String type) {
+            pw.print("    ");
+            pw.print(type);
+            pw.print(": n=");
+            pw.print(mCount);
+            pw.print(" (");
+            final double perHr = (double) mCount / (System.currentTimeMillis() - sSince)
+                    * 1000 * 60 * 60;
+            pw.print(perHr);
+            pw.print("/hr)");
+            pw.println();
+        }
+    }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
index e2c8ff9..e429801 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
@@ -49,6 +49,7 @@
     private static final String ACTION_BASE = "com.android.systemui.doze";
     private static final String PULSE_ACTION = ACTION_BASE + ".pulse";
     private static final String NOTIFICATION_PULSE_ACTION = ACTION_BASE + ".notification_pulse";
+    private static final String EXTRA_INSTANCE = "instance";
 
     private final String mTag = String.format(TAG + ".%08x", hashCode());
     private final Context mContext = this;
@@ -67,7 +68,6 @@
     private boolean mDisplayStateSupported;
     private int mDisplayStateWhenOn;
     private boolean mNotificationLightOn;
-    private PendingIntent mNotificationPulseIntent;
     private boolean mPowerSaveActive;
     private long mNotificationPulseTime;
     private int mScheduleResetsRemaining;
@@ -115,9 +115,6 @@
         mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mTag);
         mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
         mDisplayStateSupported = mDozeParameters.getDisplayStateSupported();
-        mNotificationPulseIntent = PendingIntent.getBroadcast(mContext, 0,
-                new Intent(NOTIFICATION_PULSE_ACTION).setPackage(getPackageName()),
-                PendingIntent.FLAG_UPDATE_CURRENT);
         mDisplayStateWhenOn = mDisplayStateSupported ? Display.STATE_DOZE : Display.STATE_ON;
         mDisplayOff.run();
     }
@@ -257,9 +254,17 @@
         rescheduleNotificationPulse(true /*predicate*/);
     }
 
+    private PendingIntent notificationPulseIntent(long instance) {
+        return PendingIntent.getBroadcast(mContext, 0,
+                new Intent(NOTIFICATION_PULSE_ACTION).setPackage(getPackageName())
+                        .putExtra(EXTRA_INSTANCE, instance),
+                PendingIntent.FLAG_UPDATE_CURRENT);
+    }
+
     private void rescheduleNotificationPulse(boolean predicate) {
         if (DEBUG) Log.d(TAG, "rescheduleNotificationPulse predicate=" + predicate);
-        mAlarmManager.cancel(mNotificationPulseIntent);
+        final PendingIntent notificationPulseIntent = notificationPulseIntent(0);
+        mAlarmManager.cancel(notificationPulseIntent);
         if (!predicate) {
             if (DEBUG) Log.d(TAG, "  don't reschedule: predicate is false");
             return;
@@ -280,8 +285,10 @@
             if (DEBUG) Log.d(TAG, "  don't reschedule: delta is " + delta);
             return;
         }
-        if (DEBUG) Log.d(TAG, "Scheduling pulse in " + delta + "ms for " + new Date(time));
-        mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, time, mNotificationPulseIntent);
+        final long instance = time - mNotificationPulseTime;
+        if (DEBUG) Log.d(TAG, "Scheduling pulse " + instance + " in " + delta + "ms for "
+                + new Date(time));
+        mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, time, notificationPulseIntent(instance));
     }
 
     private static String triggerEventToString(TriggerEvent event) {
@@ -313,7 +320,9 @@
                 requestPulse();
             }
             if (NOTIFICATION_PULSE_ACTION.equals(intent.getAction())) {
-                if (DEBUG) Log.d(mTag, "Received notification pulse intent");
+                final long instance = intent.getLongExtra(EXTRA_INSTANCE, -1);
+                if (DEBUG) Log.d(mTag, "Received notification pulse intent instance=" + instance);
+                DozeLog.traceNotificationPulse(instance);
                 requestPulse();
                 rescheduleNotificationPulse(mNotificationLightOn);
             }
@@ -415,11 +424,16 @@
             // reset the notification pulse schedule, but only if we think we were not triggered
             // by a notification-related vibration
             final long timeSinceNotification = System.currentTimeMillis() - mNotificationPulseTime;
-            if (timeSinceNotification < mDozeParameters.getPickupVibrationThreshold()) {
+            final boolean withinVibrationThreshold =
+                    timeSinceNotification < mDozeParameters.getPickupVibrationThreshold();
+            if (withinVibrationThreshold) {
                if (DEBUG) Log.d(mTag, "Not resetting schedule, recent notification");
             } else {
                 resetNotificationResets();
             }
+            if (mSensor.getType() == Sensor.TYPE_PICK_UP_GESTURE) {
+                DozeLog.tracePickupPulse(withinVibrationThreshold);
+            }
         }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index 8d7edb9..3574877 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -298,10 +298,11 @@
         if (mDual) {
             mDualLabel.setText(state.label);
             mDualLabel.setContentDescription(state.dualLabelContentDescription);
+            mTopBackgroundView.setContentDescription(state.contentDescription);
         } else {
             mLabel.setText(state.label);
+            setContentDescription(state.contentDescription);
         }
-        setContentDescription(state.contentDescription);
     }
 
     public void onStateChanged(QSTile.State state) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BackDropView.java b/packages/SystemUI/src/com/android/systemui/statusbar/BackDropView.java
new file mode 100644
index 0000000..f1eb9fe
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BackDropView.java
@@ -0,0 +1,65 @@
+/*
+ * 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 com.android.systemui.statusbar;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+/**
+ * A view who contains media artwork.
+ */
+public class BackDropView extends FrameLayout
+{
+    private Runnable mOnVisibilityChangedRunnable;
+
+    public BackDropView(Context context) {
+        super(context);
+    }
+
+    public BackDropView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public BackDropView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    public BackDropView(Context context, AttributeSet attrs, int defStyleAttr,
+            int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+    }
+
+    @Override
+    public boolean hasOverlappingRendering() {
+        return false;
+    }
+
+    @Override
+    protected void onVisibilityChanged(View changedView, int visibility) {
+        super.onVisibilityChanged(changedView, visibility);
+        if (changedView == this && mOnVisibilityChangedRunnable != null) {
+            mOnVisibilityChangedRunnable.run();
+        }
+    }
+
+    public void setOnVisibilityChangedRunnable(Runnable runnable) {
+        mOnVisibilityChangedRunnable = runnable;
+    }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
new file mode 100644
index 0000000..2353425
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
@@ -0,0 +1,123 @@
+/*
+ * 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 com.android.systemui.statusbar;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.animation.Interpolator;
+
+/**
+ * A view which can draw a scrim
+ */
+public class ScrimView extends View
+{
+    private int mScrimColor;
+    private boolean mIsEmpty;
+    private boolean mDrawAsSrc;
+    private float mViewAlpha = 1.0f;
+    private ValueAnimator mAlphaAnimator;
+    private ValueAnimator.AnimatorUpdateListener mAlphaUpdateListener
+            = new ValueAnimator.AnimatorUpdateListener() {
+        @Override
+        public void onAnimationUpdate(ValueAnimator animation) {
+            mViewAlpha = (float) animation.getAnimatedValue();
+            invalidate();
+        }
+    };
+    private AnimatorListenerAdapter mClearAnimatorListener = new AnimatorListenerAdapter() {
+        @Override
+        public void onAnimationEnd(Animator animation) {
+            mAlphaAnimator = null;
+        }
+    };
+
+    public ScrimView(Context context) {
+        this(context, null);
+    }
+
+    public ScrimView(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public ScrimView(Context context, AttributeSet attrs, int defStyleAttr) {
+        this(context, attrs, defStyleAttr, 0);
+    }
+
+    public ScrimView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        if (mDrawAsSrc || !mIsEmpty) {
+            PorterDuff.Mode mode = mDrawAsSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER;
+            int color = mScrimColor;
+            color = Color.argb((int) (Color.alpha(color) * mViewAlpha), Color.red(color),
+                    Color.green(color), Color.blue(color));
+            canvas.drawColor(color, mode);
+        }
+    }
+
+    public void setDrawAsSrc(boolean asSrc) {
+        mDrawAsSrc = asSrc;
+        invalidate();
+    }
+
+    public void setScrimColor(int color) {
+        if (color != mScrimColor) {
+            mIsEmpty = Color.alpha(color) == 0;
+            mScrimColor = color;
+            invalidate();
+        }
+    }
+
+    public int getScrimColor() {
+        return mScrimColor;
+    }
+
+    @Override
+    public boolean hasOverlappingRendering() {
+        return false;
+    }
+
+    public void setViewAlpha(float alpha) {
+        if (mAlphaAnimator != null) {
+            mAlphaAnimator.cancel();
+        }
+        mViewAlpha = alpha;
+        invalidate();
+    }
+
+    public void animateViewAlpha(float alpha, long durationOut, Interpolator interpolator) {
+        if (mAlphaAnimator != null) {
+            mAlphaAnimator.cancel();
+        }
+        mAlphaAnimator = ValueAnimator.ofFloat(mViewAlpha, alpha);
+        mAlphaAnimator.addUpdateListener(mAlphaUpdateListener);
+        mAlphaAnimator.addListener(mClearAnimatorListener);
+        mAlphaAnimator.setInterpolator(interpolator);
+        mAlphaAnimator.setDuration(durationOut);
+        mAlphaAnimator.start();
+    }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 873d528..67c7723 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -33,6 +33,7 @@
 import android.widget.FrameLayout;
 
 import com.android.systemui.R;
+import com.android.systemui.doze.DozeLog;
 import com.android.systemui.statusbar.FlingAnimationUtils;
 import com.android.systemui.statusbar.StatusBarState;
 
@@ -347,6 +348,8 @@
                     if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
                         Log.i(TAG, "Flinging: expand=" + expand);
                     }
+                    DozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
+                            mStatusBar.isFalsingThresholdNeeded());
                     fling(vel, expand);
                     mUpdateFlingOnLayout = expand && mPanelClosedOnDown && !mHasLayoutedSinceDown;
                     if (mUpdateFlingOnLayout) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 353c887..5e9a64c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -51,7 +51,9 @@
 import android.graphics.PixelFormat;
 import android.graphics.Point;
 import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
 import android.graphics.Rect;
+import android.graphics.Xfermode;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.inputmethodservice.InputMethodService;
@@ -115,10 +117,12 @@
 import com.android.systemui.EventLogTags;
 import com.android.systemui.FontSizeUtils;
 import com.android.systemui.R;
+import com.android.systemui.doze.DozeLog;
 import com.android.systemui.doze.DozeService;
 import com.android.systemui.keyguard.KeyguardViewMediator;
 import com.android.systemui.qs.QSPanel;
 import com.android.systemui.statusbar.ActivatableNotificationView;
+import com.android.systemui.statusbar.BackDropView;
 import com.android.systemui.statusbar.BaseStatusBar;
 import com.android.systemui.statusbar.CommandQueue;
 import com.android.systemui.statusbar.DismissView;
@@ -130,6 +134,7 @@
 import com.android.systemui.statusbar.NotificationData;
 import com.android.systemui.statusbar.NotificationData.Entry;
 import com.android.systemui.statusbar.NotificationOverflowContainer;
+import com.android.systemui.statusbar.ScrimView;
 import com.android.systemui.statusbar.SignalClusterView;
 import com.android.systemui.statusbar.SpeedBumpView;
 import com.android.systemui.statusbar.StatusBarIconView;
@@ -430,8 +435,10 @@
     public static final Interpolator ALPHA_IN = new PathInterpolator(0.4f, 0f, 1f, 1f);
     public static final Interpolator ALPHA_OUT = new PathInterpolator(0f, 0f, 0.8f, 1f);
 
-    private FrameLayout mBackdrop;
+    private BackDropView mBackdrop;
     private ImageView mBackdropFront, mBackdropBack;
+    private PorterDuffXfermode mSrcXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
+    private PorterDuffXfermode mSrcOverXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER);
 
     private MediaSessionManager mMediaSessionManager;
     private MediaController mMediaController;
@@ -722,8 +729,14 @@
         mStackScroller.setDismissView(mDismissView);
         mExpandedContents = mStackScroller;
 
-        mScrimController = new ScrimController(mStatusBarWindow.findViewById(R.id.scrim_behind),
-                mStatusBarWindow.findViewById(R.id.scrim_in_front));
+        mBackdrop = (BackDropView) mStatusBarWindow.findViewById(R.id.backdrop);
+        mBackdropFront = (ImageView) mBackdrop.findViewById(R.id.backdrop_front);
+        mBackdropBack = (ImageView) mBackdrop.findViewById(R.id.backdrop_back);
+
+        ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind);
+        ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front);
+        mScrimController = new ScrimController(scrimBehind, scrimInFront);
+        mScrimController.setBackDropView(mBackdrop);
         mStatusBarView.setScrimController(mScrimController);
 
         mHeader = (StatusBarHeaderView) mStatusBarWindow.findViewById(R.id.header);
@@ -862,10 +875,6 @@
             });
         }
 
-        mBackdrop = (FrameLayout) mStatusBarWindow.findViewById(R.id.backdrop);
-        mBackdropFront = (ImageView) mBackdrop.findViewById(R.id.backdrop_front);
-        mBackdropBack = (ImageView) mBackdrop.findViewById(R.id.backdrop_back);
-
         // User info. Trigger first load.
         mHeader.setUserInfoController(mUserInfoController);
         mKeyguardStatusBar.setUserInfoController(mUserInfoController);
@@ -1851,7 +1860,9 @@
             }
             if (metaDataChanged) {
                 if (mBackdropBack.getDrawable() != null) {
-                    mBackdropFront.setImageDrawable(mBackdropBack.getDrawable());
+                    Drawable drawable = mBackdropBack.getDrawable();
+                    mBackdropFront.setImageDrawable(drawable);
+                    mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
                     mBackdropFront.setAlpha(1f);
                     mBackdropFront.setVisibility(View.VISIBLE);
                 } else {
@@ -1866,6 +1877,7 @@
                 } else {
                     mBackdropBack.setImageBitmap(artworkBitmap);
                 }
+                mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode);
 
                 if (mBackdropFront.getVisibility() == View.VISIBLE) {
                     if (DEBUG_MEDIA) {
@@ -2101,8 +2113,8 @@
 
     public boolean isFalsingThresholdNeeded() {
         boolean onKeyguard = getBarState() == StatusBarState.KEYGUARD;
-        boolean isMethodInSecure = mUnlockMethodCache.isMethodInsecure();
-        return onKeyguard && isMethodInSecure;
+        boolean isMethodInsecure = mUnlockMethodCache.isMethodInsecure();
+        return onKeyguard && (isMethodInsecure || mDozing);
     }
 
     @Override  // NotificationData.Environment
@@ -2874,6 +2886,8 @@
             mNotificationPanel.dump(fd, pw, args);
         }
 
+        DozeLog.dump(pw);
+
         if (DUMPTRUCK) {
             synchronized (mNotificationData) {
                 mNotificationData.dump(pw, "  ");
@@ -4108,6 +4122,7 @@
             mCurrentDozeService = dozeService;
             if (!mDozing) {
                 mDozing = true;
+                DozeLog.traceDozing(mContext, mDozing);
                 updateDozingState();
             }
             mCurrentDozeService.startDozing();
@@ -4125,6 +4140,7 @@
             }
             if (mDozing) {
                 mDozing = false;
+                DozeLog.traceDozing(mContext, mDozing);
                 updateDozingState();
             }
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 3ff11d2..a502470 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -21,7 +21,6 @@
 import android.animation.ValueAnimator;
 import android.content.Context;
 import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewTreeObserver;
@@ -30,6 +29,9 @@
 import android.view.animation.Interpolator;
 
 import com.android.systemui.R;
+import com.android.systemui.doze.DozeLog;
+import com.android.systemui.statusbar.BackDropView;
+import com.android.systemui.statusbar.ScrimView;
 
 /**
  * Controls both the scrim behind the notifications and in front of the notifications (when a
@@ -47,8 +49,8 @@
     private static final float SCRIM_IN_FRONT_ALPHA = 0.75f;
     private static final int TAG_KEY_ANIM = R.id.scrim;
 
-    private final View mScrimBehind;
-    private final View mScrimInFront;
+    private final ScrimView mScrimBehind;
+    private final ScrimView mScrimInFront;
     private final UnlockMethodCache mUnlockMethodCache;
     private final DozeParameters mDozeParameters;
 
@@ -69,8 +71,9 @@
     private long mPulseEndTime;
     private final Interpolator mInterpolator = new DecelerateInterpolator();
     private final Interpolator mLinearOutSlowInInterpolator;
+    private BackDropView mBackDropView;
 
-    public ScrimController(View scrimBehind, View scrimInFront) {
+    public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront) {
         mScrimBehind = scrimBehind;
         mScrimInFront = scrimInFront;
         final Context context = scrimBehind.getContext();
@@ -229,17 +232,17 @@
         }
     }
 
-    private void setScrimColor(View scrim, float alpha) {
+    private void setScrimColor(ScrimView scrim, float alpha) {
         int color = Color.argb((int) (alpha * 255), 0, 0, 0);
         if (mAnimateChange) {
             startScrimAnimation(scrim, color);
         } else {
-            scrim.setBackgroundColor(color);
+            scrim.setScrimColor(color);
         }
     }
 
-    private void startScrimAnimation(final View scrim, int targetColor) {
-        int current = getBackgroundAlpha(scrim);
+    private void startScrimAnimation(final ScrimView scrim, int targetColor) {
+        int current = Color.alpha(scrim.getScrimColor());
         int target = Color.alpha(targetColor);
         if (current == targetColor) {
             return;
@@ -253,7 +256,7 @@
             @Override
             public void onAnimationUpdate(ValueAnimator animation) {
                 int value = (int) animation.getAnimatedValue();
-                scrim.setBackgroundColor(Color.argb(value, 0, 0, 0));
+                scrim.setScrimColor(Color.argb(value, 0, 0, 0));
             }
         });
         anim.setInterpolator(mAnimateKeyguardFadingOut
@@ -277,15 +280,6 @@
         mAnimationStarted = true;
     }
 
-    private int getBackgroundAlpha(View scrim) {
-        if (scrim.getBackground() instanceof ColorDrawable) {
-            ColorDrawable drawable = (ColorDrawable) scrim.getBackground();
-            return Color.alpha(drawable.getColor());
-        } else {
-            return 0;
-        }
-    }
-
     @Override
     public boolean onPreDraw() {
         mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this);
@@ -309,6 +303,7 @@
         public void run() {
             if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing);
             if (!mDozing) return;
+            DozeLog.tracePulseStart();
             mDurationOverride = mDozeParameters.getPulseInDuration();
             mAnimationDelay = 0;
             mAnimateChange = true;
@@ -343,7 +338,24 @@
         @Override
         public void run() {
             if (DEBUG) Log.d(TAG, "Pulse out finished");
+            DozeLog.tracePulseFinish();
             mPulseEndTime = 0;
         }
     };
+
+    public void setBackDropView(BackDropView backDropView) {
+        mBackDropView = backDropView;
+        mBackDropView.setOnVisibilityChangedRunnable(new Runnable() {
+            @Override
+            public void run() {
+                updateScrimBehindDrawingMode();
+            }
+        });
+        updateScrimBehindDrawingMode();
+    }
+
+    private void updateScrimBehindDrawingMode() {
+        boolean asSrc = mBackDropView.getVisibility() != View.VISIBLE;
+        mScrimBehind.setDrawAsSrc(asSrc);
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index 78554525..89ce257 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -20,12 +20,17 @@
 import android.content.Context;
 import android.graphics.Canvas;
 import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
 import android.graphics.Rect;
+import android.os.IBinder;
 import android.util.AttributeSet;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewRootImpl;
+import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
 import android.widget.FrameLayout;
 
 import com.android.systemui.R;
@@ -45,11 +50,14 @@
     private View mBrightnessMirror;
 
     PhoneStatusBar mService;
+    private final Paint mTransparentSrcPaint = new Paint();
 
     public StatusBarWindowView(Context context, AttributeSet attrs) {
         super(context, attrs);
         setMotionEventSplittingEnabled(false);
-        setWillNotDraw(!DEBUG);
+        setWillNotDraw(false);
+        mTransparentSrcPaint.setColor(0);
+        mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
     }
 
     @Override
@@ -93,6 +101,15 @@
         if (root != null) {
             root.setDrawDuringWindowsAnimating(true);
         }
+
+        // We need to ensure that our window doesn't suffer from overdraw which would normally
+        // occur if our window is translucent. Since we are drawing the whole window anyway with
+        // the scrim, we don't need the window to be cleared in the beginning.
+        IBinder windowToken = getWindowToken();
+        WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
+        lp.token = windowToken;
+        setLayoutParams(lp);
+        WindowManagerGlobal.getInstance().changeCanvasOpacity(windowToken, true);
     }
 
     @Override
@@ -182,6 +199,24 @@
     @Override
     public void onDraw(Canvas canvas) {
         super.onDraw(canvas);
+        // We need to ensure that our window is always drawn fully even when we have paddings,
+        // since we simulate it to be opaque.
+        int paddedBottom = getHeight() - getPaddingBottom();
+        int paddedRight = getWidth() - getPaddingRight();
+        if (getPaddingTop() != 0) {
+            canvas.drawRect(0, 0, getWidth(), getPaddingTop(), mTransparentSrcPaint);
+        }
+        if (getPaddingBottom() != 0) {
+            canvas.drawRect(0, paddedBottom, getWidth(), getHeight(), mTransparentSrcPaint);
+        }
+        if (getPaddingLeft() != 0) {
+            canvas.drawRect(0, getPaddingTop(), getPaddingLeft(), paddedBottom,
+                    mTransparentSrcPaint);
+        }
+        if (getPaddingRight() != 0) {
+            canvas.drawRect(paddedRight, getPaddingTop(), getWidth(), paddedBottom,
+                    mTransparentSrcPaint);
+        }
         if (DEBUG) {
             Paint pt = new Paint();
             pt.setColor(0x80FFFF00);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java
index 7bd2e5c..895af62 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java
@@ -17,11 +17,11 @@
 package com.android.systemui.statusbar.policy;
 
 import com.android.systemui.R;
+import com.android.systemui.statusbar.ScrimView;
 import com.android.systemui.statusbar.phone.PhoneStatusBar;
 import com.android.systemui.statusbar.phone.StatusBarWindowView;
 
 import android.view.View;
-import android.view.ViewGroup;
 import android.view.ViewPropertyAnimator;
 import android.widget.FrameLayout;
 
@@ -33,26 +33,26 @@
     public long TRANSITION_DURATION_OUT = 150;
     public long TRANSITION_DURATION_IN = 200;
 
-    private final View mScrimBehind;
+    private final ScrimView mScrimBehind;
     private final View mBrightnessMirror;
     private final View mPanelHolder;
     private final int[] mInt2Cache = new int[2];
 
     public BrightnessMirrorController(StatusBarWindowView statusBarWindow) {
-        mScrimBehind = statusBarWindow.findViewById(R.id.scrim_behind);
+        mScrimBehind = (ScrimView) statusBarWindow.findViewById(R.id.scrim_behind);
         mBrightnessMirror = statusBarWindow.findViewById(R.id.brightness_mirror);
         mPanelHolder = statusBarWindow.findViewById(R.id.panel_holder);
     }
 
     public void showMirror() {
         mBrightnessMirror.setVisibility(View.VISIBLE);
-        outAnimation(mScrimBehind.animate());
+        mScrimBehind.animateViewAlpha(0.0f, TRANSITION_DURATION_OUT, PhoneStatusBar.ALPHA_OUT);
         outAnimation(mPanelHolder.animate())
                 .withLayer();
     }
 
     public void hideMirror() {
-        inAnimation(mScrimBehind.animate());
+        mScrimBehind.animateViewAlpha(1.0f, TRANSITION_DURATION_IN, PhoneStatusBar.ALPHA_IN);
         inAnimation(mPanelHolder.animate())
                 .withLayer()
                 .withEndAction(new Runnable() {
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 94c1676..00026dc 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -1241,6 +1241,13 @@
         st.decorView = new DecorView(getContext(), st.featureId);
         st.gravity = Gravity.CENTER | Gravity.BOTTOM;
         st.setStyle(getContext());
+        TypedArray a = getContext().obtainStyledAttributes(null,
+                R.styleable.Window, 0, st.listPresenterTheme);
+        final float elevation = a.getDimension(R.styleable.Window_windowElevation, 0);
+        if (elevation != 0) {
+            st.decorView.setElevation(elevation);
+        }
+        a.recycle();
 
         return true;
     }
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index d38074f..3f83a02 100755
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -24,6 +24,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import android.os.Build;
 import android.os.DeadObjectException;
 import android.os.Handler;
 import android.os.Looper;
@@ -590,6 +591,8 @@
                         r.cancelNotification();
                         r.foregroundId = 0;
                         r.foregroundNoti = null;
+                    } else if (r.appInfo.targetSdkVersion >= Build.VERSION_CODES.L) {
+                        r.stripForegroundServiceFlagFromNotification();
                     }
                 }
             }
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index baae6e4c..4d689f9 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -7528,8 +7528,8 @@
 
         // Does the caller have this permission on the URI?
         if (!checkHoldingPermissionsLocked(pm, pi, grantUri, callingUid, modeFlags)) {
-            // Have they don't have direct access to the URI, then revoke any URI
-            // permissions that have been granted to them.
+            // If they don't have direct access to the URI, then revoke any
+            // ownerless URI permissions that have been granted to them.
             final ArrayMap<GrantUri, UriPermission> perms = mGrantedUriPermissions.get(callingUid);
             if (perms != null) {
                 boolean persistChanged = false;
@@ -7538,10 +7538,10 @@
                     if (perm.uri.sourceUserId == grantUri.sourceUserId
                             && perm.uri.uri.isPathPrefixMatch(grantUri.uri)) {
                         if (DEBUG_URI_PERMISSION)
-                            Slog.v(TAG,
-                                    "Revoking " + perm.targetUid + " permission to " + perm.uri);
+                            Slog.v(TAG, "Revoking non-owned " + perm.targetUid +
+                                    " permission to " + perm.uri);
                         persistChanged |= perm.revokeModes(
-                                modeFlags | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
+                                modeFlags | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, false);
                         if (perm.modeFlags == 0) {
                             it.remove();
                         }
@@ -7573,7 +7573,7 @@
                         Slog.v(TAG,
                                 "Revoking " + perm.targetUid + " permission to " + perm.uri);
                     persistChanged |= perm.revokeModes(
-                            modeFlags | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
+                            modeFlags | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, true);
                     if (perm.modeFlags == 0) {
                         it.remove();
                     }
@@ -7661,8 +7661,8 @@
                     // Only inspect grants matching package
                     if (packageName == null || perm.sourcePkg.equals(packageName)
                             || perm.targetPkg.equals(packageName)) {
-                        persistChanged |= perm.revokeModes(
-                                persistable ? ~0 : ~Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
+                        persistChanged |= perm.revokeModes(persistable
+                                ? ~0 : ~Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, true);
 
                         // Only remove when no modes remain; any persisted grants
                         // will keep this alive.
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index 0a66a5c..d4a378b 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -517,6 +517,31 @@
             });
         }
     }
+
+    public void stripForegroundServiceFlagFromNotification() {
+        if (foregroundId == 0) {
+            return;
+        }
+
+        final int localForegroundId = foregroundId;
+        final int localUserId = userId;
+        final String localPackageName = packageName;
+
+        // Do asynchronous communication with notification manager to
+        // avoid deadlocks.
+        ams.mHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                NotificationManagerInternal nmi = LocalServices.getService(
+                        NotificationManagerInternal.class);
+                if (nmi == null) {
+                    return;
+                }
+                nmi.removeForegroundServiceFlagFromNotification(localPackageName, localForegroundId,
+                        localUserId);
+            }
+        });
+    }
     
     public void clearDeliveredStartsLocked() {
         for (int i=deliveredStarts.size()-1; i>=0; i--) {
diff --git a/services/core/java/com/android/server/am/UriPermission.java b/services/core/java/com/android/server/am/UriPermission.java
index 284086d..91daf77 100644
--- a/services/core/java/com/android/server/am/UriPermission.java
+++ b/services/core/java/com/android/server/am/UriPermission.java
@@ -180,7 +180,7 @@
     /**
      * @return if mode changes should trigger persisting.
      */
-    boolean revokeModes(int modeFlags) {
+    boolean revokeModes(int modeFlags, boolean includingOwners) {
         final boolean persistable = (modeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0;
         modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION
                 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
@@ -193,7 +193,7 @@
                 persistedModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
             }
             globalModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
-            if (mReadOwners != null) {
+            if (mReadOwners != null && includingOwners) {
                 ownedModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
                 for (UriPermissionOwner r : mReadOwners) {
                     r.removeReadPermission(this);
@@ -207,7 +207,7 @@
                 persistedModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
             }
             globalModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
-            if (mWriteOwners != null) {
+            if (mWriteOwners != null && includingOwners) {
                 ownedModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
                 for (UriPermissionOwner r : mWriteOwners) {
                     r.removeWritePermission(this);
diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
index fab064c..fb98236 100644
--- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java
+++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
@@ -82,10 +82,6 @@
     private static final String PERMISSION_ACCESS_NETWORK_CONDITIONS =
             "android.permission.ACCESS_NETWORK_CONDITIONS";
 
-    // Intent broadcast when user selects sign-in notification.
-    private static final String ACTION_SIGN_IN_REQUESTED =
-            "android.net.netmon.sign_in_requested";
-
     // Keep these in sync with CaptivePortalLoginActivity.java.
     // Intent broadcast from CaptivePortalLogin indicating sign-in is complete.
     // Extras:
@@ -404,38 +400,42 @@
         }
     }
 
-    private class UserPromptedState extends State {
-        private class UserRespondedBroadcastReceiver extends BroadcastReceiver {
-            private final int mToken;
-            UserRespondedBroadcastReceiver(int token) {
-                mToken = token;
-            }
-            @Override
-            public void onReceive(Context context, Intent intent) {
-                if (Integer.parseInt(intent.getStringExtra(Intent.EXTRA_TEXT)) ==
-                        mNetworkAgentInfo.network.netId) {
-                    sendMessage(obtainMessage(CMD_USER_WANTS_SIGN_IN, mToken));
-                }
-            }
+    // BroadcastReceiver that waits for a particular Intent and then posts a message.
+    private class CustomIntentReceiver extends BroadcastReceiver {
+        private final Message mMessage;
+        private final String mAction;
+        CustomIntentReceiver(String action, int token, int message) {
+            mMessage = obtainMessage(message, token);
+            mAction = action + "_" + mNetworkAgentInfo.network.netId + "_" + token;
+            mContext.registerReceiver(this, new IntentFilter(mAction));
         }
+        public PendingIntent getPendingIntent() {
+            return PendingIntent.getBroadcast(mContext, 0, new Intent(mAction), 0);
+        }
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(mAction)) sendMessage(mMessage);
+        }
+    }
 
-        private UserRespondedBroadcastReceiver mUserRespondedBroadcastReceiver;
+    private class UserPromptedState extends State {
+        // Intent broadcast when user selects sign-in notification.
+        private static final String ACTION_SIGN_IN_REQUESTED =
+                "android.net.netmon.sign_in_requested";
+
+        private CustomIntentReceiver mUserRespondedBroadcastReceiver;
 
         @Override
         public void enter() {
             mConnectivityServiceHandler.sendMessage(obtainMessage(EVENT_NETWORK_TESTED,
                     NETWORK_TEST_RESULT_INVALID, 0, mNetworkAgentInfo));
             // Wait for user to select sign-in notifcation.
-            mUserRespondedBroadcastReceiver = new UserRespondedBroadcastReceiver(
-                    ++mUserPromptedToken);
-            IntentFilter filter = new IntentFilter(ACTION_SIGN_IN_REQUESTED);
-            mContext.registerReceiver(mUserRespondedBroadcastReceiver, filter);
+            mUserRespondedBroadcastReceiver = new CustomIntentReceiver(ACTION_SIGN_IN_REQUESTED,
+                    ++mUserPromptedToken, CMD_USER_WANTS_SIGN_IN);
             // Initiate notification to sign-in.
-            Intent intent = new Intent(ACTION_SIGN_IN_REQUESTED);
-            intent.putExtra(Intent.EXTRA_TEXT, String.valueOf(mNetworkAgentInfo.network.netId));
             Message message = obtainMessage(EVENT_PROVISIONING_NOTIFICATION, 1,
                     mNetworkAgentInfo.network.netId,
-                    PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
+                    mUserRespondedBroadcastReceiver.getPendingIntent());
             mConnectivityServiceHandler.sendMessage(message);
         }
 
@@ -530,33 +530,15 @@
 
     private class LingeringState extends State {
         private static final String ACTION_LINGER_EXPIRED = "android.net.netmon.lingerExpired";
-        private static final String EXTRA_NETID = "lingerExpiredNetId";
-        private static final String EXTRA_TOKEN = "lingerExpiredToken";
 
-        private class LingerExpiredBroadcastReceiver extends BroadcastReceiver {
-            @Override
-            public void onReceive(Context context, Intent intent) {
-                if (intent.getAction().equals(ACTION_LINGER_EXPIRED) &&
-                        Integer.parseInt(intent.getStringExtra(EXTRA_NETID)) ==
-                        mNetworkAgentInfo.network.netId) {
-                    sendMessage(CMD_LINGER_EXPIRED,
-                            Integer.parseInt(intent.getStringExtra(EXTRA_TOKEN)));
-                }
-            }
-        }
-
-        private BroadcastReceiver mBroadcastReceiver;
+        private CustomIntentReceiver mBroadcastReceiver;
         private PendingIntent mIntent;
 
         @Override
         public void enter() {
-            mBroadcastReceiver = new LingerExpiredBroadcastReceiver();
-            mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ACTION_LINGER_EXPIRED));
-
-            Intent intent = new Intent(ACTION_LINGER_EXPIRED, null);
-            intent.putExtra(EXTRA_NETID, String.valueOf(mNetworkAgentInfo.network.netId));
-            intent.putExtra(EXTRA_TOKEN, String.valueOf(++mLingerToken));
-            mIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
+            mBroadcastReceiver = new CustomIntentReceiver(ACTION_LINGER_EXPIRED, ++mLingerToken,
+                    CMD_LINGER_EXPIRED);
+            mIntent = mBroadcastReceiver.getPendingIntent();
             long wakeupTime = SystemClock.elapsedRealtime() + mLingerDelayMs;
             mAlarmManager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, wakeupTime,
                     // Give a specific window so we aren't subject to unknown inexactitude.
diff --git a/services/core/java/com/android/server/connectivity/PacManager.java b/services/core/java/com/android/server/connectivity/PacManager.java
index 63178eb..07fe7ba 100644
--- a/services/core/java/com/android/server/connectivity/PacManager.java
+++ b/services/core/java/com/android/server/connectivity/PacManager.java
@@ -71,7 +71,7 @@
     public static final String KEY_PROXY = "keyProxy";
     private String mCurrentPac;
     @GuardedBy("mProxyLock")
-    private Uri mPacUrl;
+    private Uri mPacUrl = Uri.EMPTY;
 
     private AlarmManager mAlarmManager;
     @GuardedBy("mProxyLock")
@@ -175,7 +175,7 @@
         } else {
             getAlarmManager().cancel(mPacRefreshIntent);
             synchronized (mProxyLock) {
-                mPacUrl = null;
+                mPacUrl = Uri.EMPTY;
                 mCurrentPac = null;
                 if (mProxyService != null) {
                     try {
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 81b579d..7f89947 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -37,6 +37,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.content.pm.PackageManager.NameNotFoundException;
@@ -806,8 +807,8 @@
         final HashSet<String> availableKeyboardLayouts = new HashSet<String>();
         visitAllKeyboardLayouts(new KeyboardLayoutVisitor() {
             @Override
-            public void visitKeyboardLayout(Resources resources,
-                    String descriptor, String label, String collection, int keyboardLayoutResId) {
+            public void visitKeyboardLayout(Resources resources, String descriptor, String label,
+                    String collection, int keyboardLayoutResId, int priority) {
                 availableKeyboardLayouts.add(descriptor);
             }
         });
@@ -840,9 +841,9 @@
         final ArrayList<KeyboardLayout> list = new ArrayList<KeyboardLayout>();
         visitAllKeyboardLayouts(new KeyboardLayoutVisitor() {
             @Override
-            public void visitKeyboardLayout(Resources resources,
-                    String descriptor, String label, String collection, int keyboardLayoutResId) {
-                list.add(new KeyboardLayout(descriptor, label, collection));
+            public void visitKeyboardLayout(Resources resources, String descriptor, String label,
+                    String collection, int keyboardLayoutResId, int priority) {
+                list.add(new KeyboardLayout(descriptor, label, collection, priority));
             }
         });
         return list.toArray(new KeyboardLayout[list.size()]);
@@ -857,9 +858,9 @@
         final KeyboardLayout[] result = new KeyboardLayout[1];
         visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() {
             @Override
-            public void visitKeyboardLayout(Resources resources,
-                    String descriptor, String label, String collection, int keyboardLayoutResId) {
-                result[0] = new KeyboardLayout(descriptor, label, collection);
+            public void visitKeyboardLayout(Resources resources, String descriptor,
+                    String label, String collection, int keyboardLayoutResId, int priority) {
+                result[0] = new KeyboardLayout(descriptor, label, collection, priority);
             }
         });
         if (result[0] == null) {
@@ -874,7 +875,9 @@
         Intent intent = new Intent(InputManager.ACTION_QUERY_KEYBOARD_LAYOUTS);
         for (ResolveInfo resolveInfo : pm.queryBroadcastReceivers(intent,
                 PackageManager.GET_META_DATA)) {
-            visitKeyboardLayoutsInPackage(pm, resolveInfo.activityInfo, null, visitor);
+            final ActivityInfo activityInfo = resolveInfo.activityInfo;
+            final int priority = resolveInfo.priority;
+            visitKeyboardLayoutsInPackage(pm, activityInfo, null, priority, visitor);
         }
     }
 
@@ -887,14 +890,14 @@
                 ActivityInfo receiver = pm.getReceiverInfo(
                         new ComponentName(d.packageName, d.receiverName),
                         PackageManager.GET_META_DATA);
-                visitKeyboardLayoutsInPackage(pm, receiver, d.keyboardLayoutName, visitor);
+                visitKeyboardLayoutsInPackage(pm, receiver, d.keyboardLayoutName, 0, visitor);
             } catch (NameNotFoundException ex) {
             }
         }
     }
 
     private void visitKeyboardLayoutsInPackage(PackageManager pm, ActivityInfo receiver,
-            String keyboardName, KeyboardLayoutVisitor visitor) {
+            String keyboardName, int requestedPriority, KeyboardLayoutVisitor visitor) {
         Bundle metaData = receiver.metaData;
         if (metaData == null) {
             return;
@@ -909,6 +912,12 @@
 
         CharSequence receiverLabel = receiver.loadLabel(pm);
         String collection = receiverLabel != null ? receiverLabel.toString() : "";
+        int priority;
+        if ((receiver.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+            priority = requestedPriority;
+        } else {
+            priority = 0;
+        }
 
         try {
             Resources resources = pm.getResourcesForApplication(receiver.applicationInfo);
@@ -943,7 +952,7 @@
                                         receiver.packageName, receiver.name, name);
                                 if (keyboardName == null || name.equals(keyboardName)) {
                                     visitor.visitKeyboardLayout(resources, descriptor,
-                                            label, collection, keyboardLayoutResId);
+                                            label, collection, keyboardLayoutResId, priority);
                                 }
                             }
                         } finally {
@@ -1550,8 +1559,8 @@
         final String[] result = new String[2];
         visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() {
             @Override
-            public void visitKeyboardLayout(Resources resources,
-                    String descriptor, String label, String collection, int keyboardLayoutResId) {
+            public void visitKeyboardLayout(Resources resources, String descriptor, String label,
+                    String collection, int keyboardLayoutResId, int priority) {
                 try {
                     result[0] = descriptor;
                     result[1] = Streams.readFully(new InputStreamReader(
@@ -1699,8 +1708,8 @@
     }
 
     private interface KeyboardLayoutVisitor {
-        void visitKeyboardLayout(Resources resources,
-                String descriptor, String label, String collection, int keyboardLayoutResId);
+        void visitKeyboardLayout(Resources resources, String descriptor, String label,
+                String collection, int keyboardLayoutResId, int priority);
     }
 
     private final class InputDevicesChangedListenerRecord implements DeathRecipient {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerInternal.java b/services/core/java/com/android/server/notification/NotificationManagerInternal.java
index b695b68..c6b0d36 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerInternal.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerInternal.java
@@ -21,4 +21,6 @@
 public interface NotificationManagerInternal {
     void enqueueNotification(String pkg, String basePkg, int callingUid, int callingPid,
             String tag, int id, Notification notification, int[] idReceived, int userId);
+
+    void removeForegroundServiceFlagFromNotification(String pkg, int notificationId, int userId);
 }
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 14587e6..2829e2b 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1610,6 +1610,30 @@
             enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id, notification,
                     idReceived, userId);
         }
+
+        @Override
+        public void removeForegroundServiceFlagFromNotification(String pkg, int notificationId,
+                int userId) {
+            checkCallerIsSystem();
+            synchronized (mNotificationList) {
+                int i = indexOfNotificationLocked(pkg, null, notificationId, userId);
+                if (i < 0) {
+                    Log.d(TAG, "stripForegroundServiceFlag: Could not find notification with "
+                            + "pkg=" + pkg + " / id=" + notificationId + " / userId=" + userId);
+                    return;
+                }
+                NotificationRecord r = mNotificationList.get(i);
+                StatusBarNotification sbn = r.sbn;
+                // NoMan adds flags FLAG_NO_CLEAR and FLAG_ONGOING_EVENT when it sees
+                // FLAG_FOREGROUND_SERVICE. Hence it's not enough to remove FLAG_FOREGROUND_SERVICE,
+                // we have to revert to the flags we received initially *and* force remove
+                // FLAG_FOREGROUND_SERVICE.
+                sbn.getNotification().flags =
+                        (r.mOriginalFlags & ~Notification.FLAG_FOREGROUND_SERVICE);
+                mRankingHelper.sort(mNotificationList);
+                mListeners.notifyPostedLocked(sbn, sbn /* oldSbn */);
+            }
+        }
     };
 
     void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index fd34aa5..ea6f2db 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -45,6 +45,8 @@
  */
 public final class NotificationRecord {
     final StatusBarNotification sbn;
+    final int mOriginalFlags;
+
     NotificationUsageStats.SingleNotificationStats stats;
     boolean isCanceled;
     int score;
@@ -73,6 +75,7 @@
     {
         this.sbn = sbn;
         this.score = score;
+        mOriginalFlags = sbn.getNotification().flags;
         mRankingTimeMs = calculateRankingTimeMs(0L);
     }
 
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 79c9955..00bb908 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -201,6 +201,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
@@ -2161,7 +2162,8 @@
                         userId);
             }
             if (mResolveComponentName.equals(component)) {
-                return mResolveActivity;
+                return PackageParser.generateActivityInfo(mResolveActivity, flags,
+                        new PackageUserState(), userId);
             }
         }
         return null;
@@ -5939,25 +5941,26 @@
                 p.group = mPermissionGroups.get(p.info.group);
                 if (p.info.group == null || p.group != null) {
                     BasePermission bp = permissionMap.get(p.info.name);
+
+                    // Allow system apps to redefine non-system permissions
+                    if (bp != null && !Objects.equals(bp.sourcePackage, p.info.packageName)) {
+                        final boolean currentOwnerIsSystem = (bp.perm != null
+                                && isSystemApp(bp.perm.owner));
+                        if (isSystemApp(p.owner) && !currentOwnerIsSystem) {
+                            String msg = "New decl " + p.owner + " of permission  "
+                                    + p.info.name + " is system; overriding " + bp.sourcePackage;
+                            reportSettingsProblem(Log.WARN, msg);
+                            bp = null;
+                        }
+                    }
+
                     if (bp == null) {
                         bp = new BasePermission(p.info.name, p.info.packageName,
                                 BasePermission.TYPE_NORMAL);
                         permissionMap.put(p.info.name, bp);
                     }
+
                     if (bp.perm == null) {
-                        if (bp.sourcePackage != null
-                                && !bp.sourcePackage.equals(p.info.packageName)) {
-                            // If this is a permission that was formerly defined by a non-system
-                            // app, but is now defined by a system app (following an upgrade),
-                            // discard the previous declaration and consider the system's to be
-                            // canonical.
-                            if (isSystemApp(p.owner)) {
-                                String msg = "New decl " + p.owner + " of permission  "
-                                        + p.info.name + " is system";
-                                reportSettingsProblem(Log.WARN, msg);
-                                bp.sourcePackage = null;
-                            }
-                        }
                         if (bp.sourcePackage == null
                                 || bp.sourcePackage.equals(p.info.packageName)) {
                             BasePermission tree = findPermissionTreeLP(p.info.name);
@@ -5966,6 +5969,7 @@
                                 bp.packageSetting = pkgSetting;
                                 bp.perm = p;
                                 bp.uid = pkg.applicationInfo.uid;
+                                bp.sourcePackage = p.info.packageName;
                                 if ((parseFlags&PackageParser.PARSE_CHATTY) != 0) {
                                     if (r == null) {
                                         r = new StringBuilder(256);
diff --git a/services/core/jni/com_android_server_UsbHostManager.cpp b/services/core/jni/com_android_server_UsbHostManager.cpp
index 65a28c0..32c3f95 100644
--- a/services/core/jni/com_android_server_UsbHostManager.cpp
+++ b/services/core/jni/com_android_server_UsbHostManager.cpp
@@ -74,9 +74,9 @@
     char *serial = usb_device_get_serial(device);
 
     jstring deviceName = env->NewStringUTF(devname);
-    jstring manufacturerName = env->NewStringUTF(manufacturer);
-    jstring productName = env->NewStringUTF(product);
-    jstring serialNumber = env->NewStringUTF(serial);
+    jstring manufacturerName = AndroidRuntime::NewStringLatin1(env, manufacturer);
+    jstring productName = AndroidRuntime::NewStringLatin1(env, product);
+    jstring serialNumber = AndroidRuntime::NewStringLatin1(env, serial);
 
     jboolean result = env->CallBooleanMethod(thiz, method_beginUsbDeviceAdded,
             deviceName, usb_device_get_vendor_id(device), usb_device_get_product_id(device),
@@ -99,7 +99,7 @@
         if (desc->bDescriptorType == USB_DT_CONFIG) {
             struct usb_config_descriptor *config = (struct usb_config_descriptor *)desc;
             char *name = usb_device_get_string(device, config->iConfiguration);
-            jstring configName = env->NewStringUTF(name);
+            jstring configName = AndroidRuntime::NewStringLatin1(env, name);
 
             env->CallVoidMethod(thiz, method_addUsbConfiguration,
                     config->bConfigurationValue, configName, config->bmAttributes,
@@ -110,7 +110,7 @@
         } else if (desc->bDescriptorType == USB_DT_INTERFACE) {
             struct usb_interface_descriptor *interface = (struct usb_interface_descriptor *)desc;
             char *name = usb_device_get_string(device, interface->iInterface);
-            jstring interfaceName = env->NewStringUTF(name);
+            jstring interfaceName = AndroidRuntime::NewStringLatin1(env, name);
 
             env->CallVoidMethod(thiz, method_addUsbInterface,
                     interface->bInterfaceNumber, interfaceName, interface->bAlternateSetting,
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 95332bc..59d3dc8 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -17,6 +17,7 @@
 package com.android.server.devicepolicy;
 
 import static android.Manifest.permission.MANAGE_CA_CERTIFICATES;
+import static android.content.pm.PackageManager.GET_UNINSTALLED_PACKAGES;
 
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.accounts.AccountManager;
@@ -4661,7 +4662,8 @@
             ActiveAdmin activeAdmin =
                     getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
             boolean isDeviceOwner = isDeviceOwner(activeAdmin.info.getPackageName());
-            if (!isDeviceOwner && DEVICE_OWNER_USER_RESTRICTIONS.contains(key)) {
+            if (!isDeviceOwner && userHandle != UserHandle.USER_OWNER
+                    && DEVICE_OWNER_USER_RESTRICTIONS.contains(key)) {
                 throw new SecurityException("Profile owners cannot set user restriction " + key);
             }
             boolean alreadyRestricted = mUserManager.hasUserRestriction(key, user);
@@ -4801,19 +4803,19 @@
             long id = Binder.clearCallingIdentity();
 
             try {
-                UserManager um = UserManager.get(mContext);
-                if (!um.getUserInfo(userId).isManagedProfile()) {
-                    throw new IllegalStateException(
-                            "Only call this method from a managed profile.");
-                }
-
-                UserInfo primaryUser = um.getProfileParent(userId);
-
                 if (DBG) {
                     Slog.v(LOG_TAG, "installing " + packageName + " for "
                             + userId);
                 }
 
+                UserManager um = UserManager.get(mContext);
+                UserInfo primaryUser = um.getProfileParent(userId);
+
+                // Call did not come from a managed profile
+                if (primaryUser == null) {
+                    primaryUser = um.getUserInfo(userId);
+                }
+
                 IPackageManager pm = AppGlobals.getPackageManager();
                 if (!isSystemApp(pm, packageName, primaryUser.id)) {
                     throw new IllegalArgumentException("Only system apps can be enabled this way.");
@@ -4847,13 +4849,13 @@
 
             try {
                 UserManager um = UserManager.get(mContext);
-                if (!um.getUserInfo(userId).isManagedProfile()) {
-                    throw new IllegalStateException(
-                            "Only call this method from a managed profile.");
-                }
-
                 UserInfo primaryUser = um.getProfileParent(userId);
 
+                // Call did not come from a managed profile.
+                if (primaryUser == null) {
+                    primaryUser = um.getUserInfo(userId);
+                }
+
                 IPackageManager pm = AppGlobals.getPackageManager();
                 List<ResolveInfo> activitiesToEnable = pm.queryIntentActivities(intent,
                         intent.resolveTypeIfNeeded(mContext.getContentResolver()),
@@ -4890,7 +4892,8 @@
 
     private boolean isSystemApp(IPackageManager pm, String packageName, int userId)
             throws RemoteException {
-        ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0, userId);
+        ApplicationInfo appInfo = pm.getApplicationInfo(packageName, GET_UNINSTALLED_PACKAGES,
+                userId);
         return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
     }
 
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index b0b6fb9..a71161a 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -161,7 +161,7 @@
 
         /**
          * @return For a {@link #STATE_DISCONNECTED} {@code Call}, the disconnect cause expressed
-         * by {@link android.telecomm.DisconnectCause}.
+         * by {@link android.telecom.DisconnectCause}.
          */
         public DisconnectCause getDisconnectCause() {
             return mDisconnectCause;
diff --git a/telecomm/java/android/telecom/DisconnectCause.java b/telecomm/java/android/telecom/DisconnectCause.java
index cae115d..9be0138 100644
--- a/telecomm/java/android/telecom/DisconnectCause.java
+++ b/telecomm/java/android/telecom/DisconnectCause.java
@@ -85,6 +85,17 @@
 
     /**
      * Creates a new DisconnectCause.
+     * @param label The localized label to show to the user to explain the disconnect.
+     * @param code The code for the disconnect cause.
+     * @param description The localized description to show to the user to explain the disconnect.
+     * @param reason The reason for the disconnect.
+     */
+    public DisconnectCause(int code, CharSequence label, CharSequence description, String reason) {
+        this(code, label, description, reason, ToneGenerator.TONE_UNKNOWN);
+    }
+
+    /**
+     * Creates a new DisconnectCause.
      *
      * @param code The code for the disconnect cause.
      * @param label The localized label to show to the user to explain the disconnect.
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index afec5ed..d605202 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -781,12 +781,18 @@
     if (!addTagAttribute(root, RESOURCES_ANDROID_NAMESPACE, "versionName",
             bundle->getVersionName(), errorOnFailedInsert, replaceVersion)) {
         return UNKNOWN_ERROR;
+    } else {
+        const XMLNode::attribute_entry* attr = root->getAttribute(
+                String16(RESOURCES_ANDROID_NAMESPACE), String16("versionName"));
+        if (attr != NULL) {
+            bundle->setVersionName(strdup(String8(attr->string).string()));
+        }
     }
     
+    sp<XMLNode> vers = root->getChildElement(String16(), String16("uses-sdk"));
     if (bundle->getMinSdkVersion() != NULL
             || bundle->getTargetSdkVersion() != NULL
             || bundle->getMaxSdkVersion() != NULL) {
-        sp<XMLNode> vers = root->getChildElement(String16(), String16("uses-sdk"));
         if (vers == NULL) {
             vers = XMLNode::newElement(root->getFilename(), String16(), String16("uses-sdk"));
             root->insertChildAt(vers, 0);
@@ -806,6 +812,14 @@
         }
     }
 
+    if (vers != NULL) {
+        const XMLNode::attribute_entry* attr = vers->getAttribute(
+                String16(RESOURCES_ANDROID_NAMESPACE), String16("minSdkVersion"));
+        if (attr != NULL) {
+            bundle->setMinSdkVersion(strdup(String8(attr->string).string()));
+        }
+    }
+
     if (bundle->getPlatformBuildVersionCode() != "") {
         if (!addTagAttribute(root, "", "platformBuildVersionCode",
                     bundle->getPlatformBuildVersionCode(), errorOnFailedInsert, true)) {
@@ -973,8 +987,8 @@
 static ssize_t extractPlatformBuildVersion(AssetManager& assets, Bundle* bundle) {
     int32_t cookie = getPlatformAssetCookie(assets);
     if (cookie == 0) {
-        fprintf(stderr, "ERROR: Platform package not found\n");
-        return UNKNOWN_ERROR;
+        // No platform was loaded.
+        return NO_ERROR;
     }
 
     ResXMLTree tree;
@@ -1500,6 +1514,10 @@
         return err;
     }
 
+    if (table.modifyForCompat(bundle) != NO_ERROR) {
+        return UNKNOWN_ERROR;
+    }
+
     //block.restart();
     //printXMLBlock(&block);
 
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 8341de6..8c9efc9 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -12,6 +12,7 @@
 
 #include <androidfw/ResourceTypes.h>
 #include <utils/ByteOrder.h>
+#include <utils/TypeHelpers.h>
 #include <stdarg.h>
 
 #define NOISY(x) //x
@@ -3287,6 +3288,18 @@
     }
 }
 
+ResourceTable::Entry::Entry(const Entry& entry)
+    : RefBase()
+    , mName(entry.mName)
+    , mParent(entry.mParent)
+    , mType(entry.mType)
+    , mItem(entry.mItem)
+    , mItemFormat(entry.mItemFormat)
+    , mBag(entry.mBag)
+    , mNameIndex(entry.mNameIndex)
+    , mParentId(entry.mParentId)
+    , mPos(entry.mPos) {}
+
 status_t ResourceTable::Entry::makeItABag(const SourcePos& sourcePos)
 {
     if (mType == TYPE_BAG) {
@@ -3372,6 +3385,17 @@
     return NO_ERROR;
 }
 
+status_t ResourceTable::Entry::removeFromBag(const String16& key) {
+    if (mType != Entry::TYPE_BAG) {
+        return NO_ERROR;
+    }
+
+    if (mBag.removeItem(key) >= 0) {
+        return NO_ERROR;
+    }
+    return UNKNOWN_ERROR;
+}
+
 status_t ResourceTable::Entry::emptyBag(const SourcePos& sourcePos)
 {
     status_t err = makeItABag(sourcePos);
@@ -4113,3 +4137,175 @@
     }
     return res;
 }
+
+/**
+ * Returns true if the given attribute ID comes from
+ * a platform version from or after L.
+ */
+bool ResourceTable::isAttributeFromL(uint32_t attrId) {
+    const uint32_t baseAttrId = 0x010103f7;
+    if ((attrId & 0xffff0000) != (baseAttrId & 0xffff0000)) {
+        return false;
+    }
+
+    uint32_t specFlags;
+    if (!mAssets->getIncludedResources().getResourceFlags(attrId, &specFlags)) {
+        return false;
+    }
+
+    return (specFlags & ResTable_typeSpec::SPEC_PUBLIC) != 0 &&
+        (attrId & 0x0000ffff) >= (baseAttrId & 0x0000ffff);
+}
+
+/**
+ * Modifies the entries in the resource table to account for compatibility
+ * issues with older versions of Android.
+ *
+ * This primarily handles the issue of private/public attribute clashes
+ * in framework resources.
+ *
+ * AAPT has traditionally assigned resource IDs to public attributes,
+ * and then followed those public definitions with private attributes.
+ *
+ * --- PUBLIC ---
+ * | 0x01010234 | attr/color
+ * | 0x01010235 | attr/background
+ *
+ * --- PRIVATE ---
+ * | 0x01010236 | attr/secret
+ * | 0x01010237 | attr/shhh
+ *
+ * Each release, when attributes are added, they take the place of the private
+ * attributes and the private attributes are shifted down again.
+ *
+ * --- PUBLIC ---
+ * | 0x01010234 | attr/color
+ * | 0x01010235 | attr/background
+ * | 0x01010236 | attr/shinyNewAttr
+ * | 0x01010237 | attr/highlyValuedFeature
+ *
+ * --- PRIVATE ---
+ * | 0x01010238 | attr/secret
+ * | 0x01010239 | attr/shhh
+ *
+ * Platform code may look for private attributes set in a theme. If an app
+ * compiled against a newer version of the platform uses a new public
+ * attribute that happens to have the same ID as the private attribute
+ * the older platform is expecting, then the behavior is undefined.
+ *
+ * We get around this by detecting any newly defined attributes (in L),
+ * copy the resource into a -v21 qualified resource, and delete the
+ * attribute from the original resource. This ensures that older platforms
+ * don't see the new attribute, but when running on L+ platforms, the
+ * attribute will be respected.
+ */
+status_t ResourceTable::modifyForCompat(const Bundle* bundle) {
+    if (bundle->getMinSdkVersion() != NULL) {
+        // If this app will only ever run on L+ devices,
+        // we don't need to do any compatibility work.
+
+        if (String8("L") == bundle->getMinSdkVersion()) {
+            // Code-name for the v21 release.
+            return NO_ERROR;
+        }
+
+        const int minSdk = atoi(bundle->getMinSdkVersion());
+        if (minSdk >= SDK_L) {
+            return NO_ERROR;
+        }
+    }
+
+    const String16 attr16("attr");
+
+    const size_t packageCount = mOrderedPackages.size();
+    for (size_t pi = 0; pi < packageCount; pi++) {
+        sp<Package> p = mOrderedPackages.itemAt(pi);
+        if (p == NULL || p->getTypes().size() == 0) {
+            // Empty, skip!
+            continue;
+        }
+
+        const size_t typeCount = p->getOrderedTypes().size();
+        for (size_t ti = 0; ti < typeCount; ti++) {
+            sp<Type> t = p->getOrderedTypes().itemAt(ti);
+            if (t == NULL) {
+                continue;
+            }
+
+            const size_t configCount = t->getOrderedConfigs().size();
+            for (size_t ci = 0; ci < configCount; ci++) {
+                sp<ConfigList> c = t->getOrderedConfigs().itemAt(ci);
+                if (c == NULL) {
+                    continue;
+                }
+
+                Vector<key_value_pair_t<ConfigDescription, sp<Entry> > > entriesToAdd;
+                const DefaultKeyedVector<ConfigDescription, sp<Entry> >& entries =
+                        c->getEntries();
+                const size_t entryCount = entries.size();
+                for (size_t ei = 0; ei < entryCount; ei++) {
+                    sp<Entry> e = entries.valueAt(ei);
+                    if (e == NULL || e->getType() != Entry::TYPE_BAG) {
+                        continue;
+                    }
+
+                    const ConfigDescription& config = entries.keyAt(ei);
+                    if (config.sdkVersion >= SDK_L) {
+                        // We don't need to do anything if the resource is
+                        // already qualified for version 21 or higher.
+                        continue;
+                    }
+
+                    Vector<String16> attributesToRemove;
+                    const KeyedVector<String16, Item>& bag = e->getBag();
+                    const size_t bagCount = bag.size();
+                    for (size_t bi = 0; bi < bagCount; bi++) {
+                        const Item& item = bag.valueAt(bi);
+                        const uint32_t attrId = getResId(bag.keyAt(bi), &attr16);
+                        if (isAttributeFromL(attrId)) {
+                            attributesToRemove.add(bag.keyAt(bi));
+                        }
+                    }
+
+                    if (attributesToRemove.isEmpty()) {
+                        continue;
+                    }
+
+                    // Duplicate the entry under the same configuration
+                    // but with sdkVersion == SDK_L.
+                    ConfigDescription newConfig(config);
+                    newConfig.sdkVersion = SDK_L;
+                    entriesToAdd.add(key_value_pair_t<ConfigDescription, sp<Entry> >(
+                            newConfig, new Entry(*e)));
+
+                    // Remove the attribute from the original.
+                    for (size_t i = 0; i < attributesToRemove.size(); i++) {
+                        e->removeFromBag(attributesToRemove[i]);
+                    }
+                }
+
+                const size_t entriesToAddCount = entriesToAdd.size();
+                for (size_t i = 0; i < entriesToAddCount; i++) {
+                    if (entries.indexOfKey(entriesToAdd[i].key) >= 0) {
+                        // An entry already exists for this config.
+                        // That means that any attributes that were
+                        // defined in L in the original bag will be overriden
+                        // anyways on L devices, so we do nothing.
+                        continue;
+                    }
+
+                    entriesToAdd[i].value->getPos()
+                            .printf("using v%d attributes; synthesizing resource %s:%s/%s for configuration %s.",
+                                    SDK_L,
+                                    String8(p->getName()).string(),
+                                    String8(t->getName()).string(),
+                                    String8(entriesToAdd[i].value->getName()).string(),
+                                    entriesToAdd[i].key.toString().string());
+
+                    c->addEntry(entriesToAdd[i].key, entriesToAdd[i].value);
+                }
+            }
+        }
+    }
+    return NO_ERROR;
+}
diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h
index 3721de4..025a868 100644
--- a/tools/aapt/ResourceTable.h
+++ b/tools/aapt/ResourceTable.h
@@ -165,6 +165,8 @@
     size_t numLocalResources() const;
     bool hasResources() const;
 
+    status_t modifyForCompat(const Bundle* bundle);
+
     sp<AaptFile> flatten(Bundle* bundle, const sp<const ResourceFilter>& filter,
             const bool isBase);
 
@@ -281,6 +283,9 @@
             : mName(name), mType(TYPE_UNKNOWN),
               mItemFormat(ResTable_map::TYPE_ANY), mNameIndex(-1), mPos(pos)
         { }
+
+        Entry(const Entry& entry);
+
         virtual ~Entry() { }
 
         enum type {
@@ -311,6 +316,8 @@
                           bool replace=false, bool isId = false,
                           int32_t format = ResTable_map::TYPE_ANY);
 
+        status_t removeFromBag(const String16& key);
+
         // Index of the entry's name string in the key pool.
         int32_t getNameIndex() const { return mNameIndex; }
         void setNameIndex(int32_t index) { mNameIndex = index; }
@@ -523,6 +530,7 @@
     const Item* getItem(uint32_t resID, uint32_t attrID) const;
     bool getItemValue(uint32_t resID, uint32_t attrID,
                       Res_value* outValue);
+    bool isAttributeFromL(uint32_t attrId);
 
 
     String16 mAssetsPackage;