Merge "Code clean-ups following moving the managed profile under accounts" into lmp-dev
diff --git a/res/drawable/ring_notif.xml b/res/drawable/ring_notif.xml
new file mode 100644
index 0000000..414a83d
--- /dev/null
+++ b/res/drawable/ring_notif.xml
@@ -0,0 +1,24 @@
+<!--
+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.
+-->
+<!-- shrink ic_audio_ring_notif from 32dp to 24dp using insets -->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+        android:drawable="@*android:drawable/ic_audio_ring_notif"
+        android:insetLeft="4dp"
+        android:insetRight="4dp"
+        android:insetTop="4dp"
+        android:insetBottom="4dp"
+        />
+
diff --git a/res/drawable/ring_notif_mute.xml b/res/drawable/ring_notif_mute.xml
new file mode 100644
index 0000000..afb835c
--- /dev/null
+++ b/res/drawable/ring_notif_mute.xml
@@ -0,0 +1,23 @@
+<!--
+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.
+-->
+<!-- shrink ic_audio_ring_notif_mute from 32dp to 24dp using insets -->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+        android:drawable="@*android:drawable/ic_audio_ring_notif_mute"
+        android:insetLeft="4dp"
+        android:insetRight="4dp"
+        android:insetTop="4dp"
+        android:insetBottom="4dp"
+        />
diff --git a/res/drawable/ring_notif_vibrate.xml b/res/drawable/ring_notif_vibrate.xml
new file mode 100644
index 0000000..4f19e01
--- /dev/null
+++ b/res/drawable/ring_notif_vibrate.xml
@@ -0,0 +1,23 @@
+<!--
+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.
+-->
+<!-- shrink ic_audio_ring_notif_vibrate from 32dp to 24dp using insets -->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+        android:drawable="@*android:drawable/ic_audio_ring_notif_vibrate"
+        android:insetLeft="4dp"
+        android:insetRight="4dp"
+        android:insetTop="4dp"
+        android:insetBottom="4dp"
+        />
diff --git a/res/layout-land/setup_preference.xml b/res/layout-land/setup_preference.xml
index ce655d6..b525b68 100644
--- a/res/layout-land/setup_preference.xml
+++ b/res/layout-land/setup_preference.xml
@@ -25,7 +25,8 @@
         android:id="@+id/title_area"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@drawable/setup_illustration_bg">
+        android:background="@drawable/setup_illustration_bg"
+        android:elevation="@dimen/setup_wizard_title_area_elevation">
 
         <TextView
             android:id="@+id/title"
diff --git a/res/layout/bluetooth_device_settings.xml b/res/layout/bluetooth_device_settings.xml
new file mode 100644
index 0000000..cc2cc09
--- /dev/null
+++ b/res/layout/bluetooth_device_settings.xml
@@ -0,0 +1,53 @@
+<?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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:gravity="center">
+
+    <LinearLayout android:id="@+id/dialog_layout"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:paddingBottom="@dimen/bluetooth_dialog_padding"
+            style="@style/bt_item" >
+
+            <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/bluetooth_preference_paired_dialog_name_label"
+                    android:textDirection="locale"
+                    android:textColor="?android:attr/colorAccent"
+                    style="@style/bt_item_label" />
+
+            <EditText android:id="@+id/name"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:inputType="textNoSuggestions"
+                    android:maxLength="@integer/bluetooth_name_length"
+                    android:singleLine="true"
+                    style="@style/bt_item_edit_content" />
+
+            <fragment android:id="@+id/bluetooth_fragment_settings"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    class="com.android.settings.bluetooth.DeviceProfilesSettings" />
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/res/layout/setup_wizard_header.xml b/res/layout/setup_wizard_header.xml
index 8334868..c38a68d 100644
--- a/res/layout/setup_wizard_header.xml
+++ b/res/layout/setup_wizard_header.xml
@@ -22,6 +22,7 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="@drawable/setup_illustration_bg"
+    android:elevation="@dimen/setup_wizard_title_area_elevation"
     android:foreground="@drawable/setup_illustration_wifi"
     android:tag="stickyContainer"
     settings:aspectRatio="2.22">
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 3ec64da..f270435 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -58,6 +58,7 @@
     <dimen name="setup_wizard_card_port_margin_sides">56dp</dimen>
     <dimen name="setup_wizard_card_land_margin_top">128dp</dimen>
     <dimen name="setup_wizard_margin_sides">40dp</dimen>
+    <dimen name="setup_wizard_title_area_elevation">3dp</dimen>
 
     <dimen name="divider_height">3dip</dimen>
     <dimen name="divider_margin_top">6dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d75824e..96f57cb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5918,4 +5918,15 @@
     <!-- Summary Title for saying that the preference is experimental and will evolve over time due to User feedback. [CHAR LIMIT=NONE] -->
     <string name="experimental_preference">(Experimental)</string>
 
+    <!-- [CHAR LIMIT=45] Auto-rotate setting title -->
+    <string name="display_auto_rotate_title">When device is rotated</string>
+    <!-- [CHAR LIMIT=70] Rotate when screen is turned option -->
+    <string name="display_auto_rotate_rotate">Rotate the contents of the screen</string>
+    <!-- [CHAR LIMIT=70] Keep the screen in portrait when rotated -->
+    <string name="display_auto_rotate_stay_in_portrait">Stay in portrait view</string>
+    <!-- [CHAR LIMIT=70] Keep the screen in landscape when rotated -->
+    <string name="display_auto_rotate_stay_in_landscape">Stay in landscape view</string>
+    <!-- [CHAR LIMIT=70] Don't rotate when screen is turned option -->
+    <string name="display_auto_rotate_stay_in_current">Stay in current orientation</string>
+
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c3d2564..03a9fde 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -196,6 +196,29 @@
         <item name="android:textColor">?android:attr/colorAccent</item>
     </style>
 
