From 8c16835966a09932f3a089f19878b6fb0339d984 Mon Sep 17 00:00:00 2001 From: Muyuan Li Date: Tue, 23 Feb 2016 15:10:19 -0800 Subject: [PATCH] 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) --- src/com/android/settings/display/DisplayDensityUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/display/DisplayDensityUtils.java b/src/com/android/settings/display/DisplayDensityUtils.java index 6810511699a..f6960d359d2 100644 --- a/src/com/android/settings/display/DisplayDensityUtils.java +++ b/src/com/android/settings/display/DisplayDensityUtils.java @@ -154,10 +154,11 @@ class DisplayDensityUtils { } 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; -- GitLab