Skip to content
Snippets Groups Projects
Commit 3a96ef08 authored by Matthew Finkel's avatar Matthew Finkel
Browse files

fixup! Bug 40028: Integrate Tor Controller into HomeFragment

Move TorController's BroadcastReceiver registration into
FenixApplication because TorController misses events when
registration is controlled by HomeFragment.

Initialize tor-android-service with FenixApplication's Context.
parent 5d14717f
Branches
No related tags found
1 merge request!26Bug 40041 09
......@@ -53,6 +53,7 @@ import org.mozilla.fenix.push.WebPushEngineIntegration
import org.mozilla.fenix.session.PerformanceActivityLifecycleCallbacks
import org.mozilla.fenix.session.VisibilityLifecycleCallback
import org.mozilla.fenix.utils.BrowsersCache
import org.torproject.android.service.util.Prefs
/**
*The main application class for Fenix. Records data to measure initialization performance.
......@@ -95,6 +96,12 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
setupInMainProcessOnly()
}
override fun onTerminate() {
super.onTerminate()
components.torController.stop()
}
protected open fun initializeGlean() {
val telemetryEnabled = settings().isTelemetryEnabled
......@@ -143,6 +150,9 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
if (!megazordSetup.isCompleted) {
runBlocking { megazordSetup.await(); }
}
// Give TAS the base Context
Prefs.setContext(applicationContext)
}
setupLeakCanary()
......@@ -161,6 +171,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
initVisualCompletenessQueueAndQueueTasks()
components.appStartupTelemetry.onFenixApplicationOnCreate()
components.torController.start()
}
private fun restoreDownloads() {
......
......
......@@ -111,7 +111,6 @@ import org.mozilla.fenix.theme.ThemeManager
import org.mozilla.fenix.utils.BrowsersCache
import org.torproject.android.service.TorService
import org.torproject.android.service.TorServiceConstants
import org.torproject.android.service.util.Prefs
import java.lang.ref.WeakReference
/**
......@@ -161,9 +160,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
private var dialog: RedirectDialogFragment? = null
final override fun onCreate(savedInstanceState: Bundle?) {
// Give Orbot the base Context
Prefs.setContext(applicationContext)
StrictModeManager.changeStrictModePolicies(supportFragmentManager)
// There is disk read violations on some devices such as samsung and pixel for android 9/10
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
......
......
......@@ -776,7 +776,6 @@ class HomeFragment : Fragment() {
homeViewModel.layoutManagerState =
sessionControlView!!.view.layoutManager?.onSaveInstanceState()
requireComponents.torController.stop()
currentMode.unregisterTorListener()
}
......@@ -787,7 +786,6 @@ class HomeFragment : Fragment() {
}
hideToolbar()
requireComponents.torController.start()
}
override fun onPause() {
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment