]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Handle restarts of control activity with power whitelist dialog better
authorTobias Brunner <tobias@strongswan.org>
Mon, 19 Oct 2020 14:46:22 +0000 (16:46 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 29 Oct 2020 09:22:52 +0000 (10:22 +0100)
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.

src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java

index 6cf91a5f6243f6a27cf202a816f2a25eaac4d3ff..c32c3596204b0bc00db16a7c1abb920d26764a22 100644 (file)
@@ -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();
                }