Fix SoundTriggerModel uses to GenericSoundModel.
Change-Id: I30308b39536864d7b9640367861730e3b1b12129
This commit is contained in:
@@ -21,9 +21,9 @@ import android.content.pm.PackageManager;
|
||||
import android.Manifest;
|
||||
import android.hardware.soundtrigger.IRecognitionStatusCallback;
|
||||
import android.hardware.soundtrigger.SoundTrigger;
|
||||
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
|
||||
import android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel;
|
||||
import android.hardware.soundtrigger.SoundTrigger.RecognitionConfig;
|
||||
import android.hardware.soundtrigger.SoundTrigger.SoundTriggerModel;
|
||||
import android.os.Parcel;
|
||||
import android.os.ParcelUuid;
|
||||
import android.os.RemoteException;
|
||||
@@ -117,12 +117,12 @@ public class SoundTriggerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundTrigger.SoundTriggerModel getSoundModel(ParcelUuid soundModelId) {
|
||||
public SoundTrigger.GenericSoundModel getSoundModel(ParcelUuid soundModelId) {
|
||||
enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER);
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "getSoundModel(): id = " + soundModelId);
|
||||
}
|
||||
SoundTrigger.SoundTriggerModel model = mDbHelper.getSoundTriggerModel(soundModelId.getUuid());
|
||||
SoundTrigger.GenericSoundModel model = mDbHelper.getGenericSoundModel(soundModelId.getUuid());
|
||||
if (model == null) {
|
||||
Slog.e(TAG, "Null model in database.");
|
||||
}
|
||||
@@ -130,12 +130,12 @@ public class SoundTriggerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSoundModel(SoundTrigger.SoundTriggerModel soundModel) {
|
||||
public void updateSoundModel(SoundTrigger.GenericSoundModel soundModel) {
|
||||
enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER);
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "updateSoundModel(): model = " + soundModel);
|
||||
}
|
||||
mDbHelper.updateSoundTriggerModel(soundModel);
|
||||
mDbHelper.updateGenericSoundModel(soundModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,7 +144,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "deleteSoundModel(): id = " + soundModelId);
|
||||
}
|
||||
mDbHelper.deleteSoundTriggerModel(soundModelId.getUuid());
|
||||
mDbHelper.deleteGenericSoundModel(soundModelId.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.android.test.soundtrigger;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.soundtrigger.SoundTrigger;
|
||||
import android.hardware.soundtrigger.SoundTrigger.SoundTriggerModel;
|
||||
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
|
||||
import android.media.soundtrigger.SoundTriggerManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
@@ -54,7 +54,7 @@ public class SoundTriggerUtil {
|
||||
*
|
||||
* @param soundModel The sound model to add/update.
|
||||
*/
|
||||
public boolean addOrUpdateSoundModel(SoundTriggerModel soundModel) {
|
||||
public boolean addOrUpdateSoundModel(GenericSoundModel soundModel) {
|
||||
try {
|
||||
mSoundTriggerService.updateSoundModel(soundModel);
|
||||
} catch (RemoteException e) {
|
||||
@@ -71,14 +71,14 @@ public class SoundTriggerUtil {
|
||||
* Gets the sound model for the given keyphrase, null if none exists.
|
||||
* If a sound model for a given keyphrase exists, and it needs to be updated,
|
||||
* it should be obtained using this method, updated and then passed in to
|
||||
* {@link #addOrUpdateSoundModel(SoundTriggerModel)} without changing the IDs.
|
||||
* {@link #addOrUpdateSoundModel(GenericSoundModel)} without changing the IDs.
|
||||
*
|
||||
* @param modelId The model ID to look-up the sound model for.
|
||||
* @return The sound model if one was found, null otherwise.
|
||||
*/
|
||||
@Nullable
|
||||
public SoundTriggerModel getSoundModel(UUID modelId) {
|
||||
SoundTriggerModel model = null;
|
||||
public GenericSoundModel getSoundModel(UUID modelId) {
|
||||
GenericSoundModel model = null;
|
||||
try {
|
||||
model = mSoundTriggerService.getSoundModel(new ParcelUuid(modelId));
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.UUID;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.hardware.soundtrigger.SoundTrigger;
|
||||
import android.hardware.soundtrigger.SoundTrigger.SoundTriggerModel;
|
||||
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
|
||||
import android.media.soundtrigger.SoundTriggerManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
@@ -56,7 +56,7 @@ public class TestSoundTriggerActivity extends Activity {
|
||||
// Generate a fake model to push.
|
||||
byte[] data = new byte[1024];
|
||||
mRandom.nextBytes(data);
|
||||
SoundTriggerModel model = new SoundTriggerModel(mModelUuid, mVendorUuid, data);
|
||||
GenericSoundModel model = new GenericSoundModel(mModelUuid, mVendorUuid, data);
|
||||
|
||||
boolean status = mSoundTriggerUtil.addOrUpdateSoundModel(model);
|
||||
if (status) {
|
||||
@@ -78,7 +78,7 @@ public class TestSoundTriggerActivity extends Activity {
|
||||
* Clears the enrollment information for the user.
|
||||
*/
|
||||
public void onUnEnrollButtonClicked(View v) {
|
||||
SoundTriggerModel soundModel = mSoundTriggerUtil.getSoundModel(mModelUuid);
|
||||
GenericSoundModel soundModel = mSoundTriggerUtil.getSoundModel(mModelUuid);
|
||||
if (soundModel == null) {
|
||||
Toast.makeText(this, "Sound model not found!!!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
@@ -99,7 +99,7 @@ public class TestSoundTriggerActivity extends Activity {
|
||||
* Uses the previously enrolled sound model and makes changes to it before pushing it back.
|
||||
*/
|
||||
public void onReEnrollButtonClicked(View v) {
|
||||
SoundTriggerModel soundModel = mSoundTriggerUtil.getSoundModel(mModelUuid);
|
||||
GenericSoundModel soundModel = mSoundTriggerUtil.getSoundModel(mModelUuid);
|
||||
if (soundModel == null) {
|
||||
Toast.makeText(this, "Sound model not found!!!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
@@ -107,7 +107,7 @@ public class TestSoundTriggerActivity extends Activity {
|
||||
// Generate a fake model to push.
|
||||
byte[] data = new byte[2048];
|
||||
mRandom.nextBytes(data);
|
||||
SoundTriggerModel updated = new SoundTriggerModel(soundModel.uuid,
|
||||
GenericSoundModel updated = new GenericSoundModel(soundModel.uuid,
|
||||
soundModel.vendorUuid, data);
|
||||
boolean status = mSoundTriggerUtil.addOrUpdateSoundModel(updated);
|
||||
if (status) {
|
||||
|
||||
Reference in New Issue
Block a user