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

Commit 6ab42367 authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Android (Google) Code Review
Browse files

Merge changes Ib24f0773,I2da8f72c into sc-dev

* changes:
  VIMS: Decouple recognizer init from interactor in PackageMonitor.
  VIMS: Decouple recognizer from interactor in initForUser().
parents be83ac78 de203c37
Loading
Loading
Loading
Loading
+12 −24
Original line number Diff line number Diff line
@@ -430,25 +430,17 @@ public class VoiceInteractionManagerService extends SystemService {
                // Eventually it will be an error to not specify this.
                setCurInteractor(new ComponentName(curInteractorInfo.getServiceInfo().packageName,
                        curInteractorInfo.getServiceInfo().name), userHandle);
                if (curInteractorInfo.getRecognitionService() != null) {
                    setCurRecognizer(
                            new ComponentName(curInteractorInfo.getServiceInfo().packageName,
                                    curInteractorInfo.getRecognitionService()), userHandle);
                    return;
                }
            } else {
                // No voice interactor, so clear the setting.
                setCurInteractor(null, userHandle);
            }

            // No voice interactor, we'll just set up a simple recognizer.
            initSimpleRecognizer(curInteractorInfo, userHandle);
            initRecognizer(userHandle);
        }

        public void initSimpleRecognizer(VoiceInteractionServiceInfo curInteractorInfo,
                int userHandle) {
        public void initRecognizer(int userHandle) {
            ComponentName curRecognizer = findAvailRecognizer(null, userHandle);
            if (curRecognizer != null) {
                if (curInteractorInfo == null) {
                    setCurInteractor(null, userHandle);
                }
                setCurRecognizer(curRecognizer, userHandle);
            }
        }
@@ -1772,7 +1764,9 @@ public class VoiceInteractionManagerService extends SystemService {
                    synchronized (VoiceInteractionManagerServiceStub.this) {
                        Slog.i(TAG, "Force stopping current voice recognizer: "
                                + getCurRecognizer(userHandle));
                        initSimpleRecognizer(null, userHandle);
                        // TODO: Figure out why the interactor was being cleared and document it.
                        setCurInteractor(null, userHandle);
                        initRecognizer(userHandle);
                    }
                }
                return hitInt || hitRec;
@@ -1793,6 +1787,9 @@ public class VoiceInteractionManagerService extends SystemService {
                if (isPackageAppearing(pkgName) != PACKAGE_UNCHANGED) {
                    return;
                }
                if (getCurRecognizer(mCurUser) == null) {
                    initRecognizer(mCurUser);
                }
                final String curInteractorStr = Settings.Secure.getStringForUser(
                        mContext.getContentResolver(),
                        Settings.Secure.VOICE_INTERACTION_SERVICE, mCurUser);
@@ -1807,12 +1804,6 @@ public class VoiceInteractionManagerService extends SystemService {
                                availInteractorInfo.getServiceInfo().packageName,
                                availInteractorInfo.getServiceInfo().name);
                        setCurInteractor(availInteractor, mCurUser);
                        if (getCurRecognizer(mCurUser) == null &&
                                availInteractorInfo.getRecognitionService() != null) {
                            setCurRecognizer(new ComponentName(
                                    availInteractorInfo.getServiceInfo().packageName,
                                    availInteractorInfo.getRecognitionService()), mCurUser);
                        }
                    }
                } else {
                    if (didSomePackagesChange()) {
@@ -1843,10 +1834,7 @@ public class VoiceInteractionManagerService extends SystemService {
                    if (curRecognizer == null) {
                        // Could a new recognizer appear when we don't have one pre-installed?
                        if (anyPackagesAppearing()) {
                            curRecognizer = findAvailRecognizer(null, userHandle);
                            if (curRecognizer != null) {
                                setCurRecognizer(curRecognizer, userHandle);
                            }
                            initRecognizer(userHandle);
                        }
                        return;
                    }