OSDN Git Service

Fix: ResolverActivity sometimes cannot update the last chosen activity
authorYuichi Biwa <yuichi.xa.biwa@sonymobile.com>
Thu, 6 Aug 2015 10:45:27 +0000 (19:45 +0900)
committerAdam Powell <adamp@google.com>
Tue, 12 Apr 2016 16:18:20 +0000 (09:18 -0700)
Symptom:
Calling startActivity() with an implicit intent,
ResolverActivity displays preferred activity candidates.
At first user selects one of them as "JUST ONCE".
And next, the last one is shown again on the top with "JUST ONCE" and
"ALWAYS".

But even if user selects another ones except top with "JUST ONCE".
Next time, the last one is not shown on the top.
Instead of that, first one still remain on the top.

It means that user can't select activities as "ALWAYS"
except first one.

Root cause:
The implicit intent has a URI but not MIME type.
In this case, Intent#resolveTypeIfNeeded returns "null".
So MIME type is not passed to PackageManagerService.
That's why this issue happens.

Change-Id: I87b6da9c5d8b47e071bbedf9f7d5f3ecea730875

core/java/com/android/internal/app/ResolverActivity.java

index f2bf9e1..1f2acc9 100644 (file)
@@ -760,7 +760,7 @@ public class ResolverActivity extends Activity {
                 } else {
                     try {
                         AppGlobals.getPackageManager().setLastChosenActivity(intent,
-                                intent.resolveTypeIfNeeded(getContentResolver()),
+                                intent.resolveType(getContentResolver()),
                                 PackageManager.MATCH_DEFAULT_ONLY,
                                 filter, bestMatch, intent.getComponent());
                     } catch (RemoteException re) {