Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b74c617 authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge "Fix the arbitrary limit numbers and number overflow problem."

parents eec4b8ed f69aa8e6
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public class BillingCycleSettings extends DataUsageBase implements

    private static final String TAG = "BillingCycleSettings";
    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_CYCLE_EDITOR = "cycleEditor";
@@ -228,10 +229,13 @@ public class BillingCycleSettings extends DataUsageBase implements
            }
            final long bytes = (long) (Float.valueOf(bytesString)
                        * (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) {
                editor.setPolicyLimitBytes(template, bytes);
                editor.setPolicyLimitBytes(template, correctedBytes);
            } else {
                editor.setPolicyWarningBytes(template, bytes);
                editor.setPolicyWarningBytes(template, correctedBytes);
            }
            target.updatePrefs();
        }