Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a8fae98 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "voiceinteraction-model-enrollment"

* changes:
  async enrollment support AlwaysOnHotwordDetector
  add KeyphraseModelManager
parents a355c8c7 f771e6c9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43525,7 +43525,7 @@ package android.service.voice {
    field public static final int STATE_HARDWARE_UNAVAILABLE = -2; // 0xfffffffe
    field public static final int STATE_KEYPHRASE_ENROLLED = 2; // 0x2
    field public static final int STATE_KEYPHRASE_UNENROLLED = 1; // 0x1
    field public static final int STATE_KEYPHRASE_UNSUPPORTED = -1; // 0xffffffff
    field @Deprecated public static final int STATE_KEYPHRASE_UNSUPPORTED = -1; // 0xffffffff
  }
  public abstract static class AlwaysOnHotwordDetector.Callback {
+53 −0
Original line number Diff line number Diff line
@@ -3636,9 +3636,34 @@ package android.hardware.radio {
package android.hardware.soundtrigger {
  public class SoundTrigger {
    field public static final int RECOGNITION_MODE_GENERIC = 8; // 0x8
    field public static final int RECOGNITION_MODE_USER_AUTHENTICATION = 4; // 0x4
    field public static final int RECOGNITION_MODE_USER_IDENTIFICATION = 2; // 0x2
    field public static final int RECOGNITION_MODE_VOICE_TRIGGER = 1; // 0x1
    field public static final int STATUS_OK = 0; // 0x0
  }
  public static final class SoundTrigger.Keyphrase implements android.os.Parcelable {
    ctor public SoundTrigger.Keyphrase(int, int, @NonNull java.util.Locale, @NonNull String, @Nullable int[]);
    method @NonNull public static android.hardware.soundtrigger.SoundTrigger.Keyphrase readFromParcel(@NonNull android.os.Parcel);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.soundtrigger.SoundTrigger.Keyphrase> CREATOR;
    field public final int id;
    field @NonNull public final java.util.Locale locale;
    field public final int recognitionModes;
    field @NonNull public final String text;
    field @NonNull public final int[] users;
  }
  public static final class SoundTrigger.KeyphraseSoundModel extends android.hardware.soundtrigger.SoundTrigger.SoundModel implements android.os.Parcelable {
    ctor public SoundTrigger.KeyphraseSoundModel(@NonNull java.util.UUID, @NonNull java.util.UUID, @Nullable byte[], @Nullable android.hardware.soundtrigger.SoundTrigger.Keyphrase[], int);
    ctor public SoundTrigger.KeyphraseSoundModel(@NonNull java.util.UUID, @NonNull java.util.UUID, @Nullable byte[], @Nullable android.hardware.soundtrigger.SoundTrigger.Keyphrase[]);
    method @NonNull public static android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel readFromParcel(@NonNull android.os.Parcel);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel> CREATOR;
    field @NonNull public final android.hardware.soundtrigger.SoundTrigger.Keyphrase[] keyphrases;
  }
  public static final class SoundTrigger.ModelParamRange implements android.os.Parcelable {
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.soundtrigger.SoundTrigger.ModelParamRange> CREATOR;
@@ -3677,6 +3702,16 @@ package android.hardware.soundtrigger {
    method public boolean isCaptureAvailable();
  }
  public static class SoundTrigger.SoundModel {
    field public static final int TYPE_GENERIC_SOUND = 1; // 0x1
    field public static final int TYPE_KEYPHRASE = 0; // 0x0
    field @NonNull public final byte[] data;
    field public final int type;
    field @NonNull public final java.util.UUID uuid;
    field @NonNull public final java.util.UUID vendorUuid;
    field public final int version;
  }
}
package android.hardware.usb {
@@ -5881,6 +5916,16 @@ package android.media.tv.tuner.frontend {
}
package android.media.voice {
  public final class KeyphraseModelManager {
    method @RequiresPermission("android.permission.MANAGE_VOICE_KEYPHRASES") public void deleteKeyphraseSoundModel(int, @NonNull java.util.Locale);
    method @Nullable @RequiresPermission("android.permission.MANAGE_VOICE_KEYPHRASES") public android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int, @NonNull java.util.Locale);
    method @RequiresPermission("android.permission.MANAGE_VOICE_KEYPHRASES") public void updateKeyphraseSoundModel(@NonNull android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel);
  }
}
package android.metrics {
  public class LogMaker {
@@ -10463,6 +10508,14 @@ package android.service.trust {
}
package android.service.voice {
  public class VoiceInteractionService extends android.app.Service {
    method @NonNull @RequiresPermission("android.permission.MANAGE_VOICE_KEYPHRASES") public final android.media.voice.KeyphraseModelManager createKeyphraseModelManager();
  }
}
package android.service.wallpaper {
  public class WallpaperService.Engine {
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ class ConversionUtil {
        aidlPhrase.id = apiPhrase.id;
        aidlPhrase.recognitionModes = api2aidlRecognitionModes(apiPhrase.recognitionModes);
        aidlPhrase.users = Arrays.copyOf(apiPhrase.users, apiPhrase.users.length);
        aidlPhrase.locale = apiPhrase.locale;
        aidlPhrase.locale = apiPhrase.locale.toLanguageTag();
        aidlPhrase.text = apiPhrase.text;
        return aidlPhrase;
    }
+34 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware.soundtrigger;

import android.Manifest;
import android.annotation.IntDef;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -24,7 +25,6 @@ import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.service.voice.AlwaysOnHotwordDetector;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.AttributeSet;
@@ -35,6 +35,8 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@@ -66,9 +68,10 @@ public class KeyphraseEnrollmentInfo {
            "com.android.intent.action.MANAGE_VOICE_KEYPHRASES";
    /**
     * Intent extra: The intent extra for the specific manage action that needs to be performed.
     * Possible values are {@link AlwaysOnHotwordDetector#MANAGE_ACTION_ENROLL},
     * {@link AlwaysOnHotwordDetector#MANAGE_ACTION_RE_ENROLL}
     * or {@link AlwaysOnHotwordDetector#MANAGE_ACTION_UN_ENROLL}.
     *
     * @see #MANAGE_ACTION_ENROLL
     * @see #MANAGE_ACTION_RE_ENROLL
     * @see #MANAGE_ACTION_UN_ENROLL
     */
    public static final String EXTRA_VOICE_KEYPHRASE_ACTION =
            "com.android.intent.extra.VOICE_KEYPHRASE_ACTION";
@@ -85,6 +88,31 @@ public class KeyphraseEnrollmentInfo {
    public static final String EXTRA_VOICE_KEYPHRASE_LOCALE =
            "com.android.intent.extra.VOICE_KEYPHRASE_LOCALE";

    /**
     * Keyphrase management actions used with the {@link #EXTRA_VOICE_KEYPHRASE_ACTION} intent extra
     * @hide
     */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = { "MANAGE_ACTION_" }, value = {
            MANAGE_ACTION_ENROLL,
            MANAGE_ACTION_RE_ENROLL,
            MANAGE_ACTION_UN_ENROLL
    })
    public @interface ManageActions {}

    /**
     * Indicates desired action to enroll keyphrase model
     */
    public static final int MANAGE_ACTION_ENROLL = 0;
    /**
     * Indicates desired action to re-enroll keyphrase model
     */
    public static final int MANAGE_ACTION_RE_ENROLL = 1;
    /**
     * Indicates desired action to un-enroll keyphrase model
     */
    public static final int MANAGE_ACTION_UN_ENROLL = 2;

    /**
     * List of available keyphrases.
     */
@@ -294,15 +322,13 @@ public class KeyphraseEnrollmentInfo {
     * for the locale.
     *
     * @param action The enrollment related action that this intent is supposed to perform.
     *        This can be one of {@link AlwaysOnHotwordDetector#MANAGE_ACTION_ENROLL},
     *        {@link AlwaysOnHotwordDetector#MANAGE_ACTION_RE_ENROLL}
     *        or {@link AlwaysOnHotwordDetector#MANAGE_ACTION_UN_ENROLL}
     * @param keyphrase The keyphrase that the user needs to be enrolled to.
     * @param locale The locale for which the enrollment needs to be performed.
     * @return An {@link Intent} to manage the keyphrase. This can be null if managing the
     *         given keyphrase/locale combination isn't possible.
     */
    public Intent getManageKeyphraseIntent(int action, String keyphrase, Locale locale) {
    public Intent getManageKeyphraseIntent(@ManageActions int action, String keyphrase,
            Locale locale) {
        if (mKeyphrasePackageMap == null || mKeyphrasePackageMap.isEmpty()) {
            Slog.w(TAG, "No enrollment application exists");
            return null;
+19 −0
Original line number Diff line number Diff line
/**
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.soundtrigger;

parcelable KeyphraseMetadata;
Loading