From 3277cf1ea4f89d073f60b665ed48a5639de99ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Engstr=C3=B6m?= Date: Thu, 17 Jul 2014 12:18:29 +0200 Subject: [PATCH] Make ResolverActivity respect selector intent when making filters When the ResolverActivity makes a filter after an intent is chosen, either for remembering last used or an "always use" choice for the user it doesn't consider the selector in the intent if present. This means that when a resolver activity is launched for an intent with a selector, the selector is used for resolving preferred activities, and for populating the list, but when the same intent is sent again it doesn't match the filter created by the previous ResolverActivity. This in turn means that the user will get another ResolverActivity even if "Always Use" was chosen the last time. Bug: 28129216 Change-Id: I29be7010e7c890caf9789673b3c3f821ba362761 --- .../android/internal/app/ResolverActivity.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index 3fc02a7ce5e04..085e159c8b217 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -668,12 +668,19 @@ public class ResolverActivity extends Activity { && mAdapter.mOrigResolveList != null) { // Build a reasonable intent filter, based on what matched. IntentFilter filter = new IntentFilter(); - String action = intent.getAction(); + Intent filterIntent; + if (intent.getSelector() != null) { + filterIntent = intent.getSelector(); + } else { + filterIntent = intent; + } + + String action = filterIntent.getAction(); if (action != null) { filter.addAction(action); } - Set categories = intent.getCategories(); + Set categories = filterIntent.getCategories(); if (categories != null) { for (String cat : categories) { filter.addCategory(cat); @@ -682,9 +689,9 @@ public class ResolverActivity extends Activity { filter.addCategory(Intent.CATEGORY_DEFAULT); int cat = ri.match & IntentFilter.MATCH_CATEGORY_MASK; - Uri data = intent.getData(); + Uri data = filterIntent.getData(); if (cat == IntentFilter.MATCH_CATEGORY_TYPE) { - String mimeType = intent.resolveType(this); + String mimeType = filterIntent.resolveType(this); if (mimeType != null) { try { filter.addDataType(mimeType);