Merge "Fix app headers in settings" into mnc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index dc01c24..12551d0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1852,7 +1852,6 @@
                 android:label="@string/wifi_display_settings_title"
                 android:taskAffinity="">
             <intent-filter android:priority="1">
-                <action android:name="android.settings.WIFI_DISPLAY_SETTINGS" />
                 <action android:name="android.settings.CAST_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
@@ -2326,6 +2325,8 @@
                 android:value="com.android.settings.notification.OtherSoundSettings" />
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                 android:resource="@id/notification_settings" />
+            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+                android:value="true" />
         </activity>
 
         <!-- Show apps for which application-level notification settings are applicable -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ce56b63..4ff5090 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5969,6 +5969,9 @@
     <!-- Sound & notification > Other sounds: Title for the option enabling touch sounds for screen locking sounds. [CHAR LIMIT=30] -->
     <string name="screen_locking_sounds_title">Screen locking sounds</string>
 
+    <!-- Sound & notification > Other sounds: Title for the option enabling charging sounds. [CHAR LIMIT=30] -->
+    <string name="charging_sounds_title">Charging sounds</string>
+
     <!-- Sound & notification > Other sounds: Title for the option enabling docking sounds. [CHAR LIMIT=30] -->
     <string name="docking_sounds_title">Docking sounds</string>
 
diff --git a/res/xml/other_sound_settings.xml b/res/xml/other_sound_settings.xml
index 88c4130..57a302b 100644
--- a/res/xml/other_sound_settings.xml
+++ b/res/xml/other_sound_settings.xml
@@ -35,6 +35,14 @@
             android:switchTextOn=""
             android:persistent="false" />
 
+    <!-- Charging sounds -->
+    <SwitchPreference
+            android:key="charging_sounds"
+            android:title="@string/charging_sounds_title"
+            android:switchTextOff=""
+            android:switchTextOn=""
+            android:persistent="false" />
+
     <!-- Docking sounds -->
     <SwitchPreference
             android:key="docking_sounds"
diff --git a/src/com/android/settings/deviceinfo/SimStatus.java b/src/com/android/settings/deviceinfo/SimStatus.java
index 4fa5673..ea4c3e1 100644
--- a/src/com/android/settings/deviceinfo/SimStatus.java
+++ b/src/com/android/settings/deviceinfo/SimStatus.java
@@ -143,24 +143,28 @@
         // Note - missing in zaku build, be careful later...
         mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
 
