Commit 863b443a by jbibik Committed by Tianyi Feng

Fix Gradle Lint with @RequiresApi and SDK version

Gradle Lint doesn't recognise `checkState` assertion and TargetApi should only ever be used for suppressing a bug in Android Lint. Hence, we keep @RequiresApi and add an if-statement explicitly. Also, fixes >26 to >=26 for the version check.

PiperOrigin-RevId: 555144577
(cherry picked from commit 5720b6197479f3cd54b82d2e1e3ec9b50397e267)
parent 33ad3c23
......@@ -15,17 +15,16 @@
*/
package com.google.android.exoplayer2.transformer.mh;
import static com.google.android.exoplayer2.util.Assertions.checkState;
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
import android.graphics.Bitmap;
import android.os.Build;
import android.view.Surface;
import com.google.android.exoplayer2.effect.DefaultVideoFrameProcessor;
import com.google.android.exoplayer2.testutil.BitmapPixelTestUtil;
import com.google.android.exoplayer2.testutil.VideoFrameProcessorTestRunner;
import com.google.android.exoplayer2.util.GlTextureInfo;
import com.google.android.exoplayer2.util.GlUtil;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.util.VideoFrameProcessingException;
import java.util.Map;
import java.util.Set;
......@@ -39,7 +38,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* <p>Reads from an OpenGL texture. Only for use on physical devices.
*/
public final class TextureBitmapReader implements VideoFrameProcessorTestRunner.BitmapReader {
// TODO(b/239172735): This outputs an incorrect black output image on emulators.
private final Map<Long, Bitmap> outputTimestampsToBitmaps;
private boolean useHighPrecisionColorComponents;
private @MonotonicNonNull Bitmap outputBitmap;
......@@ -91,7 +89,9 @@ public final class TextureBitmapReader implements VideoFrameProcessorTestRunner.
if (!useHighPrecisionColorComponents) {
return BitmapPixelTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
}
checkState(Util.SDK_INT > 26, "useHighPrecisionColorComponents only supported on API 26+");
if (Build.VERSION.SDK_INT < 26) {
throw new IllegalStateException("useHighPrecisionColorComponents only supported on API 26+");
}
return BitmapPixelTestUtil.createFp16BitmapFromCurrentGlFramebuffer(width, height);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment