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

Commit 68c0c0ee authored by Charles Chen's avatar Charles Chen Committed by Automerger Merge Worker
Browse files

Merge "Skip VisualQueryDetectionService being destroyed for SDK bump" into udc-dev am: e3176790

parents eeee7dfc e3176790
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -389,7 +389,7 @@ public class VoiceInteractionService extends Service {
        // It's still guaranteed to have been stopped.
        // It's still guaranteed to have been stopped.
        // This helps with cases where the voice interaction implementation is changed
        // This helps with cases where the voice interaction implementation is changed
        // by the user.
        // by the user.
        safelyShutdownAllHotwordDetectors();
        safelyShutdownAllHotwordDetectors(true);
    }
    }


    /**
    /**
@@ -715,7 +715,7 @@ public class VoiceInteractionService extends Service {
        synchronized (mLock) {
        synchronized (mLock) {
            if (!CompatChanges.isChangeEnabled(MULTIPLE_ACTIVE_HOTWORD_DETECTORS)) {
            if (!CompatChanges.isChangeEnabled(MULTIPLE_ACTIVE_HOTWORD_DETECTORS)) {
                // Allow only one concurrent recognition via the APIs.
                // Allow only one concurrent recognition via the APIs.
                safelyShutdownAllHotwordDetectors();
                safelyShutdownAllHotwordDetectors(false);
            } else {
            } else {
                for (HotwordDetector detector : mActiveDetectors) {
                for (HotwordDetector detector : mActiveDetectors) {
                    if (detector.isUsingSandboxedDetectionService()
                    if (detector.isUsingSandboxedDetectionService()
@@ -878,7 +878,7 @@ public class VoiceInteractionService extends Service {
        synchronized (mLock) {
        synchronized (mLock) {
            if (!CompatChanges.isChangeEnabled(MULTIPLE_ACTIVE_HOTWORD_DETECTORS)) {
            if (!CompatChanges.isChangeEnabled(MULTIPLE_ACTIVE_HOTWORD_DETECTORS)) {
                // Allow only one concurrent recognition via the APIs.
                // Allow only one concurrent recognition via the APIs.
                safelyShutdownAllHotwordDetectors();
                safelyShutdownAllHotwordDetectors(false);
            } else {
            } else {
                for (HotwordDetector detector : mActiveDetectors) {
                for (HotwordDetector detector : mActiveDetectors) {
                    if (!detector.isUsingSandboxedDetectionService()) {
                    if (!detector.isUsingSandboxedDetectionService()) {
@@ -1062,11 +1062,14 @@ public class VoiceInteractionService extends Service {
        return mKeyphraseEnrollmentInfo.getKeyphraseMetadata(keyphrase, locale) != null;
        return mKeyphraseEnrollmentInfo.getKeyphraseMetadata(keyphrase, locale) != null;
    }
    }


    private void safelyShutdownAllHotwordDetectors() {
    private void safelyShutdownAllHotwordDetectors(boolean shouldShutDownVisualQueryDetector) {
        synchronized (mLock) {
        synchronized (mLock) {
            mActiveDetectors.forEach(detector -> {
            mActiveDetectors.forEach(detector -> {
                try {
                try {
                    if (detector != mActiveVisualQueryDetector.getInitializationDelegate()
                            || shouldShutDownVisualQueryDetector) {
                        detector.destroy();
                        detector.destroy();
                    }
                } catch (Exception ex) {
                } catch (Exception ex) {
                    Log.i(TAG, "exception destroying HotwordDetector", ex);
                    Log.i(TAG, "exception destroying HotwordDetector", ex);
                }
                }