Fix missing text message when WiFi Calling is Off.
automerge: a4314a5

* commit 'a4314a5d8b5959bc81ce9fc28fb902ed9ecf6cef':
  Fix missing text message when WiFi Calling is Off.
diff --git a/res/layout/wifi_ap_dialog.xml b/res/layout/wifi_ap_dialog.xml
index 30043c4..7a038cb 100644
--- a/res/layout/wifi_ap_dialog.xml
+++ b/res/layout/wifi_ap_dialog.xml
@@ -66,6 +66,31 @@
                     style="@style/wifi_item_content"
                     android:prompt="@string/wifi_security"
                     android:entries="@array/wifi_ap_security" />
+
+            <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    style="@style/wifi_item_label"
+                    android:layout_marginTop="8dip"
+                    android:text="@string/wifi_ap_band_config" />
+
+               <RadioGroup android:id = "@+id/choose_channel"
+                       android:layout_width="fill_parent"
+                       android:layout_height="wrap_content"
+                       android:orientation="vertical">
+
+                   <RadioButton android:id="@+id/ap_2G_band"
+                           android:layout_width="match_parent"
+                           android:layout_height="wrap_content"
+                           android:text="@string/wifi_ap_choose_2G"
+                           android:layout_marginTop="8dip"/>
+
+                   <RadioButton android:id="@+id/ap_5G_band"
+                           android:layout_width="match_parent"
+                           android:layout_height="wrap_content"
+                           android:text="@string/wifi_ap_choose_5G"
+                           android:layout_marginTop="8dip"/>
+               </RadioGroup>
         </LinearLayout>
 
         <LinearLayout android:id="@+id/fields"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index f0462f3..c108a21 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -316,6 +316,12 @@
         <item>TTLS</item>
         <!-- Do not translate. -->
         <item>PWD</item>
+        <!-- Do not translate. -->
+        <item>SIM</item>
+        <!-- Do not translate. -->
+        <item>AKA</item>
+        <!-- Do not translate. -->
+        <item>AKA\'</item>
     </string-array>
 
    <!-- Wi-Fi WPS setup for p2p connections.  -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cce295a..989219d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -389,6 +389,11 @@
     <!-- Bluetooth message permission Alert Activity text [CHAR LIMIT=none] -->
     <string name="bluetooth_map_acceptance_dialog_text">%1$s wants to access your messages. Give access to %2$s?</string>
 
+    <!-- Activity label of BluetoothMessagePermissionActivity, also used as Strings in the permission dialog [CHAR LIMIT=none] -->
+    <string name="bluetooth_sap_request">"SIM Access request"</string>
+
+    <!-- Bluetooth message permission Alert Activity text [CHAR LIMIT=none] -->
+    <string name="bluetooth_sap_acceptance_dialog_text">%1$s wants to access your SIM card. Give access to %2$s?</string>
     <!-- Date & time settings screen title -->
     <string name="date_and_time">Date &amp; time</string>
     <!-- The title of the activity to pick a time zone. -->
@@ -1257,6 +1262,8 @@
     <string name="bluetooth_profile_pan_nap">Internet connection sharing</string>
     <!-- Bluetooth settings.  The user-visible string that is used whenever referring to the map profile. -->
     <string name="bluetooth_profile_map">Message Access</string>
+    <!-- Bluetooth settings.  The user-visible string that is used whenever referring to the sap profile (sharing SIM card). -->
+    <string name="bluetooth_profile_sap">SIM Access</string>
 
     <!-- Bluetooth settings.  Message for disconnecting from the A2DP profile. [CHAR LIMIT=80] -->
     <string name="bluetooth_disconnect_a2dp_profile"><xliff:g id="device_name">%1$s</xliff:g> will be disconnected from media audio.</string>
@@ -1292,6 +1299,8 @@
     <string name="bluetooth_opp_profile_summary_connected">Connected to file transfer server</string>
     <!-- Bluetooth settings.  Connection options screen.  The summary for the map checkbox preference when map is connected. -->
     <string name="bluetooth_map_profile_summary_connected">Connected to map</string>
+    <!-- Bluetooth settings.  Connection options screen.  The summary for the sap checkbox preference when sap is connected. -->
+    <string name="bluetooth_sap_profile_summary_connected">Connected to sap</string>
     <!-- Bluetooth settings.  Connection options screen.  The summary for the OPP checkbox preference when OPP is not connected. -->
     <string name="bluetooth_opp_profile_summary_not_connected">Not connected to file transfer server</string>
     <!-- Bluetooth settings. Connection options screen. The summary for the HID checkbox preference when HID is connected. -->
@@ -1317,6 +1326,8 @@
     <string name="bluetooth_pan_profile_summary_use_for">Use for Internet access</string>
     <!-- Bluetooth settings.  Connection options screen.  The summary for the map checkbox preference that describes how checking it will set the map profile as preferred. -->
     <string name="bluetooth_map_profile_summary_use_for">Use for map</string>
+    <!-- Bluetooth settings.  Connection options screen.  The summary for the sap checkbox preference that describes how checking it will set the sap profile as preferred. -->
+    <string name="bluetooth_sap_profile_summary_use_for">Use for sap</string>
 
     <!-- Bluetooth settings.  Dock Setting Title -->
     <string name="bluetooth_dock_settings">Dock Settings</string>
@@ -1333,6 +1344,10 @@
     <string name="wifi_assistant_title">Wi\u2011Fi Assistant</string>
     <!-- Status message of Wi-Fi when it is connected by a Wi-Fi assistant application. [CHAR LIMIT=NONE] -->
     <string name="connected_via_wfa">Connected via Wi\u2011Fi assistant</string>
