From 264435f626b0eee97587cad455770d427ccb4836 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 19 Oct 2020 16:46:22 +0200 Subject: [PATCH] android: Handle restarts of control activity with power whitelist dialog better With the flag set, we basically ignore the resent intent, which is not ideal if we have not yet actually started another activity. The information dialog we show first would disappear when closing and reopening the app or even just rotating it (we hide all dialogs when receiving an intent), but since the flag was restored, the dialog was not shown again even when attempting to start other connections. --- .../strongswan/android/ui/VpnProfileControlActivity.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java index 6cf91a5f62..c32c359620 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java @@ -206,7 +206,6 @@ public class VpnProfileControlActivity extends AppCompatActivity !pref.getBoolean(Constants.PREF_IGNORE_POWER_WHITELIST, false)) { PowerWhitelistRequired whitelist = new PowerWhitelistRequired(); - mWaitingForResult = true; whitelist.show(getSupportFragmentManager(), DIALOG_TAG); return false; } @@ -588,9 +587,11 @@ public class VpnProfileControlActivity extends AppCompatActivity .setTitle(R.string.power_whitelist_title) .setMessage(R.string.power_whitelist_text) .setPositiveButton(android.R.string.ok, (dialog, id) -> { + VpnProfileControlActivity activity = (VpnProfileControlActivity)getActivity(); + activity.mWaitingForResult = true; Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, - Uri.parse("package:" + getActivity().getPackageName())); - getActivity().startActivityForResult(intent, ADD_TO_POWER_WHITELIST); + Uri.parse("package:" + activity.getPackageName())); + activity.startActivityForResult(intent, ADD_TO_POWER_WHITELIST); }).create(); } -- 2.47.2