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

Commit c55b9be4 authored by Ytai Ben-tsvi's avatar Ytai Ben-tsvi Committed by Android (Google) Code Review
Browse files

Merge changes from topic "deprecate-sthal-2.4"

* changes:
  Remove STHAL 2.4
  Create a soundtrigger v2.3 CLI mock
parents 9a78d09c 3f1c392d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -536,7 +536,7 @@
    </hal>
    <hal format="hidl" optional="true">
        <name>android.hardware.soundtrigger</name>
        <version>2.3-4</version>
        <version>2.3</version>
        <interface>
            <name>ISoundTriggerHw</name>
            <instance>default</instance>
+3 −3
Original line number Diff line number Diff line
@@ -8,10 +8,10 @@ package {
}

java_binary {
    name: "sthal_cli_2.4",
    wrapper: "sthal_cli_2.4",
    name: "sthal_cli_2.3",
    wrapper: "sthal_cli_2.3",
    srcs: ["java/**/*.java"],
    static_libs: [
        "android.hardware.soundtrigger-V2.4-java",
        "android.hardware.soundtrigger-V2.3-java",
    ],
}
+1 −0
Original line number Diff line number Diff line
include platform/frameworks/base:/services/core/java/com/android/server/soundtrigger_middleware/OWNERS
+16 −73
Original line number Diff line number Diff line
@@ -13,15 +13,14 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.hardware.soundtrigger.V2_4.cli;
package android.hardware.soundtrigger.V2_3.cli;

import android.hardware.soundtrigger.V2_0.PhraseRecognitionExtra;
import android.hardware.soundtrigger.V2_0.RecognitionMode;
import android.hardware.soundtrigger.V2_0.SoundModelType;
import android.hardware.soundtrigger.V2_3.OptionalModelParameterRange;
import android.hardware.soundtrigger.V2_4.ISoundTriggerHw;
import android.hardware.soundtrigger.V2_4.ISoundTriggerHwCallback;
import android.hardware.soundtrigger.V2_4.ISoundTriggerHwGlobalCallback;
import android.hardware.soundtrigger.V2_3.ISoundTriggerHw;
import android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback;
import android.os.HidlMemoryUtil;
import android.os.HwBinder;
import android.os.RemoteException;
@@ -51,7 +50,7 @@ import java.util.concurrent.ConcurrentMap;
 */
public class SthalCli {
    private static SoundTriggerImpl mService;
    private static final Scanner scanner = new Scanner(System.in);
    private static final Scanner mScanner = new Scanner(System.in);

