You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.5 KiB
Java
93 lines
2.5 KiB
Java
2 years ago
|
package com.xinyingpower.microphoto;
|
||
|
|
||
|
import android.app.Service;
|
||
|
import android.content.Intent;
|
||
|
import android.os.Environment;
|
||
|
import android.os.IBinder;
|
||
|
import android.util.Log;
|
||
|
|
||
|
import com.dowse.base.param.pic.ChannelPicParam;
|
||
|
import com.dowse.camera.client.DSCameraManager;
|
||
|
|
||
|
import java.io.File;
|
||
|
|
||
|
public class MicroPhotoService extends Service {
|
||
|
|
||
|
// Used to load the 'microphoto' library on application startup.
|
||
|
static {
|
||
|
System.loadLibrary("microphoto");
|
||
|
}
|
||
|
|
||
|
public MicroPhotoService() {
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public IBinder onBind(Intent intent) {
|
||
|
// TODO: Return the communication channel to the service.
|
||
|
throw new UnsupportedOperationException("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onCreate() {
|
||
|
super.onCreate();
|
||
|
|
||
|
boolean res = false;
|
||
|
res = DSCameraManager.getInstace().init();
|
||
|
ChannelPicParam picParam = new ChannelPicParam();
|
||
|
picParam.setColor(1);
|
||
|
picParam.setWidth(1920);
|
||
|
picParam.setHeight(1080);
|
||
|
picParam.setCompress_radio(40);
|
||
|
DSCameraManager.getInstace().setPicParam(1, picParam);
|
||
|
// Environment.getExternalStoragePublicDirectory(String)
|
||
|
File path = getApplicationContext().getFilesDir();
|
||
|
String appPath = path.getAbsolutePath();
|
||
|
Log.i("XYMP", "AppPath=" + appPath);
|
||
|
String ip = "180.166.218.222";
|
||
|
int port = 40032;
|
||
|
String cmdid = "XYDEV100230100012";
|
||
|
init(appPath, ip, port, cmdid);
|
||
|
}
|
||
|
|
||
|
public boolean takePhoto(short channel, short preset, String path) {
|
||
|
|
||
|
boolean res = DSCameraManager.getInstace().takePhoto(path, channel, 0, 0);
|
||
|
|
||
|
if (!res) {
|
||
|
|
||
|
int idx = 0;
|
||
|
do {
|
||
|
res = DSCameraManager.getInstace().isCameraServiceOK();
|
||
|
if (!res)
|
||
|
{
|
||
|
try {
|
||
|
Thread.sleep(1000L);
|
||
|
} catch (InterruptedException ex) {
|
||
|
// ex.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
} while(idx < 6);
|
||
|
|
||
|
if (DSCameraManager.getInstace().isCameraServiceOK()) {
|
||
|
res = DSCameraManager.getInstace().takePhoto(path, channel, 0, 0);
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public void onDestroy() {
|
||
|
uninit();
|
||
|
DSCameraManager.getInstace().unInit();
|
||
|
super.onDestroy();
|
||
|
}
|
||
|
|
||
|
protected native boolean init(String appPath, String ip, int port, String cmdid);
|
||
|
protected native boolean uninit();
|
||
|
|
||
|
protected long mHandler = 0;
|
||
|
}
|