Commit 090e0f3d authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

TB 42247: Android helpers for the TorProvider

GeckoView is missing some API we use on desktop for the integration
with the tor daemon, such as subprocess.
Therefore, we need to implement them in Java and plumb the data
back and forth between JS and Java.
parent 08dcdc25
Loading
Loading
Loading
Loading
+1 −0
Changes for browser/app/profile/000-tor-browser.js: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -158,3 +158,4 @@ pref("browser.torsettings.log_level", "Warn");
pref("browser.torMoat.loglevel", "Warn");
pref("browser.tordomainisolator.loglevel", "Warn");
pref("browser.torcircuitpanel.loglevel", "Log");
pref("browser.tor_android.log_level", "Info");
+16 −0
Changes for mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -270,6 +270,8 @@ public final class GeckoRuntime implements Parcelable {
  private final CrashPullController.CrashPullProxy mCrashPullProxy;
  private final GeckoScreenChangeListener mScreenChangeListener;

  private TorAndroidIntegration mTorIntegration;

  private GeckoRuntime() {
    mWebExtensionController = new WebExtensionController(this);
    mContentBlockingController = new ContentBlockingController();
@@ -590,6 +592,8 @@ public final class GeckoRuntime implements Parcelable {
    // Warm up window context of default display.
    GeckoAppShell.maybeInitScreen();

    mTorIntegration = new TorAndroidIntegration(context);

    ProfilerController.addMarker(
        "GeckoView Initialization START", ProfilerController.getProfilerTime());
    return true;
@@ -705,6 +709,10 @@ public final class GeckoRuntime implements Parcelable {
      mScreenChangeListener.disable();
    }

    if (mTorIntegration != null) {
      mTorIntegration.shutdown();
    }

    GeckoThread.forceQuit();
  }

@@ -1191,6 +1199,14 @@ public final class GeckoRuntime implements Parcelable {
        "mobile-telemetry-pref-changed", isEnabled ? "enabled" : "disabled");
  }

  /**
   * Get the Tor integration controller for this runtime.
   */
  @UiThread
  public @NonNull TorAndroidIntegration getTorIntegrationController() {
    return mTorIntegration;
  }

  /**
   * Appends notes to crash report.
   *
+18 −0
Changes for mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2817,6 +2817,24 @@ public class GeckoSession {
    mEventDispatcher.dispatch("GeckoView:FlushSessionState", null);
  }

  /**
   * Try to get last circuit used in this session, if possible.
   *
   * @return The circuit information as a {@link GeckoResult} object.
   */
  @AnyThread
  public @NonNull GeckoResult<GeckoBundle> getTorCircuits() {
    return mEventDispatcher.queryBundle("GeckoView:GetTorCircuits");
  }

  /**
   * Change the circuit for this session.
   */
  @UiThread
  public void newTorCircuit() {
    mEventDispatcher.dispatch("GeckoView:NewTorCircuit", null);
  }

  /**
   * Set this GeckoSession as active or inactive, which represents if the session is currently
   * visible or not. Setting a GeckoSession to inactive will significantly reduce its memory
+11 −0
Changes for mobile/android/geckoview/src/main/java/org/mozilla/geckoview/ProviderStatus.java: 11 added lines, 0 removed lines.
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");
  }
}
+776 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading