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

Commit 28f5a884 authored by Winson Chung's avatar Winson Chung
Browse files

Ensure VoiceInteractionManagerService updates the assistant setting

- Trigger the role changed callback manually when initializing the
  voice interaction manager in case the role handler changed prior to
  registering the listener.  In addition, ensure that we query for all
  packages regardless of current locked state.

Bug: 130126913
Test: Wipe device, restart and ensure that the assistant setting is set
      (adb shell setting get secure assistant)

Change-Id: I170189d9fd5177108c62c486e93b35a3a32af48c
parent dac5aa6d
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1238,6 +1238,9 @@ public class VoiceInteractionManagerService extends SystemService {

            RoleObserver(@NonNull @CallbackExecutor Executor executor) {
                mRm.addOnRoleHoldersChangedListenerAsUser(executor, this, UserHandle.ALL);
                UserHandle currentUser = UserHandle.of(LocalServices.getService(
                        ActivityManagerInternal.class).getCurrentUserId());
                onRoleHoldersChanged(RoleManager.ROLE_ASSISTANT, currentUser);
            }

            private @NonNull String getDefaultRecognizer(@NonNull UserHandle user) {
@@ -1285,7 +1288,9 @@ public class VoiceInteractionManagerService extends SystemService {
                    // Try to set role holder as VoiceInteractionService
                    List<ResolveInfo> services = mPm.queryIntentServicesAsUser(
                            new Intent(VoiceInteractionService.SERVICE_INTERFACE).setPackage(pkg),
                            PackageManager.GET_META_DATA, userId);
                            PackageManager.GET_META_DATA
                                    | PackageManager.MATCH_DIRECT_BOOT_AWARE
                                    | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId);

                    for (ResolveInfo resolveInfo : services) {
                        ServiceInfo serviceInfo = resolveInfo.serviceInfo;
@@ -1318,7 +1323,9 @@ public class VoiceInteractionManagerService extends SystemService {
                    // If no service could be found try to set assist activity
                    final List<ResolveInfo> activities = mPm.queryIntentActivitiesAsUser(
                            new Intent(Intent.ACTION_ASSIST).setPackage(pkg),
                            PackageManager.MATCH_DEFAULT_ONLY, userId);
                            PackageManager.MATCH_DEFAULT_ONLY
                                    | PackageManager.MATCH_DIRECT_BOOT_AWARE
                                    | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId);

                    for (ResolveInfo resolveInfo : activities) {
                        ActivityInfo activityInfo = resolveInfo.activityInfo;
@@ -1331,6 +1338,7 @@ public class VoiceInteractionManagerService extends SystemService {
                        Settings.Secure.putStringForUser(getContext().getContentResolver(),
                                Settings.Secure.VOICE_RECOGNITION_SERVICE,
                                getDefaultRecognizer(user), userId);
                        return;
                    }
                }
            }