+    <style name="bt_item">
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_marginTop">8dip</item>
+        <item name="android:layout_marginStart">16dip</item>
+        <item name="android:layout_marginEnd">16dip</item>
+        <item name="android:orientation">vertical</item>
+        <item name="android:gravity">start</item>
+    </style>
+
+    <style name="bt_item_label">
+        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:textSize">14sp</item>
+        <item name="android:textAlignment">viewStart</item>
+    </style>
+
+    <style name="bt_item_edit_content">
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:textSize">18sp</item>
+    </style>
+
     <style name="wifi_item">
         <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index cb6bab0..6cfad2d 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -72,6 +72,10 @@
                 android:entryValues="@array/entryvalues_font_size"
                 android:dialogTitle="@string/dialog_title_font_size" />
 
+        <com.android.settings.notification.DropDownPreference
+                android:key="auto_rotate"
+                android:title="@string/display_auto_rotate_title" />
+
         <PreferenceScreen
                 android:key="wifi_display"
                 android:title="@string/wifi_display_settings_title"
diff --git a/res/xml/notification_settings.xml b/res/xml/notification_settings.xml
index e5dda19..e9a4992 100644
--- a/res/xml/notification_settings.xml
+++ b/res/xml/notification_settings.xml
@@ -39,13 +39,13 @@
         <!-- Ring volume -->
         <com.android.settings.notification.VolumeSeekBarPreference
                 android:key="ring_volume"
-                android:icon="@*android:drawable/ic_audio_ring_notif"
+                android:icon="@drawable/ring_notif"
                 android:title="@string/ring_volume_option_title" />
 
         <!-- Notification volume -->
         <com.android.settings.notification.VolumeSeekBarPreference
                 android:key="notification_volume"
-                android:icon="@*android:drawable/ic_audio_ring_notif"
+                android:icon="@drawable/ring_notif"
                 android:title="@string/notification_volume_option_title" />
 
         <!-- Also vibrate for calls -->
diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
index f30e393..7db1ed7 100644
--- a/res/xml/wireless_settings.xml
+++ b/res/xml/wireless_settings.xml
@@ -16,8 +16,7 @@
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                   xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
-        android:title="wireless_settings"
-        android:key="@string/radio_controls_title">
+        android:title="@string/radio_controls_title">
 
     <SwitchPreference
         android:key="toggle_airplane"
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 9a09647..7e92cc6 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -117,6 +117,8 @@
     private boolean mValidationRequested;
     /** A flag to indicate that the volume is in a bad state (e.g. partially encrypted). */
     private boolean mEncryptionGoneBad;
+    /** If gone bad, should we show encryption failed (false) or corrupt (true)*/
+    private boolean mCorrupt;
     /** A flag to indicate when the back event should be ignored */
     private boolean mIgnoreBack = false;
     private int mCooldown;
