Commit 10faab3d92b6e4863b79684065fc63a3351a77ab

Authored by 杨帅
1 parent 47d2a0ae

1 修改计步相关逻辑

config.gradle
@@ -21,7 +21,7 @@ ext { @@ -21,7 +21,7 @@ ext {
21 //编译方式 21 //编译方式
22 debug : false, 22 debug : false,
23 //版本号 23 //版本号
24 - version: "0.5.8", 24 + version: "0.5.9",
25 //Lib库前缀 25 //Lib库前缀
26 packeg : "com.cnlive.module", 26 packeg : "com.cnlive.module",
27 //Lib库名称 27 //Lib库名称
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
@@ -565,6 +565,7 @@ public class CollStepService extends Service implements SensorEventListener { @@ -565,6 +565,7 @@ public class CollStepService extends Service implements SensorEventListener {
565 } 565 }
566 566
567 private void updateNotification() { 567 private void updateNotification() {
  568 + save();
568 // Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP); 569 // Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP);
569 EventBus.getDefault().post(new MessageEvent(Constant.COLL_SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP)); 570 EventBus.getDefault().post(new MessageEvent(Constant.COLL_SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP));
570 updateSpeedStepFlag = false; 571 updateSpeedStepFlag = false;
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
@@ -38,7 +38,7 @@ public class Constant { @@ -38,7 +38,7 @@ public class Constant {
38 public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围 38 public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围
39 public static final int LOCA_ACCURACY = 20;//定位过滤精度 39 public static final int LOCA_ACCURACY = 20;//定位过滤精度
40 public static final int LOCA_END_POINT_ACCURACY = 20;//终点位置比较精度 40 public static final int LOCA_END_POINT_ACCURACY = 20;//终点位置比较精度
41 - public static final int LOCA_START_POINT_ACCURACY = 200;//起点位置比较精度 41 + public static final int LOCA_START_POINT_ACCURACY = 20;//起点位置比较精度
42 public static final int FENCE_OFFSET = 70;//围栏偏离距离 42 public static final int FENCE_OFFSET = 70;//围栏偏离距离
43 public static final int FENCE_DENOISE = 70;//围栏去噪精度 43 public static final int FENCE_DENOISE = 70;//围栏去噪精度
44 public static final int TAKE_POINT_MAX_SIZE = 100;//最大打点数量 44 public static final int TAKE_POINT_MAX_SIZE = 100;//最大打点数量
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
@@ -108,23 +108,23 @@ public class StepService extends Service implements SensorEventListener { @@ -108,23 +108,23 @@ public class StepService extends Service implements SensorEventListener {
108 /** 108 /**
109 * 当前所走的步数 109 * 当前所走的步数
110 */ 110 */
111 - private int CURRENT_STEP = 0; 111 + private int CURRENT_STEP = 0;
112 /** 112 /**
113 * 计步传感器类型 Sensor.TYPE_STEP_COUNTER或者Sensor.TYPE_STEP_DETECTOR 113 * 计步传感器类型 Sensor.TYPE_STEP_COUNTER或者Sensor.TYPE_STEP_DETECTOR
114 */ 114 */
115 - private static int stepSensorType = -1; 115 + private int stepSensorType = -1;
116 /** 116 /**
117 * 每次第一次启动记步服务时是否从系统中获取了已有的步数记录 117 * 每次第一次启动记步服务时是否从系统中获取了已有的步数记录
118 */ 118 */
119 - private boolean hasRecord = false; 119 + private boolean hasRecord = false;
120 /** 120 /**
121 * 系统中获取到的已有的步数 121 * 系统中获取到的已有的步数
122 */ 122 */
123 - private int hasStepCount = 0; 123 + private int hasStepCount = 0;
124 /** 124 /**
125 * 上一次的步数 125 * 上一次的步数
126 */ 126 */
127 - private int previousStepCount = 0; 127 + private int previousStepCount = 0;
128 /** 128 /**
129 * 加速度传感器中获取的步数 129 * 加速度传感器中获取的步数
130 */ 130 */
@@ -644,11 +644,11 @@ public class StepService extends Service implements SensorEventListener { @@ -644,11 +644,11 @@ public class StepService extends Service implements SensorEventListener {
644 handler.removeCallbacks(speedRunnable); 644 handler.removeCallbacks(speedRunnable);
645 } 645 }
646 // Log.e("杀死", "MyTestService"); 646 // Log.e("杀死", "MyTestService");
647 - lastStep = 0;  
648 - hasStepCount = 0;  
649 - hasRecord = false;  
650 - CURRENT_STEP = 0;  
651 - previousStepCount = 0; 647 +// lastStep = 0;
  648 +// hasStepCount = 0;
  649 +// hasRecord = false;
  650 +// CURRENT_STEP = 0;
  651 +// previousStepCount = 0;
652 if (sensorManager != null) { 652 if (sensorManager != null) {
653 sensorManager.unregisterListener(StepService.this); 653 sensorManager.unregisterListener(StepService.this);
654 sensorManager = null; 654 sensorManager = null;
@@ -737,6 +737,7 @@ public class StepService extends Service implements SensorEventListener { @@ -737,6 +737,7 @@ public class StepService extends Service implements SensorEventListener {
737 } 737 }
738 738
739 private void updateNotification() { 739 private void updateNotification() {
  740 + save();
740 // Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP); 741 // Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP);
741 EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP)); 742 EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP));
742 updateSpeedStepFlag = false; 743 updateSpeedStepFlag = false;
@@ -1052,12 +1053,12 @@ public class StepService extends Service implements SensorEventListener { @@ -1052,12 +1053,12 @@ public class StepService extends Service implements SensorEventListener {
1052 //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数 1053 //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数
1053 // Log.e(TAG, "tempStep: " + tempStep + ",hasStepCount:" + hasStepCount); 1054 // Log.e(TAG, "tempStep: " + tempStep + ",hasStepCount:" + hasStepCount);
1054 int thisStepCount = tempStep - hasStepCount; 1055 int thisStepCount = tempStep - hasStepCount;
1055 -// Log.e(TAG, "onSensorChanged: thisStepCount" + thisStepCount); 1056 + Log.e(TAG, "onSensorChanged: thisStepCount" + thisStepCount);
1056 //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数) 1057 //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数)
1057 int thisStep = thisStepCount - previousStepCount; 1058 int thisStep = thisStepCount - previousStepCount;
1058 //记录最后一次APP打开到现在的总步数 1059 //记录最后一次APP打开到现在的总步数
1059 previousStepCount = thisStepCount; 1060 previousStepCount = thisStepCount;
1060 -// Log.e(TAG, "本次有效步数: thisStep" + thisStep + ",previousStepCount:" + previousStepCount); 1061 + Log.e(TAG, "本次有效步数: thisStep" + thisStep + ",previousStepCount:" + previousStepCount);
1061 //当用户点击暂停了 1062 //当用户点击暂停了
1062 if (pauseFlag) { 1063 if (pauseFlag) {
1063 thisStep = 0; 1064 thisStep = 0;