From 13dd6fd147d6c8d1ff95aec7a1a6052c3ad83218 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Tue, 24 Sep 2024 11:21:23 +0800 Subject: [PATCH] =?utf8?q?Mp3=E6=96=87=E4=BB=B6=E4=BC=A0=E8=BE=93=E9=87=8D?= =?utf8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/blemoder/bletest.h | 4 + .../service/ble_service/bleservice/bleEvent.c | 39 +++- .../msg_center/include/notify/transmitting.h | 14 +- .../msg_center/src/notify/transmitting.cpp | 190 +++++++++++++++++- 4 files changed, 230 insertions(+), 17 deletions(-) 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 d3097befe..9cf6cdb92 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -38,6 +38,10 @@ extern "C" TRANS_OTA_TRANSMITTING, TRANS_OTA_SUCC, TRANS_OTA_FAIL, + + TRANS_MP3_TRANSMITTING, + TRANS_MP3_SUCC, + TRANS_MP3_FAIL, TRANS_FREE, } transmitting_type; 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 01ae8e1c8..dcbc61ed3 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -6723,7 +6723,11 @@ errcode_t decode_mp3_json(ble_read_data *buffer_handle) buffer_handle->file_recv_stat.received_size = 0; buffer_handle->file_recv_stat.lrcvalue = 0; buffer_handle->receive_file_flag = 1; + TRANSMIT_DATA=TRANS_MP3_TRANSMITTING; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + return ERRCODE_SUCC; + }else{ buffer_handle->receive_file_flag = 0; return ERRCODE_FAIL; @@ -7078,7 +7082,9 @@ void decode_file_checksum(ble_read_data *buffer_handle) break; case 2://mp3 - + TRANSMIT_DATA=TRANS_MP3_SUCC; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ble_reply_cmd(DIAL_INSTALL_REPY_CMD,1); ble_mp3_list_update(); @@ -7123,6 +7129,8 @@ void decode_file_checksum(ble_read_data *buffer_handle) CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); break; case 2://mp3 + TRANSMIT_DATA=TRANS_MP3_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); break; case 3://dial @@ -7144,6 +7152,9 @@ void decode_file_checksum(ble_read_data *buffer_handle) CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); break; case 2://mp3 + TRANSMIT_DATA=TRANS_MP3_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + break; case 3://dial TRANSMIT_DATA= TRANS_DIAL_FAIL; @@ -7479,6 +7490,29 @@ static errcode_t check_package_same(uint8_t* lastdata,uint8_t *newdata , uint16_ return ERRCODE_FAIL; } } +//MP3文件重命名 +static errcode_t create_mp3_name(char* path,char*dir_path ,char* file_name) +{ + + sprintf_s(path,256,"%s/",dir_path); + uint16_t path_len=strlen(path); + + if(strstr(file_name,".mp3")) + { + int len=strlen(file_name)-strlen(".mp3"); + for(int i=0;ifile_recv_stat.file_name); + create_mp3_name(filepath,musicpath,buffer_handle->file_recv_stat.file_name); + buffer_handle->file_recv_stat.file = fopen(filepath,"w+"); printf("%s\r\n",filepath); } diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h b/code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h index ab79ce3b4..c228a9410 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h @@ -1,24 +1,12 @@ #ifndef TRANSMITTING_H #define TRANSMITTING_H #include "components/ui_image_animator.h" +#include "bletest.h" namespace OHOS { // UIViewGroup *ChargingStatuShow(void); // UIView *view_ = nullptr; - - typedef enum transmitting_type_t { - TRANS_DIAL_TRANSMITTING, - TRANS_DIAL_SUCC, - TRANS_DIAL_FAIL, - - TRANS_OTA_TRANSMITTING, - TRANS_OTA_SUCC, - TRANS_OTA_FAIL, - - TRANS_FREE, - } transmitting_type_t; - UIViewGroup* transmittingShow(void); void set_transmittingShow_falg(uint8_t falg); void Freetransmitting(void); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp index 1341d748d..e614e0213 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp @@ -427,8 +427,127 @@ namespace OHOS UIViewGroup_transmitting->Add(downImageAnimatorView); } - + void creat_down_MP3() + { + if (Title == nullptr) { + Title = new UILabel(); + } + Title->SetPosition(158, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("音乐传输中"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + 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 + label_->SetText("正在传输音乐,请不要做其他操作或关闭手表"); + 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, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + CreatetransmittingAnimator(); + // UIViewGroup_transmitting->Add(updatasider); + + UIViewGroup_transmitting->Add(downImageAnimatorView); + } + + void creat_down_MP3_succ() + { + if (Title == nullptr) { + Title = new UILabel(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("传输成功"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + 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 + label_->SetText("音乐传输成功正在校验,请稍等"); + 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, 30); + + + + 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_SUCC_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)dialtimerCallBack, osTimerPeriodic, NULL, NULL); + tick =2000;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + } @@ -563,6 +682,63 @@ namespace OHOS } + void creat_down_MP3_fail() + { + if (Title == nullptr) { + Title = new UILabel(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("传输失败"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + 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 + label_->SetText("音乐传输失败,请退出或重新安装"); + 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, 30); + + + + 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); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } @@ -599,6 +775,16 @@ namespace OHOS case TRANS_OTA_FAIL: creat_down_OTA_FAIL(); break; + case TRANS_MP3_TRANSMITTING: + creat_down_MP3(); + break; + case TRANS_MP3_SUCC: + creat_down_MP3_succ(); + break; + case TRANS_MP3_FAIL: + creat_down_MP3_fail(); + break; + default: break; } @@ -638,7 +824,7 @@ namespace OHOS bool transmittingViewEventListener::OnClick(UIView& view, const ClickEvent& event) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick"); - if(Transmitting_falg!=TRANS_DIAL_TRANSMITTING && Transmitting_falg!=TRANS_OTA_TRANSMITTING) + if(Transmitting_falg!=TRANS_DIAL_TRANSMITTING && Transmitting_falg!=TRANS_OTA_TRANSMITTING && Transmitting_falg!=TRANS_MP3_TRANSMITTING) { NotificationManager::GetInstance()->StopNotify(); } -- 2.17.1