@@ -224,12 +226,14 @@
     }
 
     private class ValidationTask extends AsyncTask<Void, Void, Boolean> {
+        int state;
+
         @Override
         protected Boolean doInBackground(Void... params) {
             final IMountService service = getMountService();
             try {
                 Log.d(TAG, "Validating encryption state.");
-                int state = service.getEncryptionState();
+                state = service.getEncryptionState();
                 if (state == IMountService.ENCRYPTION_STATE_NONE) {
                     Log.w(TAG, "Unexpectedly in CryptKeeper even though there is no encryption.");
                     return true; // Unexpected, but fine, I guess...
@@ -247,6 +251,7 @@
             if (Boolean.FALSE.equals(result)) {
                 Log.w(TAG, "Incomplete, or corrupted encryption detected. Prompting user to wipe.");
                 mEncryptionGoneBad = true;
+                mCorrupt = state == IMountService.ENCRYPTION_STATE_ERROR_CORRUPT;
             } else {
                 Log.d(TAG, "Encryption state validated. Proceeding to configure UI");
             }
@@ -403,7 +408,7 @@
     private void setupUi() {
         if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
             setContentView(R.layout.crypt_keeper_progress);
-            showFactoryReset(false);
+            showFactoryReset(mCorrupt);
             return;
         }
 
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index f85b74e..ddd6728 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -16,6 +16,9 @@
 
 package com.android.settings;
 
+import com.android.internal.view.RotationPolicy;
+import com.android.settings.notification.DropDownPreference;
+import com.android.settings.notification.DropDownPreference.Callback;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 
@@ -26,6 +29,7 @@
 import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
 import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
 
+import android.app.Activity;
 import android.app.ActivityManagerNative;
 import android.app.Dialog;
 import android.app.admin.DevicePolicyManager;
@@ -65,6 +69,7 @@
     private static final String KEY_LIFT_TO_WAKE = "lift_to_wake";
     private static final String KEY_DOZE = "doze";
     private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
+    private static final String KEY_AUTO_ROTATE = "auto_rotate";
 
     private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
 
@@ -81,7 +86,8 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        final ContentResolver resolver = getActivity().getContentResolver();
+        final Activity activity = getActivity();
+        final ContentResolver resolver = activity.getContentResolver();
 
         addPreferencesFromResource(R.xml.display_settings);
 
@@ -111,19 +117,59 @@
             removePreference(KEY_AUTO_BRIGHTNESS);
         }
 
-        if (isLiftToWakeAvailable(getActivity())) {
+        if (isLiftToWakeAvailable(activity)) {
             mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
             mLiftToWakePreference.setOnPreferenceChangeListener(this);
         } else {
             removePreference(KEY_LIFT_TO_WAKE);
         }
 
-        if (isDozeAvailable(getActivity())) {
+        if (isDozeAvailable(activity)) {
             mDozePreference = (SwitchPreference) findPreference(KEY_DOZE);
             mDozePreference.setOnPreferenceChangeListener(this);
         } else {
             removePreference(KEY_DOZE);
         }
+
+        if (RotationPolicy.isRotationLockToggleVisible(activity)) {
+            DropDownPreference rotatePreference =
+                    (DropDownPreference) findPreference(KEY_AUTO_ROTATE);
+            rotatePreference.addItem(activity.getString(R.string.display_auto_rotate_rotate),
+                    false);
+            int rotateLockedResourceId;
+            // The following block sets the string used when rotation is locked.
+            // If the device locks specifically to portrait or landscape (rather than current
+            // rotation), then we use a different string to include this information.
+            if (allowAllRotations(activity)) {
+                rotateLockedResourceId = R.string.display_auto_rotate_stay_in_current;
+            } else {
+                if (RotationPolicy.getRotationLockOrientation(activity)
+                        == Configuration.ORIENTATION_PORTRAIT) {
+                    rotateLockedResourceId =
+                            R.string.display_auto_rotate_stay_in_portrait;
+                } else {
+                    rotateLockedResourceId =
+                            R.string.display_auto_rotate_stay_in_landscape;
+                }
+            }
+            rotatePreference.addItem(activity.getString(rotateLockedResourceId), true);
+            rotatePreference.setSelectedItem(RotationPolicy.isRotationLocked(activity) ?
+                    1 : 0);
+            rotatePreference.setCallback(new Callback() {
+                @Override
+                public boolean onItemSelected(int pos, Object value) {
+                    RotationPolicy.setRotationLock(activity, (Boolean) value);
+                    return true;
+                }
+            });
+        } else {
+            removePreference(KEY_AUTO_ROTATE);
+        }
+    }
+
+    private static boolean allowAllRotations(Context context) {
+        return Resources.getSystem().getBoolean(
+                com.android.internal.R.bool.config_allowAllRotations);
     }
 
     private static boolean isLiftToWakeAvailable(Context context) {
@@ -382,6 +428,9 @@
                     if (!isDozeAvailable(context)) {
                         result.add(KEY_DOZE);
                     }
+                    if (!RotationPolicy.isRotationLockToggleVisible(context)) {
+                        result.add(KEY_AUTO_ROTATE);
+                    }
                     return result;
                 }
             };
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 4fb166a..47ff6af 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -30,9 +30,11 @@
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ResolveInfo;
+import android.content.pm.Signature;
 import android.content.pm.UserInfo;
 import android.content.res.Resources;
 import android.content.res.Resources.NotFoundException;
@@ -839,4 +841,34 @@
 
         return tm.getSimCount() > 0;
     }
+
+    /**
+     * Determine whether a package is a "system package", in which case certain things (like
+     * disabling notifications or disabling the package altogether) should be disallowed.
+     */
+    public static boolean isSystemPackage(PackageManager pm, PackageInfo pkg) {
+        if (sSystemSignature == null) {
+            sSystemSignature = new Signature[]{ getSystemSignature(pm) };
+        }
+        return sSystemSignature[0] != null && sSystemSignature[0].equals(getFirstSignature(pkg));
+    }
+
+    private static Signature[] sSystemSignature;
+
+    private static Signature getFirstSignature(PackageInfo pkg) {
+        if (pkg != null && pkg.signatures != null && pkg.signatures.length > 0) {
+            return pkg.signatures[0];
+        }
+        return null;
+    }
+
+    private static Signature getSystemSignature(PackageManager pm) {
+        try {
+            final PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
+            return getFirstSignature(sys);
+        } catch (NameNotFoundException e) {
+        }
+        return null;
+    }
+
 }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index eff5fb6..92c478e 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -513,19 +513,13 @@
 
         if (mServicesCategory.getPreferenceCount() == 0) {
             if (mNoServicesMessagePreference == null) {
-                mNoServicesMessagePreference = new Preference(getActivity()) {
-                        @Override
-                    protected void onBindView(View view) {
-                        super.onBindView(view);
-                        TextView summaryView = (TextView) view.findViewById(R.id.summary);
-                        String title = getString(R.string.accessibility_no_services_installed);
-                        summaryView.setText(title);
-                    }
-                };
+                mNoServicesMessagePreference = new Preference(getActivity());
                 mNoServicesMessagePreference.setPersistent(false);
                 mNoServicesMessagePreference.setLayoutResource(
                         R.layout.text_description_preference);
                 mNoServicesMessagePreference.setSelectable(false);
+                mNoServicesMessagePreference.setSummary(
+                        getString(R.string.accessibility_no_services_installed));
             }
             mServicesCategory.addPreference(mNoServicesMessagePreference);
         }
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index adec63a..4b1bc10 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -316,22 +316,13 @@
         }
     }
 
