diff options
author | Jeff Sharkey <jsharkey@google.com> | 2015-09-30 16:22:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-09-30 16:22:17 +0000 |
commit | 30fd0628970b418dea382b388120f52504ff2243 (patch) | |
tree | 728f872cffcda28049edb8f3266079bb5949f568 /core | |
parent | e69ff2a878ee7635a467259995e2924fb96a3a72 (diff) | |
parent | cc2ae6b421353e03160df3b05ce9042b8a5ff8cc (diff) | |
download | frameworks_base-30fd0628970b418dea382b388120f52504ff2243.zip frameworks_base-30fd0628970b418dea382b388120f52504ff2243.tar.gz frameworks_base-30fd0628970b418dea382b388120f52504ff2243.tar.bz2 |
Merge "Relax auto-launch checks for GET_CONTENT." into mnc-dr-dev
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/provider/DocumentsContract.java | 3 | ||||
-rw-r--r-- | core/java/com/android/internal/app/ChooserActivity.java | 16 | ||||
-rw-r--r-- | core/java/com/android/internal/app/ResolverActivity.java | 23 |
3 files changed, 31 insertions, 11 deletions
diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java index c7ba607..f5221c6 100644 --- a/core/java/android/provider/DocumentsContract.java +++ b/core/java/android/provider/DocumentsContract.java @@ -130,6 +130,9 @@ public final class DocumentsContract { */ private static final int THUMBNAIL_BUFFER_SIZE = (int) (128 * KB_IN_BYTES); + /** {@hide} */ + public static final String PACKAGE_DOCUMENTS_UI = "com.android.documentsui"; + /** * Constants related to a document, including {@link Cursor} column names * and flags. diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 3219dcb..2e0bf06 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -40,6 +40,7 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.os.UserHandle; import android.os.UserManager; +import android.provider.DocumentsContract; import android.service.chooser.ChooserTarget; import android.service.chooser.ChooserTargetService; import android.service.chooser.IChooserTargetResult; @@ -269,7 +270,20 @@ public class ChooserActivity extends ResolverActivity { } @Override - boolean shouldAutoLaunchSingleChoice() { + boolean shouldAutoLaunchSingleChoice(TargetInfo target) { + final Intent intent = target.getResolvedIntent(); + final ResolveInfo resolve = target.getResolveInfo(); + + // When GET_CONTENT is handled by the DocumentsUI system component, + // we're okay automatically launching it, since it offers it's own + // intent disambiguation UI. + if (intent != null && Intent.ACTION_GET_CONTENT.equals(intent.getAction()) + && resolve != null && resolve.priority > 0 + && resolve.activityInfo != null && DocumentsContract.PACKAGE_DOCUMENTS_UI + .equals(resolve.activityInfo.packageName)) { + return true; + } + return false; } 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 @@ public class ResolverActivity extends Activity { return false; } - boolean shouldAutoLaunchSingleChoice() { + boolean shouldAutoLaunchSingleChoice(TargetInfo target) { return true; } @@ -837,18 +837,21 @@ public class ResolverActivity extends Activity { 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); |