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

Commit fb0756fa authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Clean up scan calls used for testing."

parents 8ede3e81 4b457c39
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2150,9 +2150,9 @@ package android.provider {
    method @RequiresPermission(android.Manifest.permission.CLEAR_APP_USER_DATA) public static long getContributedMediaSize(android.content.Context, String, android.os.UserHandle) throws java.io.IOException;
    method @NonNull public static java.io.File getVolumePath(@NonNull String) throws java.io.FileNotFoundException;
    method @NonNull public static java.util.Collection<java.io.File> getVolumeScanPaths(@NonNull String) throws java.io.FileNotFoundException;
    field public static final String EXTRA_ORIGINATED_FROM_SHELL = "android.intent.extra.originated_from_shell";
    field public static final String SCAN_FILE_CALL = "scan_file";
    field public static final String SCAN_VOLUME_CALL = "scan_volume";
    method public static android.net.Uri scanFile(android.content.Context, java.io.File);
    method public static android.net.Uri scanFileFromShell(android.content.Context, java.io.File);
    method public static void scanVolume(android.content.Context, java.io.File);
  }

  public final class Settings {
+3 −10
Original line number Diff line number Diff line
@@ -3115,21 +3115,14 @@ public class Intent implements Parcelable, Cloneable {
     * <p>
     * The path to the file is contained in {@link Intent#getData()}.
     *
     * @deprecated Starting in the {@link android.os.Build.VERSION_CODES#Q}
     *             release, shared storage paths are sandboxed per application,
     *             and this broadcast cannot correctly translate those sandboxed
     *             paths. Callers will need to instead migrate to using
     *             {@link MediaScannerConnection}.
     * @deprecated Callers should migrate to inserting items directly into
     *             {@link MediaStore}, where they will be automatically scanned
     *             after each mutation.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @Deprecated
    public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";

    /** @hide */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @Deprecated
    public static final String ACTION_MEDIA_SCANNER_SCAN_VOLUME = "android.intent.action.MEDIA_SCANNER_SCAN_VOLUME";

   /**
     * Broadcast Action:  The "Media Button" was pressed.  Includes a single
     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
+23 −4
Original line number Diff line number Diff line
@@ -115,9 +115,9 @@ public final class MediaStore {
     */
    public static final String VOLUME_EXTERNAL = "external";

    /** {@hide} */ @TestApi
    /** {@hide} */
    public static final String SCAN_FILE_CALL = "scan_file";
    /** {@hide} */ @TestApi
    /** {@hide} */
    public static final String SCAN_VOLUME_CALL = "scan_volume";

    /**
@@ -126,7 +126,6 @@ public final class MediaStore {
     *
     * {@hide}
     */
    @TestApi
    public static final String EXTRA_ORIGINATED_FROM_SHELL =
            "android.intent.extra.originated_from_shell";

@@ -3539,12 +3538,32 @@ public final class MediaStore {
    }

    /** @hide */
    @TestApi
    public static Uri scanFile(Context context, File file) {
        return scan(context, SCAN_FILE_CALL, file, false);
    }

    /** @hide */
    @TestApi
    public static Uri scanFileFromShell(Context context, File file) {
        return scan(context, SCAN_FILE_CALL, file, true);
    }

    /** @hide */
    @TestApi
    public static void scanVolume(Context context, File file) {
        scan(context, SCAN_VOLUME_CALL, file, false);
    }

    /** @hide */
    private static Uri scan(Context context, String method, File file,
            boolean originatedFromShell) {
        final ContentResolver resolver = context.getContentResolver();
        try (ContentProviderClient client = resolver.acquireContentProviderClient(AUTHORITY)) {
            final Bundle in = new Bundle();
            in.putParcelable(Intent.EXTRA_STREAM, Uri.fromFile(file));
            final Bundle out = client.call(SCAN_FILE_CALL, null, in);
            in.putBoolean(EXTRA_ORIGINATED_FROM_SHELL, originatedFromShell);
            final Bundle out = client.call(method, null, in);
            return out.getParcelable(Intent.EXTRA_STREAM);
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();