Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -368,6 +368,7 @@ java_defaults { "core/java/com/android/internal/app/IAppOpsService.aidl", "core/java/com/android/internal/app/IBatteryStats.aidl", "core/java/com/android/internal/app/ISoundTriggerService.aidl", "core/java/com/android/internal/app/IVoiceActionCheckCallback.aidl", "core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl", "core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl", "core/java/com/android/internal/app/IVoiceInteractionSessionShowCallback.aidl", Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -39928,6 +39928,7 @@ package android.service.voice { method public int getDisabledShowContext(); method public static boolean isActiveService(android.content.Context, android.content.ComponentName); method public android.os.IBinder onBind(android.content.Intent); method public java.util.Set<java.lang.String> onGetSupportedVoiceActions(java.util.Set<java.lang.String>); method public void onLaunchVoiceAssistFromKeyguard(); method public void onReady(); method public void onShutdown(); core/java/android/service/voice/IVoiceInteractionService.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.service.voice; import com.android.internal.app.IVoiceActionCheckCallback; /** * @hide */ Loading @@ -24,4 +26,6 @@ oneway interface IVoiceInteractionService { void soundModelsChanged(); void shutdown(); void launchVoiceAssistFromKeyguard(); void getActiveServiceSupportedActions(in List<String> voiceActions, in IVoiceActionCheckCallback callback); } core/java/android/service/voice/VoiceInteractionService.java +73 −49 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.service.voice; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SdkConstant; import android.annotation.UnsupportedAppUsage; import android.app.Service; Loading @@ -26,17 +28,22 @@ import android.hardware.soundtrigger.KeyphraseEnrollmentInfo; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.util.ArraySet; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.IVoiceActionCheckCallback; import com.android.internal.app.IVoiceInteractionManagerService; import com.android.internal.util.function.pooled.PooledLambda; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Set; /** * Top-level service of the current global voice interactor, which is providing Loading Loading @@ -71,22 +78,42 @@ public class VoiceInteractionService extends Service { public static final String SERVICE_META_DATA = "android.voice_interaction"; IVoiceInteractionService mInterface = new IVoiceInteractionService.Stub() { @Override public void ready() { mHandler.sendEmptyMessage(MSG_READY); @Override public void ready() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onReady, VoiceInteractionService.this)); } @Override public void shutdown() { mHandler.sendEmptyMessage(MSG_SHUTDOWN); @Override public void shutdown() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onShutdownInternal, VoiceInteractionService.this)); } @Override public void soundModelsChanged() { mHandler.sendEmptyMessage(MSG_SOUND_MODELS_CHANGED); @Override public void soundModelsChanged() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onSoundModelsChangedInternal, VoiceInteractionService.this)); } @Override public void launchVoiceAssistFromKeyguard() throws RemoteException { mHandler.sendEmptyMessage(MSG_LAUNCH_VOICE_ASSIST_FROM_KEYGUARD); public void launchVoiceAssistFromKeyguard() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onLaunchVoiceAssistFromKeyguard, VoiceInteractionService.this)); } }; MyHandler mHandler; @Override public void getActiveServiceSupportedActions(List<String> voiceActions, IVoiceActionCheckCallback callback) { Handler.getMain().executeOrSendMessage( PooledLambda.obtainMessage(VoiceInteractionService::onHandleVoiceActionCheck, VoiceInteractionService.this, voiceActions, callback)); } }; IVoiceInteractionManagerService mSystemService; Loading @@ -96,33 +123,6 @@ public class VoiceInteractionService extends Service { private AlwaysOnHotwordDetector mHotwordDetector; static final int MSG_READY = 1; static final int MSG_SHUTDOWN = 2; static final int MSG_SOUND_MODELS_CHANGED = 3; static final int MSG_LAUNCH_VOICE_ASSIST_FROM_KEYGUARD = 4; class MyHandler extends Handler { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_READY: onReady(); break; case MSG_SHUTDOWN: onShutdownInternal(); break; case MSG_SOUND_MODELS_CHANGED: onSoundModelsChangedInternal(); break; case MSG_LAUNCH_VOICE_ASSIST_FROM_KEYGUARD: onLaunchVoiceAssistFromKeyguard(); break; default: super.handleMessage(msg); } } } /** * Called when a user has activated an affordance to launch voice assist from the Keyguard. * Loading Loading @@ -200,10 +200,22 @@ public class VoiceInteractionService extends Service { } } @Override public void onCreate() { super.onCreate(); mHandler = new MyHandler(); /** * Request to query for what extended voice actions this service supports. This method will * be called when the system checks the supported actions of this * {@link VoiceInteractionService}. Supported actions may be delivered to * {@link VoiceInteractionSession} later to request a session to perform an action. * * <p>Voice actions are defined in support libraries and could vary based on platform context. * For example, car related voice actions will be defined in car support libraries. * * @param voiceActions A set of checked voice actions. * @return Returns a subset of checked voice actions. Additional voice actions in the * returned set will be ignored. Returns null or empty set if no actions are supported. */ @Nullable public Set<String> onGetSupportedVoiceActions(@NonNull Set<String> voiceActions) { return null; } @Override Loading Loading @@ -254,6 +266,18 @@ public class VoiceInteractionService extends Service { } } private void onHandleVoiceActionCheck(List<String> voiceActions, IVoiceActionCheckCallback callback) { if (callback != null) { try { Set<String> voiceActionsSet = new ArraySet<>(voiceActions); Set<String> resultSet = onGetSupportedVoiceActions(voiceActionsSet); callback.onComplete(resultSet == null ? null : new ArrayList<>(resultSet)); } catch (RemoteException e) { } } } /** * Creates an {@link AlwaysOnHotwordDetector} for the given keyphrase and locale. * This instance must be retained and used by the client. Loading core/java/com/android/internal/app/AssistUtils.java +29 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,7 @@ package com.android.internal.app; import com.android.internal.R; import android.annotation.NonNull; import android.app.SearchManager; import android.content.ComponentName; import android.content.Context; Loading @@ -32,6 +31,9 @@ import android.os.ServiceManager; import android.provider.Settings; import android.util.Log; import java.util.ArrayList; import java.util.Set; /** * Utility method for dealing with the assistant aspects of * {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}. Loading Loading @@ -62,6 +64,30 @@ public class AssistUtils { return false; } /** * Checks the availability of a set of voice actions for the current active voice service. * * @param voiceActions A set of supported voice actions to be checked. * @param callback The callback which will deliver a set of supported voice actions. If * no voice actions are supported for the given voice action set, then null * or empty set is provided. */ public void getActiveServiceSupportedActions(@NonNull Set<String> voiceActions, @NonNull IVoiceActionCheckCallback callback) { try { if (mVoiceInteractionManagerService != null) { mVoiceInteractionManagerService .getActiveServiceSupportedActions(new ArrayList<>(voiceActions), callback); } } catch (RemoteException e) { Log.w(TAG, "Failed to call activeServiceSupportedActions", e); try { callback.onComplete(null); } catch (RemoteException re) { } } } public void launchVoiceAssistFromKeyguard() { try { if (mVoiceInteractionManagerService != null) { Loading Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -368,6 +368,7 @@ java_defaults { "core/java/com/android/internal/app/IAppOpsService.aidl", "core/java/com/android/internal/app/IBatteryStats.aidl", "core/java/com/android/internal/app/ISoundTriggerService.aidl", "core/java/com/android/internal/app/IVoiceActionCheckCallback.aidl", "core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl", "core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl", "core/java/com/android/internal/app/IVoiceInteractionSessionShowCallback.aidl", Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -39928,6 +39928,7 @@ package android.service.voice { method public int getDisabledShowContext(); method public static boolean isActiveService(android.content.Context, android.content.ComponentName); method public android.os.IBinder onBind(android.content.Intent); method public java.util.Set<java.lang.String> onGetSupportedVoiceActions(java.util.Set<java.lang.String>); method public void onLaunchVoiceAssistFromKeyguard(); method public void onReady(); method public void onShutdown();
core/java/android/service/voice/IVoiceInteractionService.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.service.voice; import com.android.internal.app.IVoiceActionCheckCallback; /** * @hide */ Loading @@ -24,4 +26,6 @@ oneway interface IVoiceInteractionService { void soundModelsChanged(); void shutdown(); void launchVoiceAssistFromKeyguard(); void getActiveServiceSupportedActions(in List<String> voiceActions, in IVoiceActionCheckCallback callback); }
core/java/android/service/voice/VoiceInteractionService.java +73 −49 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.service.voice; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SdkConstant; import android.annotation.UnsupportedAppUsage; import android.app.Service; Loading @@ -26,17 +28,22 @@ import android.hardware.soundtrigger.KeyphraseEnrollmentInfo; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.util.ArraySet; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.IVoiceActionCheckCallback; import com.android.internal.app.IVoiceInteractionManagerService; import com.android.internal.util.function.pooled.PooledLambda; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Set; /** * Top-level service of the current global voice interactor, which is providing Loading Loading @@ -71,22 +78,42 @@ public class VoiceInteractionService extends Service { public static final String SERVICE_META_DATA = "android.voice_interaction"; IVoiceInteractionService mInterface = new IVoiceInteractionService.Stub() { @Override public void ready() { mHandler.sendEmptyMessage(MSG_READY); @Override public void ready() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onReady, VoiceInteractionService.this)); } @Override public void shutdown() { mHandler.sendEmptyMessage(MSG_SHUTDOWN); @Override public void shutdown() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onShutdownInternal, VoiceInteractionService.this)); } @Override public void soundModelsChanged() { mHandler.sendEmptyMessage(MSG_SOUND_MODELS_CHANGED); @Override public void soundModelsChanged() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onSoundModelsChangedInternal, VoiceInteractionService.this)); } @Override public void launchVoiceAssistFromKeyguard() throws RemoteException { mHandler.sendEmptyMessage(MSG_LAUNCH_VOICE_ASSIST_FROM_KEYGUARD); public void launchVoiceAssistFromKeyguard() { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onLaunchVoiceAssistFromKeyguard, VoiceInteractionService.this)); } }; MyHandler mHandler; @Override public void getActiveServiceSupportedActions(List<String> voiceActions, IVoiceActionCheckCallback callback) { Handler.getMain().executeOrSendMessage( PooledLambda.obtainMessage(VoiceInteractionService::onHandleVoiceActionCheck, VoiceInteractionService.this, voiceActions, callback)); } }; IVoiceInteractionManagerService mSystemService; Loading @@ -96,33 +123,6 @@ public class VoiceInteractionService extends Service { private AlwaysOnHotwordDetector mHotwordDetector; static final int MSG_READY = 1; static final int MSG_SHUTDOWN = 2; static final int MSG_SOUND_MODELS_CHANGED = 3; static final int MSG_LAUNCH_VOICE_ASSIST_FROM_KEYGUARD = 4; class MyHandler extends Handler { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_READY: onReady(); break; case MSG_SHUTDOWN: onShutdownInternal(); break; case MSG_SOUND_MODELS_CHANGED: onSoundModelsChangedInternal(); break; case MSG_LAUNCH_VOICE_ASSIST_FROM_KEYGUARD: onLaunchVoiceAssistFromKeyguard(); break; default: super.handleMessage(msg); } } } /** * Called when a user has activated an affordance to launch voice assist from the Keyguard. * Loading Loading @@ -200,10 +200,22 @@ public class VoiceInteractionService extends Service { } } @Override public void onCreate() { super.onCreate(); mHandler = new MyHandler(); /** * Request to query for what extended voice actions this service supports. This method will * be called when the system checks the supported actions of this * {@link VoiceInteractionService}. Supported actions may be delivered to * {@link VoiceInteractionSession} later to request a session to perform an action. * * <p>Voice actions are defined in support libraries and could vary based on platform context. * For example, car related voice actions will be defined in car support libraries. * * @param voiceActions A set of checked voice actions. * @return Returns a subset of checked voice actions. Additional voice actions in the * returned set will be ignored. Returns null or empty set if no actions are supported. */ @Nullable public Set<String> onGetSupportedVoiceActions(@NonNull Set<String> voiceActions) { return null; } @Override Loading Loading @@ -254,6 +266,18 @@ public class VoiceInteractionService extends Service { } } private void onHandleVoiceActionCheck(List<String> voiceActions, IVoiceActionCheckCallback callback) { if (callback != null) { try { Set<String> voiceActionsSet = new ArraySet<>(voiceActions); Set<String> resultSet = onGetSupportedVoiceActions(voiceActionsSet); callback.onComplete(resultSet == null ? null : new ArrayList<>(resultSet)); } catch (RemoteException e) { } } } /** * Creates an {@link AlwaysOnHotwordDetector} for the given keyphrase and locale. * This instance must be retained and used by the client. Loading
core/java/com/android/internal/app/AssistUtils.java +29 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,7 @@ package com.android.internal.app; import com.android.internal.R; import android.annotation.NonNull; import android.app.SearchManager; import android.content.ComponentName; import android.content.Context; Loading @@ -32,6 +31,9 @@ import android.os.ServiceManager; import android.provider.Settings; import android.util.Log; import java.util.ArrayList; import java.util.Set; /** * Utility method for dealing with the assistant aspects of * {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}. Loading Loading @@ -62,6 +64,30 @@ public class AssistUtils { return false; } /** * Checks the availability of a set of voice actions for the current active voice service. * * @param voiceActions A set of supported voice actions to be checked. * @param callback The callback which will deliver a set of supported voice actions. If * no voice actions are supported for the given voice action set, then null * or empty set is provided. */ public void getActiveServiceSupportedActions(@NonNull Set<String> voiceActions, @NonNull IVoiceActionCheckCallback callback) { try { if (mVoiceInteractionManagerService != null) { mVoiceInteractionManagerService .getActiveServiceSupportedActions(new ArrayList<>(voiceActions), callback); } } catch (RemoteException e) { Log.w(TAG, "Failed to call activeServiceSupportedActions", e); try { callback.onComplete(null); } catch (RemoteException re) { } } } public void launchVoiceAssistFromKeyguard() { try { if (mVoiceInteractionManagerService != null) { Loading