Merge "Add constants for metadata_sync_state table."
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 a2fdb16..c0a2c7e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -115,7 +115,6 @@
     field public static final java.lang.String INTERNET = "android.permission.INTERNET";
     field public static final java.lang.String INVOKE_CARRIER_SETUP = "android.permission.INVOKE_CARRIER_SETUP";
     field public static final java.lang.String KILL_BACKGROUND_PROCESSES = "android.permission.KILL_BACKGROUND_PROCESSES";
-    field public static final java.lang.String KILL_UID = "android.permission.KILL_UID";
     field public static final java.lang.String LOCAL_MAC_ADDRESS = "android.permission.LOCAL_MAC_ADDRESS";
     field public static final java.lang.String LOCATION_HARDWARE = "android.permission.LOCATION_HARDWARE";
     field public static final java.lang.String LOOP_RADIO = "android.permission.LOOP_RADIO";
@@ -3673,7 +3672,6 @@
     method public static boolean isRunningInTestHarness();
     method public static boolean isUserAMonkey();
     method public void killBackgroundProcesses(java.lang.String);
-    method public void killUid(int, java.lang.String);
     method public void moveTaskToFront(int, int);
     method public void moveTaskToFront(int, int, android.os.Bundle);
     method public deprecated void restartPackage(java.lang.String);
@@ -27313,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
@@ -27414,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";
   }
@@ -32766,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/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java b/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java
index 3ec63b4..d1f7a00 100644
--- a/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java
+++ b/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java
@@ -284,8 +284,8 @@
                     userId = UserHandle.USER_ALL;
                 } else if ("current".equals(userStr)) {
                     userId = UserHandle.USER_CURRENT;
-                } else if ("owner".equals(userStr)) {
-                    userId = UserHandle.USER_OWNER;
+                } else if ("owner".equals(userStr) || "system".equals(userStr)) {
+                    userId = UserHandle.USER_SYSTEM;
                 } else {
                     userId = Integer.parseInt(nextArgRequired());
                 }
