Merge "Mark WIFI_AP_STATE_CHANGED_ACTION and extras @SystemApi."
diff --git a/Android.mk b/Android.mk
index 2673cd8..137ef85 100644
--- a/Android.mk
+++ b/Android.mk
@@ -713,8 +713,6 @@
 	$(filter-out $(patterns_to_not_document), $(call find-other-java-files, $(dirs_to_document))) \
 	$(common_src_files)
 
-#	$(call find-other-java-files, $(dirs_to_document)) \
-
 # These are relative to frameworks/base
 framework_docs_LOCAL_API_CHECK_SRC_FILES := \
 	$(call find-other-java-files, $(dirs_to_check_apis)) \
diff --git a/api/current.txt b/api/current.txt
index fac3b2b..e0dfb6c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -28068,8 +28068,9 @@
     method public boolean isSystemUser();
     method public boolean isUserAGoat();
     method public boolean isUserRunning(android.os.UserHandle);
+    method public boolean isUserRunningAndLocked(android.os.UserHandle);
+    method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
     method public boolean isUserRunningOrStopping(android.os.UserHandle);
-    method public boolean isUserRunningUnlocked(android.os.UserHandle);
     method public deprecated boolean setRestrictionsChallenge(java.lang.String);
     method public deprecated void setUserRestriction(java.lang.String, boolean);
     method public deprecated void setUserRestrictions(android.os.Bundle);
@@ -29635,6 +29636,7 @@
     ctor public ContactsContract.CommonDataKinds.Callable();
     field public static final android.net.Uri CONTENT_FILTER_URI;
     field public static final android.net.Uri CONTENT_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -29781,6 +29783,7 @@
     field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
     field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
     field public static final android.net.Uri CONTENT_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -29960,7 +29963,7 @@
     field public static final android.net.Uri CONTENT_URI;
     field public static final java.lang.String CONTENT_VCARD_TYPE = "text/x-vcard";
     field public static final android.net.Uri CONTENT_VCARD_URI;
-    field public static final android.net.Uri CORP_CONTENT_FILTER_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -30089,10 +30092,12 @@
     field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_directory";
     field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/contact_directories";
     field public static final android.net.Uri CONTENT_URI;
-    field public static final android.net.Uri CORP_CONTENT_URI;
     field public static final long DEFAULT = 0L; // 0x0L
     field public static final java.lang.String DIRECTORY_AUTHORITY = "authority";
     field public static final java.lang.String DISPLAY_NAME = "displayName";
+    field public static final android.net.Uri ENTERPRISE_CONTENT_URI;
+    field public static final long ENTERPRISE_DEFAULT = 1000000000L; // 0x3b9aca00L
+    field public static final long ENTERPRISE_LOCAL_INVISIBLE = 1000000001L; // 0x3b9aca01L
     field public static final java.lang.String EXPORT_SUPPORT = "exportSupport";
     field public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; // 0x2
     field public static final int EXPORT_SUPPORT_NONE = 0; // 0x0
@@ -30439,6 +30444,7 @@
     field public static final java.lang.String COLUMN_MIME_TYPE = "mime_type";
     field public static final java.lang.String COLUMN_SIZE = "_size";
     field public static final java.lang.String COLUMN_SUMMARY = "summary";
+    field public static final int FLAG_ARCHIVE = 2048; // 0x800
     field public static final int FLAG_DIR_PREFERS_GRID = 16; // 0x10
     field public static final int FLAG_DIR_PREFERS_LAST_MODIFIED = 32; // 0x20
     field public static final int FLAG_DIR_SUPPORTS_CREATE = 8; // 0x8
@@ -64089,4 +64095,3 @@
   }
 
 }
-
diff --git a/api/system-current.txt b/api/system-current.txt
index f4573fb..f8d0953 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -30061,8 +30061,9 @@
     method public boolean isSystemUser();
     method public boolean isUserAGoat();
     method public boolean isUserRunning(android.os.UserHandle);
+    method public boolean isUserRunningAndLocked(android.os.UserHandle);
+    method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
     method public boolean isUserRunningOrStopping(android.os.UserHandle);
-    method public boolean isUserRunningUnlocked(android.os.UserHandle);
     method public deprecated boolean setRestrictionsChallenge(java.lang.String);
     method public deprecated void setUserRestriction(java.lang.String, boolean);
     method public deprecated void setUserRestrictions(android.os.Bundle);
@@ -31628,6 +31629,7 @@
     ctor public ContactsContract.CommonDataKinds.Callable();
     field public static final android.net.Uri CONTENT_FILTER_URI;
     field public static final android.net.Uri CONTENT_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -31774,6 +31776,7 @@
     field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
     field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
     field public static final android.net.Uri CONTENT_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -31953,7 +31956,7 @@
     field public static final android.net.Uri CONTENT_URI;
     field public static final java.lang.String CONTENT_VCARD_TYPE = "text/x-vcard";
     field public static final android.net.Uri CONTENT_VCARD_URI;
-    field public static final android.net.Uri CORP_CONTENT_FILTER_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -32082,10 +32085,12 @@
     field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_directory";
     field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/contact_directories";
     field public static final android.net.Uri CONTENT_URI;
-    field public static final android.net.Uri CORP_CONTENT_URI;
     field public static final long DEFAULT = 0L; // 0x0L
     field public static final java.lang.String DIRECTORY_AUTHORITY = "authority";
     field public static final java.lang.String DISPLAY_NAME = "displayName";
+    field public static final android.net.Uri ENTERPRISE_CONTENT_URI;
+    field public static final long ENTERPRISE_DEFAULT = 1000000000L; // 0x3b9aca00L
+    field public static final long ENTERPRISE_LOCAL_INVISIBLE = 1000000001L; // 0x3b9aca01L
     field public static final java.lang.String EXPORT_SUPPORT = "exportSupport";
     field public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; // 0x2
     field public static final int EXPORT_SUPPORT_NONE = 0; // 0x0
@@ -32462,6 +32467,7 @@
     field public static final java.lang.String COLUMN_MIME_TYPE = "mime_type";
     field public static final java.lang.String COLUMN_SIZE = "_size";
     field public static final java.lang.String COLUMN_SUMMARY = "summary";
+    field public static final int FLAG_ARCHIVE = 2048; // 0x800
     field public static final int FLAG_DIR_PREFERS_GRID = 16; // 0x10
     field public static final int FLAG_DIR_PREFERS_LAST_MODIFIED = 32; // 0x20
     field public static final int FLAG_DIR_SUPPORTS_CREATE = 8; // 0x8
diff --git a/api/test-current.txt b/api/test-current.txt
index fba944c..1338d90 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -28068,8 +28068,9 @@
     method public boolean isSystemUser();
     method public boolean isUserAGoat();
     method public boolean isUserRunning(android.os.UserHandle);
+    method public boolean isUserRunningAndLocked(android.os.UserHandle);
+    method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
     method public boolean isUserRunningOrStopping(android.os.UserHandle);
-    method public boolean isUserRunningUnlocked(android.os.UserHandle);
     method public deprecated boolean setRestrictionsChallenge(java.lang.String);
     method public deprecated void setUserRestriction(java.lang.String, boolean);
     method public deprecated void setUserRestrictions(android.os.Bundle);
@@ -29637,6 +29638,7 @@
     ctor public ContactsContract.CommonDataKinds.Callable();
     field public static final android.net.Uri CONTENT_FILTER_URI;
     field public static final android.net.Uri CONTENT_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -29783,6 +29785,7 @@
     field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
     field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
     field public static final android.net.Uri CONTENT_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -29962,7 +29965,7 @@
     field public static final android.net.Uri CONTENT_URI;
     field public static final java.lang.String CONTENT_VCARD_TYPE = "text/x-vcard";
     field public static final android.net.Uri CONTENT_VCARD_URI;
-    field public static final android.net.Uri CORP_CONTENT_FILTER_URI;
+    field public static final android.net.Uri ENTERPRISE_CONTENT_FILTER_URI;
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX = "android.provider.extra.ADDRESS_BOOK_INDEX";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
     field public static final java.lang.String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
@@ -30091,10 +30094,12 @@
     field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_directory";
     field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/contact_directories";
     field public static final android.net.Uri CONTENT_URI;
-    field public static final android.net.Uri CORP_CONTENT_URI;
     field public static final long DEFAULT = 0L; // 0x0L
     field public static final java.lang.String DIRECTORY_AUTHORITY = "authority";
     field public static final java.lang.String DISPLAY_NAME = "displayName";
+    field public static final android.net.Uri ENTERPRISE_CONTENT_URI;
+    field public static final long ENTERPRISE_DEFAULT = 1000000000L; // 0x3b9aca00L
+    field public static final long ENTERPRISE_LOCAL_INVISIBLE = 1000000001L; // 0x3b9aca01L
     field public static final java.lang.String EXPORT_SUPPORT = "exportSupport";
     field public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; // 0x2
     field public static final int EXPORT_SUPPORT_NONE = 0; // 0x0
@@ -30441,6 +30446,7 @@
     field public static final java.lang.String COLUMN_MIME_TYPE = "mime_type";
     field public static final java.lang.String COLUMN_SIZE = "_size";
     field public static final java.lang.String COLUMN_SUMMARY = "summary";
+    field public static final int FLAG_ARCHIVE = 2048; // 0x800
     field public static final int FLAG_DIR_PREFERS_GRID = 16; // 0x10
     field public static final int FLAG_DIR_PREFERS_LAST_MODIFIED = 32; // 0x20
     field public static final int FLAG_DIR_SUPPORTS_CREATE = 8; // 0x8
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 798deb1..52fcbf7 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -2113,7 +2113,9 @@
         public int[] taskIds;
         public String[] taskNames;
         public Rect[] taskBounds;
+        public int[] taskUserIds;
         public int displayId;
+        public int userId;
 
         @Override
         public int describeContents() {
@@ -2137,7 +2139,9 @@
                 dest.writeInt(taskBounds[i].right);
                 dest.writeInt(taskBounds[i].bottom);
             }
+            dest.writeIntArray(taskUserIds);
             dest.writeInt(displayId);
+            dest.writeInt(userId);
         }
 
         public void readFromParcel(Parcel source) {
@@ -2157,7 +2161,9 @@
             } else {
                 taskBounds = null;
             }
+            taskUserIds = source.createIntArray();
             displayId = source.readInt();
