#include "BluetoothModel.h"
#include "ui_resource_string.h"
#include "cmsis_os2.h"
+#include "graphic_service.h"
namespace OHOS
{
return connectingScrollView->IsVisible();
}
- void connectTimerCallBack(int data)
+ static void connectTimerCallBackProc(int data)
{
bool connect_state=false;
count_num++;
}
}
+ void connectTimerCallBack(int data)
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(connectTimerCallBackProc, data));
+ }
+
bool BluetoothServiceOptionsView::init_connect_timer(uint8_t type)
{
uint32_t tick;
static constexpr uint16 MATH_ZERO = 0;
// 来电显示
-static constexpr uint16 LABEL_PERCENT_POSITION_X = 0;
+static constexpr uint16 LABEL_PERCENT_POSITION_X = 93;
static constexpr uint16 LABEL_PERCENT_POSITION_Y = 80;
-static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION;
+static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = 280;
static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80;
// 当前时间
callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER);
callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE);
callerDisplay->SetTextColor(Color::White());
- callerDisplay->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ callerDisplay->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
group->Add(callerDisplay);
if (label_call_hint == nullptr) {
static MusicPlayerModel &GetInstance(void);
std::string GetMusicPlayPath(void);
+ std::string getRealMusicNameById(int id);
+ std::string getShowMusicNameById(int id);
+
+ int getIdToMusicNameMapNumber(void);
+
private:
MusicPlayerModel();
~MusicPlayerModel();
/*获取音乐播放路径*/
std::string MusicPlayerModel::GetMusicPlayPath(void)
{
-
return PlayersModel::GetInstance()->GetMusicPlayPath();
}
+ std::string MusicPlayerModel:: getRealMusicNameById(int id)
+ {
+
+
+ return PlayersModel::GetInstance()->getRealMusicNameById(id);
+ }
+
+ std::string MusicPlayerModel::getShowMusicNameById(int id)
+ {
+ return PlayersModel::GetInstance()->getShowMusicNameById(id);
+ }
+
+ int MusicPlayerModel:: getIdToMusicNameMapNumber(void)
+ {
+ PlayersListGroup::GetInstance()->SetUpListCase();
+
+ return PlayersModel::GetInstance()->getIdToMusicNameMapNumber();
+ }
+
}
#include "power_display_service.h"
#include "ScheduleData.h"
#include "alipay_feature.h"
+#include "transmitting.h"
+
+void ota_updata_init(void)
+{
+ OHOS::get_updatafail_data();
+}
uint8_t * ble_get_sos_all_data_malloc(uint32_t *len)
}
+bool delete_MP3_file_By_ID(uint16_t id)
+{
+ char dir_path[128]={0};
+ get_music_path(dir_path,128);
+ char file_path[512];
+ std::string realname =OHOS::MusicPlayerModel::GetInstance().getRealMusicNameById(id);
+ sprintf_s(file_path,512,"%s/%s",dir_path,realname.c_str());
+
+ int ret= remove(file_path);
+ if(ret==0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+}
+
char * dir_to_json_buf_malloc_(uint8_t type)
{
char dir_path[128]={0};
break;
case 3: //
sprintf_s(dir_path,64,"%s","user/userdata/dial");
- break;
+ return NULL;
+
default:
break;
}
cJSON *dataJSON = cJSON_CreateObject();
cJSON* data_arryJSON = cJSON_CreateArray();
- struct DIR *dir;
- struct dirent *ent;
- uint32_t file_size=0;
- uint8_t file_index=1;
- if ((dir = opendir(dir_path)) != NULL)
+ int size=OHOS::MusicPlayerModel::GetInstance().getIdToMusicNameMapNumber();
+ for(int i=0;i<size;i++)
{
- while ((ent = readdir(dir)) != NULL)
+ char file_path[512];
+ int file_size;
+ std::string realname =OHOS::MusicPlayerModel::GetInstance().getRealMusicNameById(i);
+ sprintf_s(file_path,512,"%s/%s",dir_path,realname.c_str());
+ printf("%s\r\n",file_path);
+ FILE * fp = fopen(file_path,"rb+");
+ if(fp==NULL)
{
- std::string fileName = ent->d_name;
-
- if (fileName != "." && fileName != "..")
- {
- //std::string filePath = directory + fileName;
-
-
- if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件
- {
- char file_path[128]={0};
- sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
-
- FILE * fp = fopen(file_path,"rb+");
- if(fp==NULL)
- {
- printf(" fopen fail %s\r\n",file_path);
- return NULL;
- }
- if (fp != NULL)
- {
- fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
- file_size = ftell(fp); // 获取当前文件指针位置,即文件大小
- fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
- }
- //Tag_ID3V2_t tag={0};
- // fread(tag.Header,3,1,fp);
- // fread(&tag.Ver,1,1,fp);
-
- // memset_s(&Mp3Trailer,sizeof(Mp3Trailer),0,sizeof(Mp3Trailer));
- // if(tag.Ver==3)
- // {
- // printf("%s\r\n",ent->d_name);
- // fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
- // Tag_read_ID3V2(fp);
- // }
- // else
- // {
- // printf("tag.Header %s %d\r\n",tag.Header,tag.Ver);
- // }
- fclose(fp);
-
-
- cJSON* itemJSON = cJSON_CreateObject();
- cJSON_AddNumberToObject(itemJSON,"uid",file_index);
- cJSON_AddStringToObject(itemJSON,"name",fileName.c_str());
- cJSON_AddNumberToObject(itemJSON,"size",file_size);
- // cJSON_AddStringToObject(itemJSON,"artist",Mp3Trailer.Artist);
- // cJSON_AddStringToObject(itemJSON,"dur", "未知");
- cJSON_AddItemReferenceToArray(data_arryJSON,itemJSON);
- file_index++;
+ printf(" fopen fail %s\r\n",file_path);
+ return NULL;
+ }
+ if (fp != NULL)
+ {
+ fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
+ file_size = ftell(fp); // 获取当前文件指针位置,即文件大小
+ fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
- }
- else if (ent->d_type == DT_DIR) // 目录
- {
- continue;
- }
- }
+ fclose(fp);
}
- closedir(dir);
- }
- else
- {
- printf("opendir fail\r\n");
+ std::string showname =OHOS::MusicPlayerModel::GetInstance().getShowMusicNameById(i);
+ cJSON* itemJSON = cJSON_CreateObject();
+ cJSON_AddNumberToObject(itemJSON,"uid",i);
+ cJSON_AddStringToObject(itemJSON,"name",showname.c_str());
+ cJSON_AddNumberToObject(itemJSON,"size",file_size);;
+ cJSON_AddItemReferenceToArray(data_arryJSON,itemJSON);
}
cJSON_AddNumberToObject(dataJSON,"type",2);
-
cJSON_AddItemToObject(dataJSON,"list",data_arryJSON);
-
char *json_format = cJSON_PrintUnformatted(dataJSON);
-
int pSize = cJSON_GetArraySize(dataJSON);
- cJSON_Delete(dataJSON);
+ cJSON_Delete(dataJSON);
printf("mp3 :%s\r\n",json_format);
return json_format;
+
}
TRANS_MP3_TRANSMITTING,
TRANS_MP3_SUCC,
TRANS_MP3_FAIL,
-
+
+ OTA_UPDATA_FAIL,
+
TRANS_FREE,
} transmitting_type;
cJSON* ble_get_Trainingdata_by_timetamp(uint32_t timetamp);
+void ota_updata_init(void);
+
+bool delete_MP3_file_By_ID(uint16_t id);
+
#ifdef __cplusplus
#if __cplusplus
}
//send_big_data(1,NULL,0,0,1,1,0x4f,2);\r
}\r
\r
+void App_delete_file(ble_read_data *buffer_handle,uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//\r
+{\r
+\r
+ uint8_t reply[2]={0};\r
+ if (len<=2)\r
+ {\r
+ ble_reply_cmdarr(cmd,reply,2);//crc error\r
+ }\r
+ if(Check_CRC(data,len,crcvalue))\r
+ {\r
+ uint8_t count=data[0];\r
+ uint8_t type=data[1];\r
+ if(type==2)\r
+ {\r
+ if(len-2!=count*2)\r
+ {\r
+ ble_reply_cmdarr(cmd,reply,1);//crc error\r
+ }\r
+ else\r
+ {\r
+ int offest=2;\r
+ for(int i=0;i<count;i++)\r
+ {\r
+ uint16_t id=0;\r
+ memcpy_s(&id,2,&data[offest],2);\r
+ bool ret = delete_MP3_file_By_ID(id);\r
+ if(ret==false)\r
+ {\r
+ reply[0]=2;\r
+ ble_reply_cmdarr(cmd,reply,1);//crc error\r
+ return;\r
+ }\r
+ else\r
+ {\r
+ offest+=2;\r
+ }\r
+ }\r
+ reply[0]=1;\r
+ ble_mp3_list_update();\r
+ ble_reply_cmdarr(cmd,reply,1);\r
+ }\r
+\r
+ }\r
+ else\r
+ {\r
+ reply[0]=2;\r
+ ble_reply_cmdarr(cmd,reply,1);\r
+ }\r
+\r
+ \r
+ \r
+ }else{\r
+ ble_reply_cmdarr(cmd,reply,1);//crc error\r
+ }\r
+\r
+}\r
+\r
void query_dial_installed(ble_read_data *buffer_handle,uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//\r
{\r
\r
query_dial_installed(buffer_handle,typeID,data,datalen,totalData,crcvalue);\r
break;\r
case DELETE_FILE_CMD:\r
+ App_delete_file(buffer_handle,typeID,data,datalen,totalData,crcvalue);\r
break;\r
case SYN_BASIC_REAL_HEATR_CMD:\r
SYN_train_heart_datatCmd(typeID,data,datalen,totalData,crcvalue);\r
#define TRANSMITTING_H
#include "components/ui_image_animator.h"
#include "bletest.h"
+#include "components/ui_view_group.h"
namespace OHOS
{
// UIViewGroup *ChargingStatuShow(void);
// UIView *view_ = nullptr;
+
+ #ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+ void get_updatafail_data(void);
+};
+#endif
+
+#endif
+
UIViewGroup* transmittingShow(void);
void set_transmittingShow_falg(uint8_t falg);
void Freetransmitting(void);
+
class transmittingViewEventListener : public OHOS::UIView::OnClickListener,
public OHOS::UIView::OnLongPressListener,
public OHOS::UIView::OnTouchListener,
#include "bleEvent.h"
#include "power_display_service.h"
#include "uicomponents/UIComponents.h"
+#include "upg.h"
namespace OHOS
{
static UIImageView *imageCharge = nullptr;
return ;
}
}
+ static upg_result_t upg_result;
+ static uint32_t last_image_index;
+
+ static char updata_fail_str[32]={0};
+
+ static uint8_t TRANSMIT_DATA;
+
+ void get_updatafail_data(void)
+ {
+ errcode_t ret;
+ ret = uapi_upg_get_result(&upg_result, &last_image_index);
+ if (ret != ERRCODE_SUCC) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_upg_get_result error = 0x%x\r\n", ret);
+ } else {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"upg_result = %d, last_image_index:%d\r\n", upg_result, last_image_index);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_upg_get_result OK!!\r\n");
+ if(upg_result!=UPG_RESULT_UPDATE_SUCCESS)
+ {
+ sprintf_s(updata_fail_str,32,"%d_%d",(int)upg_result,last_image_index);
+ TRANSMIT_DATA=OTA_UPDATA_FAIL;
+ CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);
+ }
+
+ }
+ }
+
+ void Creat_OTA_Updata_FAIL()
+ {
+ if (Title == nullptr) {
+ Title = new UILabel();
+ }
+ Title->SetPosition(83, 50); // widget's left position and top position
+ Title->Resize(300, 35); // widget's width and height
+ Title->SetViewId("label1");// Set style
+ Title->SetStyle(STYLE_TEXT_FONT, 30);
+
+ // Set additional property
+ Title->SetText("OTA upgrade failure");
+ Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ Title->SetRollSpeed(0);
+ Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
+
+ UIViewGroup_transmitting->Add(Title);
+
+ if (label_ == nullptr) {
+ label_ = new UILabel();
+ }
+ label_->SetPosition(60, 281); // widget's left position and top position
+ label_->Resize(345, 101); // widget's width and height
+ label_->SetViewId("label2");// Set style
+ label_->SetStyle(STYLE_TEXT_FONT, 30);
+
+ // Set additional property
+ char fail_str[128]={0};
+ sprintf_s(fail_str,128,"OTA upgrade failed, try upgrade again, or repair %s",updata_fail_str);
+
+ label_->SetText(fail_str);
+ label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff));
+ label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label_->SetRollSpeed(0);
+ label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
+
+ UIViewGroup_transmitting->Add(label_);
+
+ //Add ImageView to App
+
+ if (transmitting_img == nullptr)
+ {
+ transmitting_img = new UIImageView();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!");
+ }
+ transmitting_img->SetPosition(193, 150,80, 80);
+ const char *imagesPath = TRANSMITTING_FAIL_PATH;
+ transmitting_img->SetSrc(imagesPath);
+ UIViewGroup_transmitting->Add(transmitting_img);
+ }
+
void creat_down_OTA_FAIL()
case TRANS_MP3_FAIL:
creat_down_MP3_fail();
break;
+ case OTA_UPDATA_FAIL:
+ Creat_OTA_Updata_FAIL();
+ break;
default:
break;
up_report_timer();
read_jsonHistory_weather();
+ ota_updata_init();
+
if ( cm_poweron_cat1_on_bootup_flag() )
{
PRINT("PowerOn Cat1 !\r\n");
#define DEFAULT_VECTOR_FONT_FILENAME get_current_global_font_name()
+
+#define DEFAULT_VECTOR_FONT_FILENAME_EN HARMONYOS_VECTOR_FONT_FILENAME
+
/* resources path. */
#ifdef VERSION_IOT
#define RES_PATH "/user/res/"