what-the-bank/sources/com/pingan/ai/j.java

116 lines
3.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.pingan.ai;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import com.pingan.ai.face.common.PaFaceConstants;
import com.pingan.ai.face.control.LiveFaceConfig;
import com.pingan.ai.face.utils.PaFaceLogger;
/* loaded from: classes3.dex */
public class j {
public d a;
public LiveFaceConfig b;
public SensorManager c;
public Sensor d;
public float e = 10.0f;
public SensorEventListener f = new a(this);
/* loaded from: classes3.dex */
public class a implements SensorEventListener {
public final j a;
public a(j jVar) {
this.a = jVar;
}
@Override // android.hardware.SensorEventListener
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override // android.hardware.SensorEventListener
public void onSensorChanged(SensorEvent sensorEvent) {
this.a.e = sensorEvent.values[1];
}
}
public j(d dVar, LiveFaceConfig liveFaceConfig) {
this.a = dVar;
this.b = liveFaceConfig;
}
/* JADX WARN: Multi-variable type inference failed */
public void b() {
try {
SensorManager sensorManager = this.c;
if (sensorManager != null) {
sensorManager.unregisterListener(this.f, this.d);
}
} catch (Exception e) {
d dVar = this.a;
StringBuilder sb = new StringBuilder("Exception:");
sb.append(c.a());
sb.append(" gravity:poseError,unregister=");
sb.append(e.getMessage());
dVar.a(sb.toString());
StringBuilder sb2 = new StringBuilder("GRAVITY_POSE_ERROR unregister=");
sb2.append(e.getMessage());
PaFaceLogger.error(sb2.toString());
} finally {
this.d = null;
this.c = null;
this.f = null;
}
}
public void a(Context context) {
try {
if (this.c == null) {
this.c = (SensorManager) context.getApplicationContext().getSystemService("sensor");
}
SensorManager sensorManager = this.c;
if (sensorManager == null) {
this.b.setGravitySwitch(false);
return;
}
if (this.d == null) {
this.d = sensorManager.getDefaultSensor(9);
}
Sensor sensor = this.d;
if (sensor == null) {
this.b.setGravitySwitch(false);
} else {
this.c.registerListener(this.f, sensor, 1);
}
} catch (Exception e) {
d dVar = this.a;
StringBuilder sb = new StringBuilder("Exception:");
sb.append(c.a());
sb.append(" sensorManager init Exception : ");
sb.append(e.getMessage());
dVar.a(sb.toString());
this.b.setGravitySwitch(false);
}
}
public boolean a() {
LiveFaceConfig liveFaceConfig = this.b;
if (liveFaceConfig == null || !liveFaceConfig.isGravitySwitch() || this.e > this.b.getGravityThr()) {
return false;
}
this.a.c(this.a.a(PaFaceConstants.EnvironmentalTips.GRAVITY_POSE_ERROR));
d dVar = this.a;
StringBuilder sb = new StringBuilder("GravityPossError:");
sb.append(c.a());
sb.append(" gravity:poseError,gravityY=");
sb.append(this.e);
dVar.a(sb.toString());
StringBuilder sb2 = new StringBuilder("GRAVITY_POSE_ERROR gravityY=");
sb2.append(this.e);
PaFaceLogger.error(sb2.toString());
return true;
}
}