Merge #1233 into sdk602patch0911 from refs/changes/1233/head
author袁清梦 <3449750381@qq.com>
Mon, 21 Oct 2024 11:50:55 +0000 (11:50 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Mon, 21 Oct 2024 11:50:55 +0000 (11:50 +0000)
Code review from 袁清梦

* refs/changes/1233/head: (15 commits squashed)

  - #105 5手表开启勿扰模式表盘界面会显示勿扰图标,重启后表盘勿扰图标消失(实际还是勿扰状态,下拉状态栏的勿扰图标是高亮的)

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - 系统:删除res无用资源

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - 语音助手:修复对话界面的异常滑动

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - 表盘:同步修改表盘分区路径

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - 系统:增加6个功能文件夹的内存查询显示

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - 心率:增加弹窗脱腕(待添加)

  - 表盘:增加表盘数量与空间校验

  - 表盘:同步ble修改(已验证)

  - 表盘:优化ble安装表盘的错误弹窗显示

Signed-off-by: Caisking <3449750381@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1233
14 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartNoteView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartNoteView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp
code/sdk/application/wearable/fd230app/nativeui/set_dial/include/SetDialModel.h
code/sdk/application/wearable/fd230app/nativeui/set_dial/include/SetDialModelC.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp
code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.h
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/drivers/peripheral/utils/custom_cmd_service.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index 4e48b3f..85bddc1 100644 (file)
@@ -194,6 +194,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartChartView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartChartPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartRateCardView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartNoteView.cpp
 
     #BloodCheck
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/src/BloodResultView.cpp
diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartNoteView.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartNoteView.h
new file mode 100644 (file)
index 0000000..667dfa9
--- /dev/null
@@ -0,0 +1,63 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-30 11:46:23
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/HeartNoteView.h
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-05-07 18:51:13
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/HeartNoteView.h
+ */
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: bloodResult view
+ * Author:
+ * Create: 2021-08-01
+ */
+
+#ifndef HEART_NOTE_VIEW_H
+#define HEART_NOTE_VIEW_H
+
+#include "View.h"
+#include "BaseView.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_label_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_circle_progress.h"
+#include "components/ui_view_group.h"
+
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_button_ext.h"
+namespace OHOS {
+
+#define CLICK_HEART_STOP "click_heart_stop"
+#define CLICK_HEART_RESTART "click_heart_restart"
+
+    class HeartNoteView 
+    {
+    public:
+        HeartNoteView();
+        virtual ~HeartNoteView();
+        UIScrollView *CreateHeartNoteView(void);
+
+      private:
+        bool CrearAllView();
+        // 提醒图标
+        UIImageView *noteimage = nullptr;
+        // 按键
+        UILabelButtonExt *StButton = nullptr;
+        UILabelButtonExt *ReButton = nullptr;
+        // 提醒label
+        UILabelExt *titleLabel = nullptr;
+        UILabelExt *noteLabel = nullptr;
+        UIScrollView *heartNoteView = nullptr;
+    };
+}
+
+#endif // 血氧主界面
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartNoteView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartNoteView.cpp
new file mode 100644 (file)
index 0000000..d832a5e
--- /dev/null
@@ -0,0 +1,115 @@
+
+#include "heartrate/include/HeartNoteView.h"
+#include "heartrate/include/HeartChartPresenter.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <custom_utils.h>
+namespace OHOS {
+
+static const char *ICON_PATH_NOTE = "/user/res/Blood/Error.bin";
+
+HeartNoteView::HeartNoteView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartNoteView::HeartNoteView");
+}
+
+HeartNoteView::~HeartNoteView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartNoteView::~HeartNoteView");
+  CrearAllView();
+}
+
+bool HeartNoteView::CrearAllView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartNoteView::CrearAllView");
+  if (heartNoteView) {
+    heartNoteView->RemoveAll();
+    if (noteimage) {
+      delete noteimage;
+      noteimage = nullptr;
+    }
+    if (StButton) {
+      delete StButton;
+      StButton = nullptr;
+    }
+    if (ReButton) {
+      delete ReButton;
+      ReButton = nullptr;
+    }
+    if (titleLabel) {
+      delete titleLabel;
+      titleLabel = nullptr;
+    }
+    if (noteLabel) {
+      delete noteLabel;
+      noteLabel = nullptr;
+    }
+    delete heartNoteView;
+    heartNoteView = nullptr;
+  }
+  return true;
+}
+UIScrollView *HeartNoteView::CreateHeartNoteView(void) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "CreateHeartNoteView::CreateHeartNoteView");
+  /* --------------------------------------------------------------------------
+   */
+  if (heartNoteView == nullptr) {
+    heartNoteView = new UIScrollView();
+    if (heartNoteView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartNoteView new fail");
+      return nullptr;
+    }
+  }
+  heartNoteView->SetPosition(0, 0, 466, 466);
+  heartNoteView->SetScrollBlankSize(50);
+  heartNoteView->SetReboundSize(35);
+  heartNoteView->SetThrowDrag(true);
+  heartNoteView->SetMaxScrollDistance(1000);
+  heartNoteView->SetDirection(UIScrollView::VERTICAL);
+  // 设置拖拽监听器
+  UIView::OnDragListener *dragListener =
+      static_cast<UIView::OnDragListener *>(HeartChartPresenter::GetInstance());
+  if (!dragListener) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                  "HeartChartPresenter::获取实例失败!");
+    return nullptr; // 获取失败,返回空指针
+  }
+  heartNoteView->SetOnDragListener(dragListener);
+
+  /* 初始化图片 */
+  InitImageView(noteimage, 193, 120, 80, 80, "image", ICON_PATH_NOTE);
+
+  /*初始化title*/
+  InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_CHECKERROR,
+               DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabelExt(noteLabel, 53, 230, 360, 70, "time", STR_PWUWC,
+               DEFAULT_VECTOR_FONT_FILENAME, 30);
+  // 设置来回滚动属性
+  noteLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  noteLabel->SetRollSpeed(70);
+
+  /*初始化button*/
+  InitButtonExt(StButton, 58, 320, 170, 90, CLICK_HEART_STOP, STR_STOP, 30);
+  StButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); // 设置按键颜色
+
+  UIView::OnClickListener *buttonClickst =
+      static_cast<UIView::OnClickListener *>(
+          HeartChartPresenter::GetInstance());
+  StButton->SetOnClickListener(buttonClickst);
+
+  InitButtonExt(ReButton, 238, 320, 170, 90, CLICK_HEART_RESTART, STR_RECHECK,
+                30);
+  ReButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色
+  UIView::OnClickListener *buttonClickre =
+      static_cast<UIView::OnClickListener *>(
+          HeartChartPresenter::GetInstance());
+  ReButton->SetOnClickListener(buttonClickre);
+
+  heartNoteView->Add(noteimage);
+  heartNoteView->Add(titleLabel);
+  heartNoteView->Add(noteLabel);
+  heartNoteView->Add(StButton);
+  heartNoteView->Add(ReButton);
+
+  return heartNoteView;
+}
+} // namespace OHOS
\ No newline at end of file
index ae26772..863c5f0 100644 (file)
@@ -62,7 +62,7 @@ namespace OHOS
         {DIAL_CLOCK_5, "Custom_5", CUSTOM_CLOCK5_DIALPER_PATH, DEFAULT_TASK_PERIOD}, // 表盘 Id 4\r
     };\r
     //默认表盘\r
-    static const char* DEFAULT_CUSTOM_DIAL_PATH = "/user/dial/obsidianrhythm.bin";\r
+    static const char* DEFAULT_CUSTOM_DIAL_PATH = "/user/dial/res_dial/obsidianrhythm.bin";\r
     //卡片map\r
     const CardInfo printfMap[] = {\r
         {HEART_RATE, "心率卡片"},\r
index ef0fcfa..beb9165 100644 (file)
@@ -35,8 +35,14 @@ namespace OHOS
     constexpr uint16_t CUSTOM_DIAL_ID_5 = 5;
     #define DIAL_ID_LENGTH 2
     #define DIAL_NAME_LENGTH 50
-    #define DIAL_ID_PATH "user/dial/dial_id.bin"
+    #define DIAL_ID_PATH "user/userdata/dial_id.bin"
 
+    #define DIAL_MAX_NUM 21
+    #define DIAL_CUSTOM_MAX_NUM 1
+    #define DIAL_OFFLINE_DIAL_MAX_NUM 14
+    #define DIAL_RES_DIAL_MAX_NUM 6
+
+    
     class SetDialModel
     {
     public:
@@ -76,7 +82,11 @@ namespace OHOS
         bool DeleteCustomDial(uint16_t Id);
         void TestDialConfig(void);
         std::string GetSaveDir(int Id,uint8_t type);
-        void RegisterDial(uint16_t ID, const char *dialname,uint8_t type); 
+        void RegisterDial(uint16_t ID, const char *dialname, uint8_t type);
+
+        //判断是否可以继续下载表盘
+        bool CheckDialDownload(uint16_t ID,uint32_t dial_size);
+        void CheckDialSpace();
 
     private:
         void LoadAllDialFromRam(void);
@@ -89,6 +99,10 @@ namespace OHOS
         int32_t ParseDialHeader(int type, const std::string &dialFileName, SetDialInfo &dialInfo);
         std::vector<SetDialInfo> dialInfoList;
         uint16_t currentDialID = 114; // 设置表盘默认值
+
+        uint16_t download_DialID = 1028;
+        uint32_t download_dialSize = 0;
+        bool downloadstate = false;
     };
 }
 
diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_dial/include/SetDialModelC.h b/code/sdk/application/wearable/fd230app/nativeui/set_dial/include/SetDialModelC.h
new file mode 100644 (file)
index 0000000..bc6bf7b
--- /dev/null
@@ -0,0 +1,15 @@
+
+#ifndef SET_DIAL_MODEL_C_H
+#define SET_DIAL_MODEL_C_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void check_dial_space(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
index a6cc799..850dfff 100644 (file)
@@ -1,13 +1,15 @@
-
-#include "SetDialModel.h"
+#include "set_dial/include/SetDialModel.h"
 #include "DialBinParser.h"
 #include "MainModel.h"
 #include "NativeAbility.h"
 #include "clock/include/MainClockView.h"
+#include "custom_runtime.h"
 #include "custom_utils.h"
 #include "dirent.h"
 #include "kv_store.h"
 #include "securec.h"
+#include "set_dial/include/SetDialModelC.h"
+#include "system/include/SystemLogModel.h"
 #include "wearable_log.h"
 #include <algorithm>
 #include <array>
 #include <string>
 #include <sys/stat.h>
 #include <unistd.h>
+
+extern "C" {
+void check_dial_space() { OHOS::SetDialModel::GetInstance().CheckDialSpace(); }
+}
 namespace OHOS {
 
 // 表盘map[Id--dialname] 前5个ID固定
@@ -35,7 +41,7 @@ std::unordered_map<uint16_t, std::string> registeredDials{
 
     /*
       TODO:增加表盘
-      {DEFAULT_DIAL_ID_3, "smart_payment"}, // 智能支付表盘
+      {DEFAULT_DIAL_ID_3, "dawn_insight"}, // 晨曦智影
       {MAX_DEFAULT_DIAL_ID, "kumi_point"},  // kumi指针表盘
     */
 
@@ -101,8 +107,8 @@ bool SetDialModel::readDialfile() {
 }
 
 SetDialModel::SetDialModel() {
-  readDialfile();    // 读取表盘map配置文件
   LoadAllDial();     // 更新表盘个数 当前表盘
+  readDialfile();    // 读取表盘map配置文件
   char idBuffer[10]; // 读取表盘Id配置文件
   int len = UtilsGetValue("dial_id", idBuffer, sizeof(idBuffer));
   if (len >= 0) {
@@ -184,7 +190,7 @@ uint16_t SetDialModel::GetCurrentDialID() {
   return id;
 }
 /* 获取所有表盘Id 每个表盘Id 2个字节 拼接为字符串 */
-int SetDialModel::GetAllDialIDs(char *allidStr,uint16_t MAX_LEN) {
+int SetDialModel::GetAllDialIDs(char *allidStr, uint16_t MAX_LEN) {
   std::string allIDs;
   int length = 0;
   for (const auto &entry : registeredDials) {
@@ -192,8 +198,8 @@ int SetDialModel::GetAllDialIDs(char *allidStr,uint16_t MAX_LEN) {
     if (id <= 5) {
       id--;
     }
-    if(length<MAX_LEN)
-    memcpy_s(allidStr + length, 512, &id, 2);
+    if (length < MAX_LEN)
+      memcpy_s(allidStr + length, 512, &id, 2);
     length += 2;
   }
 
@@ -326,6 +332,8 @@ bool SetDialModel::DeleteCustomDial(uint16_t Id) {
   WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP,
                 "DeleteCustomDial: Successfully deleted custom dial with ID %d",
                 Id);
+  //删除表盘,更新id文件
+  saveDialfile();
   return true;
 }
 
@@ -452,7 +460,7 @@ void SetDialModel::LoadAllDial() {
 
   // 表盘Id以及表盘map打印
   char dialId[128];
-  GetAllDialIDs(dialId,128);
+  GetAllDialIDs(dialId, 128);
   PrintRegisteredDials(registeredDials);
 }
 /*加载离线表盘*/
@@ -858,4 +866,55 @@ std::string SetDialModel::GetCustomName(int Id) {
   return (info->dialName);
 }
 
+//判断是否可以继续下载表盘
+void SetDialModel::CheckDialSpace() {
+  downloadstate = true;
+  //安装离线表盘
+  if (download_DialID > 5) {
+    //离线表盘 判断当前离线表盘个数
+    uint8_t offlinedial_num =
+        DIAL_OFFLINE_DIAL_MAX_NUM -
+        (GetDialCount() - DIAL_CUSTOM_MAX_NUM - DIAL_RES_DIAL_MAX_NUM);
+    if (offlinedial_num <= 0) {
+      //离线表盘个数已到上限
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "CheckDialSpace: Offline dial count %d", offlinedial_num);
+      downloadstate = false;
+      return;
+    } else {
+      //判断offlinedial文件夹内存是否可以继续存储
+      downloadstate = SystemLogModel::GetInstance()->canSyncFile(
+          TOTAL_DIAL_SPACE_PATH, TOTAL_DIAL_SPACE, download_dialSize);
+      //离线表盘
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckDialSpace: Offline dial %d",
+                    downloadstate);
+      return;
+    }
+  } else {
+    //安装自定义表盘
+    downloadstate = SystemLogModel::GetInstance()->canSyncFile(
+        TOTAL_CUSTOM_DAIL_SPACE_PATH, TOTAL_CUSTOM_DAIL_SPACE,
+        download_dialSize);
+    //自定义表盘
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckDialSpace: Custom dial %d",
+                  downloadstate);
+  }
+}
+
+bool SetDialModel::CheckDialDownload(uint16_t ID, uint32_t dial_size) {
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckDialDownload: %d %d", ID,
+                dial_size);
+
+  download_DialID = ID;
+  download_dialSize = dial_size;
+
+  // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CHECK_DIAL_SPACE, nullptr,0);
+  CheckDialSpace();
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckDialDownload: %d",
+                downloadstate);
+  return downloadstate;
+}
+
 } // namespace OHOS
