| ... | ... | @@ -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() {
 |