+            userId = source.readInt();
         }
 
         public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() {
@@ -2183,6 +2189,7 @@
             sb.append(prefix); sb.append("Stack id="); sb.append(stackId);
                     sb.append(" bounds="); sb.append(bounds.toShortString());
                     sb.append(" displayId="); sb.append(displayId);
+                    sb.append(" userId="); sb.append(userId);
                     sb.append("\n");
             prefix = prefix + "  ";
             for (int i = 0; i < taskIds.length; ++i) {
@@ -2191,6 +2198,7 @@
                         if (taskBounds != null) {
                             sb.append(" bounds="); sb.append(taskBounds[i].toShortString());
                         }
+                        sb.append(" userId=").append(taskUserIds[i]);
                         sb.append("\n");
             }
             return sb.toString();
@@ -3108,9 +3116,29 @@
      * @param userid the user's id. Zero indicates the default user.
      * @hide
      */
-    public boolean isUserRunning(int userid) {
+    public boolean isUserRunning(int userId) {
         try {
-            return ActivityManagerNative.getDefault().isUserRunning(userid, 0);
+            return ActivityManagerNative.getDefault().isUserRunning(userId, 0);
+        } catch (RemoteException e) {
+            return false;
+        }
+    }
+
+    /** {@hide} */
+    public boolean isUserRunningAndLocked(int userId) {
+        try {
+            return ActivityManagerNative.getDefault().isUserRunning(userId,
+                    ActivityManager.FLAG_AND_LOCKED);
+        } catch (RemoteException e) {
+            return false;
+        }
+    }
+
+    /** {@hide} */
+    public boolean isUserRunningAndUnlocked(int userId) {
+        try {
+            return ActivityManagerNative.getDefault().isUserRunning(userId,
+                    ActivityManager.FLAG_AND_UNLOCKED);
         } catch (RemoteException e) {
             return false;
         }
diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java
index 9081ef8..984a186 100644
--- a/core/java/android/app/BackStackRecord.java
+++ b/core/java/android/app/BackStackRecord.java
@@ -798,21 +798,33 @@
         }
     }
 
-    private static void setFirstOut(SparseArray<Fragment> fragments, Fragment fragment) {
+    private static void setFirstOut(SparseArray<Fragment> firstOutFragments,
+                            SparseArray<Fragment> lastInFragments, Fragment fragment) {
         if (fragment != null) {
             int containerId = fragment.mContainerId;
-            if (containerId != 0 && !fragment.isHidden() && fragment.isAdded() &&
-                    fragment.getView() != null && fragments.get(containerId) == null) {
-                fragments.put(containerId, fragment);
+            if (containerId != 0 && !fragment.isHidden()) {
+                if (fragment.isAdded() && fragment.getView() != null
+                        && firstOutFragments.get(containerId) == null) {
+                    firstOutFragments.put(containerId, fragment);
+                }
+                if (lastInFragments.get(containerId) == fragment) {
+                    lastInFragments.remove(containerId);
+                }
             }
         }
     }
 
-    private void setLastIn(SparseArray<Fragment> fragments, Fragment fragment) {
+    private void setLastIn(SparseArray<Fragment> firstOutFragments,
+            SparseArray<Fragment> lastInFragments, Fragment fragment) {
         if (fragment != null) {
             int containerId = fragment.mContainerId;
             if (containerId != 0) {
-                fragments.put(containerId, fragment);
+                if (!fragment.isAdded()) {
+                    lastInFragments.put(containerId, fragment);
+                }
+                if (firstOutFragments.get(containerId) == fragment) {
+                    firstOutFragments.remove(containerId);
+                }
             }
         }
     }
@@ -835,7 +847,7 @@
         while (op != null) {
             switch (op.cmd) {
                 case OP_ADD:
-                    setLastIn(lastInFragments, op.fragment);
+                    setLastIn(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_REPLACE: {
                     Fragment f = op.fragment;
@@ -845,29 +857,30 @@
                             if (f == null || old.mContainerId == f.mContainerId) {
                                 if (old == f) {
                                     f = null;
+                                    lastInFragments.remove(old.mContainerId);
                                 } else {
-                                    setFirstOut(firstOutFragments, old);
+                                    setFirstOut(firstOutFragments, lastInFragments, old);
                                 }
                             }
                         }
                     }
-                    setLastIn(lastInFragments, f);
+                    setLastIn(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 }
                 case OP_REMOVE:
-                    setFirstOut(firstOutFragments, op.fragment);
+                    setFirstOut(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_HIDE:
-                    setFirstOut(firstOutFragments, op.fragment);
+                    setFirstOut(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_SHOW:
-                    setLastIn(lastInFragments, op.fragment);
+                    setLastIn(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_DETACH:
-                    setFirstOut(firstOutFragments, op.fragment);
+                    setFirstOut(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_ATTACH:
-                    setLastIn(lastInFragments, op.fragment);
+                    setLastIn(firstOutFragments, lastInFragments, op.fragment);
                     break;
             }
 
@@ -889,38 +902,38 @@
         if (!mManager.mContainer.onHasView()) {
             return; // nothing to see, so no transitions
         }
-        Op op = mHead;
+        Op op = mTail;
         while (op != null) {
             switch (op.cmd) {
                 case OP_ADD:
-                    setFirstOut(firstOutFragments, op.fragment);
+                    setFirstOut(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_REPLACE:
                     if (op.removed != null) {
                         for (int i = op.removed.size() - 1; i >= 0; i--) {
-                            setLastIn(lastInFragments, op.removed.get(i));
+                            setLastIn(firstOutFragments, lastInFragments, op.removed.get(i));
                         }
                     }
-                    setFirstOut(firstOutFragments, op.fragment);
+                    setFirstOut(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_REMOVE:
-                    setLastIn(lastInFragments, op.fragment);
+                    setLastIn(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_HIDE:
-                    setLastIn(lastInFragments, op.fragment);
+                    setLastIn(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_SHOW:
-                    setFirstOut(firstOutFragments, op.fragment);
+                    setFirstOut(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_DETACH:
-                    setLastIn(lastInFragments, op.fragment);
+                    setLastIn(firstOutFragments, lastInFragments, op.fragment);
                     break;
                 case OP_ATTACH:
-                    setFirstOut(firstOutFragments, op.fragment);
+                    setFirstOut(firstOutFragments, lastInFragments, op.fragment);
                     break;
             }
 
-            op = op.next;
+            op = op.prev;
         }
     }
 
@@ -957,6 +970,7 @@
      */
     private TransitionState beginTransition(SparseArray<Fragment> firstOutFragments,
             SparseArray<Fragment> lastInFragments, boolean isBack) {
+        ensureFragmentsAreInitialized(lastInFragments);
         TransitionState state = new TransitionState();
 
         // Adding a non-existent target view makes sure that the transitions don't target
@@ -982,6 +996,21 @@
         return state;
     }
 
+    /**
+     * Ensure that fragments that are entering are at least at the CREATED state
+     * so that they may load Transitions using TransitionInflater.
+     */
+    private void ensureFragmentsAreInitialized(SparseArray<Fragment> lastInFragments) {
+        final int count = lastInFragments.size();
+        for (int i = 0; i < count; i++) {
+            final Fragment fragment = lastInFragments.valueAt(i);
+            if (fragment.mState < Fragment.CREATED) {
+                mManager.makeActive(fragment);
+                mManager.moveToState(fragment, Fragment.CREATED, 0, 0, false);
+            }
+        }
+    }
+
     private static Transition cloneTransition(Transition transition) {
         if (transition != null) {
             transition = transition.clone();
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 2d825fa..3e8a51e 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -74,6 +74,8 @@
  * {@link #listenUsingRfcommWithServiceRecord(String,UUID)}; or start a scan for
  * Bluetooth LE devices with {@link #startLeScan(LeScanCallback callback)}.
  *
+ * <p>This class is thread safe.
+ *
  * <p class="note"><strong>Note:</strong>
  * Most methods require the {@link android.Manifest.permission#BLUETOOTH}
  * permission and some also require the
@@ -82,7 +84,7 @@
  * <div class="special reference">
  * <h3>Developer Guides</h3>
  * <p>For more information about using Bluetooth, read the
- * <a href="{@docRoot}guide/topics/wireless/bluetooth.html">Bluetooth</a> developer guide.</p>
+ * <a href="{@docRoot}guide/topics/wireless/bluetooth.html">Bluetooth</a> developer guide.
  * </div>
  *
  * {@see BluetoothDevice}
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index aa960a4..abd4c28 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -259,6 +259,14 @@
      */
     public static final int SKIP_CURRENT_PROFILE = 0x00000002;
 
+    /**
+     * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
+     * activities in the other profiles can respond to the intent only if no activity with
+     * non-negative priority in current profile can respond to the intent.
+     * @hide
+     */
+    public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
+
     /** @hide */
     @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
     @Retention(RetentionPolicy.SOURCE)
@@ -4636,7 +4644,8 @@
      * @param filter The {@link IntentFilter} the intent has to match
      * @param sourceUserId The source user id.
      * @param targetUserId The target user id.
-     * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
+     * @param flags The possible values are {@link SKIP_CURRENT_PROFILE} and
+     *        {@link ONLY_IF_NO_MATCH_FOUND}.
      * @hide
      */
     public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
diff --git a/core/java/android/content/pm/RegisteredServicesCache.java b/core/java/android/content/pm/RegisteredServicesCache.java
index b3f03c3..a413f36 100644
--- a/core/java/android/content/pm/RegisteredServicesCache.java
+++ b/core/java/android/content/pm/RegisteredServicesCache.java
@@ -294,14 +294,16 @@
      */
     public static class ServiceInfo<V> {
         public final V type;
+        public final ComponentInfo componentInfo;
         public final ComponentName componentName;
         public final int uid;
 
         /** @hide */
-        public ServiceInfo(V type, ComponentName componentName, int uid) {
+        public ServiceInfo(V type, ComponentInfo componentInfo, ComponentName componentName) {
             this.type = type;
+            this.componentInfo = componentInfo;
             this.componentName = componentName;
-            this.uid = uid;
+            this.uid = (componentInfo != null) ? componentInfo.applicationInfo.uid : -1;
         }
 
         @Override
@@ -362,8 +364,9 @@
     @VisibleForTesting
     protected List<ResolveInfo> queryIntentServices(int userId) {
         final PackageManager pm = mContext.getPackageManager();
-        return pm.queryIntentServicesAsUser(
-                new Intent(mInterfaceName), PackageManager.GET_META_DATA, userId);
+        return pm.queryIntentServicesAsUser(new Intent(mInterfaceName),
+                PackageManager.GET_META_DATA | PackageManager.GET_ENCRYPTION_UNAWARE_COMPONENTS,
+                userId);
     }
 
     /**
@@ -563,9 +566,7 @@
                 return null;
             }
             final android.content.pm.ServiceInfo serviceInfo = service.serviceInfo;
-            final ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
-            final int uid = applicationInfo.uid;
-            return new ServiceInfo<V>(v, componentName, uid);
+            return new ServiceInfo<V>(v, serviceInfo, componentName);
         } catch (NameNotFoundException e) {
             throw new XmlPullParserException(
                     "Unable to load resources for pacakge " + si.packageName);
diff --git a/core/java/android/net/LocalSocket.java b/core/java/android/net/LocalSocket.java
index a374a86..e14facb1 100644
--- a/core/java/android/net/LocalSocket.java
+++ b/core/java/android/net/LocalSocket.java
@@ -25,7 +25,8 @@
 
 /**
  * Creates a (non-server) socket in the UNIX-domain namespace. The interface
- * here is not entirely unlike that of java.net.Socket
+ * here is not entirely unlike that of java.net.Socket. This class and the streams
+ * returned from it may be used from multiple threads.
  */
 public class LocalSocket implements Closeable {
 
diff --git a/core/java/android/net/http/HttpResponseCache.java b/core/java/android/net/http/HttpResponseCache.java
index 188287f..729aff0 100644
--- a/core/java/android/net/http/HttpResponseCache.java
+++ b/core/java/android/net/http/HttpResponseCache.java
@@ -36,7 +36,8 @@
  * saving time and bandwidth. This class supports {@link
  * java.net.HttpURLConnection} and {@link javax.net.ssl.HttpsURLConnection};
  * there is no platform-provided cache for {@code DefaultHttpClient} or
- * {@code AndroidHttpClient}.
+ * {@code AndroidHttpClient}. Installation and instances are thread
+ * safe.
  *
  * <h3>Installing an HTTP response cache</h3>
  * Enable caching of all of your application's HTTP requests by installing the
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 79390d4..c2fc5e4 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -755,6 +755,23 @@
     }
 
     /**
+     * Return whether the given user is running in a "locked" state. A user
+     * is unlocked only after they've entered their credentials (such as a lock
+     * pattern or PIN), and credential-encrypted private app data storage is
+     * available.
+     *
+     * @param user to retrieve the unlocked state for.
+     */
+    public boolean isUserRunningAndLocked(UserHandle user) {
+        try {
+            return ActivityManagerNative.getDefault().isUserRunning(
+                    user.getIdentifier(), ActivityManager.FLAG_AND_LOCKED);
+        } catch (RemoteException e) {
+            return false;
+        }
+    }
+
+    /**
      * Return whether the given user is running in an "unlocked" state. A user
      * is unlocked only after they've entered their credentials (such as a lock
      * pattern or PIN), and credential-encrypted private app data storage is
@@ -762,7 +779,7 @@
      *
      * @param user to retrieve the unlocked state for.
      */
-    public boolean isUserRunningUnlocked(UserHandle user) {
+    public boolean isUserRunningAndUnlocked(UserHandle user) {
         try {
             return ActivityManagerNative.getDefault().isUserRunning(
                     user.getIdentifier(), ActivityManager.FLAG_AND_UNLOCKED);
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 94a2bea..c0d95a1 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -394,12 +394,19 @@
                 Uri.withAppendedPath(AUTHORITY_URI, "directories");
 
         /**
-         * The content:// style URI for enterprise Directory table. Requests to this URI can be
-         * performed on the UI thread because they are always unblocking.
+         * URI used for getting all directories from primary and managed profile.
+         * It supports the same semantics as {@link #CONTENT_URI} and returns the same columns.
+         * If the device has no managed profile that is linked to the current profile, it behaves
+         * in the exact same way as {@link #CONTENT_URI}.
+         * If there is a managed profile linked to the current profile, it will merge
+         * managed profile and current profile's results and return.
+         *
+         * Note: this query returns primary profile results before managed profile results,
+         * and this order is not affected by sorting parameter.
          *
          */
-        public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
-                "directories_corp");
+        public static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
+                "directories_enterprise");
 
         /**
          * The MIME-type of {@link #CONTENT_URI} providing a directory of
@@ -426,16 +433,12 @@
 
         /**
          * _ID of the work profile default directory, which represents locally stored contacts.
-         *
-         * @hide
          */
         public static final long ENTERPRISE_DEFAULT = Directory.ENTERPRISE_DIRECTORY_ID_BASE
                 + DEFAULT;
 
         /**
          * _ID of the work profile directory that represents locally stored invisible contacts.
-         *
-         * @hide
          */
         public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_DIRECTORY_ID_BASE
                 + LOCAL_INVISIBLE;
@@ -1640,12 +1643,12 @@
                 CONTENT_URI, "filter");
 
         /**
-         * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
-         * columns. If there is a corp profile linked to the current profile, it will query corp
-         * profile, otherwise it will return null.
+         * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
+         * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in parameters,
+         * otherwise it will throw UnsupportedOperationException.
          */
-        public static final Uri CORP_CONTENT_FILTER_URI = Uri.withAppendedPath(
-                CORP_CONTENT_URI, "filter");
+        public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
+                CONTENT_URI, "filter_enterprise");
 
         /**
          * The content:// style URI for this table joined with useful data from
@@ -5915,6 +5918,14 @@
                     "filter");
 
             /**
+             * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
+             * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
+             * parameters, otherwise it will throw UnsupportedOperationException.
+             */
+            public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
+                    CONTENT_URI, "filter_enterprise");
+
+            /**
              * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
              * If "1" or "true", display names are searched.  If "0" or "false", display names
              * are not searched.  Default is "1".
@@ -7395,6 +7406,14 @@
              */
             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
                     "filter");
+
+            /**
+             * Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter
+             * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
+             * parameters, otherwise it will throw UnsupportedOperationException.
+             */
+            public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
+                    CONTENT_URI, "filter_enterprise");
         }
 
         /**
diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java
index d53bb0d..77a4485 100644
--- a/core/java/android/provider/DocumentsContract.java
+++ b/core/java/android/provider/DocumentsContract.java
@@ -234,6 +234,7 @@
          * @see #FLAG_DIR_PREFERS_GRID
          * @see #FLAG_DIR_PREFERS_LAST_MODIFIED
          * @see #FLAG_VIRTUAL_DOCUMENT
+         * @see #FLAG_ARCHIVE
          */
         public static final String COLUMN_FLAGS = "flags";
 
@@ -368,6 +369,18 @@
         public static final int FLAG_VIRTUAL_DOCUMENT = 1 << 10;
 
         /**
+         * Flag indicating that a document is an archive, and it's contents can be
+         * obtained via {@link DocumentsProvider#queryChildDocuments}.
+         * <p>
+         * The <em>provider</em> support library offers utility classes to add common
+         * archive support.
+         *
+         * @see #COLUMN_FLAGS
+         * @see DocumentsProvider#queryChildDocuments(String, String[], String)
+         */
+        public static final int FLAG_ARCHIVE = 1 << 11;
+
+        /**
          * Flag indicating that document titles should be hidden when viewing
          * this directory in a larger format grid. For example, a directory
          * containing only images may want the image thumbnails to speak for
diff --git a/core/java/android/util/EventLog.java b/core/java/android/util/EventLog.java
index 558b8f5..6bda83d2 100644
--- a/core/java/android/util/EventLog.java
+++ b/core/java/android/util/EventLog.java
@@ -52,7 +52,7 @@
     private static HashMap<String, Integer> sTagCodes = null;
     private static HashMap<Integer, String> sTagNames = null;
 
-    /** A previously logged event read from the logs. */
+    /** A previously logged event read from the logs. Instances are thread safe. */
     public static final class Event {
         private final ByteBuffer mBuffer;
 
diff --git a/core/tests/coretests/src/android/content/pm/RegisteredServicesCacheTest.java b/core/tests/coretests/src/android/content/pm/RegisteredServicesCacheTest.java
index 32b4557..271c639 100644
--- a/core/tests/coretests/src/android/content/pm/RegisteredServicesCacheTest.java
+++ b/core/tests/coretests/src/android/content/pm/RegisteredServicesCacheTest.java
@@ -188,7 +188,10 @@
 
     private static RegisteredServicesCache.ServiceInfo<TestServiceType> newServiceInfo(
             TestServiceType type, int uid) {
-        return new RegisteredServicesCache.ServiceInfo<>(type, null, uid);
+        final ComponentInfo info = new ComponentInfo();
+        info.applicationInfo = new ApplicationInfo();
+        info.applicationInfo.uid = uid;
+        return new RegisteredServicesCache.ServiceInfo<>(type, info, null);
     }
 
     private void assertNotEmptyFileCreated(TestServicesCache cache, int userId) {
diff --git a/libs/hwui/TextDropShadowCache.cpp b/libs/hwui/TextDropShadowCache.cpp
index 996ac8e..51f1652 100644
--- a/libs/hwui/TextDropShadowCache.cpp
+++ b/libs/hwui/TextDropShadowCache.cpp
@@ -83,7 +83,7 @@
         if (!lhs.positions) return -1;
         if (!rhs.positions) return +1;
 
-        return memcmp(lhs.positions, rhs.positions, lhs.glyphCount << 1);
+        return memcmp(lhs.positions, rhs.positions, lhs.glyphCount * sizeof(float) * 2);
     }
 
     return 0;
@@ -169,7 +169,7 @@
 
 ShadowTexture* TextDropShadowCache::get(const SkPaint* paint, const char* glyphs, int numGlyphs,
         float radius, const float* positions) {
-    ShadowText entry(paint, radius, numGlyphs * 2, glyphs, positions);
+    ShadowText entry(paint, radius, numGlyphs, glyphs, positions);
     ShadowTexture* texture = mCache.get(entry);
 
     if (!texture) {
diff --git a/media/java/android/media/MediaMetadataEditor.java b/media/java/android/media/MediaMetadataEditor.java
index 566b93f..877c872 100644
--- a/media/java/android/media/MediaMetadataEditor.java
+++ b/media/java/android/media/MediaMetadataEditor.java
@@ -73,7 +73,8 @@
 
     /**
      * Applies all of the metadata changes that have been set since the MediaMetadataEditor instance
-     * was created or since {@link #clear()} was called.
+     * was created or since {@link #clear()} was called. Subclasses should synchronize on
+     * {@code this} for thread safety.
      */
     public abstract void apply();
 
diff --git a/packages/DocumentsUI/res/values/config.xml b/packages/DocumentsUI/res/values/config.xml
index ad419aa..ff28e15 100644
--- a/packages/DocumentsUI/res/values/config.xml
+++ b/packages/DocumentsUI/res/values/config.xml
@@ -15,6 +15,9 @@
 -->
 
 <resources>
+    <!-- Allow Advanced Devices default value to be customised -->
+    <bool name="config_defaultAdvancedDevices">false</bool>
+
     <bool name="productivity_device">true</bool>
     <!-- Intentionally unset. Vendors should set this in an overlay. -->
     <string name="trusted_quick_viewer_package"></string>
diff --git a/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java b/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java
index e6c5ae2..113e9d7 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/LocalPreferences.java
@@ -24,8 +24,10 @@
     private static final String KEY_FILE_SIZE = "fileSize";
 
     public static boolean getDisplayAdvancedDevices(Context context) {
+        boolean defaultAdvanced = context.getResources()
+                .getBoolean(R.bool.config_defaultAdvancedDevices);
         return PreferenceManager.getDefaultSharedPreferences(context)
-                .getBoolean(KEY_ADVANCED_DEVICES, false);
+                .getBoolean(KEY_ADVANCED_DEVICES, defaultAdvanced);
     }
 
     public static boolean getDisplayFileSize(Context context) {
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpManagerTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpManagerTest.java
index a045d06..ed617e7 100644
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpManagerTest.java
+++ b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpManagerTest.java
@@ -24,6 +24,9 @@
 import android.test.InstrumentationTestCase;
 
 import java.io.IOException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
 
 @RealDeviceTest
 public class MtpManagerTest extends InstrumentationTestCase {
@@ -53,20 +56,23 @@
 
     public void testCancelEvent() throws Exception {
         final CancellationSignal signal = new CancellationSignal();
-        final Thread thread = new Thread() {
-            @Override
-            public void run() {
-                try {
-                    mManager.readEvent(mUsbDevice.getDeviceId(), signal);
-                } catch (OperationCanceledException | IOException e) {
-                    getInstrumentation().show(e.getMessage());
-                }
-            }
-        };
+        final FutureTask<Boolean> future = new FutureTask<Boolean>(
+                new Callable<Boolean>() {
+                    @Override
+                    public Boolean call() throws IOException {
+                        try {
+                            mManager.readEvent(mUsbDevice.getDeviceId(), signal);
+                            return false;
+                        } catch (OperationCanceledException exception) {
+                            return true;
+                        }
+                    }
+                });
+        final Thread thread = new Thread(future);
         thread.start();
         Thread.sleep(TIMEOUT_MS);
         signal.cancel();
-        thread.join(TIMEOUT_MS);
+        assertTrue(future.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
     }
 
     private Context getContext() {
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultInstrumentation.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultInstrumentation.java
index 3e64f9a2..4e4cf78 100644
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultInstrumentation.java
+++ b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResultInstrumentation.java
@@ -23,6 +23,10 @@
 import junit.framework.Test;
 import junit.framework.TestListener;
 
+/**
+ * Instrumentation that can show the test result in the TestResultActivity.
+ * It's useful when it runs testcases with a real USB device and could not use USB port for ADB.
+ */
 public class TestResultInstrumentation extends InstrumentationTestRunner implements TestListener {
     private boolean mHasError = false;
 
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestUtil.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestUtil.java
index e6c12cb..f910321 100644
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestUtil.java
+++ b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestUtil.java
@@ -33,7 +33,7 @@
 /**
  * Static utility methods for testing.
  */
-class TestUtil {
+final class TestUtil {
     private static final String ACTION_USB_PERMISSION =
             "com.android.mtp.USB_PERMISSION";
 
@@ -42,12 +42,11 @@
     /**
      * Requests permission for a MTP device and returns the first MTP device that has at least one
      * storage.
-     * @throws Exception
      */
     static UsbDevice setupMtpDevice(
             TestResultInstrumentation instrumentation,
             UsbManager usbManager,
-            MtpManager manager) throws Exception {
+            MtpManager manager) throws InterruptedException, IOException {
         for (int i = 0; i < 2; i++) {
             final UsbDevice device = findMtpDevice(instrumentation, usbManager);
             manager.openDevice(device.getDeviceId());
@@ -121,7 +120,7 @@
     private static void waitForStorages(
             TestResultInstrumentation instrumentation,
             MtpManager manager,
-            int deviceId) throws Exception {
+            int deviceId) throws IOException, InterruptedException {
         while (true) {
             if (manager.getRoots(deviceId).length == 0) {
                 instrumentation.show("Wait for storages.");
diff --git a/packages/SettingsLib/res/values/arrays.xml b/packages/SettingsLib/res/values/arrays.xml
index a52ed69..4e88c1c 100644
--- a/packages/SettingsLib/res/values/arrays.xml
+++ b/packages/SettingsLib/res/values/arrays.xml
@@ -78,4 +78,306 @@
         <!-- Status message of Wi-Fi when connectiong is being verified. -->
         <item>Temporarily avoiding poor connection</item>
     </string-array>
+
+    <!-- Titles for HDCP checking preference. [CHAR LIMIT=35] -->
+    <string-array name="hdcp_checking_titles">
+        <item>Never check</item>
+        <item>Check for DRM content only</item>
+        <item>Always check</item>
+    </string-array>
+
+    <!-- Values for HDCP checking preference. -->
+    <string-array name="hdcp_checking_values" translatable="false" >
+        <item>never</item>
+        <item>drm-only</item>
+        <item>always</item>
+    </string-array>
+
+    <!-- Summaries for HDCP checking preference. [CHAR LIMIT=100]-->
+    <string-array name="hdcp_checking_summaries" >
+        <item>Never use HDCP checking</item>
+        <item>Use HDCP checking for DRM content only</item>
+        <item>Always use HDCP checking</item>
+    </string-array>
+
+    <!-- Titles for logd limit size selection preference. [CHAR LIMIT=14] -->
+    <string-array name="select_logd_size_titles">
+        <item>64K</item>
+        <item>256K</item>
+        <item>1M</item>
+        <item>4M</item>
+        <item>16M</item>
+    </string-array>
+
+    <!-- Titles for logd limit size lowram selection preference. [CHAR LIMIT=14] -->
+    <string-array name="select_logd_size_lowram_titles">
+        <item>64K</item>
+        <item>256K</item>
+        <item>1M</item>
+    </string-array>
+
+    <!-- Values for logd limit size selection preference. -->
+    <string-array name="select_logd_size_values" translatable="false" >
+        <item>65536</item>
+        <item>262144</item>
+        <item>1048576</item>
+        <item>4194304</item>
+        <item>16777216</item>
+    </string-array>
+
+    <!-- Summaries for logd limit size selection preference. [CHAR LIMIT=30]-->
+    <string-array name="select_logd_size_summaries" >
+        <item>64K per log buffer</item>
+        <item>256K per log buffer</item>
+        <item>1M per log buffer</item>
+        <item>4M per log buffer</item>
+        <item>16M per log buffer</item>
+    </string-array>
+
+    <!-- Titles for window animation scale preference. [CHAR LIMIT=35] -->
+    <string-array name="window_animation_scale_entries">
+        <item>Animation off</item>
+        <item>Animation scale .5x</item>
+        <item>Animation scale 1x</item>
+        <item>Animation scale 1.5x</item>
+        <item>Animation scale 2x</item>
+        <item>Animation scale 5x</item>
+        <item>Animation scale 10x</item>
+    </string-array>
+
+    <!-- Values for window animation scale preference. -->
+    <string-array name="window_animation_scale_values" translatable="false" >
+        <item>0</item>
+        <item>.5</item>
+        <item>1</item>
+        <item>1.5</item>
+        <item>2</item>
+        <item>5</item>
+        <item>10</item>
+    </string-array>
+
+    <!-- Titles for transition animation scale preference. [CHAR LIMIT=35] -->
+    <string-array name="transition_animation_scale_entries">
+        <item>Animation off</item>
+        <item>Animation scale .5x</item>
+        <item>Animation scale 1x</item>
+        <item>Animation scale 1.5x</item>
+        <item>Animation scale 2x</item>
+        <item>Animation scale 5x</item>
+        <item>Animation scale 10x</item>
+    </string-array>
+
+    <!-- Values for transition animation scale preference. -->
+    <string-array name="transition_animation_scale_values" translatable="false" >
+        <item>0</item>
+        <item>.5</item>
+        <item>1</item>
+        <item>1.5</item>
+        <item>2</item>
+        <item>5</item>
+        <item>10</item>
+    </string-array>
+
+    <!-- Titles for animator duration scale preference. [CHAR LIMIT=35] -->
+    <string-array name="animator_duration_scale_entries">
+        <item>Animation off</item>
+        <item>Animation scale .5x</item>
+        <item>Animation scale 1x</item>
+        <item>Animation scale 1.5x</item>
+        <item>Animation scale 2x</item>
+        <item>Animation scale 5x</item>
+        <item>Animation scale 10x</item>
+    </string-array>
+
+    <!-- Values for animator duration scale preference. -->
+    <string-array name="animator_duration_scale_values" translatable="false" >
+        <item>0</item>
+        <item>.5</item>
+        <item>1</item>
+        <item>1.5</item>
+        <item>2</item>
+        <item>5</item>
+        <item>10</item>
+    </string-array>
+
+    <!-- Titles for overlay display devices preference. [CHAR LIMIT=35] -->
+    <string-array name="overlay_display_devices_entries">
+        <item>None</item>
+        <item>480p</item>
+        <item>480p (secure)</item>
+        <item>720p</item>
+        <item>720p (secure)</item>
+        <item>1080p</item>
+        <item>1080p (secure)</item>
+        <item>4K</item>
+        <item>4K (secure)</item>
+        <item>4K (upscaled)</item>
+        <item>4K (upscaled, secure)</item>
+        <item>720p, 1080p (dual screen)</item>
+    </string-array>
+
+    <!-- Values for overlay display devices preference. -->
+    <string-array name="overlay_display_devices_values" translatable="false" >
+        <item></item>
+        <item>720x480/142</item>
+        <item>720x480/142,secure</item>
+        <item>1280x720/213</item>
+        <item>1280x720/213,secure</item>
+        <item>1920x1080/320</item>
+        <item>1920x1080/320,secure</item>
+        <item>3840x2160/320</item>
+        <item>3840x2160/320,secure</item>
+        <item>1920x1080/320|3840x2160/640</item>
+        <item>1920x1080/320|3840x2160/640,secure</item>
+        <item>1280x720/213;1920x1080/320</item>
+    </string-array>
+
+    <!-- Titles for OpenGL traces preference. [CHAR LIMIT=35] -->
+    <string-array name="enable_opengl_traces_entries">
+        <item>None</item>
+        <item>Logcat</item>
+        <item>Systrace (Graphics)</item>
+        <item>Call stack on glGetError</item>
+    </string-array>
+
+    <!-- Values for OpenGL traces preference. -->
+    <string-array name="enable_opengl_traces_values" translatable="false" >
+        <item>0</item>
+        <item>1</item>
+        <item>systrace</item>
+        <item>error</item>
+    </string-array>
+
+    <!-- Titles for non-rectangular clipping preference. [CHAR LIMIT=35] -->
+    <string-array name="show_non_rect_clip_entries">
+        <item>Off</item>
+        <item>Draw non-rectangular clip region in blue</item>
+        <item>Highlight tested drawing commands in green</item>
+    </string-array>
+
+    <!-- Values for non-rectangular clipping preference. -->
+    <string-array name="show_non_rect_clip_values" translatable="false" >
+        <item>hide</item>
+        <item>region</item>
+        <item>highlight</item>
+    </string-array>
+
+    <!-- Titles for frame time tracking preference. [CHAR LIMIT=35] -->
+    <string-array name="track_frame_time_entries">
+        <item>Off</item>
+        <item>On screen as bars</item>
+        <item>In adb shell dumpsys gfxinfo</item>
+    </string-array>
+
+    <!-- Values for frame time tracking preference. -->
+    <string-array name="track_frame_time_values" translatable="false" >
+        <item>false</item>
+        <item>visual_bars</item>
+        <item>true</item>
+    </string-array>
+
+    <!-- Titles for debug overdraw preference. [CHAR LIMIT=50] -->
+    <string-array name="debug_hw_overdraw_entries">
+        <item>Off</item>
+        <item>Show overdraw areas</item>
+        <item>Show areas for Deuteranomaly</item>
+    </string-array>
+
+    <!-- Values for debug overdraw preference. -->
+    <string-array name="debug_hw_overdraw_values" translatable="false" >
+        <item>false</item>
+        <item>show</item>
+        <item>show_deuteranomaly</item>
+    </string-array>
+
+    <!-- Titles for app process limit preference. [CHAR LIMIT=35] -->
+    <string-array name="app_process_limit_entries">
+        <item>Standard limit</item>
+        <item>No background processes</item>
+        <item>At most 1 process</item>
+        <item>At most 2 processes</item>
+        <item>At most 3 processes</item>
+        <item>At most 4 processes</item>
+    </string-array>
+
+    <!-- Values for app process limit preference. -->
+    <string-array name="app_process_limit_values" translatable="false" >
+        <item>-1</item>
+        <item>0</item>
+        <item>1</item>
+        <item>2</item>
+        <item>3</item>
+        <item>4</item>
+    </string-array>
+
+    <!-- USB configuration names for Developer Settings.
+         This can be overridden by devices with additional USB configurations. -->
+    <string-array name="usb_configuration_titles">
+        <item>Charging</item>
+        <item>MTP (Media Transfer Protocol)</item>
+        <item>PTP (Picture Transfer Protocol)</item>
+        <item>RNDIS (USB Ethernet)</item>
+        <item>Audio Source</item>
+        <item>MIDI</item>
+    </string-array>
+
+    <!-- USB configuration values for Developer Settings.
+         These are lists of USB functions passed to the USB Manager to change USB configuraton.
+         This can be overridden by devices with additional USB configurations.
+         Do not translate. -->
+    <string-array name="usb_configuration_values" translatable="false">
+        <!-- Do not translate. -->
+        <item>none</item>
+        <!-- Do not translate. -->
+        <item>mtp</item>
+        <!-- Do not translate. -->
+        <item>ptp</item>
+        <!-- Do not translate. -->
+        <item>rndis</item>
+        <!-- Do not translate. -->
+        <item>audio_source</item>
+        <!-- Do not translate. -->
+        <item>midi</item>
+    </string-array>
+
+    <!-- Possible values for user theme in Display Settings.
+         Do not translate. -->
+    <string-array name="night_mode_entries" translatable="false">
+        <!-- Do not translate. -->
+        <item>@string/night_mode_no</item>
+        <!-- Do not translate. -->
+        <item>@string/night_mode_yes</item>
+        <!-- Do not translate. -->
+        <item>@string/night_mode_auto</item>
+    </string-array>
+
+    <!-- These values should match up with the MODE_NIGHT constants in UiModeManager.
+         Do not translate. -->
+    <string-array name="night_mode_values" translatable="false">
+        <!-- Do not translate. -->
+        <item>1</item>
+        <!-- Do not translate. -->
+        <item>2</item>
+        <!-- Do not translate. -->
+        <item>0</item>
+    </string-array>
+
+    <!-- Display color space adjustment modes for developers -->
+    <string-array name="simulate_color_space_entries" translatable="false">
+        <item>@string/daltonizer_mode_disabled</item>
+        <item>@string/daltonizer_mode_monochromacy</item>
+        <item>@string/daltonizer_mode_deuteranomaly</item>
+        <item>@string/daltonizer_mode_protanomaly</item>
+        <item>@string/daltonizer_mode_tritanomaly</item>
+    </string-array>
+
+    <!-- Values for display color space adjustment modes for developers -->
+    <string-array name="simulate_color_space_values" translatable="false">
+        <item>-1</item>
+        <item>0</item>
+        <item>2</item>
+        <item>1</item>
+        <item>3</item>
+    </string-array>
+
 </resources>
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index a37196e..55bd08a 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -351,4 +351,369 @@
     <!-- Full package name of OEM preferred device feedback reporter. Leave this blank, overlaid in Settings/TvSettings [DO NOT TRANSLATE] -->
     <string name="oem_preferred_feedback_reporter" translatable="false" />
 
+    <!-- Development settings -->
+    <skip/>
+    <!-- Development Settings.  the title for the item to take the user to Development settings.  Development settings are settings meant for application developers.  -->
+    <string name="development_settings_title">Developer options</string>
+    <!-- Development settings enable title. -->
+    <string name="development_settings_enable">Enable developer options</string>
+    <!-- Development Settings summary.  The summary of the item to take the user to Development settings.  Development settings are settings meant for application developers. -->
+    <string name="development_settings_summary">Set options for app development</string>
+    <!-- Setting checkbox title for Whether to enable USB debugging support on the phone. -->
+    <!-- Error message for users that aren't allowed to modify developer options [CHAR LIMIT=none] -->
+    <string name="development_settings_not_available">Developer options are not available for this user</string>
+    <!-- Error message for users that aren't allowed to modify VPN settings [CHAR LIMIT=none] -->
+    <string name="vpn_settings_not_available">VPN settings are not available for this user</string>
+    <!-- Error message for users that aren't allowed to modify Tethering settings [CHAR LIMIT=none] -->
+    <string name="tethering_settings_not_available">Tethering settings are not available for this user</string>
+    <!-- Error message for users that aren't allowed to modify Access Point Names settings [CHAR LIMIT=none] -->
+    <string name="apn_settings_not_available">Access Point Name settings are not available for this user</string>
+    <string name="enable_adb">USB debugging</string>
+    <!-- Setting checkbox summary for Whether to enable USB debugging support on the phone -->
+    <string name="enable_adb_summary">Debug mode when USB is connected</string>
+    <!-- Setting title to revoke secure USB debugging authorizations -->
+    <string name="clear_adb_keys">Revoke USB debugging authorizations</string>
+    <!-- [CHAR LIMIT=NONE] Setting checkbox title for Whether to include bug report item in power menu. -->
+    <string name="bugreport_in_power">Bug report shortcut</string>
+    <!-- [CHAR LIMIT=NONE] Setting checkbox summary for Whether to include bug report item in power -->
+    <string name="bugreport_in_power_summary">Show a button in the power menu for taking a bug report</string>
+    <!-- Setting Checkbox title whether to keep the screen on when plugged in to a power source -->
+    <string name="keep_screen_on">Stay awake</string>
+    <!-- setting Checkbox summary whether to keep the screen on when plugged in  -->
+    <string name="keep_screen_on_summary">Screen will never sleep while charging</string>
+    <!-- Setting Checkbox title whether to enable bluetooth HCI snoop log -->
+    <string name="bt_hci_snoop_log">Enable Bluetooth HCI snoop log</string>
+    <!-- setting Checkbox summary whether to capture all bluetooth HCI packets in a file -->
+    <string name="bt_hci_snoop_log_summary">Capture all bluetooth HCI packets in a file</string>
+    <!-- setting Checkbox title whether to enable OEM unlock [CHAR_LIMIT=35] -->
+    <string name="oem_unlock_enable">OEM unlocking</string>
+    <!-- setting Checkbox summary whether to enable OEM unlock [CHAR_LIMIT=50] -->
+    <string name="oem_unlock_enable_summary">Allow the bootloader to be unlocked</string>
+    <!-- Confirmation dialog title to ensure user wishes to enable OEM unlock and disable theft protection features -->
+    <string name="confirm_enable_oem_unlock_title">Allow OEM unlocking?</string>
+    <!-- Warning dialog message to confirm user wishes to enable OEM unlock and disable theft protection features -->
+    <string name="confirm_enable_oem_unlock_text">WARNING: Device protection features will not work on this device while this setting is turned on.</string>
+
+    <!-- UI debug setting: select current app to mock location [CHAR LIMIT=50] -->
+    <string name="mock_location_app">Select mock location app</string>
+    <!-- UI debug setting: no mock location app has been set [CHAR LIMIT=50] -->
+    <string name="mock_location_app_not_set">No mock location app set</string>
+    <!-- UI debug setting: mock location app has been set [CHAR LIMIT=50] -->
+    <string name="mock_location_app_set">Mock location app: <xliff:g id="app_name">%1$s</xliff:g></string>
+
+    <!-- Preference category for networking debugging development settings. [CHAR LIMIT=50] -->
+    <string name="debug_networking_category">Networking</string>
+
+    <!-- Setting Checkbox title whether to show options for wireless display certification -->
+    <string name="wifi_display_certification">Wireless display certification</string>
+    <!-- Setting Checkbox title whether to enable WiFi Verbose Logging. [CHAR LIMIT=40] -->
+    <string name="wifi_verbose_logging">Enable Wi\u2011Fi Verbose Logging</string>
+    <!-- Setting Checkbox title whether to enable WiFi Aggressive Handover. [CHAR LIMIT=40] -->
+    <string name="wifi_aggressive_handover">Aggressive Wi\u2011Fi to Cellular handover</string>
+    <!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
+    <string name="wifi_allow_scan_with_traffic">Always allow Wi\u2011Fi Roam Scans</string>
+    <!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
+    <string name="legacy_dhcp_client">Use legacy DHCP client</string>
+    <!-- Setting Checkbox title whether to always keep cellular data active. [CHAR LIMIT=80] -->
+    <string name="mobile_data_always_on">Cellular data always active</string>
+
+    <!-- setting Checkbox summary whether to show options for wireless display certification  -->
+    <string name="wifi_display_certification_summary">Show options for wireless display certification</string>
+    <!-- Setting Checkbox summary whether to enable Wifi verbose Logging [CHAR LIMIT=80] -->
+    <string name="wifi_verbose_logging_summary">Increase Wi\u2011Fi logging level, show per SSID RSSI in Wi\u2011Fi Picker</string>
+    <!-- Setting Checkbox summary whether to enable Wifi aggressive handover [CHAR LIMIT=130] -->
+    <string name="wifi_aggressive_handover_summary">When enabled, Wi\u2011Fi will be more aggressive in handing over the data connection to Cellular, when Wi\u2011Fi signal is low</string>
+    <!-- Setting Checkbox summary whether to always allow WiFi Roam Scans [CHAR LIMIT=130] -->
+    <string name="wifi_allow_scan_with_traffic_summary">Allow/Disallow Wi\u2011Fi Roam Scans based on the amount of data traffic present at the interface</string>
+    <!-- UI debug setting: limit size of Android logger buffers -->
+    <string name="select_logd_size_title">Logger buffer sizes</string>
+    <!-- UI debug setting: limit size of Android logger buffers [CHAR LIMIT=59] -->
+    <string name="select_logd_size_dialog_title">Select Logger sizes per log buffer</string>
+    <!-- UI debug setting: select USB configuration -->
+    <string name="select_usb_configuration_title">Select USB Configuration</string>
+    <!-- UI debug setting: limit size of Android logger buffers [CHAR LIMIT=59] -->
+    <string name="select_usb_configuration_dialog_title">Select USB Configuration</string>
+    <!-- Setting Checkbox title whether to allow mock locations -->
+    <string name="allow_mock_location">Allow mock locations</string>
+    <!-- setting Checkbox summary whether to allow mock locations  -->
+    <string name="allow_mock_location_summary">Allow mock locations</string>
+    <!-- Setting Checkbox title whether to enable view attribute inspection -->
+    <string name="debug_view_attributes">Enable view attribute inspection</string>
+    <!-- Setting Checkbox summary whether to use DHCP client from Lollipop (Android 5.0) [CHAR LIMIT=130] -->
+    <string name="legacy_dhcp_client_summary">Use the DHCP client from Lollipop instead of the new Android DHCP client.</string>
+    <string name="mobile_data_always_on_summary">Always keep mobile data active, even when Wi\u2011Fi is active (for fast network switching).</string>
+    <!-- Title of warning dialog about the implications of enabling USB debugging -->
+    <string name="adb_warning_title">Allow USB debugging?</string>
+    <!-- Warning text to user about the implications of enabling USB debugging -->
+    <string name="adb_warning_message">USB debugging is intended for development purposes only. Use it to copy data between your computer and your device, install apps on your device without notification, and read log data.</string>
+    <!-- Message of dialog confirming that user wants to revoke access to adb from all computers they have authorized -->
+    <string name="adb_keys_warning_message">Revoke access to USB debugging from all computers you\u2019ve previously authorized?</string>
+    <!-- Title of warning dialog about the implications of enabling developer settings -->
+    <string name="dev_settings_warning_title">Allow development settings?</string>
+    <!-- Warning text to user about the implications of enabling USB debugging -->
+    <string name="dev_settings_warning_message">These settings are intended for development use only.  They can cause your device and the applications on it to break or misbehave.</string>
+    <!-- Title of checkbox setting to perform package verification on apps installed over USB/ADT/ADB [CHAR LIMIT=32] -->
+    <string name="verify_apps_over_usb_title">Verify apps over USB</string>
+    <!-- Summary of checkbox setting to perform package verification on apps installed over USB/ADT/ADB [CHAR LIMIT=NONE] -->
+    <string name="verify_apps_over_usb_summary">Check apps installed via ADB/ADT for harmful behavior.</string>
+
+    <!-- Title of checkbox setting that enables the terminal app. [CHAR LIMIT=32] -->
+    <string name="enable_terminal_title">Local terminal</string>
+    <!-- Summary of checkbox setting that enables the terminal app. [CHAR LIMIT=64] -->
+    <string name="enable_terminal_summary">Enable terminal app that offers local shell access</string>
+
+    <!-- HDCP checking title, used for debug purposes only. [CHAR LIMIT=25] -->
+    <string name="hdcp_checking_title">HDCP checking</string>
+    <!-- HDCP checking dialog title, used for debug purposes only. [CHAR LIMIT=25] -->
+    <string name="hdcp_checking_dialog_title">Set HDCP checking behavior</string>
+
+    <!-- Preference category for app debugging development settings. [CHAR LIMIT=50] -->
+    <string name="debug_debugging_category">Debugging</string>
+
+    <!-- UI debug setting: select current app to debug [CHAR LIMIT=50] -->
+    <string name="debug_app">Select debug app</string>
+    <!-- UI debug setting: no debug app has been set [CHAR LIMIT=50] -->
+    <string name="debug_app_not_set">No debug application set</string>
+    <!-- UI debug setting: debug app has been set [CHAR LIMIT=50] -->
+    <string name="debug_app_set">Debugging application: <xliff:g id="app_name">%1$s</xliff:g></string>
+
+    <!-- UI debug setting: title for app picker dialog [CHAR LIMIT=50] -->
+    <string name="select_application">Select application</string>
+    <!-- UI debug setting: label for app picker to select no applicatiojn [CHAR LIMIT=50] -->
+    <string name="no_application">Nothing</string>
+
+    <!-- UI debug setting: wait for debugger to attach to debugging process? [CHAR LIMIT=50] -->
+    <string name="wait_for_debugger">Wait for debugger</string>
+    <!-- UI debug setting: wait for debugger to attach to debugging process summary [CHAR LIMIT=500] -->
+    <string name="wait_for_debugger_summary">Debugged application waits for debugger to
+        attach before executing</string>
+
+    <!-- Preference category for input debugging development settings. [CHAR LIMIT=25] -->
+    <string name="debug_input_category">Input</string>
+
+    <!-- Preference category for drawing debugging development settings. [CHAR LIMIT=25] -->
+    <string name="debug_drawing_category">Drawing</string>
+
+    <!-- Preference category for hardware accelerated drawing debugging development settings. [CHAR LIMIT=50] -->
+    <string name="debug_hw_drawing_category">Hardware accelerated rendering</string>
+
+    <!-- Preference category for media development settings. [CHAR LIMIT=50] -->
+    <string name="media_category">Media</string>
+
+    <!-- Preference category for monitoring debugging development settings. [CHAR LIMIT=25] -->
+    <string name="debug_monitoring_category">Monitoring</string>
+
+    <!-- UI debug setting: always enable strict mode? [CHAR LIMIT=25] -->
+    <string name="strict_mode">Strict mode enabled</string>
+    <!-- UI debug setting: show strict mode summary [CHAR LIMIT=50] -->
+    <string name="strict_mode_summary">Flash screen when apps do long operations
+        on main thread</string>
+
+    <!-- UI debug setting: show pointer location? [CHAR LIMIT=25] -->
+    <string name="pointer_location">Pointer location</string>
+    <!-- UI debug setting: show pointer location summary [CHAR LIMIT=50] -->
+    <string name="pointer_location_summary">Screen overlay showing current touch data</string>
+
+    <!-- UI debug setting: show touches? [CHAR LIMIT=25] -->
+    <string name="show_touches">Show touches</string>
+    <!-- UI debug setting: show touches location summary [CHAR LIMIT=50] -->
+    <string name="show_touches_summary">Show visual feedback for touches</string>
+
+    <!-- UI debug setting: show where surface updates happen? [CHAR LIMIT=25] -->
+    <string name="show_screen_updates">Show surface updates</string>
+    <!-- UI debug setting: show surface updates summary [CHAR LIMIT=50] -->
+    <string name="show_screen_updates_summary">Flash entire window surfaces when they update</string>
+
+    <!-- UI debug setting: show where window updates happen with GPU rendering? [CHAR LIMIT=25] -->
+    <string name="show_hw_screen_updates">Show GPU view updates</string>
+    <!-- UI debug setting: show GPU rendering screen updates summary [CHAR LIMIT=50] -->
+    <string name="show_hw_screen_updates_summary">Flash views inside windows when drawn with the GPU</string>
+
+    <!-- UI debug setting: show when hardware layers get updated [CHAR LIMIT=25] -->
+    <string name="show_hw_layers_updates">Show hardware layers updates</string>
+    <!-- UI debug setting: show hardware layers updates summary [CHAR LIMIT=50] -->
+    <string name="show_hw_layers_updates_summary">Flash hardware layers green when they update</string>
+
+    <!-- UI debug setting: show the amount of overdraw in apps using the GPU [CHAR LIMIT=25] -->
+    <string name="debug_hw_overdraw">Debug GPU overdraw</string>
+
+    <!-- UI debug setting: disable use of overlays? [CHAR LIMIT=25] -->
+    <string name="disable_overlays">Disable HW overlays</string>
+    <!-- UI debug setting: disable use of overlays summary [CHAR LIMIT=50] -->
+    <string name="disable_overlays_summary">Always use GPU for screen compositing</string>
+
+    <!-- UI debug setting: simulate color space anomalies. [CHAR LIMIT=25] -->
+    <string name="simulate_color_space">Simulate color space</string>
+
+    <!-- UI debug setting: enable various types of OpenGL traces [CHAR LIMIT=25] -->
+    <string name="enable_opengl_traces_title">Enable OpenGL traces</string>
+
+    <!-- UI debug setting: disable USB audio routing title [CHAR LIMIT=32] -->
+    <string name="usb_audio_disable_routing">Disable USB audio routing</string>
+    <!-- UI debug setting: disable USB audio routing summary [CHAR LIMIT=50] -->
+    <string name="usb_audio_disable_routing_summary">Disable automatic routing to USB audio peripherals</string>
+
+    <!-- UI debug setting: show layout bounds information [CHAR LIMIT=25] -->
+    <string name="debug_layout">Show layout bounds</string>
+    <!-- UI debug setting: show layout bounds information summary [CHAR LIMIT=50] -->
+    <string name="debug_layout_summary">Show clip bounds, margins, etc.</string>
+
+    <!-- UI debug setting: force right to left layout [CHAR LIMIT=37] -->
+    <string name="force_rtl_layout_all_locales">Force RTL layout direction</string>
+    <!-- UI debug setting: force right to left layout summary [CHAR LIMIT=100] -->
+    <string name="force_rtl_layout_all_locales_summary">Force screen layout direction to RTL for all locales</string>
+
+    <!-- UI debug setting: show how CPU is being used? [CHAR LIMIT=25] -->
+    <string name="show_cpu_usage">Show CPU usage</string>
+    <!-- UI debug setting: show cpu usage summary [CHAR LIMIT=50] -->
+    <string name="show_cpu_usage_summary">Screen overlay showing current CPU usage</string>
+
+    <!-- UI debug setting: force hardware acceleration to render apps [CHAR LIMIT=25] -->
+    <string name="force_hw_ui">Force GPU rendering</string>
+    <!-- UI debug setting: force hardware acceleration summary [CHAR LIMIT=50] -->
+    <string name="force_hw_ui_summary">Force use of GPU for 2d drawing</string>
+
+    <!-- UI debug setting: force anti-aliasing to render apps [CHAR LIMIT=25] -->
+    <string name="force_msaa">Force 4x MSAA</string>
+    <!-- UI debug setting: force anti-aliasing summary [CHAR LIMIT=50] -->
+    <string name="force_msaa_summary">Enable 4x MSAA in OpenGL ES 2.0 apps</string>
+
+    <!-- UI debug setting: show when non-rectangular clip operations are used [CHAR LIMIT=100] -->
+    <string name="show_non_rect_clip">Debug non-rectangular clip operations</string>
+
+    <!-- UI debug setting: profile time taken by hardware acceleration to render apps [CHAR LIMIT=25] -->
+    <string name="track_frame_time">Profile GPU rendering</string>
+
+    <!-- UI debug setting: scaling factor for window animations [CHAR LIMIT=25] -->
+    <string name="window_animation_scale_title">Window animation scale</string>
+
+    <!-- UI debug setting: scaling factor for transition animations [CHAR LIMIT=25] -->
+    <string name="transition_animation_scale_title">Transition animation scale</string>
+
+    <!-- UI debug setting: scaling factor for all Animator-based animations [CHAR LIMIT=25] -->
+    <string name="animator_duration_scale_title">Animator duration scale</string>
+
+    <!-- UI debug setting: simulate secondary display devices using overlays [CHAR LIMIT=25] -->
+    <string name="overlay_display_devices_title">Simulate secondary displays</string>
+
+    <!-- Preference category for application debugging development settings. [CHAR LIMIT=25] -->
+    <string name="debug_applications_category">Apps</string>
+
+    <!-- UI debug setting: immediately destroy activities? [CHAR LIMIT=25] -->
+    <string name="immediately_destroy_activities">Don\u2019t keep activities</string>
+    <!-- UI debug setting: immediately destroy activities summary [CHAR LIMIT=50] -->
+    <string name="immediately_destroy_activities_summary">Destroy every activity as soon as
+        the user leaves it</string>
+
+    <!-- UI debug setting: limit number of running background processes [CHAR LIMIT=25] -->
+    <string name="app_process_limit_title">Background process limit</string>
+
+    <!-- UI debug setting: show all ANRs? [CHAR LIMIT=25] -->
+    <string name="show_all_anrs">Show all ANRs</string>
+    <!-- UI debug setting: show all ANRs summary [CHAR LIMIT=50] -->
+    <string name="show_all_anrs_summary">Show App Not Responding dialog
+        for background apps</string>
+
+    <!-- UI debug setting: force allow apps on external storage [CHAR LIMIT=50] -->
+    <string name="force_allow_on_external">Force allow apps on external</string>
+    <!-- UI debug setting: force allow on external summary [CHAR LIMIT=150] -->
+    <string name="force_allow_on_external_summary">Makes any app elligible to be written to external storage, regardless of manifest values</string>
+
+    <!-- UI debug setting: force all activites to be resizable for multiwindow [CHAR LIMIT=50] -->
+    <string name="force_resizable_activities">Force activities to be resizable</string>
+    <!-- UI debug setting: force allow on external summary [CHAR LIMIT=150] -->
+    <string name="force_resizable_activities_summary">Makes all activities resizable for multi-window, regardless of manifest values.</string>
+
+    <!-- Local (desktop) backup password menu title [CHAR LIMIT=25] -->
+    <string name="local_backup_password_title">Desktop backup password</string>
+    <!-- Summary text of the "local backup password" setting when the user has not supplied a password -->
+    <string name="local_backup_password_summary_none">Desktop full backups aren\u2019t currently protected</string>
+    <!-- Summary text of the "local backup password" setting when the user has already supplied a password -->
+    <string name="local_backup_password_summary_change">Touch to change or remove the password for desktop full backups</string>
+
+    <!-- Toast message shown when the user successfully sets a new local backup password [CHAR LIMIT=80] -->
+    <string name="local_backup_password_toast_success">New backup password set</string>
+    <!-- Toast message shown when setting a new local backup password fails due to the user not correctly typing the password again for confirmation [CHAR LIMIT=80] -->
+    <string name="local_backup_password_toast_confirmation_mismatch">New password and confirmation don\u2019t match</string>
+    <!-- Toast message shown when setting a new local backup password fails due to the user not supplying the correct existing password. The phrasing here is deliberately quite general. [CHAR LIMIT=80] -->
+    <string name="local_backup_password_toast_validation_failure">Failure setting backup password</string>
+
+    <!-- Name of each color mode for the display. [CHAR LIMIT=40] -->
+    <string-array name="color_mode_names">
+        <item>Vibrant (default)</item>
+        <item>Natural</item>
+        <item>Standard</item>
+    </string-array>
+
+    <!-- Description of each color mode for the display. [CHAR LIMIT=NONE] -->
+    <string-array name="color_mode_descriptions">
+        <item>Enhanced colors</item>
+        <item>Natural colors as seen by the eye</item>
+        <item>Colors optimized for digital content</item>
+    </string-array>
+
+    <!-- Settings item title for inactive apps [CHAR LIMIT=35] -->
+    <string name="inactive_apps_title">Inactive apps</string>
+    <!-- Settings item summary for inactive app [CHAR LIMIT=100] -->
+    <string name="inactive_app_inactive_summary">Inactive. Touch to toggle.</string>
+    <!-- Settings item summary for active app [CHAR LIMIT=100] -->
+    <string name="inactive_app_active_summary">Active. Touch to toggle.</string>
+
+    <!-- Services settings screen, setting option name for the user to go to the screen to view running services -->
+    <string name="runningservices_settings_title">Running services</string>
+    <!-- Services settings screen, setting option summary for the user to go to the screen to view running services  -->
+    <string name="runningservices_settings_summary">View and control currently running services</string>
+
+    <!-- Sound & display settings screen, setting option name to change the user interface theme [CHAR LIMIT=30] -->
+    <string name="night_mode_title">Night mode</string>
+    <!-- Sound & display settings screen, setting option summary to change the user interface theme [CHAR LIMIT=100] -->
+    <string name="night_mode_summary">%s</string>
+    <!-- Sound & display settings screen, theme setting value to prefer a light-colored user interface [CHAR LIMIT=30] -->
+    <string name="night_mode_no">Disabled</string>
+    <!-- Sound & display settings screen, theme setting value to prefer a dark-colored user interface [CHAR LIMIT=30] -->
+    <string name="night_mode_yes">Always on</string>
+    <!-- Sound & display settings screen, theme setting value to automatically switch between a light- or dark-colored user interface [CHAR LIMIT=30] -->
+    <string name="night_mode_auto">Automatic</string>
+
+    <!-- Developer settings screen, convert userdata to file encryption option name -->
+    <string name="convert_to_file_encryption">Convert to file encryption</string>
+    <!-- Developer settings screen, convert userdata to file encryption summary when option is available -->
+    <string name="convert_to_file_encryption_enabled">Convert\u2026</string>
+    <!-- Developer settings screen, convert userdata to file encryption summary when option is already done -->
+    <string name="convert_to_file_encryption_done">Already file encrypted</string>
+    <!-- Title used on dialog with final prompt for converting to file encryption -->
+    <string name="title_convert_fbe">Converting to file based encryption</string>
+    <!-- Warning displayed on dialog with final prompt for converting to file encryption -->
+    <string name="convert_to_fbe_warning">
+        Convert data partition to file based encryption.\n
+        !!Warning!! This will erase all your data.\n
+        This feature is alpha, and may not work correctly.\n
+        Press \'Wipe and convert\u2026\' to continue.</string>
+    <!-- Button on dialog that triggers convertion to file encryption -->
+    <string name="button_convert_fbe">Wipe and convert\u2026</string>
+
+    <!-- Name of feature to change color setting for the display [CHAR LIMIT=60] -->
+    <string name="picture_color_mode">Picture color mode</string>
+
+    <!-- Description of feature to change color setting for the display [CHAR LIMIT=NONE] -->
+    <string name="picture_color_mode_desc">Use sRGB</string>
+
+    <!-- Label for disabling color space adjustment [CHAR LIMIT=45] -->
+    <string name="daltonizer_mode_disabled">Disabled</string>
+    <!-- Label for converting display colors to grayscale, which simulates monochromacy (complete color blindness). [CHAR LIMIT=45] -->
+    <string name="daltonizer_mode_monochromacy">Monochromacy</string>
+    <!-- Label for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
+    <string name="daltonizer_mode_deuteranomaly">Deuteranomaly (red-green)</string>
+    <!-- Label for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
+    <string name="daltonizer_mode_protanomaly">Protanomaly (red-green)</string>
+    <!-- Label for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
+    <string name="daltonizer_mode_tritanomaly">Tritanomaly (blue-yellow)</string>
+
+    <!-- Title for the accessibility preference to configure display color space correction. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_display_daltonizer_preference_title">Color correction</string>
+    <!-- Subtitle for the accessibility preference to configure display color space correction. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_display_daltonizer_preference_subtitle">This feature is experimental and may affect performance.</string>
+    <!-- Summary shown for color space correction preference when its value is overridden by another preference [CHAR LIMIT=35] -->
+    <string name="daltonizer_type_overridden">Overridden by <xliff:g id="title" example="Simulate color space">%1$s</xliff:g></string>
+
 </resources>
diff --git a/services/core/java/com/android/server/NativeDaemonConnector.java b/services/core/java/com/android/server/NativeDaemonConnector.java
index e6b6074..d6dbad8 100644
--- a/services/core/java/com/android/server/NativeDaemonConnector.java
+++ b/services/core/java/com/android/server/NativeDaemonConnector.java
@@ -177,6 +177,7 @@
 
             mCallbacks.onDaemonConnected();
 
+            FileDescriptor[] fdList = null;
             byte[] buffer = new byte[BUFFER_SIZE];
             int start = 0;
 
@@ -186,6 +187,7 @@
                     loge("got " + count + " reading with start = " + start);
                     break;
                 }
+                fdList = socket.getAncillaryFileDescriptors();
 
                 // Add our starting point to the count and reset the start.
                 count += start;
@@ -200,8 +202,8 @@
 
                         boolean releaseWl = false;
                         try {
-                            final NativeDaemonEvent event = NativeDaemonEvent.parseRawEvent(
-                                    rawEvent);
+                            final NativeDaemonEvent event =
+                                    NativeDaemonEvent.parseRawEvent(rawEvent, fdList);
 
                             log("RCV <- {" + event + "}");
 
diff --git a/services/core/java/com/android/server/NativeDaemonEvent.java b/services/core/java/com/android/server/NativeDaemonEvent.java
index 4e61c0b..e6feda3 100644
--- a/services/core/java/com/android/server/NativeDaemonEvent.java
+++ b/services/core/java/com/android/server/NativeDaemonEvent.java
@@ -19,6 +19,7 @@
 import android.util.Slog;
 import com.google.android.collect.Lists;
 
+import java.io.FileDescriptor;
 import java.util.ArrayList;
 
 /**
@@ -35,15 +36,17 @@
     private final String mRawEvent;
     private final String mLogMessage;
     private String[] mParsed;
+    private FileDescriptor[] mFdList;
 
     private NativeDaemonEvent(int cmdNumber, int code, String message,
-                              String rawEvent, String logMessage) {
+                              String rawEvent, String logMessage, FileDescriptor[] fdList) {
         mCmdNumber = cmdNumber;
         mCode = code;
         mMessage = message;
         mRawEvent = rawEvent;
         mLogMessage = logMessage;
         mParsed = null;
+        mFdList = fdList;
     }
 
     static public final String SENSITIVE_MARKER = "{{sensitive}}";
@@ -60,6 +63,10 @@
         return mMessage;
     }
 
+    public FileDescriptor[] getFileDescriptors() {
+        return mFdList;
+    }
+
     @Deprecated
     public String getRawEvent() {
         return mRawEvent;
@@ -127,7 +134,7 @@
      * @throws IllegalArgumentException when line doesn't match format expected
      *             from native side.
      */
-    public static NativeDaemonEvent parseRawEvent(String rawEvent) {
+    public static NativeDaemonEvent parseRawEvent(String rawEvent, FileDescriptor[] fdList) {
         final String[] parsed = rawEvent.split(" ");
         if (parsed.length < 2) {
             throw new IllegalArgumentException("Insufficient arguments");
@@ -164,7 +171,7 @@
 
         final String message = rawEvent.substring(skiplength);
 
-        return new NativeDaemonEvent(cmdNumber, code, message, rawEvent, logMessage);
+        return new NativeDaemonEvent(cmdNumber, code, message, rawEvent, logMessage, fdList);
     }
 
     /**
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 93eaf0e..91702cf 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -3484,6 +3484,14 @@
                 return false;
             }
 
+            final ActivityManager am = mContext.getSystemService(ActivityManager.class);
+            if (am.isUserRunningAndLocked(mAccounts.userId)
+                    && !authenticatorInfo.componentInfo.encryptionAware) {
+                Slog.w(TAG, "Blocking binding to authenticator " + authenticatorInfo.componentName
+                        + " which isn't encryption aware");
+                return false;
+            }
+
             Intent intent = new Intent();
             intent.setAction(AccountManager.ACTION_AUTHENTICATOR_INTENT);
             intent.setComponent(authenticatorInfo.componentName);
@@ -3498,7 +3506,6 @@
                 return false;
             }
 
-
             return true;
         }
     }
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 36a7cee..7413e5a 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1424,16 +1424,15 @@
     final void ensureActivitiesVisibleLocked(ActivityRecord starting, int configChanges,
             boolean preserveWindows) {
         ActivityRecord top = topRunningActivityLocked();
-        if (top == null) {
-            return;
-        }
         if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "ensureActivitiesVisible behind " + top
                 + " configChanges=0x" + Integer.toHexString(configChanges));
-        checkTranslucentActivityWaiting(top);
+        if (top != null) {
+            checkTranslucentActivityWaiting(top);
+        }
 
         // If the top activity is not fullscreen, then we need to
         // make sure any activities under it are now visible.
-        boolean aboveTop = true;
+        boolean aboveTop = top != null;
         final boolean stackInvisible = !isStackVisibleLocked();
         boolean behindFullscreenActivity = stackInvisible;
         boolean noStackActivityResumed = (isInStackLocked(starting) == null);
@@ -1447,13 +1446,15 @@
                 if (r.finishing) {
                     continue;
                 }
-                if (aboveTop && r != top) {
+                final boolean isTop = r == top;
+                if (aboveTop && !isTop) {
                     continue;
                 }
                 aboveTop = false;
                 // mLaunchingBehind: Activities launching behind are at the back of the task stack
                 // but must be drawn initially for the animation as though they were visible.
-                if (!behindFullscreenActivity || r.mLaunchTaskBehind) {
+                if ((!behindFullscreenActivity || r.mLaunchTaskBehind)
+                        && okToShowLocked(r)) {
                     if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY,
                             "Make visible? " + r + " finishing=" + r.finishing
                             + " state=" + r.state);
@@ -1464,7 +1465,7 @@
                     }
 
                     if (r.app == null || r.app.thread == null) {
-                        if (makeVisibleAndRestartIfNeeded(starting, configChanges, top,
+                        if (makeVisibleAndRestartIfNeeded(starting, configChanges, isTop,
                                 noStackActivityResumed, r)) {
                             if (activityNdx >= activities.size()) {
                                 // Record may be removed if its process needs to restart.
@@ -1474,18 +1475,19 @@
                             }
                         }
                     } else if (r.visible) {
-                        if (alreadyVisible(r)) {
+                        // If this activity is already visible, then there is nothing to do here.
+                        if (handleAlreadyVisible(r)) {
                             noStackActivityResumed = false;
                         }
                     } else {
-                        becomeVisible(starting, r);
+                        makeVisible(starting, r);
                     }
                     // Aggregate current change flags.
                     configChanges |= r.configChangeFlags;
                     behindFullscreenActivity = updateBehindFullscreen(stackInvisible,
                             behindFullscreenActivity, task, r);
                 } else {
-                    becomeInvisible(stackInvisible, behindFullscreenActivity, r);
+                    makeInvisible(stackInvisible, behindFullscreenActivity, r);
                 }
             }
             if (mStackId == FREEFORM_WORKSPACE_STACK_ID) {
@@ -1516,12 +1518,12 @@
     }
 
     private boolean makeVisibleAndRestartIfNeeded(ActivityRecord starting, int configChanges,
-            ActivityRecord top, boolean noStackActivityResumed, ActivityRecord r) {
+            boolean isTop, boolean noStackActivityResumed, ActivityRecord r) {
         // We need to make sure the app is running if it's the top, or it is just made visible from
         // invisible. If the app is already visible, it must have died while it was visible. In this
         // case, we'll show the dead window but will not restart the app. Otherwise we could end up
         // thrashing.
-        if (r == top || !r.visible) {
+        if (isTop || !r.visible) {
             // This activity needs to be visible, but isn't even running...
             // get it started and resume if no other stack in this stack is resumed.
             if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Start and freeze screen for " + r);
@@ -1540,7 +1542,7 @@
         return false;
     }
 
-    private void becomeInvisible(boolean stackInvisible, boolean behindFullscreenActivity,
+    private void makeInvisible(boolean stackInvisible, boolean behindFullscreenActivity,
             ActivityRecord r) {
         if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Make invisible? " + r + " finishing="
                 + r.finishing + " state=" + r.state + " stackInvisible=" + stackInvisible
@@ -1606,7 +1608,7 @@
         return behindFullscreenActivity;
     }
 
-    private void becomeVisible(ActivityRecord starting, ActivityRecord r) {
+    private void makeVisible(ActivityRecord starting, ActivityRecord r) {
         // This activity is not currently visible, but is running. Tell it to become visible.
         r.visible = true;
         if (r.state != ActivityState.RESUMED && r != starting) {
@@ -1631,8 +1633,7 @@
         }
     }
 
-    private boolean alreadyVisible(ActivityRecord r) {
-        // If this activity is already visible, then there is nothing else to do here.
+    private boolean handleAlreadyVisible(ActivityRecord r) {
         if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Skipping: already visible at " + r);
         r.stopFreezingScreenLocked(false);
         try {
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index a6af0d10..18b3e62 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -2702,7 +2702,6 @@
             Configuration config) {
         if (DEBUG_ALL) Slog.v(TAG, "Activity idle: " + token);
 
-        ArrayList<ActivityRecord> stops = null;
         ArrayList<ActivityRecord> finishes = null;
         ArrayList<UserState> startingUsers = null;
         int NS = 0;
@@ -2756,7 +2755,7 @@
         }
 
         // Atomically retrieve all of the other things to do.
-        stops = processStoppingActivitiesLocked(true);
+        final ArrayList<ActivityRecord> stops = processStoppingActivitiesLocked(true);
         NS = stops != null ? stops.size() : 0;
         if ((NF = mFinishingActivities.size()) > 0) {
             finishes = new ArrayList<>(mFinishingActivities);
@@ -4304,12 +4303,14 @@
         mWindowManager.getStackBounds(stack.mStackId, info.bounds);
         info.displayId = Display.DEFAULT_DISPLAY;
         info.stackId = stack.mStackId;
+        info.userId = stack.mCurrentUser;
 
         ArrayList<TaskRecord> tasks = stack.getAllTasks();
         final int numTasks = tasks.size();
         int[] taskIds = new int[numTasks];
         String[] taskNames = new String[numTasks];
         Rect[] taskBounds = new Rect[numTasks];
+        int[] taskUserIds = new int[numTasks];
         for (int i = 0; i < numTasks; ++i) {
             final TaskRecord task = tasks.get(i);
             taskIds[i] = task.taskId;
@@ -4319,10 +4320,12 @@
                     : "unknown";
             taskBounds[i] = new Rect();
             mWindowManager.getTaskBounds(task.taskId, taskBounds[i]);
+            taskUserIds[i] = task.userId;
         }
         info.taskIds = taskIds;
         info.taskNames = taskNames;
         info.taskBounds = taskBounds;
+        info.taskUserIds = taskUserIds;
         return info;
     }
 
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index 4f53882..a066835 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -422,8 +422,8 @@
 
             if (Intent.ACTION_USER_REMOVED.equals(action)) {
                 onUserRemoved(userId);
-            } else if (Intent.ACTION_USER_STARTING.equals(action)) {
-                onUserStarting(userId);
+            } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
+                onUserUnlocked(userId);
             } else if (Intent.ACTION_USER_STOPPING.equals(action)) {
                 onUserStopping(userId);
             }
@@ -517,7 +517,7 @@
 
         intentFilter = new IntentFilter();
         intentFilter.addAction(Intent.ACTION_USER_REMOVED);
-        intentFilter.addAction(Intent.ACTION_USER_STARTING);
+        intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
         intentFilter.addAction(Intent.ACTION_USER_STOPPING);
         mContext.registerReceiverAsUser(
                 mUserIntentReceiver, UserHandle.ALL, intentFilter, null, null);
@@ -1292,7 +1292,7 @@
         }
     }
 
-    private void onUserStarting(int userId) {
+    private void onUserUnlocked(int userId) {
         // Make sure that accounts we're about to use are valid
         AccountManagerService.getSingleton().validateAccounts(userId);
 
@@ -2673,21 +2673,20 @@
                 final Iterator<SyncOperation> operationIterator =
                         mSyncQueue.getOperations().iterator();
 
-                final ActivityManager activityManager
-                        = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+                final ActivityManager am = mContext.getSystemService(ActivityManager.class);
                 final Set<Integer> removedUsers = Sets.newHashSet();
                 while (operationIterator.hasNext()) {
                     final SyncOperation op = operationIterator.next();
 
-                    // If the user is not running, skip the request.
-                    if (!activityManager.isUserRunning(op.target.userId)) {
+                    // If the user is not running unlocked, skip the request.
+                    if (!am.isUserRunningAndUnlocked(op.target.userId)) {
                         final UserInfo userInfo = mUserManager.getUserInfo(op.target.userId);
                         if (userInfo == null) {
                             removedUsers.add(op.target.userId);
                         }
                         if (isLoggable) {
                             Log.v(TAG, "    Dropping all sync operations for + "
-                                    + op.target.userId + ": user not running.");
+                                    + op.target.userId + ": user not running unlocked.");
                         }
                         continue;
                     }
diff --git a/services/core/java/com/android/server/job/JobStore.java b/services/core/java/com/android/server/job/JobStore.java
index 0004c42..d9f94d0 100644
--- a/services/core/java/com/android/server/job/JobStore.java
+++ b/services/core/java/com/android/server/job/JobStore.java
@@ -278,6 +278,11 @@
                 // Copy over the jobs so we can release the lock before writing.
                 for (int i=0; i<mJobSet.size(); i++) {
                     JobStatus jobStatus = mJobSet.valueAt(i);
+
+                    if (!jobStatus.isPersisted()){
+                        continue;
+                    }
+
                     JobStatus copy = new JobStatus(jobStatus.getJob(), jobStatus.getUid(),
                             jobStatus.getEarliestRunTime(), jobStatus.getLatestRunTimeElapsed());
                     mStoreCopy.add(copy);
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 8ef8276..6f19911 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4868,15 +4868,21 @@
                 // Check for results in the current profile.
                 List<ResolveInfo> result = mActivities.queryIntent(
                         intent, resolvedType, flags, userId);
+                result = filterIfNotSystemUser(result, userId);
 
                 // Check for cross profile results.
+                boolean hasNonNegativePriorityResult = hasNonNegativePriority(result);
                 xpResolveInfo = queryCrossProfileIntents(
-                        matchingFilters, intent, resolvedType, flags, userId);
+                        matchingFilters, intent, resolvedType, flags, userId,
+                        hasNonNegativePriorityResult);
                 if (xpResolveInfo != null && isUserEnabled(xpResolveInfo.targetUserId)) {
-                    result.add(xpResolveInfo);
-                    Collections.sort(result, mResolvePrioritySorter);
+                    boolean isVisibleToUser = filterIfNotSystemUser(
+                            Collections.singletonList(xpResolveInfo), userId).size() > 0;
+                    if (isVisibleToUser) {
+                        result.add(xpResolveInfo);
+                        Collections.sort(result, mResolvePrioritySorter);
+                    }
                 }
-                result = filterIfNotSystemUser(result, userId);
                 if (hasWebURI(intent)) {
                     CrossProfileDomainInfo xpDomainInfo = null;
                     final UserInfo parent = getProfileParent(userId);
@@ -5009,6 +5015,14 @@
         return resolveInfos;
     }
 
+    /**
+     * @param resolveInfos list of resolve infos in descending priority order
+     * @return if the list contains a resolve info with non-negative priority
+     */
+    private boolean hasNonNegativePriority(List<ResolveInfo> resolveInfos) {
+        return resolveInfos.size() > 0 && resolveInfos.get(0).priority >= 0;
+    }
+
     private static boolean hasWebURI(Intent intent) {
         if (intent.getData() == null) {
             return false;
@@ -5212,10 +5226,10 @@
         return null;
     }
 
-    // Return matching ResolveInfo if any for skip current profile intent filters.
+    // Return matching ResolveInfo in target user if any.
     private ResolveInfo queryCrossProfileIntents(
             List<CrossProfileIntentFilter> matchingFilters, Intent intent, String resolvedType,
-            int flags, int sourceUserId) {
+            int flags, int sourceUserId, boolean matchInCurrentProfile) {
         if (matchingFilters != null) {
             // Two {@link CrossProfileIntentFilter}s can have the same targetUserId and
             // match the same intent. For performance reasons, it is better not to
@@ -5225,8 +5239,12 @@
             for (int i = 0; i < size; i++) {
                 CrossProfileIntentFilter filter = matchingFilters.get(i);
                 int targetUserId = filter.getTargetUserId();
-                if ((filter.getFlags() & PackageManager.SKIP_CURRENT_PROFILE) == 0
-                        && !alreadyTriedUserIds.get(targetUserId)) {
+                boolean skipCurrentProfile =
+                        (filter.getFlags() & PackageManager.SKIP_CURRENT_PROFILE) != 0;
+                boolean skipCurrentProfileIfNoMatchFound =
+                        (filter.getFlags() & PackageManager.ONLY_IF_NO_MATCH_FOUND) != 0;
+                if (!skipCurrentProfile && !alreadyTriedUserIds.get(targetUserId)
+                        && (!skipCurrentProfileIfNoMatchFound || !matchInCurrentProfile)) {
                     // Checking if there are activities in the target user that can handle the
                     // intent.
                     ResolveInfo resolveInfo = createForwardingResolveInfo(filter, intent,
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index df8d5d6..32c9b2a 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -20,8 +20,6 @@
 import android.graphics.Rect;
 import android.os.RemoteException;
 import android.util.Slog;
-import android.util.SparseArray;
-import android.util.SparseIntArray;
 import android.view.IDockDividerVisibilityListener;
 
 import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
@@ -46,6 +44,7 @@
     private final Rect mLastRect = new Rect();
     private IDockDividerVisibilityListener mListener;
     private boolean mLastVisibility = false;
+    private boolean mForceVisibilityReevaluation;
 
     DockedStackDividerController(Context context, DisplayContent displayContent) {
         mDisplayContent = displayContent;
@@ -69,16 +68,16 @@
 
     void setWindow(WindowState window) {
         mWindow = window;
-        reevaluateVisibility();
+        reevaluateVisibility(false);
     }
 
-    void reevaluateVisibility() {
+    void reevaluateVisibility(boolean force) {
         if (mWindow == null) {
             return;
         }
         TaskStack stack = mDisplayContent.mService.mStackIdToStack.get(DOCKED_STACK_ID);
         final boolean visible = stack != null && stack.isVisibleLocked();
-        if (mLastVisibility == visible) {
+        if (mLastVisibility == visible && !force) {
             return;
         }
         mLastVisibility = visible;
@@ -131,5 +130,6 @@
             throw new IllegalStateException("Dock divider visibility listener already set!");
         }
         mListener = listener;
+        reevaluateVisibility(true);
     }
 }
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index f25f1e3..de1f4d1 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -8030,7 +8030,7 @@
                 case UPDATE_DOCKED_STACK_DIVIDER: {
                     synchronized (mWindowMap) {
                         getDefaultDisplayContentLocked().getDockedDividerController()
-                                .reevaluateVisibility();
+                                .reevaluateVisibility(false);
                     }
                 }
                 break;
diff --git a/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java
index f9aa124..5b4803b 100644
--- a/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/accounts/AccountManagerServiceTest.java
@@ -195,8 +195,8 @@
             mServices = new ArrayList<ServiceInfo<AuthenticatorDescription>>();
             AuthenticatorDescription d1 = new AuthenticatorDescription("type1", "p1", 0, 0, 0, 0);
             AuthenticatorDescription d2 = new AuthenticatorDescription("type2", "p2", 0, 0, 0, 0);
-            mServices.add(new ServiceInfo<AuthenticatorDescription>(d1, null, 0));
-            mServices.add(new ServiceInfo<AuthenticatorDescription>(d2, null, 0));
+            mServices.add(new ServiceInfo<AuthenticatorDescription>(d1, null, null));
+            mServices.add(new ServiceInfo<AuthenticatorDescription>(d2, null, null));
         }
 
         @Override
diff --git a/services/tests/servicestests/src/com/android/server/job/JobStoreTest.java b/services/tests/servicestests/src/com/android/server/job/JobStoreTest.java
index 0b73beb..312b1b0 100644
--- a/services/tests/servicestests/src/com/android/server/job/JobStoreTest.java
+++ b/services/tests/servicestests/src/com/android/server/job/JobStoreTest.java
@@ -183,6 +183,28 @@
     }
 
     /**
+     * Test that non persisted job is not written to disk.
+     */
+    public void testNonPersistedTaskIsNotPersisted() throws Exception {
+        JobInfo.Builder b = new Builder(42, mComponent)
+                .setOverrideDeadline(10000)
+                .setPersisted(false);
+        JobStatus jsNonPersisted = new JobStatus(b.build(), SOME_UID);
+        mTaskStoreUnderTest.add(jsNonPersisted);
+        b = new Builder(43, mComponent)
+                .setOverrideDeadline(10000)
+                .setPersisted(true);
+        JobStatus jsPersisted = new JobStatus(b.build(), SOME_UID);
+        mTaskStoreUnderTest.add(jsPersisted);
+        Thread.sleep(IO_WAIT);
+        final ArraySet<JobStatus> jobStatusSet = new ArraySet<JobStatus>();
+        mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
+        assertEquals("Job count is incorrect.", 1, jobStatusSet.size());
+        JobStatus jobStatus = jobStatusSet.iterator().next();
+        assertEquals("Wrong job persisted.", 43, jobStatus.getJobId());
+    }
+
+    /**
      * Helper function to throw an error if the provided task and TaskStatus objects are not equal.
      */
     private void assertTasksEqual(JobInfo first, JobInfo second) {
diff --git a/services/usb/java/com/android/server/usb/UsbSettingsManager.java b/services/usb/java/com/android/server/usb/UsbSettingsManager.java
index 154cbd3..4786d11 100644
--- a/services/usb/java/com/android/server/usb/UsbSettingsManager.java
+++ b/services/usb/java/com/android/server/usb/UsbSettingsManager.java
@@ -984,7 +984,14 @@
     public boolean hasPermission(UsbDevice device) {
         synchronized (mLock) {
             int uid = Binder.getCallingUid();
-            if (uid == Process.SYSTEM_UID || mDisablePermissionDialogs) {
+            int androidMediaUid;
+            try {
+                androidMediaUid = mPackageManager.getApplicationInfo("com.android.mtp", 0).uid;
+            } catch (NameNotFoundException e) {
+                androidMediaUid = -1;
+            }
+            if (uid == Process.SYSTEM_UID || UserHandle.getAppId(uid) == androidMediaUid ||
+                    mDisablePermissionDialogs) {
                 return true;
             }
             SparseBooleanArray uidList = mDevicePermissionMap.get(device.getDeviceName());
diff --git a/telephony/java/android/telephony/CellSignalStrengthLte.java b/telephony/java/android/telephony/CellSignalStrengthLte.java
index 5a1559a..2606466 100644
--- a/telephony/java/android/telephony/CellSignalStrengthLte.java
+++ b/telephony/java/android/telephony/CellSignalStrengthLte.java
@@ -168,6 +168,20 @@
     }
 
     /**
+     * @hide
+     */
+    public int getRsrq() {
+        return mRsrq;
+    }
+
+    /**
+     * @hide
+     */
+    public int getRssnr() {
+        return mRssnr;
+    }
+
+    /**
      * Get signal strength as dBm
      */
     @Override
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index b430340..553221d 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -2354,7 +2354,7 @@
                         tempDialStr = postDialStr.substring(dialableIndex);
                     } else {
                         // Non-dialable character such as P/W should not be at the end of
-                        // the dial string after P/W processing in CdmaConnection.java
+                        // the dial string after P/W processing in GsmCdmaConnection.java
                         // Set the postDialStr to "" to break out of the loop
                         if (dialableIndex < 0) {
                             postDialStr = "";
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 1337487..8537f9c 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -906,7 +906,7 @@
 
     /**
      * In CDMA, mOperatorAlphaLong can be set from the ERI text.
-     * This is done from the CDMAPhone and not from the CdmaServiceStateTracker.
+     * This is done from the GsmCdmaPhone and not from the ServiceStateTracker.
      *
      * @hide
      */