Merge "Enable PhotoPicker APIs" into sc-mainline-prod
diff --git a/apex/framework/api/current.txt b/apex/framework/api/current.txt
index 0a53fb5..3ea467e 100644
--- a/apex/framework/api/current.txt
+++ b/apex/framework/api/current.txt
@@ -14,6 +14,7 @@
     method public static android.net.Uri getMediaScannerUri();
     method @Nullable public static android.net.Uri getMediaUri(@NonNull android.content.Context, @NonNull android.net.Uri);
     method @NonNull public static android.os.ParcelFileDescriptor getOriginalMediaFormatFileDescriptor(@NonNull android.content.Context, @NonNull android.os.ParcelFileDescriptor) throws java.io.IOException;
+    method public static int getPickImagesMaxLimit();
     method @NonNull public static java.util.Set<java.lang.String> getRecentExternalVolumeNames(@NonNull android.content.Context);
     method @Nullable public static android.net.Uri getRedactedUri(@NonNull android.content.ContentResolver, @NonNull android.net.Uri);
     method @NonNull public static java.util.List<android.net.Uri> getRedactedUri(@NonNull android.content.ContentResolver, @NonNull java.util.List<android.net.Uri>);
@@ -26,6 +27,7 @@
     method @NonNull public static android.net.Uri setRequireOriginal(@NonNull android.net.Uri);
     field public static final String ACTION_IMAGE_CAPTURE = "android.media.action.IMAGE_CAPTURE";
     field public static final String ACTION_IMAGE_CAPTURE_SECURE = "android.media.action.IMAGE_CAPTURE_SECURE";
+    field public static final String ACTION_PICK_IMAGES = "android.provider.action.PICK_IMAGES";
     field public static final String ACTION_REVIEW = "android.provider.action.REVIEW";
     field public static final String ACTION_REVIEW_SECURE = "android.provider.action.REVIEW_SECURE";
     field public static final String ACTION_VIDEO_CAPTURE = "android.media.action.VIDEO_CAPTURE";
@@ -46,6 +48,7 @@
     field public static final String EXTRA_MEDIA_RADIO_CHANNEL = "android.intent.extra.radio_channel";
     field public static final String EXTRA_MEDIA_TITLE = "android.intent.extra.title";
     field public static final String EXTRA_OUTPUT = "output";
+    field public static final String EXTRA_PICK_IMAGES_MAX = "android.provider.extra.PICK_IMAGES_MAX";
     field public static final String EXTRA_SCREEN_ORIENTATION = "android.intent.extra.screenOrientation";
     field public static final String EXTRA_SHOW_ACTION_ICONS = "android.intent.extra.showActionIcons";
     field public static final String EXTRA_SIZE_LIMIT = "android.intent.extra.sizeLimit";
@@ -358,6 +361,15 @@
     field public static final String YEAR = "year";
   }
 
