Merge "Expose "default tts locale" to the TTS V2 API."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7810466..c8362f0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -130,8 +130,7 @@
         <activity android:name="Settings$WifiSettingsActivity"
                 android:taskAffinity=""
                 android:label="@string/wifi_settings"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:excludeFromRecents="true">
+                android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.WIFI_SETTINGS" />
@@ -270,8 +269,7 @@
 
         <activity android:name="Settings$BluetoothSettingsActivity"
                 android:label="@string/bluetooth_settings_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.BLUETOOTH_SETTINGS" />
@@ -309,8 +307,7 @@
 
         <activity android:name="Settings$TetherSettingsActivity"
                 android:label="@string/tether_settings_title_all"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -352,8 +349,7 @@
 
         <activity android:name="Settings$VpnSettingsActivity"
                 android:label="@string/vpn_settings_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.net.vpn.SETTINGS" />
@@ -369,8 +365,7 @@
 
         <activity android:name="Settings$DateTimeSettingsActivity"
                 android:label="@string/date_and_time"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.DATE_SETTINGS" />
@@ -527,8 +522,7 @@
         <activity android:name="Settings$ZenModeSettingsActivity"
                 android:label="@string/zen_mode_settings_title"
                 android:exported="true"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.ZEN_MODE_SETTINGS" />
@@ -543,8 +537,7 @@
 
         <activity android:name="Settings$DisplaySettingsActivity"
                 android:label="@string/display_settings"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="com.android.settings.DISPLAY_SETTINGS" />
@@ -608,8 +601,7 @@
 
         <activity android:name="Settings$ManageApplicationsActivity"
                 android:label="@string/applications_settings"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.APPLICATION_SETTINGS" />
@@ -737,8 +729,7 @@
         <activity android:name="Settings$NotificationStationActivity"
                 android:theme="@android:style/Theme.DeviceDefault"
                 android:label="@string/notification_log_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -752,7 +743,6 @@
         <activity android:name="Settings$AppOpsSummaryActivity"
                 android:label="@string/app_ops_settings"
                 android:taskAffinity=""
-                android:excludeFromRecents="true"
                 android:enabled="false">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -771,8 +761,7 @@
         <activity android:name="Settings$LocationSettingsActivity"
                 android:label="@string/location_settings_title"
                 android:configChanges="orientation|keyboardHidden|screenSize"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
@@ -807,8 +796,7 @@
         <activity android:name="MonitoringCertInfoActivity"
                 android:label="@string/ssl_ca_cert_dialog_title"
                 android:theme="@style/Transparent"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="com.android.settings.MONITORING_CERT_INFO" />
@@ -818,8 +806,7 @@
 
         <activity android:name="Settings$TrustedCredentialsSettingsActivity"
                 android:label="@string/trusted_credentials"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="com.android.settings.TRUSTED_CREDENTIALS" />
@@ -930,8 +917,7 @@
         <activity android:name="Settings$AccessibilitySettingsActivity"
                 android:label="@string/accessibility_settings"
                 android:configChanges="orientation|keyboardHidden|screenSize"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.ACCESSIBILITY_SETTINGS" />
@@ -1308,8 +1294,7 @@
 
         <activity android:name="Settings$WifiDisplaySettingsActivity"
                 android:label="@string/wifi_display_settings_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.WIFI_DISPLAY_SETTINGS" />
@@ -1437,8 +1422,7 @@
 
         <activity android:name="Settings$PowerUsageSummaryActivity"
                 android:label="@string/power_usage_summary_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.intent.action.POWER_USAGE_SUMMARY" />
@@ -1462,6 +1446,21 @@
                 android:resource="@id/battery_settings" />
         </activity-alias>
 
+        <activity android:name="Settings$BatterySaverSettingsActivity"
+                android:label="@string/battery_saver"
+                android:taskAffinity="">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <action android:name="android.settings.BATTERY_SAVER_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="com.android.settings.SHORTCUT" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                android:value="com.android.settings.fuelgauge.BatterySaverSettings" />
+            <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
+                android:resource="@id/battery_settings" />
+        </activity>
+
         <activity android:name="Settings$AccountSyncSettingsActivity"
             android:label="@string/account_sync_settings_title"
             android:taskAffinity=""
@@ -1512,7 +1511,7 @@
                   android:immersive="true"
                   android:launchMode="singleTop"
                   android:excludeFromRecents="true"
-                  android:theme="@android:style/Theme.Material.Light.NoActionBar"
+                  android:theme="@style/Theme.CryptKeeper"
                   android:configChanges="keyboard|keyboardHidden|uiMode"
                   android:windowSoftInputMode="adjustResize"
                   android:screenOrientation="nosensor">
@@ -1551,8 +1550,7 @@
 
         <activity android:name="Settings$DataUsageSummaryActivity"
                 android:label="@string/data_usage_summary_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1566,8 +1564,7 @@
 
         <activity android:name="Settings$DreamSettingsActivity"
                 android:label="@string/screensaver_settings_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.DREAM_SETTINGS" />
@@ -1582,8 +1579,7 @@
 
         <activity android:name="Settings$UserSettingsActivity"
                 android:label="@string/user_settings_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.USER_SETTINGS" />
@@ -1597,8 +1593,7 @@
 
         <activity android:name="Settings$PaymentSettingsActivity"
                 android:label="@string/nfc_payment_settings_title"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.NFC_PAYMENT_SETTINGS" />
@@ -1641,8 +1636,7 @@
 
         <activity android:name="Settings$NotificationAccessSettingsActivity"
                   android:label="@string/manage_notification_access"
-                  android:taskAffinity=""
-                  android:excludeFromRecents="true">
+                  android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
@@ -1656,8 +1650,7 @@
 
         <activity android:name="Settings$ConditionProviderSettingsActivity"
                   android:label="@string/manage_condition_providers"
-                  android:taskAffinity=""
-                  android:excludeFromRecents="true">
+                  android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS" />
@@ -1672,8 +1665,7 @@
         <activity android:name="Settings$NotificationSettingsActivity"
                 android:label="@string/notification_settings"
                 android:exported="true"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.NOTIFICATION_SETTINGS" />
@@ -1690,7 +1682,6 @@
         <activity-alias android:name="Settings$SoundSettingsActivity"
                 android:label="@string/notification_settings"
                 android:taskAffinity=""
-                android:excludeFromRecents="true"
                 android:targetActivity="Settings$NotificationSettingsActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -1719,8 +1710,7 @@
         <activity android:name="Settings$NotificationDisplaySettingsActivity"
                 android:label="@string/notification_display_settings"
                 android:exported="true"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.ACTION_NOTIFICATION_DISPLAY_SETTINGS" />
@@ -1735,8 +1725,7 @@
         <activity android:name="Settings$OtherSoundSettingsActivity"
                 android:label="@string/other_sound_settings"
                 android:exported="true"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.ACTION_OTHER_SOUND_SETTINGS" />
@@ -1751,8 +1740,7 @@
         <activity android:name="Settings$AppNotificationSettingsActivity"
                 android:label="@string/app_notifications_title"
                 android:exported="true"
-                android:taskAffinity=""
-                android:excludeFromRecents="true">
+                android:taskAffinity="">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.ACTION_APP_NOTIFICATION_SETTINGS" />
@@ -1768,7 +1756,6 @@
         <activity android:name="RegulatoryInfoDisplayActivity"
                   android:label="@string/regulatory_information"
                   android:taskAffinity=""
-                  android:excludeFromRecents="true"
                   android:enabled="@bool/config_show_regulatory_info">
             <intent-filter>
                 <action android:name="android.settings.SHOW_REGULATORY_INFO" />
diff --git a/res/drawable-hdpi/ic_power_system.png b/res/drawable-hdpi/ic_power_system.png
index 5e7cf99..3592466 100644
--- a/res/drawable-hdpi/ic_power_system.png
+++ b/res/drawable-hdpi/ic_power_system.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_search_history.png b/res/drawable-hdpi/ic_search_history.png
new file mode 100644
index 0000000..eaef70c
--- /dev/null
+++ b/res/drawable-hdpi/ic_search_history.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_settings_cell_standby.png b/res/drawable-hdpi/ic_settings_cell_standby.png
index 262a860..7d51c80 100644
--- a/res/drawable-hdpi/ic_settings_cell_standby.png
+++ b/res/drawable-hdpi/ic_settings_cell_standby.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_settings_language.png b/res/drawable-hdpi/ic_settings_language.png
index bf641aa..e27035a 100644
--- a/res/drawable-hdpi/ic_settings_language.png
+++ b/res/drawable-hdpi/ic_settings_language.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_settings_more.png b/res/drawable-hdpi/ic_settings_more.png
index e9b6309..61bb00c 100644
--- a/res/drawable-hdpi/ic_settings_more.png
+++ b/res/drawable-hdpi/ic_settings_more.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_settings_phone_idle.png b/res/drawable-hdpi/ic_settings_phone_idle.png
index fd66f84..6ae7f5e 100644
--- a/res/drawable-hdpi/ic_settings_phone_idle.png
+++ b/res/drawable-hdpi/ic_settings_phone_idle.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_settings_voice_calls.png b/res/drawable-hdpi/ic_settings_voice_calls.png
index 3cb7e49..b3cefda 100644
--- a/res/drawable-hdpi/ic_settings_voice_calls.png
+++ b/res/drawable-hdpi/ic_settings_voice_calls.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sync_anim_holo.png b/res/drawable-hdpi/ic_sync_anim_holo.png
index bc8dc58..4a0ddfa 100644
--- a/res/drawable-hdpi/ic_sync_anim_holo.png
+++ b/res/drawable-hdpi/ic_sync_anim_holo.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sync_error_holo.png b/res/drawable-hdpi/ic_sync_error_holo.png
index 3e34bd0..ab3c34f 100644
--- a/res/drawable-hdpi/ic_sync_error_holo.png
+++ b/res/drawable-hdpi/ic_sync_error_holo.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sync_green_holo.png b/res/drawable-hdpi/ic_sync_green_holo.png
index 2588f3d..692289a 100644
--- a/res/drawable-hdpi/ic_sync_green_holo.png
+++ b/res/drawable-hdpi/ic_sync_green_holo.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sync_grey_holo.png b/res/drawable-hdpi/ic_sync_grey_holo.png
index 4c7060d..6f86d13 100644
--- a/res/drawable-hdpi/ic_sync_grey_holo.png
+++ b/res/drawable-hdpi/ic_sync_grey_holo.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sync_red_holo.png b/res/drawable-hdpi/ic_sync_red_holo.png
index b65520d..7b21b14 100644
--- a/res/drawable-hdpi/ic_sync_red_holo.png
+++ b/res/drawable-hdpi/ic_sync_red_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_power_system.png b/res/drawable-mdpi/ic_power_system.png
old mode 100755
new mode 100644
index cce5187..f9813d9
--- a/res/drawable-mdpi/ic_power_system.png
+++ b/res/drawable-mdpi/ic_power_system.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_search_history.png b/res/drawable-mdpi/ic_search_history.png
new file mode 100644
index 0000000..fd6755f
--- /dev/null
+++ b/res/drawable-mdpi/ic_search_history.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_settings_cell_standby.png b/res/drawable-mdpi/ic_settings_cell_standby.png
index 0ac7b5d..c922222 100644
--- a/res/drawable-mdpi/ic_settings_cell_standby.png
+++ b/res/drawable-mdpi/ic_settings_cell_standby.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_settings_language.png b/res/drawable-mdpi/ic_settings_language.png
index a6dba3c..604a710 100644
--- a/res/drawable-mdpi/ic_settings_language.png
+++ b/res/drawable-mdpi/ic_settings_language.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_settings_more.png b/res/drawable-mdpi/ic_settings_more.png
index 8619833..bad02c8 100644
--- a/res/drawable-mdpi/ic_settings_more.png
+++ b/res/drawable-mdpi/ic_settings_more.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_settings_phone_idle.png b/res/drawable-mdpi/ic_settings_phone_idle.png
index 7734b09..92b4b0a 100644
--- a/res/drawable-mdpi/ic_settings_phone_idle.png
+++ b/res/drawable-mdpi/ic_settings_phone_idle.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_settings_voice_calls.png b/res/drawable-mdpi/ic_settings_voice_calls.png
index 89d04d7..9277295 100644
--- a/res/drawable-mdpi/ic_settings_voice_calls.png
+++ b/res/drawable-mdpi/ic_settings_voice_calls.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sync_anim_holo.png b/res/drawable-mdpi/ic_sync_anim_holo.png
index 66db062..f9affbd 100644
--- a/res/drawable-mdpi/ic_sync_anim_holo.png
+++ b/res/drawable-mdpi/ic_sync_anim_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sync_error_holo.png b/res/drawable-mdpi/ic_sync_error_holo.png
index dd3958e..06f638a 100644
--- a/res/drawable-mdpi/ic_sync_error_holo.png
+++ b/res/drawable-mdpi/ic_sync_error_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sync_green_holo.png b/res/drawable-mdpi/ic_sync_green_holo.png
index 1c981b66..dd15bf9 100644
--- a/res/drawable-mdpi/ic_sync_green_holo.png
+++ b/res/drawable-mdpi/ic_sync_green_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sync_grey_holo.png b/res/drawable-mdpi/ic_sync_grey_holo.png
index bb4267f..b6afc12 100644
--- a/res/drawable-mdpi/ic_sync_grey_holo.png
+++ b/res/drawable-mdpi/ic_sync_grey_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sync_red_holo.png b/res/drawable-mdpi/ic_sync_red_holo.png
index 36fe6b8..3bb9980 100644
--- a/res/drawable-mdpi/ic_sync_red_holo.png
+++ b/res/drawable-mdpi/ic_sync_red_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_power_system.png b/res/drawable-xhdpi/ic_power_system.png
index 9a360f7..8671616 100644
--- a/res/drawable-xhdpi/ic_power_system.png
+++ b/res/drawable-xhdpi/ic_power_system.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_search_history.png b/res/drawable-xhdpi/ic_search_history.png
new file mode 100644
index 0000000..7183fc2
--- /dev/null
+++ b/res/drawable-xhdpi/ic_search_history.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_settings_cell_standby.png b/res/drawable-xhdpi/ic_settings_cell_standby.png
index cf783dc..a02b5a2 100644
--- a/res/drawable-xhdpi/ic_settings_cell_standby.png
+++ b/res/drawable-xhdpi/ic_settings_cell_standby.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_settings_language.png b/res/drawable-xhdpi/ic_settings_language.png
index 24a1d3c..4e44c01 100644
--- a/res/drawable-xhdpi/ic_settings_language.png
+++ b/res/drawable-xhdpi/ic_settings_language.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_settings_more.png b/res/drawable-xhdpi/ic_settings_more.png
index 717b7ec..8b9fe07 100644
--- a/res/drawable-xhdpi/ic_settings_more.png
+++ b/res/drawable-xhdpi/ic_settings_more.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_settings_phone_idle.png b/res/drawable-xhdpi/ic_settings_phone_idle.png
index 09c322f..1f8bd65 100644
--- a/res/drawable-xhdpi/ic_settings_phone_idle.png
+++ b/res/drawable-xhdpi/ic_settings_phone_idle.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_settings_voice_calls.png b/res/drawable-xhdpi/ic_settings_voice_calls.png
index 07b9074..fac4916 100644
--- a/res/drawable-xhdpi/ic_settings_voice_calls.png
+++ b/res/drawable-xhdpi/ic_settings_voice_calls.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sync_anim_holo.png b/res/drawable-xhdpi/ic_sync_anim_holo.png
index d315e95..34071fe 100644
--- a/res/drawable-xhdpi/ic_sync_anim_holo.png
+++ b/res/drawable-xhdpi/ic_sync_anim_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sync_error_holo.png b/res/drawable-xhdpi/ic_sync_error_holo.png
index 85f19bf..1e8c170 100644
--- a/res/drawable-xhdpi/ic_sync_error_holo.png
+++ b/res/drawable-xhdpi/ic_sync_error_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sync_green_holo.png b/res/drawable-xhdpi/ic_sync_green_holo.png
index 95e2d7d..b66eb3f 100644
--- a/res/drawable-xhdpi/ic_sync_green_holo.png
+++ b/res/drawable-xhdpi/ic_sync_green_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sync_grey_holo.png b/res/drawable-xhdpi/ic_sync_grey_holo.png
index 10cc48a..a05bdae 100644
--- a/res/drawable-xhdpi/ic_sync_grey_holo.png
+++ b/res/drawable-xhdpi/ic_sync_grey_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sync_red_holo.png b/res/drawable-xhdpi/ic_sync_red_holo.png
index c4b9136..63898c4 100644
--- a/res/drawable-xhdpi/ic_sync_red_holo.png
+++ b/res/drawable-xhdpi/ic_sync_red_holo.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_power_system.png b/res/drawable-xxhdpi/ic_power_system.png
new file mode 100644
index 0000000..8d4979f
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_power_system.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_search_history.png b/res/drawable-xxhdpi/ic_search_history.png
new file mode 100644
index 0000000..174409b
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_search_history.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_settings_cell_standby.png b/res/drawable-xxhdpi/ic_settings_cell_standby.png
new file mode 100644
index 0000000..07d5c85
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_settings_cell_standby.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_settings_language.png b/res/drawable-xxhdpi/ic_settings_language.png
index 2303abe..3d6559d 100644
--- a/res/drawable-xxhdpi/ic_settings_language.png
+++ b/res/drawable-xxhdpi/ic_settings_language.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_settings_more.png b/res/drawable-xxhdpi/ic_settings_more.png
index 507a279..0e0ba13 100644
--- a/res/drawable-xxhdpi/ic_settings_more.png
+++ b/res/drawable-xxhdpi/ic_settings_more.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_settings_phone_idle.png b/res/drawable-xxhdpi/ic_settings_phone_idle.png
new file mode 100644
index 0000000..a6fe868
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_settings_phone_idle.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_settings_voice_calls.png b/res/drawable-xxhdpi/ic_settings_voice_calls.png
new file mode 100644
index 0000000..78e4483
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_settings_voice_calls.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_sync_anim_holo.png b/res/drawable-xxhdpi/ic_sync_anim_holo.png
new file mode 100644
index 0000000..98be2be
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_sync_anim_holo.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_sync_error_holo.png b/res/drawable-xxhdpi/ic_sync_error_holo.png
new file mode 100644
index 0000000..8b7fee5
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_sync_error_holo.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_sync_green_holo.png b/res/drawable-xxhdpi/ic_sync_green_holo.png
new file mode 100644
index 0000000..696ca25
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_sync_green_holo.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_sync_grey_holo.png b/res/drawable-xxhdpi/ic_sync_grey_holo.png
new file mode 100644
index 0000000..b8d7685
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_sync_grey_holo.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_sync_red_holo.png b/res/drawable-xxhdpi/ic_sync_red_holo.png
new file mode 100644
index 0000000..c0cd4533
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_sync_red_holo.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_power_system.png b/res/drawable-xxxhdpi/ic_power_system.png
new file mode 100644
index 0000000..bc92e90
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_power_system.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_search_history.png b/res/drawable-xxxhdpi/ic_search_history.png
new file mode 100644
index 0000000..ffce51e
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_search_history.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_settings_cell_standby.png b/res/drawable-xxxhdpi/ic_settings_cell_standby.png
new file mode 100644
index 0000000..3c864ce
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_settings_cell_standby.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_settings_language.png b/res/drawable-xxxhdpi/ic_settings_language.png
index 04f0f8d..c9447bd 100644
--- a/res/drawable-xxxhdpi/ic_settings_language.png
+++ b/res/drawable-xxxhdpi/ic_settings_language.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_settings_phone_idle.png b/res/drawable-xxxhdpi/ic_settings_phone_idle.png
new file mode 100644
index 0000000..4851676
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_settings_phone_idle.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_settings_voice_calls.png b/res/drawable-xxxhdpi/ic_settings_voice_calls.png
new file mode 100644
index 0000000..633cfc1
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_settings_voice_calls.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_sync_anim_holo.png b/res/drawable-xxxhdpi/ic_sync_anim_holo.png
new file mode 100644
index 0000000..b48c4db
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_sync_anim_holo.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_sync_error_holo.png b/res/drawable-xxxhdpi/ic_sync_error_holo.png
new file mode 100644
index 0000000..56ae11e
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_sync_error_holo.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_sync_green_holo.png b/res/drawable-xxxhdpi/ic_sync_green_holo.png
new file mode 100644
index 0000000..5227542
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_sync_green_holo.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_sync_grey_holo.png b/res/drawable-xxxhdpi/ic_sync_grey_holo.png
new file mode 100644
index 0000000..a0ae3f3
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_sync_grey_holo.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_sync_red_holo.png b/res/drawable-xxxhdpi/ic_sync_red_holo.png
new file mode 100644
index 0000000..3ac5f63
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_sync_red_holo.png
Binary files differ
diff --git a/res/drawable/dashboard_tile_background.xml b/res/drawable/dashboard_tile_background.xml
index f66ff23..2629cda 100644
--- a/res/drawable/dashboard_tile_background.xml
+++ b/res/drawable/dashboard_tile_background.xml
@@ -15,9 +15,7 @@
 -->
 
 <ripple xmlns:android="http://schemas.android.com/apk/res/android"
