Merge "WLAN: Reset power save mode to startup value after DHCP response."
This commit is contained in:
@@ -390,6 +390,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];
|
||||
@@ -538,6 +552,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",
|
||||
|
||||
@@ -106,6 +106,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();
|
||||
|
||||
@@ -1755,6 +1755,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
|
||||
@@ -1782,7 +1784,15 @@ public class WifiStateTracker extends NetworkStateTracker {
|
||||
}
|
||||
|
||||
synchronized (WifiStateTracker.this) {
|
||||
WifiNative.setPowerModeCommand(DRIVER_POWER_MODE_ACTIVE);
|
||||
powerMode = WifiNative.getPowerModeCommand();
|
||||
if (powerMode < 0) {
|
||||
// Handle the case where supplicant driver does not support
|
||||
// getPowerModeCommand.
|
||||
powerMode = DRIVER_POWER_MODE_AUTO;
|
||||
}
|
||||
if (powerMode != DRIVER_POWER_MODE_ACTIVE) {
|
||||
WifiNative.setPowerModeCommand(DRIVER_POWER_MODE_ACTIVE);
|
||||
}
|
||||
}
|
||||
synchronized (this) {
|
||||
// A new request is being made, so assume we will callback
|
||||
@@ -1798,7 +1808,9 @@ public class WifiStateTracker extends NetworkStateTracker {
|
||||
NetworkUtils.getDhcpError());
|
||||
}
|
||||
synchronized (WifiStateTracker.this) {
|
||||
WifiNative.setPowerModeCommand(DRIVER_POWER_MODE_AUTO);
|
||||
if (powerMode != DRIVER_POWER_MODE_ACTIVE) {
|
||||
WifiNative.setPowerModeCommand(powerMode);
|
||||
}
|
||||
}
|
||||
|
||||
if (modifiedBluetoothCoexistenceMode) {
|
||||
|
||||
Reference in New Issue
Block a user