Matthew Finkel pushed to branch android-components-60.0.3-10.0-1 at The Tor Project / Applications / android-components
Commits: 9eb30f13 by Alex Catarineu at 2020-10-21T22:15:39+02:00 Bug 40022: Migrate Tor security level from Fennec
- - - - - 6b75c81e by Matthew Finkel at 2020-10-21T22:09:37+00:00 Merge remote-tracking branch 'acatgl/40022' into android-components-60.0.3-10.0-1
- - - - -
2 changed files:
- components/support/migration/src/main/java/mozilla/components/support/migration/FennecMigrator.kt - components/support/migration/src/main/java/mozilla/components/support/migration/GeckoMigration.kt
Changes:
===================================== components/support/migration/src/main/java/mozilla/components/support/migration/FennecMigrator.kt ===================================== @@ -975,7 +975,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>) {
===================================== components/support/migration/src/main/java/mozilla/components/support/migration/GeckoMigration.kt ===================================== @@ -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 @@ -95,7 +96,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. @@ -118,6 +120,23 @@ 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(50, 51)?.toIntOrNull() + } + if (secLevel != null && secLevel > 0 && secLevel < 4) { + 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 {
View it on GitLab: https://gitlab.torproject.org/tpo/applications/android-components/-/compare/...