Matthew Finkel pushed to branch tor-browser-82.0.0b4-10.0-1 at The Tor Project / Applications / fenix

Commits:

2 changed files:

Changes:

  • app/src/main/java/org/mozilla/fenix/FenixApplication.kt
    ... ... @@ -67,6 +67,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
    67 67
     
    
    68 68
         private val logger = Logger("FenixApplication")
    
    69 69
     
    
    70
    +    var terminating = false
    
    71
    +
    
    70 72
         open val components by lazy { Components(this) }
    
    71 73
     
    
    72 74
         var visibilityLifecycleCallback: VisibilityLifecycleCallback? = null
    
    ... ... @@ -96,9 +98,19 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
    96 98
             setupInMainProcessOnly()
    
    97 99
         }
    
    98 100
     
    
    101
    +    fun isTerminating() = terminating
    
    102
    +
    
    103
    +    fun terminate() {
    
    104
    +        onTerminate()
    
    105
    +        System.exit(0)
    
    106
    +    }
    
    107
    +
    
    99 108
         override fun onTerminate() {
    
    109
    +        terminating = true
    
    110
    +
    
    100 111
             super.onTerminate()
    
    101 112
             components.torController.stop()
    
    113
    +        components.torController.stopTor()
    
    102 114
         }
    
    103 115
     
    
    104 116
         protected open fun initializeGlean() {
    

  • app/src/main/java/org/mozilla/fenix/HomeActivity.kt
    ... ... @@ -131,6 +131,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    131 131
     
    
    132 132
         private var isToolbarInflated = false
    
    133 133
     
    
    134
    +    private var isBeingRecreated = false
    
    135
    +
    
    134 136
         private val webExtensionPopupFeature by lazy {
    
    135 137
             WebExtensionPopupFeature(components.core.store, ::openPopup)
    
    136 138
         }
    
    ... ... @@ -362,10 +364,14 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    362 364
             )
    
    363 365
     
    
    364 366
             privateNotificationObserver?.stop()
    
    365
    -        components.torController.stopTor()
    
    366
    -        // Explicitly change our internal state because the status broadcast from tor-android-service may
    
    367
    -        // arrive after we unregister the broadcast listener when the app is exiting.
    
    368
    -        components.torController.setTorStopped()
    
    367
    +        if (!isBeingRecreated && !(application as FenixApplication).isTerminating()) {
    
    368
    +            // We assume the Activity is being destroyed because the user
    
    369
    +            // swiped away the app on the Recent screen. When this happens,
    
    370
    +            // we assume the user expects the entire Application is destroyed
    
    371
    +            // and not only the top Activity/Task. Therefore we kill the
    
    372
    +            // underlying Application, as well.
    
    373
    +            (application as FenixApplication).terminate()
    
    374
    +        }
    
    369 375
         }
    
    370 376
     
    
    371 377
         override fun onConfigurationChanged(newConfig: Configuration) {
    
    ... ... @@ -385,6 +391,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    385 391
                 message = "recreate()"
    
    386 392
             )
    
    387 393
     
    
    394
    +        isBeingRecreated = true
    
    395
    +
    
    388 396
             super.recreate()
    
    389 397
         }
    
    390 398