Commit 92457cce authored by clairehurst's avatar clairehurst 🌱 Committed by brizental
Browse files

fixup! TB 42247: Android helpers for the TorProvider

Bug 43576: Connection Assist on Android Fast Follows (Bug 41188)
Add frequent regions
parent b15f225e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public class TorAndroidIntegration implements BundleEventListener {
  private static final String EVENT_QUICKSTART_GET = "GeckoView:Tor:QuickstartGet";
  private static final String EVENT_QUICKSTART_SET = "GeckoView:Tor:QuickstartSet";
  private static final String EVENT_REGION_NAMES_GET = "GeckoView:Tor:RegionNamesGet";
  private static final String EVENT_FREQUENT_REGION_NAMES_GET = "GeckoView:Tor:FrequentRegionNamesGet";
  private static final String EVENT_SHOULD_SHOW_TOR_CONNECT = "GeckoView:Tor:ShouldShowTorConnect";

  private static final String CONTROL_PORT_FILE = "/control-ipc";
@@ -709,6 +710,19 @@ public class TorAndroidIntegration implements BundleEventListener {
    });
  }

  public interface FrequentRegionNamesGetter {
    void onValue(String[] frequentRegionNames);
  }

  public void frequentRegionNamesGet(FrequentRegionNamesGetter frequentRegionNamesGetter) {
    EventDispatcher.getInstance().queryBundle(EVENT_FREQUENT_REGION_NAMES_GET).then( frequentRegionNames -> {
      if (frequentRegionNames != null) {
        frequentRegionNamesGetter.onValue(frequentRegionNames.getStringArray("codes"));
      }
      return new GeckoResult<Void>();
    });
  }

  public interface ShouldShowTorConnectGetter {
    void onValue(Boolean shouldShowTorConnect);
  }
+6 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ const ListenedEvents = Object.freeze({
  quickstartGet: "GeckoView:Tor:QuickstartGet",
  quickstartSet: "GeckoView:Tor:QuickstartSet",
  regionNamesGet: "GeckoView:Tor:RegionNamesGet",
  frequentRegionNamesGet: "GeckoView:Tor:FrequentRegionNamesGet",
  shouldShowTorConnectGet: "GeckoView:Tor:ShouldShowTorConnect",
});

@@ -213,6 +214,11 @@ class TorAndroidIntegrationImpl {
        case ListenedEvents.regionNamesGet:
          callback?.onSuccess(lazy.TorConnect.getRegionNames());
          return;
        case ListenedEvents.frequentRegionNamesGet:
          callback?.onSuccess({
            codes: await lazy.TorConnect.getFrequentRegions(),
          });
          return;
        case ListenedEvents.shouldShowTorConnectGet:
          callback?.onSuccess(lazy.TorConnect.shouldShowTorConnect());
          return;