]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Avoid races between FragmentManager and state saving
authorTobias Brunner <tobias@strongswan.org>
Thu, 28 Apr 2016 17:35:56 +0000 (19:35 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 2 May 2016 16:38:15 +0000 (18:38 +0200)
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.

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

index bf5eaf64d87a95b1aa49bb155451b6c71880286b..ab8dfc2de6adee33533df94cc2602ad66c96902d 100644 (file)
@@ -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);