Skip to content

Commit

Permalink
Pass explicit securityLevel into MediaDrm.requiresSecureDecoder
Browse files Browse the repository at this point in the history
Previous to this change, `FrameworkMediaDrm.requiresSecureDecoder`
ignores its `sessionId` parameter on API 31+, and uses only the
`mimeType` parameter. This means the result [assumes the session is
opened at the 'default security
level'](https://developer.android.com/reference/android/media/MediaDrm#requiresSecureDecoder(java.lang.String)):
> The default security level is defined as the highest security level
> supported on the device.

This change is a no-op in all (?) cases, because the `ExoMediaDrm`
interface only exposes the zero-arg `openSession()` method, which in the
framework case **also** assumes the highest security level is preferred:
> By default, sessions are opened at the native security level of the
> device.

However, it seems more obviously correct to only make this
"highest/native security level" assumption in one place
(`openSession()`), and check the session's **actual** security level
everywhere else.

Issue: #1603
PiperOrigin-RevId: 662872860
  • Loading branch information
icbaker authored and copybara-github committed Aug 14, 2024
1 parent e9cfd72 commit 9d62845
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ public Map<String, String> queryKeyStatus(byte[] sessionId) {
public boolean requiresSecureDecoder(byte[] sessionId, String mimeType) {
boolean result;
if (Util.SDK_INT >= 31 && isMediaDrmRequiresSecureDecoderImplemented()) {
result = Api31.requiresSecureDecoder(mediaDrm, mimeType);
result =
Api31.requiresSecureDecoder(mediaDrm, mimeType, mediaDrm.getSecurityLevel(sessionId));
} else {
MediaCrypto mediaCrypto = null;
try {
Expand Down Expand Up @@ -591,8 +592,9 @@ private static class Api31 {
private Api31() {}

@DoNotInline
public static boolean requiresSecureDecoder(MediaDrm mediaDrm, String mimeType) {
return mediaDrm.requiresSecureDecoder(mimeType);
public static boolean requiresSecureDecoder(
MediaDrm mediaDrm, String mimeType, int securityLevel) {
return mediaDrm.requiresSecureDecoder(mimeType, securityLevel);
}

@DoNotInline
Expand Down

0 comments on commit 9d62845

Please sign in to comment.