Merge "Add cache for each animation's duration in AnimatorSet"
diff --git a/Android.mk b/Android.mk
index a45a4d6..b1ca0bc 100644
--- a/Android.mk
+++ b/Android.mk
@@ -711,6 +711,7 @@
 	bouncycastle \
 	okhttp \
 	ext \
+	icu4j \
 	framework \
 	telephony-common \
 	voip-common
diff --git a/api/current.txt b/api/current.txt
index d468831..c4dd6e1 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -25355,6 +25355,7 @@
     field public static final java.lang.String JOB_DESCRIPTION = "data6";
     field public static final java.lang.String OFFICE_LOCATION = "data9";
     field public static final java.lang.String PHONETIC_NAME = "data8";
+    field public static final java.lang.String PHONETIC_NAME_STYLE = "data10";
     field public static final java.lang.String SYMBOL = "data7";
     field public static final java.lang.String TITLE = "data4";
     field public static final int TYPE_OTHER = 2; // 0x2
@@ -25456,6 +25457,7 @@
     field public static final java.lang.String PHONETIC_FAMILY_NAME = "data9";
     field public static final java.lang.String PHONETIC_GIVEN_NAME = "data7";
     field public static final java.lang.String PHONETIC_MIDDLE_NAME = "data8";
+    field public static final java.lang.String PHONETIC_NAME_STYLE = "data11";
     field public static final java.lang.String PREFIX = "data4";
     field public static final java.lang.String SUFFIX = "data6";
   }
diff --git a/api/system-current.txt b/api/system-current.txt
index 1474689..c0a2c7e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -27311,6 +27311,7 @@
     field public static final java.lang.String JOB_DESCRIPTION = "data6";
     field public static final java.lang.String OFFICE_LOCATION = "data9";
     field public static final java.lang.String PHONETIC_NAME = "data8";
+    field public static final java.lang.String PHONETIC_NAME_STYLE = "data10";
     field public static final java.lang.String SYMBOL = "data7";
     field public static final java.lang.String TITLE = "data4";
     field public static final int TYPE_OTHER = 2; // 0x2
@@ -27412,6 +27413,7 @@
     field public static final java.lang.String PHONETIC_FAMILY_NAME = "data9";
     field public static final java.lang.String PHONETIC_GIVEN_NAME = "data7";
     field public static final java.lang.String PHONETIC_MIDDLE_NAME = "data8";
+    field public static final java.lang.String PHONETIC_NAME_STYLE = "data11";
     field public static final java.lang.String PREFIX = "data4";
     field public static final java.lang.String SUFFIX = "data6";
   }
@@ -27764,6 +27766,19 @@
     field public static final java.lang.String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id";
   }
 
+  public static final class ContactsContract.MetadataSyncState implements android.provider.BaseColumns android.provider.ContactsContract.MetadataSyncStateColumns {
+    field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata_sync_state";
+    field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata_sync_state";
+    field public static final android.net.Uri CONTENT_URI;
+  }
+
+  protected static abstract interface ContactsContract.MetadataSyncStateColumns {
+    field public static final java.lang.String ACCOUNT_NAME = "account_name";
+    field public static final java.lang.String ACCOUNT_TYPE = "account_type";
+    field public static final java.lang.String DATA_SET = "data_set";
+    field public static final java.lang.String STATE = "state";
+  }
+
   public static final class ContactsContract.PhoneLookup implements android.provider.BaseColumns android.provider.ContactsContract.ContactOptionsColumns android.provider.ContactsContract.ContactsColumns android.provider.ContactsContract.PhoneLookupColumns {
     field public static final android.net.Uri CONTENT_FILTER_URI;
     field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
@@ -32751,17 +32766,22 @@
     field public static final java.lang.String ACTION_PHONE_ACCOUNT_REGISTERED = "android.telecom.action.PHONE_ACCOUNT_REGISTERED";
     field public static final java.lang.String ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS = "android.telecom.action.SHOW_CALL_ACCESSIBILITY_SETTINGS";
     field public static final java.lang.String ACTION_SHOW_CALL_SETTINGS = "android.telecom.action.SHOW_CALL_SETTINGS";
+    field public static final java.lang.String ACTION_SHOW_MISSED_CALLS_NOTIFICATION = "android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION";
     field public static final java.lang.String ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS = "android.telecom.action.SHOW_RESPOND_VIA_SMS_SETTINGS";
     field public static final char DTMF_CHARACTER_PAUSE = 44; // 0x002c ','
     field public static final char DTMF_CHARACTER_WAIT = 59; // 0x003b ';'
+    field public static final java.lang.String EXTRA_CALL_BACK_INTENT = "android.telecom.extra.CALL_BACK_INTENT";
     field public static final java.lang.String EXTRA_CALL_BACK_NUMBER = "android.telecom.extra.CALL_BACK_NUMBER";
     field public static final java.lang.String EXTRA_CALL_DISCONNECT_CAUSE = "android.telecom.extra.CALL_DISCONNECT_CAUSE";
     field public static final java.lang.String EXTRA_CALL_DISCONNECT_MESSAGE = "android.telecom.extra.CALL_DISCONNECT_MESSAGE";
     field public static final java.lang.String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
     field public static final java.lang.String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME = "android.telecom.extra.CHANGE_DEFAULT_DIALER_PACKAGE_NAME";
+    field public static final java.lang.String EXTRA_CLEAR_MISSED_CALLS_INTENT = "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT";
     field public static final java.lang.String EXTRA_CONNECTION_SERVICE = "android.telecom.extra.CONNECTION_SERVICE";
     field public static final java.lang.String EXTRA_INCOMING_CALL_ADDRESS = "android.telecom.extra.INCOMING_CALL_ADDRESS";
     field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.telecom.extra.INCOMING_CALL_EXTRAS";
+    field public static final java.lang.String EXTRA_NOTIFICATION_COUNT = "android.telecom.extra.NOTIFICATION_COUNT";
+    field public static final java.lang.String EXTRA_NOTIFICATION_PHONE_NUMBER = "android.telecom.extra.NOTIFICATION_PHONE_NUMBER";
     field public static final java.lang.String EXTRA_OUTGOING_CALL_EXTRAS = "android.telecom.extra.OUTGOING_CALL_EXTRAS";
     field public static final java.lang.String EXTRA_PHONE_ACCOUNT_HANDLE = "android.telecom.extra.PHONE_ACCOUNT_HANDLE";
     field public static final java.lang.String EXTRA_START_CALL_WITH_SPEAKERPHONE = "android.telecom.extra.START_CALL_WITH_SPEAKERPHONE";
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 983af2f..84892a3 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -6211,6 +6211,7 @@
         mFragments.attachHost(null /*parent*/);
 
         mWindow = new PhoneWindow(this);
+        mWindow.setWindowStackCallback(this);
         mWindow.setCallback(this);
         mWindow.setOnWindowDismissedCallback(this);
         mWindow.getLayoutInflater().setPrivateFactory(this);
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 0950a16..10c122a 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -107,8 +107,8 @@
             int userId) {
         try {
             getDefault().broadcastIntent(
-                null, intent, null, null, Activity.RESULT_OK, null, null,
-                null /*permission*/, appOp, null, false, true, userId);
+                    null, intent, null, null, Activity.RESULT_OK, null, null,
+                    null /*permission*/, appOp, null, false, true, userId);
         } catch (RemoteException ex) {
         }
     }
@@ -2653,6 +2653,24 @@
             reply.writeNoException();
             return true;
         }
+        case REPORT_SIZE_CONFIGURATIONS: {
+            data.enforceInterface(IActivityManager.descriptor);
+            IBinder token = data.readStrongBinder();
+            int horizontalSize = data.readInt();
+            int[] horizontal = null;
+            if (horizontalSize > 0) {
+                horizontal = new int[horizontalSize];
+                data.readIntArray(horizontal);
+            }
+            int[] vertical = null;
+            int verticalSize = data.readInt();
+            if (verticalSize > 0) {
+                vertical = new int[verticalSize];
+                data.readIntArray(vertical);
+            }
+            reportSizeConfigurations(token, horizontal, vertical);
+            return true;
+        }
         }
 
         return super.onTransact(code, data, reply, flags);
@@ -6146,5 +6164,30 @@
         return stackId;
     }
 
+    @Override
+    public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
+            int[] verticalSizeConfigurations) throws RemoteException {
+        Parcel data = Parcel.obtain();
+        Parcel reply = Parcel.obtain();
+        data.writeInterfaceToken(IActivityManager.descriptor);
+        data.writeStrongBinder(token);
+        if (horizontalSizeConfiguration == null) {
+            data.writeInt(0);
+        } else {
+            data.writeInt(horizontalSizeConfiguration.length);
+            data.writeIntArray(horizontalSizeConfiguration);
+        }
+        if (verticalSizeConfigurations == null) {
+            data.writeInt(0);
+        } else {
+            data.writeInt(verticalSizeConfigurations.length);
+            data.writeIntArray(verticalSizeConfigurations);
+        }
+        mRemote.transact(REPORT_SIZE_CONFIGURATIONS, data, reply, 0);
+        reply.readException();
+        data.recycle();
+        reply.recycle();
+    }
+
     private IBinder mRemote;
 }
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 594ec41..fe79629 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -82,6 +82,7 @@
 import android.util.ArrayMap;
 import android.util.DisplayMetrics;
 import android.util.EventLog;
+import android.util.IntArray;
 import android.util.Log;
 import android.util.LogPrinter;
 import android.util.Pair;
@@ -2504,6 +2505,7 @@
 
         if (a != null) {
             r.createdConfig = new Configuration(mConfiguration);
+            reportSizeConfigurations(r);
             Bundle oldState = r.state;
             handleResumeActivity(r.token, false, r.isForward,
                     !r.activity.mFinished && !r.startsNotResumed);
@@ -2563,6 +2565,42 @@
         }
     }
 
+    private void reportSizeConfigurations(ActivityClientRecord r) {
+        Configuration[] configurations = r.activity.getResources().getSizeConfigurations();
+        if (configurations == null) {
+            return;
+        }
+        IntArray horizontal = new IntArray();
+        IntArray vertical = new IntArray();
+        for (int i = configurations.length - 1; i >= 0; i--) {
+            Configuration config = configurations[i];
+            if (config.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
+                vertical.add(config.screenHeightDp);
+            }
+            if (config.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
+                horizontal.add(config.screenWidthDp);
+            }
+            if (config.smallestScreenWidthDp != Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
+                vertical.add(config.smallestScreenWidthDp);
+                horizontal.add(config.smallestScreenWidthDp);
+            }
+        }
+        int[] horizontalArray = null;
+        if (horizontal.size() > 0) {
+            horizontalArray = horizontal.toArray();
+        }
+        int[] verticalArray = null;
+        if (vertical.size() > 0) {
+            verticalArray = vertical.toArray();
+        }
+        try {
+            ActivityManagerNative.getDefault().reportSizeConfigurations(r.token, horizontalArray,
+                    verticalArray);
+        } catch (RemoteException ex) {
+        }
+
+    }
+
     private void deliverNewIntents(ActivityClientRecord r, List<ReferrerIntent> intents) {
         final int N = intents.size();
         for (int i=0; i<N; i++) {
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index b32e54c..ff1d595 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -121,6 +121,8 @@
             PersistableBundle persistentState, CharSequence description) throws RemoteException;
     public void activitySlept(IBinder token) throws RemoteException;
     public void activityDestroyed(IBinder token) throws RemoteException;
+    public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
+            int[] verticalSizeConfigurations) throws RemoteException;
     public String getCallingPackage(IBinder token) throws RemoteException;
     public ComponentName getCallingActivity(IBinder token) throws RemoteException;
     public List<IAppTask> getAppTasks(String callingPackage) throws RemoteException;
@@ -884,4 +886,5 @@
     int POSITION_TASK_IN_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 342;
     int GET_ACTIVITY_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 343;
     int MOVE_ACTIVITY_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
+    int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
 }
diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java
index fa2813e..af3b565 100644
--- a/core/java/android/app/MediaRouteButton.java
+++ b/core/java/android/app/MediaRouteButton.java
@@ -330,40 +330,40 @@
         final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
         final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
 
-        final int minWidth = Math.max(mMinWidth,
-                mRemoteIndicator != null ? mRemoteIndicator.getIntrinsicWidth() : 0);
-        final int minHeight = Math.max(mMinHeight,
-                mRemoteIndicator != null ? mRemoteIndicator.getIntrinsicHeight() : 0);
+        final int width = Math.max(mMinWidth, mRemoteIndicator != null ?
+                mRemoteIndicator.getIntrinsicWidth() + getPaddingLeft() + getPaddingRight() : 0);
+        final int height = Math.max(mMinHeight, mRemoteIndicator != null ?
+                mRemoteIndicator.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom() : 0);
 
-        int width;
+        int measuredWidth;
         switch (widthMode) {
             case MeasureSpec.EXACTLY:
-                width = widthSize;
+                measuredWidth = widthSize;
                 break;
             case MeasureSpec.AT_MOST:
-                width = Math.min(widthSize, minWidth + getPaddingLeft() + getPaddingRight());
+                measuredWidth = Math.min(widthSize, width);
                 break;
             default:
             case MeasureSpec.UNSPECIFIED:
-                width = minWidth + getPaddingLeft() + getPaddingRight();
+                measuredWidth = width;
                 break;
         }
 
-        int height;
+        int measuredHeight;
         switch (heightMode) {
             case MeasureSpec.EXACTLY:
-                height = heightSize;
+                measuredHeight = heightSize;
                 break;
             case MeasureSpec.AT_MOST:
-                height = Math.min(heightSize, minHeight + getPaddingTop() + getPaddingBottom());
+                measuredHeight = Math.min(heightSize, height);
                 break;
             default:
             case MeasureSpec.UNSPECIFIED:
-                height = minHeight + getPaddingTop() + getPaddingBottom();
+                measuredHeight = height;
                 break;
         }
 
-        setMeasuredDimension(width, height);
+        setMeasuredDimension(measuredWidth, measuredHeight);
     }
 
     @Override
diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java
index 6fca0de..689283c 100644
--- a/core/java/android/app/backup/BackupAgent.java
+++ b/core/java/android/app/backup/BackupAgent.java
@@ -605,6 +605,13 @@
     public void onRestoreFile(ParcelFileDescriptor data, long size,
             File destination, int type, long mode, long mtime)
             throws IOException {
+
+        final boolean accept = isFileEligibleForRestore(destination);
+        // If we don't accept the file, consume the bytes from the pipe anyway.
+        FullBackup.restoreFile(data, size, type, mode, mtime, accept ? destination : null);
+    }
+
+    private boolean isFileEligibleForRestore(File destination) throws IOException {
         FullBackup.BackupScheme bs = FullBackup.getBackupScheme(this);
         if (!bs.isFullBackupContentEnabled()) {
             if (Log.isLoggable(FullBackup.TAG_XML_PARSER, Log.VERBOSE)) {
@@ -612,8 +619,9 @@
                         "onRestoreFile \"" + destination.getCanonicalPath()
                                 + "\" : fullBackupContent not enabled for " + getPackageName());
             }
-            return;
+            return false;
         }
+
         Map<String, Set<String>> includes = null;
         ArraySet<String> excludes = null;
         final String destinationCanonicalPath = destination.getCanonicalPath();
@@ -627,7 +635,7 @@
                                 + "\" : Exception trying to parse fullBackupContent xml file!"
                                 + " Aborting onRestoreFile.", e);
             }
-            return;
+            return false;
         }
 
         if (excludes != null &&
@@ -637,7 +645,7 @@
                         "onRestoreFile: \"" + destinationCanonicalPath + "\": listed in"
                                 + " excludes; skipping.");
             }
-            return;
+            return false;
         }
 
         if (includes != null && !includes.isEmpty()) {
@@ -657,10 +665,10 @@
                                     + destinationCanonicalPath + "\" but it isn't specified"
                                     + " in the included files; skipping.");
                 }
-                return;
+                return false;
             }
         }
-        FullBackup.restoreFile(data, size, type, mode, mtime, destination);
+        return true;
     }
 
     /**
diff --git a/core/java/android/app/usage/UsageStatsManagerInternal.java b/core/java/android/app/usage/UsageStatsManagerInternal.java
index 9113426..948ea1e 100644
--- a/core/java/android/app/usage/UsageStatsManagerInternal.java
+++ b/core/java/android/app/usage/UsageStatsManagerInternal.java
@@ -77,6 +77,13 @@
     public abstract boolean isAppIdle(String packageName, int userId);
 
     /**
+     * Returns all of the uids for a given user where all packages associating with that uid
+     * are in the app idle state -- there are no associated apps that are not idle.  This means
+     * all of the returned uids can be safely considered app idle.
+     */
+    public abstract int[] getIdleUidsForUser(int userId);
+
+    /**
      * @return True if currently app idle parole mode is on.  This means all idle apps are allow to
      * run for a short period of time.
      */
diff --git a/core/java/android/content/pm/PermissionInfo.java b/core/java/android/content/pm/PermissionInfo.java
index d514513..9da2ba9 100644
--- a/core/java/android/content/pm/PermissionInfo.java
+++ b/core/java/android/content/pm/PermissionInfo.java
@@ -145,6 +145,13 @@
     public static final int FLAG_COSTS_MONEY = 1<<0;
 
     /**
+     * Flag for {@link #flags}, corresponding to <code>hidden</code>
+     * value of {@link android.R.attr#permissionFlags}.
+     * @hide
+     */
+    public static final int FLAG_HIDDEN = 1<<1;
+
+    /**
      * Flag for {@link #flags}, indicating that this permission has been
      * installed into the system's globally defined permissions.
      */
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index 8d96f5c2..c248a9e 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -691,6 +691,9 @@
      */
     public native final String[] getLocales();
 
+    /** {@hide} */
+    public native final Configuration[] getSizeConfigurations();
+
     /**
      * Change the configuation used when retrieving resources.  Not for use by
      * applications.
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 788aee9..5abc645e3 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -2139,7 +2139,12 @@
     public Configuration getConfiguration() {
         return mConfiguration;
     }
-    
+
+    /** @hide */
+    public Configuration[] getSizeConfigurations() {
+        return mAssets.getSizeConfigurations();
+    };
+
     /**
      * Return the compatibility mode information for the application.
      * The returned object should be treated as read-only.
diff --git a/core/java/android/emoji/EmojiFactory.java b/core/java/android/emoji/EmojiFactory.java
deleted file mode 100644
index aba990d..0000000
--- a/core/java/android/emoji/EmojiFactory.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.emoji;
-
-import android.graphics.Bitmap;
-
-import java.lang.ref.WeakReference;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * A class for the factories which produce Emoji (pictgram) images.
- * This is intended to be used by IME, Email app, etc.
- * There's no plan to make this public for now.
- * @hide
- */
-public final class EmojiFactory {
-    // private static final String LOG_TAG = "EmojiFactory";
-    
-    private int sCacheSize = 100;
-    
-    // HashMap for caching Bitmap object. In order not to make a cache object
-    // blow up, we use LinkedHashMap with size limit.
-    private class CustomLinkedHashMap<K, V> extends LinkedHashMap<K, V> {
-        public CustomLinkedHashMap() {
-            // These magic numbers are gotten from the source code of
-            // LinkedHashMap.java and HashMap.java.
-            super(16, 0.75f, true);
-        }
-        
-        /*
-         * If size() becomes more than sCacheSize, least recently used cache
-         * is erased. 
-         * @see java.util.LinkedHashMap#removeEldestEntry(java.util.Map.Entry)
-         */
-        @Override
-        protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
-            return size() > sCacheSize;
-        }
-    }
-    
-    // A pointer to native EmojiFactory object.
-    private long mNativeEmojiFactory;
-    private String mName;
-    // Cache.
-    private Map<Integer, WeakReference<Bitmap>> mCache;
-    
-    /**
-     * @noinspection UnusedDeclaration
-     */
-    /*
-     * Private constructor that must received an already allocated native
-     * EmojiFactory int (pointer).
-     *
-     * This can be called from JNI code.
-     */
-    private EmojiFactory(long nativeEmojiFactory, String name) {
-        mNativeEmojiFactory = nativeEmojiFactory;
-        mName = name;
-        mCache = new CustomLinkedHashMap<Integer, WeakReference<Bitmap>>();
-    }
-    
-    @Override
-    protected void finalize() throws Throwable {
-        try {
-            nativeDestructor(mNativeEmojiFactory);
-        } finally {
-            super.finalize();
-        }
-    }
-    
-    public String name() {
-        return mName;
-    }
-    
-    /**
-     * Returns Bitmap object corresponding to the AndroidPua.
-     * 
-     * Note that each Bitmap is cached by this class, which means that, if you modify a
-     * Bitmap object (using setPos() method), all same emoji Bitmap will be modified.
-     * If it is unacceptable, please copy the object before modifying it.
-     *  
-     * @param pua A unicode codepoint.
-     * @return Bitmap object when this factory knows the Bitmap relevant to the codepoint.
-     * Otherwise null is returned.  
-     */
-    public synchronized Bitmap getBitmapFromAndroidPua(int pua) {
-        WeakReference<Bitmap> cache = mCache.get(pua);
-        if (cache == null) {
-            Bitmap ret = nativeGetBitmapFromAndroidPua(mNativeEmojiFactory, pua);
-            // There is no need to cache returned null, since in most cases it means there
-            // is no map from the AndroidPua to a specific image. In other words, it usually does
-            // not include the cost of creating Bitmap object.
-            if (ret != null) {
-               mCache.put(pua, new WeakReference<Bitmap>(ret));
-            }
-            return ret;
-        } else {
-            Bitmap tmp = cache.get();
-            if (tmp == null) {
-                Bitmap ret = nativeGetBitmapFromAndroidPua(mNativeEmojiFactory, pua);
-                mCache.put(pua, new WeakReference<Bitmap>(ret));
-                return ret;
-            } else {
-                return tmp;
-            }
-        }
-    }
-
-    /**
-     * Returns Bitmap object corresponding to the vendor specified sjis.
-     * 
-     * See comments in getBitmapFromAndroidPua().
-     * 
-     * @param sjis sjis code specific to each career(vendor)
-     * @return Bitmap object when this factory knows the Bitmap relevant to the code. Otherwise
-     * null is returned.
-     */
-    public synchronized Bitmap getBitmapFromVendorSpecificSjis(char sjis) {
-        return getBitmapFromAndroidPua(getAndroidPuaFromVendorSpecificSjis(sjis));
-    }
-
-    /**
-     * Returns Bitmap object corresponding to the vendor specific Unicode.
-     * 
-     * See comments in getBitmapFromAndroidPua().
-     * 
-     * @param vsp vendor specific PUA.
-     * @return Bitmap object when this factory knows the Bitmap relevant to the code. Otherwise
-     * null is returned.
-     */
-    public synchronized Bitmap getBitmapFromVendorSpecificPua(int vsp) {
-        return getBitmapFromAndroidPua(getAndroidPuaFromVendorSpecificPua(vsp));
-    }
-    
-    /**
-     * Returns Unicode PUA for Android corresponding to the vendor specific sjis.
-     * 
-     * @param sjis vendor specific sjis
-     * @return Unicode PUA for Android, or -1 if there's no map for the sjis.
-     */
-    public int getAndroidPuaFromVendorSpecificSjis(char sjis) {
-        return nativeGetAndroidPuaFromVendorSpecificSjis(mNativeEmojiFactory, sjis);
-    }
-    
-    /**
-     * Returns vendor specific sjis corresponding to the Unicode AndroidPua.
-     * 
-     * @param pua Unicode PUA for Android,
-     * @return vendor specific sjis, or -1 if there's no map for the AndroidPua.
-     */
-    public int getVendorSpecificSjisFromAndroidPua(int pua) {
-        return nativeGetVendorSpecificSjisFromAndroidPua(mNativeEmojiFactory, pua);
-    }
-    
-    /**
-     * Returns Unicode PUA for Android corresponding to the vendor specific Unicode.
-     * 
-     * @param vsp vendor specific PUA.
-     * @return Unicode PUA for Android, or -1 if there's no map for the
-     * Unicode.
-     */
-    public int getAndroidPuaFromVendorSpecificPua(int vsp) {
-        return nativeGetAndroidPuaFromVendorSpecificPua(mNativeEmojiFactory, vsp);
-    }
-
-    public String getAndroidPuaFromVendorSpecificPua(String vspString) {
-        if (vspString == null) {
-            return null;
-        }
-        int minVsp = nativeGetMinimumVendorSpecificPua(mNativeEmojiFactory);
-        int maxVsp = nativeGetMaximumVendorSpecificPua(mNativeEmojiFactory);
-        int len = vspString.length();
-        int[] codePoints = new int[vspString.codePointCount(0, len)];
-
-        int new_len = 0;
-        for (int i = 0; i < len; i = vspString.offsetByCodePoints(i, 1), new_len++) {
-            int codePoint = vspString.codePointAt(i);
-            if (minVsp <= codePoint && codePoint <= maxVsp) {
-                int newCodePoint = getAndroidPuaFromVendorSpecificPua(codePoint);
-                if (newCodePoint > 0) {
-                    codePoints[new_len] = newCodePoint;
-                    continue;
-                }
-            }
-            codePoints[new_len] = codePoint;
-        }
-        return new String(codePoints, 0, new_len);
-    }
-    
-    /**
-     * Returns vendor specific Unicode corresponding to the Unicode AndroidPua.
-     * 
-     * @param pua Unicode PUA for Android,
-     * @return vendor specific sjis, or -1 if there's no map for the AndroidPua.
-     */
-    public int getVendorSpecificPuaFromAndroidPua(int pua) {
-        return nativeGetVendorSpecificPuaFromAndroidPua(mNativeEmojiFactory, pua);
-    }
-
-    public String getVendorSpecificPuaFromAndroidPua(String puaString) {
-        if (puaString == null) {
-            return null;
-        }
-        int minVsp = nativeGetMinimumAndroidPua(mNativeEmojiFactory);
-        int maxVsp = nativeGetMaximumAndroidPua(mNativeEmojiFactory);
-        int len = puaString.length();
-        int[] codePoints = new int[puaString.codePointCount(0, len)];
-
-        int new_len = 0;
-        for (int i = 0; i < len; i = puaString.offsetByCodePoints(i, 1), new_len++) {
-            int codePoint = puaString.codePointAt(i);
-            if (minVsp <= codePoint && codePoint <= maxVsp) {
-                int newCodePoint = getVendorSpecificPuaFromAndroidPua(codePoint);
-                if (newCodePoint > 0) {
-                    codePoints[new_len] = newCodePoint;
-                    continue;
-                }
-            }
-            codePoints[new_len] = codePoint;
-        }
-        return new String(codePoints, 0, new_len);
-    }
-
-    /**
-     * Constructs an instance of EmojiFactory corresponding to the name.
-     *  
-     * @param class_name Name of the factory. This must include complete package name.
-     * @return A concrete EmojiFactory instance corresponding to factory_name.
-     * If factory_name is invalid, null is returned. 
-     */
-    public static native EmojiFactory newInstance(String class_name);
-    
-    /**
-     * Constructs an instance of available EmojiFactory.
-     * 
-     * @return A concrete EmojiFactory instance. If there are several available
-     * EmojiFactory class, preferred one is chosen by the system. If there isn't, null
-     * is returned. 
-     */
-    public static native EmojiFactory newAvailableInstance();
-
-    /**
-     * Returns the lowest code point corresponding to an Android
-     * emoji character.
-     */
-    public int getMinimumAndroidPua() {
-        return nativeGetMinimumAndroidPua(mNativeEmojiFactory);
-    }
-
-    /**
-     * Returns the highest code point corresponding to an Android
-     * emoji character.
-     */
-    public int getMaximumAndroidPua() {
-        return nativeGetMaximumAndroidPua(mNativeEmojiFactory);
-    }
-    
-    // native methods
-    
-    private native void nativeDestructor(long nativeEmojiFactory);
-    private native Bitmap nativeGetBitmapFromAndroidPua(long nativeEmojiFactory, int AndroidPua);
-    private native int nativeGetAndroidPuaFromVendorSpecificSjis(long nativeEmojiFactory,
-            char sjis);
-    private native int nativeGetVendorSpecificSjisFromAndroidPua(long nativeEmojiFactory,
-            int pua);
-    private native int nativeGetAndroidPuaFromVendorSpecificPua(long nativeEmojiFactory,
-            int vsp);
-    private native int nativeGetVendorSpecificPuaFromAndroidPua(long nativeEmojiFactory,
-            int pua);
-    private native int nativeGetMaximumVendorSpecificPua(long nativeEmojiFactory);
-    private native int nativeGetMinimumVendorSpecificPua(long nativeEmojiFactory);
-    private native int nativeGetMaximumAndroidPua(long nativeEmojiFactory);
-    private native int nativeGetMinimumAndroidPua(long nativeEmojiFactory);
-}
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index f2cbe98..a4e6219 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1550,8 +1550,9 @@
             context.enforceCallingOrSelfPermission(
                     android.Manifest.permission.CONNECTIVITY_INTERNAL, "ConnectivityService");
         } else {
-            context.enforceCallingOrSelfPermission(
-                    android.Manifest.permission.CHANGE_NETWORK_STATE, "ConnectivityService");
+            int uid = Binder.getCallingUid();
+            Settings.checkAndNoteChangeNetworkStateOperation(context, uid, Settings
+                    .getPackageNameForUid(context, uid), true);
         }
     }
 
diff --git a/core/java/android/net/NetworkScorerAppManager.java b/core/java/android/net/NetworkScorerAppManager.java
index 46f7194..29daf35 100644
--- a/core/java/android/net/NetworkScorerAppManager.java
+++ b/core/java/android/net/NetworkScorerAppManager.java
@@ -23,6 +23,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.os.UserHandle;
@@ -54,6 +55,9 @@
         /** Package name of this scorer app. */
         public final String mPackageName;
 
+        /** UID of the scorer app. */
+        public final int mPackageUid;
+
         /** Name of this scorer app for display. */
         public final CharSequence mScorerName;
 
@@ -64,10 +68,11 @@
          */
         public final String mConfigurationActivityClassName;
 
-        public NetworkScorerAppData(String packageName, CharSequence scorerName,
+        public NetworkScorerAppData(String packageName, int packageUid, CharSequence scorerName,
                 @Nullable String configurationActivityClassName) {
             mScorerName = scorerName;
             mPackageName = packageName;
+            mPackageUid = packageUid;
             mConfigurationActivityClassName = configurationActivityClassName;
         }
     }
@@ -125,7 +130,8 @@
             // NOTE: loadLabel will attempt to load the receiver's label and fall back to the app
             // label if none is present.
             scorers.add(new NetworkScorerAppData(receiverInfo.packageName,
-                    receiverInfo.loadLabel(pm), configurationActivityClassName));
+                    receiverInfo.applicationInfo.uid, receiverInfo.loadLabel(pm),
+                    configurationActivityClassName));
         }
 
         return scorers;
@@ -187,13 +193,9 @@
         if (defaultApp == null) {
             return false;
         }
-        AppOpsManager appOpsMgr = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
-        try {
-            appOpsMgr.checkPackage(callingUid, defaultApp.mPackageName);
-        } catch (SecurityException e) {
+        if (callingUid != defaultApp.mPackageUid) {
             return false;
         }
-
         // To be extra safe, ensure the caller holds the SCORE_NETWORKS permission. It always
         // should, since it couldn't become the active scorer otherwise, but this can't hurt.
         return context.checkCallingPermission(Manifest.permission.SCORE_NETWORKS) ==
diff --git a/core/java/android/os/IDeviceIdleController.aidl b/core/java/android/os/IDeviceIdleController.aidl
index d3eec1e..f55883a 100644
--- a/core/java/android/os/IDeviceIdleController.aidl
+++ b/core/java/android/os/IDeviceIdleController.aidl
@@ -22,10 +22,14 @@
 interface IDeviceIdleController {
     void addPowerSaveWhitelistApp(String name);
     void removePowerSaveWhitelistApp(String name);
+    String[] getSystemPowerWhitelistExceptIdle();
     String[] getSystemPowerWhitelist();
+    String[] getFullPowerWhitelistExceptIdle();
     String[] getFullPowerWhitelist();
+    int[] getAppIdWhitelistExceptIdle();
     int[] getAppIdWhitelist();
     int[] getAppIdTempWhitelist();
+    boolean isPowerSaveWhitelistExceptIdleApp(String name);
     boolean isPowerSaveWhitelistApp(String name);
     void addPowerSaveTempWhitelistApp(String name, long duration, int userId, String reason);
     long addPowerSaveTempWhitelistAppForMms(String name, int userId, String reason);
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index af3eec2..e3694e8 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -5653,7 +5653,6 @@
             /**
              * The alphabet used for capturing the phonetic name.
              * See ContactsContract.PhoneticNameStyle.
-             * @hide
              */
             public static final String PHONETIC_NAME_STYLE = DATA11;
         }
@@ -6693,7 +6692,6 @@
             /**
              * The alphabet used for capturing the phonetic name.
              * See {@link ContactsContract.PhoneticNameStyle}.
-             * @hide
              */
             public static final String PHONETIC_NAME_STYLE = DATA10;
 
@@ -9101,4 +9099,71 @@
          */
         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata";
     }