index b4849c4..a8050a1 100644 (file)
@@ -16,7 +16,7 @@
 #define TOTAL_RING_SPACE (2 * 1024 * 1024) // 2M
 #define TOTAL_RING_SPACE_PATH "/user/musci/ring"
 
-#define TOTAL_DIAL_SPACE (27 * 1024 * 1024) // 27M
+#define TOTAL_DIAL_SPACE (24 * 1024 * 1024) // 24M
 #define TOTAL_DIAL_SPACE_PATH "/user/dial/offline_dial"
 
 #define TOTAL_RES_DIAL_SPACE (7 * 1024 * 1024) // 7M
index f3924d5..d6eeba4 100644 (file)
 #include <cstring>
 #include <ctime>
 #include <deque>
+#include <dirent.h>
 #include <fstream>
 #include <iomanip>
 #include <iostream>
 #include <sstream>
 #include <stdexcept>
+#include <stdio.h>
 #include <string>
+#include <sys/stat.h>
 #include <sys/statfs.h>
 #include <sys/time.h>
 #include <thread>
 #include <vector>
-#include <stdio.h>
-#include <dirent.h>
-#include <sys/stat.h>
 
-#define SYSTEM_LOG_FILE_PATH "/system/system_log.txt"
-#define SYSTEM_LOG_FILE_PATH_NEXTDAY "/system/system_log_nextday.txt"
-#define SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS "/system/popup_windows_log.txt"
+#define SYSTEM_LOG_FILE_PATH "/user/system/system_log.txt"
+#define SYSTEM_LOG_FILE_PATH_NEXTDAY "/user/system/system_log_nextday.txt"
+#define SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS "/user/system/popup_windows_log.txt"
 
 extern "C" {
 // 通用日志记录功能
@@ -142,6 +142,40 @@ const std::deque<SystemLogData> &SystemLogModel::getLogData() const {
 // 获取日志大小
 size_t SystemLogModel::getLogSize() const { return logData.size(); }
 
+long long SystemLogModel::getFolderSize(const char *folderPath) {
+  DIR *dir;
+  struct dirent *entry;
+  struct stat fileStat;
+  long long totalSize = 0;
+
+  dir = opendir(folderPath);
+  if (dir == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error opening directory");
+    return 0;
+  }
+
+  while ((entry = readdir(dir)) != NULL) {
+    char filePath[1024];
+    snprintf(filePath, sizeof(filePath), "%s/%s", folderPath, entry->d_name);
+
+    if (stat(filePath, &fileStat) == -1) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error getting file status");
+      continue;
+    }
+
+    if (S_ISDIR(fileStat.st_mode)) {
+      if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+        continue;
+      totalSize += getFolderSize(filePath);
+    } else {
+      totalSize += fileStat.st_size;
+    }
+  }
+
+  closedir(dir);
+  return totalSize;
+}
+
 //获取系统内存
 /*
 [FS INFO]total size=12416KB used size=8114KB free size=4302KB
@@ -154,17 +188,11 @@ size_t SystemLogModel::getLogSize() const { return logData.size(); }
 */
 std::string SystemLogModel::get_system_mem_info() {
   struct statfs file_buf = {0};
-  std::stringstream result; // 使用 stringstream 来构建返回的字符串
-  const std::vector<std::string> volume_names = {"/system/", "/update/",
-                                                 "/music/", "/user/"};
-
-  for (const auto &volume : volume_names) {
-    // 获取文件系统状态
-    if (statfs(volume.c_str(), &file_buf) != 0) {
-      result << "Error retrieving info for " << volume << std::endl;
-      continue;
-    }
-
+  std::stringstream result;
+  std::string system_volume_name = "/user/";
+  if (statfs(system_volume_name.c_str(), &file_buf) != 0) {
+    result << "Error retrieving info for " << system_volume_name << std::endl;
+  } else {
     // 计算总大小、已用大小和自由空间
     uint64_t total_size =
         static_cast<uint64_t>(file_buf.f_blocks) * file_buf.f_bsize;
@@ -173,63 +201,47 @@ std::string SystemLogModel::get_system_mem_info() {
     uint64_t used_size = total_size - free_size;
 
     // 按照所需格式输出
-    result << "[" << volume << "]" << std::endl;
-    result << "Total size=" << total_size / 1024 << "KB " << std::endl;
-    result << "Used size=" << used_size / 1024 << "KB " << std::endl;
-    result << "Free size=" << free_size / 1024 << "KB" << std::endl;
+    result << "[" << system_volume_name << "]" << std::endl;
+    result << "Total size = " << total_size / 1024 << " KB" << std::endl;
+    result << "Used size = " << used_size / 1024 << " KB" << std::endl;
+    result << "Free size = " << free_size / 1024 << " KB" << std::endl;
+    result << "====================" << std::endl; // 分隔线
   }
 
-  // 返回所有分区的自由空间信息,如果没有信息,则返回说明信息
-  return result.str().empty() ? "No volumes found or accessible."
-                              : result.str();
-}
-
-
-
-long long SystemLogModel::getFolderSize(const char* folderPath) {
-    DIR* dir;
-    struct dirent* entry;
-    struct stat fileStat;
-    long long totalSize = 0;
-
-    dir = opendir(folderPath);
-    if (dir == NULL) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error opening directory");
-        return 0;
-    }
+  std::vector<std::string> volume_names = {
+      "/user/dial/", "/user/music/",  "/user/update/",
+      "/user/res/",  "/user/system/", "/user/userdata/",
+  };
 
-    while ((entry = readdir(dir))!= NULL) {
-        char filePath[1024];
-        snprintf(filePath, sizeof(filePath), "%s/%s", folderPath, entry->d_name);
-
-        if (stat(filePath, &fileStat) == -1) {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error getting file status");
-            continue;
-        }
-
-        if (S_ISDIR(fileStat.st_mode)) {
-            if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
-                continue;
-            totalSize += getFolderSize(filePath);
-        } else {
-            totalSize += fileStat.st_size;
-        }
+  // 遍历每个目录,获取文件系统状态
+  for (const auto &volume_name : volume_names) {
+    // 获取文件系统状态
+    uint64_t total_size = getFolderSize(volume_name.c_str());
+    if (total_size == 0) {
+      result << "Error retrieving info for " << volume_name << std::endl;
+    } else {
+      // 计算总大小
+      result << "[" << volume_name << "]" << std::endl;
+      result << "Total size = " << total_size / 1024 << " KB" << std::endl;
+      result << "====================" << std::endl; // 分隔线
     }
+  }
 
-    closedir(dir);
-    return totalSize;
+  // 如果没有信息,则返回说明信息
+  return result.str().empty() ? "No volumes found or accessible."
+                              : result.str();
 }
 
 // 检查是否可以同步文件
-bool SystemLogModel::canSyncFile(std::string path,uint32_t path_max_size,uint32_t download_size)
-{
-    // 获取文件夹的大小
-    long long usedSpace = getFolderSize(path.c_str());
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "usedSpace = %lld",usedSpace);
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "path_max_size = %lld",path_max_size);
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "download_size = %lld",download_size);
-
-    return (usedSpace + download_size) <= path_max_size;
+bool SystemLogModel::canSyncFile(std::string path, uint32_t path_max_size,
+                                 uint32_t download_size) {
+  // 获取文件夹的大小
+  long long usedSpace = getFolderSize(path.c_str());
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "usedSpace = %lld", usedSpace);
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "path_max_size = %lld", path_max_size);
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "download_size = %lld", download_size);
+
+  return (usedSpace + download_size) <= path_max_size;
 }
 // nextday相关
 bool SystemLogModel::save_nextday_log(uint32_t timestamp) {
@@ -282,69 +294,68 @@ size_t SystemLogModel::get_nextday_log_size() const {
 }
 
 // 保存popup_windows日志
-bool SystemLogModel::save_popup_windows_log(popup_windows_log_data data)                
-{
-    // 保存新日志
-    popup_windows_log.push_back(data);
-
-    // 将日志写入文件
-    std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::app);
-    if (!outFile) {
-      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open log file for writing");
-      return false; // 文件打开失败
-    }
+bool SystemLogModel::save_popup_windows_log(popup_windows_log_data data) {
+  // 保存新日志
+  popup_windows_log.push_back(data);
+
+  // 将日志写入文件
+  std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::app);
+  if (!outFile) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Failed to open log file for writing");
+    return false; // 文件打开失败
+  }
 
