Fix NewApi error for DummySurface usage

API level >= 17 is guaranteed by shouldUseDummySurface returning true,
but Android Studio shows a warning anyway.

PiperOrigin-RevId: 295118491
This commit is contained in:
andrewlewis 2020-02-14 12:16:19 +00:00 committed by Ian Baker
parent c1e0d77389
commit 07f66ea469
2 changed files with 3 additions and 8 deletions

View file

@ -80,7 +80,6 @@ public final class DummySurface extends Surface {
* {@link #isSecureSupported(Context)} returns {@code false}.
*/
public static DummySurface newInstanceV17(Context context, boolean secure) {
assertApiLevel17OrHigher();
Assertions.checkState(!secure || isSecureSupported(context));
DummySurfaceThread thread = new DummySurfaceThread();
return thread.init(secure ? secureMode : SECURE_MODE_NONE);
@ -107,12 +106,6 @@ public final class DummySurface extends Surface {
}
}
private static void assertApiLevel17OrHigher() {
if (Util.SDK_INT < 17) {
throw new UnsupportedOperationException("Unsupported prior to API level 17");
}
}
@SecureMode
private static int getSecureMode(Context context) {
if (GlUtil.isProtectedContentExtensionSupported(context)) {

View file

@ -641,7 +641,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
deviceNeedsNoPostProcessWorkaround,
tunnelingAudioSessionId);
if (surface == null) {
Assertions.checkState(shouldUseDummySurface(codecInfo));
if (!shouldUseDummySurface(codecInfo)) {
throw new IllegalStateException();
}
if (dummySurface == null) {
dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
}