From 68c58cb0f71d75cce31817dc08514b60b74b1904 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 26 Sep 2024 16:15:54 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0MP3=E5=88=A0=E9=99=A4=EF=BC=8C?= =?utf8?q?=E5=A2=9E=E5=8A=A0ota=E5=8D=87=E7=BA=A7=E7=BB=93=E6=9E=9C?= =?utf8?q?=E6=8F=90=E7=A4=BA=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/BluetoothServiceOptionsView.cpp | 8 +- .../makephone/src/CallerDisplayView.cpp | 6 +- .../musicplayer/include/MusicPlayerModel.h | 5 + .../musicplayer/src/MusicPlayerModel.cpp | 20 ++- .../service/ble_service/blemoder/bletest.cpp | 126 ++++++++---------- .../service/ble_service/blemoder/bletest.h | 8 +- .../service/ble_service/bleservice/bleEvent.c | 58 ++++++++ .../msg_center/include/notify/transmitting.h | 12 ++ .../msg_center/src/notify/transmitting.cpp | 83 ++++++++++++ .../drivers/peripheral/utils/custom_utils.c | 2 + .../interfaces/innerkits/graphic_config.h | 3 + 11 files changed, 253 insertions(+), 78 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp index ec7f598f6..89567c555 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp @@ -8,6 +8,7 @@ #include "BluetoothModel.h" #include "ui_resource_string.h" #include "cmsis_os2.h" +#include "graphic_service.h" namespace OHOS { @@ -99,7 +100,7 @@ namespace OHOS return connectingScrollView->IsVisible(); } - void connectTimerCallBack(int data) + static void connectTimerCallBackProc(int data) { bool connect_state=false; count_num++; @@ -169,6 +170,11 @@ namespace OHOS } } + void connectTimerCallBack(int data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(connectTimerCallBackProc, data)); + } + bool BluetoothServiceOptionsView::init_connect_timer(uint8_t type) { uint32_t tick; diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp index eb5a5ef4b..aba6b9fd0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp @@ -14,9 +14,9 @@ namespace OHOS { 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; // 当前时间 @@ -173,7 +173,7 @@ bool CallerDisplayView::InitUILabelDisplay() 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) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h index 3b8d03bfe..61c477429 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h @@ -20,6 +20,11 @@ namespace OHOS static MusicPlayerModel &GetInstance(void); std::string GetMusicPlayPath(void); + std::string getRealMusicNameById(int id); + std::string getShowMusicNameById(int id); + + int getIdToMusicNameMapNumber(void); + private: MusicPlayerModel(); ~MusicPlayerModel(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp index 209ae5dac..eccfac2b8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp @@ -24,8 +24,26 @@ namespace OHOS /*获取音乐播放路径*/ 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(); + } + } 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 ababd2830..c23eacecd 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -85,6 +85,12 @@ extern "C" { #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) @@ -483,6 +489,26 @@ void Tag_read_ID3V2( FILE *fp) } +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}; @@ -494,95 +520,51 @@ char * dir_to_json_buf_malloc_(uint8_t type) 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;id_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; + } diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index c3297fbc6..1721e7971 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -42,7 +42,9 @@ extern "C" TRANS_MP3_TRANSMITTING, TRANS_MP3_SUCC, TRANS_MP3_FAIL, - + + OTA_UPDATA_FAIL, + TRANS_FREE, } transmitting_type; @@ -378,6 +380,10 @@ uint8_t* ble_get_sos_all_data_malloc(uint32_t*); 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 } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 301a30a7c..b880d6c99 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -3040,6 +3040,63 @@ void GetGPSCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_ //send_big_data(1,NULL,0,0,1,1,0x4f,2); } +void App_delete_file(ble_read_data *buffer_handle,uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// +{ + + uint8_t reply[2]={0}; + if (len<=2) + { + ble_reply_cmdarr(cmd,reply,2);//crc error + } + if(Check_CRC(data,len,crcvalue)) + { + uint8_t count=data[0]; + uint8_t type=data[1]; + if(type==2) + { + if(len-2!=count*2) + { + ble_reply_cmdarr(cmd,reply,1);//crc error + } + else + { + int offest=2; + for(int i=0;iSetPosition(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() @@ -795,6 +875,9 @@ namespace OHOS case TRANS_MP3_FAIL: creat_down_MP3_fail(); break; + case OTA_UPDATA_FAIL: + Creat_OTA_Updata_FAIL(); + break; default: break; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 95304b470..fcf469b13 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -386,6 +386,8 @@ void startup_post_init_task(void) up_report_timer(); read_jsonHistory_weather(); + ota_updata_init(); + if ( cm_poweron_cat1_on_bootup_flag() ) { PRINT("PowerOn Cat1 !\r\n"); diff --git a/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h b/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h index 881714304..c6d1c8319 100755 --- a/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h +++ b/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h @@ -546,6 +546,9 @@ bool is_load_languages(uint8_t id); #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/" -- 2.17.1