use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by crdroidandroid.
the class InputMethodUtils method setNonSelectedSystemImesDisabledUntilUsed.
public static void setNonSelectedSystemImesDisabledUntilUsed(IPackageManager packageManager, List<InputMethodInfo> enabledImis, int userId, String callingPackage) {
if (DEBUG) {
Slog.d(TAG, "setNonSelectedSystemImesDisabledUntilUsed");
}
final String[] systemImesDisabledUntilUsed = Resources.getSystem().getStringArray(com.android.internal.R.array.config_disabledUntilUsedPreinstalledImes);
if (systemImesDisabledUntilUsed == null || systemImesDisabledUntilUsed.length == 0) {
return;
}
// Only the current spell checker should be treated as an enabled one.
final SpellCheckerInfo currentSpellChecker = TextServicesManager.getInstance().getCurrentSpellChecker();
for (final String packageName : systemImesDisabledUntilUsed) {
if (DEBUG) {
Slog.d(TAG, "check " + packageName);
}
boolean enabledIme = false;
for (int j = 0; j < enabledImis.size(); ++j) {
final InputMethodInfo imi = enabledImis.get(j);
if (packageName.equals(imi.getPackageName())) {
enabledIme = true;
break;
}
}
if (enabledIme) {
// enabled ime. skip
continue;
}
if (currentSpellChecker != null && packageName.equals(currentSpellChecker.getPackageName())) {
// enabled spell checker. skip
if (DEBUG) {
Slog.d(TAG, packageName + " is the current spell checker. skip");
}
continue;
}
ApplicationInfo ai = null;
try {
ai = packageManager.getApplicationInfo(packageName, PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS, userId);
} catch (RemoteException e) {
Slog.w(TAG, "getApplicationInfo failed. packageName=" + packageName + " userId=" + userId, e);
continue;
}
if (ai == null) {
// No app found for packageName
continue;
}
final boolean isSystemPackage = (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
if (!isSystemPackage) {
continue;
}
setDisabledUntilUsed(packageManager, packageName, userId, callingPackage);
}
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by crdroidandroid.
the class InputMethodUtils method getMostApplicableDefaultIME.
public static InputMethodInfo getMostApplicableDefaultIME(List<InputMethodInfo> enabledImes) {
if (enabledImes == null || enabledImes.isEmpty()) {
return null;
}
// We'd prefer to fall back on a system IME, since that is safer.
int i = enabledImes.size();
int firstFoundSystemIme = -1;
while (i > 0) {
i--;
final InputMethodInfo imi = enabledImes.get(i);
if (imi.isAuxiliaryIme()) {
continue;
}
if (InputMethodUtils.isSystemIme(imi) && containsSubtypeOf(imi, ENGLISH_LOCALE, false, /* checkCountry */
SUBTYPE_MODE_KEYBOARD)) {
return imi;
}
if (firstFoundSystemIme < 0 && InputMethodUtils.isSystemIme(imi)) {
firstFoundSystemIme = i;
}
}
return enabledImes.get(Math.max(firstFoundSystemIme, 0));
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by crdroidandroid.
the class AppRestrictionsHelper method addSystemImes.
/**
* Find all pre-installed input methods that are marked as default
* and add them to an exclusion list so that they aren't
* presented to the user for toggling.
* Don't add non-default ones, as they may include other stuff that we
* don't need to auto-include.
* @param excludePackages the set of package names to append to
*/
private void addSystemImes(Set<String> excludePackages) {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> imis = imm.getInputMethodList();
for (InputMethodInfo imi : imis) {
try {
if (imi.isDefault(mContext) && isSystemPackage(imi.getPackageName())) {
excludePackages.add(imi.getPackageName());
}
} catch (Resources.NotFoundException rnfe) {
// Not default
}
}
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by crdroidandroid.
the class UiAutomatorTestCase method setDummyIme.
private void setDummyIme() throws RemoteException {
IInputMethodManager im = IInputMethodManager.Stub.asInterface(ServiceManager.getService(Context.INPUT_METHOD_SERVICE));
List<InputMethodInfo> infos = im.getInputMethodList();
String id = null;
for (InputMethodInfo info : infos) {
if (DUMMY_IME_PACKAGE.equals(info.getComponent().getPackageName())) {
id = info.getId();
}
}
if (id == null) {
throw new RuntimeException(String.format("Required testing fixture missing: IME package (%s)", DUMMY_IME_PACKAGE));
}
im.setInputMethod(null, id);
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by crdroidandroid.
the class InputMethodManagerService method getLastInputMethodSubtype.
@Override
public InputMethodSubtype getLastInputMethodSubtype() {
if (!calledFromValidUser()) {
return null;
}
synchronized (mMethodMap) {
final Pair<String, String> lastIme = mSettings.getLastInputMethodAndSubtypeLocked();
// TODO: Handle the case of the last IME with no subtypes
if (lastIme == null || TextUtils.isEmpty(lastIme.first) || TextUtils.isEmpty(lastIme.second))
return null;
final InputMethodInfo lastImi = mMethodMap.get(lastIme.first);
if (lastImi == null)
return null;
try {
final int lastSubtypeHash = Integer.parseInt(lastIme.second);
final int lastSubtypeId = InputMethodUtils.getSubtypeIdFromHashCode(lastImi, lastSubtypeHash);
if (lastSubtypeId < 0 || lastSubtypeId >= lastImi.getSubtypeCount()) {
return null;
}
return lastImi.getSubtypeAt(lastSubtypeId);
} catch (NumberFormatException e) {
return null;
}
}
}
Aggregations