+    <!-- Status message of Wi-Fi when it is connected by Passpoint configuration. [CHAR LIMIT=NONE] -->
+    <string name="connected_via_passpoint">Connected via %1$s</string>
+    <!-- Status message of Wi-Fi when network has matching passpoint credentials. [CHAR LIMIT=NONE] -->
+    <string name="available_via_passpoint">Available via %1$s</string>
 
     <!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
     <string name="wifi_display_settings_title">Cast screen</string>
@@ -1582,6 +1597,12 @@
     <string name="wifi_password">Password</string>
     <!-- Label for the check box to show password -->
     <string name="wifi_show_password">Show password</string>
+    <!-- Label for the RadioGroup to choose wifi ap band -->
+    <string name="wifi_ap_band_config">Config AP Band</string>
+    <!-- Label for the radio button to choose wifi ap 2.4 GHz band -->
+    <string name="wifi_ap_choose_2G">2.4 GHz Band</string>
+    <!-- Label for the radio button to choose wifi ap 5GHz band -->
+    <string name="wifi_ap_choose_5G">5 GHz Band</string>
     <!-- Label for the spinner to show ip settings [CHAR LIMIT=25] -->
     <string name="wifi_ip_settings">IP settings</string>
     <!-- Hint for unchanged fields -->
@@ -3434,22 +3455,6 @@
     <string name="confirm_enable_oem_unlock_text">WARNING: Device protection features will not work on this device while this setting is turned on.</string>
 
 
-    <!-- Setting Checkbox title whether to show options for wireless display certification -->
-    <string name="wifi_display_certification">Wireless display certification</string>
-    <!-- Setting Checkbox title whether to enable WiFi Verbose Logging. [CHAR LIMIT=40] -->
-    <string name="wifi_verbose_logging">Enable Wi\u2011Fi Verbose Logging</string>
-    <!-- Setting Checkbox title whether to enable WiFi Aggressive Handover. [CHAR LIMIT=40] -->
-    <string name="wifi_aggressive_handover">Aggressive Wi\u2011Fi to Cellular handover</string>
-    <!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
-    <string name="wifi_allow_scan_with_traffic">Always allow Wi\u2011Fi Roam Scans</string>
-    <!-- setting Checkbox summary whether to show options for wireless display certification  -->
-    <string name="wifi_display_certification_summary">Show options for wireless display certification</string>
-    <!-- Setting Checkbox summary whether to enable Wifi verbose Logging [CHAR LIMIT=80] -->
-    <string name="wifi_verbose_logging_summary">Increase Wi\u2011Fi logging level, show per SSID RSSI in Wi\u2011Fi Picker</string>
-    <!-- Setting Checkbox summary whether to enable Wifi aggressive handover [CHAR LIMIT=130] -->
-    <string name="wifi_aggressive_handover_summary">When enabled, Wi\u2011Fi will be more aggressive in handing over the data connection to Cellular, when Wi\u2011Fi signal is low</string>
-    <!-- Setting Checkbox summary whether to always allow WiFi Roam Scans [CHAR LIMIT=130] -->
-    <string name="wifi_allow_scan_with_traffic_summary">Allow/Disallow Wi\u2011Fi Roam Scans based on the amount of data traffic present at the interface</string>
     <!-- UI debug setting: limit size of Android logger buffers -->
     <string name="select_logd_size_title">Logger buffer sizes</string>
     <!-- UI debug setting: limit size of Android logger buffers [CHAR LIMIT=59] -->
@@ -3461,6 +3466,32 @@
     <!-- Setting Checkbox title whether to enable view attribute inspection -->
     <string name="debug_view_attributes">Enable view attribute inspection</string>
     <!-- Title of warning dialog about the implications of enabling USB debugging -->
+
+    <!-- Preference category for networking debugging development settings. [CHAR LIMIT=50] -->
+    <string name="debug_networking_category">Networking</string>
+
+    <!-- Setting Checkbox title whether to show options for wireless display certification -->
+    <string name="wifi_display_certification">Wireless display certification</string>
+    <!-- Setting Checkbox title whether to enable WiFi Verbose Logging. [CHAR LIMIT=40] -->
+    <string name="wifi_verbose_logging">Enable Wi\u2011Fi Verbose Logging</string>
+    <!-- Setting Checkbox title whether to enable WiFi Aggressive Handover. [CHAR LIMIT=40] -->
+    <string name="wifi_aggressive_handover">Aggressive Wi\u2011Fi to Cellular handover</string>
+    <!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
+    <string name="wifi_allow_scan_with_traffic">Always allow Wi\u2011Fi Roam Scans</string>
+    <!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
+    <string name="legacy_dhcp_client">Use legacy DHCP client</string>
+
+    <!-- setting Checkbox summary whether to show options for wireless display certification  -->
+    <string name="wifi_display_certification_summary">Show options for wireless display certification</string>
+    <!-- Setting Checkbox summary whether to enable Wifi verbose Logging [CHAR LIMIT=80] -->
+    <string name="wifi_verbose_logging_summary">Increase Wi\u2011Fi logging level, show per SSID RSSI in Wi\u2011Fi Picker</string>
+    <!-- Setting Checkbox summary whether to enable Wifi aggressive handover [CHAR LIMIT=130] -->
+    <string name="wifi_aggressive_handover_summary">When enabled, Wi\u2011Fi will be more aggressive in handing over the data connection to Cellular, when Wi\u2011Fi signal is low</string>
+    <!-- Setting Checkbox summary whether to always allow WiFi Roam Scans [CHAR LIMIT=130] -->
+    <string name="wifi_allow_scan_with_traffic_summary">Allow/Disallow Wi\u2011Fi Roam Scans based on the amount of data traffic present at the interface</string>
+    <!-- Setting Checkbox summary whether to use DHCP client from Lollipop (Android 5.0) [CHAR LIMIT=130] -->
+    <string name="legacy_dhcp_client_summary">Use the DHCP client from Lollipop instead of the new Android DHCP client.</string>
+
     <string name="adb_warning_title">Allow USB debugging?</string>
     <!-- Warning text to user about the implications of enabling USB debugging -->
     <string name="adb_warning_message">USB debugging is intended for development purposes only. Use it to copy data between your computer and your device, install apps on your device without notification, and read log data.</string>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index f31d556..1a03c2c 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -103,6 +103,18 @@
             android:title="@string/verify_apps_over_usb_title"
             android:summary="@string/verify_apps_over_usb_summary"/>
 
