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, " ");
}
}
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);
}
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());
}
}
}
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);
}
}
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);
}
}
Aggregations