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

Commit 56686819 authored by Sergey Volnov's avatar Sergey Volnov Committed by Android (Google) Code Review
Browse files

Merge "Implement preriodic trusted process restarting for hotword detectors." into sc-dev

parents b4350b9d 1b2b909a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
    private static final int MSG_DETECTION_RESUME = 5;
    private static final int MSG_HOTWORD_REJECTED = 6;
    private static final int MSG_HOTWORD_STATUS_REPORTED = 7;
    private static final int MSG_PROCESS_RESTARTED = 8;

    private final String mText;
    private final Locale mLocale;
@@ -1212,6 +1213,12 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
            message.arg1 = status;
            message.sendToTarget();
        }

        @Override
        public void onProcessRestarted() {
            Slog.i(TAG, "onProcessRestarted");
            mHandler.sendEmptyMessage(MSG_PROCESS_RESTARTED);
        }
    }

    class MyHandler extends Handler {
@@ -1246,6 +1253,9 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
                case MSG_HOTWORD_STATUS_REPORTED:
                    mExternalCallback.onHotwordDetectionServiceInitialized(msg.arg1);
                    break;
                case MSG_PROCESS_RESTARTED:
                    mExternalCallback.onHotwordDetectionServiceRestarted();
                    break;
                default:
                    super.handleMessage(msg);
            }
+1 −3
Original line number Diff line number Diff line
@@ -291,9 +291,7 @@ public abstract class HotwordDetectionService extends Service {
            @Nullable PersistableBundle options,
            @Nullable SharedMemory sharedMemory,
            @DurationMillisLong long callbackTimeoutMillis,
            @Nullable IntConsumer statusCallback) {
        // TODO: Handle the unimplemented case by throwing?
    }
            @Nullable IntConsumer statusCallback) {}

    /**
     * Called when the {@link VoiceInteractionService} requests that this service
+27 −7
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector {
            this.mCallback = callback;
        }

        /** TODO: onDetected */
        /** Called when the detected result is valid. */
        @Override
        public void onDetected(
                @Nullable HotwordDetectedResult hotwordDetectedResult,
@@ -150,33 +150,45 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector {
        public void onKeyphraseDetected(
                SoundTrigger.KeyphraseRecognitionEvent recognitionEvent,
                HotwordDetectedResult result) {

            if (DEBUG) {
                Slog.i(TAG, "Ignored #onKeyphraseDetected event");
            }
        }

        @Override
        public void onGenericSoundTriggerDetected(
                SoundTrigger.GenericRecognitionEvent recognitionEvent) throws RemoteException {

            if (DEBUG) {
                Slog.i(TAG, "Ignored #onGenericSoundTriggerDetected event");
            }
        }

        @Override
        public void onRejected(HotwordRejectedResult result) throws RemoteException {

            if (DEBUG) {
                Slog.i(TAG, "Ignored #onRejected event");
            }
        }

        @Override
        public void onError(int status) throws RemoteException {

            if (DEBUG) {
                Slog.i(TAG, "Ignored #onError (" + status + ") event");
            }
        }

        @Override
        public void onRecognitionPaused() throws RemoteException {

            if (DEBUG) {
                Slog.i(TAG, "Ignored #onRecognitionPaused event");
            }
        }

        @Override
        public void onRecognitionResumed() throws RemoteException {

            if (DEBUG) {
                Slog.i(TAG, "Ignored #onRecognitionResumed event");
            }
        }

        @Override
@@ -187,6 +199,14 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector {
                    mCallback,
                    status));
        }

        @Override
        public void onProcessRestarted() throws RemoteException {
            Slog.v(TAG, "onProcessRestarted()");
            mHandler.sendMessage(obtainMessage(
                    HotwordDetector.Callback::onHotwordDetectionServiceRestarted,
                    mCallback));
        }
    }

    /** @hide */
+3 −0
Original line number Diff line number Diff line
@@ -78,4 +78,7 @@ oneway interface IHotwordRecognitionStatusCallback {
     * @param status The status about the result of requesting update state action.
     */
    void onStatusReported(int status);

    /** Called when the hotword detection process is restarted */
    void onProcessRestarted();
}
+1 −1
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public interface ServiceConnector<I extends IInterface> {
        private final int mBindingFlags;
        private final @Nullable Function<IBinder, I> mBinderAsInterface;
        private final @NonNull Handler mHandler;
        private final @NonNull Executor mExecutor;
        protected final @NonNull Executor mExecutor;

        private volatile I mService = null;
        private boolean mBinding = false;
Loading