use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.
the class InputMethodUtils method setNonSelectedSystemImesDisabledUntilUsed.
public static void setNonSelectedSystemImesDisabledUntilUsed(PackageManager packageManager, List<InputMethodInfo> enabledImis) {
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);
} catch (NameNotFoundException e) {
Slog.w(TAG, "NameNotFoundException: " + packageName, e);
}
if (ai == null) {
// No app found for packageName
continue;
}
final boolean isSystemPackage = (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
if (!isSystemPackage) {
continue;
}
setDisabledUntilUsed(packageManager, packageName);
}
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by AOSPA.
the class InputMethodUtilsTest method createDummyInputMethodInfo.
private static InputMethodInfo createDummyInputMethodInfo(String packageName, String name, CharSequence label, boolean isAuxIme, boolean isDefault, List<InputMethodSubtype> subtypes) {
final ResolveInfo ri = new ResolveInfo();
final ServiceInfo si = new ServiceInfo();
final ApplicationInfo ai = new ApplicationInfo();
ai.packageName = packageName;
ai.enabled = true;
ai.flags |= ApplicationInfo.FLAG_SYSTEM;
si.applicationInfo = ai;
si.enabled = true;
si.packageName = packageName;
si.name = name;
si.exported = true;
si.nonLocalizedLabel = label;
ri.serviceInfo = si;
return new InputMethodInfo(ri, isAuxIme, "", subtypes, 1, isDefault);
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method buildInputMethodListLocked.
void buildInputMethodListLocked(boolean resetDefaultEnabledIme) {
if (DEBUG) {
Slog.d(TAG, "--- re-buildInputMethodList reset = " + resetDefaultEnabledIme + " \n ------ caller=" + Debug.getCallers(10));
}
mMethodList.clear();
mMethodMap.clear();
// Use for queryIntentServicesAsUser
final PackageManager pm = mContext.getPackageManager();
// Note: We do not specify PackageManager.MATCH_ENCRYPTION_* flags here because the default
// behavior of PackageManager is exactly what we want. It by default picks up appropriate
// services depending on the unlock state for the specified user.
final List<ResolveInfo> services = pm.queryIntentServicesAsUser(new Intent(InputMethod.SERVICE_INTERFACE), PackageManager.GET_META_DATA | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS, mSettings.getCurrentUserId());
final HashMap<String, List<InputMethodSubtype>> additionalSubtypes = mFileManager.getAllAdditionalInputMethodSubtypes();
for (int i = 0; i < services.size(); ++i) {
ResolveInfo ri = services.get(i);
ServiceInfo si = ri.serviceInfo;
ComponentName compName = new ComponentName(si.packageName, si.name);
if (!android.Manifest.permission.BIND_INPUT_METHOD.equals(si.permission)) {
Slog.w(TAG, "Skipping input method " + compName + ": it does not require the permission " + android.Manifest.permission.BIND_INPUT_METHOD);
continue;
}
if (DEBUG)
Slog.d(TAG, "Checking " + compName);
try {
InputMethodInfo p = new InputMethodInfo(mContext, ri, additionalSubtypes);
mMethodList.add(p);
final String id = p.getId();
mMethodMap.put(id, p);
if (DEBUG) {
Slog.d(TAG, "Found an input method " + p);
}
} catch (Exception e) {
Slog.wtf(TAG, "Unable to load input method " + compName, e);
}
}
// TODO: The following code should find better place to live.
if (!resetDefaultEnabledIme) {
boolean enabledImeFound = false;
final List<InputMethodInfo> enabledImes = mSettings.getEnabledInputMethodListLocked();
final int N = enabledImes.size();
for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = enabledImes.get(i);
if (mMethodList.contains(imi)) {
enabledImeFound = true;
break;
}
}
if (!enabledImeFound) {
Slog.i(TAG, "All the enabled IMEs are gone. Reset default enabled IMEs.");
resetDefaultEnabledIme = true;
resetSelectedInputMethodAndSubtypeLocked("");
}
}
if (resetDefaultEnabledIme) {
final ArrayList<InputMethodInfo> defaultEnabledIme = InputMethodUtils.getDefaultEnabledImes(mContext, mSystemReady, mMethodList);
final int N = defaultEnabledIme.size();
for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = defaultEnabledIme.get(i);
if (DEBUG) {
Slog.d(TAG, "--- enable ime = " + imi);
}
setInputMethodEnabledLocked(imi.getId(), true);
}
}
final String defaultImiId = mSettings.getSelectedInputMethod();
if (!TextUtils.isEmpty(defaultImiId)) {
if (!mMethodMap.containsKey(defaultImiId)) {
Slog.w(TAG, "Default IME is uninstalled. Choose new default IME.");
if (chooseNewDefaultIMELocked()) {
updateInputMethodsFromSettingsLocked(true);
}
} else {
// Double check that the default IME is certainly enabled.
setInputMethodEnabledLocked(defaultImiId, true);
}
}
// Here is not the perfect place to reset the switching controller. Ideally
// mSwitchingController and mSettings should be able to share the same state.
// TODO: Make sure that mSwitchingController and mSettings are sharing the
// the same enabled IMEs list.
mSwitchingController.resetCircularListLocked(mContext);
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method dump.
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump InputMethodManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
return;
}
IInputMethod method;
ClientState client;
ClientState focusedWindowClient;
final Printer p = new PrintWriterPrinter(pw);
synchronized (mMethodMap) {
p.println("Current Input Method Manager state:");
int N = mMethodList.size();
p.println(" Input Methods:");
for (int i = 0; i < N; i++) {
InputMethodInfo info = mMethodList.get(i);
p.println(" InputMethod #" + i + ":");
info.dump(p, " ");
}
p.println(" Clients:");
for (ClientState ci : mClients.values()) {
p.println(" Client " + ci + ":");
p.println(" client=" + ci.client);
p.println(" inputContext=" + ci.inputContext);
p.println(" sessionRequested=" + ci.sessionRequested);
p.println(" curSession=" + ci.curSession);
}
p.println(" mCurMethodId=" + mCurMethodId);
client = mCurClient;
p.println(" mCurClient=" + client + " mCurSeq=" + mCurSeq);
p.println(" mCurFocusedWindow=" + mCurFocusedWindow);
focusedWindowClient = mCurFocusedWindowClient;
p.println(" mCurFocusedWindowClient=" + focusedWindowClient);
p.println(" mCurId=" + mCurId + " mHaveConnect=" + mHaveConnection + " mBoundToMethod=" + mBoundToMethod);
p.println(" mCurToken=" + mCurToken);
p.println(" mCurIntent=" + mCurIntent);
method = mCurMethod;
p.println(" mCurMethod=" + mCurMethod);
p.println(" mEnabledSession=" + mEnabledSession);
p.println(" mImeWindowVis=" + imeWindowStatusToString(mImeWindowVis));
p.println(" mShowRequested=" + mShowRequested + " mShowExplicitlyRequested=" + mShowExplicitlyRequested + " mShowForced=" + mShowForced + " mInputShown=" + mInputShown);
p.println(" mCurUserActionNotificationSequenceNumber=" + mCurUserActionNotificationSequenceNumber);
p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mIsInteractive);
p.println(" mSettingsObserver=" + mSettingsObserver);
p.println(" mSwitchingController:");
mSwitchingController.dump(p);
p.println(" mSettings:");
mSettings.dumpLocked(p, " ");
}
p.println(" ");
if (client != null) {
pw.flush();
try {
client.client.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method client dead: " + e);
}
} else {
p.println("No input method client.");
}
if (focusedWindowClient != null && client != focusedWindowClient) {
p.println(" ");
p.println("Warning: Current input method client doesn't match the last focused. " + "window.");
p.println("Dumping input method client in the last focused window just in case.");
p.println(" ");
pw.flush();
try {
focusedWindowClient.client.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method client in focused window dead: " + e);
}
}
p.println(" ");
if (method != null) {
pw.flush();
try {
method.asBinder().dump(fd, args);
} catch (RemoteException e) {
p.println("Input method service dead: " + e);
}
} else {
p.println("No input method service.");
}
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by AOSPA.
the class KeyguardPasswordView method hasMultipleEnabledIMEsOrSubtypes.
/**
* Method adapted from com.android.inputmethod.latin.Utils
*
* @param imm The input method manager
* @param shouldIncludeAuxiliarySubtypes
* @return true if we have multiple IMEs to choose from
*/
private boolean hasMultipleEnabledIMEsOrSubtypes(InputMethodManager imm, final boolean shouldIncludeAuxiliarySubtypes) {
final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
// Number of the filtered IMEs
int filteredImisCount = 0;
for (InputMethodInfo imi : enabledImis) {
// We can return true immediately after we find two or more filtered IMEs.
if (filteredImisCount > 1)
return true;
final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
// IMEs that have no subtypes should be counted.
if (subtypes.isEmpty()) {
++filteredImisCount;
continue;
}
int auxCount = 0;
for (InputMethodSubtype subtype : subtypes) {
if (subtype.isAuxiliary()) {
++auxCount;
}
}
final int nonAuxCount = subtypes.size() - auxCount;
// subtypes should be counted as well.
if (nonAuxCount > 0 || (shouldIncludeAuxiliarySubtypes && auxCount > 1)) {
++filteredImisCount;
continue;
}
}
return filteredImisCount > 1 || // input method subtype (The current IME should be LatinIME.)
imm.getEnabledInputMethodSubtypeList(null, false).size() > 1;
}
Aggregations