OSDN Git Service

wifi: Check for the sizeof ssid to start SoftAP
authorSunil Dutt <usdutt@codeaurora.org>
Thu, 2 Jul 2015 09:58:58 +0000 (15:28 +0530)
committerVinit Deshpande <vinitd@google.com>
Sat, 1 Aug 2015 00:20:17 +0000 (17:20 -0700)
Disable the option to start SoftAP if ssid byte length is over 32 bytes.

Bug: 22074821

Change-Id: I696dca1aac8673bff168481fde4b013450bac72c

src/com/android/settings/wifi/WifiApDialog.java

index b43a7ac..254c386 100644 (file)
@@ -34,6 +34,7 @@ import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.Spinner;
 import android.widget.TextView;
+import java.nio.charset.Charset;
 
 import com.android.settings.R;
 
@@ -213,9 +214,11 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
     }
 
     private void validate() {
-        if ((mSsid != null && mSsid.length() == 0) ||
-                   ((mSecurityTypeIndex == WPA2_INDEX)&&
-                        mPassword.length() < 8)) {
+        String mSsidString = mSsid.getText().toString();
+        if ((mSsid != null && mSsid.length() == 0)
+                || ((mSecurityTypeIndex == WPA2_INDEX) && mPassword.length() < 8)
+                || (mSsid != null &&
+                Charset.forName("UTF-8").encode(mSsidString).limit() > 32)) {
             getButton(BUTTON_SUBMIT).setEnabled(false);
         } else {
             getButton(BUTTON_SUBMIT).setEnabled(true);