-                android:tint="?android:attr/colorControlHighlight">
-    <item>
-        <color android:color="@android:color/white" />
-    </item>
+    android:color="?android:attr/colorControlHighlight">
+    <item android:drawable="@android:color/white" />
 </ripple>
 
diff --git a/res/drawable/preference_highlight.xml b/res/drawable/preference_highlight.xml
index bbffe62..20c1a0f 100644
--- a/res/drawable/preference_highlight.xml
+++ b/res/drawable/preference_highlight.xml
@@ -15,8 +15,7 @@
 -->
 
 <ripple xmlns:android="http://schemas.android.com/apk/res/android"
-                android:tint="?android:attr/colorControlHighlight"
-                android:pinned="true">
+    android:color="?android:attr/colorControlHighlight">
     <item android:id="@android:id/mask"
           android:drawable="@android:color/white" />
 </ripple>
diff --git a/res/drawable/switchbar_background.xml b/res/drawable/switchbar_background.xml
index d329b6b..ac340be 100644
--- a/res/drawable/switchbar_background.xml
+++ b/res/drawable/switchbar_background.xml
@@ -15,9 +15,7 @@
 -->
 
 <ripple xmlns:android="http://schemas.android.com/apk/res/android"
-                android:tint="?android:attr/colorControlHighlight">
-    <item>
-        <color android:color="@color/switchbar_background_color" />
-    </item>
+    android:color="?android:attr/colorControlHighlight">
+    <item android:drawable="@color/switchbar_background_color" />
 </ripple>
 
diff --git a/res/layout/apn_disallowed_preference_screen.xml b/res/layout/apn_disallowed_preference_screen.xml
new file mode 100644
index 0000000..25f6f37
--- /dev/null
+++ b/res/layout/apn_disallowed_preference_screen.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2014 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.
+ */
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             android:id="@+id/listContainer"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent">
+
+        <ListView android:id="@android:id/list"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:drawSelectorOnTop="false"
+                android:scrollbarStyle="insideOverlay"
+                android:background="@android:color/white"
+                android:cacheColorHint="@android:color/white"
+                android:fadingEdgeLength="16dip" />
+
+        <TextView android:id="@+android:id/empty"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:gravity="center"
+                android:text="@string/apn_settings_not_available"
+                android:textAppearance="?android:attr/textAppearanceMedium" />
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/battery_history_chart.xml b/res/layout/battery_history_chart.xml
index 0d3e185..48eb7ed 100644
--- a/res/layout/battery_history_chart.xml
+++ b/res/layout/battery_history_chart.xml
@@ -14,22 +14,29 @@
      limitations under the License.
 -->
 
-<com.android.settings.fuelgauge.BatteryHistoryChart
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        xmlns:app="http://schemas.android.com/apk/res/com.android.settings"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:gravity="center_vertical"
-    android:id="@+android:id/battery_history_chart"
-    android:paddingEnd="?android:attr/scrollbarSize"
-    android:textAppearance="?android:attr/textAppearanceSmall"
-    android:textColor="#ff000000"
-    app:headerAppearance="?android:attr/textAppearanceMedium"
-    android:shadowRadius="4"
-    android:shadowColor="?android:attr/colorBackground"
-    android:shadowDx="2"
-    android:shadowDy="2"
-    app:barPrimaryColor="?android:attr/colorControlActivated"
-    app:barPredictionColor="@color/material_empty_color_light"
-    app:chartMinHeight="@dimen/battery_history_chart_height">
-</com.android.settings.fuelgauge.BatteryHistoryChart>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+
+    <com.android.settings.fuelgauge.BatteryHistoryChart
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            xmlns:app="http://schemas.android.com/apk/res/com.android.settings"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:gravity="center_vertical"
+        android:id="@+android:id/battery_history_chart"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textColor="#ff000000"
+        app:headerAppearance="?android:attr/textAppearanceMedium"
+        android:shadowRadius="4"
+        android:shadowColor="?android:attr/colorBackground"
+        android:shadowDx="2"
+        android:shadowDy="2"
+        app:barPrimaryColor="?android:attr/colorControlActivated"
+        app:barPredictionColor="@color/material_empty_color_light"
+        app:chartMinHeight="@dimen/battery_history_chart_height">
+    </com.android.settings.fuelgauge.BatteryHistoryChart>
+
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/dashboard_category.xml b/res/layout/dashboard_category.xml
index 6e90fa9..afa038b 100644
--- a/res/layout/dashboard_category.xml
+++ b/res/layout/dashboard_category.xml
@@ -23,7 +23,7 @@
     <TextView android:id="@+id/category_title"
             android:layout_width="match_parent"
             android:layout_height="@dimen/dashboard_category_title_height"
-            android:paddingStart="@dimen/dashboard_category_title_padding_start"
+            android:layout_marginStart="@dimen/dashboard_category_title_margin_start"
             android:singleLine="true"
             android:ellipsize="marquee"
             android:gravity="center_vertical"
diff --git a/res/layout/preference_batteryhistory.xml b/res/layout/preference_batteryhistory.xml
index 766ec51..723b0e1 100644
--- a/res/layout/preference_batteryhistory.xml
+++ b/res/layout/preference_batteryhistory.xml
@@ -18,11 +18,11 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
-        android:minHeight="@dimen/battery_history_chart_height"
-        android:paddingEnd="?android:attr/scrollbarSize">
+        android:minHeight="@dimen/battery_history_chart_height">
     <include layout="@layout/battery_history_chart" />
     <TextView android:id="@+id/labelsHeader"
-              android:layout_width="match_parent" android:layout_height="48dp"
+              android:layout_width="match_parent"
+              android:layout_height="48dp"
               android:textAppearance="?android:attr/textAppearanceMedium"
               android:textSize="14sp"
               android:textColor="?android:attr/colorControlActivated"
diff --git a/res/layout/preference_progress_category.xml b/res/layout/preference_progress_category.xml
index 17d87d7..d0cf60c 100644
--- a/res/layout/preference_progress_category.xml
+++ b/res/layout/preference_progress_category.xml
@@ -22,7 +22,8 @@
 
     <!-- This text view has the style of the list separator text view without the background and padding. -->
     <TextView
-        style="?android:attr/listSeparatorTextViewStyle"
+        android:textAppearance="@android:style/TextAppearance.Material.Body2"
+        android:textColor="?android:attr/colorAccent"
         android:background="@null"
         android:id="@+android:id/title"
         android:paddingStart="0dp"
diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml
index 1242c73..c892ff9 100644
--- a/res/layout/search_panel.xml
+++ b/res/layout/search_panel.xml
@@ -33,17 +33,6 @@
                 android:layout_gravity="center"
                 android:orientation="vertical">
 
-            <TextView android:layout_width="wrap_content"
-                      android:layout_height="@dimen/dashboard_category_title_height"
-                      android:paddingStart="@dimen/search_title_padding_start"
-                      android:singleLine="true"
-                      android:ellipsize="marquee"
-                      android:gravity="center_vertical"
-                      android:textAppearance="@style/TextAppearance.RecentsTitle"
-                      android:textAlignment="viewStart"
-                      android:text="@string/search_recents_queries_label"
-                    />
-
             <ListView android:id="@+id/list_suggestions"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
@@ -58,17 +47,6 @@
                 android:orientation="vertical"
                 android:layout_weight="1">
 
-            <TextView android:layout_width="wrap_content"
-                      android:layout_height="@dimen/dashboard_category_title_height"
-                      android:paddingStart="@dimen/search_title_padding_start"
-                      android:singleLine="true"
-                      android:ellipsize="marquee"
-                      android:gravity="center_vertical"
-                      android:textAppearance="@style/TextAppearance.ResultTitle"
-                      android:textAlignment="viewStart"
-                      android:text="@string/search_results_label"
-                    />
-
             <ListView android:id="@+id/list_results"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
diff --git a/res/layout/search_panel_results_header.xml b/res/layout/search_panel_results_header.xml
new file mode 100644
index 0000000..07f77a7
--- /dev/null
+++ b/res/layout/search_panel_results_header.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+          android:layout_width="wrap_content"
+          android:layout_height="@dimen/dashboard_category_title_height"
+          android:paddingStart="@dimen/search_title_padding_start"
+          android:singleLine="true"
+          android:ellipsize="marquee"
+          android:gravity="center_vertical"
+          android:textAppearance="@style/TextAppearance.ResultTitle"
+          android:textAlignment="viewStart"
+          android:text="@string/search_results_label"
+        />
diff --git a/res/layout/search_panel_suggestions_header.xml b/res/layout/search_panel_suggestions_header.xml
new file mode 100644
index 0000000..21500bc
--- /dev/null
+++ b/res/layout/search_panel_suggestions_header.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+          android:layout_width="wrap_content"
+          android:layout_height="@dimen/dashboard_category_title_height"
+          android:paddingStart="@dimen/search_title_padding_start"
+          android:singleLine="true"
+          android:ellipsize="marquee"
+          android:gravity="center_vertical"
+          android:textAppearance="@style/TextAppearance.RecentsTitle"
+          android:textAlignment="viewStart"
+          android:text="@string/search_recents_queries_label"
+        />
diff --git a/res/layout/search_suggestion_item.xml b/res/layout/search_suggestion_item.xml
index b92a7f0..245b684 100644
--- a/res/layout/search_suggestion_item.xml
+++ b/res/layout/search_suggestion_item.xml
@@ -20,13 +20,39 @@
               android:minHeight="?android:attr/listPreferredItemHeight"
               android:gravity="center_vertical">
 
-    <TextView android:id="@+id/title"
-              android:layout_width="wrap_content"
-              android:layout_height="wrap_content"
-              android:paddingStart="@dimen/search_title_padding_start"
-              android:singleLine="true"
-              android:textAppearance="?android:attr/textAppearanceMedium"
-              android:ellipsize="marquee"
-              android:fadingEdge="horizontal" />
+    <RelativeLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1">
+
+        <TextView android:id="@+id/title"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:paddingStart="@dimen/search_title_padding_start"
+                  android:singleLine="true"
+                  android:textAppearance="?android:attr/textAppearanceMedium"
+                  android:ellipsize="marquee"
+                  android:fadingEdge="horizontal" />
+
+    </RelativeLayout>
+
+    <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:gravity="center"
+            android:minWidth="@*android:dimen/preference_icon_minWidth"
+            android:orientation="horizontal">
+
+        <ImageView
+                android:id="@+id/icon"
+                android:layout_width="@dimen/search_suggestion_item_image_size"
+                android:layout_height="@dimen/search_suggestion_item_image_size"
+                android:scaleType="centerInside"
+                android:src="@drawable/ic_search_history"
+                android:layout_marginStart="@dimen/search_suggestion_item_image_margin_start"
+                android:layout_marginEnd="@dimen/search_suggestion_item_image_margin_end"
+                />
+
+    </LinearLayout>
 
 </LinearLayout>
diff --git a/res/layout/switch_bar.xml b/res/layout/switch_bar.xml
index 51914c9..cdf14d7 100644
--- a/res/layout/switch_bar.xml
+++ b/res/layout/switch_bar.xml
@@ -23,7 +23,7 @@
               android:layout_height="wrap_content"
               android:layout_width="0dp"
               android:layout_weight="1"
-              android:paddingStart="@dimen/switchbar_padding_start"
+              android:layout_marginStart="?attr/switchBarMarginStart"
               android:layout_gravity="center_vertical"
               android:textAppearance="@style/TextAppearance.Switch"
               android:textAlignment="viewStart" />
@@ -32,6 +32,6 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical"
-            android:paddingEnd="@dimen/switchbar_padding_end" />
+            android:layout_marginEnd="?attr/switchBarMarginEnd" />
 </merge>
 
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index fe42d69..dcf75e7 100755
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -41,18 +41,22 @@
 
     <!-- ActionBar contentInsetStart -->
     <dimen name="actionbar_contentInsetStart">24dp</dimen>
+    <dimen name="actionbar_subsettings_contentInsetStart">80dp</dimen>
 
-    <!-- Dashboard category title padding start -->
-    <dimen name="dashboard_category_title_padding_start">24dp</dimen>
+    <!-- Dashboard category title margin start -->
+    <dimen name="dashboard_category_title_margin_start">23dp</dimen>
 
     <!-- Dashboard tile image padding start / end -->
     <dimen name="dashboard_tile_image_margin_start">24dp</dimen>
     <dimen name="dashboard_tile_image_margin_end">32dp</dimen>
 
-    <!-- SwitchBar padding start -->
-    <dimen name="switchbar_padding_start">24dp</dimen>
-    <!-- SwitchBar padding end -->
-    <dimen name="switchbar_padding_end">24dp</dimen>
+    <!-- SwitchBar margin start / end -->
+    <dimen name="switchbar_margin_start">24dp</dimen>
+    <dimen name="switchbar_margin_end">24dp</dimen>
+
+    <!-- SwitchBar sub settings margin start / end -->
+    <dimen name="switchbar_subsettings_margin_start">80dp</dimen>
+    <dimen name="switchbar_subsettings_margin_end">24dp</dimen>
 
     <!-- Search title (recent / results) padding start -->
     <dimen name="search_title_padding_start">24dp</dimen>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index b95a479..7118865 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1220,4 +1220,13 @@
         <item>1</item>
         <item>2</item>
     </string-array>
+
+    <!-- Battery saver mode: allowable trigger threshold levels. -->
+    <integer-array name="battery_saver_trigger_values" translatable="false" >
+        <item>0</item>
+        <item>5</item>
+        <item>10</item>
+        <item>15</item>
+        <item>20</item>
+    </integer-array>
 </resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index c1cb5ae..86cffa9 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -96,4 +96,8 @@
     <declare-styleable name="Preference">
         <attr name="keywords" format="string" />
     </declare-styleable>
