projects
/
zxing.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some error checking put in. When a new network is created and the
[zxing.git]
/
android
/
src
/
com
/
google
/
zxing
/
client
/
android
/
wifi
/
NetworkUtil.java
diff --git
a/android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
b/android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
index
0fbad03
..
fe15108
100644
(file)
--- a/
android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
+++ b/
android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
@@
-21,17
+21,22
@@
import android.text.TextUtils;
/**
* Try with:
* http://chart.apis.google.com/chart?cht=qr&chs=240x240&chl=WIFI:S:linksys;P:mypass;T:WPA;;
/**
* Try with:
* http://chart.apis.google.com/chart?cht=qr&chs=240x240&chl=WIFI:S:linksys;P:mypass;T:WPA;;
- * @author Vikram Aggarwal
*
* TODO(vikrama): Test with binary ssid or password.
*
* TODO(vikrama): Test with binary ssid or password.
+ *
+ * @author Vikram Aggarwal
*/
*/
-public final class NetworkUtil {
+final class NetworkUtil {
+
+ private NetworkUtil() {
+ }
+
/**
* Encloses the incoming string inside double quotes, if it isn't already quoted.
* @param string: the input string
* @return a quoted string, of the form "input". If the input string is null, it returns null as well.
*/
/**
* Encloses the incoming string inside double quotes, if it isn't already quoted.
* @param string: the input string
* @return a quoted string, of the form "input". If the input string is null, it returns null as well.
*/
-
public
static String convertToQuotedString(String string) {
+ static String convertToQuotedString(String string) {
if (string == null){
return null;
}
if (string == null){
return null;
}
@@
-41,11
+46,11
@@
public final class NetworkUtil {
final int lastPos = string.length() - 1;
if (lastPos < 0 || (string.charAt(0) == '"' && string.charAt(lastPos) == '"')) {
return string;
final int lastPos = string.length() - 1;
if (lastPos < 0 || (string.charAt(0) == '"' && string.charAt(lastPos) == '"')) {
return string;
- }
- return
"\"" + string + "\""
;
+ }
+ return
'\"' + string + '\"'
;
}
}
- private static boolean isHex(
String
key) {
+ private static boolean isHex(
CharSequence
key) {
if (key == null){
return false;
}
if (key == null){
return false;
}
@@
-54,7
+59,7
@@
public final class NetworkUtil {
if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f')) {
return false;
}
if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f')) {
return false;
}
- }
+ }
return true;
}
return true;
}
@@
-63,14
+68,13
@@
public final class NetworkUtil {
* @param wepKey the input to be checked
* @return true if the input string is indeed hex or empty. False if the input string is non-hex or null.
*/
* @param wepKey the input to be checked
* @return true if the input string is indeed hex or empty. False if the input string is non-hex or null.
*/
- public static boolean isHexWepKey(String wepKey) {
- if (wepKey == null)
- return false;
- final int len = wepKey.length();
- // WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?)
- if (len != 10 && len != 26 && len != 58) {
+ static boolean isHexWepKey(CharSequence wepKey) {
+ if (wepKey == null) {
return false;
}
return false;
}
- return isHex(wepKey);
- }
-}
+ final int length = wepKey.length();
+ // WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?)
+ return (length == 10 || length == 26 || length == 58) && isHex(wepKey);
+ }
+
+}
\ No newline at end of file