package com.appsflyer.internal;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Handler;
import android.os.Looper;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class t {

    /* renamed from: ˋॱ  reason: contains not printable characters */
    public static volatile t f2122;

    /* renamed from: ˏॱ  reason: contains not printable characters */
    public static final Handler f2123 = new Handler(Looper.getMainLooper());

    /* renamed from: ॱ  reason: contains not printable characters */
    public static final BitSet f2124 = new BitSet(6);

    /* renamed from: ʻ  reason: contains not printable characters */
    public final Runnable f2125 = new Runnable() {
        /* class com.appsflyer.internal.t.AnonymousClass5 */

        public final void run() {
            synchronized (t.this.f2130) {
                t tVar = t.this;
                try {
                    for (Sensor sensor : tVar.f2128.getSensorList(-1)) {
                        int type = sensor.getType();
                        if (type >= 0 && t.f2124.get(type)) {
                            q qVar = new q(sensor.getType(), sensor.getName(), sensor.getVendor());
                            if (!tVar.f2129.containsKey(qVar)) {
                                tVar.f2129.put(qVar, qVar);
                            }
                            tVar.f2128.registerListener(tVar.f2129.get(qVar), sensor, 0);
                        }
                    }
                } catch (Throwable unused) {
                }
                tVar.f2126 = true;
                t.this.f2131.postDelayed(t.this.f2127, 500);
                t.this.f2133 = true;
            }
        }
    };

    /* renamed from: ʼ  reason: contains not printable characters */
    public boolean f2126;

    /* renamed from: ʽ  reason: contains not printable characters */
    public final Runnable f2127 = new Runnable() {
        /* class com.appsflyer.internal.t.AnonymousClass1 */

        public final void run() {
            synchronized (t.this.f2130) {
                t.this.m1245();
                t.this.f2131.postDelayed(t.this.f2125, 1800000);
            }
        }
    };

    /* renamed from: ˊ  reason: contains not printable characters */
    public final SensorManager f2128;

    /* renamed from: ˋ  reason: contains not printable characters */
    public final Map<q, q> f2129 = new HashMap(f2124.size());

    /* renamed from: ˎ  reason: contains not printable characters */
    public final Object f2130 = new Object();

    /* renamed from: ˏ  reason: contains not printable characters */
    public final Handler f2131;

    /* renamed from: ॱˊ  reason: contains not printable characters */
    public final Map<q, Map<String, Object>> f2132 = new HashMap(f2124.size());

    /* renamed from: ॱॱ  reason: contains not printable characters */
    public boolean f2133;

    /* renamed from: ᐝ  reason: contains not printable characters */
    public final Runnable f2134 = new Runnable() {
        /* class com.appsflyer.internal.t.AnonymousClass2 */

        public final void run() {
            synchronized (t.this.f2130) {
                if (t.this.f2133) {
                    t.this.f2131.removeCallbacks(t.this.f2125);
                    t.this.f2131.removeCallbacks(t.this.f2127);
                    t.this.m1245();
                    t.this.f2133 = false;
                }
            }
        }
    };

    static {
        f2124.set(1);
        f2124.set(2);
        f2124.set(4);
    }

    public t(SensorManager sensorManager, Handler handler) {
        this.f2128 = sensorManager;
        this.f2131 = handler;
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    public static t m1243(Context context) {
        return m1244((SensorManager) context.getApplicationContext().getSystemService("sensor"), f2123);
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    public static t m1244(SensorManager sensorManager, Handler handler) {
        if (f2122 == null) {
            synchronized (t.class) {
                if (f2122 == null) {
                    f2122 = new t(sensorManager, handler);
                }
            }
        }
        return f2122;
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    public final List<Map<String, Object>> m1246() {
        synchronized (this.f2130) {
            if (!this.f2129.isEmpty() && this.f2126) {
                for (q qVar : this.f2129.values()) {
                    qVar.m1237(this.f2132, false);
                }
            }
            if (this.f2132.isEmpty()) {
                return Collections.emptyList();
            }
            return new ArrayList(this.f2132.values());
        }
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    public final void m1245() {
        try {
            if (!this.f2129.isEmpty()) {
                for (q qVar : this.f2129.values()) {
                    this.f2128.unregisterListener(qVar);
                    qVar.m1237(this.f2132, true);
                }
            }
        } catch (Throwable unused) {
        }
        this.f2126 = false;
    }
}