+
+    <attr name="switchBarMarginStart" format="dimension" />
+    <attr name="switchBarMarginEnd" format="dimension" />
+
 </resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 30516a1..b835add 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -47,27 +47,12 @@
     <color name="lock_pattern_view_success_color">#ff009688</color>
     <color name="lock_pattern_view_error_color">#fff4511e</color>
 
-    <color name="material_blue_grey_50">#ffeceff1</color>
-    <color name="material_blue_grey_100">#ffcfd8dc</color>
-    <color name="material_blue_grey_300">#ff90a4ae</color>
-    <color name="material_blue_grey_500">#ff607d8b</color>
-    <color name="material_blue_grey_700">#ff455a64</color>
-
-    <color name="material_orange_100">#ffffe0b2</color>
-    <color name="material_orange_300">#ffffb74d</color>
-    <color name="material_orange_500">#ffff9800</color>
-    <color name="material_orange_700">#fff57c00</color>
-    <color name="material_orange_A200">#ffffab40</color>
-    <color name="material_orange_A400">#ffff9100</color>
-
-    <color name="material_accent_color_light">#FF009688</color>
-    <color name="material_accent_color_dark">#FF80CBC4</color>
     <color name="material_empty_color_light">#FFCED7DB</color>
 
-    <!-- Palette colors referenced by top-level themes and manually copied into base theme. -->
+    <!-- Palette colors referenced by top-level themes. -->
     <color name="theme_primary">#ff263238</color>
-    <color name="theme_primary_dark">@color/theme_primary</color>
-    <color name="theme_accent">@color/material_accent_color_light</color>
+    <color name="theme_primary_dark">#ff21272b</color>
+    <color name="theme_accent">#ff009688</color>
 
     <color name="dashboard_background_color">#ffe1e1e0</color>
     <color name="switchbar_background_color">#ff384248</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b656182..eef43a7 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -74,7 +74,7 @@
 
     <dimen name="captioning_preview_height">200dp</dimen>
 
-    <dimen name="settings_side_margin">@*android:dimen/preference_fragment_padding_side</dimen>
+    <dimen name="settings_side_margin">0dip</dimen>
 
     <!-- Weight of the left pane in a multi-pane preference layout. -->
     <integer name="preferences_left_pane_weight">4</integer>
@@ -92,6 +92,7 @@
 
     <!-- ActionBar contentInsetStart -->
     <dimen name="actionbar_contentInsetStart">16dp</dimen>
+    <dimen name="actionbar_subsettings_contentInsetStart">72dp</dimen>
 
     <!-- Dashboard padding between each tiles within the layout -->
     <dimen name="dashboard_cell_gap">1dp</dimen>
@@ -104,8 +105,8 @@
     <!-- Dashboard category title layout height -->
     <dimen name="dashboard_category_title_height">48dp</dimen>
 
-    <!-- Dashboard category title padding start -->
-    <dimen name="dashboard_category_title_padding_start">16dp</dimen>
+    <!-- Dashboard category title margin start -->
+    <dimen name="dashboard_category_title_margin_start">15dp</dimen>
 
     <!-- Dashboard tile minimum height -->
     <dimen name="dashboard_tile_minimum_height">72dp</dimen>
@@ -117,10 +118,13 @@
     <dimen name="dashboard_tile_image_margin_start">16dp</dimen>
     <dimen name="dashboard_tile_image_margin_end">32dp</dimen>
 
-    <!-- SwitchBar padding start -->
-    <dimen name="switchbar_padding_start">16dp</dimen>
-    <!-- SwitchBar padding end. Should be n x @*android:dimen/preference_fragment_padding_side -->
-    <dimen name="switchbar_padding_end">16dp</dimen>
+    <!-- SwitchBar margin start / end -->
+    <dimen name="switchbar_margin_start">16dp</dimen>
+    <dimen name="switchbar_margin_end">16dp</dimen>
+
+    <!-- SwitchBar sub settings margin start / end -->
+    <dimen name="switchbar_subsettings_margin_start">72dp</dimen>
+    <dimen name="switchbar_subsettings_margin_end">16dp</dimen>
 
     <!-- Search Results padding in its container -->
     <dimen name="search_results_padding_start">1dp</dimen>
@@ -136,4 +140,11 @@
     <dimen name="search_result_item_image_margin_start">16dp</dimen>
     <dimen name="search_result_item_image_margin_end">32dp</dimen>
 
+    <!-- Suggestion item image size -->
+    <dimen name="search_suggestion_item_image_size">24dp</dimen>
+
+    <!-- Suggestion item image margin start / end -->
+    <dimen name="search_suggestion_item_image_margin_start">32dp</dimen>
+    <dimen name="search_suggestion_item_image_margin_end">16dp</dimen>
+
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 72f8408..e50f8e9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3132,6 +3132,12 @@
     <!-- 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>
@@ -3575,16 +3581,6 @@
     <string name="battery_stats_phone_signal_label">Mobile network signal</string>
     <!-- Battery usage during last unplugged period -->
     <string name="battery_stats_last_duration">@string/menu_stats_last_unplugged</string>
-    <!-- [CHAR_LIMIT=5] Label for an hour time when using 24 hour mode -->
-    <string name="battery_stats_hour_24_label"><xliff:g id="time">%1$d</xliff:g>:00</string>
-    <!-- [CHAR_LIMIT=5] Label for an hour time when using 12 hour mode in the AM -->
-    <string name="battery_stats_hour_am_label"><xliff:g id="time">%1$d</xliff:g> AM</string>
-    <!-- [CHAR_LIMIT=5] Label for an hour time when using 12 hour mode in the PM -->
-    <string name="battery_stats_hour_pm_label"><xliff:g id="time">%1$d</xliff:g> PM</string>
-    <!-- [CHAR_LIMIT=3] Label for date of day and month (not year) when the day is shown first -->
-    <string name="battery_stats_date_day_first_label"><xliff:g id="day">%1$d</xliff:g>/<xliff:g id="month">%2$d</xliff:g></string>
-    <!-- [CHAR_LIMIT=3] Label for date of day and month (not year) when the month is shown first -->
-    <string name="battery_stats_date_month_first_label"><xliff:g id="month">%2$d</xliff:g>/<xliff:g id="day">%1$d</xliff:g></string>
     <!-- CPU awake time title -->
     <string name="awake">Device awake time</string>
     <!-- Wifi on time -->
@@ -3742,6 +3738,24 @@
     <!-- Label for mediaserver process -->
     <string name="process_mediaserver_label">Mediaserver</string>
 
+    <!-- [CHAR_LIMIT=40] Battery saver: Label for feature, title + menu item -->
+    <string name="battery_saver">Battery saver</string>
+
+    <!-- [CHAR_LIMIT=40] Battery saver: Title for always on option -->
+    <string name="battery_saver_always_on_title">Always on</string>
+
+    <!-- [CHAR_LIMIT=40] Battery saver: Title for automatic entry option -->
+    <string name="battery_saver_turn_on_automatically_title">Turn on automatically</string>
+
+    <!-- [CHAR_LIMIT=40] Battery saver: Value for automatic entry option: Never -->
+    <string name="battery_saver_turn_on_automatically_never">Never</string>
+
+    <!-- [CHAR_LIMIT=40] Battery saver: Value for automatic entry option: pct% battery -->
+    <string name="battery_saver_turn_on_automatically_pct">at %1$d%% battery</string>
+
+    <!-- [CHAR_LIMIT=NONE] Battery saver: Feature description -->
+    <string name="battery_saver_description">To help improve battery life, Battery saver will reduce your device’s performance.\n\nBattery saver will be disabled when your device is plugged in.</string>
+
     <!-- Process Stats strings -->
     <skip />
 
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 82f0bc1..e23b300 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -30,6 +30,8 @@
         <item name="ic_wps">@drawable/ic_wps_dark</item>
         <item name="setup_divider_color">@color/setup_divider_color_dark</item>
         <item name="wifi_signal">@drawable/wifi_signal_dark</item>
+        <item name="switchBarMarginStart">0dip</item>
+        <item name="switchBarMarginEnd">0dip</item>
     </style>
 
     <style name="SetupWizardWifiTheme.Light" parent="android:Theme.Material.Light.NoActionBar">
@@ -41,6 +43,8 @@
         <item name="ic_wps">@drawable/ic_wps_light</item>
         <item name="setup_divider_color">@color/setup_divider_color_light</item>
         <item name="wifi_signal">@drawable/wifi_signal_light</item>
+        <item name="switchBarMarginStart">0dip</item>
+        <item name="switchBarMarginEnd">0dip</item>
     </style>
 
     <style name="Theme.WifiDialog" parent="@*android:style/Theme.Material.Dialog.Alert">
@@ -63,14 +67,7 @@
          layouts against a remote context using our local theme colors. Due to the implementation
          details of Theme, we can't reference any local resources and MUST instead use the values
          directly. So use #ff263238 instead of @color/theme_primary and so on. -->
-    <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Light.DarkActionBar">
-        <!-- Should match @color/theme_primary. -->
-        <item name="android:colorPrimary">#ff263238</item>
-        <!-- Should match @color/theme_primary_dark. -->
-        <item name="android:colorPrimaryDark">#ff263238</item>
-        <!-- Should match @color/theme_accent. -->
-        <item name="android:colorAccent">#ff009688</item>
-    </style>
+    <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" />
 
     <style name="Theme.Settings" parent="Theme.SettingsBase">
         <item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
@@ -84,6 +81,9 @@
         <item name="ic_wps">@drawable/ic_wps_dark</item>
         <item name="wifi_signal">@drawable/wifi_signal_dark</item>
 
+        <item name="switchBarMarginStart">@dimen/switchbar_margin_start</item>
+        <item name="switchBarMarginEnd">@dimen/switchbar_margin_end</item>
+
         <!-- Redefine the ActionBar style for contentInsetStart -->
         <item name="android:actionBarStyle">@style/Theme.ActionBar</item>
 
@@ -100,7 +100,19 @@
         <item name="android:contentInsetStart">@dimen/actionbar_contentInsetStart</item>
     </style>
 
-    <style name="Theme.DialogWhenLarge" parent="android:style/Theme.Material.Light.DialogWhenLarge">
+    <style name="Theme.SubSettings" parent="Theme.Settings">
+        <!-- Redefine the ActionBar style for contentInsetStart -->
+        <item name="android:actionBarStyle">@style/Theme.SubSettingsActionBar</item>
+
+        <item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
+        <item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
+    </style>
+
+    <style name="Theme.SubSettingsActionBar" parent="Theme.ActionBar">
+        <item name="android:contentInsetStart">@dimen/actionbar_subsettings_contentInsetStart</item>
+    </style>
+
+    <style name="Theme.DialogWhenLarge" parent="@android:style/Theme.Material.Light.DialogWhenLarge">
         <!-- Used by the ActionBar -->
         <item name="android:colorPrimary">@color/theme_primary</item>
         <!-- Used by the StatusBar -->
@@ -112,6 +124,13 @@
         <item name="android:actionBarStyle">@style/Theme.ActionBar</item>
     </style>
 
+    <style name="Theme.CryptKeeper" parent="@android:style/Theme.Material.Light.NoActionBar">
+        <!-- LockPatternView colors -->
+        <item name="@*android:regularColor">@color/lock_pattern_view_regular_color</item>
+        <item name="@*android:successColor">@color/lock_pattern_view_success_color</item>
+        <item name="@*android:errorColor">@color/lock_pattern_view_error_color</item>
+    </style>
+
     <style name="Theme.SubSettingsDialogWhenLarge" parent="Theme.DialogWhenLarge">
         <item name="android:actionBarWidgetTheme">@null</item>
         <item name="android:actionBarTheme">@android:style/ThemeOverlay.Material.Dark.ActionBar</item>
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
new file mode 100644
index 0000000..472586a
--- /dev/null
+++ b/res/xml/battery_saver_settings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+        android:title="@string/battery_saver"
+        android:key="battery_saver">
+
+    <!-- Always on -->
+    <SwitchPreference
+            android:key="always_on"
+            android:title="@string/battery_saver_always_on_title"
+            android:switchTextOff=""
+            android:switchTextOn=""
+            android:persistent="false" />
+
+    <!-- Turn on automatically -->
+    <com.android.settings.notification.DropDownPreference
+            android:key="turn_on_automatically"
+            android:title="@string/battery_saver_turn_on_automatically_title"
+            android:persistent="false" />
+
+    <!-- Feature description text -->
+    <Preference
+            android:key="description"
+            android:summary="@string/battery_saver_description"
+            android:persistent="false"
+            android:selectable="false" />
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_nfc_unlock.xml b/res/xml/security_settings_nfc_unlock.xml
deleted file mode 100644
index 63e5a74..0000000
--- a/res/xml/security_settings_nfc_unlock.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <PreferenceCategory
-            android:key="security_category"
-            android:title="@string/lock_settings_nfc_title">
-
-    <CheckBoxPreference
-            android:key="nfc_unlock_enabled"
-            android:title="@string/nfc_unlock_enabled"
-            android:persistent="false" />
-
-    <Preference
-            android:key="nfc_pairing"
-            android:title="@string/start_nfc_pairing"
-            android:persistent="false"
-            android:dependency="nfc_unlock_enabled" >
-            <intent android:action="android.settings.PAIR_NFC_DEVICE"/>
-    </Preference>
-
-    </PreferenceCategory>
-
-        <PreferenceCategory
-            android:key="nfc_unlock_tags_category"
-            android:title="@string/nfc_unlock_paired_tags_title">
-        </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java
index 3fbb5e3..ef79f2b 100644
--- a/src/com/android/settings/ApnSettings.java
+++ b/src/com/android/settings/ApnSettings.java
@@ -32,6 +32,7 @@
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
+import android.os.UserManager;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceGroup;
@@ -83,10 +84,14 @@
     private RestoreApnProcessHandler mRestoreApnProcessHandler;
     private HandlerThread mRestoreDefaultApnThread;
 
+    private UserManager mUm;
+
     private String mSelectedKey;
 
     private IntentFilter mMobileStateFilter;
 
+    private boolean mUnavailable;
+
     private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
@@ -119,6 +124,14 @@
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
+        mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+
+        if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
+            mUnavailable = true;
+            setContentView(R.layout.apn_disallowed_preference_screen);
+            return;
+        }
+
         addPreferencesFromResource(R.xml.apn_settings);
         getListView().setItemsCanFocus(true);
 
