Merge "Sim name doesn't persist on reboot" into lmp-mr1-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5e87d85..933497e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1598,12 +1598,16 @@
     <!-- Status for networks disabled for unknown reason -->
     <string name="wifi_disabled_generic">Disabled</string>
     <!-- Status for networked disabled from a DNS or DHCP failure -->
-    <string name="wifi_disabled_network_failure">Avoided poor Internet connection</string>
+    <string name="wifi_disabled_network_failure">IP Configuration Failure</string>
+    <!-- Status for networked disabled from a wifi association failure -->
+    <string name="wifi_disabled_wifi_failure">WiFi Connection Failure</string>
     <!-- Status for networks disabled from authentication failure (wrong password
          or certificate). -->
     <string name="wifi_disabled_password_failure">Authentication problem</string>
     <!-- Summary for the remembered network but currently not in range. -->
     <string name="wifi_not_in_range">Not in range</string>
+    <!-- Summary for the remembered network but no internet connection was detected. -->
+    <string name="wifi_no_internet">No Internet Access Detected, won\'t automatically reconnect.</string>
     <!-- Substring of status line when Wi-Fi Protected Setup (WPS) is available and
          string is listed first [CHAR LIMIT=20]-->
     <string name="wifi_wps_available_first_item">WPS available</string>
@@ -2462,8 +2466,6 @@
     <string name="master_clear_final_desc">Erase all your personal information and downloaded apps? You can\'t reverse this action!</string>
     <!-- SD card & phone storage settings screen, button on screen after user selects Reset phone button -->
     <string name="master_clear_final_button_text">Erase everything</string>
-    <!-- Message to draw an unlock pattern before clearing the device -->
-    <string name="master_clear_gesture_prompt">Draw your unlock pattern</string>
     <!-- Explanation of drawing unlock pattern to reset phone -->
     <string name="master_clear_gesture_explanation">You need to draw your unlock pattern to confirm a factory data reset.</string>
     <!-- Master clear failed message -->
@@ -2500,8 +2502,6 @@
     <string name="media_format_final_desc" product="default">Erase the SD card, deleting all files stored there? You can\'t reverse this action!</string>
     <!-- SD card & phone storage settings screen, button on screen after user selects Format media button -->
     <string name="media_format_final_button_text">Erase everything</string>
-    <!-- Message to draw an unlock pattern before clearing the device -->
-    <string name="media_format_gesture_prompt">Draw your unlock pattern</string>
     <!-- Explanation of drawing unlock pattern to format card [CHAR LIMIT=NONE] -->
     <string name="media_format_gesture_explanation" product="nosdcard">You need to draw your unlock pattern to confirm that you want to erase the USB storage.</string>
     <!-- Explanation of drawing unlock pattern to format card [CHAR LIMIT=NONE] -->
@@ -3396,6 +3396,15 @@
     <string name="oem_unlock_enable">Enable OEM unlock</string>
     <!-- setting Checkbox summary whether to enable OEM unlock [CHAR_LIMIT=50] -->
     <string name="oem_unlock_enable_summary">Allow the device to be OEM unlocked</string>
+    <!-- Message to enter device PIN to enable OEM unlock -->
+    <string name="oem_unlock_enable_pin_prompt">Enter your PIN</string>
+    <!-- Explanation to enter device pin to enable OEM unlock -->
+    <string name="oem_unlock_enable_pin_description">Enter your device PIN to enable OEM unlock</string>
+    <!-- Confirmation dialog title to ensure user wishes to enable OEM unlock and disable theft protection features -->
+    <string name="confirm_enable_oem_unlock_title">Warning</string>
+    <!-- Confirmation dialog message to ensure user wishes to enable OEM unlock and disable theft protection features -->
+    <string name="confirm_enable_oem_unlock_text">Enabling OEM unlock disables theft protection features on this device and may void your warranty. Continue?</string>
+
 
     <!-- Setting Checkbox title whether to show options for wireless display certification -->
     <string name="wifi_display_certification">Wireless display certification</string>
@@ -4322,8 +4331,6 @@
     <!-- Error message for users that aren't allowed to see or modify credentials [CHAR LIMIT=none] -->
     <string name="credentials_settings_not_available">Credentials are not available for this user</string>
 
-    <!-- Message to draw an unlock pattern when installing credentials -->
-    <string name="credentials_install_gesture_prompt">Draw your unlock pattern</string>
     <!-- Explanation of drawing unlock pattern to install credentials -->
     <string name="credentials_install_gesture_explanation">You need to draw your unlock pattern to confirm credential installation.</string>
 
