- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
134 lines
6.3 KiB
Java
134 lines
6.3 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.drm;
|
|
|
|
import android.os.ConditionVariable;
|
|
import android.os.Handler;
|
|
import android.os.HandlerThread;
|
|
import android.util.Pair;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.C;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.drm.DrmSession;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.drm.ExoMediaCrypto;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.upstream.HttpDataSource;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
|
|
import java.util.HashMap;
|
|
import java.util.UUID;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
|
|
private final ConditionVariable conditionVariable;
|
|
private final DefaultDrmSessionManager<T> drmSessionManager;
|
|
private final HandlerThread handlerThread;
|
|
|
|
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(String str, HttpDataSource.Factory factory) throws UnsupportedDrmException {
|
|
return newWidevineInstance(str, false, factory, null);
|
|
}
|
|
|
|
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(String str, boolean z, HttpDataSource.Factory factory) throws UnsupportedDrmException {
|
|
return newWidevineInstance(str, z, factory, null);
|
|
}
|
|
|
|
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(String str, boolean z, HttpDataSource.Factory factory, HashMap<String, String> hashMap) throws UnsupportedDrmException {
|
|
UUID uuid = C.WIDEVINE_UUID;
|
|
return new OfflineLicenseHelper<>(uuid, FrameworkMediaDrm.newInstance(uuid), new HttpMediaDrmCallback(str, z, factory), hashMap);
|
|
}
|
|
|
|
public OfflineLicenseHelper(UUID uuid, ExoMediaDrm<T> exoMediaDrm, MediaDrmCallback mediaDrmCallback, HashMap<String, String> hashMap) {
|
|
HandlerThread handlerThread = new HandlerThread("OfflineLicenseHelper");
|
|
this.handlerThread = handlerThread;
|
|
handlerThread.start();
|
|
this.conditionVariable = new ConditionVariable();
|
|
DefaultDrmSessionEventListener defaultDrmSessionEventListener = new DefaultDrmSessionEventListener() { // from class: com.mbridge.msdk.playercommon.exoplayer2.drm.OfflineLicenseHelper.1
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.drm.DefaultDrmSessionEventListener
|
|
public void onDrmKeysLoaded() {
|
|
OfflineLicenseHelper.this.conditionVariable.open();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.drm.DefaultDrmSessionEventListener
|
|
public void onDrmSessionManagerError(Exception exc) {
|
|
OfflineLicenseHelper.this.conditionVariable.open();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.drm.DefaultDrmSessionEventListener
|
|
public void onDrmKeysRestored() {
|
|
OfflineLicenseHelper.this.conditionVariable.open();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.drm.DefaultDrmSessionEventListener
|
|
public void onDrmKeysRemoved() {
|
|
OfflineLicenseHelper.this.conditionVariable.open();
|
|
}
|
|
};
|
|
DefaultDrmSessionManager<T> defaultDrmSessionManager = new DefaultDrmSessionManager<>(uuid, exoMediaDrm, mediaDrmCallback, hashMap);
|
|
this.drmSessionManager = defaultDrmSessionManager;
|
|
defaultDrmSessionManager.addListener(new Handler(handlerThread.getLooper()), defaultDrmSessionEventListener);
|
|
}
|
|
|
|
public final synchronized byte[] getPropertyByteArray(String str) {
|
|
return this.drmSessionManager.getPropertyByteArray(str);
|
|
}
|
|
|
|
public final synchronized void setPropertyByteArray(String str, byte[] bArr) {
|
|
this.drmSessionManager.setPropertyByteArray(str, bArr);
|
|
}
|
|
|
|
public final synchronized String getPropertyString(String str) {
|
|
return this.drmSessionManager.getPropertyString(str);
|
|
}
|
|
|
|
public final synchronized void setPropertyString(String str, String str2) {
|
|
this.drmSessionManager.setPropertyString(str, str2);
|
|
}
|
|
|
|
public final synchronized byte[] downloadLicense(DrmInitData drmInitData) throws DrmSession.DrmSessionException {
|
|
Assertions.checkArgument(drmInitData != null);
|
|
return blockingKeyRequest(2, null, drmInitData);
|
|
}
|
|
|
|
public final synchronized byte[] renewLicense(byte[] bArr) throws DrmSession.DrmSessionException {
|
|
Assertions.checkNotNull(bArr);
|
|
return blockingKeyRequest(2, bArr, null);
|
|
}
|
|
|
|
public final synchronized void releaseLicense(byte[] bArr) throws DrmSession.DrmSessionException {
|
|
Assertions.checkNotNull(bArr);
|
|
blockingKeyRequest(3, bArr, null);
|
|
}
|
|
|
|
public final synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] bArr) throws DrmSession.DrmSessionException {
|
|
Assertions.checkNotNull(bArr);
|
|
DrmSession<T> openBlockingKeyRequest = openBlockingKeyRequest(1, bArr, null);
|
|
DrmSession.DrmSessionException error = openBlockingKeyRequest.getError();
|
|
Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(openBlockingKeyRequest);
|
|
this.drmSessionManager.releaseSession(openBlockingKeyRequest);
|
|
if (error == null) {
|
|
return licenseDurationRemainingSec;
|
|
}
|
|
if (error.getCause() instanceof KeysExpiredException) {
|
|
return Pair.create(0L, 0L);
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
public final void release() {
|
|
this.handlerThread.quit();
|
|
}
|
|
|
|
private byte[] blockingKeyRequest(int i, byte[] bArr, DrmInitData drmInitData) throws DrmSession.DrmSessionException {
|
|
DrmSession<T> openBlockingKeyRequest = openBlockingKeyRequest(i, bArr, drmInitData);
|
|
DrmSession.DrmSessionException error = openBlockingKeyRequest.getError();
|
|
byte[] offlineLicenseKeySetId = openBlockingKeyRequest.getOfflineLicenseKeySetId();
|
|
this.drmSessionManager.releaseSession(openBlockingKeyRequest);
|
|
if (error == null) {
|
|
return offlineLicenseKeySetId;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
private DrmSession<T> openBlockingKeyRequest(int i, byte[] bArr, DrmInitData drmInitData) {
|
|
this.drmSessionManager.setMode(i, bArr);
|
|
this.conditionVariable.close();
|
|
DrmSession<T> acquireSession = this.drmSessionManager.acquireSession(this.handlerThread.getLooper(), drmInitData);
|
|
this.conditionVariable.block();
|
|
return acquireSession;
|
|
}
|
|
}
|