@@ -130,6 +143,10 @@
     protected void onResume() {
         super.onResume();
 
+        if (mUnavailable) {
+            return;
+        }
+
         registerReceiver(mMobileStateReceiver, mMobileStateFilter);
 
         if (!mRestoreDefaultApnMode) {
@@ -143,6 +160,10 @@
     protected void onPause() {
         super.onPause();
 
+        if (mUnavailable) {
+            return;
+        }
+
         unregisterReceiver(mMobileStateReceiver);
     }
 
diff --git a/src/com/android/settings/CredentialStorage.java b/src/com/android/settings/CredentialStorage.java
index fcf208a..44e966c 100644
--- a/src/com/android/settings/CredentialStorage.java
+++ b/src/com/android/settings/CredentialStorage.java
@@ -270,7 +270,6 @@
         private ResetDialog() {
             AlertDialog dialog = new AlertDialog.Builder(CredentialStorage.this)
                     .setTitle(android.R.string.dialog_alert_title)
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(R.string.credentials_reset_hint)
                     .setPositiveButton(android.R.string.ok, this)
                     .setNegativeButton(android.R.string.cancel, this)
@@ -340,7 +339,6 @@
         private ConfigureKeyGuardDialog() {
             AlertDialog dialog = new AlertDialog.Builder(CredentialStorage.this)
                     .setTitle(android.R.string.dialog_alert_title)
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(R.string.credentials_configure_lock_screen_hint)
                     .setPositiveButton(android.R.string.ok, this)
                     .setNegativeButton(android.R.string.cancel, this)
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index 1846580..7f7a675 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -87,7 +87,6 @@
                 // TODO replace (or follow) this dialog with an explicit launch into password UI
                 new AlertDialog.Builder(getActivity())
                     .setTitle(R.string.crypt_keeper_dialog_need_password_title)
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(R.string.crypt_keeper_dialog_need_password_message)
                     .setPositiveButton(android.R.string.ok, null)
                     .create()
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index fe7a217..6d1cadc 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -122,7 +122,6 @@
     private static final String USE_NUPLAYER_KEY = "use_nuplayer";
     private static final String USE_NUPLAYER_PROPERTY = "persist.sys.media.use-nuplayer";
     private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage";
-    private static final String LOW_POWER_MODE_KEY = "low_power_mode";
     private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
     private static final String FORCE_MSAA_KEY = "force_msaa";
     private static final String TRACK_FRAME_TIME_KEY = "track_frame_time";
@@ -168,7 +167,6 @@
     private WifiManager mWifiManager;
 
     private SwitchBar mSwitchBar;
-    private Switch mEnabledSwitch;
     private boolean mLastEnabledState;
     private boolean mHaveDebugSettings;
     private boolean mDontPokeProperties;
@@ -196,7 +194,6 @@
     private CheckBoxPreference mShowScreenUpdates;
     private CheckBoxPreference mDisableOverlays;
     private CheckBoxPreference mShowCpuUsage;
-    private CheckBoxPreference mLowPowerMode;
     private CheckBoxPreference mForceHardwareUi;
     private CheckBoxPreference mForceMsaa;
     private CheckBoxPreference mShowHwScreenUpdates;
@@ -308,7 +305,6 @@
         mShowScreenUpdates = findAndInitCheckboxPref(SHOW_SCREEN_UPDATES_KEY);
         mDisableOverlays = findAndInitCheckboxPref(DISABLE_OVERLAYS_KEY);
         mShowCpuUsage = findAndInitCheckboxPref(SHOW_CPU_USAGE_KEY);
-        mLowPowerMode = findAndInitCheckboxPref(LOW_POWER_MODE_KEY);
         mForceHardwareUi = findAndInitCheckboxPref(FORCE_HARDWARE_UI_KEY);
         mForceMsaa = findAndInitCheckboxPref(FORCE_MSAA_KEY);
         mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY);
@@ -389,11 +385,12 @@
         final SettingsActivity activity = (SettingsActivity) getActivity();
 
         mSwitchBar = activity.getSwitchBar();
-        mEnabledSwitch = mSwitchBar.getSwitch();
-        if (mUnavailable) {
-            mEnabledSwitch.setEnabled(false);
+       if (mUnavailable) {
+            mSwitchBar.setEnabled(false);
             return;
         }
+
+        mSwitchBar.addOnSwitchChangeListener(this);
     }
 
     private boolean removePreferenceForProduction(Preference preference) {
@@ -444,7 +441,7 @@
         final ContentResolver cr = getActivity().getContentResolver();
         mLastEnabledState = Settings.Global.getInt(cr,
                 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
-        mEnabledSwitch.setChecked(mLastEnabledState);
+        mSwitchBar.setChecked(mLastEnabledState);
         setPrefsEnabledState(mLastEnabledState);
 
         if (mHaveDebugSettings && !mLastEnabledState) {
@@ -455,18 +452,19 @@
             Settings.Global.putInt(getActivity().getContentResolver(),
                     Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
             mLastEnabledState = true;
-            mEnabledSwitch.setChecked(mLastEnabledState);
+            mSwitchBar.setChecked(mLastEnabledState);
             setPrefsEnabledState(mLastEnabledState);
         }
-
-        mSwitchBar.addOnSwitchChangeListener(this);
         mSwitchBar.show();
     }
 
     @Override
-    public void onPause() {
-        super.onPause();
+    public void onDestroyView() {
+        super.onDestroyView();
 
+        if (mUnavailable) {
+            return;
+        }
         mSwitchBar.removeOnSwitchChangeListener(this);
         mSwitchBar.hide();
     }
@@ -504,7 +502,6 @@
         updateShowTouchesOptions();
         updateFlingerOptions();
         updateCpuUsageOptions();
-        updateLowPowerModeOptions();
         updateHardwareUiOptions();
         updateMsaaOptions();
         updateTrackFrameTimeOptions();
@@ -1040,22 +1037,11 @@
         mWifiManager.enableVerboseLogging(mWifiVerboseLogging.isChecked() ? 1 : 0);
     }
 
-    private void updateLowPowerModeOptions() {
-        updateCheckBox(mLowPowerMode, Settings.Global.getInt(getActivity().getContentResolver(),
-                Settings.Global.LOW_POWER_MODE, 0) != 0);
-    }
-
     private void updateCpuUsageOptions() {
         updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(),
                 Settings.Global.SHOW_PROCESSES, 0) != 0);
     }
 
-    private void writeLowPowerModeOptions() {
-        boolean value = mLowPowerMode.isChecked();
-        Settings.Global.putInt(getActivity().getContentResolver(),
-                Settings.Global.LOW_POWER_MODE, value ? 1 : 0);
-    }
-
     private void writeCpuUsageOptions() {
         boolean value = mShowCpuUsage.isChecked();
         Settings.Global.putInt(getActivity().getContentResolver(),
@@ -1225,7 +1211,7 @@
 
     @Override
     public void onSwitchChanged(Switch switchView, boolean isChecked) {
-        if (switchView != mEnabledSwitch) {
+        if (switchView != mSwitchBar.getSwitch()) {
             return;
         }
         if (isChecked != mLastEnabledState) {
@@ -1236,7 +1222,6 @@
                         getActivity().getResources().getString(
                                 R.string.dev_settings_warning_message))
                         .setTitle(R.string.dev_settings_warning_title)
-                        .setIconAttribute(android.R.attr.alertDialogIcon)
                         .setPositiveButton(android.R.string.yes, this)
                         .setNegativeButton(android.R.string.no, this)
                         .show();
@@ -1277,7 +1262,6 @@
                 mAdbDialog = new AlertDialog.Builder(getActivity()).setMessage(
                         getActivity().getResources().getString(R.string.adb_warning_message))
                         .setTitle(R.string.adb_warning_title)
-                        .setIconAttribute(android.R.attr.alertDialogIcon)
                         .setPositiveButton(android.R.string.yes, this)
                         .setNegativeButton(android.R.string.no, this)
                         .show();
@@ -1332,8 +1316,6 @@
             writeShowUpdatesOption();
         } else if (preference == mDisableOverlays) {
             writeDisableOverlaysOption();
-        } else if (preference == mLowPowerMode) {
-            writeLowPowerModeOptions();
         } else if (preference == mShowCpuUsage) {
             writeCpuUsageOptions();
         } else if (preference == mImmediatelyDestroyActivities) {
@@ -1482,7 +1464,7 @@
                 setPrefsEnabledState(mLastEnabledState);
             } else {
                 // Reset the toggle
-                mEnabledSwitch.setChecked(false);
+                mSwitchBar.setChecked(false);
             }
         }
     }
@@ -1496,7 +1478,7 @@
             mAdbDialog = null;
         } else if (dialog == mEnableDialog) {
             if (!mDialogClicked) {
-                mEnabledSwitch.setChecked(false);
+                mSwitchBar.setChecked(false);
             }
             mEnableDialog = null;
         }
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 75236de..ae1d8d1 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -299,7 +299,8 @@
                 @Override
                 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
                         boolean enabled) {
-                    ArrayList<SearchIndexableResource> result = new ArrayList<>(1);
+                    ArrayList<SearchIndexableResource> result =
+                            new ArrayList<SearchIndexableResource>();
 
                     SearchIndexableResource sir = new SearchIndexableResource(context);
                     sir.xmlResId = R.xml.display_settings;
@@ -310,11 +311,15 @@
 
                 @Override
                 public List<String> getNonIndexableKeys(Context context) {
-                    ArrayList<String> nonIndexableKeys = new ArrayList<>(1);
-                    if (!isAutomaticBrightnessAvailable(context.getResources())) {
-                        nonIndexableKeys.add(KEY_AUTO_BRIGHTNESS);
+                    ArrayList<String> result = new ArrayList<String>();
+                    if (!context.getResources().getBoolean(
+                            com.android.internal.R.bool.config_dreamsSupported)) {
+                        result.add(KEY_SCREEN_SAVER);
                     }
-                    return nonIndexableKeys;
+                    if (!isAutomaticBrightnessAvailable(context.getResources())) {
+                        result.add(KEY_AUTO_BRIGHTNESS);
+                    }
+                    return result;
                 }
             };
 }
diff --git a/src/com/android/settings/DreamSettings.java b/src/com/android/settings/DreamSettings.java
index 1175639..38cba7a 100644
--- a/src/com/android/settings/DreamSettings.java
+++ b/src/com/android/settings/DreamSettings.java
@@ -61,7 +61,6 @@
     private DreamBackend mBackend;
     private DreamInfoAdapter mAdapter;
     private SwitchBar mSwitchBar;
-    private Switch mSwitch;
     private MenuItem[] mMenuItemsWhenEnabled;
     private boolean mRefreshing;
 
@@ -105,6 +104,9 @@
     public void onDestroyView() {
         logd("onDestroyView()");
         super.onDestroyView();
+
+        mSwitchBar.removeOnSwitchChangeListener(this);
+        mSwitchBar.hide();
     }
 
     @Override
@@ -124,7 +126,8 @@
 
         final SettingsActivity sa = (SettingsActivity) getActivity();
         mSwitchBar = sa.getSwitchBar();
-        mSwitch = mSwitchBar.getSwitch();
+        mSwitchBar.addOnSwitchChangeListener(this);
+        mSwitchBar.show();
     }
 
     @Override
@@ -212,9 +215,6 @@
         super.onPause();
 
         mContext.unregisterReceiver(mPackageReceiver);
-
-        mSwitchBar.removeOnSwitchChangeListener(this);
-        mSwitchBar.hide();
     }
 
     @Override
@@ -231,9 +231,6 @@
         filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
         filter.addDataScheme(PACKAGE_SCHEME);
         mContext.registerReceiver(mPackageReceiver , filter);
-
-        mSwitchBar.addOnSwitchChangeListener(this);
-        mSwitchBar.show();
     }
 
     public static int getSummaryResource(Context context) {
@@ -263,8 +260,8 @@
         logd("refreshFromBackend()");
         mRefreshing = true;
         boolean dreamsEnabled = mBackend.isEnabled();
-        if (mSwitch.isChecked() != dreamsEnabled)
-            mSwitch.setChecked(dreamsEnabled);
+        if (mSwitchBar.isChecked() != dreamsEnabled)
+            mSwitchBar.setChecked(dreamsEnabled);
 
         mAdapter.clear();
         if (dreamsEnabled) {
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index d936f46..7f699c5 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -119,7 +119,6 @@
         // TODO: DialogFragment?
         mConfirmDialog = new AlertDialog.Builder(getActivity()).setMessage(msg)
                 .setTitle(R.string.backup_erase_dialog_title)
-                .setIconAttribute(android.R.attr.alertDialogIcon)
                 .setPositiveButton(android.R.string.ok, this)
                 .setNegativeButton(android.R.string.cancel, this)
                 .show();
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index b35a362..5091eea 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -22,6 +22,7 @@
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
@@ -43,6 +44,7 @@
 import android.security.KeyStore;
 import android.service.trust.TrustAgentService;
 import android.telephony.TelephonyManager;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.android.internal.widget.LockPatternUtils;
@@ -315,27 +317,30 @@
             PackageManager pm = getPackageManager();
             List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT,
                     PackageManager.GET_META_DATA);
-            for (ResolveInfo resolveInfo : resolveInfos) {
-                if (resolveInfo.serviceInfo == null) continue;
-                if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue;
-                TrustAgentUtils.TrustAgentComponentInfo trustAgentComponentInfo =
-                        TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
-                if (trustAgentComponentInfo.componentName == null ||
-                        trustAgentComponentInfo.title == null ||
-                        trustAgentComponentInfo.title == "") continue;
-                Preference trustAgentPreference =
-                        new Preference(securityCategory.getContext());
-                trustAgentPreference.setKey(KEY_TRUST_AGENT);
-                trustAgentPreference.setTitle(trustAgentComponentInfo.title);
-                trustAgentPreference.setSummary(trustAgentComponentInfo.summary);
-                // Create intent for this preference.
-                Intent intent = new Intent();
-                intent.setComponent(trustAgentComponentInfo.componentName);
-                intent.setAction(Intent.ACTION_MAIN);
-                trustAgentPreference.setIntent(intent);
-                // Add preference to the settings menu.
-                securityCategory.addPreference(trustAgentPreference);
-                break; // Only render the first one.
+            List<ComponentName> enabledTrustAgents = mLockPatternUtils.getEnabledTrustAgents();
+            if (enabledTrustAgents != null && !enabledTrustAgents.isEmpty()) {
+                for (ResolveInfo resolveInfo : resolveInfos) {
+                    if (resolveInfo.serviceInfo == null) continue;
+                    if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue;
+                    TrustAgentUtils.TrustAgentComponentInfo trustAgentComponentInfo =
+                            TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
+                    if (trustAgentComponentInfo.componentName == null ||
+                            !enabledTrustAgents.contains(trustAgentComponentInfo.componentName) ||
+                            TextUtils.isEmpty(trustAgentComponentInfo.title)) continue;
+                    Preference trustAgentPreference =
+                            new Preference(securityCategory.getContext());
+                    trustAgentPreference.setKey(KEY_TRUST_AGENT);
+                    trustAgentPreference.setTitle(trustAgentComponentInfo.title);
+                    trustAgentPreference.setSummary(trustAgentComponentInfo.summary);
+                    // Create intent for this preference.
+                    Intent intent = new Intent();
+                    intent.setComponent(trustAgentComponentInfo.componentName);
+                    intent.setAction(Intent.ACTION_MAIN);
+                    trustAgentPreference.setIntent(intent);
+                    // Add preference to the settings menu.
+                    securityCategory.addPreference(trustAgentPreference);
+                    break; // Only render the first one.
+                }
             }
         }
 
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 22ae719..7ef33ae 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -66,6 +66,7 @@
     public static class RunningServicesActivity extends SettingsActivity { /* empty */ }
     public static class ManageAccountsSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PowerUsageSummaryActivity extends SettingsActivity { /* empty */ }
+    public static class BatterySaverSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AccountSyncSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AccountSyncSettingsInAddAccountActivity extends SettingsActivity { /* empty */ }
     public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index ad7d473..9cce9a1 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -63,8 +63,8 @@
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.Button;
-
 import android.widget.SearchView;
+
 import com.android.internal.util.ArrayUtils;
 import com.android.internal.util.XmlUtils;
 import com.android.settings.accessibility.AccessibilitySettings;
@@ -83,6 +83,7 @@
 import com.android.settings.dashboard.SearchResultsSummary;
 import com.android.settings.deviceinfo.Memory;
 import com.android.settings.deviceinfo.UsbSettings;
+import com.android.settings.fuelgauge.BatterySaverSettings;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.search.DynamicIndexableContentMonitor;
 import com.android.settings.search.Index;
@@ -108,6 +109,7 @@
 import com.android.settings.wifi.AdvancedWifiSettings;
 import com.android.settings.wifi.WifiSettings;
 import com.android.settings.wifi.p2p.WifiP2pSettings;
+
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
@@ -175,10 +177,11 @@
 
     /**
      * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
-     * this extra can also be specify to supply the title to be shown for
+     * those extra can also be specify to supply the title or title res id to be shown for
      * that fragment.
      */
     public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title";
+    public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = ":settings:show_fragment_title_resid";
 
     private static final String META_DATA_KEY_FRAGMENT_CLASS =
         "com.android.settings.FRAGMENT_CLASS";
@@ -192,6 +195,7 @@
     private String mFragmentClass;
 
     private CharSequence mInitialTitle;
+    private int mInitialTitleResId;
 
     // Show only these settings for restricted users
     private int[] SETTINGS_FOR_RESTRICTED = {
@@ -274,7 +278,8 @@
             NotificationSettings.class.getName(),
             ChooseLockPassword.ChooseLockPasswordFragment.class.getName(),
             ChooseLockPattern.ChooseLockPatternFragment.class.getName(),
-            InstalledAppDetails.class.getName()
+            InstalledAppDetails.class.getName(),
+            BatterySaverSettings.class.getName(),
     };
 
     private SharedPreferences mDevelopmentPreferences;
@@ -454,6 +459,20 @@
 
         super.onCreate(savedState);
 
+        // Getting Intent properties can only be done after the super.onCreate(...)
+        final String initialFragmentName = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
+
+        mIsShowingDashboard = (initialFragmentName == null);
+
+        final ComponentName cn = getIntent().getComponent();
+        final boolean isShortcut = !cn.getClassName().equals(SubSettings.class.getName());
+
+        // If this is a subsettings (but not a Shortcut) then apply the correct theme for
+        // the ActionBar content inset
+        if (!mIsShowingDashboard && !isShortcut) {
+            setTheme(R.style.Theme_SubSettings);
+        }
+
         setContentView(R.layout.settings_main);
 
         mContent = (ViewGroup) findViewById(R.id.prefs);
@@ -463,11 +482,6 @@
         mDisplayHomeAsUpEnabled = true;
         mDisplaySearch = true;
 
-        // Getting Intent properties can only be done after the super.onCreate(...)
-        final String initialFragmentName = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
-
-        mIsShowingDashboard = (initialFragmentName == null);
-
         if (mIsShowingDashboard) {
             Index.getInstance(getApplicationContext()).update();
         }
@@ -478,9 +492,7 @@
             mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED);
             mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY);
 
-            final String initialTitle = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE);
-            mInitialTitle = (initialTitle != null) ? initialTitle : getTitle();
-            setTitle(mInitialTitle);
+            setTitleFromIntent(getIntent());
 
             ArrayList<DashboardCategory> categories =
                     savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
@@ -494,25 +506,22 @@
             mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH);
         } else {
             if (!mIsShowingDashboard) {
-                final ComponentName cn = getIntent().getComponent();
                 // No UP nor Search is shown we are launched thru a Settings "shortcut"
-                if (!cn.getClassName().equals(SubSettings.class.getName())) {
+                if (isShortcut) {
                     mDisplayHomeAsUpEnabled = false;
                     mDisplaySearch = false;
                 }
-                final String initialTitle = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE);
-                mInitialTitle = (initialTitle != null) ? initialTitle : getTitle();
-                setTitle(mInitialTitle);
+                setTitleFromIntent(getIntent());
 
                 Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
-                switchToFragment( initialFragmentName, initialArguments, true, false,
-                        mInitialTitle, false);
+                switchToFragment(initialFragmentName, initialArguments, true, false,
+                        mInitialTitleResId, mInitialTitle, false);
             } else {
                 // No UP if we are displaying the main Dashboard
                 mDisplayHomeAsUpEnabled = false;
-                mInitialTitle = getText(R.string.dashboard_title);
+                mInitialTitleResId = R.string.dashboard_title;
                 switchToFragment(DashboardSummary.class.getName(), null, false, false,
-                        mInitialTitle, false);
+                        mInitialTitleResId, mInitialTitle, false);
             }
         }
 
@@ -579,6 +588,20 @@
         }
     }
 
+    private void setTitleFromIntent(Intent intent) {
+        final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
+        if (initialTitleResId > 0) {
+            mInitialTitle = null;
+            mInitialTitleResId = initialTitleResId;
+            setTitle(mInitialTitleResId);
+        } else {
+            mInitialTitleResId = -1;
+            final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE);
+            mInitialTitle = (initialTitle != null) ? initialTitle : getTitle();
+            setTitle(mInitialTitle);
+        }
+    }
+
     @Override
     public void onBackStackChanged() {
         setTitleFromBackStack();
@@ -588,7 +611,11 @@
         final int count = getFragmentManager().getBackStackEntryCount();
 
         if (count == 0) {
-            setTitle(mInitialTitle);
+            if (mInitialTitleResId > 0) {
+                setTitle(mInitialTitleResId);
+            } else {
+                setTitle(mInitialTitle);
+            }
             return 0;
         }
 
@@ -753,16 +780,17 @@
      */
     public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
             CharSequence titleText, Fragment resultTo, int resultRequestCode) {
-        String title;
-        if (titleRes > 0) {
-            title = getString(titleRes);
-        } else if (titleText != null) {
-            title = titleText.toString();
-        } else {
-            // There not much we can do in that case
-            title = "";
+        String title = null;
+        if (titleRes < 0) {
+            if (titleText != null) {
+                title = titleText.toString();
+            } else {
+                // There not much we can do in that case
+                title = "";
+            }
         }
-        Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode, title);
+        Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode,
+                titleRes, title);
     }
 
     /**
@@ -801,7 +829,7 @@
      * Switch to a specific Fragment with taking care of validation, Title and BackStack
      */
     private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
-            boolean addToBackStack, CharSequence title, boolean withTransition) {
+            boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) {
         if (validate && !isValidFragment(fragmentName)) {
             throw new IllegalArgumentException("Invalid fragment for this activity: "
                     + fragmentName);
@@ -815,7 +843,9 @@
         if (addToBackStack) {
             transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
         }
-        if (title != null) {
+        if (titleResId > 0) {
+            transaction.setBreadCrumbTitle(titleResId);
+        } else if (title != null) {
             transaction.setBreadCrumbTitle(title);
         }
         transaction.commitAllowingStateLoss();
@@ -1270,10 +1300,9 @@
         if (current != null && current instanceof SearchResultsSummary) {
             mSearchResultsFragment = (SearchResultsSummary) current;
         } else {
-            String title = getString(R.string.search_results_title);
             mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
-                    SearchResultsSummary.class.getName(), null, false, true, title,
-                    true);
+                    SearchResultsSummary.class.getName(), null, false, true,
+                    R.string.search_results_title, null, true);
         }
         mSearchResultsFragment.setSearchView(mSearchView);
         mSearchMenuItemExpanded = true;
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index 4e0933d..d960ce6 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -47,6 +47,7 @@
 import android.view.ViewGroup;
 import android.view.ViewParent;
 import android.webkit.WebView;
+import android.widget.TextView;
 
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -92,6 +93,7 @@
     private WifiApDialog mDialog;
     private WifiManager mWifiManager;
     private WifiConfiguration mWifiConfig = null;
+    private UserManager mUm;
 
     private boolean mUsbConnected;
     private boolean mMassStorageActive;
@@ -110,11 +112,21 @@
     private String[] mProvisionApp;
     private static final int PROVISION_REQUEST = 0;
 
+    private boolean mUnavailable;
+
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         addPreferencesFromResource(R.xml.tether_prefs);
 
+        mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+
+        if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) {
+            mUnavailable = true;
+            setPreferenceScreen(new PreferenceScreen(getActivity(), null));
+            return;
+        }
+
         final Activity activity = getActivity();
         BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
         if (adapter != null) {
@@ -264,6 +276,15 @@
     public void onStart() {
         super.onStart();
 
+        if (mUnavailable) {
+            TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
+            getListView().setEmptyView(emptyView);
+            if (emptyView != null) {
+                emptyView.setText(R.string.tethering_settings_not_available);
+            }
+            return;
+        }
+
         final Activity activity = getActivity();
 
         mMassStorageActive = Environment.MEDIA_SHARED.equals(Environment.getExternalStorageState());
@@ -297,6 +318,10 @@
     @Override
     public void onStop() {
         super.onStop();
+
+        if (mUnavailable) {
+            return;
+        }
         getActivity().unregisterReceiver(mTetherChangeReceiver);
         mTetherChangeReceiver = null;
         if (mWifiApEnabler != null) {
diff --git a/src/com/android/settings/TrustAgentUtils.java b/src/com/android/settings/TrustAgentUtils.java
index 31a073c..b08feff 100644
--- a/src/com/android/settings/TrustAgentUtils.java
+++ b/src/com/android/settings/TrustAgentUtils.java
@@ -43,6 +43,8 @@
      * @return true, if the service in resolveInfo has the permission to provide a trust agent.
      */
     public static boolean checkProvidePermission(ResolveInfo resolveInfo, PackageManager pm) {
+        // STOPSHIP Reenable this check once the GMS Core prebuild library has the permission.
+        /*
         String packageName = resolveInfo.serviceInfo.packageName;
         if (pm.checkPermission(PERMISSION_PROVIDE_AGENT, packageName)
                 != PackageManager.PERMISSION_GRANTED) {
@@ -50,6 +52,7 @@
                     + " does not have permission " + PERMISSION_PROVIDE_AGENT + ".");
             return false;
         }
+        */
         return true;
     }
 
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 1b64064..59a137e 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -519,15 +519,16 @@
      * @param context The context.
      * @param fragmentName The name of the fragment to display.
      * @param args Optional arguments to supply to the fragment.
-     * @param resultTo Option fragment that should receive the result of
-     * the activity launch.
-     * @param resultRequestCode If resultTo is non-null, this is the request
-     * code in which to report the result.
+     * @param resultTo Option fragment that should receive the result of the activity launch.
+     * @param resultRequestCode If resultTo is non-null, this is the request code in which
+     *                          to report the result.
+     * @param titleResId resource id for the String to display for the title of this set
+     *                   of preferences.
      * @param title String to display for the title of this set of preferences.
      */
     public static void startWithFragment(Context context, String fragmentName, Bundle args,
-            Fragment resultTo, int resultRequestCode, CharSequence title) {
-        Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, title);
+            Fragment resultTo, int resultRequestCode, int titleResId, CharSequence title) {
+        Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResId, title);
         if (resultTo == null) {
             context.startActivity(intent);
         } else {
@@ -543,16 +544,18 @@
      * @param context The Context.
      * @param fragmentName The name of the fragment to display.
      * @param args Optional arguments to supply to the fragment.
+     * @param titleResId Optional title resource id to show for this item.
      * @param title Optional title to show for this item.
      * @return Returns an Intent that can be launched to display the given
      * fragment.
      */
     public static Intent onBuildStartFragmentIntent(Context context, String fragmentName,
-            Bundle args, CharSequence title) {
+            Bundle args, int titleResId, CharSequence title) {
         Intent intent = new Intent(Intent.ACTION_MAIN);
         intent.setClass(context, SubSettings.class);
         intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, fragmentName);
         intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
+        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, titleResId);
         intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title);
         return intent;
     }
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 7aaa0a6..507445f 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -34,6 +34,7 @@
 import android.os.Bundle;
 import android.os.SystemProperties;
 import android.os.UserHandle;
+import android.os.UserManager;
 import android.preference.CheckBoxPreference;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceChangeListener;
@@ -86,6 +87,7 @@
     private ConnectivityManager mCm;
     private TelephonyManager mTm;
     private PackageManager mPm;
+    private UserManager mUm;
 
     private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
     private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
@@ -251,6 +253,7 @@
         mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
         mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
         mPm = getPackageManager();
+        mUm = (UserManager) getSystemService(Context.USER_SERVICE);
 
         addPreferencesFromResource(R.xml.wireless_settings);
 
@@ -296,10 +299,11 @@
         if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
             findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
         }
-        if (isSecondaryUser) { // Disable VPN
+        // Disable VPN.
+        if (isSecondaryUser || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) {
             removePreference(KEY_VPN_SETTINGS);
         }
-        protectByRestrictions(KEY_VPN_SETTINGS);
+
         // Manually set dependencies for Bluetooth when not toggleable.
         if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
             // No bluetooth-dependent items in the list. Code kept in case one is added later.
@@ -319,8 +323,10 @@
             mNfcEnabler = null;
         }
 
-        // Remove Mobile Network Settings and Manage Mobile Plan if it's a wifi-only device.
-        if (isSecondaryUser || Utils.isWifiOnly(getActivity())) {
+        // Remove Mobile Network Settings and Manage Mobile Plan for secondary users,
+        // if it's a wifi-only device, or if the settings are restricted.
+        if (isSecondaryUser || Utils.isWifiOnly(getActivity())
+                || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
             removePreference(KEY_MOBILE_NETWORK_SETTINGS);
             removePreference(KEY_MANAGE_MOBILE_PLAN);
         }
@@ -334,8 +340,6 @@
                 removePreference(KEY_MANAGE_MOBILE_PLAN);
             }
         }
-        protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS);
-        protectByRestrictions(KEY_MANAGE_MOBILE_PLAN);
 
         // Remove SMS Application if the device does not support SMS
         if (!isSmsSupported()) {
@@ -358,13 +362,13 @@
         // Disable Tethering if it's not allowed or if it's a wifi-only device
         final ConnectivityManager cm =
                 (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
-        if (isSecondaryUser || !cm.isTetheringSupported()) {
+        if (isSecondaryUser || !cm.isTetheringSupported()
+                || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) {
             getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
         } else {
             Preference p = findPreference(KEY_TETHER_SETTINGS);
             p.setTitle(Utils.getTetheringLabel(cm));
         }
-        protectByRestrictions(KEY_TETHER_SETTINGS);
 
         // Enable link to CMAS app settings depending on the value in config.xml.
         boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
@@ -379,12 +383,12 @@
         } catch (IllegalArgumentException ignored) {
             isCellBroadcastAppLinkEnabled = false;  // CMAS app not installed
         }
-        if (isSecondaryUser || !isCellBroadcastAppLinkEnabled) {
+        if (isSecondaryUser || !isCellBroadcastAppLinkEnabled
+                || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS)) {
             PreferenceScreen root = getPreferenceScreen();
             Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
             if (ps != null) root.removePreference(ps);
         }
-        protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS);
     }
 
     @Override
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index 41c80ae..53d614d 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -142,27 +142,30 @@
                 refreshPreviewText();
             }
         });
+    }
 
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+
+        final boolean enabled = mCaptioningManager.isEnabled();
         SettingsActivity activity = (SettingsActivity) getActivity();
         mSwitchBar = activity.getSwitchBar();
+        mSwitchBar.setTextViewLabel(enabled);
         mToggleSwitch = mSwitchBar.getSwitch();
         mToggleSwitch.setCheckedInternal(enabled);
 
         getPreferenceScreen().setEnabled(enabled);
 
         refreshPreviewText();
-    }
 
-    @Override
-    public void onResume() {
-        super.onResume();
         installSwitchBarToggleSwitch();
     }
 
     @Override
-    public void onPause() {
+    public void onDestroyView() {
+        super.onDestroyView();
         removeSwitchBarToggleSwitch();
-        super.onPause();
     }
 
     private void refreshPreviewText() {
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index a446f49..cb7699e 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -163,7 +163,6 @@
                 AlertDialog ad = new AlertDialog.Builder(getActivity())
                         .setTitle(getString(R.string.enable_service_title,
                                 info.getResolveInfo().loadLabel(getPackageManager())))
-                        .setIconAttribute(android.R.attr.alertDialogIcon)
                         .setView(createEnableDialogContentView(info))
                         .setCancelable(true)
                         .setPositiveButton(android.R.string.ok, this)
@@ -182,7 +181,6 @@
                 return new AlertDialog.Builder(getActivity())
                         .setTitle(getString(R.string.disable_service_title,
                                 info.getResolveInfo().loadLabel(getPackageManager())))
-                        .setIconAttribute(android.R.attr.alertDialogIcon)
                         .setMessage(getString(R.string.disable_service_message,
                                 info.getResolveInfo().loadLabel(getPackageManager())))
                         .setCancelable(true)
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 331c0e3..bc21759 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -95,17 +95,17 @@
     }
 
     @Override
-    public void onResume() {
-        super.onResume();
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
 
         installActionBarToggleSwitch();
     }
 
     @Override
-    public void onPause() {
-        removeActionBarToggleSwitch();
+    public void onDestroyView() {
+        super.onDestroyView();
 
-        super.onPause();
+        removeActionBarToggleSwitch();
     }
 
     protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java
index 2477877..bb06b2f 100644
--- a/src/com/android/settings/accounts/AccountSettings.java
+++ b/src/com/android/settings/accounts/AccountSettings.java
@@ -238,7 +238,7 @@
         public boolean onPreferenceClick(Preference preference) {
             if (mFragment != null) {
                 Utils.startWithFragment(
-                        getContext(), mFragment, mFragmentArguments, null, 0, mTitle);
+                        getContext(), mFragment, mFragmentArguments, null, 0, 0, mTitle);
                 return true;
             }
             return false;
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index ef27e2e..6ed517f 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -1109,7 +1109,6 @@
                 case DLG_CLEAR_DATA:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.clear_data_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.clear_data_dlg_text))
                     .setPositiveButton(R.string.dlg_ok,
                             new DialogInterface.OnClickListener() {
@@ -1123,7 +1122,6 @@
                 case DLG_FACTORY_RESET:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.app_factory_reset_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.app_factory_reset_dlg_text))
                     .setPositiveButton(R.string.dlg_ok,
                             new DialogInterface.OnClickListener() {
@@ -1138,7 +1136,6 @@
                 case DLG_APP_NOT_FOUND:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.app_not_found_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.app_not_found_dlg_title))
                     .setNeutralButton(getActivity().getText(R.string.dlg_ok),
                             new DialogInterface.OnClickListener() {
@@ -1151,7 +1148,6 @@
                 case DLG_CANNOT_CLEAR_DATA:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.clear_failed_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.clear_failed_dlg_text))
                     .setNeutralButton(R.string.dlg_ok,
                             new DialogInterface.OnClickListener() {
@@ -1165,7 +1161,6 @@
                 case DLG_FORCE_STOP:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.force_stop_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.force_stop_dlg_text))
                     .setPositiveButton(R.string.dlg_ok,
                         new DialogInterface.OnClickListener() {
@@ -1181,14 +1176,12 @@
                             getOwner().getMoveErrMsg(moveErrorCode));
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.move_app_failed_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(msg)
                     .setNeutralButton(R.string.dlg_ok, null)
                     .create();
                 case DLG_DISABLE:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.app_disable_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.app_disable_dlg_text))
                     .setPositiveButton(R.string.dlg_ok,
                         new DialogInterface.OnClickListener() {
@@ -1204,7 +1197,6 @@
                 case DLG_DISABLE_NOTIFICATIONS:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.app_disable_notifications_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.app_disable_notifications_dlg_text))
                     .setPositiveButton(R.string.dlg_ok,
                         new DialogInterface.OnClickListener() {
@@ -1224,7 +1216,6 @@
                 case DLG_SPECIAL_DISABLE:
                     return new AlertDialog.Builder(getActivity())
                     .setTitle(getActivity().getText(R.string.app_special_disable_dlg_title))
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setMessage(getActivity().getText(R.string.app_special_disable_dlg_text))
                     .setPositiveButton(R.string.dlg_ok,
                             new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/applications/RunningServiceDetails.java b/src/com/android/settings/applications/RunningServiceDetails.java
index 73547f1..45cad3d 100644
--- a/src/com/android/settings/applications/RunningServiceDetails.java
+++ b/src/com/android/settings/applications/RunningServiceDetails.java
@@ -583,7 +583,6 @@
                     
                     return new AlertDialog.Builder(getActivity())
                             .setTitle(getActivity().getString(R.string.runningservicedetails_stop_dlg_title))
-                            .setIconAttribute(android.R.attr.alertDialogIcon)
                             .setMessage(getActivity().getString(R.string.runningservicedetails_stop_dlg_text))
                             .setPositiveButton(R.string.dlg_ok,
                                     new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index be03b63..45f3d06 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -89,6 +89,16 @@
         mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
     }
 
+    public void setupSwitchBar() {
+        mSwitchBar.addOnSwitchChangeListener(this);
+        mSwitchBar.show();
+    }
+
+    public void teardownSwitchBar() {
+        mSwitchBar.removeOnSwitchChangeListener(this);
+        mSwitchBar.hide();
+    }
+
     public void resume(Context context) {
         if (mLocalAdapter == null) {
             mSwitch.setEnabled(false);
@@ -103,8 +113,6 @@
         handleStateChanged(mLocalAdapter.getBluetoothState());
 
         mContext.registerReceiver(mReceiver, mIntentFilter);
-        mSwitchBar.addOnSwitchChangeListener(this);
-        mSwitchBar.show();
         mValidListener = true;
     }
 
@@ -114,8 +122,6 @@
         }
 
         mContext.unregisterReceiver(mReceiver);
-        mSwitchBar.removeOnSwitchChangeListener(this);
-        mSwitchBar.hide();
         mValidListener = false;
     }
 
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index dd4edff..eb318cd 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -119,6 +119,14 @@
         mSwitchBar = activity.getSwitchBar();
 
         mBluetoothEnabler = new BluetoothEnabler(activity, mSwitchBar);
+        mBluetoothEnabler.setupSwitchBar();
+    }
+
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+
+        mBluetoothEnabler.teardownSwitchBar();
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index fb44d5a..1970400 100755
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -93,7 +93,6 @@
         Context activity = manager.getForegroundActivity();
         if(manager.isForegroundActivity()) {
             new AlertDialog.Builder(activity)
-                .setIconAttribute(android.R.attr.alertDialogIcon)
                 .setTitle(R.string.bluetooth_error_title)
                 .setMessage(message)
                 .setPositiveButton(android.R.string.ok, null)
diff --git a/src/com/android/settings/dashboard/DashboardTileView.java b/src/com/android/settings/dashboard/DashboardTileView.java
index a114f70..099459c 100644
--- a/src/com/android/settings/dashboard/DashboardTileView.java
+++ b/src/com/android/settings/dashboard/DashboardTileView.java
@@ -85,7 +85,7 @@
     public void onClick(View v) {
         if (mTile.fragment != null) {
             Utils.startWithFragment(getContext(), mTile.fragment, mTile.fragmentArguments, null, 0,
-                    mTile.getTitle(getResources()));
+                    mTile.titleRes, mTile.getTitle(getResources()));
         } else if (mTile.intent != null) {
             getContext().startActivity(mTile.intent);
         }
diff --git a/src/com/android/settings/dashboard/SearchResultsSummary.java b/src/com/android/settings/dashboard/SearchResultsSummary.java
index 910d661..6981634 100644
--- a/src/com/android/settings/dashboard/SearchResultsSummary.java
+++ b/src/com/android/settings/dashboard/SearchResultsSummary.java
@@ -166,6 +166,9 @@
         mResultsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                // We have a header, so we need to decrement the position by one
+                position--;
+
                 final Cursor cursor = mResultsAdapter.mCursor;
                 cursor.moveToPosition(position);
 
@@ -181,7 +184,7 @@
                     Bundle args = new Bundle();
                     args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
 
-                    Utils.startWithFragment(sa, className, args, null, 0, screenTitle);
+                    Utils.startWithFragment(sa, className, args, null, 0, -1, screenTitle);
                 } else {
                     final Intent intent = new Intent(action);
 
@@ -202,12 +205,17 @@
                 saveQueryToDatabase();
             }
         });
