From 1ee1368e18f5264704cbe58ad36408394c867ab9 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 27 Sep 2019 13:07:43 +0530 Subject: Fix activity leak on Android Q This workaround was discussed at https://twitter.com/Piwai/status/1169274622614704129 after Google had closed the issuetracker with a WONTFIX at https://issuetracker.google.com/issues/139738913. The situation has since changed with Google promising a fix on October's ASB but since we can't really know, patch this ourselves for the timebeing. Signed-off-by: Harsh Shandilya --- .../java/com/wireguard/android/activity/MainActivity.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/com/wireguard/android/activity/MainActivity.java b/app/src/main/java/com/wireguard/android/activity/MainActivity.java index ab9a4f8a..0a1dc0be 100644 --- a/app/src/main/java/com/wireguard/android/activity/MainActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/MainActivity.java @@ -53,7 +53,16 @@ public class MainActivity extends BaseActivity setSelectedTunnel(null); return; } - super.onBackPressed(); + if (isTaskRoot()) { + // @{link TunnelDetailFragment} is in foreground + if (backStackEntries == 2) { + getSupportFragmentManager().popBackStack(); + } else if (backStackEntries == 0) { + finishAfterTransition(); + } + } else { + super.onBackPressed(); + } } @Override public void onBackStackChanged() { -- cgit v1.2.3