|
|
@ -85,14 +85,15 @@ public class MicroPhotoService extends Service {
|
|
|
|
// public static final int NOTIFICATION_ID_FOREGROUND_SERVICE = 0;
|
|
|
|
// public static final int NOTIFICATION_ID_FOREGROUND_SERVICE = 0;
|
|
|
|
public static final String ACTION_MSG_BROADCAST = "ACT_MSG_BROADCAST";
|
|
|
|
public static final String ACTION_MSG_BROADCAST = "ACT_MSG_BROADCAST";
|
|
|
|
|
|
|
|
|
|
|
|
public static final String ACTION_START = "ACT_START";
|
|
|
|
public static final String ACTION_START = "com.xypower.mpapp.ACT_START";
|
|
|
|
public static final String ACTION_STOP = "ACT_STOP";
|
|
|
|
public static final String ACTION_STOP = "com.xypower.mpapp.ACT_STOP";
|
|
|
|
public static final String ACTION_MAIN = "ACT_MAIN";
|
|
|
|
public static final String ACTION_MAIN = "com.xypower.mpapp.ACT_MAIN";
|
|
|
|
private static final String ACTION_HEARTBEAT = "ACT_HB";
|
|
|
|
private static final String ACTION_HEARTBEAT = "com.xypower.mpapp.ACT_HB";
|
|
|
|
private static final String ACTION_TAKE_PHOTO = "ACT_TP";
|
|
|
|
private static final String ACTION_TAKE_PHOTO = "com.xypower.mpapp.ACT_TP";
|
|
|
|
private static final String ACTION_TAKE_PHOTO_MANUALLY = "ACT_TP_M";
|
|
|
|
private static final String ACTION_TAKE_PHOTO_MANUALLY = "com.xypower.mpapp.ACT_TP_M";
|
|
|
|
private static final String ACTION_HEARTBEAT_MANUALLY = "ACT_HB_M";
|
|
|
|
private static final String ACTION_HEARTBEAT_MANUALLY = "com.xypower.mpapp.ACT_HB_M";
|
|
|
|
private static final String ACTION_TIMEOUT = "ACT_TIMEOUT";
|
|
|
|
private static final String ACTION_TIMEOUT = "com.xypower.mpapp.ACT_TIMEOUT";
|
|
|
|
|
|
|
|
public static final String ACTION_VIDEO_FINISHED = "com.xypower.mpapp.ACT_V_FINISHED";
|
|
|
|
private static final String EXTRA_PARAM_CHANNEL = "Channel";
|
|
|
|
private static final String EXTRA_PARAM_CHANNEL = "Channel";
|
|
|
|
private static final String EXTRA_PARAM_PRESET = "Preset";
|
|
|
|
private static final String EXTRA_PARAM_PRESET = "Preset";
|
|
|
|
private static final String EXTRA_PARAM_PHOTO_OR_VIDEO = "PhotoOrVideo";
|
|
|
|
private static final String EXTRA_PARAM_PHOTO_OR_VIDEO = "PhotoOrVideo";
|
|
|
@ -161,6 +162,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
intentFilter.addAction(ACTION_TAKE_PHOTO_MANUALLY);
|
|
|
|
intentFilter.addAction(ACTION_TAKE_PHOTO_MANUALLY);
|
|
|
|
intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
intentFilter.addAction(ACTION_MSG_BROADCAST);
|
|
|
|
intentFilter.addAction(ACTION_MSG_BROADCAST);
|
|
|
|
|
|
|
|
intentFilter.addAction(ACTION_VIDEO_FINISHED);
|
|
|
|
registerReceiver(mAlarmReceiver, intentFilter);
|
|
|
|
registerReceiver(mAlarmReceiver, intentFilter);
|
|
|
|
|
|
|
|
|
|
|
|
// IntentFilter intentFilter2 = new IntentFilter(ACTION_MSG_BROADCAST);
|
|
|
|
// IntentFilter intentFilter2 = new IntentFilter(ACTION_MSG_BROADCAST);
|
|
|
@ -281,9 +283,10 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
|
|
int channel = (int) ((val & 0xFF0000L) >> 16);
|
|
|
|
int channel = (int) ((val & 0xFF0000L) >> 16);
|
|
|
|
int preset = (int) ((val & 0xFF00L) >> 8);
|
|
|
|
int preset = (int) ((val & 0xFF00L) >> 8);
|
|
|
|
|
|
|
|
boolean photoOrVideo = ((val & 0xFFL) == 0);
|
|
|
|
|
|
|
|
|
|
|
|
Log.i(TAG, "PhotoTimer Fired: CH=" + channel + " PR=" + preset);
|
|
|
|
Log.i(TAG, "PhotoTimer Fired: CH=" + channel + " PR=" + preset);
|
|
|
|
mService.notifyToTakePhoto(mService.mNativeHandle, channel, preset, ts, true);
|
|
|
|
mService.notifyToTakePhoto(mService.mNativeHandle, channel, preset, ts, photoOrVideo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -340,6 +343,13 @@ public class MicroPhotoService extends Service {
|
|
|
|
if (what == MSG_WHAT_SENDING_HB) {
|
|
|
|
if (what == MSG_WHAT_SENDING_HB) {
|
|
|
|
mService.sendHeartbeat(mService.mNativeHandle);
|
|
|
|
mService.sendHeartbeat(mService.mNativeHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (TextUtils.equals(ACTION_VIDEO_FINISHED, action)) {
|
|
|
|
|
|
|
|
boolean result = intent.getBooleanExtra("result", false);
|
|
|
|
|
|
|
|
String path = intent.getStringExtra("path");
|
|
|
|
|
|
|
|
long videoId = intent.getLongExtra("videoId", 0);
|
|
|
|
|
|
|
|
Log.i(TAG, "Recording received(" + Long.toString(videoId) + "):" + path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mService.recordingFinished(mService.mNativeHandle, result, path, videoId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -397,6 +407,20 @@ public class MicroPhotoService extends Service {
|
|
|
|
registerPhotoTimer(this.getApplicationContext(), channel, preset, ts, timeout, schedules);
|
|
|
|
registerPhotoTimer(this.getApplicationContext(), channel, preset, ts, timeout, schedules);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void startRecording(int cameraId, long videoId, int duration, int width, int height, int quality) {
|
|
|
|
|
|
|
|
Context context = getApplicationContext();
|
|
|
|
|
|
|
|
Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.xypower.mvapp");
|
|
|
|
|
|
|
|
intent.putExtra("cameraId", cameraId);
|
|
|
|
|
|
|
|
intent.putExtra("videoId", videoId);
|
|
|
|
|
|
|
|
intent.putExtra("duration", duration);
|
|
|
|
|
|
|
|
intent.putExtra("width", width);
|
|
|
|
|
|
|
|
intent.putExtra("height", height);
|
|
|
|
|
|
|
|
intent.putExtra("quality", quality);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
|
|
|
|
context.startActivity(intent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// private HashMap<Long, Integer> mTimers = new HashMap<Long, Integer>();
|
|
|
|
// private HashMap<Long, Integer> mTimers = new HashMap<Long, Integer>();
|
|
|
|
public boolean registerTimer(long uid, int timeout, long times) {
|
|
|
|
public boolean registerTimer(long uid, int timeout, long times) {
|
|
|
|
|
|
|
|
|
|
|
@ -536,6 +560,8 @@ public class MicroPhotoService extends Service {
|
|
|
|
long val = 0;
|
|
|
|
long val = 0;
|
|
|
|
val |= ((long)channel << 16);
|
|
|
|
val |= ((long)channel << 16);
|
|
|
|
val |= ((long)preset << 8);
|
|
|
|
val |= ((long)preset << 8);
|
|
|
|
|
|
|
|
val |= photoOrVideo ? 0L : 1L;
|
|
|
|
|
|
|
|
|
|
|
|
schedules.add(Long.valueOf(val));
|
|
|
|
schedules.add(Long.valueOf(val));
|
|
|
|
|
|
|
|
|
|
|
|
registerPhotoTimer(context, channel, preset, 0, 0, schedules);
|
|
|
|
registerPhotoTimer(context, channel, preset, 0, 0, schedules);
|
|
|
@ -997,12 +1023,12 @@ cellSignalStrengthGsm.getDbm();
|
|
|
|
protected native long getHeartbeatDuration(long handler);
|
|
|
|
protected native long getHeartbeatDuration(long handler);
|
|
|
|
protected native long[] getPhotoTimeData(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, boolean sendToCma);
|
|
|
|
protected native boolean notifyToTakePhoto(long handler, int channel, int preset, long scheduleTime, boolean photoOrVideo);
|
|
|
|
protected native boolean sendHeartbeat(long handler);
|
|
|
|
protected native boolean sendHeartbeat(long handler);
|
|
|
|
protected native boolean fireTimeout(long handler, long uid, long times);
|
|
|
|
protected native boolean fireTimeout(long handler, long uid, long times);
|
|
|
|
protected native void updatePosition(long handler, double lon, double lat, long ts);
|
|
|
|
protected native void updatePosition(long handler, double lon, double lat, long ts);
|
|
|
|
protected native boolean uninit(long handler);
|
|
|
|
protected native boolean uninit(long handler);
|
|
|
|
|
|
|
|
protected native void recordingFinished(long handler, boolean result, String path, long videoId);
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////GPS////////////////////
|
|
|
|
////////////////////////GPS////////////////////
|
|
|
|
private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER;
|
|
|
|
private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER;
|
|
|
|