Remove "Wi-Fi only" option from Wi-Fi Calling settings
automerge: a72c266

* commit 'a72c266d5de51188666435ca1fc1e5c2754ef033':
  Remove "Wi-Fi only" option from Wi-Fi Calling settings
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..292355e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1333,6 +1333,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 +1586,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 +3444,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 +3455,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/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index f33f4db..c8b9c5b 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;
@@ -102,6 +103,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 +525,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 +537,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();
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);
                 }