+        <ListPreference
+            android:key="select_logd_size"
+            android:title="@string/select_logd_size_title"
+            android:dialogTitle="@string/select_logd_size_dialog_title"
+            android:entries="@array/select_logd_size_titles"
+            android:entryValues="@array/select_logd_size_values" />
+
+    </PreferenceCategory>
+
+    <PreferenceCategory android:key="debug_networking_category"
+            android:title="@string/debug_networking_category">
+
         <SwitchPreference
             android:key="wifi_display_certification"
             android:title="@string/wifi_display_certification"
@@ -123,12 +135,10 @@
             android:title="@string/wifi_allow_scan_with_traffic" />
             android:summary="@string/wifi_allow_scan_with_traffic_summary"/>
 
-        <ListPreference
-            android:key="select_logd_size"
-            android:title="@string/select_logd_size_title"
-            android:dialogTitle="@string/select_logd_size_dialog_title"
-            android:entries="@array/select_logd_size_titles"
-            android:entryValues="@array/select_logd_size_values" />
+       <SwitchPreference
+            android:key="legacy_dhcp_client"
+            android:title="@string/legacy_dhcp_client" />
+            android:summary="@string/legacy_dhcp_client_summary"/>
 
     </PreferenceCategory>
 
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index a001fd7..51177e1 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -135,13 +135,16 @@
     private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
     private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
     private static final String DEBUG_APPLICATIONS_CATEGORY_KEY = "debug_applications_category";
+    private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";
+    private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";
+    private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size";
+
+    private static final String DEBUG_NETWORKING_CATEGORY_KEY = "debug_networking_category";
     private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification";
     private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging";
     private static final String WIFI_AGGRESSIVE_HANDOVER_KEY = "wifi_aggressive_handover";
     private static final String WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY = "wifi_allow_scan_with_traffic";
-    private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";
-    private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";
-    private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size";
+    private static final String WIFI_LEGACY_DHCP_CLIENT_KEY = "legacy_dhcp_client";
 
     private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
 
@@ -197,6 +200,7 @@
     private SwitchPreference mWifiDisplayCertification;
     private SwitchPreference mWifiVerboseLogging;
     private SwitchPreference mWifiAggressiveHandover;
+    private SwitchPreference mLegacyDhcpClient;
 
     private SwitchPreference mWifiAllowScansWithTraffic;
     private SwitchPreference mStrictMode;
@@ -336,6 +340,7 @@
         mWifiVerboseLogging = findAndInitSwitchPref(WIFI_VERBOSE_LOGGING_KEY);
         mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
         mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
+        mLegacyDhcpClient = findAndInitSwitchPref(WIFI_LEGACY_DHCP_CLIENT_KEY);
         mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
 
         mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
@@ -543,6 +548,7 @@
         updateWifiVerboseLoggingOptions();
         updateWifiAggressiveHandoverOptions();
         updateWifiAllowScansWithTrafficOptions();
+        updateLegacyDhcpClientOptions();
         updateSimulateColorSpace();
         updateUseNuplayerOptions();
         updateUSBAudioOptions();
@@ -1073,6 +1079,18 @@
         mWifiManager.setAllowScansWithTraffic(mWifiAllowScansWithTraffic.isChecked() ? 1 : 0);
     }
 
+    private void updateLegacyDhcpClientOptions() {
+        updateSwitchPreference(mLegacyDhcpClient, Settings.Global.getInt(
+                getActivity().getContentResolver(),
+                Settings.Global.LEGACY_DHCP_CLIENT, 0) != 0);
+    }
+
+    private void writeLegacyDhcpClientOptions() {
+        Settings.Global.putInt(getActivity().getContentResolver(),
+                Settings.Global.LEGACY_DHCP_CLIENT,
+                mLegacyDhcpClient.isChecked() ? 1 : 0);
+    }
+
     private void updateLogdSizeValues() {
         if (mLogdSize != null) {
             String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
@@ -1450,6 +1468,8 @@
             writeWifiAggressiveHandoverOptions();
         } else if (preference == mWifiAllowScansWithTraffic) {
             writeWifiAllowScansWithTrafficOptions();
+        } else if (preference == mLegacyDhcpClient) {
+            writeLegacyDhcpClientOptions();
         } else if (preference == mUseAwesomePlayer) {
             writeUseAwesomePlayerOptions();
         } else if (preference == mUSBAudio) {
diff --git a/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
index 4466aea..ccbb655 100644
--- a/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
@@ -188,7 +188,7 @@
         } else {
             mDeviceNameEdited = true;
             if (mOkButton != null) {
-                mOkButton.setEnabled(s.length() != 0);
+                mOkButton.setEnabled(s.toString().trim().length() != 0);
             }
         }
     }
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
index f43d176..3c250f0 100755
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -99,6 +99,8 @@
             showDialog(getString(R.string.bluetooth_phonebook_request), mRequestType);
         } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
             showDialog(getString(R.string.bluetooth_map_request), mRequestType);
