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

Commit 530deca4 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

More robust DRM support, including tests.

Based on guidance from the DRM team, we should pass DRM files
directly to MediaMetadataRetriever, which can be used to obtain both
the underlying MIME type and the typical metadata to be indexed.

To help ensure this works correctly and doesn't regress, borrow
strategy from CTS which creates new Forward Locked media items for
testing, and verify that we scan them correctly.

Allow MediaMetadataRetriever to override the MIME type obtained
from a file extension, but only when the primary type agrees with
the extension.  This is the same policy we apply to XMP metadata.

Bug: 141146658
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I494a539a81ed39411a3b59c4433b6520967962c2
parent 1403ee3a
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -13439,6 +13439,7 @@ package android.drm {
    method public android.drm.DrmConvertedStatus closeConvertSession(int);
    method public android.drm.DrmConvertedStatus closeConvertSession(int);
    method public android.drm.DrmConvertedStatus convertData(int, byte[]);
    method public android.drm.DrmConvertedStatus convertData(int, byte[]);
    method public String[] getAvailableDrmEngines();
    method public String[] getAvailableDrmEngines();
    method @NonNull public java.util.Collection<android.drm.DrmSupportInfo> getAvailableDrmSupportInfo();
    method public android.content.ContentValues getConstraints(String, int);
    method public android.content.ContentValues getConstraints(String, int);
    method public android.content.ContentValues getConstraints(android.net.Uri, int);
    method public android.content.ContentValues getConstraints(android.net.Uri, int);
    method public int getDrmObjectType(String, String);
    method public int getDrmObjectType(String, String);
+14 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.drm;
package android.drm;


import android.annotation.NonNull;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.ContentValues;
import android.content.Context;
import android.content.Context;
@@ -37,6 +38,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicBoolean;


@@ -369,6 +372,17 @@ public class DrmManagerClient implements AutoCloseable {
        return descriptions.toArray(drmEngines);
        return descriptions.toArray(drmEngines);
    }
    }


    /**
     * Retrieves information about all the DRM plug-ins (agents) that are
     * registered with the DRM framework.
     *
     * @return List of all the DRM plug-ins (agents) that are registered with
     *         the DRM framework.
     */
    public @NonNull Collection<DrmSupportInfo> getAvailableDrmSupportInfo() {
        return Arrays.asList(_getAllSupportInfo(mUniqueId));
    }

    /**
    /**
     * Retrieves constraint information for rights-protected content.
     * Retrieves constraint information for rights-protected content.
     *
     *