Allow configurable data warning for BillingCyclerPreference
Bug: 30898071
Change-Id: Ifb822828c5e7152e4ca217593f7746bfbb29ab2a
diff --git a/packages/SettingsLib/res/values/config.xml b/packages/SettingsLib/res/values/config.xml
index 299a5b7..d9473fa 100755
--- a/packages/SettingsLib/res/values/config.xml
+++ b/packages/SettingsLib/res/values/config.xml
@@ -19,4 +19,7 @@
<resources>
<!-- Configuration for automotive -->
<bool name="enable_pbap_pce_profile">false</bool>
+
+ <!-- Default data warning level in mb -->
+ <integer name="default_data_warning_level_mb">2048</integer>
</resources>
diff --git a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java
index e53dd2f..994ea88 100644
--- a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java
+++ b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageController.java
@@ -32,6 +32,8 @@
import android.text.format.Time;
import android.util.Log;
+import com.android.settingslib.R;
+
import java.util.Date;
import java.util.Locale;
@@ -41,12 +43,12 @@
import static android.telephony.TelephonyManager.SIM_STATE_READY;
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
+import static android.net.TrafficStats.MB_IN_BYTES;
public class DataUsageController {
+
private static final String TAG = "DataUsageController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-
- public static final long DEFAULT_WARNING_LEVEL = 2L * 1024 * 1024 * 1024;
private static final int FIELDS = FIELD_RX_BYTES | FIELD_TX_BYTES;
private static final StringBuilder PERIOD_BUILDER = new StringBuilder(50);
private static final java.util.Formatter PERIOD_FORMATTER = new java.util.Formatter(
@@ -75,6 +77,14 @@
mNetworkController = networkController;
}
+ /**
+ * Returns the default warning level in bytes.
+ */
+ public long getDefaultWarningLevel() {
+ return MB_IN_BYTES
+ * mContext.getResources().getInteger(R.integer.default_data_warning_level_mb);
+ }
+
private INetworkStatsSession getSession() {
if (mSession == null) {
try {
@@ -169,7 +179,7 @@
usage.limitLevel = policy.limitBytes > 0 ? policy.limitBytes : 0;
usage.warningLevel = policy.warningBytes > 0 ? policy.warningBytes : 0;
} else {
- usage.warningLevel = DEFAULT_WARNING_LEVEL;
+ usage.warningLevel = getDefaultWarningLevel();
}
if (usage != null && mNetworkController != null) {
usage.carrier = mNetworkController.getMobileDataNetworkName();