+        } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
+            showDialog(getString(R.string.bluetooth_sap_request), mRequestType);
         }
         else {
             Log.e(TAG, "Error: bad request type: " + mRequestType);
@@ -127,6 +129,9 @@
         case BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS:
             p.mView = createMapDialogView();
             break;
+        case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS:
+            p.mView = createSapDialogView();
+            break;
         }
         p.mPositiveButtonText = getString(R.string.yes);
         p.mPositiveButtonListener = this;
@@ -181,6 +186,15 @@
         return mView;
     }
 
+    private View createSapDialogView() {
+        String mRemoteName = createRemoteName();
+        mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
+        messageView = (TextView)mView.findViewById(R.id.message);
+        messageView.setText(getString(R.string.bluetooth_sap_acceptance_dialog_text,
+                mRemoteName, mRemoteName));
+        return mView;
+    }
+
     private void onPositive() {
         if (DEBUG) Log.d(TAG, "onPositive");
         sendReplyIntentToReceiver(true, true);
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index 12c1d77..0cf8cc8 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -41,6 +41,7 @@
 
     private static final String NOTIFICATION_TAG_PBAP = "Phonebook Access" ;
     private static final String NOTIFICATION_TAG_MAP = "Message Access";
+    private static final String NOTIFICATION_TAG_SAP = "SIM Access";
 
 
     Context mContext;
@@ -181,6 +182,8 @@
             return NOTIFICATION_TAG_PBAP;
         } else if(mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
             return NOTIFICATION_TAG_MAP;
+        } else if(mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
+            return NOTIFICATION_TAG_SAP;
         }
         return null;
     }
@@ -195,7 +198,8 @@
 
         // ignore if it is something else than phonebook/message settings it wants us to remember
         if (mRequestType != BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS
-                && mRequestType != BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
+                && mRequestType != BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS
+                && mRequestType != BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
             if (DEBUG) Log.d(TAG, "checkUserChoice(): Unknown RequestType " + mRequestType);
             return processed;
         }
@@ -239,6 +243,20 @@
             } else {
                 Log.e(TAG, "Bad messagePermission: " + messagePermission);
             }
+        } else if(mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
+            int simPermission = cachedDevice.getSimPermissionChoice();
+
+            if (simPermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
+                // Leave 'processed' as false.
+            } else if (simPermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
+                sendReplyIntentToReceiver(true);
+                processed = true;
+            } else if (simPermission == CachedBluetoothDevice.ACCESS_REJECTED) {
+                sendReplyIntentToReceiver(false);
+                processed = true;
+            } else {
+                Log.e(TAG, "Bad simPermission: " + simPermission);
+            }
         }
         if (DEBUG) Log.d(TAG,"checkUserChoice(): returning " + processed);
         return processed;
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index f33f4db..cf289a7 100755
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.bluetooth;
 
+import android.bluetooth.BluetoothUuid;
 import android.bluetooth.BluetoothClass;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
@@ -65,10 +66,6 @@
 
     private boolean mVisible;
 
-    private int mPhonebookPermissionChoice;
-
-    private int mMessagePermissionChoice;
-
     private int mMessageRejectionCount;
 
     private final Collection<Callback> mCallbacks = new ArrayList<Callback>();
@@ -102,6 +99,7 @@
 
     // See mConnectAttempted
     private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000;
+    private static final long MAX_HOGP_DELAY_FOR_AUTO_CONNECT = 30000;
 
     /** Auto-connect after pairing only if locally initiated. */
     private boolean mConnectAfterPairing;
@@ -523,9 +521,11 @@
      */
     void onUuidChanged() {
         updateProfiles();
+        ParcelUuid[] uuids = mDevice.getUuids();
+        long timeout = MAX_UUID_DELAY_FOR_AUTO_CONNECT;
 
         if (DEBUG) {
-            Log.e(TAG, "onUuidChanged: Time since last connect"
+            Log.d(TAG, "onUuidChanged: Time since last connect"
                     + (SystemClock.elapsedRealtime() - mConnectAttempted));
         }
 
@@ -533,9 +533,11 @@
          * If a connect was attempted earlier without any UUID, we will do the
          * connect now.
          */
+        if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) {
+            timeout = MAX_HOGP_DELAY_FOR_AUTO_CONNECT;
+        }
         if (!mProfiles.isEmpty()
-                && (mConnectAttempted + MAX_UUID_DELAY_FOR_AUTO_CONNECT) > SystemClock
-                        .elapsedRealtime()) {
+                && (mConnectAttempted + timeout) > SystemClock.elapsedRealtime()) {
             connectWithoutResettingTimer(false);
         }
         dispatchAttributesChanged();
@@ -547,6 +549,7 @@
             mConnectAfterPairing = false;  // cancel auto-connect
             setPhonebookPermissionChoice(ACCESS_UNKNOWN);
             setMessagePermissionChoice(ACCESS_UNKNOWN);
+            setSimPermissionChoice(ACCESS_UNKNOWN);
             mMessageRejectionCount = 0;
             saveMessageRejectionCount();
         }
@@ -703,6 +706,26 @@
         editor.commit();
     }
 
