From ada518457491bf6e5074a607eb484fc26d7ee1be Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Tue, 14 May 2019 15:19:52 -0700 Subject: [PATCH] Minor improvements on voice interaction workflows. Bug: 131411751 Fixes: 132783948 Test: atest CtsVoiceInteractionTestCases CtsAssistTestCases Change-Id: I28c8577caa35a783863f4313487c6e9b9abc8ff2 --- core/java/android/app/ActivityThread.java | 3 ++- .../core/java/com/android/server/audio/AudioService.java | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index ca04536af4c02..97dba429595fd 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -123,7 +123,6 @@ import android.provider.Settings; import android.renderscript.RenderScriptCacheDir; import android.security.NetworkSecurityPolicy; import android.security.net.config.NetworkSecurityConfigProvider; -import android.service.voice.VoiceInteractionSession; import android.system.ErrnoException; import android.system.OsConstants; import android.system.StructStat; @@ -3555,11 +3554,13 @@ public final class ActivityThread extends ClientTransactionHandler { @NonNull RemoteCallback callback) { final ActivityClientRecord r = mActivities.get(activityToken); if (r == null) { + Log.w(TAG, "requestDirectActions(): no activity for " + activityToken); callback.sendResult(null); return; } final int lifecycleState = r.getLifecycleState(); if (lifecycleState < ON_START || lifecycleState >= ON_STOP) { + Log.w(TAG, "requestDirectActions(" + r + "): wrong lifecycle: " + lifecycleState); callback.sendResult(null); return; } diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 4cde931d2ef5a..355140c75bee5 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -1452,7 +1452,13 @@ public class AudioService extends IAudioService.Stub Settings.Secure.ASSISTANT, UserHandle.USER_CURRENT); } if (!TextUtils.isEmpty(assistantName)) { - packageName = ComponentName.unflattenFromString(assistantName).getPackageName(); + ComponentName componentName = ComponentName.unflattenFromString(assistantName); + if (componentName == null) { + Slog.w(TAG, "Invalid service name for " + + Settings.Secure.VOICE_INTERACTION_SERVICE + ": " + assistantName); + return; + } + packageName = componentName.getPackageName(); } } if (!TextUtils.isEmpty(packageName)) {