Add null-check to PlayerView to avoid NPE in edit mode

Previously we assumed that `surfaceSyncGroupV34` was always non-null on
API 34, but this isn't true in edit mode. Instead we add an explicit
null-check before accessing it. We don't need to null-check it at the
other usage site because we are already null-checking `surfaceView` (via
`instanceof` check).

Issue: androidx/media#1237

#cherrypick

PiperOrigin-RevId: 645008049
This commit is contained in:
ibaker 2024-06-20 06:28:04 -07:00 committed by Copybara-Service
parent 307655f6d5
commit 99803066ea

View File

@ -1783,8 +1783,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (Util.SDK_INT == 34) {
checkNotNull(surfaceSyncGroupV34).maybeMarkSyncReadyAndClear();
if (Util.SDK_INT == 34 && surfaceSyncGroupV34 != null) {
surfaceSyncGroupV34.maybeMarkSyncReadyAndClear();
}
}