diff --git a/src/com/android/settings/CredentialStorage.java b/src/com/android/settings/CredentialStorage.java
index 57b5384..2e917f5 100644
--- a/src/com/android/settings/CredentialStorage.java
+++ b/src/com/android/settings/CredentialStorage.java
@@ -376,8 +376,7 @@
     private boolean confirmKeyGuard() {
         Resources res = getResources();
         boolean launched = new ChooseLockSettingsHelper(this)
-                .launchConfirmationActivity(CONFIRM_KEY_GUARD_REQUEST,
-                                            res.getText(R.string.credentials_install_gesture_prompt),
+                .launchConfirmationActivity(CONFIRM_KEY_GUARD_REQUEST, null,
                                             res.getText(R.string.credentials_install_gesture_explanation),
                                             true);
         return launched;
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index c572738..d962446 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -16,8 +16,6 @@
 
 package com.android.settings;
 
-import com.android.internal.widget.LockPatternUtils;
-
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Fragment;
@@ -81,7 +79,7 @@
      * is no keyguard available, we prompt the user to set a password.
      */
     private Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
-
+        @Override
         public void onClick(View v) {
             if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
                 // TODO replace (or follow) this dialog with an explicit launch into password UI
@@ -162,8 +160,7 @@
             return true;
         }
 
-        return helper.launchConfirmationActivity(request,
-                res.getText(R.string.master_clear_gesture_prompt),
+        return helper.launchConfirmationActivity(request, null,
                 res.getText(R.string.crypt_keeper_confirm_encrypt),
                 true);
     }
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 3aee293..08de3b7 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -710,7 +710,7 @@
     /**
      * Build {@link TabSpec} with thin indicator, and empty content.
      */
-    private TabSpec buildTabSpec(String tag, String title) {
+    private TabSpec buildTabSpec(String tag, CharSequence title) {
         return mTabHost.newTabSpec(tag).setIndicator(title).setContent(
                 mEmptyTabContent);
     }
@@ -2590,7 +2590,7 @@
                 for (SubInfoRecord subInfo : mSubInfoList) {
                     if (hasReadyMobileRadio(context, subInfo.getSubscriptionId())) {
                         mTabHost.addTab(buildTabSpec(mMobileTagMap.get(subInfo.getSubscriptionId()),
-                                subInfo.getDisplayName().toString()));
+                                subInfo.getDisplayName()));
                     }
                 }
             }
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index d410366..4af2baf 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -31,6 +31,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
 import android.hardware.usb.IUsbManager;
 import android.net.wifi.WifiManager;
 import android.os.AsyncTask;
@@ -162,6 +163,8 @@
 
     private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst";
 
+    private static final int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0;
+
     private static String DEFAULT_LOG_RING_BUFFER_SIZE_IN_BYTES = "262144"; // 256K
 
     private IWindowManager mWindowManager;
@@ -1276,6 +1279,24 @@
                 getActivity().getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0);
     }
 
+    private void confirmEnableOemUnlock() {
+        DialogInterface.OnClickListener onConfirmListener = new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                Utils.setOemUnlockEnabled(getActivity(), true);
+                updateAllOptions();
+            }
+        };
+
+        new AlertDialog.Builder(getActivity())
+                .setTitle(R.string.confirm_enable_oem_unlock_title)
+                .setMessage(R.string.confirm_enable_oem_unlock_text)
+                .setPositiveButton(R.string.yes, onConfirmListener)
+                .setNegativeButton(android.R.string.cancel, null)
+                .create()
+                .show();
+    }
+
     @Override
     public void onSwitchChanged(Switch switchView, boolean isChecked) {
         if (switchView != mSwitchBar.getSwitch()) {
@@ -1311,6 +1332,14 @@
                 writeDebuggerOptions();
                 updateDebuggerOptions();
             }
+        } else if (requestCode == REQUEST_CODE_ENABLE_OEM_UNLOCK) {
+            if (resultCode == Activity.RESULT_OK) {
+                if (mEnableOemUnlock.isChecked()) {
+                    confirmEnableOemUnlock();
+                } else {
+                    Utils.setOemUnlockEnabled(getActivity(), false);
+                }
+            }
         } else {
             super.onActivityResult(requestCode, resultCode, data);
         }
