Skip to content
Snippets Groups Projects
Verified Commit a48e4389 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

fixup! Bug 42247: Android helpers for the TorProvider

Update the cached mSettings whenever someone one the GeckoView side
changes any TorSettings settings.
parent bb028644
Branches
Tags
1 merge request!902Bug 42384: Fix quickstart not working anymore
......@@ -47,6 +47,8 @@ public class TorIntegrationAndroid implements BundleEventListener {
private static final String EVENT_BOOTSTRAP_COMPLETE = "GeckoView:Tor:BootstrapComplete";
private static final String EVENT_BOOTSTRAP_ERROR = "GeckoView:Tor:BootstrapError";
private static final String EVENT_SETTINGS_OPEN = "GeckoView:Tor:OpenSettings";
private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady";
private static final String EVENT_SETTINGS_CHANGED = "GeckoView:Tor:SettingsChanged";
// Events we emit
private static final String EVENT_SETTINGS_GET = "GeckoView:Tor:SettingsGet";
......@@ -57,7 +59,6 @@ public class TorIntegrationAndroid implements BundleEventListener {
private static final String EVENT_BOOTSTRAP_BEGIN_AUTO = "GeckoView:Tor:BootstrapBeginAuto";
private static final String EVENT_BOOTSTRAP_CANCEL = "GeckoView:Tor:BootstrapCancel";
private static final String EVENT_BOOTSTRAP_GET_STATE = "GeckoView:Tor:BootstrapGetState";
private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady";
private static final String CONTROL_PORT_FILE = "/control-ipc";
private static final String SOCKS_FILE = "/socks-ipc";
......@@ -112,6 +113,7 @@ public class TorIntegrationAndroid implements BundleEventListener {
EVENT_MEEK_START,
EVENT_MEEK_STOP,
EVENT_SETTINGS_READY,
EVENT_SETTINGS_CHANGED,
EVENT_BOOTSTRAP_STATE_CHANGED,
EVENT_BOOTSTRAP_PROGRESS,
EVENT_BOOTSTRAP_COMPLETE,
......@@ -136,6 +138,14 @@ public class TorIntegrationAndroid implements BundleEventListener {
} catch(Exception e) {
Log.e(TAG, "SettingsLoader error: "+ e.toString());
}
} else if (EVENT_SETTINGS_CHANGED.equals(event)) {
GeckoBundle newSettings = message.getBundle("settings");
if (newSettings != null) {
// TODO: Should we notify listeners?
mSettings = new TorSettings(newSettings);
} else {
Log.w(TAG, "Ignoring a settings changed event that did not have the new settings.");
}
} else if (EVENT_BOOTSTRAP_STATE_CHANGED.equals(event)) {
String state = message.getString("state");
for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
......
......
......@@ -124,6 +124,15 @@ class TorAndroidIntegrationImpl {
settings: lazy.TorSettings.getSettings(),
});
break;
case lazy.TorSettingsTopics.SettingsChanged:
// For Android we push also the settings object to avoid a round trip on
// the event dispatcher.
lazy.EventDispatcher.instance.sendRequest({
type: EmittedEvents.settingsChanged,
changes: subj.wrappedJSObject.changes ?? [],
settings: lazy.TorSettings.getSettings(),
});
break;
}
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment