Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54c331a0 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am 5dfd06f7: am c2fa99ed: am 792a9cc3: am 30fd0628: Merge "Relax auto-launch...

am 5dfd06f7: am c2fa99ed: am 792a9cc3: am 30fd0628: Merge "Relax auto-launch checks for GET_CONTENT." into mnc-dr-dev

* commit '5dfd06f7':
  Relax auto-launch checks for GET_CONTENT.
parents d3af58e2 5dfd06f7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -136,6 +136,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.
+15 −1
Original line number Diff line number Diff line
@@ -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;
    }

+13 −10
Original line number Diff line number Diff line
@@ -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)) {
            setContentView(layoutId);
            mAdapterView = (AbsListView) findViewById(R.id.resolver_list);
            onPrepareAdapterView(mAdapterView, mAdapter, alwaysUseOption);
        } else if (count == 1) {
            safelyStartActivity(mAdapter.targetInfoForPosition(0, false));
        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 {
            setContentView(R.layout.resolver_list);