Merge "Use the fast track calculation for apps."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 382e362..4b8ee88 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -83,7 +83,7 @@
     <uses-permission android:name="android.permission.DELETE_PACKAGES"/>
 
     <application android:label="@string/settings_label"
-            android:icon="@drawable/ic_launcher_settings"
+            android:icon="@mipmap/ic_launcher_settings"
             android:taskAffinity=""
             android:theme="@style/Theme.Settings"
             android:hardwareAccelerated="true"
diff --git a/res/drawable/ic_launcher_settings.xml b/res/drawable/ic_launcher_settings.xml
deleted file mode 100644
index fc63648..0000000
--- a/res/drawable/ic_launcher_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<maskable-icon xmlns:android="http://schemas.android.com/apk/res/android">
-    <background android:color="?android:attr/colorAccent"/>
-    <foreground android:drawable="@mipmap/ic_launcher_settings"/>
-</maskable-icon>
\ No newline at end of file
diff --git a/res/mipmap-hdpi/ic_launcher_settings.png b/res/mipmap-hdpi/ic_launcher_settings.png
index ddce98e..252e6b4 100644
--- a/res/mipmap-hdpi/ic_launcher_settings.png
+++ b/res/mipmap-hdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_settings.png b/res/mipmap-mdpi/ic_launcher_settings.png
index 86f3be8..d2ecee9 100644
--- a/res/mipmap-mdpi/ic_launcher_settings.png
+++ b/res/mipmap-mdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_launcher_settings.png b/res/mipmap-xhdpi/ic_launcher_settings.png
index 360aa69..fa8c813 100644
--- a/res/mipmap-xhdpi/ic_launcher_settings.png
+++ b/res/mipmap-xhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/mipmap-xxhdpi/ic_launcher_settings.png b/res/mipmap-xxhdpi/ic_launcher_settings.png
index 7cb67a9..3fa69e9 100644
--- a/res/mipmap-xxhdpi/ic_launcher_settings.png
+++ b/res/mipmap-xxhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/mipmap-xxxhdpi/ic_launcher_settings.png b/res/mipmap-xxxhdpi/ic_launcher_settings.png
index 3fec9c4..72946b7 100644
--- a/res/mipmap-xxxhdpi/ic_launcher_settings.png
+++ b/res/mipmap-xxxhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 34f3c51..da10faf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1209,9 +1209,9 @@
     <string name="lock_profile_wipe_dismiss">Dismiss</string>
 
     <!-- Hint shown in dialog screen when password is too short -->
-    <string name="lockpassword_password_too_short">Must be at least %d characters</string>
+    <string name="lockpassword_password_too_short">Must be at least <xliff:g id="count" example="3">%d</xliff:g> characters</string>
     <!-- Hint shown in dialog screen when PIN is too short -->
-    <string name="lockpassword_pin_too_short">PIN must be at least %d digits</string>
+    <string name="lockpassword_pin_too_short">PIN must be at least <xliff:g id="count" example="3">%d</xliff:g> digits</string>
 
     <!-- Hint shown after minimum password criteria is met -->
     <string name="lockpassword_continue_label">Continue</string>
@@ -1242,37 +1242,37 @@
     <!-- Error shown when in PASSWORD mode and password doesn't contain the required number of letters -->
     <plurals name="lockpassword_password_requires_letters">
         <item quantity="one">Must contain at least 1 letter</item>
-        <item quantity="other">Must contain at least %d letters</item>
+        <item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> letters</item>
     </plurals>
 
     <!-- Error shown when in PASSWORD mode and password doesn't contain the required number of lowercase letters -->
     <plurals name="lockpassword_password_requires_lowercase">
         <item quantity="one">Must contain at least 1 lowercase letter</item>
-        <item quantity="other">Must contain at least %d lowercase letters</item>
+        <item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> lowercase letters</item>
     </plurals>
 
     <!-- Error shown when in PASSWORD mode and password doesn't contain the required number of uppercase letters -->
     <plurals name="lockpassword_password_requires_uppercase">
         <item quantity="one">Must contain at least 1 uppercase letter</item>
