diff options
author | Yorke Lee <yorkelee@google.com> | 2014-10-28 11:51:40 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-10-28 14:06:44 -0700 |
commit | 19e68ca002b7586b84fcde5e32eca125e7a033ad (patch) | |
tree | 86982d613cfaa3ccdea38cf56a7d3fb82c80e06a /src | |
parent | 7d7591f5644d58f561d74fb0899a452d0dad7f1e (diff) |
Fix various IllegalStateExceptions in Dialer
Make sure to not commit any fragment transactions when
onSaveInstanceState has been called.
Bug: 18038718
Bug: 18142294
Bug: 18106980
Change-Id: I0755208ee6637431cb3e494b5494b1ccdd930489
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index aacf20844..e8cc45e24 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -176,6 +176,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private ListsFragment mListsFragment; + /** + * Tracks whether onSaveInstanceState has been called. If true, no fragment transactions can + * be commited. + */ + private boolean mStateSaved; private boolean mInDialpadSearch; private boolean mInRegularSearch; private boolean mClearSearchOnPause; @@ -460,6 +465,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override protected void onResume() { super.onResume(); + mStateSaved = false; if (mFirstLaunch) { displayFragment(getIntent()); } else if (!phoneIsInUse() && mInCallDialpadUp) { @@ -481,6 +487,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O hideDialpadAndSearchUi(); mClearSearchOnPause = false; } + if (mSlideOut.hasStarted() && !mSlideOut.hasEnded()) { + commitDialpadFragmentHide(); + } super.onPause(); } @@ -493,6 +502,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown); mActionBarController.saveInstanceState(outState); + mStateSaved = true; } @Override @@ -608,7 +618,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * @see #onDialpadShown */ private void showDialpadFragment(boolean animate) { - if (mIsDialpadShown) { + if (mIsDialpadShown || mStateSaved) { return; } mIsDialpadShown = true; @@ -684,10 +694,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * Finishes hiding the dialpad fragment after any animations are completed. */ private void commitDialpadFragmentHide() { - final FragmentTransaction ft = getFragmentManager().beginTransaction(); - ft.hide(mDialpadFragment); - ft.commit(); - + if (!mStateSaved && !mDialpadFragment.isHidden()) { + final FragmentTransaction ft = getFragmentManager().beginTransaction(); + ft.hide(mDialpadFragment); + ft.commit(); + } mFloatingActionButtonController.scaleIn(AnimUtils.NO_DELAY); } @@ -840,7 +851,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * Shows the search fragment */ private void enterSearchUi(boolean smartDialSearch, String query) { - if (getFragmentManager().isDestroyed()) { + if (mStateSaved || getFragmentManager().isDestroyed()) { // Weird race condition where fragment is doing work after the activity is destroyed // due to talkback being on (b/10209937). Just return since we can't do any // constructive here. @@ -893,7 +904,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private void exitSearchUi() { // See related bug in enterSearchUI(); - if (getFragmentManager().isDestroyed()) { + if (getFragmentManager().isDestroyed() || mStateSaved) { return; } @@ -923,6 +934,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void onBackPressed() { + if (mStateSaved) { + return; + } if (mIsDialpadShown) { if (TextUtils.isEmpty(mSearchQuery) || (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible() |