修改电量为20%触发
authorxue <2144439972@qq.com>
Mon, 15 Jun 2026 01:43:45 +0000 (09:43 +0800)
committerxue <2144439972@qq.com>
Mon, 15 Jun 2026 01:43:45 +0000 (09:43 +0800)
code/sdk/application/wearable/n9/nativeapp/nativeui/ecg/src/ECGHistoryView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/health/HealthMeasureBattery.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/health/HealthMeasureBattery.h
code/sdk/application/wearable/n9/service/msg_center/include/notify/charge_notification.h
code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp
code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_recorder.a

index 7d271bc..2f09d06 100644 (file)
@@ -287,7 +287,7 @@ void ECGHistoryView::RebuildList() {
 
     UILabel *bpmLabel = nullptr;
     std::string bpmStr = rec.bpm > 0 ? (std::to_string(rec.bpm) + " 次/分") : "-- 次/分";
-    InitUILabel(bpmLabel, ECG_HISTORY_CARD_MARGIN + 40 + 38 + 8 + 8 + 120, y + 36 + 5 + 4, 119, 35, "ecg_list_bpm",
+    InitUILabel(bpmLabel, ECG_HISTORY_CARD_MARGIN + 40 + 38 + 8 + 8 + 120, y + 36 + 5 + 2, 119, 35, "ecg_list_bpm",
                 bpmStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 28);
     bpmLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
 
index cfd45b8..3cee20d 100644 (file)
@@ -20,6 +20,7 @@ UIViewGroup *CreateHealthMeasureLowPowerNotifyView() { return lowPowerShow(); }
 void ShowHealthMeasureLowBatteryNotifyImpl() {
   uapi_set_screen_on_api();
   set_lowpower_falg(0);
+  set_lowpower_charge_remind_percent(kHealthMeasureMinBatteryPercent);
   NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
   NotificationManager::GetInstance()->ShowNotify(
       CreateHealthMeasureLowPowerNotifyView, TOPIC_EVENT_LOWPOWER_ALARM, true);
index 1878614..38db5f5 100644 (file)
@@ -3,12 +3,12 @@
 
 namespace OHOS {
 
-static constexpr int kHealthMeasureMinBatteryPercent = 80;
+static constexpr int kHealthMeasureMinBatteryPercent = 20;
 
-/** 电量低于 10% 时不允许开始测量/校准 */
+/** 电量低于 kHealthMeasureMinBatteryPercent 时不允许开始测量/校准 */
 bool IsBatteryTooLowForMeasure();
 
-/** å¤\8dç\94¨ç³»ç»\9fä½\8eç\94µé\87\8få\85\85ç\94µæ\8f\90é\86\92å¼¹çª\97ï¼\88charge_notification::lowPowerShowï¼\89 */
+/** å¤\8dç\94¨ç³»ç»\9fä½\8eç\94µé\87\8få\85\85ç\94µæ\8f\90é\86\92å¼¹çª\97ï¼\8cæ\96\87æ¡\88é\98\88å\80¼ä¸\8e kHealthMeasureMinBatteryPercent ä¸\80è\87´ */
 void ShowHealthMeasureLowBatteryNotify();
 
 } // namespace OHOS
index 9827724..9fad1fc 100644 (file)
@@ -12,7 +12,11 @@ namespace OHOS
     UIViewGroup * ShowChargeingView(void);
 
     UIViewGroup* lowPowerShow(void);
-    
+
+    /** 充电提醒弹窗文案中的电量阈值(0=使用 STR_LOW_POWER_NOTIF_1 默认 10%) 二代手表特有,需要修改*/
+    void set_lowpower_charge_remind_percent(int percent);
+    void reset_lowpower_charge_remind_percent(void);
+
     void set_lowpower_falg(uint8_t falg);
     void FreelowPower(void);
     void low_power_play();
index 9c56845..efb9cbc 100644 (file)
@@ -18,6 +18,8 @@
 #include "uicomponents/UIComponents.h"
 #include "charge_notification.h"
 
+#include <string>
+
 // #include "ui_resource_string.h"
 
 namespace OHOS
@@ -393,6 +395,37 @@ namespace OHOS
     }
 
     static uint8_t battery_falg = 0;
+    static int lowpower_charge_remind_percent = 0;
+
+    void set_lowpower_charge_remind_percent(int percent)
+    {
+        lowpower_charge_remind_percent = percent > 0 ? percent : 0;
+    }
+
+    void reset_lowpower_charge_remind_percent(void)
+    {
+        lowpower_charge_remind_percent = 0;
+    }
+
+    static void apply_lowpower_charge_remind_text(UILabelExt *label)
+    {
+        if (label == nullptr) {
+            return;
+        }
+        if (lowpower_charge_remind_percent <= 0) {
+            label->SetTextId(STR_LOW_POWER_NOTIF_1);
+            return;
+        }
+        label->SetTextId(STR_LOW_POWER_NOTIF_1);
+        std::string result = UpdateLabel(label, lowpower_charge_remind_percent, STR_LOW_POWER_NOTIF_1);
+        const std::string percentStr = std::to_string(lowpower_charge_remind_percent);
+        if (result.find(percentStr) == std::string::npos) {
+            char buf[80] = {0};
+            (void)snprintf(buf, sizeof(buf) - 1, "当前电量低于%d%%请及时充电", lowpower_charge_remind_percent);
+            label->SetText(buf);
+        }
+    }
+
     void set_lowpower_falg(uint8_t falg)
     {
         battery_falg = falg;
@@ -445,6 +478,7 @@ namespace OHOS
             delete UIViewGroup_lowpower;
             UIViewGroup_lowpower = nullptr;
         }
+        reset_lowpower_charge_remind_percent();
     }
     
     void low_power_TimerCallBack(int data)
@@ -546,8 +580,7 @@ namespace OHOS
         {
             alarm_UILabel->SetPosition(110, 252); 
             alarm_UILabel->Resize(245, 70);       
-            // alarm_UILabel->SetText("当前电量低于10%请及时充电");
-            alarm_UILabel->SetTextId(STR_LOW_POWER_NOTIF_1);
+            apply_lowpower_charge_remind_text(alarm_UILabel);
 
             alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
             alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
index d1adaf5..515ce65 100644 (file)
Binary files a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_recorder.a and b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_recorder.a differ