+    int getSimPermissionChoice() {
+        int permission = mDevice.getSimAccessPermission();
+        if (permission == BluetoothDevice.ACCESS_ALLOWED) {
+            return ACCESS_ALLOWED;
+        } else if (permission == BluetoothDevice.ACCESS_REJECTED) {
+            return ACCESS_REJECTED;
+        }
+        return ACCESS_UNKNOWN;
+    }
+
+    void setSimPermissionChoice(int permissionChoice) {
+        int permission = BluetoothDevice.ACCESS_UNKNOWN;
+        if (permissionChoice == ACCESS_ALLOWED) {
+            permission = BluetoothDevice.ACCESS_ALLOWED;
+        } else if (permissionChoice == ACCESS_REJECTED) {
+            permission = BluetoothDevice.ACCESS_REJECTED;
+        }
+        mDevice.setSimAccessPermission(permission);
+    }
+
     int getMessagePermissionChoice() {
         int permission = mDevice.getMessageAccessPermission();
         if (permission == BluetoothDevice.ACCESS_ALLOWED) {
diff --git a/src/com/android/settings/bluetooth/SapProfile.java b/src/com/android/settings/bluetooth/SapProfile.java
new file mode 100644
index 0000000..95dfd1f
--- /dev/null
+++ b/src/com/android/settings/bluetooth/SapProfile.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.bluetooth;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothClass;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothSap;
+import android.bluetooth.BluetoothProfile;
+import android.bluetooth.BluetoothUuid;
+import android.content.Context;
+import android.os.ParcelUuid;
+import android.util.Log;
+
+import com.android.settings.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * SapProfile handles Bluetooth SAP profile.
+ */
+final class SapProfile implements LocalBluetoothProfile {
+    private static final String TAG = "SapProfile";
+    private static boolean V = true;
+
+    private BluetoothSap mService;
+    private boolean mIsProfileReady;
+
+    private final LocalBluetoothAdapter mLocalAdapter;
+    private final CachedBluetoothDeviceManager mDeviceManager;
+    private final LocalBluetoothProfileManager mProfileManager;
+
+    static final ParcelUuid[] UUIDS = {
+        BluetoothUuid.SAP,
+    };
+
+    static final String NAME = "SAP";
+
+    // Order of this profile in device profiles list
+    private static final int ORDINAL = 10;
+
+    // These callbacks run on the main thread.
+    private final class SapServiceListener
+            implements BluetoothProfile.ServiceListener {
+
+        public void onServiceConnected(int profile, BluetoothProfile proxy) {
+            if (V) Log.d(TAG,"Bluetooth service connected");
+            mService = (BluetoothSap) proxy;
+            // We just bound to the service, so refresh the UI for any connected SAP devices.
+            List<BluetoothDevice> deviceList = mService.getConnectedDevices();
+            while (!deviceList.isEmpty()) {
+                BluetoothDevice nextDevice = deviceList.remove(0);
+                CachedBluetoothDevice device = mDeviceManager.findDevice(nextDevice);
+                // we may add a new device here, but generally this should not happen
+                if (device == null) {
+                    Log.w(TAG, "SapProfile found new device: " + nextDevice);
+                    device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+                }
+                device.onProfileStateChanged(SapProfile.this,
+                        BluetoothProfile.STATE_CONNECTED);
+                device.refresh();
+            }
+
+            mProfileManager.callServiceConnectedListeners();
+            mIsProfileReady=true;
+        }
+
+        public void onServiceDisconnected(int profile) {
+            if (V) Log.d(TAG,"Bluetooth service disconnected");
+            mProfileManager.callServiceDisconnectedListeners();
+            mIsProfileReady=false;
+        }
+    }
+
+    public boolean isProfileReady() {
+        return mIsProfileReady;
+    }
+
+    SapProfile(Context context, LocalBluetoothAdapter adapter,
+            CachedBluetoothDeviceManager deviceManager,
+            LocalBluetoothProfileManager profileManager) {
+        mLocalAdapter = adapter;
+        mDeviceManager = deviceManager;
+        mProfileManager = profileManager;
+        mLocalAdapter.getProfileProxy(context, new SapServiceListener(),
+                BluetoothProfile.SAP);
+    }
+
+    public boolean isConnectable() {
+        return true;
+    }
+
+    public boolean isAutoConnectable() {
+        return true;
+    }
+
+    public boolean connect(BluetoothDevice device) {
+        if (mService == null) return false;
+        List<BluetoothDevice> sinks = mService.getConnectedDevices();
+        if (sinks != null) {
+            for (BluetoothDevice sink : sinks) {
+                mService.disconnect(sink);
+            }
+        }
+        return mService.connect(device);
+    }
+
+    public boolean disconnect(BluetoothDevice device) {
+        if (mService == null) return false;
+        List<BluetoothDevice> deviceList = mService.getConnectedDevices();
+        if (!deviceList.isEmpty() && deviceList.get(0).equals(device)) {
+            if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
+                mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
+            }
+            return mService.disconnect(device);
+        } else {
+            return false;
+        }
+    }
+
+    public int getConnectionStatus(BluetoothDevice device) {
+        if (mService == null) return BluetoothProfile.STATE_DISCONNECTED;
+        List<BluetoothDevice> deviceList = mService.getConnectedDevices();
+
+        return !deviceList.isEmpty() && deviceList.get(0).equals(device)
+                ? mService.getConnectionState(device)
+                : BluetoothProfile.STATE_DISCONNECTED;
+    }
+
+    public boolean isPreferred(BluetoothDevice device) {
+        if (mService == null) return false;
+        return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF;
+    }
+
+    public int getPreferred(BluetoothDevice device) {
+        if (mService == null) return BluetoothProfile.PRIORITY_OFF;
+        return mService.getPriority(device);
+    }
+
+    public void setPreferred(BluetoothDevice device, boolean preferred) {
+        if (mService == null) return;
+        if (preferred) {
+            if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) {
+                mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
+            }
+        } else {
+            mService.setPriority(device, BluetoothProfile.PRIORITY_OFF);
+        }
+    }
+
+    public List<BluetoothDevice> getConnectedDevices() {
+        if (mService == null) return new ArrayList<BluetoothDevice>(0);
+        return mService.getDevicesMatchingConnectionStates(
+              new int[] {BluetoothProfile.STATE_CONNECTED,
+                         BluetoothProfile.STATE_CONNECTING,
+                         BluetoothProfile.STATE_DISCONNECTING});
+    }
+
+    public String toString() {
+        return NAME;
+    }
+
+    public int getOrdinal() {
+        return ORDINAL;
+    }
+
+    public int getNameResource(BluetoothDevice device) {
+        return R.string.bluetooth_profile_sap;
+    }
+
+    public int getSummaryResourceForDevice(BluetoothDevice device) {
+        int state = getConnectionStatus(device);
+        switch (state) {
+            case BluetoothProfile.STATE_DISCONNECTED:
+                return R.string.bluetooth_sap_profile_summary_use_for;
+
+            case BluetoothProfile.STATE_CONNECTED:
+                return R.string.bluetooth_sap_profile_summary_connected;
+
+            default:
+                return Utils.getConnectionStateSummary(state);
+        }
+    }
+
+    public int getDrawableResource(BluetoothClass btClass) {
+        return R.drawable.ic_bt_cellphone;
+    }
+
+    protected void finalize() {
+        if (V) Log.d(TAG, "finalize()");
+        if (mService != null) {
+            try {
+                BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.SAP,
+                                                                       mService);
+                mService = null;
+            }catch (Throwable t) {
+                Log.w(TAG, "Error cleaning up SAP proxy", t);
+            }
+        }
+    }
+}
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index 3170dae..4566662 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -29,6 +29,7 @@
 import android.telecom.TelecomManager;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.KeyEvent;
