diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2018-01-19 18:02:47 +0900 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2018-01-19 18:18:51 +0900 |
| commit | 2e4714575ff7aac65a0e107cbf2dd03fa3affe95 (patch) | |
| tree | 91f96552a4d5769dfe0208bf325db43e47762939 /core/java | |
| parent | 9252b34065809731ea2f6d3ffad91f678f809c93 (diff) | |
Alert user on rapid/heavy data usage.
Now that we have accurate information about a user's carrier data
plan, we can alert them if the current usage patterns would end up
with a nasty surprise towards the end of the current billing cycle.
For example, a single abusive app could use 90% of the user's budget
within the first few days of a billing cycle, leaving the user to
limp along for the remainder of the month.
The simple algorithm here extrapolates to see if the average usage
over the last 4 days would be more than 150% of the data limit for
the full billing cycle. This period is short enough to catch rapid
recent usage, but long enough to smooth over short-term habit
changes, such as a weekend getaway. This was chosen after
backtesting the proposed algorithm against real-world data usage
from a handful of internal users.
Fix NPMS unit tests, and write new ones, but leave the existing
@Ignored annotation intact for now.
Test: bit FrameworksServicesTests:com.android.server.NetworkPolicyManagerServiceTest
Bug: 64133169
Change-Id: I0d394b133257e8569a9aa2631b57638839d870ce
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/util/ArrayUtils.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/java/com/android/internal/util/ArrayUtils.java b/core/java/com/android/internal/util/ArrayUtils.java index 7b023f412cbc..621619c5134d 100644 --- a/core/java/com/android/internal/util/ArrayUtils.java +++ b/core/java/com/android/internal/util/ArrayUtils.java @@ -619,6 +619,10 @@ public class ArrayUtils { return size - leftIdx; } + public static @NonNull int[] defeatNullable(@Nullable int[] val) { + return (val != null) ? val : EmptyArray.INT; + } + public static @NonNull String[] defeatNullable(@Nullable String[] val) { return (val != null) ? val : EmptyArray.STRING; } |
