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
This commit is contained in:
@@ -94,7 +94,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
|||||||
mAutoTimeZonePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME_ZONE);
|
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.
|
// 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.
|
// 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);
|
getPreferenceScreen().removePreference(mAutoTimeZonePref);
|
||||||
autoTimeZoneEnabled = false;
|
autoTimeZoneEnabled = false;
|
||||||
}
|
}
|
||||||
|
@@ -87,7 +87,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
|
|||||||
PROPERTY_URL_SAFETYLEGAL);
|
PROPERTY_URL_SAFETYLEGAL);
|
||||||
|
|
||||||
// Remove Baseband version if wifi-only device
|
// Remove Baseband version if wifi-only device
|
||||||
if (Utils.isWifiOnly()) {
|
if (Utils.isWifiOnly(getActivity())) {
|
||||||
getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION));
|
getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ public class LocationSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Change the summary for wifi-only devices
|
// Change the summary for wifi-only devices
|
||||||
if (Utils.isWifiOnly()) {
|
if (Utils.isWifiOnly(getActivity())) {
|
||||||
mNetwork.setSummaryOn(R.string.location_neighborhood_level_wifi);
|
mNetwork.setSummaryOn(R.string.location_neighborhood_level_wifi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -290,8 +290,10 @@ public class Utils {
|
|||||||
return telephony != null && telephony.isVoiceCapable();
|
return telephony != null && telephony.isVoiceCapable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWifiOnly() {
|
public static boolean isWifiOnly(Context context) {
|
||||||
return "wifi-only".equals(SystemProperties.get("ro.carrier"));
|
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(
|
||||||
|
Context.CONNECTIVITY_SERVICE);
|
||||||
|
return (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -129,7 +129,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove Mobile Network Settings if it's a wifi-only device.
|
// 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));
|
getPreferenceScreen().removePreference(findPreference(KEY_MOBILE_NETWORK_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -194,7 +194,7 @@ public class Status extends PreferenceActivity {
|
|||||||
mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
|
mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
|
||||||
mUptime = findPreference("up_time");
|
mUptime = findPreference("up_time");
|
||||||
|
|
||||||
if (Utils.isWifiOnly()) {
|
if (Utils.isWifiOnly(getApplicationContext())) {
|
||||||
for (String key : PHONE_RELATED_ENTRIES) {
|
for (String key : PHONE_RELATED_ENTRIES) {
|
||||||
removePreferenceFromScreen(key);
|
removePreferenceFromScreen(key);
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ public class Status extends PreferenceActivity {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (!Utils.isWifiOnly()) {
|
if (!Utils.isWifiOnly(getApplicationContext())) {
|
||||||
mPhoneStateReceiver.registerIntent();
|
mPhoneStateReceiver.registerIntent();
|
||||||
|
|
||||||
updateSignalStrength();
|
updateSignalStrength();
|
||||||
@@ -281,7 +281,7 @@ public class Status extends PreferenceActivity {
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (!Utils.isWifiOnly()) {
|
if (!Utils.isWifiOnly(getApplicationContext())) {
|
||||||
mPhoneStateReceiver.unregisterIntent();
|
mPhoneStateReceiver.unregisterIntent();
|
||||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
||||||
}
|
}
|
||||||
|
@@ -378,7 +378,7 @@ public class BatteryHistoryChart extends View {
|
|||||||
mNumHist = lastInteresting;
|
mNumHist = lastInteresting;
|
||||||
mHaveGps = (aggrStates&HistoryItem.STATE_GPS_ON_FLAG) != 0;
|
mHaveGps = (aggrStates&HistoryItem.STATE_GPS_ON_FLAG) != 0;
|
||||||
mHaveWifi = (aggrStates&HistoryItem.STATE_WIFI_RUNNING_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;
|
mHavePhoneSignal = true;
|
||||||
}
|
}
|
||||||
if (mHistEnd <= mHistStart) mHistEnd = mHistStart+1;
|
if (mHistEnd <= mHistStart) mHistEnd = mHistStart+1;
|
||||||
|
@@ -713,7 +713,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
|
|||||||
addBluetoothUsage(uSecNow);
|
addBluetoothUsage(uSecNow);
|
||||||
addIdleUsage(uSecNow); // Not including cellular idle power
|
addIdleUsage(uSecNow); // Not including cellular idle power
|
||||||
// Don't compute radio usage if it's a wifi-only device
|
// 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);
|
addRadioUsage(uSecNow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
||||||
if (sleepPolicyPref != null) {
|
if (sleepPolicyPref != null) {
|
||||||
if (Utils.isWifiOnly()) {
|
if (Utils.isWifiOnly(getActivity())) {
|
||||||
sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
|
sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
|
||||||
sleepPolicyPref.setSummary(R.string.wifi_setting_sleep_policy_summary_wifi_only);
|
sleepPolicyPref.setSummary(R.string.wifi_setting_sleep_policy_summary_wifi_only);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user