@@ -210,6 +211,7 @@
         ArrayList<SubscriptionInfo> callsSubInfoList = new ArrayList<SubscriptionInfo>();
         if (id == CALLS_PICK) {
             final TelecomManager telecomManager = TelecomManager.from(context);
+            final TelephonyManager telephonyManager = TelephonyManager.from(context);
             final Iterator<PhoneAccountHandle> phoneAccounts =
                     telecomManager.getCallCapablePhoneAccounts().listIterator();
 
@@ -219,13 +221,9 @@
                 final PhoneAccount phoneAccount =
                         telecomManager.getPhoneAccount(phoneAccounts.next());
                 list.add((String)phoneAccount.getLabel());
-                // Added check to add entry into callsSubInforList only if phoneAccountId is int
-                // Todo : Might have to change it later based on b/18904714
-                if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) &&
-                        TextUtils.isDigitsOnly(phoneAccount.getAccountHandle().getId())) {
-                    final String phoneAccountId = phoneAccount.getAccountHandle().getId();
-                    final SubscriptionInfo sir = Utils.findRecordBySubId(context,
-                            Integer.parseInt(phoneAccountId));
+                int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
+                if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+                    final SubscriptionInfo sir = Utils.findRecordBySubId(context, subId);
                     callsSubInfoList.add(sir);
                 } else {
                     callsSubInfoList.add(null);
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 1bf1a5c..cb48f1f 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -230,7 +230,11 @@
     }
 
     private void loadConfig(WifiConfiguration config) {
-        ssid = (config.SSID == null ? "" : removeDoubleQuotes(config.SSID));
+        if (config.isPasspoint())
+            ssid = config.providerFriendlyName;
+        else
+            ssid = (config.SSID == null ? "" : removeDoubleQuotes(config.SSID));
+
         bssid = config.BSSID;
         security = getSecurity(config);
         networkId = config.networkId;
@@ -360,6 +364,7 @@
             refresh();
             return true;
         }
+
         return false;
     }
 
@@ -394,6 +399,12 @@
         }
     }
 
