Merge "Deprecate SoundTriggerModule"
This commit is contained in:
@@ -2017,26 +2017,14 @@ public class SoundTrigger {
|
||||
* - {@link #STATUS_BAD_VALUE} if modules is null
|
||||
* - {@link #STATUS_DEAD_OBJECT} if the binder transaction to the native service fails
|
||||
*
|
||||
* @deprecated Please use {@link #listModulesAsOriginator(ArrayList, Identity)} or
|
||||
* @removed Please use {@link #listModulesAsOriginator(ArrayList, Identity)} or
|
||||
* {@link #listModulesAsMiddleman(ArrayList, Identity, Identity)}, based on whether the
|
||||
* client is acting on behalf of its own identity or a separate identity.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static int listModules(@NonNull ArrayList<ModuleProperties> modules) {
|
||||
// TODO(ytai): This is a temporary hack to retain prior behavior, which makes
|
||||
// assumptions about process affinity and Binder context, namely that the binder calling ID
|
||||
// reliably reflects the originator identity.
|
||||
Identity middlemanIdentity = new Identity();
|
||||
middlemanIdentity.packageName = ActivityThread.currentOpPackageName();
|
||||
|
||||
Identity originatorIdentity = new Identity();
|
||||
originatorIdentity.pid = Binder.getCallingPid();
|
||||
originatorIdentity.uid = Binder.getCallingUid();
|
||||
|
||||
try (SafeCloseable ignored = ClearCallingIdentityContext.create()) {
|
||||
return listModulesAsMiddleman(modules, middlemanIdentity, originatorIdentity);
|
||||
}
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2051,10 +2039,11 @@ public class SoundTrigger {
|
||||
* - {@link #STATUS_NO_INIT} if the native service cannot be reached
|
||||
* - {@link #STATUS_BAD_VALUE} if modules is null
|
||||
* - {@link #STATUS_DEAD_OBJECT} if the binder transaction to the native service fails
|
||||
*
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(allOf = {RECORD_AUDIO, CAPTURE_AUDIO_HOTWORD})
|
||||
@Deprecated
|
||||
public static int listModulesAsOriginator(@NonNull ArrayList<ModuleProperties> modules,
|
||||
@NonNull Identity originatorIdentity) {
|
||||
try {
|
||||
@@ -2082,9 +2071,11 @@ public class SoundTrigger {
|
||||
* - {@link #STATUS_BAD_VALUE} if modules is null
|
||||
* - {@link #STATUS_DEAD_OBJECT} if the binder transaction to the native service fails
|
||||
*
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(SOUNDTRIGGER_DELEGATE_IDENTITY)
|
||||
@Deprecated
|
||||
public static int listModulesAsMiddleman(@NonNull ArrayList<ModuleProperties> modules,
|
||||
@NonNull Identity middlemanIdentity,
|
||||
@NonNull Identity originatorIdentity) {
|
||||
@@ -2123,30 +2114,14 @@ public class SoundTrigger {
|
||||
* is OK.
|
||||
* @return a valid sound module in case of success or null in case of error.
|
||||
*
|
||||
* @deprecated Please use
|
||||
* {@link #attachModuleAsOriginator(int, StatusListener, Handler, Identity)} or
|
||||
* {@link #attachModuleAsMiddleman(int, StatusListener, Handler, Identity, Identity)}, based
|
||||
* on whether the client is acting on behalf of its own identity or a separate identity.
|
||||
* @removed Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
private static SoundTriggerModule attachModule(int moduleId,
|
||||
@NonNull StatusListener listener,
|
||||
@Nullable Handler handler) {
|
||||
// TODO(ytai): This is a temporary hack to retain prior behavior, which makes
|
||||
// assumptions about process affinity and Binder context, namely that the binder calling ID
|
||||
// reliably reflects the originator identity.
|
||||
Identity middlemanIdentity = new Identity();
|
||||
middlemanIdentity.packageName = ActivityThread.currentOpPackageName();
|
||||
|
||||
Identity originatorIdentity = new Identity();
|
||||
originatorIdentity.pid = Binder.getCallingPid();
|
||||
originatorIdentity.uid = Binder.getCallingUid();
|
||||
|
||||
try (SafeCloseable ignored = ClearCallingIdentityContext.create()) {
|
||||
return attachModuleAsMiddleman(moduleId, listener, handler, middlemanIdentity,
|
||||
originatorIdentity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2162,10 +2137,11 @@ public class SoundTrigger {
|
||||
* @param originatorIdentity The identity of the originator, which will be used for permission
|
||||
* purposes.
|
||||
* @return a valid sound module in case of success or null in case of error.
|
||||
*
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(SOUNDTRIGGER_DELEGATE_IDENTITY)
|
||||
@Deprecated
|
||||
public static SoundTriggerModule attachModuleAsMiddleman(int moduleId,
|
||||
@NonNull SoundTrigger.StatusListener listener,
|
||||
@Nullable Handler handler, Identity middlemanIdentity,
|
||||
|
||||
@@ -102,7 +102,9 @@ public class SoundTriggerModule {
|
||||
* Detach from this module. The {@link SoundTrigger.StatusListener} callback will not be called
|
||||
* anymore and associated resources will be released.
|
||||
* All models must have been unloaded prior to detaching.
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@UnsupportedAppUsage
|
||||
public synchronized void detach() {
|
||||
try {
|
||||
@@ -131,7 +133,9 @@ public class SoundTriggerModule {
|
||||
* - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native
|
||||
* service fails
|
||||
* - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@UnsupportedAppUsage
|
||||
public synchronized int loadSoundModel(@NonNull SoundTrigger.SoundModel model,
|
||||
@NonNull int[] soundModelHandle) {
|
||||
@@ -191,8 +195,10 @@ public class SoundTriggerModule {
|
||||
* - {@link SoundTrigger#STATUS_BAD_VALUE} if the sound model handle is invalid
|
||||
* - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native
|
||||
* service fails
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@Deprecated
|
||||
public synchronized int unloadSoundModel(int soundModelHandle) {
|
||||
try {
|
||||
mService.unloadModel(soundModelHandle);
|
||||
@@ -219,8 +225,10 @@ public class SoundTriggerModule {
|
||||
* - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native
|
||||
* service fails
|
||||
* - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@Deprecated
|
||||
public synchronized int startRecognition(int soundModelHandle,
|
||||
SoundTrigger.RecognitionConfig config) {
|
||||
try {
|
||||
@@ -244,8 +252,10 @@ public class SoundTriggerModule {
|
||||
* - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native
|
||||
* service fails
|
||||
* - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence
|
||||
* @deprecated Use {@link android.media.soundtrigger.SoundTriggerManager} instead.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@Deprecated
|
||||
public synchronized int stopRecognition(int soundModelHandle) {
|
||||
try {
|
||||
mService.stopRecognition(soundModelHandle);
|
||||
|
||||
Reference in New Issue
Block a user