diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-09-02 15:39:16 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-09-02 15:39:16 -0700 |
commit | ee923072eb65cbf4f007458450e182a1289c2b7b (patch) | |
tree | 7be058cbc25a28f7595f88cd1acd5aab12269487 /core | |
parent | 572031747f5fd80109e9c574927ded06fcf23e6f (diff) | |
parent | 25c9bf2396ceb48fc5cfd5c1dd58aa4d4750d056 (diff) | |
download | frameworks_base-ee923072eb65cbf4f007458450e182a1289c2b7b.zip frameworks_base-ee923072eb65cbf4f007458450e182a1289c2b7b.tar.gz frameworks_base-ee923072eb65cbf4f007458450e182a1289c2b7b.tar.bz2 |
Merge "Add set/get band in WifiNative"
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/android_net_wifi_Wifi.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp index aec537d..c5ccc43 100644 --- a/core/jni/android_net_wifi_Wifi.cpp +++ b/core/jni/android_net_wifi_Wifi.cpp @@ -411,6 +411,30 @@ static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject clazz) return (jint)power; } +static jboolean android_net_wifi_setBandCommand(JNIEnv* env, jobject clazz, jint band) +{ + char cmdstr[25]; + + int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER SETBAND %d", band); + int cmdTooLong = numWritten >= (int)sizeof(cmdstr); + + return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK"); +} + +static jint android_net_wifi_getBandCommand(JNIEnv* env, jobject clazz) +{ + char reply[25]; + int band; + + if (doCommand("DRIVER GETBAND", reply, sizeof(reply)) != 0) { + return (jint)-1; + } + // reply comes back in the form "Band X" where X is the + // number we're interested in. + sscanf(reply, "%*s %u", &band); + return (jint)band; +} + static jboolean android_net_wifi_setNumAllowedChannelsCommand(JNIEnv* env, jobject clazz, jint numChannels) { char cmdstr[256]; @@ -561,6 +585,8 @@ static JNINativeMethod gWifiMethods[] = { { "stopPacketFiltering", "()Z", (void*) android_net_wifi_stopPacketFiltering }, { "setPowerModeCommand", "(I)Z", (void*) android_net_wifi_setPowerModeCommand }, { "getPowerModeCommand", "()I", (void*) android_net_wifi_getPowerModeCommand }, + { "setBandCommand", "(I)Z", (void*) android_net_wifi_setBandCommand}, + { "getBandCommand", "()I", (void*) android_net_wifi_getBandCommand}, { "setNumAllowedChannelsCommand", "(I)Z", (void*) android_net_wifi_setNumAllowedChannelsCommand }, { "getNumAllowedChannelsCommand", "()I", (void*) android_net_wifi_getNumAllowedChannelsCommand }, { "setBluetoothCoexistenceModeCommand", "(I)Z", |