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

Commit f3421c57 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "VIMS: Helper method for InteractionService query." into sc-dev

parents faad7c72 79593fb9
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -581,17 +581,24 @@ public class VoiceInteractionManagerService extends SystemService {
            }
        }

        VoiceInteractionServiceInfo findAvailInteractor(int userHandle, String packageName) {
            List<ResolveInfo> available =
                    mContext.getPackageManager().queryIntentServicesAsUser(
                            new Intent(VoiceInteractionService.SERVICE_INTERFACE)
                                    .setPackage(packageName),
        private List<ResolveInfo> queryInteractorServices(
                @UserIdInt int user,
                @Nullable String packageName) {
            return mContext.getPackageManager().queryIntentServicesAsUser(
                    new Intent(VoiceInteractionService.SERVICE_INTERFACE).setPackage(packageName),
                    PackageManager.GET_META_DATA
                            | PackageManager.MATCH_DIRECT_BOOT_AWARE
                                    | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userHandle);
                            | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                    user);
        }

        VoiceInteractionServiceInfo findAvailInteractor(
                @UserIdInt int user,
                @Nullable String packageName) {
            List<ResolveInfo> available = queryInteractorServices(user, packageName);
            int numAvailable = available.size();
            if (numAvailable == 0) {
                Slog.w(TAG, "no available voice interaction services found for user " + userHandle);
                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
@@ -1643,13 +1650,7 @@ public class VoiceInteractionManagerService extends SystemService {
                    String pkg = roleHolders.get(0);

                    // Try to set role holder as VoiceInteractionService
                    List<ResolveInfo> services = mPm.queryIntentServicesAsUser(
                            new Intent(VoiceInteractionService.SERVICE_INTERFACE).setPackage(pkg),
                            PackageManager.GET_META_DATA
                                    | PackageManager.MATCH_DIRECT_BOOT_AWARE
                                    | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId);

                    for (ResolveInfo resolveInfo : services) {
                    for (ResolveInfo resolveInfo : queryInteractorServices(userId, pkg)) {
                        ServiceInfo serviceInfo = resolveInfo.serviceInfo;

                        VoiceInteractionServiceInfo voiceInteractionServiceInfo =