Surface metered networks as "Mobile hotspots."

String changes to give clearer definition of metered networks, and
remove metered control for mobile network.  Also fix NPE when testing
hasEthernet() before session is ready.

Bug: 6494976
Change-Id: Ia55ca3362a05977b9f21ab41eb10bbc738e29620
This commit is contained in:
Jeff Sharkey
2012-05-29 10:19:50 -07:00
parent a56e2362b1
commit d878909980
3 changed files with 20 additions and 15 deletions

View File

@@ -3749,7 +3749,7 @@
<!-- Title for checkbox menu option to show Ethernet data usage. [CHAR LIMIT=26] --> <!-- Title for checkbox menu option to show Ethernet data usage. [CHAR LIMIT=26] -->
<string name="data_usage_menu_show_ethernet">Show Ethernet usage</string> <string name="data_usage_menu_show_ethernet">Show Ethernet usage</string>
<!-- Title for menu option to configure metered networks. [CHAR LIMIT=26] --> <!-- Title for menu option to configure metered networks. [CHAR LIMIT=26] -->
<string name="data_usage_menu_metered">Metered networks</string> <string name="data_usage_menu_metered">Mobile hotspots</string>
<!-- Title for option to change data usage cycle day. [CHAR LIMIT=32] --> <!-- Title for option to change data usage cycle day. [CHAR LIMIT=32] -->
<string name="data_usage_change_cycle">Change cycle\u2026</string> <string name="data_usage_change_cycle">Change cycle\u2026</string>
@@ -3804,13 +3804,13 @@
<!-- Checkbox label that restricts background data usage of a specific application. [CHAR LIMIT=32] --> <!-- Checkbox label that restricts background data usage of a specific application. [CHAR LIMIT=32] -->
<string name="data_usage_app_restrict_background">Restrict background data</string> <string name="data_usage_app_restrict_background">Restrict background data</string>
<!-- Summary message for checkbox that restricts background data usage of a specific application. [CHAR LIMIT=64] --> <!-- Summary message for checkbox that restricts background data usage of a specific application. [CHAR LIMIT=64] -->
<string name="data_usage_app_restrict_background_summary">Disable background data on metered networks. Unmetered networks will be used if available.</string> <string name="data_usage_app_restrict_background_summary">Disable background data on mobile networks. Non-mobile networks will be used if available.</string>
<!-- Summary message for checkbox that restricts background data usage of a specific application when no networks have been limited. [CHAR LIMIT=64] --> <!-- Summary message for checkbox that restricts background data usage of a specific application when no networks have been limited. [CHAR LIMIT=64] -->
<string name="data_usage_app_restrict_background_summary_disabled">To restrict background data for this app, first set a mobile data limit.</string> <string name="data_usage_app_restrict_background_summary_disabled">To restrict background data for this app, first set a mobile data limit.</string>
<!-- Title of dialog shown when user restricts background data usage of a specific application. [CHAR LIMIT=48] --> <!-- Title of dialog shown when user restricts background data usage of a specific application. [CHAR LIMIT=48] -->
<string name="data_usage_app_restrict_dialog_title">Restrict background data?</string> <string name="data_usage_app_restrict_dialog_title">Restrict background data?</string>
<!-- Body of dialog shown when user restricts background data usage of a specific application. [CHAR LIMIT=NONE] --> <!-- Body of dialog shown when user restricts background data usage of a specific application. [CHAR LIMIT=NONE] -->
<string name="data_usage_app_restrict_dialog">This feature may cause an app that depends on background data to stop working when only metered networks are available.\n\nYou can find more appropriate data usage controls in the settings available within the app.</string> <string name="data_usage_app_restrict_dialog">This feature may cause an app that depends on background data to stop working when only mobile networks are available.\n\nYou can find more appropriate data usage controls in the settings available within the app.</string>
<!-- Body of dialog shown when user attempts to restrict background data before a network data limit has been set. [CHAR LIMIT=NONE] --> <!-- Body of dialog shown when user attempts to restrict background data before a network data limit has been set. [CHAR LIMIT=NONE] -->
<string name="data_usage_restrict_denied_dialog">Restricting background data is possible only when you\'ve set a mobile data limit.</string> <string name="data_usage_restrict_denied_dialog">Restricting background data is possible only when you\'ve set a mobile data limit.</string>
@@ -3856,15 +3856,15 @@
<string name="data_usage_total_during_range_mobile" product="default"><xliff:g id="range" example="Jul 1 - Jul 31">%2$s</xliff:g>: about <xliff:g id="total" example="128KB">%1$s</xliff:g> used, as measured by your phone. Your carrier\'s data usage accounting may differ.</string> <string name="data_usage_total_during_range_mobile" product="default"><xliff:g id="range" example="Jul 1 - Jul 31">%2$s</xliff:g>: about <xliff:g id="total" example="128KB">%1$s</xliff:g> used, as measured by your phone. Your carrier\'s data usage accounting may differ.</string>
<!-- Dialog title for selecting metered networks. [CHAR LIMIT=25] --> <!-- Dialog title for selecting metered networks. [CHAR LIMIT=25] -->
<string name="data_usage_metered_title">Metered networks</string> <string name="data_usage_metered_title">Mobile hotspots</string>
<!-- Dialog body for selecting paid networks. [CHAR LIMIT=NONE] --> <!-- Dialog body for selecting paid networks. [CHAR LIMIT=NONE] -->
<string name="data_usage_metered_body">Select the networks for which data usage is metered. Apps can be restricted from using these networks when in the background. Apps may also warn before using these networks for large downloads.</string> <string name="data_usage_metered_body">Select the Wi-Fi networks which are mobile hotspots. Apps can be restricted from using these networks when in the background. Apps may also warn before using these networks for large downloads.</string>
<!-- Header for list of mobile networks. [CHAR LIMIT=32] --> <!-- Header for list of mobile networks. [CHAR LIMIT=32] -->
<string name="data_usage_metered_mobile">Mobile networks</string> <string name="data_usage_metered_mobile">Mobile networks</string>
<!-- Header for list of Wi-Fi networks. [CHAR LIMIT=32] --> <!-- Header for list of Wi-Fi networks. [CHAR LIMIT=32] -->
<string name="data_usage_metered_wifi">Wi-Fi networks</string> <string name="data_usage_metered_wifi">Wi-Fi networks</string>
<!-- Body text prompting user to enable Wi-Fi to configure metered networks. [CHAR LIMIT=64] --> <!-- Body text prompting user to enable Wi-Fi to configure metered networks. [CHAR LIMIT=64] -->
<string name="data_usage_metered_wifi_disabled">To select metered Wi-Fi networks, turn Wi-Fi on.</string> <string name="data_usage_metered_wifi_disabled">To select mobile hotspots, turn Wi-Fi on.</string>
<!-- Button at the bottom of the CryptKeeper screen to make an emergency call. --> <!-- Button at the bottom of the CryptKeeper screen to make an emergency call. -->
<string name="cryptkeeper_emergency_call">Emergency call</string> <string name="cryptkeeper_emergency_call">Emergency call</string>

