Loading core/jni/android_net_wifi_Wifi.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -392,6 +392,20 @@ static jboolean android_net_wifi_setPowerModeCommand(JNIEnv* env, jobject clazz, return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK"); } static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject clazz) { char reply[256]; int power; if (doCommand("DRIVER GETPOWER", reply, sizeof(reply)) != 0) { return (jint)-1; } // reply comes back in the form "powermode = XX" where XX is the // number we're interested in. sscanf(reply, "%*s = %u", &power); return (jint)power; } static jboolean android_net_wifi_setNumAllowedChannelsCommand(JNIEnv* env, jobject clazz, jint numChannels) { char cmdstr[256]; Loading Loading @@ -540,6 +554,7 @@ static JNINativeMethod gWifiMethods[] = { { "startPacketFiltering", "()Z", (void*) android_net_wifi_startPacketFiltering }, { "stopPacketFiltering", "()Z", (void*) android_net_wifi_stopPacketFiltering }, { "setPowerModeCommand", "(I)Z", (void*) android_net_wifi_setPowerModeCommand }, { "getPowerModeCommand", "()I", (void*) android_net_wifi_getPowerModeCommand }, { "setNumAllowedChannelsCommand", "(I)Z", (void*) android_net_wifi_setNumAllowedChannelsCommand }, { "getNumAllowedChannelsCommand", "()I", (void*) android_net_wifi_getNumAllowedChannelsCommand }, { "setBluetoothCoexistenceModeCommand", "(I)Z", Loading wifi/java/android/net/wifi/WifiNative.java +2 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ public class WifiNative { public native static boolean setPowerModeCommand(int mode); public native static int getPowerModeCommand(); public native static boolean setNumAllowedChannelsCommand(int numChannels); public native static int getNumAllowedChannelsCommand(); Loading wifi/java/android/net/wifi/WifiStateTracker.java +26 −3 Original line number Diff line number Diff line Loading @@ -1927,6 +1927,17 @@ public class WifiStateTracker extends NetworkStateTracker { return WifiNative.stopPacketFiltering(); } /** * Get power mode * @return power mode */ public synchronized int getPowerMode() { if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) { return -1; } return WifiNative.getPowerModeCommand(); } /** * Set power mode * @param mode Loading Loading @@ -2252,6 +2263,8 @@ public class WifiStateTracker extends NetworkStateTracker { case EVENT_DHCP_START: boolean modifiedBluetoothCoexistenceMode = false; int powerMode = DRIVER_POWER_MODE_AUTO; if (shouldDisableCoexistenceMode()) { /* * There are problems setting the Wi-Fi driver's power Loading @@ -2276,7 +2289,15 @@ public class WifiStateTracker extends NetworkStateTracker { WifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED); } powerMode = getPowerMode(); if (powerMode < 0) { // Handle the case where supplicant driver does not support // getPowerModeCommand. powerMode = DRIVER_POWER_MODE_AUTO; } if (powerMode != DRIVER_POWER_MODE_ACTIVE) { setPowerMode(DRIVER_POWER_MODE_ACTIVE); } synchronized (this) { // A new request is being made, so assume we will callback Loading @@ -2292,7 +2313,9 @@ public class WifiStateTracker extends NetworkStateTracker { NetworkUtils.getDhcpError()); } setPowerMode(DRIVER_POWER_MODE_AUTO); if (powerMode != DRIVER_POWER_MODE_ACTIVE) { setPowerMode(powerMode); } if (modifiedBluetoothCoexistenceMode) { // Set the coexistence mode back to its default value Loading Loading
core/jni/android_net_wifi_Wifi.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -392,6 +392,20 @@ static jboolean android_net_wifi_setPowerModeCommand(JNIEnv* env, jobject clazz, return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK"); } static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject clazz) { char reply[256]; int power; if (doCommand("DRIVER GETPOWER", reply, sizeof(reply)) != 0) { return (jint)-1; } // reply comes back in the form "powermode = XX" where XX is the // number we're interested in. sscanf(reply, "%*s = %u", &power); return (jint)power; } static jboolean android_net_wifi_setNumAllowedChannelsCommand(JNIEnv* env, jobject clazz, jint numChannels) { char cmdstr[256]; Loading Loading @@ -540,6 +554,7 @@ static JNINativeMethod gWifiMethods[] = { { "startPacketFiltering", "()Z", (void*) android_net_wifi_startPacketFiltering }, { "stopPacketFiltering", "()Z", (void*) android_net_wifi_stopPacketFiltering }, { "setPowerModeCommand", "(I)Z", (void*) android_net_wifi_setPowerModeCommand }, { "getPowerModeCommand", "()I", (void*) android_net_wifi_getPowerModeCommand }, { "setNumAllowedChannelsCommand", "(I)Z", (void*) android_net_wifi_setNumAllowedChannelsCommand }, { "getNumAllowedChannelsCommand", "()I", (void*) android_net_wifi_getNumAllowedChannelsCommand }, { "setBluetoothCoexistenceModeCommand", "(I)Z", Loading
wifi/java/android/net/wifi/WifiNative.java +2 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ public class WifiNative { public native static boolean setPowerModeCommand(int mode); public native static int getPowerModeCommand(); public native static boolean setNumAllowedChannelsCommand(int numChannels); public native static int getNumAllowedChannelsCommand(); Loading
wifi/java/android/net/wifi/WifiStateTracker.java +26 −3 Original line number Diff line number Diff line Loading @@ -1927,6 +1927,17 @@ public class WifiStateTracker extends NetworkStateTracker { return WifiNative.stopPacketFiltering(); } /** * Get power mode * @return power mode */ public synchronized int getPowerMode() { if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) { return -1; } return WifiNative.getPowerModeCommand(); } /** * Set power mode * @param mode Loading Loading @@ -2252,6 +2263,8 @@ public class WifiStateTracker extends NetworkStateTracker { case EVENT_DHCP_START: boolean modifiedBluetoothCoexistenceMode = false; int powerMode = DRIVER_POWER_MODE_AUTO; if (shouldDisableCoexistenceMode()) { /* * There are problems setting the Wi-Fi driver's power Loading @@ -2276,7 +2289,15 @@ public class WifiStateTracker extends NetworkStateTracker { WifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED); } powerMode = getPowerMode(); if (powerMode < 0) { // Handle the case where supplicant driver does not support // getPowerModeCommand. powerMode = DRIVER_POWER_MODE_AUTO; } if (powerMode != DRIVER_POWER_MODE_ACTIVE) { setPowerMode(DRIVER_POWER_MODE_ACTIVE); } synchronized (this) { // A new request is being made, so assume we will callback Loading @@ -2292,7 +2313,9 @@ public class WifiStateTracker extends NetworkStateTracker { NetworkUtils.getDhcpError()); } setPowerMode(DRIVER_POWER_MODE_AUTO); if (powerMode != DRIVER_POWER_MODE_ACTIVE) { setPowerMode(powerMode); } if (modifiedBluetoothCoexistenceMode) { // Set the coexistence mode back to its default value Loading