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

Commit 58a1c382 authored by Ytai Ben-Tsvi's avatar Ytai Ben-Tsvi
Browse files

Print description of loaded models in dumpsys

Bug: 154020971
Test: Manual verification of dumpsys.
Change-Id: Ibae9d41ec7470cc0ddabfe087910e1eac172f39a
parent 4d38fbb4
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -313,6 +313,14 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware

    /** State of a sound model. */
    static class ModelState {
        ModelState(SoundModel model) {
            this.description = ObjectPrinter.print(model, true, 16);
        }

        ModelState(PhraseSoundModel model) {
            this.description = ObjectPrinter.print(model, true, 16);
        }

        /** Activity state of a sound model. */
        enum Activity {
            /** Model is loaded, recognition is inactive. */
@@ -324,6 +332,9 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
        /** Activity state. */
        Activity activityState = Activity.LOADED;

        /** Human-readable description of the model. */
        final String description;

        /**
         * A map of known parameter support. A missing key means we don't know yet whether the
         * parameter is supported. A null value means it is known to not be supported. A non-null
@@ -419,7 +430,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
                // From here on, every exception isn't client's fault.
                try {
                    int handle = mDelegate.loadModel(model);
                    mLoadedModels.put(handle, new ModelState());
                    mLoadedModels.put(handle, new ModelState(model));
                    return handle;
                } catch (Exception e) {
                    throw handleException(e);
@@ -443,7 +454,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
                // From here on, every exception isn't client's fault.
                try {
                    int handle = mDelegate.loadPhraseModel(model);
                    mLoadedModels.put(handle, new ModelState());
                    mLoadedModels.put(handle, new ModelState(model));
                    return handle;
                } catch (Exception e) {
                    throw handleException(e);
@@ -711,6 +722,8 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
                    pw.print(entry.getKey());
                    pw.print('\t');
                    pw.print(entry.getValue().activityState.name());
                    pw.print('\t');
                    pw.print(entry.getValue().description);
                    pw.println();
                }
            } else {