Improve reading corrupted state files

Zero-out invalid shuffle and finish modes
This commit is contained in:
Adrian Ulrich 2015-10-07 21:11:13 +02:00
parent 305a7c1823
commit f3c9678287

View File

@ -380,9 +380,15 @@ public final class SongTimeline {
}
}
mCurrentPos = Math.min(mSongs == null ? 0 : mSongs.size(), in.readInt());
mCurrentPos = Math.min(mSongs == null ? 0 : mSongs.size(), Math.abs(in.readInt()));
mFinishAction = in.readInt();
mShuffleMode = in.readInt();
// Guard against corruption
if (mFinishAction < 0 || mFinishAction >= FINISH_ICONS.length)
mFinishAction = 0;
if (mShuffleMode < 0 || mShuffleMode >= SHUFFLE_ICONS.length)
mShuffleMode = 0;
}
}