-    private boolean isThisASystemPackage() {
-        try {
-            PackageInfo sys = mPm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
-            return (mPackageInfo != null && mPackageInfo.signatures != null &&
-                    sys.signatures[0].equals(mPackageInfo.signatures[0]));
-        } catch (PackageManager.NameNotFoundException e) {
-            return false;
-        }
-    }
-
     private boolean handleDisableable(Button button) {
         boolean disableable = false;
         // Try to prevent the user from bricking their phone
         // by not allowing disabling of apps signed with the
         // system cert and any launcher app in the system.
-        if (mHomePackages.contains(mAppEntry.info.packageName) || isThisASystemPackage()) {
+        if (mHomePackages.contains(mAppEntry.info.packageName)
+                || Utils.isSystemPackage(mPm, mPackageInfo)) {
             // Disable button for core system applications.
             button.setText(R.string.disable_text);
         } else if (mAppEntry.info.enabled) {
@@ -427,7 +418,7 @@
             // this does not bode well
         }
         mNotificationSwitch.setChecked(enabled);
-        if (isThisASystemPackage()) {
+        if (Utils.isSystemPackage(mPm, mPackageInfo)) {
             mNotificationSwitch.setEnabled(false);
         } else {
             mNotificationSwitch.setEnabled(true);
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 054995b..ec288f3 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -393,7 +393,7 @@
             }
             if (profileFrag == null) {
                 LayoutInflater inflater = getActivity().getLayoutInflater();
-                mSettingsDialogView = inflater.inflate(R.layout.bluetooth_device_picker, null);
+                mSettingsDialogView = inflater.inflate(R.layout.bluetooth_device_settings, null);
                 profileFrag = (DeviceProfilesSettings)activity.getFragmentManager()
                     .findFragmentById(R.id.bluetooth_fragment_settings);
             }
diff --git a/src/com/android/settings/notification/NotificationAppList.java b/src/com/android/settings/notification/NotificationAppList.java
index 3879bef..7ca4b18 100644
--- a/src/com/android/settings/notification/NotificationAppList.java
+++ b/src/com/android/settings/notification/NotificationAppList.java
@@ -193,30 +193,6 @@
                 parent.getPaddingEnd() - eat, parent.getPaddingBottom());
     }
 
-    private boolean isSystemApp(PackageInfo pkg) {
-        if (mSystemSignature == null) {
-            mSystemSignature = new Signature[]{ getSystemSignature() };
-        }
-        return mSystemSignature[0] != null && mSystemSignature[0].equals(getFirstSignature(pkg));
-    }
-
-    private static Signature getFirstSignature(PackageInfo pkg) {
-        if (pkg != null && pkg.signatures != null && pkg.signatures.length > 0) {
-            return pkg.signatures[0];
-        }
-        return null;
-    }
-
-    private Signature getSystemSignature() {
-        final PackageManager pm = mContext.getPackageManager();
-        try {
-            final PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
-            return getFirstSignature(sys);
-        } catch (NameNotFoundException e) {
-        }
-        return null;
-    }
-
     private static class ViewHolder {
         ViewGroup row;
         ImageView icon;
@@ -375,6 +351,7 @@
         public boolean priority;
         public boolean sensitive;
         public boolean first;  // first app in section
+        public boolean isSystem;
     }
 
     private static final Comparator<AppRow> mRowComparator = new Comparator<AppRow>() {
@@ -385,6 +362,7 @@
         }
     };
 
+
     public static AppRow loadAppRow(PackageManager pm, PackageInfo pkg, Backend backend) {
         final AppRow row = new AppRow();
         row.pkg = pkg.packageName;
@@ -399,16 +377,28 @@
         row.banned = backend.getNotificationsBanned(row.pkg, row.uid);
         row.priority = backend.getHighPriority(row.pkg, row.uid);
         row.sensitive = backend.getSensitive(row.pkg, row.uid);
+        row.isSystem = Utils.isSystemPackage(pm, pkg);
         return row;
     }
 
-    public static void collectConfigActivities(PackageManager pm, ArrayMap<String, AppRow> rows) {
+    public static List<ResolveInfo> queryNotificationConfigActivities(PackageManager pm) {
         if (DEBUG) Log.d(TAG, "APP_NOTIFICATION_PREFS_CATEGORY_INTENT is "
                 + APP_NOTIFICATION_PREFS_CATEGORY_INTENT);
         final List<ResolveInfo> resolveInfos = pm.queryIntentActivities(
                 APP_NOTIFICATION_PREFS_CATEGORY_INTENT,
-                PackageManager.MATCH_DEFAULT_ONLY);
-        if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities");
+                0 //PackageManager.MATCH_DEFAULT_ONLY
+        );
+        return resolveInfos;
+    }
+    public static void collectConfigActivities(PackageManager pm, ArrayMap<String, AppRow> rows) {
+        final List<ResolveInfo> resolveInfos = queryNotificationConfigActivities(pm);
+        applyConfigActivities(pm, rows, resolveInfos);
+    }
+
+    public static void applyConfigActivities(PackageManager pm, ArrayMap<String, AppRow> rows,
+            List<ResolveInfo> resolveInfos) {
+        if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities"
+                + (resolveInfos.size() == 0 ? " ;_;" : ""));
         for (ResolveInfo ri : resolveInfos) {
             final ActivityInfo activityInfo = ri.activityInfo;
             final ApplicationInfo appInfo = activityInfo.applicationInfo;
@@ -425,7 +415,7 @@
                         + activityInfo.packageName);
                 continue;
             }
