Skip to content

Commit

Permalink
Work around a bug in the Android 13 ClearKey implementation
Browse files Browse the repository at this point in the history
The ClearKey CDM will attach an 'invalid' URL in `KeyRequest` objects,
when the documentation states this should be an empty string if a
default URL is not known.

#minor-release

PiperOrigin-RevId: 476113513
  • Loading branch information
icbaker authored and marcbaechinger committed Oct 19, 2022
1 parent cfc0eef commit 331d4d6
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ public KeyRequest getKeyRequest(
mediaDrm.getKeyRequest(scope, initData, mimeType, keyType, optionalParameters);

byte[] requestData = adjustRequestData(uuid, request.getData());

String licenseServerUrl = request.getDefaultUrl();
if (MOCK_LA_URL_VALUE.equals(licenseServerUrl)) {
licenseServerUrl = "";
}
String licenseServerUrl = adjustLicenseServerUrl(request.getDefaultUrl());
if (TextUtils.isEmpty(licenseServerUrl)
&& schemeData != null
&& !TextUtils.isEmpty(schemeData.licenseServerUrl)) {
Expand All @@ -236,6 +232,17 @@ public KeyRequest getKeyRequest(
return new KeyRequest(requestData, licenseServerUrl, requestType);
}

private static String adjustLicenseServerUrl(String licenseServerUrl) {
if (MOCK_LA_URL.equals(licenseServerUrl)) {
return "";
} else if (Util.SDK_INT == 33 && "https://default.url".equals(licenseServerUrl)) {
// Work around b/247808112
return "";
} else {
return licenseServerUrl;
}
}

@Override
@Nullable
public byte[] provideKeyResponse(byte[] scope, byte[] response)
Expand Down

0 comments on commit 331d4d6

Please sign in to comment.