Loading api/current.txt +12 −4 Original line number Diff line number Diff line Loading @@ -18185,13 +18185,21 @@ package android.service.textservice { public abstract class SpellCheckerService extends android.app.Service { ctor public SpellCheckerService(); method public void cancel(); method public abstract android.view.textservice.SuggestionsInfo getSuggestions(android.view.textservice.TextInfo, int, java.lang.String); method public android.view.textservice.SuggestionsInfo[] getSuggestionsMultiple(android.view.textservice.TextInfo[], java.lang.String, int, boolean); method public abstract android.service.textservice.SpellCheckerService.Session createSession(); method public final android.os.IBinder onBind(android.content.Intent); field public static final java.lang.String SERVICE_INTERFACE = "android.service.textservice.SpellCheckerService"; } public abstract class SpellCheckerService.Session { ctor public SpellCheckerService.Session(); method public android.os.Bundle getBundle(); method public java.lang.String getLocale(); method public void onCancel(); method public abstract void onCreate(); method public abstract android.view.textservice.SuggestionsInfo onGetSuggestions(android.view.textservice.TextInfo, int); method public android.view.textservice.SuggestionsInfo[] onGetSuggestionsMultiple(android.view.textservice.TextInfo[], int, boolean); } } package android.service.wallpaper { Loading Loading @@ -24308,7 +24316,7 @@ package android.view.textservice { } public final class TextServicesManager { method public android.view.textservice.SpellCheckerSession newSpellCheckerSession(java.util.Locale, android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener, boolean); method public android.view.textservice.SpellCheckerSession newSpellCheckerSession(android.os.Bundle, java.util.Locale, android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener, boolean); } } core/java/android/service/textservice/SpellCheckerService.java +111 −56 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.internal.textservice.ISpellCheckerSessionListener; import android.app.Service; import android.content.Intent; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; Loading @@ -43,88 +44,138 @@ public abstract class SpellCheckerService extends Service { private final SpellCheckerServiceBinder mBinder = new SpellCheckerServiceBinder(this); /** * Implement to return the implementation of the internal spell checker * service interface. Subclasses should not override. */ @Override public final IBinder onBind(final Intent intent) { if (DBG) { Log.w(TAG, "onBind"); } return mBinder; } /** * Factory method to create a spell checker session impl * @return SpellCheckerSessionImpl which should be overridden by a concrete implementation. */ public abstract Session createSession(); /** * This abstract class should be overridden by a concrete implementation of a spell checker. */ public abstract class Session { private InternalISpellCheckerSession mInternalSession; /** * @hide */ public final void setInternalISpellCheckerSession(InternalISpellCheckerSession session) { mInternalSession = session; } /** * This is called after the class is initialized, at which point it knows it can call * getLocale() etc... */ public abstract void onCreate(); /** * Get suggestions for specified text in TextInfo. * This function will run on the incoming IPC thread. So, this is not called on the main thread, * This function will run on the incoming IPC thread. * So, this is not called on the main thread, * but will be called in series on another thread. * @param textInfo the text metadata * @param suggestionsLimit the number of limit of suggestions returned * @param locale the locale for getting suggestions * @return SuggestionInfo which contains suggestions for textInfo */ public abstract SuggestionsInfo getSuggestions( TextInfo textInfo, int suggestionsLimit, String locale); public abstract SuggestionsInfo onGetSuggestions(TextInfo textInfo, int suggestionsLimit); /** * A batch process of onGetSuggestions. * This function will run on the incoming IPC thread. So, this is not called on the main thread, * This function will run on the incoming IPC thread. * So, this is not called on the main thread, * but will be called in series on another thread. * @param textInfos an array of the text metadata * @param locale the locale for getting suggestions * @param suggestionsLimit the number of limit of suggestions returned * @param sequentialWords true if textInfos can be treated as sequential words. * @return an array of SuggestionInfo of onGetSuggestions */ public SuggestionsInfo[] getSuggestionsMultiple( TextInfo[] textInfos, String locale, int suggestionsLimit, boolean sequentialWords) { public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos, int suggestionsLimit, boolean sequentialWords) { final int length = textInfos.length; final SuggestionsInfo[] retval = new SuggestionsInfo[length]; for (int i = 0; i < length; ++i) { retval[i] = getSuggestions(textInfos[i], suggestionsLimit, locale); retval[i].setCookieAndSequence(textInfos[i].getCookie(), textInfos[i].getSequence()); retval[i] = onGetSuggestions(textInfos[i], suggestionsLimit); retval[i].setCookieAndSequence( textInfos[i].getCookie(), textInfos[i].getSequence()); } return retval; } /** * Request to abort all tasks executed in SpellChecker. * This function will run on the incoming IPC thread. So, this is not called on the main thread, * This function will run on the incoming IPC thread. * So, this is not called on the main thread, * but will be called in series on another thread. */ public void cancel() {} public void onCancel() {} /** * Implement to return the implementation of the internal spell checker * service interface. Subclasses should not override. * @return Locale for this session */ @Override public final IBinder onBind(final Intent intent) { if (DBG) { Log.w(TAG, "onBind"); public String getLocale() { return mInternalSession.getLocale(); } /** * @return Bundle for this session */ public Bundle getBundle() { return mInternalSession.getBundle(); } return mBinder; } private static class SpellCheckerSessionImpl extends ISpellCheckerSession.Stub { private final WeakReference<SpellCheckerService> mInternalServiceRef; private final String mLocale; // Preventing from exposing ISpellCheckerSession.aidl, create an internal class. private static class InternalISpellCheckerSession extends ISpellCheckerSession.Stub { private final ISpellCheckerSessionListener mListener; private final Session mSession; private final String mLocale; private final Bundle mBundle; public SpellCheckerSessionImpl( SpellCheckerService service, String locale, ISpellCheckerSessionListener listener) { mInternalServiceRef = new WeakReference<SpellCheckerService>(service); mLocale = locale; public InternalISpellCheckerSession(String locale, ISpellCheckerSessionListener listener, Bundle bundle, Session session) { mListener = listener; mSession = session; mLocale = locale; mBundle = bundle; session.setInternalISpellCheckerSession(this); } @Override public void getSuggestionsMultiple( public void onGetSuggestionsMultiple( TextInfo[] textInfos, int suggestionsLimit, boolean sequentialWords) { final SpellCheckerService service = mInternalServiceRef.get(); if (service == null) return; try { mListener.onGetSuggestions( service.getSuggestionsMultiple(textInfos, mLocale, suggestionsLimit, sequentialWords)); mSession.onGetSuggestionsMultiple( textInfos, suggestionsLimit, sequentialWords)); } catch (RemoteException e) { } } @Override public void cancel() { final SpellCheckerService service = mInternalServiceRef.get(); if (service == null) return; service.cancel(); public void onCancel() { mSession.onCancel(); } public String getLocale() { return mLocale; } public Bundle getBundle() { return mBundle; } } Loading @@ -137,10 +188,14 @@ public abstract class SpellCheckerService extends Service { @Override public ISpellCheckerSession getISpellCheckerSession( String locale, ISpellCheckerSessionListener listener) { String locale, ISpellCheckerSessionListener listener, Bundle bundle) { final SpellCheckerService service = mInternalServiceRef.get(); if (service == null) return null; return new SpellCheckerSessionImpl(service, locale, listener); final Session session = service.createSession(); final InternalISpellCheckerSession internalSession = new InternalISpellCheckerSession(locale, listener, bundle, session); session.onCreate(); return internalSession; } } } core/java/android/view/textservice/SpellCheckerSession.java +2 −2 Original line number Diff line number Diff line Loading @@ -233,7 +233,7 @@ public class SpellCheckerSession { Log.w(TAG, "Cancel spell checker tasks."); } try { mISpellCheckerSession.cancel(); mISpellCheckerSession.onCancel(); } catch (RemoteException e) { Log.e(TAG, "Failed to cancel " + e); } Loading @@ -247,7 +247,7 @@ public class SpellCheckerSession { Log.w(TAG, "Get suggestions from the spell checker."); } try { mISpellCheckerSession.getSuggestionsMultiple( mISpellCheckerSession.onGetSuggestionsMultiple( scp.mTextInfos, scp.mSuggestionsLimit, scp.mSequentialWords); } catch (RemoteException e) { Log.e(TAG, "Failed to get suggestions " + e); Loading core/java/android/view/textservice/TextServicesManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -19,11 +19,11 @@ package android.view.textservice; import com.android.internal.textservice.ITextServicesManager; import android.content.Context; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; import android.view.textservice.SpellCheckerSession; import android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener; import java.util.Locale; Loading Loading @@ -74,7 +74,7 @@ public final class TextServicesManager { */ // TODO: Add a method to get enabled spell checkers. // TODO: Handle referToSpellCheckerLanguageSettings public SpellCheckerSession newSpellCheckerSession(Locale locale, public SpellCheckerSession newSpellCheckerSession(Bundle bundle, Locale locale, SpellCheckerSessionListener listener, boolean referToSpellCheckerLanguageSettings) { if (listener == null) { throw new NullPointerException(); Loading @@ -94,7 +94,7 @@ public final class TextServicesManager { try { sService.getSpellCheckerService(sci.getId(), localeString, session.getTextServicesSessionListener(), session.getSpellCheckerSessionListener()); session.getSpellCheckerSessionListener(), bundle); } catch (RemoteException e) { return null; } Loading core/java/com/android/internal/textservice/ISpellCheckerService.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -19,11 +19,13 @@ package com.android.internal.textservice; import com.android.internal.textservice.ISpellCheckerSession; import com.android.internal.textservice.ISpellCheckerSessionListener; import android.os.Bundle; /** * Public interface to the global spell checker. * @hide */ interface ISpellCheckerService { ISpellCheckerSession getISpellCheckerSession( String locale, ISpellCheckerSessionListener listener); String locale, ISpellCheckerSessionListener listener, in Bundle bundle); } Loading
api/current.txt +12 −4 Original line number Diff line number Diff line Loading @@ -18185,13 +18185,21 @@ package android.service.textservice { public abstract class SpellCheckerService extends android.app.Service { ctor public SpellCheckerService(); method public void cancel(); method public abstract android.view.textservice.SuggestionsInfo getSuggestions(android.view.textservice.TextInfo, int, java.lang.String); method public android.view.textservice.SuggestionsInfo[] getSuggestionsMultiple(android.view.textservice.TextInfo[], java.lang.String, int, boolean); method public abstract android.service.textservice.SpellCheckerService.Session createSession(); method public final android.os.IBinder onBind(android.content.Intent); field public static final java.lang.String SERVICE_INTERFACE = "android.service.textservice.SpellCheckerService"; } public abstract class SpellCheckerService.Session { ctor public SpellCheckerService.Session(); method public android.os.Bundle getBundle(); method public java.lang.String getLocale(); method public void onCancel(); method public abstract void onCreate(); method public abstract android.view.textservice.SuggestionsInfo onGetSuggestions(android.view.textservice.TextInfo, int); method public android.view.textservice.SuggestionsInfo[] onGetSuggestionsMultiple(android.view.textservice.TextInfo[], int, boolean); } } package android.service.wallpaper { Loading Loading @@ -24308,7 +24316,7 @@ package android.view.textservice { } public final class TextServicesManager { method public android.view.textservice.SpellCheckerSession newSpellCheckerSession(java.util.Locale, android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener, boolean); method public android.view.textservice.SpellCheckerSession newSpellCheckerSession(android.os.Bundle, java.util.Locale, android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener, boolean); } }
core/java/android/service/textservice/SpellCheckerService.java +111 −56 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.internal.textservice.ISpellCheckerSessionListener; import android.app.Service; import android.content.Intent; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; Loading @@ -43,88 +44,138 @@ public abstract class SpellCheckerService extends Service { private final SpellCheckerServiceBinder mBinder = new SpellCheckerServiceBinder(this); /** * Implement to return the implementation of the internal spell checker * service interface. Subclasses should not override. */ @Override public final IBinder onBind(final Intent intent) { if (DBG) { Log.w(TAG, "onBind"); } return mBinder; } /** * Factory method to create a spell checker session impl * @return SpellCheckerSessionImpl which should be overridden by a concrete implementation. */ public abstract Session createSession(); /** * This abstract class should be overridden by a concrete implementation of a spell checker. */ public abstract class Session { private InternalISpellCheckerSession mInternalSession; /** * @hide */ public final void setInternalISpellCheckerSession(InternalISpellCheckerSession session) { mInternalSession = session; } /** * This is called after the class is initialized, at which point it knows it can call * getLocale() etc... */ public abstract void onCreate(); /** * Get suggestions for specified text in TextInfo. * This function will run on the incoming IPC thread. So, this is not called on the main thread, * This function will run on the incoming IPC thread. * So, this is not called on the main thread, * but will be called in series on another thread. * @param textInfo the text metadata * @param suggestionsLimit the number of limit of suggestions returned * @param locale the locale for getting suggestions * @return SuggestionInfo which contains suggestions for textInfo */ public abstract SuggestionsInfo getSuggestions( TextInfo textInfo, int suggestionsLimit, String locale); public abstract SuggestionsInfo onGetSuggestions(TextInfo textInfo, int suggestionsLimit); /** * A batch process of onGetSuggestions. * This function will run on the incoming IPC thread. So, this is not called on the main thread, * This function will run on the incoming IPC thread. * So, this is not called on the main thread, * but will be called in series on another thread. * @param textInfos an array of the text metadata * @param locale the locale for getting suggestions * @param suggestionsLimit the number of limit of suggestions returned * @param sequentialWords true if textInfos can be treated as sequential words. * @return an array of SuggestionInfo of onGetSuggestions */ public SuggestionsInfo[] getSuggestionsMultiple( TextInfo[] textInfos, String locale, int suggestionsLimit, boolean sequentialWords) { public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos, int suggestionsLimit, boolean sequentialWords) { final int length = textInfos.length; final SuggestionsInfo[] retval = new SuggestionsInfo[length]; for (int i = 0; i < length; ++i) { retval[i] = getSuggestions(textInfos[i], suggestionsLimit, locale); retval[i].setCookieAndSequence(textInfos[i].getCookie(), textInfos[i].getSequence()); retval[i] = onGetSuggestions(textInfos[i], suggestionsLimit); retval[i].setCookieAndSequence( textInfos[i].getCookie(), textInfos[i].getSequence()); } return retval; } /** * Request to abort all tasks executed in SpellChecker. * This function will run on the incoming IPC thread. So, this is not called on the main thread, * This function will run on the incoming IPC thread. * So, this is not called on the main thread, * but will be called in series on another thread. */ public void cancel() {} public void onCancel() {} /** * Implement to return the implementation of the internal spell checker * service interface. Subclasses should not override. * @return Locale for this session */ @Override public final IBinder onBind(final Intent intent) { if (DBG) { Log.w(TAG, "onBind"); public String getLocale() { return mInternalSession.getLocale(); } /** * @return Bundle for this session */ public Bundle getBundle() { return mInternalSession.getBundle(); } return mBinder; } private static class SpellCheckerSessionImpl extends ISpellCheckerSession.Stub { private final WeakReference<SpellCheckerService> mInternalServiceRef; private final String mLocale; // Preventing from exposing ISpellCheckerSession.aidl, create an internal class. private static class InternalISpellCheckerSession extends ISpellCheckerSession.Stub { private final ISpellCheckerSessionListener mListener; private final Session mSession; private final String mLocale; private final Bundle mBundle; public SpellCheckerSessionImpl( SpellCheckerService service, String locale, ISpellCheckerSessionListener listener) { mInternalServiceRef = new WeakReference<SpellCheckerService>(service); mLocale = locale; public InternalISpellCheckerSession(String locale, ISpellCheckerSessionListener listener, Bundle bundle, Session session) { mListener = listener; mSession = session; mLocale = locale; mBundle = bundle; session.setInternalISpellCheckerSession(this); } @Override public void getSuggestionsMultiple( public void onGetSuggestionsMultiple( TextInfo[] textInfos, int suggestionsLimit, boolean sequentialWords) { final SpellCheckerService service = mInternalServiceRef.get(); if (service == null) return; try { mListener.onGetSuggestions( service.getSuggestionsMultiple(textInfos, mLocale, suggestionsLimit, sequentialWords)); mSession.onGetSuggestionsMultiple( textInfos, suggestionsLimit, sequentialWords)); } catch (RemoteException e) { } } @Override public void cancel() { final SpellCheckerService service = mInternalServiceRef.get(); if (service == null) return; service.cancel(); public void onCancel() { mSession.onCancel(); } public String getLocale() { return mLocale; } public Bundle getBundle() { return mBundle; } } Loading @@ -137,10 +188,14 @@ public abstract class SpellCheckerService extends Service { @Override public ISpellCheckerSession getISpellCheckerSession( String locale, ISpellCheckerSessionListener listener) { String locale, ISpellCheckerSessionListener listener, Bundle bundle) { final SpellCheckerService service = mInternalServiceRef.get(); if (service == null) return null; return new SpellCheckerSessionImpl(service, locale, listener); final Session session = service.createSession(); final InternalISpellCheckerSession internalSession = new InternalISpellCheckerSession(locale, listener, bundle, session); session.onCreate(); return internalSession; } } }
core/java/android/view/textservice/SpellCheckerSession.java +2 −2 Original line number Diff line number Diff line Loading @@ -233,7 +233,7 @@ public class SpellCheckerSession { Log.w(TAG, "Cancel spell checker tasks."); } try { mISpellCheckerSession.cancel(); mISpellCheckerSession.onCancel(); } catch (RemoteException e) { Log.e(TAG, "Failed to cancel " + e); } Loading @@ -247,7 +247,7 @@ public class SpellCheckerSession { Log.w(TAG, "Get suggestions from the spell checker."); } try { mISpellCheckerSession.getSuggestionsMultiple( mISpellCheckerSession.onGetSuggestionsMultiple( scp.mTextInfos, scp.mSuggestionsLimit, scp.mSequentialWords); } catch (RemoteException e) { Log.e(TAG, "Failed to get suggestions " + e); Loading
core/java/android/view/textservice/TextServicesManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -19,11 +19,11 @@ package android.view.textservice; import com.android.internal.textservice.ITextServicesManager; import android.content.Context; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; import android.view.textservice.SpellCheckerSession; import android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener; import java.util.Locale; Loading Loading @@ -74,7 +74,7 @@ public final class TextServicesManager { */ // TODO: Add a method to get enabled spell checkers. // TODO: Handle referToSpellCheckerLanguageSettings public SpellCheckerSession newSpellCheckerSession(Locale locale, public SpellCheckerSession newSpellCheckerSession(Bundle bundle, Locale locale, SpellCheckerSessionListener listener, boolean referToSpellCheckerLanguageSettings) { if (listener == null) { throw new NullPointerException(); Loading @@ -94,7 +94,7 @@ public final class TextServicesManager { try { sService.getSpellCheckerService(sci.getId(), localeString, session.getTextServicesSessionListener(), session.getSpellCheckerSessionListener()); session.getSpellCheckerSessionListener(), bundle); } catch (RemoteException e) { return null; } Loading
core/java/com/android/internal/textservice/ISpellCheckerService.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -19,11 +19,13 @@ package com.android.internal.textservice; import com.android.internal.textservice.ISpellCheckerSession; import com.android.internal.textservice.ISpellCheckerSessionListener; import android.os.Bundle; /** * Public interface to the global spell checker. * @hide */ interface ISpellCheckerService { ISpellCheckerSession getISpellCheckerSession( String locale, ISpellCheckerSessionListener listener); String locale, ISpellCheckerSessionListener listener, in Bundle bundle); }