use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project platform_frameworks_base by android.
the class SoundTriggerTestService method unloadModel.
public synchronized void unloadModel(UUID modelUuid) {
ModelInfo modelInfo = mModelInfoMap.get(modelUuid);
if (modelInfo == null) {
postError("Could not find model for: " + modelUuid.toString());
return;
}
postMessage("Unloading model: " + modelInfo.name);
GenericSoundModel soundModel = mSoundTriggerUtil.getSoundModel(modelUuid);
if (soundModel == null) {
postErrorToast("Sound model not found for " + modelInfo.name + "!");
return;
}
modelInfo.detector = null;
boolean status = mSoundTriggerUtil.deleteSoundModel(modelUuid);
if (status) {
postToast("Successfully unloaded " + modelInfo.name + ", UUID=" + soundModel.uuid);
setModelState(modelInfo, "Unloaded");
} else {
postErrorToast("Failed to unload " + modelInfo.name + ", UUID=" + soundModel.uuid + "!");
setModelState(modelInfo, "Failed to unload");
}
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project platform_frameworks_base by android.
the class SoundTriggerDbHelper method deleteGenericSoundModel.
public boolean deleteGenericSoundModel(UUID model_uuid) {
synchronized (this) {
GenericSoundModel soundModel = getGenericSoundModel(model_uuid);
if (soundModel == null) {
return false;
}
// Delete all sound models for the given keyphrase and specified user.
SQLiteDatabase db = getWritableDatabase();
String soundModelClause = GenericSoundModelContract.KEY_MODEL_UUID + "='" + soundModel.uuid.toString() + "'";
try {
return db.delete(GenericSoundModelContract.TABLE, soundModelClause, null) != 0;
} finally {
db.close();
}
}
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project android_frameworks_base by ResurrectionRemix.
the class SoundTriggerDbHelper method getGenericSoundModel.
public GenericSoundModel getGenericSoundModel(UUID model_uuid) {
synchronized (this) {
// Find the corresponding sound model ID for the keyphrase.
String selectQuery = "SELECT * FROM " + GenericSoundModelContract.TABLE + " WHERE " + GenericSoundModelContract.KEY_MODEL_UUID + "= '" + model_uuid + "'";
SQLiteDatabase db = getReadableDatabase();
Cursor c = db.rawQuery(selectQuery, null);
try {
if (c.moveToFirst()) {
do {
byte[] data = c.getBlob(c.getColumnIndex(GenericSoundModelContract.KEY_DATA));
String vendor_uuid = c.getString(c.getColumnIndex(GenericSoundModelContract.KEY_VENDOR_UUID));
return new GenericSoundModel(model_uuid, UUID.fromString(vendor_uuid), data);
} while (c.moveToNext());
}
} finally {
c.close();
db.close();
}
}
return null;
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project android_frameworks_base by ResurrectionRemix.
the class SoundTriggerTestService method reloadModel.
public synchronized void reloadModel(UUID modelUuid) {
ModelInfo modelInfo = mModelInfoMap.get(modelUuid);
if (modelInfo == null) {
postError("Could not find model for: " + modelUuid.toString());
return;
}
postMessage("Reloading model: " + modelInfo.name);
GenericSoundModel soundModel = mSoundTriggerUtil.getSoundModel(modelUuid);
if (soundModel == null) {
postErrorToast("Sound model not found for " + modelInfo.name + "!");
return;
}
GenericSoundModel updated = createNewSoundModel(modelInfo);
boolean status = mSoundTriggerUtil.addOrUpdateSoundModel(updated);
if (status) {
postToast("Successfully reloaded " + modelInfo.name + ", UUID=" + modelInfo.modelUuid);
setModelState(modelInfo, "Reloaded");
} else {
postErrorToast("Failed to reload " + modelInfo.name + ", UUID=" + modelInfo.modelUuid + "!");
setModelState(modelInfo, "Failed to reload");
}
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project android_frameworks_base by DirtyUnicorns.
the class SoundTriggerDbHelper method getGenericSoundModel.
public GenericSoundModel getGenericSoundModel(UUID model_uuid) {
synchronized (this) {
// Find the corresponding sound model ID for the keyphrase.
String selectQuery = "SELECT * FROM " + GenericSoundModelContract.TABLE + " WHERE " + GenericSoundModelContract.KEY_MODEL_UUID + "= '" + model_uuid + "'";
SQLiteDatabase db = getReadableDatabase();
Cursor c = db.rawQuery(selectQuery, null);
try {
if (c.moveToFirst()) {
do {
byte[] data = c.getBlob(c.getColumnIndex(GenericSoundModelContract.KEY_DATA));
String vendor_uuid = c.getString(c.getColumnIndex(GenericSoundModelContract.KEY_VENDOR_UUID));
return new GenericSoundModel(model_uuid, UUID.fromString(vendor_uuid), data);
} while (c.moveToNext());
}
} finally {
c.close();
db.close();
}
}
return null;
}
Aggregations