package com.pgl.ssdk;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes6.dex */
public final class D implements SensorEventListener {
    private static D f;

    /* renamed from: a  reason: collision with root package name */
    private SensorManager f4733a;
    private int b;
    private int c = 0;
    private float[] d = new float[3];
    private List<String> e = new ArrayList();

    private D(Context context) {
        this.f4733a = null;
        Context applicationContext = context.getApplicationContext();
        if (applicationContext != null) {
            try {
                this.f4733a = (SensorManager) applicationContext.getSystemService("sensor");
            } catch (Throwable unused) {
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:9:0x0017, code lost:
        if (r7.f4733a.registerListener(r7, r3.getDefaultSensor(1), 3) != false) goto L11;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void a() {
        /*
            Method dump skipped, instructions count: 234
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.pgl.ssdk.D.a():void");
    }

    public synchronized String b() {
        String str = "";
        int size = this.e.size();
        if (size <= 0) {
            return "";
        }
        if (size == 1) {
            return this.e.get(0);
        }
        try {
            List<String> list = this.e;
            int i = size - 10;
            if (i <= 0) {
                i = 0;
            }
            List<String> subList = list.subList(i, size);
            for (int i2 = 0; i2 < subList.size(); i2++) {
                str = str + subList.get(i2) + com.amazon.a.a.o.b.f.c;
            }
            str = str.substring(0, str.length() - 1);
        } catch (Throwable unused) {
        }
        return str;
    }

    @Override // android.hardware.SensorEventListener
    public void onAccuracyChanged(Sensor sensor, int i) {
    }

    @Override // android.hardware.SensorEventListener
    public void onSensorChanged(SensorEvent sensorEvent) {
        this.d = sensorEvent.values;
        this.c = 1;
    }

    private synchronized void c() {
        try {
            SensorManager sensorManager = this.f4733a;
            if (sensorManager != null) {
                int i = this.b - 1;
                this.b = i;
                if (i == 0) {
                    sensorManager.unregisterListener(this);
                }
            }
        } catch (Exception unused) {
        }
    }

    public static D a(Context context) {
        if (f == null) {
            synchronized (D.class) {
                if (f == null) {
                    f = new D(context);
                }
            }
        }
        return f;
    }
}