@@ -1364,7 +1393,13 @@
         } else if (preference == mBtHciSnoopLog) {
             writeBtHciSnoopLogOptions();
         } else if (preference == mEnableOemUnlock) {
-            Utils.setOemUnlockEnabled(getActivity(), mEnableOemUnlock.isChecked());
+            if (!showKeyguardConfirmation(getResources(), REQUEST_CODE_ENABLE_OEM_UNLOCK)) {
+                if (mEnableOemUnlock.isChecked()) {
+                    confirmEnableOemUnlock();
+                } else {
+                    Utils.setOemUnlockEnabled(getActivity(), false);
+                }
+            }
         } else if (preference == mAllowMockLocation) {
             Settings.Secure.putInt(getActivity().getContentResolver(),
                     Settings.Secure.ALLOW_MOCK_LOCATION,
@@ -1426,6 +1461,13 @@
         return false;
     }
 
+    private boolean showKeyguardConfirmation(Resources resources, int requestCode) {
+        return new ChooseLockSettingsHelper(getActivity(), this)
+                .launchConfirmationActivity(requestCode,
+                        resources.getString(R.string.oem_unlock_enable_pin_prompt),
+                        resources.getString(R.string.oem_unlock_enable_pin_description));
+    }
+
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index a2ca554..1c9fe5c 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -72,8 +72,7 @@
     private boolean runKeyguardConfirmation(int request) {
         Resources res = getActivity().getResources();
         return new ChooseLockSettingsHelper(getActivity(), this)
-                .launchConfirmationActivity(request,
-                        res.getText(R.string.master_clear_gesture_prompt),
+                .launchConfirmationActivity(request, null,
                         res.getText(R.string.master_clear_gesture_explanation));
     }
 
diff --git a/src/com/android/settings/MediaFormat.java b/src/com/android/settings/MediaFormat.java
index dc495ec..20dac8e 100644
--- a/src/com/android/settings/MediaFormat.java
+++ b/src/com/android/settings/MediaFormat.java
@@ -73,8 +73,7 @@
      */
     private boolean runKeyguardConfirmation(int request) {
         return new ChooseLockSettingsHelper(this)
-                .launchConfirmationActivity(request,
-                        getText(R.string.media_format_gesture_prompt),
+                .launchConfirmationActivity(request, null,
                         getText(R.string.media_format_gesture_explanation));
     }
 
diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java
index 8a183da..1bfa611 100644
--- a/src/com/android/settings/accounts/AccountSettings.java
+++ b/src/com/android/settings/accounts/AccountSettings.java
@@ -536,6 +536,7 @@
      */
     public static class ConfirmAutoSyncChangeFragment extends DialogFragment {
         private static final String SAVE_ENABLING = "enabling";
+        private static final String SAVE_USER_HANDLE = "userHandle";
         private boolean mEnabling;
         private UserHandle mUserHandle;
 
@@ -554,6 +555,7 @@
             final Context context = getActivity();
             if (savedInstanceState != null) {
                 mEnabling = savedInstanceState.getBoolean(SAVE_ENABLING);
+                mUserHandle = (UserHandle) savedInstanceState.getParcelable(SAVE_USER_HANDLE);
             }
 
             final AlertDialog.Builder builder = new AlertDialog.Builder(context);
@@ -581,6 +583,7 @@
         public void onSaveInstanceState(Bundle outState) {
             super.onSaveInstanceState(outState);
             outState.putBoolean(SAVE_ENABLING, mEnabling);
+            outState.putParcelable(SAVE_USER_HANDLE, mUserHandle);
         }
     }
     // TODO Implement a {@link SearchIndexProvider} to allow Indexing and Search of account types
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 6a66111..379232f 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -370,7 +370,11 @@
         } else {
             for (int i = 0; i < selectableSubInfoLength; ++i) {
                 final SubInfoRecord sir = mSelectableSubInfos.get(i);
-                list.add(sir.getDisplayName().toString());
+                CharSequence displayName = sir.getDisplayName();
+                if (displayName == null) {
+                    displayName = "";
+                }
+                list.add(displayName.toString());
             }
         }
 
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 9afab4b..ffd4bf3 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -299,7 +299,6 @@
         // 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
@@ -447,7 +446,7 @@
             visibility.append(" rssi=").append(mInfo.getRssi());
             visibility.append(" ");
             visibility.append(" score=").append(mInfo.score);
-            visibility.append(String.format("tx=%.1f,", mInfo.txSuccessRate));
+            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));
@@ -588,6 +587,8 @@
 
         if (mState != null) { // This is the active connection
             summary.append(Summary.get(context, mState));
+        } else if (mConfig != null && mConfig.noInternetAccess) {
+            summary.append(context.getString(R.string.wifi_no_internet));
         } else if (mConfig != null && ((mConfig.status == WifiConfiguration.Status.DISABLED &&
                 mConfig.disableReason != WifiConfiguration.DISABLED_UNKNOWN_REASON)
                || mConfig.autoJoinStatus
@@ -596,8 +597,10 @@
                     >= WifiConfiguration.AUTO_JOIN_DISABLED_ON_AUTH_FAILURE) {
                 if (mConfig.disableReason == WifiConfiguration.DISABLED_DHCP_FAILURE) {
                     summary.append(context.getString(R.string.wifi_disabled_network_failure));
-                } else {
+                } else if (mConfig.disableReason == WifiConfiguration.DISABLED_AUTH_FAILURE) {
                     summary.append(context.getString(R.string.wifi_disabled_password_failure));
+                } else {
+                    summary.append(context.getString(R.string.wifi_disabled_wifi_failure));
                 }
             } else {
                 switch (mConfig.disableReason) {
@@ -626,7 +629,7 @@
             //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(" f=" + Integer.toString(mInfo.getFrequency()));
             }
             summary.append(" " + getVisibilityStatus());
             if (mConfig != null && mConfig.autoJoinStatus > 0) {
@@ -644,6 +647,15 @@
                 }
                 summary.append(")");
             }
+            if (mConfig != null && mConfig.numIpConfigFailures > 0) {
+                summary.append(" ipf=").append(mConfig.numIpConfigFailures);
+            }
+            if (mConfig != null && mConfig.numConnectionFailures > 0) {
+                summary.append(" cf=").append(mConfig.numConnectionFailures);
+            }
+            if (mConfig != null && mConfig.numAuthFailures > 0) {
+                summary.append(" authf=").append(mConfig.numAuthFailures);
+            }
         }
 
         if (summary.length() > 0) {