Merge "Fix a crash on a secondary user" into jb-mr2-dev

This commit is contained in:
Jean Chalard 2013-05-21 04:27:34 +00:00 committed by Android (Google) Code Review
commit ede3db51f0
2 changed files with 16 additions and 2 deletions

View file

@ -54,6 +54,13 @@ public final class RichInputMethodManager {
return sInstance;
}
// Caveat: This may cause IPC
public static boolean isInputMethodManagerValidForUserOfThisProcess(final Context context) {
// Basically called to check whether this IME has been triggered by the current user or not
return !((InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE)).
getInputMethodList().isEmpty();
}
public static void init(final Context context) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
sInstance.initInternal(context, prefs);

View file

@ -68,8 +68,15 @@ public final class LauncherIconVisibilityManager extends BroadcastReceiver {
// 1) the package has been re-installed, 2) the device has been booted,
// 3) a multiuser has been created.
// There is no good reason to keep the process alive if this IME isn't a current IME.
RichInputMethodManager.init(context);
if (!SetupActivity.isThisImeCurrent(context)) {
final boolean isCurrentImeOfCurrentUser;
if (RichInputMethodManager.isInputMethodManagerValidForUserOfThisProcess(context)) {
RichInputMethodManager.init(context);
isCurrentImeOfCurrentUser = SetupActivity.isThisImeCurrent(context);
} else {
isCurrentImeOfCurrentUser = false;
}
if (!isCurrentImeOfCurrentUser) {
final int myPid = Process.myPid();
Log.i(TAG, "Killing my process: pid=" + myPid);
Process.killProcess(myPid);