+        mResultsListView.addHeaderView(
+                LayoutInflater.from(getActivity()).inflate(
+                R.layout.search_panel_results_header, mResultsListView, false));
 
         mSuggestionsListView = (ListView) view.findViewById(R.id.list_suggestions);
         mSuggestionsListView.setAdapter(mSuggestionsAdapter);
         mSuggestionsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                // We have a header, so we need to decrement the position by one
+                position--;
                 final Cursor cursor = mSuggestionsAdapter.mCursor;
                 cursor.moveToPosition(position);
 
@@ -216,6 +224,9 @@
                 mSearchView.setQuery(mQuery, false);
             }
         });
+        mSuggestionsListView.addHeaderView(
+                LayoutInflater.from(getActivity()).inflate(
+                        R.layout.search_panel_suggestions_header, mSuggestionsListView, false));
 
         return view;
     }
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
index 4c6a503..85047ce 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
@@ -45,6 +45,7 @@
 
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Locale;
 
 public class BatteryHistoryChart extends View {
     static final boolean DEBUG = false;
@@ -200,10 +201,7 @@
     int mLevelBottom;
     int mLevelLeft;
     int mLevelRight;
-    static final int PHONE_SIGNAL_X_MASK = CHART_DATA_X_MASK;
-    static final int PHONE_SIGNAL_BIN_MASK = CHART_DATA_BIN_MASK;
-    static final int PHONE_SIGNAL_BIN_SHIFT = CHART_DATA_BIN_SHIFT;
-    
+
     int mNumHist;
     long mHistStart;
     long mHistDataEnd;
@@ -315,22 +313,11 @@
         final String label;
         final int width;
 
-        TimeLabel(Context context, TextPaint paint, int x, Calendar cal, boolean use24hr) {
+        TimeLabel(TextPaint paint, int x, Calendar cal, boolean use24hr) {
             this.x = x;
-            if (use24hr) {
-                label = context.getString(R.string.battery_stats_hour_24_label,
-                        cal.get(Calendar.HOUR_OF_DAY));
-            } else {
-                int hour = cal.get(Calendar.HOUR);
-                if (hour == 0) {
-                    hour = 12;
-                }
-                if (cal.get(Calendar.AM_PM) == Calendar.AM) {
-                    label = context.getString(R.string.battery_stats_hour_am_label, hour);
-                } else {
-                    label = context.getString(R.string.battery_stats_hour_pm_label, hour);
-                }
-            }
+            final String bestFormat = DateFormat.getBestDateTimePattern(
+                    Locale.getDefault(), use24hr ? "km" : "ha");
+            label = DateFormat.format(bestFormat, cal).toString();
             width = (int)paint.measureText(label);
         }
     }
@@ -340,15 +327,11 @@
         final String label;
         final int width;
 
-        DateLabel(Context context, TextPaint paint, int x, Calendar cal, boolean dayFirst) {
+        DateLabel(TextPaint paint, int x, Calendar cal, boolean dayFirst) {
             this.x = x;
-            if (dayFirst) {
-                label = context.getString(R.string.battery_stats_date_day_first_label,
-                        cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH));
-            } else {
-                label = context.getString(R.string.battery_stats_date_month_first_label,
-                        cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH));
-            }
+            final String bestFormat = DateFormat.getBestDateTimePattern(
+                    Locale.getDefault(), dayFirst ? "dM" : "Md");
+            label = DateFormat.format(bestFormat, cal).toString();
             width = (int)paint.measureText(label);
         }
     }
@@ -374,18 +357,22 @@
         mBatteryCriticalPaint.setStyle(Paint.Style.STROKE);
         mTimeRemainPaint.setColor(0xFFCED7BB);
         mTimeRemainPaint.setStyle(Paint.Style.FILL);
-        mChargingPaint.setARGB(255, 0, 128, 0);
         mChargingPaint.setStyle(Paint.Style.STROKE);
         mScreenOnPaint.setStyle(Paint.Style.STROKE);
         mGpsOnPaint.setStyle(Paint.Style.STROKE);
         mWifiRunningPaint.setStyle(Paint.Style.STROKE);
         mCpuRunningPaint.setStyle(Paint.Style.STROKE);
         mPhoneSignalChart.setColors(new int[] {
-                0x00000000, 0xffa00000, 0xffa07000, 0xffa0a000,
-                0xff80a000, 0xff409000, 0xff008000
+                0x00000000, 0xffc43828, 0xffe54918, 0xfff47b00,
+                0xfffabf2c, 0xff679e37, 0xff0a7f42
         });
         mDebugRectPaint.setARGB(255, 255, 0, 0);
         mDebugRectPaint.setStyle(Paint.Style.STROKE);
+        mScreenOnPaint.setColor(0xFF009688);
+        mGpsOnPaint.setColor(0xFF009688);
+        mWifiRunningPaint.setColor(0xFF009688);
+        mCpuRunningPaint.setColor(0xFF009688);
+        mChargingPaint.setColor(0xFF009688);
 
         TypedArray a =
             context.obtainStyledAttributes(
@@ -442,6 +429,11 @@
 
                 case R.styleable.BatteryHistoryChart_barPrimaryColor:
                     mBatteryBackgroundPaint.setColor(a.getInt(attr, 0));
+                    mScreenOnPaint.setColor(a.getInt(attr, 0));
+                    mGpsOnPaint.setColor(a.getInt(attr, 0));
+                    mWifiRunningPaint.setColor(a.getInt(attr, 0));
+                    mCpuRunningPaint.setColor(a.getInt(attr, 0));
+                    mChargingPaint.setColor(a.getInt(attr, 0));
                     break;
 
                 case R.styleable.BatteryHistoryChart_barPredictionColor:
@@ -497,11 +489,9 @@
                 R.string.percentage, 0);
 
         int batteryLevel = com.android.settings.Utils.getBatteryLevel(mBatteryBroadcast);
-        final int status = mBatteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS,
-                BatteryManager.BATTERY_STATUS_UNKNOWN);
         long remainingTimeUs = 0;
         mDischarging = true;
-        if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) {
+        if (mBatteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) == 0) {
             final long drainTime = mStats.computeBatteryTimeRemaining(elapsedRealtimeUs);
             if (drainTime > 0) {
                 remainingTimeUs = drainTime;
@@ -517,6 +507,8 @@
             final long chargeTime = mStats.computeChargeTimeRemaining(elapsedRealtimeUs);
             final String statusLabel = com.android.settings.Utils.getBatteryStatus(getResources(),
                     mBatteryBroadcast);
+            final int status = mBatteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS,
+                    BatteryManager.BATTERY_STATUS_UNKNOWN);
             if (chargeTime > 0 && status != BatteryManager.BATTERY_STATUS_FULL) {
                 mDischarging = false;
                 remainingTimeUs = chargeTime;
@@ -706,17 +698,9 @@
                 // Compress lines to make more room for chart.
                 mLineWidth = textHeight/3;
             }
-            mScreenOnPaint.setARGB(255, 32, 64, 255);
-            mGpsOnPaint.setARGB(255, 32, 64, 255);
-            mWifiRunningPaint.setARGB(255, 32, 64, 255);
-            mCpuRunningPaint.setARGB(255, 32, 64, 255);
         } else {
             mLargeMode = false;
             mLineWidth = mThinLineWidth;
-            mScreenOnPaint.setARGB(255, 0, 0, 255);
-            mGpsOnPaint.setARGB(255, 0, 0, 255);
-            mWifiRunningPaint.setARGB(255, 0, 0, 255);
-            mCpuRunningPaint.setARGB(255, 0, 0, 255);
         }
         if (mLineWidth <= 0) mLineWidth = 1;
 
@@ -1033,7 +1017,7 @@
     void addTimeLabel(Calendar cal, int levelLeft, int levelRight, boolean is24hr) {
         final long walltimeStart = mStartWallTime;
         final long walltimeChange = mEndWallTime-walltimeStart;
-        mTimeLabels.add(new TimeLabel(getContext(), mTextPaint,
+        mTimeLabels.add(new TimeLabel(mTextPaint,
                 levelLeft + (int)(((cal.getTimeInMillis()-walltimeStart)*(levelRight-levelLeft))
                         / walltimeChange),
                 cal, is24hr));
@@ -1042,7 +1026,7 @@
     void addDateLabel(Calendar cal, int levelLeft, int levelRight, boolean isDayFirst) {
         final long walltimeStart = mStartWallTime;
         final long walltimeChange = mEndWallTime-walltimeStart;
-        mDateLabels.add(new DateLabel(getContext(), mTextPaint,
+        mDateLabels.add(new DateLabel(mTextPaint,
                 levelLeft + (int)(((cal.getTimeInMillis()-walltimeStart)*(levelRight-levelLeft))
                         / walltimeChange),
                 cal, isDayFirst));
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
new file mode 100644
index 0000000..808fb25
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2014 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.settings.fuelgauge;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.res.Resources;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Handler;
+import android.provider.Settings.Global;
+import android.util.Log;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.notification.SettingPref;
+
+public class BatterySaverSettings extends SettingsPreferenceFragment {
+    private static final String TAG = "BatterySaverSettings";
+    private static final String KEY_ALWAYS_ON = "always_on";
+    private static final String KEY_TURN_ON_AUTOMATICALLY = "turn_on_automatically";
+    private static final long WAIT_FOR_SWITCH_ANIM = 500;
+
+    private final Handler mHandler = new Handler();
+    private final SettingsObserver mSettingsObserver = new SettingsObserver(mHandler);
+
+    private Context mContext;
+    private boolean mCreated;
+    private SettingPref mAlwaysOnPref;
+    private SettingPref mTriggerPref;
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        if (mCreated) return;
+        mCreated = true;
+        addPreferencesFromResource(R.xml.battery_saver_settings);
+
+        mContext = getActivity();
+        mAlwaysOnPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_ALWAYS_ON,
+                Global.LOW_POWER_MODE, 0) {
+            @Override
+            protected boolean setSetting(Context context, int value) {
+                mHandler.removeCallbacks(mStartMode);
+                if (value == 0) {
+                    return super.setSetting(context, value);
+                } else {
+                    // about lose animations, make sure we don't turn the mode on until the switch
+                    // stops moving
+                    mHandler.postDelayed(mStartMode, WAIT_FOR_SWITCH_ANIM);
+                    return true;
+                }
+            }
+        };
+        mTriggerPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_TURN_ON_AUTOMATICALLY,
+                Global.LOW_POWER_MODE_TRIGGER_LEVEL,
+                mContext.getResources().getInteger(
+                        com.android.internal.R.integer.config_lowBatteryWarningLevel),
+                getResources().getIntArray(R.array.battery_saver_trigger_values)) {
+            @Override
+            protected String getCaption(Resources res, int value) {
+                if (value > 0 && value < 100) {
+                    return res.getString(R.string.battery_saver_turn_on_automatically_pct, value);
+                }
+                return res.getString(R.string.battery_saver_turn_on_automatically_never);
+            }
+        };
+        mAlwaysOnPref.init(this);
+        mTriggerPref.init(this);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        mSettingsObserver.setListening(true);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        mSettingsObserver.setListening(false);
+    }
+
+    private final Runnable mStartMode = new Runnable() {
+        @Override
+        public void run() {
+            AsyncTask.execute(new Runnable() {
+                @Override
+                public void run() {
+                    Log.d(TAG, "Starting LOW_POWER_MODE from settings");
+                    Global.putInt(mContext.getContentResolver(), Global.LOW_POWER_MODE, 1);
+                }
+            });
+        }
+    };
+
+    private final class SettingsObserver extends ContentObserver {
+        private final Uri LOW_POWER_MODE_URI = Global.getUriFor(Global.LOW_POWER_MODE);
+        private final Uri LOW_POWER_MODE_TRIGGER_LEVEL_URI
+                = Global.getUriFor(Global.LOW_POWER_MODE_TRIGGER_LEVEL);
+
+        public SettingsObserver(Handler handler) {
+            super(handler);
+        }
+
+        @Override
+        public void onChange(boolean selfChange, Uri uri) {
+            if (LOW_POWER_MODE_URI.equals(uri)) {
+                mAlwaysOnPref.update(mContext);
+            }
+            if (LOW_POWER_MODE_TRIGGER_LEVEL_URI.equals(uri)) {
+                mTriggerPref.update(mContext);
+            }
+        }
+
+        public void setListening(boolean listening) {
+            final ContentResolver cr = getContentResolver();
+            if (listening) {
+                cr.registerContentObserver(LOW_POWER_MODE_URI, false, this);
+                cr.registerContentObserver(LOW_POWER_MODE_TRIGGER_LEVEL_URI, false, this);
+            } else {
+                cr.unregisterContentObserver(this);
+            }
+        }
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index e4e2b0a..1159a2c 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -60,7 +60,8 @@
 
     private static final int MENU_STATS_TYPE = Menu.FIRST;
     private static final int MENU_STATS_REFRESH = Menu.FIRST + 1;
-    private static final int MENU_HELP = Menu.FIRST + 2;
+    private static final int MENU_BATTERY_SAVER = Menu.FIRST + 2;
+    private static final int MENU_HELP = Menu.FIRST + 3;
 
     private UserManager mUm;
 
@@ -180,6 +181,9 @@
         refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM |
                 MenuItem.SHOW_AS_ACTION_WITH_TEXT);
 
+        MenuItem batterySaver = menu.add(0, MENU_BATTERY_SAVER, 0, R.string.battery_saver);
+        batterySaver.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+
         String helpUrl;
         if (!TextUtils.isEmpty(helpUrl = getResources().getString(R.string.help_url_battery))) {
             final MenuItem help = menu.add(0, MENU_HELP, 0, R.string.help_label);
@@ -203,6 +207,11 @@
                 refreshStats();
                 mHandler.removeMessages(MSG_REFRESH_STATS);
                 return true;
+            case MENU_BATTERY_SAVER:
+                final SettingsActivity sa = (SettingsActivity) getActivity();
+                sa.startPreferencePanel(BatterySaverSettings.class.getName(), null,
+                        R.string.battery_saver, null, null, 0);
+                return true;
             default:
                 return false;
         }
diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
index 419a877..3351e63 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
@@ -166,7 +166,6 @@
                 if (mDialog == null) {
                     mDialog = (new AlertDialog.Builder(getActivity()))
                             .setTitle(android.R.string.dialog_alert_title)
-                            .setIconAttribute(android.R.attr.alertDialogIcon)
                             .setCancelable(true)
                             .setPositiveButton(android.R.string.ok,
                                     new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java
index 1d920de..e04f2c7 100644
--- a/src/com/android/settings/inputmethod/InputMethodPreference.java
+++ b/src/com/android/settings/inputmethod/InputMethodPreference.java
@@ -265,7 +265,6 @@
         }
         mDialog = (new AlertDialog.Builder(mFragment.getActivity()))
                 .setTitle(android.R.string.dialog_alert_title)
-                .setIconAttribute(android.R.attr.alertDialogIcon)
                 .setCancelable(true)
                 .setPositiveButton(android.R.string.ok,
                         new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/inputmethod/SpellCheckersSettings.java b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
index 8b1b867..03867c7 100644
--- a/src/com/android/settings/inputmethod/SpellCheckersSettings.java
+++ b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
@@ -122,7 +122,6 @@
         }
         mDialog = (new AlertDialog.Builder(getActivity()))
                 .setTitle(android.R.string.dialog_alert_title)
-                .setIconAttribute(android.R.attr.alertDialogIcon)
                 .setCancelable(true)
                 .setPositiveButton(android.R.string.ok,
                         new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 8794a8d..b10d4b6 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -73,6 +73,16 @@
 
         mSwitchBar = activity.getSwitchBar();
         mSwitch = mSwitchBar.getSwitch();
+        mSwitchBar.addOnSwitchChangeListener(this);
+        mSwitchBar.show();
+    }
+
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+
+        mSwitchBar.removeOnSwitchChangeListener(this);
+        mSwitchBar.hide();
     }
 
     @Override
@@ -84,8 +94,6 @@
     public void onResume() {
         super.onResume();
         createPreferenceHierarchy();
-        mSwitchBar.addOnSwitchChangeListener(this);
-        mSwitchBar.show();
         mValidListener = true;
     }
 
@@ -97,8 +105,6 @@
             // Ignore exceptions caused by race condition
         }
         super.onPause();
-        mSwitchBar.removeOnSwitchChangeListener(this);
-        mSwitchBar.hide();
         mValidListener = false;
     }
 
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java
index eb3ff9b..add0fa7 100644
--- a/src/com/android/settings/nfc/AndroidBeam.java
+++ b/src/com/android/settings/nfc/AndroidBeam.java
@@ -33,7 +33,6 @@
     private View mView;
     private NfcAdapter mNfcAdapter;
     private SwitchBar mSwitchBar;
-    private Switch mSwitch;
     private CharSequence mOldActivityTitle;
 
     @Override
@@ -63,46 +62,33 @@
         SettingsActivity activity = (SettingsActivity) getActivity();
 
         mSwitchBar = activity.getSwitchBar();
-        mSwitch = mSwitchBar.getSwitch();
-        mSwitch.setChecked(mNfcAdapter.isNdefPushEnabled());
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
+        mSwitchBar.setChecked(mNfcAdapter.isNdefPushEnabled());
         mSwitchBar.addOnSwitchChangeListener(this);
         mSwitchBar.show();
     }
 
     @Override
-    public void onPause() {
-        super.onPause();
-
-        mSwitchBar.removeOnSwitchChangeListener(this);
-        mSwitchBar.hide();
-    }
-
-    @Override
     public void onDestroyView() {
         super.onDestroyView();
         if (mOldActivityTitle != null) {
             getActivity().getActionBar().setTitle(mOldActivityTitle);
         }
+        mSwitchBar.removeOnSwitchChangeListener(this);
+        mSwitchBar.hide();
     }
 
     @Override
     public void onSwitchChanged(Switch switchView, boolean desiredState) {
         boolean success = false;
-        mSwitch.setEnabled(false);
+        mSwitchBar.setEnabled(false);
         if (desiredState) {
             success = mNfcAdapter.enableNdefPush();
         } else {
             success = mNfcAdapter.disableNdefPush();
         }
         if (success) {
-            mSwitch.setChecked(desiredState);
+            mSwitchBar.setChecked(desiredState);
         }
-        mSwitch.setEnabled(true);
+        mSwitchBar.setEnabled(true);
     }
 }
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 91035732..ec8af26 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -20,6 +20,7 @@
 import android.app.AlertDialog;
 import android.app.INotificationManager;
 import android.app.ListFragment;
