From: Tobias Brunner Date: Thu, 28 Apr 2016 17:35:56 +0000 (+0200) Subject: android: Avoid races between FragmentManager and state saving X-Git-Tag: 5.4.1dr2~16^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ab8ec7ad0456979d254c59b69c1f5895730b089;p=thirdparty%2Fstrongswan.git android: Avoid races between FragmentManager and state saving onSaveInstanceState is apparently called after pausing the fragment and after that committing any FragmentTransactions causes an IllegalStateException. We could use commitAllowingStateLoss() but that's not really necessary as we don't need to update when we are not active anyway. We also don't update the view directly after registration as this happens asynchronously, i.e. we might be paused when it finishes. --- diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/ImcStateFragment.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/ImcStateFragment.java index bf5eaf64d8..ab8dfc2de6 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/ImcStateFragment.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/ImcStateFragment.java @@ -66,7 +66,6 @@ public class ImcStateFragment extends Fragment implements VpnStateListener { mService = ((VpnStateService.LocalBinder)service).getService(); mService.registerListener(ImcStateFragment.this); - updateView(); } }; @@ -147,9 +146,9 @@ public class ImcStateFragment extends Fragment implements VpnStateListener } @Override - public void onStart() + public void onResume() { - super.onStart(); + super.onResume(); if (mService != null) { mService.registerListener(this); @@ -158,9 +157,9 @@ public class ImcStateFragment extends Fragment implements VpnStateListener } @Override - public void onStop() + public void onPause() { - super.onStop(); + super.onPause(); if (mService != null) { mService.unregisterListener(this);