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

Commit 202bd123 authored by MingWei Liao's avatar MingWei Liao Committed by Android Build Coastguard Worker
Browse files

Revert "Validate the VoiceInteractionService before rebind"

This reverts commit aa1b3725.

Reason for revert: Side-effect: b/343854218
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f244554df4c57f4aec8cf3c89cafef374d91aab6)
Merged-In: If67f2bc32097c37f66695416005baaffee8059f3
Change-Id: If67f2bc32097c37f66695416005baaffee8059f3
parent fd19d53f
Loading
Loading
Loading
Loading
+3 −23
Original line number Diff line number Diff line
@@ -794,8 +794,9 @@ public class VoiceInteractionManagerService extends SystemService {
                if (curService != null && !curService.isEmpty()) {
                    try {
                        serviceComponent = ComponentName.unflattenFromString(curService);
                        serviceInfo = getValidVoiceInteractionServiceInfo(serviceComponent);
                    } catch (RuntimeException e) {
                        serviceInfo = AppGlobals.getPackageManager()
                                .getServiceInfo(serviceComponent, 0, mCurUser);
                    } catch (RuntimeException | RemoteException e) {
                        Slog.wtf(TAG, "Bad voice interaction service name " + curService, e);
                        serviceComponent = null;
                        serviceInfo = null;
@@ -833,27 +834,6 @@ public class VoiceInteractionManagerService extends SystemService {
            }
        }

        @Nullable
        private ServiceInfo getValidVoiceInteractionServiceInfo(
                @Nullable ComponentName serviceComponent) {
            if (serviceComponent == null) {
                return null;
            }
            List<ResolveInfo> services = queryInteractorServices(
                    mCurUser, serviceComponent.getPackageName());
            for (int i = 0; i < services.size(); i++) {
                ResolveInfo service = services.get(i);
                VoiceInteractionServiceInfo info = new VoiceInteractionServiceInfo(
                        mContext.getPackageManager(), service.serviceInfo);
                ServiceInfo candidateInfo = info.getServiceInfo();
                if (candidateInfo != null
                        && candidateInfo.getComponentName().equals(serviceComponent)) {
                    return candidateInfo;
                }
            }
            return null;
        }

        private List<ResolveInfo> queryInteractorServices(
                @UserIdInt int user,
                @Nullable String packageName) {