From: hcj <1224667075@qq.com> Date: Thu, 3 Oct 2024 10:01:35 +0000 (+0800) Subject: 每日目标数据上传增加安全保护 X-Git-Tag: release_V1.2.70_20241020_135402~223 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=308f50489d994cf17d88a8bb7a27ca10b9457c32;p=mirrors%2FFD230.git 每日目标数据上传增加安全保护 --- diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 06245c015..e2ecded8c 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -1250,27 +1250,35 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) switch (type) { case 0x43: //同步步数历史数据 - get_now_hour_data(&value,CYWEE_SAVE_DATA_STEP); - if(value>0) + + if( get_now_hour_data(&value,CYWEE_SAVE_DATA_STEP)) { - memcpy(buf+size,&creationTime,4); - size+=4; - memcpy(buf+size,&value,4); - size+=4; + if(value>0) + { + memcpy(buf+size,&creationTime,4); + size+=4; + memcpy(buf+size,&value,4); + size+=4; + } } + break; case 0x44://同步燃脂时间数据 - get_now_hour_data(&value,CYWEE_SAVE_DATA_FAT); - if(value>0) + if(get_now_hour_data(&value,CYWEE_SAVE_DATA_FAT)) { - memcpy(buf+size,&creationTime,4); - size+=4; - uint16 temp_value= (value); - memcpy(buf+size,&(temp_value),2); - size+=2; + if(value>0) + { + memcpy(buf+size,&creationTime,4); + size+=4; + int16 temp_value= (value); + memcpy(buf+size,&(temp_value),2); + size+=2; + } } + break; case 0x45://同步站立历史数据 + if(get_stand_falg()) { memcpy(buf+size,&creationTime,4); @@ -1279,24 +1287,30 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) break; case 0x46://同步卡路里历史数据 - get_now_hour_data(&f_value,CYWEE_SAVE_DATA_CALORIES); - if(f_value>0) - { - memcpy(buf+size,&creationTime,4); - size+=4; - memcpy(buf+size,&f_value,4); - size+=4; + if(get_now_hour_data(&f_value,CYWEE_SAVE_DATA_CALORIES)) + { + if(f_value>0) + { + memcpy(buf+size,&creationTime,4); + size+=4; + memcpy(buf+size,&f_value,4); + size+=4; + } } + break; case 0x47://同步距离历史数据 - get_now_hour_data(&f_value,CYWEE_SAVE_DATA_DISTANCE); - if(f_value>0) + if(get_now_hour_data(&f_value,CYWEE_SAVE_DATA_DISTANCE)) { - memcpy(buf+size,&creationTime,4); - size+=4; - memcpy(buf+size,&f_value,4); - size+=4; + if(f_value>0) + { + memcpy(buf+size,&creationTime,4); + size+=4; + memcpy(buf+size,&f_value,4); + size+=4; + } } + break; default: break; diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 99669cea1..7ff9fab78 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -342,13 +342,8 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req) unused(req); // The alarm notification is not displayed if the incoming call notification is already being processed // cywee_save_data(); - if(uapi_dev_runtime_get_goal_storage_status()==0) - { - uapi_dev_runtime_set_goal_storage_status(1); - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SAVE_DATA,NULL); - uapi_dev_runtime_set_goal_storage_status(0); - } - + + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SAVE_DATA,NULL); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时步数"); step_history_save(); diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 097a93148..34961c5e8 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -192,6 +192,10 @@ void cywee_get_version(char *databuf,uint8_t len) void cywee_save_data(void) { + if(uapi_dev_runtime_get_goal_storage_status()) + { + return; + } uapi_dev_runtime_set_goal_storage_status(1); int step=history_step+stepcount; @@ -336,24 +340,33 @@ int32_t get_now_hour_data(void*value, uint8_t type) case CYWEE_SAVE_DATA_STEP: data= get_step_data()-history_step_; + if(data<0) + return 0; memcpy_s(value,4,&data,4); return 1; case CYWEE_SAVE_DATA_CALORIES: data =get_calories_data(); f_data=(float)data-history_calories_; + if(f_data<0) + return 0; memcpy_s(value,4,&f_data,4); return 1; case CYWEE_SAVE_DATA_DISTANCE: data= get_distance_data(); f_data=(float)data/1000.0-history_distances_; + if(f_data<0) + return 0; memcpy_s(value,4,&f_data,4); - break; + return 1; + case CYWEE_SAVE_DATA_FAT: data= get_fat_time_data(); - uint32_t data_=data/60-history_fat_; + int32_t data_=data/60-history_fat_; + if(data_<0) + return 0; memcpy_s(value,4,&data,4); - break; + return 1; default: break; }