Skip to content
Snippets Groups Projects
Commit 8bb1b960 authored by clairehurst's avatar clairehurst
Browse files

fixup! TB 41878: [android] Add standalone Tor Bootstrap

#43329 [Android] Remove remaining traces of the old Bootstrap

# Conflicts:
#	mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
parent 496a888f
Branches
Tags
1 merge request!1408[Android] Remove remaining traces of the old Bootstrap
Pipeline #255528 passed
......@@ -158,8 +158,6 @@ import org.mozilla.fenix.search.toolbar.SearchSelectorMenu
import org.mozilla.fenix.tabstray.Page
import org.mozilla.fenix.tabstray.TabsTrayAccessPoint
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.tor.TorBootstrapFragmentDirections
import org.mozilla.fenix.tor.TorBootstrapStatus
import org.mozilla.fenix.tor.TorConnectionAssistViewModel
import org.mozilla.fenix.utils.Settings.Companion.TOP_SITES_PROVIDER_MAX_THRESHOLD
import org.mozilla.fenix.utils.allowUndo
......@@ -262,7 +260,6 @@ class HomeFragment : Fragment(), UserInteractionHandler {
private val bottomToolbarContainerIntegration = ViewBoundFeatureWrapper<BottomToolbarContainerIntegration>()
private lateinit var savedLoginsLauncher: ActivityResultLauncher<Intent>
private lateinit var torBootstrapStatus: TorBootstrapStatus
override fun onCreate(savedInstanceState: Bundle?) {
// DO NOT ADD ANYTHING ABOVE THIS getProfilerTime CALL!
......@@ -295,12 +292,6 @@ class HomeFragment : Fragment(), UserInteractionHandler {
val activity = activity as HomeActivity
val components = requireComponents
torBootstrapStatus = TorBootstrapStatus(
!BuildConfig.DISABLE_TOR,
components.torController,
::dispatchModeChanges
)
val currentWallpaperName = requireContext().settings().currentWallpaperName
applyWallpaper(
wallpaperName = currentWallpaperName,
......@@ -1037,7 +1028,6 @@ class HomeFragment : Fragment(), UserInteractionHandler {
override fun onStop() {
dismissRecommendPrivateBrowsingShortcut()
super.onStop()
torBootstrapStatus.unregisterTorListener()
}
override fun onStart() {
......@@ -1090,15 +1080,6 @@ class HomeFragment : Fragment(), UserInteractionHandler {
}
}
private fun dispatchModeChanges(isBootstrapping: Boolean) {
if (isBootstrapping) {
val directions =
TorBootstrapFragmentDirections
.actionStartupTorbootstrap()
findNavController().navigate(directions)
}
}
@VisibleForTesting
internal fun removeCollectionWithUndo(tabCollection: TabCollection) {
val snackbarMessage = getString(R.string.snackbar_collection_deleted)
......@@ -1122,7 +1103,6 @@ class HomeFragment : Fragment(), UserInteractionHandler {
override fun onResume() {
super.onResume()
torBootstrapStatus.registerTorListener()
if (browsingModeManager.mode == BrowsingMode.Private) {
activity?.window?.setBackgroundDrawableResource(R.drawable.private_home_background_gradient)
}
......
......
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.tor
@SuppressWarnings("LongParameterList", "TooManyFunctions")
class TorBootstrapStatus(
private val shouldStartTor: Boolean,
private val torController: TorController,
private val dispatchModeChanges: (isShouldBootstrap: Boolean) -> Unit
) : TorEvents {
init {
torController.registerTorListener(this)
}
fun isBootstrapping() = (shouldStartTor && !torController.isBootstrapped)
@SuppressWarnings("EmptyFunctionBlock")
override fun onTorConnecting() {
}
override fun onTorConnected() {
dispatchModeChanges(isBootstrapping())
}
override fun onTorStopped() {
dispatchModeChanges(isBootstrapping())
}
@SuppressWarnings("EmptyFunctionBlock")
override fun onTorStatusUpdate(entry: String?, status: String?, progress: Double?) {
}
fun unregisterTorListener() {
torController.unregisterTorListener(this)
}
fun registerTorListener() {
torController.registerTorListener(this)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment