正在查看: Aisle v12.32 应用的 DTFaceActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Aisle v12.32 应用的 DTFaceActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package ai.digitap.faceclient.ui;
import Ha.g;
import ai.digitap.faceclient.config.DTFaceConfig;
import ai.digitap.faceclient.config.LivenessConfig;
import ai.digitap.faceclient.exception.DTException;
import ai.digitap.faceclient.handlers.FaceCaptureCompletionHandler;
import ai.digitap.faceclient.handlers.LogListener;
import ai.digitap.faceclient.model.CameraConfigResponseModel;
import ai.digitap.faceclient.model.DescModel;
import ai.digitap.faceclient.model.FLFMRequestModel;
import ai.digitap.faceclient.model.FLFMResponseModel;
import ai.digitap.faceclient.model.UserLogModel;
import ai.digitap.faceclient.model.UserLogRequestModel;
import ai.digitap.faceclient.utils.GlobalData;
import ai.digitap.faceclient.utils.LogEvent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.appcompat.app.d;
import androidx.fragment.app.Fragment;
import c.AbstractC1497d;
import c.AbstractC1498e;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import org.json.JSONObject;
@Keep
public class DTFaceActivity extends d {
public static FaceCaptureCompletionHandler handler;
private static LogListener logListener;
private Uri croppedPhotoUri;
private DTFaceConfig faceConfig;
private Bundle fragmentBundle;
private Fragment fragmentObject;
private LivenessConfig livenessConfig;
public UserLogModel logObject;
private Uri photoUri;
private final String[] REQUIRED_PERMISSIONS = {"android.permission.CAMERA"};
private int REQUEST_CODE_PERMISSIONS = 1001;
public String sensorData = "";
private String fallback = "no";
private String sensorDataCapture = "yes";
public class a implements View.OnClickListener {
public a() {
}
@Override
public final void onClick(View view) {
DTFaceActivity.this.onBackPressed();
}
}
public class b extends Ia.a {
public b() {
}
public final void a() {
DTFaceActivity dTFaceActivity = DTFaceActivity.this;
dTFaceActivity.livenessConfig = dTFaceActivity.getDefaultLivenessConfig();
Jb.a.g().c(0);
DTFaceActivity.this.startFaceCapture();
}
}
public class c extends Ib.a {
public c() {
}
public final void b(String str) {
DTFaceActivity.this.sendBackResult(new DTException(DTException.DigiTapSdkErrorCode.SERVER_ERROR, "Server Error, " + str), null);
}
}
private boolean allPermissionsGranted() {
for (String str : this.REQUIRED_PERMISSIONS) {
if (androidx.core.content.b.checkSelfPermission(this, str) != 0) {
return false;
}
}
return true;
}
private void clearAndStopSensorCapture() {
try {
if (!this.sensorDataCapture.equals("yes") || GlobalData.getInstance().getDtSensorBiometrics() == null) {
return;
}
GlobalData.getInstance().getDtSensorBiometrics().clearAndStopSensorCapturing();
} catch (Exception unused) {
}
}
private void getApiResult(FLFMRequestModel fLFMRequestModel) {
new c().a(fLFMRequestModel);
}
public LivenessConfig getDefaultLivenessConfig() {
LivenessConfig livenessConfig = new LivenessConfig();
livenessConfig.setCameraMaxAngle(45.0f);
livenessConfig.setCameraMinAngle(-45.0f);
livenessConfig.setFaceMaxAngle(12.0f);
livenessConfig.setFaceMinAngle(-12.0f);
livenessConfig.setBoundingBoxMinPercent(30.0f);
livenessConfig.setBoundingBoxMaxPercent(97.0f);
livenessConfig.setPerformanceMode(1);
livenessConfig.setTriggerType("2");
return livenessConfig;
}
private void getLivenessConfig() {
new b().b(Jb.a.g().a(), Jb.a.g().e(), this.faceConfig.getFacing() == DTFaceConfig.CameraFacing.BACK ? 2 : 1);
}
public LivenessConfig getLivenessConfigModel(CameraConfigResponseModel cameraConfigResponseModel) {
Jb.a g5;
int i5;
LivenessConfig livenessConfig = new LivenessConfig();
if (TextUtils.isEmpty(cameraConfigResponseModel.getLogState())) {
g5 = Jb.a.g();
i5 = 0;
} else {
g5 = Jb.a.g();
i5 = Integer.parseInt(cameraConfigResponseModel.getLogState());
}
g5.c(i5);
livenessConfig.setCameraMaxAngle(!TextUtils.isEmpty(cameraConfigResponseModel.getCameraMaxAngle()) ? Float.parseFloat(cameraConfigResponseModel.getCameraMaxAngle()) : 45.0f);
livenessConfig.setCameraMinAngle(!TextUtils.isEmpty(cameraConfigResponseModel.getCameraMinAngle()) ? Float.parseFloat(cameraConfigResponseModel.getCameraMinAngle()) : -45.0f);
livenessConfig.setFaceMaxAngle(!TextUtils.isEmpty(cameraConfigResponseModel.getFaceMaxAngle()) ? Float.parseFloat(cameraConfigResponseModel.getFaceMaxAngle()) : 12.0f);
livenessConfig.setFaceMinAngle(!TextUtils.isEmpty(cameraConfigResponseModel.getFaceMinAngle()) ? Float.parseFloat(cameraConfigResponseModel.getFaceMinAngle()) : -12.0f);
livenessConfig.setBoundingBoxMinPercent(!TextUtils.isEmpty(cameraConfigResponseModel.getBoundingBoxMinPercent()) ? Float.parseFloat(cameraConfigResponseModel.getBoundingBoxMinPercent()) : 30.0f);
livenessConfig.setBoundingBoxMaxPercent(!TextUtils.isEmpty(cameraConfigResponseModel.getBoundingBoxMaxPercent()) ? Float.parseFloat(cameraConfigResponseModel.getBoundingBoxMaxPercent()) : 97.0f);
livenessConfig.setPerformanceMode(!TextUtils.isEmpty(cameraConfigResponseModel.getPerformanceMode()) ? Integer.parseInt(cameraConfigResponseModel.getPerformanceMode()) : 1);
livenessConfig.setTriggerType(!TextUtils.isEmpty(cameraConfigResponseModel.getTriggerType()) ? cameraConfigResponseModel.getTriggerType() : "2");
this.fallback = !TextUtils.isEmpty(cameraConfigResponseModel.getFallback()) ? cameraConfigResponseModel.getFallback() : "no";
this.sensorDataCapture = !TextUtils.isEmpty(cameraConfigResponseModel.getCaptureSensorData()) ? cameraConfigResponseModel.getCaptureSensorData() : "yes";
return livenessConfig;
}
public static boolean isLogEnabled() {
SharedPreferences sharedPreferences = Jb.a.g().a;
return (logListener == null || (sharedPreferences == null ? 0 : sharedPreferences.getInt("DT_FL_LOG_STATE", 0)) == 0) ? false : true;
}
private JSONObject makeJsonResponse(JSONObject jSONObject) {
try {
JSONObject jSONObject2 = new JSONObject();
if (jSONObject.has("is_live")) {
jSONObject2.put("live", jSONObject.getBoolean("is_live") ? "yes" : "no");
}
if (jSONObject.has("liveness_confidence")) {
jSONObject2.put("liveness-prediction-confidence", String.valueOf(jSONObject.getDouble("liveness_confidence")));
}
if (jSONObject.has("is_face_aligned")) {
jSONObject2.put("face-aligned", jSONObject.getBoolean("is_face_aligned") ? "yes" : "no");
}
jSONObject2.put("api_response", jSONObject);
return jSONObject2;
} catch (Exception unused) {
return null;
}
}
public void parseResponse(FLFMResponseModel fLFMResponseModel) {
DTException dTException;
try {
JSONObject jSONObject = new JSONObject(fLFMResponseModel.getResult().toString());
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("imageUri", this.photoUri.getPath());
jSONObject2.put("croppedImageUri", this.croppedPhotoUri.getPath());
jSONObject2.put("reqId", fLFMResponseModel.getReqId());
jSONObject2.put("result", makeJsonResponse(jSONObject));
DTFaceConfig dTFaceConfig = this.faceConfig;
if (dTFaceConfig != null) {
JSONObject jSONObject3 = dTFaceConfig.isResponseInError().equals("yes") ? jSONObject2 : null;
if (this.faceConfig.isAllowMultipleFaces().equals("no") && jSONObject.has("multiple_face_detected") && jSONObject.getBoolean("multiple_face_detected")) {
dTException = new DTException(DTException.DigiTapSdkErrorCode.MULTIPLE_FACE);
} else if (this.faceConfig.isAllowEyesClosed().equals("no") && jSONObject.has("eye_closed") && jSONObject.getBoolean("eye_closed")) {
dTException = new DTException(DTException.DigiTapSdkErrorCode.EYES_CLOSED);
} else if (this.faceConfig.isAllowBlurFace().equals("no") && jSONObject.has("is_person_image_blurry") && jSONObject.getBoolean("is_person_image_blurry")) {
dTException = new DTException(DTException.DigiTapSdkErrorCode.BLUR_FACE);
} else if (this.faceConfig.isAllowFaceMask().equals("no") && jSONObject.has("has_mask") && jSONObject.getBoolean("has_mask")) {
dTException = new DTException(DTException.DigiTapSdkErrorCode.FACE_MASK);
} else if (this.faceConfig.isAllowNonAlignedFace().equals("no") && jSONObject.has("is_face_aligned") && !jSONObject.getBoolean("is_face_aligned")) {
dTException = new DTException(DTException.DigiTapSdkErrorCode.NON_ALIGNED_FACE);
} else if (this.faceConfig.isAllowLowLightImage().equals("no") && jSONObject.has("is_low_light_image") && jSONObject.getBoolean("is_low_light_image")) {
dTException = new DTException(DTException.DigiTapSdkErrorCode.LOW_LIGHT_IMAGE);
}
sendBackResult(dTException, jSONObject3);
return;
}
sendBackResult(null, jSONObject2);
} catch (Exception e5) {
sendBackResult(new DTException(DTException.DigiTapSdkErrorCode.INTERNAL_ERROR, "Internal error, " + e5.getMessage()), null);
}
}
public static void sendLog(@NonNull UserLogModel userLogModel) {
if (isLogEnabled()) {
logListener.onLog(Jb.a.g().a(), Jb.a.g().e(), userLogModel.getMapObject());
}
}
private void setActivityBrightness(float f5) {
Window window = getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
attributes.screenBrightness = f5;
window.setAttributes(attributes);
}
public static void start(Context context, DTFaceConfig dTFaceConfig, FaceCaptureCompletionHandler faceCaptureCompletionHandler) {
start(context, dTFaceConfig, faceCaptureCompletionHandler, null);
}
private void startSensorDataCapture() {
try {
if (!this.sensorDataCapture.equals("yes") || GlobalData.getInstance().getDtSensorBiometrics() == null) {
return;
}
GlobalData.getInstance().getDtSensorBiometrics().startCapturingSensorData("dtsdk_" + this.faceConfig.getClientRefId() + "_" + System.currentTimeMillis() + ".zip");
} catch (Exception unused) {
}
}
private void stopCaptureAndGetSensorData() {
try {
if (!this.sensorDataCapture.equals("yes") || GlobalData.getInstance().getDtSensorBiometrics() == null) {
return;
}
this.sensorData = GlobalData.getInstance().getDtSensorBiometrics().stopCapturingAndGetSensorData();
} catch (Exception unused) {
}
}
public void checkAndSendResult(Uri uri, Uri uri2) {
if (this.faceConfig.getMode() != DTFaceConfig.LivenessMode.TEXTURELIVENESS) {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("imageUri", uri.getPath());
jSONObject.put("croppedImageUri", uri2.getPath());
sendBackResult(null, jSONObject);
return;
} catch (Exception unused) {
sendBackResult(new DTException(DTException.DigiTapSdkErrorCode.INTERNAL_ERROR), null);
return;
}
}
if (!this.livenessConfig.getTriggerType().equals("3")) {
uri = uri2;
}
FLFMRequestModel fetchParamsForRESTAPIRequest = fetchParamsForRESTAPIRequest(uri);
fetchParamsForRESTAPIRequest.setClientRefId(Jb.a.g().a());
fetchParamsForRESTAPIRequest.setClientSessionId(Jb.a.g().e());
fetchParamsForRESTAPIRequest.setTriggerType(this.livenessConfig.getTriggerType());
fetchParamsForRESTAPIRequest.setSdkVersion("1.2.6");
fetchParamsForRESTAPIRequest.setAllowMultipleFace(this.faceConfig.isAllowMultipleFaces());
fetchParamsForRESTAPIRequest.setAllowEyesClosed(this.faceConfig.isAllowEyesClosed());
fetchParamsForRESTAPIRequest.setAllowBlurFace(this.faceConfig.isAllowBlurFace());
fetchParamsForRESTAPIRequest.setAllowFaceMask(this.faceConfig.isAllowFaceMask());
fetchParamsForRESTAPIRequest.setAllowNonAlignedFace(this.faceConfig.isAllowNonAlignedFace());
fetchParamsForRESTAPIRequest.setAllowLowLightImage(this.faceConfig.isAllowLowLightImage());
if (this.sensorDataCapture.equals("yes")) {
fetchParamsForRESTAPIRequest.setSensorData(this.sensorData);
}
fetchParamsForRESTAPIRequest.setImageSource(this.faceConfig.getFacing() == DTFaceConfig.CameraFacing.BACK ? "AndBackcam" : "AndFrntcam");
if (this.logObject != null) {
UserLogRequestModel userLogRequestModel = new UserLogRequestModel();
if (Float.isNaN(this.logObject.getDeviceAngle())) {
userLogRequestModel.setDeviceAngle(0.0f);
} else {
userLogRequestModel.setDeviceAngle(this.logObject.getDeviceAngle());
}
if (Float.isNaN(this.logObject.getBoundingBoxPercent())) {
userLogRequestModel.setBoundingBoxPercent(0.0f);
} else {
userLogRequestModel.setBoundingBoxPercent(this.logObject.getBoundingBoxPercent());
}
if (Float.isNaN(this.logObject.getFaceYAngle())) {
userLogRequestModel.setFaceYAngle(0.0f);
} else {
userLogRequestModel.setFaceYAngle(this.logObject.getFaceYAngle());
}
if (Float.isNaN(this.logObject.getFaceZAngle())) {
userLogRequestModel.setFaceZAngle(0.0f);
} else {
userLogRequestModel.setFaceZAngle(this.logObject.getFaceZAngle());
}
userLogRequestModel.setTimestamp(this.logObject.getTimestamp());
fetchParamsForRESTAPIRequest.setUserLog(userLogRequestModel);
}
getApiResult(fetchParamsForRESTAPIRequest);
}
public String convertByteArrayToBase64String(byte[] bArr) {
return Base64.encodeToString(bArr, 0);
}
public FLFMRequestModel fetchParamsForRESTAPIRequest(Uri uri) {
InputStream inputStream;
try {
inputStream = getContentResolver().openInputStream(uri);
} catch (Exception unused) {
inputStream = null;
} catch (Throwable th) {
th = th;
inputStream = null;
}
try {
FLFMRequestModel fLFMRequestModel = new FLFMRequestModel(convertByteArrayToBase64String(getBytes(inputStream)));
if (inputStream == null) {
return fLFMRequestModel;
}
try {
inputStream.close();
return fLFMRequestModel;
} catch (Exception unused2) {
return null;
}
} catch (Exception unused3) {
if (inputStream != null) {
try {
inputStream.close();
} catch (Exception unused4) {
}
}
return null;
} catch (Throwable th2) {
th = th2;
if (inputStream != null) {
try {
inputStream.close();
} catch (Exception unused5) {
return null;
}
}
throw th;
}
}
public byte[] getBytes(InputStream inputStream) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
return byteArrayOutputStream.toByteArray();
}
byteArrayOutputStream.write(bArr, 0, read);
}
}
public boolean isFaceDetected() {
UserLogModel userLogModel = this.logObject;
if (userLogModel == null) {
return false;
}
return (userLogModel.getEvent().equals(LogEvent.INIT.toString()) && ((double) this.logObject.getBoundingBoxPercent()) == 0.0d && ((double) this.logObject.getFaceYAngle()) == 0.0d && ((double) this.logObject.getFaceZAngle()) == 0.0d && ((double) this.logObject.getDeviceAngle()) == 0.0d) ? false : true;
}
@Override
public void onBackPressed() {
FaceCaptureCompletionHandler faceCaptureCompletionHandler;
DTException dTException;
boolean isFaceDetected = isFaceDetected();
if (this.logObject == null) {
this.logObject = new UserLogModel();
}
this.logObject.setEvent(LogEvent.CANCEL.toString());
sendLog(this.logObject);
if (handler != null) {
if (isFaceDetected || !this.fallback.equals("yes")) {
faceCaptureCompletionHandler = handler;
dTException = new DTException(DTException.DigiTapSdkErrorCode.USER_CANCELLED);
} else {
faceCaptureCompletionHandler = handler;
dTException = new DTException(DTException.DigiTapSdkErrorCode.FACE_NOT_DETECTED_USER_CANCELLED);
}
faceCaptureCompletionHandler.onResult(dTException, null);
}
super.onBackPressed();
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(AbstractC1498e.f18503a);
TextView textView = (TextView) findViewById(AbstractC1497d.f18502l);
LinearLayout linearLayout = (LinearLayout) findViewById(AbstractC1497d.f18500j);
DTFaceConfig dTFaceConfig = (DTFaceConfig) getIntent().getSerializableExtra("dtFaceConfig");
this.faceConfig = dTFaceConfig;
if (dTFaceConfig != null) {
Jb.a.g().f("CLIENT_REF_ID", this.faceConfig.getClientRefId());
Jb.a.g().f("CLIENT_SESSION_ID", this.faceConfig.getClientRefId() + "_" + System.currentTimeMillis());
if (!TextUtils.isEmpty(this.faceConfig.getFaceCaptureTitle())) {
textView.setText(this.faceConfig.getFaceCaptureTitle());
}
if (linearLayout != null) {
linearLayout.setVisibility(this.faceConfig.isShowPoweredBy() ? 0 : 8);
}
}
((ImageView) findViewById(AbstractC1497d.f18497g)).setOnClickListener(new a());
Bundle parseThis = DescModel.parseThis(this.faceConfig.getFaceLiveDescription(), this.faceConfig.getFaceNonLiveDescription(), this.faceConfig.getFaceEyesClosedDescription(), this.faceConfig.getMultipleFacesDescription(), this.faceConfig.getMoveCameraAwayDescription(), this.faceConfig.getMoveCameraClosureDescription());
this.fragmentBundle = parseThis;
parseThis.putString("DT_CAMERA_FACING", this.faceConfig.getFacing().toString());
this.fragmentBundle.putBoolean("DT_AUTO_CAPTURE", this.faceConfig.isAutoCaptureEnabled());
String str = Build.MODEL;
this.fragmentObject = (str.toLowerCase().contains("comio x1") || str.toLowerCase().contains("nexus") || str.toLowerCase().contains("lg")) ? new g() : new Ha.a();
this.fragmentObject.setArguments(this.fragmentBundle);
if (allPermissionsGranted()) {
getLivenessConfig();
} else {
androidx.core.app.b.f(this, this.REQUIRED_PERMISSIONS, this.REQUEST_CODE_PERMISSIONS);
}
}
@Override
public void onDestroy() {
super.onDestroy();
logListener = null;
}
public void onImageURIUpdate(Uri uri, Uri uri2) {
stopCaptureAndGetSensorData();
this.photoUri = uri;
this.croppedPhotoUri = uri2;
UserLogModel userLogModel = this.logObject;
if (userLogModel != null) {
userLogModel.setEvent(LogEvent.CAPTURE.toString());
sendLog(this.logObject);
}
checkAndSendResult(uri, uri2);
}
@Override
public void onPause() {
super.onPause();
clearAndStopSensorCapture();
}
@Override
public void onRequestPermissionsResult(int i5, @NonNull String[] strArr, @NonNull int[] iArr) {
if (i5 == this.REQUEST_CODE_PERMISSIONS) {
if (allPermissionsGranted()) {
getLivenessConfig();
} else {
sendBackResult(new DTException(DTException.DigiTapSdkErrorCode.PERMISSION_NOT_GRANTED), null);
}
}
}
@Override
public void onResume() {
super.onResume();
try {
setActivityBrightness(0.8f);
} catch (Exception unused) {
}
if (this.livenessConfig != null) {
startSensorDataCapture();
}
}
public void sendBackResult(DTException dTException, JSONObject jSONObject) {
try {
FaceCaptureCompletionHandler faceCaptureCompletionHandler = handler;
if (faceCaptureCompletionHandler != null) {
faceCaptureCompletionHandler.onResult(dTException, jSONObject);
handler = null;
}
finish();
} catch (Throwable unused) {
}
}
public void startFaceCapture() {
this.fragmentBundle.putSerializable("DT_FL_LIVENESS_CONFIG", this.livenessConfig);
this.fragmentObject.setArguments(this.fragmentBundle);
getSupportFragmentManager().s().b(AbstractC1497d.f18498h, this.fragmentObject).i();
startSensorDataCapture();
}
public static void start(Context context, DTFaceConfig dTFaceConfig, FaceCaptureCompletionHandler faceCaptureCompletionHandler, LogListener logListener2) {
if (logListener2 != null) {
logListener = logListener2;
}
if (faceCaptureCompletionHandler != null) {
handler = faceCaptureCompletionHandler;
if (!Jb.a.g().b("DT_FL_INITIATED", "false").equals("true")) {
faceCaptureCompletionHandler.onResult(new DTException(DTException.DigiTapSdkErrorCode.INIT_NOT_CALLED), null);
return;
}
if (dTFaceConfig == null) {
faceCaptureCompletionHandler.onResult(new DTException(DTException.DigiTapSdkErrorCode.INVALID_INPUT, "FaceConfig Should not be null"), null);
} else {
if (context == null) {
faceCaptureCompletionHandler.onResult(new DTException(DTException.DigiTapSdkErrorCode.INVALID_INPUT, "Context should not be null"), null);
return;
}
Intent intent = new Intent(context, (Class<?>) DTFaceActivity.class);
intent.putExtra("dtFaceConfig", dTFaceConfig);
context.startActivity(intent);
}
}
}
}