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

Commit 847f549f authored by Omar Eissa's avatar Omar Eissa
Browse files

Make sure that we select VIS in the default assitant

In initial boot, and before assistant role is assigned, we need to make
sure that we select the voice interaction service that belongs to the
default assistant set in the OEM config overlay. Previously, we were
selecting the first available VIS which could lead to granting
unnecessary permissions to VIS that won't be used by the system.

Test: atest CtsVoiceInteractionTestCases
Flag: EXEMPT BUFGFIX
Change-Id: I654917495b7fe4742558972f211be20252a28c49
Bug: 442373648
parent 48d2463d
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -876,9 +876,9 @@ public class VoiceInteractionManagerService extends SystemService {
                Slog.w(TAG, "no available voice interaction services found for user " + user);
                return null;
            }
            // Find first system package.  We never want to allow third party services to
            // be automatically selected, because those require approval of the user.
            VoiceInteractionServiceInfo foundInfo = null;
            final String defaultAssistant = getDefaultAssistant();
            // Assign to the first available system voice interactor that is part of either
            // the default assistant or the passed package
            for (int i = 0; i < numAvailable; i++) {
                ServiceInfo cur = available.get(i).serviceInfo;
                if ((cur.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
@@ -890,19 +890,22 @@ public class VoiceInteractionManagerService extends SystemService {
                    Slog.w(TAG,
                            "Bad interaction service " + cur.packageName + "/"
                                    + cur.name + ": " + info.getParseError());
                } else if (foundInfo == null) {
                    foundInfo = info;
                } else {
                    Slog.w(TAG, "More than one voice interaction service, "
                            + "picking first "
                            + new ComponentName(
                            foundInfo.getServiceInfo().packageName,
                            foundInfo.getServiceInfo().name)
                            + " over "
                            + new ComponentName(cur.packageName, cur.name));
                } else if (!info.getSupportsAssist()) {
                    // skip if it doesn't support assistant
                    Slog.i(TAG, "Interaction service "
                            + cur.packageName + "/" + cur.name + " doesn't support assistant");
                } else if (cur.packageName.equals(defaultAssistant)
                            || cur.packageName.equals(packageName)) {
                    return info;
                }
            }
            return null;
        }
            return foundInfo;

        @Nullable
        public String getDefaultAssistant() {
            String assistant = mContext.getString(R.string.config_defaultAssistant);
            return TextUtils.isEmpty(assistant) ? null : assistant;
        }

        ComponentName getCurInteractor(int userHandle) {