From ba9a4b397f7a8af70d0d412f6a4cb820fff73a7b Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 5 Feb 2016 17:13:16 -0700 Subject: [PATCH] Use the right ClassLoader when restoring. If we're restoring after a background process death, the Parcelable creator cache is cold, and since we're handing in a null ClassLoader the best the platform can do is try the default ClassLoader which knows nothing about the running app. That's why ClassLoaderCreator exists, so use it to snag the relevant ClassLoader and pass it along. Bug: 26075620 Change-Id: I6fd977d6178dd0f5f9c465597f5806a08097ac7c --- .../src/com/android/documentsui/State.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/DocumentsUI/src/com/android/documentsui/State.java b/packages/DocumentsUI/src/com/android/documentsui/State.java index 28f7432432341..d141de667f2fe 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/State.java +++ b/packages/DocumentsUI/src/com/android/documentsui/State.java @@ -158,9 +158,14 @@ public class State implements android.os.Parcelable { out.writeInt(mStackTouched ? 1 : 0); } - public static final Creator CREATOR = new Creator() { + public static final ClassLoaderCreator CREATOR = new ClassLoaderCreator() { @Override public State createFromParcel(Parcel in) { + return createFromParcel(in, null); + } + + @Override + public State createFromParcel(Parcel in, ClassLoader loader) { final State state = new State(); state.action = in.readInt(); state.acceptMimes = in.readStringArray(); @@ -174,9 +179,9 @@ public class State implements android.os.Parcelable { state.restored = in.readInt() != 0; DurableUtils.readFromParcel(in, state.stack); state.currentSearch = in.readString(); - in.readMap(state.dirState, null); - in.readList(state.selectedDocumentsForCopy, null); - in.readList(state.excludedAuthorities, null); + in.readMap(state.dirState, loader); + in.readList(state.selectedDocumentsForCopy, loader); + in.readList(state.excludedAuthorities, loader); state.openableOnly = in.readInt() != 0; state.mStackTouched = in.readInt() != 0; return state;