diff options
author | Nicholas Ambur <nambur@google.com> | 2019-08-22 12:13:29 -0700 |
---|---|---|
committer | Nicholas Ambur <nambur@google.com> | 2019-08-30 10:10:18 -0700 |
commit | 1aa4b4b779f351c59d45fa51b568237961aebfb6 (patch) | |
tree | a3309ce2db309f77070a4a114dfabe15c72f34dc | |
parent | 505d5634fe51e1f96b378b8475b9c78e6e95135e (diff) |
Add ability to get soundtrigger props from dsp
exposes sound trigger module properties to privileged
system apps with MANAGE_SOUND_TRIGGER permission
Bug: 139071862
Test: GTS test confirmed API accessible and providing valid data
Change-Id: Iec7ba6fc59912f44341fbe8d7f99193b9ead52f0
5 files changed, 61 insertions, 6 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 18e30bac8dfc..d10f45120cde 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3013,6 +3013,26 @@ package android.hardware.soundtrigger { field public static final int STATUS_OK = 0; // 0x0 } + public static final class SoundTrigger.ModuleProperties implements android.os.Parcelable { + method public int describeContents(); + method public void writeToParcel(android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.hardware.soundtrigger.SoundTrigger.ModuleProperties> CREATOR; + field @NonNull public final String description; + field public final int id; + field @NonNull public final String implementor; + field public final int maxBufferMs; + field public final int maxKeyphrases; + field public final int maxSoundModels; + field public final int maxUsers; + field public final int powerConsumptionMw; + field public final int recognitionModes; + field public final boolean returnsTriggerInEvent; + field public final boolean supportsCaptureTransition; + field public final boolean supportsConcurrentCapture; + field @NonNull public final java.util.UUID uuid; + field public final int version; + } + public static class SoundTrigger.RecognitionEvent { method @Nullable public android.media.AudioFormat getCaptureFormat(); method public int getCaptureSession(); @@ -3755,6 +3775,7 @@ package android.media.soundtrigger { method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public void deleteModel(java.util.UUID); method public int getDetectionServiceOperationsTimeout(); method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public android.media.soundtrigger.SoundTriggerManager.Model getModel(java.util.UUID); + method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) @Nullable public android.hardware.soundtrigger.SoundTrigger.ModuleProperties getModuleProperties(); method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public void updateModel(android.media.soundtrigger.SoundTriggerManager.Model); } diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.java b/core/java/android/hardware/soundtrigger/SoundTrigger.java index 5b5bd7661bc5..8a9617e28c4d 100644 --- a/core/java/android/hardware/soundtrigger/SoundTrigger.java +++ b/core/java/android/hardware/soundtrigger/SoundTrigger.java @@ -22,6 +22,7 @@ import static android.system.OsConstants.ENOSYS; import static android.system.OsConstants.EPERM; import static android.system.OsConstants.EPIPE; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; @@ -70,28 +71,27 @@ public class SoundTrigger { * ID used to target any API call to this paricular module. Module * properties are returned by listModules() method. * - * @hide ****************************************************************************/ - public static class ModuleProperties implements Parcelable { + public static final class ModuleProperties implements Parcelable { /** Unique module ID provided by the native service */ - @UnsupportedAppUsage public final int id; /** human readable voice detection engine implementor */ + @NonNull public final String implementor; /** human readable voice detection engine description */ + @NonNull public final String description; /** Unique voice engine Id (changes with each version) */ - @UnsupportedAppUsage + @NonNull public final UUID uuid; /** Voice detection engine version */ public final int version; /** Maximum number of active sound models */ - @UnsupportedAppUsage public final int maxSoundModels; /** Maximum number of key phrases */ @@ -119,7 +119,6 @@ public class SoundTrigger { * recognition callback event */ public final boolean returnsTriggerInEvent; - @UnsupportedAppUsage ModuleProperties(int id, String implementor, String description, String uuid, int version, int maxSoundModels, int maxKeyphrases, int maxUsers, int recognitionModes, boolean supportsCaptureTransition, diff --git a/core/java/com/android/internal/app/ISoundTriggerService.aidl b/core/java/com/android/internal/app/ISoundTriggerService.aidl index 764c0cfbd01c..ea24d5fbb2f7 100644 --- a/core/java/com/android/internal/app/ISoundTriggerService.aidl +++ b/core/java/com/android/internal/app/ISoundTriggerService.aidl @@ -54,4 +54,6 @@ interface ISoundTriggerService { boolean isRecognitionActive(in ParcelUuid parcelUuid); int getModelState(in ParcelUuid soundModelId); + + @nullable SoundTrigger.ModuleProperties getModuleProperties(); } diff --git a/media/java/android/media/soundtrigger/SoundTriggerManager.java b/media/java/android/media/soundtrigger/SoundTriggerManager.java index ada77c53bb34..dc400ad26eed 100644 --- a/media/java/android/media/soundtrigger/SoundTriggerManager.java +++ b/media/java/android/media/soundtrigger/SoundTriggerManager.java @@ -383,4 +383,20 @@ public final class SoundTriggerManager { throw e.rethrowFromSystemServer(); } } + + /** + * Get the hardware sound trigger module properties currently loaded. + * + * @return The properties currently loaded. Returns null if no supported hardware loaded. + */ + @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) + @Nullable + public SoundTrigger.ModuleProperties getModuleProperties() { + + try { + return mSoundTriggerService.getModuleProperties(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } } diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java index a8cafb33790d..1dd3972b56b4 100644 --- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java @@ -666,6 +666,23 @@ public class SoundTriggerService extends SystemService { return ret; } } + + @Override + @Nullable + public ModuleProperties getModuleProperties() { + enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER); + if (!isInitialized()) return null; + if (DEBUG) { + Slog.i(TAG, "getModuleProperties()"); + } + + synchronized (mLock) { + ModuleProperties properties = mSoundTriggerHelper.getModuleProperties(); + sEventLogger.log(new SoundTriggerLogger.StringEvent( + "getModuleProperties(): " + properties.toString())); + return properties; + } + } } /** |