From: Tobias Brunner Date: Mon, 19 Oct 2020 14:46:22 +0000 (+0200) Subject: android: Handle restarts of control activity with power whitelist dialog better X-Git-Tag: 5.9.1rc1~4^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=264435f626b0eee97587cad455770d427ccb4836;p=thirdparty%2Fstrongswan.git 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. --- 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(); }