-            row.settingsIntent = new Intent(Intent.ACTION_MAIN)
+            row.settingsIntent = new Intent(APP_NOTIFICATION_PREFS_CATEGORY_INTENT)
                     .setClassName(activityInfo.packageName, activityInfo.name);
         }
     }
@@ -439,18 +429,41 @@
                 mRows.clear();
                 mSortedRows.clear();
 
-                // collect all non-system apps
+                // collect all launchable apps, plus any packages that have notification settings
                 final PackageManager pm = mContext.getPackageManager();
-                for (PackageInfo pkg : pm.getInstalledPackages(PackageManager.GET_SIGNATURES)) {
-                    if (pkg.applicationInfo == null || isSystemApp(pkg)) {
-                        if (DEBUG) Log.d(TAG, "Skipping " + pkg.packageName);
+                final List<ResolveInfo> resolvedApps = pm.queryIntentActivities(
+                        new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER),
+                        PackageManager.MATCH_DEFAULT_ONLY
+                );
+                final List<ResolveInfo> resolvedConfigActivities
+                        = queryNotificationConfigActivities(pm);
+                resolvedApps.addAll(resolvedConfigActivities);
+
+                for (ResolveInfo info : resolvedApps) {
+                    String pkgName = info.activityInfo.packageName;
+                    if (mRows.containsKey(pkgName)) {
+                        // we already have this app, thanks
+                        continue;
+                    }
+
+                    PackageInfo pkg = null;
+                    try {
+                        pkg = pm.getPackageInfo(pkgName,
+                                PackageManager.GET_SIGNATURES);
+                    } catch (NameNotFoundException e) {
+                        if (DEBUG) Log.d(TAG, "Skipping (NNFE): " + pkg.packageName);
+                        continue;
+                    }
+                    if (info.activityInfo.applicationInfo == null) {
+                        if (DEBUG) Log.d(TAG, "Skipping (no applicationInfo): " + pkg.packageName);
                         continue;
                     }
                     final AppRow row = loadAppRow(pm, pkg, mBackend);
-                    mRows.put(row.pkg, row);
+                    mRows.put(pkgName, row);
                 }
-                // collect config activities
-                collectConfigActivities(pm, mRows);
+
+                // add config activities to the list
+                applyConfigActivities(pm, mRows, resolvedConfigActivities);
                 // sort rows
                 mSortedRows.addAll(mRows.values());
                 Collections.sort(mSortedRows, mRowComparator);
diff --git a/src/com/android/settings/notification/NotificationSettings.java b/src/com/android/settings/notification/NotificationSettings.java
index a523a75..3094032 100644
--- a/src/com/android/settings/notification/NotificationSettings.java
+++ b/src/com/android/settings/notification/NotificationSettings.java
@@ -30,6 +30,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
+import android.os.Vibrator;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceChangeListener;
 import android.preference.PreferenceCategory;
@@ -40,6 +41,7 @@
 import android.provider.Settings;
 import android.util.Log;
 
+import android.widget.SeekBar;
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
@@ -76,6 +78,8 @@
     private Context mContext;
     private PackageManager mPM;
     private boolean mVoiceCapable;
+    private Vibrator mVibrator;
+    private VolumeSeekBarPreference mRingOrNotificationPreference;
 
     private Preference mPhoneRingtonePreference;
     private Preference mNotificationRingtonePreference;
@@ -93,16 +97,24 @@
         mPM = mContext.getPackageManager();
         mVoiceCapable = Utils.isVoiceCapable(mContext);
         mSecure = new LockPatternUtils(getActivity()).isSecure();
+
+        mVibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
+        if (mVibrator != null && !mVibrator.hasVibrator()) {
+            mVibrator = null;
+        }
+
         addPreferencesFromResource(R.xml.notification_settings);
 
         final PreferenceCategory sound = (PreferenceCategory) findPreference(KEY_SOUND);
         initVolumePreference(KEY_MEDIA_VOLUME, AudioManager.STREAM_MUSIC);
         initVolumePreference(KEY_ALARM_VOLUME, AudioManager.STREAM_ALARM);
         if (mVoiceCapable) {
-            initVolumePreference(KEY_RING_VOLUME, AudioManager.STREAM_RING);
+            mRingOrNotificationPreference =
+                    initVolumePreference(KEY_RING_VOLUME, AudioManager.STREAM_RING);
             sound.removePreference(sound.findPreference(KEY_NOTIFICATION_VOLUME));
         } else {
-            initVolumePreference(KEY_NOTIFICATION_VOLUME, AudioManager.STREAM_NOTIFICATION);
+            mRingOrNotificationPreference =
+                    initVolumePreference(KEY_NOTIFICATION_VOLUME, AudioManager.STREAM_NOTIFICATION);
             sound.removePreference(sound.findPreference(KEY_RING_VOLUME));
         }
         initRingtones(sound);
@@ -134,10 +146,19 @@
 
     // === Volumes ===
 
-    private void initVolumePreference(String key, int stream) {
+    private VolumeSeekBarPreference initVolumePreference(String key, int stream) {
         final VolumeSeekBarPreference volumePref = (VolumeSeekBarPreference) findPreference(key);
-        volumePref.setStream(stream);
         volumePref.setCallback(mVolumeCallback);
+        volumePref.setStream(stream);
+        return volumePref;
+    }
+
+    private void updateRingOrNotificationIcon(int progress) {
+        mRingOrNotificationPreference.showIcon(progress > 0
+                    ? R.drawable.ring_notif
+                    : (mVibrator == null
+                            ? R.drawable.ring_notif_mute
+                            : R.drawable.ring_notif_vibrate));
     }
 
     private final class VolumePreferenceCallback implements VolumeSeekBarPreference.Callback {
@@ -155,6 +176,14 @@
             }
         }
 
+        @Override
+        public void onStreamValueChanged(int stream, int progress) {
+            if (stream == AudioManager.STREAM_RING) {
+                mHandler.removeMessages(H.UPDATE_RINGER_ICON);
+                mHandler.obtainMessage(H.UPDATE_RINGER_ICON, progress, 0).sendToTarget();
+            }
+        }
+
         public void stopSample() {
             if (mCurrent != null) {
                 mCurrent.stopSample();
@@ -426,6 +455,7 @@
         private static final int UPDATE_PHONE_RINGTONE = 1;
         private static final int UPDATE_NOTIFICATION_RINGTONE = 2;
         private static final int STOP_SAMPLE = 3;
+        private static final int UPDATE_RINGER_ICON = 4;
 
         private H() {
             super(Looper.getMainLooper());
@@ -443,6 +473,9 @@
                 case STOP_SAMPLE:
                     mVolumeCallback.stopSample();
                     break;
+                case UPDATE_RINGER_ICON:
+                    updateRingOrNotificationIcon(msg.arg1);
+                    break;
             }
         }
     }
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreference.java b/src/com/android/settings/notification/VolumeSeekBarPreference.java
index 11a83a7..f94e6a1 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreference.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreference.java
@@ -26,6 +26,7 @@
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.View;
+import android.widget.ImageView;
 import android.widget.SeekBar;
 
 import com.android.settings.R;
@@ -39,6 +40,7 @@
     private SeekBar mSeekBar;
     private SeekBarVolumizer mVolumizer;
     private Callback mCallback;
+    private ImageView mIconView;
 
     public VolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
             int defStyleRes) {
@@ -93,9 +95,35 @@
         };
         final Uri sampleUri = mStream == AudioManager.STREAM_MUSIC ? getMediaVolumeUri() : null;
         if (mVolumizer == null) {
-            mVolumizer = new SeekBarVolumizer(getContext(), mStream, sampleUri, sbvc);
+            mVolumizer = new SeekBarVolumizer(getContext(), mStream, sampleUri, sbvc) {
+                // we need to piggyback on SBV's SeekBar listener to update our icon
+                @Override
+                public void onProgressChanged(SeekBar seekBar, int progress,
+                        boolean fromTouch) {
+                    super.onProgressChanged(seekBar, progress, fromTouch);
+                    mCallback.onStreamValueChanged(mStream, progress);
+                }
+            };
         }
         mVolumizer.setSeekBar(mSeekBar);
