Pier Angelo Vendrame pushed to branch tor-browser-115.6.0esr-13.5-1 at The Tor Project / Applications / Tor Browser

Commits:

2 changed files:

Changes:

  • mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java
    ... ... @@ -7,6 +7,7 @@
    7 7
     package org.mozilla.geckoview;
    
    8 8
     
    
    9 9
     import android.content.Context;
    
    10
    +import android.os.AsyncTask;
    
    10 11
     import android.util.Log;
    
    11 12
     
    
    12 13
     import androidx.annotation.AnyThread;
    
    ... ... @@ -131,7 +132,11 @@ public class TorIntegrationAndroid implements BundleEventListener {
    131 132
             } else if (EVENT_MEEK_STOP.equals(event)) {
    
    132 133
                 stopMeek(message, callback);
    
    133 134
             } else if (EVENT_SETTINGS_READY.equals(event)) {
    
    134
    -            loadSettings(message);
    
    135
    +            try {
    
    136
    +                new SettingsLoader().execute(message);
    
    137
    +            } catch(Exception e) {
    
    138
    +                Log.e(TAG, "SettingsLoader error: "+ e.toString());
    
    139
    +            }
    
    135 140
             } else if (EVENT_BOOTSTRAP_STATE_CHANGED.equals(event)) {
    
    136 141
                 String state = message.getString("state");
    
    137 142
                 for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
    
    ... ... @@ -161,14 +166,24 @@ public class TorIntegrationAndroid implements BundleEventListener {
    161 166
             }
    
    162 167
         }
    
    163 168
     
    
    164
    -    private void loadSettings(GeckoBundle message) {
    
    165
    -        if (TorLegacyAndroidSettings.unmigrated()) {
    
    166
    -            mSettings = TorLegacyAndroidSettings.loadTorSettings();
    
    167
    -            setSettings(mSettings);
    
    168
    -            TorLegacyAndroidSettings.setMigrated();
    
    169
    -        } else {
    
    170
    -            GeckoBundle bundle = message.getBundle("settings");
    
    171
    -            mSettings = new TorSettings(bundle);
    
    169
    +    private class SettingsLoader extends AsyncTask<GeckoBundle, Void, TorSettings> {
    
    170
    +        protected TorSettings doInBackground(GeckoBundle... messages) {
    
    171
    +            GeckoBundle message = messages[0];
    
    172
    +            TorSettings settings;
    
    173
    +            if (TorLegacyAndroidSettings.unmigrated()) {
    
    174
    +                settings = TorLegacyAndroidSettings.loadTorSettings();
    
    175
    +                setSettings(settings, true, true);
    
    176
    +                TorLegacyAndroidSettings.setMigrated();
    
    177
    +            } else {
    
    178
    +                GeckoBundle bundle = message.getBundle("settings");
    
    179
    +                settings = new TorSettings(bundle);
    
    180
    +            }
    
    181
    +            return settings;
    
    182
    +        }
    
    183
    +
    
    184
    +        @Override
    
    185
    +        protected void onPostExecute(TorSettings torSettings) {
    
    186
    +            mSettings = torSettings;
    
    172 187
             }
    
    173 188
         }
    
    174 189
     
    
    ... ... @@ -515,8 +530,12 @@ public class TorIntegrationAndroid implements BundleEventListener {
    515 530
             return EventDispatcher.getInstance().queryBundle(EVENT_SETTINGS_GET);
    
    516 531
         }
    
    517 532
     
    
    518
    -    public @NonNull GeckoResult<Void> setSettings(final TorSettings settings) {
    
    519
    -        return EventDispatcher.getInstance().queryVoid(EVENT_SETTINGS_SET, settings.asGeckoBundle());
    
    533
    +    public @NonNull GeckoResult<Void> setSettings(final TorSettings settings, boolean save, boolean apply) {
    
    534
    +        GeckoBundle bundle = new GeckoBundle(3);
    
    535
    +        bundle.putBoolean("save", save);
    
    536
    +        bundle.putBoolean("apply", apply);
    
    537
    +        bundle.putBundle("settings", settings.asGeckoBundle());
    
    538
    +        return EventDispatcher.getInstance().queryVoid(EVENT_SETTINGS_SET, bundle);
    
    520 539
         }
    
    521 540
     
    
    522 541
         public @NonNull GeckoResult<Void> applySettings() {
    

  • toolkit/modules/TorAndroidIntegration.sys.mjs
    ... ... @@ -136,13 +136,19 @@ class TorAndroidIntegrationImpl {
    136 136
               return;
    
    137 137
             case ListenedEvents.settingsSet:
    
    138 138
               // This does not throw, so we do not have any way to report the error!
    
    139
    -          lazy.TorSettings.setSettings(data);
    
    139
    +          lazy.TorSettings.setSettings(data.settings);
    
    140
    +          if (data.save) {
    
    141
    +            lazy.TorSettings.saveToPrefs();
    
    142
    +          }
    
    143
    +          if (data.apply) {
    
    144
    +            lazy.TorSettings.applySettings();
    
    145
    +          }
    
    140 146
               break;
    
    141 147
             case ListenedEvents.settingsApply:
    
    142 148
               await lazy.TorSettings.applySettings();
    
    143 149
               break;
    
    144 150
             case ListenedEvents.settingsSave:
    
    145
    -          await lazy.TorSettings.saveSettings();
    
    151
    +          await lazy.TorSettings.saveToPrefs();
    
    146 152
               break;
    
    147 153
             case ListenedEvents.bootstrapBegin:
    
    148 154
               lazy.TorConnect.beginBootstrap();