    public static void main(String[] args) {
        try {
@@ -79,7 +78,7 @@ public class SthalCli {
    }

    private static boolean processCommand() {
        String line = scanner.nextLine();
        String line = mScanner.nextLine();
        String[] tokens = line.split("\\s+");
        if (tokens.length < 1) {
            return false;
@@ -88,14 +87,6 @@ public class SthalCli {
            case "q":
                return false;

            case "a":
                mService.sendOnResourcesAvailable();
                return true;

            case "u":
                mService.sendModelUnloaded(Integer.parseInt(tokens[1]));
                return true;

            case "r":
                mService.sendRecognitionEvent(Integer.parseInt(tokens[1]),
                        Integer.parseInt(tokens[2]));
@@ -112,8 +103,6 @@ public class SthalCli {

            case "h":
                System.out.print("Available commands:\n" + "h - help\n" + "q - quit\n"
                        + "a - send onResourcesAvailable event\n"
                        + "u <model> - send modelUnloaded event\n"
                        + "r <model> <status> - send recognitionEvent\n"
                        + "p <model> <status> - send phraseRecognitionEvent\n"
                        + "d - dump models\n");
@@ -143,7 +132,6 @@ public class SthalCli {
            }
        }

        private ISoundTriggerHwGlobalCallback mGlobalCallback;
        private final ConcurrentMap<Integer, Model> mLoadedModels = new ConcurrentHashMap<>();
        private int mHandleCounter = 1;

@@ -161,16 +149,6 @@ public class SthalCli {
            });
        }

        public void sendOnResourcesAvailable() {
            if (mGlobalCallback != null) {
                try {
                    mGlobalCallback.onResourcesAvailable();
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }

        public void sendRecognitionEvent(int modelHandle, int status) {
            Model model = mLoadedModels.get(modelHandle);
            if (model != null && model.config != null) {
@@ -225,46 +203,31 @@ public class SthalCli {
            }
        }

        public void sendModelUnloaded(int modelHandle) {
            Model model = mLoadedModels.remove(modelHandle);
            if (model != null) {
                try {
                    model.callback.modelUnloaded(modelHandle);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }

        @Override
        public void registerGlobalCallback(ISoundTriggerHwGlobalCallback callback) {
            System.out.println("registerGlobalCallback()");
            mGlobalCallback = callback;
        }

        @Override
        public void loadSoundModel_2_4(SoundModel soundModel, ISoundTriggerHwCallback callback,
                loadSoundModel_2_4Callback _hidl_cb) {
        public void loadSoundModel_2_1(SoundModel soundModel,
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie,
                loadSoundModel_2_1Callback _hidl_cb) {
            int handle = mHandleCounter++;
            System.out.printf("loadSoundModel_2_4(soundModel=%s) -> %d%n", soundModel, handle);
            System.out.printf("loadSoundModel_2_1(soundModel=%s) -> %d%n", soundModel, handle);
            mLoadedModels.put(handle, new Model(callback, soundModel));
            _hidl_cb.onValues(0, handle);
        }

        @Override
        public void loadPhraseSoundModel_2_4(PhraseSoundModel soundModel,
                ISoundTriggerHwCallback callback, loadPhraseSoundModel_2_4Callback _hidl_cb) {
        public void loadPhraseSoundModel_2_1(PhraseSoundModel soundModel,
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie,
                loadPhraseSoundModel_2_1Callback _hidl_cb) {
             int handle = mHandleCounter++;
            System.out.printf("loadPhraseSoundModel_2_4(soundModel=%s) -> %d%n", soundModel,
            System.out.printf("loadPhraseSoundModel_2_1(soundModel=%s) -> %d%n", soundModel,
                    handle);
            mLoadedModels.put(handle, new Model(callback, soundModel));
            _hidl_cb.onValues(0, handle);
        }

        @Override
        public int startRecognition_2_4(int modelHandle,
        public int startRecognition_2_3(int modelHandle,
                android.hardware.soundtrigger.V2_3.RecognitionConfig config) {
            System.out.printf("startRecognition_2_4(modelHandle=%d)%n", modelHandle);
            System.out.printf("startRecognition_2_3(modelHandle=%d)%n", modelHandle);
            Model model = mLoadedModels.get(modelHandle);
            if (model != null) {
                model.config = config;
@@ -329,12 +292,6 @@ public class SthalCli {
        ////////////////////////////////////////////////////////////////////////////////////////////
        // Everything below is not implemented and not expected to be called.

        @Override
        public int startRecognition_2_3(int modelHandle,
                android.hardware.soundtrigger.V2_3.RecognitionConfig config) {
            throw new UnsupportedOperationException();
        }

        @Override
        public int setParameter(int modelHandle, int modelParam, int value) {
            throw new UnsupportedOperationException();
@@ -345,20 +302,6 @@ public class SthalCli {
            throw new UnsupportedOperationException();
        }

        @Override
        public void loadSoundModel_2_1(SoundModel soundModel,
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie,
                loadSoundModel_2_1Callback _hidl_cb) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void loadPhraseSoundModel_2_1(PhraseSoundModel soundModel,
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie,
                loadPhraseSoundModel_2_1Callback _hidl_cb) {
            throw new UnsupportedOperationException();
        }

        @Override
        public int startRecognition_2_1(int modelHandle, RecognitionConfig config,
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie) {
+7 −0
Original line number Diff line number Diff line
#!/system/bin/sh
# Script to start "sthal_cli_2.3" on the device
#
base=/system
export CLASSPATH=$base/framework/sthal_cli_2.3.jar
exec app_process $base/bin android.hardware.soundtrigger.V2_3.cli.SthalCli "$@"
Loading