Commit eb4271eb90f57f950dc145bebbcaa14de2b12be9

Authored by YangShuai
1 parent 51a32df2

1 修复vivo手机步数暴增的问题

config.gradle
@@ -21,7 +21,7 @@ ext { @@ -21,7 +21,7 @@ ext {
21 //编译方式 21 //编译方式
22 debug : false, 22 debug : false,
23 //版本号 23 //版本号
24 - version: "1.0.14-beta1", 24 + version: "1.0.14-beta2",
25 //Lib库前缀 25 //Lib库前缀
26 packeg : "com.cnlive.module", 26 packeg : "com.cnlive.module",
27 //Lib库名称 27 //Lib库名称
gradle.properties
@@ -13,4 +13,5 @@ org.gradle.jvmargs=-Xmx1536m @@ -13,4 +13,5 @@ org.gradle.jvmargs=-Xmx1536m
13 # org.gradle.parallel=true 13 # org.gradle.parallel=true
14 #android.useAndroidX=true 14 #android.useAndroidX=true
15 #android.enableJetifier=true 15 #android.enableJetifier=true
  16 +android.injected.testOnly=false
16 17
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
@@ -57,7 +57,7 @@ import java.util.Date; @@ -57,7 +57,7 @@ import java.util.Date;
57 57
58 public class CollStepService extends Service implements SensorEventListener { 58 public class CollStepService extends Service implements SensorEventListener {
59 59
60 - private String TAG = "StepService"; 60 + private String TAG = "CollStepService";
61 /** 61 /**
62 * 通知栏相关 62 * 通知栏相关
63 */ 63 */
@@ -819,17 +819,17 @@ public class CollStepService extends Service implements SensorEventListener { @@ -819,17 +819,17 @@ public class CollStepService extends Service implements SensorEventListener {
819 private void addCountStepListener() { 819 private void addCountStepListener() {
820 if (sensorManager == null) return; 820 if (sensorManager == null) return;
821 Sensor countSensor = null; 821 Sensor countSensor = null;
822 - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {  
823 - countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER,true);  
824 - }else {  
825 - countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);  
826 - } 822 +// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
  823 +// countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER,true);
  824 +// }else {
  825 + countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
  826 +// }
827 Sensor detectorSensor = null; 827 Sensor detectorSensor = null;
828 - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {  
829 - detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR,true);  
830 - }else {  
831 - detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);  
832 - } 828 +// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
  829 +// detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR,true);
  830 +// }else {
  831 + detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
  832 +// }
833 if (countSensor != null) { 833 if (countSensor != null) {
834 stepSensorType = Sensor.TYPE_STEP_COUNTER; 834 stepSensorType = Sensor.TYPE_STEP_COUNTER;
835 Log.v(TAG, "Sensor.TYPE_STEP_COUNTER"); 835 Log.v(TAG, "Sensor.TYPE_STEP_COUNTER");
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
@@ -48,6 +48,7 @@ public class Constant { @@ -48,6 +48,7 @@ public class Constant {
48 public static final int COLL_GEORESULT_RADIUS = 20;//打点逆地理半径 48 public static final int COLL_GEORESULT_RADIUS = 20;//打点逆地理半径
49 public static final int WEBVIEW_FONT_SIZE = 40;//webview显示的网页文字大小 49 public static final int WEBVIEW_FONT_SIZE = 40;//webview显示的网页文字大小
50 public static final int Need_ZOOM_IN_RADUIS = 100;//需要扩大精度范围 50 public static final int Need_ZOOM_IN_RADUIS = 100;//需要扩大精度范围
51 - public static final int MINI_USER_STEP_COUNT = 100;//用户必须走的最小步数 51 +// public static final int MINI_USER_STEP_COUNT = 100;//用户必须走的最小步数
  52 + public static final int MINI_USER_STEP_COUNT = -1;//用户必须走的最小步数
52 53
53 } 54 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
@@ -1009,17 +1009,17 @@ public class StepService extends Service implements SensorEventListener { @@ -1009,17 +1009,17 @@ public class StepService extends Service implements SensorEventListener {
1009 private void addCountStepListener() { 1009 private void addCountStepListener() {
1010 if (sensorManager == null) return; 1010 if (sensorManager == null) return;
1011 Sensor countSensor = null; 1011 Sensor countSensor = null;
1012 - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {  
1013 - countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER, true);  
1014 - } else { 1012 +// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
  1013 +// countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER, true);
  1014 +// } else {
1015 countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER); 1015 countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
1016 - } 1016 +// }
1017 Sensor detectorSensor = null; 1017 Sensor detectorSensor = null;
1018 - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {  
1019 - detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR, true);  
1020 - } else { 1018 +// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
  1019 +// detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR, true);
  1020 +// } else {
1021 detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR); 1021 detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
1022 - } 1022 +// }
1023 if (countSensor != null) { 1023 if (countSensor != null) {
1024 stepSensorType = Sensor.TYPE_STEP_COUNTER; 1024 stepSensorType = Sensor.TYPE_STEP_COUNTER;
1025 Log.v(TAG, "Sensor.TYPE_STEP_COUNTER"); 1025 Log.v(TAG, "Sensor.TYPE_STEP_COUNTER");
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/ChineseToSpeechUtil.java
@@ -11,7 +11,6 @@ public class ChineseToSpeechUtil { @@ -11,7 +11,6 @@ public class ChineseToSpeechUtil {
11 11
12 12
13 public static synchronized void speech(Context context, String text) { 13 public static synchronized void speech(Context context, String text) {
14 - destroy();  
15 if (textToSpeech == null) { 14 if (textToSpeech == null) {
16 textToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() { 15 textToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
17 @Override 16 @Override
@@ -31,19 +30,18 @@ public class ChineseToSpeechUtil { @@ -31,19 +30,18 @@ public class ChineseToSpeechUtil {
31 } 30 }
32 } 31 }
33 }); 32 });
34 - }else { 33 + } else {
35 textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null); 34 textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null);
36 } 35 }
37 36
38 37
39 -  
40 } 38 }
41 39
42 public static void destroy() { 40 public static void destroy() {
43 if (textToSpeech != null) { 41 if (textToSpeech != null) {
44 textToSpeech.stop(); 42 textToSpeech.stop();
45 textToSpeech.shutdown(); 43 textToSpeech.shutdown();
46 - textToSpeech=null; 44 + textToSpeech = null;
47 } 45 }
48 } 46 }
49 47