From 97a7c6a021effd5208d4c04aa12e8a1711939146 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Mon, 21 Oct 2024 11:51:22 +0000 Subject: [PATCH] Merge #1236 into sdk602patch0911 from refs/changes/1236/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/1236/head: (7 commits squashed) - 来电界面,禁止双击进入AI - 录音列表视图修改为右滑退出到录音主视图 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 1.一个分区模式下修改音乐和录音文件夹 2.录音添加空间判断管理 3.录音添加”空间已满弹窗“:在总时长大于20分钟或总数大于等于99,录音总空间大于等于10M,弹出 4.判断录音空间大小是否超出采用指令队列读职 5.修改底层录音文件audio_capture_wrapper.cpp大小参数使之录取一个录音最长时间在20分钟左右 - 修改音乐播放器函数名英文错误拼写 - 如果手表在播放本地音乐,AI界面点击开始对话会暂停本地音乐播放,避免混音 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1236 --- .../nativelauncher/include/UiConfig.h | 4 + .../nativeui/aivoice/src/AiVoicePresenter.cpp | 8 +- .../nativeui/player/include/PlayersModel.h | 8 +- .../player/src/PlayersCaseListAdapter.cpp | 2 +- .../nativeui/player/src/PlayersModel.cpp | 10 +- .../nativeui/player/src/PlayersPresenter.cpp | 10 +- .../src/RebootAndShutdownModel.cpp | 5 +- .../nativeui/record/include/RecordingModel.h | 17 ++- .../nativeui/record/include/RecordingModelC.h | 27 ++++ .../record/include/RecordingPresenter.h | 6 +- .../nativeui/record/src/RecordListView.cpp | 4 +- .../nativeui/record/src/RecordingModel.cpp | 132 ++++++++++++++++-- .../record/src/RecordingNumLimitView.cpp | 24 +++- .../record/src/RecordingPresenter.cpp | 31 ++-- .../nativeui/record/src/RecordingView.cpp | 1 + .../nativeui/system/include/SystemLogModel.h | 6 +- .../utils/custom_fileoperate_service.c | 5 + .../drivers/peripheral/utils/custom_utils.c | 2 + .../drivers/peripheral/utils/custom_utils.h | 2 + .../sample/wrapper/audio_capture_wrapper.cpp | 3 +- 20 files changed, 253 insertions(+), 54 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModelC.h diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 13bd86c85..0f7e5b822 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -65,7 +65,11 @@ namespace OHOS #define DOUBLES 2 #define APP_RES_PATH "/user/res" +#ifdef SINGLE_USER_PARTITION +#define APP_MUSIC_PATH "/user/music/user_music" +#else #define APP_MUSIC_PATH "/user/userdata/music" +#endif #define APP_VIDEO_PATH "/user/video" #define APP_DEFAULT_DIAL_PATH "/user/dial/res_dial" /*默认表盘安装路径*/ #define APP_DOWNLOAD_DIAL_PATH "/user/dial/offline_dial" /*表盘市场安装路径*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index e2a438727..029b81357 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-19 17:39:07 + * @LastEditTime: 2024-10-21 18:35:53 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp */ #include "AppViewIDs.h" @@ -309,7 +309,8 @@ namespace OHOS } else if (viewId == AIVOICE_START_CHAT_BUTTON_VIEW_ID) // 如果点击的是开始对话按钮 { - PlayersModel::GetInstance()->HandPausePhoneMusci(); // 暂停手机音乐 + PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐 + PlayersModel::GetInstance()->PlayerPause(); // 暂停手机音乐 /* * 进入对话流程: * 1.当手表4G网络正常+与app连接正常 -> 通过4G调用大模型 @@ -360,7 +361,8 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CancelCurAIChat"); AiVoiceModel::GetInstance().CancelCurAIChat(); - PlayersModel::GetInstance()->HandPausePhoneMusci(); // 暂停手机音乐 + PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐 + PlayersModel::GetInstance()->PlayerPause(); // 暂停手机音乐 } ChangeViewAndLogicOperator(it->second.first, it->second.second); return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h index 793e13b49..5565d9694 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-18 10:55:54 + * @LastEditTime: 2024-10-21 18:17:23 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h */ @@ -111,9 +111,9 @@ public: void get_avrcp_ct_get_element_attributes(void); void set_player_state(bool value); bool get_player_state(); - bool get_a2dp_sink_connect_state(void); - void HandPausePhoneMusci(void); - void HandPlayPhoneMusci(void); + bool get_a2dp_sink_playing_state(void); + void HandPausePhoneMusic(void); + void HandPlayPhoneMusic(void); // /* -------------------------------------------------------------------------- */ std::unordered_map> &getIdToMusicNameMap(void); std::string getRealMusicNameById(int id); diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp index 88e70fef8..748f812e9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp @@ -49,7 +49,7 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && - PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态 { return false; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp index 1a6a26652..64f2806b2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp @@ -998,7 +998,7 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) } // 获取手机音乐播放状态 - bool PlayersModel::get_a2dp_sink_connect_state(void) + bool PlayersModel::get_a2dp_sink_playing_state(void) { bd_addr_t active_bd_addr = a2dp_snk_get_active_device(); int state = a2dp_snk_get_playing_state(&active_bd_addr); @@ -1012,9 +1012,9 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) //暂停播放手机音乐 - void PlayersModel::HandPausePhoneMusci(void) + void PlayersModel::HandPausePhoneMusic(void) { - if (get_avrcp_ct_or_tg_is_connected() && get_a2dp_sink_connect_state()) + if (get_avrcp_ct_or_tg_is_connected() && get_a2dp_sink_playing_state()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_PAUSE"); set_phone_music_play_state(AVRCP_KEY_PAUSE); // 控制手机音乐暂停 @@ -1022,9 +1022,9 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) } //播放手机音乐 - void PlayersModel::HandPlayPhoneMusci(void) + void PlayersModel::HandPlayPhoneMusic(void) { - if (get_avrcp_ct_or_tg_is_connected() && get_a2dp_sink_connect_state()) + if (get_avrcp_ct_or_tg_is_connected() && get_a2dp_sink_playing_state()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_PLAY"); set_phone_music_play_state(AVRCP_KEY_PLAY); // 控制手机音乐暂停 diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp index 1d4106c40..9aeb21bce 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -644,7 +644,7 @@ void ButtonOnClickListener::PlayerButtonOnClick() else //若当前歌曲列表不为空且为本地音乐 { if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && - PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态 { playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 } else { @@ -696,7 +696,7 @@ void ButtonOnClickListener::NextButtonOnClick() return; } if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && - PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态 { playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 return; @@ -725,7 +725,7 @@ void ButtonOnClickListener::PreButtonOnClick() return; } if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && - PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态 { playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 return; @@ -748,7 +748,7 @@ void ButtonOnClickListener::SoundButtonOnClick() } /* -------------------------------------------------------------------------- */ if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && - PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态 { playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 return; @@ -819,7 +819,7 @@ void ButtonOnClickListener::PlayerModelButtonOnClick() } /* -------------------------------------------------------------------------- */ if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && - PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态 { playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 return; diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp index e6750e0ca..04b422da8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:55:27 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-10-09 10:43:18 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-10-21 10:23:23 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp */ @@ -33,6 +33,7 @@ namespace OHOS VIEW_BLOOD_CHECK, // 血氧检测界面 VIEW_HEART_CHECK, // 心率检测界面 VIEW_TRAININGCRAD, // 训练控制卡片 + VIEW_INCOMING_CALL,// 来电界面 VIEW_TEST, // 产测测试界面 }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h index 7c21eda3d..4aaa71ba3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModel.h @@ -38,7 +38,7 @@ namespace OHOS RECORDER_RESPONSE_MAX, }; -#define MAX_RECORDING_NUM 30 +#define MAX_RECORDING_NUM 99 typedef struct { char recordingFileName[32]; // 录音文件名 @@ -103,6 +103,13 @@ namespace OHOS void UpdateRecordProcess(); int getMaxRecordingNumber(void); void setMaxRecordingNumber(int number); + void SetCurView(int16_t viewNum); + int GetCurView(void); + int GetUsedRecordingTime(void); + bool CheckRecordingTimeOut(int time); + void CheckRecordingSpaceOut(void); + bool GetCheckRecordingSpaceOut(void); + void SendCheckRecordingSpaceOutCmd(void); private: RecordingModel(); @@ -128,8 +135,13 @@ namespace OHOS /* -------------------------------------------------------------------------- */ std::vector fileNames; // 录音文件名数组 int RecordingMp3FileCount = 0; // 录音MP3数量 +#ifdef SINGLE_USER_PARTITION + const std::string directory = "/user/music/recording/"; // 录音目录 + const std::string recordInfoFile = "/user/music/recording/recordinfo.bin"; +#else const std::string directory = "/user/userdata/recording/"; // 录音目录 const std::string recordInfoFile = "/user/userdata/recording/recordinfo.bin"; +#endif std::vector Recordings{0}; // 存放录音信息的动态数组 std::string recordDuration; // 录音时长 /* -------------------------------------------------------------------------- */ @@ -144,6 +156,9 @@ namespace OHOS int MaxRecordingNumber{0}; //要录取的最大录音编号 /* -------------------------------------------------------------------------- */ bool RecordingPlayerViewIsCreate{false}; + int curView{0}; + int usedRecordingTime{0};//已使用的录音总时长 + bool RecordingSpaceIsOut{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModelC.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModelC.h new file mode 100644 index 000000000..c50fceb00 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModelC.h @@ -0,0 +1,27 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-10-21 16:29:03 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-10-21 16:40:18 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingModelC.h + */ + + +#ifndef RECORDING_MODELC_H +#define RECORDING_MODELC_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif +#include + void CheckRecordingSpaceOutC(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h index 5d29727b1..674d5145c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-27 09:16:51 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-20 17:08:05 + * @LastEditTime: 2024-10-21 11:20:46 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h */ @@ -131,6 +131,8 @@ namespace OHOS static RecordingPresenter *GetInstance(); int convertNumericDateTime(const char *numericDateTime, char *formattedDateTime); void UpdateRecordProcess(); + void StopRecord(void); + void showWarning(void); private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; @@ -141,7 +143,7 @@ namespace OHOS void Notify() override; void SetCircleProgress(); void StartRecord(void); - void StopRecord(void); + // void StopRecord(void); RecordingModel *p_RecordingModel{nullptr}; uint8_t state_ = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; int64_t playerCurrentTime_{0}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp index 7dc74799e..a04b01a46 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-27 09:16:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-09 17:53:56 + * @LastEditTime: 2024-10-21 10:15:26 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp */ @@ -286,7 +286,7 @@ namespace OHOS recordList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ // recordList->SetReboundSize(30); // recordList->SetScrollBlankSize(20); - recordList->SetIntercept(true); // 设置是否拦截输入事件。如果被截获,视图在本地处理后不会将输入事件传递给父视图。 + // recordList->SetIntercept(true); // 设置是否拦截输入事件。如果被截获,视图在本地处理后不会将输入事件传递给父视图。 recordList->SetAdapter(p_RecordingListAdapter); RecordListScrollView->Add(recordList); return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp index bbabf12f2..8fc509443 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp @@ -14,9 +14,24 @@ #include #include "ConfigModel.h" #include "cstring" +#include "system/include/SystemLogModel.h" +#include "record/include/RecordingModelC.h" +#include "uiservice/include/ui_service.h" +#include "custom_runtime.h" +#include "vibrator_service.h" namespace OHOS { std::string RecordingModel::recordTempDuration = 0; + // 声明定时器变量 + osTimerId_t g_timer = NULL; + static int g_RecordingTimes = {0}; + static constexpr int32 NUM_TEN = 10; + static constexpr int16 ERROR = 0; + static constexpr int16 SUCCESS = 1; + static constexpr int16 NUM_TIME_MIN = 60; + static constexpr int16 NUM_TIME_HOUR = 3600; + static constexpr int32 NUM_TIME_DAY = 86400; + const int TOTAL_RECORDING_TIME = 20 * 60; // 20 分钟换算为秒 static MutexId g_mutex; RecordingModel::RecordingModel() { @@ -537,6 +552,14 @@ namespace OHOS return ""; // 返回空字符串表示不是 .mp3 文件 } + static int timeToSeconds(const char *timeStr) + { + int minutes = 0; + int seconds = 0; + sscanf(timeStr, "%d:%d", &minutes, &seconds); + return minutes * 60 + seconds; + } + /* * @brief 搜索录音文件 * @param -directory 录音文件目录 @@ -565,6 +588,7 @@ namespace OHOS strcpy(info[mp3FileCount].recordingFileName, recordingInfo.recordingFileName); strcpy(info[mp3FileCount].recordingDuration, recordingInfo.recordingDuration); strcpy(info[mp3FileCount].recordingTime, recordingInfo.recordingTime); + usedRecordingTime += timeToSeconds(recordingInfo.recordingDuration); mp3FileCount++; } } @@ -617,6 +641,7 @@ namespace OHOS } RecordingMp3FileCount = 0; MaxRecordingNumber = 0; + usedRecordingTime = 0; /* -------------------------------------------------------------------------- */ SearchFiles(directory, Recordings, RecordingMp3FileCount); if (RecordingMp3FileCount != 0) @@ -908,16 +933,59 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingDuration %s", recordingInfo.recordingDuration); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordingTime %s", recordingInfo.recordingTime); } + + /*设置当前哪个子视图是可见的*/ + void RecordingModel::SetCurView(int16_t viewNum) + { + curView = viewNum; + } + + /*获取当前哪个子视图是可见的*/ + int RecordingModel::GetCurView(void) + { + return curView; + } + int RecordingModel::GetUsedRecordingTime(void) + { + return usedRecordingTime; + } + + // 检查录音时间是否超时 + bool RecordingModel::CheckRecordingTimeOut(int time) + { + if (time >= TOTAL_RECORDING_TIME) + { + return true; + } + return false; + } + + // 检查录音空间是否满了 + void RecordingModel::CheckRecordingSpaceOut(void) + { + long long size = SystemLogModel::GetInstance()->getFolderSize(TOTAL_RECORDING_SPACE_PATH); + if (size >= TOTAL_RECORDING_SPACE) + { + RecordingSpaceIsOut = true; + } + else + { + RecordingSpaceIsOut = false; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingModel::CheckRecordingSpaceOut:%d", RecordingSpaceIsOut); + } + + bool RecordingModel::GetCheckRecordingSpaceOut(void) + { + return RecordingSpaceIsOut; + } + + void RecordingModel::SendCheckRecordingSpaceOutCmd(void) + { + do_custom_fileoperate_service_check_msg(CUSTOM_FILEOPERATE_MSG_TYPE_RECORDING_SPACE_READ, nullptr, 0); + } + /* ----------------------------------- 定时器 ---------------------------------- */ - // 声明定时器变量 - osTimerId_t g_timer = NULL; - static int g_RecordingTimes = {0}; - static constexpr int32 NUM_TEN = 10; - static constexpr int16 ERROR = 0; - static constexpr int16 SUCCESS = 1; - static constexpr int16 NUM_TIME_MIN = 60; - static constexpr int16 NUM_TIME_HOUR = 3600; - static constexpr int32 NUM_TIME_DAY = 86400; /* * @brief 显示录音时长 @@ -980,7 +1048,7 @@ namespace OHOS */ static void Recording_TimerCallbackProc(int data) { - #if 0 +#if 0 g_RecordingTimes++; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_RecordingTimes:%d\n", g_RecordingTimes); @@ -1003,7 +1071,26 @@ namespace OHOS } RecordGoingView::GetInstance()->GetRecordingDurationLabel()->SetText(RecordingModel::GetInstance()->DisplayRecordDuration()); - #endif +#endif + int g_TotalUsedTime = RecordingModel::GetInstance()->GetUsedRecordingTime(); // 已用时间 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_RecordingTimes + g_TotalUsedTime = %d", g_RecordingTimes + g_TotalUsedTime); + if (RecordingModel::GetInstance()->CheckRecordingTimeOut(g_RecordingTimes + g_TotalUsedTime)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Recording_TimerCallback g_TotalUsedSpace >= TOTAL_RECORDING_TIME"); + // 录取时长不足,停止录制并弹出警告 + if (RecordingPresenter::GetInstance()) + { + ScreenTurnOn(3 * 1000); // 亮屏3s + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + // 震动提醒 + ui_api_vibrate_once_func(); + } + RecordingPresenter::GetInstance()->StopRecord(); // 停止录制 + RecordingPresenter::GetInstance()->showWarning(); // 显示警告 + } + } + g_RecordingTimes++; } /* @@ -1011,9 +1098,7 @@ namespace OHOS */ static void Recording_TimerCallback(int data) { - g_RecordingTimes++; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_RecordingTimes:%d\n", g_RecordingTimes); - // GraphicService::GetInstance()->PostGraphicEvent(std::bind(Recording_TimerCallbackProc, data)); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(Recording_TimerCallbackProc, data)); } /* @@ -1077,4 +1162,21 @@ namespace OHOS } } -} \ No newline at end of file +} +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + void CheckRecordingSpaceOutC(void) + { + OHOS::RecordingModel::GetInstance()->CheckRecordingSpaceOut(); + } + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingNumLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingNumLimitView.cpp index 1cf98c5a0..32e421644 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingNumLimitView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingNumLimitView.cpp @@ -120,7 +120,8 @@ namespace OHOS image->SetSrc(PNG_ATTENTION_IMAGE); scrollView->Add(image); } - /* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +#if 0 labelconfig = { .left = 53, .top = 222, @@ -141,6 +142,25 @@ namespace OHOS } scrollView->Add(note); } +#else + if (note == nullptr) + { + note = new UILabelExt(); + if (note == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "note can not be nullptr!"); + return nullptr; + } + note->SetPosition(53, 222, 360, 70); // 位置大小 + note->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + note->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + note->SetText("录音空间已满"); + note->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); // 断行模式。 + note->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + note->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView->Add(note); + } +#endif /* -------------------------------------------------------------------------- */ if (goitbutton == nullptr) { @@ -150,7 +170,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goitbutton can not be nullptr!"); return nullptr; } - goitbutton->SetPosition(93, note->GetY() + note->GetTextHeight() + 48, 280, 90); + goitbutton->SetPosition(93, 340, 280, 90); goitbutton->SetViewId(RECORDINGNUMLIMITBUTTONVIEW); goitbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); goitbutton->SetStyle(STYLE_BACKGROUND_OPA, 0xff); diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp index d6a1544b3..e7846e738 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-20 17:14:02 + * @LastEditTime: 2024-10-21 17:01:15 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp */ @@ -49,6 +49,7 @@ namespace OHOS // 初始化录音信息 p_RecordingModel->InitRecordingListItem(); p_RecordingModel->AudioInit(); + p_RecordingModel->SendCheckRecordingSpaceOutCmd(); //进入录音视图后发送指令查看录音空间是否已满 Presenter::OnStart(); // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); } @@ -232,9 +233,19 @@ namespace OHOS p_RecordingModel->RecordDataWriteToFile(recordingFileName.c_str()); RecordingModel::GetInstance()->InitRecordingListItem(); + p_RecordingModel->SendCheckRecordingSpaceOutCmd(); //录音完后发送指令查看录音空间是否已满 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView StopRecord over!!"); } + //弹窗警告 + void RecordingPresenter::showWarning(void) + { + if(view_) + { + view_->ChangeView(RecordingModel::GetInstance()->GetCurView(), RECORDINGEXCELIMIT); + } + } + bool RecordingPresenter::OnClick(UIView &view, const ClickEvent &event) { RecordingView *p_RecordingView = RecordingView::GetInstance(); @@ -246,7 +257,10 @@ namespace OHOS if (strcmp(view.GetViewId(), RECORD_BUTTON) == 0) { - if (p_RecordingModel->GetRecordingListNum() >= MAX_RECORDING_NUM) + int g_TotalUsedTime = RecordingModel::GetInstance()->GetUsedRecordingTime(); // 已用时间 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_TotalUsedTime:%d", g_TotalUsedTime); + if (p_RecordingModel->CheckRecordingTimeOut(g_TotalUsedTime) || p_RecordingModel->GetRecordingListNum() >= MAX_RECORDING_NUM || + p_RecordingModel->GetCheckRecordingSpaceOut()) { view_->ChangeView(RECORDINGVIEW, RECORDINGEXCELIMIT); return true; @@ -419,10 +433,11 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordListViewListener::OnDrag"); UNUSED(view); - if ((event.GetDeltaY() > X_DRAG_OFFSET) && (event.GetDeltaY() > (DOUBLES * MATH_ABS(event.GetDeltaX())))) // 如果滑动的为直线 - { - RecordListViewListener::X_DRAG_FLAG = true; - } + UNUSED(event); + // if ((event.GetDeltaY() > X_DRAG_OFFSET) && (event.GetDeltaY() > (DOUBLES * MATH_ABS(event.GetDeltaX())))) // 如果滑动的为直线 + // { + // RecordListViewListener::X_DRAG_FLAG = true; + // } return true; } @@ -431,12 +446,12 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordListViewListener::OnDragEnd"); std::string viewId = view.GetViewId(); - if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM && RecordListViewListener::X_DRAG_FLAG) + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { if (RecordingView::GetInstance() != nullptr && viewId == RECORDLISTSCROLLVIEW) { RecordingView::GetInstance()->ChangeView(RECORDINGLISTVIEW, RECORDINGVIEW); - RecordListViewListener::X_DRAG_FLAG = false; + // RecordListViewListener::X_DRAG_FLAG = false; } } return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp index af9d7d29a..5dcb6f150 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp @@ -312,6 +312,7 @@ namespace OHOS RecordingViewScrollView[hideView]->SetVisible(false); ClickFunc(showView); RecordingViewScrollView[showView]->SetVisible(true); + RecordingModel::GetInstance()->SetCurView(showView); Draw(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h index a8050a144..8da4aeea3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h @@ -8,13 +8,13 @@ #include #define TOTAL_MUSIC_SPACE (10 * 1024 * 1024) // 10M -#define TOTAL_MUSIC_SPACE_PATH "/user/musci/usermusci" +#define TOTAL_MUSIC_SPACE_PATH "/user/music/user_music" #define TOTAL_RECORDING_SPACE (10 * 1024 * 1024) // 10M -#define TOTAL_RECORDING_SPACE_PATH "/user/musci/recording" +#define TOTAL_RECORDING_SPACE_PATH "/user/music/recording" #define TOTAL_RING_SPACE (2 * 1024 * 1024) // 2M -#define TOTAL_RING_SPACE_PATH "/user/musci/ring" +#define TOTAL_RING_SPACE_PATH "/user/music/ring" #define TOTAL_DIAL_SPACE (24 * 1024 * 1024) // 24M #define TOTAL_DIAL_SPACE_PATH "/user/dial/offline_dial" diff --git a/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c b/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c index e065e1cc1..7842fe860 100644 --- a/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c +++ b/code/sdk/drivers/peripheral/utils/custom_fileoperate_service.c @@ -44,6 +44,7 @@ #include "sleep/include/SleepModelC.h" #include "player/include/PlayersModelC.h" +#include "record/include/RecordingModelC.h" #include "mmc5603_hal.h" @@ -147,6 +148,10 @@ static void custom_fileoperate_service_check_task(void const *arg) case CUSTOM_FILEOPERATE_MSG_TYPE_MUSICNAME_READ: custom_setUpListCase(); break; + + case CUSTOM_FILEOPERATE_MSG_TYPE_RECORDING_SPACE_READ: + CheckRecordingSpaceOutC(); + break; default: PRINT("Unknown CUSTOM_FILE_OPERATE_MSG cmd 0x%02X \r\n", mail.cmd); break; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 47d000078..26cb5ea9f 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -2075,6 +2075,8 @@ void uapi_restore_factory_setting(void) "/user/system/ConfigModel.json", "/user/userdata", "/user/system/kvstore", + "/user/music/user_music", + "/user/music/recording", "/user/dial/custom_dial/", //自定义表盘 "/user/dial/offline_dial/",//离线表盘 }; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index d2c495a6c..2f8ccb1c7 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -257,6 +257,8 @@ errcode_t do_custom_cmd_service_check_msg_head(int cmd, void *params, int paraml #define CUSTOM_FILEOPERATE_MSG_TYPE_MUSICNAME_READ 0x0C //读取音乐文件名 +#define CUSTOM_FILEOPERATE_MSG_TYPE_RECORDING_SPACE_READ 0x0D //读取录音空间 + errcode_t uapi_custom_fileoperate_service_init(void); errcode_t do_custom_fileoperate_service_check_msg(int cmd, void *params, int paramlen); diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp index f3013253c..b475d99e7 100755 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp @@ -41,7 +41,8 @@ using Audio::AudioInterrupt; using Audio::AudioManager; #define PLAYER_CONTROL_CMD_LEN 20 #define READ_RETRY_TIME_US 10000 -#define READ_COUNT_MAX 1000 +// #define READ_COUNT_MAX 1000 //原 +#define READ_COUNT_MAX 17000*2 //改过的 20分钟 #define GET_AUDIO_TIME_INTERVAL_TIMES 100 #define MAX_ARGC 5 -- 2.17.1