Search in sources :

Example 31 with SpellCheckerInfo

use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by AOSPA.

the class TextServicesManagerService 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 TextServicesManagerService from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    synchronized (mSpellCheckerMap) {
        pw.println("Current Text Services Manager state:");
        pw.println("  Spell Checkers:");
        int spellCheckerIndex = 0;
        for (final SpellCheckerInfo info : mSpellCheckerMap.values()) {
            pw.println("  Spell Checker #" + spellCheckerIndex);
            info.dump(pw, "    ");
            ++spellCheckerIndex;
        }
        pw.println("");
        pw.println("  Spell Checker Bind Groups:");
        for (final Map.Entry<String, SpellCheckerBindGroup> ent : mSpellCheckerBindGroups.entrySet()) {
            final SpellCheckerBindGroup grp = ent.getValue();
            pw.println("    " + ent.getKey() + " " + grp + ":");
            pw.println("      " + "mInternalConnection=" + grp.mInternalConnection);
            pw.println("      " + "mSpellChecker=" + grp.mSpellChecker);
            pw.println("      " + "mBound=" + grp.mBound + " mConnected=" + grp.mConnected);
            final int N = grp.mListeners.size();
            for (int i = 0; i < N; i++) {
                final InternalDeathRecipient listener = grp.mListeners.get(i);
                pw.println("      " + "Listener #" + i + ":");
                pw.println("        " + "mTsListener=" + listener.mTsListener);
                pw.println("        " + "mScListener=" + listener.mScListener);
                pw.println("        " + "mGroup=" + listener.mGroup);
                pw.println("        " + "mScLocale=" + listener.mScLocale + " mUid=" + listener.mUid);
            }
        }
        pw.println("");
        pw.println("  mSettings:");
        mSettings.dumpLocked(pw, "    ");
    }
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 32 with SpellCheckerInfo

use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by crdroidandroid.

the class TextServicesManagerService method findAvailSpellCheckerLocked.

private SpellCheckerInfo findAvailSpellCheckerLocked(String prefPackage) {
    final int spellCheckersCount = mSpellCheckerList.size();
    if (spellCheckersCount == 0) {
        Slog.w(TAG, "no available spell checker services found");
        return null;
    }
    if (prefPackage != null) {
        for (int i = 0; i < spellCheckersCount; ++i) {
            final SpellCheckerInfo sci = mSpellCheckerList.get(i);
            if (prefPackage.equals(sci.getPackageName())) {
                if (DBG) {
                    Slog.d(TAG, "findAvailSpellCheckerLocked: " + sci.getPackageName());
                }
                return sci;
            }
        }
    }
    // Look up a spell checker based on the system locale.
    // TODO: Still there is a room to improve in the following logic: e.g., check if the package
    // is pre-installed or not.
    final Locale systemLocal = mContext.getResources().getConfiguration().locale;
    final ArrayList<Locale> suitableLocales = InputMethodUtils.getSuitableLocalesForSpellChecker(systemLocal);
    if (DBG) {
        Slog.w(TAG, "findAvailSpellCheckerLocked suitableLocales=" + Arrays.toString(suitableLocales.toArray(new Locale[suitableLocales.size()])));
    }
    final int localeCount = suitableLocales.size();
    for (int localeIndex = 0; localeIndex < localeCount; ++localeIndex) {
        final Locale locale = suitableLocales.get(localeIndex);
        for (int spellCheckersIndex = 0; spellCheckersIndex < spellCheckersCount; ++spellCheckersIndex) {
            final SpellCheckerInfo info = mSpellCheckerList.get(spellCheckersIndex);
            final int subtypeCount = info.getSubtypeCount();
            for (int subtypeIndex = 0; subtypeIndex < subtypeCount; ++subtypeIndex) {
                final SpellCheckerSubtype subtype = info.getSubtypeAt(subtypeIndex);
                final Locale subtypeLocale = InputMethodUtils.constructLocaleFromString(subtype.getLocale());
                if (locale.equals(subtypeLocale)) {
                    // returning the first found one.
                    return info;
                }
            }
        }
    }
    if (spellCheckersCount > 1) {
        Slog.w(TAG, "more than one spell checker service found, picking first");
    }
    return mSpellCheckerList.get(0);
}
Also used : Locale(java.util.Locale) SpellCheckerSubtype(android.view.textservice.SpellCheckerSubtype) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 33 with SpellCheckerInfo

use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by crdroidandroid.

the class TextServicesManagerService method resetInternalState.

private void resetInternalState(@UserIdInt int userId) {
    final boolean useCopyOnWriteSettings = !mSystemReady || !mUserManager.isUserUnlockingOrUnlocked(userId);
    mSettings.switchCurrentUser(userId, useCopyOnWriteSettings);
    updateCurrentProfileIds();
    unbindServiceLocked();
    buildSpellCheckerMapLocked(mContext, mSpellCheckerList, mSpellCheckerMap, mSettings);
    SpellCheckerInfo sci = getCurrentSpellChecker(null);
    if (sci == null) {
        sci = findAvailSpellCheckerLocked(null);
        if (sci != null) {
            // Set the current spell checker if there is one or more spell checkers
            // available. In this case, "sci" is the first one in the available spell
            // checkers.
            setCurrentSpellCheckerLocked(sci.getId());
        }
    }
}
Also used : SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 34 with SpellCheckerInfo

use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by crdroidandroid.

the class TextServicesManagerService method setCurrentSpellCheckerLocked.

private void setCurrentSpellCheckerLocked(String sciId) {
    if (DBG) {
        Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
    }
    if (TextUtils.isEmpty(sciId) || !mSpellCheckerMap.containsKey(sciId))
        return;
    final SpellCheckerInfo currentSci = getCurrentSpellChecker(null);
    if (currentSci != null && currentSci.getId().equals(sciId)) {
        // Do nothing if the current spell checker is same as new spell checker.
        return;
    }
    final long ident = Binder.clearCallingIdentity();
    try {
        mSettings.putSelectedSpellChecker(sciId);
        setCurrentSpellCheckerSubtypeLocked(0);
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
Also used : SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 35 with SpellCheckerInfo

use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by ParanoidAndroid.

the class TextServicesManagerService method setCurrentSpellCheckerLocked.

private void setCurrentSpellCheckerLocked(String sciId) {
    if (DBG) {
        Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
    }
    if (TextUtils.isEmpty(sciId) || !mSpellCheckerMap.containsKey(sciId))
        return;
    final SpellCheckerInfo currentSci = getCurrentSpellChecker(null);
    if (currentSci != null && currentSci.getId().equals(sciId)) {
        // Do nothing if the current spell checker is same as new spell checker.
        return;
    }
    final long ident = Binder.clearCallingIdentity();
    try {
        mSettings.putSelectedSpellChecker(sciId);
        setCurrentSpellCheckerSubtypeLocked(0);
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
Also used : SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Aggregations

SpellCheckerInfo (android.view.textservice.SpellCheckerInfo)62 RemoteException (android.os.RemoteException)16 SpellCheckerSubtype (android.view.textservice.SpellCheckerSubtype)13 ServiceInfo (android.content.pm.ServiceInfo)11 Locale (java.util.Locale)10 Intent (android.content.Intent)7 ComponentName (android.content.ComponentName)6 ApplicationInfo (android.content.pm.ApplicationInfo)6 PackageManager (android.content.pm.PackageManager)6 ResolveInfo (android.content.pm.ResolveInfo)6 InputMethodInfo (android.view.inputmethod.InputMethodInfo)6 InputMethodManager (android.view.inputmethod.InputMethodManager)6 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)6 ISpellCheckerSession (com.android.internal.textservice.ISpellCheckerSession)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)6 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1