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

import android.view.MotionEvent;
import androidx.annotation.Nullable;
import java.util.ArrayDeque;
import java.util.HashMap;

/* JADX INFO: loaded from: classes2.dex */
public final class dm1 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayDeque f10443a = new ArrayDeque();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public bm1 f10444b = new bm1();

    @Nullable
    private MotionEvent zzb;

    public final synchronized void a(MotionEvent motionEvent) {
        try {
            if (motionEvent.getAction() == 1) {
                this.zzb = MotionEvent.obtain(motionEvent);
            }
            this.f10444b.a(motionEvent);
            ArrayDeque arrayDeque = this.f10443a;
            if (arrayDeque.size() >= 6) {
                arrayDeque.remove();
            }
            arrayDeque.add(new cm1(motionEvent));
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized void b(HashMap map) {
        try {
            MotionEvent motionEvent = this.zzb;
            if (motionEvent != null) {
                map.put("nv", motionEvent);
            }
            map.put("oe", this.f10444b);
            ArrayDeque arrayDeque = this.f10443a;
            map.put("ro", arrayDeque.toArray(new cm1[arrayDeque.size()]));
            this.f10444b = new bm1();
            arrayDeque.clear();
            MotionEvent motionEvent2 = this.zzb;
            if (motionEvent2 != null) {
                motionEvent2.recycle();
                this.zzb = null;
            }
        } catch (Throwable th) {
            throw th;
        }
    }
}
