From: snickersun Date: Tue, 11 Aug 2020 06:36:08 +0000 (+0800) Subject: release V491 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=9bd48c1482893a5392c1a878231d7ddedbbcb978;p=protocol_srv.git release V491 Ak项目 1、SleepScore计算错误 2、去掉默认0752 SOS 3、解决旧版软件升级后数据库结构错误问题 4、每周一清除一次SleepRecordData 5、日志改为只有2个备份文件 --- diff --git a/app/release/ICSer_V490_2008102058_release.apk b/app/release/ICSer_V491_2008111430_release.apk similarity index 79% rename from app/release/ICSer_V490_2008102058_release.apk rename to app/release/ICSer_V491_2008111430_release.apk index fb3f4580..a7bdfe97 100644 Binary files a/app/release/ICSer_V490_2008102058_release.apk and b/app/release/ICSer_V491_2008111430_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index d30c5b70..373dfe72 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":490,"versionName":"2008102058","enabled":true,"outputFile":"ICSer_V490_2008102058_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V490_2008102058_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":491,"versionName":"2008111430","enabled":true,"outputFile":"ICSer_V491_2008111430_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V491_2008111430_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 86d809c6..68837ef3 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -558,14 +558,14 @@ public class CoreService extends Service { Config.setPPGTestCycle(this, 0); Config.setTemperatureTestCycle(runtime, 0); Config.setConfigInitFlag(this, 1); - int contactcount=runtime.getDbHelper().getContactCount(getContentResolver()); - ICLogger.i("=====Contact count "+contactcount); - if(contactcount==0){ //如果没有SOS - ICLogger.i("=====add SOS 07522312120 "); - ArrayList contactArray=new ArrayList(); - contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos1", "07522312120")); - runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true); - } +// int contactcount=runtime.getDbHelper().getContactCount(getContentResolver()); +// ICLogger.i("=====Contact count "+contactcount); +// if(contactcount==0){ //如果没有SOS +// ICLogger.i("=====add SOS 07522312120 "); +// ArrayList contactArray=new ArrayList(); +// contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos1", "07522312120")); +// runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true); +// } } }else{ @@ -702,7 +702,13 @@ public class CoreService extends Service { //备份DB数据到sd cache目录,为调试方便 Util.getDBFile(); +// test(); //test function + } + private void test(){ + + ICLogger.i("周一清除所有睡眠数据Record"); + runtime.getDbHelper().deleteSleepData(); } public static void DevliverStringMessage(String cmd){ @@ -772,7 +778,10 @@ public class CoreService extends Service { si.calculate_sleepInfo(runtime); runtime.getDbHelper().updateSleepInfo(si); - + if (TimeUtil.getWeek().equals("周一")){ + ICLogger.i("周一清除所有睡眠数据Record"); + runtime.getDbHelper().deleteSleepData(); + } Config.setSleepDate(this, sleepdate); Config.setSleepScore(this, si.getScore()); Random r = new Random(); diff --git a/app/src/main/java/com/enqualcomm/support/ICContentProvider.java b/app/src/main/java/com/enqualcomm/support/ICContentProvider.java index d9eb873f..7fff74d6 100644 --- a/app/src/main/java/com/enqualcomm/support/ICContentProvider.java +++ b/app/src/main/java/com/enqualcomm/support/ICContentProvider.java @@ -738,7 +738,6 @@ public class ICContentProvider extends ContentProvider { return true; } - @Nullable @Override public Cursor query(Uri paramUri, String[] columns, String paramString1, String[] paramArrayOfString2, String paramString2) { long l; diff --git a/app/src/main/java/com/enqualcomm/support/MySqlitOpenHelper.java b/app/src/main/java/com/enqualcomm/support/MySqlitOpenHelper.java index 06895d35..d948d2c4 100644 --- a/app/src/main/java/com/enqualcomm/support/MySqlitOpenHelper.java +++ b/app/src/main/java/com/enqualcomm/support/MySqlitOpenHelper.java @@ -68,8 +68,55 @@ Pushtxt、message public void onUpgrade(SQLiteDatabase sqlite, int oldDBversion, int newDBversion) { if (oldDBversion <8) { - ICLogger.i("数据库升级了"); - sqlite.execSQL("ALTER TABLE SLEEP_STATUS ADD COLUMN SLEEP_DATE"); + ICLogger.i("数据库升级 to 8 "); + sqlite.execSQL("DROP TABLE IF EXISTS MESSAGE"); + sqlite.execSQL("DROP TABLE IF EXISTS EVENT_MESSAGE"); + sqlite.execSQL("DROP TABLE IF EXISTS ANTIOFF"); + sqlite.execSQL("DROP TABLE IF EXISTS SLEEP_RECORDS"); + sqlite.execSQL("DROP TABLE IF EXISTS SLEEP_STATUS"); + sqlite.execSQL("DROP TABLE IF EXISTS SLEEP_STATUS"); + sqlite.execSQL("DROP TABLE IF EXISTS SIT"); + sqlite.execSQL("DROP TABLE IF EXISTS ALARM_MSG_RECORDS"); + /* +系统对话消息表,包含微聊,系统推送文本,上传图片,上传语音等一系列消息。 +Pushtxt、message +数据库 Message,记录所有message,包括类型(下发txt,chat msg, chat image),文件url或者文本内容。 +*/ + sqlite.execSQL("CREATE TABLE MESSAGE(_id INTEGER PRIMARY KEY AUTOINCREMENT ,CATEGORY INTEGER ,CONTENT TEXT ,PREVIEW TEXT ,STATUS INTEGER ,IN_OR_OUT INTEGER ,CONTACT_CATEGORY INTEGER ,CONTACT_NUMBER TEXT ,SERVER_TIME TEXT ,LOCAL_TIME INTEGER ,ICON TEXT)"); + //sqlite.execSQL("CREATE TABLE MESSAGE(_id INTEGER PRIMARY KEY AUTOINCREMENT ,CATEGORY INTEGER ,CONTENT TEXT ,PREVIEW TEXT ,STATUS INTEGER ,IN_OR_OUT INTEGER ,CONTACT_CATEGORY INTEGER ,CONTACT_NUMBER TEXT ,SERVER_TIME TEXT ,LOCAL_TIME INTEGER ,ICON TEXT,FILETYPE INTEGER,DATATYPE INTEGER)"); + + + +//日志表格,存储开机关机,低电报警等消息。。。 + sqlite.execSQL("CREATE TABLE EVENT_MESSAGE(_id INTEGER PRIMARY KEY AUTOINCREMENT , EVENT_TYPE INTEGER, EVENT_NAME TEXT, TIME TEXT )"); + +/* +脱腕检测时段AntiOff +本身需要时间段的,在时间段内才进行 脱腕检测。没有设置时间段的话,或者从0:00~23:59表示持续判断脱腕检测。 +2个数据库,时间段和当前状态记录(包括历史记录)。 +*/ + sqlite.execSQL("CREATE TABLE ANTIOFF(_id INTEGER PRIMARY KEY AUTOINCREMENT ,START_TIME TEXT ,END_TIME TEXT ,WEEK TEXT ,STATUS TEXT,CUR_SYS_STATUS TEXT)"); + // sqlite.execSQL("CREATE TABLE ANTIOFF_RECORDS(_id INTEGER PRIMARY KEY AUTOINCREMENT ,TIME TEXT ,STATUS TEXT,CUR_SYS_STATUS TEXT)"); + +/* +睡眠 +根据时间段进行检测,时间段内,根据翻滚次数确认其睡眠类型。如深度睡眠或者浅睡。 +2个数据库翻滚次数记录,当每日睡眠情况统计计算,检测时间段记在settings里,就不放在数据库了。 +*/ + /*每次打点的记录表*/ + sqlite.execSQL("CREATE TABLE SLEEP_RECORDS(_id INTEGER PRIMARY KEY AUTOINCREMENT ,DATE TEXT, TIME TEXT ,ROLLTIMES INTEGER ,STATUS TEXT ,REM TEXT)"); + /*计算后的分值,每天会在睡眠结束后计算Records获得*/ + sqlite.execSQL("CREATE TABLE SLEEP_STATUS(_id INTEGER PRIMARY KEY AUTOINCREMENT ,TIME TEXT , DEEP_SLEEP INTEGER , LIGHT_SLEEP INTEGER ,SCORE INTEGER )"); + +/*久坐 +根据时间段进行检测,时间段内,根据计步变化确认其是否在坐着。 +1个数据库 久坐检测时间段,报警时长度要求,报警记录*/ + sqlite.execSQL("CREATE TABLE SIT(_id INTEGER PRIMARY KEY AUTOINCREMENT ,START_TIME TEXT ,END_TIME TEXT ,WEEK TEXT ,INTERVAL INTEGER)"); + + + /*所有报警的记录表,包括开关机事件*/ + sqlite.execSQL("CREATE TABLE ALARM_MSG_RECORDS(_id INTEGER PRIMARY KEY AUTOINCREMENT ,DATE TEXT, TIME TEXT ,ALARM TEXT )"); + } } } diff --git a/app/src/main/java/com/enqualcomm/support/bean/SleepInfo.java b/app/src/main/java/com/enqualcomm/support/bean/SleepInfo.java index 9475112a..114e927f 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/SleepInfo.java +++ b/app/src/main/java/com/enqualcomm/support/bean/SleepInfo.java @@ -91,27 +91,27 @@ public class SleepInfo { turnovertime = (turnovertimesArray.get(i).stepCount - turnovertimesArray.get(i-1).stepCount); String before=turnovertimesArray.get(i-1).date; String after =turnovertimesArray.get(i).date; - ICLogger.i("diffBetween2DateInMinutes before "+before+", after "+after); + ICLogger.i("======diffBetween2DateInMinutes before "+before+", after "+after); long minutes=TimeUtil.diffBetween2DateInMinutes(before,after); if (minutes>0){ long avg_turnovertime= turnovertime/minutes; //平均每分钟翻滚次数 if ( avg_turnovertime<= DEEP_TURN_LEVEL) { //小于深度睡眠标准都属于深度睡眠 deepsleep_minutes += minutes; - ICLogger.i("深度睡眠+="+ minutes); + ICLogger.i("======深度睡眠+="+ minutes); } else if (avg_turnovertime > DEEP_TURN_LEVEL && avg_turnovertime < LIGHT_TURN_LEVEL) { //深度睡眠和浅睡标准之间属于浅睡。 lightsleep_minutes += minutes; - ICLogger.i("浅睡+="+minutes); + ICLogger.i("======浅睡+="+minutes); }else{ - ICLogger.i("未睡+="+minutes); + ICLogger.i("======未睡+="+minutes); } }else{ // - ICLogger.i("两条睡眠记录间隔小于1分钟,skip计算"); //此处可以有效解决0点 reset步数造成的计算问题。 + ICLogger.i("=====两条睡眠记录间隔小于1分钟,skip计算"); //此处可以有效解决0点 reset步数造成的计算问题。 } } } - ICLogger.i("深睡 = "+deepsleep_minutes+" , 浅睡 = "+lightsleep_minutes); + ICLogger.i("======深睡 = "+deepsleep_minutes+" , 浅睡 = "+lightsleep_minutes); Score=(int)calculateScore(deepsleep_minutes,lightsleep_minutes,runtime); } @@ -142,7 +142,8 @@ public class SleepInfo { if (sleeptime>0 && sleeptime <= 3*60) { return (sleeptime/3); }else if (sleeptime >3*60 ){ - long tmp1= 100*(deepsleep/sleeptime); //深度睡眠/睡眠时间 百分比 + long tmp1= 100*deepsleep/sleeptime; //深度睡眠/睡眠时间 百分比 + ICLogger.i("======深度睡眠/睡眠时间 百分比"+tmp1); if (tmp1 >=0 && tmp1 < 20){ return 60+tmp1; }else if (tmp1 >=21 && tmp1 < 25 ){ diff --git a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java index 69b711cb..f11fb3f7 100644 --- a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java +++ b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java @@ -264,7 +264,6 @@ public class KeepAlive extends AbstractConnectionService { Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { connection.send(protocolAPIHelper.genStringMessage("login",protocolAPIHelper.getLoginMSG(paramRuntime))); - } }); @@ -298,7 +297,6 @@ public class KeepAlive extends AbstractConnectionService { Observable.timer(1000L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { connection.send(protocolAPIHelper.genStringMessage("binding", protocolAPIHelper.getBindingMSG())); - } }); startResponseCheckTimer(); diff --git a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java index 51046c23..059ea124 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java @@ -91,12 +91,13 @@ public class BatteryUtil { mRuntime.setBatteryLow(true); if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 15%!"); - send_batterylow_event_broadcast(param1Context,1); - play_waning_notify(param1Context); - mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); - //trigger AP10 报警定位 - connection.send(protocolAPIHelper.genStringMessage("AP10",protocolAPIHelper.getWarningMSG(mRuntime))); - + if (mRuntime.isPowerConnected()==false) { + send_batterylow_event_broadcast(param1Context, 1); + play_waning_notify(param1Context); + mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); + //trigger AP10 报警定位 + connection.send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(mRuntime))); + } } else { mRuntime.setBattery(String.format("%03d",batLevel)); mRuntime.setHaveBatteryChange(true); @@ -104,12 +105,16 @@ public class BatteryUtil { if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 5% !"); - send_batterylow_event_broadcast(param1Context,1); - play_waning_notify(param1Context); - mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); - //trigger AP10 报警定位 - connection.send(protocolAPIHelper.genStringMessage("AP10",protocolAPIHelper.getWarningMSG(mRuntime))); + if (mRuntime.isPowerConnected()==false) { + send_batterylow_event_broadcast(param1Context, 1); + + play_waning_notify(param1Context); + mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); + //trigger AP10 报警定位 + connection.send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(mRuntime))); + + } } }else if (Intent.ACTION_BATTERY_LOW.equals(intent.getAction())) { diff --git a/app/src/main/java/com/enqualcomm/support/utils/DBHelper.java b/app/src/main/java/com/enqualcomm/support/utils/DBHelper.java index 65655918..1dd63830 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/DBHelper.java +++ b/app/src/main/java/com/enqualcomm/support/utils/DBHelper.java @@ -990,7 +990,10 @@ public class DBHelper { } return 0; } - + public int deleteSleepData(){ + this.cr.delete(ICContentProvider.SLEEP_RECORDS_URI, (String)null, (String[])null); + return 0; + } public void insertEventMsg(String dateyyyyMMddHHmmss,int event_type,String event_name){ //日志表格,存储开机关机,低电报警等消息。。。 // sqlite.execSQL("CREATE TABLE EVENT_MESSAGE(_id INTEGER PRIMARY KEY AUTOINCREMENT , EVENT_TYPE INTEGER, EVENT_NAME TEXT, TIME TEXT )"); diff --git a/app/src/main/java/com/enqualcomm/support/utils/ICLogger.java b/app/src/main/java/com/enqualcomm/support/utils/ICLogger.java index d755ccbc..bffab824 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/ICLogger.java +++ b/app/src/main/java/com/enqualcomm/support/utils/ICLogger.java @@ -197,7 +197,7 @@ public class ICLogger { return null; } rollingFileAppender.setName(name); - rollingFileAppender.setMaxBackupIndex(3); //最多3个备份文件 + rollingFileAppender.setMaxBackupIndex(2); //最多3个备份文件 rollingFileAppender.setMaximumFileSize(10*1024*1024); //10M 大小 rollingFileAppender.setImmediateFlush(true); diff --git a/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java b/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java index 66a2031a..a8e8866b 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java @@ -63,7 +63,44 @@ public class TimeUtil { // String str2 = df2.format(date1); } - + /** + * 根据当前日期获得是星期几 + * + * @return + */ + public static String getWeek() { + String time =getSystemTime4(); + String Week = ""; + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + Calendar c = Calendar.getInstance(); + try { + c.setTime(format.parse(time)); + } catch (ParseException e) { + e.printStackTrace(); + } + if (c.get(Calendar.DAY_OF_WEEK) == 1) { + Week += "周天"; + } + if (c.get(Calendar.DAY_OF_WEEK) == 2) { + Week += "周一"; + } + if (c.get(Calendar.DAY_OF_WEEK) == 3) { + Week += "周二"; + } + if (c.get(Calendar.DAY_OF_WEEK) == 4) { + Week += "周三"; + } + if (c.get(Calendar.DAY_OF_WEEK) == 5) { + Week += "周四"; + } + if (c.get(Calendar.DAY_OF_WEEK) == 6) { + Week += "周五"; + } + if (c.get(Calendar.DAY_OF_WEEK) == 7) { + Week += "周六"; + } + return Week; + } /* 返回 2位年2位月2位日, 如2019-12-30 返回 191230*/ public static String getShortDate() { String DEFAULT_TIME_FORMAT = "yyMMdd"; diff --git a/app/src/main/java/com/ic/protocols/protocol_ic.java b/app/src/main/java/com/ic/protocols/protocol_ic.java index 3b9efc93..e6bceca4 100644 --- a/app/src/main/java/com/ic/protocols/protocol_ic.java +++ b/app/src/main/java/com/ic/protocols/protocol_ic.java @@ -731,23 +731,22 @@ public class protocol_ic { connection.send(genStringMessage("AP12",AP12(index,phNum1,phNum2,phNum3))); ArrayList contactArray=new ArrayList(); - if(Config.custom_branch_name.equals("AK")){ - - contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos1", "07522312120")); - if (!phNum1.isEmpty()) - contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos2", phNum1)); - if (!phNum2.isEmpty()) - contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos3", phNum2)); - }else { +// if(Config.custom_branch_name.equals("AK")){ +// +// contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos1", "07522312120")); +// if (!phNum1.isEmpty()) +// contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos2", phNum1)); +// if (!phNum2.isEmpty()) +// contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos3", phNum2)); +// }else { if (!phNum1.isEmpty()) contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos1", phNum1)); if (!phNum2.isEmpty()) contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos2", phNum2)); if (!phNum3.isEmpty()) contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos3", phNum3)); - } +// } runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true); - }else{ ICLogger.i(" BP12 format error!"); } diff --git a/app/version_code.properties b/app/version_code.properties index 5b46e500..26c83174 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Mon Aug 10 20:58:05 CST 2020 -VERSION_CODE=490 +#Tue Aug 11 14:30:49 CST 2020 +VERSION_CODE=491