clairehurst pushed to branch tor-browser-128.8.0esr-14.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
d7dfb3f5
by clairehurst at 2025-03-13T15:41:50-06:00
-
ec07d29a
by clairehurst at 2025-03-13T15:41:57-06:00
5 changed files:
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt
Changes:
... | ... | @@ -137,8 +137,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider { |
137 | 137 | isDeviceRamAboveThreshold()
|
138 | 138 | }
|
139 | 139 | |
140 | - var terminating = false
|
|
141 | - |
|
142 | 140 | open val components by lazy { Components(this) }
|
143 | 141 | |
144 | 142 | var visibilityLifecycleCallback: VisibilityLifecycleCallback? = null
|
... | ... | @@ -188,20 +186,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider { |
188 | 186 | }
|
189 | 187 | }
|
190 | 188 | |
191 | - fun isTerminating() = terminating
|
|
192 | - |
|
193 | - fun terminate() {
|
|
194 | - onTerminate()
|
|
195 | - }
|
|
196 | - |
|
197 | - override fun onTerminate() {
|
|
198 | - terminating = true
|
|
199 | - |
|
200 | - super.onTerminate()
|
|
201 | - components.torController.stop()
|
|
202 | - components.torController.stopTor()
|
|
203 | - }
|
|
204 | - |
|
205 | 189 | @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage
|
206 | 190 | @VisibleForTesting
|
207 | 191 | protected open fun initializeGlean() {
|
... | ... | @@ -158,6 +158,7 @@ import org.mozilla.fenix.home.HomeFragment |
158 | 158 | import org.mozilla.fenix.tor.UrlQuickLoadViewModel
|
159 | 159 | import org.mozilla.geckoview.TorAndroidIntegration
|
160 | 160 | import org.mozilla.geckoview.TorConnectStage
|
161 | +import kotlin.system.exitProcess
|
|
161 | 162 | |
162 | 163 | /**
|
163 | 164 | * The main activity of the application. The application is primarily a single Activity (this one)
|
... | ... | @@ -653,22 +654,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorAn |
653 | 654 | if (this !is ExternalAppBrowserActivity && !activityStartedWithLink) {
|
654 | 655 | stopMediaSession()
|
655 | 656 | }
|
656 | - |
|
657 | - if (isFinishing && !(application as FenixApplication).isTerminating()) {
|
|
658 | - // We assume the Activity is being destroyed because the user
|
|
659 | - // swiped away the app on the Recent screen. When this happens,
|
|
660 | - // we assume the user expects the entire Application is destroyed
|
|
661 | - // and not only the top Activity/Task. Therefore we kill the
|
|
662 | - // underlying Application, as well.
|
|
663 | - (application as FenixApplication).terminate()
|
|
664 | - if (settings().useHtmlConnectionUi) {
|
|
665 | - val engine = components.core.engine
|
|
666 | - if (engine is GeckoEngine) {
|
|
667 | - val torIntegration = engine.getTorIntegrationController()
|
|
668 | - torIntegration.unregisterBootstrapStateChangeListener(this)
|
|
669 | - }
|
|
670 | - }
|
|
671 | - }
|
|
672 | 657 | }
|
673 | 658 | |
674 | 659 | final override fun onConfigurationChanged(newConfig: Configuration) {
|
... | ... | @@ -1453,6 +1438,11 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorAn |
1453 | 1438 | private const val PWA_RECENTLY_USED_THRESHOLD = DateUtils.DAY_IN_MILLIS * 30L
|
1454 | 1439 | }
|
1455 | 1440 | |
1441 | + fun shutDown() : Nothing {
|
|
1442 | + finishAndRemoveTask()
|
|
1443 | + exitProcess(0)
|
|
1444 | + }
|
|
1445 | + |
|
1456 | 1446 | override fun onBootstrapStateChange(state: String) = Unit
|
1457 | 1447 | override fun onBootstrapStageChange(stage: TorConnectStage) = Unit
|
1458 | 1448 | override fun onBootstrapProgress(progress: Double, hasWarnings: Boolean) = Unit
|
... | ... | @@ -1394,7 +1394,6 @@ class HomeFragment : Fragment(), UserInteractionHandler { |
1394 | 1394 | }
|
1395 | 1395 | |
1396 | 1396 | override fun onBackPressed(): Boolean {
|
1397 | - requireActivity().finish()
|
|
1398 | - return true
|
|
1397 | + (requireActivity() as HomeActivity).shutDown()
|
|
1399 | 1398 | }
|
1400 | 1399 | } |
... | ... | @@ -149,7 +149,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
149 | 149 | private fun setBackButton(screen: ConnectAssistUiState) {
|
150 | 150 | binding.backButton.visibility = if (screen.backButtonVisible) View.VISIBLE else View.INVISIBLE
|
151 | 151 | binding.backButton.setOnClickListener {
|
152 | - torConnectionAssistViewModel.handleBackButtonPressed()
|
|
152 | + onBackPressed()
|
|
153 | 153 | }
|
154 | 154 | }
|
155 | 155 | |
... | ... | @@ -314,7 +314,8 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { |
314 | 314 | }
|
315 | 315 | |
316 | 316 | override fun onBackPressed(): Boolean {
|
317 | - return torConnectionAssistViewModel.handleBackButtonPressed()
|
|
317 | + torConnectionAssistViewModel.handleBackButtonPressed(requireActivity() as HomeActivity)
|
|
318 | + return true
|
|
318 | 319 | }
|
319 | 320 | |
320 | 321 | } |
... | ... | @@ -10,6 +10,7 @@ import androidx.lifecycle.AndroidViewModel |
10 | 10 | import androidx.lifecycle.MutableLiveData
|
11 | 11 | import kotlinx.coroutines.flow.MutableStateFlow
|
12 | 12 | import kotlinx.coroutines.flow.StateFlow
|
13 | +import org.mozilla.fenix.HomeActivity
|
|
13 | 14 | import org.mozilla.fenix.ext.components
|
14 | 15 | |
15 | 16 | class TorConnectionAssistViewModel(
|
... | ... | @@ -150,10 +151,10 @@ class TorConnectionAssistViewModel( |
150 | 151 | return true
|
151 | 152 | }
|
152 | 153 | |
153 | - fun handleBackButtonPressed(): Boolean {
|
|
154 | + fun handleBackButtonPressed(homeActivity: HomeActivity) {
|
|
154 | 155 | when (torConnectScreen.value) {
|
155 | - ConnectAssistUiState.Splash -> return false
|
|
156 | - ConnectAssistUiState.Configuring -> return false
|
|
156 | + ConnectAssistUiState.Splash -> homeActivity.shutDown()
|
|
157 | + ConnectAssistUiState.Configuring -> homeActivity.shutDown()
|
|
157 | 158 | ConnectAssistUiState.Connecting -> cancelTorBootstrap()
|
158 | 159 | ConnectAssistUiState.InternetError -> {
|
159 | 160 | _torController.lastKnownError = null
|
... | ... | @@ -191,6 +192,5 @@ class TorConnectionAssistViewModel( |
191 | 192 | _torConnectScreen.value = ConnectAssistUiState.LocationCheck
|
192 | 193 | }
|
193 | 194 | }
|
194 | - return true
|
|
195 | 195 | }
|
196 | 196 | } |