Fixed a bug in DisplayUtils in which the length of entries will be added
twice, causing IndexOutOfBound exception at runtime when using custom
DPI
Change-Id: Ib106f0ee8044893e2c1f3b4f334b741194171e2a
(cherry picked from commit d4ed8400ff7bc60e1391f4ea248390342a9f90dd)
diff --git a/src/com/android/settings/display/DisplayDensityUtils.java b/src/com/android/settings/display/DisplayDensityUtils.java
index 6810511..f6960d3 100644
--- a/src/com/android/settings/display/DisplayDensityUtils.java
+++ b/src/com/android/settings/display/DisplayDensityUtils.java
@@ -154,10 +154,11 @@
} else {
// We don't understand the current density. Must have been set by
// someone else. Make room for another entry...
- values = Arrays.copyOf(values, values.length + 1);
+ int newLength = values.length + 1;
+ values = Arrays.copyOf(values, newLength);
values[curIndex] = currentDensity;
- entries = Arrays.copyOf(entries, values.length + 1);
+ entries = Arrays.copyOf(entries, newLength);
entries[curIndex] = res.getString(SUMMARY_CUSTOM, currentDensity);
displayIndex = curIndex;