Merge "VpnSettings: generate arguments for IPSec XAUTH VPNs."
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 157a6c4..45f7fd8 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -635,18 +635,22 @@
 
     <!-- Titles for app process limit preference. [CHAR LIMIT=35] -->
     <string-array name="app_process_limit_entries">
-        <item>No app process limit</item>
-        <item>Max 1 app process</item>
-        <item>Max 2 app processes</item>
-        <item>Max 3 app processes</item>
+        <item>Standard limit</item>
+        <item>No background processes</item>
+        <item>At most 1 process</item>
+        <item>At most 2 processes</item>
+        <item>At most 3 processes</item>
+        <item>At most 4 processes</item>
     </string-array>
 
     <!-- Values for app process limit preference. -->
     <string-array name="app_process_limit_values" translatable="false" >
+        <item>-1</item>
         <item>0</item>
         <item>1</item>
         <item>2</item>
         <item>3</item>
+        <item>4</item>
     </string-array>
 
     <!-- Match this with the constants in VpnProfile. --> <skip />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 90f3c3f..2912291 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1618,8 +1618,10 @@
     <string name="status_msid_number">MSID</string>
     <!-- About phone, status item title.  The phone PRL Version of the current device.-->
     <string name="status_prl_version">PRL Version</string>
-    <!-- About phone, status item title.  The phone IMEI/MEID number of the current LTE/CDMA device.-->
-    <string name="status_meid_number">IMEI / MEID</string>
+    <!-- About phone, status item title.  The phone MEID number of the current LTE/CDMA device. [CHAR LIMIT=30] -->
+    <string name="status_meid_number">MEID</string>
+    <!-- About phone, status item title.  The ICCID of the current LTE device. [CHAR LIMIT=30] -->
+    <string name="status_icc_id">ICCID</string>
     <!-- About phone, status item title for the type of data phone network we're connected to, for example 3G or Edge or GPRS -->
     <string name="status_network_type">Mobile network type</string>
     <!-- About phone, status item title. The status of data access.  For example, the value may be "Connected" -->
@@ -3340,13 +3342,13 @@
     <string name="debug_applications_category">Applications</string>
 
     <!-- UI debug setting: immediately destroy activities? [CHAR LIMIT=25] -->
-    <string name="immediately_destroy_activities">Immediately destroy activities</string>
+    <string name="immediately_destroy_activities">Don\'t keep activities</string>
     <!-- UI debug setting: immediately destroy activities summary [CHAR LIMIT=50] -->
     <string name="immediately_destroy_activities_summary">Destroy every activity as soon as
             the user leaves it</string>
 
-    <!-- UI debug setting: limit number of running application processes [CHAR LIMIT=25] -->
-    <string name="app_process_limit_title">Application process limit</string>
+    <!-- UI debug setting: limit number of running background processes [CHAR LIMIT=25] -->
+    <string name="app_process_limit_title">Background process limit</string>
 
     <!-- Activity title for network data usage summary. [CHAR LIMIT=25] -->
     <string name="data_usage_summary_title">Data usage</string>
diff --git a/res/xml/device_info_status.xml b/res/xml/device_info_status.xml
index 369c565..19e22f4 100644
--- a/res/xml/device_info_status.xml
+++ b/res/xml/device_info_status.xml
@@ -4,9 +4,9 @@
      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.
@@ -17,18 +17,48 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
         android:title="@string/device_status_activity_title">
 
-    <Preference android:key="battery_status" 
-        style="?android:attr/preferenceInformationStyle" 
+    <Preference android:key="battery_status"
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/battery_status_title"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
-    <Preference android:key="battery_level" 
-        style="?android:attr/preferenceInformationStyle" 
+    <Preference android:key="battery_level"
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/battery_level_title"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
-    <Preference android:key="number" 
-        style="?android:attr/preferenceInformationStyle" 
+    <Preference android:key="operator_name"
+        style="?android:attr/preferenceInformationStyle"
+        android:title="@string/status_operator"
+        android:summary="@string/device_info_not_available"
+        android:persistent="false" />
+    <Preference android:key="signal_strength"
+        style="?android:attr/preferenceInformationStyle"
+        android:title="@string/status_signal_strength"
+        android:summary="@string/device_info_not_available"
+        android:persistent="false" />
+    <Preference android:key="network_type"
+        style="?android:attr/preferenceInformationStyle"
+        android:title="@string/status_network_type"
+        android:summary="@string/device_info_not_available"
+        android:persistent="false" />
+    <Preference android:key="service_state"
+        style="?android:attr/preferenceInformationStyle"
+        android:title="@string/status_service_state"
+        android:summary="@string/device_info_not_available"
+        android:persistent="false" />
+    <Preference android:key="roaming_state"
+        style="?android:attr/preferenceInformationStyle"
+        android:title="@string/status_roaming"
+        android:summary="@string/device_info_not_available"
+        android:persistent="false" />
+    <Preference android:key="data_state"
+        style="?android:attr/preferenceInformationStyle"
+        android:title="@string/status_data_state"
+        android:summary="@string/device_info_not_available"
+        android:persistent="false" />
+    <Preference android:key="number"
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/status_number"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
@@ -50,58 +80,33 @@
         android:title="@string/status_meid_number"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
-    <Preference android:key="operator_name" 
-        style="?android:attr/preferenceInformationStyle" 
-        android:title="@string/status_operator"
-        android:summary="@string/device_info_not_available"
-        android:persistent="false" />
-    <Preference android:key="signal_strength"
-        style="?android:attr/preferenceInformationStyle" 
-        android:title="@string/status_signal_strength"
-        android:summary="@string/device_info_not_available"
-        android:persistent="false" />
-    <Preference android:key="network_type"
-        style="?android:attr/preferenceInformationStyle" 
-        android:title="@string/status_network_type"
-        android:summary="@string/device_info_not_available"
-        android:persistent="false" />
-    <Preference android:key="service_state" 
-        style="?android:attr/preferenceInformationStyle" 
-        android:title="@string/status_service_state"
-        android:summary="@string/device_info_not_available"
-        android:persistent="false" />
-    <Preference android:key="roaming_state" 
-        style="?android:attr/preferenceInformationStyle" 
-        android:title="@string/status_roaming"
-        android:summary="@string/device_info_not_available"
-        android:persistent="false" />
-    <Preference android:key="data_state"
-        style="?android:attr/preferenceInformationStyle" 
-        android:title="@string/status_data_state"
-        android:summary="@string/device_info_not_available"
-        android:persistent="false" />
-    <Preference android:key="imei" 
-        style="?android:attr/preferenceInformationStyle" 
+    <Preference android:key="imei"
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/status_imei"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
-    <Preference android:key="imei_sv" 
-        style="?android:attr/preferenceInformationStyle" 
+    <Preference android:key="imei_sv"
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/status_imei_sv"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
+    <Preference android:key="icc_id"
+        style="?android:attr/preferenceInformationStyle"
+        android:title="@string/status_icc_id"
+        android:summary="@string/device_info_not_available"
+        android:persistent="false" />
     <Preference android:key="wifi_ip_address"
         style="?android:attr/preferenceInformationStyle"
         android:title="@string/wifi_advanced_ip_address_title"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
     <Preference android:key="wifi_mac_address"
-        style="?android:attr/preferenceInformationStyle" 
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/status_wifi_mac_address"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
     <Preference android:key="bt_address"
-        style="?android:attr/preferenceInformationStyle" 
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/status_bt_address"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
@@ -111,7 +116,7 @@
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
     <Preference android:key="up_time"