+        mIconView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
+        mCallback.onStreamValueChanged(mStream, mSeekBar.getProgress());
+    }
+
+    // during initialization, this preference is the SeekBar listener
+    @Override
+    public void onProgressChanged(SeekBar seekBar, int progress,
+            boolean fromTouch) {
+        super.onProgressChanged(seekBar, progress, fromTouch);
+        mCallback.onStreamValueChanged(mStream, progress);
+    }
+
+    public void showIcon(int resId) {
+        // Instead of using setIcon, which will trigger listeners, this just decorates the
+        // preference temporarily with a new icon.
+        if (mIconView != null) {
+            mIconView.setImageResource(resId);
+        }
     }
 
     private Uri getMediaVolumeUri() {
@@ -106,5 +134,6 @@
 
     public interface Callback {
         void onSampleStarting(SeekBarVolumizer sbv);
+        void onStreamValueChanged(int stream, int progress);
     }
 }
diff --git a/src/com/android/settings/search/Index.java b/src/com/android/settings/search/Index.java
index 65d825b..db60dfe 100644
--- a/src/com/android/settings/search/Index.java
+++ b/src/com/android/settings/search/Index.java
@@ -181,6 +181,16 @@
             nonIndexableKeys = new HashMap<String, List<String>>();
         }
 
+        public UpdateData(UpdateData other) {
+            dataToUpdate = new ArrayList<SearchIndexableData>(other.dataToUpdate);
+            dataToDelete = new ArrayList<SearchIndexableData>(other.dataToDelete);
+            nonIndexableKeys = new HashMap<String, List<String>>(other.nonIndexableKeys);
+        }
+
+        public UpdateData copy() {
+            return new UpdateData(this);
+        }
+
         public void clear() {
             dataToUpdate.clear();
             dataToDelete.clear();
@@ -286,7 +296,7 @@
         }
     }
 
-    public boolean update() {
+    public void update() {
         final Intent intent = new Intent(SearchIndexablesContract.PROVIDER_INTERFACE);
         List<ResolveInfo> list =
                 mContext.getPackageManager().queryIntentContentProviders(intent, 0);
@@ -304,7 +314,7 @@
             addNonIndexablesKeysFromRemoteProvider(packageName, authority);
         }
 
-        return updateInternal();
+        updateInternal();
     }
 
     private boolean addIndexablesFromRemoteProvider(String packageName, String authority) {
@@ -443,11 +453,10 @@
         }
     }
 
