diff options
author | Amith Yamasani <yamasani@google.com> | 2012-05-04 10:30:18 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-05-07 17:56:14 -0700 |
commit | f6d8961843f5b977640146dd5dc8872eaab60ce7 (patch) | |
tree | 6817e3f41163580621d391a2201680c0da3e97f7 /src/com/android/settings/inputmethod | |
parent | 8f04a6fb139b9330710b0bb4c714049452d63a48 (diff) | |
download | packages_apps_settings-f6d8961843f5b977640146dd5dc8872eaab60ce7.zip packages_apps_settings-f6d8961843f5b977640146dd5dc8872eaab60ce7.tar.gz packages_apps_settings-f6d8961843f5b977640146dd5dc8872eaab60ce7.tar.bz2 |
Reduce the amount of I/O done on the UI thread.
There was unnecessary saving of IME settings when changing the state
of the checkboxes, causing ANRs when monkeys are switching between
Settings fragments quickly while other background activity is using
I/O as well. In fact, all I/O should be removed, but this change at least
reduces some of it.
Potential fix for:
Bug: 6414289
Change-Id: Ice96f0f9d921128b27ddbe26519a6791d9f01c75
Diffstat (limited to 'src/com/android/settings/inputmethod')
-rw-r--r-- | src/com/android/settings/inputmethod/InputMethodPreference.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java index 90eef85..6402dff 100644 --- a/src/com/android/settings/inputmethod/InputMethodPreference.java +++ b/src/com/android/settings/inputmethod/InputMethodPreference.java @@ -66,10 +66,10 @@ public class InputMethodPreference extends CheckBoxPreference return; } if (isChecked()) { - setChecked(false); + setChecked(false, true /* save */); } else { if (mAlwaysChecked) { - setChecked(true); + setChecked(true, true /* save */); } else { showSecurityWarnDialog(mImi, InputMethodPreference.this); } @@ -222,14 +222,25 @@ public class InputMethodPreference extends CheckBoxPreference setSummary(summary); } - @Override - public void setChecked(boolean checked) { + /** + * Sets the checkbox state and optionally saves the settings. + * @param checked whether to check the box + * @param save whether to save IME settings + */ + public void setChecked(boolean checked, boolean save) { super.setChecked(checked); - saveImeSettings(); + if (save) { + saveImeSettings(); + } updateSummary(); } - private void showSecurityWarnDialog(InputMethodInfo imi, final CheckBoxPreference chkPref) { + @Override + public void setChecked(boolean checked) { + setChecked(checked, false); + } + + private void showSecurityWarnDialog(InputMethodInfo imi, final InputMethodPreference chkPref) { if (mDialog != null && mDialog.isShowing()) { mDialog.dismiss(); } @@ -241,7 +252,7 @@ public class InputMethodPreference extends CheckBoxPreference new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - chkPref.setChecked(true); + chkPref.setChecked(true, true); } }) .setNegativeButton(android.R.string.cancel, |