-        style="?android:attr/preferenceInformationStyle" 
+        style="?android:attr/preferenceInformationStyle"
         android:title="@string/status_up_time"
         android:summary="@string/device_info_not_available"
         android:persistent="false" />
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 9692dd5..10afd55 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -103,11 +103,14 @@
         mShowScreenUpdates = (CheckBoxPreference) findPreference(SHOW_SCREEN_UPDATES_KEY);
         mShowCpuUsage = (CheckBoxPreference) findPreference(SHOW_CPU_USAGE_KEY);
         mWindowAnimationScale = (ListPreference) findPreference(WINDOW_ANIMATION_SCALE_KEY);
+        mWindowAnimationScale.setOnPreferenceChangeListener(this);
         mTransitionAnimationScale = (ListPreference) findPreference(TRANSITION_ANIMATION_SCALE_KEY);
+        mTransitionAnimationScale.setOnPreferenceChangeListener(this);
 
         mImmediatelyDestroyActivities = (CheckBoxPreference) findPreference(
                 IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
         mAppProcessLimit = (ListPreference) findPreference(APP_PROCESS_LIMIT_KEY);
+        mAppProcessLimit.setOnPreferenceChangeListener(this);
 
         removeHdcpOptionsForProduction();
     }
@@ -276,10 +279,12 @@
                 float val = Float.parseFloat(values[i].toString());
                 if (scale <= val) {
                     pref.setValueIndex(i);
+                    pref.setSummary(pref.getEntries()[i]);
                     return;
                 }
             }
             pref.setValueIndex(values.length-1);
+            pref.setSummary(pref.getEntries()[0]);
         } catch (RemoteException e) {
         }
     }
@@ -289,9 +294,9 @@
         updateAnimationScaleValue(1, mTransitionAnimationScale);
     }
 
-    private void writeAnimationScaleOption(int which, ListPreference pref) {
+    private void writeAnimationScaleOption(int which, ListPreference pref, Object newValue) {
         try {
-            float scale = Float.parseFloat(pref.getValue().toString());
+            float scale = Float.parseFloat(newValue.toString());
             mWindowManager.setAnimationScale(which, scale);
         } catch (RemoteException e) {
         }
@@ -305,17 +310,19 @@
                 int val = Integer.parseInt(values[i].toString());
                 if (val >= limit) {
                     mAppProcessLimit.setValueIndex(i);
+                    mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[i]);
                     return;
                 }
             }
             mAppProcessLimit.setValueIndex(0);
+            mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[0]);
         } catch (RemoteException e) {
         }
     }
 
-    private void writeAppProcessLimitOptions() {
+    private void writeAppProcessLimitOptions(Object newValue) {
         try {
-            int limit = Integer.parseInt(mAppProcessLimit.getValue().toString());
+            int limit = Integer.parseInt(newValue.toString());
             ActivityManagerNative.getDefault().setProcessLimit(limit);
         } catch (RemoteException e) {
         }
@@ -361,19 +368,32 @@
             writeFlingerOptions();
         } else if (preference == mShowCpuUsage) {
             writeCpuUsageOptions();
-        } else if (preference == mWindowAnimationScale) {
-            writeAnimationScaleOption(0, mWindowAnimationScale);
-        } else if (preference == mTransitionAnimationScale) {
-            writeAnimationScaleOption(1, mTransitionAnimationScale);
         } else if (preference == mImmediatelyDestroyActivities) {
             writeImmediatelyDestroyActivitiesOptions();
-        } else if (preference == mAppProcessLimit) {
-            writeAppProcessLimitOptions();
         }
 
         return false;
     }
 
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
+            SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
+            updateHdcpValues();
+            return true;
+        } else if (preference == mWindowAnimationScale) {
+            writeAnimationScaleOption(0, mWindowAnimationScale, newValue);
+            return true;
+        } else if (preference == mTransitionAnimationScale) {
+            writeAnimationScaleOption(1, mTransitionAnimationScale, newValue);
+            return true;
+        } else if (preference == mAppProcessLimit) {
+            writeAppProcessLimitOptions(newValue);
+            return true;
+        }
+        return false;
+    }
+
     private void dismissDialog() {
         if (mOkDialog == null) return;
         mOkDialog.dismiss();
@@ -403,14 +423,4 @@
         dismissDialog();
         super.onDestroy();
     }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
