From 553d8a4dd3c2562959af1f6066d7697e28aef9e5 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 10 Sep 2019 09:33:11 -0400 Subject: [PATCH] Resolver - Fix NGA (voice interaction) crash in resolver A race condition existed whereby placeholder targets were attempting to be published without any target information, due to bg thread processing of resolved intents. Detect this scenario, and wait. Also have SysUI ChooserActivity accept voice interactions in the intent filter. Does not use DEFAULT category, as it should only ever be used by explicit intents. Bug: 139729579 Test: atest ResolverActivityTest Change-Id: If8fc0c3595da47c26b1edab75bd6fc82a6dcb35e (cherry picked from commit 2cf4c6c3d4b8c51fc4a59911b0a33fca0bd47422) --- .../android/internal/app/ChooserActivity.java | 4 ---- .../internal/app/ResolverActivity.java | 22 +++++++------------ packages/SystemUI/AndroidManifest.xml | 4 ++++ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index de77aaae1653b..38cb2cc1d5534 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -1666,10 +1666,6 @@ public class ChooserActivity extends ResolverActivity { mServiceConnections.clear(); } - public void onSetupVoiceInteraction() { - // Do nothing. We'll send the voice stuff ourselves. - } - private void logDirectShareTargetReceived(int logCategory) { final long queryTime = logCategory == MetricsEvent.ACTION_DIRECT_SHARE_TARGETS_LOADED_SHORTCUT_MANAGER diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index 58ce03baa136e..407a85f1bb055 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -361,9 +361,6 @@ public class ResolverActivity extends Activity { initSuspendedColorMatrix(); - if (isVoiceInteraction()) { - onSetupVoiceInteraction(); - } final Set categories = intent.getCategories(); MetricsLogger.action(this, mAdapter.hasFilteredItem() ? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED @@ -442,24 +439,21 @@ public class ResolverActivity extends Activity { mSuspendedMatrixColorFilter = new ColorMatrixColorFilter(matrix); } - /** - * Perform any initialization needed for voice interaction. - */ - public void onSetupVoiceInteraction() { - // Do it right now. Subclasses may delay this and send it later. - sendVoiceChoicesIfNeeded(); - } - public void sendVoiceChoicesIfNeeded() { if (!isVoiceInteraction()) { // Clearly not needed. return; } - final Option[] options = new Option[mAdapter.getCount()]; for (int i = 0, N = options.length; i < N; i++) { - options[i] = optionForChooserTarget(mAdapter.getItem(i), i); + TargetInfo target = mAdapter.getItem(i); + if (target == null) { + // If this occurs, a new set of targets is being loaded. Let that complete, + // and have the next call to send voice choices proceed instead. + return; + } + options[i] = optionForChooserTarget(target, i); } mPickOptionRequest = new PickTargetOptionRequest( @@ -1872,7 +1866,7 @@ public class ResolverActivity extends Activity { } } - + sendVoiceChoicesIfNeeded(); postListReadyRunnable(); } diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 4f74605b40033..403e894a68e42 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -609,6 +609,10 @@ android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden" android:process=":ui" android:visibleToInstantApps="true"> + + + +