-        <item quantity="other">Must contain at least %d uppercase letters</item>
+        <item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> uppercase letters</item>
     </plurals>
 
     <!-- Error shown when in PASSWORD mode and password doesn't contain the required number of numerical digits -->
     <plurals name="lockpassword_password_requires_numeric">
         <item quantity="one">Must contain at least 1 numerical digit</item>
-        <item quantity="other">Must contain at least %d numerical digits</item>
+        <item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> numerical digits</item>
     </plurals>
 
     <!-- Error shown when in PASSWORD mode and password doesn't contain the required number of special symbols -->
     <plurals name="lockpassword_password_requires_symbols">
         <item quantity="one">Must contain at least 1 special symbol</item>
-        <item quantity="other">Must contain at least %d special symbols</item>
+        <item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> special symbols</item>
     </plurals>
 
     <!-- Error shown when in PASSWORD mode and password doesn't contain the required number of non-letter characters -->
     <plurals name="lockpassword_password_requires_nonletter">
         <item quantity="one">Must contain at least 1 non-letter character</item>
-        <item quantity="other">Must contain at least %d non-letter characters</item>
+        <item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> non-letter characters</item>
     </plurals>
 
     <!-- Error shown when in PASSWORD mode and password has been used recently. Please keep this string short! -->
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 66c9140..ad5315d 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -17,12 +17,10 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
         android:title="@string/wifi_configure_titlebar">
 
-    <!-- android:dependency="enable_wifi" -->
-    <ListPreference
-        android:key="sleep_policy"
-        android:title="@string/wifi_setting_sleep_policy_title"
-        android:entries="@array/wifi_sleep_policy_entries"
-        android:entryValues="@array/wifi_sleep_policy_values" />
+    <SwitchPreference
+            android:key="enable_wifi_wakeup"
+            android:title="@string/wifi_wakeup"
+            android:summary="@string/wifi_wakeup_summary" />
 
     <SwitchPreference
       android:key="allow_recommendations"
@@ -35,22 +33,15 @@
         android:summary="@string/wifi_notify_open_networks_summary" />
 
     <SwitchPreference
-        android:key="enable_wifi_wakeup"
-        android:title="@string/wifi_wakeup"
-        android:summary="@string/wifi_wakeup_summary" />
-
-    <SwitchPreference
         android:key="wifi_cellular_data_fallback"
         android:title="@string/wifi_cellular_data_fallback_title"
         android:summary="@string/wifi_cellular_data_fallback_summary"/>
 
-    <Preference
-        android:key="mac_address"
-        android:title="@string/wifi_advanced_mac_address_title"/>
-
-    <Preference
-        android:key="current_ip_address"
-        android:title="@string/wifi_advanced_ip_address_title"/>
+    <ListPreference
+            android:key="sleep_policy"
+            android:title="@string/wifi_setting_sleep_policy_title"
+            android:entries="@array/wifi_sleep_policy_entries"
+            android:entryValues="@array/wifi_sleep_policy_values" />
 
     <Preference
             android:key="install_credentials"
@@ -77,4 +68,12 @@
             android:key="wps_pin_entry"
             android:title="@string/wifi_menu_wps_pin" />
 
+    <Preference
+            android:key="mac_address"
+            android:title="@string/wifi_advanced_mac_address_title"/>
+
+    <Preference
+            android:key="current_ip_address"
+            android:title="@string/wifi_advanced_ip_address_title"/>
+
 </PreferenceScreen>
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index abf0154..dc7b7aa 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -1434,7 +1434,7 @@
         Settings.Global.putInt(getActivity().getContentResolver(),
                 Settings.Global.DEVELOPMENT_FORCE_RTL, value ? 1 : 0);
         SystemProperties.set(Settings.Global.DEVELOPMENT_FORCE_RTL, value ? "1" : "0");