-    // 将结构体中的数据转换为字符串格式写入文件
-    outFile << static_cast<int>(data.type) << " " << data.timestamp << std::endl;
-    outFile.close();
-    return true;
+  // 将结构体中的数据转换为字符串格式写入文件
+  outFile << static_cast<int>(data.type) << " " << data.timestamp << std::endl;
+  outFile.close();
+  return true;
 }
 
-bool SystemLogModel::load_popup_windows_log()                                           
-{
-    std::ifstream inFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS);
-    if (!inFile) {
-      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open log file for reading");
-      return false; // 无法打开文件
-    }
+bool SystemLogModel::load_popup_windows_log() {
+  std::ifstream inFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS);
+  if (!inFile) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Failed to open log file for reading");
+    return false; // 无法打开文件
+  }
 
-    std::string line;
-    while (std::getline(inFile, line)) {
-        std::istringstream ss(line);
-        popup_windows_log_data data;
-        int typeInt;
-        if (ss >> typeInt >> data.timestamp) {
-            data.type = static_cast<popup_windows_type>(typeInt);
-            popup_windows_log.push_back(data);
-        }
+  std::string line;
+  while (std::getline(inFile, line)) {
+    std::istringstream ss(line);
+    popup_windows_log_data data;
+    int typeInt;
+    if (ss >> typeInt >> data.timestamp) {
+      data.type = static_cast<popup_windows_type>(typeInt);
+      popup_windows_log.push_back(data);
     }
+  }
 
-    inFile.close();
-    return true;
+  inFile.close();
+  return true;
 }
 // 获取popup_windows日志记录(常量引用)
