what-the-bank/sources/com/kofax/mobile/sdk/k/h.java

528 lines
17 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.mobile.sdk.k;
import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator;
import com.google.android.gms.auth.api.credentials.CredentialsApi;
import com.kofax.kmc.ken.engines.data.SelfieDetectionSettings;
import com.kofax.kmc.kui.uicontrols.AutoFocusResultEvent;
import com.kofax.kmc.kui.uicontrols.AutoFocusResultListener;
import com.kofax.kmc.kui.uicontrols.ImageCapturedEvent;
import com.kofax.kmc.kui.uicontrols.ImageCapturedListener;
import com.kofax.kmc.kui.uicontrols.PreviewCallbackListener;
import com.kofax.kmc.kui.uicontrols.PreviewFrameEvent;
import com.kofax.kmc.kui.uicontrols.captureanimations.SelfieCaptureExperienceCriteriaHolder;
import com.kofax.kmc.kut.utilities.RectUtil;
import com.kofax.mobile.sdk._internal.IBus;
import com.kofax.mobile.sdk._internal.detection.IFaceDetectionResult;
import com.kofax.mobile.sdk._internal.detection.IFaceDetector;
import com.kofax.mobile.sdk._internal.impl.event.aa;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import o.InterfaceC13391fZD;
/* loaded from: classes3.dex */
public class h implements AutoFocusResultListener, ImageCapturedListener, PreviewCallbackListener, com.kofax.mobile.sdk._internal.capture.f {
private static final String TAG = "h";
private com.kofax.mobile.sdk._internal.view.n FX;
private a FY;
private boolean FZ;
private com.kofax.mobile.sdk._internal.camera.f Fl;
private boolean Ga;
private int Gc;
private boolean Gd;
private boolean Ge;
private boolean Gf;
private IBus _bus;
private boolean _sdkCaptureRequested;
private Vibrator _vibrator;
private boolean mB;
private ImageCapturedEvent mL;
private boolean ml;
private SelfieCaptureExperienceCriteriaHolder nm;
private IFaceDetector np;
private SelfieDetectionSettings nq;
private final l Fn = new l(this);
private final Handler _uiHandler = new Handler(Looper.getMainLooper());
private Set<ImageCapturedListener> _imageCapturedListeners = new LinkedHashSet();
private boolean _vibrationEnabled = true;
private b Gb = b.NONE;
private int Ee = CredentialsApi.CREDENTIAL_PICKER_REQUEST_CODE;
final Runnable Gg = new Runnable(this) { // from class: com.kofax.mobile.sdk.k.h.3
final h Gh;
{
this.Gh = this;
}
@Override // java.lang.Runnable
public void run() {
if (!this.Gh.kN() || this.Gh.FY == null || !this.Gh.FY.li() || !this.Gh.FY.lj() || !this.Gh.FY.lk()) {
this.Gh._sdkCaptureRequested = false;
this.Gh.ml = true;
} else {
this.Gh.Fl.takePictureForCaptureExperience("com.kofax.kmc.kui.uicontrols.");
}
}
};
private final Object _lock = new Object();
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public enum b {
NONE,
FIT_FACE,
BLINK
}
@InterfaceC13391fZD
public h(Context context, IBus iBus) {
this._bus = null;
this._vibrator = (Vibrator) context.getSystemService("vibrator");
this._bus = iBus;
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void addOnImageCapturedListener(ImageCapturedListener imageCapturedListener) {
if (imageCapturedListener != null) {
this._imageCapturedListeners.add(imageCapturedListener);
}
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void removeOnImageCapturedListener(ImageCapturedListener imageCapturedListener) {
this._imageCapturedListeners.remove(imageCapturedListener);
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void d(boolean z) {
kZ();
this._sdkCaptureRequested = false;
synchronized (this._lock) {
this.ml = true;
}
}
/* JADX INFO: Access modifiers changed from: private */
public void invokeImageCapturedListeners(ImageCapturedEvent imageCapturedEvent) {
Iterator<ImageCapturedListener> it = this._imageCapturedListeners.iterator();
while (it.hasNext()) {
it.next().onImageCaptured(imageCapturedEvent);
}
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void destroy() {
removeCameraEventListeners();
IFaceDetector iFaceDetector = this.np;
if (iFaceDetector != null) {
iFaceDetector.destroy();
this.np = null;
}
removeAllViews();
kZ();
}
protected void removeAllViews() {
com.kofax.mobile.sdk._internal.camera.f fVar = this.Fl;
if (fVar != null) {
fVar.getViewGroup().removeView(this.FX.getView());
}
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void setOuterOverlayFrameColor(int i) {
this.FX.setOuterOverlayFrameColor(i);
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public int getOuterOverlayFrameColor() {
return this.FX.getOuterOverlayFrameColor();
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void a(IFaceDetector iFaceDetector) {
this.np = new j(iFaceDetector);
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void b(SelfieCaptureExperienceCriteriaHolder selfieCaptureExperienceCriteriaHolder) {
this.nm = selfieCaptureExperienceCriteriaHolder;
SelfieDetectionSettings detectionSettings = selfieCaptureExperienceCriteriaHolder.getDetectionSettings();
this.nq = detectionSettings;
com.kofax.mobile.sdk._internal.view.n nVar = this.FX;
if (nVar != null) {
nVar.setOverlayAspectRatio(detectionSettings.getTargetFrameAspectRatio());
this.FX.setCenter(this.nq.getCenterPoint());
this.FX.setPaddingPercent(this.nq.getTargetFramePaddingPercent());
}
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void a(com.kofax.mobile.sdk._internal.camera.f fVar) {
this.Fl = fVar;
fVar.getViewGroup().addView(this.FX.getView());
addCameraEventListeners();
}
protected void addCameraEventListeners() {
if (this.np == null) {
throw new IllegalStateException("detector is not set");
}
this.Fl.addOnAutoFocusResultListener(this);
this.Fl.addOnImageCapturedListener(this);
this.Fn.b(this.Fl);
this._bus.post(new aa(true));
}
protected void removeCameraEventListeners() {
com.kofax.mobile.sdk._internal.camera.f fVar = this.Fl;
if (fVar != null) {
fVar.removeOnAutoFocusResultListener(this);
this.Fl.removeOnImageCapturedListener(this);
this.Fn.stopListening();
}
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void a(com.kofax.mobile.sdk._internal.view.n nVar) {
this.FX = nVar;
this.Gc = nVar.getGuidanceFrameColor();
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public int getFrameColor() {
return this.FX.getGuidanceFrameColor();
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void setFrameColor(int i) {
this.FX.setGuidanceFrameColor(i);
this.Gc = i;
}
@Override // com.kofax.kmc.kui.uicontrols.AutoFocusResultListener
public void onAutoFocus(AutoFocusResultEvent autoFocusResultEvent) {
this.mB = autoFocusResultEvent.getSuccess();
}
/* JADX INFO: Access modifiers changed from: private */
public boolean kN() {
if (this.nm.isFocusEnabled()) {
return this.mB;
}
return true;
}
@Override // com.kofax.kmc.kui.uicontrols.ImageCapturedListener
public void onImageCaptured(ImageCapturedEvent imageCapturedEvent) {
kZ();
synchronized (this._lock) {
if (this._vibrationEnabled) {
try {
this._vibrator.vibrate(500L);
} catch (Exception unused) {
}
}
this.mL = imageCapturedEvent;
lh();
this._uiHandler.postDelayed(new Runnable(this) { // from class: com.kofax.mobile.sdk.k.h.1
final h Gh;
{
this.Gh = this;
}
@Override // java.lang.Runnable
public void run() {
h hVar = this.Gh;
hVar.invokeImageCapturedListeners(hVar.mL);
this.Gh.FX.clear();
this.Gh.mL = null;
}
}, 1000L);
}
}
protected void kZ() {
synchronized (this._lock) {
this.mL = null;
this.FY = null;
this.Gb = b.NONE;
}
}
private IFaceDetectionResult c(byte[] bArr, int i, int i2, int i3) {
try {
return this.np.detect(this.nq, bArr, i, i2, i3);
} catch (IllegalArgumentException e) {
com.kofax.mobile.sdk._internal.k.e(TAG, "Detection failed", (Throwable) new RuntimeException(e));
return null;
}
}
@Override // com.kofax.kmc.kui.uicontrols.PreviewCallbackListener
public void onPreviewFrame(PreviewFrameEvent previewFrameEvent) {
this.FY = new a(this, c(previewFrameEvent.getData(), previewFrameEvent.getWidth(), previewFrameEvent.getHeight(), previewFrameEvent.getRotation()), previewFrameEvent, this.nq, this.FX.getView().getWidth(), this.FX.getView().getHeight());
kS();
}
void kS() {
this._uiHandler.post(new Runnable(this) { // from class: com.kofax.mobile.sdk.k.h.2
final h Gh;
{
this.Gh = this;
}
@Override // java.lang.Runnable
public void run() {
synchronized (this.Gh._lock) {
this.Gh.kQ();
}
}
});
}
protected void kQ() {
a aVar;
a aVar2;
if (this.FX == null || this._sdkCaptureRequested) {
return;
}
if (!this.Gf) {
boolean isOperational = this.np.isOperational();
this.Gf = isOperational;
this.FX.setDetectorOperationState(isOperational);
}
if (this.Gf && !this._sdkCaptureRequested && ((aVar2 = this.FY) == null || !aVar2.li() || !this.FY.lj() || !this.FY.lk())) {
le();
return;
}
if (!this._sdkCaptureRequested && this.Gf && kN() && (aVar = this.FY) != null && aVar.li() && this.FY.lj() && this.FY.lk()) {
lf();
if (this.ml && this.Ge && this.FY.ll()) {
this._sdkCaptureRequested = true;
this.ml = false;
this.FX.startSteadyMessage();
this._uiHandler.postDelayed(this.Gg, this.Ee);
}
}
}
private void le() {
this.Ge = false;
if (this.Gd) {
return;
}
this.Gd = true;
this.FX.setGuidanceFrameColor(this.Gc);
if (this.Gb != b.FIT_FACE) {
this.FX.showFitWithinFrameMessage();
this.Gb = b.FIT_FACE;
} else {
this.FX.stopMessages();
this.Gb = b.NONE;
}
lg();
}
private void lf() {
if (this.Gd) {
return;
}
this.Gd = true;
this.FX.setGuidanceFrameColor(-16711936);
if (this.Gb != b.BLINK) {
this.FX.startBlink();
this.Gb = b.BLINK;
} else {
this.FX.stopMessages();
this.Gb = b.NONE;
}
lg();
this.Ge = true;
}
private void lg() {
this._uiHandler.postDelayed(new Runnable(this) { // from class: com.kofax.mobile.sdk.k.h.4
final h Gh;
{
this.Gh = this;
}
@Override // java.lang.Runnable
public void run() {
this.Gh.Gd = false;
}
}, this.Ee);
}
private void lh() {
this._uiHandler.post(new Runnable(this) { // from class: com.kofax.mobile.sdk.k.h.5
final h Gh;
{
this.Gh = this;
}
@Override // java.lang.Runnable
public void run() {
this.Gh.Gb = b.NONE;
this.Gh.FX.startCapturedMessage();
}
});
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class a {
private int FL;
private int FM;
final h Gh;
private IFaceDetectionResult Gk;
private float Gl;
private float Gm;
private Rect Gn;
private boolean Gp;
private boolean Gq;
private boolean Gr;
private boolean Gs;
private SelfieDetectionSettings nq;
private float Gi = 0.7f;
private float Gj = 0.4f;
private Rect Go = new Rect();
a(h hVar, IFaceDetectionResult iFaceDetectionResult, PreviewFrameEvent previewFrameEvent, SelfieDetectionSettings selfieDetectionSettings, int i, int i2) {
this.Gh = hVar;
this.Gk = iFaceDetectionResult;
this.nq = selfieDetectionSettings;
this.FL = i;
this.FM = i2;
this.Gl = i / previewFrameEvent.getHeight();
this.Gm = i2 / previewFrameEvent.getWidth();
if (this.Gk != null) {
this.Gp = true;
if (ln() && lq()) {
this.Gq = true;
this.Gr = true;
this.Gs = hVar.Ge ? lm() : false;
return;
}
lr();
return;
}
lr();
}
private boolean lm() {
float isLeftEyeOpenProbability = this.Gk.getIsLeftEyeOpenProbability();
float isRightEyeOpenProbability = this.Gk.getIsRightEyeOpenProbability();
com.kofax.mobile.sdk._internal.k.b("Left eye open probability", String.valueOf(isLeftEyeOpenProbability));
com.kofax.mobile.sdk._internal.k.b("Right eye open probability", String.valueOf(isRightEyeOpenProbability));
if (isLeftEyeOpenProbability != -1.0f && isRightEyeOpenProbability != -1.0f) {
float f = this.Gj;
if (isLeftEyeOpenProbability < f && isRightEyeOpenProbability < f) {
com.kofax.mobile.sdk._internal.k.b("are eyes closed", "true");
this.Gh.FZ = true;
}
float f2 = this.Gi;
boolean z = isLeftEyeOpenProbability > f2 && isRightEyeOpenProbability > f2;
if (this.Gh.FZ && z) {
com.kofax.mobile.sdk._internal.k.b("are eyes opened", "true");
this.Gh.Ga = true;
}
if (!this.Gh.FZ || !this.Gh.Ga) {
return false;
}
lr();
return true;
}
lr();
return false;
}
private boolean ln() {
double eulerY = this.Gk.getEulerY();
return eulerY <= this.nq.getFaceAngleTolerance() && eulerY >= (-this.nq.getFaceAngleTolerance());
}
private Rect lo() {
if (this.Gn == null) {
this.Gn = RectUtil.createTargetRect(this.nq.getTargetFramePaddingPercent(), this.nq.getTargetFrameAspectRatio(), this.nq.getCenterPoint(), this.FL, this.FM);
}
return this.Gn;
}
private Rect lp() {
float f = f(this.Gk.getPosition().x + (this.Gk.getWidth() / 2.0f));
float e = e(this.Gk.getPosition().y + (this.Gk.getHeight() / 2.0f));
float h = h(this.Gk.getWidth() / 2.5f);
float g = g(this.Gk.getHeight() / 2.5f);
this.Go.set((int) (f - h), (int) (e - g), (int) (f + h), (int) (e + g));
return this.Go;
}
private boolean lq() {
Rect lp = lp();
return !lp.isEmpty() && lo().contains(lp) && ((double) (lp.width() * lp.height())) >= ((double) (this.Gn.width() * this.Gn.height())) * this.nq.getMinimumFaceSize();
}
private float e(float f) {
return g(f);
}
private float f(float f) {
return this.FL - h(f);
}
private void lr() {
this.Gh.FZ = false;
this.Gh.Ga = false;
}
public boolean ll() {
return this.Gs;
}
public boolean lk() {
return this.Gr;
}
public boolean lj() {
return this.Gq;
}
public boolean li() {
return this.Gp;
}
private float h(float f) {
return f * this.Gl;
}
private float g(float f) {
return f * this.Gm;
}
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void stopCapture() {
this.ml = false;
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public void setVibrationEnabled(boolean z) {
this._vibrationEnabled = z;
}
@Override // com.kofax.mobile.sdk._internal.capture.f
public boolean isVibrationEnabled() {
return this._vibrationEnabled;
}
}