From b625e19a877dc8e128329d730bc5e9b8e8a2fce9 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Thu, 2 Jun 2016 15:25:12 -0700 Subject: [PATCH] Properly set default voice interactor We need to figure out the default voice interactor to give it default permissions. This happens before the user has been unlocked and if the voice interactor is not direct boot aware we fail to find it, hence no permissions are granted. Now we query the package manager for both direct boot aware and unaware components. This is fine as we don't interact with the assistant until the user is unlocked. bug:28963642 Change-Id: Ide5471fa1798e868c6e3a4b5e87570a5556e2d3f --- .../android/service/voice/VoiceInteractionServiceInfo.java | 6 +++++- .../voiceinteraction/VoiceInteractionManagerService.java | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/java/android/service/voice/VoiceInteractionServiceInfo.java b/core/java/android/service/voice/VoiceInteractionServiceInfo.java index a9db32b703fa4..e1a9a050212c0 100644 --- a/core/java/android/service/voice/VoiceInteractionServiceInfo.java +++ b/core/java/android/service/voice/VoiceInteractionServiceInfo.java @@ -61,7 +61,11 @@ public class VoiceInteractionServiceInfo { throws PackageManager.NameNotFoundException { try { ServiceInfo si = AppGlobals.getPackageManager().getServiceInfo(comp, - PackageManager.GET_META_DATA, userHandle); + PackageManager.GET_META_DATA + | PackageManager.MATCH_DIRECT_BOOT_AWARE + | PackageManager.MATCH_DIRECT_BOOT_UNAWARE + | PackageManager.MATCH_DEBUG_TRIAGED_MISSING, + userHandle); if (si != null) { return si; } diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index 51f5899b6841c..23c58fe4ea6c6 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -19,7 +19,6 @@ package com.android.server.voiceinteraction; import android.Manifest; import android.app.ActivityManager; import android.app.ActivityManagerInternal; -import android.app.ActivityManagerNative; import android.app.AppGlobals; import android.content.ComponentName; import android.content.ContentResolver; @@ -415,7 +414,10 @@ public class VoiceInteractionManagerService extends SystemService { VoiceInteractionServiceInfo findAvailInteractor(int userHandle, String packageName) { List available = mContext.getPackageManager().queryIntentServicesAsUser( - new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0, userHandle); + new Intent(VoiceInteractionService.SERVICE_INTERFACE), + PackageManager.MATCH_DIRECT_BOOT_AWARE + | PackageManager.MATCH_DIRECT_BOOT_UNAWARE + | PackageManager.MATCH_DEBUG_TRIAGED_MISSING, userHandle); int numAvailable = available.size(); if (numAvailable == 0) {