Hide tab when disabled, metered strings, fixes.
Hide "Data usage" item when kernel support isn't available and enabled. Change "restrict background" strings to reflect metered status. Hide app settings button when no package found. Always start limit sweep above any warning. Imply metered state for networks with limits. Bug: 6303364, 5465643, 5379686, 6376276, 6368329, 6376276 Change-Id: I4faccc9a50f2f741fd937bb8c361a3ca055135e2
This commit is contained in:
@@ -3629,8 +3629,8 @@
|
|||||||
<string name="data_usage_menu_show_wifi">Show Wi-Fi usage</string>
|
<string name="data_usage_menu_show_wifi">Show Wi-Fi usage</string>
|
||||||
<!-- Title for checkbox menu option to show Ethernet data usage. [CHAR LIMIT=32] -->
|
<!-- Title for checkbox menu option to show Ethernet data usage. [CHAR LIMIT=32] -->
|
||||||
<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 expensive networks. [CHAR LIMIT=32] -->
|
<!-- Title for menu option to configure metered networks. [CHAR LIMIT=32] -->
|
||||||
<string name="data_usage_menu_metered">Expensive networks</string>
|
<string name="data_usage_menu_metered">Metered networks</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>
|
||||||
<!-- Body of dialog prompting user to change numerical day of month that data usage cycle should reset. [CHAR LIMIT=64] -->
|
<!-- Body of dialog prompting user to change numerical day of month that data usage cycle should reset. [CHAR LIMIT=64] -->
|
||||||
@@ -3684,13 +3684,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 mobile data network only. Wi-Fi will be used if available.</string>
|
<string name="data_usage_app_restrict_background_summary">Disable background data on metered networks. Unmetered 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 Wi-Fi isn\'t 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 metered 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>
|
||||||
|
|
||||||
@@ -3735,10 +3735,10 @@
|
|||||||
<!-- Label displaying total network data transferred during a specific time period, including a disclaimer that contrasts device versus carrier reporting. [CHAR LIMIT=80] -->
|
<!-- Label displaying total network data transferred during a specific time period, including a disclaimer that contrasts device versus carrier reporting. [CHAR LIMIT=80] -->
|
||||||
<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 paid networks. [CHAR LIMIT=25] -->
|
<!-- Dialog title for selecting metered networks. [CHAR LIMIT=25] -->
|
||||||
<string name="data_usage_metered_title">Expensive networks</string>
|
<string name="data_usage_metered_title">Metered networks</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 expensive. 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 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>
|
||||||
<!-- 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] -->
|
||||||
|
@@ -784,7 +784,7 @@ public class DataUsageSummary extends Fragment {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
mAppSettingsIntent = null;
|
mAppSettingsIntent = null;
|
||||||
mAppSettings.setEnabled(false);
|
mAppSettings.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDetailData();
|
updateDetailData();
|
||||||
@@ -1601,19 +1601,21 @@ public class DataUsageSummary extends Fragment {
|
|||||||
|
|
||||||
final Resources res = parent.getResources();
|
final Resources res = parent.getResources();
|
||||||
final CharSequence message;
|
final CharSequence message;
|
||||||
|
final long minLimitBytes = (long) (
|
||||||
|
parent.mPolicyEditor.getPolicy(parent.mTemplate).warningBytes * 1.2f);
|
||||||
final long limitBytes;
|
final long limitBytes;
|
||||||
|
|
||||||
// TODO: customize default limits based on network template
|
// TODO: customize default limits based on network template
|
||||||
final String currentTab = parent.mCurrentTab;
|
final String currentTab = parent.mCurrentTab;
|
||||||
if (TAB_3G.equals(currentTab)) {
|
if (TAB_3G.equals(currentTab)) {
|
||||||
message = res.getString(R.string.data_usage_limit_dialog_mobile);
|
message = res.getString(R.string.data_usage_limit_dialog_mobile);
|
||||||
limitBytes = 5 * GB_IN_BYTES;
|
limitBytes = Math.max(5 * GB_IN_BYTES, minLimitBytes);
|
||||||
} else if (TAB_4G.equals(currentTab)) {
|
} else if (TAB_4G.equals(currentTab)) {
|
||||||
message = res.getString(R.string.data_usage_limit_dialog_mobile);
|
message = res.getString(R.string.data_usage_limit_dialog_mobile);
|
||||||
limitBytes = 5 * GB_IN_BYTES;
|
limitBytes = Math.max(5 * GB_IN_BYTES, minLimitBytes);
|
||||||
} else if (TAB_MOBILE.equals(currentTab)) {
|
} else if (TAB_MOBILE.equals(currentTab)) {
|
||||||
message = res.getString(R.string.data_usage_limit_dialog_mobile);
|
message = res.getString(R.string.data_usage_limit_dialog_mobile);
|
||||||
limitBytes = 5 * GB_IN_BYTES;
|
limitBytes = Math.max(5 * GB_IN_BYTES, minLimitBytes);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("unknown current tab: " + currentTab);
|
throw new IllegalArgumentException("unknown current tab: " + currentTab);
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,9 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.INetworkManagementService;
|
||||||
|
import android.os.RemoteException;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.os.UserId;
|
import android.os.UserId;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
@@ -359,6 +362,17 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler {
|
|||||||
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
|
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
|
||||||
target.remove(header);
|
target.remove(header);
|
||||||
}
|
}
|
||||||
|
} else if (id == R.id.data_usage_settings) {
|
||||||
|
// Remove data usage when kernel module not enabled
|
||||||
|
final INetworkManagementService netManager = INetworkManagementService.Stub
|
||||||
|
.asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
|
||||||
|
try {
|
||||||
|
if (!netManager.isBandwidthControlEnabled()) {
|
||||||
|
target.remove(header);
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
} else if (id == R.id.user_settings) {
|
} else if (id == R.id.user_settings) {
|
||||||
if (!mEnableUserManagement
|
if (!mEnableUserManagement
|
||||||
|| !UserId.MU_ENABLED || UserId.myUserId() != 0
|
|| !UserId.MU_ENABLED || UserId.myUserId() != 0
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.net;
|
package com.android.settings.net;
|
||||||
|
|
||||||
|
import static android.net.NetworkPolicy.LIMIT_DISABLED;
|
||||||
import static android.net.wifi.WifiInfo.removeDoubleQuotes;
|
import static android.net.wifi.WifiInfo.removeDoubleQuotes;
|
||||||
import static com.android.settings.DataUsageSummary.hasReadyMobileRadio;
|
import static com.android.settings.DataUsageSummary.hasReadyMobileRadio;
|
||||||
import static com.android.settings.DataUsageSummary.hasWifiRadio;
|
import static com.android.settings.DataUsageSummary.hasWifiRadio;
|
||||||
@@ -106,19 +107,35 @@ public class DataUsageMeteredSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
private class MeteredPreference extends CheckBoxPreference {
|
private class MeteredPreference extends CheckBoxPreference {
|
||||||
private final NetworkTemplate mTemplate;
|
private final NetworkTemplate mTemplate;
|
||||||
|
private boolean mBinding;
|
||||||
|
|
||||||
public MeteredPreference(Context context, NetworkTemplate template) {
|
public MeteredPreference(Context context, NetworkTemplate template) {
|
||||||
super(context);
|
super(context);
|
||||||
mTemplate = template;
|
mTemplate = template;
|
||||||
|
|
||||||
setPersistent(false);
|
setPersistent(false);
|
||||||
setChecked(mPolicyEditor.getPolicyMetered(mTemplate));
|
|
||||||
|
mBinding = true;
|
||||||
|
final NetworkPolicy policy = mPolicyEditor.getPolicy(template);
|
||||||
|
if (policy != null) {
|
||||||
|
if (policy.limitBytes != LIMIT_DISABLED) {
|
||||||
|
setChecked(true);
|
||||||
|
setEnabled(false);
|
||||||
|
} else {
|
||||||
|
setChecked(policy.metered);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setChecked(false);
|
||||||
|
}
|
||||||
|
mBinding = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void notifyChanged() {
|
protected void notifyChanged() {
|
||||||
super.notifyChanged();
|
super.notifyChanged();
|
||||||
mPolicyEditor.setPolicyMetered(mTemplate, isChecked());
|
if (!mBinding) {
|
||||||
|
mPolicyEditor.setPolicyMetered(mTemplate, isChecked());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user