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
This commit is contained in:
Ruchi Kandoi
2014-07-02 17:47:40 -07:00
parent b5e05cffcc
commit be9cbb12e9

View File

@@ -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];