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
This commit is contained in:
parent
ea55bf5df7
commit
f9ec16f9c0
1 changed files with 10 additions and 0 deletions
|
@ -20,6 +20,7 @@ import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Process;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -31,6 +32,7 @@ public class DebugSettings extends PreferenceActivity
|
||||||
private static final String DEBUG_MODE_KEY = "debug_mode";
|
private static final String DEBUG_MODE_KEY = "debug_mode";
|
||||||
|
|
||||||
private CheckBoxPreference mDebugMode;
|
private CheckBoxPreference mDebugMode;
|
||||||
|
private boolean serviceNeedsRestart = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
|
@ -39,16 +41,24 @@ public class DebugSettings extends PreferenceActivity
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
serviceNeedsRestart = false;
|
||||||
mDebugMode = (CheckBoxPreference) findPreference(DEBUG_MODE_KEY);
|
mDebugMode = (CheckBoxPreference) findPreference(DEBUG_MODE_KEY);
|
||||||
updateDebugMode();
|
updateDebugMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
if (serviceNeedsRestart) Process.killProcess(Process.myPid());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
if (key.equals(DEBUG_MODE_KEY)) {
|
if (key.equals(DEBUG_MODE_KEY)) {
|
||||||
if (mDebugMode != null) {
|
if (mDebugMode != null) {
|
||||||
mDebugMode.setChecked(prefs.getBoolean(DEBUG_MODE_KEY, false));
|
mDebugMode.setChecked(prefs.getBoolean(DEBUG_MODE_KEY, false));
|
||||||
updateDebugMode();
|
updateDebugMode();
|
||||||
|
serviceNeedsRestart = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue