303 lines
12 KiB
Java
303 lines
12 KiB
Java
package c.i.a.c.z1;
|
|
|
|
import android.media.DeniedByServerException;
|
|
import android.media.MediaCryptoException;
|
|
import android.media.MediaDrm;
|
|
import android.media.MediaDrmException;
|
|
import android.media.NotProvisionedException;
|
|
import android.media.UnsupportedSchemeException;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import c.d.b.a.a;
|
|
import c.i.a.c.a2.h0.j;
|
|
import c.i.a.c.h0;
|
|
import c.i.a.c.i2.f0;
|
|
import c.i.a.c.i2.p;
|
|
import c.i.a.c.z1.x;
|
|
import c.i.b.a.c;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.google.android.exoplayer2.drm.DrmInitData;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.ByteOrder;
|
|
import java.nio.charset.Charset;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.UUID;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
/* compiled from: FrameworkMediaDrm */
|
|
@RequiresApi(18)
|
|
public final class z implements x {
|
|
public static final /* synthetic */ int a = 0;
|
|
public final UUID b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final MediaDrm f1014c;
|
|
public int d;
|
|
|
|
public z(UUID uuid) throws UnsupportedSchemeException {
|
|
UUID uuid2;
|
|
Objects.requireNonNull(uuid);
|
|
AnimatableValueParser.n(!h0.b.equals(uuid), "Use C.CLEARKEY_UUID instead");
|
|
this.b = uuid;
|
|
MediaDrm mediaDrm = new MediaDrm((f0.a >= 27 || !h0.f873c.equals(uuid)) ? uuid : uuid2);
|
|
this.f1014c = mediaDrm;
|
|
this.d = 1;
|
|
if (h0.d.equals(uuid) && "ASUS_Z00AD".equals(f0.d)) {
|
|
mediaDrm.setPropertyString("securityLevel", "L3");
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public Class<y> a() {
|
|
return y.class;
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public Map<String, String> b(byte[] bArr) {
|
|
return this.f1014c.queryKeyStatus(bArr);
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public w c(byte[] bArr) throws MediaCryptoException {
|
|
int i = f0.a;
|
|
boolean z2 = i < 21 && h0.d.equals(this.b) && "L3".equals(this.f1014c.getPropertyString("securityLevel"));
|
|
UUID uuid = this.b;
|
|
if (i < 27 && h0.f873c.equals(uuid)) {
|
|
uuid = h0.b;
|
|
}
|
|
return new y(uuid, bArr, z2);
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public x.d d() {
|
|
MediaDrm.ProvisionRequest provisionRequest = this.f1014c.getProvisionRequest();
|
|
return new x.d(provisionRequest.getData(), provisionRequest.getDefaultUrl());
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public byte[] e() throws MediaDrmException {
|
|
return this.f1014c.openSession();
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public void f(byte[] bArr, byte[] bArr2) {
|
|
this.f1014c.restoreKeys(bArr, bArr2);
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public void g(byte[] bArr) {
|
|
this.f1014c.closeSession(bArr);
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public void h(@Nullable x.b bVar) {
|
|
this.f1014c.setOnEventListener(new m(this, bVar));
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
@Nullable
|
|
public byte[] i(byte[] bArr, byte[] bArr2) throws NotProvisionedException, DeniedByServerException {
|
|
if (h0.f873c.equals(this.b) && f0.a < 27) {
|
|
try {
|
|
JSONObject jSONObject = new JSONObject(f0.l(bArr2));
|
|
StringBuilder sb = new StringBuilder("{\"keys\":[");
|
|
JSONArray jSONArray = jSONObject.getJSONArray("keys");
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
if (i != 0) {
|
|
sb.append(",");
|
|
}
|
|
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
|
|
sb.append("{\"k\":\"");
|
|
sb.append(jSONObject2.getString("k").replace('-', '+').replace('_', '/'));
|
|
sb.append("\",\"kid\":\"");
|
|
sb.append(jSONObject2.getString("kid").replace('-', '+').replace('_', '/'));
|
|
sb.append("\",\"kty\":\"");
|
|
sb.append(jSONObject2.getString("kty"));
|
|
sb.append("\"}");
|
|
}
|
|
sb.append("]}");
|
|
bArr2 = f0.w(sb.toString());
|
|
} catch (JSONException e) {
|
|
StringBuilder L = a.L("Failed to adjust response data: ");
|
|
L.append(f0.l(bArr2));
|
|
p.b("ClearKeyUtil", L.toString(), e);
|
|
}
|
|
}
|
|
return this.f1014c.provideKeyResponse(bArr, bArr2);
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public void j(byte[] bArr) throws DeniedByServerException {
|
|
this.f1014c.provideProvisionResponse(bArr);
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:85:0x020a, code lost:
|
|
if ("AFTT".equals(r4) == false) goto L_0x0213;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:87:0x0210, code lost:
|
|
if (r1 != null) goto L_0x0214;
|
|
*/
|
|
@Override // c.i.a.c.z1.x
|
|
public x.a k(byte[] bArr, @Nullable List<DrmInitData.SchemeData> list, int i, @Nullable HashMap<String, String> hashMap) throws NotProvisionedException {
|
|
String str;
|
|
byte[] bArr2;
|
|
byte[] bArr3;
|
|
DrmInitData.SchemeData schemeData;
|
|
boolean z2;
|
|
DrmInitData.SchemeData schemeData2 = null;
|
|
if (list != null) {
|
|
if (!h0.d.equals(this.b)) {
|
|
schemeData = list.get(0);
|
|
} else {
|
|
if (f0.a >= 28 && list.size() > 1) {
|
|
DrmInitData.SchemeData schemeData3 = list.get(0);
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
while (true) {
|
|
if (i2 >= list.size()) {
|
|
z2 = true;
|
|
break;
|
|
}
|
|
DrmInitData.SchemeData schemeData4 = list.get(i2);
|
|
byte[] bArr4 = schemeData4.m;
|
|
Objects.requireNonNull(bArr4);
|
|
if (!(f0.a(schemeData4.l, schemeData3.l) && f0.a(schemeData4.k, schemeData3.k))) {
|
|
break;
|
|
}
|
|
if (!(AnimatableValueParser.V1(bArr4) != null)) {
|
|
break;
|
|
}
|
|
i3 += bArr4.length;
|
|
i2++;
|
|
}
|
|
z2 = false;
|
|
if (z2) {
|
|
byte[] bArr5 = new byte[i3];
|
|
int i4 = 0;
|
|
for (int i5 = 0; i5 < list.size(); i5++) {
|
|
byte[] bArr6 = list.get(i5).m;
|
|
Objects.requireNonNull(bArr6);
|
|
int length = bArr6.length;
|
|
System.arraycopy(bArr6, 0, bArr5, i4, length);
|
|
i4 += length;
|
|
}
|
|
schemeData = new DrmInitData.SchemeData(schemeData3.j, schemeData3.k, schemeData3.l, bArr5);
|
|
}
|
|
}
|
|
for (int i6 = 0; i6 < list.size(); i6++) {
|
|
DrmInitData.SchemeData schemeData5 = list.get(i6);
|
|
byte[] bArr7 = schemeData5.m;
|
|
Objects.requireNonNull(bArr7);
|
|
j V1 = AnimatableValueParser.V1(bArr7);
|
|
int i7 = V1 == null ? -1 : V1.b;
|
|
int i8 = f0.a;
|
|
if ((i8 < 23 && i7 == 0) || (i8 >= 23 && i7 == 1)) {
|
|
schemeData2 = schemeData5;
|
|
break;
|
|
}
|
|
}
|
|
schemeData = list.get(0);
|
|
}
|
|
schemeData2 = schemeData;
|
|
UUID uuid = this.b;
|
|
byte[] bArr8 = schemeData2.m;
|
|
Objects.requireNonNull(bArr8);
|
|
UUID uuid2 = h0.e;
|
|
if (uuid2.equals(uuid)) {
|
|
byte[] W1 = AnimatableValueParser.W1(bArr8, uuid);
|
|
if (W1 != null) {
|
|
bArr8 = W1;
|
|
}
|
|
int i9 = (bArr8[0] & 255) | ((bArr8[1] & 255) << 8) | ((bArr8[2] & 255) << 16) | ((bArr8[3] & 255) << 24);
|
|
short s2 = (short) (((bArr8[5] & 255) << 8) | (bArr8[4] & 255));
|
|
short s3 = (short) (((bArr8[7] & 255) << 8) | (bArr8[6] & 255));
|
|
if (s2 == 1 && s3 == 1) {
|
|
int i10 = (bArr8[9] & 255) << 8;
|
|
Charset charset = c.d;
|
|
String str2 = new String(bArr8, 10, (short) (i10 | (bArr8[8] & 255)), charset);
|
|
if (!str2.contains("<LA_URL>")) {
|
|
int indexOf = str2.indexOf("</DATA>");
|
|
if (indexOf == -1) {
|
|
Log.w("FrameworkMediaDrm", "Could not find the </DATA> tag. Skipping LA_URL workaround.");
|
|
}
|
|
String str3 = str2.substring(0, indexOf) + "<LA_URL>https://x</LA_URL>" + str2.substring(indexOf);
|
|
int i11 = i9 + 52;
|
|
ByteBuffer allocate = ByteBuffer.allocate(i11);
|
|
allocate.order(ByteOrder.LITTLE_ENDIAN);
|
|
allocate.putInt(i11);
|
|
allocate.putShort((short) s2);
|
|
allocate.putShort((short) s3);
|
|
allocate.putShort((short) (str3.length() * 2));
|
|
allocate.put(str3.getBytes(charset));
|
|
bArr8 = allocate.array();
|
|
}
|
|
} else {
|
|
Log.i("FrameworkMediaDrm", "Unexpected record count or type. Skipping LA_URL workaround.");
|
|
}
|
|
int length2 = (bArr8 != null ? bArr8.length : 0) + 32;
|
|
ByteBuffer allocate2 = ByteBuffer.allocate(length2);
|
|
allocate2.putInt(length2);
|
|
allocate2.putInt(1886614376);
|
|
allocate2.putInt(0);
|
|
allocate2.putLong(uuid2.getMostSignificantBits());
|
|
allocate2.putLong(uuid2.getLeastSignificantBits());
|
|
if (!(bArr8 == null || bArr8.length == 0)) {
|
|
allocate2.putInt(bArr8.length);
|
|
allocate2.put(bArr8);
|
|
}
|
|
bArr8 = allocate2.array();
|
|
}
|
|
int i12 = f0.a;
|
|
if (i12 >= 23 || !h0.d.equals(uuid)) {
|
|
if (uuid2.equals(uuid) && "Amazon".equals(f0.f899c)) {
|
|
String str4 = f0.d;
|
|
if (!"AFTB".equals(str4)) {
|
|
if (!"AFTS".equals(str4)) {
|
|
if (!"AFTM".equals(str4)) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
bArr3 = bArr8;
|
|
UUID uuid3 = this.b;
|
|
String str5 = schemeData2.l;
|
|
bArr2 = bArr3;
|
|
str = (i12 >= 26 || !h0.f873c.equals(uuid3) || (!"video/mp4".equals(str5) && !"audio/mp4".equals(str5))) ? str5 : "cenc";
|
|
}
|
|
bArr3 = AnimatableValueParser.W1(bArr8, uuid);
|
|
} else {
|
|
bArr2 = null;
|
|
str = null;
|
|
}
|
|
MediaDrm.KeyRequest keyRequest = this.f1014c.getKeyRequest(bArr, bArr2, str, i, hashMap);
|
|
UUID uuid4 = this.b;
|
|
byte[] data = keyRequest.getData();
|
|
if (h0.f873c.equals(uuid4) && f0.a < 27) {
|
|
data = f0.w(f0.l(data).replace('+', '-').replace('/', '_'));
|
|
}
|
|
String defaultUrl = keyRequest.getDefaultUrl();
|
|
if ("https://x".equals(defaultUrl)) {
|
|
defaultUrl = "";
|
|
}
|
|
if (TextUtils.isEmpty(defaultUrl) && schemeData2 != null && !TextUtils.isEmpty(schemeData2.k)) {
|
|
defaultUrl = schemeData2.k;
|
|
}
|
|
return new x.a(data, defaultUrl, f0.a >= 23 ? keyRequest.getRequestType() : Integer.MIN_VALUE);
|
|
}
|
|
|
|
@Override // c.i.a.c.z1.x
|
|
public synchronized void release() {
|
|
int i = this.d - 1;
|
|
this.d = i;
|
|
if (i == 0) {
|
|
this.f1014c.release();
|
|
}
|
|
}
|
|
}
|