From ce022748c7acd738b0762dc2c578998cd74ef6ca Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 9 Mar 2012 10:15:24 +0900 Subject: [PATCH] Fix a crash Bug: 6137076 Change-Id: I05f9f72a2678d10d3400dab5fc71544276739dcf --- .../com/android/inputmethod/latin/LatinIME.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 273593dfb..ca38cdeec 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -535,10 +535,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar registerReceiver(mReceiver, filter); mVoiceProxy = VoiceProxy.init(this, prefs, mHandler); - final IntentFilter ringerModeFilter = new IntentFilter(); - ringerModeFilter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); - registerReceiver(mFeedbackManager, ringerModeFilter); - final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); @@ -551,11 +547,19 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar registerReceiver(mDictionaryPackInstallReceiver, newDictFilter); } + private void renewFeedbackReceiver() { + if (null != mFeedbackManager) unregisterReceiver(mFeedbackManager); + mFeedbackManager = new AudioAndHapticFeedbackManager(this, mSettingsValues); + final IntentFilter ringerModeFilter = new IntentFilter(); + ringerModeFilter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); + registerReceiver(mFeedbackManager, ringerModeFilter); + } + // Has to be package-visible for unit tests /* package */ void loadSettings() { if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mSettingsValues = new SettingsValues(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr()); - mFeedbackManager = new AudioAndHapticFeedbackManager(this, mSettingsValues); + renewFeedbackReceiver(); resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary()); }