Loading core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -41450,9 +41450,11 @@ package android.speech { method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void onCancel(android.speech.RecognitionService.Callback); method public void onCheckRecognitionSupport(@NonNull android.content.Intent, @NonNull android.speech.RecognitionService.SupportCallback); method public void onCheckRecognitionSupport(@NonNull android.content.Intent, @NonNull android.content.AttributionSource, @NonNull android.speech.RecognitionService.SupportCallback); method protected abstract void onStartListening(android.content.Intent, android.speech.RecognitionService.Callback); method protected abstract void onStopListening(android.speech.RecognitionService.Callback); method public void onTriggerModelDownload(@NonNull android.content.Intent); method public void onTriggerModelDownload(@NonNull android.content.Intent, @NonNull android.content.AttributionSource); field public static final String SERVICE_INTERFACE = "android.speech.RecognitionService"; field public static final String SERVICE_META_DATA = "android.speech"; } core/java/android/speech/IRecognitionService.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -67,12 +67,15 @@ oneway interface IRecognitionService { * given recognizerIntent. For more information see {@link #startListening} and * {@link RecognizerIntent}. */ void checkRecognitionSupport(in Intent recognizerIntent, in IRecognitionSupportCallback listener); void checkRecognitionSupport( in Intent recognizerIntent, in AttributionSource attributionSource, in IRecognitionSupportCallback listener); /** * Requests RecognitionService to download the support for the given recognizerIntent. For more * information see {@link #checkRecognitionSupport}, {@link #startListening} and * {@link RecognizerIntent}. */ void triggerModelDownload(in Intent recognizerIntent); void triggerModelDownload(in Intent recognizerIntent, in AttributionSource attributionSource); } core/java/android/speech/RecognitionService.java +73 −13 Original line number Diff line number Diff line Loading @@ -110,13 +110,14 @@ public abstract class RecognitionService extends Service { dispatchClearCallback((IRecognitionListener) msg.obj); break; case MSG_CHECK_RECOGNITION_SUPPORT: Pair<Intent, IRecognitionSupportCallback> intentAndListener = (Pair<Intent, IRecognitionSupportCallback>) msg.obj; CheckRecognitionSupportArgs checkArgs = (CheckRecognitionSupportArgs) msg.obj; dispatchCheckRecognitionSupport( intentAndListener.first, intentAndListener.second); checkArgs.mIntent, checkArgs.callback, checkArgs.mAttributionSource); break; case MSG_TRIGGER_MODEL_DOWNLOAD: dispatchTriggerModelDownload((Intent) msg.obj); Pair<Intent, AttributionSource> params = (Pair<Intent, AttributionSource>) msg.obj; dispatchTriggerModelDownload(params.first, params.second); break; } } Loading Loading @@ -211,12 +212,18 @@ public abstract class RecognitionService extends Service { } private void dispatchCheckRecognitionSupport( Intent intent, IRecognitionSupportCallback callback) { RecognitionService.this.onCheckRecognitionSupport(intent, new SupportCallback(callback)); Intent intent, IRecognitionSupportCallback callback, AttributionSource attributionSource) { RecognitionService.this.onCheckRecognitionSupport( intent, attributionSource, new SupportCallback(callback)); } private void dispatchTriggerModelDownload(Intent intent) { RecognitionService.this.onTriggerModelDownload(intent); private void dispatchTriggerModelDownload( Intent intent, AttributionSource attributionSource) { RecognitionService.this.onTriggerModelDownload(intent, attributionSource); } private static class StartListeningArgs { Loading @@ -233,6 +240,21 @@ public abstract class RecognitionService extends Service { } } private static class CheckRecognitionSupportArgs { public final Intent mIntent; public final IRecognitionSupportCallback callback; public final AttributionSource mAttributionSource; private CheckRecognitionSupportArgs( Intent intent, IRecognitionSupportCallback callback, AttributionSource attributionSource) { this.mIntent = intent; this.callback = callback; this.mAttributionSource = attributionSource; } } /** * Notifies the service that it should start listening for speech. * Loading Loading @@ -297,6 +319,26 @@ public abstract class RecognitionService extends Service { supportCallback.onError(SpeechRecognizer.ERROR_CANNOT_CHECK_SUPPORT); } /** * Queries the service on whether it would support a {@link #onStartListening(Intent, Callback)} * for the same {@code recognizerIntent}. * * <p>The service will notify the caller about the level of support or error via * {@link SupportCallback}. * * <p>If the service does not offer the support check it will notify the caller with * {@link SpeechRecognizer#ERROR_CANNOT_CHECK_SUPPORT}. * * <p>Provides the calling AttributionSource to the service implementation so that permissions * and bandwidth could be correctly blamed.</p> */ public void onCheckRecognitionSupport( @NonNull Intent recognizerIntent, @NonNull AttributionSource attributionSource, @NonNull SupportCallback supportCallback) { onCheckRecognitionSupport(recognizerIntent, supportCallback); } /** * Requests the download of the recognizer support for {@code recognizerIntent}. */ Loading @@ -306,6 +348,18 @@ public abstract class RecognitionService extends Service { } } /** * Requests the download of the recognizer support for {@code recognizerIntent}. * * <p>Provides the calling AttributionSource to the service implementation so that permissions * and bandwidth could be correctly blamed.</p> */ public void onTriggerModelDownload( @NonNull Intent recognizerIntent, @NonNull AttributionSource attributionSource) { onTriggerModelDownload(recognizerIntent); } @Override @SuppressLint("MissingNullability") public Context createContext(@NonNull ContextParams contextParams) { Loading Loading @@ -524,7 +578,8 @@ public abstract class RecognitionService extends Service { public static class SupportCallback { private final IRecognitionSupportCallback mCallback; private SupportCallback(IRecognitionSupportCallback callback) { private SupportCallback( IRecognitionSupportCallback callback) { this.mCallback = callback; } Loading Loading @@ -596,22 +651,27 @@ public abstract class RecognitionService extends Service { @Override public void checkRecognitionSupport( Intent recognizerIntent, IRecognitionSupportCallback callback) { Intent recognizerIntent, @NonNull AttributionSource attributionSource, IRecognitionSupportCallback callback) { final RecognitionService service = mServiceRef.get(); if (service != null) { service.mHandler.sendMessage( Message.obtain(service.mHandler, MSG_CHECK_RECOGNITION_SUPPORT, Pair.create(recognizerIntent, callback))); new CheckRecognitionSupportArgs( recognizerIntent, callback, attributionSource))); } } @Override public void triggerModelDownload(Intent recognizerIntent) { public void triggerModelDownload( Intent recognizerIntent, @NonNull AttributionSource attributionSource) { final RecognitionService service = mServiceRef.get(); if (service != null) { service.mHandler.sendMessage( Message.obtain( service.mHandler, MSG_TRIGGER_MODEL_DOWNLOAD, recognizerIntent)); service.mHandler, MSG_TRIGGER_MODEL_DOWNLOAD, Pair.create(recognizerIntent, attributionSource))); } } Loading core/java/android/speech/SpeechRecognizer.java +2 −1 Original line number Diff line number Diff line Loading @@ -663,6 +663,7 @@ public class SpeechRecognizer { try { mService.checkRecognitionSupport( recognizerIntent, mContext.getAttributionSource(), new InternalSupportCallback(callbackExecutor, recognitionSupportCallback)); if (DBG) Log.d(TAG, "service support command succeeded"); } catch (final RemoteException e) { Loading @@ -676,7 +677,7 @@ public class SpeechRecognizer { return; } try { mService.triggerModelDownload(recognizerIntent); mService.triggerModelDownload(recognizerIntent, mContext.getAttributionSource()); } catch (final RemoteException e) { Log.e(TAG, "downloadModel() failed", e); mListener.onError(ERROR_CLIENT); Loading services/core/java/com/android/server/speech/RemoteSpeechRecognitionService.java +6 −3 Original line number Diff line number Diff line Loading @@ -233,7 +233,9 @@ final class RemoteSpeechRecognitionService extends ServiceConnector.Impl<IRecogn void checkRecognitionSupport( Intent recognizerIntent, AttributionSource attributionSource, IRecognitionSupportCallback callback) { if (!mConnected) { try { callback.onError(SpeechRecognizer.ERROR_SERVER_DISCONNECTED); Loading @@ -243,15 +245,16 @@ final class RemoteSpeechRecognitionService extends ServiceConnector.Impl<IRecogn } return; } run(service -> service.checkRecognitionSupport(recognizerIntent, callback)); run(service -> service.checkRecognitionSupport(recognizerIntent, attributionSource, callback)); } void triggerModelDownload(Intent recognizerIntent) { void triggerModelDownload(Intent recognizerIntent, AttributionSource attributionSource) { if (!mConnected) { Slog.e(TAG, "#downloadModel failed due to connection."); return; } run(service -> service.triggerModelDownload(recognizerIntent)); run(service -> service.triggerModelDownload(recognizerIntent, attributionSource)); } void shutdown(IBinder clientToken) { Loading Loading
core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -41450,9 +41450,11 @@ package android.speech { method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void onCancel(android.speech.RecognitionService.Callback); method public void onCheckRecognitionSupport(@NonNull android.content.Intent, @NonNull android.speech.RecognitionService.SupportCallback); method public void onCheckRecognitionSupport(@NonNull android.content.Intent, @NonNull android.content.AttributionSource, @NonNull android.speech.RecognitionService.SupportCallback); method protected abstract void onStartListening(android.content.Intent, android.speech.RecognitionService.Callback); method protected abstract void onStopListening(android.speech.RecognitionService.Callback); method public void onTriggerModelDownload(@NonNull android.content.Intent); method public void onTriggerModelDownload(@NonNull android.content.Intent, @NonNull android.content.AttributionSource); field public static final String SERVICE_INTERFACE = "android.speech.RecognitionService"; field public static final String SERVICE_META_DATA = "android.speech"; }
core/java/android/speech/IRecognitionService.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -67,12 +67,15 @@ oneway interface IRecognitionService { * given recognizerIntent. For more information see {@link #startListening} and * {@link RecognizerIntent}. */ void checkRecognitionSupport(in Intent recognizerIntent, in IRecognitionSupportCallback listener); void checkRecognitionSupport( in Intent recognizerIntent, in AttributionSource attributionSource, in IRecognitionSupportCallback listener); /** * Requests RecognitionService to download the support for the given recognizerIntent. For more * information see {@link #checkRecognitionSupport}, {@link #startListening} and * {@link RecognizerIntent}. */ void triggerModelDownload(in Intent recognizerIntent); void triggerModelDownload(in Intent recognizerIntent, in AttributionSource attributionSource); }
core/java/android/speech/RecognitionService.java +73 −13 Original line number Diff line number Diff line Loading @@ -110,13 +110,14 @@ public abstract class RecognitionService extends Service { dispatchClearCallback((IRecognitionListener) msg.obj); break; case MSG_CHECK_RECOGNITION_SUPPORT: Pair<Intent, IRecognitionSupportCallback> intentAndListener = (Pair<Intent, IRecognitionSupportCallback>) msg.obj; CheckRecognitionSupportArgs checkArgs = (CheckRecognitionSupportArgs) msg.obj; dispatchCheckRecognitionSupport( intentAndListener.first, intentAndListener.second); checkArgs.mIntent, checkArgs.callback, checkArgs.mAttributionSource); break; case MSG_TRIGGER_MODEL_DOWNLOAD: dispatchTriggerModelDownload((Intent) msg.obj); Pair<Intent, AttributionSource> params = (Pair<Intent, AttributionSource>) msg.obj; dispatchTriggerModelDownload(params.first, params.second); break; } } Loading Loading @@ -211,12 +212,18 @@ public abstract class RecognitionService extends Service { } private void dispatchCheckRecognitionSupport( Intent intent, IRecognitionSupportCallback callback) { RecognitionService.this.onCheckRecognitionSupport(intent, new SupportCallback(callback)); Intent intent, IRecognitionSupportCallback callback, AttributionSource attributionSource) { RecognitionService.this.onCheckRecognitionSupport( intent, attributionSource, new SupportCallback(callback)); } private void dispatchTriggerModelDownload(Intent intent) { RecognitionService.this.onTriggerModelDownload(intent); private void dispatchTriggerModelDownload( Intent intent, AttributionSource attributionSource) { RecognitionService.this.onTriggerModelDownload(intent, attributionSource); } private static class StartListeningArgs { Loading @@ -233,6 +240,21 @@ public abstract class RecognitionService extends Service { } } private static class CheckRecognitionSupportArgs { public final Intent mIntent; public final IRecognitionSupportCallback callback; public final AttributionSource mAttributionSource; private CheckRecognitionSupportArgs( Intent intent, IRecognitionSupportCallback callback, AttributionSource attributionSource) { this.mIntent = intent; this.callback = callback; this.mAttributionSource = attributionSource; } } /** * Notifies the service that it should start listening for speech. * Loading Loading @@ -297,6 +319,26 @@ public abstract class RecognitionService extends Service { supportCallback.onError(SpeechRecognizer.ERROR_CANNOT_CHECK_SUPPORT); } /** * Queries the service on whether it would support a {@link #onStartListening(Intent, Callback)} * for the same {@code recognizerIntent}. * * <p>The service will notify the caller about the level of support or error via * {@link SupportCallback}. * * <p>If the service does not offer the support check it will notify the caller with * {@link SpeechRecognizer#ERROR_CANNOT_CHECK_SUPPORT}. * * <p>Provides the calling AttributionSource to the service implementation so that permissions * and bandwidth could be correctly blamed.</p> */ public void onCheckRecognitionSupport( @NonNull Intent recognizerIntent, @NonNull AttributionSource attributionSource, @NonNull SupportCallback supportCallback) { onCheckRecognitionSupport(recognizerIntent, supportCallback); } /** * Requests the download of the recognizer support for {@code recognizerIntent}. */ Loading @@ -306,6 +348,18 @@ public abstract class RecognitionService extends Service { } } /** * Requests the download of the recognizer support for {@code recognizerIntent}. * * <p>Provides the calling AttributionSource to the service implementation so that permissions * and bandwidth could be correctly blamed.</p> */ public void onTriggerModelDownload( @NonNull Intent recognizerIntent, @NonNull AttributionSource attributionSource) { onTriggerModelDownload(recognizerIntent); } @Override @SuppressLint("MissingNullability") public Context createContext(@NonNull ContextParams contextParams) { Loading Loading @@ -524,7 +578,8 @@ public abstract class RecognitionService extends Service { public static class SupportCallback { private final IRecognitionSupportCallback mCallback; private SupportCallback(IRecognitionSupportCallback callback) { private SupportCallback( IRecognitionSupportCallback callback) { this.mCallback = callback; } Loading Loading @@ -596,22 +651,27 @@ public abstract class RecognitionService extends Service { @Override public void checkRecognitionSupport( Intent recognizerIntent, IRecognitionSupportCallback callback) { Intent recognizerIntent, @NonNull AttributionSource attributionSource, IRecognitionSupportCallback callback) { final RecognitionService service = mServiceRef.get(); if (service != null) { service.mHandler.sendMessage( Message.obtain(service.mHandler, MSG_CHECK_RECOGNITION_SUPPORT, Pair.create(recognizerIntent, callback))); new CheckRecognitionSupportArgs( recognizerIntent, callback, attributionSource))); } } @Override public void triggerModelDownload(Intent recognizerIntent) { public void triggerModelDownload( Intent recognizerIntent, @NonNull AttributionSource attributionSource) { final RecognitionService service = mServiceRef.get(); if (service != null) { service.mHandler.sendMessage( Message.obtain( service.mHandler, MSG_TRIGGER_MODEL_DOWNLOAD, recognizerIntent)); service.mHandler, MSG_TRIGGER_MODEL_DOWNLOAD, Pair.create(recognizerIntent, attributionSource))); } } Loading
core/java/android/speech/SpeechRecognizer.java +2 −1 Original line number Diff line number Diff line Loading @@ -663,6 +663,7 @@ public class SpeechRecognizer { try { mService.checkRecognitionSupport( recognizerIntent, mContext.getAttributionSource(), new InternalSupportCallback(callbackExecutor, recognitionSupportCallback)); if (DBG) Log.d(TAG, "service support command succeeded"); } catch (final RemoteException e) { Loading @@ -676,7 +677,7 @@ public class SpeechRecognizer { return; } try { mService.triggerModelDownload(recognizerIntent); mService.triggerModelDownload(recognizerIntent, mContext.getAttributionSource()); } catch (final RemoteException e) { Log.e(TAG, "downloadModel() failed", e); mListener.onError(ERROR_CLIENT); Loading
services/core/java/com/android/server/speech/RemoteSpeechRecognitionService.java +6 −3 Original line number Diff line number Diff line Loading @@ -233,7 +233,9 @@ final class RemoteSpeechRecognitionService extends ServiceConnector.Impl<IRecogn void checkRecognitionSupport( Intent recognizerIntent, AttributionSource attributionSource, IRecognitionSupportCallback callback) { if (!mConnected) { try { callback.onError(SpeechRecognizer.ERROR_SERVER_DISCONNECTED); Loading @@ -243,15 +245,16 @@ final class RemoteSpeechRecognitionService extends ServiceConnector.Impl<IRecogn } return; } run(service -> service.checkRecognitionSupport(recognizerIntent, callback)); run(service -> service.checkRecognitionSupport(recognizerIntent, attributionSource, callback)); } void triggerModelDownload(Intent recognizerIntent) { void triggerModelDownload(Intent recognizerIntent, AttributionSource attributionSource) { if (!mConnected) { Slog.e(TAG, "#downloadModel failed due to connection."); return; } run(service -> service.triggerModelDownload(recognizerIntent)); run(service -> service.triggerModelDownload(recognizerIntent, attributionSource)); } void shutdown(IBinder clientToken) { Loading