From: luozheng <1732036298@qq.com> Date: Wed, 10 Jun 2026 03:57:11 +0000 (+0800) Subject: 解决n9重启后连接app可能导致的死机问题 X-Git-Url: http://git.snicker.com.cn/css/html/static/gitweb.css?a=commitdiff_plain;h=e292176bfaf6ee167264d415a7cf6918a8a3bd94;p=mirrors%2FFD230.git 解决n9重启后连接app可能导致的死机问题 --- diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 77dde3b6c..8e2051a14 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -131,7 +131,7 @@ extern "C" sedentary_start_min = (sedentary_time & 0X0000FF00) >> 8; sedentary_start_hour = sedentary_time & 0X000000FF; clean_sedentary_flag(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "set_sedentary_data:%d:%d~%d:%d", sedentary_start_hour, sedentary_start_min, sedentary_stop_hour, sedentary_stop_min); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "set_sedentary_data:%d.%d~%d.%d", sedentary_start_hour, sedentary_start_min, sedentary_stop_hour, sedentary_stop_min); } void set_drinkreminder_data(void) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/phoneservice/src/PhoneService.cpp index 3f19185c1..5bb1f5ab3 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/phoneservice/src/PhoneService.cpp @@ -132,17 +132,23 @@ int RegisterCallChangedCb(PhoneServiceCb *phoneServiceFun) static void CallChangedCb(const PhoneCallInfo *phoneCall) { - g_callChanged.callChanged(phoneCall); + if (g_callChanged.callChanged != nullptr) { + g_callChanged.callChanged(phoneCall); + } } static void PhoneServiceErrorCallback(PhoneServiceErrorType type, int volume) { - g_callChanged.phoneServiceErrorCb(type, volume); + if (g_callChanged.phoneServiceErrorCb != nullptr) { + g_callChanged.phoneServiceErrorCb(type, volume); + } } static void ScoStatusCb(hfp_sco_connect_state_t state) { - g_callChanged.scoStatusCb(state); + if (g_callChanged.scoStatusCb != nullptr) { + g_callChanged.scoStatusCb(state); + } } int GetCurrCallState(void) @@ -618,7 +624,7 @@ static void CatBdAddr(const bd_addr_t &bdAddr) for (unsigned char i = 0; i < BD_ADDR_LEN; i++) { printf("%X", bdAddr.addr[i]); } - printf(""); + // printf(""); #else UNUSED(bdAddr); #endif diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp index ff755caca..c9bb22ee6 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp @@ -304,104 +304,93 @@ uint8_t ble_get_password(void) return SAFE_CALL_PTR_NO_ARGS(bleInstruct_t.ble_get_password); } +// 设置久坐提醒参数 void set_sedent_param(msg_sedent_set_param_info_t * data) { SAFE_CALL(bleInstruct_t.set_sedent_param,data); } - +// 获取久坐提醒参数 void get_sedent_param( msg_sedent_set_param_info_t * data) { - SAFE_CALL(bleInstruct_t.get_sedent_param, data); } +//检查表盘是否有足够的空间 bool check_dial_freespace(uint16_t id,uint32_t dial_size) { return SAFE_CALL_BOOL(bleInstruct_t.check_dial_freespace, id, dial_size); } +//获取表盘路径 void ble_get_dial_path(char * buf,uint16_t id) { SAFE_CALL(bleInstruct_t.ble_get_dial_path, buf, id); } +//保存自定义表盘 void ble_save_dial_custom(msg_recv_custom_dial_info_t *data) { SAFE_CALL(bleInstruct_t.ble_save_dial_custom, data); } -// void ble_set_dial_by_id_(uint16_t id) -// { -// return bleInstruct_t.ble_set_dial_by_id_(id); - -// } +//设置当前表盘Id void ble_set_dial_by_id(uint16_t id) { - // printf("ble_set_dial_by_id %d\n",id); - SAFE_CALL(bleInstruct_t.ble_set_dial_by_id, id); + SAFE_CALL(bleInstruct_t.ble_set_dial_by_id, id); } +//获取自定义表盘 void ble_get_custom_dial(uint16_t id,char *buf) { SAFE_CALL(bleInstruct_t.ble_get_custom_dial, id, buf); } +//获取当前表盘Id uint16_t ble_get_dial_id(void) { return SAFE_CALL_PTR_NO_ARGS(bleInstruct_t.ble_get_dial_id); } - - +//判断表盘是否存在 bool ble_is_dial_install_by_id(uint16_t id) { return SAFE_CALL_BOOL(bleInstruct_t.ble_is_dial_install_by_id, id); } +//获取表盘数量 int ble_get_dial_num(void) { return SAFE_CALL_PTR_NO_ARGS(bleInstruct_t.ble_get_dial_num); } -// void ble_delete_dial_(uint16_t id) -// { -// return bleInstruct_t.ble_delete_dial_(id); -// } - +//删除指定id表盘 bool ble_delete_dial(uint16_t id) { - return SAFE_CALL_BOOL(bleInstruct_t.ble_delete_dial, id); - } +//获取所有表盘Id int get_all_dial_id( char * buf,uint16_t MAX_LEN) { return SAFE_CALL_PTR(bleInstruct_t.get_all_dial_id, buf, MAX_LEN); } +//存储表盘到文件 bool dial_file_save(void ) { - return SAFE_CALL_BOOL(bleInstruct_t.dial_file_save); + return SAFE_CALL_BOOL(bleInstruct_t.dial_file_save); } -// void install_Register_dial_( char * name,uint16_t id) -// { -// return bleInstruct_t.install_Register_dial_(name,id); - -// } +//注册表盘 void install_Register_dial( char * name,uint16_t id) { SAFE_CALL(bleInstruct_t.install_Register_dial, name, id); - } -// #include "cywee_ble_service.h" - void delete_before_file(uint8_t type) { #ifdef SUPPORT_CYWEE_SERVICE - time_t currtime; + time_t currtime; struct tm *timeinfo; time(&currtime); timeinfo = localtime(&currtime); @@ -410,11 +399,9 @@ void delete_before_file(uint8_t type) int m=timeinfo->tm_mon+1; int d=timeinfo->tm_mday; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"delete_before_file now day%d %d %d\r\n ",y,m,d); - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"delete_before_file now day%d %d %d\r\n ",y,m,d); char path_[64]={0}; - - switch (type) + switch (type) { case 0x43: //同步步数历史数据 sprintf_s(path_,64,"%s",GOAL_DATA_CONFIG_DIR_STEP); @@ -434,12 +421,10 @@ void delete_before_file(uint8_t type) default: break; } - struct DIR *dir; struct dirent *ent; - if ((dir = opendir(path_)) != NULL) { while ((ent = readdir(dir)) != NULL) @@ -447,61 +432,53 @@ void delete_before_file(uint8_t type) std::string fileName = ent->d_name; if (fileName != "." && fileName != "..") { - if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件 { int flag=0; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%s\r\n",fileName.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%s\r\n",fileName.c_str()); int y_; int m_; int d_; - for(int i=0;i0) { - if(flag==0) { i=i+4; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"data %d\r\n",data); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"data %d\r\n",data); y_=y-data; flag++; } else if (flag==1) { i=i+2; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"data %d\r\n",data); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"data %d\r\n",data); m_=m-data; flag++; } else if (flag==2) { i=i+2; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"data %d\r\n",data); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"data %d\r\n",data); d_=d-data; flag++; } - - } } - if((y_*24+m_)*30+d_>before_file_day) { char path_remove[64]={0}; sprintf_s(path_remove,64,"%s/%s",path_,fileName.c_str()); remove(path_remove); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"succ remove %s\r\n ",path_remove); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"succ remove %s\r\n ",path_remove); } else { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"is 30d %d\r\n ",(y_*24+m_)*30+d_); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"is 30d %d\r\n ",(y_*24+m_)*30+d_); } - } } else if (ent->d_type == DT_DIR) // 目录 @@ -512,14 +489,10 @@ void delete_before_file(uint8_t type) } else { - return ; } closedir(dir); - #endif - - } //同步历史数据 diff --git a/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp b/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp index a08a485fc..c250139cd 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp @@ -549,17 +549,13 @@ void null_doing(void) void set_sedent_param_( msg_sedent_set_param_info_t * data) { OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_SWITCH,data->sedent_on); - p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,data->sedent_time ); - p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,data->frequenc); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"开关:%d\r\n",data->sedent_on); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"久坐提醒时间段:%d\r\n",data->sedent_time); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"久坐提醒时间间隔(单位小时):%d\r\n",data->frequenc); - - // set_sedentary_data(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"开关:%d\r\n",data->sedent_on); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"久坐提醒时间段:%d\r\n",data->sedent_time); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"久坐提醒时间间隔(单位小时):%d\r\n",data->frequenc); + set_sedentary_data(); return; } @@ -599,6 +595,7 @@ void ble_config_init(void) bleInstruct_t.set_br_pair=set_br_pair_; bleInstruct_t.ble_get_password=ble_get_password_; bleInstruct_t.get_sedent_param=get_sedent_param_; + bleInstruct_t.set_sedent_param=set_sedent_param_; bleInstruct_t.ble_set_sleep_remind= ble_set_sleep_remind_; bleInstruct_t.ble_get_sleep_remind=ble_get_sleep_remind_; bleInstruct_t. ble_set_drink_remind=ble_set_drink_remind_; @@ -639,8 +636,6 @@ void ble_config_init(void) bleInstruct_t.get_brigthness= get_brigthness_; bleInstruct_t.set_ScreenDuration= set_ScreenDuration_; bleInstruct_t. get_ScreenDuration=get_ScreenDuration_; - bleInstruct_t.set_sedent_param=set_sedent_param_; - } #endif \ No newline at end of file diff --git a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c index dddc9af66..97ab06c62 100644 --- a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c +++ b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c @@ -2731,7 +2731,8 @@ void SetsedentarinessSetParamCmd(uint16_t cmd, uint8_t *data, uint16_t len, uint // 解析久坐时长(4字节):先判断长度,再拷贝 if (len >= 5) { // data[1]-data[4] 需要至少5字节数据(索引0-4) memcpy_s(&sedent_data.sedent_time, sizeof(sedent_data.sedent_time), &data[1], 4); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"解析久坐时长sedent_time = %u 小时", sedent_data.sedent_time); + //久坐提醒时间段 前16位是开始时间 前8 为小时 后8为分钟 后16位为结束时间规则同前 例: 1600 0B00 11点开始到 22点结束 + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"解析久坐时长sedent_time = %u分钟", sedent_data.sedent_time); } else { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"数据长度不足(仅%d字节),无法解析久坐时长(需要5字节)", len); sendBuf[17] = 0; diff --git a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h index 9d60ca905..e777f61e6 100644 --- a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h +++ b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h @@ -689,10 +689,10 @@ typedef struct }msg_user_info_t;//获取用户信息 身高体重 typedef struct { - uint8_t sedent_on;//提醒开关 0关闭 1开启 - uint32_t sedent_time;//时间 - uint8_t frequenc;//提醒频率 -}msg_sedent_set_param_info_t; + uint8_t sedent_on; //提醒开关 0关闭 1开启 + uint32_t sedent_time; //时间单位 + uint8_t frequenc; //提醒频率 +}msg_sedent_set_param_info_t; //久坐提醒参数 #pragma pack() /******************************************