summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Martinz <amartinz@shiftphones.com>2018-07-04 17:05:51 (GMT)
committerJoey <joey@lineageos.org>2018-07-04 19:08:47 (GMT)
commit7c88420eb8971d46e99a0803c50ba6ebbd66102e (patch)
tree79bc07abfeed52edbfd9a23902e8edb8e110cbaa
parentde6e8d40eb558799d69beba22f4095d487a0495a (diff)
downloadandroid_packages_apps_Trebuchet-7c88420eb8971d46e99a0803c50ba6ebbd66102e.zip
android_packages_apps_Trebuchet-7c88420eb8971d46e99a0803c50ba6ebbd66102e.tar.gz
android_packages_apps_Trebuchet-7c88420eb8971d46e99a0803c50ba6ebbd66102e.tar.bz2
IconPicker: clone drawables array to prevent IOOBE
When binding the view holder, we are making use of lists, which can change. In case the lists are changing after binding, we can get an IOOBE when the click listener gets called. To work around this create a shallow copy of the lists and use it. ----- Stack Trace: java.lang.IndexOutOfBoundsException: Index: 44, Size: 44 at java.util.ArrayList.get(ArrayList.java:437) at com.android.launcher3.icons.IconPickerActivity$GridAdapter.lambda$-com_android_launcher3_icons_IconPickerActivity$GridAdapter_9734(IconPickerActivity.java:248) at com.android.launcher3.icons.-$Lambda$aHbfyH3p1fvGkmuJq2f35Z_cj_A$2.$m$0 at com.android.launcher3.icons.-$Lambda$aHbfyH3p1fvGkmuJq2f35Z_cj_A$2.onClick at android.view.View.performClick(View.java:6320) at android.view.View$PerformClick.run(View.java:25087) at android.os.Handler.handleCallback(Handler.java:869) at android.os.Handler.dispatchMessage(Handler.java:101) at android.os.Looper.loop(Looper.java:206) at android.app.ActivityThread.main(ActivityThread.java:6733) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:845) ----- Change-Id: Id3bc8a01c29517230765a032f220bccccda2b386 Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
-rw-r--r--src/com/android/launcher3/icons/IconPickerActivity.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/com/android/launcher3/icons/IconPickerActivity.java b/src/com/android/launcher3/icons/IconPickerActivity.java
index 3b49871..eb19a1f 100644
--- a/src/com/android/launcher3/icons/IconPickerActivity.java
+++ b/src/com/android/launcher3/icons/IconPickerActivity.java
@@ -238,8 +238,8 @@ public class IconPickerActivity extends Activity {
if (holder.getItemViewType() != TYPE_MATCHING_HEADER
&& holder.getItemViewType() != TYPE_ALL_HEADER) {
boolean drawablesMatching = holder.getItemViewType() == TYPE_MATCHING_ICONS;
- final List<String> drawables = drawablesMatching ?
- mMatchingDrawables : mAllDrawables;
+ final List<String> drawables = new ArrayList<>(drawablesMatching ?
+ mMatchingDrawables : mAllDrawables);
if (holder.getAdapterPosition() >= drawables.size()) {
return;
}
@@ -305,4 +305,4 @@ public class IconPickerActivity extends Activity {
outRect.top = spacing;
}
}
-} \ No newline at end of file
+}