+
+    /**
+     * @hide
+     */
+    @SystemApi
+    protected interface MetadataSyncStateColumns {
+
+        /**
+         * A reference to the name of the account to which this state belongs
+         * <P>Type: STRING</P>
+         */
+        public static final String ACCOUNT_TYPE = "account_type";
+
+        /**
+         * A reference to the type of the account to which this state belongs
+         * <P>Type: STRING</P>
+         */
+        public static final String ACCOUNT_NAME = "account_name";
+
+        /**
+         * A reference to the data set within the account to which this state belongs
+         * <P>Type: STRING</P>
+         */
+        public static final String DATA_SET = "data_set";
+
+        /**
+         * The sync state associated with this account.
+         * <P>Type: Blob</P>
+         */
+        public static final String STATE = "state";
+    }
+
+    /**
+     * Constants for the metadata_sync_state table. This table is used to store the metadata
+     * sync state for a set of accounts.
+     *
+     * @hide
+     */
+    @SystemApi
+    public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns {
+
+        /**
+         * This utility class cannot be instantiated
+         */
+        private MetadataSyncState() {
+        }
+
+        /**
+         * The content:// style URI for this table.
+         */
+        public static final Uri CONTENT_URI =
+                Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state");
+
+        /**
+         * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync
+         * states.
+         */
+        public static final String CONTENT_TYPE =
+                "vnd.android.cursor.dir/contact_metadata_sync_state";
+
+        /**
+         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync
+         * state.
+         */
+        public static final String CONTENT_ITEM_TYPE =
+                "vnd.android.cursor.item/contact_metadata_sync_state";
+    }
 }
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 601403c..3cd01d0 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1408,6 +1408,25 @@
     }
 
     /**
+     * An app can use this method to check if it is currently allowed to change the network
+     * state. In order to be allowed to do so, an app must first declare either the
+     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE} or
+     * {@link android.Manifest.permission#WRITE_SETTINGS} permission in its manifest. If it
+     * is currently disallowed, it can prompt the user to grant it this capability through a
+     * management UI by sending an Intent with action
+     * {@link android.provider.Settings#ACTION_MANAGE_WRITE_SETTINGS}.
+     *
+     * @param context A context
+     * @return true if the calling app can change the state of network, false otherwise.
+     * @hide
+     */
+    public static boolean canChangeNetworkState(Context context) {
+        int uid = Binder.getCallingUid();
+        return Settings.isCallingPackageAllowedToChangeNetworkState(context, uid, Settings
+                .getPackageNameForUid(context, uid), false);
+    }
+
+    /**
      * System settings, containing miscellaneous system preferences.  This
      * table holds simple name/value pairs.  There are convenience
      * functions for accessing individual settings entries.
@@ -8265,6 +8284,17 @@
         return "android-" + Long.toHexString(androidId);
     }
 
+    private static final String[] PM_WRITE_SETTINGS = {
+        android.Manifest.permission.WRITE_SETTINGS
+    };
+    private static final String[] PM_CHANGE_NETWORK_STATE = {
+        android.Manifest.permission.CHANGE_NETWORK_STATE,
+        android.Manifest.permission.WRITE_SETTINGS
+    };
+    private static final String[] PM_SYSTEM_ALERT_WINDOW = {
+        android.Manifest.permission.SYSTEM_ALERT_WINDOW
+    };
+
     /**
      * Performs a strict and comprehensive check of whether a calling package is allowed to
      * write/modify system settings, as the condition differs for pre-M, M+, and
@@ -8276,14 +8306,15 @@
             String callingPackage, boolean throwException) {
         return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
                 callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
-                android.Manifest.permission.WRITE_SETTINGS, false);
+                PM_WRITE_SETTINGS, false);
     }
 
     /**
      * Performs a strict and comprehensive check of whether a calling package is allowed to
      * write/modify system settings, as the condition differs for pre-M, M+, and
      * privileged/preinstalled apps. If the provided uid does not match the
-     * callingPackage, a negative result will be returned.
+     * callingPackage, a negative result will be returned. The caller is expected to have
+     * either WRITE_SETTINGS or CHANGE_NETWORK_STATE permission declared.
      *
      * Note: if the check is successful, the operation of this app will be updated to the
      * current time.
@@ -8293,7 +8324,40 @@
             String callingPackage, boolean throwException) {
         return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
                 callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
-                android.Manifest.permission.WRITE_SETTINGS, true);
+                PM_WRITE_SETTINGS, true);
+    }
+
+    /**
+     * Performs a strict and comprehensive check of whether a calling package is allowed to
+     * change the state of network, as the condition differs for pre-M, M+, and
+     * privileged/preinstalled apps. If the provided uid does not match the
+     * callingPackage, a negative result will be returned. The caller is expected to have
+     * either of CHANGE_NETWORK_STATE or WRITE_SETTINGS permission declared.
+     * @hide
+     */
+    public static boolean isCallingPackageAllowedToChangeNetworkState(Context context, int uid,
+            String callingPackage, boolean throwException) {
+        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
+                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
+                PM_CHANGE_NETWORK_STATE, false);
+    }
+
+    /**
+     * Performs a strict and comprehensive check of whether a calling package is allowed to
+     * change the state of network, as the condition differs for pre-M, M+, and
+     * privileged/preinstalled apps. If the provided uid does not match the
+     * callingPackage, a negative result will be returned. The caller is expected to have
+     * either CHANGE_NETWORK_STATE or WRITE_SETTINGS permission declared.
+     *
+     * Note: if the check is successful, the operation of this app will be updated to the
+     * current time.
+     * @hide
+     */
+    public static boolean checkAndNoteChangeNetworkStateOperation(Context context, int uid,
+            String callingPackage, boolean throwException) {
+        return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
+                callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS,
+                PM_CHANGE_NETWORK_STATE, true);
     }
 
     /**
@@ -8307,7 +8371,7 @@
             String callingPackage, boolean throwException) {
         return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
                 callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
-                android.Manifest.permission.SYSTEM_ALERT_WINDOW, false);
+                PM_SYSTEM_ALERT_WINDOW, false);
     }
 
     /**
@@ -8324,7 +8388,7 @@
             callingPackage, boolean throwException) {
         return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid,
                 callingPackage, throwException, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
-                android.Manifest.permission.SYSTEM_ALERT_WINDOW, true);
+                PM_SYSTEM_ALERT_WINDOW, true);
     }
 
     /**
@@ -8334,8 +8398,8 @@
      * @hide
      */
     public static boolean isCallingPackageAllowedToPerformAppOpsProtectedOperation(Context context,
-            int uid, String callingPackage, boolean throwException, int appOpsOpCode, String
-            permissionName, boolean makeNote) {
+            int uid, String callingPackage, boolean throwException, int appOpsOpCode, String[]
+            permissions, boolean makeNote) {
         if (callingPackage == null) {
             return false;
         }
@@ -8351,20 +8415,41 @@
         switch (mode) {
             case AppOpsManager.MODE_ALLOWED:
                 return true;
+
             case AppOpsManager.MODE_DEFAULT:
                 // this is the default operating mode after an app's installation
-                if(context.checkCallingOrSelfPermission(permissionName) == PackageManager
-                        .PERMISSION_GRANTED) {
-                    return true;
+                // In this case we will check all associated static permission to see
+                // if it is granted during install time.
+                for (String permission : permissions) {
+                    if (context.checkCallingOrSelfPermission(permission) == PackageManager
+                            .PERMISSION_GRANTED) {
+                        // if either of the permissions are granted, we will allow it
+                        return true;
+                    }
                 }
+
             default:
                 // this is for all other cases trickled down here...
                 if (!throwException) {
                     return false;
                 }
         }
-        throw new SecurityException(callingPackage + " was not granted "
-                + permissionName + " permission");
+
+        // prepare string to throw SecurityException
+        StringBuilder exceptionMessage = new StringBuilder();
+        exceptionMessage.append(callingPackage);
+        exceptionMessage.append(" was not granted ");
+        if (permissions.length > 1) {
+            exceptionMessage.append(" either of these permissions: ");
+        } else {
+            exceptionMessage.append(" this permission: ");
+        }
+        for (int i = 0; i < permissions.length; i++) {
+            exceptionMessage.append(permissions[i]);
+            exceptionMessage.append((i == permissions.length - 1) ? "." : ", ");
+        }
+
+        throw new SecurityException(exceptionMessage.toString());
     }
 
     /**
diff --git a/core/java/android/text/BidiFormatter.java b/core/java/android/text/BidiFormatter.java
index 5c088cd..a535480 100644
--- a/core/java/android/text/BidiFormatter.java
+++ b/core/java/android/text/BidiFormatter.java
@@ -196,17 +196,13 @@
             return this;
         }
 
-        private static BidiFormatter getDefaultInstanceFromContext(boolean isRtlContext) {
-            return isRtlContext ? DEFAULT_RTL_INSTANCE : DEFAULT_LTR_INSTANCE;
-        }
-
         /**
          * @return A BidiFormatter with the specified options.
          */
         public BidiFormatter build() {
             if (mFlags == DEFAULT_FLAGS &&
                     mTextDirectionHeuristic == DEFAULT_TEXT_DIRECTION_HEURISTIC) {
-                return getDefaultInstanceFromContext(mIsRtlContext);
+                return BidiFormatter.getDefaultInstanceFromContext(mIsRtlContext);
             }
             return new BidiFormatter(mIsRtlContext, mFlags, mTextDirectionHeuristic);
         }
@@ -233,27 +229,33 @@
     /**
      * Factory for creating an instance of BidiFormatter for the default locale directionality.
      *
+     * This does not create any new objects, and returns already existing static instances.
+     *
      */
     public static BidiFormatter getInstance() {
-        return new Builder().build();
+        return getDefaultInstanceFromContext(isRtlLocale(Locale.getDefault()));
     }
 
     /**
      * Factory for creating an instance of BidiFormatter given the context directionality.
      *
+     * This does not create any new objects, and returns already existing static instances.
+     *
      * @param rtlContext Whether the context directionality is RTL.
      */
     public static BidiFormatter getInstance(boolean rtlContext) {
-        return new Builder(rtlContext).build();
+        return getDefaultInstanceFromContext(rtlContext);
     }
 
     /**
      * Factory for creating an instance of BidiFormatter given the context locale.
      *
+     * This does not create any new objects, and returns already existing static instances.
+     *
      * @param locale The context locale.
      */
     public static BidiFormatter getInstance(Locale locale) {
-        return new Builder(locale).build();
+        return getDefaultInstanceFromContext(isRtlLocale(locale));
     }
 
     /**
@@ -440,6 +442,10 @@
         return unicodeWrap(str, mDefaultTextDirectionHeuristic, true /* isolate */);
     }
 
+    private static BidiFormatter getDefaultInstanceFromContext(boolean isRtlContext) {
+        return isRtlContext ? DEFAULT_RTL_INSTANCE : DEFAULT_LTR_INSTANCE;
+    }
+
     /**
      * Helper method to return true if the Locale directionality is RTL.
      *
diff --git a/core/java/android/text/Hyphenator.java b/core/java/android/text/Hyphenator.java
index 10a994a..1665c75 100644
--- a/core/java/android/text/Hyphenator.java
+++ b/core/java/android/text/Hyphenator.java
@@ -53,11 +53,15 @@
         mNativePtr = nativePtr;
     }
 
-    public static long get(@Nullable Locale locale) {
+    public long getNativePtr() {
+        return mNativePtr;
+    }
+
+    public static Hyphenator get(@Nullable Locale locale) {
         synchronized (sLock) {
             Hyphenator result = sMap.get(locale);
             if (result != null) {
-                return result.mNativePtr;
+                return result;
             }
 
             // TODO: Convert this a proper locale-fallback system
@@ -67,7 +71,7 @@
             result = sMap.get(languageOnlyLocale);
             if (result != null) {
                 sMap.put(locale, result);
-                return result.mNativePtr;
+                return result;
             }
 
             // Fall back to script-only, if available
@@ -80,13 +84,13 @@
                 result = sMap.get(scriptOnlyLocale);
                 if (result != null) {
                     sMap.put(locale, result);
-                    return result.mNativePtr;
+                    return result;
                 }
             }
 
             sMap.put(locale, sEmptyHyphenator);  // To remember we found nothing.
         }
-        return sEmptyHyphenator.mNativePtr;
+        return sEmptyHyphenator;
     }
 
     private static Hyphenator loadHyphenator(String languageTag) {
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index fa347b9..cf937e1 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -17,7 +17,6 @@
 package android.text;
 
 import android.annotation.IntDef;
-import android.emoji.EmojiFactory;
 import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.graphics.Path;
@@ -103,19 +102,6 @@
     private static final ParagraphStyle[] NO_PARA_SPANS =
         ArrayUtils.emptyArray(ParagraphStyle.class);
 
-    /* package */ static final EmojiFactory EMOJI_FACTORY = EmojiFactory.newAvailableInstance();
-    /* package */ static final int MIN_EMOJI, MAX_EMOJI;
-
-    static {
-        if (EMOJI_FACTORY != null) {
-            MIN_EMOJI = EMOJI_FACTORY.getMinimumAndroidPua();
-            MAX_EMOJI = EMOJI_FACTORY.getMaximumAndroidPua();
-        } else {
-            MIN_EMOJI = -1;
-            MAX_EMOJI = -1;
-        }
-    }
-
     /**
      * Return how wide a layout must be in order to display the
      * specified text with one line per paragraph.
@@ -360,9 +346,9 @@
                 }
             }
 
-            boolean hasTabOrEmoji = getLineContainsTab(lineNum);
+            boolean hasTab = getLineContainsTab(lineNum);
             // Can't tell if we have tabs for sure, currently
-            if (hasTabOrEmoji && !tabStopsIsInitialized) {
+            if (hasTab && !tabStopsIsInitialized) {
                 if (tabStops == null) {
                     tabStops = new TabStops(TAB_INCREMENT, spans);
                 } else {
@@ -405,11 +391,11 @@
 
             paint.setHyphenEdit(getHyphen(lineNum));
             Directions directions = getLineDirections(lineNum);
-            if (directions == DIRS_ALL_LEFT_TO_RIGHT && !mSpannedText && !hasTabOrEmoji) {
+            if (directions == DIRS_ALL_LEFT_TO_RIGHT && !mSpannedText && !hasTab) {
                 // XXX: assumes there's nothing additional to be done
                 canvas.drawText(buf, start, end, x, lbaseline, paint);
             } else {
-                tl.set(paint, buf, start, end, dir, directions, hasTabOrEmoji, tabStops);
+                tl.set(paint, buf, start, end, dir, directions, hasTab, tabStops);
                 tl.draw(canvas, x, ltop, lbaseline, lbottom);
             }
             paint.setHyphenEdit(0);
@@ -710,8 +696,7 @@
 
     /**
      * Returns whether the specified line contains one or more
-     * characters that need to be handled specially, like tabs
-     * or emoji.
+     * characters that need to be handled specially, like tabs.
      */
     public abstract boolean getLineContainsTab(int line);
 
@@ -911,11 +896,11 @@
         int start = getLineStart(line);
         int end = getLineEnd(line);
         int dir = getParagraphDirection(line);
-        boolean hasTabOrEmoji = getLineContainsTab(line);
+        boolean hasTab = getLineContainsTab(line);
         Directions directions = getLineDirections(line);
 
         TabStops tabStops = null;
