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

Commit 3a6c9088 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Remove the Photopicker entrypoints from DocumentsUI"

This reverts commit 25d63d3e.

Reason for revert: Droidmonitor created revert due to b/364376846. Will be verifying through ABTD before submission.

Change-Id: Ia831f772699b3f8873624205c37e0e5a0b65378d
parent 25d63d3e
Loading
Loading
Loading
Loading
+0 −29
Original line number Diff line number Diff line
@@ -29,9 +29,7 @@ import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.ext.SdkExtensions;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.view.ContextMenu;
@@ -92,7 +90,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * Display list of known storage backend roots.
@@ -524,25 +521,6 @@ public class RootsFragment extends Fragment {
            final List<ResolveInfo> infos = pm.queryIntentActivities(
                    handlerAppIntent, PackageManager.MATCH_DEFAULT_ONLY);

            // In addition to hiding DocumentsUI from possible handler apps, the Android
            // Photopicker should also be hidden. ACTION_PICK_IMAGES is used to identify
            // the Photopicker package since that is the primary API.
            List<ResolveInfo> photopickerActivities;
            List<String> photopickerPackages;

            if (SdkLevel.isAtLeastR()
                    && SdkExtensions.getExtensionVersion(Build.VERSION_CODES.R) >= 2) {
                photopickerActivities = pm.queryIntentActivities(
                        new Intent(MediaStore.ACTION_PICK_IMAGES),
                        PackageManager.MATCH_DEFAULT_ONLY);
                photopickerPackages = photopickerActivities.stream()
                        .map(info -> info.activityInfo.packageName)
                .collect(Collectors.toList());
            } else {
                photopickerActivities = Collections.emptyList();
                photopickerPackages = Collections.emptyList();
            }

            // Omit ourselves and maybe calling package from the list
            for (ResolveInfo info : infos) {
                if (!info.activityInfo.exported) {
@@ -553,13 +531,6 @@ public class RootsFragment extends Fragment {
                }

                final String packageName = info.activityInfo.packageName;

                // If the package name for the activity is in the list of Photopicker
                // activities, exclude it.
                if (photopickerPackages.contains(packageName)) {
                    continue;
                }

                if (!myPackageName.equals(packageName)
                        && !TextUtils.equals(excludePackage, packageName)) {
                    UserPackage userPackage = new UserPackage(userId, packageName);