summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/settings/widget/SettingsAppWidgetProvider.java9
-rw-r--r--src/com/android/settings/wifi/WifiApEnabler.java9
-rw-r--r--src/com/android/settings/wifi/WifiEnabler.java8
3 files changed, 26 insertions, 0 deletions
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
index 2fd618c..872d303 100644
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
@@ -248,6 +248,15 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
if (withToast) {
Toast.makeText(context, R.string.gadget_toggle_wifi, Toast.LENGTH_SHORT).show();
}
+ /**
+ * Disable tethering if enabling Wifi
+ */
+ int wifiApState = wifiManager.getWifiApState();
+ if (desiredState && ((wifiApState == WifiManager.WIFI_AP_STATE_ENABLING) ||
+ (wifiApState == WifiManager.WIFI_AP_STATE_ENABLED))) {
+ wifiManager.setWifiApEnabled(null, false);
+ }
+
wifiManager.setWifiEnabled(desiredState);
}
diff --git a/src/com/android/settings/wifi/WifiApEnabler.java b/src/com/android/settings/wifi/WifiApEnabler.java
index 3d8d282..c2f8395 100644
--- a/src/com/android/settings/wifi/WifiApEnabler.java
+++ b/src/com/android/settings/wifi/WifiApEnabler.java
@@ -97,6 +97,15 @@ public class WifiApEnabler implements Preference.OnPreferenceChangeListener {
public boolean onPreferenceChange(Preference preference, Object enable) {
+ /**
+ * Disable Wifi if enabling tethering
+ */
+ int wifiState = mWifiManager.getWifiState();
+ if ((Boolean)enable && ((wifiState == WifiManager.WIFI_STATE_ENABLING) ||
+ (wifiState == WifiManager.WIFI_STATE_ENABLED))) {
+ mWifiManager.setWifiEnabled(false);
+ }
+
if (mWifiManager.setWifiApEnabled(null, (Boolean)enable)) {
/* Disable here, enabled on receiving success broadcast */
mCheckBox.setEnabled(false);
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index 6c55136..ef9f346 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -92,6 +92,14 @@ public class WifiEnabler implements Preference.OnPreferenceChangeListener {
return false;
}
+ /**
+ * Disable tethering if enabling Wifi
+ */
+ int wifiApState = mWifiManager.getWifiApState();
+ if (enable && ((wifiApState == WifiManager.WIFI_AP_STATE_ENABLING) ||
+ (wifiApState == WifiManager.WIFI_AP_STATE_ENABLED))) {
+ mWifiManager.setWifiApEnabled(null, false);
+ }
if (mWifiManager.setWifiEnabled(enable)) {
mCheckBox.setEnabled(false);
} else {