am 9f9f5621: am 0737b164: Merge change I959a6f46 into eclair

Merge commit '9f9f56212610ddd69c8af8ddeeed39265c0e58e1' into eclair-mr2-plus-aosp

* commit '9f9f56212610ddd69c8af8ddeeed39265c0e58e1':
  Fix bug	2194213: Non-default system IMEs are enabled, but not initially shown in input method switcher.
This commit is contained in:
Brandon Ballinger
2009-10-22 11:03:16 -07:00
committed by Android Git Automerger

View File

@@ -41,6 +41,7 @@ import android.content.IntentFilter;
import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnCancelListener;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo;
@@ -366,16 +367,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
// Uh oh, current input method is no longer around! // Uh oh, current input method is no longer around!
// Pick another one... // Pick another one...
Log.i(TAG, "Current input method removed: " + curInputMethodId); Log.i(TAG, "Current input method removed: " + curInputMethodId);
List<InputMethodInfo> enabled = getEnabledInputMethodListLocked(); if (!chooseNewDefaultIME()) {
if (enabled != null && enabled.size() > 0) {
changed = true;
curIm = enabled.get(0);
curInputMethodId = curIm.getId();
Log.i(TAG, "Switching to: " + curInputMethodId);
Settings.Secure.putString(mContext.getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD,
curInputMethodId);
} else if (curIm != null) {
changed = true; changed = true;
curIm = null; curIm = null;
curInputMethodId = ""; curInputMethodId = "";
@@ -389,16 +381,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} else if (curIm == null) { } else if (curIm == null) {
// We currently don't have a default input method... is // We currently don't have a default input method... is
// one now available? // one now available?
List<InputMethodInfo> enabled = getEnabledInputMethodListLocked(); changed = chooseNewDefaultIME();
if (enabled != null && enabled.size() > 0) {
changed = true;
curIm = enabled.get(0);
curInputMethodId = curIm.getId();
Log.i(TAG, "New default input method: " + curInputMethodId);
Settings.Secure.putString(mContext.getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD,
curInputMethodId);
}
} }
if (changed) { if (changed) {
@@ -1369,6 +1352,23 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return false; return false;
} }
private boolean isSystemIme(InputMethodInfo inputMethod) {
return (inputMethod.getServiceInfo().applicationInfo.flags
& ApplicationInfo.FLAG_SYSTEM) != 0;
}
private boolean chooseNewDefaultIME() {
List<InputMethodInfo> enabled = getEnabledInputMethodListLocked();
if (enabled != null && enabled.size() > 0) {
Settings.Secure.putString(mContext.getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD,
enabled.get(0).getId());
return true;
}
return false;
}
void buildInputMethodListLocked(ArrayList<InputMethodInfo> list, void buildInputMethodListLocked(ArrayList<InputMethodInfo> list,
HashMap<String, InputMethodInfo> map) { HashMap<String, InputMethodInfo> map) {
list.clear(); list.clear();
@@ -1399,6 +1399,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
list.add(p); list.add(p);
map.put(p.getId(), p); map.put(p.getId(), p);
// System IMEs are enabled by default
if (isSystemIme(p)) {
setInputMethodEnabled(p.getId(), true);
}
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "Found a third-party input method " + p); Log.d(TAG, "Found a third-party input method " + p);
} }
@@ -1409,6 +1414,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Log.w(TAG, "Unable to load input method " + compName, e); Log.w(TAG, "Unable to load input method " + compName, e);
} }
} }
String defaultIme = Settings.Secure.getString(mContext
.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
if (!map.containsKey(defaultIme)) {
if (chooseNewDefaultIME()) {
updateFromSettingsLocked();
}
}
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------