+import android.app.Notification;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
@@ -65,10 +66,22 @@
     private static final String TAG = "AppNotificationSettings";
     private static final boolean DEBUG = true;
 
+    /**
+     * Show a checkbox in the per-app notification control dialog to allow the user
+     * to promote this app's notifications to higher priority.
+     */
+    private static final boolean ENABLE_APP_NOTIFICATION_PRIORITY_OPTION = false;
+    /**
+     * Show a checkbox in the per-app notification control dialog to allow the user to
+     * selectively redact this app's notifications on the lockscreen.
+     */
+    private static final boolean ENABLE_APP_NOTIFICATION_PRIVACY_OPTION = false;
+
     private static final String SECTION_BEFORE_A = "*";
     private static final String SECTION_AFTER_Z = "**";
     private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
-            = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_NOTIFICATION_PREFERENCES);
+            = new Intent(Intent.ACTION_MAIN)
+                .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
 
     private final Handler mHandler = new Handler();
     private final ArrayMap<String, AppRow> mRows = new ArrayMap<String, AppRow>();
@@ -187,6 +200,14 @@
         final CheckBox priBox = (CheckBox) layout.findViewById(android.R.id.button2);
         final CheckBox senBox = (CheckBox) layout.findViewById(android.R.id.button3);
 
+        if (!ENABLE_APP_NOTIFICATION_PRIORITY_OPTION) {
+            priBox.setVisibility(View.GONE);
+        }
+
+        if (!ENABLE_APP_NOTIFICATION_PRIVACY_OPTION) {
+            senBox.setVisibility(View.GONE);
+        }
+
         showBox.setChecked(!row.banned);
         final OnCheckedChangeListener showListener = new OnCheckedChangeListener() {
             @Override
diff --git a/src/com/android/settings/notification/DropDownPreference.java b/src/com/android/settings/notification/DropDownPreference.java
index 36ecf95..45c83a5 100644
--- a/src/com/android/settings/notification/DropDownPreference.java
+++ b/src/com/android/settings/notification/DropDownPreference.java
@@ -97,8 +97,12 @@
         }
     }
 
-    public void addItem(int resId, Object value) {
-        mAdapter.add(mContext.getResources().getString(resId));
+    public void addItem(int captionResid, Object value) {
+        addItem(mContext.getResources().getString(captionResid), value);
+    }
+
+    public void addItem(String caption, Object value) {
+        mAdapter.add(caption);
         mValues.add(value);
     }
 
diff --git a/src/com/android/settings/notification/ManagedServiceSettings.java b/src/com/android/settings/notification/ManagedServiceSettings.java
index 1144cb9..880ecde 100644
--- a/src/com/android/settings/notification/ManagedServiceSettings.java
+++ b/src/com/android/settings/notification/ManagedServiceSettings.java
@@ -106,7 +106,6 @@
             return new AlertDialog.Builder(getActivity())
                     .setMessage(summary)
                     .setTitle(title)
-                    .setIconAttribute(android.R.attr.alertDialogIcon)
                     .setCancelable(true)
                     .setPositiveButton(android.R.string.ok,
                             new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/notification/OtherSoundSettings.java b/src/com/android/settings/notification/OtherSoundSettings.java
index de5c917..8528ec7 100644
--- a/src/com/android/settings/notification/OtherSoundSettings.java
+++ b/src/com/android/settings/notification/OtherSoundSettings.java
@@ -21,6 +21,7 @@
 
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.res.Resources;
 import android.database.ContentObserver;
 import android.media.AudioManager;
 import android.net.Uri;
@@ -114,10 +115,15 @@
         }
 
         @Override
-        protected int getResId(Context context, int value) {
-            if (value == DOCK_AUDIO_MEDIA_DISABLED) return R.string.dock_audio_media_disabled;
-            if (value == DOCK_AUDIO_MEDIA_ENABLED) return R.string.dock_audio_media_enabled;
-            throw new IllegalArgumentException();
+        protected String getCaption(Resources res, int value) {
+            switch(value) {
+                case DOCK_AUDIO_MEDIA_DISABLED:
+                    return res.getString(R.string.dock_audio_media_disabled);
+                case DOCK_AUDIO_MEDIA_ENABLED:
+                    return res.getString(R.string.dock_audio_media_enabled);
+                default:
+                    throw new IllegalArgumentException();
+            }
         }
     };
 
@@ -131,11 +137,17 @@
         }
 
         @Override
-        protected int getResId(Context context, int value) {
-            if (value == EMERGENCY_TONE_SILENT) return R.string.emergency_tone_silent;
-            if (value == EMERGENCY_TONE_ALERT) return R.string.emergency_tone_alert;
-            if (value == EMERGENCY_TONE_VIBRATE) return R.string.emergency_tone_vibrate;
-            throw new IllegalArgumentException();
+        protected String getCaption(Resources res, int value) {
+            switch(value) {
+                case EMERGENCY_TONE_SILENT:
+                    return res.getString(R.string.emergency_tone_silent);
+                case EMERGENCY_TONE_ALERT:
+                    return res.getString(R.string.emergency_tone_alert);
+                case EMERGENCY_TONE_VIBRATE:
+                    return res.getString(R.string.emergency_tone_vibrate);
+                default:
+                    throw new IllegalArgumentException();
+            }
         }
     };
 
diff --git a/src/com/android/settings/notification/SettingPref.java b/src/com/android/settings/notification/SettingPref.java
index 1e50e2b..7fd89d8 100644
--- a/src/com/android/settings/notification/SettingPref.java
+++ b/src/com/android/settings/notification/SettingPref.java
@@ -18,6 +18,7 @@
 
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.res.Resources;
 import android.net.Uri;
 import android.preference.Preference;
 import android.preference.TwoStatePreference;
@@ -55,7 +56,7 @@
         return true;
     }
 
-    protected int getResId(Context context, int value) {
+    protected String getCaption(Resources res, int value) {
         throw new UnsupportedOperationException();
     }
 
@@ -71,7 +72,7 @@
         } else if (p instanceof DropDownPreference) {
             mDropDown = (DropDownPreference) p;
             for (int value : mValues) {
-                mDropDown.addItem(getResId(context, value), value);
+                mDropDown.addItem(getCaption(context.getResources(), value), value);
             }
         }
         update(context);
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index e9323d8..40e2c55 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -107,7 +107,6 @@
     private final SettingsObserver mSettingsObserver = new SettingsObserver();
 
     private SwitchBar mSwitchBar;
-    private Switch mSwitch;
     private Context mContext;
     private PackageManager mPM;
     private ZenModeConfig mConfig;
@@ -159,7 +158,8 @@
         if (DEBUG) Log.d(TAG, "Loaded mConfig=" + mConfig);
 
         mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
-        mSwitch = mSwitchBar.getSwitch();
+        mSwitchBar.addOnSwitchChangeListener(this);
+        mSwitchBar.show();
 
         final PreferenceCategory general = (PreferenceCategory) root.findPreference(KEY_GENERAL);
 
@@ -400,14 +400,17 @@
         updateControls();
         updateZenMode();
         mSettingsObserver.register();
-        mSwitchBar.addOnSwitchChangeListener(this);
-        mSwitchBar.show();
     }
 
     @Override
     public void onPause() {
         super.onPause();
         mSettingsObserver.unregister();
+    }
+
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
         mSwitchBar.removeOnSwitchChangeListener(this);
         mSwitchBar.hide();
     }
@@ -415,8 +418,8 @@
     private void updateZenMode() {
         final boolean zenMode = Global.getInt(getContentResolver(),
                 Global.ZEN_MODE, Global.ZEN_MODE_OFF) != Global.ZEN_MODE_OFF;
-        if (mSwitch.isChecked() != zenMode) {
-            mSwitch.setChecked(zenMode);
+        if (mSwitchBar.isChecked() != zenMode) {
+            mSwitchBar.setChecked(zenMode);
             mIgnoreNext = true;
         }
     }
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index 9a991dd..7af6338 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -143,16 +143,12 @@
         mSettingsContentObserver.register(getContentResolver());
         updateEmptyView();
         updateUiForServiceState();
-        mSwitchBar.addOnSwitchChangeListener(this);
-        mSwitchBar.show();
     }
 
     @Override
     public void onPause() {
         mSettingsContentObserver.unregister(getContentResolver());
         super.onPause();
-        mSwitchBar.removeOnSwitchChangeListener(this);
-        mSwitchBar.hide();
     }
 
     @Override
@@ -168,6 +164,8 @@
             getActivity().getActionBar().setTitle(mOldActivityTitle);
         }
         super.onDestroyView();
+        mSwitchBar.removeOnSwitchChangeListener(this);
+        mSwitchBar.hide();
     }
 
     private void onPreferenceToggled(String preferenceKey, boolean enabled) {
@@ -195,7 +193,6 @@
         }
         return new AlertDialog.Builder(getActivity())
                 .setTitle(title)
-                .setIconAttribute(android.R.attr.alertDialogIcon)
                 .setMessage(message)
                 .setCancelable(true)
                 .setPositiveButton(android.R.string.ok, this)
@@ -293,6 +290,8 @@
         final SettingsActivity activity = (SettingsActivity) getActivity();
 
         mSwitchBar = activity.getSwitchBar();
+        mSwitchBar.addOnSwitchChangeListener(this);
+        mSwitchBar.show();
 
         mToggleSwitch = mSwitchBar.getSwitch();
         mToggleSwitch.setOnBeforeCheckedChangeListener(new ToggleSwitch.OnBeforeCheckedChangeListener() {
diff --git a/src/com/android/settings/quicklaunch/QuickLaunchSettings.java b/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
index 0081a1e..a7ddc07 100644
--- a/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
+++ b/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
@@ -153,7 +153,6 @@
                 // Create the dialog for clearing a shortcut
                 return new AlertDialog.Builder(getActivity())
                         .setTitle(getString(R.string.quick_launch_clear_dialog_title))
-                        .setIconAttribute(android.R.attr.alertDialogIcon)
                         .setMessage(getString(R.string.quick_launch_clear_dialog_message,
                                 mClearDialogShortcut, mClearDialogBookmarkTitle))
                         .setPositiveButton(R.string.quick_launch_clear_ok_button, this)
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index 074a8d7..80ea83a 100644
--- a/src/com/android/settings/search/Ranking.java
+++ b/src/com/android/settings/search/Ranking.java
@@ -30,6 +30,7 @@
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.bluetooth.BluetoothSettings;
 import com.android.settings.deviceinfo.Memory;
+import com.android.settings.fuelgauge.BatterySaverSettings;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
 import com.android.settings.location.LocationSettings;
@@ -103,6 +104,7 @@
         sRankMap.put(Memory.class.getName(), RANK_MEMORY);
 
         sRankMap.put(PowerUsageSummary.class.getName(), RANK_POWER_USAGE);
+        sRankMap.put(BatterySaverSettings.class.getName(), RANK_POWER_USAGE);
 
         sRankMap.put(UserSettings.class.getName(), RANK_USERS);
 
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 7c96a4a..086ebfc 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -33,6 +33,7 @@
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.bluetooth.BluetoothSettings;
 import com.android.settings.deviceinfo.Memory;
+import com.android.settings.fuelgauge.BatterySaverSettings;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
 import com.android.settings.location.LocationSettings;
@@ -154,6 +155,13 @@
                         PowerUsageSummary.class.getName(),
                         R.drawable.ic_settings_battery));
 
+        sResMap.put(BatterySaverSettings.class.getName(),
+                new SearchIndexableResource(
+                        Ranking.getRankForClassName(BatterySaverSettings.class.getName()),
+                        R.xml.battery_saver_settings,
+                        BatterySaverSettings.class.getName(),
+                        R.drawable.ic_settings_battery));
+
         sResMap.put(UserSettings.class.getName(),
                 new SearchIndexableResource(
                         Ranking.getRankForClassName(UserSettings.class.getName()),
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 4a98661..d3f9c7b 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -482,11 +482,10 @@
 
     private void displayNetworkAlert() {
         AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-        builder.setTitle(android.R.string.dialog_alert_title);
-        builder.setIconAttribute(android.R.attr.alertDialogIcon);
-        builder.setMessage(getActivity().getString(R.string.tts_engine_network_required));
-        builder.setCancelable(false);
-        builder.setPositiveButton(android.R.string.ok, null);
+        builder.setTitle(android.R.string.dialog_alert_title)
+                .setMessage(getActivity().getString(R.string.tts_engine_network_required))
+                .setCancelable(false)
+                .setPositiveButton(android.R.string.ok, null);
 
         AlertDialog dialog = builder.create();
         dialog.show();
diff --git a/src/com/android/settings/tts/TtsEnginePreference.java b/src/com/android/settings/tts/TtsEnginePreference.java
index 7e50c47..ae921f8 100644
--- a/src/com/android/settings/tts/TtsEnginePreference.java
+++ b/src/com/android/settings/tts/TtsEnginePreference.java
@@ -198,13 +198,12 @@
         Log.i(TAG, "Displaying data alert for :" + mEngineInfo.name);
 
         AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
-        builder.setTitle(android.R.string.dialog_alert_title);
-        builder.setIconAttribute(android.R.attr.alertDialogIcon);
-        builder.setMessage(getContext().getString(
-                R.string.tts_engine_security_warning, mEngineInfo.label));
-        builder.setCancelable(true);
-        builder.setPositiveButton(android.R.string.ok, positiveOnClickListener);
-        builder.setNegativeButton(android.R.string.cancel, negativeOnClickListener);
+        builder.setTitle(android.R.string.dialog_alert_title)
+                .setMessage(getContext().getString(
+                        R.string.tts_engine_security_warning, mEngineInfo.label))
+                .setCancelable(true)
+                .setPositiveButton(android.R.string.ok, positiveOnClickListener)
+                .setNegativeButton(android.R.string.cancel, negativeOnClickListener);
 
         AlertDialog dialog = builder.create();
         dialog.show();
diff --git a/src/com/android/settings/users/RestrictedProfileSettings.java b/src/com/android/settings/users/RestrictedProfileSettings.java
index c293536..535e196 100644
--- a/src/com/android/settings/users/RestrictedProfileSettings.java
+++ b/src/com/android/settings/users/RestrictedProfileSettings.java
@@ -202,7 +202,6 @@
 
             mEditUserInfoDialog = new AlertDialog.Builder(getActivity())
                 .setTitle(R.string.profile_info_settings_title)
-                .setIconAttribute(R.drawable.ic_settings_multiuser)
                 .setView(content)
                 .setCancelable(true)
                 .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/users/UserPreference.java b/src/com/android/settings/users/UserPreference.java
index 9f53aa5..56ca114 100644
--- a/src/com/android/settings/users/UserPreference.java
+++ b/src/com/android/settings/users/UserPreference.java
@@ -58,11 +58,13 @@
 
     @Override
     protected void onBindView(View view) {
+        UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
         View deleteDividerView = view.findViewById(R.id.divider_delete);
         View manageDividerView = view.findViewById(R.id.divider_manage);
         View deleteView = view.findViewById(R.id.trash_user);
         if (deleteView != null) {
-            if (mDeleteClickListener != null) {
+            if (mDeleteClickListener != null
+                    && !um.hasUserRestriction(UserManager.DISALLOW_REMOVE_USER)) {
                 deleteView.setOnClickListener(mDeleteClickListener);
                 deleteView.setTag(this);
             } else {
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 901ee50..8d27c65 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -64,12 +64,12 @@
 import com.android.settings.ChooseLockGeneric;
 import com.android.settings.OwnerInfoSettings;
 import com.android.settings.R;
-import com.android.settings.RestrictedSettingsFragment;
 import com.android.settings.SelectableEditTextPreference;
 import com.android.settings.SettingsActivity;
+import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.Utils;
 
-public class UserSettings extends RestrictedSettingsFragment
+public class UserSettings extends SettingsPreferenceFragment
         implements OnPreferenceClickListener, OnClickListener, DialogInterface.OnDismissListener,
         Preference.OnPreferenceChangeListener {
 
@@ -136,10 +136,6 @@
     private SparseArray<Bitmap> mUserIcons = new SparseArray<Bitmap>();
     private boolean mIsOwner = UserHandle.myUserId() == UserHandle.USER_OWNER;
 
-    public UserSettings() {
-        super(RestrictedSettingsFragment.RESTRICTIONS_PIN_SET);
-    }
-
     private Handler mHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
@@ -204,7 +200,8 @@
         }
         mAddUser = findPreference(KEY_ADD_USER);
         if (!mIsOwner || UserManager.getMaxSupportedUsers() < 2
-                || !UserManager.supportsMultipleUsers()) {
+                || !UserManager.supportsMultipleUsers()
+                || mUserManager.hasUserRestriction(UserManager.DISALLOW_ADD_USER)) {
             removePreference(KEY_ADD_USER);
         } else {
             mAddUser.setOnPreferenceClickListener(this);
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 73aae99..ea6325e 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -29,8 +29,10 @@
 import android.os.Message;
 import android.os.ServiceManager;
 import android.os.SystemProperties;
+import android.os.UserManager;
 import android.preference.Preference;
 import android.preference.PreferenceGroup;
+import android.preference.PreferenceScreen;
 import android.security.Credentials;
 import android.security.KeyStore;
 import android.text.TextUtils;
@@ -45,6 +47,7 @@
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.android.internal.net.LegacyVpnInfo;
@@ -80,14 +83,25 @@
 
     private Handler mUpdater;
     private LegacyVpnInfo mInfo;
+    private UserManager mUm;
 
     // The key of the profile for the current ContextMenu.
     private String mSelectedKey;
 
+    private boolean mUnavailable;
+
     @Override
     public void onCreate(Bundle savedState) {
         super.onCreate(savedState);
 
+        mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+
+        if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) {
+            mUnavailable = true;
+            setPreferenceScreen(new PreferenceScreen(getActivity(), null));
+            return;
+        }
+
         setHasOptionsMenu(true);
         addPreferencesFromResource(R.xml.vpn_settings2);
 
@@ -156,6 +170,15 @@
     public void onResume() {
         super.onResume();
 
+        if (mUnavailable) {
+            TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
+            getListView().setEmptyView(emptyView);
+            if (emptyView != null) {
+                emptyView.setText(R.string.vpn_settings_not_available);
+            }
+            return;
+        }
+
         final boolean pickLockdown = getActivity()
                 .getIntent().getBooleanExtra(EXTRA_PICK_LOCKDOWN, false);
         if (pickLockdown) {
@@ -214,6 +237,10 @@
     public void onPause() {
         super.onPause();
 
+        if (mUnavailable) {
+            return;
+        }
+
         // Hide the dialog if there is one.
         if (mDialog != null) {
             mDialog.setOnDismissListener(null);
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index bc06d87..b503cf6 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -17,10 +17,11 @@
 package com.android.settings.widget;
 
 import android.content.Context;
+import android.os.Parcel;
+import android.os.Parcelable;
 import android.transition.TransitionManager;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
-import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.CompoundButton;
@@ -72,12 +73,11 @@
         mTextView.setText(R.string.switch_off_text);
 
         mSwitch = (ToggleSwitch) findViewById(R.id.switch_widget);
-        mSwitch.setOnCheckedChangeListener(this);
 
         addOnSwitchChangeListener(new OnSwitchChangeListener() {
             @Override
             public void onSwitchChanged(Switch switchView, boolean isChecked) {
-                mTextView.setText(isChecked ? R.string.switch_on_text : R.string.switch_off_text);
+                setTextViewLabel(isChecked);
             }
         });
 
@@ -90,18 +90,41 @@
         setVisibility(View.GONE);
     }
 
-    public ToggleSwitch getSwitch() {
+    public void setTextViewLabel(boolean isChecked) {
+        mTextView.setText(isChecked ? R.string.switch_on_text : R.string.switch_off_text);
+    }
+
+    public void setChecked(boolean checked) {
+        setTextViewLabel(checked);
+        mSwitch.setChecked(checked);
+    }
+
+    public boolean isChecked() {
+        return mSwitch.isChecked();
+    }
+
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        mTextView.setEnabled(enabled);
+        mSwitch.setEnabled(false);
+    }
+
+    public final ToggleSwitch getSwitch() {
         return mSwitch;
     }
 
     public void show() {
-        TransitionManager.beginDelayedTransition((ViewGroup) getParent());
-        setVisibility(View.VISIBLE);
+        if (!isShowing()) {
+            setVisibility(View.VISIBLE);
+            mSwitch.setOnCheckedChangeListener(this);
+        }
     }
 
     public void hide() {
-        TransitionManager.beginDelayedTransition((ViewGroup) getParent());
-        setVisibility(View.GONE);
+        if (isShowing()) {
+            setVisibility(View.GONE);
+            mSwitch.setOnCheckedChangeListener(null);
+        }
     }
 
     public boolean isShowing() {
@@ -139,4 +162,69 @@
         }
         mSwitchChangeListeners.remove(listener);
     }
+
+    static class SavedState extends BaseSavedState {
+        boolean checked;
+        boolean visible;
+
+        SavedState(Parcelable superState) {
+            super(superState);
+        }
+
+        /**
+         * Constructor called from {@link #CREATOR}
+         */
+        private SavedState(Parcel in) {
+            super(in);
+            checked = (Boolean)in.readValue(null);
+            visible = (Boolean)in.readValue(null);
+        }
+
+        @Override
+        public void writeToParcel(Parcel out, int flags) {
+            super.writeToParcel(out, flags);
+            out.writeValue(checked);
+            out.writeValue(visible);
+        }
+
+        @Override
+        public String toString() {
+            return "SwitchBar.SavedState{"
+                    + Integer.toHexString(System.identityHashCode(this))
+                    + " checked=" + checked
+                    + " visible=" + visible + "}";
+        }
+
+        public static final Parcelable.Creator<SavedState> CREATOR
+                = new Parcelable.Creator<SavedState>() {
+            public SavedState createFromParcel(Parcel in) {
+                return new SavedState(in);
+            }
+
+            public SavedState[] newArray(int size) {
+                return new SavedState[size];
+            }
+        };
+    }
+
+    @Override
+    public Parcelable onSaveInstanceState() {
+        Parcelable superState = super.onSaveInstanceState();
+
+        SavedState ss = new SavedState(superState);
+        ss.checked = mSwitch.isChecked();
+        ss.visible = isShowing();
+        return ss;
+    }
+
+    @Override
+    public void onRestoreInstanceState(Parcelable state) {
+        SavedState ss = (SavedState) state;
+
+        super.onRestoreInstanceState(ss.getSuperState());
+        mSwitch.setChecked(ss.checked);
+        setTextViewLabel(ss.checked);
+        setVisibility(ss.visible ? View.VISIBLE : View.GONE);
+        requestLayout();
+    }
 }
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 4ac9112..cd08565 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -19,6 +19,7 @@
 import com.android.settings.R;
 
 import android.content.Context;
+import android.graphics.drawable.Drawable;
 import android.net.NetworkInfo.DetailedState;
 import android.net.wifi.ScanResult;
 import android.net.wifi.WifiConfiguration;
@@ -48,6 +49,8 @@
     };
     private static final int[] STATE_NONE = {};
 
+    private static int[] wifi_signal_attributes = { R.attr.wifi_signal };
+
     /** These values are matched in string arrays -- changes must be kept in sync */
     static final int SECURITY_NONE = 0;
     static final int SECURITY_WEP = 1;
@@ -163,21 +166,18 @@
 
     AccessPoint(Context context, WifiConfiguration config) {
         super(context);
-        setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
         loadConfig(config);
         refresh();
     }
 
     AccessPoint(Context context, ScanResult result) {
         super(context);
-        setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
         loadResult(result);
         refresh();
     }
 
     AccessPoint(Context context, Bundle savedState) {
         super(context);
-        setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
 
         mConfig = savedState.getParcelable(KEY_CONFIG);
         if (mConfig != null) {
@@ -228,18 +228,28 @@
     @Override
     protected void onBindView(View view) {
         super.onBindView(view);
-        ImageView signal = (ImageView) view.findViewById(R.id.signal);
-        if (mRssi == Integer.MAX_VALUE) {
-            signal.setImageDrawable(null);
+        updateIcon(getLevel());
+        notifyChanged();
+    }
+
+    protected void updateIcon(int level) {
+        if (level == -1) {
+            setIcon(null);
         } else {
-            signal.setImageLevel(getLevel());
-            signal.setImageDrawable(getContext().getTheme().obtainStyledAttributes(
-                    new int[] {R.attr.wifi_signal}).getDrawable(0));
-            signal.setImageState((security != SECURITY_NONE) ?
-                    STATE_SECURED : STATE_NONE, true);
+            Drawable drawable = getIcon();
+
+            if (drawable == null) {
+                drawable = getContext().getTheme().obtainStyledAttributes(
+                        wifi_signal_attributes).getDrawable(0);
+                setIcon(drawable);
+            }
+
+            drawable.setLevel(level);
+            drawable.setState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE);
         }
     }
 
+
     @Override
     public int compareTo(Preference preference) {
         if (!(preference instanceof AccessPoint)) {
@@ -253,6 +263,7 @@
         // Reachable one goes before unreachable one.
         if (mRssi != Integer.MAX_VALUE && other.mRssi == Integer.MAX_VALUE) return -1;
         if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
+        if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
 
         // Configured one goes before unconfigured one.
         if (networkId != WifiConfiguration.INVALID_NETWORK_ID
@@ -368,7 +379,7 @@
     }
 
     /** visibility status of the WifiConfiguration
-     * @return RSSI and update indicator
+     * @return autojoin debugging information
      * TODO: use a string formatter
      * ["rssi 5Ghz", "num results on 5GHz" / "rssi 5Ghz", "num results on 5GHz"]
      * For instance [-40,5/-30,2]
@@ -380,12 +391,22 @@
         long age = (now - mSeen);
         if (age < VISIBILITY_MAX_AGE_IN_MILLI) {
             //show age in seconds, in the form xx
-            visibility.append(Long.toString((age / SECOND_TO_MILLI) % SECOND_TO_MILLI));
+            visibility.append(Long.toString((age / SECOND_TO_MILLI) % SECOND_TO_MILLI))
+                    .append("s");
         } else {
             //not seen for more than 1000 seconds
             visibility.append("!");
         }
 
+        if (mInfo != null) {
+            visibility.append(" sc=").append(Integer.toString(mInfo.score));
+            visibility.append(" ");
+            visibility.append(String.format("tx=%.1f,", mInfo.txSuccessRate));
+            visibility.append(String.format("%.1f,", mInfo.txRetriesRate));
+            visibility.append(String.format("%.1f ", mInfo.txBadRate));
+            visibility.append(String.format("rx=%.1f", mInfo.rxSuccessRate));
+        }
+
         if (scanResultCache != null) {
             int rssi5 = WifiConfiguration.INVALID_RSSI;
             int rssi24 = WifiConfiguration.INVALID_RSSI;
@@ -438,7 +459,7 @@
             visibility.append("]");
         } else {
             if (mRssi != Integer.MAX_VALUE) {
-                visibility.append(", ");
+                visibility.append(", ss=");
                 visibility.append(Integer.toString(mRssi));
                 if (mScanResult != null) {
                     visibility.append(", ");
@@ -446,18 +467,25 @@
                 }
             }
         }
+
         return visibility.toString();
     }
 
     /** Updates the title and summary; may indirectly call notifyChanged()  */
     private void refresh() {
         setTitle(ssid);
+        updateIcon(getLevel());
+
         StringBuilder summary = new StringBuilder();
 
         Context context = getContext();
-        if (mConfig != null && (mConfig.status == WifiConfiguration.Status.DISABLED
-                || mConfig.autoJoinStatus != WifiConfiguration.AUTO_JOIN_ENABLED)) {
-            if (mConfig.autoJoinStatus != WifiConfiguration.AUTO_JOIN_ENABLED) {
+
+        if (mState != null) { // This is the active connection
+            summary.append(Summary.get(context, mState));
+        } else if (mConfig != null && ((mConfig.status == WifiConfiguration.Status.DISABLED &&
+                mConfig.disableReason != WifiConfiguration.DISABLED_UNKNOWN_REASON)
+               || mConfig.autoJoinStatus >= WifiConfiguration.AUTO_JOIN_DISABLED_ON_AUTH_FAILURE)) {
+            if (mConfig.autoJoinStatus >= WifiConfiguration.AUTO_JOIN_DISABLED_ON_AUTH_FAILURE) {
                 summary.append(context.getString(R.string.wifi_disabled_password_failure));
             } else {
                 switch (mConfig.disableReason) {
@@ -469,13 +497,13 @@
                         summary.append(context.getString(R.string.wifi_disabled_network_failure));
                         break;
                     case WifiConfiguration.DISABLED_UNKNOWN_REASON:
+                        //this state is not useful anymore as auto-join may attempt joining
+                        //those networks
                         summary.append(context.getString(R.string.wifi_disabled_generic));
                 }
             }
         } else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
             summary.append(context.getString(R.string.wifi_not_in_range));
-        } else if (mState != null) { // This is the active connection
-            summary.append(Summary.get(context, mState));
         } else { // In range, not disabled.
             if (mConfig != null) { // Is saved network
                 summary.append(context.getString(R.string.wifi_remembered));
@@ -502,7 +530,25 @@
         if (WifiSettings.mVerboseLogging > 0) {
             //add RSSI/band information for this config, what was seen up to 6 seconds ago
             //verbose WiFi Logging is only turned on thru developers settings
+            if (mInfo != null && mState != null) { // This is the active connection
+                summary.append(" (f=" + Integer.toString(mInfo.getFrequency()) + ")");
+            }
             summary.append(" " + getVisibilityStatus());
+            if (mConfig != null && mConfig.autoJoinStatus > 0) {
+                summary.append(" (" + mConfig.autoJoinStatus);
+                if (mConfig.blackListTimestamp > 0) {
+                    long now = System.currentTimeMillis();
+                    long diff = (now - mConfig.blackListTimestamp)/1000;
+                    long sec = diff%60; //seconds
+                    long min = (diff/60)%60; //minutes
+                    long hour = (min/60)%60; //hours
+                    summary.append(", ");
+                    if (hour > 0) summary.append(Long.toString(hour) + "h ");
+                    summary.append( Long.toString(min) + "m ");
+                    summary.append( Long.toString(sec) + "s ");
+                }
+                summary.append(")");
+            }
         }
         setSummary(summary.toString());
     }
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index d190045..dc3974e 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -100,20 +100,27 @@
         // The order matters! We really should not depend on this. :(
         mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
         mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
+        setupSwitchBar();
+    }
+
+    public void setupSwitchBar() {
+        mSwitchBar.addOnSwitchChangeListener(this);
+        mSwitchBar.show();
+    }
+
+    public void teardownSwitchBar() {
+        mSwitchBar.removeOnSwitchChangeListener(this);
+        mSwitchBar.hide();
     }
 
     public void resume(Context context) {
         mContext = context;
         // Wi-Fi state is sticky, so just let the receiver update UI
         mContext.registerReceiver(mReceiver, mIntentFilter);
-        mSwitchBar.addOnSwitchChangeListener(this);
-        mSwitchBar.show();
     }
 
     public void pause() {
         mContext.unregisterReceiver(mReceiver);
-        mSwitchBar.removeOnSwitchChangeListener(this);
-        mSwitchBar.hide();
     }
 
     private void handleWifiStateChanged(int state) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 3420f36..ec77937 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -136,8 +136,6 @@
     private AccessPoint mDlgAccessPoint;
     private Bundle mAccessPointSavedState;
 
-    private SwitchBar mSwitchBar;
-
     /** verbose logging flag. this flag is set thru developer debugging options
      * and used so as to assist with in-the-field WiFi connectivity debugging  */
     public static int mVerboseLogging = 0;
@@ -233,6 +231,15 @@
     }
 
     @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+
+        if (mWifiEnabler != null) {
+            mWifiEnabler.teardownSwitchBar();
+        }
+    }
+
+    @Override
     public void onStart() {
         super.onStart();