Loading core/jni/android_net_wifi_Wifi.cpp +0 −28 Original line number Original line Diff line number Diff line Loading @@ -402,30 +402,6 @@ static jint android_net_wifi_getRssiHelper(const char *cmd) return (jint)rssi; return (jint)rssi; } } static jint android_net_wifi_getRssiCommand(JNIEnv* env, jobject) { return android_net_wifi_getRssiHelper("DRIVER RSSI"); } static jint android_net_wifi_getRssiApproxCommand(JNIEnv* env, jobject) { return android_net_wifi_getRssiHelper("DRIVER RSSI-APPROX"); } static jint android_net_wifi_getLinkSpeedCommand(JNIEnv* env, jobject) { char reply[BUF_SIZE]; int linkspeed; if (doCommand("DRIVER LINKSPEED", reply, sizeof(reply)) != 0) { return (jint)-1; } // reply comes back in the form "LinkSpeed XX" where XX is the // number we're interested in. sscanf(reply, "%*s %u", &linkspeed); return (jint)linkspeed; } static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject) static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject) { { char reply[BUF_SIZE]; char reply[BUF_SIZE]; Loading Loading @@ -625,10 +601,6 @@ static JNINativeMethod gWifiMethods[] = { (void*) android_net_wifi_setBluetoothCoexistenceModeCommand }, (void*) android_net_wifi_setBluetoothCoexistenceModeCommand }, { "setBluetoothCoexistenceScanModeCommand", "(Z)Z", { "setBluetoothCoexistenceScanModeCommand", "(Z)Z", (void*) android_net_wifi_setBluetoothCoexistenceScanModeCommand }, (void*) android_net_wifi_setBluetoothCoexistenceScanModeCommand }, { "getRssiCommand", "()I", (void*) android_net_wifi_getRssiCommand }, { "getRssiApproxCommand", "()I", (void*) android_net_wifi_getRssiApproxCommand}, { "getLinkSpeedCommand", "()I", (void*) android_net_wifi_getLinkSpeedCommand }, { "getMacAddressCommand", "()Ljava/lang/String;", (void*) android_net_wifi_getMacAddressCommand }, { "getMacAddressCommand", "()Ljava/lang/String;", (void*) android_net_wifi_getMacAddressCommand }, { "saveConfigCommand", "()Z", (void*) android_net_wifi_saveConfigCommand }, { "saveConfigCommand", "()Z", (void*) android_net_wifi_saveConfigCommand }, { "reloadConfigCommand", "()Z", (void*) android_net_wifi_reloadConfigCommand }, { "reloadConfigCommand", "()Z", (void*) android_net_wifi_reloadConfigCommand }, Loading wifi/java/android/net/wifi/WifiNative.java +10 −6 Original line number Original line Diff line number Diff line Loading @@ -106,12 +106,6 @@ public class WifiNative { public native static String statusCommand(); public native static String statusCommand(); public native static int getRssiCommand(); public native static int getRssiApproxCommand(); public native static int getLinkSpeedCommand(); public native static String getMacAddressCommand(); public native static String getMacAddressCommand(); public native static String scanResultsCommand(); public native static String scanResultsCommand(); Loading Loading @@ -209,6 +203,16 @@ public class WifiNative { private native static String doStringCommand(String command); private native static String doStringCommand(String command); /** Example output: * RSSI=-65 * LINKSPEED=48 * NOISE=9999 * FREQUENCY=0 */ public static String signalPoll() { return doStringCommand("SIGNAL_POLL"); } public static boolean wpsPbc() { public static boolean wpsPbc() { return doBooleanCommand("WPS_PBC"); return doBooleanCommand("WPS_PBC"); } } Loading wifi/java/android/net/wifi/WifiStateMachine.java +23 −2 Original line number Original line Diff line number Diff line Loading @@ -1362,7 +1362,28 @@ public class WifiStateMachine extends StateMachine { * Fetch RSSI and linkspeed on current connection * Fetch RSSI and linkspeed on current connection */ */ private void fetchRssiAndLinkSpeedNative() { private void fetchRssiAndLinkSpeedNative() { int newRssi = WifiNative.getRssiCommand(); int newRssi = -1; int newLinkSpeed = -1; String signalPoll = WifiNative.signalPoll(); if (signalPoll != null) { String[] lines = signalPoll.split("\n"); for (String line : lines) { String[] prop = line.split("="); if (prop.length < 2) continue; try { if (prop[0].equals("RSSI")) { newRssi = Integer.parseInt(prop[1]); } else if (prop[0].equals("LINKSPEED")) { newLinkSpeed = Integer.parseInt(prop[1]); } } catch (NumberFormatException e) { //Ignore, defaults on rssi and linkspeed are assigned } } } if (newRssi != -1 && MIN_RSSI < newRssi && newRssi < MAX_RSSI) { // screen out invalid values if (newRssi != -1 && MIN_RSSI < newRssi && newRssi < MAX_RSSI) { // screen out invalid values /* some implementations avoid negative values by adding 256 /* some implementations avoid negative values by adding 256 * so we need to adjust for that here. * so we need to adjust for that here. Loading Loading @@ -1390,7 +1411,7 @@ public class WifiStateMachine extends StateMachine { } else { } else { mWifiInfo.setRssi(MIN_RSSI); mWifiInfo.setRssi(MIN_RSSI); } } int newLinkSpeed = WifiNative.getLinkSpeedCommand(); if (newLinkSpeed != -1) { if (newLinkSpeed != -1) { mWifiInfo.setLinkSpeed(newLinkSpeed); mWifiInfo.setLinkSpeed(newLinkSpeed); } } Loading Loading
core/jni/android_net_wifi_Wifi.cpp +0 −28 Original line number Original line Diff line number Diff line Loading @@ -402,30 +402,6 @@ static jint android_net_wifi_getRssiHelper(const char *cmd) return (jint)rssi; return (jint)rssi; } } static jint android_net_wifi_getRssiCommand(JNIEnv* env, jobject) { return android_net_wifi_getRssiHelper("DRIVER RSSI"); } static jint android_net_wifi_getRssiApproxCommand(JNIEnv* env, jobject) { return android_net_wifi_getRssiHelper("DRIVER RSSI-APPROX"); } static jint android_net_wifi_getLinkSpeedCommand(JNIEnv* env, jobject) { char reply[BUF_SIZE]; int linkspeed; if (doCommand("DRIVER LINKSPEED", reply, sizeof(reply)) != 0) { return (jint)-1; } // reply comes back in the form "LinkSpeed XX" where XX is the // number we're interested in. sscanf(reply, "%*s %u", &linkspeed); return (jint)linkspeed; } static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject) static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject) { { char reply[BUF_SIZE]; char reply[BUF_SIZE]; Loading Loading @@ -625,10 +601,6 @@ static JNINativeMethod gWifiMethods[] = { (void*) android_net_wifi_setBluetoothCoexistenceModeCommand }, (void*) android_net_wifi_setBluetoothCoexistenceModeCommand }, { "setBluetoothCoexistenceScanModeCommand", "(Z)Z", { "setBluetoothCoexistenceScanModeCommand", "(Z)Z", (void*) android_net_wifi_setBluetoothCoexistenceScanModeCommand }, (void*) android_net_wifi_setBluetoothCoexistenceScanModeCommand }, { "getRssiCommand", "()I", (void*) android_net_wifi_getRssiCommand }, { "getRssiApproxCommand", "()I", (void*) android_net_wifi_getRssiApproxCommand}, { "getLinkSpeedCommand", "()I", (void*) android_net_wifi_getLinkSpeedCommand }, { "getMacAddressCommand", "()Ljava/lang/String;", (void*) android_net_wifi_getMacAddressCommand }, { "getMacAddressCommand", "()Ljava/lang/String;", (void*) android_net_wifi_getMacAddressCommand }, { "saveConfigCommand", "()Z", (void*) android_net_wifi_saveConfigCommand }, { "saveConfigCommand", "()Z", (void*) android_net_wifi_saveConfigCommand }, { "reloadConfigCommand", "()Z", (void*) android_net_wifi_reloadConfigCommand }, { "reloadConfigCommand", "()Z", (void*) android_net_wifi_reloadConfigCommand }, Loading
wifi/java/android/net/wifi/WifiNative.java +10 −6 Original line number Original line Diff line number Diff line Loading @@ -106,12 +106,6 @@ public class WifiNative { public native static String statusCommand(); public native static String statusCommand(); public native static int getRssiCommand(); public native static int getRssiApproxCommand(); public native static int getLinkSpeedCommand(); public native static String getMacAddressCommand(); public native static String getMacAddressCommand(); public native static String scanResultsCommand(); public native static String scanResultsCommand(); Loading Loading @@ -209,6 +203,16 @@ public class WifiNative { private native static String doStringCommand(String command); private native static String doStringCommand(String command); /** Example output: * RSSI=-65 * LINKSPEED=48 * NOISE=9999 * FREQUENCY=0 */ public static String signalPoll() { return doStringCommand("SIGNAL_POLL"); } public static boolean wpsPbc() { public static boolean wpsPbc() { return doBooleanCommand("WPS_PBC"); return doBooleanCommand("WPS_PBC"); } } Loading
wifi/java/android/net/wifi/WifiStateMachine.java +23 −2 Original line number Original line Diff line number Diff line Loading @@ -1362,7 +1362,28 @@ public class WifiStateMachine extends StateMachine { * Fetch RSSI and linkspeed on current connection * Fetch RSSI and linkspeed on current connection */ */ private void fetchRssiAndLinkSpeedNative() { private void fetchRssiAndLinkSpeedNative() { int newRssi = WifiNative.getRssiCommand(); int newRssi = -1; int newLinkSpeed = -1; String signalPoll = WifiNative.signalPoll(); if (signalPoll != null) { String[] lines = signalPoll.split("\n"); for (String line : lines) { String[] prop = line.split("="); if (prop.length < 2) continue; try { if (prop[0].equals("RSSI")) { newRssi = Integer.parseInt(prop[1]); } else if (prop[0].equals("LINKSPEED")) { newLinkSpeed = Integer.parseInt(prop[1]); } } catch (NumberFormatException e) { //Ignore, defaults on rssi and linkspeed are assigned } } } if (newRssi != -1 && MIN_RSSI < newRssi && newRssi < MAX_RSSI) { // screen out invalid values if (newRssi != -1 && MIN_RSSI < newRssi && newRssi < MAX_RSSI) { // screen out invalid values /* some implementations avoid negative values by adding 256 /* some implementations avoid negative values by adding 256 * so we need to adjust for that here. * so we need to adjust for that here. Loading Loading @@ -1390,7 +1411,7 @@ public class WifiStateMachine extends StateMachine { } else { } else { mWifiInfo.setRssi(MIN_RSSI); mWifiInfo.setRssi(MIN_RSSI); } } int newLinkSpeed = WifiNative.getLinkSpeedCommand(); if (newLinkSpeed != -1) { if (newLinkSpeed != -1) { mWifiInfo.setLinkSpeed(newLinkSpeed); mWifiInfo.setLinkSpeed(newLinkSpeed); } } Loading