|
|
|
@ -33,6 +33,7 @@ import android.os.Bundle;
|
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.method.ArrowKeyMovementMethod;
|
|
|
|
|
import android.text.method.ScrollingMovementMethod;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.Display;
|
|
|
|
@ -40,6 +41,7 @@ import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
import android.view.WindowManager;
|
|
|
|
|
import android.widget.SpinnerAdapter;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
@ -67,7 +69,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ActivityMainBinding binding;
|
|
|
|
|
private int defaultDataSubId;
|
|
|
|
|
|
|
|
|
|
private Handler mHandler = null;
|
|
|
|
|
private Messenger mMessenger = null;
|
|
|
|
@ -117,8 +118,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
|
|
|
|
setContentView(binding.getRoot());
|
|
|
|
|
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
|
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
|
|
|
|
// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
|
|
|
|
|
|
|
|
|
ActionBar actionBar = getSupportActionBar();
|
|
|
|
|
|
|
|
|
@ -131,11 +131,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
binding.logs.setText("");
|
|
|
|
|
binding.logs.setMovementMethod(ScrollingMovementMethod.getInstance());
|
|
|
|
|
binding.logs.setScrollbarFadingEnabled(false);
|
|
|
|
|
// binding.logs.setMaxLines(16);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// binding.protocol.item
|
|
|
|
|
// Context appContext = getApplicationContext();
|
|
|
|
|
|
|
|
|
|
mHandler = new Handler(Looper.myLooper()) {
|
|
|
|
|
@Override
|
|
|
|
@ -191,11 +186,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
};
|
|
|
|
|
// mMessenger = new Messenger(new Handler());
|
|
|
|
|
|
|
|
|
|
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
|
|
|
|
Display defaultDisplay = windowManager.getDefaultDisplay();
|
|
|
|
|
int width = defaultDisplay.getWidth();
|
|
|
|
|
int height = defaultDisplay.getHeight();
|
|
|
|
|
|
|
|
|
|
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
|
|
|
|
StrictMode.setThreadPolicy(policy);
|
|
|
|
|
|
|
|
|
@ -208,11 +198,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "MainActivity: reboot=" + rebootFlag + " noDelay=" + noDelay);
|
|
|
|
|
|
|
|
|
|
String cmdid = "";
|
|
|
|
|
String server = "";
|
|
|
|
|
Integer port = new Integer(6891);
|
|
|
|
|
Integer protocol = new Integer(MicroPhotoContext.DEFAULT_PROTOCOL); // 0xFF00
|
|
|
|
|
|
|
|
|
|
MicroPhotoContext.AppConfig appConfig = getAppConfig();
|
|
|
|
|
binding.cmdid.setText(appConfig.cmdid);
|
|
|
|
|
binding.server.setText(appConfig.server);
|
|
|
|
@ -316,14 +301,15 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
|
|
defaultDataSubId = getDefaultDataSubId();
|
|
|
|
|
System.out.println(defaultDataSubId);
|
|
|
|
|
// defaultDataSubId = getDefaultDataSubId();
|
|
|
|
|
// System.out.println(defaultDataSubId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
binding.simchange2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
/*
|
|
|
|
|
if (defaultDataSubId == 0) {
|
|
|
|
|
setDefaultDataSubId(1);
|
|
|
|
|
} else {
|
|
|
|
@ -333,7 +319,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
setDefaultDataSubId(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -422,41 +408,11 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
binding.video.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
//方法1
|
|
|
|
|
|
|
|
|
|
// mediaRecorder = new MediaRecorder();
|
|
|
|
|
//
|
|
|
|
|
// //设置视频和音频的来源
|
|
|
|
|
// mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
|
|
|
|
|
// mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
|
|
|
|
|
// //
|
|
|
|
|
// mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
|
|
|
|
|
// //设置录制视频的编码格式
|
|
|
|
|
// mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
|
|
|
|
|
// //设置音频的编码格式
|
|
|
|
|
// mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB);
|
|
|
|
|
// //设置视频的帧率:每秒切换图片的次数
|
|
|
|
|
// mediaRecorder.setVideoFrameRate(20);
|
|
|
|
|
// //视频的分辨率
|
|
|
|
|
// mediaRecorder.setVideoSize(176, 144);
|
|
|
|
|
//
|
|
|
|
|
//// mediaRecorder.setPreviewDisplay(surfaceView.getHolder().getSurface());
|
|
|
|
|
//
|
|
|
|
|
// mediaRecorder.setOutputFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/111.mp4");
|
|
|
|
|
// try {
|
|
|
|
|
// mediaRecorder.prepare();
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// // TODO Auto-generated catch block
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// mediaRecorder.start();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
binding.video2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
// mediaRecorder.stop();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -636,109 +592,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String buildPhotoDir(int channel) {
|
|
|
|
|
File path = new File(Environment.getExternalStorageDirectory(), "com.xinyingpower.com/photos/");
|
|
|
|
|
|
|
|
|
|
if (!path.exists() && !path.mkdirs()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String p = path.getAbsolutePath();
|
|
|
|
|
if (!p.endsWith(File.separator)) {
|
|
|
|
|
p += File.separator;
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String buildPhotoFileName(int channel, int preset) {
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyymmddhhmmss");
|
|
|
|
|
String date = dateFormat.format(new Date());
|
|
|
|
|
String photoFile = "img_" + Integer.toString(channel) + "_" + Integer.toHexString(preset).toUpperCase() + "_" + date + ".jpg";
|
|
|
|
|
return photoFile;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void takePhoto(int aa) {
|
|
|
|
|
|
|
|
|
|
System.out.println("Preparing to take photo");
|
|
|
|
|
Camera camera = null;
|
|
|
|
|
|
|
|
|
|
int cameraCount = 0;
|
|
|
|
|
|
|
|
|
|
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
|
|
|
|
|
cameraCount = Camera.getNumberOfCameras();
|
|
|
|
|
for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
|
|
|
|
|
SystemClock.sleep(1000);
|
|
|
|
|
|
|
|
|
|
Camera.getCameraInfo(camIdx, cameraInfo);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
camera = Camera.open(camIdx);
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
System.out.println("Camera not available: " + camIdx);
|
|
|
|
|
camera = null;
|
|
|
|
|
//e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
if (null == camera) {
|
|
|
|
|
System.out.println("Could not get camera instance");
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("Got the camera, creating the dummy surface texture");
|
|
|
|
|
//SurfaceTexture dummySurfaceTextureF = new SurfaceTexture(0);
|
|
|
|
|
try {
|
|
|
|
|
//camera.setPreviewTexture(dummySurfaceTextureF);
|
|
|
|
|
camera.setPreviewTexture(new SurfaceTexture(0));
|
|
|
|
|
camera.startPreview();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.out.println("Could not set the surface preview texture");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
camera.takePicture(null, null, new Camera.PictureCallback() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPictureTaken(byte[] data, Camera camera) {
|
|
|
|
|
|
|
|
|
|
File path = getApplicationContext().getFilesDir();
|
|
|
|
|
// String appPath = path.getAbsolutePath();
|
|
|
|
|
|
|
|
|
|
File pictureFileDir = path;
|
|
|
|
|
if (!pictureFileDir.exists() && !pictureFileDir.mkdirs()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyymmddhhmmss");
|
|
|
|
|
String date = dateFormat.format(new Date());
|
|
|
|
|
String photoFile = "PictureFront_" + "_" + date + ".jpg";
|
|
|
|
|
String filename = pictureFileDir.getPath() + File.separator + photoFile;
|
|
|
|
|
File mainPicture = new File(filename);
|
|
|
|
|
// addImageFile(mainPicture);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
FileOutputStream fos = new FileOutputStream(mainPicture);
|
|
|
|
|
fos.write(data);
|
|
|
|
|
fos.close();
|
|
|
|
|
System.out.println("image saved");
|
|
|
|
|
} catch (Exception error) {
|
|
|
|
|
System.out.println("Image could not be saved");
|
|
|
|
|
}
|
|
|
|
|
camera.release();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
camera.release();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A native method that is implemented by the 'microphoto' native library,
|
|
|
|
|
* which is packaged with this application.
|
|
|
|
|
*/
|
|
|
|
|
public native String stringFromJNI();
|
|
|
|
|
|
|
|
|
|
public native boolean takePhoto(int channel, int preset, String path, String fileName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|