+    void update(WifiConfiguration config) {
+        mConfig = config;
+        networkId = config.networkId;
+        refresh();
+    }
+
     int getLevel() {
         if (mRssi == Integer.MAX_VALUE) {
             return -1;
@@ -617,10 +628,14 @@
         StringBuilder summary = new StringBuilder();
 
         if (isActive()) { // This is the active connection
+            String passpointProvider = (mConfig != null && mConfig.isPasspoint()) ?
+                    mConfig.providerFriendlyName : null;
             summary.append(Summary.get(context, getState(),
-                    networkId == WifiConfiguration.INVALID_NETWORK_ID));
-        } else if (mConfig != null
-                && mConfig.hasNoInternetAccess()) {
+                    networkId == WifiConfiguration.INVALID_NETWORK_ID, passpointProvider));
+        } else if (mConfig != null && mConfig.isPasspoint()) {
+            String format = context.getString(R.string.available_via_passpoint);
+            summary.append(String.format(format, mConfig.providerFriendlyName));
+        } else if (mConfig != null && mConfig.hasNoInternetAccess()) {
             summary.append(context.getString(R.string.wifi_no_internet));
         } else if (mConfig != null && ((mConfig.status == WifiConfiguration.Status.DISABLED &&
                 mConfig.disableReason != WifiConfiguration.DISABLED_UNKNOWN_REASON)
diff --git a/src/com/android/settings/wifi/Summary.java b/src/com/android/settings/wifi/Summary.java
index 123f64a..2abe3b9 100644
--- a/src/com/android/settings/wifi/Summary.java
+++ b/src/com/android/settings/wifi/Summary.java
@@ -20,12 +20,20 @@
 
 import android.content.Context;
 import android.net.NetworkInfo.DetailedState;
+import android.text.TextUtils;
 
 class Summary {
-    static String get(Context context, String ssid, DetailedState state, boolean isEphemeral) {
-        if (state == DetailedState.CONNECTED && isEphemeral && ssid == null) {
-            // Special case for connected + ephemeral networks.
-            return context.getString(R.string.connected_via_wfa);
+    static String get(Context context, String ssid, DetailedState state, boolean isEphemeral,
+                      String passpointProvider) {
+        if (state == DetailedState.CONNECTED) {
+            if (TextUtils.isEmpty(passpointProvider) == false) {
+                // Special case for connected + ephemeral networks.
+                String format = context.getString(R.string.connected_via_passpoint);
+                return String.format(format, passpointProvider);
+            } else if (isEphemeral && ssid == null) {
+                // Special case for connected + ephemeral networks.
+                return context.getString(R.string.connected_via_wfa);
+            }
         }
 
         String[] formats = context.getResources().getStringArray((ssid == null)
@@ -38,7 +46,15 @@
         return String.format(formats[index], ssid);
     }
 
+    static String get(Context context, String ssid, DetailedState state, boolean isEphemeral) {
+        return get(context, ssid, state, isEphemeral, null);
+    }
     static String get(Context context, DetailedState state, boolean isEphemeral) {
-        return get(context, null, state, isEphemeral);
+        return get(context, null, state, isEphemeral, null);
+    }
+
+    static String get(Context context, DetailedState state, boolean isEphemeral,
+                      String passpointProvider) {
+        return get(context, null, state, isEphemeral, passpointProvider);
     }
 }
diff --git a/src/com/android/settings/wifi/WifiApDialog.java b/src/com/android/settings/wifi/WifiApDialog.java
index fb8026a..3c4d912 100644
--- a/src/com/android/settings/wifi/WifiApDialog.java
+++ b/src/com/android/settings/wifi/WifiApDialog.java
@@ -22,6 +22,7 @@
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiConfiguration.AuthAlgorithm;
 import android.net.wifi.WifiConfiguration.KeyMgmt;
+import android.net.wifi.WifiManager;
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.InputType;
@@ -32,9 +33,13 @@
 import android.widget.EditText;
 import android.widget.Spinner;
 import android.widget.TextView;
+import android.widget.RadioGroup;
+import android.widget.RadioButton;
 
 import com.android.settings.R;
 
+import android.util.Log;
+
 /**
  * Dialog to configure the SSID and security settings
  * for Access Point operation
@@ -53,8 +58,14 @@
     private TextView mSsid;
     private int mSecurityTypeIndex = OPEN_INDEX;
     private EditText mPassword;
+    private RadioGroup mChannel;
+    private RadioButton mChannel2G;
+    private RadioButton mChannel5G;
 
     WifiConfiguration mWifiConfig;
+    WifiManager mWifiManager;
+
+    private static final String TAG = "WifiApDialog";
 
     public WifiApDialog(Context context, DialogInterface.OnClickListener listener,
             WifiConfiguration wifiConfig) {
@@ -64,6 +75,7 @@
         if (wifiConfig != null) {
             mSecurityTypeIndex = getSecurityTypeIndex(wifiConfig);
         }
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
     }
 
     public static int getSecurityTypeIndex(WifiConfiguration wifiConfig) {
@@ -85,6 +97,16 @@
          */
         config.SSID = mSsid.getText().toString();
 
+        //obtain the band configure
+        if (mChannel2G.isChecked()) {
+            config.apBand = 0;
+        } else if(mChannel5G.isChecked()) {
+            config.apBand = 1;
+        } else {
+            Log.e("TAG", "AP band configure error!");
+            return null;
+        }
+
         switch (mSecurityTypeIndex) {
             case OPEN_INDEX:
                 config.allowedKeyManagement.set(KeyMgmt.NONE);
@@ -118,15 +140,36 @@
         mSsid = (TextView) mView.findViewById(R.id.ssid);
         mPassword = (EditText) mView.findViewById(R.id.password);
 
+        mChannel = (RadioGroup) mView.findViewById(R.id.choose_channel);
+        mChannel2G = (RadioButton) mView.findViewById(R.id.ap_2G_band);
+        mChannel5G = (RadioButton) mView.findViewById(R.id.ap_5G_band);
+
+        String countryCode = mWifiManager.getCountryCode();
+        if (!mWifiManager.is5GHzBandSupported() || countryCode == null) {
+            //If no country code, 5GHz AP is forbidden
+            Log.e(TAG," NO country code, forbid 5GHz");
+            mChannel5G.setVisibility(View.INVISIBLE);
+            mWifiConfig.apBand = 0;
+        } else {
+            mChannel5G.setVisibility(View.VISIBLE);
+        }
+
+
         setButton(BUTTON_SUBMIT, context.getString(R.string.wifi_save), mListener);
         setButton(DialogInterface.BUTTON_NEGATIVE,
         context.getString(R.string.wifi_cancel), mListener);
 
         if (mWifiConfig != null) {
             mSsid.setText(mWifiConfig.SSID);
+            if (mWifiConfig.apBand == 0) {
+                mChannel2G.setChecked(true);
+            } else {
+                mChannel5G.setChecked(true);
+            }
+
             mSecurity.setSelection(mSecurityTypeIndex);
             if (mSecurityTypeIndex == WPA2_INDEX) {
-                  mPassword.setText(mWifiConfig.preSharedKey);
+                mPassword.setText(mWifiConfig.preSharedKey);
             }
         }
 
@@ -141,6 +184,15 @@
         validate();
     }
 
+    public void onRestoreInstanceState(Bundle savedInstanceState) {
+        super.onRestoreInstanceState(savedInstanceState);
+        mPassword.setInputType(
+                InputType.TYPE_CLASS_TEXT |
+                (((CheckBox) mView.findViewById(R.id.show_password)).isChecked() ?
+                InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
+                InputType.TYPE_TEXT_VARIATION_PASSWORD));
+    }
+
     private void validate() {
         if ((mSsid != null && mSsid.length() == 0) ||
                    ((mSecurityTypeIndex == WPA2_INDEX)&&
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 5462d26..38ceead 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -92,6 +92,9 @@
     public static final int WIFI_EAP_METHOD_TLS  = 1;
     public static final int WIFI_EAP_METHOD_TTLS = 2;
     public static final int WIFI_EAP_METHOD_PWD  = 3;
+    public static final int WIFI_EAP_METHOD_SIM  = 4;
+    public static final int WIFI_EAP_METHOD_AKA  = 5;
+    public static final int WIFI_EAP_METHOD_AKA_PRIME  = 6;
 
     /* These values come from "wifi_peap_phase2_entries" resource array */
     public static final int WIFI_PEAP_PHASE2_NONE 	    = 0;
@@ -266,9 +269,15 @@
                     mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
                 } else {
                     if (state != null) {
-                        addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(),
-                                state, mAccessPoint.networkId ==
-                                WifiConfiguration.INVALID_NETWORK_ID));
+                        WifiConfiguration config = mAccessPoint.getConfig();
+                        if (config != null && config.isPasspoint()) {
+                            addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(),
+                                    state, false, config.providerFriendlyName));
+                        } else {
+                            addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(),
+                                    state, mAccessPoint.networkId ==
+                                            WifiConfiguration.INVALID_NETWORK_ID));
+                        }
                     }
 
                     if (signalLevel != null) {
@@ -762,9 +771,23 @@
                 mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
                 setUserCertInvisible();
                 break;
+            case WIFI_EAP_METHOD_SIM:
+            case WIFI_EAP_METHOD_AKA:
+            case WIFI_EAP_METHOD_AKA_PRIME:
+                setPhase2Invisible();
+                setAnonymousIdentInvisible();
+                setUserCertInvisible();
+                setPasswordInvisible();
+                setIdentityInvisible();
+                break;
         }
     }
 
+    private void setIdentityInvisible() {
+        mView.findViewById(R.id.l_identity).setVisibility(View.GONE);
+        mPhase2Spinner.setSelection(Phase2.NONE);
+    }
+
     private void setPhase2Invisible() {
         mView.findViewById(R.id.l_phase2).setVisibility(View.GONE);
         mPhase2Spinner.setSelection(Phase2.NONE);
@@ -999,14 +1022,12 @@
     /**
      * Make the characters of the password visible if show_password is checked.
      */
-    private void updatePasswordVisibility(boolean checked) {
-        int pos = mPasswordView.getSelectionEnd();
-        mPasswordView.setInputType(
-                InputType.TYPE_CLASS_TEXT | (checked ?
-                        InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
-                            InputType.TYPE_TEXT_VARIATION_PASSWORD));
-        if (pos >= 0) {
-            ((EditText)mPasswordView).setSelection(pos);
-        }
+    public void updatePassword() {
+        TextView passwdView = (TextView) mView.findViewById(R.id.password);
+        passwdView.setInputType(
+                InputType.TYPE_CLASS_TEXT |
+                (((CheckBox) mView.findViewById(R.id.show_password)).isChecked() ?
+                InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
+                InputType.TYPE_TEXT_VARIATION_PASSWORD));
     }
 }
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index 942c5dd..ce554bc 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -74,6 +74,11 @@
         }
     }
 
