Merge "Update client configuration when resizing without crossing size threshold."
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 7b2e273..c017754 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -2728,6 +2728,7 @@
     method public android.os.Bundle addAccountFromCredentials(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle confirmCredentials(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle editProperties(android.accounts.AccountAuthenticatorResponse, java.lang.String);
+    method public android.os.Bundle finishSession(android.accounts.AccountAuthenticatorResponse, java.lang.String, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public android.os.Bundle getAccountCredentialsForCloning(android.accounts.AccountAuthenticatorResponse, android.accounts.Account) throws android.accounts.NetworkErrorException;
     method public android.os.Bundle getAccountRemovalAllowed(android.accounts.AccountAuthenticatorResponse, android.accounts.Account) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle getAuthToken(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, java.lang.String, android.os.Bundle) throws android.accounts.NetworkErrorException;
@@ -2773,6 +2774,7 @@
     method public void clearPassword(android.accounts.Account);
     method public android.accounts.AccountManagerFuture<android.os.Bundle> confirmCredentials(android.accounts.Account, android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
     method public android.accounts.AccountManagerFuture<android.os.Bundle> editProperties(java.lang.String, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
+    method public android.accounts.AccountManagerFuture<android.os.Bundle> finishSession(android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
     method public static android.accounts.AccountManager get(android.content.Context);
     method public android.accounts.Account[] getAccounts();
     method public android.accounts.Account[] getAccountsByType(java.lang.String);
@@ -22931,7 +22933,9 @@
     method public static void incrementOperationCount(int);
     method public static void incrementOperationCount(int, int);
     method public static void setThreadStatsTag(int);
+    method public static void tagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException;
     method public static void tagSocket(java.net.Socket) throws java.net.SocketException;
+    method public static void untagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException;
     method public static void untagSocket(java.net.Socket) throws java.net.SocketException;
     field public static final int UNSUPPORTED = -1; // 0xffffffff
   }
@@ -28068,8 +28072,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 +29640,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 +29787,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 +29967,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 +30096,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 +30448,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
@@ -38651,10 +38661,11 @@
     field public static final int RTL = 1; // 0x1
   }
 
-  public final class LocaleList {
+  public final class LocaleList implements android.os.Parcelable {
     ctor public LocaleList();
     ctor public LocaleList(java.util.Locale);
     ctor public LocaleList(java.util.Locale[]);
+    method public int describeContents();
     method public static android.util.LocaleList forLanguageTags(java.lang.String);
     method public java.util.Locale get(int);
     method public java.util.Locale getBestMatch(java.lang.String[]);
@@ -38664,6 +38675,8 @@
     method public boolean isEmpty();
     method public int size();
     method public java.lang.String toLanguageTags();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.util.LocaleList> CREATOR;
   }
 
   public final class Log {
@@ -42947,6 +42960,7 @@
     field public int initialSelStart;
     field public int inputType;
     field public java.lang.CharSequence label;
+    field public android.util.LocaleList locales;
     field public java.lang.String packageName;
     field public java.lang.String privateImeOptions;
   }
@@ -64085,4 +64099,3 @@
   }
 
 }
-
diff --git a/api/system-current.txt b/api/system-current.txt
index 65dbc50..8128819 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -2829,6 +2829,7 @@
     method public android.os.Bundle addAccountFromCredentials(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle confirmCredentials(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle editProperties(android.accounts.AccountAuthenticatorResponse, java.lang.String);
+    method public android.os.Bundle finishSession(android.accounts.AccountAuthenticatorResponse, java.lang.String, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public android.os.Bundle getAccountCredentialsForCloning(android.accounts.AccountAuthenticatorResponse, android.accounts.Account) throws android.accounts.NetworkErrorException;
     method public android.os.Bundle getAccountRemovalAllowed(android.accounts.AccountAuthenticatorResponse, android.accounts.Account) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle getAuthToken(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, java.lang.String, android.os.Bundle) throws android.accounts.NetworkErrorException;
@@ -2874,6 +2875,7 @@
     method public void clearPassword(android.accounts.Account);
     method public android.accounts.AccountManagerFuture<android.os.Bundle> confirmCredentials(android.accounts.Account, android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
     method public android.accounts.AccountManagerFuture<android.os.Bundle> editProperties(java.lang.String, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
+    method public android.accounts.AccountManagerFuture<android.os.Bundle> finishSession(android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
     method public static android.accounts.AccountManager get(android.content.Context);
     method public android.accounts.Account[] getAccounts();
     method public android.accounts.Account[] getAccountsByType(java.lang.String);
@@ -24518,7 +24520,9 @@
     method public static void setThreadStatsTagBackup();
     method public static void setThreadStatsTagRestore();
     method public static void setThreadStatsUid(int);
+    method public static void tagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException;
     method public static void tagSocket(java.net.Socket) throws java.net.SocketException;
+    method public static void untagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException;
     method public static void untagSocket(java.net.Socket) throws java.net.SocketException;
     field public static final int UNSUPPORTED = -1; // 0xffffffff
   }
@@ -25528,10 +25532,12 @@
     field public static final java.lang.String EXTRA_NETWORK_INFO = "networkInfo";
     field public static final java.lang.String EXTRA_NEW_RSSI = "newRssi";
     field public static final java.lang.String EXTRA_NEW_STATE = "newState";
+    field public static final java.lang.String EXTRA_PREVIOUS_WIFI_AP_STATE = "previous_wifi_state";
     field public static final java.lang.String EXTRA_PREVIOUS_WIFI_STATE = "previous_wifi_state";
     field public static final java.lang.String EXTRA_RESULTS_UPDATED = "resultsUpdated";
     field public static final java.lang.String EXTRA_SUPPLICANT_CONNECTED = "connected";
     field public static final java.lang.String EXTRA_SUPPLICANT_ERROR = "supplicantError";
+    field public static final java.lang.String EXTRA_WIFI_AP_STATE = "wifi_state";
     field public static final java.lang.String EXTRA_WIFI_CONFIGURATION = "wifiConfiguration";
     field public static final java.lang.String EXTRA_WIFI_CREDENTIAL_EVENT_TYPE = "et";
     field public static final java.lang.String EXTRA_WIFI_CREDENTIAL_SSID = "ssid";
@@ -25543,6 +25549,12 @@
     field public static final java.lang.String SCAN_RESULTS_AVAILABLE_ACTION = "android.net.wifi.SCAN_RESULTS";
     field public static final java.lang.String SUPPLICANT_CONNECTION_CHANGE_ACTION = "android.net.wifi.supplicant.CONNECTION_CHANGE";
     field public static final java.lang.String SUPPLICANT_STATE_CHANGED_ACTION = "android.net.wifi.supplicant.STATE_CHANGE";
+    field public static final java.lang.String WIFI_AP_STATE_CHANGED_ACTION = "android.net.wifi.WIFI_AP_STATE_CHANGED";
+    field public static final int WIFI_AP_STATE_DISABLED = 11; // 0xb
+    field public static final int WIFI_AP_STATE_DISABLING = 10; // 0xa
+    field public static final int WIFI_AP_STATE_ENABLED = 13; // 0xd
+    field public static final int WIFI_AP_STATE_ENABLING = 12; // 0xc
+    field public static final int WIFI_AP_STATE_FAILED = 14; // 0xe
     field public static final java.lang.String WIFI_CREDENTIAL_CHANGED_ACTION = "android.net.wifi.WIFI_CREDENTIAL_CHANGED";
     field public static final int WIFI_CREDENTIAL_FORGOT = 1; // 0x1
     field public static final int WIFI_CREDENTIAL_SAVED = 0; // 0x0
@@ -30053,8 +30065,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);
@@ -31620,6 +31633,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";
@@ -31766,6 +31780,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";
@@ -31945,7 +31960,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";
@@ -32074,10 +32089,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
@@ -32454,6 +32471,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
@@ -37373,6 +37391,8 @@
     method public void notifyConfigChangedForSubId(int);
     method public void updateConfigForPhoneId(int, java.lang.String);
     field public static final java.lang.String ACTION_CARRIER_CONFIG_CHANGED = "android.telephony.action.CARRIER_CONFIG_CHANGED";
+    field public static final java.lang.String BOOL_ALLOW_EMERGENCY_VIDEO_CALLS = "bool_allow_emergency_video_calls";
+    field public static final java.lang.String BOOL_ALLOW_VIDEO_PAUSE = "bool_allow_video_pause";
     field public static final java.lang.String KEY_ADDITIONAL_CALL_SETTING_BOOL = "additional_call_setting_bool";
     field public static final java.lang.String KEY_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG_BOOL = "allow_emergency_numbers_in_call_log_bool";
     field public static final java.lang.String KEY_ALLOW_LOCAL_DTMF_TONES_BOOL = "allow_local_dtmf_tones_bool";
@@ -40977,10 +40997,11 @@
     field public static final int RTL = 1; // 0x1
   }
 
-  public final class LocaleList {
+  public final class LocaleList implements android.os.Parcelable {
     ctor public LocaleList();
     ctor public LocaleList(java.util.Locale);
     ctor public LocaleList(java.util.Locale[]);
+    method public int describeContents();
     method public static android.util.LocaleList forLanguageTags(java.lang.String);
     method public java.util.Locale get(int);
     method public java.util.Locale getBestMatch(java.lang.String[]);
@@ -40990,6 +41011,8 @@
     method public boolean isEmpty();
     method public int size();
     method public java.lang.String toLanguageTags();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.util.LocaleList> CREATOR;
   }
 
   public final class Log {
@@ -45276,6 +45299,7 @@
     field public int initialSelStart;
     field public int inputType;
     field public java.lang.CharSequence label;
+    field public android.util.LocaleList locales;
     field public java.lang.String packageName;
     field public java.lang.String privateImeOptions;
   }
diff --git a/api/test-current.txt b/api/test-current.txt
index 598924b..d05dba2 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -2728,6 +2728,7 @@
     method public android.os.Bundle addAccountFromCredentials(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle confirmCredentials(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle editProperties(android.accounts.AccountAuthenticatorResponse, java.lang.String);
+    method public android.os.Bundle finishSession(android.accounts.AccountAuthenticatorResponse, java.lang.String, android.os.Bundle) throws android.accounts.NetworkErrorException;
     method public android.os.Bundle getAccountCredentialsForCloning(android.accounts.AccountAuthenticatorResponse, android.accounts.Account) throws android.accounts.NetworkErrorException;
     method public android.os.Bundle getAccountRemovalAllowed(android.accounts.AccountAuthenticatorResponse, android.accounts.Account) throws android.accounts.NetworkErrorException;
     method public abstract android.os.Bundle getAuthToken(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, java.lang.String, android.os.Bundle) throws android.accounts.NetworkErrorException;
@@ -2773,6 +2774,7 @@
     method public void clearPassword(android.accounts.Account);
     method public android.accounts.AccountManagerFuture<android.os.Bundle> confirmCredentials(android.accounts.Account, android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
     method public android.accounts.AccountManagerFuture<android.os.Bundle> editProperties(java.lang.String, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
+    method public android.accounts.AccountManagerFuture<android.os.Bundle> finishSession(android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
     method public static android.accounts.AccountManager get(android.content.Context);
     method public android.accounts.Account[] getAccounts();
     method public android.accounts.Account[] getAccountsByType(java.lang.String);
@@ -22931,7 +22933,9 @@
     method public static void incrementOperationCount(int);
     method public static void incrementOperationCount(int, int);
     method public static void setThreadStatsTag(int);
+    method public static void tagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException;
     method public static void tagSocket(java.net.Socket) throws java.net.SocketException;
+    method public static void untagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException;
     method public static void untagSocket(java.net.Socket) throws java.net.SocketException;
     field public static final int UNSUPPORTED = -1; // 0xffffffff
   }
@@ -28068,8 +28072,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 +29642,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 +29789,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 +29969,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 +30098,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 +30450,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
@@ -38653,10 +38663,11 @@
     field public static final int RTL = 1; // 0x1
   }
 
-  public final class LocaleList {
+  public final class LocaleList implements android.os.Parcelable {
     ctor public LocaleList();
     ctor public LocaleList(java.util.Locale);
     ctor public LocaleList(java.util.Locale[]);
+    method public int describeContents();
     method public static android.util.LocaleList forLanguageTags(java.lang.String);
     method public java.util.Locale get(int);
     method public java.util.Locale getBestMatch(java.lang.String[]);
@@ -38666,6 +38677,8 @@
     method public boolean isEmpty();
     method public int size();
     method public java.lang.String toLanguageTags();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.util.LocaleList> CREATOR;
   }
 
   public final class Log {
@@ -42949,6 +42962,7 @@
     field public int initialSelStart;
     field public int inputType;
     field public java.lang.CharSequence label;
+    field public android.util.LocaleList locales;
     field public java.lang.String packageName;
     field public java.lang.String privateImeOptions;
   }
diff --git a/core/java/android/accounts/AbstractAccountAuthenticator.java b/core/java/android/accounts/AbstractAccountAuthenticator.java
index 041f591..a312e3f 100644
--- a/core/java/android/accounts/AbstractAccountAuthenticator.java
+++ b/core/java/android/accounts/AbstractAccountAuthenticator.java
@@ -18,6 +18,7 @@
 
 import android.os.Bundle;
 import android.os.RemoteException;
+import android.text.TextUtils;
 import android.os.Binder;
 import android.os.IBinder;
 import android.content.pm.PackageManager;
@@ -121,24 +122,28 @@
      * This is used in the default implementation of
      * {@link #startAddAccountSession} and {@link startUpdateCredentialsSession}.
      */
-    private static final String KEY_AUTH_TOKEN_TYPE = "android.accounts.KEY_AUTH_TOKEN_TYPE";
+    private static final String KEY_AUTH_TOKEN_TYPE =
+            "android.accounts.AbstractAccountAuthenticato.KEY_AUTH_TOKEN_TYPE";
     /**
      * Bundle key used for the {@link String} array of required features in
      * session bundle. This is used in the default implementation of
      * {@link #startAddAccountSession} and {@link startUpdateCredentialsSession}.
      */
-    private static final String KEY_REQUIRED_FEATURES = "android.accounts.AbstractAccountAuthenticator.KEY_REQUIRED_FEATURES";
+    private static final String KEY_REQUIRED_FEATURES =
+            "android.accounts.AbstractAccountAuthenticator.KEY_REQUIRED_FEATURES";
     /**
      * Bundle key used for the {@link Bundle} options in session bundle. This is
      * used in default implementation of {@link #startAddAccountSession} and
      * {@link startUpdateCredentialsSession}.
      */
-    private static final String KEY_OPTIONS = "android.accounts.AbstractAccountAuthenticator.KEY_OPTIONS";
+    private static final String KEY_OPTIONS =
+            "android.accounts.AbstractAccountAuthenticator.KEY_OPTIONS";
     /**
      * Bundle key used for the {@link Account} account in session bundle. This is used
      * used in default implementation of {@link startUpdateCredentialsSession}.
      */
-    private static final String KEY_ACCOUNT = "android.accounts.AbstractAccountAuthenticator.KEY_ACCOUNT";
+    private static final String KEY_ACCOUNT =
+            "android.accounts.AbstractAccountAuthenticator.KEY_ACCOUNT";
 
     private final Context mContext;
 
@@ -418,6 +423,7 @@
                     }
                     Log.v(TAG, "startUpdateCredentialsSession: result "
                             + AccountManager.sanitizeResult(result));
+
                 }
                 if (result != null) {
                     response.onResult(result);
@@ -425,6 +431,33 @@
             } catch (Exception e) {
                 handleException(response, "startUpdateCredentialsSession",
                         account.toString() + "," + authTokenType, e);
+
+            }
+        }
+
+        public void finishSession(
+                IAccountAuthenticatorResponse response,
+                String accountType,
+                Bundle sessionBundle) throws RemoteException {
+            if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                Log.v(TAG, "finishSession: accountType " + accountType);
+            }
+            checkBinderPermission();
+            try {
+                final Bundle result = AbstractAccountAuthenticator.this.finishSession(
+                        new AccountAuthenticatorResponse(response), accountType, sessionBundle);
+                if (result != null) {
+                    result.keySet(); // force it to be unparcelled
+                }
+                if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                    Log.v(TAG, "finishSession: result " + AccountManager.sanitizeResult(result));
+                }
+                if (result != null) {
+                    response.onResult(result);
+                }
+            } catch (Exception e) {
+                handleException(response, "finishSession", accountType, e);
+
             }
         }
     }
@@ -697,7 +730,13 @@
 
     /**
      * Starts the add account session to authenticate user to an account of the
-     * specified accountType.
+     * specified accountType. No file I/O should be performed in this call.
+     * Account should be added to device only when {@link #finishSession} is
+     * called after this.
+     * <p>
+     * Note: when overriding this method, {@link #finishSession} should be
+     * overridden too.
+     * </p>
      *
      * @param response to send the result back to the AccountManager, will never
      *            be null
@@ -722,9 +761,13 @@
      *         </ul>
      * @throws NetworkErrorException if the authenticator could not honor the
      *             request due to a network error
+     * @see #finishSession(AccountAuthenticatorResponse, String, Bundle)
      */
-    public Bundle startAddAccountSession(final AccountAuthenticatorResponse response,
-            final String accountType, final String authTokenType, final String[] requiredFeatures,
+    public Bundle startAddAccountSession(
+            final AccountAuthenticatorResponse response,
+            final String accountType,
+            final String authTokenType,
+            final String[] requiredFeatures,
             final Bundle options)
             throws NetworkErrorException {
         new Thread(new Runnable() {
@@ -744,34 +787,43 @@
     }
 
     /**
-     * Asks user to re-authenticate for an account but defers updating the locally stored
-     * credentials.
+     * Asks user to re-authenticate for an account but defers updating the
+     * locally stored credentials. No file I/O should be performed in this call.
+     * Local credentials should be updated only when {@link #finishSession} is
+     * called after this.
+     * <p>
+     * Note: when overriding this method, {@link #finishSession} should be
+     * overridden too.
+     * </p>
      *
      * @param response to send the result back to the AccountManager, will never
      *            be null
      * @param account the account whose credentials are to be updated, will
      *            never be null
      * @param authTokenType the type of auth token to retrieve after updating
-     *            the credentials, may be null (TODO)
+     *            the credentials, may be null
      * @param options a Bundle of authenticator-specific options, may be null
      * @return a Bundle result or null if the result is to be returned via the
      *         response. The result will contain either:
      *         <ul>
      *         <li>{@link AccountManager#KEY_INTENT}, or
-     *         <li>{@link AccountManager#KEY_ACCOUNT_SESSION_BUNDLE} for updating the
-     *         locally stored credentials later, and if account is
-     *         re-authenticated, {@link AccountManager#KEY_PASSWORD} and
-     *         {@link AccountManager#KEY_ACCOUNT_STATUS_TOKEN} for checking the
-     *         status of the account later, or
+     *         <li>{@link AccountManager#KEY_ACCOUNT_SESSION_BUNDLE} for
+     *         updating the locally stored credentials later, and if account is
+     *         re-authenticated, optional {@link AccountManager#KEY_PASSWORD}
+     *         and {@link AccountManager#KEY_ACCOUNT_STATUS_TOKEN} for checking
+     *         the status of the account later, or
      *         <li>{@link AccountManager#KEY_ERROR_CODE} and
      *         {@link AccountManager#KEY_ERROR_MESSAGE} to indicate an error
      *         </ul>
      * @throws NetworkErrorException if the authenticator could not honor the
      *             request due to a network error
+     * @see #finishSession(AccountAuthenticatorResponse, String, Bundle)
      */
-    public Bundle startUpdateCredentialsSession(final AccountAuthenticatorResponse response,
-            final Account account, final String authTokenType, final Bundle options)
-                    throws NetworkErrorException {
+    public Bundle startUpdateCredentialsSession(
+            final AccountAuthenticatorResponse response,
+            final Account account,
+            final String authTokenType,
+            final Bundle options) throws NetworkErrorException {
         new Thread(new Runnable() {
             @Override
             public void run() {
@@ -787,4 +839,102 @@
         }).start();
         return null;
     }
+
+    /**
+     * Finishes the session started by #startAddAccountSession or
+     * #startUpdateCredentials by installing the account to device with
+     * AccountManager, or updating the local credentials. File I/O may be
+     * performed in this call.
+     * <p>
+     * Note: when overriding this method, {@link #startAddAccountSession} and
+     * {@link #startUpdateCredentialsSession} should be overridden too.
+     * </p>
+     *
+     * @param response to send the result back to the AccountManager, will never
+     *            be null
+     * @param accountType the type of account to authenticate with, will never
+     *            be null
+     * @param sessionBundle a bundle of session data created by
+     *            {@link #startAddAccountSession} used for adding account to
+     *            device, or by {@link #startUpdateCredentialsSession} used for
+     *            updating local credentials.
+     * @return a Bundle result or null if the result is to be returned via the
+     *         response. The result will contain either:
+     *         <ul>
+     *         <li>{@link AccountManager#KEY_INTENT}, or
+     *         <li>{@link AccountManager#KEY_ACCOUNT_NAME} and
+     *         {@link AccountManager#KEY_ACCOUNT_TYPE} of the account that was
+     *         added or local credentials were updated, or
+     *         <li>{@link AccountManager#KEY_ERROR_CODE} and
+     *         {@link AccountManager#KEY_ERROR_MESSAGE} to indicate an error
+     *         </ul>
+     * @throws NetworkErrorException
+     * @see #startAddAccountSession and #startUpdateCredentialsSession
+     */
+    public Bundle finishSession(
+            final AccountAuthenticatorResponse response,
+            final String accountType,
+            final Bundle sessionBundle) throws NetworkErrorException {
+        if (TextUtils.isEmpty(accountType)) {
+            Log.e(TAG, "Account type cannot be empty.");
+            Bundle result = new Bundle();
+            result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_BAD_ARGUMENTS);
+            result.putString(AccountManager.KEY_ERROR_MESSAGE,
+                    "accountType cannot be empty.");
+            return result;
+        }
+
+        if (sessionBundle == null) {
+            Log.e(TAG, "Session bundle cannot be null.");
+            Bundle result = new Bundle();
+            result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_BAD_ARGUMENTS);
+            result.putString(AccountManager.KEY_ERROR_MESSAGE,
+                    "sessionBundle cannot be null.");
+            return result;
+        }
+
+        if (!sessionBundle.containsKey(KEY_AUTH_TOKEN_TYPE)) {
+            // We cannot handle Session bundle not created by default startAddAccountSession(...)
+            // nor startUpdateCredentialsSession(...) implementation. Return error.
+            Bundle result = new Bundle();
+            result.putInt(AccountManager.KEY_ERROR_CODE,
+                    AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
+            result.putString(AccountManager.KEY_ERROR_MESSAGE,
+                    "Authenticator must override finishSession if startAddAccountSession"
+                            + " or startUpdateCredentialsSession is overridden.");
+            response.onResult(result);
+            return result;
+        }
+        String authTokenType = sessionBundle.getString(KEY_AUTH_TOKEN_TYPE);
+        Bundle options = sessionBundle.getBundle(KEY_OPTIONS);
+        String[] requiredFeatures = sessionBundle.getStringArray(KEY_REQUIRED_FEATURES);
+        Account account = sessionBundle.getParcelable(KEY_ACCOUNT);
+        boolean containsKeyAccount = sessionBundle.containsKey(KEY_ACCOUNT);
+
+        // Actual options passed to add account or update credentials flow.
+        Bundle sessionOptions = new Bundle(sessionBundle);
+        // Remove redundant extras in session bundle before passing it to addAccount(...) or
+        // updateCredentials(...).
+        sessionOptions.remove(KEY_AUTH_TOKEN_TYPE);
+        sessionOptions.remove(KEY_REQUIRED_FEATURES);
+        sessionOptions.remove(KEY_OPTIONS);
+        sessionOptions.remove(KEY_ACCOUNT);
+
+        if (options != null) {
+            // options may contains old system info such as
+            // AccountManager.KEY_ANDROID_PACKAGE_NAME required by the add account flow or update
+            // credentials flow, we should replace with the new values of the current call added
+            // to sessionBundle by AccountManager or AccountManagerService.
+            options.putAll(sessionOptions);
+            sessionOptions = options;
+        }
+
+        // Session bundle created by startUpdateCredentialsSession default implementation should
+        // contain KEY_ACCOUNT.
+        if (containsKeyAccount) {
+            return updateCredentials(response, account, authTokenType, options);
+        }
+        // Otherwise, session bundle was created by startAddAccountSession default implementation.
+        return addAccount(response, accountType, authTokenType, requiredFeatures, sessionOptions);
+    }
 }
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 5557905..ada1ac2 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -2617,7 +2617,8 @@
      * <p>
      * <p>
      * <b>NOTE:</b> The account will not be installed to the device by calling
-     * this api alone.
+     * this api alone. #finishSession should be called after this to install the
+     * account on device.
      *
      * @param accountType The type of account to add; must not be null
      * @param authTokenType The type of auth token (see {@link #getAuthToken})
@@ -2665,6 +2666,7 @@
      *         problem creating a new account, usually because of network
      *         trouble
      *         </ul>
+     * @see #finishSession
      */
     public AccountManagerFuture<Bundle> startAddAccountSession(
             final String accountType,
@@ -2697,14 +2699,14 @@
 
     /**
      * Asks the user to enter a new password for an account but not updating the
-     * saved credentials for the account until finishSession is
-     * called.
+     * saved credentials for the account until {@link #finishSession} is called.
      * <p>
      * This method may be called from any thread, but the returned
      * {@link AccountManagerFuture} must not be used on the main thread.
      * <p>
      * <b>NOTE:</b> The saved credentials for the account alone will not be
-     * updated by calling this API alone .
+     * updated by calling this API alone. #finishSession should be called after
+     * this to update local credentials
      *
      * @param account The account to update credentials for
      * @param authTokenType The credentials entered must allow an auth token of
@@ -2723,15 +2725,14 @@
      *            the main thread
      * @return An {@link AccountManagerFuture} which resolves to a Bundle with
      *         these fields if an activity was supplied and user was
-     *         successfully re-authenticated to the account (TODO: default impl
-     *         only returns escorw?):
+     *         successfully re-authenticated to the account:
      *         <ul>
      *         <li>{@link #KEY_ACCOUNT_SESSION_BUNDLE} - encrypted Bundle for
      *         updating the local credentials on device later.
-     *         <li>{@link #KEY_PASSWORD} - optional, the password or password hash of the
-     *         account
-     *         <li>{@link #KEY_ACCOUNT_STATUS_TOKEN} - optional, token to check status of
-     *         the account
+     *         <li>{@link #KEY_PASSWORD} - optional, the password or password
+     *         hash of the account
+     *         <li>{@link #KEY_ACCOUNT_STATUS_TOKEN} - optional, token to check
+     *         status of the account
      *         </ul>
      *         If no activity was specified, the returned Bundle contains
      *         {@link #KEY_INTENT} with the {@link Intent} needed to launch the
@@ -2747,6 +2748,7 @@
      *         problem verifying the password, usually because of network
      *         trouble
      *         </ul>
+     * @see #finishSession
      */
     public AccountManagerFuture<Bundle> startUpdateCredentialsSession(
             final Account account,
@@ -2770,4 +2772,71 @@
             }
         }.start();
     }
+
+    /**
+     * Finishes the session started by {@link #startAddAccountSession} or
+     * {@link #startUpdateCredentialsSession}. This will either add the account
+     * to AccountManager or update the local credentials stored.
+     * <p>
+     * This method may be called from any thread, but the returned
+     * {@link AccountManagerFuture} must not be used on the main thread.
+     *
+     * @param sessionBundle a {@link Bundle} created by {@link #startAddAccountSession} or
+     *            {@link #startUpdateCredentialsSession}
+     * @param activity The {@link Activity} context to use for launching a new
+     *            authenticator-defined sub-Activity to prompt the user to
+     *            create an account or reauthenticate existing account; used
+     *            only to call startActivity(); if null, the prompt will not
+     *            be launched directly, but the necessary {@link Intent} will
+     *            be returned to the caller instead
+     * @param callback Callback to invoke when the request completes, null for
+     *            no callback
+     * @param handler {@link Handler} identifying the callback thread, null for
+     *            the main thread
+     * @return An {@link AccountManagerFuture} which resolves to a Bundle with
+     *         these fields if an activity was supplied and an account was added
+     *         to device or local credentials were updated::
+     *         <ul>
+     *         <li>{@link #KEY_ACCOUNT_NAME} - the name of the account created
+     *         <li>{@link #KEY_ACCOUNT_TYPE} - the type of the account
+     *         </ul>
+     *         If no activity was specified and additional information is needed
+     *         from user, the returned Bundle may contains only
+     *         {@link #KEY_INTENT} with the {@link Intent} needed to launch the
+     *         actual account creation process. If an error occurred,
+     *         {@link AccountManagerFuture#getResult()} throws:
+     *         <ul>
+     *         <li>{@link AuthenticatorException} if no authenticator was
+     *         registered for this account type or the authenticator failed to
+     *         respond
+     *         <li>{@link OperationCanceledException} if the operation was
+     *         canceled for any reason, including the user canceling the
+     *         creation process or adding accounts (of this type) has been
+     *         disabled by policy
+     *         <li>{@link IOException} if the authenticator experienced an I/O
+     *         problem creating a new account, usually because of network
+     *         trouble
+     *         </ul>
+     * @see #startAddAccountSession and #startUpdateCredentialsSession
+     */
+    public AccountManagerFuture<Bundle> finishSession(
+            final Bundle sessionBundle,
+            final Activity activity,
+            AccountManagerCallback<Bundle> callback,
+            Handler handler) {
+        if (sessionBundle == null) {
+            throw new IllegalArgumentException("sessionBundle is null");
+        }
+
+        /* Add information required by add account flow */
+        final Bundle appInfo = new Bundle();
+        appInfo.putString(KEY_ANDROID_PACKAGE_NAME, mContext.getPackageName());
+
+        return new AmsTask(activity, handler, callback) {
+            @Override
+            public void doWork() throws RemoteException {
+                mService.finishSession(mResponse, sessionBundle, activity != null, appInfo);
+            }
+        }.start();
+    }
 }
diff --git a/core/java/android/accounts/IAccountAuthenticator.aidl b/core/java/android/accounts/IAccountAuthenticator.aidl
index 921fb19..6bda800 100644
--- a/core/java/android/accounts/IAccountAuthenticator.aidl
+++ b/core/java/android/accounts/IAccountAuthenticator.aidl
@@ -96,4 +96,12 @@
      */
     void startUpdateCredentialsSession(in IAccountAuthenticatorResponse response, in Account account,
         String authTokenType, in Bundle options);
+
+    /**
+     * Finishes the session started by startAddAccountSession(...) or
+     * startUpdateCredentialsSession(...) by adding account to or updating local credentials
+     * in the IAccountManager.
+     */
+    void finishSession(in IAccountAuthenticatorResponse response, String accountType,
+        in Bundle sessionBundle);
 }
diff --git a/core/java/android/accounts/IAccountManager.aidl b/core/java/android/accounts/IAccountManager.aidl
index 8489e47..4af9f33 100644
--- a/core/java/android/accounts/IAccountManager.aidl
+++ b/core/java/android/accounts/IAccountManager.aidl
@@ -91,4 +91,8 @@
     /* Update credentials in two steps. */
     void startUpdateCredentialsSession(in IAccountManagerResponse response, in Account account,
         String authTokenType, boolean expectActivityLaunch, in Bundle options);
+
+    /* Finish session started by startAddAccountSession(...) or startUpdateCredentialsSession(...) */
+    void finishSession(in IAccountManagerResponse response, in Bundle sessionBundle,
+        boolean expectActivityLaunch, in Bundle appInfo);
 }
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 798deb1..b11a12f 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -548,6 +548,17 @@
         public static boolean canReceiveKeys(int stackId) {
             return stackId != PINNED_STACK_ID;
         }
+
+        /**
+         * Returns true if the stack can be visible above lockscreen.
+         */
+        public static boolean isAllowedOverLockscreen(int stackId) {
+            return stackId == HOME_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID;
+        }
+
+        public static boolean isAlwaysOnTop(int stackId) {
+            return stackId == PINNED_STACK_ID;
+        }
     }
 
     /**
@@ -2113,7 +2124,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 +2150,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 +2172,9 @@
             } else {
                 taskBounds = null;
             }
+            taskUserIds = source.createIntArray();
             displayId = source.readInt();
+            userId = source.readInt();
         }
 
         public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() {
@@ -2183,6 +2200,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 +2209,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 +3127,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/ActivityThread.java b/core/java/android/app/ActivityThread.java
index e867bb7..e64d13a 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4848,7 +4848,7 @@
         if (ii != null) {
             final ApplicationInfo instrApp = new ApplicationInfo();
             ii.copyTo(instrApp);
-
+            instrApp.initForUser(UserHandle.myUserId());
             final LoadedApk pi = getPackageInfo(instrApp, data.compatInfo,
                     appContext.getClassLoader(), false, true, false);
             final ContextImpl instrContext = ContextImpl.createAppContext(this, pi);
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/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index c504ce3..136b810 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -52,6 +52,8 @@
     int getTopicVisibilityOverride(String pkg, int uid, in Notification.Topic topic);
     void setTopicPriority(String pkg, int uid, in Notification.Topic topic, int priority);
     int getTopicPriority(String pkg, int uid, in Notification.Topic topic);
+    void setTopicImportance(String pkg, int uid, in Notification.Topic topic, int importance);
+    int getTopicImportance(String pkg, int uid, in Notification.Topic topic);
 
     // TODO: Remove this when callers have been migrated to the equivalent
     // INotificationListener method.
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/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 6fc998f..bb0a04f 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -398,17 +398,24 @@
      * this camera device.</p>
      * <p>For devices at the LEGACY level or above:</p>
      * <ul>
-     * <li>This list will always include (30, 30).</li>
-     * <li>Also, for constant-framerate recording, for each normal
+     * <li>
+     * <p>For constant-framerate recording, for each normal
+     * {@link android.media.CamcorderProfile CamcorderProfile}, that is, a
      * {@link android.media.CamcorderProfile CamcorderProfile} that has
      * {@link android.media.CamcorderProfile#quality quality} in
      * the range [{@link android.media.CamcorderProfile#QUALITY_LOW QUALITY_LOW},
      * {@link android.media.CamcorderProfile#QUALITY_2160P QUALITY_2160P}], if the profile is
      * supported by the device and has
      * {@link android.media.CamcorderProfile#videoFrameRate videoFrameRate} <code>x</code>, this list will
-     * always include (<code>x</code>,<code>x</code>).</li>
-     * <li>For preview streaming use case, this list will always include (<code>min</code>, <code>max</code>) where
-     * <code>min</code> &lt;= 15 and <code>max</code> &gt;= 30.</li>
+     * always include (<code>x</code>,<code>x</code>).</p>
+     * </li>
+     * <li>
+     * <p>Also, a camera device must either not support any
+     * {@link android.media.CamcorderProfile CamcorderProfile},
+     * or support at least one
+     * normal {@link android.media.CamcorderProfile CamcorderProfile} that has
+     * {@link android.media.CamcorderProfile#videoFrameRate videoFrameRate} <code>x</code> &gt;= 24.</p>
+     * </li>
      * </ul>
      * <p>For devices at the LIMITED level or above:</p>
      * <ul>
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/TrafficStats.java b/core/java/android/net/TrafficStats.java
index 2137c3a..e82485d 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -28,6 +28,7 @@
 
 import dalvik.system.SocketTagger;
 
+import java.net.DatagramSocket;
 import java.net.Socket;
 import java.net.SocketException;
 
@@ -226,6 +227,27 @@
     }
 
     /**
+     * Tag the given {@link DatagramSocket} with any statistics parameters
+     * active for the current thread. Subsequent calls always replace any
+     * existing parameters. When finished, call
+     * {@link #untagDatagramSocket(DatagramSocket)} to remove statistics
+     * parameters.
+     *
+     * @see #setThreadStatsTag(int)
+     * @see #setThreadStatsUid(int)
+     */
+    public static void tagDatagramSocket(DatagramSocket socket) throws SocketException {
+        SocketTagger.get().tag(socket);
+    }
+
+    /**
+     * Remove any statistics parameters from the given {@link DatagramSocket}.
+     */
+    public static void untagDatagramSocket(DatagramSocket socket) throws SocketException {
+        SocketTagger.get().untag(socket);
+    }
+
+    /**
      * Start profiling data usage for current UID. Only one profiling session
      * can be active at a time.
      *
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/provider/Settings.java b/core/java/android/provider/Settings.java
index c92382a..dad3c67 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4931,6 +4931,15 @@
                 "accessibility_autoclick_delay";
 
         /**
+         * Whether or not larger size icons are used for the pointer of mouse/trackpad for
+         * accessibility.
+         * (0 = false, 1 = true)
+         * @hide
+         */
+        public static final String ACCESSIBILITY_LARGE_POINTER_ICON =
+                "accessibility_large_pointer_icon";
+
+        /**
          * The timeout for considering a press to be a long press in milliseconds.
          * @hide
          */
@@ -7730,7 +7739,7 @@
         public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt";
 
         /**
-         * Whether the Volte/VT is enabled
+         * Whether the Volte is enabled
          * <p>
          * Type: int (0 for false, 1 for true)
          * @hide
@@ -7738,6 +7747,15 @@
         public static final String ENHANCED_4G_MODE_ENABLED = "volte_vt_enabled";
 
         /**
+         * Whether VT (Video Telephony over IMS) is enabled
+         * <p>
+         * Type: int (0 for false, 1 for true)
+         *
+         * @hide
+         */
+        public static final String VT_IMS_ENABLED = "vt_ims_enabled";
+
+        /**
          * Whether WFC is enabled
          * <p>
          * Type: int (0 for false, 1 for true)
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index d741f1a..a7545f2 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -823,9 +823,9 @@
         public static final int VISIBILITY_NO_OVERRIDE = -1000;
 
         /**
-         * Value signifying thatn the has not expressed an importance.
+         * Value signifying that the user has not expressed an importance.
          *
-         * This value is for persisting preferences, and should never ve associated with
+         * This value is for persisting preferences, and should never be associated with
          * an actual notification.
          */
         public static final int IMPORTANCE_UNSPECIFIED = -1000;
@@ -952,6 +952,28 @@
             mVisibilityOverride = visibilityOverride;
             mSuppressedVisualEffects = suppressedVisualEffects;
         }
+
+        /**
+         * {@hide}
+         */
+        public static String importanceToString(int importance) {
+            switch (importance) {
+                case IMPORTANCE_UNSPECIFIED:
+                    return "UNSPECIFIED";
+                case IMPORTANCE_NONE:
+                    return "NONE";
+                case IMPORTANCE_LOW:
+                    return "LOW";
+                case IMPORTANCE_DEFAULT:
+                    return "DEFAULT";
+                case IMPORTANCE_HIGH:
+                    return "HIGH";
+                case IMPORTANCE_MAX:
+                    return "MAX";
+                default:
+                    return "UNKNOWN(" + String.valueOf(importance) + ")";
+            }
+        }
     }
 
     /**
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/java/android/util/LocaleList.aidl b/core/java/android/util/LocaleList.aidl
new file mode 100644
index 0000000..f5de354
--- /dev/null
+++ b/core/java/android/util/LocaleList.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.util;
+
+parcelable LocaleList;
diff --git a/core/java/android/util/LocaleList.java b/core/java/android/util/LocaleList.java
index c1d23bb..b2ee045 100644
--- a/core/java/android/util/LocaleList.java
+++ b/core/java/android/util/LocaleList.java
@@ -19,6 +19,8 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.Size;
+import android.os.Parcel;
+import android.os.Parcelable;
 
 import com.android.internal.annotations.GuardedBy;
 
@@ -35,11 +37,12 @@
  * LocaleList is an immutable list of Locales, typically used to keep an
  * ordered user preferences for locales.
  */
-public final class LocaleList {
+public final class LocaleList implements Parcelable {
     private final Locale[] mList;
     // This is a comma-separated list of the locales in the LocaleList created at construction time,
     // basically the result of running each locale's toLanguageTag() method and concatenating them
     // with commas in between.
+    @NonNull
     private final String mStringRepresentation;
 
     private static final Locale[] sEmptyList = new Locale[0];
@@ -101,6 +104,16 @@
         return sb.toString();
     }
 
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int parcelableFlags) {
+        dest.writeString(mStringRepresentation);
+    }
+
     @NonNull
     public String toLanguageTags() {
         return mStringRepresentation;
@@ -163,10 +176,25 @@
         }
     }
 
+    public static final Parcelable.Creator<LocaleList> CREATOR
+            = new Parcelable.Creator<LocaleList>() {
+        @Override
+        public LocaleList createFromParcel(Parcel source) {
+            return LocaleList.forLanguageTags(source.readString());
+        }
+
+        @Override
+        public LocaleList[] newArray(int size) {
+            return new LocaleList[size];
+        }
+    };
+
+    @NonNull
     public static LocaleList getEmptyLocaleList() {
         return sEmptyLocaleList;
     }
 
+    @NonNull
     public static LocaleList forLanguageTags(@Nullable String list) {
         if (list == null || list.equals("")) {
             return getEmptyLocaleList();
diff --git a/core/java/android/view/PointerIcon.java b/core/java/android/view/PointerIcon.java
index b61706e..d2a7d4a 100644
--- a/core/java/android/view/PointerIcon.java
+++ b/core/java/android/view/PointerIcon.java
@@ -16,6 +16,8 @@
 
 package android.view;
 
+import android.os.UserHandle;
+import android.provider.Settings;
 import com.android.internal.util.XmlUtils;
 
 import android.annotation.XmlRes;
@@ -199,9 +201,14 @@
             styleIndex = getSystemIconStyleIndex(STYLE_DEFAULT);
         }
 
+        int accessibilityConfig = Settings.Secure.getIntForUser(
+                    context.getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
+                    0, UserHandle.USER_CURRENT);
+        int defStyle = (accessibilityConfig == 1) ?
+                com.android.internal.R.style.LargePointer : com.android.internal.R.style.Pointer;
         TypedArray a = context.obtainStyledAttributes(null,
                 com.android.internal.R.styleable.Pointer,
-                com.android.internal.R.attr.pointerStyle, 0);
+                0, defStyle);
         int resourceId = a.getResourceId(styleIndex, -1);
         a.recycle();
 
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index b0e68de..6dd87a0 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -3057,14 +3057,29 @@
     /**
      * @hide
      *
-     * Makes system ui transparent.
+     * Makes navigation bar transparent (but not the status bar).
      */
-    public static final int SYSTEM_UI_TRANSPARENT = 0x00008000;
+    public static final int NAVIGATION_BAR_TRANSPARENT = 0x00008000;
+
+    /**
+     * @hide
+     *
+     * Makes status bar transparent (but not the navigation bar).
+     */
+    public static final int STATUS_BAR_TRANSPARENT = 0x0000008;
+
+    /**
+     * @hide
+     *
+     * Makes both status bar and navigation bar transparent.
+     */
+    public static final int SYSTEM_UI_TRANSPARENT = NAVIGATION_BAR_TRANSPARENT
+            | STATUS_BAR_TRANSPARENT;
 
     /**
      * @hide
      */
-    public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x00003FFF;
+    public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x00003FF7;
 
     /**
      * These are the system UI flags that can be cleared by events outside
@@ -18557,15 +18572,15 @@
      * must be an array of two integers. After the method returns, the array
      * contains the x and y location in that order.</p>
      *
-     * @param location an array of two integers in which to hold the coordinates
+     * @param outLocation an array of two integers in which to hold the coordinates
      */
-    public void getLocationOnScreen(@Size(2) int[] location) {
-        getLocationInWindow(location);
+    public void getLocationOnScreen(@Size(2) int[] outLocation) {
+        getLocationInWindow(outLocation);
 
         final AttachInfo info = mAttachInfo;
         if (info != null) {
-            location[0] += info.mWindowLeft;
-            location[1] += info.mWindowTop;
+            outLocation[0] += info.mWindowLeft;
+            outLocation[1] += info.mWindowTop;
         }
     }
 
@@ -18574,13 +18589,17 @@
      * must be an array of two integers. After the method returns, the array
      * contains the x and y location in that order.</p>
      *
-     * @param outWindowSpace an array of two integers in which to hold the coordinates
+     * @param outLocation an array of two integers in which to hold the coordinates
      */
-    public void getLocationInWindow(@Size(2) int[] outWindowSpace) {
-        outWindowSpace[0] = 0;
-        outWindowSpace[1] = 0;
+    public void getLocationInWindow(@Size(2) int[] outLocation) {
+        if (outLocation == null || outLocation.length < 2) {
+            throw new IllegalArgumentException("outLocation must be an array of two integers");
+        }
 
-        transformFromViewToWindowSpace(outWindowSpace);
+        outLocation[0] = 0;
+        outLocation[1] = 0;
+
+        transformFromViewToWindowSpace(outLocation);
     }
 
     void transformFromViewToWindowSpace(@Size(2) int[] inOutLocation) {
diff --git a/core/java/android/view/inputmethod/EditorInfo.java b/core/java/android/view/inputmethod/EditorInfo.java
index 6130fd5..3ff9522 100644
--- a/core/java/android/view/inputmethod/EditorInfo.java
+++ b/core/java/android/view/inputmethod/EditorInfo.java
@@ -21,6 +21,7 @@
 import android.os.Parcelable;
 import android.text.InputType;
 import android.text.TextUtils;
+import android.util.LocaleList;
 import android.util.Printer;
 
 /**
@@ -340,6 +341,22 @@
     public Bundle extras;
 
     /**
+     * Additional context information that tells what languages are expected by the user.
+     *
+     * <p><strong>IME authors:</strong> Possible use cases for IME developers would be:</p>
+     * <ul>
+     *     <li>Automatically switching keyboard layout.</li>
+     *     <li>Changing language model for better typing experience.</li>
+     * </ul>
+     *
+     * <p><strong>Editor authors:</strong> Providing this context information can help IMEs to
+     * improve text input experience.  For example, chat applications can remember what language is
+     * used in the last conversation for each chat session, and put the last used language at the
+     * top of {@link #locales}.</p>
+     */
+    public LocaleList locales = LocaleList.getEmptyLocaleList();
+
+    /**
      * Ensure that the data in this EditorInfo is compatible with an application
      * that was developed against the given target API version.  This can
      * impact the following input types:
@@ -393,6 +410,7 @@
                 + " fieldId=" + fieldId
                 + " fieldName=" + fieldName);
         pw.println(prefix + "extras=" + extras);
+        pw.println(prefix + "locales=" + locales);
     }
 
     /**
@@ -416,6 +434,7 @@
         dest.writeInt(fieldId);
         dest.writeString(fieldName);
         dest.writeBundle(extras);
+        locales.writeToParcel(dest, flags);
     }
 
     /**
@@ -439,6 +458,7 @@
                     res.fieldId = source.readInt();
                     res.fieldName = source.readString();
                     res.extras = source.readBundle();
+                    res.locales = LocaleList.CREATOR.createFromParcel(source);
                     return res;
                 }
 
diff --git a/core/java/android/view/textservice/SpellCheckerSubtype.java b/core/java/android/view/textservice/SpellCheckerSubtype.java
index c753188..77fd002 100644
--- a/core/java/android/view/textservice/SpellCheckerSubtype.java
+++ b/core/java/android/view/textservice/SpellCheckerSubtype.java
@@ -16,6 +16,9 @@
 
 package android.view.textservice;
 
+import com.android.internal.inputmethod.InputMethodUtils;
+
+import android.annotation.Nullable;
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
 import android.os.Parcel;
@@ -147,22 +150,15 @@
     }
 
     /**
+     * @return The normalized {@link Locale} object of the subtype. The returned locale may or may
+     * not equal to "locale" string parameter passed to the constructor.
+     *
+     * <p>TODO: Consider to make this a public API.</p>
      * @hide
      */
-    public static Locale constructLocaleFromString(String localeStr) {
-        if (TextUtils.isEmpty(localeStr))
-            return null;
-        String[] localeParams = localeStr.split("_", 3);
-        // The length of localeStr is guaranteed to always return a 1 <= value <= 3
-        // because localeStr is not empty.
-        if (localeParams.length == 1) {
-            return new Locale(localeParams[0]);
-        } else if (localeParams.length == 2) {
-            return new Locale(localeParams[0], localeParams[1]);
-        } else if (localeParams.length == 3) {
-            return new Locale(localeParams[0], localeParams[1], localeParams[2]);
-        }
-        return null;
+    @Nullable
+    public Locale getLocaleObject() {
+        return InputMethodUtils.constructLocaleFromString(mSubtypeLocale);
     }
 
     /**
@@ -177,7 +173,7 @@
      */
     public CharSequence getDisplayName(
             Context context, String packageName, ApplicationInfo appInfo) {
-        final Locale locale = constructLocaleFromString(mSubtypeLocale);
+        final Locale locale = getLocaleObject();
         final String localeStr = locale != null ? locale.getDisplayName() : mSubtypeLocale;
         if (mSubtypeNameResId == 0) {
             return localeStr;
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index 88f02d1..45fc6c3 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -45,7 +45,9 @@
 import android.text.TextWatcher;
 import android.text.style.ImageSpan;
 import android.util.AttributeSet;
+import android.util.DisplayMetrics;
 import android.util.Log;
+import android.util.TypedValue;
 import android.view.CollapsibleActionView;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -1722,6 +1724,14 @@
             mThreshold = getThreshold();
         }
 
+        @Override
+        protected void onFinishInflate() {
+            super.onFinishInflate();
+            DisplayMetrics metrics = getResources().getDisplayMetrics();
+            setMinWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+                    getSearchViewTextMinWidthDp(), metrics));
+        }
+
         void setSearchView(SearchView searchView) {
             mSearchView = searchView;
         }
@@ -1818,5 +1828,21 @@
             return super.onKeyPreIme(keyCode, event);
         }
 
+        /**
+         * Get minimum width of the search view text entry area.
+         */
+        private int getSearchViewTextMinWidthDp() {
+            final Configuration configuration = getResources().getConfiguration();
+            final int width = configuration.screenWidthDp;
+            final int height = configuration.screenHeightDp;
+            final int orientation = configuration.orientation;
+            if (width >= 960 && height >= 720
+                    && orientation == Configuration.ORIENTATION_LANDSCAPE) {
+                return 256;
+            } else if (width >= 600 || (width >= 640 && height >= 480)) {
+                return 192;
+            };
+            return 160;
+        }
     }
 }
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d666939..56513a3 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6439,6 +6439,9 @@
                 outAttrs.initialCapsMode = ic.getCursorCapsMode(getInputType());
                 return ic;
             }
+            // LocaleList is designed to be immutable.  This is theoretically equivalent to copy
+            // the snapshot of the current text locales.
+            outAttrs.locales = getTextLocales();
         }
         return null;
     }
