Set wifi password minimal length to 5

WEP and PSK use the same password field, but the original code
flow only consider the minimal length of PSK. So it will cause
user can not input WEP password which less than 8.
So we need to consider the minimal length of WEP = 5.
Besides, we only allow 5, 13, 16 characters password if type is WEP.

Change-Id: I490145c015c72e2f164834ae4067f1b508865bdd
diff --git a/Settings/src/com/android/tv/settings/connectivity/FormPageDisplayer.java b/Settings/src/com/android/tv/settings/connectivity/FormPageDisplayer.java
index a5fbf29..e9f9b21 100644
--- a/Settings/src/com/android/tv/settings/connectivity/FormPageDisplayer.java
+++ b/Settings/src/com/android/tv/settings/connectivity/FormPageDisplayer.java
@@ -44,10 +44,11 @@
     public static final int DISPLAY_TYPE_TEXT_INPUT = 1;
     public static final int DISPLAY_TYPE_LIST_CHOICE = 2;
     public static final int DISPLAY_TYPE_LOADING = 3;
-    // Minimum 8 characters
+    // Minimum 5 characters for WEP, 8 characters for PSK
     public static final int DISPLAY_TYPE_PSK_INPUT = 4;
 
-    private static final int PSK_MIN_LENGTH = 8;
+    private static final int WEP_MIN_LENGTH = 5;
+    public static final int PSK_MIN_LENGTH = 8;
 
     public interface FormPageInfo {
         /**
@@ -253,7 +254,7 @@
         mPasswordInputWizardFragmentListener = new PasswordInputWizardFragment.Listener() {
             @Override
             public boolean onPasswordInputComplete(String text, boolean obfuscate) {
-                if (!TextUtils.isEmpty(text) && text.length() >= PSK_MIN_LENGTH) {
+                if (!TextUtils.isEmpty(text) && text.length() >= WEP_MIN_LENGTH) {
                     Bundle result = new Bundle();
                     result.putString(FormPage.DATA_KEY_SUMMARY_STRING, text);
                     if (obfuscate) {
diff --git a/Settings/src/com/android/tv/settings/connectivity/WifiMultiPagedFormActivity.java b/Settings/src/com/android/tv/settings/connectivity/WifiMultiPagedFormActivity.java
index be5105b..366c75d 100644
--- a/Settings/src/com/android/tv/settings/connectivity/WifiMultiPagedFormActivity.java
+++ b/Settings/src/com/android/tv/settings/connectivity/WifiMultiPagedFormActivity.java
@@ -143,13 +143,17 @@
         if (wifiSecurity == WifiSecurity.WEP) {
             int length = password.length();
             // WEP-40, WEP-104, and 256-bit WEP (WEP-232?)
-            if ((length == 10 || length == 26 || length == 58)
+            if ((length == 10 || length == 26 || length == 32 || length == 58)
                     && password.matches("[0-9A-Fa-f]*")) {
                 wifiConfiguration.wepKeys[0] = password;
-            } else {
+            } else if (length == 5 || length == 13 || length == 16 || length == 29) {
                 wifiConfiguration.wepKeys[0] = '"' + password + '"';
             }
         } else {
+            if (wifiSecurity == WifiSecurity.PSK
+                    && password.length() < FormPageDisplayer.PSK_MIN_LENGTH) {
+                return;
+            }
             if (password.matches("[0-9A-Fa-f]{64}")) {
                 wifiConfiguration.preSharedKey = password;
             } else {