Remove / re-word some settings for WiFi-only devices.
Bug: 3468248
1. Remove Wireless->Mobile networks
2. Remove Wireless->Tethering and WiFi hotspot
3. Remove Wireless->Wi-Fi Settings->Wi-Fi disconnect policy
4. Re-word Network location summary text to not include "mobile network"
Change-Id: I84a551a1b63591974731029b0d4b90a85e43a716
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 5d031ef..dc4c42b 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -160,6 +160,11 @@
mUseLocation = useLocation;
}
+ // Change the summary for wifi-only devices
+ if (Utils.isWifiOnly()) {
+ mNetwork.setSummaryOn(R.string.location_neighborhood_level_wifi);
+ }
+
// Add options for lock/unlock screen
int resid = 0;
if (!mLockPatternUtils.isSecure()) {
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index d635403..dd80222 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -278,4 +278,8 @@
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return telephony != null && telephony.isVoiceCapable();
}
+
+ public static boolean isWifiOnly() {
+ return "wifi-only".equals(SystemProperties.get("ro.carrier"));
+ }
}
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index bdf8ce8..9567c01 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -48,6 +48,7 @@
private static final String KEY_VPN_SETTINGS = "vpn_settings";
private static final String KEY_TETHER_SETTINGS = "tether_settings";
private static final String KEY_PROXY_SETTINGS = "proxy_settings";
+ private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
public static final int REQUEST_CODE_EXIT_ECM = 1;
@@ -131,6 +132,11 @@
getPreferenceScreen().removePreference(nfc);
}
+ // Remove Mobile Network Settings if it's a wifi-only device.
+ if (Utils.isWifiOnly()) {
+ getPreferenceScreen().removePreference(findPreference(KEY_MOBILE_NETWORK_SETTINGS));
+ }
+
// Enable Proxy selector settings if allowed.
Preference mGlobalProxy = findPreference(KEY_PROXY_SETTINGS);
DevicePolicyManager mDPM = (DevicePolicyManager)
@@ -139,10 +145,10 @@
getPreferenceScreen().removePreference(mGlobalProxy);
mGlobalProxy.setEnabled(mDPM.getGlobalProxyAdmin() == null);
- // Disable Tethering if it's not allowed
+ // Disable Tethering if it's not allowed or if it's a wifi-only device
ConnectivityManager cm =
(ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (!cm.isTetheringSupported()) {
+ if (!cm.isTetheringSupported() || Utils.isWifiOnly()) {
getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
} else {
String[] usbRegexs = cm.getTetherableUsbRegexs();
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 1222e77..5a2bf45 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -21,6 +21,7 @@
import com.android.settings.ProgressCategoryBase;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
import android.app.Activity;
import android.app.AlertDialog;
@@ -211,11 +212,15 @@
ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
if (pref != null) {
- pref.setOnPreferenceChangeListener(this);
- int value = Settings.System.getInt(getContentResolver(),
- Settings.System.WIFI_SLEEP_POLICY,
- Settings.System.WIFI_SLEEP_POLICY_NEVER);
- pref.setValue(String.valueOf(value));
+ if (Utils.isWifiOnly()) {
+ getPreferenceScreen().removePreference(pref);
+ } else {
+ pref.setOnPreferenceChangeListener(this);
+ int value = Settings.System.getInt(getContentResolver(),
+ Settings.System.WIFI_SLEEP_POLICY,
+ Settings.System.WIFI_SLEEP_POLICY_NEVER);
+ pref.setValue(String.valueOf(value));
+ }
}
registerForContextMenu(getListView());