-        LocalePicker.updateLocale(getActivity().getResources().getConfiguration().locale);
+        LocalePicker.updateLocales(getActivity().getResources().getConfiguration().getLocales());
     }
 
     private void updateWifiDisplayCertificationOptions() {
@@ -1805,9 +1805,11 @@
         synchronized (mBluetoothA2dpLock) {
             if (mBluetoothA2dp != null) {
                 codecStatus = mBluetoothA2dp.getCodecStatus();
-                codecConfig = codecStatus.getCodecConfig();
-                codecsLocalCapabilities = codecStatus.getCodecsLocalCapabilities();
-                codecsSelectableCapabilities = codecStatus.getCodecsSelectableCapabilities();
+                if (codecStatus != null) {
+                    codecConfig = codecStatus.getCodecConfig();
+                    codecsLocalCapabilities = codecStatus.getCodecsLocalCapabilities();
+                    codecsSelectableCapabilities = codecStatus.getCodecsSelectableCapabilities();
+                }
             }
         }
         if (codecConfig == null)
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 443ce34..97f36c3 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -1139,6 +1139,9 @@
         public void onPackageSizeChanged(String packageName) {
             for (int i = 0; i < mActive.size(); i++) {
                 AppViewHolder holder = (AppViewHolder) mActive.get(i).getTag();
+                if (holder == null) {
+                    continue;
+                }
                 ApplicationInfo info = holder.entry.info;
                 if (info == null) {
                     continue;
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
index 6a0bdcf..5ada965 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
@@ -148,6 +148,20 @@
         editor.apply();
     }
 
+    static void persistDiscoveringTimestamp(final Context context) {
+        // Load the shared preferences and edit it on a background
+        // thread (but serialized!).
+        QueuedWork.queue(new Runnable() {
+                public void run() {
+                    SharedPreferences.Editor editor = getSharedPreferences(context).edit();
+                    editor.putLong(
+                            KEY_DISCOVERING_TIMESTAMP,
+                        System.currentTimeMillis());
+                    editor.apply();
+                }
+            }, false);
+    }
+
     static boolean hasDockAutoConnectSetting(Context context, String addr) {
         return getSharedPreferences(context).contains(KEY_DOCK_AUTO_CONNECT + addr);
     }
diff --git a/src/com/android/settings/wifi/ConfigureWifiSettings.java b/src/com/android/settings/wifi/ConfigureWifiSettings.java
index 5fd3eeb..2b4743f 100644
--- a/src/com/android/settings/wifi/ConfigureWifiSettings.java
+++ b/src/com/android/settings/wifi/ConfigureWifiSettings.java
@@ -50,6 +50,12 @@
     }
 
     @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        mProgressiveDisclosureMixin.setTileLimit(5);
+    }
+
+    @Override
     protected int getPreferenceScreenResId() {
         return R.xml.wifi_configure_settings;
     }
diff --git a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
index 419fd00..acfd400 100644
--- a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
@@ -193,6 +193,30 @@
         verify(preference).setSummary(anyString());
     }
 
+    @Test
+    public void onResume_availableButLocked_shouldRedactPreferences() {
+        final String notAvailable = "(not available)";
+        when(mContext.getString(R.string.managed_profile_not_available_label))
+                .thenReturn(notAvailable);
+
+        // Given a device with a managed profile:
+        when(mAudioHelper.isSingleVolume()).thenReturn(false);
+        when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+        when(mAudioHelper.createPackageContextAsUser(anyInt())).thenReturn(mContext);
+        when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
+                .thenReturn(UserHandle.myUserId());
+        when(mAudioHelper.isUserUnlocked(any(UserManager.class), anyInt())).thenReturn(false);
+        mockWorkCategory();
+
+        // When resumed:
+        mController.onResume();
+
+        // Sound preferences should explain that the profile isn't available yet.
+        verify(mScreen.findPreference(KEY_WORK_PHONE_RINGTONE)).setSummary(eq(notAvailable));
+        verify(mScreen.findPreference(KEY_WORK_NOTIFICATION_RINGTONE)).setSummary(eq(notAvailable));
+        verify(mScreen.findPreference(KEY_WORK_ALARM_RINGTONE)).setSummary(eq(notAvailable));
+    }
+
     private void mockWorkCategory() {
         when(mScreen.findPreference(KEY_WORK_CATEGORY))
             .thenReturn(mock(PreferenceGroup.class));