From: snickersun Date: Thu, 30 Jul 2020 09:04:30 +0000 (+0800) Subject: 修复超过一天待机后如果重启就会清空步数问题。 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.js?a=commitdiff_plain;h=5e3f3be9b0a04694696dee5186da00cf40353d24;p=protocol_srv.git 修复超过一天待机后如果重启就会清空步数问题。 --- diff --git a/app/src/main/java/com/enqualcomm/support/Config.java b/app/src/main/java/com/enqualcomm/support/Config.java index 9f63f4ef..ba97bda3 100644 --- a/app/src/main/java/com/enqualcomm/support/Config.java +++ b/app/src/main/java/com/enqualcomm/support/Config.java @@ -307,15 +307,13 @@ public class Config { return SharPreferenceUtil.getPrefInt(context,KeyLocationMode, ICLocation.NORMAL_MOD); } - private static final String KeyBootUpDate = "bootupdate"; - private static int bootupcount=0; + private static final String KeyBootUpDate = "bootupdate"; public static boolean logBootDate(Context context){ //如果时间和最后一次时间不同,则重置,否则启动次数+1 if (isFirstBootToday(context)) { SharPreferenceUtil.setPrefString(context, KeyBootUpDate, TimeUtil.getSystemTime4()); return true; }else{ - bootupcount++; return false; } } @@ -324,6 +322,9 @@ public class Config { return SharPreferenceUtil.getPrefString(context,KeyBootUpDate,""); } private static boolean isFirstBootToday(Context context){ + //第一次启动记录的日期,当前日期只要相同,就认为有启动过。 + //如果手表一直没有重启过,则每次resetStepCount的时候把启动时间更新到当天, + //从而解决第二天重启就会被重置的问题! String currentDate=TimeUtil.getSystemTime4(); String lastDate=getLastBootupDate(context); boolean ret=false; @@ -331,7 +332,6 @@ public class Config { ret= false; }else { - bootupcount=1; ret= true; } ICLogger.i("Current BootDate="+currentDate+", Last BootDate="+lastDate+", ret="+ret); diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index d23b72fc..1418b07f 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -821,6 +821,7 @@ public class CoreService extends Service { runtime.getContextProxy().brodcastResetStepCount(runtime.getTotalStepCount()); resetStepCount(); setCleanStepCountAlarm(); + Config.logBootDate(this);//重置步数的时候,要把开机时间也更新一下,否则第二天 任意时间重启都会造成计步数据清零 return Service.START_STICKY; } else if (ACTION_HEATR_RATE_START.equals(paramIntent.getAction())) {