-    private boolean updateFromRemoteProvider(String packageName, String authority) {
-        if (!addIndexablesFromRemoteProvider(packageName, authority)) {
-            return false;
+    private void updateFromRemoteProvider(String packageName, String authority) {
+        if (addIndexablesFromRemoteProvider(packageName, authority)) {
+            updateInternal();
         }
-        return updateInternal();
     }
 
     /**
@@ -457,9 +466,8 @@
      * @param rebuild true means that you want to delete the data from the Index first.
      * @param includeInSearchResults true means that you want the bit "enabled" set so that the
      *                               data will be seen included into the search results
-     * @return true of the Index update has been successful.
      */
-    public boolean updateFromClassNameResource(String className, boolean rebuild,
+    public void updateFromClassNameResource(String className, boolean rebuild,
             boolean includeInSearchResults) {
         if (className == null) {
             throw new IllegalArgumentException("class name cannot be null!");
@@ -467,7 +475,7 @@
         final SearchIndexableResource res = SearchIndexableResources.getResourceByName(className);
         if (res == null ) {
             Log.e(LOG_TAG, "Cannot find SearchIndexableResources for class name: " + className);
-            return false;
+            return;
         }
         res.context = mContext;
         res.enabled = includeInSearchResults;
@@ -476,15 +484,14 @@
         }
         addIndexableData(res);
         mDataToProcess.forceUpdate = true;
-        boolean result = updateInternal();
+        updateInternal();
         res.enabled = false;
-        return result;
     }
 
-    public boolean updateFromSearchIndexableData(SearchIndexableData data) {
+    public void updateFromSearchIndexableData(SearchIndexableData data) {
         addIndexableData(data);
         mDataToProcess.forceUpdate = true;
-        return updateInternal();
+        updateInternal();
     }
 
     private SQLiteDatabase getReadableDatabase() {
@@ -510,21 +517,12 @@
                 SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH);
     }
 
-    private boolean updateInternal() {
+    private void updateInternal() {
         synchronized (mDataToProcess) {
             final UpdateIndexTask task = new UpdateIndexTask();
-            task.execute(mDataToProcess);
-            try {
-                final boolean result = task.get();
-                mDataToProcess.clear();
-                return result;
-            } catch (InterruptedException e) {
-                Log.e(LOG_TAG, "Cannot update index", e);
-                return false;
-            } catch (ExecutionException e) {
-                Log.e(LOG_TAG, "Cannot update index", e);
-                return false;
-            }
+            UpdateData copy = mDataToProcess.copy();
+            task.execute(copy);
+            mDataToProcess.clear();
         }
     }
 
@@ -1027,8 +1025,14 @@
             return;
         }
 
+        // The DocID should contains more than the title string itself (you may have two settings
+        // with the same title). So we need to use a combination of the title and the screenTitle.
+        StringBuilder sb = new StringBuilder(updatedTitle);
+        sb.append(screenTitle);
+        int docId = sb.toString().hashCode();
+
         ContentValues values = new ContentValues();
-        values.put(IndexColumns.DOCID, updatedTitle.hashCode());
+        values.put(IndexColumns.DOCID, docId);
         values.put(IndexColumns.LOCALE, locale);
         values.put(IndexColumns.DATA_RANK, rank);
         values.put(IndexColumns.DATA_TITLE, updatedTitle);
@@ -1143,7 +1147,7 @@
     /**
      * A private class for updating the Index database
      */
-    private class UpdateIndexTask extends AsyncTask<UpdateData, Integer, Boolean> {
+    private class UpdateIndexTask extends AsyncTask<UpdateData, Integer, Void> {
 
         @Override
         protected void onPreExecute() {
@@ -1152,15 +1156,13 @@
         }
 
         @Override
-        protected void onPostExecute(Boolean aBoolean) {
-            super.onPostExecute(aBoolean);
+        protected void onPostExecute(Void aVoid) {
+            super.onPostExecute(aVoid);
             mIsAvailable.set(true);
         }
 
         @Override
-        protected Boolean doInBackground(UpdateData... params) {
-            boolean result = false;
-
+        protected Void doInBackground(UpdateData... params) {
             final List<SearchIndexableData> dataToUpdate = params[0].dataToUpdate;
             final List<SearchIndexableData> dataToDelete = params[0].dataToDelete;
             final Map<String, List<String>> nonIndexableKeys = params[0].nonIndexableKeys;
@@ -1180,11 +1182,11 @@
                             forceUpdate);
                 }
                 database.setTransactionSuccessful();
-                result = true;
             } finally {
                 database.endTransaction();
             }
-            return result;
+
+            return null;
         }
 
         private boolean processDataToUpdate(SQLiteDatabase database, String localeStr,
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 6526996..abfeccb 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -99,7 +99,7 @@
         super.onCreate(bundle);
 
         if (mSubInfoList == null) {
-            mSubInfoList = SubscriptionManager.getActivatedSubInfoList(getActivity());
+            mSubInfoList = SubscriptionManager.getActiveSubInfoList();
         }
 
         createPreferences();
@@ -135,7 +135,7 @@
     }
 
     private void updateSimSlotValues() {
-        SubscriptionManager.getAllSubInfoList(getActivity());
+        SubscriptionManager.getAllSubInfoList();
         final PreferenceCategory simCards = (PreferenceCategory)findPreference(SIM_CARD_CATEGORY);
         final PreferenceScreen prefScreen = getPreferenceScreen();
 
@@ -197,7 +197,7 @@
 
     private void updateSmsValues() {
         final DropDownPreference simPref = (DropDownPreference) findPreference(KEY_SMS);
-        final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getPreferredSmsSubId());
+        final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultSmsSubId());
         if (sir != null) {
             simPref.setSelectedItem(sir.mSlotId + 1);
         }
@@ -344,13 +344,13 @@
                     final Spinner displayNumbers =
                         (Spinner)dialogLayout.findViewById(R.id.display_numbers);
 
-                    SubscriptionManager.setDisplayNumberFormat(getActivity(),
+                    SubscriptionManager.setDisplayNumberFormat(
                         displayNumbers.getSelectedItemPosition() == 0
                             ? SubscriptionManager.DISPLAY_NUMBER_LAST
                             : SubscriptionManager.DISPLAY_NUMBER_FIRST, mSubInfoRecord.mSubId);
 
                     mSubInfoRecord.mDisplayName = nameText.getText().toString();
-                    SubscriptionManager.setDisplayName(getActivity(), mSubInfoRecord.mDisplayName,
+                    SubscriptionManager.setDisplayName(mSubInfoRecord.mDisplayName,
                         mSubInfoRecord.mSubId);
 
                     updateAllOptions();
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index c0ffca5..f5ea6aa 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -418,9 +418,11 @@
         int userId = newUserInfo.id;
         UserHandle user = new UserHandle(userId);
         mUserManager.setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user);
-        mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user);
+        // Change the setting before applying the DISALLOW_SHARE_LOCATION restriction, otherwise
+        // the putIntForUser() will fail.
         Secure.putIntForUser(getContentResolver(),
                 Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF, userId);
+        mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user);
         Bitmap bitmap = createBitmapFromDrawable(
                 USER_DRAWABLES[userId % UserSettings.USER_DRAWABLES.length]);
         mUserManager.setUserIcon(userId, bitmap);
diff --git a/src/com/android/settings/widget/SetupWizardIllustration.java b/src/com/android/settings/widget/SetupWizardIllustration.java
index acdb5b3..717ec35 100644
--- a/src/com/android/settings/widget/SetupWizardIllustration.java
+++ b/src/com/android/settings/widget/SetupWizardIllustration.java
@@ -23,8 +23,8 @@
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.view.Gravity;
+import android.view.ViewOutlineProvider;
 import android.widget.FrameLayout;
 
 import com.android.settings.R;
@@ -107,6 +107,7 @@
             illustrationHeight -= illustrationHeight % mBaselineGridSize;
             setPaddingRelative(0, illustrationHeight, 0, 0);
         }
+        setOutlineProvider(ViewOutlineProvider.BOUNDS);
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
     }
 
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 0321e7f..ac818a7 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -271,9 +271,13 @@
                 // set the icon (drawable) to that state's drawable.
                 StateListDrawable sld = (StateListDrawable) context.getTheme()
                         .obtainStyledAttributes(wifi_signal_attributes).getDrawable(0);
-                sld.setState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE);
-                drawable = sld.getCurrent();
-                setIcon(drawable);
+                // If sld is null then we are indexing and therefore do not have access to
+                // (nor need to display) the drawable.
+                if (sld != null) {
+                    sld.setState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE);
+                    drawable = sld.getCurrent();
+                    setIcon(drawable);
+                }
             }
 
             if (drawable != null) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index abf4de8..50789b8 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -813,7 +813,13 @@
 
         final List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks();
         if (configs != null) {
-            savedNetworksExist = (configs.size() > 0);
+            // Update "Saved Networks" menu option.
+            if (savedNetworksExist != (configs.size() > 0)) {
+                savedNetworksExist = !savedNetworksExist;
+                if (context instanceof Activity) {
+                    ((Activity) context).invalidateOptionsMenu();
+                }
+            }
             for (WifiConfiguration config : configs) {
                 AccessPoint accessPoint = new AccessPoint(context, config);
                 if (lastInfo != null && lastState != null) {
diff --git a/src/com/android/settings/wifi/WpsDialog.java b/src/com/android/settings/wifi/WpsDialog.java
index 662d477..d0b116b 100644
--- a/src/com/android/settings/wifi/WpsDialog.java
+++ b/src/com/android/settings/wifi/WpsDialog.java
@@ -57,7 +57,7 @@
     private static final int WPS_TIMEOUT_S = 120;
 
     private WifiManager mWifiManager;
-    private WifiManager.WpsListener mWpsListener;
+    private WifiManager.WpsCallback mWpsListener;
     private int mWpsSetup;
 
     private final IntentFilter mFilter;
@@ -81,8 +81,9 @@
         mContext = context;
         mWpsSetup = wpsSetup;
 
-        class WpsListener implements WifiManager.WpsListener {
-            public void onStartSuccess(String pin) {
+        class WpsListener extends WifiManager.WpsCallback {
+
+            public void onStarted(String pin) {
                 if (pin != null) {
                     updateDialog(DialogState.WPS_START, String.format(
                             mContext.getString(R.string.wifi_wps_onstart_pin), pin));
@@ -91,12 +92,13 @@
                             R.string.wifi_wps_onstart_pbc));
                 }
             }
-            public void onCompletion() {
+
+            public void onSucceeded() {
                 updateDialog(DialogState.WPS_COMPLETE,
                         mContext.getString(R.string.wifi_wps_complete));
             }
 
-            public void onFailure(int reason) {
+            public void onFailed(int reason) {
                 String msg;
                 switch (reason) {
                     case WifiManager.WPS_OVERLAP_ERROR: