From: Tobias Brunner Date: Mon, 19 Oct 2020 15:41:52 +0000 (+0200) Subject: android: Prevent illegalStateException when showing power whitelist dialog X-Git-Tag: 5.9.1rc1~4^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80337f4f9d3d189b05b171db7f1d57a08cbfc7fa;p=thirdparty%2Fstrongswan.git android: Prevent illegalStateException when showing power whitelist dialog If the activity is not active when the service connection is established and handleIntent() is called, the activity's state is already saved and any fragment transaction would result in an illegalStateException due to state loss. We just ignore this and wait for another initiation attempt (via onNewIntent()). --- 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 c32c359620..5174cafb07 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 @@ -205,6 +205,12 @@ public class VpnProfileControlActivity extends AppCompatActivity if (!pm.isIgnoringBatteryOptimizations(this.getPackageName()) && !pref.getBoolean(Constants.PREF_IGNORE_POWER_WHITELIST, false)) { + if (getSupportFragmentManager().isStateSaved()) + { /* we might get called via service connection and manual onActivityResult() + * call when the activity is not active anymore and fragment transactions + * would cause an illegalStateException */ + return false; + } PowerWhitelistRequired whitelist = new PowerWhitelistRequired(); whitelist.show(getSupportFragmentManager(), DIALOG_TAG); return false;