正在查看: AdaModal v1.4.0 应用的 LiveDetectActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: AdaModal v1.4.0 应用的 LiveDetectActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.common.fine.activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.TextUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.common.fine.R;
import com.common.fine.utils.ExpUtils;
import com.common.fine.utils.PathUtils;
import com.common.fine.widget.LoadingUtils;
import com.hzy.prd.newface.BaseDetectionActivity;
import com.oliveapp.camerasdk.CameraManager;
import com.oliveapp.face.livenessdetectorsdk.livenessdetector.datatype.LivenessDetectionFrames;
import java.io.FileOutputStream;
import org.json.JSONArray;
import org.json.JSONObject;
public class LiveDetectActivity extends BaseDetectionActivity implements CameraManager.CameraPictureCallback {
public static final int RESULT_FACE_FAILED = 20;
private void vibrate() {
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
String string = getIntent().getExtras().getString("data");
if (TextUtils.isEmpty(string)) {
return;
}
try {
JSONObject jSONObject = new JSONObject(string);
JSONArray optJSONArray = jSONObject.optJSONArray("actions");
int optInt = jSONObject.optInt("actionsNum");
int[] iArr = new int[optJSONArray.length()];
for (int i = 0; i < optJSONArray.length(); i++) {
iArr[i] = ((Integer) optJSONArray.get(i)).intValue();
}
setDetectionActions(iArr);
setUsePredefinedConfig(optInt);
} catch (Exception e) {
e.printStackTrace();
}
}
public void onInitializeSucc() {
this.mPhotoModule.setShutterRawDataCallback(this);
startVerification();
}
public void onInitializeFail(Throwable th) {
super.onInitializeFail(th);
ToastUtils.showShort(R.string.face_check_failed);
setResult(20);
finish();
}
public void onLivenessFail(int i, LivenessDetectionFrames livenessDetectionFrames) {
super.onLivenessFail(i, livenessDetectionFrames);
ToastUtils.showShort(R.string.face_check_failed);
Intent intent = new Intent();
intent.putExtra("errorCode", i + "");
setResult(20, intent);
finish();
}
public void onLivenessSuccess(LivenessDetectionFrames livenessDetectionFrames) {
super.onLivenessSuccess(livenessDetectionFrames);
this.mPhotoModule.captureWithCallBack();
}
public void onPictureTaken(byte[] bArr, CameraManager.CameraProxy cameraProxy) {
saveImageAndFinish(bArr);
}
private void saveImageAndFinish(final byte[] bArr) {
LoadingUtils.show();
new Thread() {
@Override
public void run() {
try {
String randomImagePath = PathUtils.randomImagePath();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
byte[] bArr2 = bArr;
BitmapFactory.decodeByteArray(bArr2, 0, bArr2.length, options);
options.inSampleSize = 2;
options.inJustDecodeBounds = false;
byte[] bArr3 = bArr;
Bitmap decodeByteArray = BitmapFactory.decodeByteArray(bArr3, 0, bArr3.length, options);
try {
FileOutputStream fileOutputStream = new FileOutputStream(randomImagePath);
try {
decodeByteArray.compress(Bitmap.CompressFormat.JPEG, 60, fileOutputStream);
fileOutputStream.close();
} finally {
}
} finally {
if (decodeByteArray != null) {
decodeByteArray.recycle();
}
LiveDetectActivity.this.setReturnDataAndFinish(randomImagePath);
}
} catch (Exception e) {
ExpUtils.show(e);
} finally {
LoadingUtils.dismiss();
LiveDetectActivity.this.finish();
}
}
}.start();
}
public void setReturnDataAndFinish(String str) {
vibrate();
Intent intent = new Intent();
intent.putExtra("imagePath", str);
setResult(-1, intent);
}
}