Loading components/support/migration/src/main/java/mozilla/components/support/migration/FennecMigrator.kt +1 −1 Original line number Diff line number Diff line Loading @@ -995,7 +995,7 @@ class FennecMigrator private constructor( return try { logger.debug("Migrating gecko files...") val result = GeckoMigration.migrate(profile.path, migrationVersion) val result = GeckoMigration.migrate(profile.path, migrationVersion, context) logger.debug("Migrated gecko files.") if (result is Result.Failure<GeckoMigrationResult>) { Loading components/support/migration/src/main/java/mozilla/components/support/migration/GeckoMigration.kt +26 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package mozilla.components.support.migration import android.content.Context import android.util.AtomicFile import androidx.annotation.VisibleForTesting import mozilla.components.support.ktx.util.writeString Loading @@ -12,6 +13,9 @@ import java.io.IOException private const val PREFS_FILE = "prefs.js" private const val PREFS_BACKUP_FILE = "prefs.js.backup.v" private const val SEC_LEVEL_OFFSET = 50 private const val SEC_LEVEL_MIN = 0 private const val SEC_LEVEL_MAX = 4 @VisibleForTesting internal var userPrefsToKeep = setOf("extensions.webextensions.uuids") Loading Loading @@ -95,7 +99,8 @@ internal object GeckoMigration { */ fun migrate( profilePath: String, migrationVersion: Int migrationVersion: Int, context: Context ): Result<GeckoMigrationResult> { // GeckoView will happily pick up the profile from Fennec and reuse all data in it. So this // migration is mostly focused on removing all prefs that we do not want to reuse. Loading @@ -118,6 +123,26 @@ internal object GeckoMigration { }.toList() } val secLevel = prefsjs.useLines { // The prefs are auto-generated, so we can expect the offset to be always the same it.find { line -> line.startsWith("$USER_PREF(\"extensions.torbutton.security_slider\"") } ?.substring(SEC_LEVEL_OFFSET, SEC_LEVEL_OFFSET + 1)?.toIntOrNull() } if (secLevel != null && secLevel > SEC_LEVEL_MIN && secLevel < SEC_LEVEL_MAX) { val prefVal = when (secLevel) { 1 -> "pref_key_tor_security_level_safest_option" else -> "pref_key_tor_security_level_safer_option" } val fenixAppPrefs = context.getSharedPreferences( FennecSettingsMigration.FENIX_SHARED_PREFS_NAME, Context.MODE_PRIVATE ) fenixAppPrefs.edit() .putBoolean("pref_key_tor_security_level_standard_option", false) .putBoolean(prefVal, true) .apply() } return if (transformed.isEmpty()) { removePrefsFile(prefsjs) } else { Loading config/detekt-baseline.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ <CurrentIssues> <ID>AbsentOrWrongFileLicense:AutoFitTextureView.kt$mozilla.components.feature.qr.views.AutoFitTextureView.kt</ID> <ID>AbsentOrWrongFileLicense:QrFragment.kt$mozilla.components.feature.qr.QrFragment.kt</ID> <ID>ComplexMethod:GeckoMigration.kt$GeckoMigration$migrate</ID> <ID>UndocumentedPublicClass:AutoSave.kt$AutoSave</ID> <ID>UndocumentedPublicClass:AutoSave.kt$AutoSave$Storage</ID> <ID>UndocumentedPublicClass:Base64.kt$Base64</ID> Loading Loading @@ -141,6 +142,7 @@ <ID>UndocumentedPublicClass:ToolbarFeature.kt$ToolbarFeature.RenderStyle$ColoredUrl : RenderStyle</ID> <ID>UndocumentedPublicClass:ToolbarFeature.kt$ToolbarFeature.RenderStyle$RegistrableDomain : RenderStyle</ID> <ID>UndocumentedPublicClass:ToolbarFeature.kt$ToolbarFeature.RenderStyle$UncoloredUrl : RenderStyle</ID> <ID>UndocumentedPublicClass:TorUtils.kt$TorUtils</ID> <ID>UndocumentedPublicClass:URLStringUtils.kt$URLStringUtils</ID> <ID>UndocumentedPublicClass:WebAppManifest.kt$WebAppManifest.Icon$Purpose</ID> <ID>UndocumentedPublicFunction:AppLinksUseCases.kt$AppLinksUseCases.GetAppLinkRedirect$operator fun invoke(url: String): AppLinkRedirect</ID> Loading Loading
components/support/migration/src/main/java/mozilla/components/support/migration/FennecMigrator.kt +1 −1 Original line number Diff line number Diff line Loading @@ -995,7 +995,7 @@ class FennecMigrator private constructor( return try { logger.debug("Migrating gecko files...") val result = GeckoMigration.migrate(profile.path, migrationVersion) val result = GeckoMigration.migrate(profile.path, migrationVersion, context) logger.debug("Migrated gecko files.") if (result is Result.Failure<GeckoMigrationResult>) { Loading
components/support/migration/src/main/java/mozilla/components/support/migration/GeckoMigration.kt +26 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package mozilla.components.support.migration import android.content.Context import android.util.AtomicFile import androidx.annotation.VisibleForTesting import mozilla.components.support.ktx.util.writeString Loading @@ -12,6 +13,9 @@ import java.io.IOException private const val PREFS_FILE = "prefs.js" private const val PREFS_BACKUP_FILE = "prefs.js.backup.v" private const val SEC_LEVEL_OFFSET = 50 private const val SEC_LEVEL_MIN = 0 private const val SEC_LEVEL_MAX = 4 @VisibleForTesting internal var userPrefsToKeep = setOf("extensions.webextensions.uuids") Loading Loading @@ -95,7 +99,8 @@ internal object GeckoMigration { */ fun migrate( profilePath: String, migrationVersion: Int migrationVersion: Int, context: Context ): Result<GeckoMigrationResult> { // GeckoView will happily pick up the profile from Fennec and reuse all data in it. So this // migration is mostly focused on removing all prefs that we do not want to reuse. Loading @@ -118,6 +123,26 @@ internal object GeckoMigration { }.toList() } val secLevel = prefsjs.useLines { // The prefs are auto-generated, so we can expect the offset to be always the same it.find { line -> line.startsWith("$USER_PREF(\"extensions.torbutton.security_slider\"") } ?.substring(SEC_LEVEL_OFFSET, SEC_LEVEL_OFFSET + 1)?.toIntOrNull() } if (secLevel != null && secLevel > SEC_LEVEL_MIN && secLevel < SEC_LEVEL_MAX) { val prefVal = when (secLevel) { 1 -> "pref_key_tor_security_level_safest_option" else -> "pref_key_tor_security_level_safer_option" } val fenixAppPrefs = context.getSharedPreferences( FennecSettingsMigration.FENIX_SHARED_PREFS_NAME, Context.MODE_PRIVATE ) fenixAppPrefs.edit() .putBoolean("pref_key_tor_security_level_standard_option", false) .putBoolean(prefVal, true) .apply() } return if (transformed.isEmpty()) { removePrefsFile(prefsjs) } else { Loading
config/detekt-baseline.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ <CurrentIssues> <ID>AbsentOrWrongFileLicense:AutoFitTextureView.kt$mozilla.components.feature.qr.views.AutoFitTextureView.kt</ID> <ID>AbsentOrWrongFileLicense:QrFragment.kt$mozilla.components.feature.qr.QrFragment.kt</ID> <ID>ComplexMethod:GeckoMigration.kt$GeckoMigration$migrate</ID> <ID>UndocumentedPublicClass:AutoSave.kt$AutoSave</ID> <ID>UndocumentedPublicClass:AutoSave.kt$AutoSave$Storage</ID> <ID>UndocumentedPublicClass:Base64.kt$Base64</ID> Loading Loading @@ -141,6 +142,7 @@ <ID>UndocumentedPublicClass:ToolbarFeature.kt$ToolbarFeature.RenderStyle$ColoredUrl : RenderStyle</ID> <ID>UndocumentedPublicClass:ToolbarFeature.kt$ToolbarFeature.RenderStyle$RegistrableDomain : RenderStyle</ID> <ID>UndocumentedPublicClass:ToolbarFeature.kt$ToolbarFeature.RenderStyle$UncoloredUrl : RenderStyle</ID> <ID>UndocumentedPublicClass:TorUtils.kt$TorUtils</ID> <ID>UndocumentedPublicClass:URLStringUtils.kt$URLStringUtils</ID> <ID>UndocumentedPublicClass:WebAppManifest.kt$WebAppManifest.Icon$Purpose</ID> <ID>UndocumentedPublicFunction:AppLinksUseCases.kt$AppLinksUseCases.GetAppLinkRedirect$operator fun invoke(url: String): AppLinkRedirect</ID> Loading