From cbdcca6cf6326af64b13832b797cf28250e0a417 Mon Sep 17 00:00:00 2001 From: xinhe Date: Mon, 13 Jul 2015 15:26:45 -0700 Subject: [PATCH] Need to disable 5GHz bands for WiFi tethering in Japan b/22396383 Change-Id: I99090f28eff1b232ebba89ff638e37be82a3f21b --- res/values/strings.xml | 2 ++ .../android/settings/wifi/WifiApEnabler.java | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index d90f6e92d1d..ea0d34a8c6b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1380,6 +1380,8 @@ Turning off Wi\u2011Fi\u2026 Error + + 5 GHz band not available in this country In Airplane mode diff --git a/src/com/android/settings/wifi/WifiApEnabler.java b/src/com/android/settings/wifi/WifiApEnabler.java index bf2fa38ef4f..741c4a7e2c3 100644 --- a/src/com/android/settings/wifi/WifiApEnabler.java +++ b/src/com/android/settings/wifi/WifiApEnabler.java @@ -47,8 +47,15 @@ public class WifiApEnabler { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (WifiManager.WIFI_AP_STATE_CHANGED_ACTION.equals(action)) { - handleWifiApStateChanged(intent.getIntExtra( - WifiManager.EXTRA_WIFI_AP_STATE, WifiManager.WIFI_AP_STATE_FAILED)); + int state = intent.getIntExtra( + WifiManager.EXTRA_WIFI_AP_STATE, WifiManager.WIFI_AP_STATE_FAILED); + if (state == WifiManager.WIFI_AP_STATE_FAILED) { + int reason = intent.getIntExtra(WifiManager.EXTRA_WIFI_AP_FAILURE_REASON, + WifiManager.SAP_START_FAILURE_GENERAL); + handleWifiApStateChanged(state, reason); + } else { + handleWifiApStateChanged(state, WifiManager.SAP_START_FAILURE_GENERAL); + } } else if (ConnectivityManager.ACTION_TETHER_STATE_CHANGED.equals(action)) { ArrayList available = intent.getStringArrayListExtra( ConnectivityManager.EXTRA_AVAILABLE_TETHER); @@ -142,7 +149,7 @@ public class WifiApEnabler { } } - private void handleWifiApStateChanged(int state) { + private void handleWifiApStateChanged(int state, int reason) { switch (state) { case WifiManager.WIFI_AP_STATE_ENABLING: mSwitch.setSummary(R.string.wifi_tether_starting); @@ -169,7 +176,11 @@ public class WifiApEnabler { break; default: mSwitch.setChecked(false); - mSwitch.setSummary(R.string.wifi_error); + if (reason == WifiManager.SAP_START_FAILURE_NO_CHANNEL) { + mSwitch.setSummary(R.string.wifi_sap_no_channel_error); + } else { + mSwitch.setSummary(R.string.wifi_error); + } enableWifiSwitch(); } }