Fix issue #2967969: Crash rotating screen on "delete account" dialog

- Have PreferenceActivity save and restore its header state.
- Keep track of the current header selection.
- When headers are updated, try to retain the current header selection.

Also fix issue #2995541: Cannot add new contact.  We were not allowing
fragment transactions in some cases.

Change-Id: I4aa4c703ed5f4ecf9f425cd7eeea4740c6360ce9
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 97aa23e..2e8d682 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4204,6 +4204,7 @@
     }
     
     final void performStart() {
+        mFragments.mStateSaved = false;
         mCalled = false;
         mFragments.execPendingActions();
         mInstrumentation.callActivityOnStart(this);
@@ -4221,6 +4222,8 @@
     }
     
     final void performRestart() {
+        mFragments.mStateSaved = false;
+
         synchronized (mManagedCursors) {
             final int N = mManagedCursors.size();
             for (int i=0; i<N; i++) {
@@ -4359,6 +4362,7 @@
         if (Config.LOGV) Log.v(
             TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode
             + ", resCode=" + resultCode + ", data=" + data);
+        mFragments.mStateSaved = false;
         if (who == null) {
             onActivityResult(requestCode, resultCode, data);
         } else {