-            SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
-            updateHdcpValues();
-            return true;
-        }
-        return false;
-    }
 }
diff --git a/src/com/android/settings/applications/RunningState.java b/src/com/android/settings/applications/RunningState.java
index e7e3af4..8ca17a5 100644
--- a/src/com/android/settings/applications/RunningState.java
+++ b/src/com/android/settings/applications/RunningState.java
@@ -776,6 +776,7 @@
         }
         
         // Look for services and their primary processes that no longer exist...
+        ArrayList<Integer> uidToDelete = null;
         for (int i=0; i<mServiceProcessesByName.size(); i++) {
             HashMap<String, ProcessItem> procs = mServiceProcessesByName.valueAt(i);
             Iterator<ProcessItem> pit = procs.values().iterator();
@@ -792,7 +793,10 @@
                     changed = true;
                     pit.remove();
                     if (procs.size() == 0) {
-                        mServiceProcessesByName.remove(mServiceProcessesByName.keyAt(i));
+                        if (uidToDelete == null) {
+                            uidToDelete = new ArrayList<Integer>();
+                        }
+                        uidToDelete.add(mServiceProcessesByName.keyAt(i));
                     }
                     if (pi.mPid != 0) {
                         mServiceProcessesByPid.remove(pi.mPid);
@@ -810,6 +814,13 @@
             }
         }
         
+        if (uidToDelete != null) {
+            for (int i = 0; i < uidToDelete.size(); i++) {
+                int uid = uidToDelete.get(i);
+                mServiceProcessesByName.remove(uid);
+            }
+        }
+
         if (changed) {
             // First determine an order for the services.
             ArrayList<ProcessItem> sortedProcesses = new ArrayList<ProcessItem>();
diff --git a/src/com/android/settings/deviceinfo/Status.java b/src/com/android/settings/deviceinfo/Status.java
index 68ba354..456bc98 100644
--- a/src/com/android/settings/deviceinfo/Status.java
+++ b/src/com/android/settings/deviceinfo/Status.java
@@ -82,6 +82,7 @@
     private static final String KEY_WIFI_MAC_ADDRESS = "wifi_mac_address";
     private static final String KEY_BT_ADDRESS = "bt_address";
     private static final String KEY_SERIAL_NUMBER = "serial_number";
+    private static final String KEY_ICC_ID = "icc_id";
 
     private static final String[] PHONE_RELATED_ENTRIES = {
         KEY_DATA_STATE,
@@ -95,7 +96,8 @@
         KEY_PRL_VERSION,
         KEY_MIN_NUMBER,
         KEY_MEID_NUMBER,
-        KEY_SIGNAL_STRENGTH
+        KEY_SIGNAL_STRENGTH,
+        KEY_ICC_ID
     };
 
     private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200;
@@ -111,7 +113,7 @@
     private Preference mUptime;
 
     private static String sUnknown;
-    
+
     private Preference mBatteryStatus;
     private Preference mBatteryLevel;
 
@@ -150,7 +152,7 @@
     }
 
     private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
-        
+
         @Override
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
@@ -158,9 +160,9 @@
 
                 int level = intent.getIntExtra("level", 0);
                 int scale = intent.getIntExtra("scale", 100);
-                
+
                 mBatteryLevel.setSummary(String.valueOf(level * 100 / scale) + "%");
-                
+
                 int plugType = intent.getIntExtra("plugged", 0);
                 int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
                 String statusString;
@@ -193,7 +195,7 @@
             updateNetworkType();
         }
     };