-        mSir = mSelectableSubInfos.size() > 0 ? mSelectableSubInfos.get(0) : null;
-        if (mSelectableSubInfos.size() > 1) {
-            setContentView(R.layout.sim_information);
+        if (mSelectableSubInfos == null) {
+            mSir = null;
+        } else {
+            mSir = mSelectableSubInfos.size() > 0 ? mSelectableSubInfos.get(0) : null;
 
-            mTabHost = (TabHost) findViewById(android.R.id.tabhost);
-            mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
-            mListView = (ListView) findViewById(android.R.id.list);
+            if (mSelectableSubInfos.size() > 1) {
+                setContentView(R.layout.sim_information);
 
-            mTabHost.setup();
-            mTabHost.setOnTabChangedListener(mTabListener);
-            mTabHost.clearAllTabs();
+                mTabHost = (TabHost) findViewById(android.R.id.tabhost);
+                mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
+                mListView = (ListView) findViewById(android.R.id.list);
 
-            for (int i = 0; i < mSelectableSubInfos.size(); i++) {
-                mTabHost.addTab(buildTabSpec(String.valueOf(i),
-                        String.valueOf(mSelectableSubInfos.get(i).getDisplayName())));
+                mTabHost.setup();
+                mTabHost.setOnTabChangedListener(mTabListener);
+                mTabHost.clearAllTabs();
+
+                for (int i = 0; i < mSelectableSubInfos.size(); i++) {
+                    mTabHost.addTab(buildTabSpec(String.valueOf(i),
+                            String.valueOf(mSelectableSubInfos.get(i).getDisplayName())));
+                }
             }
         }
-
         updatePhoneInfos();
     }
 
diff --git a/src/com/android/settings/notification/OtherSoundSettings.java b/src/com/android/settings/notification/OtherSoundSettings.java
index c226906..969ec90 100644
--- a/src/com/android/settings/notification/OtherSoundSettings.java
+++ b/src/com/android/settings/notification/OtherSoundSettings.java
@@ -60,6 +60,7 @@
 
     private static final String KEY_DIAL_PAD_TONES = "dial_pad_tones";
     private static final String KEY_SCREEN_LOCKING_SOUNDS = "screen_locking_sounds";
+    private static final String KEY_CHARGING_SOUNDS = "charging_sounds";
     private static final String KEY_DOCKING_SOUNDS = "docking_sounds";
     private static final String KEY_TOUCH_SOUNDS = "touch_sounds";
     private static final String KEY_VIBRATE_ON_TOUCH = "vibrate_on_touch";
@@ -77,6 +78,9 @@
     private static final SettingPref PREF_SCREEN_LOCKING_SOUNDS = new SettingPref(
             TYPE_SYSTEM, KEY_SCREEN_LOCKING_SOUNDS, System.LOCKSCREEN_SOUNDS_ENABLED, DEFAULT_ON);
 
+    private static final SettingPref PREF_CHARGING_SOUNDS = new SettingPref(
+            TYPE_GLOBAL, KEY_CHARGING_SOUNDS, Global.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
+
     private static final SettingPref PREF_DOCKING_SOUNDS = new SettingPref(
             TYPE_GLOBAL, KEY_DOCKING_SOUNDS, Global.DOCK_SOUNDS_ENABLED, DEFAULT_ON) {
         @Override
@@ -155,6 +159,7 @@
     private static final SettingPref[] PREFS = {
         PREF_DIAL_PAD_TONES,
         PREF_SCREEN_LOCKING_SOUNDS,
+        PREF_CHARGING_SOUNDS,
         PREF_DOCKING_SOUNDS,
         PREF_TOUCH_SOUNDS,
         PREF_VIBRATE_ON_TOUCH,
diff --git a/src/com/android/settings/wifi/AccessPointPreference.java b/src/com/android/settings/wifi/AccessPointPreference.java
index 0f702b2..511d88d 100644
--- a/src/com/android/settings/wifi/AccessPointPreference.java
+++ b/src/com/android/settings/wifi/AccessPointPreference.java
@@ -21,7 +21,6 @@
 import android.preference.Preference;
 import android.view.View;
 import android.widget.TextView;
-
 import com.android.settings.R;
 import com.android.settingslib.wifi.AccessPoint;
 
@@ -81,7 +80,11 @@
                             ? STATE_SECURED
                             : STATE_NONE);
                     drawable = sld.getCurrent();
-                    setIcon(drawable);
+                    if (!mForSavedNetworks) {
+                        setIcon(drawable);
+                    } else {
+                        setIcon(null);
+                    }
                 }
             }
 
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index 04d2107..1444ad5 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -41,6 +41,8 @@
 import com.android.settings.search.SearchIndexableRaw;
 import com.android.settingslib.wifi.AccessPoint;
 import com.android.settingslib.wifi.WifiTracker;
+import java.util.Collections;
+import java.util.Comparator;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -97,35 +99,22 @@
 
         final List<AccessPoint> accessPoints = WifiTracker.getCurrentAccessPoints(context, true,
                 false, true);
-
+        Collections.sort(accessPoints, new Comparator<AccessPoint>() {
+            public int compare(AccessPoint ap1, AccessPoint ap2) {
+                if (ap1.getConfigName() != null) {
+                    return ap1.getConfigName().compareTo(ap2.getConfigName());
+                } else {
+                    return -1;
+                }
+            }
+        });
         preferenceScreen.removeAll();
 
-        PackageManager pm = context.getPackageManager();
-        String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
-
         final int accessPointsSize = accessPoints.size();
         for (int i = 0; i < accessPointsSize; ++i){
             AccessPointPreference preference = new AccessPointPreference(accessPoints.get(i),
                     context, true);
-            WifiConfiguration config = accessPoints.get(i).getConfig();
-            if (config != null) {
-                int userId = UserHandle.getUserId(config.creatorUid);
-                ApplicationInfo appInfo = null;
-                if (config.creatorName != null && config.creatorName.equals(systemName)) {
-                    appInfo = context.getApplicationInfo();
-                } else {
-                    try {
-                        IPackageManager ipm = AppGlobals.getPackageManager();
-                        appInfo = ipm.getApplicationInfo(config.creatorName, 0 /* flags */, userId);
-                    } catch (RemoteException rex) {
-                    }
-                }
-                if (appInfo != null) {
-                    preference.setSummary(getResources().getString(appInfo.labelRes));
-                }
-            } else {
-                preference.setShowSummary(false);
-            }
+            preference.setIcon(null);
             preferenceScreen.addPreference(preference);
         }