View File

@@ -104,7 +104,6 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener; import android.widget.AdapterView.OnItemSelectedListener;
@@ -2164,6 +2163,7 @@ public class DataUsageSummary extends Fragment {
final boolean hasEthernet = conn.isNetworkSupported(TYPE_ETHERNET); final boolean hasEthernet = conn.isNetworkSupported(TYPE_ETHERNET);
final long ethernetBytes; final long ethernetBytes;
if (mStatsSession != null) {
try { try {
ethernetBytes = mStatsSession.getSummaryForNetwork( ethernetBytes = mStatsSession.getSummaryForNetwork(
NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE) NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
@@ -2171,8 +2171,11 @@ public class DataUsageSummary extends Fragment {
} catch (RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else {
ethernetBytes = 0;
}
// suppress ethernet unless traffic has occurred // only show ethernet when both hardware present and traffic has occurred
return hasEthernet && ethernetBytes > 0; return hasEthernet && ethernetBytes > 0;
} }

View File

@@ -41,6 +41,8 @@ import com.android.settings.SettingsPreferenceFragment;
*/ */
public class DataUsageMeteredSettings extends SettingsPreferenceFragment { public class DataUsageMeteredSettings extends SettingsPreferenceFragment {
private static final boolean SHOW_MOBILE_CATEGORY = false;
private NetworkPolicyManager mPolicyManager; private NetworkPolicyManager mPolicyManager;
private WifiManager mWifiManager; private WifiManager mWifiManager;
@@ -70,7 +72,7 @@ public class DataUsageMeteredSettings extends SettingsPreferenceFragment {
} }
private void updateNetworks(Context context) { private void updateNetworks(Context context) {
if (hasReadyMobileRadio(context)) { if (SHOW_MOBILE_CATEGORY && hasReadyMobileRadio(context)) {
mMobileCategory.removeAll(); mMobileCategory.removeAll();
mMobileCategory.addPreference(buildMobilePref(context)); mMobileCategory.addPreference(buildMobilePref(context));
} else { } else {