Unverified Commit e7ca4137 authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Merge branch 'bug_40068_01' into tor-browser-82.0.0b4-10.0-1

parents 8c969c0c a061d49c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {

    private val logger = Logger("FenixApplication")

    var terminating = false

    open val components by lazy { Components(this) }

    var visibilityLifecycleCallback: VisibilityLifecycleCallback? = null
@@ -96,9 +98,19 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
        setupInMainProcessOnly()
    }

    fun isTerminating() = terminating

    fun terminate() {
        onTerminate()
        System.exit(0)
    }

    override fun onTerminate() {
        terminating = true

        super.onTerminate()
        components.torController.stop()
        components.torController.stopTor()
    }

    protected open fun initializeGlean() {
+12 −4
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {

    private var isToolbarInflated = false

    private var isBeingRecreated = false

    private val webExtensionPopupFeature by lazy {
        WebExtensionPopupFeature(components.core.store, ::openPopup)
    }
@@ -362,10 +364,14 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
        )

        privateNotificationObserver?.stop()
        components.torController.stopTor()
        // Explicitly change our internal state because the status broadcast from tor-android-service may
        // arrive after we unregister the broadcast listener when the app is exiting.
        components.torController.setTorStopped()
        if (!isBeingRecreated && !(application as FenixApplication).isTerminating()) {
            // We assume the Activity is being destroyed because the user
            // swiped away the app on the Recent screen. When this happens,
            // we assume the user expects the entire Application is destroyed
            // and not only the top Activity/Task. Therefore we kill the
            // underlying Application, as well.
            (application as FenixApplication).terminate()
        }
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
@@ -385,6 +391,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
            message = "recreate()"
        )

        isBeingRecreated = true

        super.recreate()
    }