Search in sources :

Example 6 with ISpellCheckerSession

use of com.android.internal.textservice.ISpellCheckerSession in project android_frameworks_base by ResurrectionRemix.

the class TextServicesManagerService method getSpellCheckerService.

@Override
public void getSpellCheckerService(String sciId, String locale, ITextServicesSessionListener tsListener, ISpellCheckerSessionListener scListener, Bundle bundle) {
    if (!calledFromValidUser()) {
        return;
    }
    if (!mSystemReady) {
        return;
    }
    if (TextUtils.isEmpty(sciId) || tsListener == null || scListener == null) {
        Slog.e(TAG, "getSpellCheckerService: Invalid input.");
        return;
    }
    synchronized (mSpellCheckerMap) {
        if (!mSpellCheckerMap.containsKey(sciId)) {
            return;
        }
        final SpellCheckerInfo sci = mSpellCheckerMap.get(sciId);
        final int uid = Binder.getCallingUid();
        if (mSpellCheckerBindGroups.containsKey(sciId)) {
            final SpellCheckerBindGroup bindGroup = mSpellCheckerBindGroups.get(sciId);
            if (bindGroup != null) {
                final InternalDeathRecipient recipient = mSpellCheckerBindGroups.get(sciId).addListener(tsListener, locale, scListener, uid, bundle);
                if (recipient == null) {
                    if (DBG) {
                        Slog.w(TAG, "Didn't create a death recipient.");
                    }
                    return;
                }
                if (bindGroup.mSpellChecker == null & bindGroup.mConnected) {
                    Slog.e(TAG, "The state of the spell checker bind group is illegal.");
                    bindGroup.removeAll();
                } else if (bindGroup.mSpellChecker != null) {
                    if (DBG) {
                        Slog.w(TAG, "Existing bind found. Return a spell checker session now. " + "Listeners count = " + bindGroup.mListeners.size());
                    }
                    try {
                        final ISpellCheckerSession session = bindGroup.mSpellChecker.getISpellCheckerSession(recipient.mScLocale, recipient.mScListener, bundle);
                        if (session != null) {
                            tsListener.onServiceConnected(session);
                            return;
                        } else {
                            if (DBG) {
                                Slog.w(TAG, "Existing bind already expired. ");
                            }
                            bindGroup.removeAll();
                        }
                    } catch (RemoteException e) {
                        Slog.e(TAG, "Exception in getting spell checker session: " + e);
                        bindGroup.removeAll();
                    }
                }
            }
        }
        final long ident = Binder.clearCallingIdentity();
        try {
            startSpellCheckerServiceInnerLocked(sci, locale, tsListener, scListener, uid, bundle);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }
    return;
}
Also used : ISpellCheckerSession(com.android.internal.textservice.ISpellCheckerSession) RemoteException(android.os.RemoteException) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Aggregations

RemoteException (android.os.RemoteException)6 SpellCheckerInfo (android.view.textservice.SpellCheckerInfo)6 ISpellCheckerSession (com.android.internal.textservice.ISpellCheckerSession)6