-const std::deque<popup_windows_log_data> &SystemLogModel::get_popup_windows_log() const 
-{
+const std::deque<popup_windows_log_data> &
+SystemLogModel::get_popup_windows_log() const {
   return popup_windows_log;
 }
 // 获取日志大小
-size_t SystemLogModel::get_popup_windows_log_size() const                               
-{
+size_t SystemLogModel::get_popup_windows_log_size() const {
   return popup_windows_log.size();
 }
 
-void SystemLogModel::clear_popup_windows_log()
-{
-   // 清空当前的日志
+void SystemLogModel::clear_popup_windows_log() {
+  // 清空当前的日志
   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clear_popup_windows_log");
   popup_windows_log.clear();
-  
+
   std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::trunc);
   if (!outFile) {
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open log file for writing");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Failed to open log file for writing");
     return;
   }
-  outFile<<"";
+  outFile << "";
   outFile.close();
 }
 } // namespace OHOS
index c58611b..d72f6c3 100644 (file)
@@ -918,6 +918,10 @@ void get_sedent_param(  msg_sedent_set_param_info_t * data)
     return;
 }
 
+bool check_dial_freespace(uint16_t id,uint32_t dial_size) {
+  return OHOS::SetDialModel::GetInstance().CheckDialDownload(id,dial_size);
+}
+
 void ble_get_dial_path(char * buf,uint16_t id)
 {
     char *path= (char*)OHOS::SetDialModel::GetInstance().GetSaveDir(id,0).c_str();
index f20fafe..e4e41d3 100644 (file)
@@ -247,7 +247,9 @@ bool dial_file_save(void);
 
 void ble_save_dial_custom(msg_recv_custom_dial_info_t *data);
 
-void ble_get_custom_dial(uint16_t id,char *buf);
+void ble_get_custom_dial(uint16_t id, char *buf);
+
+bool check_dial_freespace(uint16_t id,uint32_t dial_size);
 
 //////////////////////久坐提醒////////////////////////////
 void set_sedent_param(  msg_sedent_set_param_info_t * data);
index 6563c35..7330aad 100644 (file)
@@ -7284,8 +7284,11 @@ errcode_t decode_single_dial_info(ble_read_data *buffer_handle)
     ble_dial_uid = dialinfo.dial_uid;\r
     // if(ble_dial_uid<=4)\r
     // ble_dial_uid++;\r
-    \r
 \r
+    if (check_dial_freespace(ble_dial_uid, file_size) == false)\r
+    {\r
+        return ERRCODE_FAIL;\r
+    }\r
 \r
     buffer_handle->file_recv_stat.file_name = filename;\r
     buffer_handle->file_recv_stat.file_size = file_size;\r
@@ -7760,10 +7763,10 @@ void type2AE0Data(ble_read_data *buffer_handle)
                 if (decode_single_dial_info(buffer_handle) == ERRCODE_SUCC)\r
                 {\r
                     ble_reply_cmd(SINGLE_DIAL_FILE_RECV_CMD,1);\r
-\r
-                }else{\r
+                } else {\r
+                    TRANSMIT_DATA=TRANS_DIAL_FAIL;\r
+                    CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
                     ble_reply_cmd(SINGLE_DIAL_FILE_RECV_CMD,2);\r
-\r
                 }         \r
                 break;\r
             case EPO_DATA_RECV_CMD:\r
@@ -7857,7 +7860,8 @@ void type2AE6Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u
             {\r
                 ble_reply_cmd(DIAL_SINGEL_FILE_CMD,1);\r
 \r
-            }else{\r
+           } else {\r
+\r
                 ble_reply_cmd(DIAL_SINGEL_FILE_CMD,2);\r
 \r
             }         \r
index 22885b2..4811b31 100644 (file)
 #include "bletest.h"
 
 #include "safemodemanager/include/SafeModeManagerModelC.h"
+#include "set_dial/include/SetDialModelC.h"
 
 #include "alarmclocktimerconfig/include/AlarmClockTimerConfig.h"
 
+
 typedef struct
 {
     uint8_t cmd;
@@ -304,6 +306,9 @@ static void custom_cmd_service_check_task(void const *arg)
         case CUSTOM_CMD_MSG_BLE_ADV_CHECK:
             Check_ble_adv_status();
             break;
+        case CUSTOM_CMD_MSG_CHECK_DIAL_SPACE:
+            check_dial_space();
+            break;
         default:
             PRINT("Unknown CUSTOM_CMD_MSG cmd 0x%02X \r\n", mail.cmd);
             break;
index b532c7c..d2c495a 100644 (file)
@@ -224,6 +224,8 @@ uint32_t uapi_calendar_store_date(void);
 
 #define CUSTOM_CMD_MSG_BLE_ADV_CHECK 0x11
 
+#define CUSTOM_CMD_MSG_CHECK_DIAL_SPACE 0x12
+
 typedef enum {
     BR_HFP_CONNECT=1,
     BR_HFP_DISCONNECT,