-    
+
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -231,11 +233,18 @@
                     findPreference(KEY_MIN_NUMBER).setTitle(R.string.status_msid_number);
                 }
                 setSummaryText(KEY_PRL_VERSION, mPhone.getCdmaPrlVersion());
-
-                // device is not GSM/UMTS, do not display GSM/UMTS features
-                // check Null in case no specified preference in overlay xml
-                removePreferenceFromScreen(KEY_IMEI);
                 removePreferenceFromScreen(KEY_IMEI_SV);
+
+                if (mPhone.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) {
+                    // Show ICC ID and IMEI for LTE device
+                    setSummaryText(KEY_ICC_ID, mPhone.getIccSerialNumber());
+                    setSummaryText(KEY_IMEI, mPhone.getImei());
+                } else {
+                    // device is not GSM/UMTS, do not display GSM/UMTS features
+                    // check Null in case no specified preference in overlay xml
+                    removePreferenceFromScreen(KEY_IMEI);
+                    removePreferenceFromScreen(KEY_ICC_ID);
+                }
             } else {
                 setSummaryText(KEY_IMEI, mPhone.getDeviceId());
 
@@ -248,6 +257,7 @@
                 removePreferenceFromScreen(KEY_PRL_VERSION);
                 removePreferenceFromScreen(KEY_MEID_NUMBER);
                 removePreferenceFromScreen(KEY_MIN_NUMBER);
+                removePreferenceFromScreen(KEY_ICC_ID);
             }
 
             String rawNumber = mPhone.getLine1Number();  // may be null or empty
@@ -291,7 +301,7 @@
         registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
         mHandler.sendEmptyMessage(EVENT_UPDATE_STATS);
     }
-    
+
     @Override
     public void onPause() {
         super.onPause();
@@ -325,7 +335,7 @@
             findPreference(preference).setSummary(
                     SystemProperties.get(property, alt));
         } catch (RuntimeException e) {
-            
+
         }
     }
 
@@ -338,12 +348,12 @@
                  findPreference(preference).setSummary(text);
              }
     }
-    
+
     private void updateNetworkType() {
         // Whether EDGE, UMTS, etc...
         setSummary(KEY_NETWORK_TYPE, TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, sUnknown);
     }
-    
+
     private void updateDataState() {
         int state = mTelephonyManager.getDataState();
         String display = mRes.getString(R.string.radioInfo_unknown);
@@ -362,14 +372,14 @@
                 display = mRes.getString(R.string.radioInfo_data_disconnected);
                 break;
         }
-        
+
         setSummaryText(KEY_DATA_STATE, display);
     }
 
     private void updateServiceState(ServiceState serviceState) {
         int state = serviceState.getState();
         String display = mRes.getString(R.string.radioInfo_unknown);
-        
+
         switch (state) {
             case ServiceState.STATE_IN_SERVICE:
                 display = mRes.getString(R.string.radioInfo_service_in);
@@ -382,9 +392,9 @@
                 display = mRes.getString(R.string.radioInfo_service_off);
                 break;
         }
-        
+
         setSummaryText(KEY_SERVICE_STATE, display);
-        
+
         if (serviceState.getRoaming()) {
             setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_in));
         } else {
@@ -392,7 +402,7 @@
         }
         setSummaryText(KEY_OPERATOR_NAME, serviceState.getOperatorAlphaLong());
     }
-    
+
     void updateSignalStrength() {
         // TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener
         // should probably used instead.
@@ -429,7 +439,7 @@
 
         Preference wifiMacAddressPref = findPreference(KEY_WIFI_MAC_ADDRESS);
         String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
-        wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress 
+        wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress
                 : getString(R.string.status_unavailable));
 
         Preference wifiIpAddressPref = findPreference(KEY_WIFI_IP_ADDRESS);
@@ -465,7 +475,7 @@
 
         mUptime.setSummary(convert(ut));
     }
-    
+
     private String pad(int n) {
         if (n >= 10) {
             return String.valueOf(n);