@@ -8782,7 +8785,7 @@
         final SpellCheckerSubtype subtype = textServicesManager.getCurrentSpellCheckerSubtype(true);
         final Locale locale;
         if (subtype != null) {
-            locale = SpellCheckerSubtype.constructLocaleFromString(subtype.getLocale());
+            locale = subtype.getLocaleObject();
         } else {
             locale = null;
         }
diff --git a/core/java/com/android/internal/policy/BackdropFrameRenderer.java b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
index b101733..75ca639 100644
--- a/core/java/com/android/internal/policy/BackdropFrameRenderer.java
+++ b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
@@ -17,6 +17,7 @@
 package com.android.internal.policy;
 
 import android.graphics.Rect;
+import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Looper;
 import android.view.Choreographer;
@@ -44,6 +45,7 @@
     // The render nodes for the multi threaded renderer.
     private ThreadedRenderer mRenderer;
     private RenderNode mFrameAndBackdropNode;
+    private RenderNode mSystemBarBackgroundNode;
 
     private final Rect mOldTargetRect = new Rect();
     private final Rect mNewTargetRect = new Rect();
@@ -62,13 +64,16 @@
 
     private Drawable mCaptionBackgroundDrawable;
     private Drawable mResizingBackgroundDrawable;
+    private ColorDrawable mStatusBarColor;
 
     public BackdropFrameRenderer(DecorView decorView, ThreadedRenderer renderer, Rect initialBounds,
-            Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawable) {
+            Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawable,
+            int statusBarColor) {
         setName("ResizeFrame");
 
         mRenderer = renderer;
-        onResourcesLoaded(decorView, resizingBackgroundDrawable, captionBackgroundDrawable);
+        onResourcesLoaded(decorView, resizingBackgroundDrawable, captionBackgroundDrawable,
+                statusBarColor);
 
         // Create a render node for the content and frame backdrop
         // which can be resized independently from the content.
@@ -87,10 +92,24 @@
     }
 
     void onResourcesLoaded(DecorView decorView, Drawable resizingBackgroundDrawable,
-            Drawable captionBackgroundDrawableDrawable) {
+            Drawable captionBackgroundDrawableDrawable, int statusBarColor) {
         mDecorView = decorView;
         mResizingBackgroundDrawable = resizingBackgroundDrawable;
         mCaptionBackgroundDrawable = captionBackgroundDrawableDrawable;
+        if (statusBarColor != 0) {
+            mStatusBarColor = new ColorDrawable(statusBarColor);
+            addSystemBarNodeIfNeeded();
+        } else {
+            mStatusBarColor = null;
+        }
+    }
+
+    private void addSystemBarNodeIfNeeded() {
+        if (mSystemBarBackgroundNode != null) {
+            return;
+        }
+        mSystemBarBackgroundNode = RenderNode.create("SystemBarBackgroundNode", null);
+        mRenderer.addRenderNode(mSystemBarBackgroundNode, false);
     }
 
     /**
@@ -132,6 +151,9 @@
                 // Remove the render node again
                 // (see comment above - better to do that only once).
                 mRenderer.removeRenderNode(mFrameAndBackdropNode);
+                if (mSystemBarBackgroundNode != null) {
+                    mRenderer.removeRenderNode(mSystemBarBackgroundNode);
+                }
 
                 mRenderer = null;
 
@@ -232,6 +254,8 @@
         // inaccessible. For that case we remember the previous metrics to avoid flashes.
         // Note that even when there is no visible caption, the caption child will exist.
         final int captionHeight = mDecorView.getCaptionHeight();
+        final int statusBarHeight = mDecorView.getStatusBarHeight();
+
         // The caption height will probably never dynamically change while we are resizing.
         // Once set to something other then 0 it should be kept that way.
         if (captionHeight != 0) {
@@ -256,7 +280,7 @@
         mFrameAndBackdropNode.setLeftTopRightBottom(left, top, left + width, top + height);
 
         // Draw the caption and content backdrops in to our render node.
-        final DisplayListCanvas canvas = mFrameAndBackdropNode.start(width, height);
+        DisplayListCanvas canvas = mFrameAndBackdropNode.start(width, height);
         mCaptionBackgroundDrawable.setBounds(0, 0, left + width, top + mLastCaptionHeight);
         mCaptionBackgroundDrawable.draw(canvas);
 
@@ -265,6 +289,15 @@
         mResizingBackgroundDrawable.draw(canvas);
         mFrameAndBackdropNode.end(canvas);
 
+        if (mSystemBarBackgroundNode != null && mStatusBarColor != null) {
+            canvas = mSystemBarBackgroundNode.start(width, height);
+            mSystemBarBackgroundNode.setLeftTopRightBottom(left, top, left + width, top + height);
+            mStatusBarColor.setBounds(0, 0, left + width, statusBarHeight);
+            mStatusBarColor.draw(canvas);
+            mSystemBarBackgroundNode.end(canvas);
+            mRenderer.drawRenderNode(mSystemBarBackgroundNode);
+        }
+
         // We need to render the node explicitly
         mRenderer.drawRenderNode(mFrameAndBackdropNode);
 
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index a95c401..9107b1f 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -151,6 +151,8 @@
     private final Interpolator mShowInterpolator;
     private final Interpolator mHideInterpolator;
     private final int mBarEnterExitDuration;
+    private final boolean mForceWindowDrawsStatusBarBackground;
+    private final int mSemiTransparentStatusBarColor;
 
     private final BackgroundFallback mBackgroundFallback = new BackgroundFallback();
 
@@ -197,6 +199,10 @@
 
         mBarEnterExitDuration = context.getResources().getInteger(
                 R.integer.dock_enter_exit_duration);
+        mForceWindowDrawsStatusBarBackground = context.getResources().getBoolean(
+                R.bool.config_forceWindowDrawsStatusBarBackground);
+        mSemiTransparentStatusBarColor = context.getResources().getColor(
+                R.color.system_bar_background_semi_transparent, null /* theme */);
 
         setWindow(window);
     }
