package com.tencent.mm.plugin.scanner.util;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.HandlerThread;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ak;
import com.tencent.mm.sdk.platformtools.bo;

public class ScanCameraLightDetector implements SensorEventListener {
    public static final ScanCameraLightDetector qia = new ScanCameraLightDetector();
    public ak handler;
    private float lTs = -1.0f;
    public long qib = -1;
    public Sensor qic;
    public boolean qid = false;
    public HandlerThread qie;
    public SensorManager sensorManager;

    private static native int calcLumNative(byte[] bArr, int i, int i2);

    static {
        AppMethodBeat.i(81449);
        AppMethodBeat.o(81449);
    }

    public void onSensorChanged(SensorEvent sensorEvent) {
        float[] fArr = sensorEvent.values;
        if (fArr != null && fArr.length > 0) {
            this.lTs = fArr[0];
        }
    }

    public void onAccuracyChanged(Sensor sensor, int i) {
        AppMethodBeat.i(81447);
        ab.d("MicroMsg.ScanCameraLightDetector", "onAccuracyChanged");
        AppMethodBeat.o(81447);
    }

    static /* synthetic */ boolean w(byte[] bArr, int i, int i2) {
        AppMethodBeat.i(81448);
        if (!bo.cb(bArr) && bArr.length > i * i2) {
            ab.i("MicroMsg.ScanCameraLightDetector", "lum light: %s", new Object[]{Integer.valueOf(calcLumNative(bArr, i, i2))});
            if (calcLumNative(bArr, i, i2) < 50) {
                AppMethodBeat.o(81448);
                return true;
            }
        }
        AppMethodBeat.o(81448);
        return false;
    }
}
