[tbb-commits] [Git][tpo/applications/fenix][tor-browser-82.0.0b4-10.0-1] 2 commits: fixup! Bug 40028: Integrate Tor Controller into HomeFragment

Matthew Finkel gitlab at torproject.org
Fri Oct 23 14:11:54 UTC 2020



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


Commits:
a061d49c by Matthew Finkel at 2020-10-16T17:04:37+00:00
fixup! Bug 40028: Integrate Tor Controller into HomeFragment

Bug 40068: Tor Service closes when changing theme

- - - - -
e7ca4137 by Matthew Finkel at 2020-10-23T14:11:39+00:00
Merge branch 'bug_40068_01' into tor-browser-82.0.0b4-10.0-1

- - - - -


2 changed files:

- app/src/main/java/org/mozilla/fenix/FenixApplication.kt
- app/src/main/java/org/mozilla/fenix/HomeActivity.kt


Changes:

=====================================
app/src/main/java/org/mozilla/fenix/FenixApplication.kt
=====================================
@@ -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() {


=====================================
app/src/main/java/org/mozilla/fenix/HomeActivity.kt
=====================================
@@ -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()
     }
 



View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/compare/8c969c0c9aa529dbc601cfe85b8ff058f4c54f5d...e7ca4137fe8e0322b2df55f7863f78937f02e6e1

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/compare/8c969c0c9aa529dbc601cfe85b8ff058f4c54f5d...e7ca4137fe8e0322b2df55f7863f78937f02e6e1
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20201023/7accb713/attachment-0001.htm>


More information about the tbb-commits mailing list