@@ -884,14 +890,15 @@
             int navBarSize = navBarToRightEdge ? mLastRightInset : mLastBottomInset;
             updateColorViewInt(mNavigationColorViewState, sysUiVisibility,
                     mWindow.mNavigationBarColor, navBarSize, navBarToRightEdge,
-                    0 /* rightInset */, animate && !disallowAnimate);
+                    0 /* rightInset */, animate && !disallowAnimate, false /* force */);
 
             boolean statusBarNeedsRightInset = navBarToRightEdge
                     && mNavigationColorViewState.present;
             int statusBarRightInset = statusBarNeedsRightInset ? mLastRightInset : 0;
-            updateColorViewInt(mStatusColorViewState, sysUiVisibility, mWindow.mStatusBarColor,
-                    mLastTopInset, false /* matchVertical */, statusBarRightInset,
-                    animate && !disallowAnimate);
+            updateColorViewInt(mStatusColorViewState, sysUiVisibility,
+                    calculateStatusBarColor(), mLastTopInset,
+                    false /* matchVertical */, statusBarRightInset, animate && !disallowAnimate,
+                    mForceWindowDrawsStatusBarBackground);
         }
 
         // When we expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, we still need
@@ -935,6 +942,21 @@
         return insets;
     }
 
+    private int calculateStatusBarColor() {
+        int flags = mWindow.getAttributes().flags;
+        return (flags & FLAG_TRANSLUCENT_STATUS) != 0 ? mSemiTransparentStatusBarColor
+                : (flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0 ? mWindow.mStatusBarColor
+                : Color.BLACK;
+    }
+
+    private int getCurrentColor(ColorViewState state) {
+        if (state.visible) {
+            return state.color;
+        } else {
+            return 0;
+        }
+    }
+
     /**
      * Update a color view
      *
@@ -948,13 +970,15 @@
      * @param animate if true, the change will be animated.
      */
     private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color,
-            int size, boolean verticalBar, int rightMargin, boolean animate) {
+            int size, boolean verticalBar, int rightMargin, boolean animate, boolean force) {
         state.present = size > 0 && (sysUiVis & state.systemUiHideFlag) == 0
                 && (mWindow.getAttributes().flags & state.hideWindowFlag) == 0
-                && (mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0;
+                && ((mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
+                        || force);
         boolean show = state.present
                 && (color & Color.BLACK) != 0
-                && (mWindow.getAttributes().flags & state.translucentFlag) == 0;
+                && ((mWindow.getAttributes().flags & state.translucentFlag) == 0  || force);
+        boolean showView = show && !isResizing();
 
         boolean visibilityChanged = false;
         View view = state.view;
@@ -964,7 +988,7 @@
         int resolvedGravity = verticalBar ? state.horizontalGravity : state.verticalGravity;
 
         if (view == null) {
-            if (show) {
+            if (showView) {
                 state.view = view = new View(mContext);
                 view.setBackgroundColor(color);
                 view.setTransitionName(state.transitionName);
@@ -980,7 +1004,7 @@
                 updateColorViewTranslations();
             }
         } else {
-            int vis = show ? VISIBLE : INVISIBLE;
+            int vis = showView ? VISIBLE : INVISIBLE;
             visibilityChanged = state.targetVisibility != vis;
             state.targetVisibility = vis;
             LayoutParams lp = (LayoutParams) view.getLayoutParams();
@@ -992,14 +1016,14 @@
                 lp.rightMargin = rightMargin;
                 view.setLayoutParams(lp);
             }
-            if (show) {
+            if (showView) {
                 view.setBackgroundColor(color);
             }
         }
         if (visibilityChanged) {
             view.animate().cancel();
-            if (animate) {
-                if (show) {
+            if (animate && !isResizing()) {
+                if (showView) {
                     if (view.getVisibility() != VISIBLE) {
                         view.setVisibility(VISIBLE);
                         view.setAlpha(0.0f);
@@ -1019,9 +1043,11 @@
                 }
             } else {
                 view.setAlpha(1.0f);
-                view.setVisibility(show ? VISIBLE : INVISIBLE);
+                view.setVisibility(showView ? VISIBLE : INVISIBLE);
             }
         }
+        state.visible = show;
+        state.color = color;
     }
 
     private void updateColorViewTranslations() {
@@ -1553,7 +1579,8 @@
 
         if (mBackdropFrameRenderer != null) {
             mBackdropFrameRenderer.onResourcesLoaded(
-                    this, mResizingBackgroundDrawable, mCaptionBackgroundDrawable);
+                    this, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
+                    getCurrentColor(mStatusColorViewState));
         }
 
         mDecorCaptionView = createDecorCaptionView(inflater);
@@ -1668,9 +1695,15 @@
         if (mDecorCaptionView != null) {
             mDecorCaptionView.removeContentView();
         } else {
-            // This window doesn't have caption, so we need to just remove the
-            // children of the decor view.
-            removeAllViews();
+            // This window doesn't have caption, so we need to remove everything except our views
+            // we might have added.
+            for (int i = getChildCount() - 1; i >= 0; i--) {
+                View v = getChildAt(i);
+                if (v != mStatusColorViewState.view && v != mNavigationColorViewState.view
+                        && v != mStatusGuard && v != mNavigationGuard) {
+                    removeViewAt(i);
+                }
+            }
         }
     }
 
@@ -1694,18 +1727,22 @@
         final ThreadedRenderer renderer = (ThreadedRenderer) getHardwareRenderer();
         if (renderer != null) {
             mBackdropFrameRenderer = new BackdropFrameRenderer(this, renderer,
-                    initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable);
+                    initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
+                    getCurrentColor(mStatusColorViewState));
 
             // Get rid of the shadow while we are resizing. Shadow drawing takes considerable time.
             // If we want to get the shadow shown while resizing, we would need to elevate a new
             // element which owns the caption and has the elevation.
             updateElevation();
+
+            updateColorViews(null /* insets */, false);
         }
     }
 
     @Override
     public void onWindowDragResizeEnd() {
         releaseThreadedRenderer();
+        updateColorViews(null /* insets */, false);
     }
 
     @Override
@@ -1738,6 +1775,10 @@
         }
     }
 
+    private boolean isResizing() {
+        return mBackdropFrameRenderer != null;
+    }
+
     /**
      * The elevation gets set for the first time and the framework needs to be informed that
      * the surface layer gets created with the shadow size in mind.
@@ -1753,8 +1794,7 @@
         final boolean wasAdjustedForStack = mElevationAdjustedForStack;
         // Do not use a shadow when we are in resizing mode (mBackdropFrameRenderer not null)
         // since the shadow is bound to the content size and not the target size.
-        if (ActivityManager.StackId.hasWindowShadow(mStackId)
-                && mBackdropFrameRenderer == null) {
+        if (ActivityManager.StackId.hasWindowShadow(mStackId) && !isResizing()) {
             elevation = hasWindowFocus() ?
                     DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP;
             // TODO(skuhne): Remove this if clause once b/22668382 got fixed.
@@ -1784,6 +1824,10 @@
         return isShowingCaption() ? mDecorCaptionView.getCaptionHeight() : 0;
     }
 
+    int getStatusBarHeight() {
+        return mStatusColorViewState.view != null ? mStatusColorViewState.view.getHeight() : 0;
+    }
+
     /**
      * Converts a DIP measure into physical pixels.
      * @param dip The dip value.
@@ -1798,6 +1842,8 @@
         View view = null;
         int targetVisibility = View.INVISIBLE;
         boolean present = false;
+        boolean visible;
+        int color;
 
         final int id;
         final int systemUiHideFlag;
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 04f1dc5..57d2244 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -2406,6 +2406,13 @@
             setNeedsMenuKey(WindowManager.LayoutParams.NEEDS_MENU_SET_FALSE);
         }
 
+        if (!mForcedStatusBarColor) {
+            mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
+        }
+        if (!mForcedNavigationBarColor) {
+            mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
+        }
+
         // Non-floating windows on high end devices must put up decor beneath the system bars and
         // therefore must know about visibility changes of those.
         if (!mIsFloating && ActivityManager.isHighEndGfx()) {
@@ -2416,12 +2423,6 @@
                         FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS & ~getForcedWindowFlags());
             }
         }
-        if (!mForcedStatusBarColor) {
-            mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
-        }
-        if (!mForcedNavigationBarColor) {
-            mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
-        }
         if (a.getBoolean(R.styleable.Window_windowLightStatusBar, false)) {
             decor.setSystemUiVisibility(
                     decor.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
diff --git a/core/java/com/android/internal/view/ActionBarPolicy.java b/core/java/com/android/internal/view/ActionBarPolicy.java
index 007ab29..755faf3 100644
--- a/core/java/com/android/internal/view/ActionBarPolicy.java
+++ b/core/java/com/android/internal/view/ActionBarPolicy.java
@@ -78,7 +78,11 @@
 
         // The embedded tabs policy changed in Jellybean; give older apps the old policy
         // so they get what they expect.
-        return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs_pre_jb);
+        final Configuration configuration = mContext.getResources().getConfiguration();
+        final int width = configuration.screenWidthDp;
+        final int height = configuration.screenHeightDp;
+        return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE ||
+                width >= 480 || (width >= 640 && height >= 480);
     }
 
     public int getTabContainerHeight() {
diff --git a/core/java/com/android/internal/view/menu/ActionMenuItemView.java b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
index ce5bc90..bd97e5d 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
@@ -72,8 +72,7 @@
     public ActionMenuItemView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
         super(context, attrs, defStyleAttr, defStyleRes);
         final Resources res = context.getResources();
-        mAllowTextWithIcon = res.getBoolean(
-                com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon);
+        mAllowTextWithIcon = shouldAllowTextWithIcon();
         final TypedArray a = context.obtainStyledAttributes(attrs,
                 com.android.internal.R.styleable.ActionMenuItemView, defStyleAttr, defStyleRes);
         mMinWidth = a.getDimensionPixelSize(
@@ -93,11 +92,22 @@
     public void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
 
-        mAllowTextWithIcon = getContext().getResources().getBoolean(
-                com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon);
+        mAllowTextWithIcon = shouldAllowTextWithIcon();
         updateTextButtonVisibility();
     }
 
+    /**
+     * Whether action menu items should obey the "withText" showAsAction flag. This may be set to
+     * false for situations where space is extremely limited. -->
+     */
+    private boolean shouldAllowTextWithIcon() {
+        final Configuration configuration = getContext().getResources().getConfiguration();
+        final int width = configuration.screenWidthDp;
+        final int height = configuration.screenHeightDp;
+        return  width >= 480 || (width >= 640 && height >= 480)
+                || configuration.orientation == Configuration.ORIENTATION_LANDSCAPE;
+    }
+
     @Override
     public void setPadding(int l, int t, int r, int b) {
         mSavedPaddingLeft = l;
diff --git a/core/res/res/drawable-mdpi/pointer_alias_large.png b/core/res/res/drawable-mdpi/pointer_alias_large.png
new file mode 100644
index 0000000..283bf7f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_alias_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_all_scroll_large.png b/core/res/res/drawable-mdpi/pointer_all_scroll_large.png
new file mode 100644
index 0000000..c29db87
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_all_scroll_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_arrow_large.png b/core/res/res/drawable-mdpi/pointer_arrow_large.png
new file mode 100644
index 0000000..9f59c4c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_arrow_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_cell_large.png b/core/res/res/drawable-mdpi/pointer_cell_large.png
new file mode 100644
index 0000000..3dec5e5
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_cell_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_context_menu_large.png b/core/res/res/drawable-mdpi/pointer_context_menu_large.png
new file mode 100644
index 0000000..7c9e250
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_context_menu_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_copy_large.png b/core/res/res/drawable-mdpi/pointer_copy_large.png
new file mode 100644
index 0000000..18f4696
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_copy_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_crosshair_large.png b/core/res/res/drawable-mdpi/pointer_crosshair_large.png
new file mode 100644
index 0000000..ea1f5fc
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_crosshair_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_grab_large.png b/core/res/res/drawable-mdpi/pointer_grab_large.png
new file mode 100644
index 0000000..2e32766
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_grab_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_grabbing_large.png b/core/res/res/drawable-mdpi/pointer_grabbing_large.png
new file mode 100644
index 0000000..3c54751
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_grabbing_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_hand_large.png b/core/res/res/drawable-mdpi/pointer_hand_large.png
new file mode 100644
index 0000000..785047f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_hand_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_help_large.png b/core/res/res/drawable-mdpi/pointer_help_large.png
new file mode 100644
index 0000000..6552f9b
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_help_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_horizontal_double_arrow_large.png b/core/res/res/drawable-mdpi/pointer_horizontal_double_arrow_large.png
new file mode 100644
index 0000000..7086106
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_horizontal_double_arrow_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_nodrop_large.png b/core/res/res/drawable-mdpi/pointer_nodrop_large.png
new file mode 100644
index 0000000..da981df
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_nodrop_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_text_large.png b/core/res/res/drawable-mdpi/pointer_text_large.png
new file mode 100644
index 0000000..2fba190
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_text_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_top_left_diagonal_double_arrow_large.png b/core/res/res/drawable-mdpi/pointer_top_left_diagonal_double_arrow_large.png
new file mode 100644
index 0000000..eecaa89
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_top_left_diagonal_double_arrow_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_top_right_diagonal_double_arrow_large.png b/core/res/res/drawable-mdpi/pointer_top_right_diagonal_double_arrow_large.png
new file mode 100644
index 0000000..9d47ecf
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_top_right_diagonal_double_arrow_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_vertical_double_arrow_large.png b/core/res/res/drawable-mdpi/pointer_vertical_double_arrow_large.png
new file mode 100644
index 0000000..fd777b1
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_vertical_double_arrow_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_vertical_text_large.png b/core/res/res/drawable-mdpi/pointer_vertical_text_large.png
new file mode 100644
index 0000000..1cbe49a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_vertical_text_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_zoom_in_large.png b/core/res/res/drawable-mdpi/pointer_zoom_in_large.png
new file mode 100644
index 0000000..923ad79
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_zoom_in_large.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/pointer_zoom_out_large.png b/core/res/res/drawable-mdpi/pointer_zoom_out_large.png
new file mode 100644
index 0000000..aa47eb9
--- /dev/null
+++ b/core/res/res/drawable-mdpi/pointer_zoom_out_large.png
Binary files differ
diff --git a/core/res/res/drawable/pointer_alias_large_icon.xml b/core/res/res/drawable/pointer_alias_large_icon.xml
new file mode 100644
index 0000000..149f58c
--- /dev/null
+++ b/core/res/res/drawable/pointer_alias_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_alias_large"
+    android:hotSpotX="19dp"
+    android:hotSpotY="11dp" />
diff --git a/core/res/res/drawable/pointer_all_scroll_large_icon.xml b/core/res/res/drawable/pointer_all_scroll_large_icon.xml
new file mode 100644
index 0000000..c580f76
--- /dev/null
+++ b/core/res/res/drawable/pointer_all_scroll_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_all_scroll_large"
+    android:hotSpotX="32dp"
+    android:hotSpotY="31dp" />
diff --git a/core/res/res/drawable/pointer_arrow_large_icon.xml b/core/res/res/drawable/pointer_arrow_large_icon.xml
new file mode 100644
index 0000000..22c7bfe
--- /dev/null
+++ b/core/res/res/drawable/pointer_arrow_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_arrow_large"
+    android:hotSpotX="10dp"
+    android:hotSpotY="10dp" />
diff --git a/core/res/res/drawable/pointer_cell_large_icon.xml b/core/res/res/drawable/pointer_cell_large_icon.xml
new file mode 100644
index 0000000..f2530b7
--- /dev/null
+++ b/core/res/res/drawable/pointer_cell_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_cell_large"
+    android:hotSpotX="30dp"
+    android:hotSpotY="30dp" />
diff --git a/core/res/res/drawable/pointer_context_menu_large_icon.xml b/core/res/res/drawable/pointer_context_menu_large_icon.xml
new file mode 100644
index 0000000..c57e615
--- /dev/null
+++ b/core/res/res/drawable/pointer_context_menu_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_context_menu_large"
+    android:hotSpotX="11dp"
+    android:hotSpotY="11dp" />
diff --git a/core/res/res/drawable/pointer_copy_large_icon.xml b/core/res/res/drawable/pointer_copy_large_icon.xml
new file mode 100644
index 0000000..4ee3f18
--- /dev/null
+++ b/core/res/res/drawable/pointer_copy_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_copy_large"
+    android:hotSpotX="10dp"
+    android:hotSpotY="10dp" />
diff --git a/core/res/res/drawable/pointer_crosshair_large_icon.xml b/core/res/res/drawable/pointer_crosshair_large_icon.xml
new file mode 100644
index 0000000..6a71b7b
--- /dev/null
+++ b/core/res/res/drawable/pointer_crosshair_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_crosshair_large"
+    android:hotSpotX="31dp"
+    android:hotSpotY="30dp" />
diff --git a/core/res/res/drawable/pointer_grab_large_icon.xml b/core/res/res/drawable/pointer_grab_large_icon.xml
new file mode 100644
index 0000000..f2df1cb
--- /dev/null
+++ b/core/res/res/drawable/pointer_grab_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_grab_large"
+    android:hotSpotX="21dp"
+    android:hotSpotY="11dp" />
diff --git a/core/res/res/drawable/pointer_grabbing_large_icon.xml b/core/res/res/drawable/pointer_grabbing_large_icon.xml
new file mode 100644
index 0000000..e4042bf
--- /dev/null
+++ b/core/res/res/drawable/pointer_grabbing_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_grabbing_large"
+    android:hotSpotX="20dp"
+    android:hotSpotY="12dp" />
diff --git a/core/res/res/drawable/pointer_hand_large_icon.xml b/core/res/res/drawable/pointer_hand_large_icon.xml
new file mode 100644
index 0000000..e34422a
--- /dev/null
+++ b/core/res/res/drawable/pointer_hand_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_hand_large"
+    android:hotSpotX="25dp"
+    android:hotSpotY="7dp" />
diff --git a/core/res/res/drawable/pointer_help_large_icon.xml b/core/res/res/drawable/pointer_help_large_icon.xml
new file mode 100644
index 0000000..4c60a55
--- /dev/null
+++ b/core/res/res/drawable/pointer_help_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_help_large"
+    android:hotSpotX="10dp"
+    android:hotSpotY="11dp" />
diff --git a/core/res/res/drawable/pointer_horizontal_double_arrow_large_icon.xml b/core/res/res/drawable/pointer_horizontal_double_arrow_large_icon.xml
new file mode 100644
index 0000000..a2039e6
--- /dev/null
+++ b/core/res/res/drawable/pointer_horizontal_double_arrow_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_horizontal_double_arrow_large"
+    android:hotSpotX="35dp"
+    android:hotSpotY="29dp" />
diff --git a/core/res/res/drawable/pointer_nodrop_large_icon.xml b/core/res/res/drawable/pointer_nodrop_large_icon.xml
new file mode 100644
index 0000000..cde2e41
--- /dev/null
+++ b/core/res/res/drawable/pointer_nodrop_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_nodrop_large"
+    android:hotSpotX="10dp"
+    android:hotSpotY="10dp" />
diff --git a/core/res/res/drawable/pointer_text_large_icon.xml b/core/res/res/drawable/pointer_text_large_icon.xml
new file mode 100644
index 0000000..24d35b0
--- /dev/null
+++ b/core/res/res/drawable/pointer_text_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_text_large"
+    android:hotSpotX="30dp"
+    android:hotSpotY="32dp" />
diff --git a/core/res/res/drawable/pointer_top_left_diagonal_double_arrow_large_icon.xml b/core/res/res/drawable/pointer_top_left_diagonal_double_arrow_large_icon.xml
new file mode 100644
index 0000000..270ccc9
--- /dev/null
+++ b/core/res/res/drawable/pointer_top_left_diagonal_double_arrow_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_top_left_diagonal_double_arrow_large"
+    android:hotSpotX="32dp"
+    android:hotSpotY="30dp" />
diff --git a/core/res/res/drawable/pointer_top_right_diagonal_double_arrow_large_icon.xml b/core/res/res/drawable/pointer_top_right_diagonal_double_arrow_large_icon.xml
new file mode 100644
index 0000000..e350a43
--- /dev/null
+++ b/core/res/res/drawable/pointer_top_right_diagonal_double_arrow_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_top_right_diagonal_double_arrow_large"
+    android:hotSpotX="32dp"
+    android:hotSpotY="31dp" />
diff --git a/core/res/res/drawable/pointer_vertical_double_arrow_large_icon.xml b/core/res/res/drawable/pointer_vertical_double_arrow_large_icon.xml
new file mode 100644
index 0000000..65728ad
--- /dev/null
+++ b/core/res/res/drawable/pointer_vertical_double_arrow_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_vertical_double_arrow_large"
+    android:hotSpotX="29dp"
+    android:hotSpotY="32dp" />
diff --git a/core/res/res/drawable/pointer_vertical_text_large_icon.xml b/core/res/res/drawable/pointer_vertical_text_large_icon.xml
new file mode 100644
index 0000000..48211cb
--- /dev/null
+++ b/core/res/res/drawable/pointer_vertical_text_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_vertical_text_large"
+    android:hotSpotX="32dp"
+    android:hotSpotY="30dp" />
diff --git a/core/res/res/drawable/pointer_zoom_in_large_icon.xml b/core/res/res/drawable/pointer_zoom_in_large_icon.xml
new file mode 100644
index 0000000..3eb89f56
--- /dev/null
+++ b/core/res/res/drawable/pointer_zoom_in_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_zoom_in_large"
+    android:hotSpotX="25dp"
+    android:hotSpotY="26dp" />
diff --git a/core/res/res/drawable/pointer_zoom_out_large_icon.xml b/core/res/res/drawable/pointer_zoom_out_large_icon.xml
new file mode 100644
index 0000000..df6412e
--- /dev/null
+++ b/core/res/res/drawable/pointer_zoom_out_large_icon.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+    android:bitmap="@drawable/pointer_zoom_out_large"
+    android:hotSpotX="26dp"
+    android:hotSpotY="26dp" />
diff --git a/core/res/res/layout/search_view.xml b/core/res/res/layout/search_view.xml
index b5b5b27..718e4a2 100644
--- a/core/res/res/layout/search_view.xml
+++ b/core/res/res/layout/search_view.xml
@@ -81,7 +81,6 @@
                 android:layout_height="36dip"
                 android:layout_width="0dp"
                 android:layout_weight="1"
-                android:minWidth="@dimen/search_view_text_min_width"
                 android:layout_gravity="bottom"
                 android:paddingStart="@dimen/dropdownitem_text_padding_left"
                 android:paddingEnd="@dimen/dropdownitem_text_padding_right"
@@ -113,7 +112,7 @@
             android:orientation="horizontal"
             android:layout_width="wrap_content"
             android:layout_height="match_parent">
-    
+
             <ImageView
                 android:id="@+id/search_go_btn"
                 android:layout_width="wrap_content"
diff --git a/core/res/res/values-large/dimens.xml b/core/res/res/values-large/dimens.xml
index 8cd614d..69a1aa1 100644
--- a/core/res/res/values-large/dimens.xml
+++ b/core/res/res/values-large/dimens.xml
@@ -24,9 +24,6 @@
     <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 -->
     <dimen name="password_keyboard_height">48.0mm</dimen>
 
-    <!-- Minimum width of the search view text entry area. -->
-    <dimen name="search_view_text_min_width">192dip</dimen>
-
     <item type="dimen" name="dialog_min_width_major">55%</item>
     <item type="dimen" name="dialog_min_width_minor">80%</item>
 
diff --git a/core/res/res/values-w480dp/bools.xml b/core/res/res/values-w480dp/bools.xml
index 3a463a6..c7df562 100644
--- a/core/res/res/values-w480dp/bools.xml
+++ b/core/res/res/values-w480dp/bools.xml
@@ -17,6 +17,5 @@
 */
 -->
 <resources>
-    <bool name="action_bar_embed_tabs_pre_jb">true</bool>
     <bool name="split_action_bar_is_narrow">false</bool>
 </resources>
diff --git a/core/res/res/values-w480dp/config.xml b/core/res/res/values-w480dp/config.xml
deleted file mode 100644
index 269a9b4..0000000
--- a/core/res/res/values-w480dp/config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2011, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-<resources>
-    <bool name="config_allowActionMenuItemTextWithIcon">true</bool>
-</resources>
diff --git a/core/res/res/values-xlarge-land/dimens.xml b/core/res/res/values-xlarge-land/dimens.xml
index 0b43a42..3812178 100644
--- a/core/res/res/values-xlarge-land/dimens.xml
+++ b/core/res/res/values-xlarge-land/dimens.xml
@@ -20,6 +20,4 @@
     <!-- Default height of a key in the password keyboard for alpha -->
     <dimen name="password_keyboard_key_height_alpha">100dip</dimen>
     <dimen name="password_keyboard_key_height_numeric">75dip</dimen>
-    <!-- Minimum width of the search view text entry area. -->
-    <dimen name="search_view_text_min_width">256dip</dimen>
 </resources>
diff --git a/core/res/res/values-xlarge/dimens.xml b/core/res/res/values-xlarge/dimens.xml
index 29cea26..b13e74a 100644
--- a/core/res/res/values-xlarge/dimens.xml
+++ b/core/res/res/values-xlarge/dimens.xml
@@ -25,9 +25,6 @@
     <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 -->
     <dimen name="password_keyboard_height">48.0mm</dimen>
 
-    <!-- Minimum width of the search view text entry area. -->
-    <dimen name="search_view_text_min_width">192dip</dimen>
-
     <item type="dimen" name="dialog_min_width_major">45%</item>
     <item type="dimen" name="dialog_min_width_minor">72%</item>
 </resources>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index f9f8162..34a66d0 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -1026,9 +1026,6 @@
         <!-- ============== -->
         <eat-comment />
 
-        <!-- Reference to the Pointer style -->
-        <attr name="pointerStyle" format="reference" />
-
         <!-- The drawable for accessibility focused views. -->
         <attr name="accessibilityFocusedDrawable" format="reference" />
 
diff --git a/core/res/res/values/bools.xml b/core/res/res/values/bools.xml
index 457131a..5c50e73 100644
--- a/core/res/res/values/bools.xml
+++ b/core/res/res/values/bools.xml
@@ -19,7 +19,6 @@
     <bool name="kg_center_small_widgets_vertically">false</bool>
     <bool name="kg_top_align_page_shrink_on_bouncer_visible">true</bool>
     <bool name="action_bar_embed_tabs">true</bool>
-    <bool name="action_bar_embed_tabs_pre_jb">false</bool>
     <bool name="split_action_bar_is_narrow">true</bool>
     <bool name="preferences_prefer_dual_pane">false</bool>
     <bool name="show_ongoing_ime_switcher">true</bool>
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index dad68ba..af8ff2e 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -173,4 +173,7 @@
     <color name="Red_800">#ffb93221</color>
 
     <color name="chooser_service_row_background_color">#fff5f5f5</color>
+
+    <!-- Status bar color for semi transparent mode. -->
+    <color name="system_bar_background_semi_transparent">#66000000</color> <!-- 40% black -->
 </resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index caa20dc..decb1ef 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1537,11 +1537,6 @@
          it should be disabled in that locale's resources. -->
     <bool name="config_actionMenuItemAllCaps">true</bool>
 
-    <!-- Whether action menu items should obey the "withText" showAsAction
-         flag. This may be set to false for situations where space is
-         extremely limited. -->
-    <bool name="config_allowActionMenuItemTextWithIcon">false</bool>
-
     <!-- Remote server that can provide NTP responses. -->
     <string translatable="false" name="config_ntpServer">2.android.pool.ntp.org</string>
     <!-- Normal polling frequency in milliseconds -->
@@ -1965,6 +1960,7 @@
         <item>com.android.server.notification.TopicPriorityExtractor</item>
         <item>com.android.server.notification.NotificationIntrusivenessExtractor</item>
         <item>com.android.server.notification.TopicVisibilityExtractor</item>
+        <item>com.android.server.notification.TopicImportanceExtractor</item>
     </string-array>
 
     <!-- Flag indicating that this device does not rotate and will always remain in its default
@@ -2400,4 +2396,9 @@
          The duplication is necessary, because this information is used before the features are
          available to the system.-->
     <bool name="config_freeformWindowManagement">false</bool>
+
+    <!-- If set, this will force all windows to draw the status bar background, including the apps
+         that have not requested doing so (via the WindowManager.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
+         flag). -->
+    <bool name="config_forceWindowDrawsStatusBarBackground">true</bool>
 </resources>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 7b4becc..b167711 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -162,9 +162,6 @@
     <!-- The minimum height of the content if there is a picture present with big picture -->
     <dimen name="notification_big_picture_content_min_height_with_picture">41dp</dimen>
 
-    <!-- Minimum width of the search view text entry area. -->
-    <dimen name="search_view_text_min_width">160dip</dimen>
-
     <!-- Preferred width of the search view. -->
     <dimen name="search_view_preferred_width">320dip</dimen>
 
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index d6dd842..e5415df 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3954,6 +3954,22 @@
     <!-- [CHAR_LIMIT=NONE] Battery saver: Feature description -->
     <string name="battery_saver_description">To help improve battery life, battery saver reduces your device’s performance and limits vibration, location services, and most background data. Email, messaging, and other apps that rely on syncing may not update unless you open them.\n\nBattery saver turns off automatically when your device is charging.</string>
 
+
+    <!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
+    <string name="notification_importance_blocked">Blocked: Never show these notifications</string>
+
+    <!-- [CHAR LIMIT=100] Notification Importance slider: low importance level description -->
+    <string name="notification_importance_low">Low: Silently show at the bottom of the notification list</string>
+
+    <!-- [CHAR LIMIT=100] Notification Importance slider: normal importance level description -->
+    <string name="notification_importance_default">Normal: Silently show these notifications</string>
+
+    <!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
+    <string name="notification_importance_high">High: Show at the top of the notifications list and make sound</string>
+
+    <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
+    <string name="notification_importance_max">Urgent: Peek onto the screen and make sound</string>
+
     <!-- Zen mode condition - summary: time duration in minutes. [CHAR LIMIT=NONE] -->
     <plurals name="zen_mode_duration_minutes_summary">
         <item quantity="one">For one minute (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index e6f279d..9a4016b 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1368,6 +1368,42 @@
         <item name="pointerIconGrabbing">@drawable/pointer_grabbing_icon</item>
     </style>
 
+    <style name="LargePointer">
+        <item name="pointerIconArrow">@drawable/pointer_arrow_large_icon</item>
+        <item name="pointerIconSpotHover">@drawable/pointer_spot_hover_icon</item>
+        <item name="pointerIconSpotTouch">@drawable/pointer_spot_touch_icon</item>
+        <item name="pointerIconSpotAnchor">@drawable/pointer_spot_anchor_icon</item>
+        <item name="pointerIconHand">@drawable/pointer_hand_large_icon</item>
+        <item name="pointerIconContextMenu">@drawable/pointer_context_menu_large_icon</item>
+        <item name="pointerIconHelp">@drawable/pointer_help_large_icon</item>
+        <!-- TODO: create large wait icon. -->
+        <item name="pointerIconWait">@drawable/pointer_wait_icon</item>
+        <item name="pointerIconCell">@drawable/pointer_cell_large_icon</item>
+        <item name="pointerIconCrosshair">@drawable/pointer_crosshair_large_icon</item>
+        <item name="pointerIconText">@drawable/pointer_text_large_icon</item>
+        <item name="pointerIconVerticalText">@drawable/pointer_vertical_text_large_icon</item>
+        <item name="pointerIconAlias">@drawable/pointer_alias_large_icon</item>
+        <item name="pointerIconCopy">@drawable/pointer_copy_large_icon</item>
+        <item name="pointerIconAllScroll">@drawable/pointer_all_scroll_large_icon</item>
+        <item name="pointerIconNodrop">@drawable/pointer_nodrop_large_icon</item>
+        <item name="pointerIconHorizontalDoubleArrow">
+            @drawable/pointer_horizontal_double_arrow_large_icon
+        </item>
+        <item name="pointerIconVerticalDoubleArrow">
+            @drawable/pointer_vertical_double_arrow_large_icon
+        </item>
+        <item name="pointerIconTopRightDiagonalDoubleArrow">
+            @drawable/pointer_top_right_diagonal_double_arrow_large_icon
+        </item>
+        <item name="pointerIconTopLeftDiagonalDoubleArrow">
+            @drawable/pointer_top_left_diagonal_double_arrow_large_icon
+        </item>
+        <item name="pointerIconZoomIn">@drawable/pointer_zoom_in_large_icon</item>
+        <item name="pointerIconZoomOut">@drawable/pointer_zoom_out_large_icon</item>
+        <item name="pointerIconGrab">@drawable/pointer_grab_large_icon</item>
+        <item name="pointerIconGrabbing">@drawable/pointer_grabbing_large_icon</item>
+    </style>
+
     <!-- Wifi dialog styles -->
     <!-- @hide -->
     <style name="wifi_item">
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 16c9db1..d92adc2 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -227,7 +227,6 @@
   <java-symbol type="attr" name="gestureOverlayViewStyle" />
   <java-symbol type="attr" name="keyboardViewStyle" />
   <java-symbol type="attr" name="numberPickerStyle" />
-  <java-symbol type="attr" name="pointerStyle" />
   <java-symbol type="attr" name="preferenceFrameLayoutStyle" />
   <java-symbol type="attr" name="searchDialogTheme" />
   <java-symbol type="attr" name="textAppearanceAutoCorrectionSuggestion" />
@@ -243,10 +242,8 @@
   <java-symbol type="attr" name="isLightTheme"/>
 
   <java-symbol type="bool" name="action_bar_embed_tabs" />
-  <java-symbol type="bool" name="action_bar_embed_tabs_pre_jb" />
   <java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" />
   <java-symbol type="bool" name="config_avoidGfxAccel" />
-  <java-symbol type="bool" name="config_allowActionMenuItemTextWithIcon" />
   <java-symbol type="bool" name="config_bluetooth_address_validation" />
   <java-symbol type="bool" name="config_bluetooth_sco_off_call" />
   <java-symbol type="bool" name="config_bluetooth_le_peripheral_mode_supported" />
@@ -1424,6 +1421,8 @@
   <java-symbol type="style" name="Theme.DeviceDefault.Dialog.NoFrame" />
   <java-symbol type="style" name="Theme.IconMenu" />
   <java-symbol type="style" name="Theme.DeviceDefault.VoiceInteractionSession" />
+  <java-symbol type="style" name="Pointer" />
+  <java-symbol type="style" name="LargePointer" />
 
   <java-symbol type="attr" name="mediaRouteButtonStyle" />
   <java-symbol type="attr" name="externalRouteEnabledDrawable" />
@@ -2087,6 +2086,11 @@
   <java-symbol type="array" name="config_system_condition_providers" />
   <java-symbol type="string" name="muted_by" />
   <java-symbol type="string" name="zen_mode_alarm" />
+  <java-symbol type="string" name="notification_importance_blocked" />
+  <java-symbol type="string" name="notification_importance_low" />
+  <java-symbol type="string" name="notification_importance_default" />
+  <java-symbol type="string" name="notification_importance_high" />
+  <java-symbol type="string" name="notification_importance_max" />
 
   <java-symbol type="string" name="select_day" />
   <java-symbol type="string" name="select_year" />
@@ -2347,6 +2351,8 @@
 
   <java-symbol type="string" name="config_packagedKeyboardName" />
   <java-symbol type="string" name="default_notification_topic_label" />
+  <java-symbol type="bool" name="config_forceWindowDrawsStatusBarBackground" />
+  <java-symbol type="color" name="system_bar_background_semi_transparent" />
 
   <!-- EditText suggestion popup. -->
   <java-symbol type="id" name="suggestionContainer" />
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index d56674a..bf7718e 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -428,9 +428,6 @@
         <item name="fastScrollOverlayPosition">floating</item>
         <item name="fastScrollTextColor">@color/primary_text_dark</item>
 
-        <!-- Pointer style -->
-        <item name="pointerStyle">@style/Pointer</item>
-
         <!-- Accessibility focused drawable -->
         <item name="accessibilityFocusedDrawable">@drawable/view_accessibility_focused</item>
 
diff --git a/core/res/res/xml/sms_short_codes.xml b/core/res/res/xml/sms_short_codes.xml
index 5783a49..5f1f927 100644
--- a/core/res/res/xml/sms_short_codes.xml
+++ b/core/res/res/xml/sms_short_codes.xml
@@ -187,6 +187,6 @@
 
     <!-- USA: 5-6 digits (premium codes from https://www.premiumsmsrefunds.com/ShortCodes.htm),
          visual voicemail code for T-Mobile: 122 -->
-    <shortcode country="us" pattern="\\d{5,6}" premium="20433|21(?:344|472)|22715|23(?:333|847)|24(?:15|28)0|25209|27(?:449|606|663)|28498|305(?:00|83)|32(?:340|941)|33(?:166|786|849)|34746|35(?:182|564)|37975|38(?:135|146|254)|41(?:366|463)|42335|43(?:355|500)|44(?:578|711|811)|45814|46(?:157|173|327)|46666|47553|48(?:221|277|669)|50(?:844|920)|51(?:062|368)|52944|54(?:723|892)|55928|56483|57370|59(?:182|187|252|342)|60339|61(?:266|982)|62478|64(?:219|898)|65(?:108|500)|69(?:208|388)|70877|71851|72(?:078|087|465)|73(?:288|588|882|909|997)|74(?:034|332|815)|76426|79213|81946|83177|84(?:103|685)|85797|86(?:234|236|666)|89616|90(?:715|842|938)|91(?:362|958)|94719|95297|96(?:040|666|835|969)|97(?:142|294|688)|99(?:689|796|807)" free="122|87902" />
+    <shortcode country="us" pattern="\\d{5,6}" premium="20433|21(?:344|472)|22715|23(?:333|847)|24(?:15|28)0|25209|27(?:449|606|663)|28498|305(?:00|83)|32(?:340|941)|33(?:166|786|849)|34746|35(?:182|564)|37975|38(?:135|146|254)|41(?:366|463)|42335|43(?:355|500)|44(?:578|711|811)|45814|46(?:157|173|327|654)|46666|47553|48(?:221|277|669)|50(?:844|920)|51(?:062|368)|52944|54(?:723|892)|55928|56483|57370|59(?:182|187|252|342)|60339|61(?:266|982)|62478|64(?:219|898)|65(?:108|500)|69(?:208|388)|70877|71851|72(?:078|087|465)|73(?:288|588|882|909|997)|74(?:034|332|815)|76426|79213|81946|83177|84(?:103|685)|85797|86(?:234|236|666)|89616|90(?:715|842|938)|91(?:362|958)|94719|95297|96(?:040|666|835|969)|97(?:142|294|688)|99(?:689|796|807)" free="122|87902" />
 
 </shortcodes>
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/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java b/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
new file mode 100644
index 0000000..157c815
--- /dev/null
+++ b/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.textservice;
+
+import android.os.Parcel;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import java.util.Arrays;
+import java.util.Locale;
+
+import static android.test.MoreAsserts.assertNotEqual;
+
+/**
+ * TODO: Most of part can be, and probably should be, moved to CTS.
+ */
+public class SpellCheckerSubtypeTest extends InstrumentationTestCase {
+    private static final String SUBTYPE_SUBTYPE_LOCALE_STRING_A = "en_GB";
+    private static final int SUBTYPE_NAME_RES_ID_A = 0x12345;
+    private static final String SUBTYPE_EXTRA_VALUE_A = "Key1=Value1,Key2=Value2";
+    private static final String SUBTYPE_SUBTYPE_LOCALE_STRING_B = "en_IN";
+    private static final int SUBTYPE_NAME_RES_ID_B = 0x54321;
+    private static final String SUBTYPE_EXTRA_VALUE_B = "Key3=Value3,Key4=Value4";
+
+    private static int defaultHashCodeAlgorithm(String locale, String extraValue) {
+        return Arrays.hashCode(new Object[] {locale, extraValue});
+    }
+
+    private static final SpellCheckerSubtype cloneViaParcel(final SpellCheckerSubtype original) {
+        Parcel parcel = null;
+        try {
+            parcel = Parcel.obtain();
+            original.writeToParcel(parcel, 0);
+            parcel.setDataPosition(0);
+            return SpellCheckerSubtype.CREATOR.createFromParcel(parcel);
+        } finally {
+            if (parcel != null) {
+                parcel.recycle();
+            }
+        }
+    }
+
+    @SmallTest
+    public void testSubtype() throws Exception {
+        final SpellCheckerSubtype subtype = new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A,
+                SUBTYPE_SUBTYPE_LOCALE_STRING_A, SUBTYPE_EXTRA_VALUE_A);
+
+        assertEquals(SUBTYPE_NAME_RES_ID_A, subtype.getNameResId());
+        assertEquals(SUBTYPE_SUBTYPE_LOCALE_STRING_A, subtype.getLocale());
+        assertEquals("Value1", subtype.getExtraValueOf("Key1"));
+        assertEquals("Value2", subtype.getExtraValueOf("Key2"));
+        // Historically we have used SpellCheckerSubtype#hashCode() to track which subtype is
+        // enabled, and it is supposed to be stored in SecureSettings.  Therefore we have to
+        // keep using the same algorithm for compatibility reasons.
+        assertEquals(
+                defaultHashCodeAlgorithm(SUBTYPE_SUBTYPE_LOCALE_STRING_A, SUBTYPE_EXTRA_VALUE_A),
+                subtype.hashCode());
+
+        final SpellCheckerSubtype clonedSubtype = cloneViaParcel(subtype);
+        assertEquals(SUBTYPE_NAME_RES_ID_A, clonedSubtype.getNameResId());
+        assertEquals(SUBTYPE_SUBTYPE_LOCALE_STRING_A, clonedSubtype.getLocale());
+        assertEquals("Value1", clonedSubtype.getExtraValueOf("Key1"));
+        assertEquals("Value2", clonedSubtype.getExtraValueOf("Key2"));
+        assertEquals(
+                defaultHashCodeAlgorithm(SUBTYPE_SUBTYPE_LOCALE_STRING_A, SUBTYPE_EXTRA_VALUE_A),
+                clonedSubtype.hashCode());
+    }
+
+    @SmallTest
+    public void testGetLocaleObject() throws Exception {
+        assertEquals(new Locale("en"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "en", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+        assertEquals(new Locale("en", "US"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "en_US", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+        assertEquals(new Locale("en", "US", "POSIX"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "en_US_POSIX", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+
+        // Special rewrite rule for "tl" for versions of Android earlier than Lollipop that did not
+        // support three letter language codes, and used "tl" (Tagalog) as the language string for
+        // "fil" (Filipino).
+        assertEquals(new Locale("fil"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "tl", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+        assertEquals(new Locale("fil", "PH"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "tl_PH", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+        assertEquals(new Locale("fil", "PH", "POSIX"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "tl_PH_POSIX", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+
+        // So far rejecting invalid/unexpected locale strings is out of the scope.
+        assertEquals(new Locale("a"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "a", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+        assertEquals(new Locale("a b c"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "a b c", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+        assertEquals(new Locale("en-US"), new SpellCheckerSubtype(
+                SUBTYPE_NAME_RES_ID_A, "en-US", SUBTYPE_EXTRA_VALUE_A).getLocaleObject());
+    }
+
+    @SmallTest
+    public void testEquality() throws Exception {
+        assertEquals(
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A, SUBTYPE_SUBTYPE_LOCALE_STRING_A,
+                        SUBTYPE_EXTRA_VALUE_A),
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A, SUBTYPE_SUBTYPE_LOCALE_STRING_A,
+                        SUBTYPE_EXTRA_VALUE_A));
+        assertNotEqual(
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A, SUBTYPE_SUBTYPE_LOCALE_STRING_A,
+                        SUBTYPE_EXTRA_VALUE_A),
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_B, SUBTYPE_SUBTYPE_LOCALE_STRING_B,
+                        SUBTYPE_EXTRA_VALUE_A));
+        assertNotEqual(
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A, SUBTYPE_SUBTYPE_LOCALE_STRING_A,
+                        SUBTYPE_EXTRA_VALUE_A),
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A, SUBTYPE_SUBTYPE_LOCALE_STRING_B,
+                        SUBTYPE_EXTRA_VALUE_A));
+        assertNotEqual(
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A, SUBTYPE_SUBTYPE_LOCALE_STRING_A,
+                        SUBTYPE_EXTRA_VALUE_A),
+                new SpellCheckerSubtype(SUBTYPE_NAME_RES_ID_A, SUBTYPE_SUBTYPE_LOCALE_STRING_A,
+                        SUBTYPE_EXTRA_VALUE_B));
+    }
+}
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/libs/input/PointerController.cpp b/libs/input/PointerController.cpp
index bd6af78..6a1167a 100644
--- a/libs/input/PointerController.cpp
+++ b/libs/input/PointerController.cpp
@@ -91,7 +91,14 @@
 
     mLocked.buttonState = 0;
 
+    mPolicy->loadPointerIcon(&mLocked.pointerIcon);
+
     loadResources();
+
+    if (mLocked.pointerIcon.isValid()) {
+        mLocked.pointerIconChanged = true;
+        updatePointerLocked();
+    }
 }
 
 PointerController::~PointerController() {
@@ -325,6 +332,23 @@
     }
 }
 
+void PointerController::reloadPointerResources() {
+    AutoMutex _l(mLock);
+
+    loadResources();
+
+    if (mLocked.presentation == PRESENTATION_POINTER) {
+        mLocked.additionalMouseResources.clear();
+        mLocked.animationResources.clear();
+        mPolicy->loadPointerIcon(&mLocked.pointerIcon);
+        mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources,
+                                              &mLocked.animationResources);
+    }
+
+    mLocked.presentationChanged = true;
+    updatePointerLocked();
+}
+
 void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_t orientation) {
     AutoMutex _l(mLock);
 
@@ -415,15 +439,6 @@
     }
 }
 
-void PointerController::setPointerIcon(const SpriteIcon& icon) {
-    AutoMutex _l(mLock);
-
-    mLocked.pointerIcon = icon.copy();
-    mLocked.pointerIconChanged = true;
-
-    updatePointerLocked();
-}
-
 void PointerController::handleMessage(const Message& message) {
     switch (message.what) {
     case MSG_INACTIVITY_TIMEOUT:
diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h
index b6c01d2..4fd2d85 100644
--- a/libs/input/PointerController.h
+++ b/libs/input/PointerController.h
@@ -62,6 +62,7 @@
     virtual ~PointerControllerPolicyInterface() { }
 
 public:
+    virtual void loadPointerIcon(SpriteIcon* icon) = 0;
     virtual void loadPointerResources(PointerResources* outResources) = 0;
     virtual void loadAdditionalMouseResources(std::map<int32_t, SpriteIcon>* outResources,
             std::map<int32_t, PointerAnimation>* outAnimationResources) = 0;
@@ -105,8 +106,8 @@
 
     void updatePointerShape(int32_t iconId);
     void setDisplayViewport(int32_t width, int32_t height, int32_t orientation);
-    void setPointerIcon(const SpriteIcon& icon);
     void setInactivityTimeout(InactivityTimeout inactivityTimeout);
+    void reloadPointerResources();
 
 private:
     static const size_t MAX_RECYCLED_SPRITES = 12;
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/AndroidManifest.xml b/packages/DocumentsUI/AndroidManifest.xml
index 60f5d60..8cc79a4c 100644
--- a/packages/DocumentsUI/AndroidManifest.xml
+++ b/packages/DocumentsUI/AndroidManifest.xml
@@ -41,6 +41,7 @@
         <activity
             android:name=".DownloadsActivity"
             android:theme="@style/DocumentsFullScreenTheme"
+            android:label="@string/downloads_label"
             android:icon="@drawable/ic_doc_text">
             <intent-filter>
                 <action android:name="android.provider.action.MANAGE_ROOT" />
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/res/values/strings.xml b/packages/DocumentsUI/res/values/strings.xml
index d21b5ee..016657e 100644
--- a/packages/DocumentsUI/res/values/strings.xml
+++ b/packages/DocumentsUI/res/values/strings.xml
@@ -21,6 +21,9 @@
     <!-- Title of the standalone files activity. [CHAR LIMIT=32] -->
     <string name="files_label">Files</string>
 
+    <!-- Title of the standalone downloads activity. [CHAR LIMIT=32] -->
+    <string name="downloads_label">Downloads</string>
+
     <!-- Action bar title prompting user to choose a location to open a document from [CHAR LIMIT=32] -->
     <string name="title_open">Open from</string>
     <!-- Action bar title prompting user to choose a location to save a document to [CHAR LIMIT=32] -->
diff --git a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
index abb08f5..0f25016 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
@@ -223,49 +223,61 @@
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        final int id = item.getItemId();
-        if (id == android.R.id.home) {
-            onBackPressed();
-            return true;
-        } else if (id == R.id.menu_create_dir) {
-            showCreateDirectoryDialog();
-            return true;
-        } else if (id == R.id.menu_search) {
-            return false;
-        } else if (id == R.id.menu_sort_name) {
-            setUserSortOrder(State.SORT_ORDER_DISPLAY_NAME);
-            return true;
-        } else if (id == R.id.menu_sort_date) {
-            setUserSortOrder(State.SORT_ORDER_LAST_MODIFIED);
-            return true;
-        } else if (id == R.id.menu_sort_size) {
-            setUserSortOrder(State.SORT_ORDER_SIZE);
-            return true;
-        } else if (id == R.id.menu_grid) {
-            setUserMode(State.MODE_GRID);
-            return true;
-        } else if (id == R.id.menu_list) {
-            setUserMode(State.MODE_LIST);
-            return true;
-        } else if (id == R.id.menu_paste_from_clipboard) {
-            DirectoryFragment.get(getFragmentManager())
-                .pasteFromClipboard();
-          return true;
-        } else if (id == R.id.menu_advanced) {
-            setDisplayAdvancedDevices(!LocalPreferences.getDisplayAdvancedDevices(this));
-            return true;
-        } else if (id == R.id.menu_file_size) {
-            setDisplayFileSize(!LocalPreferences.getDisplayFileSize(this));
-            return true;
-        } else if (id == R.id.menu_settings) {
-            final RootInfo root = getCurrentRoot();
-            final Intent intent = new Intent(DocumentsContract.ACTION_DOCUMENT_ROOT_SETTINGS);
-            intent.setDataAndType(root.getUri(), DocumentsContract.Root.MIME_TYPE_ITEM);
-            startActivity(intent);
-            return true;
-        }
 
-        return super.onOptionsItemSelected(item);
+        switch (item.getItemId()) {
+            case android.R.id.home:
+                onBackPressed();
+                return true;
+
+            case R.id.menu_create_dir:
+                showCreateDirectoryDialog();
+                return true;
+
+            case R.id.menu_search:
+                return false;
+
+            case R.id.menu_sort_name:
+                setUserSortOrder(State.SORT_ORDER_DISPLAY_NAME);
+                return true;
+
+            case R.id.menu_sort_date:
+                setUserSortOrder(State.SORT_ORDER_LAST_MODIFIED);
+                return true;
+            case R.id.menu_sort_size:
+                setUserSortOrder(State.SORT_ORDER_SIZE);
+                return true;
+
+            case R.id.menu_grid:
+                setUserMode(State.MODE_GRID);
+                return true;
+
+            case R.id.menu_list:
+                setUserMode(State.MODE_LIST);
+                return true;
+
+            case R.id.menu_paste_from_clipboard:
+                DirectoryFragment.get(getFragmentManager())
+                    .pasteFromClipboard();
+              return true;
+
+            case R.id.menu_advanced:
+                setDisplayAdvancedDevices(!LocalPreferences.getDisplayAdvancedDevices(this));
+                return true;
+
+            case R.id.menu_file_size:
+                setDisplayFileSize(!LocalPreferences.getDisplayFileSize(this));
+                return true;
+
+            case R.id.menu_settings:
+                final RootInfo root = getCurrentRoot();
+                final Intent intent = new Intent(DocumentsContract.ACTION_DOCUMENT_ROOT_SETTINGS);
+                intent.setDataAndType(root.getUri(), DocumentsContract.Root.MIME_TYPE_ITEM);
+                startActivity(intent);
+                return true;
+
+            default:
+                return super.onOptionsItemSelected(item);
+        }
     }
 
     void showCreateDirectoryDialog() {
diff --git a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
index 840f7fa..99d0cf4 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
@@ -369,9 +369,15 @@
                 // TODO: Should be statically bound using alphabeticShortcut. See b/21330356.
                 dir = DirectoryFragment.get(getFragmentManager());
                 dir.copySelectedToClipboard();
+                return true;
+            case KeyEvent.KEYCODE_V:
+                // TODO: Should be statically bound using alphabeticShortcut. See b/21330356.
+                dir = DirectoryFragment.get(getFragmentManager());
+                dir.pasteFromClipboard();
+                return true;
+            default:
+                return super.onKeyShortcut(keyCode, event);
         }
-
-        return super.onKeyShortcut(keyCode, event);
     }
 
     @Override
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/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
index be3013b..2e7c908 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -147,7 +147,7 @@
     public static final int REQUEST_COPY_DESTINATION = 1;
 
     private static final int LOADER_ID = 42;
-    private static final boolean DEBUG_ENABLE_DND = false;
+    private static final boolean DEBUG_ENABLE_DND = true;
 
     private static final String EXTRA_TYPE = "type";
     private static final String EXTRA_ROOT = "root";
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_SelectionTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_SelectionTest.java
index 72fc108..030ac6c 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_SelectionTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_SelectionTest.java
@@ -22,7 +22,7 @@
 import com.android.documentsui.dirlist.MultiSelectManager.Selection;
 
 @SmallTest
-public class MultiSelectManager_SelectionTest extends AndroidTestCase{
+public class MultiSelectManager_SelectionTest extends AndroidTestCase {
 
     private Selection selection;
 
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/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index c324abd..6680d88 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -209,4 +209,7 @@
 
     <!-- Default for Settings.Secure.NFC_PAYMENT_COMPONENT -->
     <string name="def_nfc_payment_component"></string>
+
+    <!-- Default setting for ability to add users from the lock screen -->
+    <bool name="def_add_users_from_lockscreen">false</bool>
 </resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index fbf8a2b..7365e66 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -61,6 +61,7 @@
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.content.PackageMonitor;
 import com.android.internal.os.BackgroundThread;
+import com.android.providers.settings.SettingsState.Setting;
 
 import java.io.File;
 import java.io.FileDescriptor;
@@ -72,8 +73,6 @@
 import java.util.Set;
 import java.util.regex.Pattern;
 
-import com.android.providers.settings.SettingsState.Setting;
-
 /**
  * <p>
  * This class is a content provider that publishes the system settings.
@@ -1891,7 +1890,7 @@
         }
 
         private final class UpgradeController {
-            private static final int SETTINGS_VERSION = 122;
+            private static final int SETTINGS_VERSION = 123;
 
             private final int mUserId;
 
@@ -2043,6 +2042,24 @@
                     }
                     currentVersion = 122;
                 }
+
+                if (currentVersion == 122) {
+                    // Version 123: Adding a default value for the ability to add a user from
+                    // the lock screen.
+                    if (userId == UserHandle.USER_SYSTEM) {
+                        final SettingsState globalSettings = getGlobalSettingsLocked();
+                        Setting currentSetting = globalSettings.getSettingLocked(
+                                Settings.Global.ADD_USERS_WHEN_LOCKED);
+                        if (currentSetting == null) {
+                            globalSettings.insertSettingLocked(
+                                    Settings.Global.ADD_USERS_WHEN_LOCKED,
+                                    getContext().getResources().getBoolean(
+                                            R.bool.def_add_users_from_lockscreen) ? "1" : "0",
+                                    SettingsState.SYSTEM_PACKAGE_NAME);
+                        }
+                    }
+                    currentVersion = 123;
+                }
                 // vXXX: Add new settings above this point.
 
                 // Return the current version.
diff --git a/packages/Shell/res/values/strings.xml b/packages/Shell/res/values/strings.xml
index cff36f7..5c25576 100644
--- a/packages/Shell/res/values/strings.xml
+++ b/packages/Shell/res/values/strings.xml
@@ -17,8 +17,8 @@
 <resources>
     <string name="app_label">Shell</string>
 
-    <!-- Title of notification indicating a bugreport process is in progress. [CHAR LIMIT=50] -->
-    <string name="bugreport_in_progress_title">Bug report in progress</string>
+    <!-- Title of notification indicating a bugreport is being generated. [CHAR LIMIT=50] -->
+    <string name="bugreport_in_progress_title">Bug report is being generated</string>
     <!-- Title of notification indicating a bugreport has been successfully captured. [CHAR LIMIT=50] -->
     <string name="bugreport_finished_title">Bug report captured</string>
 
@@ -39,4 +39,7 @@
     <!-- Toast message sent when the bugreport file could be read. -->
     <string name="bugreport_unreadable_text">Bug report file could not be read</string>
 
+    <!-- Title for bug reports received from dumpstate without a name. [CHAR LIMIT=30]-->
+    <string name="bugreport_unnamed">unnamed</string>
+
 </resources>
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index f41f52c..79d4f17 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -28,7 +28,6 @@
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.zip.ZipEntry;
@@ -117,11 +116,13 @@
     /** How long (in ms) a dumpstate process will be monitored if it didn't show progress. */
     private static final long INACTIVITY_TIMEOUT = 3 * DateUtils.MINUTE_IN_MILLIS;
 
-    /** System property used for monitoring progress. */
-    private static final String PROPERTY_TEMPLATE_PROGRESS = "dumpstate.%d.progress";
+    /** System properties used for monitoring progress. */
+    private static final String DUMPSTATE_PREFIX = "dumpstate.";
+    private static final String PROGRESS_SUFFIX = ".progress";
+    private static final String MAX_SUFFIX = ".max";
 
     /** System property (and value) used for stop dumpstate. */
-    private static final String PROPERTY_CTL_STOP = "ctl.stop";
+    private static final String CTL_STOP = "ctl.stop";
     private static final String BUGREPORT_SERVICE = "bugreport";
 
     /** Managed dumpstate processes (keyed by pid) */
@@ -179,13 +180,13 @@
     private final class ServiceHandler extends Handler {
         public ServiceHandler(Looper looper) {
             super(looper);
-            pollProgress();
+            poll();
         }
 
         @Override
         public void handleMessage(Message msg) {
             if (msg.what == MSG_POLL) {
-                pollProgress();
+                poll();
                 return;
             }
 
@@ -242,172 +243,191 @@
 
         }
 
-        /**
-         * Creates the {@link BugreportInfo} for a process and issue a system notification to
-         * indicate its progress.
-         *
-         * @return whether it succeeded or not.
-         */
-        private boolean startProgress(String name, int pid, int max) {
-            if (name == null) {
-                Log.w(TAG, "Missing " + EXTRA_NAME + " on start intent");
-                name = "N/A";
-            }
-            if (pid == -1) {
-                Log.e(TAG, "Missing " + EXTRA_PID + " on start intent");
-                return false;
-            }
-            if (max <= 0) {
-                Log.e(TAG, "Invalid value for extra " + EXTRA_MAX + ": " + max);
-                return false;
-            }
-
-            final BugreportInfo info = new BugreportInfo(pid, name, max);
-            synchronized (mProcesses) {
-                if (mProcesses.indexOfKey(pid) >= 0) {
-                    Log.w(TAG, "PID " + pid + " already watched");
-                } else {
-                    mProcesses.put(info.pid, info);
-                }
-            }
-            updateProgress(info);
-            return true;
-        }
-
-        /**
-         * Updates the system notification for a given bug report.
-         */
-        private void updateProgress(BugreportInfo info) {
-            if (info.max <= 0 || info.progress < 0 || info.name == null) {
-                Log.e(TAG, "Invalid progress values for " + info);
-                return;
-            }
-
-            final Context context = getApplicationContext();
-            final NumberFormat nf = NumberFormat.getPercentInstance();
-            nf.setMinimumFractionDigits(2);
-            nf.setMaximumFractionDigits(2);
-            final String percentText = nf.format((double) info.progress / info.max);
-
-            final Intent cancelIntent = new Intent(context, BugreportReceiver.class);
-            cancelIntent.setAction(INTENT_BUGREPORT_CANCEL);
-            cancelIntent.putExtra(EXTRA_PID, info.pid);
-            final Action cancelAction = new Action.Builder(null,
-                    context.getString(com.android.internal.R.string.cancel),
-                    PendingIntent.getBroadcast(context, info.pid, cancelIntent,
-                            PendingIntent.FLAG_CANCEL_CURRENT)).build();
-
-            final String title = context.getString(R.string.bugreport_in_progress_title);
-            final Notification notification = new Notification.Builder(context)
-                    .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
-                    .setContentTitle(title)
-                    .setTicker(title)
-                    .setContentText(info.name)
-                    .setContentInfo(percentText)
-                    .setProgress(info.max, info.progress, false)
-                    .setOngoing(true)
-                    .setLocalOnly(true)
-                    .setColor(context.getColor(
-                            com.android.internal.R.color.system_notification_accent_color))
-                    .addAction(cancelAction)
-                    .build();
-
-            NotificationManager.from(context).notify(TAG, info.pid, notification);
-        }
-
-        /**
-         * Finalizes the progress on a given process and sends the finished intent.
-         */
-        private void stopProgress(int pid, Intent intent) {
-            synchronized (mProcesses) {
-                if (mProcesses.indexOfKey(pid) < 0) {
-                    Log.w(TAG, "PID not watched: " + pid);
-                } else {
-                    mProcesses.remove(pid);
-                }
-                stopSelfWhenDone();
-            }
-            if (DEBUG) Log.v(TAG, "stopProgress(" + pid + "): cancel notification");
-            NotificationManager.from(getApplicationContext()).cancel(TAG, pid);
-            if (intent != null) {
-                // Bug report finished fine: send a new, different notification.
-                if (DEBUG) Log.v(TAG, "stopProgress(" + pid + "): finish bug report");
-                onBugreportFinished(pid, intent);
-            }
-        }
-
-        /**
-         * Cancels a bugreport upon user's request.
-         */
-        private void cancel(int pid) {
-            Log.i(TAG, "Cancelling PID " + pid + " on user's request");
-            SystemProperties.set(PROPERTY_CTL_STOP, BUGREPORT_SERVICE);
-            stopProgress(pid, null);
-        }
-
-        /**
-         * Poll {@link SystemProperties} to get the progress on each monitored process.
-         */
-        private void pollProgress() {
-            synchronized (mProcesses) {
-                if (mProcesses.size() == 0) {
-                    Log.d(TAG, "No process to poll progress.");
-                }
-                for (int i = 0; i < mProcesses.size(); i++) {
-                    int pid = mProcesses.keyAt(i);
-                    String property = String.format(PROPERTY_TEMPLATE_PROGRESS, pid);
-                    int progress = SystemProperties.getInt(property, 0);
-                    if (progress == 0) {
-                        Log.v(TAG, "System property " + property + " is not set yet");
-                        continue;
-                    }
-
-                    BugreportInfo info = mProcesses.valueAt(i);
-
-                    if (progress != info.progress) {
-                        if (DEBUG) Log.v(TAG, "Updating progress for PID " + pid + " from "
-                                + info.progress + " to " + progress);
-                        info.progress = progress;
-                        info.lastUpdate = System.currentTimeMillis();
-                        updateProgress(info);
-                    } else {
-                        long inactiveTime = System.currentTimeMillis() - info.lastUpdate;
-                        if (inactiveTime >= INACTIVITY_TIMEOUT) {
-                            Log.w(TAG, "No progress update for process " + pid + " since "
-                                    + info.getFormattedLastUpdate());
-                            stopProgress(info.pid, null);
-                        }
-                    }
-                }
+        private void poll() {
+            if (pollProgress()) {
                 // Keep polling...
                 sendEmptyMessageDelayed(MSG_POLL, POLLING_FREQUENCY);
             }
         }
+    }
 
-        /**
-         * Finishes the service when it's not monitoring any more processes.
-         */
-        private void stopSelfWhenDone() {
-            synchronized (mProcesses) {
-                if (mProcesses.size() > 0) {
-                    if (DEBUG) Log.v(TAG, "Staying alive, waiting for pids " + mProcesses);
-                    return;
-                }
-                Log.v(TAG, "No more pids to handle, shutting down");
-                stopSelf();
-            }
+    /**
+     * Creates the {@link BugreportInfo} for a process and issue a system notification to
+     * indicate its progress.
+     *
+     * @return whether it succeeded or not.
+     */
+    private boolean startProgress(String name, int pid, int max) {
+        if (name == null) {
+            Log.w(TAG, "Missing " + EXTRA_NAME + " on start intent");
+        }
+        if (pid == -1) {
+            Log.e(TAG, "Missing " + EXTRA_PID + " on start intent");
+            return false;
+        }
+        if (max <= 0) {
+            Log.e(TAG, "Invalid value for extra " + EXTRA_MAX + ": " + max);
+            return false;
         }
 
-        private void onBugreportFinished(int pid, Intent intent) {
-            final Context context = getApplicationContext();
-            final Configuration conf = context.getResources().getConfiguration();
-            final File bugreportFile = getFileExtra(intent, EXTRA_BUGREPORT);
-            final File screenshotFile = getFileExtra(intent, EXTRA_SCREENSHOT);
-
-            if ((conf.uiMode & Configuration.UI_MODE_TYPE_MASK) != Configuration.UI_MODE_TYPE_WATCH) {
-                triggerLocalNotification(context, pid, bugreportFile, screenshotFile);
+        final BugreportInfo info = new BugreportInfo(getApplicationContext(), pid, name, max);
+        synchronized (mProcesses) {
+            if (mProcesses.indexOfKey(pid) >= 0) {
+                Log.w(TAG, "PID " + pid + " already watched");
+            } else {
+                mProcesses.put(info.pid, info);
             }
         }
+        updateProgress(info);
+        return true;
+    }
+
+    /**
+     * Updates the system notification for a given bug report.
+     */
+    private void updateProgress(BugreportInfo info) {
+        if (info.max <= 0 || info.progress < 0) {
+            Log.e(TAG, "Invalid progress values for " + info);
+            return;
+        }
+
+        final Context context = getApplicationContext();
+        final NumberFormat nf = NumberFormat.getPercentInstance();
+        nf.setMinimumFractionDigits(2);
+        nf.setMaximumFractionDigits(2);
+        final String percentText = nf.format((double) info.progress / info.max);
+
+        final Intent cancelIntent = new Intent(context, BugreportReceiver.class);
+        cancelIntent.setAction(INTENT_BUGREPORT_CANCEL);
+        cancelIntent.putExtra(EXTRA_PID, info.pid);
+        final Action cancelAction = new Action.Builder(null,
+                context.getString(com.android.internal.R.string.cancel),
+                PendingIntent.getBroadcast(context, info.pid, cancelIntent,
+                        PendingIntent.FLAG_CANCEL_CURRENT)).build();
+
+        final String title = context.getString(R.string.bugreport_in_progress_title);
+        final String name =
+                info.name != null ? info.name : context.getString(R.string.bugreport_unnamed);
+
+        final Notification notification = new Notification.Builder(context)
+                .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
+                .setContentTitle(title)
+                .setTicker(title)
+                .setContentText(name)
+                .setContentInfo(percentText)
+                .setProgress(info.max, info.progress, false)
+                .setOngoing(true)
+                .setLocalOnly(true)
+                .setColor(context.getColor(
+                        com.android.internal.R.color.system_notification_accent_color))
+                .addAction(cancelAction)
+                .build();
+
+        NotificationManager.from(context).notify(TAG, info.pid, notification);
+    }
+
+    /**
+     * Finalizes the progress on a given process and sends the finished intent.
+     */
+    private void stopProgress(int pid, Intent intent) {
+        synchronized (mProcesses) {
+            if (mProcesses.indexOfKey(pid) < 0) {
+                Log.w(TAG, "PID not watched: " + pid);
+            } else {
+                mProcesses.remove(pid);
+            }
+            stopSelfWhenDone();
+        }
+        if (DEBUG) Log.v(TAG, "stopProgress(" + pid + "): cancel notification");
+        NotificationManager.from(getApplicationContext()).cancel(TAG, pid);
+        if (intent != null) {
+            // Bug report finished fine: send a new, different notification.
+            if (DEBUG) Log.v(TAG, "stopProgress(" + pid + "): finish bug report");
+            onBugreportFinished(pid, intent);
+        }
+    }
+
+    /**
+     * Cancels a bugreport upon user's request.
+     */
+    private void cancel(int pid) {
+        Log.i(TAG, "Cancelling PID " + pid + " on user's request");
+        SystemProperties.set(CTL_STOP, BUGREPORT_SERVICE);
+        stopProgress(pid, null);
+    }
+
+    /**
+     * Poll {@link SystemProperties} to get the progress on each monitored process.
+     *
+     * @return whether it should keep polling.
+     */
+    private boolean pollProgress() {
+        synchronized (mProcesses) {
+            if (mProcesses.size() == 0) {
+                Log.d(TAG, "No process to poll progress.");
+            }
+            for (int i = 0; i < mProcesses.size(); i++) {
+                final int pid = mProcesses.keyAt(i);
+                final String progressKey = DUMPSTATE_PREFIX + pid + PROGRESS_SUFFIX;
+                final int progress = SystemProperties.getInt(progressKey, 0);
+                if (progress == 0) {
+                    Log.v(TAG, "System property " + progressKey + " is not set yet");
+                    continue;
+                }
+                final int max = SystemProperties.getInt(DUMPSTATE_PREFIX + pid + MAX_SUFFIX, 0);
+                final BugreportInfo info = mProcesses.valueAt(i);
+                final boolean maxChanged = max > 0 && max != info.max;
+                final boolean progressChanged = progress > 0 && progress != info.progress;
+
+                if (progressChanged || maxChanged) {
+                    if (progressChanged) {
+                        if (DEBUG) Log.v(TAG, "Updating progress for PID " + pid + " from "
+                                + info.progress + " to " + progress);
+                        info.progress = progress;
+                    }
+                    if (maxChanged) {
+                        Log.i(TAG, "Updating max progress for PID " + pid + " from " + info.max
+                                + " to " + max);
+                        info.max = max;
+                    }
+                    info.lastUpdate = System.currentTimeMillis();
+                    updateProgress(info);
+                } else {
+                    long inactiveTime = System.currentTimeMillis() - info.lastUpdate;
+                    if (inactiveTime >= INACTIVITY_TIMEOUT) {
+                        Log.w(TAG, "No progress update for process " + pid + " since "
+                                + info.getFormattedLastUpdate());
+                        stopProgress(info.pid, null);
+                    }
+                }
+            }
+            return true;
+        }
+    }
+
+    /**
+     * Finishes the service when it's not monitoring any more processes.
+     */
+    private void stopSelfWhenDone() {
+        synchronized (mProcesses) {
+            if (mProcesses.size() > 0) {
+                if (DEBUG) Log.v(TAG, "Staying alive, waiting for pids " + mProcesses);
+                return;
+            }
+            Log.v(TAG, "No more pids to handle, shutting down");
+            stopSelf();
+        }
+    }
+
+    private void onBugreportFinished(int pid, Intent intent) {
+        final Context context = getApplicationContext();
+        final Configuration conf = context.getResources().getConfiguration();
+        final File bugreportFile = getFileExtra(intent, EXTRA_BUGREPORT);
+        final File screenshotFile = getFileExtra(intent, EXTRA_SCREENSHOT);
+
+        if ((conf.uiMode & Configuration.UI_MODE_TYPE_MASK) != Configuration.UI_MODE_TYPE_WATCH) {
+            triggerLocalNotification(context, pid, bugreportFile, screenshotFile);
+        }
     }
 
     /**
@@ -612,6 +632,8 @@
      * Information about a bug report process while its in progress.
      */
     private static final class BugreportInfo {
+        private final Context context;
+
         /**
          * {@code pid} of the {@code dumpstate} process generating the bug report.
          */
@@ -623,12 +645,12 @@
          * Initial value is the bug report filename reported by {@code dumpstate}, but user can
          * change it later to a more meaningful name.
          */
-        final String name;
+        String name;
 
         /**
          * Maximum progress of the bug report generation.
          */
-        final int max;
+        int max;
 
         /**
          * Current progress of the bug report generation.
@@ -640,22 +662,23 @@
          */
         long lastUpdate = System.currentTimeMillis();
 
-        BugreportInfo(int pid, String name, int max) {
+        BugreportInfo(Context context, int pid, String name, int max) {
+            this.context = context;
             this.pid = pid;
             this.name = name;
             this.max = max;
         }
 
         String getFormattedLastUpdate() {
-            return SimpleDateFormat.getDateTimeInstance().format(new Date(lastUpdate));
+            return DateUtils.formatDateTime(context, lastUpdate,
+                    DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
         }
 
         @Override
         public String toString() {
             final float percent = ((float) progress * 100 / max);
-            return String.format("Progress for %s (pid=%d): %d/%d (%2.2f%%) Last update: %s", name,
-                    pid, progress, max, percent,
-                    getFormattedLastUpdate());
+            return "Progress for " + name + " (pid=" + pid + "): " + progress + "/" + max
+                    + " (" + percent + "%) Last update: " + getFormattedLastUpdate();
         }
     }
 }
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index 33c4ef1..a54d9ef 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -104,7 +104,8 @@
     public void testFullWorkflow() throws Exception {
         final String name = "BUG, Y U NO REPORT?";
         // TODO: call method to remove property instead
-        SystemProperties.set("dumpstate.42.progress", "-1");
+        SystemProperties.set("dumpstate.42.progress", "0");
+        SystemProperties.set("dumpstate.42.max", "0");
 
         Intent intent = new Intent(INTENT_BUGREPORT_STARTED);
         intent.putExtra(EXTRA_PID, 42);
@@ -120,6 +121,9 @@
         SystemProperties.set("dumpstate.42.progress", "500");
         assertProgressNotification(name, "50.00%");
 
+        SystemProperties.set("dumpstate.42.max", "2000");
+        assertProgressNotification(name, "25.00%");
+
         createTextFile(PLAIN_TEXT_PATH, BUGREPORT_CONTENT);
         createTextFile(SCREENSHOT_PATH, SCREENSHOT_CONTENT);
         Bundle extras = sendBugreportFinishedIntent(42, PLAIN_TEXT_PATH, SCREENSHOT_PATH);
diff --git a/packages/SystemUI/Android.mk b/packages/SystemUI/Android.mk
index ece34fb..eb63e5d 100644
--- a/packages/SystemUI/Android.mk
+++ b/packages/SystemUI/Android.mk
@@ -21,8 +21,11 @@
 
 LOCAL_RESOURCE_DIR := \
     frameworks/base/packages/Keyguard/res \
-    $(LOCAL_PATH)/res
-LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages com.android.keyguard
+    $(LOCAL_PATH)/res \
+    frameworks/support/v7/recyclerview/res
+
+LOCAL_AAPT_FLAGS := --auto-add-overlay \
+     --extra-packages com.android.keyguard:android.support.v7.recyclerview
 
 ifneq ($(SYSTEM_UI_INCREMENTAL_BUILDS),)
     LOCAL_PROGUARD_ENABLED := disabled
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index bfd8af9..5618e9b 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -21,7 +21,6 @@
     <drawable name="ticker_background_color">#ff1d1d1d</drawable>
     <drawable name="system_bar_background">@color/system_bar_background_opaque</drawable>
     <color name="system_bar_background_opaque">#ff000000</color>
-    <color name="system_bar_background_semi_transparent">#66000000</color> <!-- 40% black -->
     <color name="system_bar_background_transparent">#00000000</color>
     <color name="notification_panel_solid_background">#ff000000</color>
     <drawable name="status_bar_notification_row_background_color">#ff090909</drawable>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 902db26..a0052ce 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -175,7 +175,7 @@
     <integer name="recents_animate_task_view_remove_duration">250</integer>
 
     <!-- The animation duration for scrolling the stack to a particular item. -->
-    <integer name="recents_animate_task_stack_scroll_duration">225</integer>
+    <integer name="recents_animate_task_stack_scroll_duration">200</integer>
 
     <!-- The animation duration for entering and exiting the history. -->
     <integer name="recents_history_transition_duration">250</integer>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index d6a361c..002b9f5 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1171,13 +1171,23 @@
     <!-- Toggles fullscreen screenshots. DO NOT TRANSLATE -->
     <string name="overview_fullscreen_thumbnails">Enable fullscreen screenshots</string>
     <!-- Description for the toggle for fullscreen screenshots. DO NOT TRANSLATE -->
-    <string name="overview_fullscreen_thumbnails_desc">Enable fullscreen screenshots in Overview</string>
+    <string name="overview_fullscreen_thumbnails_desc">Enable fullscreen screenshots in Overview. Restart required.</string>
+
+    <!-- Toggle to enable the Overview nav bar gesture. DO NOT TRANSLATE -->
+    <string name="overview_nav_bar_gesture">Enable navigation bar gesture</string>
+    <!-- Description for the toggle to enable the Overview nav bar gesture. DO NOT TRANSLATE -->
+    <string name="overview_nav_bar_gesture_desc">Enables the gesture to enter Overview by swiping up on the Nav bar</string>
 
     <!-- Toggle to show the history view in Overview. DO NOT TRANSLATE -->
     <string name="overview_show_history">Show History</string>
     <!-- Description for the toggle to show the history view in Overview. DO NOT TRANSLATE -->
     <string name="overview_show_history_desc">Enables the history view to see more recent tasks</string>
 
+    <!-- Toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
+    <string name="overview_initial_state_paging">Initialize to paging</string>
+    <!-- Description for the toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
+    <string name="overview_initial_state_paging_desc">Determines whether Overview will initially be in a stacked or paged state</string>
+
     <!-- Category in the System UI Tuner settings, where new/experimental
          settings are -->
     <string name="experimental">Experimental</string>
diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml
index f398af3..8dcf8a7 100644
--- a/packages/SystemUI/res/xml/tuner_prefs.xml
+++ b/packages/SystemUI/res/xml/tuner_prefs.xml
@@ -93,11 +93,21 @@
             android:summary="@string/overview_page_on_toggle_desc" />
 
         <com.android.systemui.tuner.TunerSwitch
+            android:key="overview_initial_state_paging"
+            android:title="@string/overview_initial_state_paging"
+            android:summary="@string/overview_initial_state_paging_desc" />
+
+        <com.android.systemui.tuner.TunerSwitch
             android:key="overview_fast_toggle"
             android:title="@string/overview_fast_toggle_via_button"
             android:summary="@string/overview_fast_toggle_via_button_desc" />
 
         <com.android.systemui.tuner.TunerSwitch
+            android:key="overview_nav_bar_gesture"
+            android:title="@string/overview_nav_bar_gesture"
+            android:summary="@string/overview_nav_bar_gesture_desc" />
+
+        <com.android.systemui.tuner.TunerSwitch
             android:key="overview_fullscreen_thumbnails"
             android:title="@string/overview_fullscreen_thumbnails"
             android:summary="@string/overview_fullscreen_thumbnails_desc" />
diff --git a/packages/SystemUI/src/com/android/systemui/RecentsComponent.java b/packages/SystemUI/src/com/android/systemui/RecentsComponent.java
index 4cb8a3c..7f6cda0 100644
--- a/packages/SystemUI/src/com/android/systemui/RecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/RecentsComponent.java
@@ -32,7 +32,7 @@
     /**
      * Docks the top-most task and opens recents.
      */
-    void dockTopTask(boolean draggingInRecents, Rect initialBounds);
+    void dockTopTask(boolean draggingInRecents, int stackCreateMode, Rect initialBounds);
 
     /**
      * Called during a drag-from-navbar-in gesture.
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
index c98ecb5..b81c23a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
@@ -365,8 +365,8 @@
     }
 
     @Override
-    public void dockTopTask(boolean draggingInRecents, Rect initialBounds) {
-        mImpl.dockTopTask(draggingInRecents, initialBounds);
+    public void dockTopTask(boolean draggingInRecents, int stackCreateMode, Rect initialBounds) {
+        mImpl.dockTopTask(draggingInRecents, stackCreateMode,initialBounds);
         if (draggingInRecents) {
             mDraggingInRecentsCurrentUser = sSystemServicesProxy.getCurrentUser();
         }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
index 43db666..e0bd59b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
@@ -82,7 +82,7 @@
             if (launchedFromHome) {
                 return numTasks - 1;
             } else {
-                if (flags.isFastToggleRecentsEnabled()) {
+                if (flags.isFastToggleRecentsEnabled() || !flags.isInitialStatePaging()) {
                     return numTasks - 1;
                 } else {
                     return numTasks - 2;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index cdfad18..53c10b7 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -115,8 +115,8 @@
         // Recompute some values based on the given state, since we can not rely on the resource
         // system to get certain values.
         boolean isLandscape = windowRect.width() > windowRect.height();
-        hasTransposedNavBar = isLandscape && isLargeScreen && !isXLargeScreen;
-        hasTransposedSearchBar = isLandscape && isLargeScreen && !isXLargeScreen;
+        hasTransposedNavBar = isLandscape && !isXLargeScreen;
+        hasTransposedSearchBar = isLandscape && !isXLargeScreen;
     }
 
     /**
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java
index e8b8816..d778886 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java
@@ -30,6 +30,7 @@
     private static final String KEY_PAGE_ON_TOGGLE = "overview_page_on_toggle";
     private static final String KEY_FULLSCREEN_THUMBNAILS = "overview_fullscreen_thumbnails";
     private static final String KEY_SHOW_HISTORY = "overview_show_history";
+    private static final String KEY_INITIAL_STATE_PAGING = "overview_initial_state_paging";
 
     public static class Static {
         // Enables debug drawing for the transition thumbnail
@@ -54,6 +55,7 @@
     private boolean mPageOnToggle;
     private boolean mUseFullscreenThumbnails;
     private boolean mShowHistory;
+    private boolean mInitialStatePaging;
 
     /**
      * We read the prefs once when we start the activity, then update them as the tuner changes
@@ -63,7 +65,7 @@
         // Register all our flags, this will also call onTuningChanged() for each key, which will
         // initialize the current state of each flag
         TunerService.get(context).addTunable(this, KEY_FAST_TOGGLE, KEY_PAGE_ON_TOGGLE,
-                KEY_FULLSCREEN_THUMBNAILS, KEY_SHOW_HISTORY);
+                KEY_FULLSCREEN_THUMBNAILS, KEY_SHOW_HISTORY, KEY_INITIAL_STATE_PAGING);
     }
 
     /**
@@ -94,6 +96,13 @@
         return mShowHistory;
     }
 
+    /**
+     * @return whether the initial stack state is paging.
+     */
+    public boolean isInitialStatePaging() {
+        return mInitialStatePaging;
+    }
+
     @Override
     public void onTuningChanged(String key, String newValue) {
         switch (key) {
@@ -113,6 +122,10 @@
                 mShowHistory = (newValue != null) &&
                         (Integer.parseInt(newValue) != 0);
                 break;
+            case KEY_INITIAL_STATE_PAGING:
+                mInitialStatePaging = (newValue != null) &&
+                        (Integer.parseInt(newValue) != 0);
+                break;
         }
         EventBus.getDefault().send(new DebugFlagsChangedEvent());
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index 3efb0cc..2a4017a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -539,12 +539,11 @@
         showRelativeAffiliatedTask(false);
     }
 
-    public void dockTopTask(boolean draggingInRecents, Rect initialBounds) {
+    public void dockTopTask(boolean draggingInRecents, int stackCreateMode, Rect initialBounds) {
         SystemServicesProxy ssp = Recents.getSystemServices();
         ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask();
         if (topTask != null && !SystemServicesProxy.isHomeStack(topTask.stackId)) {
-            ssp.moveTaskToDockedStack(topTask.id,
-                    ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, initialBounds);
+            ssp.moveTaskToDockedStack(topTask.id, stackCreateMode, initialBounds);
             showRecents(false /* triggeredFromAltTab */, draggingInRecents, false /* animate */,
                     true /* reloadTasks*/);
         }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index e313fd2..7a98393 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -137,7 +137,7 @@
 
     /** Returns the index of this task in the list of filtered tasks */
     int indexOf(Task t) {
-        if (mTaskIndices.containsKey(t.key)) {
+        if (t != null && mTaskIndices.containsKey(t.key)) {
             return mTaskIndices.get(t.key);
         }
         return -1;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 4a3bb11..a0a1bac 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -16,6 +16,8 @@
 
 package com.android.systemui.recents.views;
 
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Canvas;
@@ -27,6 +29,8 @@
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.ViewPropertyAnimator;
 import android.view.WindowInsets;
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
@@ -55,6 +59,8 @@
 import com.android.systemui.recents.misc.SystemServicesProxy;
 import com.android.systemui.recents.model.Task;
 import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.stackdivider.WindowManagerProxy;
+import com.android.systemui.statusbar.FlingAnimationUtils;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -94,8 +100,10 @@
 
     Rect mSystemInsets = new Rect();
 
+    final FlingAnimationUtils mFlingAnimationUtils;
+
     public RecentsView(Context context) {
-        super(context);
+        this(context, null);
     }
 
     public RecentsView(Context context, AttributeSet attrs) {
@@ -118,6 +126,7 @@
                 com.android.internal.R.interpolator.fast_out_linear_in);
         mHistoryTransitionDuration = res.getInteger(R.integer.recents_history_transition_duration);
         mTouchHandler = new RecentsViewTouchHandler(this);
+        mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f);
 
         LayoutInflater inflater = LayoutInflater.from(context);
         mHistoryButton = inflater.inflate(R.layout.recents_history_button, this, false);
@@ -511,7 +520,22 @@
     }
 
     public final void onBusEvent(DraggingInRecentsEndedEvent event) {
-        animate().translationY(0f);
+        ViewPropertyAnimator animator = animate();
+        if (event.velocity > mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
+            animator.translationY(getHeight());
+            animator.withEndAction(new Runnable() {
+                @Override
+                public void run() {
+                    WindowManagerProxy.getInstance().maximizeDockedStack();
+                }
+            });
+            mFlingAnimationUtils.apply(animator, getTranslationY(), getHeight(), event.velocity);
+        } else {
+            animator.translationY(0f);
+            animator.setListener(null);
+            mFlingAnimationUtils.apply(animator, getTranslationY(), 0, event.velocity);
+        }
+        animator.start();
     }
 
     public final void onBusEvent(ShowHistoryEvent event) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
index d630032..7d5daae 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
@@ -213,7 +213,7 @@
 
     Context mContext;
     private TaskStackView mStackView;
-    private Interpolator mFastOutSlowInInterpolator;
+    private Interpolator mLinearOutSlowInInterpolator;
     private StackState mState = StackState.SPLIT;
 
     // The task bounds (untransformed) for layout.  This rect is anchored at mTaskRoot.
@@ -295,8 +295,8 @@
         mMaxTranslationZ = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max);
         mContext = context;
         mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm();
-        mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
-                com.android.internal.R.interpolator.fast_out_slow_in);
+        mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
+                com.android.internal.R.interpolator.linear_out_slow_in);
     }
 
     /**
@@ -486,8 +486,9 @@
         if (Float.compare(newState, getFocusState()) != 0) {
             mFocusStateAnimator = ObjectAnimator.ofFloat(this, FOCUS_STATE, getFocusState(),
                     newState);
-            mFocusStateAnimator.setDuration(200);
-            mFocusStateAnimator.setInterpolator(mFastOutSlowInInterpolator);
+            mFocusStateAnimator.setDuration(mContext.getResources().getInteger(
+                    R.integer.recents_animate_task_stack_scroll_duration));
+            mFocusStateAnimator.setInterpolator(mLinearOutSlowInInterpolator);
             mFocusStateAnimator.start();
         }
     }
@@ -498,7 +499,8 @@
     public float getDefaultFocusState() {
         RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
         RecentsDebugFlags debugFlags = Recents.getDebugFlags();
-        if (debugFlags.isPageOnToggleEnabled() || launchState.launchedWithAltTab) {
+        if (launchState.launchedWithAltTab ||
+                (debugFlags.isPageOnToggleEnabled() && debugFlags.isInitialStatePaging())) {
             return 1f;
         }
         return 0f;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
index 4095d2e..56942a8 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
@@ -49,7 +49,7 @@
     ObjectAnimator mScrollAnimator;
     float mFinalAnimatedScroll;
 
-    Interpolator mLinearOutSlowInInterpolator;
+    private Interpolator mLinearOutSlowInInterpolator;
 
     public TaskStackViewScroller(Context context, TaskStackLayoutAlgorithm layoutAlgorithm) {
         mContext = context;
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index 98f3f0c..93264ff 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -74,7 +74,7 @@
 
     private final Rect mTmpRect = new Rect();
     private final Rect mLastResizeRect = new Rect();
-    private final WindowManagerProxy mWindowManagerProxy = new WindowManagerProxy();
+    private final WindowManagerProxy mWindowManagerProxy = WindowManagerProxy.getInstance();
     private Interpolator mFastOutSlowInInterpolator;
     private final Interpolator mTouchResponseInterpolator =
             new PathInterpolator(0.3f, 0f, 0.1f, 1f);
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
index 0d3f803..58de5d5 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
@@ -37,6 +37,8 @@
 
     private static final String TAG = "WindowManagerProxy";
 
+    private static final WindowManagerProxy sInstance = new WindowManagerProxy();
+
     @GuardedBy("mResizeRect")
     private final Rect mResizeRect = new Rect();
     private final Rect mTmpRect = new Rect();
@@ -78,6 +80,13 @@
         }
     };
 
+    private WindowManagerProxy() {
+    }
+
+    public static WindowManagerProxy getInstance() {
+        return sInstance;
+    }
+
     public void resizeDockedStack(Rect rect) {
         synchronized (mResizeRect) {
             mResizeRect.set(rect);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
index 1601b83..a3f404a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
@@ -146,7 +146,8 @@
                 mWarning = 0xffff0000;
             } else {
                 mOpaque = context.getColor(R.color.system_bar_background_opaque);
-                mSemiTransparent = context.getColor(R.color.system_bar_background_semi_transparent);
+                mSemiTransparent = context.getColor(
+                        com.android.internal.R.color.system_bar_background_semi_transparent);
                 mTransparent = context.getColor(R.color.system_bar_background_transparent);
                 mWarning = context.getColor(com.android.internal.R.color.battery_saver_mode_color);
             }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
index d91bfb9..a2616fe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
@@ -16,30 +16,29 @@
 
 package com.android.systemui.statusbar.phone;
 
+import android.app.ActivityManager;
 import android.content.Context;
-import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Rect;
-import android.os.SystemProperties;
 import android.view.GestureDetector;
 import android.view.MotionEvent;
 import android.view.VelocityTracker;
 import android.view.ViewConfiguration;
-import android.view.WindowManager;
 
 import com.android.systemui.R;
 import com.android.systemui.RecentsComponent;
 import com.android.systemui.stackdivider.Divider;
-import com.android.systemui.statusbar.BaseStatusBar;
+import com.android.systemui.tuner.TunerService;
 
 import static android.view.WindowManager.*;
 
 /**
  * Class to detect gestures on the navigation bar.
  */
-public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureListener {
+public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureListener
+        implements TunerService.Tunable {
 
-    private static final String DOCK_WINDOW_GESTURE_ENABLED_PROP = "persist.dock_gesture_enabled";
+    private static final String KEY_DOCK_WINDOW_GESTURE = "overview_nav_bar_gesture";
 
     /**
      * When dragging from the navigation bar, we drag in recents.
@@ -53,6 +52,7 @@
 
     private RecentsComponent mRecentsComponent;
     private Divider mDivider;
+    private Context mContext;
     private boolean mIsVertical;
     private boolean mIsRTL;
 
@@ -69,13 +69,14 @@
     private int mDragMode;
 
     public NavigationBarGestureHelper(Context context) {
+        mContext = context;
         ViewConfiguration configuration = ViewConfiguration.get(context);
         Resources r = context.getResources();
         mScrollTouchSlop = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance);
         mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
         mMinFlingVelocity = configuration.getScaledMinimumFlingVelocity();
         mTaskSwitcherDetector = new GestureDetector(context, this);
-        mDockWindowEnabled = SystemProperties.getBoolean(DOCK_WINDOW_GESTURE_ENABLED_PROP, false);
+        TunerService.get(context).addTunable(this, KEY_DOCK_WINDOW_GESTURE);
     }
 
     public void setComponents(RecentsComponent recentsComponent, Divider divider) {
@@ -172,6 +173,7 @@
                     == DOCKED_INVALID) {
                 mDragMode = calculateDragMode();
                 Rect initialBounds = null;
+                int createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
                 if (mDragMode == DRAG_MODE_DIVIDER) {
                     initialBounds = new Rect();
                     mDivider.getView().calculateBoundsForPosition(mIsVertical
@@ -181,8 +183,12 @@
                                     ? DOCKED_TOP
                                     : DOCKED_LEFT,
                             initialBounds);
+                } else if (mDragMode == DRAG_MODE_RECENTS && mTouchDownX
+                        < mContext.getResources().getDisplayMetrics().widthPixels / 2) {
+                    createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
                 }
-                mRecentsComponent.dockTopTask(mDragMode == DRAG_MODE_RECENTS, initialBounds);
+                mRecentsComponent.dockTopTask(mDragMode == DRAG_MODE_RECENTS, createMode,
+                        initialBounds);
                 if (mDragMode == DRAG_MODE_DIVIDER) {
                     mDivider.getView().startDragging();
                 }
@@ -259,4 +265,14 @@
         }
         return true;
     }
+
+    @Override
+    public void onTuningChanged(String key, String newValue) {
+        switch (key) {
+            case KEY_DOCK_WINDOW_GESTURE:
+                mDockWindowEnabled = (newValue != null) &&
+                        (Integer.parseInt(newValue) != 0);
+                break;
+        }
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 685c4e5..e51cf7ac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1133,7 +1133,9 @@
         @Override
         public boolean onLongClick(View v) {
             if (mRecents != null) {
-                mRecents.dockTopTask(false /* draggingInRecents */, null /* initialBounds */);
+                mRecents.dockTopTask(false /* draggingInRecents */,
+                        ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT,
+                        null /* initialBounds */);
                 return true;
             }
             return false;
@@ -2486,12 +2488,14 @@
 
             // update status bar mode
             final int sbMode = computeBarMode(oldVal, newVal, mStatusBarView.getBarTransitions(),
-                    View.STATUS_BAR_TRANSIENT, View.STATUS_BAR_TRANSLUCENT);
+                    View.STATUS_BAR_TRANSIENT, View.STATUS_BAR_TRANSLUCENT,
+                    View.STATUS_BAR_TRANSPARENT);
 
             // update navigation bar mode
             final int nbMode = mNavigationBarView == null ? -1 : computeBarMode(
                     oldVal, newVal, mNavigationBarView.getBarTransitions(),
-                    View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT);
+                    View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT,
+                    View.NAVIGATION_BAR_TRANSPARENT);
             final boolean sbModeChanged = sbMode != -1;
             final boolean nbModeChanged = nbMode != -1;
             boolean checkBarModes = false;
@@ -2542,21 +2546,21 @@
     }
 
     private int computeBarMode(int oldVis, int newVis, BarTransitions transitions,
-            int transientFlag, int translucentFlag) {
-        final int oldMode = barMode(oldVis, transientFlag, translucentFlag);
-        final int newMode = barMode(newVis, transientFlag, translucentFlag);
+            int transientFlag, int translucentFlag, int transparentFlag) {
+        final int oldMode = barMode(oldVis, transientFlag, translucentFlag, transparentFlag);
+        final int newMode = barMode(newVis, transientFlag, translucentFlag, transparentFlag);
         if (oldMode == newMode) {
             return -1; // no mode change
         }
         return newMode;
     }
 
-    private int barMode(int vis, int transientFlag, int translucentFlag) {
-        int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_TRANSPARENT;
+    private int barMode(int vis, int transientFlag, int translucentFlag, int transparentFlag) {
+        int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | transparentFlag;
         return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT
                 : (vis & translucentFlag) != 0 ? MODE_TRANSLUCENT
                 : (vis & lightsOutTransparent) == lightsOutTransparent ? MODE_LIGHTS_OUT_TRANSPARENT
-                : (vis & View.SYSTEM_UI_TRANSPARENT) != 0 ? MODE_TRANSPARENT
+                : (vis & transparentFlag) != 0 ? MODE_TRANSPARENT
                 : (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0 ? MODE_LIGHTS_OUT
                 : MODE_OPAQUE;
     }
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..502d61a 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -2475,6 +2475,129 @@
         }
     }
 
+    @Override
+    public void finishSession(IAccountManagerResponse response,
+            @NonNull Bundle sessionBundle,
+            boolean expectActivityLaunch,
+            Bundle appInfo) {
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG,
+                    "finishSession: response "+ response
+                            + ", expectActivityLaunch " + expectActivityLaunch
+                            + ", caller's uid " + Binder.getCallingUid()
+                            + ", pid " + Binder.getCallingPid());
+        }
+        if (response == null) {
+            throw new IllegalArgumentException("response is null");
+        }
+
+        // Session bundle is the encrypted bundle of the original bundle created by authenticator.
+        // Account type is added to it before encryption.
+        if (sessionBundle == null || sessionBundle.size() == 0) {
+            throw new IllegalArgumentException("sessionBundle is empty");
+        }
+
+        int userId = Binder.getCallingUserHandle().getIdentifier();
+        if (!canUserModifyAccounts(userId)) {
+            sendErrorResponse(response,
+                    AccountManager.ERROR_CODE_USER_RESTRICTED,
+                    "User is not allowed to add an account!");
+            showCantAddAccount(AccountManager.ERROR_CODE_USER_RESTRICTED, userId);
+            return;
+        }
+
+        final int pid = Binder.getCallingPid();
+        final int uid = Binder.getCallingUid();
+        final Bundle decryptedBundle;
+        final String accountType;
+        // First decrypt session bundle to get account type for checking permission.
+        try {
+            CryptoHelper cryptoHelper = CryptoHelper.getInstance();
+            decryptedBundle = cryptoHelper.decryptBundle(sessionBundle);
+            if (decryptedBundle == null) {
+                sendErrorResponse(
+                        response,
+                        AccountManager.ERROR_CODE_BAD_REQUEST,
+                        "failed to decrypt session bundle");
+                return;
+            }
+            accountType = decryptedBundle.getString(AccountManager.KEY_ACCOUNT_TYPE);
+            // Account type cannot be null. This should not happen if session bundle was created
+            // properly by #StartAccountSession.
+            if (TextUtils.isEmpty(accountType)) {
+                sendErrorResponse(
+                        response,
+                        AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+                        "accountType is empty");
+                return;
+            }
+
+            // If by any chances, decryptedBundle contains colliding keys with
+            // system info
+            // such as AccountManager.KEY_ANDROID_PACKAGE_NAME required by the add account flow or
+            // update credentials flow, we should replace with the new values of the current call.
+            if (appInfo != null) {
+                decryptedBundle.putAll(appInfo);
+            }
+
+            // Add info that may be used by add account or update credentials flow.
+            decryptedBundle.putInt(AccountManager.KEY_CALLER_UID, uid);
+            decryptedBundle.putInt(AccountManager.KEY_CALLER_PID, pid);
+        } catch (GeneralSecurityException e) {
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.v(TAG, "Failed to decrypt session bundle!", e);
+            }
+            sendErrorResponse(
+                    response,
+                    AccountManager.ERROR_CODE_BAD_REQUEST,
+                    "failed to decrypt session bundle");
+            return;
+        }
+
+        if (!canUserModifyAccountsForType(userId, accountType)) {
+            sendErrorResponse(
+                    response,
+                    AccountManager.ERROR_CODE_MANAGEMENT_DISABLED_FOR_ACCOUNT_TYPE,
+                    "User cannot modify accounts of this type (policy).");
+            showCantAddAccount(AccountManager.ERROR_CODE_MANAGEMENT_DISABLED_FOR_ACCOUNT_TYPE,
+                    userId);
+            return;
+        }
+
+        long identityToken = clearCallingIdentity();
+        try {
+            UserAccounts accounts = getUserAccounts(userId);
+            logRecordWithUid(
+                    accounts,
+                    DebugDbHelper.ACTION_CALLED_ACCOUNT_SESSION_FINISH,
+                    TABLE_ACCOUNTS,
+                    uid);
+            new Session(
+                    accounts,
+                    response,
+                    accountType,
+                    expectActivityLaunch,
+                    true /* stripAuthTokenFromResult */,
+                    null /* accountName */,
+                    false /* authDetailsRequired */,
+                    true /* updateLastAuthenticationTime */) {
+                @Override
+                public void run() throws RemoteException {
+                    mAuthenticator.finishSession(this, mAccountType, decryptedBundle);
+                }
+
+                @Override
+                protected String toDebugString(long now) {
+                    return super.toDebugString(now)
+                            + ", finishSession"
+                            + ", accountType " + accountType;
+                }
+            }.bind();
+        } finally {
+            restoreCallingIdentity(identityToken);
+        }
+    }
+
     private void showCantAddAccount(int errorCode, int userId) {
         Intent cantAddAccount = new Intent(mContext, CantAddAccountActivity.class);
         cantAddAccount.putExtra(CantAddAccountActivity.EXTRA_ERROR_CODE, errorCode);
@@ -3484,6 +3607,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 +3629,6 @@
                 return false;
             }
 
-
             return true;
         }
     }
@@ -3582,10 +3712,11 @@
         private static String ACTION_CALLED_ACCOUNT_ADD = "action_called_account_add";
         private static String ACTION_CALLED_ACCOUNT_REMOVE = "action_called_account_remove";
 
-        // TODO: This action doesn't add account to accountdb. Account is only
-        // added in finishAddAccount or finishAddAccountAsUser which may be in
-        // a different user profile.
+        //This action doesn't add account to accountdb. Account is only
+        // added in finishSession which may be in a different user profile.
         private static String ACTION_CALLED_START_ACCOUNT_ADD = "action_called_start_account_add";
+        private static String ACTION_CALLED_ACCOUNT_SESSION_FINISH =
+                "action_called_account_session_finish";
 
         private static SimpleDateFormat dateFromat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index c4f3634..65497cf 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -24,7 +24,7 @@
 import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
 
 import static com.android.server.am.ActivityManagerDebugConfig.*;
-
+import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN;
 import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
 import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
 
@@ -538,9 +538,8 @@
 
         if (addIndex > 0) {
             final ActivityStack topStack = mStacks.get(addIndex - 1);
-            if (topStack.mStackId == PINNED_STACK_ID && topStack != this) {
-                // The pinned stack is always the top most stack (always-on-top).
-                // So, stack is moved just below the pinned stack.
+            if (StackId.isAlwaysOnTop(topStack.mStackId) && topStack != this) {
+                // If the top stack is always on top, we move this stack just below it.
                 addIndex--;
             }
         }
@@ -1071,6 +1070,7 @@
         if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Complete pause: " + prev);
 
         if (prev != null) {
+            final boolean wasStopping = prev.state == ActivityState.STOPPING;
             prev.state = ActivityState.PAUSED;
             if (prev.finishing) {
                 if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Executing finish of activity: " + prev);
@@ -1089,9 +1089,15 @@
                     // the current instance before starting the new one.
                     if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Destroying after pause: " + prev);
                     destroyActivityLocked(prev, true, "pause-config");
+                } else if (wasStopping) {
+                    // We are also stopping, the stop request must have gone soon after the pause.
+                    // We can't clobber it, because the stop confirmation will not be handled.
+                    // We don't need to schedule another stop, we only need to let it happen.
+                    prev.state = ActivityState.STOPPING;
                 } else if (!hasVisibleBehindActivity() || mService.isSleepingOrShuttingDown()) {
                     // If we were visible then resumeTopActivities will release resources before
                     // stopping.
+
                     mStackSupervisor.mStoppingActivities.add(prev);
                     if (mStackSupervisor.mStoppingActivities.size() > 3 ||
                             prev.frontOfTask && mTaskHistory.size() <= 1) {
@@ -1334,6 +1340,11 @@
             return false;
         }
 
+        final boolean isLockscreenShown = mService.mLockScreenShown == LOCK_SCREEN_SHOWN;
+        if (isLockscreenShown && !StackId.isAllowedOverLockscreen(mStackId)) {
+            return false;
+        }
+
         final ActivityStack focusedStack = mStackSupervisor.getFocusedStack();
         final int focusedStackId = focusedStack.mStackId;
 
@@ -1424,16 +1435,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 +1457,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 +1476,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 +1486,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 +1529,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 +1553,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 +1619,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 +1644,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 {
@@ -4641,7 +4653,9 @@
                 voiceInteractor);
         // add the task to stack first, mTaskPositioner might need the stack association
         addTask(task, toTop, false);
-        if (!layoutTaskInStack(task, info.layout) && mBounds != null && task.mResizeable) {
+        final boolean isLockscreenShown = mService.mLockScreenShown == LOCK_SCREEN_SHOWN;
+        if (!layoutTaskInStack(task, info.layout) && mBounds != null && task.mResizeable
+                && !isLockscreenShown) {
             task.updateOverrideConfiguration(mBounds);
         }
         return task;
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/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 1e529dab..4d18e96 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -37,6 +37,7 @@
 import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_TASKS;
 import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
 import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN;
 import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
 import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
 import static com.android.server.am.ActivityRecord.RECENTS_ACTIVITY_TYPE;
@@ -1341,6 +1342,12 @@
     /** Returns the bounds that should be used to launch this task. */
     Rect getLaunchBounds() {
         final int stackId = stack.mStackId;
+
+        // If we're over lockscreen, forget about stack bounds and use fullscreen.
+        if (mService.mLockScreenShown == LOCK_SCREEN_SHOWN) {
+            return null;
+        }
+
         if (stack == null
                 || stackId == HOME_STACK_ID
                 || stackId == FULLSCREEN_WORKSPACE_STACK_ID) {
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/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index ae8fca8..f2d0031 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -212,6 +212,7 @@
     private static native String nativeDump(long ptr);
     private static native void nativeMonitor(long ptr);
     private static native void nativeSetPointerIconShape(long ptr, int iconId);
+    private static native void nativeReloadPointerIcons(long ptr);
 
     // Input event injection constants defined in InputDispatcher.h.
     private static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0;
@@ -311,12 +312,14 @@
 
         registerPointerSpeedSettingObserver();
         registerShowTouchesSettingObserver();
+        registerAccessibilityLargePointerSettingObserver();
 
         mContext.registerReceiver(new BroadcastReceiver() {
             @Override
             public void onReceive(Context context, Intent intent) {
                 updatePointerSpeedFromSettings();
                 updateShowTouchesFromSettings();
+                nativeReloadPointerIcons(mPtr);
             }
         }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
 
@@ -1362,6 +1365,17 @@
                 }, UserHandle.USER_ALL);
     }
 
+    private void registerAccessibilityLargePointerSettingObserver() {
+        mContext.getContentResolver().registerContentObserver(
+                Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON), true,
+                new ContentObserver(mHandler) {
+                    @Override
+                    public void onChange(boolean selfChange) {
+                        nativeReloadPointerIcons(mPtr);
+                    }
+                }, UserHandle.USER_ALL);
+    }
+
     private int getShowTouchesSetting(int defaultValue) {
         int result = defaultValue;
         try {
@@ -1431,11 +1445,11 @@
         }
     }
 
-  // Binder call
-  @Override
-  public void setPointerIconShape(int iconId) {
-      nativeSetPointerIconShape(mPtr, iconId);
-  }
+    // Binder call
+    @Override
+    public void setPointerIconShape(int iconId) {
+        nativeSetPointerIconShape(mPtr, iconId);
+    }
 
     @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
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/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index c2666b8..33f39bc 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1243,6 +1243,20 @@
             return mRankingHelper.getTopicVisibilityOverride(pkg, uid, topic);
         }
 
+        @Override
+        public void setTopicImportance(String pkg, int uid, Notification.Topic topic,
+                int importance) {
+            checkCallerIsSystem();
+            mRankingHelper.setTopicImportance(pkg, uid, topic, importance);
+            savePolicyFile();
+        }
+
+        @Override
+        public int getTopicImportance(String pkg, int uid, Notification.Topic topic) {
+            checkCallerIsSystem();
+            return mRankingHelper.getTopicImportance(pkg, uid, topic);
+        }
+
         /**
          * System-only API for getting a list of current (i.e. not cleared) notifications.
          *
@@ -2201,6 +2215,7 @@
                     }
 
                     mRankingHelper.extractSignals(r);
+                    savePolicyFile();
 
                     // 3. Apply local rules
 
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index 2a7568d..3b7384e 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -23,6 +23,7 @@
 import android.graphics.drawable.Icon;
 import android.media.AudioAttributes;
 import android.os.UserHandle;
+import android.service.notification.NotificationListenerService;
 import android.service.notification.StatusBarNotification;
 
 import com.android.internal.annotations.VisibleForTesting;
@@ -82,6 +83,7 @@
     private int mAuthoritativeRank;
     private String mGlobalSortKey;
     private int mPackageVisibility;
+    private int mTopicImportance = NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
 
     private int mSuppressedVisualEffects = 0;
 
@@ -106,6 +108,7 @@
         mRankingTimeMs = calculateRankingTimeMs(previous.getRankingTimeMs());
         mCreationTimeMs = previous.mCreationTimeMs;
         mVisibleSinceMs = previous.mVisibleSinceMs;
+        mTopicImportance = previous.mTopicImportance;
         // Don't copy mGlobalSortKey, recompute it.
     }
 
@@ -195,6 +198,8 @@
         pw.println(prefix + "  mRecentlyIntrusive=" + mRecentlyIntrusive);
         pw.println(prefix + "  mPackagePriority=" + mPackagePriority);
         pw.println(prefix + "  mPackageVisibility=" + mPackageVisibility);
+        pw.println(prefix + "  mTopicImportance="
+                + NotificationListenerService.Ranking.importanceToString(mTopicImportance));
         pw.println(prefix + "  mIntercept=" + mIntercept);
         pw.println(prefix + "  mGlobalSortKey=" + mGlobalSortKey);
         pw.println(prefix + "  mRankingTimeMs=" + mRankingTimeMs);
@@ -268,6 +273,16 @@
         return mPackageVisibility;
     }
 
+    public void setTopicImportance(int importance) {
+        if (importance != NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED) {
+            mTopicImportance = importance;
+        }
+    }
+
+    public int getTopicImportance() {
+        return mTopicImportance;
+    }
+
     public boolean setIntercepted(boolean intercept) {
         mIntercept = intercept;
         return mIntercept;
diff --git a/services/core/java/com/android/server/notification/RankingConfig.java b/services/core/java/com/android/server/notification/RankingConfig.java
index 7ee29e4..acdd90a 100644
--- a/services/core/java/com/android/server/notification/RankingConfig.java
+++ b/services/core/java/com/android/server/notification/RankingConfig.java
@@ -31,4 +31,8 @@
 
     void setTopicVisibilityOverride(String packageName, int uid, Notification.Topic topic,
             int visibility);
+
+    void setTopicImportance(String packageName, int uid, Notification.Topic topic, int importance);
+
+    int getTopicImportance(String packageName, int uid, Notification.Topic topic);
 }
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 543cd89..5a31c6a 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -23,6 +23,7 @@
 import android.os.Message;
 import android.os.UserHandle;
 import android.service.notification.NotificationListenerService;
+import android.service.notification.NotificationListenerService.Ranking;
 import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.Slog;
@@ -55,12 +56,13 @@
     private static final String ATT_UID = "uid";
     private static final String ATT_PRIORITY = "priority";
     private static final String ATT_VISIBILITY = "visibility";
+    private static final String ATT_IMPORTANCE = "importance";
     private static final String ATT_TOPIC_ID = "id";
     private static final String ATT_TOPIC_LABEL = "label";
 
     private static final int DEFAULT_PRIORITY = Notification.PRIORITY_DEFAULT;
-    private static final int DEFAULT_VISIBILITY =
-            NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE;
+    private static final int DEFAULT_VISIBILITY = Ranking.VISIBILITY_NO_OVERRIDE;
+    private static final int DEFAULT_IMPORTANCE = Ranking.IMPORTANCE_UNSPECIFIED;
 
     private final NotificationSignalExtractor[] mSignalExtractors;
     private final NotificationComparator mPreliminaryComparator = new NotificationComparator();
@@ -197,6 +199,7 @@
             if (TAG_TOPIC.equals(tagName)) {
                 int priority = safeInt(parser, ATT_PRIORITY, DEFAULT_PRIORITY);
                 int vis = safeInt(parser, ATT_VISIBILITY, DEFAULT_VISIBILITY);
+                int importance = safeInt(parser, ATT_IMPORTANCE, DEFAULT_IMPORTANCE);
                 String id = parser.getAttributeValue(null, ATT_TOPIC_ID);
                 CharSequence label = parser.getAttributeValue(null, ATT_TOPIC_LABEL);
 
@@ -209,6 +212,9 @@
                     if (vis != DEFAULT_VISIBILITY) {
                         topic.visibility = vis;
                     }
+                    if (importance != DEFAULT_IMPORTANCE) {
+                        topic.importance = importance;
+                    }
                     r.topics.put(id, topic);
                 }
             }
@@ -267,6 +273,9 @@
             if (t.visibility != DEFAULT_VISIBILITY) {
                 out.attribute(null, ATT_VISIBILITY, Integer.toString(t.visibility));
             }
+            if (t.importance != DEFAULT_IMPORTANCE) {
+                out.attribute(null, ATT_IMPORTANCE, Integer.toString(t.importance));
+            }
             out.endTag(null, TAG_TOPIC);
         }
     }
@@ -403,6 +412,20 @@
         updateConfig();
     }
 
+    @Override
+    public int getTopicImportance(String packageName, int uid, Notification.Topic topic) {
+        final Record r = getOrCreateRecord(packageName, uid);
+        return getOrCreateTopic(r, topic).importance;
+    }
+
+    @Override
+    public void setTopicImportance(String pkgName, int uid, Notification.Topic topic,
+            int importance) {
+        final Record r = getOrCreateRecord(pkgName, uid);
+        getOrCreateTopic(r, topic).importance = importance;
+        updateConfig();
+    }
+
     private Topic getOrCreateTopic(Record r, Notification.Topic topic) {
         if (topic == null) {
             topic = createDefaultTopic();
@@ -468,6 +491,10 @@
                         pw.print(" visibility=");
                         pw.print(Notification.visibilityToString(t.visibility));
                     }
+                    if (t.importance != DEFAULT_IMPORTANCE) {
+                        pw.print(" importance=");
+                        pw.print(Ranking.importanceToString(t.importance));
+                    }
                     pw.println();
                 }
             }
@@ -512,6 +539,7 @@
         Notification.Topic topic;
         int priority = DEFAULT_PRIORITY;
         int visibility = DEFAULT_VISIBILITY;
+        int importance = DEFAULT_IMPORTANCE;
 
         public Topic(Notification.Topic topic) {
             this.topic = topic;
diff --git a/services/core/java/com/android/server/notification/TopicImportanceExtractor.java b/services/core/java/com/android/server/notification/TopicImportanceExtractor.java
new file mode 100644
index 0000000..01770d0
--- /dev/null
+++ b/services/core/java/com/android/server/notification/TopicImportanceExtractor.java
@@ -0,0 +1,56 @@
+/**
+* Copyright (C) 2015 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.android.server.notification;
+
+import android.content.Context;
+import android.util.Slog;
+
+/**
+ * Determines the importance of the given notification.
+ */
+public class TopicImportanceExtractor implements NotificationSignalExtractor {
+    private static final String TAG = "ImportantTopicExtractor";
+    private static final boolean DBG = false;
+
+    private RankingConfig mConfig;
+
+    public void initialize(Context ctx, NotificationUsageStats usageStats) {
+        if (DBG) Slog.d(TAG, "Initializing  " + getClass().getSimpleName() + ".");
+    }
+
+    public RankingReconsideration process(NotificationRecord record) {
+        if (record == null || record.getNotification() == null) {
+            if (DBG) Slog.d(TAG, "skipping empty notification");
+            return null;
+        }
+
+        if (mConfig == null) {
+            if (DBG) Slog.d(TAG, "missing config");
+            return null;
+        }
+
+        final int topicImportance = mConfig.getTopicImportance(record.sbn.getPackageName(),
+                record.sbn.getUid(), record.sbn.getNotification().getTopic());
+        record.setTopicImportance(topicImportance);
+
+        return null;
+    }
+
+    @Override
+    public void setConfig(RankingConfig config) {
+        mConfig = config;
+    }
+}
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/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
index dbb5818..c549b8c 100644
--- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
+++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
@@ -101,6 +101,8 @@
                     return runList();
                 case "uninstall":
                     return runUninstall();
+                case "resolve-activity":
+                    return runResolveActivity();
                 case "query-intent-activities":
                     return runQueryIntentActivities();
                 case "query-intent-services":
@@ -565,6 +567,28 @@
         return intent;
     }
 
+    private int runResolveActivity() {
+        Intent intent;
+        try {
+            intent = parseIntentAndUser();
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+        try {
+            ResolveInfo ri = mInterface.resolveIntent(intent, null, 0, mTargetUser);
+            PrintWriter pw = getOutPrintWriter();
+            if (ri == null) {
+                pw.println("No activity found");
+            } else {
+                PrintWriterPrinter pr = new PrintWriterPrinter(pw);
+                ri.dump(pr, "");
+            }
+        } catch (RemoteException e) {
+            throw new RuntimeException("Failed calling service", e);
+        }
+        return 0;
+    }
+
     private int runQueryIntentActivities() {
         Intent intent;
         try {
@@ -1016,6 +1040,8 @@
         pw.println("      -s: short summary");
         pw.println("      -d: only list dangerous permissions");
         pw.println("      -u: list only the permissions users will see");
+        pw.println("  resolve-intent [--user USER_ID] INTENT");
+        pw.println("    Prints the activity that resolves to the given Intent.");
         pw.println("  query-intent-activities [--user USER_ID] INTENT");
         pw.println("    Prints all activities that can handle the given Intent.");
         pw.println("  query-intent-services [--user USER_ID] INTENT");
diff --git a/services/core/java/com/android/server/policy/BarController.java b/services/core/java/com/android/server/policy/BarController.java
index 051b7fb..0c80ffa 100644
--- a/services/core/java/com/android/server/policy/BarController.java
+++ b/services/core/java/com/android/server/policy/BarController.java
@@ -47,6 +47,7 @@
     private final int mTransientFlag;
     private final int mUnhideFlag;
     private final int mTranslucentFlag;
+    private final int mTransparentFlag;
     private final int mStatusBarManagerId;
     private final int mTranslucentWmFlag;
     protected final Handler mHandler;
@@ -63,13 +64,14 @@
     private boolean mNoAnimationOnNextShow;
 
     public BarController(String tag, int transientFlag, int unhideFlag, int translucentFlag,
-            int statusBarManagerId, int translucentWmFlag) {
+            int statusBarManagerId, int translucentWmFlag, int transparentFlag) {
         mTag = "BarController." + tag;
         mTransientFlag = transientFlag;
         mUnhideFlag = unhideFlag;
         mTranslucentFlag = translucentFlag;
         mStatusBarManagerId = statusBarManagerId;
         mTranslucentWmFlag = translucentWmFlag;
+        mTransparentFlag = transparentFlag;
         mHandler = new Handler();
     }
 
@@ -126,13 +128,13 @@
                     vis &= ~mTranslucentFlag;
                 }
                 if ((fl & WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) {
-                    vis |= View.SYSTEM_UI_TRANSPARENT;
+                    vis |= mTransparentFlag;
                 } else {
-                    vis &= ~View.SYSTEM_UI_TRANSPARENT;
+                    vis &= ~mTransparentFlag;
                 }
             } else {
                 vis = (vis & ~mTranslucentFlag) | (oldVis & mTranslucentFlag);
-                vis = (vis & ~View.SYSTEM_UI_TRANSPARENT) | (oldVis & View.SYSTEM_UI_TRANSPARENT);
+                vis = (vis & ~mTransparentFlag) | (oldVis & mTransparentFlag);
             }
         }
         return vis;
@@ -247,7 +249,7 @@
             }
         }
         if (mShowTransparent) {
-            vis |= View.SYSTEM_UI_TRANSPARENT;
+            vis |= mTransparentFlag;
             if (mSetUnHideFlagWhenNextTransparent) {
                 vis |= mUnhideFlag;
                 mSetUnHideFlagWhenNextTransparent = false;
@@ -258,7 +260,7 @@
             vis &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;  // never show transient bars in low profile
         }
         if ((vis & mTranslucentFlag) != 0 || (oldVis & mTranslucentFlag) != 0 ||
-                ((vis | oldVis) & View.SYSTEM_UI_TRANSPARENT) != 0) {
+                ((vis | oldVis) & mTransparentFlag) != 0) {
             mLastTranslucent = SystemClock.uptimeMillis();
         }
         return vis;
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 2031061..fe427d3 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -209,7 +209,8 @@
             | View.SYSTEM_UI_FLAG_FULLSCREEN
             | View.STATUS_BAR_TRANSLUCENT
             | View.NAVIGATION_BAR_TRANSLUCENT
-            | View.SYSTEM_UI_TRANSPARENT;
+            | View.STATUS_BAR_TRANSPARENT
+            | View.NAVIGATION_BAR_TRANSPARENT;
 
     private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
             .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
@@ -626,6 +627,8 @@
     private final LogDecelerateInterpolator mLogDecelerateInterpolator
             = new LogDecelerateInterpolator(100, 0);
 
+    private boolean mForceWindowDrawsStatusBarBackground;
+
     private static final int MSG_ENABLE_POINTER_LOCATION = 1;
     private static final int MSG_DISABLE_POINTER_LOCATION = 2;
     private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
@@ -806,7 +809,8 @@
             View.NAVIGATION_BAR_UNHIDE,
             View.NAVIGATION_BAR_TRANSLUCENT,
             StatusBarManager.WINDOW_NAVIGATION_BAR,
-            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
+            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
+            View.NAVIGATION_BAR_TRANSPARENT);
 
     private ImmersiveModeConfirmation mImmersiveModeConfirmation;
 
@@ -1587,6 +1591,8 @@
 
         mScreenshotChordEnabled = mContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_enableScreenshotChord);
+        mForceWindowDrawsStatusBarBackground = mContext.getResources().getBoolean(
+                R.bool.config_forceWindowDrawsStatusBarBackground);
 
         mGlobalKeyManager = new GlobalKeyManager(mContext);
 
@@ -2049,10 +2055,14 @@
             attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
         }
 
-        if (ActivityManager.isHighEndGfx()
-                && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) {
-            attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
-                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+        if (ActivityManager.isHighEndGfx()) {
+            if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) {
+                attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+            }
+            if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
+                    || mForceWindowDrawsStatusBarBackground) {
+                attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+            }
         }
     }
 
@@ -3609,7 +3619,7 @@
             final int sysui = mLastSystemUiFlags;
             boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
             boolean navTranslucent = (sysui
-                    & (View.NAVIGATION_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0;
+                    & (View.NAVIGATION_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSPARENT)) != 0;
             boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0;
             boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0;
             boolean navAllowedHidden = immersive || immersiveSticky;
@@ -3677,7 +3687,7 @@
 
             boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0;
             boolean statusBarTranslucent = (sysui
-                    & (View.STATUS_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0;
+                    & (View.STATUS_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSPARENT)) != 0;
             if (!isKeyguardShowing) {
                 statusBarTranslucent &= areTranslucentBarsAllowed();
             }
@@ -4008,7 +4018,8 @@
                         && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0
                         && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0
                         && (fl & WindowManager.LayoutParams.
-                                FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) {
+                                FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0
+                        && !mForceWindowDrawsStatusBarBackground) {
                     // Ensure policy decor includes status bar
                     dcf.top = mStableTop;
                 }
@@ -6733,10 +6744,7 @@
         final boolean freeformStackVisible =
                 mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID);
         final boolean forceShowSystemBars = dockedStackVisible || freeformStackVisible;
-        // TODO(multi-window): Update to force opaque independently for status bar and nav bar.
-        // This will require refactoring the code to have separate vis flag for each bar so it can
-        // be adjusted independently.
-        final boolean forceOpaqueSystemBars = forceShowSystemBars;
+        final boolean forceOpaqueSystemBars = forceShowSystemBars && !mForceStatusBarFromKeyguard;
 
         // apply translucent bar vis flags
         WindowState transWin = isStatusBarKeyguard() && !mHideLockScreen
@@ -6766,6 +6774,11 @@
                     | View.SYSTEM_UI_TRANSPARENT);
         }
 
+        if (mForceWindowDrawsStatusBarBackground) {
+            vis |= View.STATUS_BAR_TRANSPARENT;
+            vis &= ~View.STATUS_BAR_TRANSLUCENT;
+        }
+
         // update status bar
         boolean immersiveSticky =
                 (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0;
diff --git a/services/core/java/com/android/server/policy/StatusBarController.java b/services/core/java/com/android/server/policy/StatusBarController.java
index b935f5a..9d353c6 100644
--- a/services/core/java/com/android/server/policy/StatusBarController.java
+++ b/services/core/java/com/android/server/policy/StatusBarController.java
@@ -111,7 +111,8 @@
                 View.STATUS_BAR_UNHIDE,
                 View.STATUS_BAR_TRANSLUCENT,
                 StatusBarManager.WINDOW_STATUS_BAR,
-                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
+                View.STATUS_BAR_TRANSPARENT);
     }
 
     public AppTransitionListener getAppTransitionListener() {
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 4bbf586..898a9a4 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -237,8 +237,8 @@
     }
 
     void moveStack(TaskStack stack, boolean toTop) {
-        if (stack.mStackId == PINNED_STACK_ID && !toTop) {
-            // Pinned stack is always-on-top silly...
+        if (StackId.isAlwaysOnTop(stack.mStackId) && !toTop) {
+            // This stack is always-on-top silly...
             Slog.w(TAG, "Ignoring move of always-on-top stack=" + stack + " to bottom");
             return;
         }
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/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 611ad40..996fadf 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -692,6 +692,10 @@
     }
 
     boolean isVisibleLocked() {
+        final boolean keyguardOn = mService.mPolicy.isKeyguardShowingOrOccluded();
+        if (keyguardOn && !StackId.isAllowedOverLockscreen(mStackId)) {
+            return false;
+        }
         for (int i = mTasks.size() - 1; i >= 0; i--) {
             Task task = mTasks.get(i);
             for (int j = task.mAppTokens.size() - 1; j >= 0; j--) {
diff --git a/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java b/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java
index 2f890be..af109d4 100644
--- a/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java
+++ b/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java
@@ -109,6 +109,7 @@
                 final int y = (int) motionEvent.getY();
                 final Task task = mDisplayContent.findTaskForControlPoint(x, y);
                 if (task == null) {
+                    mPointerIconShape = STYLE_NOT_SPECIFIED;
                     break;
                 }
                 task.getDimBounds(mTmpRect);
@@ -137,6 +138,7 @@
             } break;
 
             case MotionEvent.ACTION_HOVER_EXIT:
+                mPointerIconShape = STYLE_NOT_SPECIFIED;
                 motionEvent.getDevice().setPointerShape(STYLE_DEFAULT);
                 break;
 
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index f25f1e3..410d810 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -58,6 +58,8 @@
 import android.animation.ValueAnimator;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.app.ActivityManager;
+import android.app.ActivityManager.StackId;
 import android.app.ActivityManagerNative;
 import android.app.AppOpsManager;
 import android.app.IActivityManager;
@@ -8030,7 +8032,7 @@
                 case UPDATE_DOCKED_STACK_DIVIDER: {
                     synchronized (mWindowMap) {
                         getDefaultDisplayContentLocked().getDockedDividerController()
-                                .reevaluateVisibility();
+                                .reevaluateVisibility(false);
                     }
                 }
                 break;
@@ -8652,14 +8654,7 @@
             } else if (wtoken != null) {
                 winAnimator.mAnimLayer =
                         w.mLayer + wtoken.mAppAnimator.animLayerAdjustment;
-                if (wtoken.mWillReplaceWindow && wtoken.mReplacingWindow != w
-                        && wtoken.mAnimateReplacingWindow) {
-                    // We know that we will be animating a relaunching window in the near future,
-                    // which will receive a z-order increase. We want the replaced window to
-                    // immediately receive the same treatment, e.g. to be above the dock divider.
-                    w.mLayer += TYPE_LAYER_OFFSET;
-                    winAnimator.mAnimLayer += TYPE_LAYER_OFFSET;
-                }
+                forceHigherLayerIfNeeded(w, winAnimator, wtoken);
             } else {
                 winAnimator.mAnimLayer = w.mLayer;
             }
@@ -8696,6 +8691,30 @@
         }
     }
 
+    private void forceHigherLayerIfNeeded(WindowState w, WindowStateAnimator winAnimator,
+            AppWindowToken wtoken) {
+        boolean force = false;
+        if (wtoken.mWillReplaceWindow && wtoken.mReplacingWindow != w
+                && wtoken.mAnimateReplacingWindow) {
+            // We know that we will be animating a relaunching window in the near future,
+            // which will receive a z-order increase. We want the replaced window to
+            // immediately receive the same treatment, e.g. to be above the dock divider.
+            force = true;
+        }
+        if (!force) {
+            final TaskStack stack = w.getStack();
+            if (stack != null && StackId.isAlwaysOnTop(stack.mStackId)) {
+                // If the window's stack is always on top, we want to make it above other windows
+                // also when these windows are animating.
+                force = true;
+            }
+        }
+        if (force) {
+            w.mLayer += TYPE_LAYER_OFFSET;
+            winAnimator.mAnimLayer += TYPE_LAYER_OFFSET;
+        }
+    }
+
     void makeWindowFreezingScreenIfNeededLocked(WindowState w) {
         // If the screen is currently frozen or off, then keep
         // it frozen/off until this window draws at its new
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index b5654ee..9c9a5da 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -205,6 +205,7 @@
     void setInteractive(bool interactive);
     void reloadCalibration();
     void setPointerIconShape(int32_t iconId);
+    void reloadPointerIcons();
 
     /* --- InputReaderPolicyInterface implementation --- */
 
@@ -242,6 +243,7 @@
 
     /* --- PointerControllerPolicyInterface implementation --- */
 
+    virtual void loadPointerIcon(SpriteIcon* icon);
     virtual void loadPointerResources(PointerResources* outResources);
     virtual void loadAdditionalMouseResources(std::map<int32_t, SpriteIcon>* outResources,
             std::map<int32_t, PointerAnimation>* outAnimationResources);
@@ -477,22 +479,6 @@
                 v.logicalBottom - v.logicalTop,
                 v.orientation);
 
-        JNIEnv* env = jniEnv();
-        jobject pointerIconObj = env->CallObjectMethod(mServiceObj,
-                gServiceClassInfo.getPointerIcon);
-        if (!checkAndClearExceptionFromCallback(env, "getPointerIcon")) {
-            PointerIcon pointerIcon;
-            status_t status = android_view_PointerIcon_load(env, pointerIconObj,
-                    mContextObj, &pointerIcon);
-            if (!status && !pointerIcon.isNullIcon()) {
-                controller->setPointerIcon(SpriteIcon(pointerIcon.bitmap,
-                        pointerIcon.hotSpotX, pointerIcon.hotSpotY));
-            } else {
-                controller->setPointerIcon(SpriteIcon());
-            }
-            env->DeleteLocalRef(pointerIconObj);
-        }
-
         updateInactivityTimeoutLocked(controller);
     }
     return controller;
@@ -789,12 +775,19 @@
 }
 
 void NativeInputManager::setPointerIconShape(int32_t iconId) {
-  AutoMutex _l(mLock);
-  sp<PointerController> controller = mLocked.pointerController.promote();
-  if (controller != NULL) {
-        // Use 0 (the default icon) for ARROW.
+    AutoMutex _l(mLock);
+    sp<PointerController> controller = mLocked.pointerController.promote();
+    if (controller != NULL) {
         controller->updatePointerShape(iconId);
-  }
+    }
+}
+
+void NativeInputManager::reloadPointerIcons() {
+    AutoMutex _l(mLock);
+    sp<PointerController> controller = mLocked.pointerController.promote();
+    if (controller != NULL) {
+        controller->reloadPointerResources();
+    }
 }
 
 TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
@@ -1036,6 +1029,25 @@
     return result;
 }
 
+void NativeInputManager::loadPointerIcon(SpriteIcon* icon) {
+    JNIEnv* env = jniEnv();
+
+    ScopedLocalRef<jobject> pointerIconObj(env, env->CallObjectMethod(
+            mServiceObj, gServiceClassInfo.getPointerIcon));
+    if (checkAndClearExceptionFromCallback(env, "getPointerIcon")) {
+        return;
+    }
+
+    PointerIcon pointerIcon;
+    status_t status = android_view_PointerIcon_load(env, pointerIconObj.get(),
+                                                    mContextObj, &pointerIcon);
+    if (!status && !pointerIcon.isNullIcon()) {
+        *icon = SpriteIcon(pointerIcon.bitmap, pointerIcon.hotSpotX, pointerIcon.hotSpotY);
+    } else {
+        *icon = SpriteIcon();
+    }
+}
+
 void NativeInputManager::loadPointerResources(PointerResources* outResources) {
     JNIEnv* env = jniEnv();
 
@@ -1420,6 +1432,11 @@
     im->setPointerIconShape(iconId);
 }
 
+static void nativeReloadPointerIcons(JNIEnv* /* env */, jclass /* clazz */, jlong ptr) {
+    NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
+    im->reloadPointerIcons();
+}
+
 // ----------------------------------------------------------------------------
 
 static const JNINativeMethod gInputManagerMethods[] = {
@@ -1480,6 +1497,8 @@
             (void*) nativeMonitor },
     { "nativeSetPointerIconShape", "(JI)V",
             (void*) nativeSetPointerIconShape },
