Relax auto-launch checks for GET_CONTENT.

When a developer wraps an intent with Intent.createChooser(), they're
indicating that the user should always be prompted, instead of using
any "always use" defaults.  A recent CL changed the chooser behavior
to ensure that UI is always shown in the case where there is only one
match.

However, this caused us to start prompting for the GET_CONTENT intent,
for which there is only ever one DocumentsUI system app.  Since that
app delivers on the createChooser() contract described above, we're
okay automatically launching it.

Bug: 24464358
Change-Id: I0279d3343479c134a35f41ddf3cb4204d0ae6a90
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index ef9d1ce..1710489 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -796,7 +796,7 @@
         return false;
     }
 
-    boolean shouldAutoLaunchSingleChoice() {
+    boolean shouldAutoLaunchSingleChoice(TargetInfo target) {
         return true;
     }
 
@@ -837,18 +837,21 @@
         mAlwaysUseOption = alwaysUseOption;
 
         int count = mAdapter.getUnfilteredCount();
-        if ((!shouldAutoLaunchSingleChoice() && count > 0)
-                || count > 1
-                || (count == 1 && mAdapter.getOtherProfile() != null)) {
+        if (count == 1 && mAdapter.getOtherProfile() == null) {
+            // Only one target, so we're a candidate to auto-launch!
+            final TargetInfo target = mAdapter.targetInfoForPosition(0, false);
+            if (shouldAutoLaunchSingleChoice(target)) {
+                safelyStartActivity(target);
+                mPackageMonitor.unregister();
+                mRegistered = false;
+                finish();
+                return true;
+            }
+        }
+        if (count > 0) {
             setContentView(layoutId);
             mAdapterView = (AbsListView) findViewById(R.id.resolver_list);
             onPrepareAdapterView(mAdapterView, mAdapter, alwaysUseOption);
-        } else if (count == 1) {
-            safelyStartActivity(mAdapter.targetInfoForPosition(0, false));
-            mPackageMonitor.unregister();
-            mRegistered = false;
-            finish();
-            return true;
         } else {
             setContentView(R.layout.resolver_list);