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

Commit 05589720 authored by Sandeep Siddhartha's avatar Sandeep Siddhartha
Browse files

Move sound trigger calls to VoiceInteractionManagerService

- This ensures that any data being loaded on the DSP comes from the framework

Change-Id: Ie15f0994850ba8f298ca07c49fe0b89e066d9e2b
parent 6eb262c3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/location/IGeofenceHardware.aidl \
	core/java/android/hardware/location/IGeofenceHardwareCallback.aidl \
	core/java/android/hardware/location/IGeofenceHardwareMonitorCallback.aidl \
	core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl \
	core/java/android/hardware/usb/IUsbManager.aidl \
	core/java/android/net/IConnectivityManager.aidl \
	core/java/android/net/IEthernetManager.aidl \
+1 −1
Original line number Diff line number Diff line
@@ -27242,7 +27242,7 @@ package android.service.voice {
    field public static final int RECOGNITION_STATUS_NOT_REQUESTED = 2; // 0x2
    field public static final int RECOGNITION_STATUS_REQUESTED = 4; // 0x4
    field public static final int STATUS_ERROR = -2147483648; // 0x80000000
    field public static final int STATUS_OK = 1; // 0x1
    field public static final int STATUS_OK = 0; // 0x0
  }
  public static abstract interface AlwaysOnHotwordDetector.Callback {
+39 −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");
@@ -16,42 +16,24 @@

package android.hardware.soundtrigger;

import java.util.UUID;

/**
 * Properties of the DSP hardware on the device.
 *
 * @hide
 */
public class DspInfo {
    /**
     * Unique voice engine Id (changes with each version).
     */
    public final UUID voiceEngineId;

oneway interface IRecognitionStatusCallback {
    /**
     * Human readable voice detection engine implementor.
     */
    public final String voiceEngineImplementor;
    /**
     * Human readable voice detection engine description.
     * Called when the keyphrase is spoken.
     *
     * @param data Optional trigger audio data, if it was requested and is available.
     *        TODO: See if the data being passed in works well, if not use shared memory.
     *        This *MUST* not exceed 100K.
     */
    public final String voiceEngineDescription;
    void onDetected(in byte[] data);
    /**
     * Human readable voice detection engine version
     * Called when the detection for the associated keyphrase starts.
     */
    public final int voiceEngineVersion;
    void onDetectionStarted();
    /**
     * Rated power consumption when detection is active.
     * Called when the detection for the associated keyphrase stops.
     */
    public final int powerConsumptionMw;

    public DspInfo(UUID voiceEngineId, String voiceEngineImplementor,
            String voiceEngineDescription, int version, int powerConsumptionMw) {
        this.voiceEngineId = voiceEngineId;
        this.voiceEngineImplementor = voiceEngineImplementor;
        this.voiceEngineDescription = voiceEngineDescription;
        this.voiceEngineVersion = version;
        this.powerConsumptionMw = powerConsumptionMw;
    }
    void onDetectionStopped();
}
 No newline at end of file
+0 −4
Original line number Diff line number Diff line
package android.hardware.soundtrigger;

// @hide
parcelable Keyphrase;
 No newline at end of file
+0 −135
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;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * A Voice Keyphrase.
 *
 * @hide
 */
public class Keyphrase implements Parcelable {
    /** A unique identifier for this keyphrase */
    public final int id;
    /** A hint text to display corresponding to this keyphrase, e.g. "Hello There". */
    public final String hintText;
    /** The locale of interest when using this Keyphrase. */
    public final String locale;
    /** The various recognition modes supported by this keyphrase */
    public final int recognitionModeFlags;
    /** The users associated with this keyphrase */
    public final int[] users;

    public static final Parcelable.Creator<Keyphrase> CREATOR
            = new Parcelable.Creator<Keyphrase>() {
        public Keyphrase createFromParcel(Parcel in) {
            return Keyphrase.fromParcel(in);
        }

        public Keyphrase[] newArray(int size) {
            return new Keyphrase[size];
        }
    };

    private static Keyphrase fromParcel(Parcel in) {
        int id = in.readInt();
        String hintText = in.readString();
        String locale = in.readString();
        int recognitionModeFlags = in.readInt();
        int numUsers = in.readInt();
        int[] users = null;
        if (numUsers > 0) {
            users = new int[numUsers];
            in.readIntArray(users);
        }
        return new Keyphrase(id, hintText, locale, recognitionModeFlags, users);
    }

    public Keyphrase(int id, String hintText, String locale, int recognitionModeFlags,
            int[] users) {
        this.id = id;
        this.hintText = hintText;
        this.locale = locale;
        this.recognitionModeFlags = recognitionModeFlags;
        this.users = users;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(hintText);
        dest.writeString(locale);
        dest.writeInt(recognitionModeFlags);
        if (users != null) {
            dest.writeInt(users.length);
            dest.writeIntArray(users);
        } else {
            dest.writeInt(0);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((hintText == null) ? 0 : hintText.hashCode());
        result = prime * result + id;
        result = prime * result + ((locale == null) ? 0 : locale.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Keyphrase other = (Keyphrase) obj;
        if (hintText == null) {
            if (other.hintText != null)
                return false;
        } else if (!hintText.equals(other.hintText))
            return false;
        if (id != other.id)
            return false;
        if (locale == null) {
            if (other.locale != null)
                return false;
        } else if (!locale.equals(other.locale))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Keyphrase[id=" + id + ", text=" + hintText + ", locale=" + locale
                + ", recognitionModes=" + recognitionModeFlags + "]";
    }

    protected SoundTrigger.Keyphrase convertToSoundTriggerKeyphrase() {
        return new SoundTrigger.Keyphrase(id, recognitionModeFlags, locale, hintText, users);
    }
}
Loading