Merge "Allow configurable data warning for BillingCyclerPreference" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f1e87a2003
@@ -19,4 +19,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Configuration for automotive -->
|
<!-- Configuration for automotive -->
|
||||||
<bool name="enable_pbap_pce_profile">false</bool>
|
<bool name="enable_pbap_pce_profile">false</bool>
|
||||||
|
|
||||||
|
<!-- Default data warning level in mb -->
|
||||||
|
<integer name="default_data_warning_level_mb">2048</integer>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import android.text.format.DateUtils;
|
|||||||
import android.text.format.Time;
|
import android.text.format.Time;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.settingslib.R;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -41,12 +43,12 @@ import static android.net.NetworkStatsHistory.FIELD_TX_BYTES;
|
|||||||
import static android.telephony.TelephonyManager.SIM_STATE_READY;
|
import static android.telephony.TelephonyManager.SIM_STATE_READY;
|
||||||
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
|
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
|
||||||
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
|
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
|
||||||
|
import static android.net.TrafficStats.MB_IN_BYTES;
|
||||||
|
|
||||||
public class DataUsageController {
|
public class DataUsageController {
|
||||||
|
|
||||||
private static final String TAG = "DataUsageController";
|
private static final String TAG = "DataUsageController";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
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 int FIELDS = FIELD_RX_BYTES | FIELD_TX_BYTES;
|
||||||
private static final StringBuilder PERIOD_BUILDER = new StringBuilder(50);
|
private static final StringBuilder PERIOD_BUILDER = new StringBuilder(50);
|
||||||
private static final java.util.Formatter PERIOD_FORMATTER = new java.util.Formatter(
|
private static final java.util.Formatter PERIOD_FORMATTER = new java.util.Formatter(
|
||||||
@@ -75,6 +77,14 @@ public class DataUsageController {
|
|||||||
mNetworkController = networkController;
|
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() {
|
private INetworkStatsSession getSession() {
|
||||||
if (mSession == null) {
|
if (mSession == null) {
|
||||||
try {
|
try {
|
||||||
@@ -169,7 +179,7 @@ public class DataUsageController {
|
|||||||
usage.limitLevel = policy.limitBytes > 0 ? policy.limitBytes : 0;
|
usage.limitLevel = policy.limitBytes > 0 ? policy.limitBytes : 0;
|
||||||
usage.warningLevel = policy.warningBytes > 0 ? policy.warningBytes : 0;
|
usage.warningLevel = policy.warningBytes > 0 ? policy.warningBytes : 0;
|
||||||
} else {
|
} else {
|
||||||
usage.warningLevel = DEFAULT_WARNING_LEVEL;
|
usage.warningLevel = getDefaultWarningLevel();
|
||||||
}
|
}
|
||||||
if (usage != null && mNetworkController != null) {
|
if (usage != null && mNetworkController != null) {
|
||||||
usage.carrier = mNetworkController.getMobileDataNetworkName();
|
usage.carrier = mNetworkController.getMobileDataNetworkName();
|
||||||
|
|||||||
Reference in New Issue
Block a user