|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
package com.xypower.mpapp;
|
|
|
|
|
|
|
|
|
|
import static java.lang.System.err;
|
|
|
|
|
import static java.lang.System.loadLibrary;
|
|
|
|
|
|
|
|
|
|
import android.app.AlarmManager;
|
|
|
|
@ -229,6 +228,8 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
// Environment.getExternalStoragePublicDirectory(String)
|
|
|
|
|
|
|
|
|
|
// registerHeartbeatTimer(getHeartbeatDuration());
|
|
|
|
|
|
|
|
|
|
requestPosition();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroy() {
|
|
|
|
@ -705,6 +706,15 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
long startTime = (date.getTime() + 999) / 1000;
|
|
|
|
|
service.updateCaptureSchedule(startTime);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Location location = mLocationManager.getLastKnownLocation(mLocateType);
|
|
|
|
|
if (location != null) {
|
|
|
|
|
service.updatePosition(service.mNativeHandle, location.getLongitude(), location.getLatitude(), location.getAccuracy(), location.getTime() / 1000);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -890,21 +900,23 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
if (mLocationManager == null) {
|
|
|
|
|
mLocationManager = (LocationManager) getSystemService (Context.LOCATION_SERVICE);
|
|
|
|
|
|
|
|
|
|
if (!mLocationManager.isProviderEnabled(GPS_LOCATION_NAME)) {
|
|
|
|
|
if (!mLocationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mLocateType = mLocationManager.GPS_PROVIDER;
|
|
|
|
|
// Set Listener
|
|
|
|
|
mLocationManager.requestLocationUpdates(mLocateType, 100,0, mLocationListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Location location = mLocationManager.getLastKnownLocation(mLocateType);
|
|
|
|
|
if (location != null) {
|
|
|
|
|
updatePosition(mNativeHandle, location.getLongitude(), location.getLatitude(), location.getTime());
|
|
|
|
|
if (location != null && mNativeHandle != 0) {
|
|
|
|
|
updatePosition(mNativeHandle, location.getLongitude(), location.getLatitude(), location.getAccuracy(), location.getTime() / 1000);
|
|
|
|
|
}
|
|
|
|
|
// Set Listener
|
|
|
|
|
mLocationManager.requestLocationUpdates(mLocateType, 100,0, locationListener);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} catch (SecurityException ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
@ -944,6 +956,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
try {
|
|
|
|
|
final TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
SignalStrength ss = telephonyManager.getSignalStrength();
|
|
|
|
|
|
|
|
|
|
if (ss != null) {
|
|
|
|
|
return ss.getLevel();
|
|
|
|
|
}
|
|
|
|
@ -1095,7 +1108,7 @@ cellSignalStrengthGsm.getDbm();
|
|
|
|
|
protected native boolean notifyToTakePhoto(long handler, int channel, int preset, long scheduleTime, boolean photoOrVideo);
|
|
|
|
|
protected native boolean sendHeartbeat(long handler, int signalLevel);
|
|
|
|
|
protected native boolean reloadConfigs(long handler);
|
|
|
|
|
protected native void updatePosition(long handler, double lon, double lat, long ts);
|
|
|
|
|
protected native void updatePosition(long handler, double lon, double lat, double radius, long ts);
|
|
|
|
|
protected native boolean uninit(long handler);
|
|
|
|
|
protected native void recordingFinished(long handler, boolean result, String path, long videoId);
|
|
|
|
|
public static native void setOtgState(boolean enabled);
|
|
|
|
@ -1103,19 +1116,18 @@ cellSignalStrengthGsm.getDbm();
|
|
|
|
|
public static native String getSerialNumber();
|
|
|
|
|
|
|
|
|
|
////////////////////////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;
|
|
|
|
|
private LocationManager mLocationManager;
|
|
|
|
|
private String mLocateType;
|
|
|
|
|
|
|
|
|
|
private LocationListener locationListener = new LocationListener() {
|
|
|
|
|
private LocationListener mLocationListener = new LocationListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLocationChanged(Location location) {
|
|
|
|
|
updatePosition(mNativeHandle, location.getLongitude(), location.getLatitude(), location.getTime());
|
|
|
|
|
// Log.i(TAG, "Time: " + location.getTime());
|
|
|
|
|
// Log.i(TAG, "经度:" + location.getLongitude());
|
|
|
|
|
// Log.i(TAG, "纬度:" + location.getLatitude());
|
|
|
|
|
// Log.i(TAG, "海拔:" + location.getAltitude());
|
|
|
|
|
if (mNativeHandle != 0) {
|
|
|
|
|
updatePosition(mNativeHandle, location.getLongitude(), location.getLatitude(), location.getAccuracy(), location.getTime() / 1000);
|
|
|
|
|
}
|
|
|
|
|
Log.i(TAG, "Time:" + location.getTime() + " Lon=" + location.getLongitude() + "Lat=" + location.getLatitude() + "Alt=" + location.getAltitude());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|