Commit ec776e7f authored by clairehurst's avatar clairehurst 🌱
Browse files

fixup! TB 42247: Android helpers for the TorProvider

Bug 43570: Add tor exit prompt
parent 48c8f5a9
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
package org.mozilla.geckoview;

import org.mozilla.gecko.util.GeckoBundle;

public class ProviderStatus {
  public Boolean maybeConfigIssue;

  public ProviderStatus(GeckoBundle bundle) {
    maybeConfigIssue = bundle.getBoolean("maybeConfigIssue");
  }
}
+5 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public class TorAndroidIntegration 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_START_AGAIN = "GeckoView:Tor:StartAgain";
  private static final String EVENT_RESTART_PROVIDER = "GeckoView:Tor:RestartProvider";
  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";
@@ -706,6 +707,10 @@ public class TorAndroidIntegration implements BundleEventListener {
    return EventDispatcher.getInstance().queryVoid(EVENT_START_AGAIN);
  }

  public @NonNull GeckoResult<Void> restartProvider() {
    return EventDispatcher.getInstance().queryVoid(EVENT_RESTART_PROVIDER);
  }

  public interface QuickstartGetter {
    void onValue(boolean enabled);
  }
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ public class TorConnectStage {
    public Boolean potentiallyBlocked;
    public Boolean tryAgain;
    public TorBootstrappingStatus bootstrappingStatus;
    public ProviderStatus providerStatus;

    public TorConnectStage(GeckoBundle bundle) {
        name = TorConnectStageName.fromString(bundle.getString("name"));
@@ -26,6 +27,7 @@ public class TorConnectStage {
            error = new TorConnectError(bundle.getBundle("error"));
        }
        bootstrappingStatus = new TorBootstrappingStatus(bundle.getBundle("bootstrappingStatus"));
        providerStatus = new ProviderStatus(bundle.getBundle("providerStatus"));
    }

    public Boolean isBootstrapped() {
+2 −1
Original line number Diff line number Diff line
@@ -3,9 +3,10 @@ package org.mozilla.geckoview;
import java.security.InvalidParameterException;

public enum TorConnectStageName {
    // These names should match entries from TorConnectStage in TorConnect.sys.mjs at ~ln163.
    // These names should match entries from TorConnectStage in TorConnect.sys.mjs at ~ln674.
    Disabled("Disabled"),
    Loading("Loading"),
    ProviderStopped("ProviderStopped"),
    Start("Start"),
    Bootstrapping("Bootstrapping"),
    Offline("Offline"),
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ const ListenedEvents = Object.freeze({
  bootstrapBeginAuto: "GeckoView:Tor:BootstrapBeginAuto",
  bootstrapCancel: "GeckoView:Tor:BootstrapCancel",
  startAgain: "GeckoView:Tor:StartAgain",
  restartProvider: "GeckoView:Tor:RestartProvider",
  quickstartGet: "GeckoView:Tor:QuickstartGet",
  quickstartSet: "GeckoView:Tor:QuickstartSet",
  regionNamesGet: "GeckoView:Tor:RegionNamesGet",
@@ -198,6 +199,9 @@ class TorAndroidIntegrationImpl {
        case ListenedEvents.startAgain:
          lazy.TorConnect.startAgain();
          break;
        case ListenedEvents.restartProvider:
          lazy.TorConnect.restartProvider();
          break;
        case ListenedEvents.quickstartGet:
          callback?.onSuccess(lazy.TorConnect.quickstart);
          return;