-        if (hasTabOrEmoji && mText instanceof Spanned) {
+        if (hasTab && mText instanceof Spanned) {
             // Just checking this line should be good enough, tabs should be
             // consistent across all lines in a paragraph.
             TabStopSpan[] tabs = getParagraphSpans((Spanned) mText, start, end, TabStopSpan.class);
@@ -925,7 +910,7 @@
         }
 
         TextLine tl = TextLine.obtain();
-        tl.set(mPaint, mText, start, end, dir, directions, hasTabOrEmoji, tabStops);
+        tl.set(mPaint, mText, start, end, dir, directions, hasTab, tabStops);
         float wid = tl.measure(offset - start, trailing, null);
         TextLine.recycle(tl);
 
@@ -1031,9 +1016,9 @@
         int start = getLineStart(line);
         int end = full ? getLineEnd(line) : getLineVisibleEnd(line);
 
-        boolean hasTabsOrEmoji = getLineContainsTab(line);
+        boolean hasTabs = getLineContainsTab(line);
         TabStops tabStops = null;
-        if (hasTabsOrEmoji && mText instanceof Spanned) {
+        if (hasTabs && mText instanceof Spanned) {
             // Just checking this line should be good enough, tabs should be
             // consistent across all lines in a paragraph.
             TabStopSpan[] tabs = getParagraphSpans((Spanned) mText, start, end, TabStopSpan.class);
@@ -1049,7 +1034,7 @@
         int dir = getParagraphDirection(line);
 
         TextLine tl = TextLine.obtain();
-        tl.set(mPaint, mText, start, end, dir, directions, hasTabsOrEmoji, tabStops);
+        tl.set(mPaint, mText, start, end, dir, directions, hasTabs, tabStops);
         float width = tl.metrics(null);
         TextLine.recycle(tl);
         return width;
@@ -1066,12 +1051,12 @@
     private float getLineExtent(int line, TabStops tabStops, boolean full) {
         int start = getLineStart(line);
         int end = full ? getLineEnd(line) : getLineVisibleEnd(line);
-        boolean hasTabsOrEmoji = getLineContainsTab(line);
+        boolean hasTabs = getLineContainsTab(line);
         Directions directions = getLineDirections(line);
         int dir = getParagraphDirection(line);
 
         TextLine tl = TextLine.obtain();
-        tl.set(mPaint, mText, start, end, dir, directions, hasTabsOrEmoji, tabStops);
+        tl.set(mPaint, mText, start, end, dir, directions, hasTabs, tabStops);
         float width = tl.metrics(null);
         TextLine.recycle(tl);
         return width;
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 3b0def2..79c4a55 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -341,7 +341,8 @@
 
         private void setLocale(Locale locale) {
             if (!locale.equals(mLocale)) {
-                nSetLocale(mNativePtr, locale.toLanguageTag(), Hyphenator.get(locale));
+                nSetLocale(mNativePtr, locale.toLanguageTag(),
+                        Hyphenator.get(locale).getNativePtr());
                 mLocale = locale;
             }
         }
@@ -1308,7 +1309,7 @@
         private static final int INITIAL_SIZE = 16;
         public int[] breaks = new int[INITIAL_SIZE];
         public float[] widths = new float[INITIAL_SIZE];
-        public int[] flags = new int[INITIAL_SIZE]; // hasTabOrEmoji
+        public int[] flags = new int[INITIAL_SIZE]; // hasTab
         // breaks, widths, and flags should all have the same length
     }
 
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index 39e8694..c42c791 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -128,7 +128,7 @@
      * @param limit the limit of the line relative to the text
      * @param dir the paragraph direction of this line
      * @param directions the directions information of this line
-     * @param hasTabs true if the line might contain tabs or emoji
+     * @param hasTabs true if the line might contain tabs
      * @param tabStops the tabStops. Can be null.
      */
     void set(TextPaint paint, CharSequence text, int start, int limit, int dir,
@@ -204,7 +204,6 @@
 
         float h = 0;
         int[] runs = mDirections.mDirections;
-        RectF emojiRect = null;
 
         int lastRunIndex = runs.length - 2;
         for (int i = 0; i < runs.length; i += 2) {
@@ -218,41 +217,23 @@
             int segstart = runStart;
             for (int j = mHasTabs ? runStart : runLimit; j <= runLimit; j++) {
                 int codept = 0;
-                Bitmap bm = null;
-
                 if (mHasTabs && j < runLimit) {
                     codept = mChars[j];
-                    if (codept >= 0xd800 && codept < 0xdc00 && j + 1 < runLimit) {
+                    if (codept >= 0xD800 && codept < 0xDC00 && j + 1 < runLimit) {
                         codept = Character.codePointAt(mChars, j);
-                        if (codept >= Layout.MIN_EMOJI && codept <= Layout.MAX_EMOJI) {
-                            bm = Layout.EMOJI_FACTORY.getBitmapFromAndroidPua(codept);
-                        } else if (codept > 0xffff) {
+                        if (codept > 0xFFFF) {
                             ++j;
                             continue;
                         }
                     }
                 }
 
-                if (j == runLimit || codept == '\t' || bm != null) {
+                if (j == runLimit || codept == '\t') {
                     h += drawRun(c, segstart, j, runIsRtl, x+h, top, y, bottom,
                             i != lastRunIndex || j != mLen);
 
                     if (codept == '\t') {
                         h = mDir * nextTab(h * mDir);
-                    } else if (bm != null) {
-                        float bmAscent = ascent(j);
-                        float bitmapHeight = bm.getHeight();
-                        float scale = -bmAscent / bitmapHeight;
-                        float width = bm.getWidth() * scale;
-
-                        if (emojiRect == null) {
-                            emojiRect = new RectF();
-                        }
-                        emojiRect.set(x + h, y + bmAscent,
-                                x + h + width, y);
-                        c.drawBitmap(bm, null, emojiRect, mPaint);
-                        h += width;
-                        j++;
                     }
                     segstart = j + 1;
                 }
@@ -313,22 +294,18 @@
             int segstart = runStart;
             for (int j = mHasTabs ? runStart : runLimit; j <= runLimit; j++) {
                 int codept = 0;
-                Bitmap bm = null;
-
                 if (mHasTabs && j < runLimit) {
                     codept = chars[j];
-                    if (codept >= 0xd800 && codept < 0xdc00 && j + 1 < runLimit) {
+                    if (codept >= 0xD800 && codept < 0xDC00 && j + 1 < runLimit) {
                         codept = Character.codePointAt(chars, j);
-                        if (codept >= Layout.MIN_EMOJI && codept <= Layout.MAX_EMOJI) {
-                            bm = Layout.EMOJI_FACTORY.getBitmapFromAndroidPua(codept);
-                        } else if (codept > 0xffff) {
+                        if (codept > 0xFFFF) {
                             ++j;
                             continue;
                         }
                     }
                 }
 
-                if (j == runLimit || codept == '\t' || bm != null) {
+                if (j == runLimit || codept == '\t') {
                     boolean inSegment = target >= segstart && target < j;
 
                     boolean advance = (mDir == Layout.DIR_RIGHT_TO_LEFT) == runIsRtl;
@@ -353,13 +330,6 @@
                         }
                     }
 
-                    if (bm != null) {
-                        float bmAscent = ascent(j);
-                        float wid = bm.getWidth() * -bmAscent / bm.getHeight();
-                        h += mDir * wid;
-                        j++;
-                    }
-
                     segstart = j + 1;
                 }
             }
@@ -705,7 +675,7 @@
 
     /**
      * Utility function for measuring and rendering text.  The text must
-     * not include a tab or emoji.
+     * not include a tab.
      *
      * @param wp the working paint
      * @param start the start of the text
@@ -860,7 +830,7 @@
 
     /**
      * Utility function for handling a unidirectional run.  The run must not
-     * contain tabs or emoji but can contain styles.
+     * contain tabs but can contain styles.
      *
      *
      * @param start the line-relative start of the run
@@ -994,32 +964,6 @@
     }
 
     /**
-     * Returns the ascent of the text at start.  This is used for scaling
-     * emoji.
-     *
-     * @param pos the line-relative position
-     * @return the ascent of the text at start
-     */
-    float ascent(int pos) {
-        if (mSpanned == null) {
-            return mPaint.ascent();
-        }
-
-        pos += mStart;
-        MetricAffectingSpan[] spans = mSpanned.getSpans(pos, pos + 1, MetricAffectingSpan.class);
-        if (spans.length == 0) {
-            return mPaint.ascent();
-        }
-
-        TextPaint wp = mWorkPaint;
-        wp.set(mPaint);
-        for (MetricAffectingSpan span : spans) {
-            span.updateMeasureState(wp);
-        }
-        return wp.ascent();
-    }
-
-    /**
      * Returns the next tab position.
      *
      * @param h the (unsigned) offset from the leading margin
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index d8f7158..ae2c0c7 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -18,6 +18,7 @@
 
 import android.annotation.Nullable;
 import android.content.res.Resources;
+import android.icu.util.ULocale;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.os.SystemProperties;
@@ -283,17 +284,6 @@
     }
 
     /**
-     * Returns list of multiple {@link CharSequence} joined into a single
-     * {@link CharSequence} separated by localized delimiter such as ", ".
-     *
-     * @hide
-     */
-    public static CharSequence join(Iterable<CharSequence> list) {
-        final CharSequence delimiter = Resources.getSystem().getText(R.string.list_delimeter);
-        return join(delimiter, list);
-    }
-
-    /**
      * Returns a string containing the tokens joined by delimiters.
      * @param tokens an array objects to be joined. Strings will be formed from
      *     the objects by calling object.toString().
@@ -1754,45 +1744,12 @@
      * Be careful: this code will need to be updated when vertical scripts will be supported
      */
     public static int getLayoutDirectionFromLocale(Locale locale) {
-        if (locale != null && !locale.equals(Locale.ROOT)) {
-            final String scriptSubtag = ICU.addLikelySubtags(locale).getScript();
-            if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale);
-
-            if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) ||
-                    scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {
-                return View.LAYOUT_DIRECTION_RTL;
-            }
-        }
-        // If forcing into RTL layout mode, return RTL as default, else LTR
-        return SystemProperties.getBoolean(Settings.Global.DEVELOPMENT_FORCE_RTL, false)
-                ? View.LAYOUT_DIRECTION_RTL
-                : View.LAYOUT_DIRECTION_LTR;
-    }
-
-    /**
-     * Fallback algorithm to detect the locale direction. Rely on the fist char of the
-     * localized locale name. This will not work if the localized locale name is in English
-     * (this is the case for ICU 4.4 and "Urdu" script)
-     *
-     * @param locale
-     * @return the layout direction. This may be one of:
-     * {@link View#LAYOUT_DIRECTION_LTR} or
-     * {@link View#LAYOUT_DIRECTION_RTL}.
-     *
-     * Be careful: this code will need to be updated when vertical scripts will be supported
-     *
-     * @hide
-     */
-    private static int getLayoutDirectionFromFirstChar(Locale locale) {
-        switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
-            case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
-            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
-                return View.LAYOUT_DIRECTION_RTL;
-
-            case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
-            default:
-                return View.LAYOUT_DIRECTION_LTR;
-        }
+        return ((locale != null && !locale.equals(Locale.ROOT)
+                        && ULocale.forLocale(locale).isRightToLeft())
+                // If forcing into RTL layout mode, return RTL as default
+                || SystemProperties.getBoolean(Settings.Global.DEVELOPMENT_FORCE_RTL, false))
+            ? View.LAYOUT_DIRECTION_RTL
+            : View.LAYOUT_DIRECTION_LTR;
     }
 
     /**
@@ -1811,7 +1768,4 @@
     private static String[] EMPTY_STRING_ARRAY = new String[]{};
 
     private static final char ZWNBS_CHAR = '\uFEFF';
-
-    private static String ARAB_SCRIPT_SUBTAG = "Arab";
-    private static String HEBR_SCRIPT_SUBTAG = "Hebr";
 }
diff --git a/core/java/android/util/SparseIntArray.java b/core/java/android/util/SparseIntArray.java
index 2b85a21..e5c729d 100644
--- a/core/java/android/util/SparseIntArray.java
+++ b/core/java/android/util/SparseIntArray.java
@@ -184,6 +184,14 @@
     }
 
     /**
+     * Directly set the value at a particular index.
+     * @hide
+     */
+    public void setValueAt(int index, int value) {
+        mValues[index] = value;
+    }
+
+    /**
      * Returns the index for which {@link #keyAt} would return the
      * specified key, or a negative number if the specified
      * key is not mapped.
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index bc19b40..bdcd998 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -43,6 +43,7 @@
 import android.util.Log;
 import android.util.Pools.SynchronizedPool;
 import android.util.SparseArray;
+import android.util.SparseBooleanArray;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.view.animation.Animation;
@@ -2922,13 +2923,58 @@
                 final int childrenCount = getChildCount();
                 if (childrenCount > 0) {
                     structure.setChildCount(childrenCount);
-                    final ArrayList<View> preorderedList = buildOrderedChildList();
-                    final boolean customOrder = preorderedList == null
+                    ArrayList<View> preorderedList = buildOrderedChildList();
+                    boolean customOrder = preorderedList == null
                             && isChildrenDrawingOrderEnabled();
                     final View[] children = mChildren;
                     for (int i=0; i<childrenCount; i++) {
-                        final int childIndex = customOrder
-                                ? getChildDrawingOrder(childrenCount, i) : i;
+                        int childIndex;
+                        try {
+                            childIndex = customOrder ? getChildDrawingOrder(childrenCount, i) : i;
+                        } catch (IndexOutOfBoundsException e) {
+                            childIndex = i;
+                            if (mContext.getApplicationInfo().targetSdkVersion
+                                    < Build.VERSION_CODES.M) {
+                                Log.w(TAG, "Bad getChildDrawingOrder while collecting assist @ "
+                                        + i + " of " + childrenCount, e);
+                                // At least one app is failing when we call getChildDrawingOrder
+                                // at this point, so deal semi-gracefully with it by falling back
+                                // on the basic order.
+                                customOrder = false;
+                                if (i > 0) {
+                                    // If we failed at the first index, there really isn't
+                                    // anything to do -- we will just proceed with the simple
+                                    // sequence order.
+                                    // Otherwise, we failed in the middle, so need to come up
+                                    // with an order for the remaining indices and use that.
+                                    // Failed at the first one, easy peasy.
+                                    int[] permutation = new int[childrenCount];
+                                    SparseBooleanArray usedIndices = new SparseBooleanArray();
+                                    // Go back and collected the indices we have done so far.
+                                    for (int j=0; j<i; j++) {
+                                        permutation[j] = getChildDrawingOrder(childrenCount, j);
+                                        usedIndices.put(permutation[j], true);
+                                    }
+                                    // Fill in the remaining indices with indices that have not
+                                    // yet been used.
+                                    int nextIndex = 0;
+                                    for (int j=i; j<childrenCount; j++) {
+                                        while (usedIndices.get(nextIndex, false)) {
+                                            nextIndex++;
+                                        }
+                                        permutation[j] = nextIndex;
+                                        nextIndex++;
+                                    }
+                                    // Build the final view list.
+                                    preorderedList = new ArrayList<>(childrenCount);
+                                    for (int j=0; j<childrenCount; j++) {
+                                        preorderedList.add(children[permutation[j]]);
+                                    }
+                                }
+                            } else {
+                                throw e;
+                            }
+                        }
                         final View child = (preorderedList == null)
                                 ? children[childIndex] : preorderedList.get(childIndex);
                         ViewStructure cstructure = structure.newChild(i);
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index 4fc2ad3..eecda89 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -183,6 +183,7 @@
     private TypedArray mWindowStyle;
     private Callback mCallback;
     private OnWindowDismissedCallback mOnWindowDismissedCallback;
+    private WindowStackCallback mWindowStackCallback;
     private WindowManager mWindowManager;
     private IBinder mAppToken;
     private String mAppName;
@@ -674,12 +675,22 @@
     }
 
     /** @hide */
-    public final void dispatchOnWindowDismissed() {
+    public final void dispatchOnWindowDismissed(boolean finishTask) {
         if (mOnWindowDismissedCallback != null) {
-            mOnWindowDismissedCallback.onWindowDismissed(false);
+            mOnWindowDismissedCallback.onWindowDismissed(finishTask);
         }
     }
 
+    /** @hide */
+    public final void setWindowStackCallback(WindowStackCallback wscb) {
+        mWindowStackCallback = wscb;
+    }
+
+    /** @hide */
+    public final WindowStackCallback getWindowStackCallback() {
+        return mWindowStackCallback;
+    }
+
     /**
      * Take ownership of this window's surface.  The window's view hierarchy
      * will no longer draw into the surface, though it will otherwise continue
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index 3b9aca8..584deff 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -314,8 +314,7 @@
                     if (path.contains("!/")) {
                         String[] split = TextUtils.split(path, "!/");
                         if (split.length == 2) {
-                            try {
-                                ZipFile z = new ZipFile(split[0]);
+                            try (ZipFile z = new ZipFile(split[0])) {
                                 ZipEntry e = z.getEntry(split[1]);
                                 if (e != null && e.getMethod() == ZipEntry.STORED) {
                                     newVmSize = Math.max(newVmSize, e.getSize());
@@ -355,8 +354,7 @@
                                              String[] abiList,
                                              String nativeLibFileName) {
         // Search the APK for a native library conforming to a listed ABI.
-        try {
-            ZipFile z = new ZipFile(apkPath);
+        try (ZipFile z = new ZipFile(apkPath)) {
             for (String abi : abiList) {
                 final String entry = "lib/" + abi + "/" + nativeLibFileName;
                 ZipEntry e = z.getEntry(entry);
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 0bd8d85..eccf5fa 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -16,6 +16,8 @@
 
 package com.android.internal.policy;
 
+import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
+import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
 import static android.view.View.MeasureSpec.AT_MOST;
 import static android.view.View.MeasureSpec.EXACTLY;
 import static android.view.View.MeasureSpec.getMode;
@@ -163,6 +165,14 @@
     // This is the top-level view of the window, containing the window decor.
     private DecorView mDecor;
 
+    // This is the non client decor view for the window, containing the caption and window control
+    // buttons. The visibility of this decor depends on the workspace and the window type.
+    // If the window type does not require such a view, this member might be null.
+    NonClientDecorView mNonClientDecorView;
+    // The non client decor needs to adapt to the used workspace. Since querying and changing the
+    // workspace is expensive, this is the workspace value the window is currently set up for.
+    int mWorkspaceId;
+
     // This is the view in which the window contents are placed. It is either
     // mDecor itself, or a child of mDecor where the contents go.
     private ViewGroup mContentParent;
@@ -657,6 +667,16 @@
                 }
             }
         }
+        if (mNonClientDecorView != null) {
+            int workspaceId = getWorkspaceId();
+            if (mWorkspaceId != workspaceId) {
+                mWorkspaceId = workspaceId;
+                // We might have to change the kind of surface before we do anything else.
+                mNonClientDecorView.phoneWindowUpdated(hasNonClientDecor(mWorkspaceId),
+                        nonClientDecorHasShadow(mWorkspaceId));
+                mDecor.enableNonClientDecor(hasNonClientDecor(workspaceId));
+            }
+        }
     }
 
     private static void clearMenuViews(PanelFeatureState st) {
@@ -3499,24 +3519,34 @@
                 .addOnPreDrawListener(mFloatingToolbarPreDrawListener);
         }
 
-        // Set when the window is free floating and a non client decor frame was added.
-        void enableNonClientDecor(boolean enable) {
-            if (mHasNonClientDecor != enable) {
-                mHasNonClientDecor = enable;
+        /**
+         * Informs the decor if a non client decor is attached and visible.
+         * @param attachedAndVisible true when the decor is visible.
+         * Note that this will even be called if there is no non client decor.
+         **/
+        void enableNonClientDecor(boolean attachedAndVisible) {
+            if (mHasNonClientDecor != attachedAndVisible) {
+                mHasNonClientDecor = attachedAndVisible;
                 if (getForeground() != null) {
                     drawableChanged();
                 }
             }
         }
 
-        // Returns true if the window has a non client decor.
+        /**
+         * Returns true if the window has a non client decor.
+         * @return If there is a non client decor - even if it is not visible.
+         **/
         private boolean windowHasNonClientDecor() {
             return mHasNonClientDecor;
         }
 
-        // Returns true if the Window is free floating and has a shadow. Note that non overlapping
-        // windows do not have a shadow since it could not be seen anyways (a small screen / tablet
-        // "tiles" the windows side by side but does not overlap them).
+        /**
+         * Returns true if the Window is free floating and has a shadow. Note that non overlapping
+         * windows do not have a shadow since it could not be seen anyways (a small screen / tablet
+         * "tiles" the windows side by side but does not overlap them).
+         * @return Returns true when the window has a shadow created by the non client decor.
+         **/
         private boolean windowHasShadow() {
             return windowHasNonClientDecor() && getElevation() > 0;
         }
@@ -3910,12 +3940,12 @@
 
         mDecor.startChanging();
 
-        NonClientDecorView nonClientDecorView = createNonClientDecorView();
+        mNonClientDecorView = createNonClientDecorView();
         View in = mLayoutInflater.inflate(layoutResource, null);
-        if (nonClientDecorView != null) {
-            decor.addView(nonClientDecorView,
+        if (mNonClientDecorView != null) {
+            decor.addView(mNonClientDecorView,
                     new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
-            nonClientDecorView.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
+            mNonClientDecorView.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
         } else {
             decor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
         }
@@ -3976,32 +4006,13 @@
 
     // Free floating overlapping windows require a non client decor with a caption and shadow..
     private NonClientDecorView createNonClientDecorView() {
-        boolean needsDecor = true;
         NonClientDecorView nonClientDecorView = null;
-
         final WindowManager.LayoutParams attrs = getAttributes();
-        // TODO(skuhne): Use the associated stack to figure out if the window is on the free style
-        // desktop, the side by side desktop or the full screen desktop. With that informations the
-        // choice is fairly easy to decide.
-        // => This is only a kludge for now to suppress fullscreen windows, recents, launcher, etc..
-        boolean isFullscreen =
-                0 != ((mDecor.getWindowSystemUiVisibility() | mDecor.getSystemUiVisibility()) &
-                        (View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION));
-        boolean isApplication = attrs.type != TYPE_BASE_APPLICATION &&
-                attrs.type != TYPE_APPLICATION;
-
-        // We do not show the non client decor if...
-        // - this is a floating dialog (which is not a real window, e.g. it cannot be maximized).
-        // - it is not an application (special windows have special functions, e.g text selector).
-        // - the application is full screen, drawing everything (since the decor would be out of the
-        //   screen in that case and could not be seen).
-        if (isFloating() || isFullscreen || isApplication) {
-            needsDecor = false;
-        }
-
-        if (needsDecor) {
-            // TODO(skuhne): If running in side by side mode on a device - turn off the shadow.
-            boolean windowHasShadow = true;
+        boolean isApplication = attrs.type == TYPE_BASE_APPLICATION ||
+                attrs.type == TYPE_APPLICATION;
+        mWorkspaceId = getWorkspaceId();
+        // Only a non floating application window can get a non client decor.
+        if (!isFloating() && isApplication) {
             // Dependent on the brightness of the used title we either use the
             // dark or the light button frame.
             TypedValue value = new TypedValue();
@@ -4013,11 +4024,12 @@
                 nonClientDecorView = (NonClientDecorView) mLayoutInflater.inflate(
                         R.layout.non_client_decor_light, null);
             }
-            nonClientDecorView.setPhoneWindow(this, windowHasShadow);
+            nonClientDecorView.setPhoneWindow(this, hasNonClientDecor(mWorkspaceId),
+                    nonClientDecorHasShadow(mWorkspaceId));
         }
-
-        // Tell the Decor if it has a non client decor.
-        mDecor.enableNonClientDecor(needsDecor);
+        // Tell the decor if it has a visible non client decor.
+        mDecor.enableNonClientDecor(nonClientDecorView != null &&
+                hasNonClientDecor(mWorkspaceId));
 
         return nonClientDecorView;
     }
@@ -4403,7 +4415,7 @@
         swipeDismiss.setOnDismissedListener(new SwipeDismissLayout.OnDismissedListener() {
             @Override
             public void onDismissed(SwipeDismissLayout layout) {
-                dispatchOnWindowDismissed();
+                dispatchOnWindowDismissed(false /*finishTask*/);
             }
         });
         swipeDismiss.setOnSwipeProgressChangedListener(
@@ -5162,4 +5174,42 @@
     public void setIsStartingWindow(boolean isStartingWindow) {
         mIsStartingWindow = isStartingWindow;
     }
+
+    /**
+     * Returns the Id of the workspace which contains this window.
+     * Note that if no workspace can be determined - which usually means that it was not
+     * created for an activity - the fullscreen workspace ID will be returned.
+     * @return Returns the workspace stack id which contains this window.
+     **/
+    private int getWorkspaceId() {
+        int workspaceId = FULLSCREEN_WORKSPACE_STACK_ID;
+        WindowStackCallback callback = getWindowStackCallback();
+        if (callback != null) {
+            try {
+                workspaceId = callback.getWindowStackId();
+            } catch (RemoteException ex) {
+                Log.e(TAG, "Failed to get the workspace ID of a PhoneWindow.");
+            }
+        }
+        return workspaceId;
+    }
+
+    /**
+     * Determines if the window should show a non client decor for the workspace it is in.
+     * @param workspaceId The Id of the workspace which contains this window.
+     * @Return Returns true if the window should show a non client decor.
+     **/
+    private boolean hasNonClientDecor(int workspaceId) {
+        return workspaceId == FREEFORM_WORKSPACE_STACK_ID;
+    }
+
+    /**
+     * Determines if the window should show a shadow or not, dependent on the workspace.
+     * @param workspaceId The Id of the workspace which contains this window.
+     * @Return Returns true if the window should show a shadow.
+     **/
+    private boolean nonClientDecorHasShadow(int workspaceId) {
+        // TODO(skuhne): Add side by side mode here to add a decor.
+        return workspaceId == FREEFORM_WORKSPACE_STACK_ID;
+    }
 }
diff --git a/core/java/com/android/internal/widget/NonClientDecorView.java b/core/java/com/android/internal/widget/NonClientDecorView.java
index 57039b7..d8626cd 100644
--- a/core/java/com/android/internal/widget/NonClientDecorView.java
+++ b/core/java/com/android/internal/widget/NonClientDecorView.java
@@ -16,24 +16,20 @@
 
 package com.android.internal.widget;
 
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningTaskInfo;
-import android.app.ActivityManagerNative;
 import android.content.Context;
 import android.os.RemoteException;
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
+import android.view.Window;
+import android.view.WindowInsets;
 import android.util.Log;
 import android.util.TypedValue;
 
-import android.view.ViewOutlineProvider;
-import android.view.WindowInsets;
 import com.android.internal.R;
 import com.android.internal.policy.PhoneWindow;
 
-import java.util.List;
-
 /**
  * This class represents the special screen elements to control a window on free form
  * environment. All thse screen elements are added in the "non client area" which is the area of
@@ -68,6 +64,7 @@
 
     private PhoneWindow mOwner = null;
     boolean mWindowHasShadow = false;
+    boolean mShowDecor = false;
 
     // The current focus state of the window for updating the window elevation.
     boolean mWindowHasFocus = true;
@@ -89,12 +86,12 @@
         super(context, attrs, defStyle);
     }
 
-    public void setPhoneWindow(PhoneWindow owner, boolean windowHasShadow) {
+    public void setPhoneWindow(PhoneWindow owner, boolean showDecor, boolean windowHasShadow) {
         mOwner = owner;
         mWindowHasShadow = windowHasShadow;
+        mShowDecor = showDecor;
         if (mWindowHasShadow) {
-            // TODO(skuhne): Call setMaxElevation here as soon as b/22668382 got fixed.
-            updateElevation();
+            initializeElevation();
         }
         // By changing the outline provider to BOUNDS, the window can remove its
         // background without removing the shadow.
@@ -103,23 +100,25 @@
         findViewById(R.id.close_window).setOnClickListener(this);
     }
 
+    /**
+     * The phone window configuration has changed and the decor needs to be updated.
+     * @param showDecor True if the decor should be shown.
+     * @param windowHasShadow True when the window should show a shadow.
+     **/
+    public void phoneWindowUpdated(boolean showDecor, boolean windowHasShadow) {
+        mShowDecor = showDecor;
+        if (windowHasShadow != mWindowHasShadow) {
+            mWindowHasShadow = windowHasShadow;
+            initializeElevation();
+        }
+    }
+
     @Override
     public void onClick(View view) {
         if (view.getId() == R.id.maximize_window) {
-            // TODO(skuhne): Add code to maximize window.
+            maximizeWindow();
         } else if (view.getId() == R.id.close_window) {
-            // TODO(skuhne): This is not the right way to kill an app and we should add a high level
-            // function for it.
-            final ActivityManager m =
-                    (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
-            List<RunningTaskInfo> runningTaskInfoList =  m.getRunningTasks(1);
-            if (!runningTaskInfoList.isEmpty()) {
-                try {
-                    ActivityManagerNative.getDefault().removeTask(runningTaskInfoList.get(0).id);
-                } catch (RemoteException ex) {
-                    Log.e(TAG, "Couldn't close task with the close button.");
-                }
-            }
+            mOwner.dispatchOnWindowDismissed(true /*finishTask*/);
         }
     }
 
@@ -159,8 +158,9 @@
         updateElevation();
         mAllowUpdateElevation = true;
 
-        // Remove the decor temporarily if the window entered a full screen/immersive mode.
-        final int captionHeight = isFillingScreen() ? 0 : caption.getMeasuredHeight();
+        // Don't show the decor if the window has e.g. entered full screen.
+        final int captionHeight =
+                (isFillingScreen() || !mShowDecor) ? 0 : caption.getMeasuredHeight();
         caption.layout(leftPos, topPos + systemMargin, leftPos + width,
                 topPos + systemMargin + captionHeight);
 
@@ -170,27 +170,45 @@
         }
     }
 
-    // Make sure that we never get more then one client area in our view.
     @Override
     public void addView(View child, int index, LayoutParams params) {
+        // Make sure that we never get more then one client area in our view.
         if (index >= 2 || getChildCount() >= 2) {
             throw new IllegalStateException("NonClientDecorView can only handle 1 client view");
         }
         super.addView(child, index, params);
     }
 
-    // Returns true when the window is filling the entire screen and the non client area
-    // should not be shown.
+    /**
+     * Determine if the workspace is entirely covered by the window.
+     * @return Returns true when the window is filling the entire screen/workspace.
+     **/
     private boolean isFillingScreen() {
         return (0 != ((getWindowSystemUiVisibility() | getSystemUiVisibility()) &
                 (View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                         View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_LOW_PROFILE)));
     }
 
-    // The shadow height gets controlled by the focus to visualize highlighted windows.
-    // Note: This will overwrite application elevation properties.
-    // Note: Windows which have (temporarily) changed their attributes to cover the SystemUI
-    //       will get no shadow as they are expected to be "full screen".
+    /**
+     * The elevation gets set for the first time and the framework needs to be informed that
+     * the surface layer gets created with the shadow size in mind.
+     **/
+    private void initializeElevation() {
+        // TODO(skuhne): Call setMaxElevation here accordingly after b/22668382 got fixed.
+        mAllowUpdateElevation = false;
+        if (mWindowHasShadow) {
+            updateElevation();
+        } else {
+            mOwner.setElevation(0);
+        }
+    }
+
+    /**
+     * The shadow height gets controlled by the focus to visualize highlighted windows.
+     * Note: This will overwrite application elevation properties.
+     * Note: Windows which have (temporarily) changed their attributes to cover the SystemUI
+     *       will get no shadow as they are expected to be "full screen".
+     **/
     private void updateElevation() {
         float elevation = 0;
         if (mWindowHasShadow) {
@@ -198,9 +216,8 @@
             elevation = fill ? 0 :
                     (mWindowHasFocus ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP :
                             DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP);
+            // TODO(skuhne): Remove this if clause once b/22668382 got fixed.
             if (!mAllowUpdateElevation && !fill) {
-                // TODO(skuhne): Change this to setMaxElevation as soon as b/22668382 got fixed
-                // and remove this cludge.
                 elevation = DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP;
             }
             // Convert the DP elevation into physical pixels.
@@ -212,8 +229,28 @@
         }
     }
 
+    /**
+     * Converts a DIP measure into physical pixels.
+     * @param dip The dip value.
+     * @return Returns the number of pixels.
+     */
     private float dipToPx(float dip) {
         return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip,
                 getResources().getDisplayMetrics());
     }
+
+    /**
+     * Maximize the window by moving it to the maximized workspace stack.
+     **/
+    private void maximizeWindow() {
+        Window.WindowStackCallback callback = mOwner.getWindowStackCallback();
+        if (callback != null) {
+            try {
+                callback.changeWindowStack(
+                        android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID);
+            } catch (RemoteException ex) {
+                Log.e(TAG, "Cannot change task workspace.");
+            }
+        }
+    }
 }
diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java
index 35ed63b..d88f479 100644
--- a/core/java/com/android/internal/widget/SwipeDismissLayout.java
+++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java
@@ -89,14 +89,21 @@
                 }
             };
     private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
+        private Runnable mRunnable = new Runnable() {
+            @Override
+            public void run() {
+                if (mDismissed) {
+                    dismiss();
+                } else {
+                    cancel();
+                }
+                resetMembers();
+            }
+        };
+
         @Override
         public void onReceive(Context context, Intent intent) {
-            if (mDismissed) {
-                dismiss();
-            } else {
-                cancel();
-            }
-            resetMembers();
+            post(mRunnable);
         }
     };
     private IntentFilter mScreenOffFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index fc15b964..b7eda4a 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -49,7 +49,6 @@
     android_database_SQLiteConnection.cpp \
     android_database_SQLiteGlobal.cpp \
     android_database_SQLiteDebug.cpp \
-    android_emoji_EmojiFactory.cpp \
     android_view_DisplayEventReceiver.cpp \
     android_view_DisplayListCanvas.cpp \
     android_view_GraphicBuffer.cpp \
@@ -201,7 +200,6 @@
     external/tremor/Tremor \
     external/jpeg \
     external/harfbuzz_ng/src \
-    frameworks/opt/emoji \
     libcore/include \
     $(call include-path-for, audio-utils) \
     frameworks/minikin/include \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index a29b4e6..467e03c 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -107,7 +107,6 @@
 extern int register_android_util_Log(JNIEnv* env);
 extern int register_android_content_StringBlock(JNIEnv* env);
 extern int register_android_content_XmlBlock(JNIEnv* env);
-extern int register_android_emoji_EmojiFactory(JNIEnv* env);
 extern int register_android_graphics_Canvas(JNIEnv* env);
 extern int register_android_graphics_CanvasProperty(JNIEnv* env);
 extern int register_android_graphics_ColorFilter(JNIEnv* env);
@@ -1265,7 +1264,6 @@
     REG_JNI(register_android_content_AssetManager),
     REG_JNI(register_android_content_StringBlock),
     REG_JNI(register_android_content_XmlBlock),
-    REG_JNI(register_android_emoji_EmojiFactory),
     REG_JNI(register_android_text_AndroidCharacter),
     REG_JNI(register_android_text_StaticLayout),
     REG_JNI(register_android_text_AndroidBidi),
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 3ca4e72..20a54e5 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -1,24 +1,24 @@
 #define LOG_TAG "BitmapFactory"
 
+#include "AutoDecodeCancel.h"
 #include "BitmapFactory.h"
+#include "CreateJavaOutputStreamAdaptor.h"
+#include "GraphicsJNI.h"
 #include "NinePatchPeeker.h"
 #include "SkFrontBufferedStream.h"
 #include "SkImageDecoder.h"
 #include "SkMath.h"
 #include "SkPixelRef.h"
 #include "SkStream.h"
-#include "SkTemplates.h"
 #include "SkUtils.h"
-#include "CreateJavaOutputStreamAdaptor.h"
-#include "AutoDecodeCancel.h"
 #include "Utils.h"
-#include "JNIHelp.h"
-#include "GraphicsJNI.h"
-
 #include "core_jni_helpers.h"
+
+#include <JNIHelp.h>
 #include <androidfw/Asset.h>
 #include <androidfw/ResourceTypes.h>
 #include <cutils/compiler.h>
+#include <memory>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <sys/mman.h>
@@ -291,7 +291,7 @@
     // Only setup the decoder to be deleted after its stack-based, refcounted
     // components (allocators, peekers, etc) are declared. This prevents RefCnt
     // asserts from firing due to the order objects are deleted from the stack.
-    SkAutoTDelete<SkImageDecoder> add(decoder);
+    std::unique_ptr<SkImageDecoder> add(decoder);
 
     AutoDecoderCancel adc(options, decoder);
 
@@ -453,13 +453,13 @@
         jobject padding, jobject options) {
 
     jobject bitmap = NULL;
-    SkAutoTDelete<SkStream> stream(CreateJavaInputStreamAdaptor(env, is, storage));
+    std::unique_ptr<SkStream> stream(CreateJavaInputStreamAdaptor(env, is, storage));
 
     if (stream.get()) {
-        SkAutoTDelete<SkStreamRewindable> bufferedStream(
-                SkFrontBufferedStream::Create(stream.detach(), BYTES_TO_BUFFER));
+        std::unique_ptr<SkStreamRewindable> bufferedStream(
+                SkFrontBufferedStream::Create(stream.release(), BYTES_TO_BUFFER));
         SkASSERT(bufferedStream.get() != NULL);
-        bitmap = doDecode(env, bufferedStream, padding, options);
+        bitmap = doDecode(env, bufferedStream.get(), padding, options);
     }
     return bitmap;
 }
@@ -496,16 +496,16 @@
         return nullObjectReturn("Could not open file");
     }
 
-    SkAutoTDelete<SkFILEStream> fileStream(new SkFILEStream(file,
+    std::unique_ptr<SkFILEStream> fileStream(new SkFILEStream(file,
             SkFILEStream::kCallerPasses_Ownership));
 
     // Use a buffered stream. Although an SkFILEStream can be rewound, this
     // ensures that SkImageDecoder::Factory never rewinds beyond the
     // current position of the file descriptor.
-    SkAutoTDelete<SkStreamRewindable> stream(SkFrontBufferedStream::Create(fileStream.detach(),
+    std::unique_ptr<SkStreamRewindable> stream(SkFrontBufferedStream::Create(fileStream.release(),
             BYTES_TO_BUFFER));
 
-    return doDecode(env, stream, padding, bitmapFactoryOptions);
+    return doDecode(env, stream.get(), padding, bitmapFactoryOptions);
 }
 
 static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz, jlong native_asset,
@@ -514,16 +514,16 @@
     Asset* asset = reinterpret_cast<Asset*>(native_asset);
     // since we know we'll be done with the asset when we return, we can
     // just use a simple wrapper
-    SkAutoTDelete<SkStreamRewindable> stream(new AssetStreamAdaptor(asset));
-    return doDecode(env, stream, padding, options);
+    AssetStreamAdaptor stream(asset);
+    return doDecode(env, &stream, padding, options);
 }
 
 static jobject nativeDecodeByteArray(JNIEnv* env, jobject, jbyteArray byteArray,
         jint offset, jint length, jobject options) {
 
     AutoJavaByteArray ar(env, byteArray);
-    SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(ar.ptr() + offset, length, false));
-    return doDecode(env, stream, NULL, options);
+    SkMemoryStream stream(ar.ptr() + offset, length, false);
+    return doDecode(env, &stream, NULL, options);
 }
 
 static void nativeRequestCancel(JNIEnv*, jobject joptions) {
@@ -536,7 +536,7 @@
 }
 
 jobject decodeBitmap(JNIEnv* env, void* data, size_t size) {
-    SkMemoryStream  stream(data, size);
+    SkMemoryStream stream(data, size);
     return doDecode(env, &stream, NULL, NULL);
 }
 
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index 08a3f6f..8535e6a 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -16,28 +16,25 @@
 
 #define LOG_TAG "BitmapRegionDecoder"
 
+#include "AutoDecodeCancel.h"
+#include "BitmapFactory.h"
+#include "CreateJavaOutputStreamAdaptor.h"
 #include "SkBitmap.h"
 #include "SkData.h"
-#include "SkImageEncoder.h"
 #include "GraphicsJNI.h"
+#include "SkImageEncoder.h"
 #include "SkUtils.h"
-#include "SkTemplates.h"
 #include "SkPixelRef.h"
 #include "SkStream.h"
-#include "BitmapFactory.h"
-#include "AutoDecodeCancel.h"
-#include "CreateJavaOutputStreamAdaptor.h"
 #include "Utils.h"
-#include "JNIHelp.h"
-
-#include "core_jni_helpers.h"
-#include "android_util_Binder.h"
 #include "android_nio_utils.h"
-#include "CreateJavaOutputStreamAdaptor.h"
+#include "android_util_Binder.h"
+#include "core_jni_helpers.h"
 
+#include <JNIHelp.h>
+#include <androidfw/Asset.h>
 #include <binder/Parcel.h>
 #include <jni.h>
-#include <androidfw/Asset.h>
 #include <sys/stat.h>
 
 using namespace android;
diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
index 26523f8..067489a 100644
--- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
+++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
@@ -1,11 +1,13 @@
 #include "CreateJavaOutputStreamAdaptor.h"
-#include "JNIHelp.h"
 #include "SkData.h"
 #include "SkRefCnt.h"
 #include "SkStream.h"
 #include "SkTypes.h"
 #include "Utils.h"
 
+#include <JNIHelp.h>
+#include <memory>
+
 static jmethodID    gInputStream_readMethodID;
 static jmethodID    gInputStream_skipMethodID;
 
@@ -164,7 +166,7 @@
 
 SkStreamRewindable* CopyJavaInputStream(JNIEnv* env, jobject stream,
                                         jbyteArray storage) {
-    SkAutoTDelete<SkStream> adaptor(CreateJavaInputStreamAdaptor(env, stream, storage));
+    std::unique_ptr<SkStream> adaptor(CreateJavaInputStreamAdaptor(env, stream, storage));
     if (NULL == adaptor.get()) {
         return NULL;
     }
diff --git a/core/jni/android/graphics/Interpolator.cpp b/core/jni/android/graphics/Interpolator.cpp
index f7f3511..3593d1a 100644
--- a/core/jni/android/graphics/Interpolator.cpp
+++ b/core/jni/android/graphics/Interpolator.cpp
@@ -1,9 +1,8 @@
-#include "jni.h"
-#include "core_jni_helpers.h"
-
 #include "GraphicsJNI.h"
 #include "SkInterpolator.h"
-#include "SkTemplates.h"
+#include "core_jni_helpers.h"
+
+#include <jni.h>
 
 static jlong Interpolator_constructor(JNIEnv* env, jobject clazz, jint valueCount, jint frameCount)
 {
diff --git a/core/jni/android/graphics/Matrix.cpp b/core/jni/android/graphics/Matrix.cpp
index 0ff7c78..101e2ba 100644
--- a/core/jni/android/graphics/Matrix.cpp
+++ b/core/jni/android/graphics/Matrix.cpp
@@ -15,16 +15,13 @@
 ** limitations under the License.
 */
 
-#include "jni.h"
 #include "GraphicsJNI.h"
-#include <core_jni_helpers.h>
-
-#include "SkMatrix.h"
-#include "SkTemplates.h"
-
 #include "Matrix.h"
+#include "SkMatrix.h"
+#include "core_jni_helpers.h"
 
 #include <Caches.h>
+#include <jni.h>
 
 namespace android {
 
diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp
index 5c7acf8..d67ed10 100644
--- a/core/jni/android/graphics/Movie.cpp
+++ b/core/jni/android/graphics/Movie.cpp
@@ -1,21 +1,20 @@
 #include "Canvas.h"
+#include "CreateJavaOutputStreamAdaptor.h"
+#include "GraphicsJNI.h"
+#include "Paint.h"
 #include "ScopedLocalRef.h"
 #include "SkFrontBufferedStream.h"
 #include "SkMovie.h"
 #include "SkStream.h"
-#include "GraphicsJNI.h"
-#include "SkTemplates.h"
 #include "SkUtils.h"
 #include "Utils.h"
-#include "CreateJavaOutputStreamAdaptor.h"
-#include "Paint.h"
+#include "core_jni_helpers.h"
 
 #include <androidfw/Asset.h>
 #include <androidfw/ResourceTypes.h>
+#include <jni.h>
 #include <netinet/in.h>
 
-#include "core_jni_helpers.h"
-
 static jclass       gMovie_class;
 static jmethodID    gMovie_constructorMethodID;
 static jfieldID     gMovie_nativeInstanceID;
@@ -84,8 +83,8 @@
 static jobject movie_decodeAsset(JNIEnv* env, jobject clazz, jlong native_asset) {
     android::Asset* asset = reinterpret_cast<android::Asset*>(native_asset);
     if (asset == NULL) return NULL;
-    SkAutoTDelete<SkStreamRewindable> stream(new android::AssetStreamAdaptor(asset));
-    SkMovie* moov = SkMovie::DecodeStream(stream.get());
+    android::AssetStreamAdaptor stream(asset);
+    SkMovie* moov = SkMovie::DecodeStream(&stream);
     return create_jmovie(env, moov);
 }
 
@@ -105,10 +104,10 @@
     // will only read 6.
     // FIXME: Get this number from SkImageDecoder
     // bufferedStream takes ownership of strm
-    SkAutoTDelete<SkStreamRewindable> bufferedStream(SkFrontBufferedStream::Create(strm, 6));
+    std::unique_ptr<SkStreamRewindable> bufferedStream(SkFrontBufferedStream::Create(strm, 6));
     SkASSERT(bufferedStream.get() != NULL);
 
-    SkMovie* moov = SkMovie::DecodeStream(bufferedStream);
+    SkMovie* moov = SkMovie::DecodeStream(bufferedStream.get());
     return create_jmovie(env, moov);
 }
 
diff --git a/core/jni/android/graphics/PathEffect.cpp b/core/jni/android/graphics/PathEffect.cpp
index 9d0f0ad..265944e 100644
--- a/core/jni/android/graphics/PathEffect.cpp
+++ b/core/jni/android/graphics/PathEffect.cpp
@@ -1,14 +1,12 @@
-#include <jni.h>
 #include "GraphicsJNI.h"
-
-#include "core_jni_helpers.h"
-
-#include "SkPathEffect.h"
+#include "Sk1DPathEffect.h"
 #include "SkCornerPathEffect.h"
 #include "SkDashPathEffect.h"
 #include "SkDiscretePathEffect.h"
-#include "Sk1DPathEffect.h"
-#include "SkTemplates.h"
+#include "SkPathEffect.h"
+#include "core_jni_helpers.h"
+
+#include <jni.h>
 
 class SkPathEffectGlue {
 public:
diff --git a/core/jni/android/graphics/Picture.cpp b/core/jni/android/graphics/Picture.cpp
index 12bfaa2..6e83f1b 100644
--- a/core/jni/android/graphics/Picture.cpp
+++ b/core/jni/android/graphics/Picture.cpp
@@ -16,9 +16,10 @@
 
 #include "Canvas.h"
 #include "Picture.h"
-
 #include "SkStream.h"
 
+#include <memory>
+
 namespace android {
 
 Picture::Picture(const Picture* src) {
@@ -81,7 +82,7 @@
 
 void Picture::serialize(SkWStream* stream) const {
     if (NULL != mRecorder.get()) {
-        SkAutoTDelete<SkPicture> tempPict(this->makePartialCopy());
+        std::unique_ptr<SkPicture> tempPict(this->makePartialCopy());
         tempPict->serialize(stream);
     } else if (NULL != mPicture.get()) {
         validate();
@@ -89,7 +90,7 @@
     } else {
         SkPictureRecorder recorder;
         recorder.beginRecording(0, 0);
-        SkAutoTUnref<SkPicture> empty(recorder.endRecording());
+        std::unique_ptr<SkPicture> empty(recorder.endRecording());
         empty->serialize(stream);
     }
 }
diff --git a/core/jni/android/graphics/Picture.h b/core/jni/android/graphics/Picture.h
index a9db648..26a4f6a 100644
--- a/core/jni/android/graphics/Picture.h
+++ b/core/jni/android/graphics/Picture.h
@@ -20,7 +20,8 @@
 #include "SkPicture.h"
 #include "SkPictureRecorder.h"
 #include "SkRefCnt.h"
-#include "SkTemplates.h"
+
+#include <memory>
 
 class SkStream;
 class SkWStream;
@@ -55,7 +56,7 @@
     int mWidth;
     int mHeight;
     SkAutoTUnref<const SkPicture> mPicture;
-    SkAutoTDelete<SkPictureRecorder> mRecorder;
+    std::unique_ptr<SkPictureRecorder> mRecorder;
 
     // Make a copy of a picture that is in the midst of being recorded. The
     // resulting picture will have balanced saves and restores.
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp
index ad3a5e2..49c377e 100644
--- a/core/jni/android/graphics/Shader.cpp
+++ b/core/jni/android/graphics/Shader.cpp
@@ -1,15 +1,12 @@
-#include <jni.h>
 #include "GraphicsJNI.h"
-
-#include "SkShader.h"
-#include "SkGradientShader.h"
 #include "SkComposeShader.h"
-#include "SkTemplates.h"
+#include "SkGradientShader.h"
+#include "SkShader.h"
 #include "SkXfermode.h"
+#include "core_jni_helpers.h"
 
 #include <Caches.h>
-
-#include "core_jni_helpers.h"
+#include <jni.h>
 
 using namespace android::uirenderer;
 
diff --git a/core/jni/android_emoji_EmojiFactory.cpp b/core/jni/android_emoji_EmojiFactory.cpp
deleted file mode 100644
index e9f18a6..0000000
--- a/core/jni/android_emoji_EmojiFactory.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-#include "SkTypes.h"
-#include "SkImageDecoder.h"
-
-#define LOG_TAG "EmojiFactory_jni"
-#include <utils/Log.h>
-#include <ScopedUtfChars.h>
-
-#include "BitmapFactory.h"
-#include "EmojiFactory.h"
-#include "GraphicsJNI.h"
-#include <nativehelper/JNIHelp.h>
-
-#include <dlfcn.h>
-// #include <pthread.h>
-
-namespace android {
-
-class EmojiFactoryCaller {
- public:
-  EmojiFactoryCaller() {}
-  virtual ~EmojiFactoryCaller();
-  bool Init();
-  EmojiFactory *TryCallGetImplementation(const char* name);
-  EmojiFactory *TryCallGetAvailableImplementation();
- private:
-  void *m_handle;
-  EmojiFactory *(*m_get_implementation)(const char*);
-  EmojiFactory *(*m_get_available_implementation)();
-};
-
-bool EmojiFactoryCaller::Init() {
-  const char* error_msg;
-  m_handle = dlopen("libemoji.so", RTLD_LAZY | RTLD_LOCAL);
-
-  if (m_handle == NULL) {
-    error_msg = "Failed to load libemoji.so";
-    goto FAIL;
-  }
-
-  m_get_implementation =
-      reinterpret_cast<EmojiFactory *(*)(const char*)>(
-          dlsym(m_handle, "GetImplementation"));
-  if (m_get_implementation == NULL) {
-    error_msg = "Failed to get symbol of GetImplementation";
-    goto FAIL;
-  }
-
-  m_get_available_implementation =
-      reinterpret_cast<EmojiFactory *(*)()>(
-          dlsym(m_handle,"GetAvailableImplementation"));
-  if (m_get_available_implementation == NULL) {
-    error_msg = "Failed to get symbol of GetAvailableImplementation";
-    goto FAIL;
-  }
-
-  return true;
-
-FAIL:
-  const char* error_str = dlerror();
-  if (error_str == NULL) {
-    error_str = "unknown reason";
-  }
-
-  ALOGE("%s: %s", error_msg, error_str);
-  if (m_handle != NULL) {
-    dlclose(m_handle);
-    m_handle = NULL;
-  }
-  return false;
-}
-
-EmojiFactoryCaller::~EmojiFactoryCaller() {
-  if (m_handle) {
-    dlclose(m_handle);
-  }
-}
-
-EmojiFactory *EmojiFactoryCaller::TryCallGetImplementation(
-    const char* name) {
-  if (NULL == m_handle) {
-    return NULL;
-  }
-  return m_get_implementation(name);
-}
-
-EmojiFactory *EmojiFactoryCaller::TryCallGetAvailableImplementation() {
-  if (NULL == m_handle) {
-    return NULL;
-  }
-  return m_get_available_implementation();
-}
-
-static EmojiFactoryCaller* gCaller;
-static pthread_once_t g_once = PTHREAD_ONCE_INIT;
-static bool lib_emoji_factory_is_ready;
-
-static jclass    gEmojiFactory_class;
-static jmethodID gEmojiFactory_constructorMethodID;
-
-static void InitializeCaller() {
-  gCaller = new EmojiFactoryCaller();
-  lib_emoji_factory_is_ready = gCaller->Init();
-}
-
-static jobject create_java_EmojiFactory(
-    JNIEnv* env, EmojiFactory* factory, jstring name) {
-  jobject obj = env->NewObject(gEmojiFactory_class, gEmojiFactory_constructorMethodID,
-      reinterpret_cast<jlong>(factory), name);
-  if (env->ExceptionCheck() != 0) {
-    ALOGE("*** Uncaught exception returned from Java call!\n");
-    env->ExceptionDescribe();
-  }
-  return obj;
-}
-
-static jobject android_emoji_EmojiFactory_newInstance(
-    JNIEnv* env, jobject clazz, jstring name) {
-  if (NULL == name) {
-    return NULL;
-  }
-  pthread_once(&g_once, InitializeCaller);
-  if (!lib_emoji_factory_is_ready) {
-    return NULL;
-  }
-
-  ScopedUtfChars nameUtf(env, name);
-
-  EmojiFactory *factory = gCaller->TryCallGetImplementation(nameUtf.c_str());
-  // EmojiFactory *factory = EmojiFactory::GetImplementation(str.string());
-  if (NULL == factory) {
-    return NULL;
-  }
-
-  return create_java_EmojiFactory(env, factory, name);
-}
-
-static jobject android_emoji_EmojiFactory_newAvailableInstance(
-    JNIEnv* env, jobject clazz) {
-  pthread_once(&g_once, InitializeCaller);
-  if (!lib_emoji_factory_is_ready) {
-    return NULL;
-  }
-
-  EmojiFactory *factory = gCaller->TryCallGetAvailableImplementation();
-  // EmojiFactory *factory = EmojiFactory::GetAvailableImplementation();
-  if (NULL == factory) {
-    return NULL;
-  }
-
-  jstring jname = env->NewStringUTF(factory->Name());
-  if (NULL == jname) {
-    return NULL;
-  }
-
-  return create_java_EmojiFactory(env, factory, jname);
-}
-
-static jobject android_emoji_EmojiFactory_getBitmapFromAndroidPua(
-    JNIEnv* env, jobject clazz, jlong nativeEmojiFactory, jint pua) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-
-  int size;
-  const char *bytes = factory->GetImageBinaryFromAndroidPua(pua, &size);
-  if (bytes == NULL) {
-    return NULL;
-  }
-
-  return decodeBitmap(env, (void*)bytes, size);
-}
-
-static void android_emoji_EmojiFactory_destructor(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
-  /*
-  // Must not delete this object!!
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  delete factory;
-  */
-}
-
-static jint android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificSjis(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jchar sjis) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetAndroidPuaFromVendorSpecificSjis(sjis);
-}
-
-static jint android_emoji_EmojiFactory_getVendorSpecificSjisFromAndroidPua(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jint pua) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetVendorSpecificSjisFromAndroidPua(pua);
-}
-
-static jint android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificPua(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jint vsu) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetAndroidPuaFromVendorSpecificPua(vsu);
-}
-
-static jint android_emoji_EmojiFactory_getVendorSpecificPuaFromAndroidPua(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory, jint pua) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetVendorSpecificPuaFromAndroidPua(pua);
-}
-
-static jint android_emoji_EmojiFactory_getMaximumVendorSpecificPua(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetMaximumVendorSpecificPua();
-}
-
-static jint android_emoji_EmojiFactory_getMinimumVendorSpecificPua(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetMinimumVendorSpecificPua();
-}
-
-static jint android_emoji_EmojiFactory_getMaximumAndroidPua(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetMaximumAndroidPua();
-}
-
-static jint android_emoji_EmojiFactory_getMinimumAndroidPua(
-    JNIEnv* env, jobject obj, jlong nativeEmojiFactory) {
-  EmojiFactory *factory = reinterpret_cast<EmojiFactory *>(nativeEmojiFactory);
-  return factory->GetMinimumAndroidPua();
-}
-
-static JNINativeMethod gMethods[] = {
-  { "newInstance", "(Ljava/lang/String;)Landroid/emoji/EmojiFactory;",
-    (void*)android_emoji_EmojiFactory_newInstance},
-  { "newAvailableInstance", "()Landroid/emoji/EmojiFactory;",
-    (void*)android_emoji_EmojiFactory_newAvailableInstance},
-  { "nativeDestructor", "(J)V",
-    (void*)android_emoji_EmojiFactory_destructor},
-  { "nativeGetBitmapFromAndroidPua", "(JI)Landroid/graphics/Bitmap;",
-    (void*)android_emoji_EmojiFactory_getBitmapFromAndroidPua},
-  { "nativeGetAndroidPuaFromVendorSpecificSjis", "(JC)I",
-    (void*)android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificSjis},
-  { "nativeGetVendorSpecificSjisFromAndroidPua", "(JI)I",
-    (void*)android_emoji_EmojiFactory_getVendorSpecificSjisFromAndroidPua},
-  { "nativeGetAndroidPuaFromVendorSpecificPua", "(JI)I",
-    (void*)android_emoji_EmojiFactory_getAndroidPuaFromVendorSpecificPua},
-  { "nativeGetVendorSpecificPuaFromAndroidPua", "(JI)I",
-    (void*)android_emoji_EmojiFactory_getVendorSpecificPuaFromAndroidPua},
-  { "nativeGetMaximumVendorSpecificPua", "(J)I",
-    (void*)android_emoji_EmojiFactory_getMaximumVendorSpecificPua},
-  { "nativeGetMinimumVendorSpecificPua", "(J)I",
-    (void*)android_emoji_EmojiFactory_getMinimumVendorSpecificPua},
-  { "nativeGetMaximumAndroidPua", "(J)I",
-    (void*)android_emoji_EmojiFactory_getMaximumAndroidPua},
-  { "nativeGetMinimumAndroidPua", "(J)I",
-    (void*)android_emoji_EmojiFactory_getMinimumAndroidPua}
-};
-
-static jclass make_globalref(JNIEnv* env, const char classname[])
-{
-    jclass c = env->FindClass(classname);
-    SkASSERT(c);
-    return (jclass)env->NewGlobalRef(c);
-}
-
-int register_android_emoji_EmojiFactory(JNIEnv* env) {
-  gEmojiFactory_class = make_globalref(env, "android/emoji/EmojiFactory");
-  gEmojiFactory_constructorMethodID = env->GetMethodID(
-      gEmojiFactory_class, "<init>", "(JLjava/lang/String;)V");
-  return jniRegisterNativeMethods(env, "android/emoji/EmojiFactory",
-                                  gMethods, NELEM(gMethods));
-}
-
-}  // namespace android
diff --git a/core/jni/android_graphics_Picture.cpp b/core/jni/android_graphics_Picture.cpp
index 308ee20..fd42ddb 100644
--- a/core/jni/android_graphics_Picture.cpp
+++ b/core/jni/android_graphics_Picture.cpp
@@ -14,16 +14,14 @@
  * limitations under the License.
  */
 
-#include "jni.h"
+#include "CreateJavaOutputStreamAdaptor.h"
 #include "GraphicsJNI.h"
-#include "core_jni_helpers.h"
-
 #include "Picture.h"
-
 #include "SkCanvas.h"
 #include "SkStream.h"
-#include "SkTemplates.h"
-#include "CreateJavaOutputStreamAdaptor.h"
+#include "core_jni_helpers.h"
+
+#include <jni.h>
 
 namespace android {
 
diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp
index ba08237..e10a644 100644
--- a/core/jni/android_hardware_camera2_DngCreator.cpp
+++ b/core/jni/android_hardware_camera2_DngCreator.cpp
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <algorithm>
 #include <memory>
+#include <vector>
 
 #include <utils/Log.h>
 #include <utils/Errors.h>
@@ -1659,8 +1660,7 @@
             lsmHeight = static_cast<uint32_t>(entry1.data.i32[1]);
         }
 
-        camera_metadata_entry entry2 =
-                results.find(ANDROID_STATISTICS_LENS_SHADING_MAP);
+        camera_metadata_entry entry2 = results.find(ANDROID_STATISTICS_LENS_SHADING_MAP);
 
         camera_metadata_entry entry =
                 characteristics.find(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE);
@@ -1685,6 +1685,45 @@
             }
         }
 
+
+        // Set up bad pixel correction list
+        camera_metadata_entry entry3 = characteristics.find(ANDROID_STATISTICS_HOT_PIXEL_MAP);
+
+        if ((entry3.count % 2) != 0) {
+            ALOGE("%s: Hot pixel map contains odd number of values, cannot map to pairs!",
+                    __FUNCTION__);
+            jniThrowRuntimeException(env, "failed to add hotpixel map.");
+            return nullptr;
+        }
+
+        // Adjust the bad pixel coordinates to be relative to the origin of the active area DNG tag
+        std::vector<uint32_t> v;
+        for (size_t i = 0; i < entry3.count; i+=2) {
+            int32_t x = entry3.data.i32[i];
+            int32_t y = entry3.data.i32[i + 1];
+            x -= static_cast<int32_t>(xmin);
+            y -= static_cast<int32_t>(ymin);
+            if (x < 0 || y < 0 || static_cast<uint32_t>(x) >= width ||
+                    static_cast<uint32_t>(y) >= width) {
+                continue;
+            }
+            v.push_back(x);
+            v.push_back(y);
+        }
+        const uint32_t* badPixels = &v[0];
+        uint32_t badPixelCount = v.size();
+
+        if (badPixelCount > 0) {
+            err = builder.addBadPixelListForMetadata(badPixels, badPixelCount, opcodeCfaLayout);
+
+            if (err != OK) {
+                ALOGE("%s: Could not add hotpixel map.", __FUNCTION__);
+                jniThrowRuntimeException(env, "failed to add hotpixel map.");
+                return nullptr;
+            }
+        }
+
+
         size_t listSize = builder.getSize();
         uint8_t opcodeListBuf[listSize];
         err = builder.buildOpList(opcodeListBuf);
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index dca04f5..9aa544f 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -82,6 +82,15 @@
     jmethodID put;
 } gSparseArrayOffsets;
 
+static struct configuration_offsets_t
+{
+    jclass classObject;
+    jmethodID constructor;
+    jfieldID mSmallestScreenWidthDpOffset;
+    jfieldID mScreenWidthDpOffset;
+    jfieldID mScreenHeightDpOffset;
+} gConfigurationOffsets;
+
 jclass g_stringClass = NULL;
 
 // ----------------------------------------------------------------------------
@@ -593,6 +602,56 @@
     return result;
 }
 
+static jobject constructConfigurationObject(JNIEnv* env, const ResTable_config& config) {
+    jobject result = env->NewObject(gConfigurationOffsets.classObject,
+            gConfigurationOffsets.constructor);
+    if (result == NULL) {
+        return NULL;
+    }
+
+    env->SetIntField(result, gConfigurationOffsets.mSmallestScreenWidthDpOffset,
+            config.smallestScreenWidthDp);
+    env->SetIntField(result, gConfigurationOffsets.mScreenWidthDpOffset, config.screenWidthDp);
+    env->SetIntField(result, gConfigurationOffsets.mScreenHeightDpOffset, config.screenHeightDp);
+
+    return result;
+}
+
+static jobjectArray getSizeConfigurationsInternal(JNIEnv* env,
+        const Vector<ResTable_config>& configs) {
+    const int N = configs.size();
+    jobjectArray result = env->NewObjectArray(N, gConfigurationOffsets.classObject, NULL);
+    if (result == NULL) {
+        return NULL;
+    }
+
+    for (int i=0; i<N; i++) {
+        jobject config = constructConfigurationObject(env, configs[i]);
+        if (config == NULL) {
+            env->DeleteLocalRef(result);
+            return NULL;
+        }
+
+        env->SetObjectArrayElement(result, i, config);
+        env->DeleteLocalRef(config);
+    }
+
+    return result;
+}
+
+static jobjectArray android_content_AssetManager_getSizeConfigurations(JNIEnv* env, jobject clazz) {
+    AssetManager* am = assetManagerForJavaObject(env, clazz);
+    if (am == NULL) {
+        return NULL;
+    }
+
+    const ResTable& res(am->getResources());
+    Vector<ResTable_config> configs;
+    res.getConfigurations(&configs, false /* ignoreMipmap */, true /* ignoreAndroidPackage */);
+
+    return getSizeConfigurationsInternal(env, configs);
+}
+
 static void android_content_AssetManager_setConfiguration(JNIEnv* env, jobject clazz,
                                                           jint mcc, jint mnc,
                                                           jstring locale, jint orientation,
@@ -2091,6 +2150,8 @@
         (void*) android_content_AssetManager_setLocale },
     { "getLocales",      "()[Ljava/lang/String;",
         (void*) android_content_AssetManager_getLocales },
+    { "getSizeConfigurations", "()[Landroid/content/res/Configuration;",
+        (void*) android_content_AssetManager_getSizeConfigurations },
     { "setConfiguration", "(IILjava/lang/String;IIIIIIIIIIIIII)V",
         (void*) android_content_AssetManager_setConfiguration },
     { "getResourceIdentifier","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
@@ -2203,6 +2264,17 @@
     gSparseArrayOffsets.put = GetMethodIDOrDie(env, gSparseArrayOffsets.classObject, "put",
                                                "(ILjava/lang/Object;)V");
 
+    jclass configurationClass = FindClassOrDie(env, "android/content/res/Configuration");
+    gConfigurationOffsets.classObject = MakeGlobalRefOrDie(env, configurationClass);
+    gConfigurationOffsets.constructor = GetMethodIDOrDie(env, configurationClass,
+            "<init>", "()V");
+    gConfigurationOffsets.mSmallestScreenWidthDpOffset = GetFieldIDOrDie(env, configurationClass,
+            "smallestScreenWidthDp", "I");
+    gConfigurationOffsets.mScreenWidthDpOffset = GetFieldIDOrDie(env, configurationClass,
+            "screenWidthDp", "I");
+    gConfigurationOffsets.mScreenHeightDpOffset = GetFieldIDOrDie(env, configurationClass,
+            "screenHeightDp", "I");
+
     return RegisterMethodsOrDie(env, "android/content/res/AssetManager", gAssetManagerMethods,
                                 NELEM(gAssetManagerMethods));
 }
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 77af341..54be410 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -16,35 +16,28 @@
 
 #define LOG_TAG "SurfaceControl"
 
-#include <stdio.h>
-
-#include "jni.h"
-#include "JNIHelp.h"
-
 #include "android_os_Parcel.h"
 #include "android_util_Binder.h"
 #include "android/graphics/Bitmap.h"
 #include "android/graphics/GraphicsJNI.h"
 #include "android/graphics/Region.h"
-
 #include "core_jni_helpers.h"
+
+#include <JNIHelp.h>
+#include <ScopedUtfChars.h>
 #include <android_runtime/android_view_Surface.h>
 #include <android_runtime/android_view_SurfaceSession.h>
-
 #include <gui/Surface.h>
 #include <gui/SurfaceComposerClient.h>
-
+#include <jni.h>
+#include <memory>
+#include <stdio.h>
 #include <ui/DisplayInfo.h>
 #include <ui/FrameStats.h>
 #include <ui/Rect.h>
 #include <ui/Region.h>
-
 #include <utils/Log.h>
 
-#include <ScopedUtfChars.h>
-
-#include "SkTemplates.h"
-
 // ----------------------------------------------------------------------------
 
 namespace android {
@@ -131,7 +124,7 @@
     int bottom = env->GetIntField(sourceCropObj, gRectClassInfo.bottom);
     Rect sourceCrop(left, top, right, bottom);
 
-    SkAutoTDelete<ScreenshotClient> screenshot(new ScreenshotClient());
+    std::unique_ptr<ScreenshotClient> screenshot(new ScreenshotClient());
     status_t res;
     if (allLayers) {
         minLayer = 0;
@@ -179,7 +172,7 @@
     Bitmap* bitmap = new Bitmap(
             (void*) screenshot->getPixels(), (void*) screenshot.get(), DeleteScreenshot,
             screenshotInfo, rowBytes, nullptr);
-    screenshot.detach();
+    screenshot.release();
     bitmap->peekAtPixelRef()->setImmutable();
 
     return GraphicsJNI::createBitmap(env, bitmap,
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index d3157c8..54decf1 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -599,7 +599,6 @@
     -->
     <permission android:name="android.permission.ACCESS_IMS_CALL_SERVICE"
         android:permissionGroup="android.permission-group.PHONE"
-        android:permissionFlags="hide"
         android:label="@string/permlab_accessImsCallService"
         android:description="@string/permdesc_accessImsCallService"
         android:protectionLevel="signature|system" />
@@ -760,32 +759,32 @@
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.READ_PROFILE"
         android:protectionLevel="normal"
-        android:permissionFlags="hide"/>
+        android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.WRITE_PROFILE"
         android:protectionLevel="normal"
-        android:permissionFlags="hide"/>
+        android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.READ_SOCIAL_STREAM"
         android:protectionLevel="normal"
-        android:permissionFlags="hide"/>
+        android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.WRITE_SOCIAL_STREAM"
         android:protectionLevel="normal"
-        android:permissionFlags="hide"/>
+        android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.READ_USER_DICTIONARY"
         android:protectionLevel="normal"
-        android:permissionFlags="hide"/>
+        android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.WRITE_USER_DICTIONARY"
         android:protectionLevel="normal"
-        android:permissionFlags="hide"/>
+        android:permissionFlags="hidden"/>
 
     <!-- ====================================================================== -->
     <!-- INSTALL PERMISSIONS                                                    -->
@@ -1670,7 +1669,7 @@
     <permission android:name="android.permission.CHANGE_NETWORK_STATE"
         android:description="@string/permdesc_changeNetworkState"
         android:label="@string/permlab_changeNetworkState"
-        android:protectionLevel="normal" />
+        android:protectionLevel="signature|preinstalled|appop|pre23" />
 
     <!-- Allows an application to clear the caches of all installed
          applications on the device.
diff --git a/core/res/res/values-af/strings.xml b/core/res/res/values-af/strings.xml
index cb7e68b..84161e0 100644
--- a/core/res/res/values-af/strings.xml
+++ b/core/res/res/values-af/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB-randpoort"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Nog opsies"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Maak oorloop toe"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimeer"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Maak toe"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> gekies</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> gekies</item>
diff --git a/core/res/res/values-am/strings.xml b/core/res/res/values-am/strings.xml
index 440ca50..40c56cf 100644
--- a/core/res/res/values-am/strings.xml
+++ b/core/res/res/values-am/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Peripheral ወደብ"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"ተጨማሪ አማራጮች"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ትርፍ ፍሰትን ዝጋ"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"አስፋ"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"ዝጋ"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> ተመርጧል</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ተመርጠዋል</item>
diff --git a/core/res/res/values-ar/strings.xml b/core/res/res/values-ar/strings.xml
index 3705a86..8e4ffa5 100644
--- a/core/res/res/values-ar/strings.xml
+++ b/core/res/res/values-ar/strings.xml
@@ -1563,6 +1563,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"‏منفذ الأجهزة الطرفية المزودة بكابل USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"خيارات أخرى"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"إغلاق التجاوز"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"تكبير"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"إغلاق"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="zero">تم تحديد <xliff:g id="COUNT_1">%1$d</xliff:g> من العناصر</item>
       <item quantity="two">تم تحديد عنصرين (<xliff:g id="COUNT_1">%1$d</xliff:g>)</item>
diff --git a/core/res/res/values-az-rAZ/strings.xml b/core/res/res/values-az-rAZ/strings.xml
index 50bf677..868849d 100644
--- a/core/res/res/values-az-rAZ/strings.xml
+++ b/core/res/res/values-az-rAZ/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Peripheral Port"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Daha çox seçim"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Yüklənməni qapadın"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Böyüdün"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Qapadın"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> seçilib</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> seçilib</item>
diff --git a/core/res/res/values-bg/strings.xml b/core/res/res/values-bg/strings.xml
index 05cc050..110e677 100644
--- a/core/res/res/values-bg/strings.xml
+++ b/core/res/res/values-bg/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Периферен USB порт"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Още опции"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Затваряне на менюто при препълване"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Увеличаване"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Затваряне"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">Избрахте <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="one">Избрахте <xliff:g id="COUNT_0">%1$d</xliff:g></item>
diff --git a/core/res/res/values-bn-rBD/strings.xml b/core/res/res/values-bn-rBD/strings.xml
index 5045f46..fea800e 100644
--- a/core/res/res/values-bn-rBD/strings.xml
+++ b/core/res/res/values-bn-rBD/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB পেরিফেরাল পোর্ট"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"আরো বিকল্প"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ওভারফ্লো বন্ধ করুন"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"বড় করুন"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"বন্ধ করুন"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g>টি নির্বাচন করা হয়েছে</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g>টি নির্বাচন করা হয়েছে</item>
diff --git a/core/res/res/values-ca/strings.xml b/core/res/res/values-ca/strings.xml
index 3f38360..34fb95e 100644
--- a/core/res/res/values-ca/strings.xml
+++ b/core/res/res/values-ca/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port perifèric USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Més opcions"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Tanca el menú addicional"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximitza"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Tanca"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">Seleccionats: <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="one">Seleccionats: <xliff:g id="COUNT_0">%1$d</xliff:g></item>
diff --git a/core/res/res/values-cs/strings.xml b/core/res/res/values-cs/strings.xml
index 93f8a2d..3bebb9a 100644
--- a/core/res/res/values-cs/strings.xml
+++ b/core/res/res/values-cs/strings.xml
@@ -545,7 +545,7 @@
     <item msgid="2374913952870110618">"Vlastní"</item>
   </string-array>
   <string-array name="postalAddressTypes">
-    <item msgid="6880257626740047286">"Domů"</item>
+    <item msgid="6880257626740047286">"Domov"</item>
     <item msgid="5629153956045109251">"Práce"</item>
     <item msgid="4966604264500343469">"Ostatní"</item>
     <item msgid="4932682847595299369">"Vlastní"</item>
@@ -602,7 +602,7 @@
     <string name="emailTypeOther" msgid="2923008695272639549">"Jiné"</string>
     <string name="emailTypeMobile" msgid="119919005321166205">"Mobil"</string>
     <string name="postalTypeCustom" msgid="8903206903060479902">"Vlastní"</string>
-    <string name="postalTypeHome" msgid="8165756977184483097">"Domů"</string>
+    <string name="postalTypeHome" msgid="8165756977184483097">"Domov"</string>
     <string name="postalTypeWork" msgid="5268172772387694495">"Práce"</string>
     <string name="postalTypeOther" msgid="2726111966623584341">"Jiné"</string>
     <string name="imTypeCustom" msgid="2074028755527826046">"Vlastní"</string>
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port USB pro periferní zařízení"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Další možnosti"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Zavřít rozbalovací nabídku"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximalizovat"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Zavřít"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="few"><xliff:g id="COUNT_1">%1$d</xliff:g> položky</item>
       <item quantity="many"><xliff:g id="COUNT_1">%1$d</xliff:g> položky</item>
diff --git a/core/res/res/values-da/strings.xml b/core/res/res/values-da/strings.xml
index 7c884c4..9973585 100644
--- a/core/res/res/values-da/strings.xml
+++ b/core/res/res/values-da/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB-port til eksterne enheder"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Flere valgmuligheder"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Luk overløb"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimér"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Luk"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g>valgt</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> valgt</item>
diff --git a/core/res/res/values-de/strings.xml b/core/res/res/values-de/strings.xml
index 7af117f..40519be 100644
--- a/core/res/res/values-de/strings.xml
+++ b/core/res/res/values-de/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB-Port für Peripheriegeräte"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Weitere Optionen"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Überlauf schließen"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximieren"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Schließen"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ausgewählt</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> ausgewählt</item>
diff --git a/core/res/res/values-el/strings.xml b/core/res/res/values-el/strings.xml
index 3d66deb..e4b8aa4 100644
--- a/core/res/res/values-el/strings.xml
+++ b/core/res/res/values-el/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Περιφερειακή θύρα USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Περισσότερες επιλογές"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Κλείσιμο υπερχείλισης"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Μεγιστοποίηση"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Κλείσιμο"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">Επιλέχτηκαν <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="one">Επιλέχτηκε <xliff:g id="COUNT_0">%1$d</xliff:g></item>
diff --git a/core/res/res/values-en-rAU/strings.xml b/core/res/res/values-en-rAU/strings.xml
index f4fbe40..8062057 100644
--- a/core/res/res/values-en-rAU/strings.xml
+++ b/core/res/res/values-en-rAU/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Peripheral Port"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"More options"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Close overflow"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximise"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Close"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> selected</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> selected</item>
diff --git a/core/res/res/values-en-rGB/strings.xml b/core/res/res/values-en-rGB/strings.xml
index f4fbe40..8062057 100644
--- a/core/res/res/values-en-rGB/strings.xml
+++ b/core/res/res/values-en-rGB/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Peripheral Port"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"More options"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Close overflow"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximise"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Close"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> selected</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> selected</item>
diff --git a/core/res/res/values-en-rIN/strings.xml b/core/res/res/values-en-rIN/strings.xml
index f4fbe40..8062057 100644
--- a/core/res/res/values-en-rIN/strings.xml
+++ b/core/res/res/values-en-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Peripheral Port"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"More options"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Close overflow"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximise"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Close"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> selected</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> selected</item>
diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml
index 0bad8de..bfd1570 100644
--- a/core/res/res/values-es-rUS/strings.xml
+++ b/core/res/res/values-es-rUS/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Puerto USB de periféricos"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Más opciones"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Cerrar la barra de herramientas flotante adicional"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizar"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Cerrar"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> elementos seleccionados</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> elemento seleccionado</item>
diff --git a/core/res/res/values-es/strings.xml b/core/res/res/values-es/strings.xml
index 9448e39..b784cb3 100644
--- a/core/res/res/values-es/strings.xml
+++ b/core/res/res/values-es/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Puerto periférico USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Más opciones"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Cerrar menú adicional"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizar"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Cerrar"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> seleccionados</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> seleccionado</item>
diff --git a/core/res/res/values-et-rEE/strings.xml b/core/res/res/values-et-rEE/strings.xml
index fef448a..9a6924c 100644
--- a/core/res/res/values-et-rEE/strings.xml
+++ b/core/res/res/values-et-rEE/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Väline USB-port"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Rohkem valikuid"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Ületäite sulgemine"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimeeri"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Sule"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> on valitud</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> on valitud</item>
diff --git a/core/res/res/values-eu-rES/strings.xml b/core/res/res/values-eu-rES/strings.xml
index b0a85a4..5ec09f9 100644
--- a/core/res/res/values-eu-rES/strings.xml
+++ b/core/res/res/values-eu-rES/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB ataka periferikoa"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Aukera gehiago"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Itxi gainfluxua"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizatu"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Itxi"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> hautatuta</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> hautatuta</item>
diff --git a/core/res/res/values-fa/strings.xml b/core/res/res/values-fa/strings.xml
index 5d63d35..586e25d 100644
--- a/core/res/res/values-fa/strings.xml
+++ b/core/res/res/values-fa/strings.xml
@@ -755,7 +755,7 @@
     <string name="js_dialog_before_unload_negative_button" msgid="5614861293026099715">"ماندن در این صفحه"</string>
     <string name="js_dialog_before_unload" msgid="3468816357095378590">"<xliff:g id="MESSAGE">%s</xliff:g>\n\nمطمئنید می‌خواهید این صفحه را ترک کنید؟"</string>
     <string name="save_password_label" msgid="6860261758665825069">"تأیید"</string>
-    <string name="double_tap_toast" msgid="4595046515400268881">"نکته: برای بزرگنمایی و کوچکنمایی، دو بار ضربه بزنید."</string>
+    <string name="double_tap_toast" msgid="4595046515400268881">"نکته: برای بزرگ‌نمایی و کوچکنمایی، دو بار ضربه بزنید."</string>
     <string name="autofill_this_form" msgid="4616758841157816676">"تکمیل خودکار"</string>
     <string name="setup_autofill" msgid="7103495070180590814">"راه‌اندازی تکمیل خودکار"</string>
     <string name="autofill_address_name_separator" msgid="6350145154779706772">" "</string>
@@ -1079,7 +1079,7 @@
     <string name="permdesc_readInstallSessions" msgid="2049771699626019849">"به برنامه اجازه می‌دهد جلسات نصب را بخواند. این کار به برنامه اجازه می‌دهد جزئیات نصب‌های بسته فعال را ببیند."</string>
     <string name="permlab_requestInstallPackages" msgid="1772330282283082214">"درخواست نصب بسته‌بندی"</string>
     <string name="permdesc_requestInstallPackages" msgid="5740101072486783082">"به برنامه اجازه می‌دهد درخواست نصب بسته‌بندی کند."</string>
-    <string name="tutorial_double_tap_to_zoom_message_short" msgid="4070433208160063538">"دوبار لمس کنید تا بزرگنمایی کنترل شود"</string>
+    <string name="tutorial_double_tap_to_zoom_message_short" msgid="4070433208160063538">"دوبار لمس کنید تا بزرگ‌نمایی کنترل شود"</string>
     <string name="gadget_host_error_inflating" msgid="4882004314906466162">"افزودن ابزارک انجام نشد."</string>
     <string name="ime_action_go" msgid="8320845651737369027">"برو"</string>
     <string name="ime_action_search" msgid="658110271822807811">"جستجو"</string>
@@ -1257,7 +1257,7 @@
     <string name="media_route_status_in_use" msgid="4533786031090198063">"در حال استفاده"</string>
     <string name="display_manager_built_in_display_name" msgid="2583134294292563941">"صفحه نمایش از خود"</string>
     <string name="display_manager_hdmi_display_name" msgid="1555264559227470109">"‏صفحه HDMI"</string>
-    <string name="display_manager_overlay_display_name" msgid="5142365982271620716">"همپوشانی #<xliff:g id="ID">%1$d</xliff:g>"</string>
+    <string name="display_manager_overlay_display_name" msgid="5142365982271620716">"هم‌پوشانی #<xliff:g id="ID">%1$d</xliff:g>"</string>
     <string name="display_manager_overlay_display_title" msgid="652124517672257172">"<xliff:g id="NAME">%1$s</xliff:g>: <xliff:g id="WIDTH">%2$d</xliff:g>x<xliff:g id="HEIGHT">%3$d</xliff:g>, <xliff:g id="DPI">%4$d</xliff:g> dpi"</string>
     <string name="display_manager_overlay_display_secure_suffix" msgid="6022119702628572080">"، امن"</string>
     <string name="kg_forgot_pattern_button_text" msgid="8852021467868220608">"الگو را فراموش کرده‌اید"</string>
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"‏درگاه جانبی USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"گزینه‌های بیشتر"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"بستن منوی سرریز"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"بزرگ کردن"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"بستن"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one">‏<xliff:g id="COUNT_1">%1$d</xliff:g> انتخاب شد</item>
       <item quantity="other">‏<xliff:g id="COUNT_1">%1$d</xliff:g> انتخاب شد</item>
diff --git a/core/res/res/values-fi/strings.xml b/core/res/res/values-fi/strings.xml
index e7be0a1..567c3ea 100644
--- a/core/res/res/values-fi/strings.xml
+++ b/core/res/res/values-fi/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB-oheislaiteportti"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Lisäasetukset"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Sulje ylivuoto"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Suurenna"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Sulje"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> valittu</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> valittu</item>
diff --git a/core/res/res/values-fr-rCA/strings.xml b/core/res/res/values-fr-rCA/strings.xml
index 18c52b1..36e406e 100644
--- a/core/res/res/values-fr-rCA/strings.xml
+++ b/core/res/res/values-fr-rCA/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Plus d\'options"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Fermer la barre d\'outils en superposition"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Agrandir"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Fermer"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> élément sélectionné</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> éléments sélectionnés</item>
diff --git a/core/res/res/values-fr/strings.xml b/core/res/res/values-fr/strings.xml
index e2c94e4..f2e0fa6 100644
--- a/core/res/res/values-fr/strings.xml
+++ b/core/res/res/values-fr/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port du périphérique USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Plus d\'options"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Fermer la barre d\'outils en superposition"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Agrandir"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Fermer"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> élément sélectionné</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> éléments sélectionnés</item>
diff --git a/core/res/res/values-gl-rES/strings.xml b/core/res/res/values-gl-rES/strings.xml
index 82d8452..ce68d3e 100644
--- a/core/res/res/values-gl-rES/strings.xml
+++ b/core/res/res/values-gl-rES/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Porto periférico USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Máis opcións"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Pechar barra de ferramentas adicional"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizar"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Pechar"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">Seleccionáronse <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="one">Seleccionouse <xliff:g id="COUNT_0">%1$d</xliff:g></item>
diff --git a/core/res/res/values-gu-rIN/strings.xml b/core/res/res/values-gu-rIN/strings.xml
index 6e2356a..638bf02 100644
--- a/core/res/res/values-gu-rIN/strings.xml
+++ b/core/res/res/values-gu-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB પેરિફેરલ પોર્ટ"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"વધુ વિકલ્પો"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ઓવરફ્લો બંધ કરો"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"મહત્તમ કરો"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"બંધ કરો"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> પસંદ કરી</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> પસંદ કરી</item>
diff --git a/core/res/res/values-hi/strings.xml b/core/res/res/values-hi/strings.xml
index fd87a65..cfe2279 100644
--- a/core/res/res/values-hi/strings.xml
+++ b/core/res/res/values-hi/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB पेरिफ़ेरल पोर्ट"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"अधिक विकल्प"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ओवरफ़्लो बंद करें"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"बड़ा करें"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"बंद करें"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> चयनित</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> चयनित</item>
diff --git a/core/res/res/values-hr/strings.xml b/core/res/res/values-hr/strings.xml
index e224d4c..febe600 100644
--- a/core/res/res/values-hr/strings.xml
+++ b/core/res/res/values-hr/strings.xml
@@ -1512,6 +1512,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB priključak za periferne uređaje"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Više opcija"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Zatvori dodatni izbornik"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimiziraj"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Zatvori"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> odabrana</item>
       <item quantity="few"><xliff:g id="COUNT_1">%1$d</xliff:g> odabrane</item>
diff --git a/core/res/res/values-hu/strings.xml b/core/res/res/values-hu/strings.xml
index 1a806a2..e393a4a 100644
--- a/core/res/res/values-hu/strings.xml
+++ b/core/res/res/values-hu/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB-perifériaport"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"További lehetőségek"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"További elemeket tartalmazó eszköztár bezárása"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Teljes méret"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Bezárás"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> kiválasztva</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> kiválasztva</item>
diff --git a/core/res/res/values-hy-rAM/strings.xml b/core/res/res/values-hy-rAM/strings.xml
index 6543a99..6d07aa4 100644
--- a/core/res/res/values-hy-rAM/strings.xml
+++ b/core/res/res/values-hy-rAM/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB արտաքին միացք"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Այլ ընտրանքներ"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Փակել ավելորդ տեղեկությունները"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Մեծացնել"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Փակել"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one">Ընտրված է՝ <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="other">Ընտրված է՝ <xliff:g id="COUNT_1">%1$d</xliff:g></item>
diff --git a/core/res/res/values-in/strings.xml b/core/res/res/values-in/strings.xml
index 9e4647e..e93c91e4 100644
--- a/core/res/res/values-in/strings.xml
+++ b/core/res/res/values-in/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port Periferal USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Opsi lainnya"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Tutup luapan"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimalkan"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Tutup"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> dipilih</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> dipilih</item>
diff --git a/core/res/res/values-is-rIS/strings.xml b/core/res/res/values-is-rIS/strings.xml
index 97f5adf..fdfdd72 100644
--- a/core/res/res/values-is-rIS/strings.xml
+++ b/core/res/res/values-is-rIS/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB-tengi fyrir jaðartæki"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Fleiri valkostir"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Loka viðbótaratriðum"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Stækka"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Loka"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> valið</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> valin</item>
diff --git a/core/res/res/values-it/strings.xml b/core/res/res/values-it/strings.xml
index e9e8864..7312f2b 100644
--- a/core/res/res/values-it/strings.xml
+++ b/core/res/res/values-it/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Porta periferica USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Altre opzioni"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Chiudi overflow"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Ingrandisci"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Chiudi"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> elementi selezionati</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> elemento selezionato</item>
diff --git a/core/res/res/values-iw/strings.xml b/core/res/res/values-iw/strings.xml
index e39c52f..ab9a635 100644
--- a/core/res/res/values-iw/strings.xml
+++ b/core/res/res/values-iw/strings.xml
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"‏יציאת USB בציוד היקפי"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"אפשרויות נוספות"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"סגור את האפשרויות הנוספות"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"הגדל"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"סגור"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="two">בחרת <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="many">בחרת <xliff:g id="COUNT_1">%1$d</xliff:g></item>
diff --git a/core/res/res/values-ja/strings.xml b/core/res/res/values-ja/strings.xml
index 70a248d..67dc9de 100644
--- a/core/res/res/values-ja/strings.xml
+++ b/core/res/res/values-ja/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB周辺機器ポート"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"その他のオプション"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"オーバーフローを閉じる"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"最大化"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"閉じる"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g>件選択済み</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g>件選択済み</item>
diff --git a/core/res/res/values-ka-rGE/strings.xml b/core/res/res/values-ka-rGE/strings.xml
index b45c4fed..40d91b4 100644
--- a/core/res/res/values-ka-rGE/strings.xml
+++ b/core/res/res/values-ka-rGE/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"პერიფერიული USB პორტი"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"სხვა ვარიანტები"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"გადავსების დახურვა"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"მაქსიმალური ზომა"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"დახურვა"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> შერჩეული</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> შერჩეული</item>
diff --git a/core/res/res/values-kk-rKZ/strings.xml b/core/res/res/values-kk-rKZ/strings.xml
index e50e17b..8d9e643f 100644
--- a/core/res/res/values-kk-rKZ/strings.xml
+++ b/core/res/res/values-kk-rKZ/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB перифериялық порты"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Қосымша опциялар"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Артық толуды жабу"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Жазу"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Жабу"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> таңдалды</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> таңдалды</item>
diff --git a/core/res/res/values-km-rKH/strings.xml b/core/res/res/values-km-rKH/strings.xml
index 4c85e93..23d16d6 100644
--- a/core/res/res/values-km-rKH/strings.xml
+++ b/core/res/res/values-km-rKH/strings.xml
@@ -1497,6 +1497,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"ឧបករណ៍រន្ធ USB បន្ថែម"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"ជម្រើសច្រើនទៀត"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"បិទលើសចំណុះ"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"ពង្រីក"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"បិទ"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">បានជ្រើស <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="one">បានជ្រើស <xliff:g id="COUNT_0">%1$d</xliff:g></item>
diff --git a/core/res/res/values-kn-rIN/strings.xml b/core/res/res/values-kn-rIN/strings.xml
index bde8e04..9fbd533 100644
--- a/core/res/res/values-kn-rIN/strings.xml
+++ b/core/res/res/values-kn-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB ಪೆರಿಪೆರಲ್ ಪೋರ್ಟ್"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"ಇನ್ನಷ್ಟು ಆಯ್ಕೆಗಳು"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ಓವರ್‌ಫ್ಲೋ ಮುಚ್ಚು"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"ಹಿಗ್ಗಿಸು"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"ಮುಚ್ಚು"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> ಆಯ್ಕೆಮಾಡಲಾಗಿದೆ</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ಆಯ್ಕೆಮಾಡಲಾಗಿದೆ</item>
diff --git a/core/res/res/values-ko/strings.xml b/core/res/res/values-ko/strings.xml
index d30fb4a..353d6bb 100644
--- a/core/res/res/values-ko/strings.xml
+++ b/core/res/res/values-ko/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB 주변기기 포트"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"옵션 더보기"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"오버플로우 닫기"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"최대화"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"닫기"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g>개 선택됨</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g>개 선택됨</item>
diff --git a/core/res/res/values-ky-rKG/strings.xml b/core/res/res/values-ky-rKG/strings.xml
index c410d19..aebe1c6 100644
--- a/core/res/res/values-ky-rKG/strings.xml
+++ b/core/res/res/values-ky-rKG/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Сырткы оюкча"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Дагы параметрлер"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Ашып-ташууну жабуу"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Чоңойтуу"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Жабуу"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> тандалды</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> тандалды</item>
diff --git a/core/res/res/values-lo-rLA/strings.xml b/core/res/res/values-lo-rLA/strings.xml
index 7d673ff..051833f 100644
--- a/core/res/res/values-lo-rLA/strings.xml
+++ b/core/res/res/values-lo-rLA/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"ຜອດ​ຮອບນອກ USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"ໂຕ​ເລືອກ​ເພີ່ມ​ເຕີມ"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ປິດ​ການ​ໄຫຼ​ລົ້ນ​ອອກ​ມາ"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"ຂະຫຍາຍອອກ"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"ປິດ"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ຖືກເລືອກ​ແລ້ວ</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> ຖືກເລືອກ​ແລ້ວ</item>
diff --git a/core/res/res/values-lt/strings.xml b/core/res/res/values-lt/strings.xml
index 3efcd84..7189c4b 100644
--- a/core/res/res/values-lt/strings.xml
+++ b/core/res/res/values-lt/strings.xml
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB išorinis prievadas"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Daugiau parinkčių"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Uždaryti perpildymo sritį"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Padidinti"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Uždaryti"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one">Pasir. <xliff:g id="COUNT_1">%1$d</xliff:g> elem.</item>
       <item quantity="few">Pasir. <xliff:g id="COUNT_1">%1$d</xliff:g> elem.</item>
diff --git a/core/res/res/values-lv/strings.xml b/core/res/res/values-lv/strings.xml
index c91041e..63ad122 100644
--- a/core/res/res/values-lv/strings.xml
+++ b/core/res/res/values-lv/strings.xml
@@ -1512,6 +1512,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB perifērijas ports"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Citas opcijas"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Aizvērt pārpildes izvēlni"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimizēt"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Aizvērt"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="zero"><xliff:g id="COUNT_1">%1$d</xliff:g> atlasīti</item>
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> atlasīts</item>
diff --git a/core/res/res/values-mk-rMK/strings.xml b/core/res/res/values-mk-rMK/strings.xml
index 9716807..d818a9d 100644
--- a/core/res/res/values-mk-rMK/strings.xml
+++ b/core/res/res/values-mk-rMK/strings.xml
@@ -1497,6 +1497,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Надворешна порта на УСБ"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Повеќе опции"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Затвори прелевање"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Зголеми"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Затвори"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> е избрана</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> се избрани</item>
diff --git a/core/res/res/values-ml-rIN/strings.xml b/core/res/res/values-ml-rIN/strings.xml
index 5c7a43f..dc4749f 100644
--- a/core/res/res/values-ml-rIN/strings.xml
+++ b/core/res/res/values-ml-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB പെരിഫറൽ പോർട്ട്"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"കൂടുതല്‍ ഓപ്ഷനുകള്‍"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ഓവർഫ്ലോ അടയ്‌ക്കുക"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"വലുതാക്കുക"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"അടയ്‌ക്കുക"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> തിരഞ്ഞെടുത്തു</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> തിരഞ്ഞെടുത്തു</item>
diff --git a/core/res/res/values-mn-rMN/strings.xml b/core/res/res/values-mn-rMN/strings.xml
index c457247..4b568ec 100644
--- a/core/res/res/values-mn-rMN/strings.xml
+++ b/core/res/res/values-mn-rMN/strings.xml
@@ -1493,6 +1493,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Peripheral Port"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Нэмэлт сонголтууд"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Илүү цонхнуудыг хаах"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Томруулах"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Хаах"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> сонгосон</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> сонгосон</item>
diff --git a/core/res/res/values-mr-rIN/strings.xml b/core/res/res/values-mr-rIN/strings.xml
index 9cce231..45e6358 100644
--- a/core/res/res/values-mr-rIN/strings.xml
+++ b/core/res/res/values-mr-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB परिधीय पोर्ट"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"अधिक पर्याय"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ओव्हरफ्लो बंद करा"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"मोठे करा"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"बंद करा"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> निवडला</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> निवडले</item>
diff --git a/core/res/res/values-ms-rMY/strings.xml b/core/res/res/values-ms-rMY/strings.xml
index 0017f2b..dc30d38 100644
--- a/core/res/res/values-ms-rMY/strings.xml
+++ b/core/res/res/values-ms-rMY/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port Persisian USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Lagi pilihan"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Tutup limpahan"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimumkan"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Tutup"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> dipilih</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> dipilih</item>
diff --git a/core/res/res/values-my-rMM/strings.xml b/core/res/res/values-my-rMM/strings.xml
index 4ba2827..135605b 100644
--- a/core/res/res/values-my-rMM/strings.xml
+++ b/core/res/res/values-my-rMM/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB ဘေးရှိပို့တ်"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"နောက်ထပ် ရွေးစရာများ"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ကိရိယာဘားအပိုအား ပိတ်ရန်"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"အများဆုံး လုပ်ပေးရန်"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"ပိတ်ရန်"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ရွေးချယ်ပြီးပါပြီ</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> ရွေးချယ်ပြီးပါပြီ</item>
diff --git a/core/res/res/values-nb/strings.xml b/core/res/res/values-nb/strings.xml
index 56e2cf2..ae43e25 100644
--- a/core/res/res/values-nb/strings.xml
+++ b/core/res/res/values-nb/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port for USB-tilleggsutstyr"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Flere alternativer"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Lukk overflytsmenyen"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimer"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Lukk"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> er valgt</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> er valgt</item>
diff --git a/core/res/res/values-ne-rNP/strings.xml b/core/res/res/values-ne-rNP/strings.xml
index 0f10385..b0643ea 100644
--- a/core/res/res/values-ne-rNP/strings.xml
+++ b/core/res/res/values-ne-rNP/strings.xml
@@ -1501,6 +1501,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB पेरिफेरल पोर्ट"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"थप विकल्पहरू"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ओभरफ्लो बन्द गर्नुहोस्"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"अधिकतम गर्नुहोस्"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"बन्द गर्नुहोस्"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> चयन गरियो</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> चयन गरियो</item>
diff --git a/core/res/res/values-nl/strings.xml b/core/res/res/values-nl/strings.xml
index 6ca7c5f..5be486a 100644
--- a/core/res/res/values-nl/strings.xml
+++ b/core/res/res/values-nl/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Poort voor USB-randapparatuur"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Meer opties"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Overloop sluiten"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximaliseren"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Sluiten"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> geselecteerd</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> geselecteerd</item>
diff --git a/core/res/res/values-pa-rIN/strings.xml b/core/res/res/values-pa-rIN/strings.xml
index dd039d9..7306582 100644
--- a/core/res/res/values-pa-rIN/strings.xml
+++ b/core/res/res/values-pa-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB ਪੈਰੀਫੈਰਲ ਪੋਰਟ"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"ਹੋਰ ਚੋਣਾਂ"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ਓਵਰਫਲੋ ਬੰਦ ਕਰੋ"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"ਵੱਡਾ ਕਰੋ"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"ਬੰਦ ਕਰੋ"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> ਚੁਣਿਆ ਗਿਆ</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ਚੁਣਿਆ ਗਿਆ</item>
diff --git a/core/res/res/values-pl/strings.xml b/core/res/res/values-pl/strings.xml
index 5a8bd6a..f220b25 100644
--- a/core/res/res/values-pl/strings.xml
+++ b/core/res/res/values-pl/strings.xml
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port peryferyjny USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Więcej opcji"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Zamknij rozszerzony pasek"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksymalizuj"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Zamknij"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="few">Wybrano <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="many">Wybrano <xliff:g id="COUNT_1">%1$d</xliff:g></item>
diff --git a/core/res/res/values-pt-rBR/strings.xml b/core/res/res/values-pt-rBR/strings.xml
index 0fd4f5e..bd0c90c 100644
--- a/core/res/res/values-pt-rBR/strings.xml
+++ b/core/res/res/values-pt-rBR/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Porta USB periférica"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Mais opções"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Fechar barra flutuante"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizar"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Fechar"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> selecionados</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> selecionados</item>
diff --git a/core/res/res/values-pt-rPT/strings.xml b/core/res/res/values-pt-rPT/strings.xml
index a056ea9..7eb3809 100644
--- a/core/res/res/values-pt-rPT/strings.xml
+++ b/core/res/res/values-pt-rPT/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Porta periférica USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Mais opções"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Fechar excesso"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizar"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Fechar"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> selecionados</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> selecionado</item>
diff --git a/core/res/res/values-pt/strings.xml b/core/res/res/values-pt/strings.xml
index 0fd4f5e..bd0c90c 100644
--- a/core/res/res/values-pt/strings.xml
+++ b/core/res/res/values-pt/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Porta USB periférica"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Mais opções"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Fechar barra flutuante"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizar"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Fechar"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> selecionados</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> selecionados</item>
diff --git a/core/res/res/values-ro/strings.xml b/core/res/res/values-ro/strings.xml
index 9bfa8e3..515d23c 100644
--- a/core/res/res/values-ro/strings.xml
+++ b/core/res/res/values-ro/strings.xml
@@ -702,7 +702,7 @@
     <string name="lockscreen_glogin_instructions" msgid="3931816256100707784">"Pentru a debloca, conectaţi-vă folosind Contul Google."</string>
     <string name="lockscreen_glogin_username_hint" msgid="8846881424106484447">"Nume de utilizator (e-mail)"</string>
     <string name="lockscreen_glogin_password_hint" msgid="5958028383954738528">"Parolă"</string>
-    <string name="lockscreen_glogin_submit_button" msgid="7130893694795786300">"Conectaţi-vă"</string>
+    <string name="lockscreen_glogin_submit_button" msgid="7130893694795786300">"Conectați-vă"</string>
     <string name="lockscreen_glogin_invalid_input" msgid="1364051473347485908">"Nume de utilizator sau parolă nevalide."</string>
     <string name="lockscreen_glogin_account_recovery_hint" msgid="1696924763690379073">"Aţi uitat numele de utilizator sau parola?\nAccesaţi "<b>"google.com/accounts/recovery"</b>"."</string>
     <string name="lockscreen_glogin_checking_password" msgid="7114627351286933867">"Se verifică..."</string>
@@ -970,7 +970,7 @@
       <item quantity="other">Rețele Wi-Fi deschise disponibile</item>
       <item quantity="one">Rețea Wi-Fi deschisă disponibilă</item>
     </plurals>
-    <string name="wifi_available_sign_in" msgid="9157196203958866662">"Conectaţi-vă la reţeaua Wi-Fi"</string>
+    <string name="wifi_available_sign_in" msgid="9157196203958866662">"Conectați-vă la reţeaua Wi-Fi"</string>
     <string name="network_available_sign_in" msgid="1848877297365446605">"Conectați-vă la rețea"</string>
     <!-- no translation found for network_available_sign_in_detailed (8000081941447976118) -->
     <skip />
@@ -1290,7 +1290,7 @@
     <string name="kg_login_instructions" msgid="1100551261265506448">"Pentru a debloca, conectaţi-vă cu Contul dvs. Google."</string>
     <string name="kg_login_username_hint" msgid="5718534272070920364">"Nume de utilizator (e-mail)"</string>
     <string name="kg_login_password_hint" msgid="9057289103827298549">"Parolă"</string>
-    <string name="kg_login_submit_button" msgid="5355904582674054702">"Conectaţi-vă"</string>
+    <string name="kg_login_submit_button" msgid="5355904582674054702">"Conectați-vă"</string>
     <string name="kg_login_invalid_input" msgid="5754664119319872197">"Nume de utilizator sau parolă nevalide."</string>
     <string name="kg_login_account_recovery_hint" msgid="5690709132841752974">"Aţi uitat numele de utilizator sau parola?\nAccesaţi "<b>"google.com/accounts/recovery"</b>"."</string>
     <string name="kg_login_checking_password" msgid="1052685197710252395">"Se verifică contul…"</string>
@@ -1512,6 +1512,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port USB periferic"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Mai multe opțiuni"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Închideți meniul suplimentar"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximizați"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Închideți"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="few"><xliff:g id="COUNT_1">%1$d</xliff:g> selectate</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> selectate</item>
diff --git a/core/res/res/values-ru/strings.xml b/core/res/res/values-ru/strings.xml
index 9fe29e1..c3e7411 100644
--- a/core/res/res/values-ru/strings.xml
+++ b/core/res/res/values-ru/strings.xml
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Внешний USB-порт"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Ещё"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Закрыть дополнительное меню"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Развернуть"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Закрыть"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one">Выбрано: <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="few">Выбрано: <xliff:g id="COUNT_1">%1$d</xliff:g></item>
diff --git a/core/res/res/values-si-rLK/strings.xml b/core/res/res/values-si-rLK/strings.xml
index f13a69e..c8fae8f 100644
--- a/core/res/res/values-si-rLK/strings.xml
+++ b/core/res/res/values-si-rLK/strings.xml
@@ -1497,6 +1497,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB පර්යන්ත තොට"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"තවත් විකල්ප"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ඉතිරී යාම වසන්න"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"විහිදන්න"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"වසන්න"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> ක් තෝරන ලදි</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ක් තෝරන ලදි</item>
diff --git a/core/res/res/values-sk/strings.xml b/core/res/res/values-sk/strings.xml
index 27258cf..fc17568 100644
--- a/core/res/res/values-sk/strings.xml
+++ b/core/res/res/values-sk/strings.xml
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Port USB pre periférne zariadenia"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Ďalšie možnosti"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Zatvoriť rozbaľovaciu ponuku"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximalizovať"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Zavrieť"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="few">Vybrané: <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="many">Vybrané: <xliff:g id="COUNT_1">%1$d</xliff:g></item>
diff --git a/core/res/res/values-sl/strings.xml b/core/res/res/values-sl/strings.xml
index 5f38419..941f3a1 100644
--- a/core/res/res/values-sl/strings.xml
+++ b/core/res/res/values-sl/strings.xml
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Vrata USB za dodatno opremo"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Več možnosti"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Zapri presežni element"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimiziraj"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Zapri"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> izbran</item>
       <item quantity="two"><xliff:g id="COUNT_1">%1$d</xliff:g> izbrana</item>
diff --git a/core/res/res/values-sq-rAL/strings.xml b/core/res/res/values-sq-rAL/strings.xml
index 370bc9a..65d4d19 100644
--- a/core/res/res/values-sq-rAL/strings.xml
+++ b/core/res/res/values-sq-rAL/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Porta periferike USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Opsione të tjera"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Mbylle tejkalimin"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimizo"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Mbyll"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> të zgjedhura</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> i zgjedhur</item>
diff --git a/core/res/res/values-sr/strings.xml b/core/res/res/values-sr/strings.xml
index 8f19379..0b5be6b 100644
--- a/core/res/res/values-sr/strings.xml
+++ b/core/res/res/values-sr/strings.xml
@@ -1512,6 +1512,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB порт за периферијске уређаје"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Још опција"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Затвори преклопни мени"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Увећај"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Затвори"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one">Изабрана је <xliff:g id="COUNT_1">%1$d</xliff:g> ставка</item>
       <item quantity="few">Изабране су <xliff:g id="COUNT_1">%1$d</xliff:g> ставке</item>
diff --git a/core/res/res/values-sv/strings.xml b/core/res/res/values-sv/strings.xml
index 467c3dc..f5bd759 100644
--- a/core/res/res/values-sv/strings.xml
+++ b/core/res/res/values-sv/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB-port för kringutrustning"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Fler alternativ"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Dölj utökat verktygsfält"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maximera"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Stäng"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> har valts</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> har valts</item>
diff --git a/core/res/res/values-sw/strings.xml b/core/res/res/values-sw/strings.xml
index 25f8ded..b34c115 100644
--- a/core/res/res/values-sw/strings.xml
+++ b/core/res/res/values-sw/strings.xml
@@ -229,7 +229,7 @@
     <string name="user_owner_label" msgid="2804351898001038951">"Binafsi"</string>
     <string name="managed_profile_label" msgid="6260850669674791528">"Kazini"</string>
     <string name="permgrouplab_contacts" msgid="3657758145679177612">"Anwani"</string>
-    <string name="permgroupdesc_contacts" msgid="6951499528303668046">"fikia anwani zako"</string>
+    <string name="permgroupdesc_contacts" msgid="6951499528303668046">"ifikie anwani zako"</string>
     <string name="permgrouplab_location" msgid="7275582855722310164">"Mahali"</string>
     <string name="permgroupdesc_location" msgid="1346617465127855033">"fikia mahali kilipo kifaa hiki"</string>
     <string name="permgrouplab_calendar" msgid="5863508437783683902">"Kalenda"</string>
@@ -1497,6 +1497,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Mlango wa USB wa Pembeni"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Chaguo zaidi"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Funga vipengee vya ziada"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Panua"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Funga"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> vimechaguliwa</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> kimechaguliwa</item>
diff --git a/core/res/res/values-ta-rIN/strings.xml b/core/res/res/values-ta-rIN/strings.xml
index 7795025..14d0c35 100644
--- a/core/res/res/values-ta-rIN/strings.xml
+++ b/core/res/res/values-ta-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB பெரிபெரல் போர்ட்"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"கூடுதல் விருப்பங்கள்"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"மேல்தோன்றலை மூடு"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"பெரிதாக்கு"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"மூடு"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> தேர்ந்தெடுக்கப்பட்டன</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> தேர்ந்தெடுக்கப்பட்டது</item>
diff --git a/core/res/res/values-te-rIN/strings.xml b/core/res/res/values-te-rIN/strings.xml
index 860738a..d15148c 100644
--- a/core/res/res/values-te-rIN/strings.xml
+++ b/core/res/res/values-te-rIN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB పెరిఫెరల్ పోర్ట్"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"మరిన్ని ఎంపికలు"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"అతివ్యాప్తిని మూసివేస్తుంది"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"గరిష్టీకరించు"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"మూసివేయి"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ఎంచుకోబడ్డాయి</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> ఎంచుకోబడింది</item>
diff --git a/core/res/res/values-th/strings.xml b/core/res/res/values-th/strings.xml
index 27a1e9a..78d1c2e 100644
--- a/core/res/res/values-th/strings.xml
+++ b/core/res/res/values-th/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"อุปกรณ์สำหรับต่อพอร์ต USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"ตัวเลือกเพิ่มเติม"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"ปิดรายการเพิ่มเติม"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"ขยายใหญ่สุด"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"ปิด"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">เลือกไว้ <xliff:g id="COUNT_1">%1$d</xliff:g> รายการ</item>
       <item quantity="one">เลือกไว้ <xliff:g id="COUNT_0">%1$d</xliff:g> รายการ</item>
diff --git a/core/res/res/values-tl/strings.xml b/core/res/res/values-tl/strings.xml
index b33e498..b8a82eb 100644
--- a/core/res/res/values-tl/strings.xml
+++ b/core/res/res/values-tl/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Peripheral Port"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Higit pang mga opsyon"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Isara ang overflow"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"I-maximize"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Isara"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> ang napili</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ang napili</item>
diff --git a/core/res/res/values-tr/strings.xml b/core/res/res/values-tr/strings.xml
index 223fdb1..8140caf 100644
--- a/core/res/res/values-tr/strings.xml
+++ b/core/res/res/values-tr/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB Çevre Birimi Bağlantı Noktası"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Diğer seçenekler"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Taşan araç çubuğunu kapat"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Ekranı Kapla"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Kapat"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> öğe seçildi</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> öğe seçildi</item>
diff --git a/core/res/res/values-uk/strings.xml b/core/res/res/values-uk/strings.xml
index 4e17662..d3b6500 100644
--- a/core/res/res/values-uk/strings.xml
+++ b/core/res/res/values-uk/strings.xml
@@ -1529,6 +1529,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Периферійний USB-порт"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Більше опцій"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Закрити розширені інструменти"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Розгорнути"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Закрити"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one">Вибрано <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="few">Вибрано <xliff:g id="COUNT_1">%1$d</xliff:g></item>
diff --git a/core/res/res/values-ur-rPK/strings.xml b/core/res/res/values-ur-rPK/strings.xml
index 2a5c5ea..21e9e03 100644
--- a/core/res/res/values-ur-rPK/strings.xml
+++ b/core/res/res/values-ur-rPK/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"‏USB پیرفرل پورٹ"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"مزید اختیارات"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"اوورفلو بند کریں"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"بڑا کریں"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"بند کریں"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> منتخب کردہ</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> منتخب کردہ</item>
diff --git a/core/res/res/values-uz-rUZ/strings.xml b/core/res/res/values-uz-rUZ/strings.xml
index 1345673..68a5d9d 100644
--- a/core/res/res/values-uz-rUZ/strings.xml
+++ b/core/res/res/values-uz-rUZ/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Tashqi USB porti"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Ko‘proq"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Qalqib turuvchi asboblar panelini yopish"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Maksimallashtirish"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Yopish"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> ta tanlandi</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> ta tanlandi</item>
diff --git a/core/res/res/values-vi/strings.xml b/core/res/res/values-vi/strings.xml
index 3d19a45..886bbec 100644
--- a/core/res/res/values-vi/strings.xml
+++ b/core/res/res/values-vi/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Cổng ngoại vi USB"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Tùy chọn khác"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Đóng tràn"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Tối đa hóa"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Đóng"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">Đã chọn <xliff:g id="COUNT_1">%1$d</xliff:g></item>
       <item quantity="one">Đã chọn <xliff:g id="COUNT_0">%1$d</xliff:g></item>
diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml
index d271b36..dc44593 100644
--- a/core/res/res/values-zh-rCN/strings.xml
+++ b/core/res/res/values-zh-rCN/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB 外设端口"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"更多选项"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"关闭工具栏溢出"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"最大化"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"关闭"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">已选择 <xliff:g id="COUNT_1">%1$d</xliff:g> 项</item>
       <item quantity="one">已选择 <xliff:g id="COUNT_0">%1$d</xliff:g> 项</item>
diff --git a/core/res/res/values-zh-rHK/strings.xml b/core/res/res/values-zh-rHK/strings.xml
index d3eb587..cfeb274 100644
--- a/core/res/res/values-zh-rHK/strings.xml
+++ b/core/res/res/values-zh-rHK/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB 外端連接埠"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"更多選項"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"關閉工具列溢位功能"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"最大化"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"關閉"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">已選取 <xliff:g id="COUNT_1">%1$d</xliff:g> 個項目</item>
       <item quantity="one">已選取 <xliff:g id="COUNT_0">%1$d</xliff:g> 個項目</item>
diff --git a/core/res/res/values-zh-rTW/strings.xml b/core/res/res/values-zh-rTW/strings.xml
index c674255..1ac240f 100644
--- a/core/res/res/values-zh-rTW/strings.xml
+++ b/core/res/res/values-zh-rTW/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"USB 週邊連接埠"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"更多選項"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"關閉溢出模式"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"最大化"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"關閉"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="other">已選取 <xliff:g id="COUNT_1">%1$d</xliff:g> 個項目</item>
       <item quantity="one">已選取 <xliff:g id="COUNT_0">%1$d</xliff:g> 個項目</item>
diff --git a/core/res/res/values-zu/strings.xml b/core/res/res/values-zu/strings.xml
index 07edb0c..e8c7ca3 100644
--- a/core/res/res/values-zu/strings.xml
+++ b/core/res/res/values-zu/strings.xml
@@ -1495,6 +1495,8 @@
     <string name="usb_midi_peripheral_product_name" msgid="4971827859165280403">"Imbobo ye-USB Peripheral"</string>
     <string name="floating_toolbar_open_overflow_description" msgid="4797287862999444631">"Izinketho eziningi"</string>
     <string name="floating_toolbar_close_overflow_description" msgid="559796923090723804">"Vala ukuchichima"</string>
+    <string name="maximize_button_text" msgid="7543285286182446254">"Khulisa"</string>
+    <string name="close_button_text" msgid="3937902162644062866">"Vala"</string>
     <plurals name="selected_count" formatted="false" msgid="7187339492915744615">
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> okukhethiwe</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> okukhethiwe</item>
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index de16f20..1a45b3a 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -250,7 +250,7 @@
         <flag name="costsMoney" value="0x0001" />
         <!-- Additional flag from base permission type: this permission is hidden
              and should not show in the UI. -->
-        <flag name="hide" value="0x2" />
+        <flag name="hidden" value="0x2" />
     </attr>
 
     <!-- Specified the name of a group that this permission is associated
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index ac6204d..af5c74d 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3374,9 +3374,6 @@
     <!-- Title for a dialog showing possible activities for sharing in ShareActionProvider [CHAR LIMIT=25] -->
     <string name="share_action_provider_share_with">Share with</string>
 
-    <!-- Delimeter used between each item in a textual list; for example "Alpha, Beta". [CHAR LIMIT=3] -->
-    <string name="list_delimeter">", "</string>
-
     <!-- STK sending DTMF, SMS, USSD, SS -->
     <string name="sending">Sending\u2026</string>
 
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index 1e202e4..2369c9b 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -967,12 +967,8 @@
         <item name="borderRight">?attr/preferenceFragmentPaddingSide</item>
     </style>
 
-    <style name="Widget.Material.MediaRouteButton">
-        <item name="background">@drawable/control_background_40dp_material</item>
+    <style name="Widget.Material.MediaRouteButton" parent ="Widget.Material.ActionButton">
         <item name="externalRouteEnabledDrawable">@drawable/ic_media_route_material</item>
-        <item name="minWidth">56dp</item>
-        <item name="minHeight">48dp</item>
-        <item name="focusable">true</item>
         <item name="contentDescription">@string/media_route_button_content_description</item>
     </style>
 
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index a45d907..e2a9d08 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -450,7 +450,6 @@
   <java-symbol type="string" name="delete" />
   <java-symbol type="string" name="deleteText" />
   <java-symbol type="string" name="grant_permissions_header_text" />
-  <java-symbol type="string" name="list_delimeter" />
   <java-symbol type="string" name="menu_delete_shortcut_label" />
   <java-symbol type="string" name="menu_enter_shortcut_label" />
   <java-symbol type="string" name="menu_space_shortcut_label" />
diff --git a/core/tests/coretests/src/android/net/NetworkScorerAppManagerTest.java b/core/tests/coretests/src/android/net/NetworkScorerAppManagerTest.java
index 9bb44d0..605f067 100644
--- a/core/tests/coretests/src/android/net/NetworkScorerAppManagerTest.java
+++ b/core/tests/coretests/src/android/net/NetworkScorerAppManagerTest.java
@@ -57,16 +57,19 @@
 
     public void testGetAllValidScorers() throws Exception {
         // Package 1 - Valid scorer.
-        Pair<ResolveInfo, ResolveInfo> package1 = buildResolveInfo("package1", true, true, false);
+        Pair<ResolveInfo, ResolveInfo> package1 = buildResolveInfo("package1", 1, true, true,
+                false);
 
         // Package 2 - Receiver does not have BROADCAST_NETWORK_PRIVILEGED permission.
-        Pair<ResolveInfo, ResolveInfo> package2 = buildResolveInfo("package2", false, true, false);
+        Pair<ResolveInfo, ResolveInfo> package2 = buildResolveInfo("package2", 2, false, true,
+                false);
 
         // Package 3 - App does not have SCORE_NETWORKS permission.
-        Pair<ResolveInfo, ResolveInfo> package3 = buildResolveInfo("package3", true, false, false);
+        Pair<ResolveInfo, ResolveInfo> package3 = buildResolveInfo("package3", 3, true, false,
+                false);
 
         // Package 4 - Valid scorer w/ optional config activity.
-        Pair<ResolveInfo, ResolveInfo> package4 = buildResolveInfo("package4", true, true, true);
+        Pair<ResolveInfo, ResolveInfo> package4 = buildResolveInfo("package4", 4, true, true, true);
 
         List<Pair<ResolveInfo, ResolveInfo>> scorers = new ArrayList<>();
         scorers.add(package1);
@@ -81,11 +84,13 @@
         assertTrue(result.hasNext());
         NetworkScorerAppData next = result.next();
         assertEquals("package1", next.mPackageName);
+        assertEquals(1, next.mPackageUid);
         assertNull(next.mConfigurationActivityClassName);
 
         assertTrue(result.hasNext());
         next = result.next();
         assertEquals("package4", next.mPackageName);
+        assertEquals(4, next.mPackageUid);
         assertEquals(".ConfigActivity", next.mConfigurationActivityClassName);
 
         assertFalse(result.hasNext());
@@ -122,7 +127,7 @@
                 .thenReturn(receivers);
     }
 
-    private Pair<ResolveInfo, ResolveInfo> buildResolveInfo(String packageName,
+    private Pair<ResolveInfo, ResolveInfo> buildResolveInfo(String packageName, int packageUid,
             boolean hasReceiverPermission, boolean hasScorePermission, boolean hasConfigActivity)
             throws Exception {
         Mockito.when(mMockPm.checkPermission(permission.SCORE_NETWORKS, packageName))
@@ -133,6 +138,7 @@
         resolveInfo.activityInfo = new ActivityInfo();
         resolveInfo.activityInfo.packageName = packageName;
         resolveInfo.activityInfo.applicationInfo = new ApplicationInfo();
+        resolveInfo.activityInfo.applicationInfo.uid = packageUid;
         if (hasReceiverPermission) {
             resolveInfo.activityInfo.permission = permission.BROADCAST_NETWORK_PRIVILEGED;
         }
diff --git a/core/tests/coretests/src/android/text/TextUtilsTest.java b/core/tests/coretests/src/android/text/TextUtilsTest.java
index 5a6ef30..121f02a 100644
--- a/core/tests/coretests/src/android/text/TextUtilsTest.java
+++ b/core/tests/coretests/src/android/text/TextUtilsTest.java
@@ -25,9 +25,11 @@
 import android.text.style.StyleSpan;
 import android.text.util.Rfc822Token;
 import android.text.util.Rfc822Tokenizer;
+import android.view.View;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 
 import junit.framework.TestCase;
 
@@ -519,4 +521,46 @@
             return 0;
         }
     }
+
+    @SmallTest
+    public void testGetLayoutDirectionFromLocale() {
+        assertEquals(View.LAYOUT_DIRECTION_LTR, TextUtils.getLayoutDirectionFromLocale(null));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.ROOT));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("en")));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("en-US")));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("az")));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("az-AZ")));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("az-Latn")));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("en-EG")));
+        assertEquals(View.LAYOUT_DIRECTION_LTR,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("ar-Latn")));
+
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("ar")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("fa")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("he")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("iw")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("ur")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("dv")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("az-Arab")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("az-IR")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("fa-US")));
+        assertEquals(View.LAYOUT_DIRECTION_RTL,
+                TextUtils.getLayoutDirectionFromLocale(Locale.forLanguageTag("tr-Arab")));
+    }
 }
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 579d2df..350310c 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -141,6 +141,6 @@
 
     <!-- These are the standard packages that are white-listed to always have internet
          access while in power save mode, even if they aren't in the foreground. -->
