package com.appsflyer.internal;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class q implements SensorEventListener {

    /* renamed from: ʻ  reason: contains not printable characters */
    public final int f2109;

    /* renamed from: ʽ  reason: contains not printable characters */
    public long f2110;

    /* renamed from: ˊ  reason: contains not printable characters */
    public final int f2111;

    /* renamed from: ˋ  reason: contains not printable characters */
    public final long[] f2112 = new long[2];

    /* renamed from: ˎ  reason: contains not printable characters */
    public final String f2113;

    /* renamed from: ˏ  reason: contains not printable characters */
    public final float[][] f2114 = new float[2][];

    /* renamed from: ॱ  reason: contains not printable characters */
    public final String f2115;

    /* renamed from: ॱॱ  reason: contains not printable characters */
    public double f2116;

    public q(int i, String str, String str2) {
        this.f2111 = i;
        this.f2113 = str == null ? "" : str;
        this.f2115 = str2 == null ? "" : str2;
        this.f2109 = this.f2115.hashCode() + ((this.f2113.hashCode() + ((i + 31) * 31)) * 31);
    }

    /* renamed from: ˊ  reason: contains not printable characters */
    private boolean m1233(int i, String str, String str2) {
        return this.f2111 == i && this.f2113.equals(str) && this.f2115.equals(str2);
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    private Map<String, Object> m1234() {
        HashMap hashMap = new HashMap(7);
        hashMap.put("sT", Integer.valueOf(this.f2111));
        hashMap.put("sN", this.f2113);
        hashMap.put("sV", this.f2115);
        float[] fArr = this.f2114[0];
        if (fArr != null) {
            hashMap.put("sVS", m1236(fArr));
        }
        float[] fArr2 = this.f2114[1];
        if (fArr2 != null) {
            hashMap.put("sVE", m1236(fArr2));
        }
        return hashMap;
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    public static double m1235(float[] fArr, float[] fArr2) {
        int min = Math.min(fArr.length, fArr2.length);
        double d = 0.0d;
        for (int i = 0; i < min; i++) {
            d += StrictMath.pow((double) (fArr[i] - fArr2[i]), 2.0d);
        }
        return Math.sqrt(d);
    }

    public final boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof q)) {
            return false;
        }
        q qVar = (q) obj;
        return m1233(qVar.f2111, qVar.f2113, qVar.f2115);
    }

    public final int hashCode() {
        return this.f2109;
    }

    public final void onAccuracyChanged(Sensor sensor, int i) {
    }

    public final void onSensorChanged(SensorEvent sensorEvent) {
        if (sensorEvent != null && sensorEvent.values != null) {
            Sensor sensor = sensorEvent.sensor;
            if ((sensor == null || sensor.getName() == null || sensor.getVendor() == null) ? false : true) {
                int type = sensorEvent.sensor.getType();
                String name = sensorEvent.sensor.getName();
                String vendor = sensorEvent.sensor.getVendor();
                long j = sensorEvent.timestamp;
                float[] fArr = sensorEvent.values;
                if (m1233(type, name, vendor)) {
                    long currentTimeMillis = System.currentTimeMillis();
                    float[][] fArr2 = this.f2114;
                    float[] fArr3 = fArr2[0];
                    if (fArr3 == null) {
                        fArr2[0] = Arrays.copyOf(fArr, fArr.length);
                        this.f2112[0] = currentTimeMillis;
                        return;
                    }
                    float[] fArr4 = fArr2[1];
                    if (fArr4 == null) {
                        float[] copyOf = Arrays.copyOf(fArr, fArr.length);
                        this.f2114[1] = copyOf;
                        this.f2112[1] = currentTimeMillis;
                        this.f2116 = m1235(fArr3, copyOf);
                    } else if (50000000 <= j - this.f2110) {
                        this.f2110 = j;
                        if (Arrays.equals(fArr4, fArr)) {
                            this.f2112[1] = currentTimeMillis;
                            return;
                        }
                        double r0 = m1235(fArr3, fArr);
                        if (r0 > this.f2116) {
                            this.f2114[1] = Arrays.copyOf(fArr, fArr.length);
                            this.f2112[1] = currentTimeMillis;
                            this.f2116 = r0;
                        }
                    }
                }
            }
        }
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    public static List<Float> m1236(float[] fArr) {
        ArrayList arrayList = new ArrayList(fArr.length);
        for (float f : fArr) {
            arrayList.add(Float.valueOf(f));
        }
        return arrayList;
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    public final void m1237(Map<q, Map<String, Object>> map, boolean z) {
        if (this.f2114[0] != null) {
            map.put(this, m1234());
            if (z) {
                for (int i = 0; i < 2; i++) {
                    this.f2114[i] = null;
                }
                for (int i2 = 0; i2 < 2; i2++) {
                    this.f2112[i2] = 0;
                }
                this.f2116 = 0.0d;
                this.f2110 = 0;
            }
        } else if (!map.containsKey(this)) {
            map.put(this, m1234());
        }
    }
}
