- 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
206 lines
6.9 KiB
Java
206 lines
6.9 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.video;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.content.Context;
|
|
import android.graphics.SurfaceTexture;
|
|
import android.opengl.EGL14;
|
|
import android.os.Handler;
|
|
import android.os.HandlerThread;
|
|
import android.os.Message;
|
|
import android.util.Log;
|
|
import android.view.Surface;
|
|
import androidx.annotation.Nullable;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.EGLSurfaceTexture;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
|
|
|
|
@TargetApi(17)
|
|
/* loaded from: classes4.dex */
|
|
public final class DummySurface extends Surface {
|
|
private static final String EXTENSION_PROTECTED_CONTENT = "EGL_EXT_protected_content";
|
|
private static final String EXTENSION_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
|
|
private static final String TAG = "DummySurface";
|
|
private static int secureMode;
|
|
private static boolean secureModeInitialized;
|
|
public final boolean secure;
|
|
private final DummySurfaceThread thread;
|
|
private boolean threadReleased;
|
|
|
|
public static synchronized boolean isSecureSupported(Context context) {
|
|
boolean z;
|
|
synchronized (DummySurface.class) {
|
|
try {
|
|
if (!secureModeInitialized) {
|
|
secureMode = Util.SDK_INT < 24 ? 0 : getSecureModeV24(context);
|
|
secureModeInitialized = true;
|
|
}
|
|
z = secureMode != 0;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public static DummySurface newInstanceV17(Context context, boolean z) {
|
|
assertApiLevel17OrHigher();
|
|
Assertions.checkState(!z || isSecureSupported(context));
|
|
return new DummySurfaceThread().init(z ? secureMode : 0);
|
|
}
|
|
|
|
private DummySurface(DummySurfaceThread dummySurfaceThread, SurfaceTexture surfaceTexture, boolean z) {
|
|
super(surfaceTexture);
|
|
this.thread = dummySurfaceThread;
|
|
this.secure = z;
|
|
}
|
|
|
|
@Override // android.view.Surface
|
|
public final void release() {
|
|
super.release();
|
|
synchronized (this.thread) {
|
|
try {
|
|
if (!this.threadReleased) {
|
|
this.thread.release();
|
|
this.threadReleased = true;
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void assertApiLevel17OrHigher() {
|
|
if (Util.SDK_INT < 17) {
|
|
throw new UnsupportedOperationException("Unsupported prior to API level 17");
|
|
}
|
|
}
|
|
|
|
@TargetApi(24)
|
|
private static int getSecureModeV24(Context context) {
|
|
String eglQueryString;
|
|
int i = Util.SDK_INT;
|
|
if (i < 26 && ("samsung".equals(Util.MANUFACTURER) || "XT1650".equals(Util.MODEL))) {
|
|
return 0;
|
|
}
|
|
if ((i >= 26 || context.getPackageManager().hasSystemFeature("android.hardware.vr.high_performance")) && (eglQueryString = EGL14.eglQueryString(EGL14.eglGetDisplay(0), 12373)) != null && eglQueryString.contains(EXTENSION_PROTECTED_CONTENT)) {
|
|
return eglQueryString.contains(EXTENSION_SURFACELESS_CONTEXT) ? 1 : 2;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public static class DummySurfaceThread extends HandlerThread implements Handler.Callback {
|
|
private static final int MSG_INIT = 1;
|
|
private static final int MSG_RELEASE = 2;
|
|
|
|
@Nullable
|
|
private EGLSurfaceTexture eglSurfaceTexture;
|
|
|
|
@Nullable
|
|
private Handler handler;
|
|
|
|
@Nullable
|
|
private Error initError;
|
|
|
|
@Nullable
|
|
private RuntimeException initException;
|
|
|
|
@Nullable
|
|
private DummySurface surface;
|
|
|
|
public DummySurfaceThread() {
|
|
super("dummySurface");
|
|
}
|
|
|
|
public DummySurface init(int i) {
|
|
boolean z;
|
|
start();
|
|
this.handler = new Handler(getLooper(), this);
|
|
this.eglSurfaceTexture = new EGLSurfaceTexture(this.handler);
|
|
synchronized (this) {
|
|
z = false;
|
|
this.handler.obtainMessage(1, i, 0).sendToTarget();
|
|
while (this.surface == null && this.initException == null && this.initError == null) {
|
|
try {
|
|
wait();
|
|
} catch (InterruptedException unused) {
|
|
z = true;
|
|
}
|
|
}
|
|
}
|
|
if (z) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
RuntimeException runtimeException = this.initException;
|
|
if (runtimeException != null) {
|
|
throw runtimeException;
|
|
}
|
|
Error error = this.initError;
|
|
if (error != null) {
|
|
throw error;
|
|
}
|
|
return (DummySurface) Assertions.checkNotNull(this.surface);
|
|
}
|
|
|
|
public void release() {
|
|
Assertions.checkNotNull(this.handler);
|
|
this.handler.sendEmptyMessage(2);
|
|
}
|
|
|
|
@Override // android.os.Handler.Callback
|
|
public boolean handleMessage(Message message) {
|
|
int i = message.what;
|
|
try {
|
|
if (i != 1) {
|
|
if (i != 2) {
|
|
return true;
|
|
}
|
|
try {
|
|
releaseInternal();
|
|
} finally {
|
|
try {
|
|
return true;
|
|
} finally {
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
try {
|
|
initInternal(message.arg1);
|
|
synchronized (this) {
|
|
notify();
|
|
}
|
|
} catch (Error e) {
|
|
Log.e(DummySurface.TAG, "Failed to initialize dummy surface", e);
|
|
this.initError = e;
|
|
synchronized (this) {
|
|
notify();
|
|
}
|
|
} catch (RuntimeException e2) {
|
|
Log.e(DummySurface.TAG, "Failed to initialize dummy surface", e2);
|
|
this.initException = e2;
|
|
synchronized (this) {
|
|
notify();
|
|
}
|
|
}
|
|
return true;
|
|
} catch (Throwable th) {
|
|
synchronized (this) {
|
|
notify();
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void initInternal(int i) {
|
|
Assertions.checkNotNull(this.eglSurfaceTexture);
|
|
this.eglSurfaceTexture.init(i);
|
|
this.surface = new DummySurface(this, this.eglSurfaceTexture.getSurfaceTexture(), i != 0);
|
|
}
|
|
|
|
private void releaseInternal() {
|
|
Assertions.checkNotNull(this.eglSurfaceTexture);
|
|
this.eglSurfaceTexture.release();
|
|
}
|
|
}
|
|
}
|