analysis: full official-app reverse artifacts (jadx sources, ghidra libcxsdk decomp, authoritative protocol conclusions) + docs
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AsyncLoadImage {
|
||||
private static final int MSG = 305419896;
|
||||
private Handler[] handlers_;
|
||||
private String imageDir_;
|
||||
private volatile int maxTaskLen = Integer.MAX_VALUE;
|
||||
private Object receiver_;
|
||||
private volatile boolean running_;
|
||||
private volatile ArrayList<String> taskList;
|
||||
private volatile ArrayList<String> taskList_;
|
||||
private ImageLoaderThread[] threads_;
|
||||
private WaitCondition wcObj_;
|
||||
|
||||
public interface DelegateExecute {
|
||||
Object onBackToDo(Object obj);
|
||||
|
||||
void onExecuteFinished(Object obj);
|
||||
}
|
||||
|
||||
public AsyncLoadImage(String imageDir, int threadNum, Object receiver) {
|
||||
this.receiver_ = receiver;
|
||||
this.imageDir_ = imageDir;
|
||||
this.threads_ = new ImageLoaderThread[threadNum];
|
||||
ImageLoaderThread[] imageLoaderThreadArr = this.threads_;
|
||||
int length = imageLoaderThreadArr.length;
|
||||
int i = 0;
|
||||
int index = 0;
|
||||
while (i < length) {
|
||||
ImageLoaderThread imageLoaderThread = imageLoaderThreadArr[i];
|
||||
ImageLoaderThread thread = new ImageLoaderThread(index);
|
||||
thread.start();
|
||||
i++;
|
||||
index++;
|
||||
}
|
||||
this.wcObj_ = new WaitCondition();
|
||||
this.taskList_ = new ArrayList<>();
|
||||
for (Handler handler : this.handlers_) {
|
||||
new Handler() { // from class: cn.com.magnity.magnitycx.sdk.AsyncLoadImage.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case AsyncLoadImage.MSG /* 305419896 */:
|
||||
if (AsyncLoadImage.this.receiver_ instanceof DelegateExecute) {
|
||||
((DelegateExecute) AsyncLoadImage.this.receiver_).onExecuteFinished(msg.obj);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String name) {
|
||||
synchronized (this.wcObj_.cond) {
|
||||
if (!this.taskList_.contains(name)) {
|
||||
if (this.taskList_.size() > this.maxTaskLen) {
|
||||
}
|
||||
if (!this.taskList_.contains(name)) {
|
||||
this.taskList_.add(name);
|
||||
this.wcObj_.notified = true;
|
||||
this.wcObj_.cond.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTaskQueueLen(int len) {
|
||||
synchronized (this.wcObj_.cond) {
|
||||
this.maxTaskLen = len;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
synchronized (this.wcObj_.cond) {
|
||||
this.taskList_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
this.running_ = false;
|
||||
synchronized (this.wcObj_.cond) {
|
||||
this.wcObj_.notified = true;
|
||||
this.wcObj_.cond.notifyAll();
|
||||
}
|
||||
try {
|
||||
for (ImageLoaderThread thread : this.threads_) {
|
||||
thread.join();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private class ImageLoaderThread extends Thread {
|
||||
private int index_;
|
||||
|
||||
public ImageLoaderThread(int index) {
|
||||
this.index_ = index;
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (AsyncLoadImage.this.running_) {
|
||||
synchronized (AsyncLoadImage.this.wcObj_.cond) {
|
||||
while (!AsyncLoadImage.this.wcObj_.notified) {
|
||||
try {
|
||||
AsyncLoadImage.this.wcObj_.cond.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
AsyncLoadImage.this.wcObj_.notified = false;
|
||||
if (AsyncLoadImage.this.taskList_.size() > 0) {
|
||||
String name = (String) AsyncLoadImage.this.taskList_.get(0);
|
||||
AsyncLoadImage.this.taskList_.remove(0);
|
||||
if (AsyncLoadImage.this.running_) {
|
||||
if (AsyncLoadImage.this.receiver_ instanceof DelegateExecute) {
|
||||
Object object = ((DelegateExecute) AsyncLoadImage.this.receiver_).onBackToDo(name);
|
||||
Message msg = new Message();
|
||||
msg.what = AsyncLoadImage.MSG;
|
||||
msg.obj = object;
|
||||
AsyncLoadImage.this.handlers_[this.index_].sendMessage(msg);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BasePara1 implements Cloneable {
|
||||
public int devType;
|
||||
public int fpaFlip;
|
||||
public int fpaGain;
|
||||
public int fpaHeight;
|
||||
public int fpaWidth;
|
||||
public int fps;
|
||||
public int gfid;
|
||||
public int gsk;
|
||||
public int hwVersion;
|
||||
public int interFrame;
|
||||
public int interLine;
|
||||
public int reserved1;
|
||||
public int reserved2;
|
||||
public int serialNumber;
|
||||
public int swVersion;
|
||||
|
||||
public BasePara1() {
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.serialNumber = 0;
|
||||
this.hwVersion = 0;
|
||||
this.devType = 0;
|
||||
this.swVersion = 0;
|
||||
this.reserved1 = 0;
|
||||
this.fpaWidth = 0;
|
||||
this.fpaHeight = 0;
|
||||
this.fps = 0;
|
||||
this.reserved2 = 0;
|
||||
this.fpaGain = 0;
|
||||
this.fpaFlip = 0;
|
||||
this.interFrame = 0;
|
||||
this.interLine = 0;
|
||||
this.gfid = 0;
|
||||
this.gsk = 0;
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BasePara2 implements Cloneable {
|
||||
public float ATErrorSlope;
|
||||
public int ATZeroErrorPoint;
|
||||
public int baseLineAcc;
|
||||
public int denoiseLevel;
|
||||
public int enlargeRange;
|
||||
public int ffcTriggerFrame;
|
||||
public int ffcTriggerTemperature;
|
||||
public short fpaTempFix;
|
||||
public int laserPos;
|
||||
public int reserved1;
|
||||
public short reserved2;
|
||||
public int reserved5;
|
||||
public int reserved6;
|
||||
public int shutterCloseSpeed;
|
||||
public int shutterOpenSpeed;
|
||||
|
||||
public BasePara2() {
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.baseLineAcc = 0;
|
||||
this.denoiseLevel = 0;
|
||||
this.reserved1 = 0;
|
||||
this.reserved2 = (short) 0;
|
||||
this.fpaTempFix = (short) 0;
|
||||
this.shutterCloseSpeed = 0;
|
||||
this.shutterOpenSpeed = 0;
|
||||
this.ffcTriggerFrame = 0;
|
||||
this.ffcTriggerTemperature = 0;
|
||||
this.enlargeRange = 0;
|
||||
this.laserPos = 0;
|
||||
this.ATZeroErrorPoint = 0;
|
||||
this.ATErrorSlope = 0.0f;
|
||||
this.reserved5 = 0;
|
||||
this.reserved6 = 0;
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Point;
|
||||
import android.media.ThumbnailUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BitmapUtilities {
|
||||
public static Bitmap getBitmapThumbnail(String pathName, int width, int height) {
|
||||
Bitmap bitmap = null;
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
if (opts.outWidth > 0 && opts.outHeight > 0) {
|
||||
float r = Math.max(opts.outHeight / height, opts.outWidth / width);
|
||||
opts.inSampleSize = (int) (r + 0.5d);
|
||||
opts.inJustDecodeBounds = false;
|
||||
bitmap = BitmapFactory.decodeFile(pathName, opts);
|
||||
}
|
||||
if (bitmap == null) {
|
||||
return ThumbnailUtils.createVideoThumbnail(pathName, 1);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Bitmap getBitmapThumbnail(String pathName, int sampleSize) {
|
||||
Bitmap bitmap = null;
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
if (opts.outWidth > 0 && opts.outHeight > 0) {
|
||||
opts.inSampleSize = sampleSize;
|
||||
opts.inJustDecodeBounds = false;
|
||||
bitmap = BitmapFactory.decodeFile(pathName, opts);
|
||||
}
|
||||
if (bitmap == null) {
|
||||
return ThumbnailUtils.createVideoThumbnail(pathName, 1);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Point getBitmapSize(String pathName) {
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
if (opts.outWidth <= 0 || opts.outHeight <= 0) {
|
||||
return null;
|
||||
}
|
||||
return new Point(opts.outWidth, opts.outHeight);
|
||||
}
|
||||
|
||||
public static Bitmap getBitmapThumbnail(Bitmap bmp, int width, int height) {
|
||||
Bitmap bitmap;
|
||||
if (bmp == null) {
|
||||
return null;
|
||||
}
|
||||
int bmpWidth = bmp.getWidth();
|
||||
int bmpHeight = bmp.getHeight();
|
||||
if (width > 0 && height > 0) {
|
||||
Matrix matrix = new Matrix();
|
||||
float scaleWidth = width / bmpWidth;
|
||||
float scaleHeight = height / bmpHeight;
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
bitmap = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true);
|
||||
} else {
|
||||
bitmap = bmp;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CaliInfo implements Cloneable {
|
||||
public long date;
|
||||
public int reserved;
|
||||
public int size;
|
||||
|
||||
public CaliInfo() {
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.size = 0;
|
||||
this.reserved = 0;
|
||||
this.date = 0L;
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class D2PCmd {
|
||||
public static final int D2P_CaliHandledAck = 1538635104;
|
||||
public static final int D2P_CmdHandledAck = 1538635103;
|
||||
public static final int D2P_SendCaliFile = 1538635101;
|
||||
public static final int D2P_SendCaliInfo = 1538635102;
|
||||
public static final int D2P_SendFPAState = 1538635106;
|
||||
public static final int D2P_SendLifeTime = 1538635105;
|
||||
public static final int D2P_SendParameter1 = 1538635099;
|
||||
public static final int D2P_SendParameter2 = 1538635100;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateDeviceConnected {
|
||||
void onDeviceConnected(UsbCommunication usbCommunication);
|
||||
|
||||
void onDeviceDisconnected();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateMedia {
|
||||
void onCapture();
|
||||
|
||||
void onRecordingStart();
|
||||
|
||||
void onRecordingStop();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateMediaStatusChanged {
|
||||
void onModeChanged(int i, int i2, int i3);
|
||||
|
||||
void onSelChanged(int i, int i2);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateOptionSelected {
|
||||
void onOptionSelected(int i, int i2);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DeviceController {
|
||||
public static final int BITSPERPIXEL = 16;
|
||||
|
||||
public interface ShutterCallBack {
|
||||
void setShutterState(int i);
|
||||
}
|
||||
|
||||
public static native void Lock();
|
||||
|
||||
public static native void Unlock();
|
||||
|
||||
public static native int[] clientPos2ScreenXY(int i, int i2, int i3);
|
||||
|
||||
public static native int[] clientXY2ScreenXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native boolean doRecording(Bitmap bitmap);
|
||||
|
||||
public static native int getEX();
|
||||
|
||||
public static native void getExtParameter(ExtPara extPara);
|
||||
|
||||
public static native boolean getOutputBMPData(Bitmap bitmap, int i);
|
||||
|
||||
public static native boolean getOutputColorbarData(Bitmap bitmap, int i);
|
||||
|
||||
public static native int getPreviewOrientation();
|
||||
|
||||
public static native boolean getRectTemperatureInfo(int i, int i2, int i3, int i4, int[] iArr, boolean z);
|
||||
|
||||
public static native State getState();
|
||||
|
||||
public static native int getTemperature(int i, int i2, boolean z);
|
||||
|
||||
public static native boolean isOutputDataReady();
|
||||
|
||||
public static native boolean isProcessImage();
|
||||
|
||||
public static native boolean isRecording();
|
||||
|
||||
public static native boolean pushFrame(byte[] bArr, int i, int i2);
|
||||
|
||||
public static native boolean saveDDT(String str);
|
||||
|
||||
public static native int[] screenXY2ClientXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native int[] screenXY2SensorXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native int[] sensorXY2ScreenXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native void setAutoEnlarge(int i);
|
||||
|
||||
public static native void setColorPalette(int i);
|
||||
|
||||
public static native void setColorbarSize(int i, int i2);
|
||||
|
||||
public static native void setEX(int i, int i2, int i3);
|
||||
|
||||
public static native void setEmissivity(int i, int i2);
|
||||
|
||||
public static native void setExtParameter(ExtPara extPara);
|
||||
|
||||
public static native void setPreviewOrientation(int i);
|
||||
|
||||
public static native boolean startProcess(ShutterCallBack shutterCallBack, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, String str);
|
||||
|
||||
public static native boolean startRecording(String str, int i, int i2, int i3, int i4, int i5);
|
||||
|
||||
public static native void stopProcess();
|
||||
|
||||
public static native void stopRecording();
|
||||
|
||||
public static native void triggerFFC();
|
||||
|
||||
static {
|
||||
System.loadLibrary("avutil-55");
|
||||
System.loadLibrary("avcodec-57");
|
||||
System.loadLibrary("swresample-2");
|
||||
System.loadLibrary("avformat-57");
|
||||
System.loadLibrary("swscale-4");
|
||||
System.loadLibrary("postproc-54");
|
||||
System.loadLibrary("avfilter-6");
|
||||
System.loadLibrary("avdevice-57");
|
||||
System.loadLibrary("cxsdk");
|
||||
System.loadLibrary("cxx2java");
|
||||
setColorbarSize(100, 20);
|
||||
setColorPalette(SharedPreferencesManager.getInt("paletteIndex", 2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ExtPara {
|
||||
public boolean bIsothermal;
|
||||
public int dwFlip;
|
||||
public int intAutoEnlargeRange;
|
||||
public int intBrightOffset;
|
||||
public int intContrastOffset;
|
||||
public int intCurrentEnvTemperature;
|
||||
public int intDetailRatio;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class GlobalFunc {
|
||||
public static final int MEDIA_IMAGE = 0;
|
||||
public static final int MEDIA_OTHER = -1;
|
||||
public static final int MEDIA_VIDEO = 1;
|
||||
|
||||
public static int guessMediaTypeBySuffix(String name) {
|
||||
String mimeType = getMimeType(getExtension(name));
|
||||
if (mimeType == null) {
|
||||
return -1;
|
||||
}
|
||||
if (mimeType.contains("video/")) {
|
||||
return 1;
|
||||
}
|
||||
return mimeType.contains("image/") ? 0 : -1;
|
||||
}
|
||||
|
||||
public static void updateFileList(ArrayList<String> fileNames) {
|
||||
File file = new File(MagApplication.magParameter.mediaDir);
|
||||
File[] files = file.listFiles(new FileFilter() { // from class: cn.com.magnity.magnitycx.sdk.GlobalFunc.1
|
||||
@Override // java.io.FileFilter
|
||||
public boolean accept(File pathname) {
|
||||
String name = pathname.getName().toLowerCase();
|
||||
return !name.endsWith(".ddt");
|
||||
}
|
||||
});
|
||||
if (file == null || files == null) {
|
||||
fileNames.clear();
|
||||
return;
|
||||
}
|
||||
ArrayList<FileInfo> fileInfos = new ArrayList<>();
|
||||
for (File f : files) {
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.name = f.getName();
|
||||
fileInfo.lastModified = f.lastModified();
|
||||
fileInfos.add(fileInfo);
|
||||
}
|
||||
Collections.sort(fileInfos, new FileInfoComparator());
|
||||
fileNames.clear();
|
||||
Iterator<FileInfo> it = fileInfos.iterator();
|
||||
while (it.hasNext()) {
|
||||
fileNames.add(it.next().name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notifyMediaSync(Context context, File file) {
|
||||
Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
|
||||
Uri uri = Uri.fromFile(file);
|
||||
intent.setData(uri);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public static int byteArrayToInt(byte[] b) {
|
||||
return (b[0] & 255) | ((b[1] & 255) << 8) | ((b[2] & 255) << 16) | ((b[3] & 255) << 24);
|
||||
}
|
||||
|
||||
public static byte[] intToByteArray(int a) {
|
||||
return new byte[]{(byte) (a & 255), (byte) ((a >> 8) & 255), (byte) ((a >> 16) & 255), (byte) ((a >> 24) & 255)};
|
||||
}
|
||||
|
||||
public static void intToByteArray(int a, byte[] out, int offset) {
|
||||
if (out.length >= offset + 4) {
|
||||
int offset2 = offset + 1;
|
||||
out[offset] = (byte) a;
|
||||
int offset3 = offset2 + 1;
|
||||
out[offset2] = (byte) (a >> 8);
|
||||
int offset4 = offset3 + 1;
|
||||
out[offset3] = (byte) (a >> 16);
|
||||
int i = offset4 + 1;
|
||||
out[offset4] = (byte) (a >> 24);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getExtension(String name) {
|
||||
int idx = name.lastIndexOf(".");
|
||||
if (idx <= 0) {
|
||||
return "";
|
||||
}
|
||||
String suffix = name.substring(idx + 1);
|
||||
return suffix;
|
||||
}
|
||||
|
||||
private static String getMimeType(String suffix) {
|
||||
if (suffix.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(suffix);
|
||||
}
|
||||
|
||||
private static class FileInfoComparator implements Comparator<FileInfo> {
|
||||
private FileInfoComparator() {
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(FileInfo lhs, FileInfo rhs) {
|
||||
if (lhs.lastModified > rhs.lastModified) {
|
||||
return -1;
|
||||
}
|
||||
if (lhs.lastModified == rhs.lastModified) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FileInfo {
|
||||
public long lastModified;
|
||||
public String name;
|
||||
|
||||
private FileInfo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImgHeader {
|
||||
public int frameIndex;
|
||||
public int[] reserved = new int[4];
|
||||
public int sendBytes;
|
||||
public int startCode;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImgTail implements Serializable {
|
||||
public int camTemp;
|
||||
public int endCode;
|
||||
public int fpaTemp;
|
||||
public int frameIndex;
|
||||
public int intDrop;
|
||||
public int[] reserved = new int[2];
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.support.v4.util.LruCache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LruCacheManager {
|
||||
private static final int CACHE_SIZE = 10485760;
|
||||
private static LruCacheManager instance_;
|
||||
private LruCache<String, Bitmap> memCache_;
|
||||
|
||||
private LruCacheManager() {
|
||||
}
|
||||
|
||||
public static LruCacheManager getInstance() {
|
||||
if (instance_ == null) {
|
||||
instance_ = new LruCacheManager();
|
||||
instance_.init();
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
int maxMemory = (int) Runtime.getRuntime().maxMemory();
|
||||
int cacheSize = CACHE_SIZE;
|
||||
if (CACHE_SIZE > maxMemory / 8) {
|
||||
cacheSize = maxMemory / 8;
|
||||
}
|
||||
this.memCache_ = new LruCache<String, Bitmap>(cacheSize) { // from class: cn.com.magnity.magnitycx.sdk.LruCacheManager.1
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.support.v4.util.LruCache
|
||||
public int sizeOf(String key, Bitmap bitmap) {
|
||||
return Build.VERSION.SDK_INT >= 12 ? bitmap.getByteCount() : bitmap.getRowBytes() * bitmap.getHeight();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.support.v4.util.LruCache
|
||||
public void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) {
|
||||
super.entryRemoved(evicted, (boolean) key, oldValue, newValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public synchronized Bitmap put(String key, Bitmap value) {
|
||||
return this.memCache_.put(key, value);
|
||||
}
|
||||
|
||||
public synchronized Bitmap get(String key) {
|
||||
return this.memCache_.get(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MagParameter {
|
||||
public static final int DISPMODE_IRONLY = 1;
|
||||
public static final int DISPMODE_PIP = 0;
|
||||
public static final int EM_LEVEL1 = 100;
|
||||
public static final int EM_LEVEL2 = 90;
|
||||
public static final int EM_LEVEL3 = 80;
|
||||
public static final int EM_LEVEL4 = 70;
|
||||
public static final String EVENT_C1 = "c1设备启动";
|
||||
public static final String EVENT_C1_ID = "C1";
|
||||
public static final String EVENT_C3 = "c3设备启动";
|
||||
public static final String EVENT_C3_ID = "C3";
|
||||
public static final String EVENT_CLICK_ABOUT = "点击关于";
|
||||
public static final String EVENT_CLICK_ABOUT_ID = "CLICK_ABOUT";
|
||||
public static final String EVENT_CLICK_PRODUCT = "点击产品";
|
||||
public static final String EVENT_CLICK_PRODUCT_ID = "CLICK_PRODUCT";
|
||||
public static final String EVENT_CLICK_SHARE = "点击分享";
|
||||
public static final String EVENT_CLICK_SHARE_ID = "CLICK_SHARE";
|
||||
public static final String EVENT_COLOR_PALETTE = "调色板";
|
||||
public static final String EVENT_COLOR_PALETTE_ID = "COLOR_PALETTE";
|
||||
public static final String EVENT_DIABLE_MAX_TEMP = "关闭最高温测温";
|
||||
public static final String EVENT_DIABLE_MAX_TEMP_ID = "DISABLE_MAX_TEMP";
|
||||
public static final String EVENT_DISABLE_CENTER_TEMP = "关闭中心测温";
|
||||
public static final String EVENT_DISABLE_CENTER_TEMP_ID = "DISABLE_CENTER_TEMP";
|
||||
public static final String EVENT_DISABLE_LASER = "关闭激光";
|
||||
public static final String EVENT_DISABLE_LASER_ID = "DISABLE_LASER";
|
||||
public static final String EVENT_DISABLE_VISWND = "关闭可见光";
|
||||
public static final String EVENT_DISABLE_VISWND_ID = "DISABLE_VISWND";
|
||||
public static final String EVENT_EMISSIVITY_DARK = "辐射率暗光";
|
||||
public static final String EVENT_EMISSIVITY_DARK_ID = "EMISSIVITY_DARK";
|
||||
public static final String EVENT_EMISSIVITY_HALF = "辐射率半光";
|
||||
public static final String EVENT_EMISSIVITY_HALF_ID = "EMISSIVITY_HALF";
|
||||
public static final String EVENT_EMISSIVITY_LIGHT = "辐射率亮光";
|
||||
public static final String EVENT_EMISSIVITY_LIGHT_ID = "EMISSIVITY_LIGHT";
|
||||
public static final String EVENT_EMISSIVITY_NONE = "辐射率无光";
|
||||
public static final String EVENT_EMISSIVITY_NONE_ID = "EMISSIVITY_NONE";
|
||||
public static final String EVENT_ENABLE_CENTER_TEMP = "打开中心测温";
|
||||
public static final String EVENT_ENABLE_CENTER_TEMP_ID = "ENABLE_CENTER_TEMP";
|
||||
public static final String EVENT_ENABLE_LASER = "打开激光";
|
||||
public static final String EVENT_ENABLE_LASER_ID = "ENABLE_LASER";
|
||||
public static final String EVENT_ENABLE_MAX_TEMP = "打开最高温测温";
|
||||
public static final String EVENT_ENABLE_MAX_TEMP_ID = "ENABLE_MAX_TEMP";
|
||||
public static final String EVENT_ENABLE_VISWND = "打开可见光";
|
||||
public static final String EVENT_ENABLE_VISWND_ID = "ENABLE_VISWND";
|
||||
public static final String EVENT_ENTER_COMPANY_WEBSITE = "进入官网";
|
||||
public static final String EVENT_ENTER_COMPANY_WEBSITE_ID = "ENTER_COMPANY_WEBSITE";
|
||||
public static final String EVENT_ENTER_WECHAT_STORE = "进入微店";
|
||||
public static final String EVENT_ENTER_WECHAT_STORE_ID = "ENTER_WECHAT_STORE";
|
||||
public static final String EVENT_FLIP_HORIZONTAL = "水平翻转";
|
||||
public static final String EVENT_FLIP_HORIZONTAL_ID = "FLIP_HORIZONTAL";
|
||||
public static final String EVENT_FLIP_VERTICAL = "竖直翻转";
|
||||
public static final String EVENT_FLIP_VERTICAL_ID = "FLIP_VERTICAL";
|
||||
public static final String EVENT_FRAME_RATE_HIGH = "帧率高";
|
||||
public static final String EVENT_FRAME_RATE_HIGH_ID = "FRAME_RATE_HIGH";
|
||||
public static final String EVENT_FRAME_RATE_LOW = "帧率低";
|
||||
public static final String EVENT_FRAME_RATE_LOW_ID = "FRAME_RATE_LOW";
|
||||
public static final String EVENT_PHOTO = "拍照";
|
||||
public static final String EVENT_PHOTO_ID = "PHOTO";
|
||||
public static final String EVENT_ROIT_TRACE = "矩形测温";
|
||||
public static final String EVENT_ROIT_TRACE_ID = "ROIT_TRACE";
|
||||
public static final String EVENT_TRACE_MAX = "目标最高温";
|
||||
public static final String EVENT_TRACE_MAXMIN = "目标全";
|
||||
public static final String EVENT_TRACE_MAXMIN_ID = "TRACE_MAXMIN";
|
||||
public static final String EVENT_TRACE_MAX_ID = "TRACE_MAX";
|
||||
public static final String EVENT_TRACE_MIN = "目标最低温";
|
||||
public static final String EVENT_TRACE_MIN_ID = "TRACE_MIN";
|
||||
public static final String EVENT_TRACE_NONE = "目标无";
|
||||
public static final String EVENT_TRACE_NONE_ID = "TRACE_NONE";
|
||||
public static final String EVENT_VIDEO = "录像";
|
||||
public static final String EVENT_VIDEO_ID = "VIDEO";
|
||||
public static final String EVENT_VISWND_LARGE = "可见光尺寸大";
|
||||
public static final String EVENT_VISWND_LARGE_ID = "VISWND_LARGE";
|
||||
public static final String EVENT_VISWND_MIDDLE = "可见光尺寸中";
|
||||
public static final String EVENT_VISWND_MIDDLE_ID = "VISWND_MIDDLE";
|
||||
public static final String EVENT_VISWND_SMALL = "可见光尺寸小";
|
||||
public static final String EVENT_VISWND_SMALL_ID = "VISWND_SMALL";
|
||||
public static final int FLIP_HOR = 1;
|
||||
public static final int FLIP_NO = 0;
|
||||
public static final int FLIP_VER = 2;
|
||||
public static final int FPS_HIGH = 0;
|
||||
public static final int FPS_LOW = 1;
|
||||
public static final String KEY_DISPMODE = "dispMode";
|
||||
public static final String KEY_EMISSIVITY = "emissivity";
|
||||
public static final String KEY_EXMODE = "exMode";
|
||||
public static final String KEY_FLIPMODE = "flipMode";
|
||||
public static final String KEY_FPSMODE = "fpsMode";
|
||||
public static final String KEY_MAXMINTRACE = "maxMinTrace";
|
||||
public static final String KEY_ONCETIPMEDIALONGCLICK = "onceTipMediaLongClick2";
|
||||
public static final String KEY_ONCETIPVISIBLEMOVE = "onceTipVisibleMove2";
|
||||
public static final String KEY_SHOWCROSS = "isShowCross";
|
||||
public static final String KEY_SHOWMOVINGCROSS = "isShowMovingCross";
|
||||
public static final String KEY_TRACEMAXMIN = "isTraceMaxMin";
|
||||
public static final String KEY_TRACEROI = "isTraceRoi";
|
||||
public static final String KEY_VISCAMID = "visCameraId";
|
||||
public static final String KEY_VISWNDLEFTMARGIN = "visWndLeftMargin";
|
||||
public static final String KEY_VISWNDSIZE = "visWndSize";
|
||||
public static final String KEY_VISWNDTOPMARGIN = "visWndTopMargin";
|
||||
public static final int TRACE_MAX = 0;
|
||||
public static final int TRACE_MAXMIN = 2;
|
||||
public static final int TRACE_MIN = 1;
|
||||
public static final int TRACE_NONE = -1;
|
||||
public static final int TYPE_160CORE = 3;
|
||||
public static final int TYPE_C1 = 0;
|
||||
public static final int TYPE_C1Pro = 5;
|
||||
public static final int TYPE_C1ProLite = 6;
|
||||
public static final int TYPE_C3 = 1;
|
||||
public static final int TYPE_C3P = 2;
|
||||
public static final int TYPE_C6 = 4;
|
||||
public static final int VISWND_LARGE = 2;
|
||||
public static final int VISWND_MEDIUM = 1;
|
||||
public static final int VISWND_SMALL = 0;
|
||||
public BasePara1 basePara1;
|
||||
public BasePara2 basePara2;
|
||||
public CaliInfo caliInfo;
|
||||
public int dispMode;
|
||||
public int emissivity;
|
||||
public int fpsMode;
|
||||
public int imageEX;
|
||||
public int imageFlip;
|
||||
public boolean isLaserOn;
|
||||
public boolean isShowCross;
|
||||
public boolean isShowMovingCross;
|
||||
public boolean isTraceMaxMin;
|
||||
public boolean isTraceRoi;
|
||||
public int maxMinTrace;
|
||||
public int onceTipMediaLongClick;
|
||||
public int onceTipVisibleMove;
|
||||
public int portraitScreenHeight;
|
||||
public int portraitScreenWidth;
|
||||
public int visCameraId;
|
||||
public int visWndLeftMargin;
|
||||
public int visWndSize;
|
||||
public int visWndTopMargin;
|
||||
public String logDir = "";
|
||||
public String caliDir = "";
|
||||
public String mediaDir = "";
|
||||
public String otherDir = "";
|
||||
|
||||
public MagParameter(Context context) {
|
||||
SharedPreferencesManager.init(context);
|
||||
this.basePara1 = new BasePara1();
|
||||
this.basePara2 = new BasePara2();
|
||||
this.caliInfo = new CaliInfo();
|
||||
this.dispMode = SharedPreferencesManager.getInt(KEY_DISPMODE, 1);
|
||||
this.isShowCross = SharedPreferencesManager.getBoolean(KEY_SHOWCROSS, false);
|
||||
this.isShowMovingCross = SharedPreferencesManager.getBoolean(KEY_SHOWMOVINGCROSS, false);
|
||||
this.isTraceMaxMin = SharedPreferencesManager.getBoolean(KEY_TRACEMAXMIN, false);
|
||||
this.isLaserOn = false;
|
||||
this.isTraceRoi = SharedPreferencesManager.getBoolean(KEY_TRACEROI, false);
|
||||
this.visCameraId = SharedPreferencesManager.getInt(KEY_VISCAMID, 0);
|
||||
this.visWndSize = SharedPreferencesManager.getInt(KEY_VISWNDSIZE, 1);
|
||||
this.maxMinTrace = SharedPreferencesManager.getInt(KEY_MAXMINTRACE, 0);
|
||||
this.imageFlip = SharedPreferencesManager.getInt(KEY_FLIPMODE, 0);
|
||||
this.imageEX = SharedPreferencesManager.getInt(KEY_EXMODE, 0);
|
||||
this.emissivity = SharedPreferencesManager.getInt(KEY_EMISSIVITY, 100);
|
||||
this.visWndLeftMargin = SharedPreferencesManager.getInt(KEY_VISWNDLEFTMARGIN, -1);
|
||||
this.visWndTopMargin = SharedPreferencesManager.getInt(KEY_VISWNDTOPMARGIN, 0);
|
||||
this.onceTipMediaLongClick = SharedPreferencesManager.getInt(KEY_ONCETIPMEDIALONGCLICK, 3);
|
||||
this.onceTipVisibleMove = SharedPreferencesManager.getInt(KEY_ONCETIPVISIBLEMOVE, 3);
|
||||
this.fpsMode = SharedPreferencesManager.getInt(KEY_FPSMODE, 1);
|
||||
createDirs();
|
||||
}
|
||||
|
||||
private void createDirs() {
|
||||
if (Environment.getExternalStorageState().equals("mounted")) {
|
||||
String pathName = Environment.getExternalStorageDirectory().getPath() + File.separator + "magnity" + File.separator + "Cx";
|
||||
File file = new File(pathName);
|
||||
if (file.exists() || file.mkdirs()) {
|
||||
String pathName2 = pathName + File.separator;
|
||||
this.logDir = pathName2 + "log";
|
||||
File file2 = new File(this.logDir);
|
||||
if (!file2.exists()) {
|
||||
file2.mkdirs();
|
||||
}
|
||||
this.caliDir = pathName2 + "others";
|
||||
File file3 = new File(this.caliDir);
|
||||
if (!file3.exists()) {
|
||||
file3.mkdirs();
|
||||
}
|
||||
this.mediaDir = pathName2 + "media";
|
||||
File file4 = new File(this.mediaDir);
|
||||
if (!file4.exists()) {
|
||||
file4.mkdirs();
|
||||
}
|
||||
this.otherDir = pathName2 + "others";
|
||||
File file5 = new File(this.otherDir);
|
||||
if (!file5.exists()) {
|
||||
file5.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Size {
|
||||
private int height_;
|
||||
private int width_;
|
||||
|
||||
public Size() {
|
||||
}
|
||||
|
||||
public Size(int width, int height) {
|
||||
this.width_ = width;
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width_ = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width_;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MsgBus {
|
||||
private static MsgBus mInstance;
|
||||
private static LocalBroadcastManager mLocalBroadcastManager;
|
||||
|
||||
public static synchronized MsgBus getInstance() {
|
||||
MsgBus msgBus;
|
||||
synchronized (MsgBus.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new MsgBus(MagApplication.getInstance());
|
||||
}
|
||||
msgBus = mInstance;
|
||||
}
|
||||
return msgBus;
|
||||
}
|
||||
|
||||
public MsgBus(Context context) {
|
||||
mLocalBroadcastManager = LocalBroadcastManager.getInstance(context.getApplicationContext());
|
||||
}
|
||||
|
||||
public void register(BroadcastReceiver receiver, String action) {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(action);
|
||||
mLocalBroadcastManager.registerReceiver(receiver, intentFilter);
|
||||
}
|
||||
|
||||
public void register(BroadcastReceiver receiver, String[] actions) {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
for (String msg : actions) {
|
||||
intentFilter.addAction(msg);
|
||||
}
|
||||
mLocalBroadcastManager.registerReceiver(receiver, intentFilter);
|
||||
}
|
||||
|
||||
public void unregister(BroadcastReceiver receiver) {
|
||||
mLocalBroadcastManager.unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
public void postEmptytMsg(String msg) {
|
||||
mLocalBroadcastManager.sendBroadcast(new Intent(msg));
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag, int val) {
|
||||
Intent intent = new Intent(msg);
|
||||
intent.putExtra(tag, val);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag, String val) {
|
||||
Intent intent = new Intent(msg);
|
||||
intent.putExtra(tag, val);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag, Parcelable parcel) {
|
||||
Intent intent = new Intent(msg);
|
||||
intent.putExtra(tag, parcel);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag1, Parcelable parcel, String tag2, int val) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(tag1, parcel);
|
||||
intent.putExtra(tag2, val);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class Observable<T> {
|
||||
protected final ArrayList<T> observers_ = new ArrayList<>();
|
||||
|
||||
public void registerObserver(T observer) {
|
||||
if (observer != null) {
|
||||
synchronized (this.observers_) {
|
||||
if (!this.observers_.contains(observer)) {
|
||||
this.observers_.add(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterObserver(T observer) {
|
||||
if (observer != null) {
|
||||
synchronized (this.observers_) {
|
||||
int index = this.observers_.indexOf(observer);
|
||||
if (index != -1) {
|
||||
this.observers_.remove(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterAll() {
|
||||
synchronized (this.observers_) {
|
||||
this.observers_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class P2DCmd {
|
||||
public static final int P2D_GetCaliFile = 1807136368;
|
||||
public static final int P2D_GetCaliInfo = 1807136367;
|
||||
public static final int P2D_GetFPAState = 1807136376;
|
||||
public static final int P2D_GetLifeTime = 1807136373;
|
||||
public static final int P2D_GetParameter1 = 1807136363;
|
||||
public static final int P2D_GetParameter2 = 1807136364;
|
||||
public static final int P2D_PowerSave = 1807136375;
|
||||
public static final int P2D_SendCaliFile = 1807136369;
|
||||
public static final int P2D_SetFrameRate = 1807136377;
|
||||
public static final int P2D_SetLaserState = 1807136374;
|
||||
public static final int P2D_SetParameter1 = 1807136365;
|
||||
public static final int P2D_SetParameter2 = 1807136366;
|
||||
public static final int P2D_SetShutterState = 1807136370;
|
||||
public static final int P2D_StartTransferImg = 1807136371;
|
||||
public static final int P2D_StopTransferImg = 1807136372;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SharedPreferencesManager {
|
||||
private static SharedPreferences.Editor editor_;
|
||||
private static SharedPreferences preferences_;
|
||||
|
||||
public static void init(Context context) {
|
||||
preferences_ = context.getApplicationContext().getSharedPreferences("magnitycx", 0);
|
||||
editor_ = preferences_.edit();
|
||||
}
|
||||
|
||||
public static boolean commit() {
|
||||
return editor_.commit();
|
||||
}
|
||||
|
||||
public static SharedPreferences.Editor putInt(String key, int value) {
|
||||
return editor_.putInt(key, value);
|
||||
}
|
||||
|
||||
public static void putIntWithCommit(String key, int value) {
|
||||
editor_.putInt(key, value);
|
||||
editor_.commit();
|
||||
}
|
||||
|
||||
public static int getInt(String key, int defValue) {
|
||||
return preferences_.getInt(key, defValue);
|
||||
}
|
||||
|
||||
public static SharedPreferences.Editor putFloat(String key, float value) {
|
||||
return editor_.putFloat(key, value);
|
||||
}
|
||||
|
||||
public static void putFloatWithCommit(String key, float value) {
|
||||
editor_.putFloat(key, value);
|
||||
editor_.commit();
|
||||
}
|
||||
|
||||
public static float getFloat(String key, float defValue) {
|
||||
return preferences_.getFloat(key, defValue);
|
||||
}
|
||||
|
||||
public static SharedPreferences.Editor putBoolean(String key, boolean value) {
|
||||
return editor_.putBoolean(key, value);
|
||||
}
|
||||
|
||||
public static void putBooleanWithCommit(String key, boolean value) {
|
||||
editor_.putBoolean(key, value);
|
||||
editor_.commit();
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key, boolean defValue) {
|
||||
return preferences_.getBoolean(key, defValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class State implements Cloneable {
|
||||
public int intAveNETDt;
|
||||
public int intAveTemperature;
|
||||
public int[] intHistTemperature = new int[256];
|
||||
public int intMaxTemperature;
|
||||
public int intMaxX;
|
||||
public int intMaxY;
|
||||
public int intMinTemperature;
|
||||
public int intMinX;
|
||||
public int intMinY;
|
||||
public int intSTDTemperature;
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
State state = (State) super.clone();
|
||||
if (this.intHistTemperature != null) {
|
||||
state.intHistTemperature = Arrays.copyOf(this.intHistTemperature, this.intHistTemperature.length);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class TimerHelper {
|
||||
private Timer timer_ = null;
|
||||
|
||||
public abstract void run();
|
||||
|
||||
public void start(long delay, long period) {
|
||||
stop();
|
||||
this.timer_ = new Timer();
|
||||
this.timer_.schedule(new TimerTask() { // from class: cn.com.magnity.magnitycx.sdk.TimerHelper.1
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
TimerHelper.this.run();
|
||||
}
|
||||
}, delay, period);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.timer_ != null) {
|
||||
this.timer_.cancel();
|
||||
this.timer_ = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,966 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.hardware.usb.UsbDeviceConnection;
|
||||
import android.hardware.usb.UsbEndpoint;
|
||||
import android.hardware.usb.UsbInterface;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.media.TransportMediator;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import cn.com.magnity.magnitycx.ImageViewer;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import cn.com.magnity.magnitycx.R;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import com.baidu.mobstat.Config;
|
||||
import com.baidu.mobstat.autotrace.Common;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.apache.log4j.Priority;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UsbCommunication implements DeviceController.ShutterCallBack {
|
||||
private static final int DOWNLOAD_CALI_TIMEOUT = 5000;
|
||||
private static final int HEADER_SIZE = 28;
|
||||
private static final int IMG_END_CODE = 464630044;
|
||||
private static final int IMG_START_CODE = 464630043;
|
||||
private static final int MAX_CALI_FILE_LEN = 104857600;
|
||||
private static final int MAX_RECEIVED_LEN = 16384;
|
||||
private static final int MIN_CALI_FILE_LEN = 65536;
|
||||
public static final String MSG_SET_BASEPARAMETER = "set_baseparameter";
|
||||
public static final String MSG_TRIGGER_FFC = "trigger_ffc";
|
||||
public static final int PROGRESS_CALI_ID = 0;
|
||||
private static final int PROGRESS_CANCEL = 3;
|
||||
private static final int PROGRESS_CHANGED = 2;
|
||||
private static final int PROGRESS_FINISHED = 1;
|
||||
private static final int PROGRESS_START = 0;
|
||||
public static final int PROGRESS_WAIT_FOR_CORRECT_STREAM_ID = 1;
|
||||
private static final int QUERY_DEVICE_LIFETIME = 4;
|
||||
private static final int TAIL_SIZE = 28;
|
||||
private static final int TIMEOUT = 800;
|
||||
private static final int TIME_FOR_DEVICE_INIT = 15000;
|
||||
private static volatile Lock lock_ = new ReentrantLock();
|
||||
private static volatile long[] ticks_ = new long[20];
|
||||
private volatile int camTemp_;
|
||||
private UsbConnection conn_;
|
||||
private volatile int fpaTemp_;
|
||||
private byte[] imgExchangeBuf1_;
|
||||
private ImageViewer imgViewer_;
|
||||
private volatile boolean isExitThreadImgProcess_;
|
||||
private IProgressCallback progressCallback_;
|
||||
private ThreadCaliRecv threadCaliRecv_;
|
||||
private ThreadImgProcess threadImgProcess_;
|
||||
private ThreadImgRecv threadImgRecv_;
|
||||
private UsbDeviceConnection usbConn_;
|
||||
private UsbEndpoint usbEpCaliIn_;
|
||||
private UsbEndpoint usbEpCaliOut_;
|
||||
private UsbEndpoint usbEpCmdIn_;
|
||||
private UsbEndpoint usbEpCmdOut_;
|
||||
private UsbEndpoint usbEpImgIn_;
|
||||
private UsbInterface usbInterface_;
|
||||
private volatile boolean connected_ = false;
|
||||
private volatile boolean isExitCaliRecvThread = false;
|
||||
private WaitCondition condImgProcess_ = new WaitCondition();
|
||||
private volatile boolean isToRecvFirstCaliPacket_ = false;
|
||||
private String caliPathName_ = "";
|
||||
private Handler handler_ = new Handler() { // from class: cn.com.magnity.magnitycx.sdk.UsbCommunication.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case 0:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressStart(((Integer) msg.obj).intValue());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressFinished(((Integer) msg.obj).intValue());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressChanged(msg.arg1, msg.arg2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressCancel(((Integer) msg.obj).intValue());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
int t = UsbCommunication.this.getDevLifeTime();
|
||||
if (t != -1) {
|
||||
if (MagApplication.magParameter.basePara1.devType == 0 || MagApplication.magParameter.basePara1.devType == 5 || MagApplication.magParameter.basePara1.devType == 6 || MagApplication.magParameter.basePara1.devType == 3) {
|
||||
if (t > 5000) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 4) {
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(0);
|
||||
} else {
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(4);
|
||||
}
|
||||
} else if (MagApplication.magParameter.basePara1.devType == 1 || MagApplication.magParameter.basePara1.devType == 2) {
|
||||
if (t > 26000) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 1) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(0);
|
||||
} else if (t > 19500) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 2) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(1);
|
||||
} else if (t > 13000) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 3) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(2);
|
||||
} else if (t > 6500) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 4) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(3);
|
||||
} else {
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(4);
|
||||
}
|
||||
}
|
||||
if (t > 40000) {
|
||||
UsbCommunication.this.imgViewer_.setTempStableFlag(true);
|
||||
break;
|
||||
} else {
|
||||
UsbCommunication.this.imgViewer_.setTempStableFlag(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() { // from class: cn.com.magnity.magnitycx.sdk.UsbCommunication.2
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "set_baseparameter":
|
||||
UsbCommunication.this.setFrameRate();
|
||||
DeviceController.triggerFFC();
|
||||
break;
|
||||
case "trigger_ffc":
|
||||
DeviceController.triggerFFC();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public interface DelegateNewFrame {
|
||||
void onNewFrameReceived(int i, int i2);
|
||||
}
|
||||
|
||||
public interface IProgressCallback {
|
||||
void progressCancel(int i);
|
||||
|
||||
void progressChanged(int i, int i2);
|
||||
|
||||
void progressFinished(int i);
|
||||
|
||||
void progressStart(int i);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getDevLifeTime() {
|
||||
int i = -1;
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetLifeTime, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get device lifetime");
|
||||
}
|
||||
byte[] data = new byte[64];
|
||||
int len = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len < 0) {
|
||||
Logging.error("Fail to get lifetime ack");
|
||||
} else if (len < 4) {
|
||||
Logging.error("Get wrong ack size(" + len + ")");
|
||||
} else if (len < 8) {
|
||||
Logging.error("Get wrong ack size(" + len + ", cmd: " + GlobalFunc.byteArrayToInt(data) + ")");
|
||||
} else {
|
||||
ByteBuffer bb = ByteBuffer.wrap(data, 0, len);
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
try {
|
||||
if (bb.getInt() == 1538635105) {
|
||||
i = bb.getInt();
|
||||
} else {
|
||||
Logging.error("Get wrong cmd(expected is lifetime)");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
Logging.error("Exception of get liftime");
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public void setCallbackReceiver(IProgressCallback cb) {
|
||||
this.progressCallback_ = cb;
|
||||
}
|
||||
|
||||
public UsbCommunication(UsbConnection conn, UsbManager usbMgr, UsbDevice device, IProgressCallback cb) throws Exception {
|
||||
this.conn_ = conn;
|
||||
this.progressCallback_ = cb;
|
||||
this.usbConn_ = usbMgr.openDevice(device);
|
||||
if (this.usbConn_ == null) {
|
||||
throw new Exception("Unable to open USB device");
|
||||
}
|
||||
if (device.getInterfaceCount() < 1) {
|
||||
throw new Exception("Unable to get USB interface");
|
||||
}
|
||||
this.usbInterface_ = device.getInterface(0);
|
||||
if (!this.usbConn_.claimInterface(this.usbInterface_, true)) {
|
||||
throw new Exception("Unable to claim USB interface");
|
||||
}
|
||||
if (this.usbInterface_.getEndpointCount() < 4) {
|
||||
throw new Exception("Unable to get USB endpoint (" + this.usbInterface_.getEndpointCount() + ")");
|
||||
}
|
||||
for (int i = this.usbInterface_.getEndpointCount() - 1; i != -1; i--) {
|
||||
UsbEndpoint ep = this.usbInterface_.getEndpoint(i);
|
||||
switch (ep.getAddress()) {
|
||||
case 3:
|
||||
this.usbEpCmdOut_ = ep;
|
||||
break;
|
||||
case 5:
|
||||
this.usbEpCaliOut_ = ep;
|
||||
break;
|
||||
case 129:
|
||||
this.usbEpImgIn_ = ep;
|
||||
break;
|
||||
case TransportMediator.KEYCODE_MEDIA_RECORD /* 130 */:
|
||||
this.usbEpCmdIn_ = ep;
|
||||
break;
|
||||
case 132:
|
||||
this.usbEpCaliIn_ = ep;
|
||||
break;
|
||||
default:
|
||||
Logging.warn("Unknown endpoint found.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.usbEpCmdIn_ == null || this.usbEpCmdOut_ == null || this.usbEpCaliIn_ == null || this.usbEpCaliOut_ == null || this.usbEpImgIn_ == null) {
|
||||
Logging.warn("Some endpoint lost.");
|
||||
}
|
||||
}
|
||||
|
||||
public void setImageViewer(ImageViewer imageViewer) {
|
||||
this.imgViewer_ = imageViewer;
|
||||
}
|
||||
|
||||
public int connect() {
|
||||
if (this.connected_) {
|
||||
return 1;
|
||||
}
|
||||
MsgBus.getInstance().register(this.mReceiver, new String[]{MSG_SET_BASEPARAMETER, MSG_TRIGGER_FFC});
|
||||
byte[] data = new byte[64];
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetParameter1, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get parameter1");
|
||||
return -1;
|
||||
}
|
||||
int len = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len > 0) {
|
||||
if (parseCmd(data, len) != 1) {
|
||||
return -1;
|
||||
}
|
||||
if (MagApplication.magParameter.basePara1.devType != 0 && MagApplication.magParameter.basePara1.devType != 5 && MagApplication.magParameter.basePara1.devType != 6 && MagApplication.magParameter.basePara1.devType != 1 && MagApplication.magParameter.basePara1.devType != 2 && MagApplication.magParameter.basePara1.devType != 3) {
|
||||
Logging.error("unknown device type " + MagApplication.magParameter.basePara1.devType);
|
||||
return -1;
|
||||
}
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetParameter2, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get parameter2");
|
||||
return -1;
|
||||
}
|
||||
int len2 = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len2 > 0) {
|
||||
if (parseCmd(data, len2) != 1) {
|
||||
return -1;
|
||||
}
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetCaliInfo, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get remote file info");
|
||||
return -1;
|
||||
}
|
||||
int len3 = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len3 > 0) {
|
||||
int ret = parseCmd(data, len3);
|
||||
if (ret == 1) {
|
||||
return !startTransfer(this.caliPathName_) ? -1 : 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
Logging.error("Fail to get remote file info");
|
||||
return -1;
|
||||
}
|
||||
Logging.error("Fail to get parameter2 ack");
|
||||
return -1;
|
||||
}
|
||||
Logging.error("Fail to get parameter1 ack");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean startTransfer(String caliPathName) {
|
||||
BasePara1 para1 = MagApplication.magParameter.basePara1;
|
||||
BasePara2 para2 = MagApplication.magParameter.basePara2;
|
||||
if (!DeviceController.startProcess(this, para1.fpaWidth, para1.fpaHeight, para1.serialNumber, para1.devType, para2.shutterCloseSpeed, para2.shutterOpenSpeed, para2.ffcTriggerFrame, para2.ffcTriggerTemperature, SharedPreferencesManager.getInt("paletteIndex", 2), para2.baseLineAcc, caliPathName)) {
|
||||
Logging.error("SDK start fail");
|
||||
try {
|
||||
File f = new File(caliPathName);
|
||||
f.delete();
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DeviceController.setEX(MagApplication.magParameter.imageEX, MagApplication.magParameter.basePara1.fpaWidth / 2, MagApplication.magParameter.basePara1.fpaHeight / 2);
|
||||
ExtPara param = new ExtPara();
|
||||
DeviceController.Lock();
|
||||
DeviceController.getExtParameter(param);
|
||||
param.dwFlip = MagApplication.magParameter.imageFlip;
|
||||
DeviceController.setExtParameter(param);
|
||||
DeviceController.setAutoEnlarge(para2.enlargeRange);
|
||||
DeviceController.Unlock();
|
||||
Logging.info("****Start****");
|
||||
this.connected_ = true;
|
||||
this.threadImgRecv_ = new ThreadImgRecv();
|
||||
this.threadImgRecv_.start();
|
||||
this.threadImgProcess_ = new ThreadImgProcess();
|
||||
this.isExitThreadImgProcess_ = false;
|
||||
this.condImgProcess_.notified = false;
|
||||
this.threadImgProcess_.start();
|
||||
try {
|
||||
Thread.sleep(5L);
|
||||
} catch (InterruptedException e2) {
|
||||
}
|
||||
if (sendEmptyCmd(P2DCmd.P2D_StartTransferImg, Common.EDIT_SNAPSHOT_INTERVAL) < 0) {
|
||||
Logging.error("Fail to start remote transferring");
|
||||
DeviceController.stopProcess();
|
||||
return false;
|
||||
}
|
||||
if (para1.devType == 1) {
|
||||
MagApplication.magParameter.isTraceRoi = false;
|
||||
MagApplication.magParameter.isShowCross = false;
|
||||
MagApplication.magParameter.isTraceMaxMin = true;
|
||||
MagApplication.magParameter.maxMinTrace = -1;
|
||||
MagApplication.magParameter.emissivity = 100;
|
||||
DeviceController.Lock();
|
||||
DeviceController.setEmissivity(100, Priority.INFO_INT);
|
||||
DeviceController.Unlock();
|
||||
} else if (para1.devType == 0 || para1.devType == 5 || para1.devType == 6 || para1.devType == 3) {
|
||||
MagApplication.magParameter.isTraceRoi = false;
|
||||
MagApplication.magParameter.isShowMovingCross = false;
|
||||
MagApplication.magParameter.emissivity = 100;
|
||||
DeviceController.Lock();
|
||||
DeviceController.setEmissivity(100, Priority.INFO_INT);
|
||||
DeviceController.Unlock();
|
||||
} else if (para1.devType == 2) {
|
||||
MagApplication.magParameter.isShowMovingCross = false;
|
||||
MagApplication.magParameter.isTraceMaxMin = true;
|
||||
}
|
||||
if (para1.devType == 1 || para1.devType == 2) {
|
||||
if (MagApplication.magParameter.fpsMode == 0) {
|
||||
MagApplication.magParameter.basePara1.interFrame = 9;
|
||||
MagApplication.magParameter.basePara1.interLine = 12;
|
||||
} else {
|
||||
MagApplication.magParameter.basePara1.interFrame = 105;
|
||||
MagApplication.magParameter.basePara1.interLine = 105;
|
||||
}
|
||||
setFrameRate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void stopTransfer() {
|
||||
if (sendEmptyCmd(P2DCmd.P2D_StopTransferImg, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to stop remote transferring");
|
||||
}
|
||||
this.connected_ = false;
|
||||
try {
|
||||
if (this.threadImgRecv_ != null) {
|
||||
this.threadImgRecv_.join();
|
||||
this.threadImgRecv_ = null;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
this.threadImgRecv_ = null;
|
||||
Logging.trace("Thread join interrupted1");
|
||||
}
|
||||
this.isExitThreadImgProcess_ = true;
|
||||
synchronized (this.condImgProcess_.cond) {
|
||||
this.condImgProcess_.notified = true;
|
||||
this.condImgProcess_.cond.notify();
|
||||
}
|
||||
try {
|
||||
if (this.threadImgProcess_ != null) {
|
||||
this.threadImgProcess_.join();
|
||||
this.threadImgProcess_ = null;
|
||||
}
|
||||
} catch (InterruptedException e2) {
|
||||
this.condImgProcess_ = null;
|
||||
Logging.trace("Thread join interrupted2");
|
||||
}
|
||||
DeviceController.stopProcess();
|
||||
Logging.trace("****Stop****");
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
MsgBus.getInstance().unregister(this.mReceiver);
|
||||
setLaserState(0);
|
||||
MagApplication.magParameter.isLaserOn = false;
|
||||
stopTransfer();
|
||||
this.conn_ = null;
|
||||
if (this.usbConn_ != null) {
|
||||
if (this.usbInterface_ != null) {
|
||||
this.usbConn_.releaseInterface(this.usbInterface_);
|
||||
}
|
||||
this.usbConn_.close();
|
||||
this.usbConn_ = null;
|
||||
}
|
||||
this.usbEpImgIn_ = null;
|
||||
this.usbEpCaliOut_ = null;
|
||||
this.usbEpCaliIn_ = null;
|
||||
this.usbEpCmdOut_ = null;
|
||||
this.usbEpCmdIn_ = null;
|
||||
stopCaliRecvThread();
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DeviceController.ShutterCallBack
|
||||
public void setShutterState(int on) {
|
||||
setShutterState_(on);
|
||||
}
|
||||
|
||||
private void startCaliRecvThread() {
|
||||
if (this.threadCaliRecv_ == null) {
|
||||
this.threadCaliRecv_ = new ThreadCaliRecv();
|
||||
this.isExitCaliRecvThread = false;
|
||||
this.threadCaliRecv_.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopCaliRecvThread() {
|
||||
try {
|
||||
if (this.threadCaliRecv_ != null) {
|
||||
this.isExitCaliRecvThread = true;
|
||||
this.threadCaliRecv_.join();
|
||||
this.threadCaliRecv_ = null;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
this.threadCaliRecv_ = null;
|
||||
Logging.trace("Thread join interrupted.");
|
||||
}
|
||||
}
|
||||
|
||||
private void setShutterState_(int on) {
|
||||
byte[] buf = {(byte) P2DCmd.P2D_SetShutterState, (byte) 7059126, (byte) 27574, (byte) 107, (byte) on, (byte) (on >> 8), (byte) (on >> 16), (byte) (on >> 24)};
|
||||
sendCmd(buf, 0, buf.length, TIMEOUT);
|
||||
}
|
||||
|
||||
public boolean setLaserState(int on) {
|
||||
byte[] buf = {(byte) P2DCmd.P2D_SetLaserState, (byte) 7059126, (byte) 27574, (byte) 107, (byte) on, (byte) (on >> 8), (byte) (on >> 16), (byte) (on >> 24)};
|
||||
return sendCmd(buf, 0, buf.length, TIMEOUT) >= 0;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean setFrameRate() {
|
||||
int interFrame;
|
||||
int interLine;
|
||||
byte[] buf = new byte[12];
|
||||
if (MagApplication.magParameter.fpsMode == 0) {
|
||||
interFrame = 9;
|
||||
interLine = 12;
|
||||
} else {
|
||||
interFrame = 105;
|
||||
interLine = 105;
|
||||
}
|
||||
buf[0] = (byte) P2DCmd.P2D_SetFrameRate;
|
||||
buf[1] = (byte) 7059126;
|
||||
buf[2] = (byte) 27574;
|
||||
buf[3] = (byte) 107;
|
||||
buf[4] = (byte) interFrame;
|
||||
buf[5] = (byte) (interFrame >> 8);
|
||||
buf[6] = (byte) (interFrame >> 16);
|
||||
buf[7] = (byte) (interFrame >> 24);
|
||||
buf[8] = (byte) interLine;
|
||||
buf[9] = (byte) (interLine >> 8);
|
||||
buf[10] = (byte) (interLine >> 16);
|
||||
buf[11] = (byte) (interLine >> 24);
|
||||
return sendCmd(buf, 0, buf.length, TIMEOUT) >= 0;
|
||||
}
|
||||
|
||||
private boolean waitForCmdAck(int cmd, int timeout) {
|
||||
switch (cmd) {
|
||||
case P2DCmd.P2D_SetParameter1 /* 1807136365 */:
|
||||
case P2DCmd.P2D_SetParameter2 /* 1807136366 */:
|
||||
case P2DCmd.P2D_GetCaliFile /* 1807136368 */:
|
||||
case P2DCmd.P2D_SendCaliFile /* 1807136369 */:
|
||||
case P2DCmd.P2D_SetShutterState /* 1807136370 */:
|
||||
case P2DCmd.P2D_StartTransferImg /* 1807136371 */:
|
||||
case P2DCmd.P2D_StopTransferImg /* 1807136372 */:
|
||||
case P2DCmd.P2D_SetLaserState /* 1807136374 */:
|
||||
case P2DCmd.P2D_SetFrameRate /* 1807136377 */:
|
||||
byte[] buf = new byte[64];
|
||||
int ret = this.usbConn_.bulkTransfer(this.usbEpCmdIn_, buf, 0, buf.length, timeout);
|
||||
if (ret < 0) {
|
||||
Logging.trace("Fail to get command ack - " + Integer.toHexString(cmd));
|
||||
return false;
|
||||
}
|
||||
case P2DCmd.P2D_GetCaliInfo /* 1807136367 */:
|
||||
case P2DCmd.P2D_GetLifeTime /* 1807136373 */:
|
||||
case P2DCmd.P2D_PowerSave /* 1807136375 */:
|
||||
case P2DCmd.P2D_GetFPAState /* 1807136376 */:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int sendCmd(byte[] data, int offset, int len, int timeout) {
|
||||
int ret;
|
||||
ret = this.usbConn_.bulkTransfer(this.usbEpCmdOut_, data, offset, len, timeout);
|
||||
if (ret < 0) {
|
||||
ret = -1;
|
||||
} else if (!waitForCmdAck(GlobalFunc.byteArrayToInt(data), timeout)) {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public synchronized int sendEmptyCmd(int data, int timeout) {
|
||||
int ret;
|
||||
ret = this.usbConn_.bulkTransfer(this.usbEpCmdOut_, GlobalFunc.intToByteArray(data), 0, 4, timeout);
|
||||
if (ret < 0) {
|
||||
ret = -1;
|
||||
} else if (!waitForCmdAck(data, timeout)) {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public synchronized int recvCmd(byte[] buffer, int offset, int len, int timeout) {
|
||||
return this.usbConn_.bulkTransfer(this.usbEpCmdIn_, buffer, offset, len, timeout);
|
||||
}
|
||||
|
||||
public int sendCali(byte[] data, int offset, int len, int timeout) {
|
||||
int ret = this.usbConn_.bulkTransfer(this.usbEpCaliOut_, data, offset, len, timeout);
|
||||
if (ret >= 0 && waitForCmdAck(GlobalFunc.byteArrayToInt(data), timeout)) {
|
||||
return ret;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public synchronized int sendEmptyCali(int data, int timeout) {
|
||||
int ret;
|
||||
ret = this.usbConn_.bulkTransfer(this.usbEpCaliOut_, GlobalFunc.intToByteArray(data), 0, 4, timeout);
|
||||
if (ret < 0) {
|
||||
ret = -1;
|
||||
} else if (!waitForCmdAck(data, timeout)) {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int recvCali(byte[] buffer, int offset, int len, int timeout) {
|
||||
return this.usbConn_.bulkTransfer(this.usbEpCaliIn_, buffer, offset, len, timeout);
|
||||
}
|
||||
|
||||
public int recvImg(byte[] buffer, int offset, int len, int timeout) {
|
||||
return this.usbConn_.bulkTransfer(this.usbEpImgIn_, buffer, offset, len, timeout);
|
||||
}
|
||||
|
||||
public int getCmdInAddress() {
|
||||
return this.usbEpCmdIn_.getAddress();
|
||||
}
|
||||
|
||||
public int getCaliInAddress() {
|
||||
return this.usbEpCaliIn_.getAddress();
|
||||
}
|
||||
|
||||
public int getImgInAddress() {
|
||||
return this.usbEpImgIn_.getAddress();
|
||||
}
|
||||
|
||||
private int parseCmd(byte[] data, int len) {
|
||||
String productType;
|
||||
if (len < 4) {
|
||||
return -1;
|
||||
}
|
||||
ByteBuffer bb = ByteBuffer.wrap(data, 0, len);
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int cmd = bb.getInt();
|
||||
switch (cmd) {
|
||||
case D2PCmd.D2P_SendParameter1 /* 1538635099 */:
|
||||
Logging.trace("D2P_SendParameter1");
|
||||
BasePara1 para1 = MagApplication.magParameter.basePara1;
|
||||
try {
|
||||
para1.serialNumber = bb.getInt();
|
||||
int val = bb.getInt();
|
||||
para1.hwVersion = 16777215 & val;
|
||||
para1.devType = (val >> 24) & 255;
|
||||
para1.swVersion = bb.getInt();
|
||||
para1.reserved1 = bb.getInt();
|
||||
para1.fpaWidth = bb.getInt();
|
||||
para1.fpaHeight = bb.getInt();
|
||||
para1.fps = bb.getInt();
|
||||
para1.reserved2 = bb.getInt();
|
||||
para1.fpaGain = bb.getInt();
|
||||
para1.fpaFlip = bb.getInt();
|
||||
para1.interFrame = bb.getInt();
|
||||
para1.interLine = bb.getInt();
|
||||
para1.gfid = bb.getInt();
|
||||
para1.gsk = bb.getInt();
|
||||
if (bb.hasRemaining()) {
|
||||
Logging.warn("D2PCmd.D2P_SendParameter1 cmd size is too long");
|
||||
return -1;
|
||||
}
|
||||
Logging.trace("Serial number: " + para1.serialNumber);
|
||||
return 1;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
para1.reset();
|
||||
Logging.error("D2PCmd.D2P_SendParameter1 cmd size is not enough");
|
||||
return -1;
|
||||
}
|
||||
case D2PCmd.D2P_SendParameter2 /* 1538635100 */:
|
||||
Logging.trace("D2P_SendParameter2");
|
||||
BasePara2 para2 = MagApplication.magParameter.basePara2;
|
||||
try {
|
||||
para2.baseLineAcc = bb.getInt();
|
||||
para2.denoiseLevel = bb.getInt();
|
||||
para2.reserved1 = bb.getInt();
|
||||
para2.reserved2 = bb.getShort();
|
||||
para2.fpaTempFix = bb.getShort();
|
||||
para2.shutterCloseSpeed = bb.getInt();
|
||||
para2.shutterOpenSpeed = bb.getInt();
|
||||
para2.ffcTriggerFrame = bb.getInt();
|
||||
para2.ffcTriggerTemperature = bb.getInt();
|
||||
para2.enlargeRange = bb.getInt();
|
||||
para2.laserPos = bb.getInt();
|
||||
para2.ATZeroErrorPoint = bb.getInt();
|
||||
para2.ATErrorSlope = bb.getFloat();
|
||||
para2.reserved5 = bb.getInt();
|
||||
para2.reserved6 = bb.getInt();
|
||||
if (bb.hasRemaining()) {
|
||||
Logging.warn("D2PCmd.D2P_SendParameter2 cmd size is too long");
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
} catch (IndexOutOfBoundsException e2) {
|
||||
para2.reset();
|
||||
Logging.error("D2PCmd.D2P_SendParameter2 cmd size is not enough");
|
||||
return -1;
|
||||
}
|
||||
case D2PCmd.D2P_SendCaliFile /* 1538635101 */:
|
||||
Logging.trace("D2P_SendRemoteFile");
|
||||
this.isToRecvFirstCaliPacket_ = true;
|
||||
return 1;
|
||||
case D2PCmd.D2P_SendCaliInfo /* 1538635102 */:
|
||||
Logging.trace("D2P_SendRemoteFileInfo");
|
||||
CaliInfo caliInfo = MagApplication.magParameter.caliInfo;
|
||||
try {
|
||||
caliInfo.size = bb.getInt();
|
||||
caliInfo.reserved = bb.getInt();
|
||||
caliInfo.date = bb.getLong();
|
||||
if (bb.hasRemaining()) {
|
||||
Logging.warn("D2PCmd.D2P_SendRemoteFileInfo cmd size is too long");
|
||||
return -1;
|
||||
}
|
||||
Logging.trace("Remote file info: " + caliInfo.size + ", " + caliInfo.date);
|
||||
if (MagApplication.magParameter.caliInfo.size < 65536 || MagApplication.magParameter.caliInfo.size > MAX_CALI_FILE_LEN) {
|
||||
this.caliPathName_ = "";
|
||||
Logging.error("remoteFileInfo error(invalid size)");
|
||||
return -1;
|
||||
}
|
||||
if (MagApplication.magParameter.caliDir != null) {
|
||||
switch (MagApplication.magParameter.basePara1.devType) {
|
||||
case 0:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c1);
|
||||
break;
|
||||
case 1:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c3);
|
||||
break;
|
||||
case 2:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c3p);
|
||||
break;
|
||||
case 3:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.core160);
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.unknownProductType);
|
||||
break;
|
||||
case 5:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c1pro);
|
||||
break;
|
||||
case 6:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c1prolite);
|
||||
break;
|
||||
}
|
||||
this.caliPathName_ = MagApplication.magParameter.caliDir + File.separator + productType + "." + MagApplication.magParameter.basePara1.serialNumber + "." + MagApplication.magParameter.caliInfo.date;
|
||||
File dir = new File(MagApplication.magParameter.caliDir);
|
||||
File file = new File(this.caliPathName_);
|
||||
if (!file.exists() || file.length() != MagApplication.magParameter.caliInfo.size) {
|
||||
File[] files = dir.listFiles();
|
||||
for (File f : files) {
|
||||
if (f.getName().contains(MagApplication.magParameter.basePara1.serialNumber + ".")) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
stopCaliRecvThread();
|
||||
startCaliRecvThread();
|
||||
try {
|
||||
Thread.sleep(50L);
|
||||
} catch (InterruptedException e3) {
|
||||
}
|
||||
sendEmptyCmd(P2DCmd.P2D_GetCaliFile, TIMEOUT);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} catch (IndexOutOfBoundsException e4) {
|
||||
caliInfo.reset();
|
||||
Logging.error("D2PCmd.D2P_SendRemoteFileInfo cmd size is not enough");
|
||||
return -1;
|
||||
}
|
||||
default:
|
||||
Logging.warn("Unknown command(" + cmd + ")");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private class ThreadImgRecv extends Thread {
|
||||
private ThreadImgRecv() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
int drop;
|
||||
int frameBytes = ((MagApplication.magParameter.basePara1.fpaWidth * MagApplication.magParameter.basePara1.fpaHeight) * 16) / 8;
|
||||
int imgRecvBufLength = frameBytes + 1024;
|
||||
if (UsbCommunication.this.imgExchangeBuf1_ == null || UsbCommunication.this.imgExchangeBuf1_.length < imgRecvBufLength) {
|
||||
UsbCommunication.this.imgExchangeBuf1_ = new byte[imgRecvBufLength];
|
||||
}
|
||||
Logging.trace("Enter ThreadImgReceiver");
|
||||
byte[] recvbuf = new byte[imgRecvBufLength];
|
||||
boolean headerFound = false;
|
||||
int total = 0;
|
||||
int index = 0;
|
||||
long t1 = 0;
|
||||
while (UsbCommunication.this.connected_) {
|
||||
int len = UsbCommunication.this.recvImg(recvbuf, total, recvbuf.length - total, ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION);
|
||||
if (len > 0) {
|
||||
if (!headerFound) {
|
||||
if (len >= 28) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(recvbuf, 0, 28);
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
if (bb.getInt() == UsbCommunication.IMG_START_CODE) {
|
||||
headerFound = true;
|
||||
}
|
||||
}
|
||||
total = 0;
|
||||
} else if (len >= 28) {
|
||||
ByteBuffer bb2 = ByteBuffer.wrap(recvbuf, (total + len) - 28, 28);
|
||||
bb2.order(ByteOrder.LITTLE_ENDIAN);
|
||||
if (bb2.getInt() == UsbCommunication.IMG_END_CODE) {
|
||||
if ((total + len) - 28 == frameBytes) {
|
||||
int frameIndex = bb2.getInt();
|
||||
long t = System.currentTimeMillis();
|
||||
synchronized (UsbCommunication.this.condImgProcess_.cond) {
|
||||
System.arraycopy(recvbuf, 0, UsbCommunication.this.imgExchangeBuf1_, 0, recvbuf.length);
|
||||
if (MagApplication.magParameter.basePara1.devType == 0 || MagApplication.magParameter.basePara1.devType == 5 || MagApplication.magParameter.basePara1.devType == 6 || MagApplication.magParameter.basePara1.devType == 3) {
|
||||
UsbCommunication.this.fpaTemp_ = bb2.getInt();
|
||||
UsbCommunication.this.camTemp_ = UsbCommunication.this.fpaTemp_ - 500;
|
||||
drop = bb2.getInt();
|
||||
} else {
|
||||
bb2.getInt();
|
||||
drop = bb2.getInt();
|
||||
UsbCommunication.this.camTemp_ = bb2.getInt();
|
||||
UsbCommunication.this.fpaTemp_ = UsbCommunication.this.camTemp_ + 500;
|
||||
}
|
||||
if (drop == 0 || drop == 1) {
|
||||
UsbCommunication.this.condImgProcess_.notified = true;
|
||||
UsbCommunication.this.condImgProcess_.cond.notify();
|
||||
}
|
||||
}
|
||||
if (UsbCommunication.this.imgViewer_ != null && (index == 0 || !UsbCommunication.this.imgViewer_.getTempStableFlag() || UsbCommunication.this.imgViewer_.getImageStableCounter() != 0)) {
|
||||
int index2 = index + 1;
|
||||
if ((index & 15) == 0) {
|
||||
UsbCommunication.this.handler_.sendEmptyMessage(4);
|
||||
}
|
||||
index = index2;
|
||||
}
|
||||
if (MagApplication.isShowFps) {
|
||||
if (t1 != 0) {
|
||||
UsbCommunication.lock_.lock();
|
||||
UsbCommunication.ticks_[frameIndex % UsbCommunication.ticks_.length] = t - t1;
|
||||
UsbCommunication.lock_.unlock();
|
||||
}
|
||||
t1 = t;
|
||||
}
|
||||
}
|
||||
headerFound = false;
|
||||
total = 0;
|
||||
} else {
|
||||
total += len;
|
||||
}
|
||||
} else {
|
||||
total += len;
|
||||
}
|
||||
if (total > frameBytes) {
|
||||
headerFound = false;
|
||||
total = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Logging.trace("Leave ThreadImgReceiver");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getReceivedFps() {
|
||||
long[] ticks = new long[ticks_.length];
|
||||
lock_.lock();
|
||||
System.arraycopy(ticks_, 0, ticks, 0, ticks_.length);
|
||||
lock_.unlock();
|
||||
int sum = 0;
|
||||
for (int i = ticks.length - 1; i != -1; i--) {
|
||||
sum = (int) (sum + ticks[i]);
|
||||
}
|
||||
return (ticks_.length * 1000) / sum;
|
||||
}
|
||||
|
||||
private class ThreadImgProcess extends Thread {
|
||||
private ThreadImgProcess() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
int fpaTemp;
|
||||
int camTemp;
|
||||
Logging.trace("Enter ThreadImgProcess");
|
||||
int frameBytes = ((MagApplication.magParameter.basePara1.fpaWidth * MagApplication.magParameter.basePara1.fpaHeight) * 16) / 8;
|
||||
byte[] imgExchangeBuf2 = new byte[frameBytes + 1024];
|
||||
while (!UsbCommunication.this.isExitThreadImgProcess_) {
|
||||
synchronized (UsbCommunication.this.condImgProcess_.cond) {
|
||||
while (!UsbCommunication.this.condImgProcess_.notified) {
|
||||
try {
|
||||
UsbCommunication.this.condImgProcess_.cond.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
UsbCommunication.this.condImgProcess_.notified = false;
|
||||
if (imgExchangeBuf2 == null) {
|
||||
imgExchangeBuf2 = new byte[UsbCommunication.this.imgExchangeBuf1_.length];
|
||||
}
|
||||
System.arraycopy(UsbCommunication.this.imgExchangeBuf1_, 0, imgExchangeBuf2, 0, UsbCommunication.this.imgExchangeBuf1_.length);
|
||||
fpaTemp = UsbCommunication.this.fpaTemp_ + MagApplication.magParameter.basePara2.fpaTempFix;
|
||||
camTemp = UsbCommunication.this.camTemp_ + MagApplication.magParameter.basePara2.fpaTempFix;
|
||||
}
|
||||
DeviceController.Lock();
|
||||
boolean ret = DeviceController.pushFrame(imgExchangeBuf2, fpaTemp, camTemp);
|
||||
DeviceController.Unlock();
|
||||
if (UsbCommunication.this.isExitThreadImgProcess_) {
|
||||
break;
|
||||
} else if (ret && UsbCommunication.this.imgViewer_ != null) {
|
||||
UsbCommunication.this.imgViewer_.onNewFrameReceived(fpaTemp, camTemp);
|
||||
}
|
||||
}
|
||||
Logging.trace("Leave ThreadImgProcess");
|
||||
}
|
||||
}
|
||||
|
||||
private class ThreadCaliRecv extends Thread {
|
||||
private ThreadCaliRecv() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
Logging.trace("Enter ThreadRemoteFileReceiver");
|
||||
byte[] recvbuf = new byte[16384];
|
||||
int totalSize = 0;
|
||||
FileOutputStream out = null;
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(0, 0));
|
||||
long t1 = System.currentTimeMillis();
|
||||
while (true) {
|
||||
if (UsbCommunication.this.isExitCaliRecvThread) {
|
||||
break;
|
||||
}
|
||||
int remain = MagApplication.magParameter.caliInfo.size - totalSize;
|
||||
UsbCommunication usbCommunication = UsbCommunication.this;
|
||||
if (remain > 16384) {
|
||||
remain = recvbuf.length;
|
||||
}
|
||||
int len = usbCommunication.recvCali(recvbuf, 0, remain, UsbCommunication.TIMEOUT);
|
||||
if (len >= 0 && !UsbCommunication.this.caliPathName_.isEmpty()) {
|
||||
if (UsbCommunication.this.isToRecvFirstCaliPacket_) {
|
||||
totalSize = 0;
|
||||
UsbCommunication.this.isToRecvFirstCaliPacket_ = false;
|
||||
}
|
||||
if (totalSize == 0) {
|
||||
try {
|
||||
FileOutputStream out2 = new FileOutputStream(UsbCommunication.this.caliPathName_);
|
||||
out = out2;
|
||||
} catch (Exception e) {
|
||||
Logging.error("Receive remote file error 1.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
}
|
||||
totalSize += len;
|
||||
if (totalSize > MagApplication.magParameter.caliInfo.size) {
|
||||
try {
|
||||
out.close();
|
||||
Logging.error("Receive remote file error 3.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
break;
|
||||
} catch (Exception e2) {
|
||||
Logging.error("Receive remote file error 2.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
out.write(recvbuf, 0, len);
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(2, 0, (totalSize * 100) / MagApplication.magParameter.caliInfo.size));
|
||||
if (totalSize == MagApplication.magParameter.caliInfo.size) {
|
||||
try {
|
||||
out.close();
|
||||
Logging.info("Receive remote file succ.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(1, 0));
|
||||
if (!UsbCommunication.this.startTransfer(UsbCommunication.this.caliPathName_)) {
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
Logging.error("SDK start fail.");
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
Logging.error("Receive remote file error 5.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
Logging.error("Receive remote file error 4.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
}
|
||||
} else if (System.currentTimeMillis() - t1 > Config.BPLUS_DELAY_TIME) {
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
Logging.trace("Leave ThreadRemoteFileReceiver");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import cn.com.magnity.magnitycx.FragmentMainCenter;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UsbConnection extends Observable<DelegateDeviceConnected> {
|
||||
private static final String ACTION_USB_PERMISSION = "cn.com.magnity.magnitycx.USB_PERMISSION";
|
||||
private static UsbConnection instance_ = new UsbConnection();
|
||||
private FragmentMainCenter fragmentMainCenter_;
|
||||
private PhoneReceiver phoneReceiver_;
|
||||
private UsbCommunication usbComm_;
|
||||
private UsbConnectionReceiver usbConnectionReceiver_;
|
||||
private UsbPermissionReceiver usbPermissionReceiver_;
|
||||
private Context context_ = MagApplication.getInstance();
|
||||
private UsbManager usbManager_ = (UsbManager) this.context_.getSystemService("usb");
|
||||
|
||||
public static UsbConnection getInstance() {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
private UsbConnection() {
|
||||
}
|
||||
|
||||
public void setCallbackReceiver(FragmentMainCenter fragment) {
|
||||
this.fragmentMainCenter_ = fragment;
|
||||
if (this.usbComm_ != null) {
|
||||
this.usbComm_.setCallbackReceiver(fragment);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean init() {
|
||||
if (this.phoneReceiver_ == null) {
|
||||
registerPhoneReceiver();
|
||||
}
|
||||
if (this.usbConnectionReceiver_ == null) {
|
||||
registerConnectionReceiver();
|
||||
}
|
||||
UsbDevice device = findDevice(33596, 1);
|
||||
if (device != null) {
|
||||
requestDevicePermission(device);
|
||||
}
|
||||
return device != null;
|
||||
}
|
||||
|
||||
public void deinit(boolean notifyUi) {
|
||||
if (this.usbConnectionReceiver_ != null) {
|
||||
this.context_.unregisterReceiver(this.usbConnectionReceiver_);
|
||||
this.usbConnectionReceiver_ = null;
|
||||
}
|
||||
if (this.usbPermissionReceiver_ != null) {
|
||||
this.context_.unregisterReceiver(this.usbPermissionReceiver_);
|
||||
this.usbPermissionReceiver_ = null;
|
||||
}
|
||||
disconnect(notifyUi);
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return this.usbComm_ != null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean connect(UsbDevice device) {
|
||||
if (this.usbComm_ != null) {
|
||||
return true;
|
||||
}
|
||||
Logging.info("Try to connect to device");
|
||||
try {
|
||||
this.usbComm_ = new UsbCommunication(this, this.usbManager_, device, this.fragmentMainCenter_);
|
||||
int ret = this.usbComm_.connect();
|
||||
if (ret == -1) {
|
||||
Logging.error("Fail to connect to device, do clean work now");
|
||||
this.usbComm_.disconnect();
|
||||
this.usbComm_ = null;
|
||||
return false;
|
||||
}
|
||||
if (ret == 0) {
|
||||
return false;
|
||||
}
|
||||
notifyObervers(1);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
Logging.warn("Exception when connecting to device (" + ex.getMessage() + ")");
|
||||
if (this.usbComm_ != null) {
|
||||
this.usbComm_.disconnect();
|
||||
}
|
||||
this.usbComm_ = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyObervers(int status) {
|
||||
synchronized (this.observers_) {
|
||||
if (status == 1) {
|
||||
for (int i = this.observers_.size() - 1; i != -1; i--) {
|
||||
((DelegateDeviceConnected) this.observers_.get(i)).onDeviceConnected(this.usbComm_);
|
||||
}
|
||||
} else if (status == 2) {
|
||||
for (int i2 = this.observers_.size() - 1; i2 != -1; i2--) {
|
||||
}
|
||||
} else if (status == 0) {
|
||||
for (int i3 = this.observers_.size() - 1; i3 != -1; i3--) {
|
||||
((DelegateDeviceConnected) this.observers_.get(i3)).onDeviceDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void disconnect(boolean notifyUi) {
|
||||
Logging.info("Try to disconnect to device");
|
||||
if (this.usbComm_ != null) {
|
||||
this.usbComm_.disconnect();
|
||||
this.usbComm_ = null;
|
||||
}
|
||||
if (notifyUi) {
|
||||
notifyObervers(0);
|
||||
}
|
||||
}
|
||||
|
||||
private UsbDevice findDevice(int vendorId, int productId) {
|
||||
for (UsbDevice device : this.usbManager_.getDeviceList().values()) {
|
||||
if (device.getVendorId() == vendorId && device.getProductId() == productId) {
|
||||
return device;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void registerConnectionReceiver() {
|
||||
this.usbConnectionReceiver_ = new UsbConnectionReceiver();
|
||||
IntentFilter localFilter = new IntentFilter();
|
||||
localFilter.addAction("android.hardware.usb.action.USB_DEVICE_ATTACHED");
|
||||
localFilter.addAction("android.hardware.usb.action.USB_DEVICE_DETACHED");
|
||||
this.context_.registerReceiver(this.usbConnectionReceiver_, localFilter);
|
||||
}
|
||||
|
||||
private void registerPhoneReceiver() {
|
||||
this.phoneReceiver_ = new PhoneReceiver();
|
||||
IntentFilter localFilter = new IntentFilter();
|
||||
localFilter.addAction("android.intent.action.NEW_OUTGOING_CALL");
|
||||
localFilter.addAction("android.intent.action.PHONE_STATE");
|
||||
this.context_.registerReceiver(this.phoneReceiver_, localFilter);
|
||||
}
|
||||
|
||||
private void requestDevicePermission(UsbDevice device) {
|
||||
if (this.usbManager_.hasPermission(device)) {
|
||||
Logging.trace("Already has permission");
|
||||
connect(device);
|
||||
return;
|
||||
}
|
||||
if (this.usbPermissionReceiver_ == null) {
|
||||
this.usbPermissionReceiver_ = new UsbPermissionReceiver();
|
||||
IntentFilter localFilter = new IntentFilter(ACTION_USB_PERMISSION);
|
||||
this.context_.registerReceiver(this.usbPermissionReceiver_, localFilter);
|
||||
}
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context_, 0, new Intent(ACTION_USB_PERMISSION), 0);
|
||||
this.usbManager_.requestPermission(device, pendingIntent);
|
||||
Logging.trace("Request permission");
|
||||
}
|
||||
|
||||
private final class UsbConnectionReceiver extends BroadcastReceiver {
|
||||
private UsbConnectionReceiver() {
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "android.hardware.usb.action.USB_DEVICE_ATTACHED":
|
||||
Logging.trace("Broadcast for usb attached received");
|
||||
UsbConnection.this.disconnect(false);
|
||||
UsbConnection.this.init();
|
||||
break;
|
||||
case "android.hardware.usb.action.USB_DEVICE_DETACHED":
|
||||
Logging.trace("Broadcast for usb detached received");
|
||||
UsbConnection.this.disconnect(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class UsbPermissionReceiver extends BroadcastReceiver {
|
||||
private UsbPermissionReceiver() {
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "cn.com.magnity.magnitycx.USB_PERMISSION":
|
||||
Logging.trace("Broadcast for usb permission received");
|
||||
if (!intent.getBooleanExtra("permission", false)) {
|
||||
Logging.warn("Permission rejected by user");
|
||||
break;
|
||||
} else {
|
||||
UsbDevice device = (UsbDevice) intent.getParcelableExtra("device");
|
||||
if (device != null) {
|
||||
UsbConnection.this.connect(device);
|
||||
UsbConnection.this.context_.unregisterReceiver(UsbConnection.this.usbPermissionReceiver_);
|
||||
UsbConnection.this.usbPermissionReceiver_ = null;
|
||||
break;
|
||||
} else {
|
||||
Logging.warn("Failed to get device");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PhoneReceiver extends BroadcastReceiver {
|
||||
private PhoneReceiver() {
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "android.intent.action.PHONE_STATE":
|
||||
if (MagApplication.magParameter.basePara1.swVersion > 100) {
|
||||
String state = intent.getStringExtra("state");
|
||||
if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)) {
|
||||
Logging.trace("ring");
|
||||
UsbConnection.this.deinit(true);
|
||||
break;
|
||||
} else if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)) {
|
||||
Logging.trace("hang up");
|
||||
UsbConnection.this.init();
|
||||
break;
|
||||
} else if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
|
||||
Logging.trace("hang on");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.hardware.Camera;
|
||||
import android.view.SurfaceHolder;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VisibleCamera {
|
||||
private static Camera camera_;
|
||||
private static boolean isPreview_;
|
||||
|
||||
public static void initCamera(int id, SurfaceHolder surfaceHolder, int size) {
|
||||
if (Camera.getNumberOfCameras() >= 1) {
|
||||
if (!isPreview_) {
|
||||
camera_ = Camera.open(id);
|
||||
setPreviewOrientation(id);
|
||||
}
|
||||
if (camera_ != null && !isPreview_) {
|
||||
try {
|
||||
Camera.Parameters parameters = camera_.getParameters();
|
||||
setPreviewSize(parameters, size);
|
||||
parameters.setPictureFormat(256);
|
||||
parameters.set("jpeg-quality", 85);
|
||||
parameters.setFlashMode("auto");
|
||||
parameters.setFocusMode("continuous-picture");
|
||||
camera_.setParameters(parameters);
|
||||
camera_.setPreviewDisplay(surfaceHolder);
|
||||
camera_.startPreview();
|
||||
camera_.cancelAutoFocus();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
isPreview_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deinitCamera() {
|
||||
if (camera_ != null) {
|
||||
if (isPreview_) {
|
||||
camera_.stopPreview();
|
||||
isPreview_ = false;
|
||||
}
|
||||
camera_.release();
|
||||
camera_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPreviewSize(Camera.Parameters parameters, int size) {
|
||||
List<Camera.Size> list = parameters.getSupportedPreviewSizes();
|
||||
int num = list.size();
|
||||
for (int i = 0; i < num; i++) {
|
||||
Camera.Size s = list.get(i);
|
||||
if ((s.width <= s.height || s.width * 3 == s.height * 4) && ((s.width >= s.height || s.width * 4 == s.height * 3) && Math.min(s.width, s.height) >= size)) {
|
||||
parameters.setPreviewSize(s.width, s.height);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPreviewOrientation(int id) {
|
||||
int result;
|
||||
if (camera_ != null) {
|
||||
Camera.CameraInfo info = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(id, info);
|
||||
int rotation = MagApplication.windowManager.getDefaultDisplay().getRotation();
|
||||
int degrees = 0;
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
degrees = 0;
|
||||
break;
|
||||
case 1:
|
||||
degrees = 90;
|
||||
break;
|
||||
case 2:
|
||||
degrees = 180;
|
||||
break;
|
||||
case 3:
|
||||
degrees = 270;
|
||||
break;
|
||||
}
|
||||
if (info.facing == 1) {
|
||||
int result2 = (info.orientation + degrees) % 360;
|
||||
result = (360 - result2) % 360;
|
||||
} else {
|
||||
result = ((info.orientation - degrees) + 360) % 360;
|
||||
}
|
||||
camera_.setDisplayOrientation(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCameraPermission() {
|
||||
if (camera_ != null) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
Camera.open().release();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.hardware.Camera;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import android.view.SurfaceHolder;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VisibleCameraHelper {
|
||||
private static volatile VisibleCameraHelper instance_;
|
||||
private Camera camera_;
|
||||
private final CameraSizeComparator sizeComparator = new CameraSizeComparator();
|
||||
private Camera.PictureCallback jpegCallback = new Camera.PictureCallback() { // from class: cn.com.magnity.magnitycx.sdk.VisibleCameraHelper.1
|
||||
@Override // android.hardware.Camera.PictureCallback
|
||||
public void onPictureTaken(byte[] data, Camera camera) {
|
||||
try {
|
||||
Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||
File myCaptureFile = new File(MagApplication.magParameter.mediaDir, "1.jpg");
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
|
||||
bm.compress(Bitmap.CompressFormat.JPEG, 100, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
camera.stopPreview();
|
||||
camera.startPreview();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public int getOrientation(Context context, Uri photoUri) {
|
||||
Cursor cursor = context.getContentResolver().query(photoUri, new String[]{"_id", "orientation"}, null, null, null);
|
||||
if (cursor == null) {
|
||||
return 0;
|
||||
}
|
||||
cursor.moveToFirst();
|
||||
int i = cursor.getInt(cursor.getColumnIndexOrThrow("orientation"));
|
||||
cursor.close();
|
||||
return i;
|
||||
}
|
||||
|
||||
public int getExifOrientation(String filepath) {
|
||||
int orientation;
|
||||
ExifInterface exif = null;
|
||||
try {
|
||||
ExifInterface exif2 = new ExifInterface(filepath);
|
||||
exif = exif2;
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (exif == null || (orientation = exif.getAttributeInt("Orientation", -1)) == -1) {
|
||||
return 0;
|
||||
}
|
||||
switch (orientation) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static VisibleCameraHelper getInstance() {
|
||||
if (instance_ == null) {
|
||||
synchronized (VisibleCameraHelper.class) {
|
||||
if (instance_ == null) {
|
||||
instance_ = new VisibleCameraHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
public boolean openCamera(int id) {
|
||||
if (Camera.getNumberOfCameras() < 1) {
|
||||
return false;
|
||||
}
|
||||
if (this.camera_ != null) {
|
||||
stopPreview();
|
||||
closeCamera();
|
||||
}
|
||||
try {
|
||||
this.camera_ = Camera.open(id);
|
||||
return this.camera_ != null;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeCamera() {
|
||||
if (this.camera_ != null) {
|
||||
this.camera_.release();
|
||||
this.camera_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Size setPreviewSize(int expectedWidth, float rate) {
|
||||
Camera.Parameters parameters;
|
||||
if (this.camera_ == null || (parameters = this.camera_.getParameters()) == null) {
|
||||
return null;
|
||||
}
|
||||
List<Camera.Size> list = parameters.getSupportedPreviewSizes();
|
||||
Collections.sort(list, this.sizeComparator);
|
||||
Camera.Size size = null;
|
||||
int num = list.size();
|
||||
int i = 0;
|
||||
while (i < num) {
|
||||
Camera.Size size2 = list.get(i);
|
||||
size = size2;
|
||||
if (size.width > expectedWidth && equalRate(size, rate)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (i == num) {
|
||||
return null;
|
||||
}
|
||||
parameters.setPreviewSize(size.width, size.height);
|
||||
this.camera_.setParameters(parameters);
|
||||
return new Size(size.width, size.height);
|
||||
}
|
||||
|
||||
public Size setPictureSize(int expectedWidth, float rate) {
|
||||
Camera.Parameters parameters;
|
||||
if (this.camera_ == null || (parameters = this.camera_.getParameters()) == null) {
|
||||
return null;
|
||||
}
|
||||
List<Camera.Size> list = parameters.getSupportedPictureSizes();
|
||||
Collections.sort(list, this.sizeComparator);
|
||||
Camera.Size size = null;
|
||||
int num = list.size();
|
||||
int i = 0;
|
||||
while (i < num) {
|
||||
Camera.Size size2 = list.get(i);
|
||||
size = size2;
|
||||
if (size.width > expectedWidth && equalRate(size, rate)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (i == num) {
|
||||
return null;
|
||||
}
|
||||
parameters.setPictureSize(size.width, size.height);
|
||||
this.camera_.setParameters(parameters);
|
||||
return new Size(size.width, size.height);
|
||||
}
|
||||
|
||||
private boolean equalRate(Camera.Size s, float rate) {
|
||||
float r = s.width / s.height;
|
||||
return ((double) Math.abs(r - rate)) <= 0.1d;
|
||||
}
|
||||
|
||||
public boolean startPreview(SurfaceHolder holder, int flashMode) {
|
||||
String mode;
|
||||
if (this.camera_ == null) {
|
||||
return false;
|
||||
}
|
||||
stopPreview();
|
||||
try {
|
||||
this.camera_.setPreviewDisplay(holder);
|
||||
Camera.Parameters parameters = this.camera_.getParameters();
|
||||
if (parameters != null) {
|
||||
switch (flashMode) {
|
||||
case 0:
|
||||
mode = "off";
|
||||
break;
|
||||
case 1:
|
||||
mode = "auto";
|
||||
break;
|
||||
case 2:
|
||||
mode = "on";
|
||||
break;
|
||||
case 3:
|
||||
mode = "red-eye";
|
||||
break;
|
||||
case 4:
|
||||
mode = "torch";
|
||||
break;
|
||||
default:
|
||||
mode = "off";
|
||||
break;
|
||||
}
|
||||
parameters.setFlashMode(mode);
|
||||
this.camera_.setParameters(parameters);
|
||||
}
|
||||
this.camera_.startPreview();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopPreview() {
|
||||
if (this.camera_ != null) {
|
||||
this.camera_.stopPreview();
|
||||
}
|
||||
}
|
||||
|
||||
public int setPreviewOrientation(int cameraId) {
|
||||
int result;
|
||||
if (this.camera_ == null) {
|
||||
return 0;
|
||||
}
|
||||
Camera.CameraInfo info = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(cameraId, info);
|
||||
int rotation = MagApplication.windowManager.getDefaultDisplay().getRotation();
|
||||
int degrees = 0;
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
degrees = 0;
|
||||
break;
|
||||
case 1:
|
||||
degrees = 90;
|
||||
break;
|
||||
case 2:
|
||||
degrees = 180;
|
||||
break;
|
||||
case 3:
|
||||
degrees = 270;
|
||||
break;
|
||||
}
|
||||
if (info.facing == 1) {
|
||||
int result2 = (info.orientation + degrees) % 360;
|
||||
result = (360 - result2) % 360;
|
||||
} else {
|
||||
result = ((info.orientation - degrees) + 360) % 360;
|
||||
}
|
||||
this.camera_.setDisplayOrientation(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void takePicture() {
|
||||
if (this.camera_ != null) {
|
||||
this.camera_.takePicture(null, null, this.jpegCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private class CameraSizeComparator implements Comparator<Camera.Size> {
|
||||
private CameraSizeComparator() {
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Camera.Size lhs, Camera.Size rhs) {
|
||||
if (lhs.width == rhs.width) {
|
||||
return 0;
|
||||
}
|
||||
if (lhs.width > rhs.width) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public class Size {
|
||||
private int height_;
|
||||
private int width_;
|
||||
|
||||
public Size() {
|
||||
}
|
||||
|
||||
public Size(int width, int height) {
|
||||
this.width_ = width;
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width_ = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width_;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class WaitCondition {
|
||||
public final Object cond = new Object();
|
||||
public volatile boolean notified = false;
|
||||
}
|
||||
Reference in New Issue
Block a user