From: Caisking <3449750381@qq.com> Date: Thu, 29 Aug 2024 03:02:03 +0000 (+0800) Subject: 同步applist里面的Slice的内存泄漏打印 X-Git-Tag: release_V1.2.70_20241020_135402~568 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=943e82032ae58e0386aa6324f1180518bcb03957;p=mirrors%2FFD230.git 同步applist里面的Slice的内存泄漏打印 --- diff --git a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp index d988e277a..6ef22281d 100644 --- a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp +++ b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp @@ -402,6 +402,11 @@ namespace OHOS */ bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) { + if (imagePath == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath is fail"); + return false; + } // 创建新图片(如果当前图片为空) if (imageView == nullptr) { @@ -417,11 +422,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is not nullptr"); return false; // 内存分配失败,返回false } - if (imagePath == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath %s fail", imagePath); - return false; - } + imageView->SetPosition(left, top); imageView->SetAutoEnable(true); imageView->SetViewId(viewId); 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 6f09ea77d..ab6b6198e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -21,10 +21,7 @@ #include "bleEvent.h" #include -#define LEAK_CHECK 0 -#if LEAK_CHECK #include "gfx_utils/mem_check.h" -#endif namespace OHOS { @@ -33,8 +30,8 @@ namespace OHOS AiVoicePresenter::AiVoicePresenter() { -#if LEAK_CHECK - MemCheck::GetInstance().EnableLeakCheck(true); +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); #endif model = &AiVoiceModel::GetInstance(); g_pAiVoicePresenter = this; @@ -42,8 +39,8 @@ namespace OHOS AiVoicePresenter::~AiVoicePresenter() { -#if LEAK_CHECK - MemCheck::GetInstance().EnableLeakCheck(false); +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); #endif g_pAiVoicePresenter = nullptr; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPopUpPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPopUpPresenter.cpp index 6b1f76ba1..f143d97ad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPopUpPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPopUpPresenter.cpp @@ -11,7 +11,7 @@ #include "ChangeSliceListener.h" #include "PhoneService.h" #include "PlayersModel.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { static AlarmPopUpPresenter *g_pAlarmPresenter = nullptr; @@ -24,12 +24,18 @@ AlarmPopUpPresenter::AlarmPopUpPresenter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmPopUpPresenter new"); g_pAlarmPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } AlarmPopUpPresenter::~AlarmPopUpPresenter() { g_pAlarmPresenter = nullptr; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmPopUpPresenter::~AlarmPopUpPresenter"); +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } void AlarmPopUpPresenter::OnStart() diff --git a/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp index 43d546996..b72e7c591 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp @@ -20,6 +20,7 @@ #include "AlipayTransListView.h" #include "custom_utils.h" #include "common/key_code.h" +#include "gfx_utils/mem_check.h" namespace OHOS { static AlipayPresenter *g_alipayPresenter = nullptr; @@ -33,12 +34,18 @@ AlipayPresenter::AlipayPresenter() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlipayPresenter new"); alipayMode_ = AlipayModel::GetInstance(); g_alipayPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } AlipayPresenter::~AlipayPresenter() { g_alipayPresenter = nullptr; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlipayPresenter::~AlipayPresenter"); +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } AlipayPresenter *AlipayPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultPresenter.cpp index b88792aa4..1c6e801ba 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultPresenter.cpp @@ -40,6 +40,7 @@ #include "battery_hal.h" #include "heart_blood/health_service/health_service.h" +#include "gfx_utils/mem_check.h" #define BLOODKEYABLE 1 namespace OHOS @@ -76,12 +77,18 @@ namespace OHOS /* -------------------------------------------------------------------------- */ BloodResultPresenter::BloodResultPresenter() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodResultPresenter::new BloodResultPresenter"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultPresenter::new BloodResultPresenter"); g_pBloodResultPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } BloodResultPresenter::~BloodResultPresenter() { g_pBloodResultPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } BloodResultPresenter *BloodResultPresenter::GetInstance() { diff --git a/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorPresenter.cpp index 31f9f0dfb..191f14643 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorPresenter.cpp @@ -7,7 +7,7 @@ #include "calculator/include/CalculatorPresenter.h" #include "calculator/include/CalculatorView.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -15,11 +15,17 @@ static CalculatorPresenter *g_pMainView = nullptr; CalculatorPresenter::CalculatorPresenter() { g_pMainView = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } CalculatorPresenter::~CalculatorPresenter() { g_pMainView = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } CalculatorPresenter *CalculatorPresenter::GetInstance(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassPresenter.cpp index 9649379dc..454ae7615 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassPresenter.cpp @@ -8,7 +8,7 @@ #include "compass/include/CompassPresenter.h" #include "compass/include/CompassModel.h" #include "graphic_service.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { static constexpr int16_t RIGHT_NORTH_DOWN_23 = 23; static constexpr int16_t RIGHT_EASTNORTH_UP_68 = 68; @@ -58,11 +58,17 @@ static CompassPresenter *g_pMainView = nullptr; CompassPresenter::CompassPresenter() { g_pMainView = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } CompassPresenter::~CompassPresenter() { g_pMainView = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } CompassPresenter* CompassPresenter::GetInstance(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp index 4c9f25f55..33c5fce71 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp @@ -15,7 +15,7 @@ #include #include "bleEvent.h" #include "findphone/include/FindPhoneModel.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -24,11 +24,17 @@ namespace OHOS FindPhonePresenter::FindPhonePresenter() { g_pFindPhonePresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } FindPhonePresenter::~FindPhonePresenter() { g_pFindPhonePresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } FindPhonePresenter *FindPhonePresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp index 083e87d76..8d56231e9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp @@ -13,6 +13,7 @@ #include "flashlight/include/FlashlightModel.h" #include "common/key_code.h" #include +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -23,11 +24,17 @@ namespace OHOS FlashlightPresenter::FlashlightPresenter() { g_pFlashlightPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } FlashlightPresenter::~FlashlightPresenter() { g_pFlashlightPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } FlashlightPresenter *FlashlightPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp index f57041a36..71028c686 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp @@ -6,6 +6,7 @@ #include #include #include "UiConfig.h" +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -16,12 +17,17 @@ namespace OHOS { weatherModel = &GoalModel::GetInstance(); g_pMainWeatherPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } MaingoalPresenter::~MaingoalPresenter() { - g_pMainWeatherPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } MaingoalPresenter *MaingoalPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartChartView.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartChartView.h index ec5f27c63..2cd4a2ddb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartChartView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartChartView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-08-15 18:38:49 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-26 15:17:07 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartChartView.h + */ /*** * @Date: 2024-08-15 18:38:49 * @LastEditors: Caisking 3449750381@qq.com diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartPresenter.cpp index c19165ec5..53fd91c18 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartPresenter.cpp @@ -16,13 +16,12 @@ #include "displaybrightness/include/DisplayBrightnessModel.h" #include "heartrate/include/HeartModel.h" #include "MainModel.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { // 当前Presenter属性实例化的内存指针 static HeartChartPresenter *g_pHeartChartPresenter = nullptr; - HeartChartPresenter::HeartChartPresenter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartChartPresenter::HeartChartPresenter"); @@ -30,12 +29,18 @@ namespace OHOS display_time = DisplayBrightnessModel::GetInstance()->GetScreenDurationTime(); display_api->set_screen_auto_off_timeout(300 * 1000); // 设置常亮 ResetTickTimer(); +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } HeartChartPresenter::~HeartChartPresenter() { display_api->set_screen_auto_off_timeout(display_time); // 恢复 g_pHeartChartPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } HeartChartPresenter *HeartChartPresenter::GetInstance() { diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartView.cpp index 1f01f9aa5..b98dd720e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartView.cpp @@ -69,9 +69,38 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartChartView::~HeartChartView"); imageAnimator->Stop(); + /* + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + */ - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + delete CurrentHeartText; + CurrentHeartText = nullptr; + delete MaxHeartText; + MaxHeartText = nullptr; + delete MinHeartText; + MinHeartText = nullptr; + delete UHeartText; + UHeartText = nullptr; + delete RestHeartText; + RestHeartText = nullptr; + delete TopimageView; + TopimageView = nullptr; + delete BottomimageView; + BottomimageView = nullptr; + delete CoordinateimageView; + CoordinateimageView = nullptr; + delete HeartIconView; + HeartIconView = nullptr; + delete imageAnimator; + imageAnimator = nullptr; + + + heartchart->ClearDataSerial(); + delete heartSerial; + heartSerial = nullptr; + delete heartchart; + heartchart = nullptr; g_pHeartCheckView = this; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp index 57b2767ea..4dce87c36 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp @@ -148,7 +148,7 @@ namespace OHOS { int32_t i; RemoveAll(); - UnLoadHeartRateImageRes(); + // UnLoadHeartRateImageRes(); delete imageViewCoordinate; imageViewCoordinate = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp index 5888f0e3b..adade5b93 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-27 16:00:39 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp + */ /* * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. * Description: DialModelWeather @@ -19,7 +25,7 @@ namespace OHOS // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialModelWeather %d", Weather_); return true; } - + /*表盘更新天气Icon*/ void DialModelWeather::UpdateWeather(int16_t Weather) { Weather_ = static_cast(Weather); diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h index c1737a9f4..004871412 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-07-10 16:58:06 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-24 17:36:42 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h + */ /*** * @Date: 2024-07-10 16:58:06 * @LastEditors: Caisking 3449750381@qq.com diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp index 0df538133..3cbf62096 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp @@ -57,6 +57,9 @@ namespace OHOS delete DeleteButton; DeleteButton = nullptr; } + + delete p_MessageListAdapter; + p_MessageListAdapter = nullptr; } void MessageCardView::AddMessageToList(const MessageListItem &item) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp index f06a2dc5f..cf5397be8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp @@ -14,7 +14,7 @@ #include "common/key_code.h" #include "KeyInputListener.h" #include "custom_utils.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -25,11 +25,17 @@ namespace OHOS { model = &MessageModel::GetInstance(); g_pMessagePresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } MessagePresenter::~MessagePresenter() { g_pMessagePresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } MessagePresenter *MessagePresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp index 05b24e5ae..e4f997f80 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp @@ -8,7 +8,7 @@ #include "VocassistPresenter.h" #include "PlayersModel.h" #include "ui_service.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { static VocassistPresenter *g_pVocassistPresenter = nullptr; @@ -17,6 +17,9 @@ VocassistPresenter::VocassistPresenter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[VocassistPresenter] VocassistPresenter"); g_pVocassistPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } VocassistPresenter::~VocassistPresenter() @@ -24,6 +27,9 @@ VocassistPresenter::~VocassistPresenter() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[VocassistPresenter] ~VocassistPresenter"); VocassistModel::GetInstance()->SetHasOneCmd(false); g_pVocassistPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } VocassistPresenter *VocassistPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp index a80a2945e..ea913efc5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp @@ -14,6 +14,7 @@ #include "iostream" #include "UiConfig.h" #include "phone/include/phoneaddressmodel.h" +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -23,11 +24,17 @@ namespace OHOS MainPhonePresenter::MainPhonePresenter() { g_pMainPhonePresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } MainPhonePresenter::~MainPhonePresenter() { g_pMainPhonePresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } MainPhonePresenter *MainPhonePresenter::GetInstance() @@ -71,13 +78,12 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); NativeAbility::GetInstance().EnterSlice(VIEW_PHONEDIR); } - else + else { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); set_address_number((char *)view.GetViewId()); NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); } - return true; } @@ -99,7 +105,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDragEnd"); if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 { - //NativeAbility::GetInstance().Back(); + // NativeAbility::GetInstance().Back(); NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST); TelephonyInitInterface::X_DRAG_FLAG = false; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingPresenter.cpp index 1cf5bb927..18129cb73 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingPresenter.cpp @@ -16,6 +16,7 @@ #include #include #include "respiratorytraining/include/RespiratoryTrainingModel.h" +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -25,11 +26,17 @@ namespace OHOS RespiratoryTrainingPresenter::RespiratoryTrainingPresenter() { g_pRespiratoryTrainingPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } RespiratoryTrainingPresenter::~RespiratoryTrainingPresenter() { g_pRespiratoryTrainingPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } RespiratoryTrainingPresenter *RespiratoryTrainingPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp index 15f835f24..0367f9a36 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp @@ -186,8 +186,8 @@ namespace OHOS int length = 0; for (const auto &entry : registeredDials) { - uint16_t id=entry.first; - if(id<=5) + uint16_t id = entry.first; + if (id <= 5) { id--; } @@ -558,6 +558,8 @@ namespace OHOS return false; // 文件打开失败 } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "saveDialConfig: %d %d %d", layout.batteryDisplay, layout.timeDisplay, layout.colorTypeSet); + // 将结构体的三个数据按1个字节的存储到文件 configFile.put(static_cast(layout.batteryDisplay)); // 第一字节:电池图标样式 configFile.put(static_cast(layout.timeDisplay)); // 第二字节:时间label位置 @@ -603,6 +605,7 @@ namespace OHOS layout.colorTypeSet = static_cast(settings[2]); // 字体颜色 // 关闭文件 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to read config file or insufficient file content!"); configFile.close(); return true; // 成功读取配置 } diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp index 6ef81bc38..2b4f7db0a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp @@ -11,7 +11,7 @@ * Author: * Create: 2021-11-23 */ - +#include "gfx_utils/mem_check.h" #include "settings/include/SettingView.h" #include "settings/include/SettingModel.h" #include "settings/include/SettingPresenter.h" @@ -27,12 +27,18 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::SettingPresenter"); settingModel = &SettingModel::GetInstance(); g_pSettingPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } SettingPresenter::~SettingPresenter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::~SettingPresenter"); g_pSettingPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } SettingPresenter *SettingPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlPresenter.cpp index 25120a99f..dd9776cef 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlPresenter.cpp @@ -1,4 +1,4 @@ -/*** +/*** * @Date: 2024-06-25 10:33:08 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-07-12 20:00:41 @@ -13,6 +13,7 @@ #include #include "UiConfig.h" #include "string.h" +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -23,12 +24,17 @@ namespace OHOS { // SleepModel = &SleepModel::GetInstance(); g_pSleepControlPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } SleepControlPresenter::~SleepControlPresenter() { - g_pSleepControlPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } SleepControlPresenter *SleepControlPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp index 4bdac8819..336ad3fb1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp @@ -24,6 +24,7 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SleepTimeView::~SleepTimeView"); ClearAll(); + g_pSleepView = nullptr; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp index 4c32e7d27..8e02dad6d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -6,6 +6,7 @@ #include "common/key_code.h" #include /*秒表主视图*/ +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -14,19 +15,23 @@ namespace OHOS MainStopWatchPresenter::MainStopWatchPresenter() { - g_pMainStopWatchPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } MainStopWatchPresenter::~MainStopWatchPresenter() { StopWatchModel::GetInstance()->StopWatch_StopTimer(); // 退出删除并清理定时器资源 g_pMainStopWatchPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } MainStopWatchPresenter *MainStopWatchPresenter::GetInstance() { - return g_pMainStopWatchPresenter; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp index e758edea1..0c839ce93 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp @@ -21,6 +21,7 @@ #include "takephotos/include/TakephotosPresenter.h" #include "takephotos/include/TakephotosModel.h" +#include "gfx_utils/mem_check.h" // #include "TakephotosView.h" namespace OHOS @@ -32,11 +33,17 @@ namespace OHOS TakephotosPresenter::TakephotosPresenter() { g_pTakephotosPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } TakephotosPresenter::~TakephotosPresenter() { g_pTakephotosPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } TakephotosPresenter *TakephotosPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp index 8ee55650b..3d27a9962 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp @@ -20,7 +20,7 @@ #include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" // #include "TraingView.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -30,11 +30,17 @@ namespace OHOS TraingPresenter::TraingPresenter() { g_pTraingPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } TraingPresenter::~TraingPresenter() { g_pTraingPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } TraingPresenter *TraingPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h index f6b3ca384..7e52f6804 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h @@ -1,4 +1,10 @@ /*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-24 15:18:42 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h + */ +/*** * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-08-19 10:55:50 @@ -57,7 +63,7 @@ namespace OHOS bool ControlSensor(ExerciseState state); void ModifiesTime(); - void RefreshData(); // 更新数据 + void RefreshData(SportData *sportdata); // 更新数据 /*蓝牙开启运动*/ bool send_sport_cmd(training_ble *cmd); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp index 02e49f133..16488879a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -29,6 +29,7 @@ #include #include #include +#include "graphic_service.h" extern "C" void do_cywee_service_check_msg(int cmd, int data[]); @@ -190,9 +191,8 @@ namespace OHOS return true; } - void TraingCardPresenter::RefreshData() + void TraingCardPresenter::RefreshData(SportData *sportdata) { - SportData *sportdata = TraingModel::GetInstance()->GetSportdata(); if (sportdata == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata is null"); @@ -235,7 +235,7 @@ namespace OHOS // 未开启训练 直接退出 if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) return; - // 刷新训练数据界面 时间 + // 刷新训练数据界面 现实时间 TrainingDataView::GetInstance()->UpdataTime(); // 刷新训练数据界面 心率 卡路里 距离 步数 训练强度 目标完成度 RefreshData(); @@ -247,10 +247,13 @@ namespace OHOS // 未开启训练 直接退出 if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) return; - // 刷新训练数据界面 时间 - TrainingDataView::GetInstance()->UpdataTime(); + + // 刷新训练数据界面 现实时间 + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&TrainingDataView::UpdataTime, TrainingDataView::GetInstance())); + // 刷新训练数据界面 心率 卡路里 距离 步数 训练强度 目标完成度 - RefreshData(); + SportData *sportdata = TraingModel::GetInstance()->GetSportdata(); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&TraingCardPresenter::RefreshData, TraingCardPresenter::GetInstance(), sportdata)); } #endif /* --------------------------------- 点击事件处理 --------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp index f875d99ea..d8b1483b9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp @@ -56,7 +56,7 @@ namespace OHOS // 初始化Lable InitLabelExt(labeltitle, 83, 50, 300, 35, "label1", STR_TRAINING_IN_PROGRESS, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(labeltimer, 45, 110, 360, 80, "label2", "00:00:00", GILROY_BOLD_FONT, 65); + InitLabel(labeltimer, 45, 110, 360, 80, "label2", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 65); InitLabelExt(labelend, 81, 330, 130, 35, "label3", STR_FINISH, DEFAULT_VECTOR_FONT_FILENAME, 30); InitLabelExt(labelstop, 251, 330, 130, 35, "label4", STR_PAUSE, DEFAULT_VECTOR_FONT_FILENAME, 30); Add(labeltitle); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp index e620b186d..e045bf142 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp @@ -64,9 +64,9 @@ namespace OHOS u_stepslabel->SetTextColor(Color::Gray()); u_calorielabel->SetTextColor(Color::Gray()); - InitLabel(milelabel, 17, 160, 200, 80, "label6", "13.21", GILROY_BOLD_FONT, 65); - InitLabel(calorielabel, 230, 160, 200, 80, "label7", "28312", GILROY_BOLD_FONT, 65); - InitLabel(steplabel, 133, 285, 200, 80, "label8", "210.03", GILROY_BOLD_FONT, 65); + InitLabel(milelabel, 17, 160, 200, 80, "label6", "13.21", DEFAULT_VECTOR_FONT_FILENAME, 65); + InitLabel(calorielabel, 230, 160, 200, 80, "label7", "28312", DEFAULT_VECTOR_FONT_FILENAME, 65); + InitLabel(steplabel, 133, 285, 200, 80, "label8", "210.03", DEFAULT_VECTOR_FONT_FILENAME, 65); Add(u_milelabel); Add(u_stepslabel); Add(u_calorielabel); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp index a2b121000..09f7070c5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp @@ -21,7 +21,7 @@ #include "custom_utils.h" #include "common/key_code.h" // #include "TraingRecordView.h" - +#include "gfx_utils/mem_check.h" namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -31,11 +31,18 @@ namespace OHOS { p_TraingRecordModel = &TraingRecordModel::GetInstance(); g_pTraingRecordPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } TraingRecordPresenter::~TraingRecordPresenter() { g_pTraingRecordPresenter = nullptr; + p_TraingRecordModel = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } TraingRecordPresenter *TraingRecordPresenter::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp index 9f867b281..f4e5fef9f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp @@ -6,6 +6,7 @@ #include #include #include "UiConfig.h" +#include "gfx_utils/mem_check.h" namespace OHOS { @@ -16,12 +17,17 @@ namespace OHOS { weatherModel = &WeatherModel::GetInstance(); g_pMainWeatherPresenter = this; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(true); +#endif } MainWeatherPresenter::~MainWeatherPresenter() { - g_pMainWeatherPresenter = nullptr; +#ifdef MEM_CHECK + MemCheck::GetInstance()->EnableLeakCheck(false); +#endif } MainWeatherPresenter *MainWeatherPresenter::GetInstance() diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp index e811e93e6..f62809ed4 100755 --- a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp +++ b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp @@ -21,227 +21,272 @@ #include #include "BaseView.h" #include "AppViewIDs.h" -namespace OHOS { -/* - * @brief 负责将一个SliceProxy对象添加到Ability对象中,如果传入的sliceId是无效的或者代理对象proxy为空,则不执行任何操作。 - */ -void Ability::AddSliceProxy(const uint16_t sliceId, SliceProxy* proxy) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::AddSliceProxy sliceId = %d", sliceId); - if (sliceId <= gSliceInvalid || proxy == nullptr) { - return; - } +#include "los_memory_pri.h" +#include "gfx_utils/mem_check.h" - /*首先,会检查是否已经有一个与传入的sliceId对应的Slice存在,如果存在,则不会添加新的代理。*/ - if (Find(sliceId) != nullptr) { - return; - } +namespace OHOS +{ + /* + * @brief 负责将一个SliceProxy对象添加到Ability对象中,如果传入的sliceId是无效的或者代理对象proxy为空,则不执行任何操作。 + */ + void Ability::AddSliceProxy(const uint16_t sliceId, SliceProxy *proxy) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::AddSliceProxy sliceId = %d", sliceId); + if (sliceId <= gSliceInvalid || proxy == nullptr) + { + return; + } - /*如果检查通过,则将sliceId和proxy作为一个结构体添加到allSlicesProxy_列表中,allSlicesProxy_可能是存储所有尚存代理的列表。*/ - Ability::ProxyStruct proxyPair = {sliceId, proxy}; - allSlicesProxy_.PushBack(proxyPair); -} + /*首先,会检查是否已经有一个与传入的sliceId对应的Slice存在,如果存在,则不会添加新的代理。*/ + if (Find(sliceId) != nullptr) + { + return; + } -/* - * @brief 该函数用于启动一个指定ID的Slice。 - */ -void Ability::StartSlice(const uint16_t sliceId, const uint16_t priority) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice sliceId = %d", sliceId); - - /* ---------------------- 1.首先检查sliceId的有效性,如果无效,则直接返回。 --------------------- */ - if (sliceId <= gSliceInvalid) { - return; + /*如果检查通过,则将sliceId和proxy作为一个结构体添加到allSlicesProxy_列表中,allSlicesProxy_可能是存储所有尚存代理的列表。*/ + Ability::ProxyStruct proxyPair = {sliceId, proxy}; + allSlicesProxy_.PushBack(proxyPair); } - /* ---- 2.通过Find函数查找是否已经有对应的SliceProxy存在,如果没有找到对应的代理或创建新Slice实例失败,则不继续执行。 --- */ - ListsNode* node = Find(sliceId); - if (node == nullptr) { - return; - } - InputDeviceManager::GetInstance()->ClearPressableViews(); - Slice* nextSlice = node->value_.proxy->CreateSlice(); - if (nextSlice == nullptr) { - return; - } + /* + * @brief 该函数用于启动一个指定ID的Slice。 + */ + void Ability::StartSlice(const uint16_t sliceId, const uint16_t priority) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice sliceId = %d", sliceId); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice Size = %d", allSlices_.size()); - /* ----------- 3.记录历史Slice ID,如果历史记录达到最大值gMaxHistorySlices,则移除最旧的记录。 ---------- */ - if (allSlices_.size() == gMaxHistorySlices) {// 记录最多gMaxHistorySlices个页面id - allSlices_.erase(allSlices_.begin()); - } - /* -------------- 4.设置当前Slice的相关信息,并调用Slice的OnStart和OnResume方法。 ------------- */ - allSlices_.push_back(sliceId); - if (curSlice_.slice != nullptr) { - prevSlice_.sliceId = curSlice_.sliceId; - prevSlice_.slice = curSlice_.slice; - } + /* ---------------------- 1.首先检查sliceId的有效性,如果无效,则直接返回。 --------------------- */ + if (sliceId <= gSliceInvalid) + { + return; + } - curSlice_.sliceId = sliceId; - curSlice_.slice = nextSlice; - curSlicePriority_ = priority; + /* ---- 2.通过Find函数查找是否已经有对应的SliceProxy存在,如果没有找到对应的代理或创建新Slice实例失败,则不继续执行。 --- */ + ListsNode *node = Find(sliceId); + if (node == nullptr) + { + return; + } + InputDeviceManager::GetInstance()->ClearPressableViews(); + Slice *nextSlice = node->value_.proxy->CreateSlice(); + if (nextSlice == nullptr) + { + return; + } - nextSlice->OnStart(); - nextSlice->OnResume(); -} + WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice Size = %d", allSlices_.size()); + /* ----------- 3.记录历史Slice ID,如果历史记录达到最大值gMaxHistorySlices,则移除最旧的记录。 ---------- */ + if (allSlices_.size() == gMaxHistorySlices) + { // 记录最多gMaxHistorySlices个页面id + allSlices_.erase(allSlices_.begin()); + } + /* -------------- 4.设置当前Slice的相关信息,并调用Slice的OnStart和OnResume方法。 ------------- */ + allSlices_.push_back(sliceId); + if (curSlice_.slice != nullptr) + { + prevSlice_.sliceId = curSlice_.sliceId; + prevSlice_.slice = curSlice_.slice; + } + curSlice_.sliceId = sliceId; + curSlice_.slice = nextSlice; + curSlicePriority_ = priority; -/* - * @brief 在allSlicesProxy_列表中寻找与给定sliceId相符合的ProxyStruct节点。如果找到则返回该节点,否则返回nullptr。 - */ -ListsNode* Ability::Find(const uint16_t sliceId) -{ - if (sliceId <= gSliceInvalid) { - return nullptr; + nextSlice->OnStart(); + nextSlice->OnResume(); } - if (allSlicesProxy_.IsEmpty()) { - return nullptr; - } + /* + * @brief 在allSlicesProxy_列表中寻找与给定sliceId相符合的ProxyStruct节点。如果找到则返回该节点,否则返回nullptr。 + */ + ListsNode *Ability::Find(const uint16_t sliceId) + { + if (sliceId <= gSliceInvalid) + { + return nullptr; + } - ListsNode* node = allSlicesProxy_.Begin(); - while (node != allSlicesProxy_.End()) { - if (node->value_.sliceId == sliceId) { - return node; + if (allSlicesProxy_.IsEmpty()) + { + return nullptr; } - node = node->next_; - } - return nullptr; -} + ListsNode *node = allSlicesProxy_.Begin(); + while (node != allSlicesProxy_.End()) + { + if (node->value_.sliceId == sliceId) + { + return node; + } + node = node->next_; + } -/* - * @brief 用于改变当前Slice。首先检查切换是否正在进行中;如果是,直接返回。 - * @param {uint16_t} targetSliceId - * @param {uint16_t} transitionId - * @param {uint16_t} priority - * @return {*} - */ -void Ability::ChangeSlice(const uint16_t targetSliceId, TransitionType type, const uint16_t priority) -{ - if(targetSliceId == VIEW_MAIN) - { - ClearSliceIdStack();/*凡是回到主界面都要清空栈*/ - } - // showsStackSliceId(); - /* - if (GetCurSliceId() == targetSliceId) { - return; - } - */ - if (osal_atomic_read(&transitionCount_) <= 0) { - osal_atomic_inc(&transitionCount_); - // onStop释放当前页面需要和当前页面的事件监听异步执行,否则会出现自己杀掉自己的情况 - //使用图形服务的PostGraphicEvent方法异步执行PostChangeSlice,以避免在页面事件监听时出现当前页面自我销毁的情况。 - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&Ability::PostChangeSlice, this, targetSliceId, - type, priority)); + return nullptr; } -} -void Ability::PostChangeSlice(const uint16_t targetSliceId, TransitionType type, const uint16_t priority) -{ /* - 1.首先检查当前Slice是否存在,并验证transitionId的有效性。 - 如果当前存在一个有效的Slice,并且transitionId合法,则调用sliceTransition_的SaveCurrentSnapshot方法保存当前Slice的快照, - 主要是为了后续可能使用的页面转场效果。 - */ - bool useTransition = sliceTransition_.SetTransitionType(type); - bool isCurSnapshotEnabled = sliceTransition_.IsCurrentSnapshotEnabled(); - FocusManager::GetInstance()->ClearFocus(); - if(type == TransitionType::TRANSITION_HEXAGONS) + * @brief 用于改变当前Slice。首先检查切换是否正在进行中;如果是,直接返回。 + * @param {uint16_t} targetSliceId + * @param {uint16_t} transitionId + * @param {uint16_t} priority + * @return {*} + */ + void Ability::ChangeSlice(const uint16_t targetSliceId, TransitionType type, const uint16_t priority) { - RootView::GetInstance()->ClearOnKeyActListener(); + if (targetSliceId == VIEW_MAIN) + { + ClearSliceIdStack(); /*凡是回到主界面都要清空栈*/ + } + // showsStackSliceId(); + /* + if (GetCurSliceId() == targetSliceId) { + return; + } + */ + if (osal_atomic_read(&transitionCount_) <= 0) + { + osal_atomic_inc(&transitionCount_); + // onStop释放当前页面需要和当前页面的事件监听异步执行,否则会出现自己杀掉自己的情况 + // 使用图形服务的PostGraphicEvent方法异步执行PostChangeSlice,以避免在页面事件监听时出现当前页面自我销毁的情况。 + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&Ability::PostChangeSlice, this, targetSliceId, + type, priority)); + } } - if (!useTransition) { - StopSlice(); - } else if (isCurSnapshotEnabled) { - if (!sliceTransition_.SaveCurrentSnapshot(curSlice_.slice->GetSliceContainer())) { - useTransition = false; + void Ability::PostChangeSlice(const uint16_t targetSliceId, TransitionType type, const uint16_t priority) + { + /* + 1.首先检查当前Slice是否存在,并验证transitionId的有效性。 + 如果当前存在一个有效的Slice,并且transitionId合法,则调用sliceTransition_的SaveCurrentSnapshot方法保存当前Slice的快照, + 主要是为了后续可能使用的页面转场效果。 + */ + /*进行内存泄漏自查*/ + bool useTransition; +#ifdef MEM_CHECK + useTransition = sliceTransition_.SetTransitionType(type); +#else + useTransition = false; +#endif + bool isCurSnapshotEnabled = sliceTransition_.IsCurrentSnapshotEnabled(); + FocusManager::GetInstance()->ClearFocus(); + if (type == TransitionType::TRANSITION_HEXAGONS) + { + RootView::GetInstance()->ClearOnKeyActListener(); } - // slice页面跳转,先onstop,再onstart.在一个线程同步执行绘制,不会出现闪屏现象 - /* - 2.调用StopSlice函数停止当前Slice的运行。在StopSlice中,会调用当前Slice的OnStop方法,并释放当前Slice占用的资源。 - */ - StopSlice(); - } - - // slice页面跳转,先onstop,再onstart.在一个线程同步执行绘制,不会出现闪屏现象 + if (!useTransition) + { + StopSlice(); + } + else if (isCurSnapshotEnabled) + { + if (!sliceTransition_.SaveCurrentSnapshot(curSlice_.slice->GetSliceContainer())) + { + useTransition = false; + } + StopSlice(); + } + // slice页面跳转,先onstop,再onstart.在一个线程同步执行绘制,不会出现闪屏现象 + /* + 2.调用StopSlice函数停止当前Slice的运行。在StopSlice中,会调用当前Slice的OnStop方法,并释放当前Slice占用的资源。 + */ +#ifdef MEM_CHECK + OsMemInfoPrint(OS_SYS_MEM_ADDR); + OsMemInfoPrint(OS_EXTEND_MEM_ADDR); + printf("*******************next slice id is %d*****************\r\n", targetSliceId); +#endif + // slice页面跳转,先onstop,再onstart.在一个线程同步执行绘制,不会出现闪屏现象 #ifdef JS_ENABLE - ElementName *elementName = OHOS::AbilityMsClient::GetInstance().GetTopAbility(); - if (elementName != nullptr && strcmp(elementName->bundleName, "com.huawei.launcher") != 0) { - OHOS::AbilityMsClient::GetInstance().ForceStop(elementName->bundleName); - targetSliceIdFromJS_ = targetSliceId; - osal_atomic_dec(&transitionCount_); - return; - } + ElementName *elementName = OHOS::AbilityMsClient::GetInstance().GetTopAbility(); + if (elementName != nullptr && strcmp(elementName->bundleName, "com.huawei.launcher") != 0) + { + OHOS::AbilityMsClient::GetInstance().ForceStop(elementName->bundleName); + targetSliceIdFromJS_ = targetSliceId; + osal_atomic_dec(&transitionCount_); + return; + } #endif - /* - 调用StartSlice函数以启动新的指定的Slice。 - StartSlice函数内部会先检查是否存在目标Slice的Proxy,并通过Proxy创建新的实例, - 记录Slice ID到历史记录中,并调用该Slice的OnStart和OnResume方法开始运行新的Slice。 - */ - StartSlice(targetSliceId, priority); - - if (useTransition) { - if (isCurSnapshotEnabled) { - sliceTransition_.Transition(nullptr, curSlice_.slice->GetSliceContainer()); - } else { - sliceTransition_.Transition(prevSlice_.slice->GetSliceContainer(), curSlice_.slice->GetSliceContainer()); - } - } else { - osal_atomic_dec(&transitionCount_); + /* + 调用StartSlice函数以启动新的指定的Slice。 + StartSlice函数内部会先检查是否存在目标Slice的Proxy,并通过Proxy创建新的实例, + 记录Slice ID到历史记录中,并调用该Slice的OnStart和OnResume方法开始运行新的Slice。 + */ + StartSlice(targetSliceId, priority); + + if (useTransition) + { + if (isCurSnapshotEnabled) + { + sliceTransition_.Transition(nullptr, curSlice_.slice->GetSliceContainer()); + } + else + { + sliceTransition_.Transition(prevSlice_.slice->GetSliceContainer(), curSlice_.slice->GetSliceContainer()); + } + } + else + { + osal_atomic_dec(&transitionCount_); + } } -} -void Ability::OnTransitionEnd() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::OnTransitionEnd"); - if (!sliceTransition_.IsCurrentSnapshotEnabled()) { - if (prevSlice_.slice != nullptr) { - prevSlice_.slice->OnStop(); - if (prevSlice_.slice != nullptr) { - prevSlice_.sliceId = gSliceInvalid; - delete prevSlice_.slice; - prevSlice_.slice = nullptr; + void Ability::OnTransitionEnd() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::OnTransitionEnd"); + if (!sliceTransition_.IsCurrentSnapshotEnabled()) + { + if (prevSlice_.slice != nullptr) + { + prevSlice_.slice->OnStop(); + if (prevSlice_.slice != nullptr) + { + prevSlice_.sliceId = gSliceInvalid; + delete prevSlice_.slice; + prevSlice_.slice = nullptr; + } } } + osal_atomic_dec(&transitionCount_); } - osal_atomic_dec(&transitionCount_); -} -/* - * @brief 重新启动当前或默认Slice。根据当前记录的切片历史来决定重启哪个Slice。 - */ -void Ability::ResumeSlice(const uint16_t priority) -{ - uint16_t targetSliceId = gSliceInvalid; - if (targetSliceIdFromJS_ != 0) { - targetSliceId = targetSliceIdFromJS_; - targetSliceIdFromJS_ = 0; - } else if (allSlices_.empty()) { - targetSliceId = defaultSliceId_; - } else { - targetSliceId = GetCurSliceId(); + /* + * @brief 重新启动当前或默认Slice。根据当前记录的切片历史来决定重启哪个Slice。 + */ + void Ability::ResumeSlice(const uint16_t priority) + { + uint16_t targetSliceId = gSliceInvalid; + if (targetSliceIdFromJS_ != 0) + { + targetSliceId = targetSliceIdFromJS_; + targetSliceIdFromJS_ = 0; + } + else if (allSlices_.empty()) + { + targetSliceId = defaultSliceId_; + } + else + { + targetSliceId = GetCurSliceId(); + } + StartSlice(targetSliceId, priority); } - StartSlice(targetSliceId, priority); -} -/* - * @brief 停止当前的Slice,调用其OnStop方法,并释放当前Slice资源。 - */ -void Ability::StopSlice() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StopSlice"); - if (curSlice_.slice != nullptr) { - curSlice_.slice->OnStop(); - if (curSlice_.slice != nullptr) { - curSlice_.sliceId = gSliceInvalid; - delete curSlice_.slice; - curSlice_.slice = nullptr; - } + /* + * @brief 停止当前的Slice,调用其OnStop方法,并释放当前Slice资源。 + */ + void Ability::StopSlice() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StopSlice"); + if (curSlice_.slice != nullptr) + { + curSlice_.slice->OnStop(); + if (curSlice_.slice != nullptr) + { + curSlice_.sliceId = gSliceInvalid; + delete curSlice_.slice; + curSlice_.slice = nullptr; + } - curSlicePriority_ = gSliceDefaultPriority; + curSlicePriority_ = gSliceDefaultPriority; + } } -} } // namespace OHOS diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index ed4299fdd..0d4b4a92f 100755 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -140,6 +140,7 @@ target = { 'SUPPORT_AT_CUSTOMUTILS', 'SUPPORT_BLE_SERVICE', 'FD230', + #"MEM_CHECK", # 'ENABLE_WEBSOCKET', 'CYWEE_SPORT', 'SUPPORT_TCPIP', diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/add_card/button_no.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/add_card/button_no.bin new file mode 100644 index 000000000..818af6a2d --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/add_card/button_no.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c93e6f6eec8c947e19fbc32a041b262607f991083a5c9871a998469bdefb6739 +size 8664 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/add_card/button_ok.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/add_card/button_ok.bin new file mode 100644 index 000000000..4f648208a --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/add_card/button_ok.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c269a13d2d8e861b7e619138f44c38f5c395de04a8258a3f181cb5a5c7f938d9 +size 8664 diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_check.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_check.cpp index 15e48a483..d16d72726 100755 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_check.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_check.cpp @@ -139,7 +139,7 @@ int MemCheck::MemAdd(int size, uintptr_t address) } if (leakCount_ == crashCnt_) { if (leakSize_ != allocNote->size) { - GRAPHIC_LOGE("size not right!"); + GRAPHIC_LOGE("size not right! %d",allocNote->size); } #ifdef __LITEOS__ LOS_Panic("mem leak here!\n"); diff --git a/tools/image_converter_tool/test/hert/card_set/button_no.png b/tools/image_converter_tool/test/hert/card_set/button_no.png new file mode 100644 index 000000000..56702c13d Binary files /dev/null and b/tools/image_converter_tool/test/hert/card_set/button_no.png differ diff --git a/tools/image_converter_tool/test/hert/card_set/button_ok.png b/tools/image_converter_tool/test/hert/card_set/button_ok.png new file mode 100644 index 000000000..106b0171f Binary files /dev/null and b/tools/image_converter_tool/test/hert/card_set/button_ok.png differ