|
@@ -21,6 +21,7 @@ import android.os.Handler;
|
|
|
import android.os.IBinder;
|
|
|
import android.os.Message;
|
|
|
import android.os.RemoteException;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.widget.Toast;
|
|
|
|
|
@@ -43,6 +44,8 @@ import java.util.Locale;
|
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
+import retrofit2.http.POST;
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -112,14 +115,34 @@ public class ReportService extends Service {
|
|
|
public void onCreate() {
|
|
|
|
|
|
super.onCreate();
|
|
|
+ initLocationManager();
|
|
|
+
|
|
|
|
|
|
executor = new ScheduledThreadPoolExecutor(1);
|
|
|
executor.scheduleAtFixedRate(() -> {
|
|
|
startForeground(NOTICE_ID, new Notification());
|
|
|
|
|
|
- Post();
|
|
|
- }, 0, 1, TimeUnit.MINUTES);
|
|
|
- initLocationManager();
|
|
|
+ if (locationManager != null && locationProvider != null && locationProvider != "") {
|
|
|
+ @SuppressLint("MissingPermission")
|
|
|
+ Location location = locationManager.getLastKnownLocation(locationProvider);
|
|
|
+
|
|
|
+ if (location != null) {
|
|
|
+ reportData.setLat(location.getLatitude() + "");
|
|
|
+ reportData.setLng(location.getLongitude() + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ GPSPost();
|
|
|
+ }, 0, 5, TimeUnit.SECONDS);
|
|
|
startAlarmService();
|
|
|
}
|
|
|
|
|
@@ -157,38 +180,18 @@ public class ReportService extends Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 采集手环数据
|
|
|
+ */
|
|
|
public static void Post() {
|
|
|
-
|
|
|
RestService.Post(reportData);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ * 采集手机数据
|
|
|
+ */
|
|
|
+ public static void GPSPost() {
|
|
|
+ RestService.GPSPost(reportData);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -634,14 +637,13 @@ public class ReportService extends Service {
|
|
|
@Override
|
|
|
public void onGetCurSportData(int type, long timestamp, int step, int distance,
|
|
|
int cal, int cursleeptime, int totalrunningtime, int steptime) throws RemoteException {
|
|
|
- Date date = new Date(timestamp * 1000);
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
|
|
- String time = sdf.format(date);
|
|
|
- showToast("onGetCurSportData", "type : " + type + " , time :" + time + " , step: " + step + ", distance :" + distance + ", cal :" + cal + ", cursleeptime :" + cursleeptime + ", totalrunningtime:" + totalrunningtime);
|
|
|
-
|
|
|
- if (reportData != null && step > 0)
|
|
|
- reportData.setBs(step + "");
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -750,59 +752,18 @@ public class ReportService extends Service {
|
|
|
public void onReceiveSensorData(int arg0, int arg1, int arg2, int arg3, int arg4) throws RemoteException {
|
|
|
|
|
|
Log.e("=========", "result:" + arg0 + " , " + arg1 + " , " + arg2 + " , " + arg3 + " , " + arg4);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- long ts = new Date().getTime();
|
|
|
- if (arg0 > 0) {
|
|
|
+
|
|
|
+ if (arg0 > 0 && arg1 > 0 && arg2 > 0 && arg3 > 0 && arg4 > 0){
|
|
|
reportData.setXtpl(arg0 + "");
|
|
|
- }
|
|
|
-
|
|
|
- if (arg1 > 0) {
|
|
|
reportData.setSzxy(arg1 + "");
|
|
|
- }
|
|
|
-
|
|
|
- if (arg2 > 0) {
|
|
|
reportData.setSsxy(arg2 + "");
|
|
|
- }
|
|
|
-
|
|
|
- if (arg3 > 0) {
|
|
|
reportData.setXynd(arg3 + "");
|
|
|
- }
|
|
|
-
|
|
|
- if (arg4 > 0) {
|
|
|
reportData.setPld(arg4 + "");
|
|
|
- }
|
|
|
-
|
|
|
- if (locationManager != null && locationProvider != null && locationProvider != "") {
|
|
|
- @SuppressLint("MissingPermission")
|
|
|
- Location location = locationManager.getLastKnownLocation(locationProvider);
|
|
|
|
|
|
- if (location != null) {
|
|
|
- reportData.setLat(location.getLatitude() + "");
|
|
|
- reportData.setLng(location.getLongitude() + "");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (mService != null) {
|
|
|
- try {
|
|
|
- int step = mService.getCurSportData();
|
|
|
- if (step > 0)
|
|
|
- reportData.setBs(step + "");
|
|
|
- } catch (RemoteException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ Post();
|
|
|
+ if (restBinder != null){
|
|
|
+ Log.e("=========", "回调关闭");
|
|
|
+ restBinder.callRemoteOpenBlood(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -884,7 +845,7 @@ public class ReportService extends Service {
|
|
|
Intent intent = new Intent();
|
|
|
intent.setAction("action.STARTEARTBEATTEST");
|
|
|
pendingIntent = PendingIntent.getBroadcast(this, 100, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
|
- alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 5000, 60000, pendingIntent);
|
|
|
+ alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 0, 5 * 60 * 1000, pendingIntent);
|
|
|
|
|
|
showToast("AlarmBroadcastReceiver", "报警服务start!!!!!");
|
|
|
|