+  public static class MediaStore.PickerMediaColumns {
+    field public static final String DATA = "_data";
+    field public static final String DATE_TAKEN = "datetaken";
+    field public static final String DISPLAY_NAME = "_display_name";
+    field public static final String DURATION_MILLIS = "duration";
+    field public static final String MIME_TYPE = "mime_type";
+    field public static final String SIZE = "_size";
+  }
+
   public static final class MediaStore.Video {
     ctor public MediaStore.Video();
     method @Deprecated public static android.database.Cursor query(android.content.ContentResolver, android.net.Uri, String[]);
diff --git a/apex/framework/java/android/provider/MediaStore.java b/apex/framework/java/android/provider/MediaStore.java
index e9c4305..61022df 100644
--- a/apex/framework/java/android/provider/MediaStore.java
+++ b/apex/framework/java/android/provider/MediaStore.java
@@ -709,8 +709,6 @@
      * Before this API, apps could use {@link Intent#ACTION_GET_CONTENT}. However, this
      * new action is recommended for images and videos use-cases, since it ofers a
      * better user experience.
-     *
-     * @hide
      */
     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_PICK_IMAGES = "android.provider.action.PICK_IMAGES";
@@ -740,8 +738,6 @@
      * than 1 and less than or equal to
      * {@link MediaStore#getPickImagesMaxLimit}, otherwise
      * {@link Activity#RESULT_CANCELED} is returned.
-     *
-     * @hide
      */
     public final static String EXTRA_PICK_IMAGES_MAX = "android.provider.extra.PICK_IMAGES_MAX";
 
@@ -749,8 +745,6 @@
      * The maximum limit for the number of items that can be selected using
      * {@link MediaStore#ACTION_PICK_IMAGES} when launched in multiple selection mode.
      * This can be used as a constant value for {@link MediaStore#EXTRA_PICK_IMAGES_MAX}.
-     *
-     * @hide
      */
     public static int getPickImagesMaxLimit() {
         return PICK_IMAGES_MAX_LIMIT;
@@ -1817,9 +1811,7 @@
      * Photo picker metadata columns.
      *
      * @see #ACTION_PICK_IMAGES
-     * @hide
      */
-    // TODO(b/205291616): Unhide before release
     public static class PickerMediaColumns {
         private PickerMediaColumns() {}
 
diff --git a/src/com/android/providers/media/photopicker/PhotoPickerActivity.java b/src/com/android/providers/media/photopicker/PhotoPickerActivity.java
index 33746af..f499177 100644
--- a/src/com/android/providers/media/photopicker/PhotoPickerActivity.java
+++ b/src/com/android/providers/media/photopicker/PhotoPickerActivity.java
@@ -31,11 +31,8 @@
 import android.graphics.Rect;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
-import android.os.Binder;
 import android.os.Bundle;
-import android.os.SystemProperties;
 import android.os.UserHandle;
-import android.provider.DeviceConfig;
 import android.util.Log;
 import android.view.MotionEvent;
 import android.view.View;
@@ -51,7 +48,6 @@
 import androidx.fragment.app.FragmentManager;
 import androidx.lifecycle.ViewModelProvider;
 
-import com.android.modules.utils.build.SdkLevel;
 import com.android.providers.media.R;
 import com.android.providers.media.photopicker.data.Selection;
 import com.android.providers.media.photopicker.data.UserIdManager;
@@ -105,10 +101,6 @@
 
         super.onCreate(savedInstanceState);
 
-        if (!isPhotoPickerEnabled()) {
-            setCancelledResultAndFinishSelf();
-        }
-
         setContentView(R.layout.activity_photo_picker);
 
         mToolbar = findViewById(R.id.toolbar);
@@ -157,44 +149,6 @@
     }
 
     /**
-     * TODO(b/205291616) Remove this before launch. This is a temporary method to hide the API
-     * until we are ready to launch it.
-     */
-    @VisibleForTesting
-    public boolean isPhotoPickerEnabled() {
-        // Always enabled on T+
-        if (SdkLevel.isAtLeastT()) {
-            return true;
-        }
-
-        // If the system property is enabled, then picker is enabled
-        boolean isSysPropertyEnabled =
-                SystemProperties.getBoolean(
-                        "persist.sys.storage_picker_enabled" /* key */,
-                        false /* def */);
-        if (isSysPropertyEnabled) {
-            return true;
-        }
-
-        // If build is < S, then picker is disabled since we cannot check device config
-        if (!SdkLevel.isAtLeastS()) {
-            // We cannot read device config on R
-            return false;
-        }
-
-        // If the device config is enabled, then picker is enabled
-        final long token = Binder.clearCallingIdentity();
-        try {
-            return DeviceConfig.getBoolean(
-                    DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
-                    "picker_intent_enabled",
-                    false /* defaultValue */ );
-        } finally {
-            Binder.restoreCallingIdentity(token);
-        }
-    }
-
-    /**
      * Warning: This method is needed for tests, we are not customizing anything here.
      * Allowing ourselves to control ViewModel creation helps us mock the ViewModel for test.
      */
diff --git a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java
index 8577da7..55dcd99 100644
--- a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java
+++ b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java
@@ -29,9 +29,4 @@
         pickerViewModel.setUserIdManager(PhotoPickerBaseTest.getMockUserIdManager());
         return pickerViewModel;
     }
-
-    @Override
-    public boolean isPhotoPickerEnabled() {
-        return true;
-    }
 }
\ No newline at end of file