summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2016-06-07 18:30:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-06-07 18:30:56 +0000
commit4b15a0f9d5b92cd1ebd169ca74089b2acad541ce (patch)
tree3fa87c1ffb79f35d5c242661df43704317abb1b8 /service
parent42ab3717158a00b6a9c6d8b222a38544eea4feb9 (diff)
parentb42a86825e82d806743af1441c073ab016cf18da (diff)
Merge "resolve merge conflicts of da56856 to master"
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/FrameworkFacade.java4
-rw-r--r--service/java/com/android/server/wifi/WifiCountryCode.java27
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java20
3 files changed, 36 insertions, 15 deletions
diff --git a/service/java/com/android/server/wifi/FrameworkFacade.java b/service/java/com/android/server/wifi/FrameworkFacade.java
index 616511446..7805d7088 100644
--- a/service/java/com/android/server/wifi/FrameworkFacade.java
+++ b/service/java/com/android/server/wifi/FrameworkFacade.java
@@ -65,6 +65,10 @@ public class FrameworkFacade {
return Settings.Global.getLong(context.getContentResolver(), name, def);
}
+ public boolean setStringSetting(Context context, String name, String def) {
+ return Settings.Global.putString(context.getContentResolver(), name, def);
+ }
+
public String getStringSetting(Context context, String name) {
return Settings.Global.getString(context.getContentResolver(), name);
}
diff --git a/service/java/com/android/server/wifi/WifiCountryCode.java b/service/java/com/android/server/wifi/WifiCountryCode.java
index b603d904a..bd9b14b4b 100644
--- a/service/java/com/android/server/wifi/WifiCountryCode.java
+++ b/service/java/com/android/server/wifi/WifiCountryCode.java
@@ -36,14 +36,19 @@ public class WifiCountryCode {
private String mTelephonyCountryCode = null;
private String mCurrentCountryCode = null;
- public WifiCountryCode(WifiNative wifiNative, String defaultCountryCode,
+ public WifiCountryCode(
+ WifiNative wifiNative,
+ String oemDefaultCountryCode,
+ String persistentCountryCode,
boolean revertCountryCodeOnCellularLoss) {
+
mWifiNative = wifiNative;
mRevertCountryCodeOnCellularLoss = revertCountryCodeOnCellularLoss;
- if (!TextUtils.isEmpty(defaultCountryCode)) {
- mDefaultCountryCode = defaultCountryCode;
- mDefaultCountryCode = mDefaultCountryCode.toUpperCase();
+ if (!TextUtils.isEmpty(persistentCountryCode)) {
+ mDefaultCountryCode = persistentCountryCode.toUpperCase();
+ } else if (!TextUtils.isEmpty(oemDefaultCountryCode)) {
+ mDefaultCountryCode = oemDefaultCountryCode.toUpperCase();
} else {
if (mRevertCountryCodeOnCellularLoss) {
Log.w(TAG, "config_wifi_revert_country_code_on_cellular_loss is set, "
@@ -122,21 +127,25 @@ public class WifiCountryCode {
* @param countryCode The country code intended to set.
* This is supposed to be from Telephony service.
* otherwise we think it is from other applications.
+ * @return Returns true if the country code passed in is acceptable.
*/
- public synchronized void setCountryCode(String countryCode) {
+ public synchronized boolean setCountryCode(String countryCode, boolean persist) {
if (DBG) Log.d(TAG, "Receive set country code request: " + countryCode);
// Ignore empty country code.
- if (countryCode.length() == 0) {
+ if (TextUtils.isEmpty(countryCode)) {
if (DBG) Log.d(TAG, "Ignore empty country code");
- return;
+ return false;
+ }
+ if (persist) {
+ mDefaultCountryCode = countryCode;
}
- mTelephonyCountryCode = countryCode;
- mTelephonyCountryCode = mTelephonyCountryCode.toUpperCase();
+ mTelephonyCountryCode = countryCode.toUpperCase();
// If wpa_supplicant is ready we set the country code now, otherwise it will be
// set once wpa_supplicant is ready.
if (mReady) {
updateCountryCode();
}
+ return true;
}
/**
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 73553b75d..3f8c26985 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -128,6 +128,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
final WifiStateMachine mWifiStateMachine;
private final Context mContext;
+ private final FrameworkFacade mFacade;
private final List<Multicaster> mMulticasters =
new ArrayList<Multicaster>();
@@ -315,7 +316,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
public WifiServiceImpl(Context context) {
mContext = context;
mWifiInjector = WifiInjector.getInstance();
- FrameworkFacade facade = new FrameworkFacade();
+ mFacade = new FrameworkFacade();
HandlerThread wifiThread = new HandlerThread("WifiService");
wifiThread.start();
mWifiMetrics = mWifiInjector.getWifiMetrics();
@@ -324,11 +325,13 @@ public class WifiServiceImpl extends IWifiManager.Stub {
mUserManager = UserManager.get(mContext);
HandlerThread wifiStateMachineThread = new HandlerThread("WifiStateMachine");
wifiStateMachineThread.start();
- mCountryCode = new WifiCountryCode(WifiNative.getWlanNativeInterface(),
+ mCountryCode = new WifiCountryCode(
+ WifiNative.getWlanNativeInterface(),
SystemProperties.get(BOOT_DEFAULT_WIFI_COUNTRY_CODE),
+ mFacade.getStringSetting(mContext, Settings.Global.WIFI_COUNTRY_CODE),
mContext.getResources().getBoolean(
R.bool.config_wifi_revert_country_code_on_cellular_loss));
- mWifiStateMachine = new WifiStateMachine(mContext, facade,
+ mWifiStateMachine = new WifiStateMachine(mContext, mFacade,
wifiStateMachineThread.getLooper(), mUserManager, mWifiInjector,
new BackupManagerProxy(), mCountryCode);
mSettingsStore = new WifiSettingsStore(mContext);
@@ -339,13 +342,13 @@ public class WifiServiceImpl extends IWifiManager.Stub {
mCertManager = new WifiCertManager(mContext);
mNotificationController = new WifiNotificationController(mContext,
- wifiThread.getLooper(), mWifiStateMachine, facade, null);
+ wifiThread.getLooper(), mWifiStateMachine, mFacade, null);
mWifiLockManager = new WifiLockManager(mContext, mBatteryStats);
mClientHandler = new ClientHandler(wifiThread.getLooper());
mWifiStateMachineHandler = new WifiStateMachineHandler(wifiThread.getLooper());
mWifiController = new WifiController(mContext, mWifiStateMachine,
- mSettingsStore, mWifiLockManager, wifiThread.getLooper(), facade);
+ mSettingsStore, mWifiLockManager, wifiThread.getLooper(), mFacade);
// Set the WifiController for WifiLastResortWatchdog
mWifiInjector.getWifiLastResortWatchdog().setWifiController(mWifiController);
mWifiBackupRestore = new WifiBackupRestore();
@@ -1141,7 +1144,12 @@ public class WifiServiceImpl extends IWifiManager.Stub {
enforceConnectivityInternalPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCountryCode.setCountryCode(countryCode);
+ if (mCountryCode.setCountryCode(countryCode, persist) && persist) {
+ // Save this country code to persistent storage
+ mFacade.setStringSetting(mContext,
+ Settings.Global.WIFI_COUNTRY_CODE,
+ countryCode);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}