From f9ec16f9c03545d2b4d0d5a40f23e28bd1826d5f Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 3 Feb 2011 17:05:46 +0900 Subject: [PATCH] Kill the process when the debug mode is updated. Killing the process allows for some settings that are read only on service start up to be correctly read again. Change-Id: Ia48f2ca4760a530ac47b727f290d606715cb6bde --- .../com/android/inputmethod/latin/DebugSettings.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java index 03211f36b..b23fe9fe8 100644 --- a/java/src/com/android/inputmethod/latin/DebugSettings.java +++ b/java/src/com/android/inputmethod/latin/DebugSettings.java @@ -20,6 +20,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; +import android.os.Process; import android.preference.CheckBoxPreference; import android.preference.PreferenceActivity; import android.util.Log; @@ -31,6 +32,7 @@ public class DebugSettings extends PreferenceActivity private static final String DEBUG_MODE_KEY = "debug_mode"; private CheckBoxPreference mDebugMode; + private boolean serviceNeedsRestart = false; @Override protected void onCreate(Bundle icicle) { @@ -39,16 +41,24 @@ public class DebugSettings extends PreferenceActivity SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); prefs.registerOnSharedPreferenceChangeListener(this); + serviceNeedsRestart = false; mDebugMode = (CheckBoxPreference) findPreference(DEBUG_MODE_KEY); updateDebugMode(); } + @Override + protected void onStop() { + super.onStop(); + if (serviceNeedsRestart) Process.killProcess(Process.myPid()); + } + @Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key.equals(DEBUG_MODE_KEY)) { if (mDebugMode != null) { mDebugMode.setChecked(prefs.getBoolean(DEBUG_MODE_KEY, false)); updateDebugMode(); + serviceNeedsRestart = true; } } }