From be9cbb12e93c521ff0ef256658422720f5c3f55e Mon Sep 17 00:00:00 2001 From: Ruchi Kandoi Date: Wed, 2 Jul 2014 17:47:40 -0700 Subject: BatteryStats: Adds an additional condition to avoid ArrayIndexOutOfBounds. This change takes care of the case when the length of the array is 0. Bug: 16039301 Change-Id: Ideb3ccc723c5d720069760aeedae8abb91c6420d --- core/java/com/android/internal/os/PowerProfile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/java/com/android/internal/os/PowerProfile.java b/core/java/com/android/internal/os/PowerProfile.java index 94750d3..efca0cb 100644 --- a/core/java/com/android/internal/os/PowerProfile.java +++ b/core/java/com/android/internal/os/PowerProfile.java @@ -251,7 +251,7 @@ public class PowerProfile { final Double[] values = (Double[]) data; if (values.length > level && level >= 0) { return values[level]; - } else if (level < 0) { + } else if (level < 0 || values.length == 0) { return 0; } else { return values[values.length - 1]; -- cgit v1.1