Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba9a4b39 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

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
parent 37355a9f
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -158,9 +158,14 @@ public class State implements android.os.Parcelable {
        out.writeInt(mStackTouched ? 1 : 0);
    }

    public static final Creator<State> CREATOR = new Creator<State>() {
    public static final ClassLoaderCreator<State> CREATOR = new ClassLoaderCreator<State>() {
        @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;