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

Commit 06042dcb authored by Omar Eissa's avatar Omar Eissa Committed by Markus S
Browse files

Don't allow 3p apps to become voice recognizer automatically

Currently, If there is no default recognizer set using config_systemSpeechRecognizer, any 3p app defining recongition service could become the default recognizer automatically without user selection. Make sure that we only automatically select system apps rather random 3p app.

Test: Manual, install 3p app defining recognizer when no default or
system recognizer is available on the device
Bug: 352518318
Flag: EXEMPT CVE_FIX
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:0bc6ced90e2ee1e6140a4d87ee62923bdfd2ca93)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:b7fdf40f6bccdca670915636e06e4e8d27f23005
Merged-In: I52681da7381be4ebe6cf20b639508311f3a90eba
Change-Id: I52681da7381be4ebe6cf20b639508311f3a90eba
parent cd36af73
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -546,13 +546,21 @@ public class VoiceInteractionManagerService extends SystemService {
                        }
                    }
                }
                if (numAvailable > 1) {
                    Slog.w(TAG, "more than one voice recognition service found, picking first");
                }

                ServiceInfo serviceInfo = available.get(0).serviceInfo;
                // If prefPackage isn't found then only default to system recognizer.
                // prefPackage could be either the current recognizer or the default recognizer.
                for (int i = 0; i < numAvailable; i++) {
                    ServiceInfo serviceInfo = available.get(i).serviceInfo;
                    if ((serviceInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                        continue;
                    }
                    return new ComponentName(serviceInfo.packageName, serviceInfo.name);
                }

                Slog.w(TAG, "no auto selectable voice recognition services found for user "
                        + userHandle);
                return null;
            }
        }

        ComponentName getCurRecognizer(int userHandle) {