Browse Source

Fix a ClassCastException crash for the remote_access_medialibrary_content setting

merge-requests/2329/head
Nicolas Pomepuy 11 months ago
parent
commit
8d926b0737
  1. 34
      application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt

34
application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt

@ -41,8 +41,8 @@ import org.videolan.resources.util.getFromMl
import org.videolan.tools.KEY_APP_THEME
import org.videolan.tools.KEY_CURRENT_EQUALIZER_ID
import org.videolan.tools.KEY_CURRENT_MAJOR_VERSION
import org.videolan.tools.KEY_CURRENT_SETTINGS_VERSION_AFTER_LIBVLC_INSTANTIATION
import org.videolan.tools.KEY_CURRENT_SETTINGS_VERSION
import org.videolan.tools.KEY_CURRENT_SETTINGS_VERSION_AFTER_LIBVLC_INSTANTIATION
import org.videolan.tools.KEY_PLAYBACK_SPEED_AUDIO_GLOBAL
import org.videolan.tools.KEY_PLAYBACK_SPEED_AUDIO_GLOBAL_VALUE
import org.videolan.tools.KEY_PLAYBACK_SPEED_VIDEO_GLOBAL
@ -70,7 +70,7 @@ import org.videolan.vlc.repository.EqualizerRepository
import java.io.File
import java.io.IOException
private const val CURRENT_VERSION = 16
private const val CURRENT_VERSION = 17
private const val CURRENT_VERSION_LIBVLC = 1
object VersionMigration {
@ -152,6 +152,10 @@ object VersionMigration {
migrateToVersion16(settings)
}
if (lastVersion < 17) {
migrateToVersion17(settings)
}
//Major version upgrade
if (lastMajorVersion == 3 && currentMajorVersion == 4) {
migrateToVlc4(settings)
@ -469,6 +473,32 @@ object VersionMigration {
}
}
/**
* Migrate the wrongly typed remote_access_medialibrary_content setting
*
*/
private fun migrateToVersion17(settings: SharedPreferences) {
Log.i(this::class.java.simpleName, "Migrate to version 17: Migrate the wrongly typed remote_access_medialibrary_content setting")
if (settings.contains("remote_access_medialibrary_content")) {
try {
settings.getString("remote_access_medialibrary_content", "")?.let { oldValue ->
settings.edit(true) {
putStringSet(
"remote_access_medialibrary_content",
oldValue
.split(",")
.map { it.filter(Char::isDigit) }
.toSet()
)
}
}
} catch (_: ClassCastException) {
//Not a string. Safe to keep
}
}
}
/**
* Migrate the equalizer to room
*/

Loading…
Cancel
Save