diff options
author | Nicholas Ambur <nambur@google.com> | 2020-01-14 20:28:37 -0800 |
---|---|---|
committer | Nicholas Ambur <nambur@google.com> | 2020-01-22 16:40:13 -0800 |
commit | ef84fc48433d47ea9c91dcb3273ae3d74ca6d32a (patch) | |
tree | 7ae618ac7d63eb705ca913274d800c38cbc98b58 /services/voiceinteraction | |
parent | 4ec0be1fafd70ff43f5c579c73627b147168b194 (diff) |
add KeyphraseModelManager
Exposes a set of @SystemApi's allowing the active VoiceInteractionService
to enroll voice models.
Bug: 147159435
Test: manual tested enrollment and unenrollment via bundled
hotwordenrollment application and test app.
Change-Id: I94ef3550df236486401a0a6f9de9d874b9bf9b46
Diffstat (limited to 'services/voiceinteraction')
2 files changed, 25 insertions, 16 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/DatabaseHelper.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/DatabaseHelper.java index c58b6da64baa..195a9e49d70d 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/DatabaseHelper.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/DatabaseHelper.java @@ -46,18 +46,21 @@ public class DatabaseHelper extends SQLiteOpenHelper { private static final String NAME = "sound_model.db"; private static final int VERSION = 7; - public static interface SoundModelContract { - public static final String TABLE = "sound_model"; - public static final String KEY_MODEL_UUID = "model_uuid"; - public static final String KEY_VENDOR_UUID = "vendor_uuid"; - public static final String KEY_KEYPHRASE_ID = "keyphrase_id"; - public static final String KEY_TYPE = "type"; - public static final String KEY_DATA = "data"; - public static final String KEY_RECOGNITION_MODES = "recognition_modes"; - public static final String KEY_LOCALE = "locale"; - public static final String KEY_HINT_TEXT = "hint_text"; - public static final String KEY_USERS = "users"; - public static final String KEY_MODEL_VERSION = "model_version"; + /** + * Keyphrase sound model database columns + */ + public interface SoundModelContract { + String TABLE = "sound_model"; + String KEY_MODEL_UUID = "model_uuid"; + String KEY_VENDOR_UUID = "vendor_uuid"; + String KEY_KEYPHRASE_ID = "keyphrase_id"; + String KEY_TYPE = "type"; + String KEY_DATA = "data"; + String KEY_RECOGNITION_MODES = "recognition_modes"; + String KEY_LOCALE = "locale"; + String KEY_HINT_TEXT = "hint_text"; + String KEY_USERS = "users"; + String KEY_MODEL_VERSION = "model_version"; } // Table Create Statement @@ -173,7 +176,8 @@ public class DatabaseHelper extends SQLiteOpenHelper { soundModel.keyphrases[0].recognitionModes); values.put(SoundModelContract.KEY_USERS, getCommaSeparatedString(soundModel.keyphrases[0].users)); - values.put(SoundModelContract.KEY_LOCALE, soundModel.keyphrases[0].locale); + values.put(SoundModelContract.KEY_LOCALE, + soundModel.keyphrases[0].locale.toLanguageTag()); values.put(SoundModelContract.KEY_HINT_TEXT, soundModel.keyphrases[0].text); try { return db.insertWithOnConflict(SoundModelContract.TABLE, null, values, @@ -257,8 +261,8 @@ public class DatabaseHelper extends SQLiteOpenHelper { c.getColumnIndex(SoundModelContract.KEY_RECOGNITION_MODES)); int[] users = getArrayForCommaSeparatedString( c.getString(c.getColumnIndex(SoundModelContract.KEY_USERS))); - String modelLocale = c.getString( - c.getColumnIndex(SoundModelContract.KEY_LOCALE)); + Locale modelLocale = Locale.forLanguageTag(c.getString( + c.getColumnIndex(SoundModelContract.KEY_LOCALE))); String text = c.getString( c.getColumnIndex(SoundModelContract.KEY_HINT_TEXT)); int version = c.getInt( @@ -431,8 +435,11 @@ public class DatabaseHelper extends SQLiteOpenHelper { } } + /** + * Dumps contents of database for dumpsys + */ public void dump(PrintWriter pw) { - synchronized(this) { + synchronized (this) { String selectQuery = "SELECT * FROM " + SoundModelContract.TABLE; SQLiteDatabase db = getReadableDatabase(); Cursor c = db.rawQuery(selectQuery, null); diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index 506c67e12528..ec0a1bacf094 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -923,6 +923,8 @@ public class VoiceInteractionManagerService extends SystemService { } //----------------- Model management APIs --------------------------------// + // TODO: add check to only allow active voice interaction service or keyphrase enrollment + // application to manage voice models @Override public KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, String bcp47Locale) { |