Fix the arbitrary limit numbers and number overflow problem.
Bug: 30560513 Change-Id: Ic36381cbf7e03d21e2ef8f9b7c76268386e5f40e
This commit is contained in:
@@ -48,6 +48,7 @@ public class BillingCycleSettings extends DataUsageBase implements
|
|||||||
|
|
||||||
private static final String TAG = "BillingCycleSettings";
|
private static final String TAG = "BillingCycleSettings";
|
||||||
private static final boolean LOGD = false;
|
private static final boolean LOGD = false;
|
||||||
|
private static final long MAX_DATA_LIMIT_BYTES = 50000 * GB_IN_BYTES;
|
||||||
|
|
||||||
private static final String TAG_CONFIRM_LIMIT = "confirmLimit";
|
private static final String TAG_CONFIRM_LIMIT = "confirmLimit";
|
||||||
private static final String TAG_CYCLE_EDITOR = "cycleEditor";
|
private static final String TAG_CYCLE_EDITOR = "cycleEditor";
|
||||||
@@ -228,10 +229,13 @@ public class BillingCycleSettings extends DataUsageBase implements
|
|||||||
}
|
}
|
||||||
final long bytes = (long) (Float.valueOf(bytesString)
|
final long bytes = (long) (Float.valueOf(bytesString)
|
||||||
* (spinner.getSelectedItemPosition() == 0 ? MB_IN_BYTES : GB_IN_BYTES));
|
* (spinner.getSelectedItemPosition() == 0 ? MB_IN_BYTES : GB_IN_BYTES));
|
||||||
|
|
||||||
|
// to fix the overflow problem
|
||||||
|
final long correctedBytes = Math.min(MAX_DATA_LIMIT_BYTES, bytes);
|
||||||
if (isLimit) {
|
if (isLimit) {
|
||||||
editor.setPolicyLimitBytes(template, bytes);
|
editor.setPolicyLimitBytes(template, correctedBytes);
|
||||||
} else {
|
} else {
|
||||||
editor.setPolicyWarningBytes(template, bytes);
|
editor.setPolicyWarningBytes(template, correctedBytes);
|
||||||
}
|
}
|
||||||
target.updatePrefs();
|
target.updatePrefs();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user