diff options
| author | 2017-07-07 21:34:32 +0000 | |
|---|---|---|
| committer | 2017-07-07 21:34:32 +0000 | |
| commit | 03f4ddb1b2c94903cb221c215e0f51da0973c537 (patch) | |
| tree | b63ea860cdf4f1536c11f2ca30a2a1edefe154f5 | |
| parent | bc4dc42887576226d185b155d362a77362739e5b (diff) | |
| parent | 1249e0a1b0dba25853a487c75627d3b9e9fe59e5 (diff) | |
Merge "Fix wrong array index bound in NotificationUsageStats" am: 87e893a449
am: 1249e0a1b0
Change-Id: I962bd3c6dee3d635c6f5b56f2141e8f785fa4cfb
| -rw-r--r-- | services/core/java/com/android/server/notification/NotificationUsageStats.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationUsageStats.java b/services/core/java/com/android/server/notification/NotificationUsageStats.java index e8cf6a195c90..365321c540b8 100644 --- a/services/core/java/com/android/server/notification/NotificationUsageStats.java +++ b/services/core/java/com/android/server/notification/NotificationUsageStats.java @@ -40,6 +40,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.PrintWriter; +import java.lang.Math; import java.util.ArrayDeque; import java.util.Calendar; import java.util.GregorianCalendar; @@ -718,8 +719,8 @@ public class NotificationUsageStats { } void increment(int imp) { - imp = imp < 0 ? 0 : imp > NUM_IMPORTANCES ? NUM_IMPORTANCES : imp; - mCount[imp] ++; + imp = Math.max(0, Math.min(imp, mCount.length - 1)); + mCount[imp]++; } void maybeCount(ImportanceHistogram prev) { |