+    public void onRestoreInstanceState(Bundle savedInstanceState) {
+            super.onRestoreInstanceState(savedInstanceState);
+            mController.updatePassword();
+    }
+
     @Override
     public boolean isEdit() {
         return mEdit;
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 54ebc6d..10175ec 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -653,6 +653,7 @@
         switch (wifiState) {
             case WifiManager.WIFI_STATE_ENABLED:
                 // AccessPoints are automatically sorted with TreeSet.
+                mLastInfo = mWifiManager.getConnectionInfo();
                 final Collection<AccessPoint> accessPoints =
                         constructAccessPoints(getActivity(), mWifiManager, mLastInfo,
                                 mLastNetworkInfo);
@@ -721,6 +722,7 @@
         /** Lookup table to more quickly update AccessPoints by only considering objects with the
          * correct SSID.  Maps SSID -> List of AccessPoints with the given SSID.  */
         Multimap<String, AccessPoint> apMap = new Multimap<String, AccessPoint>();
+        WifiConfiguration connectionConfig = null;
 
         final List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks();
         if (configs != null) {
@@ -732,13 +734,23 @@
                 }
             }
             for (WifiConfiguration config : configs) {
+                if (lastInfo != null && lastInfo.getNetworkId() == config.networkId) {
+                    connectionConfig = config;
+                }
+
                 if (config.selfAdded && config.numAssociation == 0) {
                     continue;
                 }
+
+                if (config.isPasspoint()) {
+                    continue;
+                }
+
                 AccessPoint accessPoint = new AccessPoint(context, config);
                 if (lastInfo != null && lastNetworkInfo != null) {
                     accessPoint.update(lastInfo, lastNetworkInfo);
                 }
+
                 accessPoints.add(accessPoint);
                 apMap.put(accessPoint.ssid, accessPoint);
             }
@@ -758,11 +770,29 @@
                     if (accessPoint.update(result))
                         found = true;
                 }
+
                 if (!found) {
+
                     AccessPoint accessPoint = new AccessPoint(context, result);
                     if (lastInfo != null && lastNetworkInfo != null) {
                         accessPoint.update(lastInfo, lastNetworkInfo);
                     }
+
+                    if (result.passpointNetwork) {
+                        WifiConfiguration config = wifiManager.getMatchingWifiConfig(result);
+                        if (config != null) {
+                            accessPoint.update(config);
+                        }
+                    }
+
+                    if (lastInfo != null && lastInfo.getBSSID() != null
+                            && lastInfo.getBSSID().equals(result.BSSID)
+                            && connectionConfig != null && connectionConfig.isPasspoint()) {
+                        /* This network is connected via this passpoint config */
+                        /* SSID match is not going to work for it; so update explicitly */
+                        accessPoint.update(connectionConfig);
+                    }
+
                     accessPoints.add(accessPoint);
                     apMap.put(accessPoint.ssid, accessPoint);
                 }