|
|
|
@ -16,6 +16,7 @@ import android.net.ConnectivityManager;
|
|
|
|
|
import android.net.NetworkInfo;
|
|
|
|
|
import android.os.Environment;
|
|
|
|
|
import android.os.IBinder;
|
|
|
|
|
import android.os.PowerManager;
|
|
|
|
|
import android.os.SystemClock;
|
|
|
|
|
|
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
@ -35,8 +36,6 @@ import android.util.Log;
|
|
|
|
|
import android.widget.RemoteViews;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.dowse.camera.client.DSCameraManager;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
@ -44,6 +43,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -87,23 +87,6 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
private final static String FOREGROUND_CHANNEL_ID = "foreground_channel_id";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
|
|
|
|
|
|
|
|
|
|
public static final int SIGNAL_STRENGTH_POOR = 1;
|
|
|
|
|
|
|
|
|
|
public static final int SIGNAL_STRENGTH_MODERATE = 2;
|
|
|
|
|
|
|
|
|
|
public static final int SIGNAL_STRENGTH_GOOD = 3;
|
|
|
|
|
|
|
|
|
|
public static final int SIGNAL_STRENGTH_GREAT = 4;
|
|
|
|
|
|
|
|
|
|
public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
|
|
|
|
|
|
|
|
|
|
//无 ,低劣的 ,适度的 ,好 ,优异的
|
|
|
|
|
public static final String[] SIGNAL_STRENGTH_NAMES = {
|
|
|
|
|
"none", "poor", "moderate", "good", "great"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static class STATE_SERVICE {
|
|
|
|
|
public static final int CONNECTED = 10;
|
|
|
|
|
public static final int NOT_CONNECTED = 0;
|
|
|
|
@ -111,6 +94,10 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
private NotificationManager mNotificationManager;
|
|
|
|
|
|
|
|
|
|
private PowerManager.WakeLock wakeLock = null;
|
|
|
|
|
|
|
|
|
|
private Map<String, PowerManager.WakeLock> mWakeLocks = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
private int mHeartbeatDuration = 0; // 5m: 5 * 60 * 1000
|
|
|
|
|
private long mNextHeartbeatTime = 0;
|
|
|
|
|
|
|
|
|
@ -130,10 +117,15 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
public void onCreate() {
|
|
|
|
|
super.onCreate();
|
|
|
|
|
|
|
|
|
|
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
|
|
|
|
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
|
|
|
|
"MicroPhoto::MyWakelockTag");
|
|
|
|
|
wakeLock.acquire();
|
|
|
|
|
|
|
|
|
|
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
|
|
|
|
stateService = STATE_SERVICE.NOT_CONNECTED;
|
|
|
|
|
|
|
|
|
|
getPhoneState(this.getApplicationContext());
|
|
|
|
|
DeviceUtil.getPhoneState(this.getApplicationContext());
|
|
|
|
|
|
|
|
|
|
alarmReceiver = new AlarmReceiver(this);
|
|
|
|
|
// 注册广播接受者
|
|
|
|
@ -155,52 +147,15 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
// alarmManager.cancel(aci.getShowIntent());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// alarmManager.cancel();
|
|
|
|
|
|
|
|
|
|
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 = new File(Environment.getExternalStorageDirectory(), "com.xyp.mp/");
|
|
|
|
|
if (!path.exists()) {
|
|
|
|
|
path.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
// File path = getApplicationContext().getFilesDir();
|
|
|
|
|
String appPath = path.getAbsolutePath();
|
|
|
|
|
Log.i(TAG, "AppPath=" + appPath);
|
|
|
|
|
// String ip = "180.166.218.222";
|
|
|
|
|
String ip = "47.96.238.157";
|
|
|
|
|
// int port = 40032;
|
|
|
|
|
// String ip = "192.168.50.50";
|
|
|
|
|
int port = 6891;
|
|
|
|
|
String cmdid = "XY-ANDROIDSIM-003";
|
|
|
|
|
mHandler = init(appPath, ip, port, cmdid);
|
|
|
|
|
|
|
|
|
|
// registerHeartbeatTimer(getHeartbeatDuration());
|
|
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
long nowTs = date.getTime() / 1000;
|
|
|
|
|
date.setHours(0);
|
|
|
|
|
date.setMinutes(0);
|
|
|
|
|
date.setSeconds(0);
|
|
|
|
|
long startTime = date.getTime() / 1000;
|
|
|
|
|
long baseTime = nowTs - startTime;
|
|
|
|
|
|
|
|
|
|
registerCaptureSchedule(startTime, baseTime);
|
|
|
|
|
|
|
|
|
|
// registerPhotoTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
|
|
|
|
@ -210,7 +165,17 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
mHandler = 0;
|
|
|
|
|
|
|
|
|
|
unregisterReceiver(alarmReceiver);
|
|
|
|
|
DSCameraManager.getInstace().unInit();
|
|
|
|
|
|
|
|
|
|
if (wakeLock != null) {
|
|
|
|
|
wakeLock.release();
|
|
|
|
|
wakeLock = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(Map.Entry<String, PowerManager.WakeLock> entry : mWakeLocks.entrySet()) {
|
|
|
|
|
entry.getValue().release();
|
|
|
|
|
}
|
|
|
|
|
mWakeLocks.clear();
|
|
|
|
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -241,7 +206,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
int channel = (int) ((val & 0xFF0000L) >> 16);
|
|
|
|
|
int preset = (int) ((val & 0xFF00L) >> 8);
|
|
|
|
|
|
|
|
|
|
mService.notifyToTakePhoto(mService.mHandler, channel, preset, ts, mService.buildPhotoDir(channel), mService.buildPhotoFileName(channel, preset, ts), true);
|
|
|
|
|
mService.notifyToTakePhoto(mService.mHandler, channel, preset, ts, mService.buildPhotoDir(mService.getApplicationContext(), channel), mService.buildPhotoFileName(channel, preset, ts), true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -262,7 +227,8 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
boolean photoOrVideo = intent.getBooleanExtra(EXTRA_PARAM_PHOTO_OR_VIDEO, true);
|
|
|
|
|
long ts = System.currentTimeMillis() / 1000;
|
|
|
|
|
|
|
|
|
|
mService.notifyToTakePhoto(mService.mHandler, channel, preset, ts, mService.buildPhotoDir(channel), mService.buildPhotoFileName(channel, preset, ts), photoOrVideo);
|
|
|
|
|
Log.i(TAG, "Take Photo CH=" + channel + " PR=" + preset);
|
|
|
|
|
mService.notifyToTakePhoto(mService.mHandler, channel, preset, ts, mService.buildPhotoDir(mService.getApplicationContext(), channel), mService.buildPhotoFileName(channel, preset, ts), photoOrVideo);
|
|
|
|
|
} else if (TextUtils.equals(ACTION_TIMEOUT, action)) {
|
|
|
|
|
long uid = intent.getLongExtra(EXTRA_PARAM_TIMER_UID, 0);
|
|
|
|
|
Log.i(TAG, "Timeout:" + uid);
|
|
|
|
@ -431,9 +397,16 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
preset = (short) ((val & 0xFF00L) >> 8);
|
|
|
|
|
|
|
|
|
|
schedules.add(Long.valueOf(val));
|
|
|
|
|
|
|
|
|
|
Log.i(TAG, "Reg Photo Timer: CH=" + channel + " PR=" + preset);
|
|
|
|
|
} else if (ts > currentTs) {
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
channel = (short) ((val & 0xFF0000L) >> 16);
|
|
|
|
|
preset = (short) ((val & 0xFF00L) >> 8);
|
|
|
|
|
|
|
|
|
|
Log.i(TAG, "Reg Photo Timer: CH=" + channel + " PR=" + preset);
|
|
|
|
|
schedules.add(Long.valueOf(val));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -478,11 +451,33 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
Log.d(TAG, "Received user starts foreground intent");
|
|
|
|
|
startForeground(NOTIFICATION_ID_FOREGROUND_SERVICE, prepareNotification());
|
|
|
|
|
|
|
|
|
|
connect();
|
|
|
|
|
|
|
|
|
|
// File path = getApplicationContext().getFilesDir();
|
|
|
|
|
String appPath = buildAppDir(this.getApplicationContext());
|
|
|
|
|
|
|
|
|
|
String ip = intent.getStringExtra("server");
|
|
|
|
|
int port = intent.getIntExtra("port", 0);
|
|
|
|
|
String cmdid = intent.getStringExtra("cmdid");
|
|
|
|
|
|
|
|
|
|
Log.i(TAG, "AppPath=" + appPath + " Server=" + ip + ":" + port + " cmdid=" + cmdid);
|
|
|
|
|
mHandler = init(appPath, ip, port, cmdid);
|
|
|
|
|
|
|
|
|
|
// Start the locker receiver
|
|
|
|
|
|
|
|
|
|
registerReceiver(screenactionreceiver, screenactionreceiver.getFilter());
|
|
|
|
|
|
|
|
|
|
connect();
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
long nowTs = date.getTime() / 1000;
|
|
|
|
|
date.setHours(0);
|
|
|
|
|
date.setMinutes(0);
|
|
|
|
|
date.setSeconds(0);
|
|
|
|
|
long startTime = date.getTime() / 1000;
|
|
|
|
|
long baseTime = nowTs - startTime;
|
|
|
|
|
|
|
|
|
|
registerCaptureSchedule(startTime, baseTime);
|
|
|
|
|
|
|
|
|
|
// registerPhotoTimer();
|
|
|
|
|
break;
|
|
|
|
|
case ACTION_STOP:
|
|
|
|
|
unregisterReceiver(screenactionreceiver);
|
|
|
|
@ -498,6 +493,31 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
return START_NOT_STICKY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void requestWakelock(String name, long timeout) {
|
|
|
|
|
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
|
|
|
|
PowerManager.WakeLock wl = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, name);
|
|
|
|
|
PowerManager.WakeLock wl2 = null;
|
|
|
|
|
synchronized (mWakeLocks) {
|
|
|
|
|
wl2 = mWakeLocks.replace(name, wl);
|
|
|
|
|
}
|
|
|
|
|
if (wl2 != null) {
|
|
|
|
|
wl2.release();
|
|
|
|
|
}
|
|
|
|
|
if (timeout == 0) wl.acquire();
|
|
|
|
|
else wl.acquire(timeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void releaseWakelock(String name) {
|
|
|
|
|
PowerManager.WakeLock wl = null;
|
|
|
|
|
synchronized (mWakeLocks) {
|
|
|
|
|
wl = mWakeLocks.get(name);
|
|
|
|
|
mWakeLocks.remove(name);
|
|
|
|
|
}
|
|
|
|
|
if (wl != null) {
|
|
|
|
|
wl.release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void connect() {
|
|
|
|
|
// after 10 seconds its connected
|
|
|
|
|
new android.os.Handler().postDelayed(
|
|
|
|
@ -576,158 +596,56 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
return notificationBuilder.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected String getNetworkType() {
|
|
|
|
|
|
|
|
|
|
// ConnectionManager instance
|
|
|
|
|
ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
|
|
|
|
|
public String buildAppDir(Context contxt) {
|
|
|
|
|
|
|
|
|
|
// If not connected, "-" will be displayed
|
|
|
|
|
if (ni == null || !ni.isConnected()) return "";
|
|
|
|
|
File[] paths = contxt.getExternalFilesDirs(null);
|
|
|
|
|
|
|
|
|
|
// If Connected to Wifi
|
|
|
|
|
if (ni.getType() == ConnectivityManager.TYPE_WIFI) return "WIFI";
|
|
|
|
|
|
|
|
|
|
// If Connected to Mobile
|
|
|
|
|
String subTypeName = "";
|
|
|
|
|
if (ni.getType() == ConnectivityManager.TYPE_MOBILE) {
|
|
|
|
|
int subType = ni.getSubtype();
|
|
|
|
|
switch (subType) {
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_GPRS:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EDGE:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_CDMA:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_1xRTT:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_IDEN:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_GSM:
|
|
|
|
|
subTypeName = "2G";
|
|
|
|
|
break;
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_UMTS:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EVDO_0:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EVDO_A:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSPA:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EVDO_B:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EHRPD:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSPAP:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
|
|
|
|
|
subTypeName = "3G";
|
|
|
|
|
break;
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_LTE:
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_IWLAN:
|
|
|
|
|
case 19:
|
|
|
|
|
subTypeName = "4G";
|
|
|
|
|
break;
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_NR:
|
|
|
|
|
subTypeName = "5G";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
subTypeName = "";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return subTypeName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void getPhoneState(Context context) {
|
|
|
|
|
final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
PhoneStateListener MyPhoneListener = new PhoneStateListener() {
|
|
|
|
|
@Override
|
|
|
|
|
//获取对应网络的ID,这个方法在这个程序中没什么用处
|
|
|
|
|
public void onCellLocationChanged(CellLocation location) {
|
|
|
|
|
if (location instanceof GsmCellLocation) {
|
|
|
|
|
int CID = ((GsmCellLocation) location).getCid();
|
|
|
|
|
} else if (location instanceof CdmaCellLocation) {
|
|
|
|
|
int ID = ((CdmaCellLocation) location).getBaseStationId();
|
|
|
|
|
}
|
|
|
|
|
if (paths == null || paths.length == 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//系统自带的服务监听器,实时监听网络状态
|
|
|
|
|
@Override
|
|
|
|
|
public void onServiceStateChanged(ServiceState serviceState) {
|
|
|
|
|
super.onServiceStateChanged(serviceState);
|
|
|
|
|
}
|
|
|
|
|
File path = paths[0];
|
|
|
|
|
|
|
|
|
|
//这个是我们的主角,就是获取对应网络信号强度
|
|
|
|
|
@Override
|
|
|
|
|
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
|
|
|
|
|
//这个ltedbm 是4G信号的值
|
|
|
|
|
String signalinfo = signalStrength.toString();
|
|
|
|
|
String[] parts = signalinfo.split(" ");
|
|
|
|
|
String ltedbm = parts[9];
|
|
|
|
|
//这个dbm 是2G和3G信号的值
|
|
|
|
|
int asu = signalStrength.getGsmSignalStrength();
|
|
|
|
|
int dbm = -113 + 2 * asu;
|
|
|
|
|
|
|
|
|
|
if (telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE) {
|
|
|
|
|
Log.i("NetWorkUtil", "网络:LTE 信号强度:" + ltedbm + "======Detail:" + signalinfo);
|
|
|
|
|
} else if (telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_HSDPA ||
|
|
|
|
|
telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_HSPA ||
|
|
|
|
|
telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_HSUPA ||
|
|
|
|
|
telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS) {
|
|
|
|
|
String bin;
|
|
|
|
|
if (dbm > -75) {
|
|
|
|
|
bin = "网络很好";
|
|
|
|
|
} else if (dbm > -85) {
|
|
|
|
|
bin = "网络不错";
|
|
|
|
|
} else if (dbm > -95) {
|
|
|
|
|
bin = "网络还行";
|
|
|
|
|
} else if (dbm > -100) {
|
|
|
|
|
bin = "网络很差";
|
|
|
|
|
} else {
|
|
|
|
|
bin = "网络错误";
|
|
|
|
|
}
|
|
|
|
|
Log.i("NetWorkUtil", "网络:WCDMA 信号值:" + dbm + "========强度:" + bin + "======Detail:" + signalinfo);
|
|
|
|
|
} else {
|
|
|
|
|
String bin;
|
|
|
|
|
if (asu < 0 || asu >= 99) bin = "网络错误";
|
|
|
|
|
else if (asu >= 16) bin = "网络很好";
|
|
|
|
|
else if (asu >= 8) bin = "网络不错";
|
|
|
|
|
else if (asu >= 4) bin = "网络还行";
|
|
|
|
|
else bin = "网络很差";
|
|
|
|
|
Log.i("NetWorkUtil", "网络:GSM 信号值:" + dbm + "========强度:" + bin + "======Detail:" + signalinfo);
|
|
|
|
|
if (!path.exists() && !path.mkdirs()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
super.onSignalStrengthsChanged(signalStrength);
|
|
|
|
|
String p = path.getAbsolutePath();
|
|
|
|
|
if (!p.endsWith(File.separator)) {
|
|
|
|
|
p += File.separator;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
telephonyManager.listen(MyPhoneListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String buildPhotoDir(Context contxt, int channel) {
|
|
|
|
|
// File path = new File(Environment.getExternalStorageDirectory(), "com.xinyingpower.mp/photos/");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
public boolean takePhoto(short channel, short preset, String path) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean res = DSCameraManager.getInstace().takePhoto(path, channel, 0, 0);
|
|
|
|
|
String appDir = buildAppDir(contxt);
|
|
|
|
|
if (appDir == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!res) {
|
|
|
|
|
File path = new File(appDir, "photos/");
|
|
|
|
|
|
|
|
|
|
int idx = 0;
|
|
|
|
|
do {
|
|
|
|
|
res = DSCameraManager.getInstace().isCameraServiceOK();
|
|
|
|
|
if (!res)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(1000L);
|
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
// ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
if (!path.exists() && !path.mkdirs()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
} while(idx < 6);
|
|
|
|
|
|
|
|
|
|
if (DSCameraManager.getInstace().isCameraServiceOK()) {
|
|
|
|
|
res = DSCameraManager.getInstace().takePhoto(path, channel, 0, 0);
|
|
|
|
|
String p = path.getAbsolutePath();
|
|
|
|
|
if (!p.endsWith(File.separator)) {
|
|
|
|
|
p += File.separator;
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private String buildPhotoFileName(int channel, int preset, long ts) {
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
|
|
|
String photoFile = "img_" + Integer.toString(channel) + "_" + Integer.toHexString(preset).toUpperCase() + "_" + date + ".jpg";
|
|
|
|
|
return photoFile;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected boolean updateTime(long timeInMillis) {
|
|
|
|
|
public boolean updateTime(long timeInMillis) {
|
|
|
|
|
boolean res = false;
|
|
|
|
|
try {
|
|
|
|
|
// Calendar c = Calendar.getInstance();
|
|
|
|
@ -741,27 +659,6 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String buildPhotoDir(int channel) {
|
|
|
|
|
File path = new File(Environment.getExternalStorageDirectory(), "com.xyp.mp/photos/");
|
|
|
|
|
|
|
|
|
|
if (!path.exists() && !path.mkdirs()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String p = path.getAbsolutePath();
|
|
|
|
|
if (!p.endsWith(File.separator)) {
|
|
|
|
|
p += File.separator;
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String buildPhotoFileName(int channel, int preset, long ts) {
|
|
|
|
|
|
|
|
|
|
String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
|
|
|
String photoFile = "img_" + Integer.toString(channel) + "_" + Integer.toHexString(preset).toUpperCase() + "_" + date + ".jpg";
|
|
|
|
|
return photoFile;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
// for example value of first element
|
|
|
|
@ -773,7 +670,7 @@ cellSignalStrengthGsm.getDbm();
|
|
|
|
|
protected native long init(String appPath, String ip, int port, String cmdid);
|
|
|
|
|
protected native long getHeartbeatDuration(long handler);
|
|
|
|
|
protected native long[] getPhotoTimeData(long handler);
|
|
|
|
|
protected native long[] getNextScheduleItem(long handler);
|
|
|
|
|
// protected native long[] getNextScheduleItem(long handler);
|
|
|
|
|
protected native boolean notifyToTakePhoto(long handler, int channel, int preset, long scheduleTime, String path, String fileName, boolean sendToCma);
|
|
|
|
|
protected native boolean sendHeartbeat(long handler);
|
|
|
|
|
protected native boolean fireTimeout(long handler, long uid);
|
|
|
|
|