diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2011-08-31 11:17:47 -0700 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2011-08-31 16:45:39 -0700 |
commit | 8af88fb8387259e51615709b2d1ea0260f7057fd (patch) | |
tree | e5ae0ac9f9696e68d38d02fdf205603fd858a150 /src | |
parent | ca6d987a87698cda7ca216adb8e827b30111f984 (diff) | |
download | packages_apps_Settings-8af88fb8387259e51615709b2d1ea0260f7057fd.tar.gz packages_apps_Settings-8af88fb8387259e51615709b2d1ea0260f7057fd.tar.bz2 packages_apps_Settings-8af88fb8387259e51615709b2d1ea0260f7057fd.zip |
Use the new isNetworkSupported api for wifi-only
Didn't have an API for this before so people used a hacked system property (ro.carrier)
to determine if the device supported mobile data. Added new API and switching callsites.
bug:5087537
Change-Id: Ibd799559be102a9e2fd552d1a23d1afbcf8f4614
Diffstat (limited to 'src')
9 files changed, 14 insertions, 12 deletions
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java index 3935d59a6..1d8e341eb 100644 --- a/src/com/android/settings/DateTimeSettings.java +++ b/src/com/android/settings/DateTimeSettings.java @@ -94,7 +94,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment mAutoTimeZonePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME_ZONE); // Override auto-timezone if it's a wifi-only device or if we're still in setup wizard. // TODO: Remove the wifiOnly test when auto-timezone is implemented based on wifi-location. - if (Utils.isWifiOnly() || isFirstRun) { + if (Utils.isWifiOnly(getActivity()) || isFirstRun) { getPreferenceScreen().removePreference(mAutoTimeZonePref); autoTimeZoneEnabled = false; } diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 76f5a8e7c..337233eeb 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -87,7 +87,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { PROPERTY_URL_SAFETYLEGAL); // Remove Baseband version if wifi-only device - if (Utils.isWifiOnly()) { + if (Utils.isWifiOnly(getActivity())) { getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION)); } diff --git a/src/com/android/settings/LocationSettings.java b/src/com/android/settings/LocationSettings.java index 0824aab0f..ef438e675 100644 --- a/src/com/android/settings/LocationSettings.java +++ b/src/com/android/settings/LocationSettings.java @@ -101,7 +101,7 @@ public class LocationSettings extends SettingsPreferenceFragment } // Change the summary for wifi-only devices - if (Utils.isWifiOnly()) { + if (Utils.isWifiOnly(getActivity())) { mNetwork.setSummaryOn(R.string.location_neighborhood_level_wifi); } diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 73a9a30b0..2d2b6548c 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -290,8 +290,10 @@ public class Utils { return telephony != null && telephony.isVoiceCapable(); } - public static boolean isWifiOnly() { - return "wifi-only".equals(SystemProperties.get("ro.carrier")); + public static boolean isWifiOnly(Context context) { + ConnectivityManager cm = (ConnectivityManager)context.getSystemService( + Context.CONNECTIVITY_SERVICE); + return (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false); } /** diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java index e1fc88225..b10b93fb1 100644 --- a/src/com/android/settings/WirelessSettings.java +++ b/src/com/android/settings/WirelessSettings.java @@ -129,7 +129,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { } // Remove Mobile Network Settings if it's a wifi-only device. - if (Utils.isWifiOnly()) { + if (Utils.isWifiOnly(getActivity())) { getPreferenceScreen().removePreference(findPreference(KEY_MOBILE_NETWORK_SETTINGS)); } diff --git a/src/com/android/settings/deviceinfo/Status.java b/src/com/android/settings/deviceinfo/Status.java index 987fab8dd..57a8e94b3 100644 --- a/src/com/android/settings/deviceinfo/Status.java +++ b/src/com/android/settings/deviceinfo/Status.java @@ -194,7 +194,7 @@ public class Status extends PreferenceActivity { mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH); mUptime = findPreference("up_time"); - if (Utils.isWifiOnly()) { + if (Utils.isWifiOnly(getApplicationContext())) { for (String key : PHONE_RELATED_ENTRIES) { removePreferenceFromScreen(key); } @@ -263,7 +263,7 @@ public class Status extends PreferenceActivity { protected void onResume() { super.onResume(); - if (!Utils.isWifiOnly()) { + if (!Utils.isWifiOnly(getApplicationContext())) { mPhoneStateReceiver.registerIntent(); updateSignalStrength(); @@ -281,7 +281,7 @@ public class Status extends PreferenceActivity { public void onPause() { super.onPause(); - if (!Utils.isWifiOnly()) { + if (!Utils.isWifiOnly(getApplicationContext())) { mPhoneStateReceiver.unregisterIntent(); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); } diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java index 13a962d25..a22988882 100644 --- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java +++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java @@ -378,7 +378,7 @@ public class BatteryHistoryChart extends View { mNumHist = lastInteresting; mHaveGps = (aggrStates&HistoryItem.STATE_GPS_ON_FLAG) != 0; mHaveWifi = (aggrStates&HistoryItem.STATE_WIFI_RUNNING_FLAG) != 0; - if (!com.android.settings.Utils.isWifiOnly()) { + if (!com.android.settings.Utils.isWifiOnly(getContext())) { mHavePhoneSignal = true; } if (mHistEnd <= mHistStart) mHistEnd = mHistStart+1; diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index f28ba9392..32ba2790d 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -713,7 +713,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable { addBluetoothUsage(uSecNow); addIdleUsage(uSecNow); // Not including cellular idle power // Don't compute radio usage if it's a wifi-only device - if (!com.android.settings.Utils.isWifiOnly()) { + if (!com.android.settings.Utils.isWifiOnly(getActivity())) { addRadioUsage(uSecNow); } } diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java index 7ec546b06..7fb987118 100644 --- a/src/com/android/settings/wifi/AdvancedWifiSettings.java +++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java @@ -97,7 +97,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY); if (sleepPolicyPref != null) { - if (Utils.isWifiOnly()) { + if (Utils.isWifiOnly(getActivity())) { sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only); sleepPolicyPref.setSummary(R.string.wifi_setting_sleep_policy_summary_wifi_only); } |