-    <allow-in-power-save package="com.android.providers.downloads" />
+    <allow-in-power-save-except-idle package="com.android.providers.downloads" />
 
 </permissions>
diff --git a/data/fonts/fallback_fonts.xml b/data/fonts/fallback_fonts.xml
deleted file mode 100644
index 55c000c..0000000
--- a/data/fonts/fallback_fonts.xml
+++ /dev/null
@@ -1,467 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-    NOTE: this file is the legacy format, for compatibility with apps. The new,
-    more flexible format is fonts.xml. Please keep the two in sync until the legacy
-    format can be fully removed.
-
-    Fallback Fonts
-
-    This file specifies the fonts, and the priority order, that will be searched for any
-    glyphs not handled by the default fonts specified in /system/etc/system_fonts.xml.
-    Each entry consists of a family tag and a list of files (file names) which support that
-    family. The fonts for each family are listed in the order of the styles that they
-    handle (the order is: regular, bold, italic, and bold-italic). The order in which the
-    families are listed in this file represents the order in which these fallback fonts
-    will be searched for glyphs that are not supported by the default system fonts (which are
-    found in /system/etc/system_fonts.xml).
-
-    Note that there is not nameset for fallback fonts, unlike the fonts specified in
-    system_fonts.xml. The ability to support specific names in fallback fonts may be supported
-    in the future. For now, the lack of files entries here is an indicator to the system that
-    these are fallback fonts, instead of default named system fonts.
-
-    There is another optional file in /vendor/etc/fallback_fonts.xml. That file can be used to
-    provide references to other font families that should be used in addition to the default
-    fallback fonts. That file can also specify the order in which the fallback fonts should be
-    searched, to ensure that a vendor-provided font will be used before another fallback font
-    which happens to handle the same glyph.
-
-    Han languages (Chinese, Japanese, and Korean) share a common range of unicode characters;
-    their ordering in the fallback or vendor files gives priority to the first in the list.
-    Language-specific ordering can be configured by adding a BCP 47-style "lang" attribute to
-    a "file" element; fonts matching the language of text being drawn will be prioritised over
-    all others.
--->
-<familyset>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoNaskhArabic-Regular.ttf</file>
-            <file variant="elegant">NotoNaskhArabic-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoNaskhArabicUI-Regular.ttf</file>
-            <file variant="compact">NotoNaskhArabicUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansEthiopic-Regular.ttf</file>
-            <file>NotoSansEthiopic-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansHebrew-Regular.ttf</file>
-            <file>NotoSansHebrew-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansThai-Regular.ttf</file>
-            <file variant="elegant">NotoSansThai-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansThaiUI-Regular.ttf</file>
-            <file variant="compact">NotoSansThaiUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansArmenian-Regular.ttf</file>
-            <file>NotoSansArmenian-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansGeorgian-Regular.ttf</file>
-            <file>NotoSansGeorgian-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansDevanagari-Regular.ttf</file>
-            <file variant="elegant">NotoSansDevanagari-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansDevanagariUI-Regular.ttf</file>
-            <file variant="compact">NotoSansDevanagariUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <!-- Gujarati should come after Devanagari -->
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansGujarati-Regular.ttf</file>
-            <file variant="elegant">NotoSansGujarati-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansGujaratiUI-Regular.ttf</file>
-            <file variant="compact">NotoSansGujaratiUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <!-- Gurmukhi should come after Devanagari -->
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansGurmukhi-Regular.ttf</file>
-            <file variant="elegant">NotoSansGurmukhi-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansGurmukhiUI-Regular.ttf</file>
-            <file variant="compact">NotoSansGurmukhiUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansTamil-Regular.ttf</file>
-            <file variant="elegant">NotoSansTamil-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansTamilUI-Regular.ttf</file>
-            <file variant="compact">NotoSansTamilUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansMalayalam-Regular.ttf</file>
-            <file variant="elegant">NotoSansMalayalam-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansMalayalamUI-Regular.ttf</file>
-            <file variant="compact">NotoSansMalayalamUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansBengali-Regular.ttf</file>
-            <file variant="elegant">NotoSansBengali-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansBengaliUI-Regular.ttf</file>
-            <file variant="compact">NotoSansBengaliUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansTelugu-Regular.ttf</file>
-            <file variant="elegant">NotoSansTelugu-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansTeluguUI-Regular.ttf</file>
-            <file variant="compact">NotoSansTeluguUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansKannada-Regular.ttf</file>
-            <file variant="elegant">NotoSansKannada-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansKannadaUI-Regular.ttf</file>
-            <file variant="compact">NotoSansKannadaUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansOriya-Regular.ttf</file>
-            <file variant="elegant">NotoSansOriya-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansOriyaUI-Regular.ttf</file>
-            <file variant="compact">NotoSansOriyaUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansSinhala-Regular.ttf</file>
-            <file>NotoSansSinhala-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansKhmer-Regular.ttf</file>
-            <file variant="elegant">NotoSansKhmer-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansKhmerUI-Regular.ttf</file>
-            <file variant="compact">NotoSansKhmerUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansLao-Regular.ttf</file>
-            <file variant="elegant">NotoSansLao-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansLaoUI-Regular.ttf</file>
-            <file variant="compact">NotoSansLaoUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="elegant">NotoSansMyanmar-Regular.ttf</file>
-            <file variant="elegant">NotoSansMyanmar-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file variant="compact">NotoSansMyanmarUI-Regular.ttf</file>
-            <file variant="compact">NotoSansMyanmarUI-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansThaana-Regular.ttf</file>
-            <file>NotoSansThaana-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansCham-Regular.ttf</file>
-            <file>NotoSansCham-Bold.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansBalinese-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansBamum-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansBatak-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansBuginese-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansBuhid-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansCanadianAboriginal-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansCherokee-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansCoptic-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansGlagolitic-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansHanunoo-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansJavanese-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansKayahLi-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansLepcha-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansLimbu-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansLisu-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansMandaic-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansMeeteiMayek-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansNewTaiLue-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansNKo-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansOlChiki-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansRejang-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansSaurashtra-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansSundanese-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansSylotiNagri-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansSyriacEstrangela-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansTagbanwa-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansTaiTham-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansTaiViet-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansTibetan-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansTifinagh-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansVai-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansYi-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansSymbols-Regular-Subsetted.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file lang="zh-Hans">NotoSansSC-Regular.otf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file lang="zh-Hant">NotoSansTC-Regular.otf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file lang="ja">NotoSansJP-Regular.otf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file lang="ko">NotoSansKR-Regular.otf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NanumGothic.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoColorEmoji.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>DroidSansFallback.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file lang="ja">MTLmr3m.ttf</file>
-        </fileset>
-    </family>
-    <!--
-        Tai Le and Mongolian are intentionally kept last, to make sure they don't override
-        the East Asian punctuation for Chinese.
-    -->
-    <family>
-        <fileset>
-            <file>NotoSansTaiLe-Regular.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>NotoSansMongolian-Regular.ttf</file>
-        </fileset>
-    </family>
-</familyset>
diff --git a/data/fonts/fonts.mk b/data/fonts/fonts.mk
index a5939fa..597a122 100644
--- a/data/fonts/fonts.mk
+++ b/data/fonts/fonts.mk
@@ -15,8 +15,6 @@
 # Warning: this is actually a product definition, to be inherited from
 
 PRODUCT_COPY_FILES := \
-    frameworks/base/data/fonts/system_fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/system_fonts.xml \
-    frameworks/base/data/fonts/fallback_fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/fallback_fonts.xml \
     frameworks/base/data/fonts/fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/fonts.xml
 
 PRODUCT_PACKAGES := \
diff --git a/data/fonts/fonts.xml b/data/fonts/fonts.xml
index dbe81fa..1b97b65 100644
--- a/data/fonts/fonts.xml
+++ b/data/fonts/fonts.xml
@@ -1,11 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    NOTE: this is the newer (L) version of the system font configuration,
-    supporting richer weight selection. Some apps will expect the older
-    version, so please keep system_fonts.xml and fallback_fonts.xml in sync
-    with any changes, even though framework will only read this file.
-
-    All fonts withohut names are added to the default list. Fonts are chosen
+    All fonts without names are added to the default list. Fonts are chosen
     based on a match: full BCP-47 language tag including script, then just
     language, and finally order (the first font containing the glyph).
 
diff --git a/data/fonts/system_fonts.xml b/data/fonts/system_fonts.xml
deleted file mode 100644
index 2a48faa..0000000
--- a/data/fonts/system_fonts.xml
+++ /dev/null
@@ -1,179 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-    System Fonts
-
-    This file lists the font families that will be used by default for all supported glyphs.
-    Each entry consists of a family, various names that are supported by that family, and
-    up to four font files. The font files are listed in the order of the styles which they
-    support: regular, bold, italic and bold-italic. If less than four styles are listed, then
-    the styles with no associated font file will be supported by the other font files listed.
-
-    The first family is also the default font, which handles font request that have not specified
-    specific font names.
-
-    Any glyph that is not handled by the system fonts will cause a search of the fallback fonts.
-    The default fallback fonts are specified in the file /system/etc/fallback_fonts.xml, and there
-    is an optional file which may be supplied by vendors to specify other fallback fonts to use
-    in /vendor/etc/fallback_fonts.xml.
--->
-<familyset>
-
-    <family>
-        <nameset>
-            <name>sans-serif</name>
-            <name>arial</name>
-            <name>helvetica</name>
-            <name>tahoma</name>
-            <name>verdana</name>
-        </nameset>
-        <fileset>
-            <file>Roboto-Regular.ttf</file>
-            <file>Roboto-Bold.ttf</file>
-            <file>Roboto-Italic.ttf</file>
-            <file>Roboto-BoldItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>sans-serif-light</name>
-        </nameset>
-        <fileset>
-            <file>Roboto-Light.ttf</file>
-            <file>Roboto-LightItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>sans-serif-thin</name>
-        </nameset>
-        <fileset>
-            <file>Roboto-Thin.ttf</file>
-            <file>Roboto-ThinItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>sans-serif-condensed</name>
-        </nameset>
-        <fileset>
-            <file>RobotoCondensed-Regular.ttf</file>
-            <file>RobotoCondensed-Bold.ttf</file>
-            <file>RobotoCondensed-Italic.ttf</file>
-            <file>RobotoCondensed-BoldItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>sans-serif-medium</name>
-        </nameset>
-        <fileset>
-            <file>Roboto-Medium.ttf</file>
-            <file>Roboto-MediumItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>sans-serif-black</name>
-        </nameset>
-        <fileset>
-            <file>Roboto-Black.ttf</file>
-            <file>Roboto-BlackItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>sans-serif-condensed-light</name>
-        </nameset>
-        <fileset>
-            <file>RobotoCondensed-Light.ttf</file>
-            <file>RobotoCondensed-LightItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>serif</name>
-            <name>times</name>
-            <name>times new roman</name>
-            <name>palatino</name>
-            <name>georgia</name>
-            <name>baskerville</name>
-            <name>goudy</name>
-            <name>fantasy</name>
-            <name>ITC Stone Serif</name>
-        </nameset>
-        <fileset>
-            <file>NotoSerif-Regular.ttf</file>
-            <file>NotoSerif-Bold.ttf</file>
-            <file>NotoSerif-Italic.ttf</file>
-            <file>NotoSerif-BoldItalic.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>Droid Sans</name>
-        </nameset>
-        <fileset>
-            <file>DroidSans.ttf</file>
-            <file>DroidSans-Bold.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>monospace</name>
-            <name>sans-serif-monospace</name>
-            <name>monaco</name>
-        </nameset>
-        <fileset>
-            <file>DroidSansMono.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>serif-monospace</name>
-            <name>courier</name>
-            <name>courier new</name>
-        </nameset>
-        <fileset>
-            <file>CutiveMono.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>casual</name>
-        </nameset>
-        <fileset>
-            <file>ComingSoon.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>cursive</name>
-        </nameset>
-        <fileset>
-            <file>DancingScript-Regular.ttf</file>
-            <file>DancingScript-Bold.ttf</file>
-        </fileset>
-    </family>
-
-    <family>
-        <nameset>
-            <name>sans-serif-smallcaps</name>
-        </nameset>
-        <fileset>
-            <file>CarroisGothicSC-Regular.ttf</file>
-        </fileset>
-    </family>
-
-</familyset>
diff --git a/data/fonts/vendor_fonts.xml b/data/fonts/vendor_fonts.xml
deleted file mode 100644
index 8690ee1..0000000
--- a/data/fonts/vendor_fonts.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-    Vendor-provided fallback fonts
-
-    This file can be edited to add references to fonts that are not installed or referenced in the
-    default system. The file should then be placed in /vendor/etc/fallback_fonts.xml. Note
-    that in your makefile, this directory should be referenced as $(TARGET_COPY_OUT_VENDOR)/etc/:
-
-        PRODUCT_COPY_FILES += \
-            frameworks/base/data/fonts/vendor_fonts.xml:$(TARGET_COPY_OUT_VENDOR)/etc/fallback_fonts.xml
-
-    For example, vendors might want to build configurations for locales that are
-    better served by fonts which either handle glyphs not supported in the default fonts or which
-    handle these glyphs differently than the default fallback fonts.
-    Each entry in this list is a "family", which consists of a list of "files"
-    (the filenames for that family). The files objects are
-    provided in the order of the styles supported for that family: regular, bold, italic, and
-    bold-italic. Only providing one font means that all styles will be rendered with that font.
-    Providing two means that these two fonts will render regular and bold fonts (italics will
-    be mapped to these two fonts).
-
-    There is also an optional "order" attribute on the Family tag. This specifies the index at
-    which that family of fonts should be inserted in the fallback font list, where the
-    default fallback fonts on the system (in /system/etc/fallback_fonts.xml) start at index 0.
-    If no 'order' attribute is supplied, that family will be inserted either at the end of the
-    current fallback list (if no order was supplied for any previous family in this file) or
-    after the previous family (if there was an order specified previously). Typically, vendors
-    may want to supply an order for the first family that puts this set of fonts at the appropriate
-    place in the overall fallback fonts. The order of this list determines which fallback font
-    will be used to support any glyphs that are not handled by the default system fonts.
-
-    Han languages (Chinese, Japanese, and Korean) share a common range of unicode characters;
-    their ordering in the fallback or vendor files gives priority to the first in the list.
-    Language-specific ordering can be configured by adding a BCP 47-style "lang" attribute to
-    a "file" element; fonts matching the language of text being drawn will be prioritised over
-    all others.
-
-    The sample configuration below is an example of how one might provide two families of fonts
-    that get inserted at the first and second (0  and 1) position in the overall fallback fonts.
-
-    See /system/etc/system_fonts.xml and /system/etc/fallback_fonts.xml for more information
-    and to understand the order in which the default system fonts are loaded and structured for
-    lookup.
--->
-
-<!-- Sample fallback font additions to the default fallback list. These fonts will be added
-    to the top two positions of the fallback list, since the first has an order of 0. -->
-<!--
-<familyset>
-    <family order="0">
-        <fileset>
-            <file>MyFont.ttf</file>
-        </fileset>
-    </family>
-    <family>
-        <fileset>
-            <file>MyOtherFont.ttf</file>
-        </fileset>
-    </family>
-</familyset>
---->
diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h
index 5130e6c..eff1f5f 100644
--- a/include/androidfw/ResourceTypes.h
+++ b/include/androidfw/ResourceTypes.h
@@ -1819,7 +1819,8 @@
     const DynamicRefTable* getDynamicRefTableForCookie(int32_t cookie) const;
 
     // Return the configurations (ResTable_config) that we know about
-    void getConfigurations(Vector<ResTable_config>* configs, bool ignoreMipmap=false) const;
+    void getConfigurations(Vector<ResTable_config>* configs, bool ignoreMipmap=false,
+            bool ignoreAndroidPackage=false) const;
 
     void getLocales(Vector<String8>* locales) const;
 
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 4f9af7f..9e04964 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -5660,11 +5660,15 @@
     return NULL;
 }
 
-void ResTable::getConfigurations(Vector<ResTable_config>* configs, bool ignoreMipmap) const
-{
+void ResTable::getConfigurations(Vector<ResTable_config>* configs, bool ignoreMipmap,
+        bool ignoreAndroidPackage) const {
     const size_t packageCount = mPackageGroups.size();
+    String16 android("android");
     for (size_t i = 0; i < packageCount; i++) {
         const PackageGroup* packageGroup = mPackageGroups[i];
+        if (ignoreAndroidPackage && android == packageGroup->name) {
+            continue;
+        }
         const size_t typeCount = packageGroup->types.size();
         for (size_t j = 0; j < typeCount; j++) {
             const TypeList& typeList = packageGroup->types[j];
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 77079b7..b2d1fec 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -26,6 +26,8 @@
 #include <SkTArray.h>
 #include <SkTemplates.h>
 
+#include <memory>
+
 namespace android {
 
 // Holds an SkCanvas reference plus additional native data.
@@ -151,7 +153,7 @@
     void drawTextDecorations(float x, float y, float length, const SkPaint& paint);
 
     SkAutoTUnref<SkCanvas> mCanvas;
-    SkAutoTDelete<SkDeque> mSaveStack; // lazily allocated, tracks partial saves.
+    std::unique_ptr<SkDeque> mSaveStack; // lazily allocated, tracks partial saves.
 };
 
 Canvas* Canvas::create_canvas(const SkBitmap& bitmap) {
diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java
index fef65ee..7f22b8a 100644
--- a/media/java/android/media/AudioDeviceInfo.java
+++ b/media/java/android/media/AudioDeviceInfo.java
@@ -111,14 +111,6 @@
      * A device type connected over IP.
      */
     public static final int TYPE_IP               = 20;
-    /**
-     * @hide
-     * A remote-submix device.
-     * We need this for CTS, but it is not part of the external API.
-     * FIXME It has been suggested that CTS should only be testing public APIs.
-     *   Consider this for a public API.
-     */
-    public static final int TYPE_REMOTE_SUBMIX    = 0x7FFF;
 
     private final AudioDevicePort mPort;
 
@@ -286,7 +278,6 @@
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_FM, TYPE_FM);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_AUX_LINE, TYPE_AUX_LINE);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_IP, TYPE_IP);
-        INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX);
 
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUILTIN_MIC, TYPE_BUILTIN_MIC);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET, TYPE_BLUETOOTH_SCO);
@@ -304,7 +295,10 @@
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_SPDIF, TYPE_LINE_DIGITAL);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, TYPE_BLUETOOTH_A2DP);
         INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_IP, TYPE_IP);
-        INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX);
+
+        // not covered here, legacy
+        //AudioSystem.DEVICE_OUT_REMOTE_SUBMIX
+        //AudioSystem.DEVICE_IN_REMOTE_SUBMIX
 
         // privileges mapping to output device
         EXT_TO_INT_DEVICE_MAPPING = new SparseIntArray();
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 5290cac..875e716 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -3757,6 +3757,12 @@
                port.role() == AudioPort.ROLE_SOURCE && (flags & GET_DEVICES_INPUTS) != 0;
     }
 
+    private static boolean checkTypes(AudioDevicePort port) {
+        return AudioDeviceInfo.convertInternalDeviceToDeviceType(port.type()) !=
+                    AudioDeviceInfo.TYPE_UNKNOWN &&
+                port.type() != AudioSystem.DEVICE_IN_BACK_MIC;
+    }
+
     /**
      * Returns an array of {@link AudioDeviceInfo} objects corresponding to the audio devices
      * currently connected to the system and meeting the criteria specified in the
@@ -3779,7 +3785,7 @@
         // figure out how many AudioDeviceInfo we need space for...
         int numRecs = 0;
         for (AudioDevicePort port : ports) {
-            if (checkFlags(port, flags)) {
+            if (checkTypes(port) && checkFlags(port, flags)) {
                 numRecs++;
             }
         }
@@ -3788,7 +3794,7 @@
         AudioDeviceInfo[] deviceList = new AudioDeviceInfo[numRecs];
         int slot = 0;
         for (AudioDevicePort port : ports) {
-            if (checkFlags(port, flags)) {
+            if (checkTypes(port) && checkFlags(port, flags)) {
                 deviceList[slot++] = new AudioDeviceInfo(port);
             }
         }
diff --git a/packages/DocumentsUI/res/values-fa/strings.xml b/packages/DocumentsUI/res/values-fa/strings.xml
index 23c75f5..a857ee7 100644
--- a/packages/DocumentsUI/res/values-fa/strings.xml
+++ b/packages/DocumentsUI/res/values-fa/strings.xml
@@ -88,8 +88,8 @@
     <string name="copy_failure_alert_content" msgid="3715575000297709082">"این فایل‌ها کپی نشدند: <xliff:g id="LIST">%1$s</xliff:g>"</string>
     <string name="move_failure_alert_content" msgid="7151140279020481180">"این فایل‌ها منتقل نشدند: <xliff:g id="LIST">%1$s</xliff:g>"</string>
     <plurals name="clipboard_files_clipped" formatted="false" msgid="855459017537058539">
-      <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> فایل در کلیپ‌بورد کپی شد.</item>
-      <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> فایل در کلیپ‌بورد کپی شد.</item>
+      <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> فایل در بریده‌دان کپی شد.</item>
+      <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> فایل در بریده‌دان کپی شد.</item>
     </plurals>
     <string name="clipboard_files_cannot_paste" msgid="2878324825602325706">"نمی‌توان فایل‌های انتخابی را در این مکان جای‌گذاری کرد."</string>
 </resources>
diff --git a/packages/Keyguard/res/values-ro/strings.xml b/packages/Keyguard/res/values-ro/strings.xml
index d4bb025..efa81fa 100644
--- a/packages/Keyguard/res/values-ro/strings.xml
+++ b/packages/Keyguard/res/values-ro/strings.xml
@@ -61,7 +61,7 @@
     <string name="kg_wrong_pattern" msgid="1850806070801358830">"Model greşit"</string>
     <string name="kg_wrong_password" msgid="2333281762128113157">"Parolă greşită"</string>
     <string name="kg_wrong_pin" msgid="1131306510833563801">"Cod PIN greşit"</string>
-    <string name="kg_too_many_failed_attempts_countdown" msgid="6358110221603297548">"Încercaţi din nou peste <xliff:g id="NUMBER">%d</xliff:g> (de) secunde."</string>
+    <string name="kg_too_many_failed_attempts_countdown" msgid="6358110221603297548">"Încercați din nou peste <xliff:g id="NUMBER">%d</xliff:g> (de) secunde."</string>
     <string name="kg_pattern_instructions" msgid="398978611683075868">"Desenaţi modelul"</string>
     <string name="kg_sim_pin_instructions" msgid="2319508550934557331">"Introduceţi codul PIN al cardului SIM"</string>
     <string name="kg_sim_pin_instructions_multi" msgid="7818515973197201434">"Introduceți codul PIN al cardului SIM pentru „<xliff:g id="CARRIER">%1$s</xliff:g>”"</string>
@@ -77,9 +77,9 @@
     <string name="kg_invalid_puk" msgid="3638289409676051243">"Reintroduceţi codul PUK corect. Încercările repetate vor dezactiva definitiv cardul SIM."</string>
     <string name="kg_invalid_confirm_pin_hint" product="default" msgid="7003469261464593516">"Codurile PIN nu coincid"</string>
     <string name="kg_login_too_many_attempts" msgid="6486842094005698475">"Prea multe încercări de desenare a modelului"</string>
-    <string name="kg_too_many_failed_pin_attempts_dialog_message" msgid="8276745642049502550">"Aţi introdus incorect codul PIN de <xliff:g id="NUMBER_0">%d</xliff:g> ori.\n\nÎncercaţi din nou peste <xliff:g id="NUMBER_1">%d</xliff:g> (de) secunde."</string>
-    <string name="kg_too_many_failed_password_attempts_dialog_message" msgid="7813713389422226531">"Aţi introdus incorect parola de <xliff:g id="NUMBER_0">%d</xliff:g> ori. \n\nÎncercaţi din nou peste <xliff:g id="NUMBER_1">%d</xliff:g> (de) secunde."</string>
-    <string name="kg_too_many_failed_pattern_attempts_dialog_message" msgid="74089475965050805">"Aţi desenat incorect modelul pentru deblocare de <xliff:g id="NUMBER_0">%d</xliff:g> ori. \n\nÎncercaţi din nou peste <xliff:g id="NUMBER_1">%d</xliff:g> (de) secunde."</string>
+    <string name="kg_too_many_failed_pin_attempts_dialog_message" msgid="8276745642049502550">"Aţi introdus incorect codul PIN de <xliff:g id="NUMBER_0">%d</xliff:g> ori.\n\nÎncercați din nou peste <xliff:g id="NUMBER_1">%d</xliff:g> (de) secunde."</string>
+    <string name="kg_too_many_failed_password_attempts_dialog_message" msgid="7813713389422226531">"Aţi introdus incorect parola de <xliff:g id="NUMBER_0">%d</xliff:g> ori. \n\nÎncercați din nou peste <xliff:g id="NUMBER_1">%d</xliff:g> (de) secunde."</string>
+    <string name="kg_too_many_failed_pattern_attempts_dialog_message" msgid="74089475965050805">"Aţi desenat incorect modelul pentru deblocare de <xliff:g id="NUMBER_0">%d</xliff:g> ori. \n\nÎncercați din nou peste <xliff:g id="NUMBER_1">%d</xliff:g> (de) secunde."</string>
     <string name="kg_failed_attempts_almost_at_wipe" product="tablet" msgid="8774056606869646621">"Ați efectuat <xliff:g id="NUMBER_0">%d</xliff:g> încercări incorecte de deblocare a tabletei. După încă <xliff:g id="NUMBER_1">%d</xliff:g> încercări nereușite, această tabletă va fi resetată, iar toate datele acesteia vor fi șterse."</string>
     <string name="kg_failed_attempts_almost_at_wipe" product="default" msgid="1843331751334128428">"Ați efectuat <xliff:g id="NUMBER_0">%d</xliff:g> încercări incorecte de deblocare a telefonului. După încă <xliff:g id="NUMBER_1">%d</xliff:g> încercări nereușite, acest telefon va fi resetat, iar toate datele acestuia vor fi șterse."</string>
     <string name="kg_failed_attempts_now_wiping" product="tablet" msgid="258925501999698032">"Ați efectuat <xliff:g id="NUMBER">%d</xliff:g> încercări incorecte de deblocare a tabletei. Această tabletă va fi resetată, iar toate datele acesteia vor fi șterse."</string>
@@ -92,8 +92,8 @@
     <string name="kg_failed_attempts_almost_at_erase_profile" product="default" msgid="6853071165802933545">"Ați efectuat <xliff:g id="NUMBER_0">%d</xliff:g> încercări incorecte de deblocare a telefonului. După încă <xliff:g id="NUMBER_1">%d</xliff:g> încercări nereușite, profilul de serviciu va fi eliminat, iar toate datele profilului vor fi șterse."</string>
     <string name="kg_failed_attempts_now_erasing_profile" product="tablet" msgid="4686386497449912146">"Ați efectuat <xliff:g id="NUMBER">%d</xliff:g> încercări incorecte de deblocare a tabletei. Profilul de serviciu va fi eliminat, iar toate datele profilului vor fi șterse."</string>
     <string name="kg_failed_attempts_now_erasing_profile" product="default" msgid="4951507352869831265">"Ați efectuat <xliff:g id="NUMBER">%d</xliff:g> încercări incorecte de deblocare a telefonului. Profilul de serviciu va fi eliminat, iar toate datele profilului vor fi șterse."</string>
-    <string name="kg_failed_attempts_almost_at_login" product="tablet" msgid="3253575572118914370">"Aţi desenat incorect modelul pentru deblocare de <xliff:g id="NUMBER_0">%d</xliff:g> ori. După încă <xliff:g id="NUMBER_1">%d</xliff:g> încercări nereuşite, vi se va solicita să deblocaţi tableta cu ajutorul unui cont de e-mail.\n\n Încercaţi din nou peste <xliff:g id="NUMBER_2">%d</xliff:g> (de) secunde."</string>
-    <string name="kg_failed_attempts_almost_at_login" product="default" msgid="1437638152015574839">"Aţi desenat incorect modelul pentru deblocare de <xliff:g id="NUMBER_0">%d</xliff:g> ori. După încă <xliff:g id="NUMBER_1">%d</xliff:g> încercări nereuşite, vi se va solicita să deblocaţi telefonul cu ajutorul unui cont de e-mail.\n\n Încercaţi din nou peste <xliff:g id="NUMBER_2">%d</xliff:g> (de) secunde."</string>
+    <string name="kg_failed_attempts_almost_at_login" product="tablet" msgid="3253575572118914370">"Aţi desenat incorect modelul pentru deblocare de <xliff:g id="NUMBER_0">%d</xliff:g> ori. După încă <xliff:g id="NUMBER_1">%d</xliff:g> încercări nereuşite, vi se va solicita să deblocaţi tableta cu ajutorul unui cont de e-mail.\n\n Încercați din nou peste <xliff:g id="NUMBER_2">%d</xliff:g> (de) secunde."</string>
+    <string name="kg_failed_attempts_almost_at_login" product="default" msgid="1437638152015574839">"Aţi desenat incorect modelul pentru deblocare de <xliff:g id="NUMBER_0">%d</xliff:g> ori. După încă <xliff:g id="NUMBER_1">%d</xliff:g> încercări nereuşite, vi se va solicita să deblocaţi telefonul cu ajutorul unui cont de e-mail.\n\n Încercați din nou peste <xliff:g id="NUMBER_2">%d</xliff:g> (de) secunde."</string>
     <string name="kg_password_wrong_pin_code_pukked" msgid="30531039455764924">"Codul PIN pentru cardul SIM este incorect. Contactați operatorul pentru a vă debloca dispozitivul."</string>
     <plurals name="kg_password_wrong_pin_code" formatted="false" msgid="6721575017538162249">
       <item quantity="few">Codul PIN pentru cardul SIM este incorect. V-au mai rămas <xliff:g id="NUMBER_1">%d</xliff:g> încercări.</item>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index d99f741..e74334b 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -447,8 +447,10 @@
                     Settings.Global.putInt(cr,
                             Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0);
                 }
-                // !!! Give the wifi stack a moment to quiesce
-                try { Thread.sleep(1500); } catch (InterruptedException e) {}
+                // !!! Give the wifi stack a moment to quiesce.  We've observed the
+                // response to disabling WIFI_SCAN_ALWAYS_AVAILABLE taking more
+                // than 1500ms, so we wait a generous 2500 here before proceeding.
+                try { Thread.sleep(2500); } catch (InterruptedException e) {}
                 if (restoredSupplicantData != null) {
                     restoreWifiSupplicant(FILE_WIFI_SUPPLICANT,
                             restoredSupplicantData, restoredSupplicantData.length);
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png
index d2760bb..aa9f6d4 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime.png
index 5cbf418..151caea 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_home.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_home.png
index df43e21..613afce 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_home.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_home.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_recent.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_recent.png
index 6fab1d6..eb80426 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_recent.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_recent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png
index 1d8c3af..34a11df 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime.png
index 47c6ebd..1c1e78c 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home.png
index 66de0ec..7c25fc5 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent.png
index 30c65f5..1ee9cf5 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png
index a356285..987aac5 100644
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime.png
index 42893ff..433e5a74 100644
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime.png
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_home.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_home.png
index ba2d0b2..0e2a14d 100644
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_home.png
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_home.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_recent.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_recent.png
index 94a74b1..f810704 100644
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_recent.png
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_recent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back.png
index 29da099..be03cbe 100644
--- a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back.png
+++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_ime.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_ime.png
index ada2879..b6b1615 100644
--- a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_ime.png
+++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_ime.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_home.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_home.png
index 59b32f2..f16aa48 100644
--- a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_home.png
+++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_home.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_recent.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_recent.png
index ba66d27..109aeed 100644
--- a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_recent.png
+++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_recent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back.png
new file mode 100644
index 0000000..a059704
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_ime.png b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_ime.png
new file mode 100644
index 0000000..8f00a64
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_ime.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_home.png b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_home.png
new file mode 100644
index 0000000..194d39f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_home.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_recent.png b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_recent.png
new file mode 100644
index 0000000..046d850
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_recent.png
Binary files differ
diff --git a/packages/SystemUI/res/values-fa/strings.xml b/packages/SystemUI/res/values-fa/strings.xml
index ad063c6..d4a1fa2 100644
--- a/packages/SystemUI/res/values-fa/strings.xml
+++ b/packages/SystemUI/res/values-fa/strings.xml
@@ -65,7 +65,7 @@
     <string name="usb_debugging_always" msgid="303335496705863070">"همیشه از این رایانه انجام شود"</string>
     <string name="usb_debugging_secondary_user_title" msgid="6353808721761220421">"‏اشکال‌زدایی USB مجاز نیست"</string>
     <string name="usb_debugging_secondary_user_message" msgid="8572228137833020196">"‏کاربری که درحال‌حاضر در این دستگاه وارد سیستم شده نمی‌تواند اشکال‌زدای USB را روشن کند. برای استفاده از این ویژگی، لطفاً به کاربر «سرپرست» تغییر حالت دهید."</string>
-    <string name="compat_mode_on" msgid="6623839244840638213">"بزرگنمایی برای پر کردن صفحه"</string>
+    <string name="compat_mode_on" msgid="6623839244840638213">"بزرگ‌نمایی برای پر کردن صفحه"</string>
     <string name="compat_mode_off" msgid="4434467572461327898">"گسترده کردن برای پر کردن صفحه"</string>
     <string name="screenshot_saving_ticker" msgid="7403652894056693515">"در حال ذخیره تصویر صفحه..."</string>
     <string name="screenshot_saving_title" msgid="8242282144535555697">"در حال ذخیره تصویر صفحه..."</string>
@@ -95,8 +95,8 @@
     <string name="camera_label" msgid="7261107956054836961">"باز کردن دوربین"</string>
     <string name="recents_caption_resize" msgid="3517056471774958200">"انتخاب طرح‌بندی جدید کار"</string>
     <string name="cancel" msgid="6442560571259935130">"لغو"</string>
-    <string name="accessibility_compatibility_zoom_button" msgid="8461115318742350699">"دکمه بزرگنمایی سازگار."</string>
-    <string name="accessibility_compatibility_zoom_example" msgid="4220687294564945780">"بزرگنمایی از صفحه‌های کوچک تا بزرگ."</string>
+    <string name="accessibility_compatibility_zoom_button" msgid="8461115318742350699">"دکمه بزرگ‌نمایی سازگار."</string>
+    <string name="accessibility_compatibility_zoom_example" msgid="4220687294564945780">"بزرگ‌نمایی از صفحه‌های کوچک تا بزرگ."</string>
     <string name="accessibility_bluetooth_connected" msgid="2707027633242983370">"بلوتوث متصل است."</string>
     <string name="accessibility_bluetooth_disconnected" msgid="7416648669976870175">"بلوتوث قطع شده است."</string>
     <string name="accessibility_no_battery" msgid="358343022352820946">"باتری موجود نیست."</string>
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index ae6ce53..e44d109 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -841,11 +841,6 @@
         synchronized (this) {
             if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")");
 
-            if (isSecure()) {
-                Log.d(TAG, "current mode is SecurityMode, ignore hide keyguard");
-                return;
-            }
-
             mExternallyEnabled = enabled;
 
             if (!enabled && mShowing) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index ed1dca3..b65bf43 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -88,8 +88,10 @@
 
         mapIconSets();
 
-        mLastState.networkName = mCurrentState.networkName = mNetworkNameDefault;
-        mLastState.networkNameData = mCurrentState.networkNameData = mNetworkNameDefault;
+        String networkName = info.getCarrierName() != null ? info.getCarrierName().toString()
+                : mNetworkNameDefault;
+        mLastState.networkName = mCurrentState.networkName = networkName;
+        mLastState.networkNameData = mCurrentState.networkNameData = networkName;
         mLastState.enabled = mCurrentState.enabled = hasMobileData;
         mLastState.iconGroup = mCurrentState.iconGroup = mDefaultIcons;
         // Get initial data sim state.
diff --git a/preloaded-classes b/preloaded-classes
index 4d7a6e1..d6b4ec9 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -742,7 +742,6 @@
 android.ddm.DdmHandleThread
 android.ddm.DdmHandleViewDebug
 android.ddm.DdmRegister
-android.emoji.EmojiFactory
 android.graphics.AvoidXfermode
 android.graphics.Bitmap
 android.graphics.Bitmap$1
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index 45c020c..56ebed6 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -1245,6 +1245,7 @@
                     return;
                 }
                 boolean success = false;
+                mUidStates.clear();
                 try {
                     XmlPullParser parser = Xml.newPullParser();
                     parser.setInput(stream, StandardCharsets.UTF_8.name());
@@ -1448,7 +1449,7 @@
                 XmlSerializer out = new FastXmlSerializer();
                 out.setOutput(stream, StandardCharsets.UTF_8.name());
                 out.startDocument(null, true);
-                out.startTag(null, "app");
+                out.startTag(null, "app-ops");
 
                 final int uidStateCount = mUidStates.size();
                 for (int i = 0; i < uidStateCount; i++) {
@@ -1541,6 +1542,17 @@
         }
     }
 
+    private void dumpHelp(PrintWriter pw) {
+        pw.println("AppOps service (appops) dump options:");
+        pw.println("  [-h] [CMD]");
+        pw.println("  -h: print this help text.");
+        pw.println("Commands:");
+        pw.println("  write-settings");
+        pw.println("    Immediately write pending changes to storage.");
+        pw.println("  read-settings");
+        pw.println("    Read the last written settings, replacing current state in RAM.");
+    }
+
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -1551,6 +1563,43 @@
             return;
         }
 
+        if (args != null) {
+            for (int i=0; i<args.length; i++) {
+                String arg = args[i];
+                if ("-h".equals(arg)) {
+                    dumpHelp(pw);
+                    return;
+                } else if ("write-settings".equals(arg)) {
+                    long token = Binder.clearCallingIdentity();
+                    try {
+                        synchronized (this) {
+                            mHandler.removeCallbacks(mWriteRunner);
+                        }
+                        writeState();
+                        pw.println("Current settings written.");
+                    } finally {
+                        Binder.restoreCallingIdentity(token);
+                    }
+                    return;
+                } else if ("read-settings".equals(arg)) {
+                    long token = Binder.clearCallingIdentity();
+                    try {
+                        readState();
+                        pw.println("Last settings read.");
+                    } finally {
+                        Binder.restoreCallingIdentity(token);
+                    }
+                    return;
+                } else if (arg.length() > 0 && arg.charAt(0) == '-'){
+                    pw.println("Unknown option: " + arg);
+                    return;
+                } else {
+                    pw.println("Unknown command: " + arg);
+                    return;
+                }
+            }
+        }
+
         synchronized (this) {
             pw.println("Current AppOps Service state:");
             final long now = System.currentTimeMillis();
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 028460c..921e71e 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -1440,9 +1440,10 @@
     }
 
     private void enforceChangePermission() {
-        mContext.enforceCallingOrSelfPermission(
-                android.Manifest.permission.CHANGE_NETWORK_STATE,
-                "ConnectivityService");
+        int uid = Binder.getCallingUid();
+        Settings.checkAndNoteChangeNetworkStateOperation(mContext, uid, Settings
+                .getPackageNameForUid(mContext, uid), true);
+
     }
 
     private void enforceTetherAccessPermission() {
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index 7561c7d..e678bbc 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -113,6 +113,7 @@
     private Display mCurDisplay;
     private AnyMotionDetector mAnyMotionDetector;
     private boolean mEnabled;
+    private boolean mForceIdle;
     private boolean mScreenOn;
     private boolean mCharging;
     private boolean mSigMotionActive;
@@ -151,7 +152,14 @@
     public final AtomicFile mConfigFile;
 
     /**
-     * Package names the system has white-listed to opt out of power save restrictions.
+     * Package names the system has white-listed to opt out of power save restrictions,
+     * except for device idle mode.
+     */
+    private final ArrayMap<String, Integer> mPowerSaveWhitelistAppsExceptIdle = new ArrayMap<>();
+
+    /**
+     * Package names the system has white-listed to opt out of power save restrictions for
+     * all modes.
      */
     private final ArrayMap<String, Integer> mPowerSaveWhitelistApps = new ArrayMap<>();
 
