diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-09-16 17:53:34 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-09-23 09:13:34 -0700 |
commit | 5ee89800bee7c6c755778795a536e0e2f12b85ff (patch) | |
tree | 383d40f410fe859f218456e8aa006dd090fadc0b /core/jni/android_net_wifi_Wifi.cpp | |
parent | e59c69dc3b1f2fa206aa22698c4aa31498438a5e (diff) | |
download | frameworks_base-5ee89800bee7c6c755778795a536e0e2f12b85ff.zip frameworks_base-5ee89800bee7c6c755778795a536e0e2f12b85ff.tar.gz frameworks_base-5ee89800bee7c6c755778795a536e0e2f12b85ff.tar.bz2 |
Add Wifi Protected Setup support
Add WPS PBC and WPS pin method support with pin obtained
from AP
Bug: 2277571
Change-Id: I6ff8e447ab8c5e59456a55152588fd4d6386c610
Diffstat (limited to 'core/jni/android_net_wifi_Wifi.cpp')
-rw-r--r-- | core/jni/android_net_wifi_Wifi.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp index c5ccc43..defd0a0 100644 --- a/core/jni/android_net_wifi_Wifi.cpp +++ b/core/jni/android_net_wifi_Wifi.cpp @@ -30,6 +30,8 @@ namespace android { static jboolean sScanModeActive = false; +//TODO: check general errors in addition to overflow on snprintf + /* * The following remembers the jfieldID's of the fields * of the DhcpInfo Java object, so that we don't have @@ -155,6 +157,36 @@ static jint android_net_wifi_addNetworkCommand(JNIEnv* env, jobject clazz) return doIntCommand("ADD_NETWORK"); } +static jboolean android_net_wifi_wpsPbcCommand(JNIEnv* env, jobject clazz, jstring bssid) +{ + char cmdstr[50]; + jboolean isCopy; + + const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy); + int numWritten = snprintf(cmdstr, sizeof(cmdstr), "WPS_PBC %s", bssidStr); + env->ReleaseStringUTFChars(bssid, bssidStr); + + if ((numWritten == -1) || (numWritten >= sizeof(cmdstr))) { + return false; + } + return doBooleanCommand(cmdstr, "OK"); +} + +static jboolean android_net_wifi_wpsPinCommand(JNIEnv* env, jobject clazz, jstring bssid, int apPin) +{ + char cmdstr[50]; + jboolean isCopy; + + const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy); + int numWritten = snprintf(cmdstr, sizeof(cmdstr), "WPS_REG %s %d", bssidStr, apPin); + env->ReleaseStringUTFChars(bssid, bssidStr); + + if ((numWritten == -1) || (numWritten >= (int)sizeof(cmdstr))) { + return false; + } + return doBooleanCommand(cmdstr, "OK"); +} + static jboolean android_net_wifi_setNetworkVariableCommand(JNIEnv* env, jobject clazz, jint netId, @@ -603,7 +635,8 @@ static JNINativeMethod gWifiMethods[] = { { "setScanResultHandlingCommand", "(I)Z", (void*) android_net_wifi_setScanResultHandlingCommand }, { "addToBlacklistCommand", "(Ljava/lang/String;)Z", (void*) android_net_wifi_addToBlacklistCommand }, { "clearBlacklistCommand", "()Z", (void*) android_net_wifi_clearBlacklistCommand }, - + { "startWpsPbcCommand", "(Ljava/lang/String;)Z", (void*) android_net_wifi_wpsPbcCommand }, + { "startWpsPinCommand", "(Ljava/lang/String;I)Z", (void*) android_net_wifi_wpsPinCommand }, { "doDhcpRequest", "(Landroid/net/DhcpInfo;)Z", (void*) android_net_wifi_doDhcpRequest }, { "getDhcpError", "()Ljava/lang/String;", (void*) android_net_wifi_getDhcpError }, }; |