mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Rewrite logic for enabling secure DummySurface
Issue: #3215 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=167505797
This commit is contained in:
parent
a0df5bb50a
commit
bec5e6e2b2
1 changed files with 19 additions and 16 deletions
|
|
@ -90,12 +90,7 @@ public final class DummySurface extends Surface {
|
||||||
*/
|
*/
|
||||||
public static synchronized boolean isSecureSupported(Context context) {
|
public static synchronized boolean isSecureSupported(Context context) {
|
||||||
if (!secureSupportedInitialized) {
|
if (!secureSupportedInitialized) {
|
||||||
if (Util.SDK_INT >= 17) {
|
secureSupported = Util.SDK_INT >= 24 && enableSecureDummySurfaceV24(context);
|
||||||
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
||||||
String extensions = EGL14.eglQueryString(display, EGL10.EGL_EXTENSIONS);
|
|
||||||
secureSupported = extensions != null && extensions.contains("EGL_EXT_protected_content")
|
|
||||||
&& !deviceNeedsSecureDummySurfaceWorkaround(context);
|
|
||||||
}
|
|
||||||
secureSupportedInitialized = true;
|
secureSupportedInitialized = true;
|
||||||
}
|
}
|
||||||
return secureSupported;
|
return secureSupported;
|
||||||
|
|
@ -148,20 +143,28 @@ public final class DummySurface extends Surface {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the device is known to advertise secure surface textures but not implement them
|
* Returns whether use of secure dummy surfaces should be enabled.
|
||||||
* correctly.
|
|
||||||
*
|
*
|
||||||
* @param context Any {@link Context}.
|
* @param context Any {@link Context}.
|
||||||
*/
|
*/
|
||||||
private static boolean deviceNeedsSecureDummySurfaceWorkaround(Context context) {
|
|
||||||
return (Util.SDK_INT == 24 && "samsung".equals(Util.MANUFACTURER))
|
|
||||||
|| (Util.SDK_INT < 26
|
|
||||||
&& !hasVrModeHighPerformanceSystemFeatureV24(context.getPackageManager()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(24)
|
@TargetApi(24)
|
||||||
private static boolean hasVrModeHighPerformanceSystemFeatureV24(PackageManager packageManager) {
|
private static boolean enableSecureDummySurfaceV24(Context context) {
|
||||||
return packageManager.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
|
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
String eglExtensions = EGL14.eglQueryString(display, EGL10.EGL_EXTENSIONS);
|
||||||
|
if (eglExtensions == null || !eglExtensions.contains("EGL_EXT_protected_content")) {
|
||||||
|
// EGL_EXT_protected_content is required to enable secure dummy surfaces.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Util.SDK_INT == 24 && "samsung".equals(Util.MANUFACTURER)) {
|
||||||
|
// Samsung devices running API level 24 are known to be broken [Internal: b/37197802].
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Util.SDK_INT < 26 && !context.getPackageManager().hasSystemFeature(
|
||||||
|
PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE)) {
|
||||||
|
// Pre API level 26 devices were not well tested unless they supported VR mode.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DummySurfaceThread extends HandlerThread implements OnFrameAvailableListener,
|
private static class DummySurfaceThread extends HandlerThread implements OnFrameAvailableListener,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue