am ba85b970: Merge "Set country code on P2p interfaces as well" into klp-dev
* commit 'ba85b970f3ae7fd58c9a631e64bff0d05b787b9b': Set country code on P2p interfaces as well
This commit is contained in:
@@ -25,6 +25,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native calls for bring up/shut down of the supplicant daemon and for
|
* Native calls for bring up/shut down of the supplicant daemon and for
|
||||||
@@ -457,7 +458,7 @@ public class WifiNative {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean setCountryCode(String countryCode) {
|
public boolean setCountryCode(String countryCode) {
|
||||||
return doBooleanCommand("DRIVER COUNTRY " + countryCode);
|
return doBooleanCommand("DRIVER COUNTRY " + countryCode.toUpperCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableBackgroundScan(boolean enable) {
|
public void enableBackgroundScan(boolean enable) {
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ import java.net.InetAddress;
|
|||||||
import java.net.Inet6Address;
|
import java.net.Inet6Address;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -1431,6 +1430,7 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
countryCode);
|
countryCode);
|
||||||
}
|
}
|
||||||
sendMessage(CMD_SET_COUNTRY_CODE, countryCode);
|
sendMessage(CMD_SET_COUNTRY_CODE, countryCode);
|
||||||
|
mWifiP2pChannel.sendMessage(WifiP2pService.SET_COUNTRY_CODE, countryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2952,7 +2952,7 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
case CMD_SET_COUNTRY_CODE:
|
case CMD_SET_COUNTRY_CODE:
|
||||||
String country = (String) message.obj;
|
String country = (String) message.obj;
|
||||||
if (DBG) log("set country code " + country);
|
if (DBG) log("set country code " + country);
|
||||||
if (!mWifiNative.setCountryCode(country.toUpperCase(Locale.ROOT))) {
|
if (!mWifiNative.setCountryCode(country)) {
|
||||||
loge("Failed to set country code " + country);
|
loge("Failed to set country code " + country);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -4256,7 +4256,7 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
/**
|
/**
|
||||||
* arg2 on the source message has a unique id that needs to be retained in replies
|
* arg2 on the source message has a unique id that needs to be retained in replies
|
||||||
* to match the request
|
* to match the request
|
||||||
*
|
|
||||||
* see WifiManager for details
|
* see WifiManager for details
|
||||||
*/
|
*/
|
||||||
private Message obtainMessageWithArg2(Message srcMsg) {
|
private Message obtainMessageWithArg2(Message srcMsg) {
|
||||||
|
|||||||
@@ -174,6 +174,9 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
// msg.obj = StateMachine to send to when blocked
|
// msg.obj = StateMachine to send to when blocked
|
||||||
public static final int BLOCK_DISCOVERY = BASE + 15;
|
public static final int BLOCK_DISCOVERY = BASE + 15;
|
||||||
|
|
||||||
|
// set country code
|
||||||
|
public static final int SET_COUNTRY_CODE = BASE + 16;
|
||||||
|
|
||||||
public static final int ENABLED = 1;
|
public static final int ENABLED = 1;
|
||||||
public static final int DISABLED = 0;
|
public static final int DISABLED = 0;
|
||||||
|
|
||||||
@@ -632,6 +635,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
case WifiP2pManager.START_LISTEN:
|
case WifiP2pManager.START_LISTEN:
|
||||||
case WifiP2pManager.STOP_LISTEN:
|
case WifiP2pManager.STOP_LISTEN:
|
||||||
case WifiP2pManager.SET_CHANNEL:
|
case WifiP2pManager.SET_CHANNEL:
|
||||||
|
case SET_COUNTRY_CODE:
|
||||||
break;
|
break;
|
||||||
case WifiStateMachine.CMD_ENABLE_P2P:
|
case WifiStateMachine.CMD_ENABLE_P2P:
|
||||||
// Enable is lazy and has no response
|
// Enable is lazy and has no response
|
||||||
@@ -1064,6 +1068,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
replyToMessage(message, WifiP2pManager.SET_CHANNEL_FAILED);
|
replyToMessage(message, WifiP2pManager.SET_CHANNEL_FAILED);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SET_COUNTRY_CODE:
|
||||||
|
String countryCode = (String) message.obj;
|
||||||
|
mWifiNative.setCountryCode(countryCode);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return NOT_HANDLED;
|
return NOT_HANDLED;
|
||||||
}
|
}
|
||||||
@@ -2537,6 +2545,12 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
|||||||
mServiceTransactionId = 0;
|
mServiceTransactionId = 0;
|
||||||
mServiceDiscReqId = null;
|
mServiceDiscReqId = null;
|
||||||
|
|
||||||
|
String countryCode = Settings.Global.getString(mContext.getContentResolver(),
|
||||||
|
Settings.Global.WIFI_COUNTRY_CODE);
|
||||||
|
if (countryCode != null && !countryCode.isEmpty()) {
|
||||||
|
mP2pStateMachine.sendMessage(SET_COUNTRY_CODE, countryCode);
|
||||||
|
}
|
||||||
|
|
||||||
updatePersistentNetworks(RELOAD);
|
updatePersistentNetworks(RELOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user