@@ -161,11 +169,30 @@
     private final ArrayMap<String, Integer> mPowerSaveWhitelistUserApps = new ArrayMap<>();
 
     /**
+     * App IDs of built-in system apps that have been white-listed except for idle modes.
+     */
+    private final SparseBooleanArray mPowerSaveWhitelistSystemAppIdsExceptIdle
+            = new SparseBooleanArray();
+
+    /**
      * App IDs of built-in system apps that have been white-listed.
      */
     private final SparseBooleanArray mPowerSaveWhitelistSystemAppIds = new SparseBooleanArray();
 
     /**
+     * App IDs that have been white-listed to opt out of power save restrictions, except
+     * for device idle modes.
+     */
+    private final SparseBooleanArray mPowerSaveWhitelistExceptIdleAppIds = new SparseBooleanArray();
+
+    /**
+     * Current app IDs that are in the complete power save white list, but shouldn't be
+     * excluded from idle modes.  This array can be shared with others because it will not be
+     * modified once set.
+     */
+    private int[] mPowerSaveWhitelistExceptIdleAppIdArray = new int[0];
+
+    /**
      * App IDs that have been white-listed to opt out of power save restrictions.
      */
     private final SparseBooleanArray mPowerSaveWhitelistAllAppIds = new SparseBooleanArray();
@@ -583,14 +610,26 @@
             removePowerSaveWhitelistAppInternal(name);
         }
 
+        @Override public String[] getSystemPowerWhitelistExceptIdle() {
+            return getSystemPowerWhitelistExceptIdleInternal();
+        }
+
         @Override public String[] getSystemPowerWhitelist() {
             return getSystemPowerWhitelistInternal();
         }
 
+        @Override public String[] getFullPowerWhitelistExceptIdle() {
+            return getFullPowerWhitelistExceptIdleInternal();
+        }
+
         @Override public String[] getFullPowerWhitelist() {
             return getFullPowerWhitelistInternal();
         }
 
+        @Override public int[] getAppIdWhitelistExceptIdle() {
+            return getAppIdWhitelistExceptIdleInternal();
+        }
+
         @Override public int[] getAppIdWhitelist() {
             return getAppIdWhitelistInternal();
         }
@@ -599,6 +638,10 @@
             return getAppIdTempWhitelistInternal();
         }
 
+        @Override public boolean isPowerSaveWhitelistExceptIdleApp(String name) {
+            return isPowerSaveWhitelistExceptIdleAppInternal(name);
+        }
+
         @Override public boolean isPowerSaveWhitelistApp(String name) {
             return isPowerSaveWhitelistAppInternal(name);
         }
@@ -679,6 +722,19 @@
             mEnabled = getContext().getResources().getBoolean(
                     com.android.internal.R.bool.config_enableAutoPowerModes);
             SystemConfig sysConfig = SystemConfig.getInstance();
+            ArraySet<String> allowPowerExceptIdle = sysConfig.getAllowInPowerSaveExceptIdle();
+            for (int i=0; i<allowPowerExceptIdle.size(); i++) {
+                String pkg = allowPowerExceptIdle.valueAt(i);
+                try {
+                    ApplicationInfo ai = pm.getApplicationInfo(pkg, 0);
+                    if ((ai.flags&ApplicationInfo.FLAG_SYSTEM) != 0) {
+                        int appid = UserHandle.getAppId(ai.uid);
+                        mPowerSaveWhitelistAppsExceptIdle.put(ai.packageName, appid);
+                        mPowerSaveWhitelistSystemAppIdsExceptIdle.put(appid, true);
+                    }
+                } catch (PackageManager.NameNotFoundException e) {
+                }
+            }
             ArraySet<String> allowPower = sysConfig.getAllowInPowerSave();
             for (int i=0; i<allowPower.size(); i++) {
                 String pkg = allowPower.valueAt(i);
@@ -686,6 +742,10 @@
                     ApplicationInfo ai = pm.getApplicationInfo(pkg, 0);
                     if ((ai.flags&ApplicationInfo.FLAG_SYSTEM) != 0) {
                         int appid = UserHandle.getAppId(ai.uid);
+                        // These apps are on both the whitelist-except-idle as well
+                        // as the full whitelist, so they apply in all cases.
+                        mPowerSaveWhitelistAppsExceptIdle.put(ai.packageName, appid);
+                        mPowerSaveWhitelistSystemAppIdsExceptIdle.put(appid, true);
                         mPowerSaveWhitelistApps.put(ai.packageName, appid);
                         mPowerSaveWhitelistSystemAppIds.put(appid, true);
                     }
@@ -783,17 +843,45 @@
         return false;
     }
 
+    public String[] getSystemPowerWhitelistExceptIdleInternal() {
+        synchronized (this) {
+            int size = mPowerSaveWhitelistAppsExceptIdle.size();
+            String[] apps = new String[size];
+            for (int i = 0; i < size; i++) {
+                apps[i] = mPowerSaveWhitelistAppsExceptIdle.keyAt(i);
+            }
+            return apps;
+        }
+    }
+
     public String[] getSystemPowerWhitelistInternal() {
         synchronized (this) {
             int size = mPowerSaveWhitelistApps.size();
             String[] apps = new String[size];
-            for (int i = 0; i < mPowerSaveWhitelistApps.size(); i++) {
+            for (int i = 0; i < size; i++) {
                 apps[i] = mPowerSaveWhitelistApps.keyAt(i);
             }
             return apps;
         }
     }
 
+    public String[] getFullPowerWhitelistExceptIdleInternal() {
+        synchronized (this) {
+            int size = mPowerSaveWhitelistAppsExceptIdle.size() + mPowerSaveWhitelistUserApps.size();
+            String[] apps = new String[size];
+            int cur = 0;
+            for (int i = 0; i < mPowerSaveWhitelistAppsExceptIdle.size(); i++) {
+                apps[cur] = mPowerSaveWhitelistAppsExceptIdle.keyAt(i);
+                cur++;
+            }
+            for (int i = 0; i < mPowerSaveWhitelistUserApps.size(); i++) {
+                apps[cur] = mPowerSaveWhitelistUserApps.keyAt(i);
+                cur++;
+            }
+            return apps;
+        }
+    }
+
     public String[] getFullPowerWhitelistInternal() {
         synchronized (this) {
             int size = mPowerSaveWhitelistApps.size() + mPowerSaveWhitelistUserApps.size();
@@ -811,6 +899,13 @@
         }
     }
 
+    public boolean isPowerSaveWhitelistExceptIdleAppInternal(String packageName) {
+        synchronized (this) {
+            return mPowerSaveWhitelistAppsExceptIdle.containsKey(packageName)
+                    || mPowerSaveWhitelistUserApps.containsKey(packageName);
+        }
+    }
+
     public boolean isPowerSaveWhitelistAppInternal(String packageName) {
         synchronized (this) {
             return mPowerSaveWhitelistApps.containsKey(packageName)
@@ -818,6 +913,12 @@
         }
     }
 
+    public int[] getAppIdWhitelistExceptIdleInternal() {
+        synchronized (this) {
+            return mPowerSaveWhitelistExceptIdleAppIdArray;
+        }
+    }
+
     public int[] getAppIdWhitelistInternal() {
         synchronized (this) {
             return mPowerSaveWhitelistAllAppIdArray;
@@ -921,6 +1022,9 @@
                     Slog.d(TAG, "Removing UID " + uid + " from temp whitelist");
                 }
                 updateTempWhitelistAppIdsLocked();
+                if (mNetworkPolicyTempWhitelistCallback != null) {
+                    mHandler.post(mNetworkPolicyTempWhitelistCallback);
+                }
                 reportTempWhitelistChangedLocked();
                 try {
                     mBatteryStats.noteEvent(BatteryStats.HistoryItem.EVENT_TEMP_WHITELIST_FINISH,
@@ -949,10 +1053,14 @@
         if (DEBUG) Slog.d(TAG, "updateDisplayLocked: screenOn=" + screenOn);
         if (!screenOn && mScreenOn) {
             mScreenOn = false;
-            becomeInactiveIfAppropriateLocked();
+            if (!mForceIdle) {
+                becomeInactiveIfAppropriateLocked();
+            }
         } else if (screenOn) {
             mScreenOn = true;
-            becomeActiveLocked("screen", Process.myUid());
+            if (!mForceIdle) {
+                becomeActiveLocked("screen", Process.myUid());
+            }
         }
     }
 
@@ -960,10 +1068,14 @@
         if (DEBUG) Slog.i(TAG, "updateChargingLocked: charging=" + charging);
         if (!charging && mCharging) {
             mCharging = false;
-            becomeInactiveIfAppropriateLocked();
+            if (!mForceIdle) {
+                becomeInactiveIfAppropriateLocked();
+            }
         } else if (charging) {
             mCharging = charging;
-            becomeActiveLocked("charging", Process.myUid());
+            if (!mForceIdle) {
+                becomeActiveLocked("charging", Process.myUid());
+            }
         }
     }
 
@@ -989,7 +1101,7 @@
 
     void becomeInactiveIfAppropriateLocked() {
         if (DEBUG) Slog.d(TAG, "becomeInactiveIfAppropriateLocked()");
-        if (!mScreenOn && !mCharging && mEnabled && mState == STATE_ACTIVE) {
+        if (((!mScreenOn && !mCharging) || mForceIdle) && mEnabled && mState == STATE_ACTIVE) {
             // Screen has turned off; we are now going to become inactive and start
             // waiting to see if we will ultimately go idle.
             mState = STATE_INACTIVE;
@@ -1010,6 +1122,15 @@
         becomeInactiveIfAppropriateLocked();
     }
 
+    void exitForceIdleLocked() {
+        if (mForceIdle) {
+            mForceIdle = false;
+            if (mScreenOn || mCharging) {
+                becomeActiveLocked("exit-force-idle", Process.myUid());
+            }
+        }
+    }
+
     void stepIdleStateLocked() {
         if (DEBUG) Slog.d(TAG, "stepIdleStateLocked: mState=" + mState);
         EventLogTags.writeDeviceIdleStep();
@@ -1138,20 +1259,28 @@
           mNextAlarmTime, mSensingAlarmIntent);
     }
 
-    private void updateWhitelistAppIdsLocked() {
-        mPowerSaveWhitelistAllAppIds.clear();
-        for (int i=0; i<mPowerSaveWhitelistApps.size(); i++) {
-            mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistApps.valueAt(i), true);
+    private static int[] buildAppIdArray(ArrayMap<String, Integer> systemApps,
+            ArrayMap<String, Integer> userApps, SparseBooleanArray outAppIds) {
+        outAppIds.clear();
+        for (int i=0; i<systemApps.size(); i++) {
+            outAppIds.put(systemApps.valueAt(i), true);
         }
-        for (int i=0; i<mPowerSaveWhitelistUserApps.size(); i++) {
-            mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistUserApps.valueAt(i), true);
+        for (int i=0; i<userApps.size(); i++) {
+            outAppIds.put(userApps.valueAt(i), true);
         }
-        int size = mPowerSaveWhitelistAllAppIds.size();
+        int size = outAppIds.size();
         int[] appids = new int[size];
         for (int i = 0; i < size; i++) {
-            appids[i] = mPowerSaveWhitelistAllAppIds.keyAt(i);
+            appids[i] = outAppIds.keyAt(i);
         }
-        mPowerSaveWhitelistAllAppIdArray = appids;
+        return appids;
+    }
+
+    private void updateWhitelistAppIdsLocked() {
+        mPowerSaveWhitelistExceptIdleAppIdArray = buildAppIdArray(mPowerSaveWhitelistAppsExceptIdle,
+                mPowerSaveWhitelistUserApps, mPowerSaveWhitelistExceptIdleAppIds);
+        mPowerSaveWhitelistAllAppIdArray = buildAppIdArray(mPowerSaveWhitelistApps,
+                mPowerSaveWhitelistUserApps, mPowerSaveWhitelistAllAppIds);
         if (mLocalPowerManager != null) {
             if (DEBUG) {
                 Slog.d(TAG, "Setting wakelock whitelist to "
@@ -1320,6 +1449,9 @@
         pw.println("Commands:");
         pw.println("  step");
         pw.println("    Immediately step to next state, without waiting for alarm.");
+        pw.println("  force-idle");
+        pw.println("    Force directly into idle mode, regardless of other device state.");
+        pw.println("    Use \"step\" to get out.");
         pw.println("  disable");
         pw.println("    Completely disable device idle mode.");
         pw.println("  enable");
@@ -1362,6 +1494,7 @@
                     synchronized (this) {
                         long token = Binder.clearCallingIdentity();
                         try {
+                            exitForceIdleLocked();
                             stepIdleStateLocked();
                             pw.print("Stepped to: "); pw.println(stateToString(mState));
                         } finally {
@@ -1369,6 +1502,33 @@
                         }
                     }
                     return;
+                } else if ("force-idle".equals(arg)) {
+                    synchronized (this) {
+                        long token = Binder.clearCallingIdentity();
+                        try {
+                            if (!mEnabled) {
+                                pw.println("Unable to go idle; not enabled");
+                                return;
+                            }
+                            mForceIdle = true;
+                            becomeInactiveIfAppropriateLocked();
+                            int curState = mState;
+                            while (curState != STATE_IDLE) {
+                                stepIdleStateLocked();
+                                if (curState == mState) {
+                                    pw.print("Unable to go idle; stopped at ");
+                                    pw.println(stateToString(mState));
+                                    exitForceIdleLocked();
+                                    return;
+                                }
+                                curState = mState;
+                            }
+                            pw.println("Now forced in to idle mode");
+                        } finally {
+                            Binder.restoreCallingIdentity(token);
+                        }
+                    }
+                    return;
                 } else if ("disable".equals(arg)) {
                     synchronized (this) {
                         long token = Binder.clearCallingIdentity();
@@ -1387,6 +1547,7 @@
                     synchronized (this) {
                         long token = Binder.clearCallingIdentity();
                         try {
+                            exitForceIdleLocked();
                             if (!mEnabled) {
                                 mEnabled = true;
                                 becomeInactiveIfAppropriateLocked();
@@ -1431,6 +1592,12 @@
                             }
                         } else {
                             synchronized (this) {
+                                for (int j=0; j<mPowerSaveWhitelistAppsExceptIdle.size(); j++) {
+                                    pw.print("system-excidle,");
+                                    pw.print(mPowerSaveWhitelistAppsExceptIdle.keyAt(j));
+                                    pw.print(",");
+                                    pw.println(mPowerSaveWhitelistAppsExceptIdle.valueAt(j));
+                                }
                                 for (int j=0; j<mPowerSaveWhitelistApps.size(); j++) {
                                     pw.print("system,");
                                     pw.print(mPowerSaveWhitelistApps.keyAt(j));
@@ -1481,7 +1648,15 @@
         synchronized (this) {
             mConstants.dump(pw);
 
-            int size = mPowerSaveWhitelistApps.size();
+            int size = mPowerSaveWhitelistAppsExceptIdle.size();
+            if (size > 0) {
+                pw.println("  Whitelist (except idle) system apps:");
+                for (int i = 0; i < size; i++) {
+                    pw.print("    ");
+                    pw.println(mPowerSaveWhitelistAppsExceptIdle.keyAt(i));
+                }
+            }
+            size = mPowerSaveWhitelistApps.size();
             if (size > 0) {
                 pw.println("  Whitelist system apps:");
                 for (int i = 0; i < size; i++) {
@@ -1497,6 +1672,15 @@
                     pw.println(mPowerSaveWhitelistUserApps.keyAt(i));
                 }
             }
+            size = mPowerSaveWhitelistExceptIdleAppIds.size();
+            if (size > 0) {
+                pw.println("  Whitelist (except idle) all app ids:");
+                for (int i = 0; i < size; i++) {
+                    pw.print("    ");
+                    pw.print(mPowerSaveWhitelistExceptIdleAppIds.keyAt(i));
+                    pw.println();
+                }
+            }
             size = mPowerSaveWhitelistAllAppIds.size();
             if (size > 0) {
                 pw.println("  Whitelist all app ids:");
@@ -1531,6 +1715,7 @@
             }
 
             pw.print("  mEnabled="); pw.println(mEnabled);
+            pw.print("  mForceIdle="); pw.println(mForceIdle);
             pw.print("  mSigMotionSensor="); pw.println(mSigMotionSensor);
             pw.print("  mCurDisplay="); pw.println(mCurDisplay);
             pw.print("  mScreenOn="); pw.println(mScreenOn);
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index 7fa1d09..0d64540 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -766,6 +766,15 @@
         }
     }
 
+    private void addInternalVolume() {
+        // Create a stub volume that represents internal storage
+        final VolumeInfo internal = new VolumeInfo(VolumeInfo.ID_PRIVATE_INTERNAL,
+                VolumeInfo.TYPE_PRIVATE, null, null);
+        internal.state = VolumeInfo.STATE_MOUNTED;
+        internal.path = Environment.getDataDirectory().getAbsolutePath();
+        mVolumes.put(internal.id, internal);
+    }
+
     private void resetIfReadyAndConnectedLocked() {
         Slog.d(TAG, "Thinking about reset, mSystemReady=" + mSystemReady
                 + ", mDaemonConnected=" + mDaemonConnected);
@@ -775,12 +784,7 @@
             mDisks.clear();
             mVolumes.clear();
 
-            // Create a stub volume that represents internal storage
-            final VolumeInfo internal = new VolumeInfo(VolumeInfo.ID_PRIVATE_INTERNAL,
-                    VolumeInfo.TYPE_PRIVATE, null, null);
-            internal.state = VolumeInfo.STATE_MOUNTED;
-            internal.path = Environment.getDataDirectory().getAbsolutePath();
-            mVolumes.put(internal.id, internal);
+            addInternalVolume();
 
             try {
                 mConnector.execute("volume", "reset");
@@ -1412,6 +1416,8 @@
         userFilter.addAction(Intent.ACTION_USER_REMOVED);
         mContext.registerReceiver(mUserReceiver, userFilter, null, mHandler);
 
+        addInternalVolume();
+
         // Add ourself to the Watchdog monitors if enabled.
         if (WATCHDOG_ENABLE) {
             Watchdog.getInstance().addMonitor(this);
diff --git a/services/core/java/com/android/server/SystemConfig.java b/services/core/java/com/android/server/SystemConfig.java
index ad5406c..cd61347 100644
--- a/services/core/java/com/android/server/SystemConfig.java
+++ b/services/core/java/com/android/server/SystemConfig.java
@@ -84,6 +84,11 @@
     final ArrayMap<String, PermissionEntry> mPermissions = new ArrayMap<>();
 
     // These are the packages that are white-listed to be able to run in the
+    // background while in power save mode (but not whitelisted from device idle modes),
+    // as read from the configuration files.
+    final ArraySet<String> mAllowInPowerSaveExceptIdle = new ArraySet<>();
+
+    // These are the packages that are white-listed to be able to run in the
     // background while in power save mode, as read from the configuration files.
     final ArraySet<String> mAllowInPowerSave = new ArraySet<>();
 
@@ -123,6 +128,10 @@
         return mPermissions;
     }
 
+    public ArraySet<String> getAllowInPowerSaveExceptIdle() {
+        return mAllowInPowerSaveExceptIdle;
+    }
+
     public ArraySet<String> getAllowInPowerSave() {
         return mAllowInPowerSave;
     }
@@ -329,6 +338,17 @@
                     XmlUtils.skipCurrentTag(parser);
                     continue;
 
+                } else if ("allow-in-power-save-except-idle".equals(name) && !onlyFeatures) {
+                    String pkgname = parser.getAttributeValue(null, "package");
+                    if (pkgname == null) {
+                        Slog.w(TAG, "<allow-in-power-save-except-idle> without package in "
+                                + permFile + " at " + parser.getPositionDescription());
+                    } else {
+                        mAllowInPowerSaveExceptIdle.add(pkgname);
+                    }
+                    XmlUtils.skipCurrentTag(parser);
+                    continue;
+
                 } else if ("allow-in-power-save".equals(name) && !onlyFeatures) {
                     String pkgname = parser.getAttributeValue(null, "package");
                     if (pkgname == null) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 72892a2..2be3bf7 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -29,6 +29,7 @@
 import static com.android.internal.util.XmlUtils.writeLongAttribute;
 import static com.android.server.Watchdog.NATIVE_STACKS_OF_INTEREST;
 import static com.android.server.am.ActivityManagerDebugConfig.*;
+import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
 import static com.android.server.am.TaskRecord.INVALID_TASK_ID;
 import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK;
 import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
@@ -6493,6 +6494,22 @@
     }
 
     @Override
+    public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
+            int[] verticalSizeConfigurations) {
+        if (DEBUG_CONFIGURATION) Slog.v(TAG, "Report configuration: " + token + " "
+                + horizontalSizeConfiguration + " " + verticalSizeConfigurations);
+        synchronized (this) {
+            ActivityRecord record = ActivityRecord.isInStackLocked(token);
+            if (record == null) {
+                throw new IllegalArgumentException("reportSizeConfigurations: ActivityRecord not "
+                        + "found for: " + token);
+            }
+            record.setSizeConfigurations(horizontalSizeConfiguration,
+                    verticalSizeConfigurations);
+        }
+    }
+
+    @Override
     public final void backgroundResourcesReleased(IBinder token) {
         final long origId = Binder.clearCallingIdentity();
         try {
@@ -8943,17 +8960,29 @@
 
     @Override
     public void moveActivityToStack(IBinder token, int stackId) throws RemoteException {
-        synchronized(this) {
-            final long origId = Binder.clearCallingIdentity();
+        if (stackId == HOME_STACK_ID) {
+            throw new IllegalArgumentException(
+                    "moveTaskToStack: Attempt to move token " + token + " to home stack");
+        }
+        synchronized (this) {
+            long ident = Binder.clearCallingIdentity();
             try {
                 final ActivityRecord r = ActivityRecord.forTokenLocked(token);
                 if (r == null) {
                     throw new IllegalArgumentException(
                             "moveActivityToStack: No activity record matching token=" + token);
                 }
-                moveTaskToStack(r.task.taskId, stackId, true /*toTop*/);
+                if (DEBUG_STACK) Slog.d(TAG_STACK, "moveActivityToStack: moving r=" + r
+                        + " to stackId=" + stackId);
+                mStackSupervisor.moveTaskToStackLocked(r.task.taskId, stackId, ON_TOP);
+                if (mFocusedActivity != r) {
+                    setFocusedActivityLocked(r, "moveActivityToStack");
+                } else {
+                    mStackSupervisor.setFocusedStack(r, "moveActivityToStack");
+                }
+                mStackSupervisor.resumeTopActivitiesLocked(r.task.stack, null, null);
             } finally {
-                Binder.restoreCallingIdentity(origId);
+                Binder.restoreCallingIdentity(ident);
             }
         }
     }
@@ -8963,8 +8992,8 @@
         enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
                 "moveTaskToStack()");
         if (stackId == HOME_STACK_ID) {
-            Slog.e(TAG, "moveTaskToStack: Attempt to move task " + taskId + " to home stack",
-                    new RuntimeException("here").fillInStackTrace());
+            throw new IllegalArgumentException(
+                    "moveTaskToStack: Attempt to move task " + taskId + " to home stack");
         }
         synchronized (this) {
             long ident = Binder.clearCallingIdentity();
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 3f8a8a1..8eea00f 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -184,6 +184,12 @@
     boolean mLaunchTaskBehind; // this activity is actively being launched with
         // ActivityOptions.setLaunchTaskBehind, will be cleared once launch is completed.
 
+    // These configurations are collected from application's resources based on size-sensitive
+    // qualifiers. For example, layout-w800dp will be added to mHorizontalSizeConfigurations as 800
+    // and drawable-sw400dp will be added to both as 400.
+    private int[] mVerticalSizeConfigurations;
+    private int[] mHorizontalSizeConfigurations;
+
     void dump(PrintWriter pw, String prefix) {
         final long now = SystemClock.uptimeMillis();
         pw.print(prefix); pw.print("packageName="); pw.print(packageName);
@@ -327,6 +333,49 @@
         }
     }
 
+    public boolean crossesHorizontalSizeThreshold(int firstDp, int secondDp) {
+        return crossesSizeThreshold(mHorizontalSizeConfigurations, firstDp, secondDp);
+    }
+
+    public boolean crossesVerticalSizeThreshold(int firstDp, int secondDp) {
+        return crossesSizeThreshold(mVerticalSizeConfigurations, firstDp, secondDp);
+    }
+
+    /**
+     * The purpose of this method is to decide whether the activity needs to be relaunched upon
+     * changing its size. In most cases the activities don't need to be relaunched, if the resize
+     * is small, all the activity content has to do is relayout itself within new bounds. There are
+     * cases however, where the activity's content would be completely changed in the new size and
+     * the full relaunch is required.
+     *
+     * The activity will report to us vertical and horizontal thresholds after which a relaunch is
+     * required. These thresholds are collected from the application resource qualifiers. For
+     * example, if application has layout-w600dp resource directory, then it needs a relaunch when
+     * we resize from width of 650dp to 550dp, as it crosses the 600dp threshold. However, if
+     * it resizes width from 620dp to 700dp, it won't be relaunched as it stays on the same side
+     * of the threshold.
+     */
+    private static boolean crossesSizeThreshold(int[] thresholds, int firstDp,
+            int secondDp) {
+        if (thresholds == null) {
+            return false;
+        }
+        for (int i = thresholds.length - 1; i >= 0; i--) {
+            final int threshold = thresholds[i];
+            if ((firstDp < threshold && secondDp >= threshold)
+                    || (firstDp >= threshold && secondDp < threshold)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public void setSizeConfigurations(int[] horizontalSizeConfiguration,
+            int[] verticalSizeConfigurations) {
+        mHorizontalSizeConfigurations = horizontalSizeConfiguration;
+        mVerticalSizeConfigurations = verticalSizeConfigurations;
+    }
+
     static class Token extends IApplicationToken.Stub {
         private final WeakReference<ActivityRecord> weakActivity;
         private final ActivityManagerService mService;
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 8abebe4..b997926 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -16,6 +16,7 @@
 
 package com.android.server.am;
 
+import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
 import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
 import static android.app.ActivityManager.HOME_STACK_ID;
 import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
@@ -2671,21 +2672,28 @@
             ActivityRecord next = topRunningActivityLocked(null);
             final String myReason = reason + " adjustFocus";
             if (next != r) {
-                final TaskRecord task = r.task;
-                if (r.frontOfTask && task == topTask() && task.isOverHomeStack()) {
-                    // For non-fullscreen stack, we want to move the focus to the next visible
-                    // stack to prevent the home screen from moving to the top and obscuring
-                    // other visible stacks.
-                    if (!mFullscreen
-                            && adjustFocusToNextVisibleStackLocked(null, myReason)) {
-                        return;
-                    }
-                    // Move the home stack to the top if this stack is fullscreen or there is no
-                    // other visible stack.
-                    if (mStackSupervisor.moveHomeStackTaskToTop(
-                            task.getTaskToReturnTo(), myReason)) {
-                        // Activity focus was already adjusted. Nothing else to do...
-                        return;
+                if (next != null && mStackId == FREEFORM_WORKSPACE_STACK_ID) {
+                    // For freeform stack we always keep the focus within the stack as long as
+                    // there is a running activity in the stack that we can adjust focus to.
+                    mService.setFocusedActivityLocked(next, myReason);
+                    return;
+                } else {
+                    final TaskRecord task = r.task;
+                    if (r.frontOfTask && task == topTask() && task.isOverHomeStack()) {
+                        // For non-fullscreen stack, we want to move the focus to the next visible
+                        // stack to prevent the home screen from moving to the top and obscuring
+                        // other visible stacks.
+                        if (!mFullscreen
+                                && adjustFocusToNextVisibleStackLocked(null, myReason)) {
+                            return;
+                        }
+                        // Move the home stack to the top if this stack is fullscreen or there is no
+                        // other visible stack.
+                        if (mStackSupervisor.moveHomeStackTaskToTop(
+                                task.getTaskToReturnTo(), myReason)) {
+                            // Activity focus was already adjusted. Nothing else to do...
+                            return;
+                        }
                     }
                 }
             }
@@ -3897,25 +3905,7 @@
         r.configuration = newConfig;
         r.taskConfigOverride = taskConfig;
 
-        // Determine what has changed.  May be nothing, if this is a config
-        // that has come back from the app after going idle.  In that case
-        // we just want to leave the official config object now in the
-        // activity and do nothing else.
-        int taskChanges = oldTaskOverride.diff(taskConfig);
-        if (taskChanges == 0) {
-            // {@link Configuration#diff} doesn't catch changes from unset values.
-            // Check for changes we care about.
-            if (oldTaskOverride.orientation != taskConfig.orientation) {
-                taskChanges |= ActivityInfo.CONFIG_ORIENTATION;
-            }
-            if (oldTaskOverride.screenHeightDp != taskConfig.screenHeightDp
-                    || oldTaskOverride.screenWidthDp != taskConfig.screenWidthDp) {
-                taskChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
-            }
-            if (oldTaskOverride.smallestScreenWidthDp != taskConfig.smallestScreenWidthDp) {
-                taskChanges |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
-            }
-        }
+        int taskChanges = getTaskConfigurationChanges(r, taskConfig, oldTaskOverride);
         final int changes = oldConfig.diff(newConfig) | taskChanges;
         if (changes == 0 && !r.forceNewConfig) {
             if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
@@ -3995,6 +3985,72 @@
         return true;
     }
 
+    private int getTaskConfigurationChanges(ActivityRecord record, Configuration taskConfig,
+            Configuration oldTaskOverride) {
+        // Determine what has changed.  May be nothing, if this is a config
+        // that has come back from the app after going idle.  In that case
+        // we just want to leave the official config object now in the
+        // activity and do nothing else.
+        int taskChanges = oldTaskOverride.diff(taskConfig);
+        // We don't want to use size changes if they don't cross boundaries that are important to
+        // the app.
+        if ((taskChanges & ActivityInfo.CONFIG_SCREEN_SIZE) != 0) {
+            final boolean crosses = record.crossesHorizontalSizeThreshold(
+                    oldTaskOverride.screenWidthDp, taskConfig.screenWidthDp)
+                    || record.crossesVerticalSizeThreshold(
+                    oldTaskOverride.screenHeightDp, taskConfig.screenHeightDp);
+            if (!crosses) {
+                taskChanges &= ~ActivityInfo.CONFIG_SCREEN_SIZE;
+            }
+        }
+        if ((taskChanges & ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) != 0) {
+            final int oldSmallest = oldTaskOverride.smallestScreenWidthDp;
+            final int newSmallest = taskConfig.smallestScreenWidthDp;
+            final boolean crosses = record.crossesHorizontalSizeThreshold(oldSmallest, newSmallest)
+                    || record.crossesVerticalSizeThreshold(oldSmallest, newSmallest);
+            if (!crosses) {
+                taskChanges &= ~ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
+            }
+        }
+        return catchConfigChangesFromUnset(taskConfig, oldTaskOverride, taskChanges);
+    }
+
+    private static int catchConfigChangesFromUnset(Configuration taskConfig,
+            Configuration oldTaskOverride, int taskChanges) {
+        if (taskChanges == 0) {
+            // {@link Configuration#diff} doesn't catch changes from unset values.
+            // Check for changes we care about.
+            if (oldTaskOverride.orientation != taskConfig.orientation) {
+                taskChanges |= ActivityInfo.CONFIG_ORIENTATION;
+            }
+            // We want to explicitly track situations where the size configuration goes from
+            // undefined to defined. We don't care about crossing the threshold in that case,
+            // because there is no threshold.
+            final int oldHeight = oldTaskOverride.screenHeightDp;
+            final int newHeight = taskConfig.screenHeightDp;
+            final int undefinedHeight = Configuration.SCREEN_HEIGHT_DP_UNDEFINED;
+            if ((oldHeight == undefinedHeight && newHeight != undefinedHeight)
+                    || (oldHeight != undefinedHeight && newHeight == undefinedHeight)) {
+                taskChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
+            }
+            final int oldWidth = oldTaskOverride.screenWidthDp;
+            final int newWidth = taskConfig.screenWidthDp;
+            final int undefinedWidth = Configuration.SCREEN_WIDTH_DP_UNDEFINED;
+            if ((oldWidth == undefinedWidth && newWidth != undefinedWidth)
+                    || (oldWidth != undefinedWidth && newWidth == undefinedWidth)) {
+                taskChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
+            }
+            final int oldSmallest = oldTaskOverride.smallestScreenWidthDp;
+            final int newSmallest = taskConfig.smallestScreenWidthDp;
+            final int undefinedSmallest = Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
+            if ((oldSmallest == undefinedSmallest && newSmallest != undefinedSmallest)
+                    || (oldSmallest != undefinedSmallest && newSmallest == undefinedSmallest)) {
+                taskChanges |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
+            }
+        }
+        return taskChanges;
+    }
+
     private boolean relaunchActivityLocked(ActivityRecord r, int changes, boolean andResume) {
         List<ResultInfo> results = null;
         List<ReferrerIntent> newIntents = null;
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 5417ece..2e9272c 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -178,7 +178,7 @@
 
     // Used to indicate if an object (e.g. task) should be moved/created
     // at the top of its container (e.g. stack).
-    private static final boolean ON_TOP = true;
+    static final boolean ON_TOP = true;
 
     // Used to indicate that an objects (e.g. task) removal from its container
     // (e.g. stack) is due to it moving to another container.
@@ -1518,9 +1518,13 @@
                     intent.addCategory(Intent.CATEGORY_VOICE);
                     if (!AppGlobals.getPackageManager().activitySupportsIntent(
                             intent.getComponent(), intent, resolvedType)) {
+                        Slog.w(TAG,
+                                "Activity being started in current voice task does not support voice: "
+                                + intent);
                         err = ActivityManager.START_NOT_VOICE_COMPATIBLE;
                     }
                 } catch (RemoteException e) {
+                    Slog.w(TAG, "Failure checking voice capabilities", e);
                     err = ActivityManager.START_NOT_VOICE_COMPATIBLE;
                 }
             }
@@ -1532,9 +1536,13 @@
             try {
                 if (!AppGlobals.getPackageManager().activitySupportsIntent(intent.getComponent(),
                         intent, resolvedType)) {
+                    Slog.w(TAG,
+                            "Activity being started in new voice task does not support: "
+                            + intent);
                     err = ActivityManager.START_NOT_VOICE_COMPATIBLE;
                 }
             } catch (RemoteException e) {
+                Slog.w(TAG, "Failure checking voice capabilities", e);
                 err = ActivityManager.START_NOT_VOICE_COMPATIBLE;
             }
         }
@@ -2945,13 +2953,21 @@
         // Place the task in the right stack if it isn't there already based on the requested
         // bounds.
         int stackId = task.stack.mStackId;
+        final boolean wasFrontStack = isFrontStack(task.stack);
         if (bounds == null && stackId != FULLSCREEN_WORKSPACE_STACK_ID) {
             stackId = FULLSCREEN_WORKSPACE_STACK_ID;
         } else if (bounds != null && task.stack.mStackId != FREEFORM_WORKSPACE_STACK_ID) {
             stackId = FREEFORM_WORKSPACE_STACK_ID;
         }
         if (stackId != task.stack.mStackId) {
-            moveTaskToStackUncheckedLocked(task, stackId, ON_TOP, "resizeTask");
+            final String reason = "resizeTask";
+            final ActivityStack stack =
+                    moveTaskToStackUncheckedLocked(task, stackId, ON_TOP, reason);
+            if (wasFrontStack) {
+                // Since the stack was previously in front,
+                // move the stack in which we are placing the task to the front.
+                stack.moveToFront(reason);
+            }
         }
 
         final Configuration overrideConfig = mWindowManager.resizeTask(task.taskId, bounds);
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 7334f5b..7d16a35 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -39,6 +39,7 @@
 import static android.net.NetworkPolicyManager.EXTRA_NETWORK_TEMPLATE;
 import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_DOZABLE;
 import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_STANDBY;
+import static android.net.NetworkPolicyManager.FIREWALL_RULE_DEFAULT;
 import static android.net.NetworkPolicyManager.FIREWALL_RULE_ALLOW;
 import static android.net.NetworkPolicyManager.FIREWALL_RULE_DENY;
 import static android.net.NetworkPolicyManager.POLICY_ALLOW_BACKGROUND_BATTERY_SAVE;
@@ -46,7 +47,6 @@
 import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
 import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL;
 import static android.net.NetworkPolicyManager.RULE_REJECT_METERED;
-import static android.net.NetworkPolicyManager.RULE_REJECT_ALL;
 import static android.net.NetworkPolicyManager.computeLastCycleBoundary;
 import static android.net.NetworkPolicyManager.dumpPolicy;
 import static android.net.NetworkPolicyManager.dumpRules;
@@ -282,6 +282,13 @@
 
     /**
      * UIDs that have been white-listed to always be able to have network access
+     * in power save mode, except device idle (doze) still applies.
+     * TODO: An int array might be sufficient
+     */
+    private final SparseBooleanArray mPowerSaveWhitelistExceptIdleAppIds = new SparseBooleanArray();
+
+    /**
+     * UIDs that have been white-listed to always be able to have network access
      * in power save mode.
      * TODO: An int array might be sufficient
      */
@@ -300,9 +307,6 @@
     /** Foreground at UID granularity. */
     final SparseIntArray mUidState = new SparseIntArray();
 
-    /** The current maximum process state that we are considering to be foreground. */
-    private int mCurForegroundState = ActivityManager.PROCESS_STATE_TOP;
-
     private final RemoteCallbackList<INetworkPolicyListener>
             mListeners = new RemoteCallbackList<>();
 
@@ -363,7 +367,14 @@
 
     void updatePowerSaveWhitelistLocked() {
         try {
-            final int[] whitelist = mDeviceIdleController.getAppIdWhitelist();
+            int[] whitelist = mDeviceIdleController.getAppIdWhitelistExceptIdle();
+            mPowerSaveWhitelistExceptIdleAppIds.clear();
+            if (whitelist != null) {
+                for (int uid : whitelist) {
+                    mPowerSaveWhitelistExceptIdleAppIds.put(uid, true);
+                }
+            }
+            whitelist = mDeviceIdleController.getAppIdWhitelist();
             mPowerSaveWhitelistAppIds.clear();
             if (whitelist != null) {
                 for (int uid : whitelist) {
@@ -423,7 +434,6 @@
                         if (mRestrictPower != enabled) {
                             mRestrictPower = enabled;
                             updateRulesForGlobalChangeLocked(true);
-                            updateRulesForTempWhitelistChangeLocked();
                         }
                     }
                 }
@@ -435,9 +445,12 @@
             readPolicyLocked();
 
             if (mRestrictBackground || mRestrictPower || mDeviceIdleMode) {
-                updateRulesForGlobalChangeLocked(true);
-                updateRulesForTempWhitelistChangeLocked();
+                updateRulesForGlobalChangeLocked(false);
                 updateNotificationsLocked();
+            } else {
+                // If we are not in any special mode, we just need to make sure the current
+                // app idle state is updated.
+                updateRulesForAppIdleLocked();
             }
         }
 
@@ -1905,7 +1918,6 @@
             fout.print("Restrict background: "); fout.println(mRestrictBackground);
             fout.print("Restrict power: "); fout.println(mRestrictPower);
             fout.print("Device idle: "); fout.println(mDeviceIdleMode);
-            fout.print("Current foreground state: "); fout.println(mCurForegroundState);
             fout.println("Network policies:");
             fout.increaseIndent();
             for (int i = 0; i < mNetworkPolicy.size(); i++) {
@@ -1929,6 +1941,20 @@
             }
             fout.decreaseIndent();
 
+            size = mPowerSaveWhitelistExceptIdleAppIds.size();
+            if (size > 0) {
+                fout.println("Power save whitelist (except idle) app ids:");
+                fout.increaseIndent();
+                for (int i = 0; i < size; i++) {
+                    fout.print("UID=");
+                    fout.print(mPowerSaveWhitelistExceptIdleAppIds.keyAt(i));
+                    fout.print(": ");
+                    fout.print(mPowerSaveWhitelistExceptIdleAppIds.valueAt(i));
+                    fout.println();
+                }
+                fout.decreaseIndent();
+            }
+
             size = mPowerSaveWhitelistAppIds.size();
             if (size > 0) {
                 fout.println("Power save whitelist app ids:");
@@ -1958,7 +1984,7 @@
                 int state = mUidState.get(uid, ActivityManager.PROCESS_STATE_CACHED_EMPTY);
                 fout.print(" state=");
                 fout.print(state);
-                fout.print(state <= mCurForegroundState ? " (fg)" : " (bg)");
+                fout.print(state <= ActivityManager.PROCESS_STATE_TOP ? " (fg)" : " (bg)");
 
                 fout.print(" rules=");
                 final int rulesIndex = mUidRules.indexOfKey(uid);
@@ -1986,7 +2012,7 @@
     boolean isUidForegroundLocked(int uid) {
         // only really in foreground when screen is also on
         return mScreenOn && mUidState.get(uid, ActivityManager.PROCESS_STATE_CACHED_EMPTY)
-                <= mCurForegroundState;
+                <= ActivityManager.PROCESS_STATE_TOP;
     }
 
     /**
@@ -2022,8 +2048,8 @@
     }
 
     void updateRulesForUidStateChangeLocked(int uid, int oldUidState, int newUidState) {
-        final boolean oldForeground = oldUidState <= mCurForegroundState;
-        final boolean newForeground = newUidState <= mCurForegroundState;
+        final boolean oldForeground = oldUidState <= ActivityManager.PROCESS_STATE_TOP;
+        final boolean newForeground = newUidState <= ActivityManager.PROCESS_STATE_TOP;
         if (oldForeground != newForeground) {
             updateRulesForUidLocked(uid);
         }
@@ -2047,7 +2073,7 @@
         // only update rules for anyone with foreground activities
         final int size = mUidState.size();
         for (int i = 0; i < size; i++) {
-            if (mUidState.valueAt(i) <= mCurForegroundState) {
+            if (mUidState.valueAt(i) <= ActivityManager.PROCESS_STATE_TOP) {
                 final int uid = mUidState.keyAt(i);
                 updateRulesForUidLocked(uid);
             }
@@ -2067,9 +2093,11 @@
             for (int ui = users.size() - 1; ui >= 0; ui--) {
                 UserInfo user = users.get(ui);
                 for (int i = mPowerSaveTempWhitelistAppIds.size() - 1; i >= 0; i--) {
-                    int appId = mPowerSaveTempWhitelistAppIds.keyAt(i);
-                    int uid = UserHandle.getUid(user.id, appId);
-                    uidRules.put(uid, FIREWALL_RULE_ALLOW);
+                    if (mPowerSaveTempWhitelistAppIds.valueAt(i)) {
+                        int appId = mPowerSaveTempWhitelistAppIds.keyAt(i);
+                        int uid = UserHandle.getUid(user.id, appId);
+                        uidRules.put(uid, FIREWALL_RULE_ALLOW);
+                    }
                 }
                 for (int i = mPowerSaveWhitelistAppIds.size() - 1; i >= 0; i--) {
                     int appId = mPowerSaveWhitelistAppIds.keyAt(i);
@@ -2087,6 +2115,45 @@
         enableFirewallChainLocked(FIREWALL_CHAIN_DOZABLE, mDeviceIdleMode);
     }
 
+    void updateRuleForDeviceIdleLocked(int uid) {
+        if (mDeviceIdleMode) {
+            int appId = UserHandle.getAppId(uid);
+            if (mPowerSaveTempWhitelistAppIds.get(appId) || mPowerSaveWhitelistAppIds.get(appId)
+                    || isProcStateAllowedWhileIdle(mUidState.get(uid))) {
+                setUidFirewallRule(FIREWALL_CHAIN_DOZABLE, uid, FIREWALL_RULE_ALLOW);
+            } else {
+                setUidFirewallRule(FIREWALL_CHAIN_DOZABLE, uid, FIREWALL_RULE_DEFAULT);
+            }
+        }
+    }
+
+    void updateRulesForAppIdleLocked() {
+        // Fully update the app idle firewall chain.
+        SparseIntArray uidRules = new SparseIntArray();
+        final List<UserInfo> users = mUserManager.getUsers();
+        for (int ui = users.size() - 1; ui >= 0; ui--) {
+            UserInfo user = users.get(ui);
+            int[] idleUids = mUsageStats.getIdleUidsForUser(user.id);
+            for (int uid : idleUids) {
+                if (!mPowerSaveTempWhitelistAppIds.get(UserHandle.getAppId(uid), false)) {
+                    uidRules.put(uid, FIREWALL_RULE_DENY);
+                }
+            }
+        }
+        setUidFirewallRules(FIREWALL_CHAIN_STANDBY, uidRules);
+    }
+
+    void updateRuleForAppIdleLocked(int uid) {
+        if (!isUidValidForRules(uid)) return;
+
+        int appId = UserHandle.getAppId(uid);
+        if (!mPowerSaveTempWhitelistAppIds.get(appId) && isUidIdle(uid)) {
+            setUidFirewallRule(FIREWALL_CHAIN_STANDBY, uid, FIREWALL_RULE_DENY);
+        } else {
+            setUidFirewallRule(FIREWALL_CHAIN_STANDBY, uid, FIREWALL_RULE_DEFAULT);
+        }
+    }
+
     void updateRulesForAppIdleParoleLocked() {
         boolean enableChain = !mUsageStats.isAppIdleParoleOn();
         enableFirewallChainLocked(FIREWALL_CHAIN_STANDBY, enableChain);
@@ -2099,14 +2166,8 @@
     void updateRulesForGlobalChangeLocked(boolean restrictedNetworksChanged) {
         final PackageManager pm = mContext.getPackageManager();
 
-        // If we are in restrict power mode, we allow all important apps
-        // to have data access.  Otherwise, we restrict data access to only
-        // the top apps.
-        mCurForegroundState = (!mRestrictBackground && mRestrictPower)
-                ? ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE
-                : ActivityManager.PROCESS_STATE_TOP;
-
         updateRulesForDeviceIdleLocked();
+        updateRulesForAppIdleLocked();
 
         // update rules for all installed applications
         final List<UserInfo> users = mUserManager.getUsers();
@@ -2136,10 +2197,9 @@
         for (UserInfo user : users) {
             for (int i = mPowerSaveTempWhitelistAppIds.size() - 1; i >= 0; i--) {
                 int appId = mPowerSaveTempWhitelistAppIds.keyAt(i);
-                boolean isAllow = mPowerSaveTempWhitelistAppIds.valueAt(i);
                 int uid = UserHandle.getUid(user.id, appId);
-                updateRulesForUidLocked(uid);
-                setUidFirewallRule(FIREWALL_CHAIN_DOZABLE, uid, !isAllow);
+                updateRuleForAppIdleLocked(uid);
+                updateRuleForDeviceIdleLocked(uid);
             }
         }
     }
@@ -2186,16 +2246,12 @@
 
         final int uidPolicy = mUidPolicy.get(uid, POLICY_NONE);
         final boolean uidForeground = isUidForegroundLocked(uid);
-        final boolean uidIdle = isUidIdle(uid);
 
         // derive active rules based on policy and active state
 
         int appId = UserHandle.getAppId(uid);
         int uidRules = RULE_ALLOW_ALL;
-        if (uidIdle && !mPowerSaveWhitelistAppIds.get(appId)
-                && !mPowerSaveTempWhitelistAppIds.get(appId)) {
-            uidRules = RULE_REJECT_ALL;
-        } else if (!uidForeground && (uidPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0) {
+        if (!uidForeground && (uidPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0) {
             // uid in background, and policy says to block metered data
             uidRules = RULE_REJECT_METERED;
         } else if (mRestrictBackground) {
@@ -2204,7 +2260,7 @@
                 uidRules = RULE_REJECT_METERED;
             }
         } else if (mRestrictPower) {
-            final boolean whitelisted = mPowerSaveWhitelistAppIds.get(appId)
+            final boolean whitelisted = mPowerSaveWhitelistExceptIdleAppIds.get(appId)
                     || mPowerSaveTempWhitelistAppIds.get(appId);
             if (!whitelisted && !uidForeground
                     && (uidPolicy & POLICY_ALLOW_BACKGROUND_BATTERY_SAVE) == 0) {
@@ -2230,13 +2286,6 @@
             setUidNetworkRules(uid, rejectMetered);
         }
 
-        // Update firewall rules if necessary
-        final boolean oldFirewallReject = (oldRules & RULE_REJECT_ALL) != 0;
-        final boolean firewallReject = (uidRules & RULE_REJECT_ALL) != 0;
-        if (oldFirewallReject != firewallReject) {
-            setUidFirewallRule(FIREWALL_CHAIN_STANDBY, uid, firewallReject);
-        }
-
         // dispatch changed rule to existing listeners
         if (oldRules != uidRules) {
             mHandler.obtainMessage(MSG_RULES_CHANGED, uid, uidRules).sendToTarget();
@@ -2258,7 +2307,7 @@
             try {
                 int uid = mContext.getPackageManager().getPackageUid(packageName, userId);
                 synchronized (mRulesLock) {
-                    updateRulesForUidLocked(uid);
+                    updateRuleForAppIdleLocked(uid);
                 }
             } catch (NameNotFoundException nnfe) {
             }
@@ -2420,10 +2469,9 @@
     /**
      * Add or remove a uid to the firewall blacklist for all network ifaces.
      */
-    private void setUidFirewallRule(int chain, int uid, boolean rejectOnAll) {
+    private void setUidFirewallRule(int chain, int uid, int rule) {
         try {
-            mNetworkManager.setFirewallUidRule(chain, uid,
-                    rejectOnAll ? FIREWALL_RULE_DENY : FIREWALL_RULE_ALLOW);
+            mNetworkManager.setFirewallUidRule(chain, uid, rule);
         } catch (IllegalStateException e) {
             Log.wtf(TAG, "problem setting firewall uid rules", e);
         } catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 5e2cb47..dc6e17d 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -13149,7 +13149,8 @@
                 // they have set the special DELETE_SYSTEM_APP which requests different
                 // semantics than normal for uninstalling system apps.
                 if (DEBUG_REMOVE) Slog.d(TAG, "Only deleting for single user");
-                ps.setUserState(user.getIdentifier(),
+                final int userId = user.getIdentifier();
+                ps.setUserState(userId,
                         COMPONENT_ENABLED_STATE_DEFAULT,
                         false, //installed
                         true,  //stopped
@@ -13157,7 +13158,7 @@
                         false, //hidden
                         null, null, null,
                         false, // blockUninstall
-                        INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED, 0);
+                        ps.readUserState(userId).domainVerificationStatus, 0);
                 if (!isSystemApp(ps)) {
                     if (ps.isAnyInstalled(sUserManager.getUserIds())) {
                         // Other user still have this package installed, so all
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 5bdad50..bd7ec31 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -4153,6 +4153,9 @@
                 if ((perm.info.flags&PermissionInfo.FLAG_COSTS_MONEY) != 0) {
                     pw.print(", COSTS_MONEY");
                 }
+                if ((perm.info.flags&PermissionInfo.FLAG_HIDDEN) != 0) {
+                    pw.print(", COSTS_HIDDEN");
+                }
                 if ((perm.info.flags&PermissionInfo.FLAG_INSTALLED) != 0) {
                     pw.print(", INSTALLED");
                 }
@@ -4309,7 +4312,8 @@
                     pw.println(PermissionInfo.protectionToString(p.protectionLevel));
             if (p.perm != null) {
                 pw.print("    perm="); pw.println(p.perm);
-                if (p.perm.info.flags != PermissionInfo.FLAG_INSTALLED) {
+                if ((p.perm.info.flags & PermissionInfo.FLAG_INSTALLED) == 0
+                        || (p.perm.info.flags & PermissionInfo.FLAG_HIDDEN) != 0) {
                     pw.print("    flags=0x"); pw.println(Integer.toHexString(p.perm.info.flags));
                 }
             }
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 74dd087..fcfb5e8 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -247,7 +247,7 @@
                 }
                 for (int i = 0; i < partials.size(); i++) {
                     UserInfo ui = partials.get(i);
-                    Slog.w(LOG_TAG, "Removing partially created user #" + i
+                    Slog.w(LOG_TAG, "Removing partially created user " + ui.id
                             + " (name=" + ui.name + ")");
                     removeUserStateLocked(ui.id);
                 }
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 3d7b499..9af5e14 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -5363,6 +5363,12 @@
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
+        // If this isn't coming from the system then don't allow disabling the lockscreen
+        // to bypass security.
+        if (Binder.getCallingUid() != Process.SYSTEM_UID && isKeyguardSecure()) {
+            Log.d(TAG, "current mode is SecurityMode, ignore hide keyguard");
+            return;
+        }
 
         if (token == null) {
             throw new IllegalArgumentException("token == null");
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index eba9e1e..8e475e6 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -35,6 +35,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ParceledListSlice;
@@ -65,6 +66,7 @@
 import android.util.KeyValueListParser;
 import android.util.Slog;
 import android.util.SparseArray;
+import android.util.SparseIntArray;
 import android.util.TimeUtils;
 import android.view.Display;
 
@@ -799,7 +801,10 @@
         }
         if (packageName.equals("android")) return false;
         try {
-            if (mDeviceIdleController.isPowerSaveWhitelistApp(packageName)) {
+            // We allow all whitelisted apps, including those that don't want to be whitelisted
+            // for idle mode, because app idle (aka app standby) is really not as big an issue
+            // for controlling who participates vs. doze mode.
+            if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
                 return false;
             }
         } catch (RemoteException re) {
@@ -825,6 +830,72 @@
         return isAppIdleUnfiltered(packageName, userService, timeNow, screenOnTime);
     }
 
+    int[] getIdleUidsForUser(int userId) {
+        if (!mAppIdleEnabled) {
+            return new int[0];
+        }
+
+        final long timeNow;
+        final UserUsageStatsService userService;
+        final long screenOnTime;
+        synchronized (mLock) {
+            timeNow = checkAndGetTimeLocked();
+            userService = getUserDataAndInitializeIfNeededLocked(userId, timeNow);
+            screenOnTime = getScreenOnTimeLocked(timeNow);
+        }
+
+        List<ApplicationInfo> apps;
+        try {
+            ParceledListSlice<ApplicationInfo> slice
+                    = AppGlobals.getPackageManager().getInstalledApplications(0, userId);
+            apps = slice.getList();
+        } catch (RemoteException e) {
+            return new int[0];
+        }
+
+        // State of each uid.  Key is the uid.  Value lower 16 bits is the number of apps
+        // associated with that uid, upper 16 bits is the number of those apps that is idle.
+        SparseIntArray uidStates = new SparseIntArray();
+
+        // Now resolve all app state.  Iterating over all apps, keeping track of how many
+        // we find for each uid and how many of those are idle.
+        for (int i = apps.size()-1; i >= 0; i--) {
+            ApplicationInfo ai = apps.get(i);
+
+            // Check whether this app is idle.
+            boolean idle = isAppIdleFiltered(ai.packageName, userId, userService, timeNow,
+                    screenOnTime);
+
+            int index = uidStates.indexOfKey(ai.uid);
+            if (index < 0) {
+                uidStates.put(ai.uid, 1 + (idle ? 1<<16 : 0));
+            } else {
+                int value = uidStates.valueAt(index);
+                uidStates.setValueAt(index, value + 1 + (idle ? 1<<16 : 0));
+            }
+        }
+
+        int numIdle = 0;
+        for (int i = uidStates.size() - 1; i >= 0; i--) {
+            int value = uidStates.valueAt(i);
+            if ((value&0x7fff) == (value>>16)) {
+                numIdle++;
+            }
+        }
+
+        int[] res = new int[numIdle];
+        numIdle = 0;
+        for (int i = uidStates.size() - 1; i >= 0; i--) {
+            int value = uidStates.valueAt(i);
+            if ((value&0x7fff) == (value>>16)) {
+                res[numIdle] = uidStates.keyAt(i);
+                numIdle++;
+            }
+        }
+
+        return res;
+    }
+
     void setAppIdle(String packageName, boolean idle, int userId) {
         if (packageName == null) return;
 
@@ -1284,6 +1355,11 @@
         }
 
         @Override
+        public int[] getIdleUidsForUser(int userId) {
+            return UsageStatsService.this.getIdleUidsForUser(userId);
+        }
+
+        @Override
         public boolean isAppIdleParoleOn() {
             return mAppIdleParoled;
         }
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 067e734..8779462 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -367,6 +367,48 @@
             "android.telecom.intent.extra.TTY_PREFERRED";
 
     /**
+     * Broadcast intent action for letting custom component know to show the missed call
+     * notification.
+     * @hide
+     */
+    @SystemApi
+    public static final String ACTION_SHOW_MISSED_CALLS_NOTIFICATION =
+            "android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION";
+
+    /**
+     * The number of calls associated with the notification.
+     * @hide
+     */
+    @SystemApi
+    public static final String EXTRA_NOTIFICATION_COUNT =
+            "android.telecom.extra.NOTIFICATION_COUNT";
+
+    /**
+     * The number associated with the missed calls. This number is only relevant
+     * when EXTRA_NOTIFICATION_COUNT is 1.
+     * @hide
+     */
+    @SystemApi
+    public static final String EXTRA_NOTIFICATION_PHONE_NUMBER =
+            "android.telecom.extra.NOTIFICATION_PHONE_NUMBER";
+
+    /**
+     * The intent to clear missed calls.
+     * @hide
+     */
+    @SystemApi
+    public static final String EXTRA_CLEAR_MISSED_CALLS_INTENT =
+            "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT";
+
+    /**
+     * The intent to call back a missed call.
+     * @hide
+     */
+    @SystemApi
+    public static final String EXTRA_CALL_BACK_INTENT =
+            "android.telecom.extra.CALL_BACK_INTENT";
+
+    /**
      * The following 4 constants define how properties such as phone numbers and names are
      * displayed to the user.
      */