Dan Ballard pushed to branch tor-browser-140.2.0esr-15.0-1 at The Tor Project / Applications / Tor Browser
Commits:
-
1df86592
by clairehurst at 2025-08-26T14:27:58-07:00
3 changed files:
- mobile/android/android-components/components/support/base/src/main/java/mozilla/components/support/base/android/NotificationsDelegate.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/session/PrivateNotificationService.kt
Changes:
| ... | ... | @@ -33,6 +33,15 @@ class NotificationsDelegate( |
| 33 | 33 | var isRequestingPermission: Boolean = false
|
| 34 | 34 | private set
|
| 35 | 35 | |
| 36 | + /**
|
|
| 37 | + * Defaults to true, normal behavior is to destroy the app when OnDestroy is called with isFinishing set to true
|
|
| 38 | + *
|
|
| 39 | + * A value of false indicates that the notification was just swiped away and the app should not shut down on it's behalf
|
|
| 40 | + *
|
|
| 41 | + * Workaround to make swiping the notification away not shutdown the app
|
|
| 42 | + */
|
|
| 43 | + var shouldShutDownWithOnDestroyWhenIsFinishing: Boolean = true
|
|
| 44 | + |
|
| 36 | 45 | @VisibleForTesting
|
| 37 | 46 | internal var permissionRequestsCount: Int = 0
|
| 38 | 47 |
| ... | ... | @@ -821,10 +821,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorAn |
| 821 | 821 | |
| 822 | 822 | super.onDestroy()
|
| 823 | 823 | |
| 824 | - if (isFinishing) {
|
|
| 825 | - exitProcess(0)
|
|
| 826 | - }
|
|
| 827 | - |
|
| 828 | 824 | // Diagnostic breadcrumb for "Display already aquired" crash:
|
| 829 | 825 | // https://github.com/mozilla-mobile/android-components/issues/7960
|
| 830 | 826 | breadcrumb(
|
| ... | ... | @@ -852,6 +848,16 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorAn |
| 852 | 848 | stopMediaSession()
|
| 853 | 849 | }
|
| 854 | 850 | |
| 851 | + if (applicationContext.components.notificationsDelegate.shouldShutDownWithOnDestroyWhenIsFinishing) {
|
|
| 852 | + if (isFinishing) {
|
|
| 853 | + shutDown()
|
|
| 854 | + }
|
|
| 855 | + } else {
|
|
| 856 | + // We only want to not shut down when the notification is swiped away,
|
|
| 857 | + // if we do not reset this value
|
|
| 858 | + applicationContext.components.notificationsDelegate.shouldShutDownWithOnDestroyWhenIsFinishing = true
|
|
| 859 | + }
|
|
| 860 | + |
|
| 855 | 861 | components.core.engine.profiler?.addMarker(
|
| 856 | 862 | MarkersActivityLifecycleCallbacks.MARKER_NAME,
|
| 857 | 863 | startTimeProfiler,
|
| ... | ... | @@ -79,6 +79,7 @@ class PrivateNotificationService : AbstractPrivateNotificationService() { |
| 79 | 79 | @SuppressLint("MissingSuperCall")
|
| 80 | 80 | override fun erasePrivateTabs() {
|
| 81 | 81 | val inPrivateMode = store.state.selectedTab?.content?.private ?: false
|
| 82 | + notificationsDelegate.shouldShutDownWithOnDestroyWhenIsFinishing = false
|
|
| 82 | 83 | |
| 83 | 84 | // Trigger use case directly for now (instead of calling super.erasePrivateTabs)
|
| 84 | 85 | // as otherwise SessionManager and the store will be out of sync.
|