diff --git a/cmds/appwidget/src/com/android/commands/appwidget/AppWidget.java b/cmds/appwidget/src/com/android/commands/appwidget/AppWidget.java
index 5ea7352..5414224 100644
--- a/cmds/appwidget/src/com/android/commands/appwidget/AppWidget.java
+++ b/cmds/appwidget/src/com/android/commands/appwidget/AppWidget.java
@@ -85,7 +85,7 @@
         private SetBindAppWidgetPermissionCommand parseSetGrantBindAppWidgetPermissionCommand(
                 boolean granted) {
             String packageName = null;
-            int userId = UserHandle.USER_OWNER;
+            int userId = UserHandle.USER_SYSTEM;
             for (String argument; (argument = mTokenizer.nextArg()) != null;) {
                 if (ARGUMENT_PACKAGE.equals(argument)) {
                     packageName = argumentValueRequired(argument);
diff --git a/cmds/content/src/com/android/commands/content/Content.java b/cmds/content/src/com/android/commands/content/Content.java
index c0ed893..d43b8c5 100644
--- a/cmds/content/src/com/android/commands/content/Content.java
+++ b/cmds/content/src/com/android/commands/content/Content.java
@@ -184,7 +184,7 @@
 
         private InsertCommand parseInsertCommand() {
             Uri uri = null;
-            int userId = UserHandle.USER_OWNER;
+            int userId = UserHandle.USER_SYSTEM;
             ContentValues values = new ContentValues();
             for (String argument; (argument = mTokenizer.nextArg()) != null;) {
                 if (ARGUMENT_URI.equals(argument)) {
@@ -210,7 +210,7 @@
 
         private DeleteCommand parseDeleteCommand() {
             Uri uri = null;
-            int userId = UserHandle.USER_OWNER;
+            int userId = UserHandle.USER_SYSTEM;
             String where = null;
             for (String argument; (argument = mTokenizer.nextArg())!= null;) {
                 if (ARGUMENT_URI.equals(argument)) {
@@ -232,7 +232,7 @@
 
         private UpdateCommand parseUpdateCommand() {
             Uri uri = null;
-            int userId = UserHandle.USER_OWNER;
+            int userId = UserHandle.USER_SYSTEM;
             String where = null;
             ContentValues values = new ContentValues();
             for (String argument; (argument = mTokenizer.nextArg())!= null;) {
@@ -261,7 +261,7 @@
 
         public CallCommand parseCallCommand() {
             String method = null;
-            int userId = UserHandle.USER_OWNER;
+            int userId = UserHandle.USER_SYSTEM;
             String arg = null;
             Uri uri = null;
             ContentValues values = new ContentValues();
@@ -293,7 +293,7 @@
 
         private ReadCommand parseReadCommand() {
             Uri uri = null;
-            int userId = UserHandle.USER_OWNER;
+            int userId = UserHandle.USER_SYSTEM;
             for (String argument; (argument = mTokenizer.nextArg())!= null;) {
                 if (ARGUMENT_URI.equals(argument)) {
                     uri = Uri.parse(argumentValueRequired(argument));
@@ -312,7 +312,7 @@
 
         public QueryCommand parseQueryCommand() {
             Uri uri = null;
-            int userId = UserHandle.USER_OWNER;
+            int userId = UserHandle.USER_SYSTEM;
             String[] projection = null;
             String sort = null;
             String where = null;
diff --git a/cmds/dpm/src/com/android/commands/dpm/Dpm.java b/cmds/dpm/src/com/android/commands/dpm/Dpm.java
index 3d86ac1..f9b3419 100644
--- a/cmds/dpm/src/com/android/commands/dpm/Dpm.java
+++ b/cmds/dpm/src/com/android/commands/dpm/Dpm.java
@@ -43,7 +43,7 @@
     private static final String COMMAND_SET_PROFILE_OWNER = "set-profile-owner";
 
     private IDevicePolicyManager mDevicePolicyManager;
-    private int mUserId = UserHandle.USER_OWNER;
+    private int mUserId = UserHandle.USER_SYSTEM;
     private ComponentName mComponent = null;
 
     @Override
diff --git a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
index c27d0c0..a675769 100644
--- a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
+++ b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
@@ -130,7 +130,7 @@
 
         if (valid) {
             if (mUser < 0) {
-                mUser = UserHandle.USER_OWNER;
+                mUser = UserHandle.USER_SYSTEM;
             }
 
             try {
@@ -139,7 +139,7 @@
                 IBinder token = new Binder();
                 try {
                     ContentProviderHolder holder = activityManager.getContentProviderExternal(
-                            "settings", UserHandle.USER_OWNER, token);
+                            "settings", UserHandle.USER_SYSTEM, token);
                     if (holder == null) {
                         throw new IllegalStateException("Could not find settings provider");
                     }
@@ -291,7 +291,8 @@
         System.err.println("        settings [--user NUM] delete namespace key");
         System.err.println("        settings [--user NUM] list namespace");
         System.err.println("\n'namespace' is one of {system, secure, global}, case-insensitive");
-        System.err.println("If '--user NUM' is not given, the operations are performed on the owner user.");
+        System.err.println("If '--user NUM' is not given, the operations are performed on the"
+                + "system user.");
     }
 
     public static String resolveCallingPackage() {
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/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 78e1b76..8c25c58 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -2506,11 +2506,11 @@
      *
      * @hide
      */
-    @SystemApi
     @RequiresPermission(Manifest.permission.KILL_UID)
     public void killUid(int uid, String reason) {
         try {
-            ActivityManagerNative.getDefault().killUid(uid, reason);
+            ActivityManagerNative.getDefault().killUid(UserHandle.getAppId(uid),
+                    UserHandle.getUserId(uid), reason);
         } catch (RemoteException e) {
             Log.e(TAG, "Couldn't kill uid:" + uid, e);
         }
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 4232db4..0950a16 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -2263,9 +2263,10 @@
 
         case KILL_UID_TRANSACTION: {
             data.enforceInterface(IActivityManager.descriptor);
-            int uid = data.readInt();
+            int appId = data.readInt();
+            int userId = data.readInt();
             String reason = data.readString();
-            killUid(uid, reason);
+            killUid(appId, userId, reason);
             reply.writeNoException();
             return true;
         }
@@ -5566,11 +5567,12 @@
         return res;
     }
 
-    public void killUid(int uid, String reason) throws RemoteException {
+    public void killUid(int appId, int userId, String reason) throws RemoteException {
         Parcel data = Parcel.obtain();
         Parcel reply = Parcel.obtain();
         data.writeInterfaceToken(IActivityManager.descriptor);
-        data.writeInt(uid);
+        data.writeInt(appId);
+        data.writeInt(userId);
         data.writeString(reason);
         mRemote.transact(KILL_UID_TRANSACTION, data, reply, 0);
         reply.readException();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 00e397d..b32e54c 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -449,7 +449,7 @@
 
     public boolean showAssistFromActivity(IBinder token, Bundle args) throws RemoteException;
 
-    public void killUid(int uid, String reason) throws RemoteException;
+    public void killUid(int appId, int userId, String reason) throws RemoteException;
 
     public void hang(IBinder who, boolean allowRestart) throws RemoteException;
 
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/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/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index 9f5184d..364c0eb 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -27,6 +27,12 @@
  *  {@hide}
  */
 interface IUserManager {
+
+    /*
+     * DO NOT MOVE - UserManager.h depends on the ordering of this function.
+     */
+    int getCredentialOwnerProfile(int userHandle);
+
     UserInfo createUser(in String name, int flags);
     UserInfo createProfileForUser(in String name, int flags, int userHandle);
     void setUserEnabled(int userHandle);
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index b7c049a..aea5123 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -1095,6 +1095,22 @@
     }
 
     /**
+     * Returns the device credential owner id of the profile from
+     * which this method is called, or userHandle if called from a user that
+     * is not a profile.
+     *
+     * @hide
+     */
+    public int getCredentialOwnerProfile(int userHandle) {
+        try {
+            return mService.getCredentialOwnerProfile(userHandle);
+        } catch (RemoteException re) {
+            Log.w(TAG, "Could not get credential owner", re);
+            return -1;
+        }
+    }
+
+    /**
      * Returns the parent of the profile which this method is called from
      * or null if called from a user that is not a profile.
      *
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 37d082f..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;
 
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/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..24fc6f2 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -1308,7 +1308,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..8132dee 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;
@@ -1754,45 +1755,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 +1779,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/android/widget/Switch.java b/core/java/android/widget/Switch.java
index e672fc3..9319af0 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -1026,9 +1026,9 @@
 
         if (newState != oldState) {
             playSoundEffect(SoundEffectConstants.CLICK);
-            setChecked(newState);
         }
-
+        // Always call setChecked so that the thumb is moved back to the correct edge
+        setChecked(newState);
         cancelSuperTouch(ev);
     }
 
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_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 2fbf6bf..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.
@@ -2585,7 +2584,7 @@
     <permission android:name="android.permission.QUERY_DO_NOT_ASK_CREDENTIALS_ON_BOOT"
                 android:protectionLevel="signature" />
 
-    <!-- @SystemApi Allows applications to kill UIDs.
+    <!-- Allows applications to kill UIDs.
         <p>Not for use by third-party applications.
          @hide -->
     <permission android:name="android.permission.KILL_UID"
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..9252024 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..89c6aae 100644
--- a/core/res/res/values-sw/strings.xml
+++ b/core/res/res/values-sw/strings.xml
@@ -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/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/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/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/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 789457d..b47fb30 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -419,8 +419,10 @@
         updateRecentsTasks();
 
         // If this is a new instance from a configuration change, then we have to manually trigger
-        // the enter animation state
-        if (mConfig.launchedHasConfigurationChanged) {
+        // the enter animation state, or if recents was relaunched by AM, without going through
+        // the normal mechanisms
+        boolean wasLaunchedByAm = !mConfig.launchedFromHome && !mConfig.launchedFromAppWithThumbnail;
+        if (mConfig.launchedHasConfigurationChanged || wasLaunchedByAm) {
             onEnterAnimationTriggered();
         }
 
@@ -454,6 +456,16 @@
 
         // Unregister any broadcast receivers for the task loader
         loader.unregisterReceivers();
+
+        // Workaround for b/22542869, if the RecentsActivity is started again, but without going
+        // through SystemUI, we need to reset the config launch flags to ensure that we do not
+        // wait on the system to send a signal that was never queued.
+        mConfig.launchedFromHome = false;
+        mConfig.launchedFromSearchHome = false;
+        mConfig.launchedFromAppWithThumbnail = false;
+        mConfig.launchedToTaskId = -1;
+        mConfig.launchedWithAltTab = false;
+        mConfig.launchedHasConfigurationChanged = false;
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 2253cad..400f167 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -603,7 +603,7 @@
 
         // Lastly, call to the icon policy to install/update all the icons.
         mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController,
-                mUserInfoController);
+                mUserInfoController, mBluetoothController);
         mIconPolicy.setCurrentUserSetup(mUserSetup);
         mSettingsObserver.onChange(false); // set up
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 53dae5c..540b9d0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -21,7 +21,6 @@
 import android.app.AlarmManager.AlarmClockInfo;
 import android.app.IUserSwitchObserver;
 import android.app.StatusBarManager;
-import android.bluetooth.BluetoothAdapter;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -41,6 +40,8 @@
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.systemui.R;
 import com.android.systemui.qs.tiles.DndTile;
+import com.android.systemui.statusbar.policy.BluetoothController;
+import com.android.systemui.statusbar.policy.BluetoothController.Callback;
 import com.android.systemui.statusbar.policy.CastController;
 import com.android.systemui.statusbar.policy.CastController.CastDevice;
 import com.android.systemui.statusbar.policy.HotspotController;
@@ -51,7 +52,7 @@
  * bar at boot time.  It goes through the normal API for icons, even though it probably
  * strictly doesn't need to.
  */
-public class PhoneStatusBarPolicy {
+public class PhoneStatusBarPolicy implements Callback {
     private static final String TAG = "PhoneStatusBarPolicy";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
@@ -82,12 +83,11 @@
 
     private int mZen;
 
-    private boolean mBluetoothEnabled = false;
-
     private boolean mManagedProfileFocused = false;
     private boolean mManagedProfileIconVisible = true;
 
     private boolean mKeyguardVisible = true;
+    private BluetoothController mBluetooth;
 
     private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
         @Override
@@ -96,10 +96,6 @@
             if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
                 updateAlarm();
             }
-            else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) ||
-                    action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
-                updateBluetooth();
-            }
             else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
                     action.equals(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)) {
                 updateVolumeZen();
@@ -114,10 +110,12 @@
     };
 
     public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot,
-            UserInfoController userInfoController) {
+            UserInfoController userInfoController, BluetoothController bluetooth) {
         mContext = context;
         mCast = cast;
         mHotspot = hotspot;
+        mBluetooth = bluetooth;
+        mBluetooth.addStateChangedCallback(this);
         mService = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
         mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
         mUserInfoController = userInfoController;
@@ -127,8 +125,6 @@
         filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
         filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
         filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
-        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
-        filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
         filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
         filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
         mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
@@ -275,23 +271,31 @@
         updateAlarm();
     }
 
+    @Override
+    public void onBluetoothDevicesChanged() {
+        updateBluetooth();
+    }
+
+    @Override
+    public void onBluetoothStateChange(boolean enabled) {
+        updateBluetooth();
+    }
+
     private final void updateBluetooth() {
-        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
         int iconId = R.drawable.stat_sys_data_bluetooth;
         String contentDescription =
                 mContext.getString(R.string.accessibility_quick_settings_bluetooth_on);
-        if (adapter != null) {
-            mBluetoothEnabled = (adapter.getState() == BluetoothAdapter.STATE_ON);
-            if (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED) {
+        boolean bluetoothEnabled = false;
+        if (mBluetooth != null) {
+            bluetoothEnabled = mBluetooth.isBluetoothEnabled();
+            if (mBluetooth.isBluetoothConnected()) {
                 iconId = R.drawable.stat_sys_data_bluetooth_connected;
                 contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected);
             }
-        } else {
-            mBluetoothEnabled = false;
         }
 
         mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription);
-        mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
+        mService.setIconVisibility(SLOT_BLUETOOTH, bluetoothEnabled);
     }
 
     private final void updateTTY(Intent intent) {
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 147a5fd..72892a2 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -4141,7 +4141,7 @@
         final Intent intent;
         final int userId;
         synchronized (this) {
-            task = mRecentTasks.taskForIdLocked(taskId);
+            task = mStackSupervisor.anyTaskForIdLocked(taskId);
             if (task == null) {
                 throw new IllegalArgumentException("Task " + taskId + " not found.");
             }
@@ -5527,7 +5527,7 @@
                 // If no package is specified, we call all processes under the
                 // give user id.
                 if (packageName == null) {
-                    if (app.userId != userId) {
+                    if (userId != UserHandle.USER_ALL && app.userId != userId) {
                         continue;
                     }
                     if (appId >= 0 && UserHandle.getAppId(app.uid) != appId) {
@@ -8839,7 +8839,7 @@
             final long origId = Binder.clearCallingIdentity();
             try {
                 int taskId = ActivityRecord.getTaskForActivityLocked(token, !nonRoot);
-                final TaskRecord task = mRecentTasks.taskForIdLocked(taskId);
+                final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
                 if (task != null) {
                     if (mStackSupervisor.isLockedTask(task)) {
                         mStackSupervisor.showLockTaskToast();
@@ -11325,13 +11325,12 @@
     }
 
     @Override
-    public void killUid(int uid, String reason) {
+    public void killUid(int appId, int userId, String reason) {
         enforceCallingPermission(Manifest.permission.KILL_UID, "killUid");
         synchronized (this) {
             final long identity = Binder.clearCallingIdentity();
             try {
-                killPackageProcessesLocked(null, UserHandle.getAppId(uid),
-                        UserHandle.getUserId(uid),
+                killPackageProcessesLocked(null, appId, userId,
                         ProcessList.PERSISTENT_PROC_ADJ, false, true, true, true,
                         reason != null ? reason : "kill uid");
             } finally {
@@ -20807,7 +20806,7 @@
             synchronized (ActivityManagerService.this) {
                 long origId = Binder.clearCallingIdentity();
                 try {
-                    TaskRecord tr = mRecentTasks.taskForIdLocked(mTaskId);
+                    TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(mTaskId);
                     if (tr == null) {
                         throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
                     }
@@ -20834,7 +20833,7 @@
             TaskRecord tr;
             IApplicationThread appThread;
             synchronized (ActivityManagerService.this) {
-                tr = mRecentTasks.taskForIdLocked(mTaskId);
+                tr = mStackSupervisor.anyTaskForIdLocked(mTaskId);
                 if (tr == null) {
                     throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
                 }
@@ -20855,7 +20854,7 @@
             synchronized (ActivityManagerService.this) {
                 long origId = Binder.clearCallingIdentity();
                 try {
-                    TaskRecord tr = mRecentTasks.taskForIdLocked(mTaskId);
+                    TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(mTaskId);
                     if (tr == null) {
                         throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
                     }
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index e083709..8abebe4 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -25,6 +25,8 @@
 import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
 import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
 
+import static com.android.server.am.ActivityStackSupervisor.MOVING;
+
 import android.graphics.Rect;
 import android.util.ArraySet;
 import android.view.IApplicationToken;
@@ -4306,18 +4308,18 @@
     }
 
     void removeTask(TaskRecord task, String reason) {
-        removeTask(task, reason, true /* notMoving */);
+        removeTask(task, reason, !MOVING);
     }
 
     /**
      * Removes the input task from this stack.
      * @param task to remove.
      * @param reason for removal.
-     * @param notMoving task to another stack. In the case we are moving we don't want to perform
-     *                  some operations on the task like removing it from window manager or recents.
+     * @param moving task to another stack. In the case we are moving we don't want to perform
+     *               some operations on the task like removing it from window manager or recents.
      */
-    void removeTask(TaskRecord task, String reason, boolean notMoving) {
-        if (notMoving) {
+    void removeTask(TaskRecord task, String reason, boolean moving) {
+        if (!moving) {
             mStackSupervisor.removeLockedTaskLocked(task);
             mWindowManager.removeTask(task.taskId);
         }
@@ -4338,7 +4340,7 @@
         mTaskHistory.remove(task);
         updateTaskMovement(task, true);
 
-        if (notMoving && task.mActivities.isEmpty()) {
+        if (!moving && task.mActivities.isEmpty()) {
             final boolean isVoiceSession = task.voiceSession != null;
             if (isVoiceSession) {
                 try {
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 4a0fd89..3ed9270 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -168,10 +168,22 @@
     static final int LAUNCH_TASK_BEHIND_COMPLETE = FIRST_SUPERVISOR_STACK_MSG + 12;
     static final int SHOW_LOCK_TASK_ESCAPE_MESSAGE_MSG = FIRST_SUPERVISOR_STACK_MSG + 13;
 
-    private final static String VIRTUAL_DISPLAY_BASE_NAME = "ActivityViewVirtualDisplay";
+    private static final String VIRTUAL_DISPLAY_BASE_NAME = "ActivityViewVirtualDisplay";
 
     private static final String LOCK_TASK_TAG = "Lock-to-App";
 
+    // Used to indicate if an object (e.g. stack) that we are trying to get
+    // should be created if it doesn't exist already.
+    private static final boolean CREATE_IF_NEEDED = true;
+
+    // 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;
+
+    // Used to indicate that an objects (e.g. task) removal from its container
+    // (e.g. stack) is due to it moving to another container.
+    static final boolean MOVING = true;
+
     // Activity actions an app cannot start if it uses a permission which is not granted.
     private static final ArrayMap<String, String> ACTION_TO_RUNTIME_PERMISSION =
             new ArrayMap<>();
@@ -1506,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;
                 }
             }
@@ -1520,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;
             }
         }
@@ -1797,8 +1817,7 @@
             stack = getStack(
                     task != null
                             ? task.getLaunchStackId(mFocusedStack) : FULLSCREEN_WORKSPACE_STACK_ID,
-                    true /*createStaticStackIfNeeded*/,
-                    true /*createOnTop*/);
+                    CREATE_IF_NEEDED, ON_TOP);
             if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS, "computeStackFocus: New stack r="
                     + r + " stackId=" + stack.mStackId);
             return stack;
@@ -2785,7 +2804,7 @@
     }
 
     ActivityStack getStack(int stackId) {
-        return getStack(stackId, false /*createStaticStackIfNeeded*/, false /*createOnTop*/);
+        return getStack(stackId, !CREATE_IF_NEEDED, !ON_TOP);
     }
 
     ActivityStack getStack(int stackId, boolean createStaticStackIfNeeded, boolean createOnTop) {
@@ -2930,6 +2949,19 @@
             return;
         }
 
+        // The stack of a task is determined by its size (fullscreen vs non-fullscreen).
+        // Place the task in the right stack if it isn't there already based on the requested
+        // bounds.
+        int stackId = task.stack.mStackId;
+        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 Configuration overrideConfig = mWindowManager.resizeTask(task.taskId, bounds);
         if (task.updateOverrideConfiguration(overrideConfig, bounds)) {
             ActivityRecord r = task.topRunningActivityLocked(null);
@@ -2980,11 +3012,11 @@
             }
             // Remove current stack association, so we can re-associate the task with the
             // right stack below.
-            task.stack.removeTask(task, "restoreRecentTaskLocked", false /*notMoving*/);
+            task.stack.removeTask(task, "restoreRecentTaskLocked", MOVING);
         }
 
         ActivityStack stack =
-                getStack(stackId, true /*createStaticStackIfNeeded*/, false /*createOnTop*/);
+                getStack(stackId, CREATE_IF_NEEDED, !ON_TOP);
 
         if (stack == null) {
             // What does this mean??? Not sure how we would get here...
@@ -3003,6 +3035,30 @@
         return true;
     }
 
+    /**
+     * Moves the specified task record to the input stack id.
+     * WARNING: This method performs an unchecked/raw move of the task and
+     * can leave the system in an unstable state if used incorrectly.
+     * Use {@link #moveTaskToStackLocked} to perform safe task movement
+     * to a stack.
+     * @param task Task to move.
+     * @param stackId Id of stack to move task to.
+     * @param toTop True if the task should be placed at the top of the stack.
+     * @param reason Reason the task is been moved.
+     * @return The stack the task was moved to.
+     */
+    private ActivityStack moveTaskToStackUncheckedLocked(
+            TaskRecord task, int stackId, boolean toTop, String reason) {
+        final ActivityStack stack =
+                getStack(stackId, CREATE_IF_NEEDED, toTop);
+        mWindowManager.moveTaskToStack(task.taskId, stack.mStackId, toTop);
+        if (task.stack != null) {
+            task.stack.removeTask(task, reason, MOVING);
+        }
+        stack.addTask(task, toTop, MOVING);
+        return stack;
+    }
+
     void moveTaskToStackLocked(int taskId, int stackId, boolean toTop) {
         final TaskRecord task = anyTaskForIdLocked(taskId);
         if (task == null) {
@@ -3010,12 +3066,7 @@
             return;
         }
         ActivityStack stack =
-                getStack(stackId, true /*createStaticStackIfNeeded*/, toTop /*createOnTop*/);
-        mWindowManager.moveTaskToStack(taskId, stackId, toTop);
-        if (task.stack != null) {
-            task.stack.removeTask(task, "moveTaskToStack", false /* notMoving */);
-        }
-        stack.addTask(task, toTop, true);
+                moveTaskToStackUncheckedLocked(task, stackId, toTop, "moveTaskToStack");
 
         // Make sure the task has the appropriate bounds/size for the stack it is in.
         if (stackId == FULLSCREEN_WORKSPACE_STACK_ID && task.mBounds != null) {
@@ -3038,11 +3089,11 @@
             return;
         }
         ActivityStack stack =
-                getStack(stackId, true /*createStaticStackIfNeeded*/, false /*createOnTop*/);
+                getStack(stackId, CREATE_IF_NEEDED, !ON_TOP);
         mWindowManager.positionTaskInStack(taskId, stackId, position);
         final boolean stackChanged = task.stack != null && task.stack != stack;
         if (stackChanged) {
-            task.stack.removeTask(task, "moveTaskToStack", false /* notMoving */);
+            task.stack.removeTask(task, "moveTaskToStack", MOVING);
         }
         stack.positionTask(task, position, stackChanged);
         // The task might have already been running and its visibility needs to be synchronized with
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index a8c8dce..1475f2f 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -5151,7 +5151,9 @@
                 continue;
             }
             try {
-                ActivityManagerNative.getDefault().killUid(pkg.applicationInfo.uid,
+                final int uid = pkg.applicationInfo.uid;
+                ActivityManagerNative.getDefault().killUid(UserHandle.getAppId(uid),
+                        UserHandle.getUserId(uid),
                         "killBackgroundUserProcessesWithAudioRecordPermission");
             } catch (RemoteException e) {
                 Log.w(TAG, "Error calling killUid", e);
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 3b9f402..dc6e17d 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3488,10 +3488,11 @@
                 }
 
                 case PermissionsState.PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED: {
+                    final int appId = UserHandle.getAppId(pkg.applicationInfo.uid);
                     mHandler.post(new Runnable() {
                         @Override
                         public void run() {
-                            killSettingPackagesForUser(sb, userId, KILL_APP_REASON_GIDS_CHANGED);
+                            killUid(appId, userId, KILL_APP_REASON_GIDS_CHANGED);
                         }
                     });
                 } break;
@@ -3535,7 +3536,7 @@
         enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
                 "revokeRuntimePermission");
 
-        final SettingBase sb;
+        final int appId;
 
         synchronized (mPackages) {
             final PackageParser.Package pkg = mPackages.get(packageName);
@@ -3550,7 +3551,7 @@
 
             enforceDeclaredAsUsedAndRuntimePermission(pkg, bp);
 
-            sb = (SettingBase) pkg.mExtras;
+            SettingBase sb = (SettingBase) pkg.mExtras;
             if (sb == null) {
                 throw new IllegalArgumentException("Unknown package: " + packageName);
             }
@@ -3572,9 +3573,11 @@
 
             // Critical, after this call app should never have the permission.
             mSettings.writeRuntimePermissionsForUserLPr(userId, true);
+
+            appId = UserHandle.getAppId(pkg.applicationInfo.uid);
         }
 
-        killSettingPackagesForUser(sb, userId, KILL_APP_REASON_PERMISSIONS_REVOKED);
+        killUid(appId, userId, KILL_APP_REASON_PERMISSIONS_REVOKED);
     }
 
     @Override
@@ -3878,28 +3881,15 @@
         }
     }
 
-    private void killSettingPackagesForUser(SettingBase sb, int userId, String reason) {
+    private void killUid(int appId, int userId, String reason) {
         final long identity = Binder.clearCallingIdentity();
         try {
-            if (sb instanceof SharedUserSetting) {
-                SharedUserSetting sus = (SharedUserSetting) sb;
-                final int packageCount = sus.packages.size();
-                for (int i = 0; i < packageCount; i++) {
-                    PackageSetting susPs = sus.packages.valueAt(i);
-                    if (userId == UserHandle.USER_ALL) {
-                        killApplication(susPs.pkg.packageName, susPs.appId, reason);
-                    } else {
-                        final int uid = UserHandle.getUid(userId, susPs.appId);
-                        killUid(uid, reason);
-                    }
-                }
-            } else if (sb instanceof PackageSetting) {
-                PackageSetting ps = (PackageSetting) sb;
-                if (userId == UserHandle.USER_ALL) {
-                    killApplication(ps.pkg.packageName, ps.appId, reason);
-                } else {
-                    final int uid = UserHandle.getUid(userId, ps.appId);
-                    killUid(uid, reason);
+            IActivityManager am = ActivityManagerNative.getDefault();
+            if (am != null) {
+                try {
+                    am.killUid(appId, userId, reason);
+                } catch (RemoteException e) {
+                    /* ignore - same process */
                 }
             }
         } finally {
@@ -3907,17 +3897,6 @@
         }
     }
 
-    private static void killUid(int uid, String reason) {
-        IActivityManager am = ActivityManagerNative.getDefault();
-        if (am != null) {
-            try {
-                am.killUid(uid, reason);
-            } catch (RemoteException e) {
-                /* ignore - same process */
-            }
-        }
-    }
-
     /**
      * Compares two sets of signatures. Returns:
      * <br />
@@ -12933,7 +12912,7 @@
                                     @Override
                                     public void run() {
                                         // This has to happen with no lock held.
-                                        killSettingPackagesForUser(deletedPs, userIdToKill,
+                                        killApplication(deletedPs.name, deletedPs.appId,
                                                 KILL_APP_REASON_GIDS_CHANGED);
                                     }
                                 });
@@ -13054,6 +13033,10 @@
         synchronized (mPackages) {
             PackageSetting ps = mSettings.mPackages.get(newPkg.packageName);
 
+            // Propagate the permissions state as we do not want to drop on the floor
+            // runtime permissions. The update permissions method below will take
+            // care of removing obsolete permissions and grant install permissions.
+            ps.getPermissionsState().copyFrom(newPs.getPermissionsState());
             updatePermissionsLPw(newPkg.packageName, newPkg,
                     UPDATE_PERMISSIONS_ALL | UPDATE_PERMISSIONS_REPLACE_PKG);
 
@@ -13166,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
@@ -13174,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
@@ -13515,13 +13499,11 @@
 
                     case PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED: {
                         writeRuntimePermissions = true;
-                        // If gids changed for this user, kill all affected packages.
+                        final int appId = ps.appId;
                         mHandler.post(new Runnable() {
                             @Override
                             public void run() {
-                                // This has to happen with no lock held.
-                                killSettingPackagesForUser(ps, userId,
-                                        KILL_APP_REASON_GIDS_CHANGED);
+                                killUid(appId, userId, KILL_APP_REASON_GIDS_CHANGED);
                             }
                         });
                     } break;
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 c75ef875..fcfb5e8 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -136,6 +136,11 @@
     // without first making sure that the rest of the framework is prepared for it.
     private static final int MAX_MANAGED_PROFILES = 1;
 
+    /**
+     * Flag indicating whether device credentials are shared among same-user profiles.
+     */
+    private static final boolean CONFIG_PROFILES_SHARE_CREDENTIAL = true;
+
     // Set of user restrictions, which can only be enforced by the system
     private static final Set<String> SYSTEM_CONTROLLED_RESTRICTIONS = Sets.newArraySet(
             UserManager.DISALLOW_RECORD_AUDIO);
@@ -242,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);
                 }
@@ -332,6 +337,21 @@
     }
 
     @Override
+    public int getCredentialOwnerProfile(int userHandle) {
+        checkManageUsersPermission("get the credential owner");
+        if (CONFIG_PROFILES_SHARE_CREDENTIAL) {
+            synchronized (mPackagesLock) {
+                UserInfo profileParent = getProfileParentLocked(userHandle);
+                if (profileParent != null) {
+                    return profileParent.id;
+                }
+            }
+        }
+
+        return userHandle;
+    }
+
+    @Override
     public UserInfo getProfileParent(int userHandle) {
         checkManageUsersPermission("get the profile parent");
         synchronized (mPackagesLock) {
@@ -964,7 +984,7 @@
         }
     }
 
-    private void writeRestrictionsLocked(XmlSerializer serializer, Bundle restrictions) 
+    private void writeRestrictionsLocked(XmlSerializer serializer, Bundle restrictions)
             throws IOException {
         serializer.startTag(null, TAG_RESTRICTIONS);
         writeBoolean(serializer, restrictions, UserManager.DISALLOW_CONFIG_WIFI);
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index 43f4047..2a12aac 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -122,7 +122,7 @@
     private final SparseBooleanArray mUserHasAuthenticatedSinceBoot = new SparseBooleanArray();
 
     private boolean mTrustAgentsCanRun = false;
-    private int mCurrentUser = UserHandle.USER_OWNER;
+    private int mCurrentUser = UserHandle.USER_SYSTEM;
 
     public TrustManagerService(Context context) {
         super(context);
@@ -150,7 +150,7 @@
             mTrustAgentsCanRun = true;
             refreshAgentList(UserHandle.USER_ALL);
         } else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
-            maybeEnableFactoryTrustAgents(mLockPatternUtils, UserHandle.USER_OWNER);
+            maybeEnableFactoryTrustAgents(mLockPatternUtils, UserHandle.USER_SYSTEM);
         }
     }
 
@@ -205,7 +205,7 @@
         if (!mTrustAgentsCanRun) {
             return;
         }
-        if (userId != UserHandle.USER_ALL && userId < UserHandle.USER_OWNER) {
+        if (userId != UserHandle.USER_ALL && userId < UserHandle.USER_SYSTEM) {
             Log.e(TAG, "refreshAgentList(userId=" + userId + "): Invalid user handle,"
                     + " must be USER_ALL or a specific user.", new Throwable("here"));
             userId = UserHandle.USER_ALL;
@@ -296,7 +296,7 @@
     }
 
     private void refreshDeviceLockedForUser(int userId) {
-        if (userId != UserHandle.USER_ALL && userId < UserHandle.USER_OWNER) {
+        if (userId != UserHandle.USER_ALL && userId < UserHandle.USER_SYSTEM) {
             Log.e(TAG, "refreshDeviceLockedForUser(userId=" + userId + "): Invalid user handle,"
                     + " must be USER_ALL or a specific user.", new Throwable("here"));
             userId = UserHandle.USER_ALL;
@@ -689,7 +689,7 @@
         @Override
         public void reportRequireCredentialEntry(int userId) throws RemoteException {
             enforceReportPermission();
-            if (userId == UserHandle.USER_ALL || userId >= UserHandle.USER_OWNER) {
+            if (userId == UserHandle.USER_ALL || userId >= UserHandle.USER_SYSTEM) {
                 mHandler.obtainMessage(MSG_REQUIRE_CREDENTIAL_ENTRY, userId, 0).sendToTarget();
             } else {
                 throw new IllegalArgumentException(
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.
      */
diff --git a/tools/layoutlib/.idea/inspectionProfiles/Project_Default.xml b/tools/layoutlib/.idea/inspectionProfiles/Project_Default.xml
index 0ac7a44..5bb3e3e 100644
--- a/tools/layoutlib/.idea/inspectionProfiles/Project_Default.xml
+++ b/tools/layoutlib/.idea/inspectionProfiles/Project_Default.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <component name="InspectionProjectProfileManager">
   <profile version="1.0" is_locked="false">
     <option name="myName" value="Project Default" />
@@ -7,5 +8,6 @@
       <option name="CHECK_TRY_CATCH_SECTION" value="true" />
       <option name="CHECK_METHOD_BODY" value="true" />
     </inspection_tool>
+    <inspection_tool class="ToArrayCallWithZeroLengthArrayArgument" enabled="false" level="WARNING" enabled_by_default="false" />
   </profile>
 </component>
\ No newline at end of file
diff --git a/tools/layoutlib/bridge/src/android/widget/SimpleMonthView_Delegate.java b/tools/layoutlib/bridge/src/android/widget/SimpleMonthView_Delegate.java
new file mode 100644
index 0000000..8e41e51
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/widget/SimpleMonthView_Delegate.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.widget;
+
+import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.icu.text.SimpleDateFormat;
+import android.text.format.DateFormat;
+
+import java.util.Calendar;
+import java.util.Locale;
+
+/**
+ * Delegate that provides implementation for some methods in {@link SimpleMonthView}.
+ * <p/>
+ * Through the layoutlib_create tool, selected methods of SimpleMonthView have been replaced by
+ * calls to methods of the same name in this delegate class.
+ * <p/>
+ * The main purpose of this class is to use {@link android.icu.text.SimpleDateFormat} instead of
+ * {@link java.text.SimpleDateFormat}.
+ */
+public class SimpleMonthView_Delegate {
+
+    private static final String DEFAULT_TITLE_FORMAT = "MMMMy";
+    private static final String DAY_OF_WEEK_FORMAT = "EEEEE";
+
+    // Maintain a cache of the last view used, so that the formatters can be reused.
+    @Nullable private static SimpleMonthView sLastView;
+    @Nullable private static SimpleMonthView_Delegate sLastDelegate;
+
+    private SimpleDateFormat mTitleFormatter;
+    private SimpleDateFormat mDayOfWeekFormatter;
+
+    private Locale locale;
+
+    @LayoutlibDelegate
+    /*package*/ static CharSequence getTitle(SimpleMonthView view) {
+        if (view.mTitle == null) {
+            SimpleMonthView_Delegate delegate = getDelegate(view);
+            if (delegate.mTitleFormatter == null) {
+                delegate.mTitleFormatter = new SimpleDateFormat(DateFormat.getBestDateTimePattern(
+                        getLocale(delegate, view), DEFAULT_TITLE_FORMAT));
+            }
+            view.mTitle = delegate.mTitleFormatter.format(view.mCalendar.getTime());
+        }
+        return view.mTitle;
+    }
+
+    @LayoutlibDelegate
+    /*package*/ static String getDayOfWeekLabel(SimpleMonthView view, int dayOfWeek) {
+        view.mDayOfWeekLabelCalendar.set(Calendar.DAY_OF_WEEK, dayOfWeek);
+        SimpleMonthView_Delegate delegate = getDelegate(view);
+        if (delegate.mDayOfWeekFormatter == null) {
+            delegate.mDayOfWeekFormatter =
+                    new SimpleDateFormat(DAY_OF_WEEK_FORMAT, getLocale(delegate, view));
+        }
+        return delegate.mDayOfWeekFormatter.format(view.mDayOfWeekLabelCalendar.getTime());
+    }
+
+    private static Locale getLocale(SimpleMonthView_Delegate delegate, SimpleMonthView view) {
+        if (delegate.locale == null) {
+            delegate.locale = view.getContext().getResources().getConfiguration().locale;
+        }
+        return delegate.locale;
+    }
+
+    @NonNull
+    private static SimpleMonthView_Delegate getDelegate(SimpleMonthView view) {
+        if (view == sLastView) {
+            assert sLastDelegate != null;
+            return sLastDelegate;
+        } else {
+            sLastView = view;
+            sLastDelegate = new SimpleMonthView_Delegate();
+            return sLastDelegate;
+        }
+    }
+
+    public static void clearCache() {
+        sLastView = null;
+        sLastDelegate = null;
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java
index e589d9e..faaf105 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java
@@ -16,6 +16,8 @@
 
 package com.android.layoutlib.bridge.android;
 
+import com.android.layoutlib.bridge.impl.RenderAction;
+
 import android.icu.util.ULocale;
 
 import java.util.Locale;
@@ -56,4 +58,15 @@
     public static String getScript(Locale locale) {
         return ULocale.forLocale(locale).getScript();
     }
+
+    public static Locale getDefault() {
+        BridgeContext context = RenderAction.getCurrentContext();
+        if (context != null) {
+            Locale locale = context.getConfiguration().locale;
+            if (locale != null) {
+                return locale;
+            }
+        }
+        return Locale.getDefault();
+    }
 }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
index 9380ca7..92b39e3 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -36,7 +36,9 @@
 import android.view.ViewConfiguration_Accessor;
 import android.view.inputmethod.InputMethodManager;
 import android.view.inputmethod.InputMethodManager_Accessor;
+import android.widget.SimpleMonthView_Delegate;
 
+import java.util.Locale;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -276,6 +278,7 @@
             mContext.getRenderResources().setLogger(null);
         }
         ParserFactory.setParserFactory(null);
+        SimpleMonthView_Delegate.clearCache();
     }
 
     public static BridgeContext getCurrentContext() {
@@ -397,6 +400,8 @@
             // preview releases of API 15.
             // TODO: Remove the try catch around Oct 2015.
         }
+        String locale = getParams().getLocale();
+        if (locale != null && !locale.isEmpty()) config.locale = new Locale(locale);
 
         // TODO: fill in more config info.
 
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
index f6c2626..8f0ad01 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
@@ -77,6 +77,8 @@
     /** Methods to inject. FQCN of class in which method should be injected => runnable that does
      * the injection. */
     private final Map<String, ICreateInfo.InjectMethodRunnable> mInjectedMethodsMap;
+    /** A map { FQCN => set { field names } } which should be promoted to public visibility */
+    private final Map<String, Set<String>> mPromotedFields;
 
     /**
      * Creates a new generator that can generate the output JAR with the stubbed classes.
@@ -109,20 +111,8 @@
 
         // Create the map/set of methods to change to delegates
         mDelegateMethods = new HashMap<String, Set<String>>();
-        for (String signature : createInfo.getDelegateMethods()) {
-            int pos = signature.indexOf('#');
-            if (pos <= 0 || pos >= signature.length() - 1) {
-                continue;
-            }
-            String className = binaryToInternalClassName(signature.substring(0, pos));
-            String methodName = signature.substring(pos + 1);
-            Set<String> methods = mDelegateMethods.get(className);
-            if (methods == null) {
-                methods = new HashSet<String>();
-                mDelegateMethods.put(className, methods);
-            }
-            methods.add(methodName);
-        }
+        addToMap(createInfo.getDelegateMethods(), mDelegateMethods);
+
         for (String className : createInfo.getDelegateClassNatives()) {
             className = binaryToInternalClassName(className);
             Set<String> methods = mDelegateMethods.get(className);
@@ -187,10 +177,34 @@
             returnTypes.add(binaryToInternalClassName(className));
         }
 
+        mPromotedFields = new HashMap<String, Set<String>>();
+        addToMap(createInfo.getPromotedFields(), mPromotedFields);
+
         mInjectedMethodsMap = createInfo.getInjectedMethodsMap();
     }
 
     /**
+     * For each value in the array, split the value on '#' and add the parts to the map as key
+     * and value.
+     */
+    private void addToMap(String[] entries, Map<String, Set<String>> map) {
+        for (String entry : entries) {
+            int pos = entry.indexOf('#');
+            if (pos <= 0 || pos >= entry.length() - 1) {
+                return;
+            }
+            String className = binaryToInternalClassName(entry.substring(0, pos));
+            String methodOrFieldName = entry.substring(pos + 1);
+            Set<String> set = map.get(className);
+            if (set == null) {
+                set = new HashSet<String>();
+                map.put(className, set);
+            }
+            set.add(methodOrFieldName);
+        }
+    }
+
+    /**
      * Returns the list of classes that have not been renamed yet.
      * <p/>
      * The names are "internal class names" rather than FQCN, i.e. they use "/" instead "."
@@ -380,6 +394,10 @@
             }
         }
 
+        Set<String> promoteFields = mPromotedFields.get(className);
+        if (promoteFields != null && !promoteFields.isEmpty()) {
+            cv = new PromoteFieldClassAdapter(cv, promoteFields);
+        }
         cr.accept(cv, 0);
         return cw.toByteArray();
     }
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 499bea4..484240f 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -120,6 +120,11 @@
     }
 
     @Override
+    public String[] getPromotedFields() {
+        return PROMOTED_FIELDS;
+    }
+
+    @Override
     public Map<String, InjectMethodRunnable> getInjectedMethodsMap() {
         return INJECTED_METHODS;
     }
@@ -185,6 +190,8 @@
         "android.view.RenderNode#nSetElevation",
         "android.view.RenderNode#nGetElevation",
         "android.view.ViewGroup#drawChild",
+        "android.widget.SimpleMonthView#getTitle",
+        "android.widget.SimpleMonthView#getDayOfWeekLabel",
         "android.widget.TimePickerClockDelegate#getAmOrPmKeyCode",
         "com.android.internal.view.menu.MenuBuilder#createNewMenuItem",
         "com.android.internal.util.XmlUtils#convertValueToInt",
@@ -289,6 +296,12 @@
             "org.kxml2.io.KXmlParser"
         };
 
+    private final static String[] PROMOTED_FIELDS = new String[] {
+        "android.widget.SimpleMonthView#mTitle",
+        "android.widget.SimpleMonthView#mCalendar",
+        "android.widget.SimpleMonthView#mDayOfWeekLabelCalendar"
+    };
+
     /**
      * List of classes for which the methods returning them should be deleted.
      * The array contains a list of null terminated section starting with the name of the class
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ICreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ICreateInfo.java
index 54b1fe6..6c62423 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ICreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ICreateInfo.java
@@ -78,6 +78,13 @@
     Set<String> getExcludedClasses();
 
     /**
+     * Returns a list of fields which should be promoted to public visibility. The array values
+     * are in the form of the binary FQCN of the class containing the field and the field name
+     * separated by a '#'.
+     */
+    String[] getPromotedFields();
+
+    /**
      * Returns a map from binary FQCN className to {@link InjectMethodRunnable} which will be
      * called to inject methods into a class.
      * Can be empty but must not be null.
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/PromoteFieldClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/PromoteFieldClassAdapter.java
new file mode 100644
index 0000000..e4b70da
--- /dev/null
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/PromoteFieldClassAdapter.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.layoutlib.create;
+
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+
+import java.util.Set;
+
+import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
+import static org.objectweb.asm.Opcodes.ACC_PROTECTED;
+import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static org.objectweb.asm.Opcodes.ASM4;
+
+/**
+ * Promotes given fields to public visibility.
+ */
+public class PromoteFieldClassAdapter extends ClassVisitor {
+
+    private final Set<String> mFieldNames;
+    private static final int ACC_NOT_PUBLIC = ~(ACC_PRIVATE | ACC_PROTECTED);
+
+    public PromoteFieldClassAdapter(ClassVisitor cv, Set<String> fieldNames) {
+        super(ASM4, cv);
+        mFieldNames = fieldNames;
+    }
+
+    @Override
+    public FieldVisitor visitField(int access, String name, String desc, String signature,
+            Object value) {
+        if (mFieldNames.contains(name)) {
+            if ((access & ACC_PUBLIC) == 0) {
+                access = (access & ACC_NOT_PUBLIC) | ACC_PUBLIC;
+            }
+        }
+        return super.visitField(access, name, desc, signature, value);
+    }
+}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
index 4369148..0b85c48 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
@@ -93,18 +93,22 @@
             }
         });
 
-        // Case 3: java.util.Locale.adjustLanguageCode() or java.util.Locale.forLanguageTag()
+        // Case 3: java.util.Locale.adjustLanguageCode() or java.util.Locale.forLanguageTag() or
+        // java.util.Locale.getDefault()
         METHOD_REPLACERS.add(new MethodReplacer() {
 
             private final String STRING_TO_STRING = Type.getMethodDescriptor(STRING, STRING);
             private final String STRING_TO_LOCALE = Type.getMethodDescriptor(
                     Type.getType(Locale.class), STRING);
+            private final String VOID_TO_LOCALE =
+                    Type.getMethodDescriptor(Type.getType(Locale.class));
 
             @Override
             public boolean isNeeded(String owner, String name, String desc, String sourceClass) {
                 return JAVA_LOCALE_CLASS.equals(owner) &&
                         ("adjustLanguageCode".equals(name) && desc.equals(STRING_TO_STRING) ||
-                        "forLanguageTag".equals(name) && desc.equals(STRING_TO_LOCALE));
+                        "forLanguageTag".equals(name) && desc.equals(STRING_TO_LOCALE) ||
+                        "getDefault".equals(name) && desc.equals(VOID_TO_LOCALE));
             }
 
             @Override
diff --git a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java
index 2c21470..8a2235b 100644
--- a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java
+++ b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java
@@ -138,6 +138,11 @@
             }
 
             @Override
+            public String[] getPromotedFields() {
+                return new String[0];
+            }
+
+            @Override
             public Map<String, InjectMethodRunnable> getInjectedMethodsMap() {
                 return new HashMap<String, InjectMethodRunnable>(0);
             }
@@ -213,6 +218,11 @@
             }
 
             @Override
+            public String[] getPromotedFields() {
+                return new String[0];
+            }
+
+            @Override
             public Map<String, InjectMethodRunnable> getInjectedMethodsMap() {
                 return new HashMap<String, InjectMethodRunnable>(0);
             }
@@ -296,6 +306,11 @@
             }
 
             @Override
+            public String[] getPromotedFields() {
+                return new String[0];
+            }
+
+            @Override
             public Map<String, InjectMethodRunnable> getInjectedMethodsMap() {
                 return new HashMap<String, InjectMethodRunnable>(0);
             }
@@ -374,6 +389,11 @@
             }
 
             @Override
+            public String[] getPromotedFields() {
+                return new String[0];
+            }
+
+            @Override
             public Map<String, InjectMethodRunnable> getInjectedMethodsMap() {
                 HashMap<String, InjectMethodRunnable> map =
                         new HashMap<String, InjectMethodRunnable>(1);