package com.google.android.gms.internal.ads;

import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.view.Choreographer;
import android.view.Choreographer$VsyncCallback;

/* JADX INFO: loaded from: classes2.dex */
public final class h1 extends f1 implements Choreographer$VsyncCallback {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Handler f11976e;

    public /* synthetic */ h1(Choreographer choreographer, DisplayManager displayManager) {
        super(choreographer, displayManager);
        this.f11976e = bb1.zzc(null);
    }

    @Override // com.google.android.gms.internal.ads.f1
    public final void a() {
        this.f10982b.registerDisplayListener(this, bb1.zzc(null));
        this.f10981a.postVsyncCallback(this);
    }

    @Override // com.google.android.gms.internal.ads.f1
    public final void b() {
        this.f10982b.unregisterDisplayListener(this);
        this.f11976e.removeCallbacksAndMessages(null);
        this.f10981a.removeVsyncCallback(this);
        this.f10983c = -9223372036854775807L;
        this.f10984d = -9223372036854775807L;
    }

    @Override // android.hardware.display.DisplayManager.DisplayListener
    public final void onDisplayChanged(int i10) {
        if (i10 == 0) {
            this.f10981a.postVsyncCallback(this);
        }
    }

    public final void onVsync(Choreographer.FrameData frameData) {
        this.f10983c = frameData.getFrameTimeNanos();
        Choreographer.FrameTimeline[] frameTimelines = frameData.getFrameTimelines();
        if (frameTimelines.length >= 2) {
            long expectedPresentationTimeNanos = frameTimelines[1].getExpectedPresentationTimeNanos() - frameTimelines[0].getExpectedPresentationTimeNanos();
            this.f10984d = expectedPresentationTimeNanos != 0 ? expectedPresentationTimeNanos : -9223372036854775807L;
        } else {
            this.f10984d = -9223372036854775807L;
        }
        this.f11976e.postDelayed(new mv1(this, 4), 500L);
    }
}
