[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/android-components][android-components-60.0.3-10.0-1] 2 commits: Bug 40022: Migrate Tor security level from Fennec



Title: GitLab

Matthew Finkel pushed to branch android-components-60.0.3-10.0-1 at The Tor Project / Applications / android-components

Commits:

2 changed files:

Changes:

  • components/support/migration/src/main/java/mozilla/components/support/migration/FennecMigrator.kt
    ... ... @@ -975,7 +975,7 @@ class FennecMigrator private constructor(
    975 975
     
    
    976 976
             return try {
    
    977 977
                 logger.debug("Migrating gecko files...")
    
    978
    -            val result = GeckoMigration.migrate(profile.path, migrationVersion)
    
    978
    +            val result = GeckoMigration.migrate(profile.path, migrationVersion, context)
    
    979 979
                 logger.debug("Migrated gecko files.")
    
    980 980
     
    
    981 981
                 if (result is Result.Failure<GeckoMigrationResult>) {
    

  • components/support/migration/src/main/java/mozilla/components/support/migration/GeckoMigration.kt
    ... ... @@ -4,6 +4,7 @@
    4 4
     
    
    5 5
     package mozilla.components.support.migration
    
    6 6
     
    
    7
    +import android.content.Context
    
    7 8
     import android.util.AtomicFile
    
    8 9
     import androidx.annotation.VisibleForTesting
    
    9 10
     import mozilla.components.support.ktx.util.writeString
    
    ... ... @@ -95,7 +96,8 @@ internal object GeckoMigration {
    95 96
          */
    
    96 97
         fun migrate(
    
    97 98
             profilePath: String,
    
    98
    -        migrationVersion: Int
    
    99
    +        migrationVersion: Int,
    
    100
    +        context: Context
    
    99 101
         ): Result<GeckoMigrationResult> {
    
    100 102
             // GeckoView will happily pick up the profile from Fennec and reuse all data in it. So this
    
    101 103
             // migration is mostly focused on removing all prefs that we do not want to reuse.
    
    ... ... @@ -118,6 +120,23 @@ internal object GeckoMigration {
    118 120
                 }.toList()
    
    119 121
             }
    
    120 122
     
    
    123
    +        val secLevel = prefsjs.useLines {
    
    124
    +            // The prefs are auto-generated, so we can expect the offset to be always the same
    
    125
    +            it.find { line -> line.startsWith("$USER_PREF(\"extensions.torbutton.security_slider\"") }
    
    126
    +                    ?.substring(50, 51)?.toIntOrNull()
    
    127
    +        }
    
    128
    +        if (secLevel != null && secLevel > 0 && secLevel < 4) {
    
    129
    +            val prefVal = when (secLevel) {
    
    130
    +                1 -> "pref_key_tor_security_level_safest_option"
    
    131
    +                else -> "pref_key_tor_security_level_safer_option"
    
    132
    +            }
    
    133
    +            val fenixAppPrefs = context.getSharedPreferences(FennecSettingsMigration.FENIX_SHARED_PREFS_NAME, Context.MODE_PRIVATE)
    
    134
    +            fenixAppPrefs.edit()
    
    135
    +                    .putBoolean("pref_key_tor_security_level_standard_option", false)
    
    136
    +                    .putBoolean(prefVal, true)
    
    137
    +                    .apply()
    
    138
    +        }
    
    139
    +
    
    121 140
             return if (transformed.isEmpty()) {
    
    122 141
                 removePrefsFile(prefsjs)
    
    123 142
             } else {
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits