Fix to not lose state when saving a deactivated fragment.

Also deactivating a fragment shouldn't put it in the exiting state.

Change-Id: I514f3589ee7bbbee131cd7b4a48803e99b212bd0
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 2164ada..3b2e108 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -1109,7 +1109,6 @@
                     mNeedMenuInvalidate = true;
                 }
                 fragment.mAdded = false;
-                fragment.mRemoving = true;
                 moveToState(fragment, Fragment.CREATED, transition, transitionStyle);
             }
         }
@@ -1122,7 +1121,6 @@
             if (!fragment.mAdded) {
                 mAdded.add(fragment);
                 fragment.mAdded = true;
-                fragment.mRemoving = false;
                 if (fragment.mHasMenu) {
                     mNeedMenuInvalidate = true;
                 }
@@ -1435,13 +1433,13 @@
 
         if (f.mView != null) {
             saveFragmentViewState(f);
-            if (f.mSavedViewState != null) {
-                if (result == null) {
-                    result = new Bundle();
-                }
-                result.putSparseParcelableArray(
-                        FragmentManagerImpl.VIEW_STATE_TAG, f.mSavedViewState);
+        }
+        if (f.mSavedViewState != null) {
+            if (result == null) {
+                result = new Bundle();
             }
+            result.putSparseParcelableArray(
+                    FragmentManagerImpl.VIEW_STATE_TAG, f.mSavedViewState);
         }
 
         return result;