+    { "nativeReloadPointerIcons", "(J)V",
+            (void*) nativeReloadPointerIcons },
 };
 
 #define FIND_CLASS(var, className) \
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/tests/servicestests/src/com/android/server/notification/RankingHelperTest.java b/services/tests/servicestests/src/com/android/server/notification/RankingHelperTest.java
index b40fd068..d0065cd 100644
--- a/services/tests/servicestests/src/com/android/server/notification/RankingHelperTest.java
+++ b/services/tests/servicestests/src/com/android/server/notification/RankingHelperTest.java
@@ -15,10 +15,17 @@
  */
 package com.android.server.notification;
 
+import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
+import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_HIGH;
+import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_LOW;
+import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_MAX;
+import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_NONE;
+
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
 import android.app.Notification;
+import android.os.Handler;
 import android.os.UserHandle;
 import android.service.notification.StatusBarNotification;
 import android.test.AndroidTestCase;
@@ -28,6 +35,7 @@
 
 public class RankingHelperTest extends AndroidTestCase {
     @Mock NotificationUsageStats mUsageStats;
+    @Mock Handler handler;
 
     private Notification mNotiGroupGSortA;
     private Notification mNotiGroupGSortB;
@@ -46,13 +54,15 @@
         MockitoAnnotations.initMocks(this);
         UserHandle user = UserHandle.ALL;
 
-        mHelper = new RankingHelper(getContext(), null, mUsageStats, new String[0]);
+        mHelper = new RankingHelper(getContext(), handler, mUsageStats,
+                new String[] {TopicImportanceExtractor.class.getName()});
 
         mNotiGroupGSortA = new Notification.Builder(getContext())
                 .setContentTitle("A")
                 .setGroup("G")
                 .setSortKey("A")
                 .setWhen(1205)
+                .setTopic(new Notification.Topic("A", "a"))
                 .build();
         mRecordGroupGSortA = new NotificationRecord(new StatusBarNotification(
                 "package", "package", 1, null, 0, 0, 0, mNotiGroupGSortA, user), 0);
@@ -62,6 +72,7 @@
                 .setGroup("G")
                 .setSortKey("B")
                 .setWhen(1200)
+                .setTopic(new Notification.Topic("A", "a"))
                 .build();
         mRecordGroupGSortB = new NotificationRecord(new StatusBarNotification(
                 "package", "package", 1, null, 0, 0, 0, mNotiGroupGSortB, user), 0);
@@ -69,6 +80,7 @@
         mNotiNoGroup = new Notification.Builder(getContext())
                 .setContentTitle("C")
                 .setWhen(1201)
+                .setTopic(new Notification.Topic("C", "c"))
                 .build();
         mRecordNoGroup = new NotificationRecord(new StatusBarNotification(
                 "package", "package", 1, null, 0, 0, 0, mNotiNoGroup, user), 0);
@@ -76,6 +88,7 @@
         mNotiNoGroup2 = new Notification.Builder(getContext())
                 .setContentTitle("D")
                 .setWhen(1202)
+                .setTopic(new Notification.Topic("D", "d"))
                 .build();
         mRecordNoGroup2 = new NotificationRecord(new StatusBarNotification(
                 "package", "package", 1, null, 0, 0, 0, mNotiNoGroup2, user), 0);
@@ -84,6 +97,7 @@
                 .setContentTitle("E")
                 .setWhen(1201)
                 .setSortKey("A")
+                .setTopic(new Notification.Topic("E", "e"))
                 .build();
         mRecordNoGroupSortA = new NotificationRecord(new StatusBarNotification(
                 "package", "package", 1, null, 0, 0, 0, mNotiNoGroupSortA, user), 0);
@@ -138,4 +152,30 @@
         ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>();
         mHelper.sort(notificationList);
     }
+
+    @SmallTest
+    public void testTopicImportanceExtractor() throws Exception {
+        mHelper.setTopicImportance("package", 0, new Notification.Topic("A", "a"),
+                IMPORTANCE_MAX);
+        // There is no B. There never was a b. Moving on...
+        mHelper.setTopicImportance("package", 0, new Notification.Topic("C", "c"),
+                IMPORTANCE_HIGH);
+        mHelper.setTopicImportance("package", 0, new Notification.Topic("D", "d"),
+                IMPORTANCE_LOW);
+        // watch out: different package.
+        mHelper.setTopicImportance("package2", 0, new Notification.Topic("E", "e"),
+                IMPORTANCE_NONE);
+
+        TopicImportanceExtractor validator = mHelper.findExtractor(TopicImportanceExtractor.class);
+        validator.process(mRecordGroupGSortA);
+        validator.process(mRecordGroupGSortB);
+        validator.process(mRecordNoGroup);
+        validator.process(mRecordNoGroup2);
+        validator.process(mRecordNoGroupSortA);
+        assertTrue(mRecordGroupGSortA.getTopicImportance() == IMPORTANCE_MAX);
+        assertTrue(mRecordGroupGSortB.getTopicImportance() == IMPORTANCE_MAX);
+        assertTrue(mRecordNoGroup.getTopicImportance() == IMPORTANCE_HIGH);
+        assertTrue(mRecordNoGroup2.getTopicImportance() == IMPORTANCE_LOW);
+        assertTrue(mRecordNoGroupSortA.getTopicImportance() == IMPORTANCE_UNSPECIFIED);
+    }
 }
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/telecomm/java/android/telecom/VideoCallImpl.java b/telecomm/java/android/telecom/VideoCallImpl.java
index c8072d1..93484cd 100644
--- a/telecomm/java/android/telecom/VideoCallImpl.java
+++ b/telecomm/java/android/telecom/VideoCallImpl.java
@@ -57,13 +57,20 @@
     private final class VideoCallListenerBinder extends IVideoCallback.Stub {
         @Override
         public void receiveSessionModifyRequest(VideoProfile videoProfile) {
+            if (mHandler == null) {
+                return;
+            }
             mHandler.obtainMessage(MessageHandler.MSG_RECEIVE_SESSION_MODIFY_REQUEST,
                     videoProfile).sendToTarget();
+
         }
 
         @Override
         public void receiveSessionModifyResponse(int status, VideoProfile requestProfile,
                 VideoProfile responseProfile) {
+            if (mHandler == null) {
+                return;
+            }
             SomeArgs args = SomeArgs.obtain();
             args.arg1 = status;
             args.arg2 = requestProfile;
@@ -74,12 +81,18 @@
 
         @Override
         public void handleCallSessionEvent(int event) {
+            if (mHandler == null) {
+                return;
+            }
             mHandler.obtainMessage(MessageHandler.MSG_HANDLE_CALL_SESSION_EVENT, event)
                     .sendToTarget();
         }
 
         @Override
         public void changePeerDimensions(int width, int height) {
+            if (mHandler == null) {
+                return;
+            }
             SomeArgs args = SomeArgs.obtain();
             args.arg1 = width;
             args.arg2 = height;
@@ -88,18 +101,27 @@
 
         @Override
         public void changeVideoQuality(int videoQuality) {
+            if (mHandler == null) {
+                return;
+            }
             mHandler.obtainMessage(MessageHandler.MSG_CHANGE_VIDEO_QUALITY, videoQuality, 0)
                     .sendToTarget();
         }
 
         @Override
         public void changeCallDataUsage(long dataUsage) {
+            if (mHandler == null) {
+                return;
+            }
             mHandler.obtainMessage(MessageHandler.MSG_CHANGE_CALL_DATA_USAGE, dataUsage)
                     .sendToTarget();
         }
 
         @Override
         public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
+            if (mHandler == null) {
+                return;
+            }
             mHandler.obtainMessage(MessageHandler.MSG_CHANGE_CAMERA_CAPABILITIES,
                     cameraCapabilities).sendToTarget();
         }
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 8ebef32..c7f3d0a 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -524,6 +524,30 @@
     public static final String KEY_ALLOW_NON_EMERGENCY_CALLS_IN_ECM_BOOL =
             "allow_non_emergency_calls_in_ecm_bool";
 
+    /**
+     * Flag indicating whether to allow carrier video calls to emergency numbers.
+     * When {@code true}, video calls to emergency numbers will be allowed.  When {@code false},
+     * video calls to emergency numbers will be initiated as audio-only calls instead.
+     *
+     * @hide
+     */
+    @SystemApi
+    public static final String BOOL_ALLOW_EMERGENCY_VIDEO_CALLS =
+            "bool_allow_emergency_video_calls";
+
+    /**
+     * Flag indicating whether the carrier supports video pause signaling.  When {@code true}, the
+     * carrier supports use of the {@link android.telecom.VideoProfile#STATE_PAUSED} video state
+     * to pause transmission of video when the In-Call app is sent to the background.
+     * When {@code false}, video pause signaling is not supported.  {@code True} by default unless
+     * a carrier configuration overrides the default.
+     *
+     * @hide
+     */
+    @SystemApi
+    public static final String BOOL_ALLOW_VIDEO_PAUSE =
+            "bool_allow_video_pause";
+
     /** The default value for every variable. */
     private final static PersistableBundle sDefaults;
 
@@ -596,6 +620,8 @@
         sDefaults.putBoolean(KEY_EDITABLE_ENHANCED_4G_LTE_BOOL, true);
         sDefaults.putBoolean(KEY_HIDE_IMS_APN_BOOL, false);
         sDefaults.putBoolean(KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL, false);
+        sDefaults.putBoolean(BOOL_ALLOW_EMERGENCY_VIDEO_CALLS, false);
+        sDefaults.putBoolean(BOOL_ALLOW_VIDEO_PAUSE, true);
 
         // MMS defaults
         sDefaults.putBoolean(KEY_MMS_ALIAS_ENABLED_BOOL, false);
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
      */
diff --git a/telephony/java/com/android/ims/ImsStreamMediaProfile.java b/telephony/java/com/android/ims/ImsStreamMediaProfile.java
index 359b270..5a99212 100644
--- a/telephony/java/com/android/ims/ImsStreamMediaProfile.java
+++ b/telephony/java/com/android/ims/ImsStreamMediaProfile.java
@@ -76,7 +76,7 @@
     }
 
     public ImsStreamMediaProfile() {
-        mAudioQuality = AUDIO_QUALITY_AMR_WB;
+        mAudioQuality = AUDIO_QUALITY_NONE;
         mAudioDirection = DIRECTION_SEND_RECEIVE;
         mVideoQuality = VIDEO_QUALITY_NONE;
         mVideoDirection = DIRECTION_INVALID;
diff --git a/tools/aapt/pseudolocalize.h b/tools/aapt/pseudolocalize.h
index 71b974b..1faecd1 100644
--- a/tools/aapt/pseudolocalize.h
+++ b/tools/aapt/pseudolocalize.h
@@ -1,7 +1,7 @@
 #ifndef HOST_PSEUDOLOCALIZE_H
 #define HOST_PSEUDOLOCALIZE_H
 
-#include <base/macros.h>
+#include <android-base/macros.h>
 #include "StringPool.h"
 
 class PseudoMethodImpl {
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 3fb9667..7a5a74f 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -188,6 +188,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final String WIFI_AP_STATE_CHANGED_ACTION =
         "android.net.wifi.WIFI_AP_STATE_CHANGED";
 
@@ -204,6 +205,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final String EXTRA_WIFI_AP_STATE = "wifi_state";
 
     /**
@@ -222,6 +224,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final String EXTRA_PREVIOUS_WIFI_AP_STATE = "previous_wifi_state";
     /**
      * Wi-Fi AP is currently being disabled. The state will change to
@@ -232,6 +235,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final int WIFI_AP_STATE_DISABLING = 10;
     /**
      * Wi-Fi AP is disabled.
@@ -241,6 +245,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final int WIFI_AP_STATE_DISABLED = 11;
     /**
      * Wi-Fi AP is currently being enabled. The state will change to
@@ -251,6 +256,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final int WIFI_AP_STATE_ENABLING = 12;
     /**
      * Wi-Fi AP is enabled.
@@ -260,6 +266,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final int WIFI_AP_STATE_ENABLED = 13;
     /**
      * Wi-Fi AP is in a failed state. This state will occur when an error occurs during
@@ -270,6 +277,7 @@
      *
      * @hide
      */
+    @SystemApi
     public static final int WIFI_AP_STATE_FAILED = 14;
 
     /**