From: luozheng <1732036298@qq.com> Date: Tue, 13 May 2025 03:23:12 +0000 (+0800) Subject: patch_650_base_to_0423 补丁合入提交 ,界面可能有问题需要修改 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~310 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1748%2F2;p=mirrors%2FFD230.git patch_650_base_to_0423 补丁合入提交 ,界面可能有问题需要修改 --- diff --git a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c index 137b70080..74c3b2c22 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c @@ -14,6 +14,8 @@ #endif #include "cpu_trace.h" #include "non_os_reboot.h" +#include "memory_config.h" +#include "chip_exception_utils.h" /* after reboot system emmc need write exc info to the file system from sector */ #if defined(SAVE_EXC_INFO) && defined(CFG_DRIVERS_MMC) #include "exception.h" @@ -156,9 +158,6 @@ static void sample_gfx_init(void) ztw523_host_init_sample(); #endif uapi_lcd_init(); -#ifdef SUPPORT_GPU_GMMU - drv_gmmu_module_init(); -#endif uapi_vau_module_init(); uapi_dpu_module_init(); #ifdef SUPPORT_GPU_JPEG @@ -199,11 +198,20 @@ static void emmc_init_handle(void) } #endif -#ifdef CFG_SDIO_EMMC_COEXIST +#ifdef CFG_DRIVERS_SDIO static void sdio_init(void) { init_sdio_pinmux(); sdio_drv_context_init(); + + /* sdio probe失败, NANDFLASH访问异常bugfix */ +#ifdef CFG_DRIVERS_NANDFLASH + clocks_clk_src_t clk_src = (clocks_clk_src_t)hal_clocks_ccrg_module_get_src(HAL_CLOCKS_MODULE_SDIOM); + if (clk_src == CLOCKS_CLK_SRC_TCXO) { + dprintf("sdio probe fail, switch sdiom clk to pll\r\n"); + clocks_set_sdio_freq(CLOCKS_SDIO_FREQ_H); + } +#endif } #endif @@ -306,19 +314,30 @@ static void audio_smartpa_init(void) #endif /* DSP_EXIST */ #if DSP_EXIST == YES +#ifdef CFG_LOAD_FROM_FS +#define DSP_FILE_PATH "/user/dsp/" +#endif static void audio_init() { + int32_t ret; (void)osDelay(TICK_TEN_MS); uapi_watchdog_kick(); audio_smartpa_init(); - uint32_t ret = (uint32_t)uapi_audio_init(); + ret = uapi_audio_init(); if (ret != 0) { - PRINT("audio init error:[%d]\r\n", ret); + PRINT("audio init error:[%x]\r\n", ret); } else { PRINT("audio init OK\r\n"); } + +#ifdef CFG_LOAD_FROM_FS + ret = uapi_audio_set_dsp_file_path(DSP_FILE_PATH, sizeof(DSP_FILE_PATH)); + if (ret != 0) { + PRINT("audio set dsp file path error:[%x]\r\n", ret); + } +#endif } #endif @@ -409,9 +428,10 @@ static void thread_main(const void *unused) #ifdef CFG_DRIVERS_MMC emmc_init_handle(); #endif -#ifdef CFG_SDIO_EMMC_COEXIST +#ifdef CFG_DRIVERS_SDIO sdio_init(); #endif + #ifdef CFG_DRIVERS_NANDFLASH nandflash_init_handle(); #endif @@ -425,7 +445,8 @@ static void thread_main(const void *unused) PRINT("nmi reboot cause: 0x%x, reason: 0x%x"NEWLINE, cause, get_fault_reason()); // save cputrace memory if chip watchdog reset hal_cpu_trace_clock_enable(); - panic(PANIC_ASSERT, cause); + write_fileinfo("/user/exc/hard_watchdog_error.bin", 0, (const uint8_t *)MCPU_TRACE_MEM_REGION_START, CPU_TRACE_MEM_REGION_LENGTH); + cpu_trace_enable_mcpu_repeat(); } uapi_pm_control(PM_DISPLAY_POWER_UP_AND_RUN); diff --git a/code/sdk/application/brandy/brandy_standard/thread_pri_init.h b/code/sdk/application/brandy/brandy_standard/thread_pri_init.h index e3b38ca3d..02b5785ec 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.h +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.h @@ -28,7 +28,6 @@ typedef enum { CLOCK_SOURCE_MAX } clock_32k_source_t; -int32_t drv_gmmu_module_init(void); int32_t uapi_vau_module_init(void); int32_t uapi_dpu_module_init(void); void los_vfs_init(void); diff --git a/code/sdk/application/wearable/fd230/nativeabilityfwk/include/PageTransitionMgr.h b/code/sdk/application/wearable/fd230/nativeabilityfwk/include/PageTransitionMgr.h index ca6c64714..6e64f4bcb 100644 --- a/code/sdk/application/wearable/fd230/nativeabilityfwk/include/PageTransitionMgr.h +++ b/code/sdk/application/wearable/fd230/nativeabilityfwk/include/PageTransitionMgr.h @@ -29,7 +29,10 @@ public: if (parent != nullptr) { parent->Remove(this); } - ImageCacheFree(*const_cast(GetImageInfo())); + const ImageInfo* info = GetImageInfo(); + if (info != nullptr) { + ImageCacheFree(*const_cast(info)); + } } }; diff --git a/code/sdk/application/wearable/fd230/nativeabilityfwk/src/Ability.cpp b/code/sdk/application/wearable/fd230/nativeabilityfwk/src/Ability.cpp index 9fb24f468..96368d19d 100644 --- a/code/sdk/application/wearable/fd230/nativeabilityfwk/src/Ability.cpp +++ b/code/sdk/application/wearable/fd230/nativeabilityfwk/src/Ability.cpp @@ -116,7 +116,7 @@ void Ability::ChangeSlice(const uint16_t targetSliceId, TransitionType type, #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, TransitionType::TRANSITION_ZOOM); + OHOS::AbilityMsClient::GetInstance().ForceStop(elementName->bundleName, type); targetSliceIdFromJS_ = targetSliceId; FreeElement(elementName); return; diff --git a/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt index 813dd0729..097cd192c 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt @@ -2,6 +2,7 @@ set(COMPONENT_NAME "nativelauncher") set(MODULE_NAME "app") set(AUTO_DEF_FILE_ID TRUE) set(NativeApp ${CMAKE_CURRENT_SOURCE_DIR}) +set(UIKIT_ROOT_DIR ${ROOT_DIR}/middleware/services/gui/uikit) set(UI_SAMPLE_ROOT ${ROOT_DIR}/middleware/services/gui/uikit/sample/uitest) set(PUBLIC_HEADER @@ -93,6 +94,10 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/utils/include ${ROOT_DIR}/open_source/openharmony/utils/native/lite/include ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/format/interfaces/include + ${UIKIT_ROOT_DIR}/proprietary/src/ui/innerkits + ${ROOT_DIR}/application/wearable/service/dial_market + ${ROOT_DIR}/open_source/openharmony/third_party/cJSON ${ROOT_DIR}/zhihui/UI/CustomUIComponentTool/ @@ -135,6 +140,7 @@ set(SOURCES list(REMOVE_ITEM SOURCES ${NativeApp}/nativeui/main/src/dial/parser/DialBinParser.cpp ${NativeApp}/nativeui/main/src/dial/parser/DialBinParserManager.cpp + ${NativeApp}/nativeui/main/src/dial/parser/DialBinParserV3.cpp ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) @@ -222,6 +228,7 @@ set(COMPONENT_SRC ${UIKIT_NATIVE_FWK}/src/TransitionRecord.cpp ${UIKIT_NATIVE_DIAL}/src/dial/parser/DialBinParser.cpp ${UIKIT_NATIVE_DIAL}/src/dial/parser/DialBinParserManager.cpp + ${UIKIT_NATIVE_DIAL}/src/dial/parser/DialBinParserV3.cpp ) set(SOURCES @@ -246,9 +253,11 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks ${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include/ ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/format/interfaces/include ${UIKIT_NATIVE_DIAL}/include/dial ${ROOT_DIR}/middleware/services/media/foundation/sample/wrapper ${ROOT_DIR}/middleware/services/media/foundation/player/interfaces/kits + ${UIKIT_ROOT_DIR}/proprietary/src/ui/innerkits ) set(PRIVATE_DEFINES diff --git a/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a b/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a index 025d43300..c530718d4 100644 Binary files a/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a and b/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a b/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a index 4e49f57f4..410571e58 100644 Binary files a/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a and b/code/sdk/application/wearable/fd230/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-fd230/libuikit_fwk.a b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-fd230/libuikit_fwk.a index 84c02f06e..55d73657a 100644 Binary files a/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-fd230/libuikit_fwk.a and b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-fd230/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-xts/libuikit_fwk.a b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-xts/libuikit_fwk.a index 84c02f06e..55d73657a 100644 Binary files a/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-xts/libuikit_fwk.a and b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-xts/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js/libuikit_fwk.a b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js/libuikit_fwk.a index 84c02f06e..55d73657a 100644 Binary files a/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js/libuikit_fwk.a and b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/nativeapp/brandy-xts/libuikit_fwk.a b/code/sdk/application/wearable/fd230/nativeapp/brandy-xts/libuikit_fwk.a index fc6ad8984..2c30eba89 100644 Binary files a/code/sdk/application/wearable/fd230/nativeapp/brandy-xts/libuikit_fwk.a and b/code/sdk/application/wearable/fd230/nativeapp/brandy-xts/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/NativeRegisterManager.h b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/NativeRegisterManager.h index 343fbac73..9225b8321 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/NativeRegisterManager.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/NativeRegisterManager.h @@ -50,6 +50,7 @@ public: void RegisterNative(const AppItem &nativeAppList, NativeRegisterCallback* native); void RegisterSlice(const uint16_t id, SliceProxy* slice); void RegisterMenu(const uint16_t id, const char *icon, const char *iconHexagon, const char *label); + bool IsSliceIdExist(AppViewId id); void RegisterMenuPro(const uint16_t id, const char *iconLarge, const char *iconSmall,const char *iconHexagon, const char *label, uint16_t TextId); private: diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/src/NativeRegisterManager.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/src/NativeRegisterManager.cpp index 7e13cd762..cf1d7b98b 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/src/NativeRegisterManager.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/src/NativeRegisterManager.cpp @@ -88,6 +88,16 @@ void NativeRegisterManager::RegisterMenu(const uint16_t id, const char *icon, co nativeAppLists_.PushBack(item); } +bool NativeRegisterManager::IsSliceIdExist(AppViewId id) +{ + for (uint16_t index = 0; index < slices_.Size(); index++) { + if (slices_[index].id == static_cast(id)) { + return true; + } + } + return false; +} + void NativeRegisterManager::RegisterMenuPro(const uint16_t id, const char *iconLarge, const char *iconSmall, const char *iconHexagon, const char *label, uint16_t TextId) { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp index e9fd5bc28..a58470e2d 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp @@ -51,8 +51,6 @@ AlipayPresenter *AlipayPresenter::GetInstance() void AlipayPresenter::OnStart() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlipayPresenter OnStart"); - Presenter::OnStart(); alipayMode_->AlipayExitLpm(); if (!alipayMode_->AlipayInitModel()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlipayPresenter::OnStart AlipayInitModel fail."); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp index c5a7339bf..03bf44dea 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -19,6 +19,25 @@ #include "SetDesktopView.h" #include "NativeRegisterManager.h" + +#ifdef XTS_SUPPORT +#include "hal_tick.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif +#ifdef XTS_SUPPORT + extern uint8_t is_xts_test_done(void); +#endif +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif + namespace OHOS { #define FOOTBALL_PLANE_MAX_NUM 20 @@ -57,6 +76,7 @@ namespace OHOS { void ApplistModel::ResolvingJSAppItems(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ResolvingJSAppItems start\r"); #ifdef JS_ENABLE if (bundleInfos != nullptr) { for (uint8_t i = 0; i < bundleLen; i++) { @@ -87,6 +107,7 @@ namespace OHOS { #ifdef JS_ENABLE int32_t len = 0; uint8_t ret = BundleMsClient::GetInstance().GetBundleInfos(0, &bundleInfos, &len); + printf("ResolvingJSAppItems GetBundleInfos ret = %d ,len = %d\r\n", ret, len); if ((ret == 0) && (len > 0) && (bundleInfos != nullptr)) { bundleLen = len; if (len > APP_MAX_NUM - nativeAppNumTotal) { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistView.cpp index 2bfd89579..11876d275 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistView.cpp @@ -57,7 +57,6 @@ ApplistView::~ApplistView() void ApplistView::OnStart() { - View::OnStart(); AppListStyle style = presenter_->GetCurrentStyle(); if (style == AppListStyle::FOOTBALL_STYLE) { FootballStyleOnStart(); @@ -131,8 +130,11 @@ void ApplistView::WaterfallStyleOnStart() int16_t blankSize = waterfallList_->GetRelativeRect().GetWidth() > waterfallList_->GetRelativeRect().GetHeight() ? waterfallList_->GetRelativeRect().GetWidth() / 2 : waterfallList_->GetRelativeRect().GetHeight() / 2; // 2, half waterfallList_->SetThrowDrag(true); - waterfallList_->SetReboundSize(imgDistance_ * Sin(60)); // 60, degree - waterfallList_->SetScrollBlankSize(0); + uint16_t layoutHeight = static_cast(imgDistance_ * Sin(60)); + waterfallList_->SetReboundSize(layoutHeight); // 60: degree, row's layout height + waterfallList_->SetScrollBlankSize(layoutHeight, UIAbstractScroll::Direction::TOP); + waterfallList_->SetScrollBlankSize(Screen::GetInstance().GetHeight() / 2 - layoutHeight, // 2: half + UIAbstractScroll::Direction::BOTTOM); waterfallList_->RequestFocus(); waterfallList_->SetRotateFactor(10); // 10, empirical coefficient waterfallList_->SetOnRotateListener(presenter_); @@ -201,7 +203,6 @@ void ApplistView::OnStop() } else { ListStyleOnStop(); } - FocusManager::GetInstance()->ClearFocus(); return; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp index 54e9fb1f6..ccf14147d 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -42,6 +42,7 @@ #include "dfx_channel.h" #include "tcxo.h" #include "ui_service.h" +#include "network/network_listener.h" #include "font/ui_font_header.h" @@ -1180,7 +1181,11 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); - + /* ---------------------------------- 补丁合入 ---------------------------------- */ + // send to ace network + // SetAclConnected(false); + net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_DISCONNECTED); + /* -------------------------------------------------------------------------- */ gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 0); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_SCAN_MODE_CONNECTABLE"); @@ -1189,6 +1194,12 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); + /* ---------------------------------- 补丁合入 ---------------------------------- */ + // send to ace network + // SetAclConnected(true); + net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_CONNECTED); + /* -------------------------------------------------------------------------- */ + uapi_set_ACL_br_address(bdAddr); gap_br_set_bt_scan_mode(GAP_SCAN_MODE_NONE, 0); @@ -1314,9 +1325,19 @@ static void BleConnStateChangeCallback(unsigned short connId, bd_addr_t *addr, g if (GAP_BLE_STATE_DISCONNECTED == connState) { // restart ble adv when disconnected /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); + + /* ---------------------------------- 补丁合入 ---------------------------------- */ + // send to ace network + net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_DISCONNECTED); + /* -------------------------------------------------------------------------- */ } else { SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); (void)memcpy_s(&g_bd_addr, sizeof(bd_addr_t), addr, sizeof(bd_addr_t)); + + /* ---------------------------------- 补丁合入 ---------------------------------- */ + // send to ace network + net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_CONNECTED); + /* -------------------------------------------------------------------------- */ } #endif } @@ -1373,6 +1394,8 @@ static void BtGattsServiceAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_ memcpy_s(character.chara_uuid.uuid, sizeof(character.chara_uuid.uuid), (char *)&diag_id, sizeof(diag_id)); character.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE | GATT_ATTRIBUTE_PERMISSION_READ; character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE | GATT_CHARACTER_PROPERTY_BIT_READ; + /* -------------------------------- 下方注释为补丁合入不确定是否合入 ------------------------------- */ + // character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP | GATT_CHARACTER_PROPERTY_BIT_READ | GATT_CHARACTER_PROPERTY_BIT_NOTIFY; character.value_len = (uint16_t)sizeof(value); character.value = (uint8_t *)(&value); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp index 511b5a3b8..7a6e49156 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp @@ -436,12 +436,12 @@ static void CallModelResumePlayer(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallModelResumePlayer] [ResumePlayer] start"); usleep(5000); // 延时等待通话释放媒体资源 - std::shared_ptr PlayerIntrptListener = - OHOS::PlayersModel::GetInstance()->GetPlayerIntrptListener(); - if (PlayerIntrptListener != nullptr && PlayerIntrptListener->IsPaused()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallModelResumePlayer] ResumePlayer "); - PlayerIntrptListener->ResumePlayer(); - } + // std::shared_ptr PlayerIntrptListener = + // OHOS::PlayersModel::GetInstance()->GetPlayerIntrptListener(); + // if (PlayerIntrptListener != nullptr && PlayerIntrptListener->IsPaused()) { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallModelResumePlayer] ResumePlayer "); + // PlayerIntrptListener->ResumePlayer(); + // } } static void CallModelPostGraphicEvent(void (*fun)(void)) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinParserManager.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinParserManager.h index 530c39b5b..50a9e4a6f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinParserManager.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinParserManager.h @@ -23,11 +23,25 @@ public: class DialBinParserManager { public: - static DialBinParserManager* GetInstance(void); - bool UpdateDial(const std::string& file, FILE* fp, DialViewGroup* group, DisplayState state); - bool GetDialPreviewInfo(FILE* fp, DialPreviewInfo* info); + static DialBinParserManager *GetInstance(void); + bool UpdateDial(const std::string &file, FILE *fp, DialViewGroup *group, DisplayState state); + bool GetDialPreviewInfo(FILE *fp, DialPreviewInfo *info); bool RegisterParser(const std::string &version, DialBinParserInterface *parser); + uint8_t GetSupportVersionCnt() const + { + return cnt_; + } + + bool GetVersionByIndex(uint8_t index, std::string &version) + { + if (index >= cnt_) { + return false; + } + version = parsers_[index].version; + return true; + } + private: DialBinParserManager(); virtual ~DialBinParserManager(); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinParserV3.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinParserV3.h new file mode 100644 index 000000000..1d5e2ca9d --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinParserV3.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialBinParserV3 + * Author: + * Create: 2025-02-06 + */ + +#ifndef GRAPHIC_LITE_DIAL_BIN_PARSER_V3_H +#define GRAPHIC_LITE_DIAL_BIN_PARSER_V3_H +#include "DialBinParserManager.h" +#include "DialTimePublisher.h" +#include "components/ui_abstract_progress.h" +#include "DialViewContainer.h" +#include "DialOHDataType.h" +#include "DialOHSliceId.h" + +namespace OHOS { +class DialBinParserV3 : public DialBinParserInterface { +public: + DialBinParserV3(); + ~DialBinParserV3() override; + bool UpdateDial(const std::string& file, FILE* fp, DialViewGroup* group, DisplayState state) override; + bool GetDialPreviewInfo(FILE* fp, DialPreviewInfo* info) override; + +protected: + bool ParseDialHeader(FILE* file); + bool ParserDialStaticImg(ContainerInterface &parent); + bool ParserDialSequenceImg(ContainerInterface &parent); + bool ParserDialRotateImg(ContainerInterface &parent); + bool ParserDialOptionImg(ContainerInterface &parent); + bool ParserDialDigitalImg(ContainerInterface &parent); + bool ParserDialLabel(ContainerInterface &parent); + bool ParserDialArcLabel(ContainerInterface &parent); + bool ParserDialBoxProgress(ContainerInterface &parent); + bool ParserDialArcProgress(ContainerInterface &parent); + bool ParserDialVideo(ContainerInterface &parent); + bool ParserDialClick(ContainerInterface &parent); + bool ParserDialKaleidoscope(ContainerInterface &parent); + bool ParserDialContainer(ContainerInterface &parent); + bool ParserDialOptions(ContainerInterface &parent); + +private: + void* MallocAndReadBuf(FILE* file, uint32_t readSize); + bool SetProgressType(FILE* fp, UIAbstractProgress* view, DialProgressType data); + + static constexpr uint8_t DIAL_BIN_PARSER_FUNC_NUM = 14; // 14: func max value + bool (DialBinParserV3::*funcArray_[DIAL_BIN_PARSER_FUNC_NUM])(ContainerInterface&); + void AddToParentWithView(ContainerInterface &parent, uint8_t displayMode, UIView *view); + void AddToParentWithDialView(ContainerInterface &parent, uint8_t displayMode, + DialView *view, DialOHDataType bindData, bool isPeriodic); + struct { + uint8_t *viewType; + uint8_t dialViewCount; + FILE *file; + uint8_t curIndex; + } curViewType_; + bool ParseTimeIntervals(FILE* fp, uint8_t cnt, DialTimePublisher::TimeChangeListener *listener); + bool ParseViewType(uint8_t *viewType, uint8_t dialViewCount, FILE *file); + bool ParseContainerSubviews(DialViewContainer *container, uint8_t num); + bool ParseOptionsSubviews(ContainerInterface &parent); + + DialViewGroup* dialGroup_ = nullptr; + std::string file_; + uint32_t dirId_ = 0xfef << 20; // 20: offset + uint32_t imageOffset_ = 0; + DisplayState state_ = DisplayState::NORMAL; +}; // class DialBinParserV3 +} // namespace OHOS + +#endif // GRAPHIC_LITE_DIAL_BIN_PARSER_V3_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinTypes.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinTypes.h index d242a3dc2..3301b3d77 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinTypes.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/DialBinTypes.h @@ -30,6 +30,9 @@ struct DialPreviewInfo { uint32_t imgId; uint32_t offset; uint8_t capability; + uint32_t uuid; + char protocolVersion[DIAL_VERSION_MAX_LEN]; + char watchVersion[DIAL_VERSION_MAX_LEN]; }; struct DialRect { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h index 80269cfbb..6043be78e 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h @@ -41,8 +41,63 @@ #include "sleep/include/SleepCardView.h" #include "set_card/include/SetMainView.h" #include "heartrate/include/HeartRateCardView.h" + +#ifdef XTS_SUPPORT +#include "hal_tick.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif +#ifdef XTS_SUPPORT + extern uint8_t is_xts_test_done(void); +#endif +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif + namespace OHOS { + #ifdef XTS_SUPPORT + class XTSCallback : public AnimatorCallback + { + public: + explicit XTSCallback(UILabel *XTSlabel) : XTSlabel(XTSlabel) {} + ~XTSCallback() {} + virtual void Callback(UIView *view) + { + uint8_t xts_testing = 1; +#ifdef XTS_SUPPORT + xts_testing = is_xts_test_done(); +#endif + if (!xts_testing) + { + // XTS测试进行 + xts_flag = 1; + XTSlabel->SetText("XTS测试进行中\n请勿操作表盘"); + XTSlabel->SetTextColor(Color::GetColorFromRGBA(0xe6, 0x04, 0x09, 0xff)); + } + else + { + // XTS测试结束 + if (xts_flag) + { + XTSlabel->SetText("XTS测试结束"); + XTSlabel->SetTextColor(Color::GetColorFromRGBA(0x4e, 0xe6, 0x04, 0xff)); + xts_flag = 0; // 复位 + } + } + } + private: + uint8_t xts_flag = 0; // 标志位 + UILabel *XTSlabel{nullptr}; + }; + #endif + class MainPresenterSample; class MainViewSample : public View { @@ -121,7 +176,14 @@ namespace OHOS UIImageView *dialstateicon_{nullptr}; UIImageView *messageicon_{nullptr}; + +#ifdef XTS_SUPPORT + /* --------------------------------- XTS监测标签 -------------------------------- */ + UILabel *XTSLabel = nullptr; + AnimatorCallback *xtsCallback_ = nullptr; + Animator *xtsanimator_ = nullptr; /* -------------------------------------------------------------------------- */ +#endif UICardPage *recordCard[MAX_CARD]{nullptr}; bool pageStatus[MAX_CARD]{false}; UICrossView *mainSwipeGroup{nullptr}; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialArcLabelView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialArcLabelView.h index d3ad91ee2..43d0dd217 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialArcLabelView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialArcLabelView.h @@ -8,9 +8,10 @@ #include #include "DialView.h" #include "components/ui_arc_label.h" +#include "font/font_global_manager.h" namespace OHOS { -class DialArcLabelView : public UIArcLabel, public DialView { +class DialArcLabelView : public UIArcLabel, public DialView, public FontGlobalManager::LangChangeListener { public: DialArcLabelView(); ~DialArcLabelView() override; @@ -20,12 +21,15 @@ public: void HandleTextData(const std::string* data, uint16_t num) override; void HandleFloatData(const float* data, uint16_t num) override; void HandleFloatData(float data) override; + void SetLang(uint8_t lang); + void OnLangChange(uint8_t langId) override; private: void SetTextWithWildcardInner(const char* text); static const uint8_t MAX_BUF_SIZE = 255; char* text_ = nullptr; char dstBuf_[MAX_BUF_SIZE] = {0}; + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; }; } #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDataBase.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDataBase.h index 077473636..d258eec5a 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDataBase.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDataBase.h @@ -42,10 +42,10 @@ enum class DialDataType { DATA_TYPE_STEPS_GOAL_INT, // 运动步数百分比 DATA_TYPE_CALORIE_GOAL_INT, // 运动卡路里目标百分比 - DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff, // 多个浮点数据类型基值 + DATA_TYPE_MULTI_FLOAT_BASE = 0x4000, // 多个浮点数据类型基值 DATA_TYPE_HOUR_MIN, // 时分 - DATA_TYPE_TEXT_BASE = 0x4fff, // 文本数据类型基值 + DATA_TYPE_TEXT_BASE = 0x2000, // 文本数据类型基值 DATA_TYPE_WEEK_STR, // 星期(string) DATA_TYPE_DATE_STR, // 日期(string) DATA_TYPE_WEATHER_STR, // 天气(string) @@ -58,6 +58,13 @@ enum class DialDataType { DATA_TYPE_STEPS_GOAL_STR, // 运动步数目标(string) DATA_TYPE_CALORIE_GOAL_STR, // 卡路里目标(string) - DATA_TYPE_MAX = 0x7fff, // 数据类型的最大值 + DATA_TYPE_SWIVEL_GEAR_ONE = 20, + DATA_TYPE_SWIVEL_GEAR_TWO, + DATA_TYPE_SWIVEL_GEAR_THREE, + DATA_TYPE_SWIVEL_GEAR_FOUR, + DATA_TYPE_SWIVEL_GEAR_FIVE, + DATA_TYPE_SWIVEL_GEAR_SIX, + + DATA_TYPE_MAX = 0x6000, // 数据类型的最大值 }; #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h index 2817eabc9..5b3249662 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h @@ -7,6 +7,7 @@ #include #include "DialView.h" +#include "DialTimePublisher.h" #include "components/ui_image_view.h" #include "gfx_utils/graphic_math.h" #include "components/ui_view_group.h" @@ -19,7 +20,7 @@ enum class ImgAlign { RIGHT, }; -class DialDigitalImgView : public UIImageView, public DialView { +class DialDigitalImgView : public UIImageView, public DialView, public DialTimePublisher::TimeChangeListener { public: DialDigitalImgView(); ~DialDigitalImgView() override; @@ -35,6 +36,7 @@ public: void SetAlignPos(Point pos); void SetDecimalPrecision(uint8_t precision); void SetParent(UIViewGroup* parent); + void OnTimeUpdate(const struct tm &curTime) override; private: void SetNumImg(UIImageView* img, const ImageInfo *info); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialLabelView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialLabelView.h index 355656e7d..0a9097522 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialLabelView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialLabelView.h @@ -8,10 +8,10 @@ #include #include "DialView.h" #include "components/ui_label.h" +#include "font/font_global_manager.h" #include "components/ui_label_ext.h" - namespace OHOS { -class DialLabelView : public UILabel, public DialView { +class DialLabelView : public UILabel, public DialView, public FontGlobalManager::LangChangeListener { public: DialLabelView(); ~DialLabelView() override; @@ -21,12 +21,15 @@ public: void HandleTextData(const std::string* data, uint16_t num) override; void HandleFloatData(const float* data, uint16_t num) override; void HandleFloatData(float data) override; + void SetLang(uint8_t lang); + void OnLangChange(uint8_t langId) override; private: void SetTextWithWildcardInner(const char* text); static const uint8_t MAX_BUF_SIZE = 255; char* text_ = nullptr; char dstBuf_[MAX_BUF_SIZE] = {0}; + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; }; } #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTime.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTime.h index 65067ac6f..43cd8b08d 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTime.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTime.h @@ -9,27 +9,37 @@ #define DIAL_MODEL_TIME_H #include "DialBaseModel.h" +#include "DialTimePublisher.h" +#include "gfx_utils/list.h" namespace OHOS { -class DialModelTime : public DialBaseModel { +class DialModelTime : public DialBaseModel, public DialTimePublisher { public: - DialModelTime() {} - ~DialModelTime() override {} + DialModelTime() + { + DialModelTime::SetPublisher(dynamic_cast(this)); + } + ~DialModelTime() override + { + listeners_.Clear(); + } static DialModelTime* GetInstance() { static DialModelTime instance; return &instance; } bool GetDialFloatData(DialDataType& type, float& out) override; - void UpdateTime(); + void UpdateTime() override; + void Register(TimeChangeListener* listener) override; + void Unregister(TimeChangeListener* listener) override; private: - struct tm tblock_; + struct tm *tblock_; uint16_t angleH_ = 0; uint16_t angleM_ = 0; uint16_t angleS_ = 0; float angleMS_ = 0; - uint8_t pm_ = 0; + List listeners_; }; } #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOHDataType.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOHDataType.h new file mode 100644 index 000000000..83f8f0fc8 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOHDataType.h @@ -0,0 +1,189 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialOHDataType + * Author: + * Create: 2025-02-15 + */ + +#ifndef DIAL_OH_DATATYPE_H +#define DIAL_OH_DATATYPE_H + +#include +#include "DialDataBase.h" + +namespace OHOS { +enum class DialOHDataType : int16_t { + CLOCK = 1, + CLOCK_HIGH_BIT = 2, + CLOCK_LOW_BIT = 3, + CLOCK_RATIO_12 = 4, + CLOCK_RATIO_24 = 5, + MINUTES = 6, + MINUTES_HIGH_BIT = 7, + MINUTES_LOW_BIT = 8, + MINUTES_RATIO = 9, + SECONDS = 10, + SECONDS_HIGH_BIT = 11, + SECONDS_LOW_BIT = 12, + SECONDS_RATIO = 13, + AM_PM = 14, + AMPM_TEXT = 15, + HOUR_MODE = 16, + PREVIOUS_HOUR = 17, + NEXT_HOUR = 18, + CLOCK_ANGLE = 19, + MINUTE_ANGLE = 20, + SECONDS_ANGLE = 21, + MILLISECOND_ANGLE = 22, + PREVIOUS_SECOND = 25, + NEXT_SECOND = 26, + PREVIOUS_SECOND_PREVIOUS_SECOND = 27, + PREVIOUS_MINUTE = 28, + NEXT_MINUTE = 29, + DUAL_TIME_ZONE_CLOCK = 30, + DUAL_TIME_ZONE_CLOCK_HIGH_BIT = 31, + DUAL_TIME_ZONE_CLOCK_LOW_BIT = 32, + DUAL_TIME_ZONE_CLOCK_RATIO_12 = 33, + DUAL_TIME_ZONE_CLOCK_RATIO_24 = 34, + DUAL_TIME_ZONE_MINUTES = 35, + DUAL_TIME_ZONE_MINUTES_HIGH_BIT = 36, + DUAL_TIME_ZONE_MINUTES_LOW_BIT = 37, + DUAL_TIME_ZONE_MINUTES_RATIO = 38, + DUAL_TIME_ZONE_ABBREVIATION_TEXT = 39, + DUAL_TIME_ZONE_TIME_MINUTE_TEXT = 40, + DUAL_TIME_ZONE_AMPM = 41, + DUAL_TIME_ZONE_AM_PM_TEXT = 42, + SUNRISE_SUNSET_PICTURE_SELECTION = 50, + SUNRISE_SUNSET_CLOCK_HIGH_BIT = 51, + SUNRISE_SUNSET_CLOCK_LOW_BIT = 52, + SUNRISE_SUNSET_MINUTES_HIGH_BIT = 53, + SUNRISE_SUNSET_MINUTES_LOW_BIT = 54, + SUNRISE_TEXT = 55, + SUNSET_TEXT = 56, + MOONRISE_TEXT = 60, + MOONSET_TEXT = 61, + DATE = 70, + DATE_HIGH_BIT = 71, + DATE_LOW_BIT = 72, + DATE_OCCUPIES_31_DAYS_RATIO = 73, + YESTERDAY = 74, + YESTERDAY_DATE_HIGH_BIT = 75, + YESTERDAY_DATE_LOW_BIT = 76, + TOMORROW = 77, + TOMORROW_DATE_HIGH_BIT = 78, + TOMORROW_DATE_LOW_BIT = 79, + MONTH_DATA = 80, + MONTH = 81, + MONTH_TEXT = 82, + WEEK_DATA = 83, + WEEK_RATIO = 84, + WEEK_TEXT = 85, + TWELVE_DIVISIONS = 86, + LUNAR_PHASE = 87, + PREVIOUS_MONTH = 88, + NEXT_MONTH = 89, + LUNAR_MONTH = 90, + LUNAR_DATE_HIGH_BIT = 91, + LUNAR_DATE_LOW_BIT = 92, + CHARGE = 100, + CHARGE_ENUMERATION = 102, + CHARGE_STATUS_ENUMERATION = 103, + CHARGE_RATIO = 104, + CHARGING_STATUS = 105, + STEPS = 110, + STEPS_UNIT_DIGIT = 111, + STEPS_TENS_DIGIT = 112, + STEPS_HUNDRED_DIGIT = 113, + STEPS_THOUSAND_DIGIT = 114, + STEPS_TEN_THOUSAND_DIGIT = 115, + STEPS_TARGET_ACHIEVEMENT_RATE = 116, + STEPS_TARGET_PROGRESS_ENUMERATION = 117, + CALORIES = 120, + CALORIES_RATIO = 121, + CALORIES_TARGET_PROGRESS_ENUMERATION = 122, + HEART_RATE = 130, + MAXIMUM_HEART_RATE = 131, + MINIMUM_HEART_RATE = 132, + HEART_RATE_RANGE = 133, + HEART_RATE_RATIO = 134, + STRESS = 140, + STRESS_RATIO = 141, + STRESS_LEVEL_TYPE = 142, + MODERATE_TO_VIGOROUS_INTENSITY_TIME = 150, + MODERATE_TO_VIGOROUS_INTENSITY_TIME_RATIO = 151, + STANDING_TIMES = 152, + STANDING_TIMES_RATIO = 153, + MAXIMUM_OXYGEN_UPTAKE = 160, + MAXIMUM_OXYGEN_UPTAKE_RATIO = 161, + SLEEP_TEXT = 165, + SLEEP_RATIO = 166, + SLEEP_TARGET_ACHIEVEMENT_RATE_ENUMERATION = 167, + TEMPERATURE = 170, + HIGHEST_TEMPERATURE = 171, + LOWEST_TEMPERATURE = 172, + CURRENT_TEMPERATURE_MINUS_ONE = 173, + CURRENT_TEMPERATURE_PLUS_ONE = 174, + TEMPERATURE_TYPE = 175, + WEATHER_TYPE = 176, + TEMPERATURE_RATIO = 177, + ATMOSPHERIC_PRESSURE = 180, + ATMOSPHERIC_PRESSURE_RATIO = 181, + AIR_QUALITY_INDEX = 182, + AIR_QUALITY_INDEX_LEVEL = 183, + AIR_QUALITY_INDEX_RATIO = 184, + ELEVATION = 190, + ELEVATION_HEIGHT_DATA = 191, + ELEVATION_HEIGHT_UNIT = 192, + HEIGHT_RATIO = 193, + DISTANCE_TEXT = 194, + DISTANCE_DATA = 195, + DISTANCE_UNIT = 196, + DISTANCE_TARGET_PROGRESS = 197, + HIGH_TIDE_TIME_TEXT = 200, + LOW_TIDE_TIME_TEXT = 201, + BLE_CONNECTION_STATUS = 210, + BT_CONNECTION_STATUS = 211, + BLOOD_OXYGEN = 220, + SYSTOLIC_BLOOD_PRESSURE = 221, + DIASTOLIC_BLOOD_PRESSURE = 222, + DUAL_LANGUAGE_SYSTEM = 230, + SWIVEL_GEAR_POSITIVE = (1 << 12) + 20, // private data, clockwise + SWIVEL_GEAR_NEGATIVE, // counterclockwise +}; // enum class DialOHDataType + +struct HashOHDataType { + size_t operator()(DialOHDataType data) const + { + return std::hash()(static_cast(data)); + } +}; + +const std::unordered_map g_bindDataConverter = { + {DialOHDataType::CLOCK, DialDataType::DATA_TYPE_TIME_HOUR}, + {DialOHDataType::MINUTES, DialDataType::DATA_TYPE_TIME_MINUTE}, + {DialOHDataType::SECONDS, DialDataType::DATA_TYPE_TIME_SECOND}, + {DialOHDataType::MILLISECOND_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_MS}, + {DialOHDataType::DATE, DialDataType::DATA_TYPE_TIME_DATE}, + {DialOHDataType::WEEK_DATA, DialDataType::DATA_TYPE_TIME_WEEK}, + {DialOHDataType::CHARGE, DialDataType::DATA_TYPE_POWER}, + {DialOHDataType::STEPS, DialDataType::DATA_TYPE_STEPS}, + {DialOHDataType::CALORIES, DialDataType::DATA_TYPE_CALORIE}, + {DialOHDataType::HEART_RATE, DialDataType::DATA_TYPE_HEART_RATE}, + {DialOHDataType::STRESS, DialDataType::DATA_TYPE_PRESSURE}, + {DialOHDataType::TEMPERATURE, DialDataType::DATA_TYPE_TEMPERATURE}, + {DialOHDataType::ELEVATION, DialDataType::DATA_TYPE_AILTITUDE}, + {DialOHDataType::AIR_QUALITY_INDEX, DialDataType::DATA_TYPE_PM25}, + {DialOHDataType::CLOCK_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_H}, + {DialOHDataType::MINUTE_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_M}, + {DialOHDataType::SECONDS_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_S}, + {DialOHDataType::MONTH, DialDataType::DATA_TYPE_TIME_MONTH}, + {DialOHDataType::SWIVEL_GEAR_POSITIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_ONE}, + {DialOHDataType::SWIVEL_GEAR_POSITIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_FOUR}, + {DialOHDataType::SWIVEL_GEAR_POSITIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_SIX}, + {DialOHDataType::SWIVEL_GEAR_NEGATIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_TWO}, + {DialOHDataType::SWIVEL_GEAR_NEGATIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_THREE}, + {DialOHDataType::SWIVEL_GEAR_NEGATIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_FIVE}, +}; +} // namespace OHOS + +#endif // DIAL_OH_DATATYPE_H diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOHSliceId.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOHSliceId.h new file mode 100644 index 000000000..f19784a3b --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOHSliceId.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialOHSliceId + * Author: + * Create: 2025-02-15 + */ + + +#ifndef DIALOHSLICEID_H +#define DIALOHSLICEID_H + +#include +#include "AppViewIDs.h" + +namespace OHOS { +enum class DialOHSliceId : uint16_t { + DUAL_TIME_ZONES = 0, + HEART_RATE = 1, + STANDING_TIMES = 2, + STRESS = 3, + MODERATE_TO_VIGOROUS_INTENSITY_TIME = 4, + WEATHER = 5, + AIR_QUALITY_ONLY_CHINA = 6, + ATMOSPHERIC_PRESSURE = 7, + ELEVATION_HEIGHT = 8, + SUNRISE_SUNSET_TIME = 9, + DISTANCE = 10, + SLEEP = 11, + EXERCISE = 12, + PAYMENT_ONLY_CHINA = 13, + ALARM_CLOCK = 14, + STOPWATCH = 15, + TIMER = 16, + EXERCISE_RECORD = 17, + TRAINING_STATUS = 18, + ACTIVITY_RECORD = 19, + AEROBIC_EXERCISE = 20, + CONTACTS = 21, + MUSIC = 22, + COMPASS = 23, + CALL_LOG = 24, + BLOOD_OXYGEN_SATURATION_ONLY_CHINA = 25, + ULTRAVIOLET_RAYS_ONLY_CHINA = 26, + PHASE_OF_THE_MOON = 27, + STAIR_CLIMBING = 28, + BLOOD_PRESSURE = 29, + MESSAGE_LIST = 30, + DIAL = 31, + AUDIO_SWITCH = 32, +}; // enum class DialOHSliceId + +struct HashOhSliceId { + size_t operator()(DialOHSliceId id) const + { + return std::hash()(static_cast(id)); + } +}; + +const std::unordered_map g_sliceIdConverter = { + {DialOHSliceId::COMPASS, VIEW_COMPASS}, + {DialOHSliceId::DIAL, VIEW_CALLER_SAMPLE}, + {DialOHSliceId::ALARM_CLOCK, VIEW_MAIN_ALARM}, + {DialOHSliceId::AUDIO_SWITCH, VIEW_VOLUME}, +}; +} // namespace OHOS +#endif // DIALOHSLICEID_H diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOptionImgView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOptionImgView.h index 4fa2fbd65..dd08a9d6b 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOptionImgView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialOptionImgView.h @@ -7,11 +7,16 @@ #include #include "DialView.h" +#include "DialTimePublisher.h" #include "components/ui_image_view.h" +#include "font/font_global_manager.h" namespace OHOS { -class DialOptionImgView : public UIImageView, public DialView { +class DialOptionImgView : public UIImageView, + public DialView, + public FontGlobalManager::LangChangeListener, + public DialTimePublisher::TimeChangeListener { public: DialOptionImgView(); ~DialOptionImgView() override; @@ -20,10 +25,19 @@ public: bool SetOptionRes(const ImageInfo* src, uint16_t num); + void SetLang(uint8_t lang); + + void OnLangChange(uint8_t langId) override; + + void OnTimeUpdate(const struct tm &curTime) override; + private: ImageInfo* info_ = nullptr; uint16_t infoNum_ = 0; int16_t selected_ = -1; + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; + bool langVisible_ = true; + bool timeVisible_ = true; }; } #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialSequenceContainer.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialSequenceContainer.h new file mode 100644 index 000000000..f692d1f3b --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialSequenceContainer.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialSequenceContainer + * Author: + * Create: 2025-03-05 + */ + +#ifndef DIAL_SEQUENCE_CONTAINER_H +#define DIAL_SEQUENCE_CONTAINER_H +#include "components/ui_view_group.h" +#include "components/ui_image_animator.h" + +namespace OHOS { +class DialSequenceContainer : public UIViewGroup, public UIImageAnimatorView::AnimatorStopListener { +public: + DialSequenceContainer(); + ~DialSequenceContainer() override; + DialSequenceContainer(const DialSequenceContainer&) = delete; + DialSequenceContainer& operator=(const DialSequenceContainer&) = delete; + bool AddSequenceRes(uint16_t interval, bool repeat, const ImageAnimatorInfo *imgSrc, uint8_t imgNum); + bool OnClickEvent(const ClickEvent& event) override; + void Start(); + void Stop(); + void Pause(); + void Resume(); + void OnAnimatorStop(UIView& view) override; + +private: + void UpdateCurrentView(); + UIImageAnimatorView *repeatView_ = nullptr; + UIImageAnimatorView *nonCycleView_[3]; // 3: max seqImg num + // if curView_ is not null, curView_ must be added into parent. + UIImageAnimatorView *curView_ = nullptr; + uint8_t nonCycleNum_ = 0; + uint8_t loop_ = 0; + bool isClick_ = false; +}; // class DialSequenceContainer +} // namespace OHOS +#endif // DIAL_SEQUENCE_CONTAINER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialStaticImgView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialStaticImgView.h index e1b48a0a6..733c5ed7a 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialStaticImgView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialStaticImgView.h @@ -6,12 +6,29 @@ #define DIAL_STATIC_IMG_VIEW_H #include "components/ui_image_view.h" +#include "font/font_global_manager.h" +#include "DialTimePublisher.h" namespace OHOS { -class DialStaticImgView : public UIImageView { +class DialStaticImgView : public UIImageView, + public FontGlobalManager::LangChangeListener, + public DialTimePublisher::TimeChangeListener { public: DialStaticImgView(); ~DialStaticImgView() override; + void SetLang(uint8_t lang); + void OnLangChange(uint8_t langId) override; + bool SetImgs(const ImageInfo* src, uint8_t num); + bool OnClickEvent(const ClickEvent& event) override; + void OnTimeUpdate(const struct tm &curTime) override; + +private: + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; + ImageInfo* info_ = nullptr; + uint8_t infoNum_ = 0; + int16_t selected_ = -1; + bool langVisible_ = true; + bool timeVisible_ = true; }; } #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialTimePublisher.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialTimePublisher.h new file mode 100644 index 000000000..fcdb80cb3 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialTimePublisher.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialTimePublisher + * Author: + * Create: 2025-03-04 + */ + +#ifndef DIAL_TIME_PUBLISHER_H +#define DIAL_TIME_PUBLISHER_H +#include +#include + +namespace OHOS { +class DialTimePublisher { +public: + struct TimeInterval { + uint8_t start; + uint8_t end; + }; + class TimeChangeListener { + public: + virtual void OnTimeUpdate(const struct tm &curTime) = 0; + void SetTimeInervals(TimeInterval *intervals, uint8_t num); + bool IsInTimeInterval(const struct tm &curTime); + TimeChangeListener(const TimeChangeListener&) = delete; + TimeChangeListener& operator=(const TimeChangeListener&) = delete; + TimeChangeListener(); + virtual ~TimeChangeListener(); + private: + TimeInterval *intervals_ = nullptr; + uint8_t num_ = 0; + }; + + virtual void Register(TimeChangeListener *listener) = 0; + virtual void Unregister(TimeChangeListener *listener) = 0; + virtual void UpdateTime() = 0; + static void SetPublisher(DialTimePublisher *publisher); + static DialTimePublisher *GetPublisher(); + virtual ~DialTimePublisher() {} + +private: + static DialTimePublisher *publisher_; +}; // class DialTimePublisher +} // namespace OHOS +#endif // DIAL_TIME_PUBLISHER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewContainer.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewContainer.h new file mode 100644 index 000000000..0dd421c44 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewContainer.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialViewContainer + * Author: + * Create: 2025-02-06 + */ + +#ifndef DIAL_VIEW_CONTAINER_H +#define DIAL_VIEW_CONTAINER_H +#include "components/ui_view_group.h" +#include "gfx_utils/list.h" +#include "dial/DialView.h" +#include "dial/DialDataBase.h" + +namespace OHOS { +class ContainerInterface { +public: + virtual void AddView(UIView* view) = 0; + + virtual void AddView(DialDataType type, DialView* view, bool isPeriodic) = 0; + + virtual ~ContainerInterface() {} +}; + +class DialViewContainer : public UIViewGroup, public ContainerInterface { +public: + struct SubView { + UIView *view; + DialView *dialView; + DialDataType type; + bool isPeriodic; + }; + DialViewContainer(uint8_t dialviewNum, uint16_t dataSize) : + dialViewNum_(dialviewNum), dataSize_(dataSize) + { + SetTouchable(true); + } + DialViewContainer() {} + ~DialViewContainer() override; + DialViewContainer(const DialViewContainer&) = delete; + DialViewContainer& operator=(const DialViewContainer&) = delete; + + uint8_t GetDialviewNum() const + { + return dialViewNum_; + } + + uint16_t GetDataSize() const + { + return dataSize_; + } + + void AddView(UIView* view) override; + + void AddView(DialDataType type, DialView* view, bool isPeriodic) override; + + ListNode* Begin() + { + return dialViews_.Begin(); + } + + const ListNode* End() + { + return dialViews_.End(); + } + + bool HasInvalidBindData() const + { + return hasInvalidBindData_; + } + + bool RemoveSubView(uint8_t index, SubView &subView); + + bool IsInvalidateBindData(uint8_t index); + +private: + uint8_t dialViewNum_; + uint16_t dataSize_; + List dialViews_; + bool hasInvalidBindData_ = false; +}; // class DialViewContainer +} // namesapce OHOS +#endif // DIAL_VIEW_CONTAINER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h index f1b5844f6..92b014ec2 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h @@ -8,16 +8,21 @@ #include #include "DialDataBase.h" #include "components/ui_view_group.h" +#include "components/ui_image_animator.h" +#include "components/ui_label.h" #include "OnDialDataUpdateListener.h" #include "components/ui_card_page.h" #include "components/ui_kaleidoscope_view.h" #include "gfx_utils/list.h" +#include "gfx_utils/vector.h" #include "DialView.h" #include "DialVideoView.h" #include "DialBinTypesV2.h" +#include "DialViewContainer.h" +#include "DialSequenceContainer.h" namespace OHOS { -class DialViewGroup : public UICardPage, public OnDialDataUpdateListener { +class DialViewGroup : public UICardPage, public OnDialDataUpdateListener, public ContainerInterface { public: DialViewGroup(); ~DialViewGroup() override; @@ -30,12 +35,12 @@ public: /** * @brief Add a view which binds with data of a specific type and could be updated periodically. */ - void AddView(DialDataType type, DialView* view, bool isPeriodic = false); + void AddView(DialDataType type, DialView* view, bool isPeriodic) override; /** - * @brief Add a view. If the view is DialVideoView, the second parameter should be true. + * @brief Add a view. */ - void AddView(UIView* view, bool isDialVideoView = false); + void AddView(UIView* view) override; /** * @brief Add a click rect. When the rect is clicked, it will start a js app with the given bundleName. @@ -112,14 +117,31 @@ public: */ void OnActive(void) override; - void OnInactive() override; + /** + * @brief This function is invoked when the function SetHorCurrentPage() is called. + */ + void OnInactive(void) override; + + /** + * @brief This function is invoked when SetVerCurrentPage is called and horizontal page is covered. + */ + void OnCovered(void) override; + + /** + * @brief This function is invoked when SetVerCurrentPage is called and horizontal page is not covered. + */ + void OnUncovered(void) override; + void OnPause() override; + + /* -------------------------------------------------------------------------- */ /*外部接口对表盘进行调用*/ void StopDial(); void StartDial(); /*外部接口更新表盘状态*/ void UpdateStateShow(); + /* -------------------------------------------------------------------------- */ MediaVideoPlay* GetVideoPlay(); @@ -130,7 +152,15 @@ private: private: void ProcessData(DialDataType type, DialView* view); - std::unordered_map dataTypeMap_; + void DoStop(void); + void DoStart(void); + void DoPause(void); + void RecordSpecial(UIView *view); + void RecordBindData(DialDataType type, DialView* view, bool isPeriodic); + void ClearViews(); + using Views = Graphic::Vector; + std::unordered_map dataTypeMap_; + Graphic::Vector viewsMemPool_; List periodicUpdateTypes_; List passiveUpdateTypes_; List dialViews_; @@ -155,6 +185,12 @@ private: List dialClicks_; void ClearDial(); + + void SetLableAnimatorState(uint8_t state); + void SetImgAnimatorState(uint8_t state); + List rollingLabelList_; + List imgAnimList_; + List seqList_; }; } #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h index 33bedbe49..30c1d1c31 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h @@ -11,6 +11,7 @@ #include #include "DialBaseModel.h" #include "DialDataBase.h" +#include "DialOHDataType.h" #include "ModelDialDataFactory.h" namespace OHOS { @@ -30,6 +31,8 @@ public: models_[static_cast(type)] = model; } + bool IsOHBindDataExist(DialOHDataType type) const; + bool IsBindDataExist(DialDataType type) const; bool RegisterDialDataListener(DialDataType type, OnDialDataUpdateListener* listener); bool UnRegisterDialDataListener(DialDataType type); bool GetDialTextData(DialDataType& type, std::string*& out, int16_t& strNum); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/WatchInterface.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/WatchInterface.h new file mode 100644 index 000000000..2938ed4a0 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/WatchInterface.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: WatchInterface + * Author: + * Create: 2025-03-17 + */ + +#ifndef WATCH_INTERFACE_H +#define WATCH_INTERFACE_H +#include +#include "format_type.h" +#include "dial_market.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get all watch face information + * @param[out] info Pointer to store the watch face information + * @param[out] num Pointer to store the number of watch faces + * @param[in] maxCnt Maximum number of watch faces to retrieve + * @return bool Returns true if successful, false otherwise + */ +bool GetAllWatchFaceInfo(watch_dial_info *info, uint8_t *num, uint8_t maxCnt); + +/** + * @brief Get information of a specific watch face by UUID + * @param[in] uuid Unique identifier of the watch face + * @param[out] watch Pointer to store the watch face information + * @return bool Returns true if successful, false otherwise + */ +bool GetWatchFaceInfo(uint32_t uuid, watch_dial_info *watch); + +/** + * @brief Get the capability set of the watch + * @param[out] capability Pointer to store the watch capability information + * @return bool Returns true if successful, false otherwise + */ +bool GetWatchCapability(watch_dev_cap_info *capability); + +/** + * @brief Get system information + * @param[out] sysInfo Pointer to store the system information + * @return bool Returns true if successful, false otherwise + */ +bool GetWatchSystemInfo(watch_sys_info *sysInfo); + +/** + * @brief Get information of the currently active watch face + * @param[out] watch Pointer to store the watch face information + * @return bool Returns true if successful, false otherwise + */ +bool GetCurrentWatchFaceInfo(watch_dial_info *watch); + +/** + * @brief Set the currently active watch face by UUID + * @param[in] uuid Unique identifier of the watch face to set as active + * @return bool Returns true if successful, false otherwise + */ +bool SetCurrentWatchFace(uint32_t uuid); + +/** + * @brief Uninstall a watch face by UUID + * @param[in] uuid Unique identifier of the watch face to uninstall + * @return bool Returns true if successful, false otherwise + * @note If the UUID corresponds to the currently active watch face, it will switch to the default watch face + */ +bool UninstallWatch(uint32_t uuid); + +/** + * @brief Install a watch face from a specified path + * @param[in] path Path to the watch face file + * @param[out] uuid Pointer to store the unique identifier of the installed watch face + * @return bool Returns true if successful, false otherwise + * @note If a watch face with the same UUID already exists, it will be replaced + */ +bool InstallWatch(const char *path, uint32_t *uuid); + +#ifdef __cplusplus +} +#endif +#endif // WATCH_INTERFACE_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp index bbeca06ec..bb5f686d8 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -167,6 +167,26 @@ namespace OHOS delete callback; callback = nullptr; } +#ifdef XTS_SUPPORT + /* ----------------------------------- XTS ---------------------------------- */ + if(XTSLabel) + { + delete XTSLabel; + XTSLabel = nullptr; + } + if (xtsCallback_ != nullptr) + { + delete xtsCallback_; + xtsCallback_ = nullptr; + } + if (xtsanimator_ != nullptr) + { + xtsanimator_->Stop(); + delete xtsanimator_; + xtsanimator_ = nullptr; + } + /* -------------------------------------------------------------------------- */ +#endif g_pMainView = nullptr; } MainViewSample *MainViewSample::GetInstance(void) @@ -245,6 +265,26 @@ namespace OHOS } // } +#ifdef XTS_SUPPORT + /* ----------------------------------- XTS ---------------------------------- */ + if (XTSLabel == nullptr) + { + XTSLabel = new UILabel(); + } + XTSLabel->SetPosition(130, 273); // widget's left position and top position + XTSLabel->Resize(200, 60); // widget's width and height + XTSLabel->SetViewId("label1"); // Set style + XTSLabel->SetStyle(STYLE_TEXT_FONT, 30); + XTSLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + XTSLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + XTSLabel->SetRollSpeed(0); + XTSLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + mainSwipeGroup->Add(XTSLabel); + xtsCallback_ = new XTSCallback(XTSLabel); + xtsanimator_ = new Animator(xtsCallback_, XTSLabel, 1000, true); + xtsanimator_->Start(); +#endif + AddViewToRootContainer(mainSwipeGroup); } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp index 6704a2267..02ce99c31 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp @@ -129,4 +129,21 @@ void DialArcLabelView::HandleFloatData(float data) } SetTextWithWildcardInner(tempBuf); } + +void DialArcLabelView::SetLang(uint8_t lang) +{ + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); +} + +void DialArcLabelView::OnLangChange(uint8_t langId) +{ + if (language_ == FontGlobalManager::INVALID_LANG_ID) { + SetVisible(true); + } else if (language_ == langId) { + SetVisible(true); + } else { + SetVisible(false); + } +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp index 6d7bb7467..4f316171e 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp @@ -74,6 +74,18 @@ void DialDigitalImgView::SetParent(UIViewGroup* parent) parent_ = parent; } +void DialDigitalImgView::OnTimeUpdate(const struct tm &curTime) +{ + bool isVisible = false; + if (IsInTimeInterval(curTime)) { + isVisible = true; + } + for (uint8_t i = 0; i < imgCnt_; ++i) { + imgs_[i]->SetVisible(isVisible); + } + SetVisible(isVisible); +} + void DialDigitalImgView::SetDecimalPrecision(uint8_t precision) { decimalPrecision_ = precision; @@ -208,6 +220,9 @@ bool DialDigitalImgView::CreateImageViews(float data) void DialDigitalImgView::HandleFloatData(float data) { + if (!IsVisible()) { + return; + } if (isValueSet_ && FloatEqual(value_, data)) { return; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialLabelView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialLabelView.cpp index 5f1c60bf2..54a2e90f6 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialLabelView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialLabelView.cpp @@ -166,4 +166,25 @@ namespace OHOS } SetTextWithWildcardInner(tempBuf); } + void DialLabelView::SetLang(uint8_t lang) + { + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); + } + + void DialLabelView::OnLangChange(uint8_t langId) + { + if (language_ == FontGlobalManager::INVALID_LANG_ID) + { + SetVisible(true); + } + else if (language_ == langId) + { + SetVisible(true); + } + else + { + SetVisible(false); + } + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTime.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTime.cpp index 6dd110f1c..4d1acc532 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTime.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTime.cpp @@ -8,6 +8,7 @@ #include "sys/time.h" #include "RegisterDialModel.h" #include "DialModelTime.h" +#include "components/root_view.h" #include "custom_runtime.h" #define REGIST_DIAL_MODULE_ANGLE_H(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_H)(type, func) #define REGIST_DIAL_MODULE_ANGLE_M(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_M)(type, func) @@ -21,6 +22,12 @@ #define REGIST_DIAL_MODULE_WEEK(type, func) static OHOS::RegisterDialModel(REGIST_WEEK)(type, func) #define REGIST_DIAL_MODULE_MOUNTH(type, func) static OHOS::RegisterDialModel(REGIST_MOUNTH)(type, func) #define REGIST_DIAL_MODULE_YEAR(type, func) static OHOS::RegisterDialModel(REGIST_YEAR)(type, func) +#define REGIST_DIAL_MODULE_GEAR_ONE(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_ONE)(type, func) +#define REGIST_DIAL_MODULE_GEAR_TWO(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_TWO)(type, func) +#define REGIST_DIAL_MODULE_GEAR_THREE(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_THREE)(type, func) +#define REGIST_DIAL_MODULE_GEAR_FOUR(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_FOUR)(type, func) +#define REGIST_DIAL_MODULE_GEAR_FIVE(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_FIVE)(type, func) +#define REGIST_DIAL_MODULE_GEAR_SIX(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_SIX)(type, func) REGIST_DIAL_MODULE_ANGLE_H(DialDataType::DATA_TYPE_CLOCK_ANGLE_H, OHOS::DialModelTime::GetInstance()); REGIST_DIAL_MODULE_ANGLE_M(DialDataType::DATA_TYPE_CLOCK_ANGLE_M, OHOS::DialModelTime::GetInstance()); @@ -35,15 +42,22 @@ REGIST_DIAL_MODULE_WEEK(DialDataType::DATA_TYPE_TIME_WEEK, OHOS::DialModelTime:: REGIST_DIAL_MODULE_MOUNTH(DialDataType::DATA_TYPE_TIME_MONTH, OHOS::DialModelTime::GetInstance()); REGIST_DIAL_MODULE_YEAR(DialDataType::DATA_TYPE_TIME_YEAR, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_ONE(DialDataType::DATA_TYPE_SWIVEL_GEAR_ONE, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_TWO(DialDataType::DATA_TYPE_SWIVEL_GEAR_TWO, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_THREE(DialDataType::DATA_TYPE_SWIVEL_GEAR_THREE, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_FOUR(DialDataType::DATA_TYPE_SWIVEL_GEAR_FOUR, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_FIVE(DialDataType::DATA_TYPE_SWIVEL_GEAR_FIVE, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_SIX(DialDataType::DATA_TYPE_SWIVEL_GEAR_SIX, OHOS::DialModelTime::GetInstance()); + namespace OHOS { static constexpr int16_t S_MS_US_TRANS = 1000; // 1000: seconds, milliseconds, microsecond transform value -static constexpr uint16_t CIRCLE_IN_DEGREE_UI = 360; // 360: A full rotation: 360 degrees static constexpr uint8_t ONE_MINUTE_IN_SECOND = 60; // 60: 60 seconds per minute static constexpr uint8_t ONE_HOUR_IN_MINUTE = 60; // 60: 60 minutes per hour static constexpr uint8_t HALF_DAY_IN_HOUR = 12; // 60: 12 hours every half day static uint16_t ConvertHandValueToAngle(int32_t handValue, uint8_t range, int32_t secondHandValue, uint16_t ratio) { + #ifdef fd230_650 if ((range == 0) || (ratio == 0)) { return 0; } @@ -56,20 +70,45 @@ static uint16_t ConvertHandValueToAngle(int32_t handValue, uint8_t range, int32_ degree = CIRCLE_IN_DEGREE_UI * degree / (static_cast(range) * ratio); return static_cast(degree % CIRCLE_IN_DEGREE_UI); + #endif + + /* -------------------------------- 0423补丁合入 -------------------------------- */ + if ((range == 0) || (ratio == 0)) { + return 0; + } + /* + * Example: calculate the angle of hour hand + * Assume that the time is 5: 30, then range is 12, radio is 60 + * angle is [(5 * 60 + 30) / (12 * 60)] * 360 + */ + int32_t degree = (handValue * ratio + secondHandValue); + degree = CIRCLE_IN_DEGREE * degree / (static_cast(range) * ratio); + + return static_cast(degree % CIRCLE_IN_DEGREE); } static float ConvertHandSecondValueToAngle(int32_t handValue, uint16_t range) { + #ifdef fd230_650 /* * Example: calculate the angle of second hand without millisecond handle * Assume that the time is 5:30:30, then range is 60 * angle is (30 / 60) * 360 */ return (static_cast(handValue * CIRCLE_IN_DEGREE_UI) / range); + #endif + /* -------------------------------- 0423补丁合入 -------------------------------- */ + /* + * Example: calculate the angle of second hand without millisecond handle + * Assume that the time is 5:30:30, then range is 60 + * angle is (30 / 60) * 360 + */ + return (static_cast(handValue * CIRCLE_IN_DEGREE) / range); } void DialModelTime::UpdateTime() { +#ifdef fd230_650 #if 0 struct timeval tv; gettimeofday(&tv, NULL); @@ -101,11 +140,63 @@ void DialModelTime::UpdateTime() angleM_ = ConvertHandValueToAngle(tblock_.tm_min, ONE_HOUR_IN_MINUTE, tblock_.tm_sec, ONE_MINUTE_IN_SECOND); angleS_ = ConvertHandValueToAngle(tblock_.tm_sec, ONE_MINUTE_IN_SECOND, 0, 1); angleMS_ = ConvertHandSecondValueToAngle(realMS, S_MS_US_TRANS * ONE_MINUTE_IN_SECOND); + + #endif + + /* --------------------------------- 0423补丁 --------------------------------- */ + struct timeval tv; + gettimeofday(&tv, nullptr); + tblock_ = localtime(&tv.tv_sec); + int realMS = tblock_->tm_sec * S_MS_US_TRANS + tv.tv_usec / S_MS_US_TRANS; + + angleH_ = ConvertHandValueToAngle(tblock_->tm_hour, HALF_DAY_IN_HOUR, tblock_->tm_min, ONE_HOUR_IN_MINUTE); + angleM_ = ConvertHandValueToAngle(tblock_->tm_min, ONE_HOUR_IN_MINUTE, tblock_->tm_sec, ONE_MINUTE_IN_SECOND); + angleS_ = ConvertHandValueToAngle(tblock_->tm_sec, ONE_MINUTE_IN_SECOND, 0, 1); + angleMS_ = ConvertHandSecondValueToAngle(realMS, S_MS_US_TRANS * ONE_MINUTE_IN_SECOND); + if (tblock_ == nullptr) { + return; + } + for (ListNode* node = listeners_.Head(); node != listeners_.End(); node = node->next_) { + TimeChangeListener *listener = node->data_; + if (listener != nullptr) { + listener->OnTimeUpdate(*tblock_); + } + } + RootView::GetInstance()->Invalidate(); + /* -------------------------------------------------------------------------- */ } -bool DialModelTime::GetDialFloatData(DialDataType& type, float& out) +void DialModelTime::Register(TimeChangeListener* listener) +{ + if (listener == nullptr) { + return; + } + for (ListNode* node = listeners_.Head(); node != listeners_.End(); node = node->next_) { + TimeChangeListener *tmp = node->data_; + if (tmp == listener) { + return; + } + } + listeners_.PushBack(listener); +} + +void DialModelTime::Unregister(TimeChangeListener* listener) { + if (listener == nullptr) { + return; + } + for (ListNode* node = listeners_.Head(); node != listeners_.End(); node = node->next_) { + TimeChangeListener *tmp = node->data_; + if (tmp == listener) { + listeners_.Remove(node); + return; + } + } +} +bool DialModelTime::GetDialFloatData(DialDataType& type, float& out) +{ + #ifdef fd230_650 UpdateTime(); switch (type) { @@ -146,5 +237,66 @@ bool DialModelTime::GetDialFloatData(DialDataType& type, float& out) return false; } return true; + #endif + + /* --------------------------------- 0423补丁 --------------------------------- */ + if (tblock_ == nullptr) { + UpdateTime(); + } + + switch (type) { + case DialDataType::DATA_TYPE_CLOCK_ANGLE_H: + out = static_cast(angleH_); + break; + case DialDataType::DATA_TYPE_CLOCK_ANGLE_M: + out = static_cast(angleM_); + break; + case DialDataType::DATA_TYPE_CLOCK_ANGLE_S: + out = static_cast(angleS_); + break; + case DialDataType::DATA_TYPE_CLOCK_ANGLE_MS: + out = static_cast(angleMS_); + break; + case DialDataType::DATA_TYPE_TIME_YEAR: + out = static_cast(tblock_->tm_year); + break; + case DialDataType::DATA_TYPE_TIME_MONTH: + out = static_cast(tblock_->tm_mon); + break; + case DialDataType::DATA_TYPE_TIME_WEEK: + out = static_cast(tblock_->tm_wday); + break; + case DialDataType::DATA_TYPE_TIME_DATE: + out = static_cast(tblock_->tm_mday); + break; + case DialDataType::DATA_TYPE_TIME_HOUR: + out = static_cast(tblock_->tm_hour); + break; + case DialDataType::DATA_TYPE_TIME_MINUTE: + out = static_cast(tblock_->tm_min); + break; + case DialDataType::DATA_TYPE_TIME_SECOND: + out = static_cast(tblock_->tm_sec); + break; + case DialDataType::DATA_TYPE_SWIVEL_GEAR_TWO: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_THREE: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_FIVE: { + float coeff = 6.0f; // 6.0: coeff + float accleratedAngle = angleMS_ * coeff - floor(angleMS_ * coeff / CIRCLE_IN_DEGREE) * CIRCLE_IN_DEGREE; + out = static_cast(accleratedAngle * -1.0 + CIRCLE_IN_DEGREE); + break; + } + case DialDataType::DATA_TYPE_SWIVEL_GEAR_ONE: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_FOUR: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_SIX: { + float coeff = 6.0f; // 6.0: coeff + float accleratedAngle = angleMS_ * coeff - floor(angleMS_ * coeff / CIRCLE_IN_DEGREE) * CIRCLE_IN_DEGREE; + out = static_cast(accleratedAngle); + break; + } + default: + return false; + } + return true; } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp index 8c78ad49f..980d438cd 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp @@ -53,4 +53,32 @@ void DialOptionImgView::HandleFloatData(float data) selected_ = selected; SetSrc(&info_[selected_]); } + +void DialOptionImgView::SetLang(uint8_t lang) +{ + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); +} + +void DialOptionImgView::OnLangChange(uint8_t langId) +{ + if (language_ == FontGlobalManager::INVALID_LANG_ID) { + langVisible_ = true; + } else if (language_ == langId) { + langVisible_ = true; + } else { + langVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} + +void DialOptionImgView::OnTimeUpdate(const struct tm &curTime) +{ + if (IsInTimeInterval(curTime)) { + timeVisible_ = true; + } else { + timeVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialSequenceContainer.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialSequenceContainer.cpp new file mode 100644 index 000000000..4024f4696 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialSequenceContainer.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialSequenceContainer + * Author: + * Create: 2025-03-05 + */ + +#include "DialSequenceContainer.h" + +namespace OHOS { +DialSequenceContainer::DialSequenceContainer() +{ + SetTouchable(true); + SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + memset_s(nonCycleView_, sizeof(nonCycleView_), 0, sizeof(nonCycleView_)); +} + +DialSequenceContainer::~DialSequenceContainer() +{ + if (repeatView_ != nullptr) { + delete repeatView_; + repeatView_ = nullptr; + } + + for (uint8_t i = 0; i < nonCycleNum_; ++i) { + delete nonCycleView_[i]; + nonCycleView_[i] = nullptr; + } + nonCycleNum_ = 0; + curView_ = nullptr; +} + +bool DialSequenceContainer::AddSequenceRes(uint16_t interval, bool repeat, + const ImageAnimatorInfo *imgSrc, uint8_t imgNum) +{ + if (imgSrc == nullptr || imgNum == 0) { + return false; + } + + // add animator images to view + if (repeat) { + if (repeatView_ != nullptr) { + GRAPHIC_LOGE("the repeat seq view has existed!"); + return false; + } + repeatView_ = new UIImageAnimatorView; + repeatView_->SetImageAnimatorSrc(imgSrc, imgNum, interval); + repeatView_->SetRepeat(false); + } else { + if (nonCycleNum_ >= sizeof(nonCycleView_) / sizeof(nonCycleView_[0])) { + GRAPHIC_LOGE("non cycle seq views have been exceedeed!"); + return false; + } + nonCycleView_[nonCycleNum_] = new UIImageAnimatorView; + nonCycleView_[nonCycleNum_]->SetImageAnimatorSrc(imgSrc, imgNum, interval); + nonCycleView_[nonCycleNum_]->SetRepeat(false); + ++nonCycleNum_; + } + + // update rect area + Rect rect(GetRelativeRect()); + for (uint8_t i = 0; i < imgNum; ++i) { + rect.JoinRect(rect, + Rect(rect.GetX(), + rect.GetY(), + rect.GetX() + imgSrc[i].width - 1, + rect.GetY() + imgSrc[i].height - 1)); + } + rect.JoinRect(rect, GetRelativeRect()); + SetPosition(rect.GetX(), rect.GetY()); + SetWidth(rect.GetWidth()); + SetHeight(rect.GetHeight()); + Invalidate(); + + return true; +} + +bool DialSequenceContainer::OnClickEvent(const ClickEvent& event) +{ + if (curView_ == nullptr) { + return false; + } + uint8_t curState = curView_->GetState(); + switch (curState) { + case Animator::STOP: { + if (curView_ == repeatView_) { + isClick_ = true; + } else { + UpdateCurrentView(); + Start(); + } + break; + } + case Animator::PAUSE: { + return false; + } + case Animator::RUNNING: + case Animator::START: { + if (curView_ == repeatView_) { + isClick_ = true; + } + break; + } + default: { + GRAPHIC_LOGE("error state"); + } + } + + return UIViewGroup::OnClickEvent(event); +} + +void DialSequenceContainer::Start() +{ + if (curView_ != nullptr) { + curView_->Start(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Start(); +} + +void DialSequenceContainer::Stop() +{ + if (curView_ != nullptr) { + curView_->Stop(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Stop(); +} + +void DialSequenceContainer::Pause() +{ + if (curView_ != nullptr) { + curView_->Pause(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Pause(); +} + +void DialSequenceContainer::Resume() +{ + if (curView_ != nullptr) { + curView_->Resume(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Resume(); +} + +void DialSequenceContainer::OnAnimatorStop(UIView& view) +{ + bool isClick = isClick_; + isClick_ = false; + bool isRepeat = (curView_ == repeatView_); + if (isRepeat && isClick) { + UpdateCurrentView(); + Start(); + } else if (isRepeat && !isClick) { + Start(); + } else { + if (repeatView_ != nullptr) { + UpdateCurrentView(); + Start(); + } + } +} + +void DialSequenceContainer::UpdateCurrentView() +{ + if (curView_ != nullptr) { + if (repeatView_ != nullptr && nonCycleNum_ == 0) { + return; + } else if (repeatView_ == nullptr && nonCycleNum_ != 0) { + Remove(curView_); + curView_ = nonCycleView_[loop_]; + loop_ = (loop_ + 1) % nonCycleNum_; + curView_->SetAnimatorStopListener(this); + Add(curView_); + Invalidate(); + return; + } + + // both repeat and noncycle exist + Remove(curView_); + if (curView_ == repeatView_) { + curView_ = nonCycleView_[loop_]; + loop_ = (loop_ + 1) % nonCycleNum_; + } else { + curView_ = repeatView_; + } + curView_->SetAnimatorStopListener(this); + Add(curView_); + Invalidate(); + return; + } + + if (repeatView_ != nullptr) { + curView_ = repeatView_; + } else if (nonCycleNum_ != 0) { + curView_ = nonCycleView_[loop_]; + loop_ = (loop_ + 1) % nonCycleNum_; + } else { + GRAPHIC_LOGE("sequence img has not been added!"); + return; + } + curView_->SetAnimatorStopListener(this); + Add(curView_); + Invalidate(); +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp index dd3126f75..ffc87a701 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp @@ -10,5 +10,74 @@ DialStaticImgView::DialStaticImgView() SetAutoEnable(true); } -DialStaticImgView::~DialStaticImgView() {} +DialStaticImgView::~DialStaticImgView() +{ + if (info_ != nullptr) { + UIFree(info_); + info_ = nullptr; + } +} + +void DialStaticImgView::SetLang(uint8_t lang) +{ + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); +} + +void DialStaticImgView::OnLangChange(uint8_t langId) +{ + if (language_ == FontGlobalManager::INVALID_LANG_ID) { + langVisible_ = true; + } else if (language_ == langId) { + langVisible_ = true; + } else { + langVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} + +bool DialStaticImgView::SetImgs(const ImageInfo* src, uint8_t num) +{ + if (src == nullptr || num == 0) { + return false; + } + if (info_ != nullptr) { + UIFree(info_); + info_ = nullptr; + } + uint32_t size = sizeof(ImageInfo) * num; + info_ = static_cast(UIMalloc(size)); + if (info_ == nullptr) { + return false; + } + if (memcpy_s(info_, size, src, size) != EOK) { + UIFree(info_); + return false; + } + infoNum_ = num; + selected_ = 0; + SetSrc(&info_[selected_]); + SetTouchable(infoNum_ > 1); + return true; +} + +bool DialStaticImgView::OnClickEvent(const ClickEvent& event) +{ + if (selected_ < 0 || info_ == nullptr || infoNum_ == 0) { + return false; + } + selected_ = (selected_ + 1) % infoNum_; + SetSrc(&info_[selected_]); + return true; +} + +void DialStaticImgView::OnTimeUpdate(const struct tm &curTime) +{ + if (IsInTimeInterval(curTime)) { + timeVisible_ = true; + } else { + timeVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialTimePublisher.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialTimePublisher.cpp new file mode 100644 index 000000000..cb4539b16 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialTimePublisher.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialTimePublisher + * Author: + * Create: 2025-03-04 + */ + +#include "DialTimePublisher.h" +#include "securec.h" +#include "gfx_utils/mem_api.h" +#include "gfx_utils/graphic_log.h" + +namespace OHOS { +DialTimePublisher *DialTimePublisher::publisher_ = nullptr; + +void DialTimePublisher::TimeChangeListener::SetTimeInervals(TimeInterval *intervals, uint8_t num) +{ + if (intervals == nullptr || num == 0) { + return; + } + if (intervals_ != nullptr) { + UIFree(intervals_); + intervals_ = nullptr; + } + num_ = 0; + + intervals_ = static_cast(UIMalloc(sizeof(TimeInterval) * num)); + if (intervals_ == nullptr) { + GRAPHIC_LOGE("failed to malloc!"); + return; + } + num_ = num; + memcpy_s(intervals_, sizeof(TimeInterval) * num, intervals, sizeof(TimeInterval) * num); +} + +bool DialTimePublisher::TimeChangeListener::IsInTimeInterval(const struct tm &curTime) +{ + if (num_ == 0) { // 0-24 + return true; + } + for (uint8_t i = 0; i < num_; ++i) { + if (intervals_[i].start <= curTime.tm_hour && intervals_[i].end > curTime.tm_hour) { + return true; + } + } + return false; +} + +DialTimePublisher::TimeChangeListener::TimeChangeListener() +{ + if (DialTimePublisher::GetPublisher() != nullptr) { + DialTimePublisher::GetPublisher()->Register(this); + } +} + +DialTimePublisher::TimeChangeListener::~TimeChangeListener() +{ + if (intervals_ != nullptr) { + UIFree(intervals_); + intervals_ = nullptr; + } + num_ = 0; + if (DialTimePublisher::GetPublisher() != nullptr) { + DialTimePublisher::GetPublisher()->Unregister(this); + } +} + +void DialTimePublisher::SetPublisher(DialTimePublisher *publisher) +{ + publisher_ = publisher; +} + +DialTimePublisher *DialTimePublisher::GetPublisher() +{ + return publisher_; +} +} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewContainer.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewContainer.cpp new file mode 100644 index 000000000..6db086094 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewContainer.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialViewContainer + * Author: + * Create: 2025-02-06 + */ + +#include "DialViewContainer.h" +#include "DialDigitalImgView.h" + +namespace OHOS { +DialViewContainer::~DialViewContainer() +{ + ListNode* viewNode = dialViews_.Head(); + while (viewNode != dialViews_.End()) { + UIViewGroup::Remove(viewNode->data_.view); + delete viewNode->data_.view; + viewNode = viewNode->next_; + } + dialViews_.Clear(); +} + +void DialViewContainer::AddView(UIView* view) +{ + if (view == nullptr) { + return; + } + Add(view); + SubView info = { + .view = view, + .dialView = nullptr, + }; + DialViewContainer *container = dynamic_cast(view); + if (container != nullptr && container->HasInvalidBindData()) { + hasInvalidBindData_ = true; + } + dialViews_.PushBack(info); +} + +void DialViewContainer::AddView(DialDataType type, DialView* view, bool isPeriodic) +{ + if (view == nullptr) { + return; + } + UIView *uiView = dynamic_cast(view); + if (uiView == nullptr) { + return; + } + Add(uiView); + DialDigitalImgView *digital = dynamic_cast(view); + if (digital != nullptr) { + digital->SetParent(this); + } + SubView info = { + .view = uiView, + .dialView = view, + .type = type, + .isPeriodic = isPeriodic + }; + if (type == DialDataType::DATA_TYPE_MAX) { + hasInvalidBindData_ = true; + } + dialViews_.PushBack(info); +} + +bool DialViewContainer::RemoveSubView(uint8_t index, SubView &subView) +{ + if (index >= dialViews_.Size()) { + return false; + } + ListNode *it = Begin(); + for (uint8_t i = 0; i < index; ++i) { + it = it->next_; + } + subView = it->data_; + Remove(subView.view); + DialDigitalImgView *digital = dynamic_cast(subView.view); + if (digital != nullptr) { + digital->SetParent(nullptr); + } + dialViews_.Remove(it); + return true; +} + +bool DialViewContainer::IsInvalidateBindData(uint8_t index) +{ + if (index >= dialViews_.Size()) { + return false; + } + ListNode *it = Begin(); + for (uint8_t i = 0; i < index; ++i) { + it = it->next_; + } + if (it->data_.dialView != nullptr && it->data_.type == DialDataType::DATA_TYPE_MAX) { + return true; + } + DialViewContainer *container = dynamic_cast(it->data_.view); + if (container != nullptr) { + return container->HasInvalidBindData(); + } + return false; +} +} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp index 0ed3e1315..a8bd70a5c 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp @@ -18,9 +18,10 @@ #ifdef SUPPORT_OHOSFWK #include "ui_screennotify.h" #endif +#include "DialDigitalImgView.h" namespace OHOS { -static DialVideoView *g_video = nullptr; + static DialVideoView *g_video = nullptr; static constexpr const char *DISTURBICON = "user/res/dial_state/disturbicon.bin"; static constexpr const char *MESSAGEICON = "user/res/dial_state/unread.bin"; @@ -46,13 +47,13 @@ static DialVideoView *g_video = nullptr; { if (g_video->IsPaused()) { - g_video->ResumePlay(); - // printf("恢复视频\n"); + g_video->ResumePlay(); + // printf("恢复视频\n"); } else if (!g_video->IsPlayed()) { - g_video->StartPlay(); - // printf("开始播放\n"); + g_video->StartPlay(); + // printf("开始播放\n"); } } } @@ -123,16 +124,18 @@ static DialVideoView *g_video = nullptr; video_ = nullptr; - if (dialstateicon_ != nullptr) { - delete dialstateicon_; - dialstateicon_ = nullptr; + if (dialstateicon_ != nullptr) + { + delete dialstateicon_; + dialstateicon_ = nullptr; } - if (messageicon_ != nullptr) { - delete messageicon_; - messageicon_ = nullptr; + if (messageicon_ != nullptr) + { + delete messageicon_; + messageicon_ = nullptr; } - + if (fp_ != nullptr) { fclose(fp_); @@ -185,7 +188,7 @@ static DialVideoView *g_video = nullptr; GRAPHIC_LOGE("cannot open file: %s\n", filePath_.c_str()); return; } - DialBinParserManager::GetInstance()->UpdateDial(filePath_, fp_, this,state_); // 添加主表盘卡片内容 + DialBinParserManager::GetInstance()->UpdateDial(filePath_, fp_, this, state_); // 添加主表盘卡片内容 // 添加自定义logo,例如勿扰模式 /*增加手表状态图标*/ @@ -213,7 +216,6 @@ static DialVideoView *g_video = nullptr; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialViewGroup::GetElapseTime %d", elapseTime); } - void DialViewGroup::ProcessData(DialDataType type, DialView *view) { int16_t value = static_cast(type) >> 14; // 14: bit shift @@ -240,22 +242,79 @@ static DialVideoView *g_video = nullptr; } } - void DialViewGroup::AddView(UIView *view, bool isDialVideoView) + void DialViewGroup::DoStop(void) { - if (view == nullptr) + SetLableAnimatorState(Animator::PAUSE); + SetImgAnimatorState(Animator::PAUSE); + if (video_ != nullptr && !video_->IsStopped()) { - GRAPHIC_LOGE("Parameter is nullptr.\n"); - return; + video_->StopPlay(); } - dialViews_.PushBack(view); - Add(view); + if (kaleidoscope_ != nullptr) + { + kaleidoscope_->StopRotateAnimator(); + kaleidoscope_->ClearFocus(); + } + } - if (view->GetViewType() == UI_KALEIDOSCOPE_VIEW) + void DialViewGroup::DoStart(void) + { + SetLableAnimatorState(Animator::START); + SetImgAnimatorState(Animator::START); + if (video_ != nullptr) { - kaleidoscope_ = dynamic_cast(view); + if (video_->IsPaused()) + { + video_->ResumePlay(); + } + else if (!video_->IsPlayed()) + { + video_->StartPlay(); + } + } + if (kaleidoscope_ != nullptr) + { + kaleidoscope_->RequestFocus(); + kaleidoscope_->StartRotateAnimator(); } + } - if (isDialVideoView) + void DialViewGroup::DoPause(void) + { + SetLableAnimatorState(Animator::PAUSE); + SetImgAnimatorState(Animator::PAUSE); + if (kaleidoscope_ != nullptr) + { + kaleidoscope_->StopRotateAnimator(); + kaleidoscope_->ClearFocus(); + } + if (video_ != nullptr) + { + video_->PausePlay(); + } + } + + void DialViewGroup::RecordSpecial(UIView *view) + { + if (dynamic_cast(view) != nullptr) + { + UILabel *label = dynamic_cast(view); + uint8_t mode = label->GetLineBreakMode(); + if (mode == UILabel::LINE_BREAK_MARQUEE || mode == UILabel::LINE_BREAK_OSCILLATION) + { + rollingLabelList_.PushBack(label); + } + } + else if (dynamic_cast(view) != nullptr) + { + UIImageAnimatorView *imgAnim = dynamic_cast(view); + imgAnimList_.PushBack(imgAnim); + } + else if (dynamic_cast(view) != nullptr) + { + kaleidoscope_ = dynamic_cast(view); + } + else if (dynamic_cast(view) != nullptr) { if (video_ != nullptr) { @@ -263,22 +322,43 @@ static DialVideoView *g_video = nullptr; return; } video_ = reinterpret_cast(view); - g_video = video_; -#ifdef SUPPORT_OHOSFWK - registerNotifyScreenStatus(ScreenStatusNotify); -#endif + } + else if (dynamic_cast(view) != nullptr) + { + DialSequenceContainer *seq = dynamic_cast(view); + seqList_.PushBack(seq); } } - void DialViewGroup::AddView(DialDataType type, DialView *view, bool isPeriodic) + void DialViewGroup::RecordBindData(DialDataType type, DialView *view, bool isPeriodic) { - if (view == nullptr) + if (dynamic_cast(view) != nullptr) { - GRAPHIC_LOGE("Parameter is nullptr.\n"); - return; + UILabel *label = dynamic_cast(view); + uint8_t mode = label->GetLineBreakMode(); + if (mode == UILabel::LINE_BREAK_MARQUEE || mode == UILabel::LINE_BREAK_OSCILLATION) + { + rollingLabelList_.PushBack(label); + } } - dataTypeMap_.insert(std::make_pair(static_cast(type), view)); + auto it = dataTypeMap_.find(static_cast(type)); + if (it != dataTypeMap_.end()) + { + it->second->PushBack(view); + } + else + { + Views *container = new Views; + if (container == nullptr) + { + GRAPHIC_LOGE("failed to alloc binddata container"); + return; + } + container->PushBack(view); + dataTypeMap_.insert(std::make_pair(static_cast(type), container)); + viewsMemPool_.PushBack(container); + } if (isPeriodic) { periodicUpdateTypes_.PushBack(type); @@ -288,9 +368,68 @@ static DialVideoView *g_video = nullptr; ModelDialDataFactory::GetInstance().RegisterDialDataListener(type, this); passiveUpdateTypes_.PushBack(type); } + } + + void DialViewGroup::ClearViews() + { + dataTypeMap_.clear(); + for (uint16_t i = 0; i < viewsMemPool_.Size(); ++i) + { + delete viewsMemPool_[i]; + } + viewsMemPool_.Clear(); + } + + void DialViewGroup::AddView(UIView *view) + { + if (view == nullptr) + { + GRAPHIC_LOGE("Parameter is nullptr.\n"); + return; + } + dialViews_.PushBack(view); + Add(view); + DialViewContainer *container = dynamic_cast(view); + if (container != nullptr) + { + ListNode *head = container->Begin(); + for (; head != container->End(); head = head->next_) + { + DialViewContainer::SubView &subView = head->data_; + if (subView.dialView != nullptr) + { + RecordBindData(subView.type, subView.dialView, subView.isPeriodic); + ProcessData(subView.type, subView.dialView); + } + else if (subView.view != nullptr) + { + RecordSpecial(subView.view); + } + } + } + else + { + RecordSpecial(view); + } + } + + void DialViewGroup::AddView(DialDataType type, DialView *view, bool isPeriodic) + { + if (view == nullptr) + { + GRAPHIC_LOGE("Parameter is nullptr.\n"); + return; + } + + DialDigitalImgView *digital = dynamic_cast(view); + if (digital != nullptr) + { + digital->SetParent(this); + } + RecordBindData(type, view, isPeriodic); dialViews_.PushBack(dynamic_cast(view)); Add(dynamic_cast(view)); - ProcessData(type, view); + ProcessData(type, view); } void DialViewGroup::SetPeriod(uint32_t period) @@ -310,14 +449,17 @@ static DialVideoView *g_video = nullptr; return period_; } - void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, float data) { auto iter = dataTypeMap_.find(static_cast(type)); if (iter != dataTypeMap_.end()) { - DialView *view = iter->second; - view->HandleFloatData(data); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) + { + DialView *view = (*container)[i]; + view->HandleFloatData(data); + } } } @@ -326,8 +468,12 @@ static DialVideoView *g_video = nullptr; auto iter = dataTypeMap_.find(static_cast(type)); if (iter != dataTypeMap_.end()) { - DialView *view = iter->second; - view->HandleFloatData(data, num); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) + { + DialView *view = (*container)[i]; + view->HandleFloatData(data, num); + } } } @@ -336,8 +482,12 @@ static DialVideoView *g_video = nullptr; auto iter = dataTypeMap_.find(static_cast(type)); if (iter != dataTypeMap_.end()) { - DialView *view = iter->second; - view->HandleTextData(data, num); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) + { + DialView *view = (*container)[i]; + view->HandleTextData(data, num); + } } } @@ -384,15 +534,16 @@ static DialVideoView *g_video = nullptr; DialClick dialClick = node->data_; if (dialClick.area.IsContains(point)) { - if (dialClick.isSliceType) { - //支付宝需要先判断 + if (dialClick.isSliceType) + { + // 支付宝需要先判断 #ifdef SUPPORT_ALIPAY_SEC - // if(dialClick.sliceId == VIEW_MAIN_ALIPAY && Alipay_is_init()==false) - // { - // return false; - // } -#endif - NativeAbility::GetInstance().ChangeSlice(dialClick.sliceId); + // if(dialClick.sliceId == VIEW_MAIN_ALIPAY && Alipay_is_init()==false) + // { + // return false; + // } +#endif + NativeAbility::GetInstance().ChangeSlice(dialClick.sliceId); } else { @@ -409,124 +560,206 @@ static DialVideoView *g_video = nullptr; void DialViewGroup::ScrollBegin(bool isActive) { - if (kaleidoscope_ != nullptr) + if (isActive) + { + DoPause(); + } + } + + void DialViewGroup::ScrollEnd(bool isActive) + { + MainPresenterSample *mainPresenter = MainPresenterSample::GetInstance(); + if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { - if (isActive) + return; + } + + if (isActive) + { + DoStart(); + } + else + { + if (video_ != nullptr && !video_->IsStopped()) { - kaleidoscope_->ClearFocus(); - kaleidoscope_->StopRotateAnimator(); + video_->StopPlay(); + } + if (video_ != nullptr) + { + ClearCache(); } - return; } + } - if (video_ == nullptr) + void DialViewGroup::CoverBegin(bool isCovered) + { + if (!isCovered) + { + DoPause(); + } + } + + void DialViewGroup::CoverEnd(bool isCovered) + { + MainPresenterSample *mainPresenter = MainPresenterSample::GetInstance(); + if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { return; } - if (video_->IsPlayed()) + + if (!isCovered) { - video_->PausePlay(); + DoStart(); } } - void DialViewGroup::ScrollEnd(bool isActive) + void DialViewGroup::OnActive(void) { - if (kaleidoscope_ != nullptr) + MainPresenterSample *mainPresenter = MainPresenterSample::GetInstance(); + if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { - if (isActive) - { - kaleidoscope_->StartRotateAnimator(); - kaleidoscope_->RequestFocus(); - } return; } - if (video_ == nullptr) + DoStart(); + } + + void DialViewGroup::OnInactive(void) + { + DoStop(); + } + + void DialViewGroup::OnCovered(void) + { + MainPresenterSample *mainPresenter = MainPresenterSample::GetInstance(); + if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { return; } - if (isActive) + DoPause(); + } + + void DialViewGroup::OnUncovered(void) + { + MainPresenterSample *mainPresenter = MainPresenterSample::GetInstance(); + if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { - if (video_->IsPaused()) - { - video_->ResumePlay(); - } - else if (!video_->IsPlayed()) - { - video_->StartPlay(); - } - g_video = video_; + return; } - else + + DoStart(); + } + + void DialViewGroup::OnPause() + { + DoPause(); + } + + void DialViewGroup::SetLableAnimatorState(uint8_t state) + { + if (rollingLabelList_.IsEmpty()) { - if (video_->IsPaused() || video_->IsPlayed()) + return; + } + + ListNode *node = rollingLabelList_.Begin(); + while (node != rollingLabelList_.End()) + { + if (node->data_ != nullptr) { - video_->StopPlay(); + UILabel *label = node->data_; + label->SetAnimState(state); } - ClearCache(); - g_video = nullptr; + node = node->next_; } } - void DialViewGroup::CoverBegin(bool isCovered) + void DialViewGroup::SetImgAnimatorState(uint8_t state) { - if (kaleidoscope_ != nullptr) + if (imgAnimList_.IsEmpty() && seqList_.IsEmpty()) { - if (!isCovered) - { - kaleidoscope_->StopRotateAnimator(); - kaleidoscope_->ClearFocus(); - } return; } - if (video_ == nullptr) + ListNode *node = imgAnimList_.Begin(); + while (node != imgAnimList_.End()) { - return; + if (node->data_ != nullptr) + { + UIImageAnimatorView *imgAnim = node->data_; + switch (state) + { + case Animator::PAUSE: + imgAnim->Pause(); + break; + case Animator::START: + imgAnim->Resume(); + break; + } + } + node = node->next_; } - if (video_->IsPlayed()) + ListNode *it = seqList_.Begin(); + while (it != seqList_.End()) { - video_->PausePlay(); + if (it->data_ != nullptr) + { + switch (state) + { + case Animator::PAUSE: + it->data_->Pause(); + break; + case Animator::START: + it->data_->Resume(); + break; + } + } + it = it->next_; } } - void DialViewGroup::CoverEnd(bool isCovered) + MediaVideoPlay *DialViewGroup::GetVideoPlay() { - if (kaleidoscope_ != nullptr) + if (video_ != nullptr) { - if (!isCovered) - { - kaleidoscope_->RequestFocus(); - kaleidoscope_->StartRotateAnimator(); - } - return; + return video_->GetVideoPlay(); } - if (video_ == nullptr) + return nullptr; + } + + void DialViewGroup::StopDial() + { + #if 0 + if (MainModel::GetInstance().getVideostate() != false) { return; } - if (isCovered) + MainModel::GetInstance().setVideostate(true); + if (video_ != nullptr) { + if (!video_->IsStopped()) + { + video_->StopPlay(); + } g_video = nullptr; } - else + else if (kaleidoscope_ != nullptr) { - if (video_->IsPaused()) - { - video_->ResumePlay(); - } - else if (!video_->IsPlayed()) - { - video_->StartPlay(); - } - g_video = video_; + kaleidoscope_->StopRotateAnimator(); + kaleidoscope_->ClearFocus(); } + #endif } - - void DialViewGroup::OnActive(void) + void DialViewGroup::StartDial() { + #if 0 + if (MainModel::GetInstance().getVideostate() != true) + { + return; + } + MainModel::GetInstance().setVideostate(false); if (video_ != nullptr) { if (video_->IsPaused()) @@ -544,84 +777,41 @@ static DialVideoView *g_video = nullptr; kaleidoscope_->RequestFocus(); kaleidoscope_->StartRotateAnimator(); } + #endif } - - void DialViewGroup::OnInactive(void) + + // 更新数据 + void DialViewGroup::UpdateViewsByPeriodicUpdateData() { - if (video_ != nullptr) + ListNode *node = periodicUpdateTypes_.Head(); + while (node != periodicUpdateTypes_.End()) { - if (!video_->IsStopped()) + DialDataType type = node->data_; + auto iter = dataTypeMap_.find(static_cast(type)); + if (iter != dataTypeMap_.end()) { - video_->StopPlay(); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) + { + ProcessData(type, (*container)[i]); + } } - g_video = nullptr; + node = node->next_; } - else if (kaleidoscope_ != nullptr) + if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView()) { - kaleidoscope_->StopRotateAnimator(); - kaleidoscope_->ClearFocus(); + Invalidate(); + } + // ota进行视频暂停 + if (uapi_dev_runtime_get_transmitting_status() == 1 || uapi_dev_runtime_get_restore_factory_status() == 1) + { + // 暂停视频 + StopDial(); + } + else + { + // 获取视频 + StartDial(); } } -void DialViewGroup::StopDial() { - if (MainModel::GetInstance().getVideostate() != false) { - return; - } - MainModel::GetInstance().setVideostate(true); - if (video_ != nullptr) { - if (!video_->IsStopped()) { - video_->StopPlay(); - } - g_video = nullptr; - } else if (kaleidoscope_ != nullptr) { - kaleidoscope_->StopRotateAnimator(); - kaleidoscope_->ClearFocus(); - } -} -void DialViewGroup::StartDial() { - if (MainModel::GetInstance().getVideostate() != true) { - return; - } - MainModel::GetInstance().setVideostate(false); - if (video_ != nullptr) { - if (video_->IsPaused()) { - video_->ResumePlay(); - } else if (!video_->IsPlayed()) { - video_->StartPlay(); - } - g_video = video_; - } else if (kaleidoscope_ != nullptr) { - kaleidoscope_->RequestFocus(); - kaleidoscope_->StartRotateAnimator(); - } -} -MediaVideoPlay* DialViewGroup::GetVideoPlay() -{ - if (video_ != nullptr) { - return video_->GetVideoPlay(); - } - return nullptr; -} -//更新数据 -void DialViewGroup::UpdateViewsByPeriodicUpdateData() { - ListNode *node = periodicUpdateTypes_.Head(); - while (node != periodicUpdateTypes_.End()) { - DialDataType type = node->data_; - auto iter = dataTypeMap_.find(static_cast(type)); - if (iter != dataTypeMap_.end()) { - ProcessData(type, iter->second); - } - node = node->next_; - } - if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView()) { - Invalidate(); - } - // ota进行视频暂停 - if (uapi_dev_runtime_get_transmitting_status() == 1 || uapi_dev_runtime_get_restore_factory_status() == 1 ) { - //暂停视频 - StopDial(); - } else { - //获取视频 - StartDial(); - } -} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp index 88ce467e3..81c7106fd 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp @@ -13,7 +13,6 @@ bool ModelDialDataFactory::GetDialTextData(DialDataType& type, std::string*& out if (model == nullptr) { return false; } - // printf("type %d strNum %d\r\n",type,strNum); return model->GetDialTextData(type, out, strNum); } @@ -44,6 +43,24 @@ DialBaseModel* ModelDialDataFactory::GetModuleByType(DialDataType& type) return iter->second; } +bool ModelDialDataFactory::IsOHBindDataExist(DialOHDataType type) const +{ + auto it = g_bindDataConverter.find(type); + if (it == g_bindDataConverter.end()) { + return false; + } + return IsBindDataExist(it->second); +} + +bool ModelDialDataFactory::IsBindDataExist(DialDataType type) const +{ + auto it = models_.find(static_cast(type)); + if (it != models_.end() && it->second != nullptr) { + return true; + } + return false; +} + bool ModelDialDataFactory::RegisterDialDataListener(DialDataType type, OnDialDataUpdateListener* listener) { DialBaseModel* model = GetModuleByType(type); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/WatchInterface.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/WatchInterface.cpp new file mode 100644 index 000000000..45e63594e --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/WatchInterface.cpp @@ -0,0 +1,385 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: WatchInterface + * Author: + * Create: 2025-03-17 + */ + +#include +#include "dirent.h" +#include "DialBinParser.h" +#include "UiConfig.h" +#include "WatchInterface.h" +#include "gfx_utils/vector.h" +#include "common/screen.h" +#include "MainModel.h" +#include "MainViewSample.h" +#include "SetDialModel.h" +#include "graphic_service.h" +#include "NativeAbility.h" + +using namespace OHOS; +namespace { +struct { + Graphic::Vector fileNames; // only for 3.0 + Graphic::Vector watchInfo; // only for 3.0 +} g_info; + +bool GetActiveWatchPath(std::string &path) +{ + if (MainModel::GetInstance().GetDialSetting().dialFlag == 1) { + path = MainModel::GetInstance().GetDialSetting().dialFullName; + return true; + } + return false; +} + +bool GetPreviewInfo(const std::string &fileName, DialPreviewInfo &preview) +{ + const std::string type(".bin"); + if (!(fileName.length() > type.length() && + fileName.substr(fileName.length() - type.length(), type.length()) == type)) { + return false; + } + memset_s(&preview, sizeof(preview), 0, sizeof(preview)); + FILE *file = fopen(fileName.c_str(), "rb"); + bool isSuccess = false; + if (file != nullptr) { + isSuccess = DialBinParserManager::GetInstance()->GetDialPreviewInfo(file, &preview); + fclose(file); + } + return isSuccess; +} + +bool ConvertPreview2WatchDialInfo(const DialPreviewInfo &preview, watch_dial_info &info) +{ + errno_t ret = strcpy_s(reinterpret_cast(info.watch_protocol_version), + sizeof(info.watch_protocol_version), + preview.protocolVersion); + if (ret != 0) { + GRAPHIC_LOGE("failed to copy protocol version."); + return false; + } + + ret = strcpy_s(reinterpret_cast(info.watch_version), sizeof(info.watch_version), preview.watchVersion); + if (ret != 0) { + GRAPHIC_LOGE("failed to copy watch version."); + return false; + } + info.uuid = preview.uuid; + return true; +} + +#define APP_DIAL_PATH "user/dial/" //为了编译过加的 + +bool GetAllWatchInfo() +{ + g_info.fileNames.Clear(); + g_info.watchInfo.Clear(); + struct dirent *direntp = nullptr; + + + // ��Ŀ¼ + DIR *dirp = opendir(APP_DIAL_PATH); + bool isSuccess = true; + // �����ļ� + DialPreviewInfo info; + watch_dial_info watchInfo; + std::string activePath; + bool isActiveExist = GetActiveWatchPath(activePath); + if (dirp != nullptr) { + while ((direntp = readdir(dirp)) != nullptr) { + std::string fileName = std::string(APP_DIAL_PATH) + std::string("/") + std::string(direntp->d_name); + isSuccess = GetPreviewInfo(fileName, info); + if (!isSuccess) { + continue; + } + + const std::string lowestVersion("3.0"); + std::string curVersion(info.protocolVersion); + if (curVersion >= lowestVersion) { + isSuccess = ConvertPreview2WatchDialInfo(info, watchInfo); + if (!isSuccess) { + break; + } + watchInfo.install_state = true; + watchInfo.is_current_watch = isActiveExist ? (activePath == fileName) : false; + g_info.fileNames.PushBack(fileName); + g_info.watchInfo.PushBack(watchInfo); + } + } + } + // �ر�Ŀ¼ + closedir(dirp); + return isSuccess; +} +} // namespace + +bool GetAllWatchFaceInfo(watch_dial_info *info, uint8_t *num, uint8_t maxCnt) +{ + if (info == nullptr || num == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + if (g_info.watchInfo.Size() > maxCnt) { + GRAPHIC_LOGE("mem is not enough."); + return false; + } + *num = g_info.watchInfo.Size(); + if (*num == 0) { + return false; + } + if (memcpy_s(info, + g_info.watchInfo.Size() * sizeof(watch_dial_info), + &g_info.watchInfo[0], + g_info.watchInfo.Size() * sizeof(watch_dial_info)) != 0) { + GRAPHIC_LOGE("copy info error!"); + return false; + } + return true; +} + +bool GetWatchFaceInfo(uint32_t uuid, watch_dial_info *watch) +{ + if (watch == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + if (g_info.watchInfo[i].uuid == uuid) { + *watch = g_info.watchInfo[i]; + return true; + } + } + return false; +} + +bool GetWatchCapability(watch_dev_cap_info *capability) +{ + if (capability == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + capability->kaleidoscope = true; + capability->effect_3D = false; + capability->interaction = true; + capability->video = true; + capability->video_format = (1 << CODEC_JPEG); + return true; +} + +bool GetWatchSystemInfo(watch_sys_info *sysInfo) +{ + if (sysInfo == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + sysInfo->watch_proto_support_cnt = DialBinParserManager::GetInstance()->GetSupportVersionCnt(); + for (uint8_t i = 0; i < sysInfo->watch_proto_support_cnt; ++i) { + std::string version; + bool isSuccess = DialBinParserManager::GetInstance()->GetVersionByIndex(i, version); + if (!isSuccess) { + return false; + } + errno_t ret = + strcpy_s(sysInfo->watch_protocol_verion[i], sizeof(sysInfo->watch_protocol_verion[i]), version.c_str()); + if (ret != 0) { + GRAPHIC_LOGE("get protocal version error!"); + return false; + } + } + int ret = sprintf_s(sysInfo->resolution, + sizeof(sysInfo->resolution), + "%u*%u", + Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + if (ret == -1) { + GRAPHIC_LOGE("get resolution error!"); + return false; + } + + return true; +} + +bool GetCurrentWatchFaceInfo(watch_dial_info *watch) +{ + if (watch == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + std::string activePath; + if (!GetActiveWatchPath(activePath)) { + return false; + } + + DialPreviewInfo preview; + if (!GetPreviewInfo(activePath, preview)) { + return false; + } + + if (std::string(preview.protocolVersion) < std::string("3.0")) { + return false; + } + if (!ConvertPreview2WatchDialInfo(preview, *watch)) { + return false; + } + watch->install_state = true; + watch->is_current_watch = true; + return true; +} + +bool SetCurrentWatchFace(uint32_t uuid) +{ + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + watch_dial_info info; + uint16_t index = 0; + bool isExists = false; + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + if (uuid == g_info.watchInfo[i].uuid) { + isExists = true; + info = g_info.watchInfo[i]; + index = i; + break; + } + } + if (!isExists) { + GRAPHIC_LOGE("uuid does not exist!"); + return false; + } + if (info.is_current_watch) { + return true; + } + + DialSetting setting = MainModel::GetInstance().GetDialSetting(); + setting.dialFlag = 1; + setting.dialFullName = g_info.fileNames[index]; + GraphicService::GetInstance()->PostGraphicEvent([setting]() { + MainModel::GetInstance().GetDialSetting() = setting; + #ifdef fd230_650 + MainModel::GetInstance().AddDialSetting(setting); + #endif + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAIN) { + #ifdef fd230_650 + MainViewSample::GetInstance()->ReloadWatchFace(); + #endif + } + }); + + return true; +} + +bool UninstallWatch(uint32_t uuid) +{ + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + watch_dial_info info; + uint16_t index = 0; + bool isExists = false; + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + if (uuid == g_info.watchInfo[i].uuid) { + isExists = true; + info = g_info.watchInfo[i]; + index = i; + break; + } + } + if (!isExists) { + GRAPHIC_LOGE("uuid does not exist!"); + return false; + } + + if (info.is_current_watch) { + DialSetting setting = MainModel::GetInstance().GetDialSetting(); + setting.dialFlag = 0; + setting.dialId = 0; + std::string fileName = g_info.fileNames[index]; + GraphicService::GetInstance()->PostGraphicEvent([setting, fileName]() { + MainModel::GetInstance().GetDialSetting() = setting; + #ifdef fd230_650 + MainModel::GetInstance().AddDialSetting(setting,0); + #endif + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAIN) { + #ifdef fd230_650 + MainViewSample::GetInstance()->ReloadWatchFace(); + #endif + } + if (remove(fileName.c_str()) != 0) { + GRAPHIC_LOGE("failed to remove file %s", fileName.c_str()); + } + }); + } else { + if (remove(g_info.fileNames[index].c_str()) != 0) { + GRAPHIC_LOGE("failed to remove file %s", g_info.fileNames[index].c_str()); + return false; + } + } + return true; +} + +bool InstallWatch(const char *path, uint32_t *uuid) +{ + if (path == nullptr || uuid == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + + DialPreviewInfo preview; + if (!GetPreviewInfo(std::string(path), preview)) { + return false; + } + if (std::string(preview.protocolVersion) < std::string("3.0")) { + return false; + } + *uuid = preview.uuid; + + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watchinfo!"); + return false; + } + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + const std::string &fileName = g_info.fileNames[i]; + const watch_dial_info &info = g_info.watchInfo[i]; + if (!(info.uuid == *uuid && std::string(path) != fileName)) { + continue; + } + + if (info.is_current_watch) { + DialSetting setting = MainModel::GetInstance().GetDialSetting(); + setting.dialFlag = 1; + setting.dialFullName = std::string(path); + GraphicService::GetInstance()->PostGraphicEvent([setting, fileName]() { + MainModel::GetInstance().GetDialSetting() = setting; + #ifdef fd230_650 + MainModel::GetInstance().AddDialSetting(setting); + #endif + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAIN) { + #ifdef fd230_650 + MainViewSample::GetInstance()->ReloadWatchFace(); + #endif + } + if (remove(fileName.c_str()) != 0) { + GRAPHIC_LOGE("failed to remove file %s", fileName.c_str()); + } + }); + } else { + if (remove(fileName.c_str()) != 0) { + return false; + } + } + } + + return true; +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp index e46942b71..9bd9f98a6 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp @@ -128,7 +128,6 @@ void VocassistPresenter::OnResume(void) void VocassistPresenter::OnStop(void) { - Presenter::OnStop(); ScreenTurnOff(); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp index 06ef3c55b..7e33d902f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp @@ -337,6 +337,8 @@ void PlayersModel::NextSong(int16_t index) } } else if (playerState == PlayerStates::PLAYER_PAUSED || (playerState == PlayerStates::PLAYER_IDLE)) { ret = playerCtr->Reset(); + AudioManager::GetInstance().DeactivateAudioInterrupt(interrupt); + ClearActivateAudioInterrupt(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Reset, ret:%d", ret); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersPresenter.cpp index e6eabbd40..5b327381b 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersPresenter.cpp @@ -29,6 +29,7 @@ #include #include "NativeRegisterManager.h" +#include "MainViewSample.h" namespace OHOS @@ -119,7 +120,7 @@ bool JumpView::ChangeBluetoothEarPhoneView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } // 动画开始 bluetoothEarPhoneView->BtAnimatorStart(); @@ -143,7 +144,7 @@ bool JumpView::ChangeBluetoothEarListView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } else { // 刷新列表 UIList *scanList = bluetoothEarListView->GetScanUIList(); @@ -175,7 +176,7 @@ bool JumpView::ChangeBluetoothView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "JumpView::ChangeBluetoothView"); BluetoothModel::GetInstance()->SetTagConnectView(false); @@ -200,7 +201,7 @@ bool JumpView::ChangeBluetoothOptionsView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } return true; } @@ -222,7 +223,7 @@ bool JumpView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } else { // 刷新列表 UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList(); @@ -259,7 +260,7 @@ bool JumpView::ChangeBluetoothReconnectView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } BluetoothModel::GetInstance()->SetTagDisconnectView(true); BluetoothReconnectView::GetInstance()->RefreshBluetoothNameLabel(); @@ -281,7 +282,7 @@ void JumpView::ResetEarListView(int16_t hideView) } else if (hideView == TIPSCONNFAILMESSAGEVIEW) { bluetoothEarListView->SetTitleLabel("扫描完成"); bluetoothEarListView->SetNewEquipmentButtonAdd(); - RootView::GetInstance()->Invalidate(); + MainViewSample::GetInstance()->GetRootContainer()->Invalidate(); } } @@ -302,7 +303,7 @@ bool JumpView::ChangeTipsSuccMessageView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } return true; } @@ -324,7 +325,7 @@ bool JumpView::ChangeTipsConnFailMessageView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } BluetoothReconnectView *bluetoothReconnectView = BluetoothReconnectView::GetInstance(); if (bluetoothReconnectView == nullptr) { @@ -353,7 +354,7 @@ bool JumpView::ChangeTipsFailMessageView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } return true; } @@ -400,7 +401,7 @@ void JumpView::ChangeView(int16_t hideView, int16_t showView) } container[showView]->SetVisible(true); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "JumpView:: ChangeView end!!!%d", showView); - RootView::GetInstance()->Invalidate(); + MainViewSample::GetInstance()->GetRootContainer()->Invalidate(); BluetoothModel::GetInstance()->SetCurView(showView); } @@ -1057,7 +1058,7 @@ static void Pause(void) void PlayerInterruptListener::PausePlayer(void) { - PlayerPostGraphicEvent(Pause); + Pause(); } static void Resume(void) @@ -1101,15 +1102,13 @@ static void Resume(void) void PlayerInterruptListener::ResumePlayer(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PlayerInterruptListener::ResumePlayer] start"); - usleep(50000); // 确保界面切换完成 + usleep(500000); // 确保界面切换完成 if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL || (GetCurrCallState() != HFP_HF_CALL_STATE_FINISHED && GetScoConnectState() == HFP_SCO_STATE_CONNECTED)) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PlayerInterruptListener::ResumePlayer] this is in calling"); return; // 通话界面,禁止音乐恢复播放 } - AudioRelease(); // 适配某些机型不触发SCO - - PlayerPostGraphicEvent(Resume); + Resume(); } static void Stop(void) @@ -1464,7 +1463,7 @@ void PlayersPresenter::OnClickCancelConnedRequestButton(void) pbItermView->ConnectAnimatorStop(); BluetoothModel::GetInstance()->SetConnectionView(nullptr); bluetoothEarListView->SetNewEquipmentButtonAdd(); - RootView::GetInstance()->Invalidate(); + MainViewSample::GetInstance()->GetRootContainer()->Invalidate(); return; } diff --git a/code/sdk/application/wearable/fd230/service/CMakeLists.txt b/code/sdk/application/wearable/fd230/service/CMakeLists.txt index 124bf1176..7b1691bee 100644 --- a/code/sdk/application/wearable/fd230/service/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230/service/CMakeLists.txt @@ -15,3 +15,4 @@ if("CONFIG_SEA_PHS_SUPPORT" IN_LIST DEFINES) add_subdirectory_if_exist(smart_voice) endif() add_subdirectory_if_exist(power_manager) +add_subdirectory_if_exist(dial_market) diff --git a/code/sdk/application/wearable/fd230/service/app_store/app_store.cpp b/code/sdk/application/wearable/fd230/service/app_store/app_store.cpp index 922286134..8c6efbeb1 100644 --- a/code/sdk/application/wearable/fd230/service/app_store/app_store.cpp +++ b/code/sdk/application/wearable/fd230/service/app_store/app_store.cpp @@ -8,7 +8,6 @@ #include "bundle_install_msg.h" #include "bundlems_slite_client.h" #include "appexecfwk_errors.h" -#include "sign_mode.h" #include "ui_service.h" void AppStoreReplyAck(uint8_t cmd_id, uint8_t type, uint32_t ack) @@ -40,13 +39,10 @@ static void SendMsgToAppStore(CallbackStatus status, const uint8_t resultCode, c SendMsgToUIService(JS_UNINSTALL_SUCESS_TO_UI, 0, &bundleData, sizeof(BundleData)); report.operationResult = UNINSTALL_OK; } - OHOS::SignMode::GetInstance().SetSignMode(true); } else if (resultCode == ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_BUNDLE_NUMBER) { report.operationResult = INSTALL_OVER_LIMIT; - OHOS::SignMode::GetInstance().SetSignMode(true); } else { report.operationResult = (status == INSTALL_CALLBACK) ? INSTALL_FAILED : UNINSTALL_FAILED; - OHOS::SignMode::GetInstance().SetSignMode(true); } AdapterFree(installMsg); WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "SendMsgToAppStore operationResult = %u", report.operationResult); @@ -79,7 +75,6 @@ errcode_t AppStorePkgOperation(uint8_t cmd_id, uint8_t type, void *usr_data, uin if (pkgFullName != nullptr) { (void)sprintf_s(pkgFullName, len, "%s%s", FS_DIR_APP_STORE, (char *)operInfo->pkgName); WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "AppStorePkgOperation install pkgFullName=%s", pkgFullName); - OHOS::SignMode::GetInstance().SetSignMode(false); InstallParam installParam = { .installLocation = 1, .keepData = false }; ret = OHOS::BundleMsClient::GetInstance().Install(pkgFullName, &installParam, InstallCallbackFunc); free(pkgFullName); @@ -87,7 +82,6 @@ errcode_t AppStorePkgOperation(uint8_t cmd_id, uint8_t type, void *usr_data, uin } else if (operInfo->operationType == PKG_OPERATION_TYPE_UNINSTALL) { StopJsApp((char*)operInfo->pkgName); WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "AppStorePkgOperation uninstall pkgName=%s", operInfo->pkgName); - OHOS::SignMode::GetInstance().SetSignMode(false); InstallParam installParam = { .installLocation = 1, .keepData = false }; ret = OHOS::BundleMsClient::GetInstance().Uninstall((char*)operInfo->pkgName, &installParam, UninstallCallbackFunc); } @@ -119,6 +113,7 @@ errcode_t AppStoreGetPkgList(uint8_t cmd_id, uint8_t type, void *usr_data, uint1 (void)strncpy_s((char*)unitInfo[i].pkgName, PKG_NAME_MAX_LENGTH, bundleInfos[i].bundleName, strlen(bundleInfos[i].bundleName)); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppStoreGetPkgList pkgName[%d] = %s", i, unitInfo[i].pkgName); + unitInfo[i].versionCode = bundleInfos[i].versionCode; } ret = msg_center_send_data(MSGCENTER_CMD_APP_STORE, type, infoList, len); free(infoList); diff --git a/code/sdk/application/wearable/fd230/service/app_store/app_store.h b/code/sdk/application/wearable/fd230/service/app_store/app_store.h index e5b28b345..7bbc93b96 100644 --- a/code/sdk/application/wearable/fd230/service/app_store/app_store.h +++ b/code/sdk/application/wearable/fd230/service/app_store/app_store.h @@ -59,6 +59,7 @@ typedef struct { typedef struct { uint8_t pkgName[PKG_NAME_MAX_LENGTH]; + int32_t versionCode; } PkgUnitInfo; errcode_t AppStorePkgOperation(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); diff --git a/code/sdk/application/wearable/fd230/service/dial_market/CMakeLists.txt b/code/sdk/application/wearable/fd230/service/dial_market/CMakeLists.txt new file mode 100644 index 000000000..058f8dc76 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/dial_market/CMakeLists.txt @@ -0,0 +1,43 @@ +set(COMPONENT_NAME "dial_market") + +set(PUBLIC_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/ +) + +set(PRIVATE_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/../../ohos_deps + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits/gfx_utils + ${ROOT_DIR}/open_source/openharmony/base/startup/syspara_lite/include + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/format/interfaces/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/main/include/dial +) + +set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/dial_market_msg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dial_market.cpp +) + +set(COMPONENT_PUBLIC_CCFLAGS +) + +set(COMPONENT_CCFLAGS + -std=c++11 +) + +set(WHOLE_LINK + true +) + +set(PUBLIC_DEFINES +) + +set(PRIVATE_DEFINES + APP_PLATFORM_WATCHGT + CONFIG_ACELITE_ENABLE +) + +build_component() + + diff --git a/code/sdk/application/wearable/fd230/service/dial_market/dial_market.h b/code/sdk/application/wearable/fd230/service/dial_market/dial_market.h new file mode 100644 index 000000000..6110188e5 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/dial_market/dial_market.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: broadcast service api + * Author: CompanyName + * Create: 2021-11-11 + */ + +#ifndef DIAL_MARKET_H +#define DIAL_MARKET_H + +#include "msg_center_protocol.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#define MAX_CHIP_PLAT_LEN 5 +#define MAX_CHIP_MODEL_LEN 5 +#define MAX_OS_LEN 23 +#define MAX_API_LEVEL_LEN 3 +#define MAX_WATCH_PROTO_VER_LEN 4 +#define MAX_WATCH_INTERNAL_VER 6 +#define MAX_RESOLUTION_LEN 8 +#define MAX_SUPPORT_PROTOCOL 8 +#define MAX_WATCH_CNT 64 + +typedef enum msg_center_dial_market_type_id { + MSGCENTER_TYPE_ID_DM_GET_SYS_INFO = 0x1, + MSGCENTER_TYPE_ID_DM_GET_DEV_CAP = 0x2, + MSGCENTER_TYPE_ID_DM_GET_ONE_WATCH_INFO = 0x3, + MSGCENTER_TYPE_ID_DM_INSTALL_WATCH = 0x4, + MSGCENTER_TYPE_ID_DM_UNINSTALL_WATCH = 0x5, + MSGCENTER_TYPE_ID_DM_SET_WATCH = 0x6, + MSGCENTER_TYPE_ID_DM_GET_ALL_WATCH_INFO = 0x7, + MSGCENTER_TYPE_ID_DM_GET_CUR_WATCH_INFO = 0x8, +} msg_center_dial_market_type_id_t; + +typedef struct { + char chip_platform[MAX_CHIP_PLAT_LEN]; + char chip_model[MAX_CHIP_MODEL_LEN]; + char os_version[MAX_OS_LEN]; + char api_level[MAX_API_LEVEL_LEN]; + uint8_t watch_proto_support_cnt; + char watch_protocol_verion[MAX_SUPPORT_PROTOCOL][MAX_WATCH_PROTO_VER_LEN]; + char resolution[MAX_RESOLUTION_LEN]; +} watch_sys_info; + +typedef struct { + uint8_t kaleidoscope; + uint8_t effect_3D; + uint8_t interaction; + uint8_t video; + uint16_t video_format; /* 按照CodecFormat做位映射形成能力集 */ +} watch_dev_cap_info; + +typedef struct { + uint32_t uuid; + uint8_t install_state; + uint8_t is_current_watch; + uint8_t watch_protocol_version[MAX_WATCH_PROTO_VER_LEN]; + uint8_t watch_version[MAX_WATCH_INTERNAL_VER]; +} watch_dial_info; + +errcode_t msg_center_dial_market_get_sys_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_dev_cap(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_one_watch_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_install_watch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_uninstall_watch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_set_watch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_all_watch_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_cur_watch_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif /* DIAL_MARKET_H */ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt index 360c83733..1a21912b2 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt @@ -21,24 +21,10 @@ set(PRIVATE_HEADER ${ROOT_DIR}/application/wearable/service/xiaodu_navi_vector ${ROOT_DIR}/application/wearable/service/xiaodu_navi_vector/libs ${ROOT_DIR}/application/wearable/service/msg_center/src/notify/ketinput/include - ${ROOT_DIR}/application/wearable/nativeapp/nativelauncher/include - ${ROOT_DIR}/application/wearable/nativeabilityfwk/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarm/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/key/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclockmanage/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclocktimerconfig/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/main/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/callerlog/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/phoneservice/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/makephone/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/player/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include - ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits ) set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_protocol.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/client/msg_center_client.cpp @@ -134,6 +120,20 @@ set(PRIVATE_HEADER ${ROOT_DIR}/include/middleware/services/bts/common ${ROOT_DIR}/application/auto_ota ${ROOT_DIR}/application/wearable/service/xiaodu_navi_vector + ${ROOT_DIR}/application/wearable/service/msg_center/src/notify/ketinput/include + ${ROOT_DIR}/application/wearable/nativeapp/nativelauncher/include + ${ROOT_DIR}/application/wearable/nativeabilityfwk/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarm/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/key/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclockmanage/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclocktimerconfig/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/main/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/callerlog/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/phoneservice/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/makephone/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/player/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits ) if("JS_ENABLE" IN_LIST DEFINES) @@ -144,6 +144,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp ) else() set(SOURCES @@ -152,6 +153,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_self_cmd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp ) endif() diff --git a/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-cli/libmsg_center.a b/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-cli/libmsg_center.a index f08ef6530..f6ea17c48 100644 Binary files a/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-cli/libmsg_center.a and b/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-cli/libmsg_center.a differ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-ser/libmsg_center.a b/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-ser/libmsg_center.a index 41ad2aba2..c7c253e08 100644 Binary files a/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-ser/libmsg_center.a and b/code/sdk/application/wearable/fd230/service/msg_center/brandy-auto-ota-ser/libmsg_center.a differ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-fd230/libmsg_center.a b/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-fd230/libmsg_center.a index 0b1a2609a..0e24be78a 100644 Binary files a/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-fd230/libmsg_center.a and b/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-fd230/libmsg_center.a differ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-xts/libmsg_center.a b/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-xts/libmsg_center.a index 0b1a2609a..0e24be78a 100644 Binary files a/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-xts/libmsg_center.a and b/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js-xts/libmsg_center.a differ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js/libmsg_center.a b/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js/libmsg_center.a index 0b1a2609a..0e24be78a 100644 Binary files a/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js/libmsg_center.a and b/code/sdk/application/wearable/fd230/service/msg_center/brandy-native-js/libmsg_center.a differ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/brandy-xts/libmsg_center.a b/code/sdk/application/wearable/fd230/service/msg_center/brandy-xts/libmsg_center.a index 998789235..c686df549 100644 Binary files a/code/sdk/application/wearable/fd230/service/msg_center/brandy-xts/libmsg_center.a and b/code/sdk/application/wearable/fd230/service/msg_center/brandy-xts/libmsg_center.a differ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_customer.h b/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_customer.h index 41578ba57..79cb07fac 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_customer.h +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_customer.h @@ -23,6 +23,7 @@ extern "C" { void StartJsApp(char *bundleName); void StopJsApp(char *bundleName); void MsgCenterReportBtStatusToJS(uint16_t msgId); +bool MsgCenterNotifyProc(const Topic topic, Request* req); #endif #ifdef __cplusplus diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_protocol.h b/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_protocol.h index 93961d39e..02cf29c8f 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_protocol.h +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/msg_center_protocol.h @@ -61,6 +61,7 @@ typedef enum msg_center_cmd_id { MSGCENTER_CMD_PING = 0x7, MSGCENTER_CMD_WATCH_CONNECT = 0x8, MSGCENTER_CMD_APP_STORE = 0x9, + MSGCENTER_CMD_DIAL_MARKET = 0xa, MSGCENTER_CMD_MAX } msg_center_cmd_id_t; diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/ketinput/include/NotifyOnKeyListener.h b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/ketinput/include/NotifyOnKeyListener.h new file mode 100644 index 000000000..fd6b6bf47 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/ketinput/include/NotifyOnKeyListener.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024-2024. All rights reserved. + * Description: NotifyOnKeyListener.h + * Author: g30037431 + * Create: 2024-12-12 + */ + +#ifndef KEY_NOTIFY_INPUT_LISTENER_H +#define KEY_NOTIFY_INPUT_LISTENER_H + +#include "components/root_view.h" +#include "events/key_event.h" +#include "ohos_types.h" + +namespace OHOS { +class NotifyOnKeyListener : public RootView::OnKeyActListener { +public: + static NotifyOnKeyListener* GetInstance(); + bool OnKeyAct(UIView& view, const KeyEvent& event) override; + +private: + NotifyOnKeyListener() {} + ~NotifyOnKeyListener() {} + void OnKeyPress(void); + void OnKeyLongPress(const KeyEvent& event); + void OnKeyRelease(const KeyEvent& event); + void CallVolumeDipSwitchControl(uint8_t status); + void PlayerVolumeDipSwitchControl(uint8_t status); +private: + int32 pressFlag{0}; + int32 longPressFlag{0}; +}; +} +#endif // KEY_NOTIFY_INPUT_LISTENER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/ketinput/src/NotifyOnKeyListener.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/ketinput/src/NotifyOnKeyListener.cpp new file mode 100644 index 000000000..bfcc29b0b --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/ketinput/src/NotifyOnKeyListener.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024-2024. All rights reserved. + * Description: NotifyOnKeyListener.cpp + * Author:g30037431 + * Create: 2024-12-14 + */ + +#include "NotifyOnKeyListener.h" +#include "common/key_code.h" +#include "AppViewIDs.h" +#include "View.h" +#include "KeyInputListener.h" +#include "VolumeSettingView.h" +#include "VolumeSettingPresenter.h" +#include "VolumeSettingView.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "dock/input_device.h" +#include "notification_manager.h" +#include "AlarmPopUpPresenter.h" +#include "CallerLogModel.h" +#include "MainCallingPresenter.h" +#include "ApplistModel.h" +namespace OHOS { +static bool IsNotifyCallStatus() +{ + uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId(); + if (NotificationManager::GetInstance()->HasNotifyShowing() && + (notifyId == TOPIC_EVENT_HFP_WATCH_ACTIVE || notifyId == TOPIC_EVENT_HFP_PHONE_TO_WATCH)) { + return true; + } else { + return false; + } +} + +static void PressAlarmNotify() +{ + AlarmClockModel::GetInstance()->AlarmGetClockNum(); + AlarmPopUpPresenter::GetInstance()->DelayAlarmRing(); + NotificationManager::GetInstance()->StopNotify(); +} + +NotifyOnKeyListener *NotifyOnKeyListener::GetInstance() +{ + static NotifyOnKeyListener instance; + return &instance; +} + +void NotifyOnKeyListener::OnKeyPress(void) +{ + pressFlag = 1; // Short press the logo + return; +} + +void NotifyOnKeyListener::OnKeyLongPress(const KeyEvent &event) +{ + longPressFlag = 1; // Long press the logo + + uint16 keyID = event.GetKeyId(); + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button + NativeAbility::GetInstance().ChangeSlice(VIEW_REBOOT); // Switch to shutdown/restart card + } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons + // Switch to View System Version Card + } + return; +} + +void NotifyOnKeyListener::CallVolumeDipSwitchControl(uint8_t status) +{ + VolumeSliderEventListener *volumeSliderEventListener = nullptr; + if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) { + VolumeSettingView *settingView = GetvolumeSetting(); + if (settingView == nullptr) { + return; + } + volumeSliderEventListener = settingView->GetVolumeEventListener(); + if (volumeSliderEventListener == nullptr) { + return; + } + volumeSliderEventListener->ChangeVolume(static_cast(status)); + } else { + HonrsViewChange(); + NotificationManager::GetInstance()->SetVolumeScreenStatus(true); + } + return; +} + +void NotifyOnKeyListener::OnKeyRelease(const KeyEvent &event) +{ + uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); + uint16 keyID = event.GetKeyId(); + uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId(); + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button + if (longPressFlag == 0 && pressFlag == 1 && + NotificationManager::GetInstance()->HasNotifyShowing()) { // Short press the power button + if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Call notify + CallVolumeDipSwitchControl(VOLUMEUP); // Volume+ + } else if (notifyId == TOPIC_EVENT_ALARM_RING) { // Main dial + PressAlarmNotify(); // When currently on the alarm notification page, process the alarm first before switching pages + } + } + } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons + if (longPressFlag == 0 && pressFlag == 1) { // Short press the function key + if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Volume card + CallVolumeDipSwitchControl(VOLUMEDOWN); // Volume- + } else { + // Switch to user configured shortcut card + } + } + } + + pressFlag = 0; + longPressFlag = 0; + return; +} + +bool NotifyOnKeyListener::OnKeyAct(UIView &view, const KeyEvent &event) +{ + UNUSED(view); + uint8 state = event.GetState(); + + switch (state) { + case InputDevice::STATE_PRESS: // Short press + OnKeyPress(); + break; +#ifdef __LITEOS_M__ + case InputDevice::STATE_LONG_PRESS: // Long press + OnKeyLongPress(event); + break; +#endif + case InputDevice::STATE_RELEASE: // Release + OnKeyRelease(event); + break; + default: + break; + } + return true; +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/service/power_manager/src/actions/display_action.c b/code/sdk/application/wearable/fd230/service/power_manager/src/actions/display_action.c index 976e3c5c0..6f45b72ff 100644 --- a/code/sdk/application/wearable/fd230/service/power_manager/src/actions/display_action.c +++ b/code/sdk/application/wearable/fd230/service/power_manager/src/actions/display_action.c @@ -16,7 +16,6 @@ #include "soc_dpu_type.h" #include "soc_mipi_tx.h" #include "pmu_ldo.h" -#include "soc_gmmu_api.h" #include "pm_lp_stub.h" #include "hal_pmu_ldo.h" #include "cmsis_os2.h" @@ -151,13 +150,6 @@ static uint32_t action_display_lcd_on() POWER_DISPLAY_PRINT_ERR(0, "drv vau resume error ret=%x\r\n", ret); return ERRCODE_FAIL; } -#ifdef SUPPORT_GPU_GMMU - ret = drv_gmmu_resume(NULL); - if (ret != 0) { - POWER_DISPLAY_PRINT_ERR(0, "drv gmmu resume error ret=%x\r\n", ret); - return ERRCODE_FAIL; - } -#endif ret = uapi_lcd_init(); if (ret != 0 && ret != EXT_ERR_MIPI_ALREADY_INIT) { POWER_DISPLAY_PRINT_ERR(0, "LCD init error ret=%x\r\n", ret); @@ -215,13 +207,7 @@ static uint32_t action_display_lcd_off() POWER_DISPLAY_PRINT_ERR(0, "drv dpu suspend error ret=%x\r\n", ret); } #endif -#ifdef SUPPORT_GPU_GMMU - ret = drv_gmmu_suspend(NULL); - if (ret != 0) { - POWER_DISPLAY_PRINT_ERR(0, "drv gmmu suspend error ret=%x\r\n", ret); - return ERRCODE_FAIL; - } -#endif + ret = uapi_lcd_deinit(); if (ret != 0) { POWER_DISPLAY_PRINT_ERR(0, "lcd deinit error ret=%x\r\n", ret); @@ -291,6 +277,7 @@ int32_t action_display_execute_entry(uint16_t action_bitmap, uint16_t new_state, } POWER_DISPLAY_PRINT_DEBUG(0, "turn off success."); } + sc->press_state = false; sc->current_state = new_state; return ret; diff --git a/code/sdk/application/wearable/fd230/service/xiaodu_voice/xiaodu_voice.cpp b/code/sdk/application/wearable/fd230/service/xiaodu_voice/xiaodu_voice.cpp index ac4f7fffb..6ca6ae711 100644 --- a/code/sdk/application/wearable/fd230/service/xiaodu_voice/xiaodu_voice.cpp +++ b/code/sdk/application/wearable/fd230/service/xiaodu_voice/xiaodu_voice.cpp @@ -79,7 +79,8 @@ static errcode_t pcm_stream_task_body(void *data) for (;;) { osStatus_t ret = osMessageQueueGet(g_pcm_stream_msg_queue_id, &msg, nullptr, osWaitForever); if (ret != osOK) { - continue; + msg.msg_id = MSGCENTER_TYPE_ID_XIAODU_END_RECORD; + msg.data = nullptr; } if (msg.msg_id == MSGCENTER_TYPE_ID_XIAODU_SEND_PCM_STREAM) { res = msg_center_xiaodu_send_pcm_stream(MSGCENTER_CMD_XIAODU, MSGCENTER_TYPE_ID_XIAODU_SEND_PCM_STREAM, diff --git a/code/sdk/application/wearable/fd230/xts/nativeapp/brandy-native-js-xts/libuikit_fwk.a b/code/sdk/application/wearable/fd230/xts/nativeapp/brandy-native-js-xts/libuikit_fwk.a index 84c02f06e..55d73657a 100644 Binary files a/code/sdk/application/wearable/fd230/xts/nativeapp/brandy-native-js-xts/libuikit_fwk.a and b/code/sdk/application/wearable/fd230/xts/nativeapp/brandy-native-js-xts/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/xts/service/msg_center/brandy-native-js-xts/libmsg_center.a b/code/sdk/application/wearable/fd230/xts/service/msg_center/brandy-native-js-xts/libmsg_center.a index 0b1a2609a..0e24be78a 100644 Binary files a/code/sdk/application/wearable/fd230/xts/service/msg_center/brandy-native-js-xts/libmsg_center.a and b/code/sdk/application/wearable/fd230/xts/service/msg_center/brandy-native-js-xts/libmsg_center.a differ diff --git a/code/sdk/application/wearable/nativeabilityfwk/include/PageTransitionMgr.h b/code/sdk/application/wearable/nativeabilityfwk/include/PageTransitionMgr.h index ca6c64714..39e695435 100644 --- a/code/sdk/application/wearable/nativeabilityfwk/include/PageTransitionMgr.h +++ b/code/sdk/application/wearable/nativeabilityfwk/include/PageTransitionMgr.h @@ -29,7 +29,10 @@ public: if (parent != nullptr) { parent->Remove(this); } - ImageCacheFree(*const_cast(GetImageInfo())); + const ImageInfo* info = GetImageInfo(); + if (info != nullptr) { + ImageCacheFree(*const_cast(info)); + } } }; @@ -80,7 +83,6 @@ public: void SyncStopAnimator(); void AsyncStopAnimator(); void EndTransition(bool success); - void SetRunDirectlyTransition(TransitionCaller caller, TransitionTarget target); bool IsCurrentSnapshotEnabled() { return isCurrentSnapShotEnabled_; diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp index 9b5ed1d85..8be4e9709 100644 --- a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp +++ b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp @@ -116,7 +116,7 @@ void Ability::ChangeSlice(const uint16_t targetSliceId, TransitionType type, #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, TransitionType::TRANSITION_ZOOM); + OHOS::AbilityMsClient::GetInstance().ForceStop(elementName->bundleName, type); targetSliceIdFromJS_ = targetSliceId; FreeElement(elementName); return; diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index d84ffc846..852d5a3c7 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -2,6 +2,7 @@ set(COMPONENT_NAME "nativelauncher") set(MODULE_NAME "app") set(AUTO_DEF_FILE_ID TRUE) set(NativeApp ${CMAKE_CURRENT_SOURCE_DIR}) +set(UIKIT_ROOT_DIR ${ROOT_DIR}/middleware/services/gui/uikit) set(UI_SAMPLE_ROOT ${ROOT_DIR}/middleware/services/gui/uikit/sample/uitest) set(PUBLIC_HEADER @@ -52,6 +53,8 @@ set(PRIVATE_HEADER ${NativeApp}/nativeui/alipay/include/AlipayTrans ${NativeApp}/nativeui/restoredefaults/include + ${NativeApp}/nativeui/videocard/include + ${UI_SAMPLE_ROOT}/components ${NativeApp}/../service/smart_voice/smart_voice_service/interfaces/innerkits/native_c/include ${NativeApp}/../service/smart_voice/voice_engine_hal/interfaces/innerkits/native_c/include @@ -91,6 +94,10 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/utils/include ${ROOT_DIR}/open_source/openharmony/utils/native/lite/include ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/format/interfaces/include + ${UIKIT_ROOT_DIR}/proprietary/src/ui/innerkits + ${ROOT_DIR}/application/wearable/service/dial_market + ${ROOT_DIR}/open_source/openharmony/third_party/cJSON ) file(GLOB_RECURSE SOURCES "${NativeApp}/nativeui/*.cpp") @@ -127,6 +134,7 @@ set(SOURCES list(REMOVE_ITEM SOURCES ${NativeApp}/nativeui/main/src/dial/parser/DialBinParser.cpp ${NativeApp}/nativeui/main/src/dial/parser/DialBinParserManager.cpp + ${NativeApp}/nativeui/main/src/dial/parser/DialBinParserV3.cpp ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) @@ -213,6 +221,7 @@ set(COMPONENT_SRC ${UIKIT_NATIVE_FWK}/src/TransitionRecord.cpp ${UIKIT_NATIVE_DIAL}/src/dial/parser/DialBinParser.cpp ${UIKIT_NATIVE_DIAL}/src/dial/parser/DialBinParserManager.cpp + ${UIKIT_NATIVE_DIAL}/src/dial/parser/DialBinParserV3.cpp ) set(SOURCES @@ -237,9 +246,11 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks ${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include/ ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/format/interfaces/include ${UIKIT_NATIVE_DIAL}/include/dial ${ROOT_DIR}/middleware/services/media/foundation/sample/wrapper ${ROOT_DIR}/middleware/services/media/foundation/player/interfaces/kits + ${UIKIT_ROOT_DIR}/proprietary/src/ui/innerkits ) set(PRIVATE_DEFINES diff --git a/code/sdk/application/wearable/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a b/code/sdk/application/wearable/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a index 025d43300..c530718d4 100644 Binary files a/code/sdk/application/wearable/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a and b/code/sdk/application/wearable/nativeapp/brandy-auto-ota-cli/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a b/code/sdk/application/wearable/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a index 4e49f57f4..410571e58 100644 Binary files a/code/sdk/application/wearable/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a and b/code/sdk/application/wearable/nativeapp/brandy-auto-ota-ser/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/nativeapp/brandy-native-js-fd230/libuikit_fwk.a b/code/sdk/application/wearable/nativeapp/brandy-native-js-fd230/libuikit_fwk.a index 84c02f06e..55d73657a 100644 Binary files a/code/sdk/application/wearable/nativeapp/brandy-native-js-fd230/libuikit_fwk.a and b/code/sdk/application/wearable/nativeapp/brandy-native-js-fd230/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/nativeapp/brandy-native-js/libuikit_fwk.a b/code/sdk/application/wearable/nativeapp/brandy-native-js/libuikit_fwk.a index 84c02f06e..55d73657a 100644 Binary files a/code/sdk/application/wearable/nativeapp/brandy-native-js/libuikit_fwk.a and b/code/sdk/application/wearable/nativeapp/brandy-native-js/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/nativeapp/brandy-xts/libuikit_fwk.a b/code/sdk/application/wearable/nativeapp/brandy-xts/libuikit_fwk.a index fc6ad8984..2c30eba89 100644 Binary files a/code/sdk/application/wearable/nativeapp/brandy-xts/libuikit_fwk.a and b/code/sdk/application/wearable/nativeapp/brandy-xts/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeRegisterManager.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeRegisterManager.h index 0a1278694..b8d7f198d 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeRegisterManager.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeRegisterManager.h @@ -50,6 +50,7 @@ public: void RegisterNative(const AppItem &nativeAppList, NativeRegisterCallback* native); void RegisterSlice(const uint16_t id, SliceProxy* slice); void RegisterMenu(const uint16_t id, const char *icon, const char *iconHexagon, const char *label); + bool IsSliceIdExist(AppViewId id); private: NativeRegisterManager() {}; diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index 0c7c90057..ffecde66d 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -13,15 +13,18 @@ #include "graphic_config.h" namespace OHOS { - static const int CARD_SETTING_COUNT_MAX = 5; typedef enum { WATCH_FACE = 0, /* 主表盘枚举值不能修改 */ HEART_RATE, COMPASS, ACTIVITY, MUSIC_PLAYER, + VIDEO_CARD1, + VIDEO_CARD2, + VIDEO_CARD3, MAX_CARD, } CardId; + static const int CARD_SETTING_COUNT_MAX = MAX_CARD; typedef enum { DIAL_CLOCK = 0, @@ -372,6 +375,8 @@ namespace OHOS { static constexpr const char *PNG_SET_CARD_COMPASS = APP_RES_PATH"/CARD_COMPASS.bin"; static constexpr const char *PNG_SET_CARD_ACTIVITY = APP_RES_PATH"/CARD_ACTIVITY.bin"; static constexpr const char *PNG_SET_CARD_PLAYER = APP_RES_PATH"/CARD_PLAYER.bin"; + static constexpr const char *PNG_SET_CARD_VIDEO = APP_RES_PATH"/noaudio_5_set.bin"; + static constexpr const char *PNG_PREVIEW_CARD_VIDEO = APP_RES_PATH"/noaudio_05.bin"; static constexpr const char *PNG_SET_DIAL_CLOCK = APP_RES_PATH"/DIAL_CLOCK.bin"; } diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeRegisterManager.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeRegisterManager.cpp index 9d2459a77..6ea82ddfb 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeRegisterManager.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeRegisterManager.cpp @@ -87,4 +87,14 @@ void NativeRegisterManager::RegisterMenu(const uint16_t id, const char *icon, co } nativeAppLists_.PushBack(item); } + +bool NativeRegisterManager::IsSliceIdExist(AppViewId id) +{ + for (uint16_t index = 0; index < slices_.Size(); index++) { + if (slices_[index].id == static_cast(id)) { + return true; + } + } + return false; +} } // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp index e9fd5bc28..a58470e2d 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/alipay/src/AlipayPresenter.cpp @@ -51,8 +51,6 @@ AlipayPresenter *AlipayPresenter::GetInstance() void AlipayPresenter::OnStart() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlipayPresenter OnStart"); - Presenter::OnStart(); alipayMode_->AlipayExitLpm(); if (!alipayMode_->AlipayInitModel()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlipayPresenter::OnStart AlipayInitModel fail."); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistView.cpp index 2bfd89579..11876d275 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistView.cpp @@ -57,7 +57,6 @@ ApplistView::~ApplistView() void ApplistView::OnStart() { - View::OnStart(); AppListStyle style = presenter_->GetCurrentStyle(); if (style == AppListStyle::FOOTBALL_STYLE) { FootballStyleOnStart(); @@ -131,8 +130,11 @@ void ApplistView::WaterfallStyleOnStart() int16_t blankSize = waterfallList_->GetRelativeRect().GetWidth() > waterfallList_->GetRelativeRect().GetHeight() ? waterfallList_->GetRelativeRect().GetWidth() / 2 : waterfallList_->GetRelativeRect().GetHeight() / 2; // 2, half waterfallList_->SetThrowDrag(true); - waterfallList_->SetReboundSize(imgDistance_ * Sin(60)); // 60, degree - waterfallList_->SetScrollBlankSize(0); + uint16_t layoutHeight = static_cast(imgDistance_ * Sin(60)); + waterfallList_->SetReboundSize(layoutHeight); // 60: degree, row's layout height + waterfallList_->SetScrollBlankSize(layoutHeight, UIAbstractScroll::Direction::TOP); + waterfallList_->SetScrollBlankSize(Screen::GetInstance().GetHeight() / 2 - layoutHeight, // 2: half + UIAbstractScroll::Direction::BOTTOM); waterfallList_->RequestFocus(); waterfallList_->SetRotateFactor(10); // 10, empirical coefficient waterfallList_->SetOnRotateListener(presenter_); @@ -201,7 +203,6 @@ void ApplistView::OnStop() } else { ListStyleOnStop(); } - FocusManager::GetInstance()->ClearFocus(); return; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp index 699e0b1c2..abea09a37 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -36,7 +36,7 @@ #include "dfx_channel.h" #include "tcxo.h" #include "ui_service.h" - +#include "network/network_listener.h" namespace OHOS { #define BT_SPP_TASK_STACK_SIZE 2048 @@ -863,10 +863,16 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ MsgCenterSendMsg(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); + // send to ace network + // SetAclConnected(false); + net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_DISCONNECTED); } else if (state == GAP_ACL_STATE_CONNECTED) { (void)memcpy_s(gapAclConnectAddr.addr, BD_ADDR_LEN, bdAddr->addr, BD_ADDR_LEN); MsgCenterSendMsg(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); + // send to ace network + // SetAclConnected(true); + net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_CONNECTED); } return; } @@ -962,11 +968,16 @@ static void BleConnStateChangeCallback(unsigned short connId, bd_addr_t *addr, g /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ MsgCenterSendMsg(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); msg_center_set_ble_conn_state(GAP_BLE_STATE_DISCONNECTED); + // send to ace network + net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_DISCONNECTED); } else { MsgCenterSendMsg(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); msg_center_set_ble_conn_state(GAP_BLE_STATE_CONNECTED); (void)memcpy_s(&g_bd_addr, sizeof(bd_addr_t), addr, sizeof(bd_addr_t)); + // send to ace network + net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_CONNECTED); } + // send to ace network } static void BleAdvStartCallback(uint8_t advId, adv_status_t status) @@ -1019,7 +1030,7 @@ static void BtGattsServiceAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_ character.chara_uuid.uuid_len = sizeof(diag_id); memcpy_s(character.chara_uuid.uuid, sizeof(character.chara_uuid.uuid), (char *)&diag_id, sizeof(diag_id)); character.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE | GATT_ATTRIBUTE_PERMISSION_READ; - character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE | GATT_CHARACTER_PROPERTY_BIT_READ | GATT_CHARACTER_PROPERTY_BIT_NOTIFY; + character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP | GATT_CHARACTER_PROPERTY_BIT_READ | GATT_CHARACTER_PROPERTY_BIT_NOTIFY; character.value_len = (uint16_t)sizeof(value); character.value = (uint8_t *)(&value); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp index 6dc8defd7..5e9e96d73 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp @@ -193,12 +193,6 @@ static void CallModelResumePlayer(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallModelResumePlayer] [ResumePlayer] start"); usleep(5000); // 延时等待通话释放媒体资源 - std::shared_ptr PlayerIntrptListener = - OHOS::PlayersModel::GetInstance()->GetPlayerIntrptListener(); - if (PlayerIntrptListener != nullptr && PlayerIntrptListener->IsPaused()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallModelResumePlayer] ResumePlayer "); - PlayerIntrptListener->ResumePlayer(); - } } static void CallModelPostGraphicEvent(void (*fun)(void)) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp index 7991cb3f4..871138f01 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp @@ -153,7 +153,6 @@ bool KeyInputListener::OnKeyAct(UIView& view, const KeyEvent& event) UNUSED(view); uint8 state = event.GetState(); - switch (state) { case InputDevice::STATE_PRESS: // 短按 OnKeyPress(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParserManager.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParserManager.h index 530c39b5b..50a9e4a6f 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParserManager.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParserManager.h @@ -23,11 +23,25 @@ public: class DialBinParserManager { public: - static DialBinParserManager* GetInstance(void); - bool UpdateDial(const std::string& file, FILE* fp, DialViewGroup* group, DisplayState state); - bool GetDialPreviewInfo(FILE* fp, DialPreviewInfo* info); + static DialBinParserManager *GetInstance(void); + bool UpdateDial(const std::string &file, FILE *fp, DialViewGroup *group, DisplayState state); + bool GetDialPreviewInfo(FILE *fp, DialPreviewInfo *info); bool RegisterParser(const std::string &version, DialBinParserInterface *parser); + uint8_t GetSupportVersionCnt() const + { + return cnt_; + } + + bool GetVersionByIndex(uint8_t index, std::string &version) + { + if (index >= cnt_) { + return false; + } + version = parsers_[index].version; + return true; + } + private: DialBinParserManager(); virtual ~DialBinParserManager(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParserV3.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParserV3.h new file mode 100644 index 000000000..1d5e2ca9d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParserV3.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialBinParserV3 + * Author: + * Create: 2025-02-06 + */ + +#ifndef GRAPHIC_LITE_DIAL_BIN_PARSER_V3_H +#define GRAPHIC_LITE_DIAL_BIN_PARSER_V3_H +#include "DialBinParserManager.h" +#include "DialTimePublisher.h" +#include "components/ui_abstract_progress.h" +#include "DialViewContainer.h" +#include "DialOHDataType.h" +#include "DialOHSliceId.h" + +namespace OHOS { +class DialBinParserV3 : public DialBinParserInterface { +public: + DialBinParserV3(); + ~DialBinParserV3() override; + bool UpdateDial(const std::string& file, FILE* fp, DialViewGroup* group, DisplayState state) override; + bool GetDialPreviewInfo(FILE* fp, DialPreviewInfo* info) override; + +protected: + bool ParseDialHeader(FILE* file); + bool ParserDialStaticImg(ContainerInterface &parent); + bool ParserDialSequenceImg(ContainerInterface &parent); + bool ParserDialRotateImg(ContainerInterface &parent); + bool ParserDialOptionImg(ContainerInterface &parent); + bool ParserDialDigitalImg(ContainerInterface &parent); + bool ParserDialLabel(ContainerInterface &parent); + bool ParserDialArcLabel(ContainerInterface &parent); + bool ParserDialBoxProgress(ContainerInterface &parent); + bool ParserDialArcProgress(ContainerInterface &parent); + bool ParserDialVideo(ContainerInterface &parent); + bool ParserDialClick(ContainerInterface &parent); + bool ParserDialKaleidoscope(ContainerInterface &parent); + bool ParserDialContainer(ContainerInterface &parent); + bool ParserDialOptions(ContainerInterface &parent); + +private: + void* MallocAndReadBuf(FILE* file, uint32_t readSize); + bool SetProgressType(FILE* fp, UIAbstractProgress* view, DialProgressType data); + + static constexpr uint8_t DIAL_BIN_PARSER_FUNC_NUM = 14; // 14: func max value + bool (DialBinParserV3::*funcArray_[DIAL_BIN_PARSER_FUNC_NUM])(ContainerInterface&); + void AddToParentWithView(ContainerInterface &parent, uint8_t displayMode, UIView *view); + void AddToParentWithDialView(ContainerInterface &parent, uint8_t displayMode, + DialView *view, DialOHDataType bindData, bool isPeriodic); + struct { + uint8_t *viewType; + uint8_t dialViewCount; + FILE *file; + uint8_t curIndex; + } curViewType_; + bool ParseTimeIntervals(FILE* fp, uint8_t cnt, DialTimePublisher::TimeChangeListener *listener); + bool ParseViewType(uint8_t *viewType, uint8_t dialViewCount, FILE *file); + bool ParseContainerSubviews(DialViewContainer *container, uint8_t num); + bool ParseOptionsSubviews(ContainerInterface &parent); + + DialViewGroup* dialGroup_ = nullptr; + std::string file_; + uint32_t dirId_ = 0xfef << 20; // 20: offset + uint32_t imageOffset_ = 0; + DisplayState state_ = DisplayState::NORMAL; +}; // class DialBinParserV3 +} // namespace OHOS + +#endif // GRAPHIC_LITE_DIAL_BIN_PARSER_V3_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinTypes.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinTypes.h index d242a3dc2..3301b3d77 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinTypes.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinTypes.h @@ -30,6 +30,9 @@ struct DialPreviewInfo { uint32_t imgId; uint32_t offset; uint8_t capability; + uint32_t uuid; + char protocolVersion[DIAL_VERSION_MAX_LEN]; + char watchVersion[DIAL_VERSION_MAX_LEN]; }; struct DialRect { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index 3b3390499..05a667c14 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -28,6 +28,7 @@ #include "PullUpDownView.h" #include "components/ui_cross_view.h" #include "SetCardModel.h" +#include "VideoCard.h" namespace OHOS { class MainPresenterSample; @@ -43,6 +44,9 @@ public: UICardPage *InitActivityPage(void); UICardPage *InitCompassPage(void); UICardPage *InitMusicPlayerPage(void); + UICardPage *InitVideoCardPage1(void); + UICardPage *InitVideoCardPage2(void); + UICardPage *InitVideoCardPage3(void); void AnimatorStart(int pageIndex); void AnimatorStop(void); CardId GetHorCurrentCard() const; @@ -53,6 +57,9 @@ public: UICardPage* GetViewById(int16_t id) const { + if (id >= MAX_CARD) { + return nullptr; + } return recordCard[id]; } @@ -64,9 +71,8 @@ public: } void SwitchToCard(uint8_t cardId, bool loadAdjacent = true); bool IsMainClockPage(void); - void SetDragFg(bool continFg); - bool GetDragFg(void); void SetPage(int16_t page, bool loadAdjacent = true); + void ReloadWatchFace(); private: PullUpDownView *dropDownView{nullptr}; @@ -81,6 +87,9 @@ private: bool pageStatus[MAX_CARD]{false}; UICrossView *mainSwipeGroup{nullptr}; ZoomEffect* callback{nullptr}; + VideoCard *videoCard1{nullptr}; + VideoCard *videoCard2{nullptr}; + VideoCard *videoCard3{nullptr}; bool HorizontalViewInit(void); void VerticalViewInit(void); @@ -88,6 +97,7 @@ private: void HorViewLoad(void); UICardPage *InitWatchOffDial(DialSetting &setting); UICardPage *InitWatchDial(DialSetting &setting); + UICardPage *InitVideoCardPage(const std::string &video, const std::string &preview); }; } // namespace OHOS #endif // MAIN_VIEW_SAMPLE_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialArcLabelView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialArcLabelView.h index d3ad91ee2..43d0dd217 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialArcLabelView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialArcLabelView.h @@ -8,9 +8,10 @@ #include #include "DialView.h" #include "components/ui_arc_label.h" +#include "font/font_global_manager.h" namespace OHOS { -class DialArcLabelView : public UIArcLabel, public DialView { +class DialArcLabelView : public UIArcLabel, public DialView, public FontGlobalManager::LangChangeListener { public: DialArcLabelView(); ~DialArcLabelView() override; @@ -20,12 +21,15 @@ public: void HandleTextData(const std::string* data, uint16_t num) override; void HandleFloatData(const float* data, uint16_t num) override; void HandleFloatData(float data) override; + void SetLang(uint8_t lang); + void OnLangChange(uint8_t langId) override; private: void SetTextWithWildcardInner(const char* text); static const uint8_t MAX_BUF_SIZE = 255; char* text_ = nullptr; char dstBuf_[MAX_BUF_SIZE] = {0}; + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; }; } #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDataBase.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDataBase.h index 9a695b91b..d9bc68b3c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDataBase.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDataBase.h @@ -30,10 +30,17 @@ enum class DialDataType { DATA_TYPE_TIME_MONTH, DATA_TYPE_TIME_YEAR, - DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff, + DATA_TYPE_SWIVEL_GEAR_ONE = 20, + DATA_TYPE_SWIVEL_GEAR_TWO, + DATA_TYPE_SWIVEL_GEAR_THREE, + DATA_TYPE_SWIVEL_GEAR_FOUR, + DATA_TYPE_SWIVEL_GEAR_FIVE, + DATA_TYPE_SWIVEL_GEAR_SIX, - DATA_TYPE_TEXT_BASE = 0x4fff, + DATA_TYPE_TEXT_BASE = 0x2000, - DATA_TYPE_MAX = 0x7fff, + DATA_TYPE_MULTI_FLOAT_BASE = 0x4000, + + DATA_TYPE_MAX = 0x6000 }; #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h index 2817eabc9..5b3249662 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialDigitalImgView.h @@ -7,6 +7,7 @@ #include #include "DialView.h" +#include "DialTimePublisher.h" #include "components/ui_image_view.h" #include "gfx_utils/graphic_math.h" #include "components/ui_view_group.h" @@ -19,7 +20,7 @@ enum class ImgAlign { RIGHT, }; -class DialDigitalImgView : public UIImageView, public DialView { +class DialDigitalImgView : public UIImageView, public DialView, public DialTimePublisher::TimeChangeListener { public: DialDigitalImgView(); ~DialDigitalImgView() override; @@ -35,6 +36,7 @@ public: void SetAlignPos(Point pos); void SetDecimalPrecision(uint8_t precision); void SetParent(UIViewGroup* parent); + void OnTimeUpdate(const struct tm &curTime) override; private: void SetNumImg(UIImageView* img, const ImageInfo *info); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialLabelView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialLabelView.h index c5513132a..6e9f2a830 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialLabelView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialLabelView.h @@ -8,9 +8,10 @@ #include #include "DialView.h" #include "components/ui_label.h" +#include "font/font_global_manager.h" namespace OHOS { -class DialLabelView : public UILabel, public DialView { +class DialLabelView : public UILabel, public DialView, public FontGlobalManager::LangChangeListener { public: DialLabelView(); ~DialLabelView() override; @@ -20,12 +21,15 @@ public: void HandleTextData(const std::string* data, uint16_t num) override; void HandleFloatData(const float* data, uint16_t num) override; void HandleFloatData(float data) override; + void SetLang(uint8_t lang); + void OnLangChange(uint8_t langId) override; private: void SetTextWithWildcardInner(const char* text); static const uint8_t MAX_BUF_SIZE = 255; char* text_ = nullptr; char dstBuf_[MAX_BUF_SIZE] = {0}; + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; }; } #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialModelTime.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialModelTime.h index 7da252b40..43cd8b08d 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialModelTime.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialModelTime.h @@ -9,19 +9,29 @@ #define DIAL_MODEL_TIME_H #include "DialBaseModel.h" +#include "DialTimePublisher.h" +#include "gfx_utils/list.h" namespace OHOS { -class DialModelTime : public DialBaseModel { +class DialModelTime : public DialBaseModel, public DialTimePublisher { public: - DialModelTime() {} - ~DialModelTime() override {} + DialModelTime() + { + DialModelTime::SetPublisher(dynamic_cast(this)); + } + ~DialModelTime() override + { + listeners_.Clear(); + } static DialModelTime* GetInstance() { static DialModelTime instance; return &instance; } bool GetDialFloatData(DialDataType& type, float& out) override; - void UpdateTime(); + void UpdateTime() override; + void Register(TimeChangeListener* listener) override; + void Unregister(TimeChangeListener* listener) override; private: struct tm *tblock_; @@ -29,6 +39,7 @@ private: uint16_t angleM_ = 0; uint16_t angleS_ = 0; float angleMS_ = 0; + List listeners_; }; } #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOHDataType.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOHDataType.h new file mode 100644 index 000000000..83f8f0fc8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOHDataType.h @@ -0,0 +1,189 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialOHDataType + * Author: + * Create: 2025-02-15 + */ + +#ifndef DIAL_OH_DATATYPE_H +#define DIAL_OH_DATATYPE_H + +#include +#include "DialDataBase.h" + +namespace OHOS { +enum class DialOHDataType : int16_t { + CLOCK = 1, + CLOCK_HIGH_BIT = 2, + CLOCK_LOW_BIT = 3, + CLOCK_RATIO_12 = 4, + CLOCK_RATIO_24 = 5, + MINUTES = 6, + MINUTES_HIGH_BIT = 7, + MINUTES_LOW_BIT = 8, + MINUTES_RATIO = 9, + SECONDS = 10, + SECONDS_HIGH_BIT = 11, + SECONDS_LOW_BIT = 12, + SECONDS_RATIO = 13, + AM_PM = 14, + AMPM_TEXT = 15, + HOUR_MODE = 16, + PREVIOUS_HOUR = 17, + NEXT_HOUR = 18, + CLOCK_ANGLE = 19, + MINUTE_ANGLE = 20, + SECONDS_ANGLE = 21, + MILLISECOND_ANGLE = 22, + PREVIOUS_SECOND = 25, + NEXT_SECOND = 26, + PREVIOUS_SECOND_PREVIOUS_SECOND = 27, + PREVIOUS_MINUTE = 28, + NEXT_MINUTE = 29, + DUAL_TIME_ZONE_CLOCK = 30, + DUAL_TIME_ZONE_CLOCK_HIGH_BIT = 31, + DUAL_TIME_ZONE_CLOCK_LOW_BIT = 32, + DUAL_TIME_ZONE_CLOCK_RATIO_12 = 33, + DUAL_TIME_ZONE_CLOCK_RATIO_24 = 34, + DUAL_TIME_ZONE_MINUTES = 35, + DUAL_TIME_ZONE_MINUTES_HIGH_BIT = 36, + DUAL_TIME_ZONE_MINUTES_LOW_BIT = 37, + DUAL_TIME_ZONE_MINUTES_RATIO = 38, + DUAL_TIME_ZONE_ABBREVIATION_TEXT = 39, + DUAL_TIME_ZONE_TIME_MINUTE_TEXT = 40, + DUAL_TIME_ZONE_AMPM = 41, + DUAL_TIME_ZONE_AM_PM_TEXT = 42, + SUNRISE_SUNSET_PICTURE_SELECTION = 50, + SUNRISE_SUNSET_CLOCK_HIGH_BIT = 51, + SUNRISE_SUNSET_CLOCK_LOW_BIT = 52, + SUNRISE_SUNSET_MINUTES_HIGH_BIT = 53, + SUNRISE_SUNSET_MINUTES_LOW_BIT = 54, + SUNRISE_TEXT = 55, + SUNSET_TEXT = 56, + MOONRISE_TEXT = 60, + MOONSET_TEXT = 61, + DATE = 70, + DATE_HIGH_BIT = 71, + DATE_LOW_BIT = 72, + DATE_OCCUPIES_31_DAYS_RATIO = 73, + YESTERDAY = 74, + YESTERDAY_DATE_HIGH_BIT = 75, + YESTERDAY_DATE_LOW_BIT = 76, + TOMORROW = 77, + TOMORROW_DATE_HIGH_BIT = 78, + TOMORROW_DATE_LOW_BIT = 79, + MONTH_DATA = 80, + MONTH = 81, + MONTH_TEXT = 82, + WEEK_DATA = 83, + WEEK_RATIO = 84, + WEEK_TEXT = 85, + TWELVE_DIVISIONS = 86, + LUNAR_PHASE = 87, + PREVIOUS_MONTH = 88, + NEXT_MONTH = 89, + LUNAR_MONTH = 90, + LUNAR_DATE_HIGH_BIT = 91, + LUNAR_DATE_LOW_BIT = 92, + CHARGE = 100, + CHARGE_ENUMERATION = 102, + CHARGE_STATUS_ENUMERATION = 103, + CHARGE_RATIO = 104, + CHARGING_STATUS = 105, + STEPS = 110, + STEPS_UNIT_DIGIT = 111, + STEPS_TENS_DIGIT = 112, + STEPS_HUNDRED_DIGIT = 113, + STEPS_THOUSAND_DIGIT = 114, + STEPS_TEN_THOUSAND_DIGIT = 115, + STEPS_TARGET_ACHIEVEMENT_RATE = 116, + STEPS_TARGET_PROGRESS_ENUMERATION = 117, + CALORIES = 120, + CALORIES_RATIO = 121, + CALORIES_TARGET_PROGRESS_ENUMERATION = 122, + HEART_RATE = 130, + MAXIMUM_HEART_RATE = 131, + MINIMUM_HEART_RATE = 132, + HEART_RATE_RANGE = 133, + HEART_RATE_RATIO = 134, + STRESS = 140, + STRESS_RATIO = 141, + STRESS_LEVEL_TYPE = 142, + MODERATE_TO_VIGOROUS_INTENSITY_TIME = 150, + MODERATE_TO_VIGOROUS_INTENSITY_TIME_RATIO = 151, + STANDING_TIMES = 152, + STANDING_TIMES_RATIO = 153, + MAXIMUM_OXYGEN_UPTAKE = 160, + MAXIMUM_OXYGEN_UPTAKE_RATIO = 161, + SLEEP_TEXT = 165, + SLEEP_RATIO = 166, + SLEEP_TARGET_ACHIEVEMENT_RATE_ENUMERATION = 167, + TEMPERATURE = 170, + HIGHEST_TEMPERATURE = 171, + LOWEST_TEMPERATURE = 172, + CURRENT_TEMPERATURE_MINUS_ONE = 173, + CURRENT_TEMPERATURE_PLUS_ONE = 174, + TEMPERATURE_TYPE = 175, + WEATHER_TYPE = 176, + TEMPERATURE_RATIO = 177, + ATMOSPHERIC_PRESSURE = 180, + ATMOSPHERIC_PRESSURE_RATIO = 181, + AIR_QUALITY_INDEX = 182, + AIR_QUALITY_INDEX_LEVEL = 183, + AIR_QUALITY_INDEX_RATIO = 184, + ELEVATION = 190, + ELEVATION_HEIGHT_DATA = 191, + ELEVATION_HEIGHT_UNIT = 192, + HEIGHT_RATIO = 193, + DISTANCE_TEXT = 194, + DISTANCE_DATA = 195, + DISTANCE_UNIT = 196, + DISTANCE_TARGET_PROGRESS = 197, + HIGH_TIDE_TIME_TEXT = 200, + LOW_TIDE_TIME_TEXT = 201, + BLE_CONNECTION_STATUS = 210, + BT_CONNECTION_STATUS = 211, + BLOOD_OXYGEN = 220, + SYSTOLIC_BLOOD_PRESSURE = 221, + DIASTOLIC_BLOOD_PRESSURE = 222, + DUAL_LANGUAGE_SYSTEM = 230, + SWIVEL_GEAR_POSITIVE = (1 << 12) + 20, // private data, clockwise + SWIVEL_GEAR_NEGATIVE, // counterclockwise +}; // enum class DialOHDataType + +struct HashOHDataType { + size_t operator()(DialOHDataType data) const + { + return std::hash()(static_cast(data)); + } +}; + +const std::unordered_map g_bindDataConverter = { + {DialOHDataType::CLOCK, DialDataType::DATA_TYPE_TIME_HOUR}, + {DialOHDataType::MINUTES, DialDataType::DATA_TYPE_TIME_MINUTE}, + {DialOHDataType::SECONDS, DialDataType::DATA_TYPE_TIME_SECOND}, + {DialOHDataType::MILLISECOND_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_MS}, + {DialOHDataType::DATE, DialDataType::DATA_TYPE_TIME_DATE}, + {DialOHDataType::WEEK_DATA, DialDataType::DATA_TYPE_TIME_WEEK}, + {DialOHDataType::CHARGE, DialDataType::DATA_TYPE_POWER}, + {DialOHDataType::STEPS, DialDataType::DATA_TYPE_STEPS}, + {DialOHDataType::CALORIES, DialDataType::DATA_TYPE_CALORIE}, + {DialOHDataType::HEART_RATE, DialDataType::DATA_TYPE_HEART_RATE}, + {DialOHDataType::STRESS, DialDataType::DATA_TYPE_PRESSURE}, + {DialOHDataType::TEMPERATURE, DialDataType::DATA_TYPE_TEMPERATURE}, + {DialOHDataType::ELEVATION, DialDataType::DATA_TYPE_AILTITUDE}, + {DialOHDataType::AIR_QUALITY_INDEX, DialDataType::DATA_TYPE_PM25}, + {DialOHDataType::CLOCK_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_H}, + {DialOHDataType::MINUTE_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_M}, + {DialOHDataType::SECONDS_ANGLE, DialDataType::DATA_TYPE_CLOCK_ANGLE_S}, + {DialOHDataType::MONTH, DialDataType::DATA_TYPE_TIME_MONTH}, + {DialOHDataType::SWIVEL_GEAR_POSITIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_ONE}, + {DialOHDataType::SWIVEL_GEAR_POSITIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_FOUR}, + {DialOHDataType::SWIVEL_GEAR_POSITIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_SIX}, + {DialOHDataType::SWIVEL_GEAR_NEGATIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_TWO}, + {DialOHDataType::SWIVEL_GEAR_NEGATIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_THREE}, + {DialOHDataType::SWIVEL_GEAR_NEGATIVE, DialDataType::DATA_TYPE_SWIVEL_GEAR_FIVE}, +}; +} // namespace OHOS + +#endif // DIAL_OH_DATATYPE_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOHSliceId.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOHSliceId.h new file mode 100644 index 000000000..f19784a3b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOHSliceId.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialOHSliceId + * Author: + * Create: 2025-02-15 + */ + + +#ifndef DIALOHSLICEID_H +#define DIALOHSLICEID_H + +#include +#include "AppViewIDs.h" + +namespace OHOS { +enum class DialOHSliceId : uint16_t { + DUAL_TIME_ZONES = 0, + HEART_RATE = 1, + STANDING_TIMES = 2, + STRESS = 3, + MODERATE_TO_VIGOROUS_INTENSITY_TIME = 4, + WEATHER = 5, + AIR_QUALITY_ONLY_CHINA = 6, + ATMOSPHERIC_PRESSURE = 7, + ELEVATION_HEIGHT = 8, + SUNRISE_SUNSET_TIME = 9, + DISTANCE = 10, + SLEEP = 11, + EXERCISE = 12, + PAYMENT_ONLY_CHINA = 13, + ALARM_CLOCK = 14, + STOPWATCH = 15, + TIMER = 16, + EXERCISE_RECORD = 17, + TRAINING_STATUS = 18, + ACTIVITY_RECORD = 19, + AEROBIC_EXERCISE = 20, + CONTACTS = 21, + MUSIC = 22, + COMPASS = 23, + CALL_LOG = 24, + BLOOD_OXYGEN_SATURATION_ONLY_CHINA = 25, + ULTRAVIOLET_RAYS_ONLY_CHINA = 26, + PHASE_OF_THE_MOON = 27, + STAIR_CLIMBING = 28, + BLOOD_PRESSURE = 29, + MESSAGE_LIST = 30, + DIAL = 31, + AUDIO_SWITCH = 32, +}; // enum class DialOHSliceId + +struct HashOhSliceId { + size_t operator()(DialOHSliceId id) const + { + return std::hash()(static_cast(id)); + } +}; + +const std::unordered_map g_sliceIdConverter = { + {DialOHSliceId::COMPASS, VIEW_COMPASS}, + {DialOHSliceId::DIAL, VIEW_CALLER_SAMPLE}, + {DialOHSliceId::ALARM_CLOCK, VIEW_MAIN_ALARM}, + {DialOHSliceId::AUDIO_SWITCH, VIEW_VOLUME}, +}; +} // namespace OHOS +#endif // DIALOHSLICEID_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOptionImgView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOptionImgView.h index 4fa2fbd65..dd08a9d6b 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOptionImgView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialOptionImgView.h @@ -7,11 +7,16 @@ #include #include "DialView.h" +#include "DialTimePublisher.h" #include "components/ui_image_view.h" +#include "font/font_global_manager.h" namespace OHOS { -class DialOptionImgView : public UIImageView, public DialView { +class DialOptionImgView : public UIImageView, + public DialView, + public FontGlobalManager::LangChangeListener, + public DialTimePublisher::TimeChangeListener { public: DialOptionImgView(); ~DialOptionImgView() override; @@ -20,10 +25,19 @@ public: bool SetOptionRes(const ImageInfo* src, uint16_t num); + void SetLang(uint8_t lang); + + void OnLangChange(uint8_t langId) override; + + void OnTimeUpdate(const struct tm &curTime) override; + private: ImageInfo* info_ = nullptr; uint16_t infoNum_ = 0; int16_t selected_ = -1; + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; + bool langVisible_ = true; + bool timeVisible_ = true; }; } #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialSequenceContainer.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialSequenceContainer.h new file mode 100644 index 000000000..f692d1f3b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialSequenceContainer.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialSequenceContainer + * Author: + * Create: 2025-03-05 + */ + +#ifndef DIAL_SEQUENCE_CONTAINER_H +#define DIAL_SEQUENCE_CONTAINER_H +#include "components/ui_view_group.h" +#include "components/ui_image_animator.h" + +namespace OHOS { +class DialSequenceContainer : public UIViewGroup, public UIImageAnimatorView::AnimatorStopListener { +public: + DialSequenceContainer(); + ~DialSequenceContainer() override; + DialSequenceContainer(const DialSequenceContainer&) = delete; + DialSequenceContainer& operator=(const DialSequenceContainer&) = delete; + bool AddSequenceRes(uint16_t interval, bool repeat, const ImageAnimatorInfo *imgSrc, uint8_t imgNum); + bool OnClickEvent(const ClickEvent& event) override; + void Start(); + void Stop(); + void Pause(); + void Resume(); + void OnAnimatorStop(UIView& view) override; + +private: + void UpdateCurrentView(); + UIImageAnimatorView *repeatView_ = nullptr; + UIImageAnimatorView *nonCycleView_[3]; // 3: max seqImg num + // if curView_ is not null, curView_ must be added into parent. + UIImageAnimatorView *curView_ = nullptr; + uint8_t nonCycleNum_ = 0; + uint8_t loop_ = 0; + bool isClick_ = false; +}; // class DialSequenceContainer +} // namespace OHOS +#endif // DIAL_SEQUENCE_CONTAINER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialStaticImgView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialStaticImgView.h index e1b48a0a6..733c5ed7a 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialStaticImgView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialStaticImgView.h @@ -6,12 +6,29 @@ #define DIAL_STATIC_IMG_VIEW_H #include "components/ui_image_view.h" +#include "font/font_global_manager.h" +#include "DialTimePublisher.h" namespace OHOS { -class DialStaticImgView : public UIImageView { +class DialStaticImgView : public UIImageView, + public FontGlobalManager::LangChangeListener, + public DialTimePublisher::TimeChangeListener { public: DialStaticImgView(); ~DialStaticImgView() override; + void SetLang(uint8_t lang); + void OnLangChange(uint8_t langId) override; + bool SetImgs(const ImageInfo* src, uint8_t num); + bool OnClickEvent(const ClickEvent& event) override; + void OnTimeUpdate(const struct tm &curTime) override; + +private: + uint8_t language_ = FontGlobalManager::INVALID_LANG_ID; + ImageInfo* info_ = nullptr; + uint8_t infoNum_ = 0; + int16_t selected_ = -1; + bool langVisible_ = true; + bool timeVisible_ = true; }; } #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialTimePublisher.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialTimePublisher.h new file mode 100644 index 000000000..fcdb80cb3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialTimePublisher.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialTimePublisher + * Author: + * Create: 2025-03-04 + */ + +#ifndef DIAL_TIME_PUBLISHER_H +#define DIAL_TIME_PUBLISHER_H +#include +#include + +namespace OHOS { +class DialTimePublisher { +public: + struct TimeInterval { + uint8_t start; + uint8_t end; + }; + class TimeChangeListener { + public: + virtual void OnTimeUpdate(const struct tm &curTime) = 0; + void SetTimeInervals(TimeInterval *intervals, uint8_t num); + bool IsInTimeInterval(const struct tm &curTime); + TimeChangeListener(const TimeChangeListener&) = delete; + TimeChangeListener& operator=(const TimeChangeListener&) = delete; + TimeChangeListener(); + virtual ~TimeChangeListener(); + private: + TimeInterval *intervals_ = nullptr; + uint8_t num_ = 0; + }; + + virtual void Register(TimeChangeListener *listener) = 0; + virtual void Unregister(TimeChangeListener *listener) = 0; + virtual void UpdateTime() = 0; + static void SetPublisher(DialTimePublisher *publisher); + static DialTimePublisher *GetPublisher(); + virtual ~DialTimePublisher() {} + +private: + static DialTimePublisher *publisher_; +}; // class DialTimePublisher +} // namespace OHOS +#endif // DIAL_TIME_PUBLISHER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialViewContainer.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialViewContainer.h new file mode 100644 index 000000000..0dd421c44 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialViewContainer.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialViewContainer + * Author: + * Create: 2025-02-06 + */ + +#ifndef DIAL_VIEW_CONTAINER_H +#define DIAL_VIEW_CONTAINER_H +#include "components/ui_view_group.h" +#include "gfx_utils/list.h" +#include "dial/DialView.h" +#include "dial/DialDataBase.h" + +namespace OHOS { +class ContainerInterface { +public: + virtual void AddView(UIView* view) = 0; + + virtual void AddView(DialDataType type, DialView* view, bool isPeriodic) = 0; + + virtual ~ContainerInterface() {} +}; + +class DialViewContainer : public UIViewGroup, public ContainerInterface { +public: + struct SubView { + UIView *view; + DialView *dialView; + DialDataType type; + bool isPeriodic; + }; + DialViewContainer(uint8_t dialviewNum, uint16_t dataSize) : + dialViewNum_(dialviewNum), dataSize_(dataSize) + { + SetTouchable(true); + } + DialViewContainer() {} + ~DialViewContainer() override; + DialViewContainer(const DialViewContainer&) = delete; + DialViewContainer& operator=(const DialViewContainer&) = delete; + + uint8_t GetDialviewNum() const + { + return dialViewNum_; + } + + uint16_t GetDataSize() const + { + return dataSize_; + } + + void AddView(UIView* view) override; + + void AddView(DialDataType type, DialView* view, bool isPeriodic) override; + + ListNode* Begin() + { + return dialViews_.Begin(); + } + + const ListNode* End() + { + return dialViews_.End(); + } + + bool HasInvalidBindData() const + { + return hasInvalidBindData_; + } + + bool RemoveSubView(uint8_t index, SubView &subView); + + bool IsInvalidateBindData(uint8_t index); + +private: + uint8_t dialViewNum_; + uint16_t dataSize_; + List dialViews_; + bool hasInvalidBindData_ = false; +}; // class DialViewContainer +} // namesapce OHOS +#endif // DIAL_VIEW_CONTAINER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialViewGroup.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialViewGroup.h index 76ada9f87..8c1ed7400 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialViewGroup.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialViewGroup.h @@ -8,16 +8,21 @@ #include #include "DialDataBase.h" #include "components/ui_view_group.h" +#include "components/ui_image_animator.h" +#include "components/ui_label.h" #include "OnDialDataUpdateListener.h" #include "components/ui_card_page.h" #include "components/ui_kaleidoscope_view.h" #include "gfx_utils/list.h" +#include "gfx_utils/vector.h" #include "DialView.h" #include "DialVideoView.h" #include "DialBinTypesV2.h" +#include "DialViewContainer.h" +#include "DialSequenceContainer.h" namespace OHOS { -class DialViewGroup : public UICardPage, public OnDialDataUpdateListener { +class DialViewGroup : public UICardPage, public OnDialDataUpdateListener, public ContainerInterface { public: DialViewGroup(); ~DialViewGroup() override; @@ -30,12 +35,12 @@ public: /** * @brief Add a view which binds with data of a specific type and could be updated periodically. */ - void AddView(DialDataType type, DialView* view, bool isPeriodic = false); + void AddView(DialDataType type, DialView* view, bool isPeriodic) override; /** - * @brief Add a view. If the view is DialVideoView, the second parameter should be true. + * @brief Add a view. */ - void AddView(UIView* view, bool isDialVideoView = false); + void AddView(UIView* view) override; /** * @brief Add a click rect. When the rect is clicked, it will start a js app with the given bundleName. @@ -112,13 +117,36 @@ public: */ void OnActive(void) override; - void OnInactive() override; + /** + * @brief This function is invoked when the function SetHorCurrentPage() is called. + */ + void OnInactive(void) override; + + /** + * @brief This function is invoked when SetVerCurrentPage is called and horizontal page is covered. + */ + void OnCovered(void) override; + + /** + * @brief This function is invoked when SetVerCurrentPage is called and horizontal page is not covered. + */ + void OnUncovered(void) override; + + void OnPause() override; MediaVideoPlay* GetVideoPlay(); private: void ProcessData(DialDataType type, DialView* view); - std::unordered_map dataTypeMap_; + void DoStop(void); + void DoStart(void); + void DoPause(void); + void RecordSpecial(UIView *view); + void RecordBindData(DialDataType type, DialView* view, bool isPeriodic); + void ClearViews(); + using Views = Graphic::Vector; + std::unordered_map dataTypeMap_; + Graphic::Vector viewsMemPool_; List periodicUpdateTypes_; List passiveUpdateTypes_; List dialViews_; @@ -141,6 +169,12 @@ private: List dialClicks_; void ClearDial(); + + void SetLableAnimatorState(uint8_t state); + void SetImgAnimatorState(uint8_t state); + List rollingLabelList_; + List imgAnimList_; + List seqList_; }; } #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h index 33bedbe49..30c1d1c31 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/ModelDialDataFactory.h @@ -11,6 +11,7 @@ #include #include "DialBaseModel.h" #include "DialDataBase.h" +#include "DialOHDataType.h" #include "ModelDialDataFactory.h" namespace OHOS { @@ -30,6 +31,8 @@ public: models_[static_cast(type)] = model; } + bool IsOHBindDataExist(DialOHDataType type) const; + bool IsBindDataExist(DialDataType type) const; bool RegisterDialDataListener(DialDataType type, OnDialDataUpdateListener* listener); bool UnRegisterDialDataListener(DialDataType type); bool GetDialTextData(DialDataType& type, std::string*& out, int16_t& strNum); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/WatchInterface.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/WatchInterface.h new file mode 100644 index 000000000..2938ed4a0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/WatchInterface.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: WatchInterface + * Author: + * Create: 2025-03-17 + */ + +#ifndef WATCH_INTERFACE_H +#define WATCH_INTERFACE_H +#include +#include "format_type.h" +#include "dial_market.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get all watch face information + * @param[out] info Pointer to store the watch face information + * @param[out] num Pointer to store the number of watch faces + * @param[in] maxCnt Maximum number of watch faces to retrieve + * @return bool Returns true if successful, false otherwise + */ +bool GetAllWatchFaceInfo(watch_dial_info *info, uint8_t *num, uint8_t maxCnt); + +/** + * @brief Get information of a specific watch face by UUID + * @param[in] uuid Unique identifier of the watch face + * @param[out] watch Pointer to store the watch face information + * @return bool Returns true if successful, false otherwise + */ +bool GetWatchFaceInfo(uint32_t uuid, watch_dial_info *watch); + +/** + * @brief Get the capability set of the watch + * @param[out] capability Pointer to store the watch capability information + * @return bool Returns true if successful, false otherwise + */ +bool GetWatchCapability(watch_dev_cap_info *capability); + +/** + * @brief Get system information + * @param[out] sysInfo Pointer to store the system information + * @return bool Returns true if successful, false otherwise + */ +bool GetWatchSystemInfo(watch_sys_info *sysInfo); + +/** + * @brief Get information of the currently active watch face + * @param[out] watch Pointer to store the watch face information + * @return bool Returns true if successful, false otherwise + */ +bool GetCurrentWatchFaceInfo(watch_dial_info *watch); + +/** + * @brief Set the currently active watch face by UUID + * @param[in] uuid Unique identifier of the watch face to set as active + * @return bool Returns true if successful, false otherwise + */ +bool SetCurrentWatchFace(uint32_t uuid); + +/** + * @brief Uninstall a watch face by UUID + * @param[in] uuid Unique identifier of the watch face to uninstall + * @return bool Returns true if successful, false otherwise + * @note If the UUID corresponds to the currently active watch face, it will switch to the default watch face + */ +bool UninstallWatch(uint32_t uuid); + +/** + * @brief Install a watch face from a specified path + * @param[in] path Path to the watch face file + * @param[out] uuid Pointer to store the unique identifier of the installed watch face + * @return bool Returns true if successful, false otherwise + * @note If a watch face with the same UUID already exists, it will be replaced + */ +bool InstallWatch(const char *path, uint32_t *uuid); + +#ifdef __cplusplus +} +#endif +#endif // WATCH_INTERFACE_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainModel.cpp index ac3c411ed..dc5b9e350 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainModel.cpp @@ -21,6 +21,9 @@ namespace OHOS { { COMPASS, PNG_SET_CARD_COMPASS }, { ACTIVITY, PNG_SET_CARD_ACTIVITY }, { MUSIC_PLAYER, PNG_SET_CARD_PLAYER }, + { VIDEO_CARD1, PNG_SET_CARD_VIDEO }, + { VIDEO_CARD2, PNG_SET_CARD_VIDEO }, + { VIDEO_CARD3, PNG_SET_CARD_VIDEO }, }; const DialInfo dialInfoMap[] = { @@ -82,7 +85,10 @@ namespace OHOS { if (index >= CARD_SETTING_COUNT_MAX) { break; } - cardSettings[index++] = (CardId)atoi(setValue); + int val = atoi(setValue); + if (val >= 0 && val < CARD_SETTING_COUNT_MAX) { + cardSettings[index++] = static_cast(val); + } setValue = strtok_s(nullptr, ",", &setBuffer); } cardSettingCount = index; @@ -93,6 +99,9 @@ namespace OHOS { cardSettings[index++] = COMPASS; cardSettings[index++] = ACTIVITY; cardSettings[index++] = MUSIC_PLAYER; + cardSettings[index++] = VIDEO_CARD1; + cardSettings[index++] = VIDEO_CARD2; + cardSettings[index++] = VIDEO_CARD3; cardSettingCount = index; } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp index c0d7def8e..5a0f085c7 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp @@ -81,6 +81,11 @@ void MainPresenterSample::OnPause() PageTransitionMgr::GetInstance().SaveSlideBackSnapShotIfNecessary(watchFace); watchFace->SetOpaScale(opaScale); + uint8_t curCardId = view_->GetHorCurrentCard(); + UICardPage *card = view_->GetViewById(curCardId); + if (card != nullptr) { + card->OnPause(); + } mainPresenterState_ = MainPresenterState::PAUSE; } @@ -173,6 +178,7 @@ void MainPresenterSample::SetPage(int8_t id, bool loadAdjacent) void MainPresenterSample::SetTaskPeroid(CardId cardId) { + SetLastRun(0); if (cardId == COMPASS) { SetPeriod(DEFAULT_TASK_PERIOD); } else if (cardId == WATCH_FACE) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index 3784f1c90..b6c882643 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -7,6 +7,7 @@ #include "wearable_log.h" #include "MainViewSample.h" #include "graphic_service.h" +#include "common/image_cache_manager.h" namespace OHOS { static MainViewSample *g_pMainView = nullptr; @@ -28,6 +29,9 @@ static const MainViewMapper CardMapper[] = { {COMPASS, &MainViewSample::InitCompassPage}, {ACTIVITY, &MainViewSample::InitActivityPage}, {MUSIC_PLAYER, &MainViewSample::InitMusicPlayerPage}, + {VIDEO_CARD1, &MainViewSample::InitVideoCardPage1}, + {VIDEO_CARD2, &MainViewSample::InitVideoCardPage2}, + {VIDEO_CARD3, &MainViewSample::InitVideoCardPage3}, }; MainViewSample::MainViewSample() @@ -66,6 +70,29 @@ MainViewSample::~MainViewSample() playersView = nullptr; } + bool hasVideo = false; + if (videoCard1 != nullptr) { + hasVideo = true; + delete videoCard1; + videoCard1 = nullptr; + } + + if (videoCard2 != nullptr) { + hasVideo = true; + delete videoCard2; + videoCard2 = nullptr; + } + + if (videoCard3 != nullptr) { + hasVideo = true; + delete videoCard3; + videoCard3 = nullptr; + } + + if (hasVideo) { + ImageCacheManager::GetInstance().UnloadSingleRes(PNG_PREVIEW_CARD_VIDEO); + } + if (heartRateView != nullptr) { delete heartRateView; heartRateView = nullptr; @@ -107,9 +134,6 @@ MainViewSample *MainViewSample::GetInstance(void) void MainViewSample::OnStart() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStart"); - View::OnStart(); - mainSwipeGroup = new UICrossView(); if (mainSwipeGroup == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSwipeGroup new fail"); @@ -311,6 +335,36 @@ UICardPage *MainViewSample::InitMusicPlayerPage(void) return playersView; } +UICardPage *MainViewSample::InitVideoCardPage1(void) +{ + videoCard1 = dynamic_cast(InitVideoCardPage(APP_VIDEO_PATH"/noaudio_05.mp4", PNG_PREVIEW_CARD_VIDEO)); + return videoCard1; +} + +UICardPage *MainViewSample::InitVideoCardPage2(void) +{ + videoCard2 = dynamic_cast(InitVideoCardPage(APP_VIDEO_PATH"/noaudio_05.mp4", PNG_PREVIEW_CARD_VIDEO)); + return videoCard2; +} + +UICardPage *MainViewSample::InitVideoCardPage3(void) +{ + videoCard3 = dynamic_cast(InitVideoCardPage(APP_VIDEO_PATH"/noaudio_05.mp4", PNG_PREVIEW_CARD_VIDEO)); + return videoCard3; +} + +UICardPage *MainViewSample::InitVideoCardPage(const std::string &video, const std::string &preview) +{ + VideoCard *page = new VideoCard; + if (page == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "videocard new fail"); + return nullptr; + } + page->SetFilePath(video); + page->SetPreviewFile(preview); + return page; +} + void MainViewSample::SetPage(int16_t page, bool loadAdjacent) { if (mainSwipeGroup != nullptr) { @@ -320,10 +374,37 @@ void MainViewSample::SetPage(int16_t page, bool loadAdjacent) if (presenter_ != nullptr) { CardId *cardSettings = presenter_->GetCardSettings(); /* page 与CardId 没有对应关系,需要一次转换 */ - presenter_->SetTaskPeroid(cardSettings[page]); + CardId id = MAX_CARD; + for (uint8_t i = 0; i < presenter_->GetCardSettingCount(); ++i) { + if (cardSettings[i] < MAX_CARD && recordCard[cardSettings[i]] != nullptr && + recordCard[cardSettings[i]]->GetViewIndex() == page) { + id = cardSettings[i]; + } + } + presenter_->SetTaskPeroid(id); } } +void MainViewSample::ReloadWatchFace() +{ + if (mainSwipeGroup == nullptr) { + return; + } + mainSwipeGroup->Remove(mainClockView, UISwipeView::HORIZONTAL); + + delete mainClockView; + mainClockView = nullptr; + recordCard[WATCH_FACE] = InitWatchFacePage(); + if (recordCard[WATCH_FACE] == nullptr) { + GRAPHIC_LOGE("failed to reload main clock"); + return; + } + mainSwipeGroup->HorInsert(nullptr, mainClockView); + + SwitchToCard(WATCH_FACE); + Draw(); +} + bool MainViewSample::IsMainClockPage(void) { if (mainSwipeGroup->GetCurrentPageId(0) == mainClockView->GetViewIndex() && @@ -339,7 +420,13 @@ CardId MainViewSample::GetHorCurrentCard() const CardId *cardSettings = presenter_->GetCardSettings(); int pageId = mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical /* pageId 与CardId 没有对应关系,需要一次转换 */ - return cardSettings[pageId]; + for (uint8_t i = 0; i < presenter_->GetCardSettingCount(); ++i) { + if (cardSettings[i] < MAX_CARD && recordCard[cardSettings[i]] != nullptr && + recordCard[cardSettings[i]]->GetViewIndex() == pageId) { + return cardSettings[i]; + } + } + return MAX_CARD; } void MainViewSample::SwitchToCard(uint8_t cardId, bool loadAdjacent) @@ -350,5 +437,4 @@ void MainViewSample::SwitchToCard(uint8_t cardId, bool loadAdjacent) SwitchToClockPage(loadAdjacent); } } - -} +} // OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp index 6704a2267..02ce99c31 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialArcLabelView.cpp @@ -129,4 +129,21 @@ void DialArcLabelView::HandleFloatData(float data) } SetTextWithWildcardInner(tempBuf); } + +void DialArcLabelView::SetLang(uint8_t lang) +{ + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); +} + +void DialArcLabelView::OnLangChange(uint8_t langId) +{ + if (language_ == FontGlobalManager::INVALID_LANG_ID) { + SetVisible(true); + } else if (language_ == langId) { + SetVisible(true); + } else { + SetVisible(false); + } +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp index 6d7bb7467..4f316171e 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialDigitalImgView.cpp @@ -74,6 +74,18 @@ void DialDigitalImgView::SetParent(UIViewGroup* parent) parent_ = parent; } +void DialDigitalImgView::OnTimeUpdate(const struct tm &curTime) +{ + bool isVisible = false; + if (IsInTimeInterval(curTime)) { + isVisible = true; + } + for (uint8_t i = 0; i < imgCnt_; ++i) { + imgs_[i]->SetVisible(isVisible); + } + SetVisible(isVisible); +} + void DialDigitalImgView::SetDecimalPrecision(uint8_t precision) { decimalPrecision_ = precision; @@ -208,6 +220,9 @@ bool DialDigitalImgView::CreateImageViews(float data) void DialDigitalImgView::HandleFloatData(float data) { + if (!IsVisible()) { + return; + } if (isValueSet_ && FloatEqual(value_, data)) { return; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialLabelView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialLabelView.cpp index b2e41f5de..40fd07671 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialLabelView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialLabelView.cpp @@ -128,4 +128,21 @@ void DialLabelView::HandleFloatData(float data) } SetTextWithWildcardInner(tempBuf); } + +void DialLabelView::SetLang(uint8_t lang) +{ + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); +} + +void DialLabelView::OnLangChange(uint8_t langId) +{ + if (language_ == FontGlobalManager::INVALID_LANG_ID) { + SetVisible(true); + } else if (language_ == langId) { + SetVisible(true); + } else { + SetVisible(false); + } +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelTime.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelTime.cpp index 2af8cd26d..aa17d850c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelTime.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelTime.cpp @@ -8,6 +8,7 @@ #include "sys/time.h" #include "RegisterDialModel.h" #include "DialModelTime.h" +#include "components/root_view.h" #define REGIST_DIAL_MODULE_ANGLE_H(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_H)(type, func) #define REGIST_DIAL_MODULE_ANGLE_M(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_M)(type, func) @@ -21,6 +22,12 @@ #define REGIST_DIAL_MODULE_WEEK(type, func) static OHOS::RegisterDialModel(REGIST_WEEK)(type, func) #define REGIST_DIAL_MODULE_MOUNTH(type, func) static OHOS::RegisterDialModel(REGIST_MOUNTH)(type, func) #define REGIST_DIAL_MODULE_YEAR(type, func) static OHOS::RegisterDialModel(REGIST_YEAR)(type, func) +#define REGIST_DIAL_MODULE_GEAR_ONE(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_ONE)(type, func) +#define REGIST_DIAL_MODULE_GEAR_TWO(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_TWO)(type, func) +#define REGIST_DIAL_MODULE_GEAR_THREE(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_THREE)(type, func) +#define REGIST_DIAL_MODULE_GEAR_FOUR(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_FOUR)(type, func) +#define REGIST_DIAL_MODULE_GEAR_FIVE(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_FIVE)(type, func) +#define REGIST_DIAL_MODULE_GEAR_SIX(type, func) static OHOS::RegisterDialModel(REGIST_GEAR_SIX)(type, func) REGIST_DIAL_MODULE_ANGLE_H(DialDataType::DATA_TYPE_CLOCK_ANGLE_H, OHOS::DialModelTime::GetInstance()); REGIST_DIAL_MODULE_ANGLE_M(DialDataType::DATA_TYPE_CLOCK_ANGLE_M, OHOS::DialModelTime::GetInstance()); @@ -35,9 +42,15 @@ REGIST_DIAL_MODULE_WEEK(DialDataType::DATA_TYPE_TIME_WEEK, OHOS::DialModelTime:: REGIST_DIAL_MODULE_MOUNTH(DialDataType::DATA_TYPE_TIME_MONTH, OHOS::DialModelTime::GetInstance()); REGIST_DIAL_MODULE_YEAR(DialDataType::DATA_TYPE_TIME_YEAR, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_ONE(DialDataType::DATA_TYPE_SWIVEL_GEAR_ONE, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_TWO(DialDataType::DATA_TYPE_SWIVEL_GEAR_TWO, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_THREE(DialDataType::DATA_TYPE_SWIVEL_GEAR_THREE, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_FOUR(DialDataType::DATA_TYPE_SWIVEL_GEAR_FOUR, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_FIVE(DialDataType::DATA_TYPE_SWIVEL_GEAR_FIVE, OHOS::DialModelTime::GetInstance()); +REGIST_DIAL_MODULE_GEAR_SIX(DialDataType::DATA_TYPE_SWIVEL_GEAR_SIX, OHOS::DialModelTime::GetInstance()); + namespace OHOS { static constexpr int16_t S_MS_US_TRANS = 1000; // 1000: seconds, milliseconds, microsecond transform value -static constexpr uint16_t CIRCLE_IN_DEGREE = 360; // 360: A full rotation: 360 degrees static constexpr uint8_t ONE_MINUTE_IN_SECOND = 60; // 60: 60 seconds per minute static constexpr uint8_t ONE_HOUR_IN_MINUTE = 60; // 60: 60 minutes per hour static constexpr uint8_t HALF_DAY_IN_HOUR = 12; // 60: 12 hours every half day @@ -79,6 +92,45 @@ void DialModelTime::UpdateTime() angleM_ = ConvertHandValueToAngle(tblock_->tm_min, ONE_HOUR_IN_MINUTE, tblock_->tm_sec, ONE_MINUTE_IN_SECOND); angleS_ = ConvertHandValueToAngle(tblock_->tm_sec, ONE_MINUTE_IN_SECOND, 0, 1); angleMS_ = ConvertHandSecondValueToAngle(realMS, S_MS_US_TRANS * ONE_MINUTE_IN_SECOND); + + if (tblock_ == nullptr) { + return; + } + for (ListNode* node = listeners_.Head(); node != listeners_.End(); node = node->next_) { + TimeChangeListener *listener = node->data_; + if (listener != nullptr) { + listener->OnTimeUpdate(*tblock_); + } + } + RootView::GetInstance()->Invalidate(); +} + +void DialModelTime::Register(TimeChangeListener* listener) +{ + if (listener == nullptr) { + return; + } + for (ListNode* node = listeners_.Head(); node != listeners_.End(); node = node->next_) { + TimeChangeListener *tmp = node->data_; + if (tmp == listener) { + return; + } + } + listeners_.PushBack(listener); +} + +void DialModelTime::Unregister(TimeChangeListener* listener) +{ + if (listener == nullptr) { + return; + } + for (ListNode* node = listeners_.Head(); node != listeners_.End(); node = node->next_) { + TimeChangeListener *tmp = node->data_; + if (tmp == listener) { + listeners_.Remove(node); + return; + } + } } bool DialModelTime::GetDialFloatData(DialDataType& type, float& out) @@ -121,6 +173,22 @@ bool DialModelTime::GetDialFloatData(DialDataType& type, float& out) case DialDataType::DATA_TYPE_TIME_SECOND: out = static_cast(tblock_->tm_sec); break; + case DialDataType::DATA_TYPE_SWIVEL_GEAR_TWO: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_THREE: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_FIVE: { + float coeff = 6.0f; // 6.0: coeff + float accleratedAngle = angleMS_ * coeff - floor(angleMS_ * coeff / CIRCLE_IN_DEGREE) * CIRCLE_IN_DEGREE; + out = static_cast(accleratedAngle * -1.0 + CIRCLE_IN_DEGREE); + break; + } + case DialDataType::DATA_TYPE_SWIVEL_GEAR_ONE: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_FOUR: + case DialDataType::DATA_TYPE_SWIVEL_GEAR_SIX: { + float coeff = 6.0f; // 6.0: coeff + float accleratedAngle = angleMS_ * coeff - floor(angleMS_ * coeff / CIRCLE_IN_DEGREE) * CIRCLE_IN_DEGREE; + out = static_cast(accleratedAngle); + break; + } default: return false; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp index 8c78ad49f..980d438cd 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialOptionImgView.cpp @@ -53,4 +53,32 @@ void DialOptionImgView::HandleFloatData(float data) selected_ = selected; SetSrc(&info_[selected_]); } + +void DialOptionImgView::SetLang(uint8_t lang) +{ + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); +} + +void DialOptionImgView::OnLangChange(uint8_t langId) +{ + if (language_ == FontGlobalManager::INVALID_LANG_ID) { + langVisible_ = true; + } else if (language_ == langId) { + langVisible_ = true; + } else { + langVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} + +void DialOptionImgView::OnTimeUpdate(const struct tm &curTime) +{ + if (IsInTimeInterval(curTime)) { + timeVisible_ = true; + } else { + timeVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialSequenceContainer.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialSequenceContainer.cpp new file mode 100644 index 000000000..4024f4696 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialSequenceContainer.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialSequenceContainer + * Author: + * Create: 2025-03-05 + */ + +#include "DialSequenceContainer.h" + +namespace OHOS { +DialSequenceContainer::DialSequenceContainer() +{ + SetTouchable(true); + SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + memset_s(nonCycleView_, sizeof(nonCycleView_), 0, sizeof(nonCycleView_)); +} + +DialSequenceContainer::~DialSequenceContainer() +{ + if (repeatView_ != nullptr) { + delete repeatView_; + repeatView_ = nullptr; + } + + for (uint8_t i = 0; i < nonCycleNum_; ++i) { + delete nonCycleView_[i]; + nonCycleView_[i] = nullptr; + } + nonCycleNum_ = 0; + curView_ = nullptr; +} + +bool DialSequenceContainer::AddSequenceRes(uint16_t interval, bool repeat, + const ImageAnimatorInfo *imgSrc, uint8_t imgNum) +{ + if (imgSrc == nullptr || imgNum == 0) { + return false; + } + + // add animator images to view + if (repeat) { + if (repeatView_ != nullptr) { + GRAPHIC_LOGE("the repeat seq view has existed!"); + return false; + } + repeatView_ = new UIImageAnimatorView; + repeatView_->SetImageAnimatorSrc(imgSrc, imgNum, interval); + repeatView_->SetRepeat(false); + } else { + if (nonCycleNum_ >= sizeof(nonCycleView_) / sizeof(nonCycleView_[0])) { + GRAPHIC_LOGE("non cycle seq views have been exceedeed!"); + return false; + } + nonCycleView_[nonCycleNum_] = new UIImageAnimatorView; + nonCycleView_[nonCycleNum_]->SetImageAnimatorSrc(imgSrc, imgNum, interval); + nonCycleView_[nonCycleNum_]->SetRepeat(false); + ++nonCycleNum_; + } + + // update rect area + Rect rect(GetRelativeRect()); + for (uint8_t i = 0; i < imgNum; ++i) { + rect.JoinRect(rect, + Rect(rect.GetX(), + rect.GetY(), + rect.GetX() + imgSrc[i].width - 1, + rect.GetY() + imgSrc[i].height - 1)); + } + rect.JoinRect(rect, GetRelativeRect()); + SetPosition(rect.GetX(), rect.GetY()); + SetWidth(rect.GetWidth()); + SetHeight(rect.GetHeight()); + Invalidate(); + + return true; +} + +bool DialSequenceContainer::OnClickEvent(const ClickEvent& event) +{ + if (curView_ == nullptr) { + return false; + } + uint8_t curState = curView_->GetState(); + switch (curState) { + case Animator::STOP: { + if (curView_ == repeatView_) { + isClick_ = true; + } else { + UpdateCurrentView(); + Start(); + } + break; + } + case Animator::PAUSE: { + return false; + } + case Animator::RUNNING: + case Animator::START: { + if (curView_ == repeatView_) { + isClick_ = true; + } + break; + } + default: { + GRAPHIC_LOGE("error state"); + } + } + + return UIViewGroup::OnClickEvent(event); +} + +void DialSequenceContainer::Start() +{ + if (curView_ != nullptr) { + curView_->Start(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Start(); +} + +void DialSequenceContainer::Stop() +{ + if (curView_ != nullptr) { + curView_->Stop(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Stop(); +} + +void DialSequenceContainer::Pause() +{ + if (curView_ != nullptr) { + curView_->Pause(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Pause(); +} + +void DialSequenceContainer::Resume() +{ + if (curView_ != nullptr) { + curView_->Resume(); + return; + } + + UpdateCurrentView(); + if (curView_ == nullptr) { + return; + } + curView_->Resume(); +} + +void DialSequenceContainer::OnAnimatorStop(UIView& view) +{ + bool isClick = isClick_; + isClick_ = false; + bool isRepeat = (curView_ == repeatView_); + if (isRepeat && isClick) { + UpdateCurrentView(); + Start(); + } else if (isRepeat && !isClick) { + Start(); + } else { + if (repeatView_ != nullptr) { + UpdateCurrentView(); + Start(); + } + } +} + +void DialSequenceContainer::UpdateCurrentView() +{ + if (curView_ != nullptr) { + if (repeatView_ != nullptr && nonCycleNum_ == 0) { + return; + } else if (repeatView_ == nullptr && nonCycleNum_ != 0) { + Remove(curView_); + curView_ = nonCycleView_[loop_]; + loop_ = (loop_ + 1) % nonCycleNum_; + curView_->SetAnimatorStopListener(this); + Add(curView_); + Invalidate(); + return; + } + + // both repeat and noncycle exist + Remove(curView_); + if (curView_ == repeatView_) { + curView_ = nonCycleView_[loop_]; + loop_ = (loop_ + 1) % nonCycleNum_; + } else { + curView_ = repeatView_; + } + curView_->SetAnimatorStopListener(this); + Add(curView_); + Invalidate(); + return; + } + + if (repeatView_ != nullptr) { + curView_ = repeatView_; + } else if (nonCycleNum_ != 0) { + curView_ = nonCycleView_[loop_]; + loop_ = (loop_ + 1) % nonCycleNum_; + } else { + GRAPHIC_LOGE("sequence img has not been added!"); + return; + } + curView_->SetAnimatorStopListener(this); + Add(curView_); + Invalidate(); +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp index dd3126f75..ffc87a701 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialStaticImgView.cpp @@ -10,5 +10,74 @@ DialStaticImgView::DialStaticImgView() SetAutoEnable(true); } -DialStaticImgView::~DialStaticImgView() {} +DialStaticImgView::~DialStaticImgView() +{ + if (info_ != nullptr) { + UIFree(info_); + info_ = nullptr; + } +} + +void DialStaticImgView::SetLang(uint8_t lang) +{ + language_ = lang; + OnLangChange(FontGlobalManager::GetInstance()->GetCurrentLangId()); +} + +void DialStaticImgView::OnLangChange(uint8_t langId) +{ + if (language_ == FontGlobalManager::INVALID_LANG_ID) { + langVisible_ = true; + } else if (language_ == langId) { + langVisible_ = true; + } else { + langVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} + +bool DialStaticImgView::SetImgs(const ImageInfo* src, uint8_t num) +{ + if (src == nullptr || num == 0) { + return false; + } + if (info_ != nullptr) { + UIFree(info_); + info_ = nullptr; + } + uint32_t size = sizeof(ImageInfo) * num; + info_ = static_cast(UIMalloc(size)); + if (info_ == nullptr) { + return false; + } + if (memcpy_s(info_, size, src, size) != EOK) { + UIFree(info_); + return false; + } + infoNum_ = num; + selected_ = 0; + SetSrc(&info_[selected_]); + SetTouchable(infoNum_ > 1); + return true; +} + +bool DialStaticImgView::OnClickEvent(const ClickEvent& event) +{ + if (selected_ < 0 || info_ == nullptr || infoNum_ == 0) { + return false; + } + selected_ = (selected_ + 1) % infoNum_; + SetSrc(&info_[selected_]); + return true; +} + +void DialStaticImgView::OnTimeUpdate(const struct tm &curTime) +{ + if (IsInTimeInterval(curTime)) { + timeVisible_ = true; + } else { + timeVisible_ = false; + } + SetVisible(langVisible_ && timeVisible_); +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialTimePublisher.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialTimePublisher.cpp new file mode 100644 index 000000000..cb4539b16 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialTimePublisher.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialTimePublisher + * Author: + * Create: 2025-03-04 + */ + +#include "DialTimePublisher.h" +#include "securec.h" +#include "gfx_utils/mem_api.h" +#include "gfx_utils/graphic_log.h" + +namespace OHOS { +DialTimePublisher *DialTimePublisher::publisher_ = nullptr; + +void DialTimePublisher::TimeChangeListener::SetTimeInervals(TimeInterval *intervals, uint8_t num) +{ + if (intervals == nullptr || num == 0) { + return; + } + if (intervals_ != nullptr) { + UIFree(intervals_); + intervals_ = nullptr; + } + num_ = 0; + + intervals_ = static_cast(UIMalloc(sizeof(TimeInterval) * num)); + if (intervals_ == nullptr) { + GRAPHIC_LOGE("failed to malloc!"); + return; + } + num_ = num; + memcpy_s(intervals_, sizeof(TimeInterval) * num, intervals, sizeof(TimeInterval) * num); +} + +bool DialTimePublisher::TimeChangeListener::IsInTimeInterval(const struct tm &curTime) +{ + if (num_ == 0) { // 0-24 + return true; + } + for (uint8_t i = 0; i < num_; ++i) { + if (intervals_[i].start <= curTime.tm_hour && intervals_[i].end > curTime.tm_hour) { + return true; + } + } + return false; +} + +DialTimePublisher::TimeChangeListener::TimeChangeListener() +{ + if (DialTimePublisher::GetPublisher() != nullptr) { + DialTimePublisher::GetPublisher()->Register(this); + } +} + +DialTimePublisher::TimeChangeListener::~TimeChangeListener() +{ + if (intervals_ != nullptr) { + UIFree(intervals_); + intervals_ = nullptr; + } + num_ = 0; + if (DialTimePublisher::GetPublisher() != nullptr) { + DialTimePublisher::GetPublisher()->Unregister(this); + } +} + +void DialTimePublisher::SetPublisher(DialTimePublisher *publisher) +{ + publisher_ = publisher; +} + +DialTimePublisher *DialTimePublisher::GetPublisher() +{ + return publisher_; +} +} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialViewContainer.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialViewContainer.cpp new file mode 100644 index 000000000..6db086094 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialViewContainer.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: DialViewContainer + * Author: + * Create: 2025-02-06 + */ + +#include "DialViewContainer.h" +#include "DialDigitalImgView.h" + +namespace OHOS { +DialViewContainer::~DialViewContainer() +{ + ListNode* viewNode = dialViews_.Head(); + while (viewNode != dialViews_.End()) { + UIViewGroup::Remove(viewNode->data_.view); + delete viewNode->data_.view; + viewNode = viewNode->next_; + } + dialViews_.Clear(); +} + +void DialViewContainer::AddView(UIView* view) +{ + if (view == nullptr) { + return; + } + Add(view); + SubView info = { + .view = view, + .dialView = nullptr, + }; + DialViewContainer *container = dynamic_cast(view); + if (container != nullptr && container->HasInvalidBindData()) { + hasInvalidBindData_ = true; + } + dialViews_.PushBack(info); +} + +void DialViewContainer::AddView(DialDataType type, DialView* view, bool isPeriodic) +{ + if (view == nullptr) { + return; + } + UIView *uiView = dynamic_cast(view); + if (uiView == nullptr) { + return; + } + Add(uiView); + DialDigitalImgView *digital = dynamic_cast(view); + if (digital != nullptr) { + digital->SetParent(this); + } + SubView info = { + .view = uiView, + .dialView = view, + .type = type, + .isPeriodic = isPeriodic + }; + if (type == DialDataType::DATA_TYPE_MAX) { + hasInvalidBindData_ = true; + } + dialViews_.PushBack(info); +} + +bool DialViewContainer::RemoveSubView(uint8_t index, SubView &subView) +{ + if (index >= dialViews_.Size()) { + return false; + } + ListNode *it = Begin(); + for (uint8_t i = 0; i < index; ++i) { + it = it->next_; + } + subView = it->data_; + Remove(subView.view); + DialDigitalImgView *digital = dynamic_cast(subView.view); + if (digital != nullptr) { + digital->SetParent(nullptr); + } + dialViews_.Remove(it); + return true; +} + +bool DialViewContainer::IsInvalidateBindData(uint8_t index) +{ + if (index >= dialViews_.Size()) { + return false; + } + ListNode *it = Begin(); + for (uint8_t i = 0; i < index; ++i) { + it = it->next_; + } + if (it->data_.dialView != nullptr && it->data_.type == DialDataType::DATA_TYPE_MAX) { + return true; + } + DialViewContainer *container = dynamic_cast(it->data_.view); + if (container != nullptr) { + return container->HasInvalidBindData(); + } + return false; +} +} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp index ef1979ff8..8d705373a 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp @@ -12,28 +12,9 @@ #include "ui_screennotify.h" #endif #include "MainPresenterSample.h" +#include "DialDigitalImgView.h" namespace OHOS { -static DialVideoView* g_video = nullptr; - -#ifdef SUPPORT_OHOSFWK -static void ScreenStatusNotify(ScreenStatus status) -{ - if (g_video == nullptr) { - return; - } - if (status == SCREEN_STATUS_OFF) { - g_video->PausePlay(); - } else if (status == SCREEN_STATUS_ON) { - if (g_video->IsPaused()) { - g_video->ResumePlay(); - } else if (!g_video->IsPlayed()) { - g_video->StartPlay(); - } - } -} -#endif - DialViewGroup::DialViewGroup(void) { SetTouchable(true); @@ -43,12 +24,6 @@ DialViewGroup::DialViewGroup(void) DialViewGroup::~DialViewGroup(void) { - if (video_ != nullptr) { -#ifdef SUPPORT_OHOSFWK - deregisterNotifyScreenStatus(ScreenStatusNotify); -#endif - g_video = nullptr; - } if (kaleidoscope_ != nullptr) { kaleidoscope_->ClearFocus(); kaleidoscope_ = nullptr; @@ -79,7 +54,7 @@ void DialViewGroup::ClearDial() periodicUpdateTypes_.Clear(); - dataTypeMap_.clear(); + ClearViews(); ListNode* viewNode = dialViews_.Head(); while (viewNode != dialViews_.End()) { @@ -89,6 +64,10 @@ void DialViewGroup::ClearDial() } dialViews_.Clear(); + rollingLabelList_.Clear(); + imgAnimList_.Clear(); + seqList_.Clear(); + period_ = DEFAULT_TASK_PERIOD; video_ = nullptr; @@ -139,47 +118,151 @@ void DialViewGroup::ProcessData(DialDataType type, DialView* view) view->HandleFloatData(floatsData, num); } } +void DialViewGroup::DoStop(void) +{ + SetLableAnimatorState(Animator::PAUSE); + SetImgAnimatorState(Animator::PAUSE); + if (video_ != nullptr && !video_->IsStopped()) { + video_->StopPlay(); + } + if (kaleidoscope_ != nullptr) { + kaleidoscope_->StopRotateAnimator(); + kaleidoscope_->ClearFocus(); + } +} -void DialViewGroup::AddView(UIView* view, bool isDialVideoView) +void DialViewGroup::DoStart(void) { - if (view == nullptr) { - GRAPHIC_LOGE("Parameter is nullptr.\n"); - return; + SetLableAnimatorState(Animator::START); + SetImgAnimatorState(Animator::START); + if (video_ != nullptr) { + if (video_->IsPaused()) { + video_->ResumePlay(); + } else if (!video_->IsPlayed()) { + video_->StartPlay(); + } } - dialViews_.PushBack(view); - Add(view); + if (kaleidoscope_ != nullptr) { + kaleidoscope_->RequestFocus(); + kaleidoscope_->StartRotateAnimator(); + } +} - if (view->GetViewType() == UI_KALEIDOSCOPE_VIEW) { - kaleidoscope_ = dynamic_cast(view); +void DialViewGroup::DoPause(void) +{ + SetLableAnimatorState(Animator::PAUSE); + SetImgAnimatorState(Animator::PAUSE); + if (kaleidoscope_ != nullptr) { + kaleidoscope_->StopRotateAnimator(); + kaleidoscope_->ClearFocus(); } + if (video_ != nullptr) { + video_->PausePlay(); + } +} - if (isDialVideoView) { +void DialViewGroup::RecordSpecial(UIView *view) +{ + if (dynamic_cast(view) != nullptr) { + UILabel* label = dynamic_cast(view); + uint8_t mode = label->GetLineBreakMode(); + if (mode == UILabel::LINE_BREAK_MARQUEE || mode == UILabel::LINE_BREAK_OSCILLATION) { + rollingLabelList_.PushBack(label); + } + } else if (dynamic_cast(view) != nullptr) { + UIImageAnimatorView* imgAnim = dynamic_cast(view); + imgAnimList_.PushBack(imgAnim); + } else if (dynamic_cast(view) != nullptr) { + kaleidoscope_ = dynamic_cast(view); + } else if (dynamic_cast(view) != nullptr) { if (video_ != nullptr) { GRAPHIC_LOGE("Already added a video view.\n"); return; } video_ = reinterpret_cast(view); - g_video = video_; -#ifdef SUPPORT_OHOSFWK - registerNotifyScreenStatus(ScreenStatusNotify); -#endif + } else if (dynamic_cast(view) != nullptr) { + DialSequenceContainer *seq = dynamic_cast(view); + seqList_.PushBack(seq); } } -void DialViewGroup::AddView(DialDataType type, DialView* view, bool isPeriodic) +void DialViewGroup::RecordBindData(DialDataType type, DialView* view, bool isPeriodic) { - if (view == nullptr) { - GRAPHIC_LOGE("Parameter is nullptr.\n"); - return; + if (dynamic_cast(view) != nullptr) { + UILabel* label = dynamic_cast(view); + uint8_t mode = label->GetLineBreakMode(); + if (mode == UILabel::LINE_BREAK_MARQUEE || mode == UILabel::LINE_BREAK_OSCILLATION) { + rollingLabelList_.PushBack(label); + } } - dataTypeMap_.insert(std::make_pair(static_cast(type), view)); + auto it = dataTypeMap_.find(static_cast(type)); + if (it != dataTypeMap_.end()) { + it->second->PushBack(view); + } else { + Views *container = new Views; + if (container == nullptr) { + GRAPHIC_LOGE("failed to alloc binddata container"); + return; + } + container->PushBack(view); + dataTypeMap_.insert(std::make_pair(static_cast(type), container)); + viewsMemPool_.PushBack(container); + } if (isPeriodic) { periodicUpdateTypes_.PushBack(type); } else { ModelDialDataFactory::GetInstance().RegisterDialDataListener(type, this); passiveUpdateTypes_.PushBack(type); } +} + +void DialViewGroup::ClearViews() +{ + dataTypeMap_.clear(); + for (uint16_t i = 0; i < viewsMemPool_.Size(); ++i) { + delete viewsMemPool_[i]; + } + viewsMemPool_.Clear(); +} + +void DialViewGroup::AddView(UIView* view) +{ + if (view == nullptr) { + GRAPHIC_LOGE("Parameter is nullptr.\n"); + return; + } + dialViews_.PushBack(view); + Add(view); + DialViewContainer *container = dynamic_cast(view); + if (container != nullptr) { + ListNode *head = container->Begin(); + for (;head != container->End(); head = head->next_) { + DialViewContainer::SubView &subView = head->data_; + if (subView.dialView != nullptr) { + RecordBindData(subView.type, subView.dialView, subView.isPeriodic); + ProcessData(subView.type, subView.dialView); + } else if (subView.view != nullptr) { + RecordSpecial(subView.view); + } + } + } else { + RecordSpecial(view); + } +} + +void DialViewGroup::AddView(DialDataType type, DialView* view, bool isPeriodic) +{ + if (view == nullptr) { + GRAPHIC_LOGE("Parameter is nullptr.\n"); + return; + } + + DialDigitalImgView *digital = dynamic_cast(view); + if (digital != nullptr) { + digital->SetParent(this); + } + RecordBindData(type, view, isPeriodic); dialViews_.PushBack(dynamic_cast(view)); Add(dynamic_cast(view)); ProcessData(type, view); @@ -206,7 +289,10 @@ void DialViewGroup::UpdateViewsByPeriodicUpdateData() DialDataType type = node->data_; auto iter = dataTypeMap_.find(static_cast(type)); if (iter != dataTypeMap_.end()) { - ProcessData(type, iter->second); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) { + ProcessData(type, (*container)[i]); + } } node = node->next_; } @@ -219,8 +305,11 @@ void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, float data) { auto iter = dataTypeMap_.find(static_cast(type)); if (iter != dataTypeMap_.end()) { - DialView* view = iter->second; - view->HandleFloatData(data); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) { + DialView* view = (*container)[i]; + view->HandleFloatData(data); + } } } @@ -228,8 +317,11 @@ void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, const float* data, { auto iter = dataTypeMap_.find(static_cast(type)); if (iter != dataTypeMap_.end()) { - DialView* view = iter->second; - view->HandleFloatData(data, num); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) { + DialView* view = (*container)[i]; + view->HandleFloatData(data, num); + } } } @@ -237,8 +329,11 @@ void DialViewGroup::OnDialTextDataUpdate(DialDataType type, const std::string* d { auto iter = dataTypeMap_.find(static_cast(type)); if (iter != dataTypeMap_.end()) { - DialView* view = iter->second; - view->HandleTextData(data, num); + Views *container = iter->second; + for (uint16_t i = 0; i < container->Size(); ++i) { + DialView* view = (*container)[i]; + view->HandleTextData(data, num); + } } } @@ -295,18 +390,9 @@ bool DialViewGroup::OnClickEvent(const ClickEvent& event) void DialViewGroup::ScrollBegin(bool isActive) { - if (kaleidoscope_ != nullptr) { - if (isActive) { - kaleidoscope_->ClearFocus(); - kaleidoscope_->StopRotateAnimator(); - } - return; - } - - if (video_ == nullptr) { - return; + if (isActive) { + DoPause(); } - video_->PausePlay(); } void DialViewGroup::ScrollEnd(bool isActive) @@ -316,111 +402,75 @@ void DialViewGroup::ScrollEnd(bool isActive) return; } - if (kaleidoscope_ != nullptr) { - if (isActive) { - kaleidoscope_->StartRotateAnimator(); - kaleidoscope_->RequestFocus(); - } - return; - } - - if (video_ == nullptr) { - return; - } - if (isActive) { - if (video_->IsPaused()) { - video_->ResumePlay(); - } else if (!video_->IsPlayed()) { - video_->StartPlay(); - } - g_video = video_; + DoStart(); } else { - if (!video_->IsStopped()) { + if (video_ != nullptr && !video_->IsStopped()) { video_->StopPlay(); } - ClearCache(); - g_video = nullptr; + if (video_ != nullptr) { + ClearCache(); + } } } void DialViewGroup::CoverBegin(bool isCovered) { - if (kaleidoscope_ != nullptr) { - if (!isCovered) { - kaleidoscope_->StopRotateAnimator(); - kaleidoscope_->ClearFocus(); - } - return; + if (!isCovered) { + DoPause(); } +} - if (video_ == nullptr) { +void DialViewGroup::CoverEnd(bool isCovered) +{ + MainPresenterSample* mainPresenter = MainPresenterSample::GetInstance(); + if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { return; } - video_->PausePlay(); + if (!isCovered) { + DoStart(); + } } -void DialViewGroup::CoverEnd(bool isCovered) +void DialViewGroup::OnActive(void) { MainPresenterSample* mainPresenter = MainPresenterSample::GetInstance(); if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { return; } - if (kaleidoscope_ != nullptr) { - if (!isCovered) { - kaleidoscope_->RequestFocus(); - kaleidoscope_->StartRotateAnimator(); - } - return; - } - if (video_ == nullptr) { + DoStart(); +} + +void DialViewGroup::OnInactive(void) +{ + DoStop(); +} + +void DialViewGroup::OnCovered(void) +{ + MainPresenterSample* mainPresenter = MainPresenterSample::GetInstance(); + if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { return; } - if (isCovered) { - g_video = nullptr; - } else { - if (video_->IsPaused()) { - video_->ResumePlay(); - } else if (!video_->IsPlayed()) { - video_->StartPlay(); - } - g_video = video_; - } + + DoPause(); } -void DialViewGroup::OnActive(void) +void DialViewGroup::OnUncovered(void) { MainPresenterSample* mainPresenter = MainPresenterSample::GetInstance(); if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) { return; } - if (video_ != nullptr) { - if (video_->IsPaused()) { - video_->ResumePlay(); - } else if (!video_->IsPlayed()) { - video_->StartPlay(); - } - g_video = video_; - } else if (kaleidoscope_ != nullptr) { - kaleidoscope_->RequestFocus(); - kaleidoscope_->StartRotateAnimator(); - } + DoStart(); } -void DialViewGroup::OnInactive(void) +void DialViewGroup::OnPause() { - if (video_ != nullptr) { - if (!video_->IsStopped()) { - video_->StopPlay(); - } - g_video = nullptr; - } else if (kaleidoscope_ != nullptr) { - kaleidoscope_->StopRotateAnimator(); - kaleidoscope_->ClearFocus(); - } + DoPause(); } MediaVideoPlay* DialViewGroup::GetVideoPlay() @@ -430,4 +480,58 @@ MediaVideoPlay* DialViewGroup::GetVideoPlay() } return nullptr; } -} \ No newline at end of file + +void DialViewGroup::SetLableAnimatorState(uint8_t state) +{ + if (rollingLabelList_.IsEmpty()) { + return; + } + + ListNode* node = rollingLabelList_.Begin(); + while (node != rollingLabelList_.End()) { + if (node->data_ != nullptr) { + UILabel* label = node->data_; + label->SetAnimState(state); + } + node = node->next_; + } +} + +void DialViewGroup::SetImgAnimatorState(uint8_t state) +{ + if (imgAnimList_.IsEmpty() && seqList_.IsEmpty()) { + return; + } + + ListNode* node = imgAnimList_.Begin(); + while (node != imgAnimList_.End()) { + if (node->data_ != nullptr) { + UIImageAnimatorView* imgAnim = node->data_; + switch (state) { + case Animator::PAUSE: + imgAnim->Pause(); + break; + case Animator::START: + imgAnim->Resume(); + break; + } + } + node = node->next_; + } + + ListNode* it = seqList_.Begin(); + while (it != seqList_.End()) { + if (it->data_ != nullptr) { + switch (state) { + case Animator::PAUSE: + it->data_->Pause(); + break; + case Animator::START: + it->data_->Resume(); + break; + } + } + it = it->next_; + } +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp index d17de5b31..81c7106fd 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp @@ -43,6 +43,24 @@ DialBaseModel* ModelDialDataFactory::GetModuleByType(DialDataType& type) return iter->second; } +bool ModelDialDataFactory::IsOHBindDataExist(DialOHDataType type) const +{ + auto it = g_bindDataConverter.find(type); + if (it == g_bindDataConverter.end()) { + return false; + } + return IsBindDataExist(it->second); +} + +bool ModelDialDataFactory::IsBindDataExist(DialDataType type) const +{ + auto it = models_.find(static_cast(type)); + if (it != models_.end() && it->second != nullptr) { + return true; + } + return false; +} + bool ModelDialDataFactory::RegisterDialDataListener(DialDataType type, OnDialDataUpdateListener* listener) { DialBaseModel* model = GetModuleByType(type); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/WatchInterface.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/WatchInterface.cpp new file mode 100644 index 000000000..c4f9fd1c2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/WatchInterface.cpp @@ -0,0 +1,370 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025. All rights reserved. + * Description: WatchInterface + * Author: + * Create: 2025-03-17 + */ + +#include +#include "dirent.h" +#include "DialBinParser.h" +#include "UiConfig.h" +#include "WatchInterface.h" +#include "gfx_utils/vector.h" +#include "common/screen.h" +#include "MainModel.h" +#include "MainViewSample.h" +#include "SetDialModel.h" +#include "graphic_service.h" +#include "NativeAbility.h" + +using namespace OHOS; +namespace { +struct { + Graphic::Vector fileNames; // only for 3.0 + Graphic::Vector watchInfo; // only for 3.0 +} g_info; + +bool GetActiveWatchPath(std::string &path) +{ + if (MainModel::GetInstance().GetDialSetting().dialFlag == 1) { + path = MainModel::GetInstance().GetDialSetting().dialFullName; + return true; + } + return false; +} + +bool GetPreviewInfo(const std::string &fileName, DialPreviewInfo &preview) +{ + const std::string type(".bin"); + if (!(fileName.length() > type.length() && + fileName.substr(fileName.length() - type.length(), type.length()) == type)) { + return false; + } + memset_s(&preview, sizeof(preview), 0, sizeof(preview)); + FILE *file = fopen(fileName.c_str(), "rb"); + bool isSuccess = false; + if (file != nullptr) { + isSuccess = DialBinParserManager::GetInstance()->GetDialPreviewInfo(file, &preview); + fclose(file); + } + return isSuccess; +} + +bool ConvertPreview2WatchDialInfo(const DialPreviewInfo &preview, watch_dial_info &info) +{ + errno_t ret = strcpy_s(reinterpret_cast(info.watch_protocol_version), + sizeof(info.watch_protocol_version), + preview.protocolVersion); + if (ret != 0) { + GRAPHIC_LOGE("failed to copy protocol version."); + return false; + } + + ret = strcpy_s(reinterpret_cast(info.watch_version), sizeof(info.watch_version), preview.watchVersion); + if (ret != 0) { + GRAPHIC_LOGE("failed to copy watch version."); + return false; + } + info.uuid = preview.uuid; + return true; +} + +bool GetAllWatchInfo() +{ + g_info.fileNames.Clear(); + g_info.watchInfo.Clear(); + struct dirent *direntp = nullptr; + + // ´ò¿ªÄ¿Â¼ + DIR *dirp = opendir(APP_DIAL_PATH); + bool isSuccess = true; + // ±éÀúÎļþ + DialPreviewInfo info; + watch_dial_info watchInfo; + std::string activePath; + bool isActiveExist = GetActiveWatchPath(activePath); + if (dirp != nullptr) { + while ((direntp = readdir(dirp)) != nullptr) { + std::string fileName = std::string(APP_DIAL_PATH) + std::string("/") + std::string(direntp->d_name); + isSuccess = GetPreviewInfo(fileName, info); + if (!isSuccess) { + continue; + } + + const std::string lowestVersion("3.0"); + std::string curVersion(info.protocolVersion); + if (curVersion >= lowestVersion) { + isSuccess = ConvertPreview2WatchDialInfo(info, watchInfo); + if (!isSuccess) { + break; + } + watchInfo.install_state = true; + watchInfo.is_current_watch = isActiveExist ? (activePath == fileName) : false; + g_info.fileNames.PushBack(fileName); + g_info.watchInfo.PushBack(watchInfo); + } + } + } + // ¹Ø±ÕĿ¼ + closedir(dirp); + return isSuccess; +} +} // namespace + +bool GetAllWatchFaceInfo(watch_dial_info *info, uint8_t *num, uint8_t maxCnt) +{ + if (info == nullptr || num == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + if (g_info.watchInfo.Size() > maxCnt) { + GRAPHIC_LOGE("mem is not enough."); + return false; + } + *num = g_info.watchInfo.Size(); + if (*num == 0) { + return false; + } + if (memcpy_s(info, + g_info.watchInfo.Size() * sizeof(watch_dial_info), + &g_info.watchInfo[0], + g_info.watchInfo.Size() * sizeof(watch_dial_info)) != 0) { + GRAPHIC_LOGE("copy info error!"); + return false; + } + return true; +} + +bool GetWatchFaceInfo(uint32_t uuid, watch_dial_info *watch) +{ + if (watch == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + if (g_info.watchInfo[i].uuid == uuid) { + *watch = g_info.watchInfo[i]; + return true; + } + } + return false; +} + +bool GetWatchCapability(watch_dev_cap_info *capability) +{ + if (capability == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + capability->kaleidoscope = true; + capability->effect_3D = false; + capability->interaction = true; + capability->video = true; + capability->video_format = (1 << CODEC_JPEG); + return true; +} + +bool GetWatchSystemInfo(watch_sys_info *sysInfo) +{ + if (sysInfo == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + sysInfo->watch_proto_support_cnt = DialBinParserManager::GetInstance()->GetSupportVersionCnt(); + for (uint8_t i = 0; i < sysInfo->watch_proto_support_cnt; ++i) { + std::string version; + bool isSuccess = DialBinParserManager::GetInstance()->GetVersionByIndex(i, version); + if (!isSuccess) { + return false; + } + errno_t ret = + strcpy_s(sysInfo->watch_protocol_verion[i], sizeof(sysInfo->watch_protocol_verion[i]), version.c_str()); + if (ret != 0) { + GRAPHIC_LOGE("get protocal version error!"); + return false; + } + } + int ret = sprintf_s(sysInfo->resolution, + sizeof(sysInfo->resolution), + "%u*%u", + Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + if (ret == -1) { + GRAPHIC_LOGE("get resolution error!"); + return false; + } + + return true; +} + +bool GetCurrentWatchFaceInfo(watch_dial_info *watch) +{ + if (watch == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + std::string activePath; + if (!GetActiveWatchPath(activePath)) { + return false; + } + + DialPreviewInfo preview; + if (!GetPreviewInfo(activePath, preview)) { + return false; + } + + if (std::string(preview.protocolVersion) < std::string("3.0")) { + return false; + } + if (!ConvertPreview2WatchDialInfo(preview, *watch)) { + return false; + } + watch->install_state = true; + watch->is_current_watch = true; + return true; +} + +bool SetCurrentWatchFace(uint32_t uuid) +{ + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + watch_dial_info info; + uint16_t index = 0; + bool isExists = false; + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + if (uuid == g_info.watchInfo[i].uuid) { + isExists = true; + info = g_info.watchInfo[i]; + index = i; + break; + } + } + if (!isExists) { + GRAPHIC_LOGE("uuid does not exist!"); + return false; + } + if (info.is_current_watch) { + return true; + } + + DialSetting setting = MainModel::GetInstance().GetDialSetting(); + setting.dialFlag = 1; + setting.dialFullName = g_info.fileNames[index]; + GraphicService::GetInstance()->PostGraphicEvent([setting]() { + MainModel::GetInstance().GetDialSetting() = setting; + MainModel::GetInstance().AddDialSetting(setting); + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAIN_SAMPLE) { + MainViewSample::GetInstance()->ReloadWatchFace(); + } + }); + + return true; +} + +bool UninstallWatch(uint32_t uuid) +{ + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watch info."); + return false; + } + watch_dial_info info; + uint16_t index = 0; + bool isExists = false; + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + if (uuid == g_info.watchInfo[i].uuid) { + isExists = true; + info = g_info.watchInfo[i]; + index = i; + break; + } + } + if (!isExists) { + GRAPHIC_LOGE("uuid does not exist!"); + return false; + } + + if (info.is_current_watch) { + DialSetting setting = MainModel::GetInstance().GetDialSetting(); + setting.dialFlag = 0; + setting.dialId = 0; + std::string fileName = g_info.fileNames[index]; + GraphicService::GetInstance()->PostGraphicEvent([setting, fileName]() { + MainModel::GetInstance().GetDialSetting() = setting; + MainModel::GetInstance().AddDialSetting(setting); + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAIN_SAMPLE) { + MainViewSample::GetInstance()->ReloadWatchFace(); + } + if (remove(fileName.c_str()) != 0) { + GRAPHIC_LOGE("failed to remove file %s", fileName.c_str()); + } + }); + } else { + if (remove(g_info.fileNames[index].c_str()) != 0) { + GRAPHIC_LOGE("failed to remove file %s", g_info.fileNames[index].c_str()); + return false; + } + } + return true; +} + +bool InstallWatch(const char *path, uint32_t *uuid) +{ + if (path == nullptr || uuid == nullptr) { + GRAPHIC_LOGE("para error!"); + return false; + } + + DialPreviewInfo preview; + if (!GetPreviewInfo(std::string(path), preview)) { + return false; + } + if (std::string(preview.protocolVersion) < std::string("3.0")) { + return false; + } + *uuid = preview.uuid; + + if (!GetAllWatchInfo()) { + GRAPHIC_LOGE("failed to get all watchinfo!"); + return false; + } + for (uint16_t i = 0; i < g_info.watchInfo.Size(); ++i) { + const std::string &fileName = g_info.fileNames[i]; + const watch_dial_info &info = g_info.watchInfo[i]; + if (!(info.uuid == *uuid && std::string(path) != fileName)) { + continue; + } + + if (info.is_current_watch) { + DialSetting setting = MainModel::GetInstance().GetDialSetting(); + setting.dialFlag = 1; + setting.dialFullName = std::string(path); + GraphicService::GetInstance()->PostGraphicEvent([setting, fileName]() { + MainModel::GetInstance().GetDialSetting() = setting; + MainModel::GetInstance().AddDialSetting(setting); + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAIN_SAMPLE) { + MainViewSample::GetInstance()->ReloadWatchFace(); + } + if (remove(fileName.c_str()) != 0) { + GRAPHIC_LOGE("failed to remove file %s", fileName.c_str()); + } + }); + } else { + if (remove(fileName.c_str()) != 0) { + return false; + } + } + } + + return true; +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp index ba2b91cfc..db8a0b9fc 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp @@ -33,7 +33,6 @@ MainCallingPresenter::MainCallingPresenter() MainCallingPresenter::~MainCallingPresenter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::~MainCallingPresenter"); - RootView::GetInstance()->RemoveAll(); if (volumeSetting != nullptr) { delete volumeSetting; volumeSetting = nullptr; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp index 595851acc..3a38a9e01 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/offlinevoice/src/VocassistPresenter.cpp @@ -128,7 +128,6 @@ void VocassistPresenter::OnResume(void) void VocassistPresenter::OnStop(void) { - Presenter::OnStop(); ScreenTurnOff(); } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersModel.cpp index 4e4462847..e454449be 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersModel.cpp @@ -297,6 +297,8 @@ void PlayersModel::NextSong(int16_t index) } } else if (playerState == PlayerStates::PLAYER_PAUSED || (playerState == PlayerStates::PLAYER_IDLE)) { ret = playerCtr->Reset(); + AudioManager::GetInstance().DeactivateAudioInterrupt(interrupt); + ClearActivateAudioInterrupt(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Reset, ret:%d", ret); } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp index f7282a217..e595ee337 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp @@ -19,6 +19,7 @@ #include "BluetoothPresenter.h" #include "graphic_service.h" #include "PhoneService.h" +#include "MainViewSample.h" #include "bts_avrcp_controller.h" #include "bts_avrcp_target.h" @@ -108,7 +109,7 @@ bool JumpView::ChangeBluetoothEarPhoneView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } // 动画开始 bluetoothEarPhoneView->BtAnimatorStart(); @@ -132,7 +133,7 @@ bool JumpView::ChangeBluetoothEarListView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } else { // 刷新列表 UIList *scanList = bluetoothEarListView->GetScanUIList(); @@ -163,7 +164,7 @@ bool JumpView::ChangeBluetoothView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "JumpView::ChangeBluetoothView"); BluetoothModel::GetInstance()->SetTagConnectView(false); @@ -187,7 +188,7 @@ bool JumpView::ChangeBluetoothOptionsView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } return true; } @@ -209,7 +210,7 @@ bool JumpView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } else { // 刷新列表 UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList(); @@ -245,7 +246,7 @@ bool JumpView::ChangeBluetoothReconnectView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } BluetoothModel::GetInstance()->SetTagDisconnectView(true); bluetoothReconnectView->RefreshBluetoothNameLabel(); @@ -287,7 +288,7 @@ bool JumpView::ChangeTipsSuccMessageView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } return true; } @@ -309,7 +310,7 @@ bool JumpView::ChangeTipsConnFailMessageView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } if (bluetoothReconnectView == nullptr) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback bluetoothReconnectView == nullptr"); @@ -337,7 +338,7 @@ bool JumpView::ChangeTipsFailMessageView(int16_t hideView, int16_t thisView) return false; } container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); + MainViewSample::GetInstance()->GetRootContainer()->Add(container[thisView]); } return true; } @@ -509,10 +510,8 @@ void ButtonOnClickListener::PlayerButtonOnClick() if (GetCurrCallNum() != 0 && GetScoConnectState() == HFP_SCO_STATE_CONNECTED) { if (state == UICheckBox::UICheckBoxState::SELECTED) { playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED); - playersView->GetPlayerButton()->Invalidate(); } else { playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::SELECTED); - playersView->GetPlayerButton()->Invalidate(); } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PlayerButtonOnClick] calling phone"); return; @@ -542,7 +541,7 @@ void ButtonOnClickListener::SoundButtonOnClick() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "volumeSetting SetUpVolume fail"); return; } - RootView::GetInstance()->Add(volumeSettingView); + MainViewSample::GetInstance()->GetRootContainer()->Add(volumeSettingView); } int32_t volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "current volume = %d", volume); @@ -787,7 +786,6 @@ static void Pause(void) PlayersModel::GetInstance()->SetPlayButtonState(false); } else { playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED); - playersView->GetPlayerButton()->Invalidate(); } PlayerIntrptListener->RestFlag(); PlayerIntrptListener->SetPaused(true); @@ -798,7 +796,7 @@ static void Pause(void) void PlayerInterruptListener::PausePlayer(void) { - PlayerPostGraphicEvent(Pause); + Pause(); } static void Resume(void) @@ -829,7 +827,6 @@ static void Resume(void) PlayersModel::GetInstance()->SetPlayButtonState(true); } else { playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::SELECTED); - playersView->GetPlayerButton()->Invalidate(); } PlayerIntrptListener->RestFlag(); PlayerIntrptListener->SetResumed(true); @@ -841,13 +838,13 @@ static void Resume(void) void PlayerInterruptListener::ResumePlayer(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PlayerInterruptListener::ResumePlayer] start"); - usleep(50000); // 确保界面切换完成 + usleep(500000); // 确保界面切换完成 if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE || (GetCurrCallState() != HFP_HF_CALL_STATE_FINISHED && GetScoConnectState() == HFP_SCO_STATE_CONNECTED)) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PlayerInterruptListener::ResumePlayer] this is in calling"); return; // 通话界面,禁止音乐恢复播放 } - PlayerPostGraphicEvent(Resume); + Resume(); } static void Stop(void) @@ -1359,7 +1356,6 @@ void PlayersPresenter::PlayerbackReset(void) return; } playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED); - playersView->GetPlayerButton()->Invalidate(); } // 播放器按钮复位 @@ -1377,7 +1373,6 @@ void PlayersPresenter::PlayerHeadsetReset(void) playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED); } - playersView->GetPlayerButton()->Invalidate(); } void PlayersPresenter::ShowPlayerListGroup() diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp index 1b2440bad..e318718aa 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp @@ -37,7 +37,6 @@ PlayersView::~PlayersView() if (state_ == UICheckBox::UICheckBoxState::SELECTED) { PlayersModel::GetInstance()->SetPlayButtonState(true); } - RootView::GetInstance()->RemoveAll(); RemoveAll(); listGroup->RemoveAll(); delete list; @@ -242,7 +241,7 @@ void PlayersView::ShowUpListView() list->SetAdapter(adapterText); } listGroup->Add(list); - RootView::GetInstance()->Add(listGroup); + MainViewSample::GetInstance()->GetRootContainer()->Add(listGroup); UIView::OnDragListener *dragListener = (UIView::OnDragListener*)OHOS::PlayerOnDragListener::GetInstance(); if (dragListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::OnDragListener fail"); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/rebootdevice/src/RebootView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/rebootdevice/src/RebootView.cpp index efce7f8bf..5d8d43736 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/rebootdevice/src/RebootView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/rebootdevice/src/RebootView.cpp @@ -47,7 +47,6 @@ RebootView *RebootView::GetInstance() void RebootView::OnStart() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStart"); if (RebootModel::GetInstance()->GetSelectView() == REBOOT) { ChangeView(REBOOT_MAX, REBOOTVIEW); } else if (RebootModel::GetInstance()->GetSelectView() == REBOOTDEVICE) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp index 563e1c790..974954c3a 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp @@ -186,6 +186,7 @@ namespace OHOS { } } dialInfoList.clear(); + aodDialInfoList.clear(); } uint8_t SetDialModel::GetPageIndex(void) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/videocard/include/VideoCard.h b/code/sdk/application/wearable/nativeapp/nativeui/videocard/include/VideoCard.h new file mode 100644 index 000000000..f717fc502 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/videocard/include/VideoCard.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + */ + +#ifndef VIDEO_CARD_H +#define VIDEO_CARD_H + +#include +#include "DialDataBase.h" +#include "components/ui_view_group.h" +#include "OnDialDataUpdateListener.h" +#include "components/ui_card_page.h" +#include "components/ui_lite_surface_view.h" +#include "video_play_wrapper.h" +#include "DialView.h" + +namespace OHOS { +class VideoCard : public UICardPage { +public: + VideoCard(const VideoCard &) = delete; + VideoCard &operator=(const VideoCard &) = delete; + + VideoCard(); + + ~VideoCard() override; + + /** + * @brief This function is invoked when the function SetHorCurrentPage() is called. + */ + void OnActive(void) override; + + void OnInactive() override; + + void PreLoad(void) override; + + void ScrollBegin(bool isActive) override; + + void ScrollEnd(bool isActive) override; + + void SetFilePath(const std::string &path); + + void SetPreviewFile(const std::string &path); + + void OnPause(void) override; + +private: + void StopVideo(); + + void StartVideo(); + + void PauseVideo(); + + void Deinit(); + + void Init(); + + UILiteSurfaceView *surfaceView_ = nullptr; + MediaVideoPlay *video_ = nullptr; + bool resPreloaded_ = false; + bool hasPreview_ = false; + std::string path_; + std::string previewPath_; +}; +} // OHOS +#endif // VIDEO_CARD_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/videocard/src/VideoCard.cpp b/code/sdk/application/wearable/nativeapp/nativeui/videocard/src/VideoCard.cpp new file mode 100644 index 000000000..4bd5cc73d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/videocard/src/VideoCard.cpp @@ -0,0 +1,183 @@ +#include +#include +#include "VideoCard.h" +#include "NativeAbility.h" +#include "msg_center.h" +#include "securec.h" +#include "DialBinParser.h" +#include "ModelDialDataFactory.h" +#include "common/low_power_manager.h" +#include "common/image_cache_manager.h" +#ifdef SUPPORT_OHOSFWK +#include "ui_screennotify.h" +#endif +#include "MainPresenterSample.h" +#include "common/graphic_utils.h" + +namespace OHOS { +static constexpr int16_t JPEG_HEIGHT_DIVISOR = 2; +static constexpr int16_t JPEG_WIDTH_BYTE_ALIGNMENT = 128; +static constexpr int16_t JPEG_HEIGHT_BYTE_ALIGNMENT = 16; +static constexpr int16_t BUFFER_QUEUE_SIZE = 3; +static constexpr int16_t STRIDE_ALIGNMENT_VALUE = 128; + +static inline int32_t MediaByteAlign(int16_t value, int16_t align) +{ + return (((value) + (align) - 1) & (~((align) - 1))); +} + +VideoCard::VideoCard() +{ + SetTouchable(true); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); +} + +VideoCard::~VideoCard() +{ + Deinit(); +} + +void VideoCard::OnActive(void) +{ + StartVideo(); +} + +void VideoCard::OnInactive() +{ + StopVideo(); +} + +void VideoCard::PreLoad(void) +{ + if (!resPreloaded_) { + Init(); + resPreloaded_ = true; + } +} + +void VideoCard::ScrollBegin(bool isActive) +{ + PauseVideo(); +} + +void VideoCard::ScrollEnd(bool isActive) +{ + if (isActive) { + StartVideo(); + } else { + StopVideo(); + ClearCache(); + } +} + +void VideoCard::SetFilePath(const std::string &path) +{ + Deinit(); + path_ = path; + resPreloaded_ = false; +} + +void VideoCard::SetPreviewFile(const std::string &path) +{ + hasPreview_ = true; + previewPath_ = path; +} + +void VideoCard::OnPause(void) +{ + PauseVideo(); +} + +void VideoCard::StopVideo() +{ + if (video_ == nullptr) { + return; + } + + if (video_->isPlayed_ || video_->isPause_) { + video_->StopVideoPlay(); + } +} + +void VideoCard::StartVideo() +{ + if (video_ == nullptr) { + return; + } + + if (video_->isPause_) { + video_->ResumeVideoPlay(); + } else if (!video_->isPlayed_) { + video_->StartVideoPlay(); + } +} + +void VideoCard::PauseVideo() +{ + if (video_ == nullptr) { + return; + } + + if (video_->isPlayed_) { + video_->PauseVideoPlay(); + } +} +void VideoCard::Deinit() +{ + Remove(surfaceView_); + if (video_ != nullptr) { + delete video_; + video_ = nullptr; + } + if (surfaceView_ != nullptr) { + delete surfaceView_; + surfaceView_ = nullptr; + } +} + +void VideoCard::Init() +{ + if (surfaceView_ != nullptr || video_ != nullptr) { + return; + } + surfaceView_ = new UILiteSurfaceView; + if (surfaceView_ == nullptr) { + return; + } + Rect area = GetRect(); + int16_t w = area.GetWidth(); + int16_t h = area.GetHeight(); + surfaceView_->SetPosition(0, 0, w, h); + ColorType color; + color.full = 0xff3d3a3c; + surfaceView_->SetSurfaceColorkey(color); + + Surface* surface = surfaceView_->GetSurface(); + surface->SetStrideAlignment(STRIDE_ALIGNMENT_VALUE); + surface->SetWidthAndHeight(w, h); + surface->SetQueueSize(BUFFER_QUEUE_SIZE); + surface->SetFormat(PIXEL_FMT_YCBCR_420_SP); + + // jpeg decoder output buffer size calculation formula + int32_t ySize = MediaByteAlign(w, JPEG_WIDTH_BYTE_ALIGNMENT) * h; + int32_t uvSize = MediaByteAlign(w, JPEG_WIDTH_BYTE_ALIGNMENT) * + MediaByteAlign(h, JPEG_HEIGHT_BYTE_ALIGNMENT) / JPEG_HEIGHT_DIVISOR; + int32_t bufferSize = ySize + uvSize; + surface->SetSize(bufferSize); + + video_ = new MediaVideoPlay(surface, nullptr, path_, true); + if (video_ == nullptr) { + delete surfaceView_; + surfaceView_ = nullptr; + return; + } + if (hasPreview_) { + ImageInfo *imgInfo = ImageCacheManager::GetInstance().LoadSingleRes(previewPath_.c_str()); + if (imgInfo != nullptr) { + surfaceView_->SetPreview(imgInfo); + } + } + Add(surfaceView_); + video_->SetSyncExitMode(true); +} +} // OHOS diff --git a/code/sdk/application/wearable/service/CMakeLists.txt b/code/sdk/application/wearable/service/CMakeLists.txt index 124bf1176..7b1691bee 100644 --- a/code/sdk/application/wearable/service/CMakeLists.txt +++ b/code/sdk/application/wearable/service/CMakeLists.txt @@ -15,3 +15,4 @@ if("CONFIG_SEA_PHS_SUPPORT" IN_LIST DEFINES) add_subdirectory_if_exist(smart_voice) endif() add_subdirectory_if_exist(power_manager) +add_subdirectory_if_exist(dial_market) diff --git a/code/sdk/application/wearable/service/app_store/app_store.cpp b/code/sdk/application/wearable/service/app_store/app_store.cpp index 922286134..8c6efbeb1 100644 --- a/code/sdk/application/wearable/service/app_store/app_store.cpp +++ b/code/sdk/application/wearable/service/app_store/app_store.cpp @@ -8,7 +8,6 @@ #include "bundle_install_msg.h" #include "bundlems_slite_client.h" #include "appexecfwk_errors.h" -#include "sign_mode.h" #include "ui_service.h" void AppStoreReplyAck(uint8_t cmd_id, uint8_t type, uint32_t ack) @@ -40,13 +39,10 @@ static void SendMsgToAppStore(CallbackStatus status, const uint8_t resultCode, c SendMsgToUIService(JS_UNINSTALL_SUCESS_TO_UI, 0, &bundleData, sizeof(BundleData)); report.operationResult = UNINSTALL_OK; } - OHOS::SignMode::GetInstance().SetSignMode(true); } else if (resultCode == ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_BUNDLE_NUMBER) { report.operationResult = INSTALL_OVER_LIMIT; - OHOS::SignMode::GetInstance().SetSignMode(true); } else { report.operationResult = (status == INSTALL_CALLBACK) ? INSTALL_FAILED : UNINSTALL_FAILED; - OHOS::SignMode::GetInstance().SetSignMode(true); } AdapterFree(installMsg); WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "SendMsgToAppStore operationResult = %u", report.operationResult); @@ -79,7 +75,6 @@ errcode_t AppStorePkgOperation(uint8_t cmd_id, uint8_t type, void *usr_data, uin if (pkgFullName != nullptr) { (void)sprintf_s(pkgFullName, len, "%s%s", FS_DIR_APP_STORE, (char *)operInfo->pkgName); WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "AppStorePkgOperation install pkgFullName=%s", pkgFullName); - OHOS::SignMode::GetInstance().SetSignMode(false); InstallParam installParam = { .installLocation = 1, .keepData = false }; ret = OHOS::BundleMsClient::GetInstance().Install(pkgFullName, &installParam, InstallCallbackFunc); free(pkgFullName); @@ -87,7 +82,6 @@ errcode_t AppStorePkgOperation(uint8_t cmd_id, uint8_t type, void *usr_data, uin } else if (operInfo->operationType == PKG_OPERATION_TYPE_UNINSTALL) { StopJsApp((char*)operInfo->pkgName); WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "AppStorePkgOperation uninstall pkgName=%s", operInfo->pkgName); - OHOS::SignMode::GetInstance().SetSignMode(false); InstallParam installParam = { .installLocation = 1, .keepData = false }; ret = OHOS::BundleMsClient::GetInstance().Uninstall((char*)operInfo->pkgName, &installParam, UninstallCallbackFunc); } @@ -119,6 +113,7 @@ errcode_t AppStoreGetPkgList(uint8_t cmd_id, uint8_t type, void *usr_data, uint1 (void)strncpy_s((char*)unitInfo[i].pkgName, PKG_NAME_MAX_LENGTH, bundleInfos[i].bundleName, strlen(bundleInfos[i].bundleName)); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppStoreGetPkgList pkgName[%d] = %s", i, unitInfo[i].pkgName); + unitInfo[i].versionCode = bundleInfos[i].versionCode; } ret = msg_center_send_data(MSGCENTER_CMD_APP_STORE, type, infoList, len); free(infoList); diff --git a/code/sdk/application/wearable/service/app_store/app_store.h b/code/sdk/application/wearable/service/app_store/app_store.h index e5b28b345..7bbc93b96 100644 --- a/code/sdk/application/wearable/service/app_store/app_store.h +++ b/code/sdk/application/wearable/service/app_store/app_store.h @@ -59,6 +59,7 @@ typedef struct { typedef struct { uint8_t pkgName[PKG_NAME_MAX_LENGTH]; + int32_t versionCode; } PkgUnitInfo; errcode_t AppStorePkgOperation(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); diff --git a/code/sdk/application/wearable/service/dial_market/CMakeLists.txt b/code/sdk/application/wearable/service/dial_market/CMakeLists.txt new file mode 100644 index 000000000..058f8dc76 --- /dev/null +++ b/code/sdk/application/wearable/service/dial_market/CMakeLists.txt @@ -0,0 +1,43 @@ +set(COMPONENT_NAME "dial_market") + +set(PUBLIC_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/ +) + +set(PRIVATE_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/../../ohos_deps + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits/gfx_utils + ${ROOT_DIR}/open_source/openharmony/base/startup/syspara_lite/include + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/format/interfaces/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/main/include/dial +) + +set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/dial_market_msg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dial_market.cpp +) + +set(COMPONENT_PUBLIC_CCFLAGS +) + +set(COMPONENT_CCFLAGS + -std=c++11 +) + +set(WHOLE_LINK + true +) + +set(PUBLIC_DEFINES +) + +set(PRIVATE_DEFINES + APP_PLATFORM_WATCHGT + CONFIG_ACELITE_ENABLE +) + +build_component() + + diff --git a/code/sdk/application/wearable/service/dial_market/dial_market.h b/code/sdk/application/wearable/service/dial_market/dial_market.h new file mode 100644 index 000000000..6110188e5 --- /dev/null +++ b/code/sdk/application/wearable/service/dial_market/dial_market.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: broadcast service api + * Author: CompanyName + * Create: 2021-11-11 + */ + +#ifndef DIAL_MARKET_H +#define DIAL_MARKET_H + +#include "msg_center_protocol.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#define MAX_CHIP_PLAT_LEN 5 +#define MAX_CHIP_MODEL_LEN 5 +#define MAX_OS_LEN 23 +#define MAX_API_LEVEL_LEN 3 +#define MAX_WATCH_PROTO_VER_LEN 4 +#define MAX_WATCH_INTERNAL_VER 6 +#define MAX_RESOLUTION_LEN 8 +#define MAX_SUPPORT_PROTOCOL 8 +#define MAX_WATCH_CNT 64 + +typedef enum msg_center_dial_market_type_id { + MSGCENTER_TYPE_ID_DM_GET_SYS_INFO = 0x1, + MSGCENTER_TYPE_ID_DM_GET_DEV_CAP = 0x2, + MSGCENTER_TYPE_ID_DM_GET_ONE_WATCH_INFO = 0x3, + MSGCENTER_TYPE_ID_DM_INSTALL_WATCH = 0x4, + MSGCENTER_TYPE_ID_DM_UNINSTALL_WATCH = 0x5, + MSGCENTER_TYPE_ID_DM_SET_WATCH = 0x6, + MSGCENTER_TYPE_ID_DM_GET_ALL_WATCH_INFO = 0x7, + MSGCENTER_TYPE_ID_DM_GET_CUR_WATCH_INFO = 0x8, +} msg_center_dial_market_type_id_t; + +typedef struct { + char chip_platform[MAX_CHIP_PLAT_LEN]; + char chip_model[MAX_CHIP_MODEL_LEN]; + char os_version[MAX_OS_LEN]; + char api_level[MAX_API_LEVEL_LEN]; + uint8_t watch_proto_support_cnt; + char watch_protocol_verion[MAX_SUPPORT_PROTOCOL][MAX_WATCH_PROTO_VER_LEN]; + char resolution[MAX_RESOLUTION_LEN]; +} watch_sys_info; + +typedef struct { + uint8_t kaleidoscope; + uint8_t effect_3D; + uint8_t interaction; + uint8_t video; + uint16_t video_format; /* 按照CodecFormat做位映射形成能力集 */ +} watch_dev_cap_info; + +typedef struct { + uint32_t uuid; + uint8_t install_state; + uint8_t is_current_watch; + uint8_t watch_protocol_version[MAX_WATCH_PROTO_VER_LEN]; + uint8_t watch_version[MAX_WATCH_INTERNAL_VER]; +} watch_dial_info; + +errcode_t msg_center_dial_market_get_sys_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_dev_cap(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_one_watch_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_install_watch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_uninstall_watch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_set_watch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_all_watch_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_dial_market_get_cur_watch_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif /* DIAL_MARKET_H */ diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index 360c83733..1a21912b2 100644 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -21,24 +21,10 @@ set(PRIVATE_HEADER ${ROOT_DIR}/application/wearable/service/xiaodu_navi_vector ${ROOT_DIR}/application/wearable/service/xiaodu_navi_vector/libs ${ROOT_DIR}/application/wearable/service/msg_center/src/notify/ketinput/include - ${ROOT_DIR}/application/wearable/nativeapp/nativelauncher/include - ${ROOT_DIR}/application/wearable/nativeabilityfwk/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarm/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/key/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclockmanage/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclocktimerconfig/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/main/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/callerlog/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/phoneservice/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/makephone/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/player/include - ${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include - ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits ) set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_protocol.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/client/msg_center_client.cpp @@ -134,6 +120,20 @@ set(PRIVATE_HEADER ${ROOT_DIR}/include/middleware/services/bts/common ${ROOT_DIR}/application/auto_ota ${ROOT_DIR}/application/wearable/service/xiaodu_navi_vector + ${ROOT_DIR}/application/wearable/service/msg_center/src/notify/ketinput/include + ${ROOT_DIR}/application/wearable/nativeapp/nativelauncher/include + ${ROOT_DIR}/application/wearable/nativeabilityfwk/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarm/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/key/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclockmanage/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/alarmclocktimerconfig/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/main/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/callerlog/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/phoneservice/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/makephone/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/player/include + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits ) if("JS_ENABLE" IN_LIST DEFINES) @@ -144,6 +144,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp ) else() set(SOURCES @@ -152,6 +153,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_self_cmd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp ) endif() diff --git a/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-cli/libmsg_center.a b/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-cli/libmsg_center.a index f08ef6530..f6ea17c48 100644 Binary files a/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-cli/libmsg_center.a and b/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-cli/libmsg_center.a differ diff --git a/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-ser/libmsg_center.a b/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-ser/libmsg_center.a index 41ad2aba2..c7c253e08 100644 Binary files a/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-ser/libmsg_center.a and b/code/sdk/application/wearable/service/msg_center/brandy-auto-ota-ser/libmsg_center.a differ diff --git a/code/sdk/application/wearable/service/msg_center/brandy-native-js-fd230/libmsg_center.a b/code/sdk/application/wearable/service/msg_center/brandy-native-js-fd230/libmsg_center.a index 0b1a2609a..0e24be78a 100644 Binary files a/code/sdk/application/wearable/service/msg_center/brandy-native-js-fd230/libmsg_center.a and b/code/sdk/application/wearable/service/msg_center/brandy-native-js-fd230/libmsg_center.a differ diff --git a/code/sdk/application/wearable/service/msg_center/brandy-native-js/libmsg_center.a b/code/sdk/application/wearable/service/msg_center/brandy-native-js/libmsg_center.a index 0b1a2609a..0e24be78a 100644 Binary files a/code/sdk/application/wearable/service/msg_center/brandy-native-js/libmsg_center.a and b/code/sdk/application/wearable/service/msg_center/brandy-native-js/libmsg_center.a differ diff --git a/code/sdk/application/wearable/service/msg_center/brandy-xts/libmsg_center.a b/code/sdk/application/wearable/service/msg_center/brandy-xts/libmsg_center.a index 998789235..c686df549 100644 Binary files a/code/sdk/application/wearable/service/msg_center/brandy-xts/libmsg_center.a and b/code/sdk/application/wearable/service/msg_center/brandy-xts/libmsg_center.a differ diff --git a/code/sdk/application/wearable/service/msg_center/include/msg_center_customer.h b/code/sdk/application/wearable/service/msg_center/include/msg_center_customer.h index 41578ba57..79cb07fac 100644 --- a/code/sdk/application/wearable/service/msg_center/include/msg_center_customer.h +++ b/code/sdk/application/wearable/service/msg_center/include/msg_center_customer.h @@ -23,6 +23,7 @@ extern "C" { void StartJsApp(char *bundleName); void StopJsApp(char *bundleName); void MsgCenterReportBtStatusToJS(uint16_t msgId); +bool MsgCenterNotifyProc(const Topic topic, Request* req); #endif #ifdef __cplusplus diff --git a/code/sdk/application/wearable/service/msg_center/include/msg_center_protocol.h b/code/sdk/application/wearable/service/msg_center/include/msg_center_protocol.h index 93961d39e..02cf29c8f 100644 --- a/code/sdk/application/wearable/service/msg_center/include/msg_center_protocol.h +++ b/code/sdk/application/wearable/service/msg_center/include/msg_center_protocol.h @@ -61,6 +61,7 @@ typedef enum msg_center_cmd_id { MSGCENTER_CMD_PING = 0x7, MSGCENTER_CMD_WATCH_CONNECT = 0x8, MSGCENTER_CMD_APP_STORE = 0x9, + MSGCENTER_CMD_DIAL_MARKET = 0xa, MSGCENTER_CMD_MAX } msg_center_cmd_id_t; diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/ketinput/include/NotifyOnKeyListener.h b/code/sdk/application/wearable/service/msg_center/src/notify/ketinput/include/NotifyOnKeyListener.h new file mode 100644 index 000000000..fd6b6bf47 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/ketinput/include/NotifyOnKeyListener.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024-2024. All rights reserved. + * Description: NotifyOnKeyListener.h + * Author: g30037431 + * Create: 2024-12-12 + */ + +#ifndef KEY_NOTIFY_INPUT_LISTENER_H +#define KEY_NOTIFY_INPUT_LISTENER_H + +#include "components/root_view.h" +#include "events/key_event.h" +#include "ohos_types.h" + +namespace OHOS { +class NotifyOnKeyListener : public RootView::OnKeyActListener { +public: + static NotifyOnKeyListener* GetInstance(); + bool OnKeyAct(UIView& view, const KeyEvent& event) override; + +private: + NotifyOnKeyListener() {} + ~NotifyOnKeyListener() {} + void OnKeyPress(void); + void OnKeyLongPress(const KeyEvent& event); + void OnKeyRelease(const KeyEvent& event); + void CallVolumeDipSwitchControl(uint8_t status); + void PlayerVolumeDipSwitchControl(uint8_t status); +private: + int32 pressFlag{0}; + int32 longPressFlag{0}; +}; +} +#endif // KEY_NOTIFY_INPUT_LISTENER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/ketinput/src/NotifyOnKeyListener.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/ketinput/src/NotifyOnKeyListener.cpp new file mode 100644 index 000000000..bfcc29b0b --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/ketinput/src/NotifyOnKeyListener.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024-2024. All rights reserved. + * Description: NotifyOnKeyListener.cpp + * Author:g30037431 + * Create: 2024-12-14 + */ + +#include "NotifyOnKeyListener.h" +#include "common/key_code.h" +#include "AppViewIDs.h" +#include "View.h" +#include "KeyInputListener.h" +#include "VolumeSettingView.h" +#include "VolumeSettingPresenter.h" +#include "VolumeSettingView.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "dock/input_device.h" +#include "notification_manager.h" +#include "AlarmPopUpPresenter.h" +#include "CallerLogModel.h" +#include "MainCallingPresenter.h" +#include "ApplistModel.h" +namespace OHOS { +static bool IsNotifyCallStatus() +{ + uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId(); + if (NotificationManager::GetInstance()->HasNotifyShowing() && + (notifyId == TOPIC_EVENT_HFP_WATCH_ACTIVE || notifyId == TOPIC_EVENT_HFP_PHONE_TO_WATCH)) { + return true; + } else { + return false; + } +} + +static void PressAlarmNotify() +{ + AlarmClockModel::GetInstance()->AlarmGetClockNum(); + AlarmPopUpPresenter::GetInstance()->DelayAlarmRing(); + NotificationManager::GetInstance()->StopNotify(); +} + +NotifyOnKeyListener *NotifyOnKeyListener::GetInstance() +{ + static NotifyOnKeyListener instance; + return &instance; +} + +void NotifyOnKeyListener::OnKeyPress(void) +{ + pressFlag = 1; // Short press the logo + return; +} + +void NotifyOnKeyListener::OnKeyLongPress(const KeyEvent &event) +{ + longPressFlag = 1; // Long press the logo + + uint16 keyID = event.GetKeyId(); + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button + NativeAbility::GetInstance().ChangeSlice(VIEW_REBOOT); // Switch to shutdown/restart card + } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons + // Switch to View System Version Card + } + return; +} + +void NotifyOnKeyListener::CallVolumeDipSwitchControl(uint8_t status) +{ + VolumeSliderEventListener *volumeSliderEventListener = nullptr; + if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) { + VolumeSettingView *settingView = GetvolumeSetting(); + if (settingView == nullptr) { + return; + } + volumeSliderEventListener = settingView->GetVolumeEventListener(); + if (volumeSliderEventListener == nullptr) { + return; + } + volumeSliderEventListener->ChangeVolume(static_cast(status)); + } else { + HonrsViewChange(); + NotificationManager::GetInstance()->SetVolumeScreenStatus(true); + } + return; +} + +void NotifyOnKeyListener::OnKeyRelease(const KeyEvent &event) +{ + uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); + uint16 keyID = event.GetKeyId(); + uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId(); + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button + if (longPressFlag == 0 && pressFlag == 1 && + NotificationManager::GetInstance()->HasNotifyShowing()) { // Short press the power button + if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Call notify + CallVolumeDipSwitchControl(VOLUMEUP); // Volume+ + } else if (notifyId == TOPIC_EVENT_ALARM_RING) { // Main dial + PressAlarmNotify(); // When currently on the alarm notification page, process the alarm first before switching pages + } + } + } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons + if (longPressFlag == 0 && pressFlag == 1) { // Short press the function key + if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Volume card + CallVolumeDipSwitchControl(VOLUMEDOWN); // Volume- + } else { + // Switch to user configured shortcut card + } + } + } + + pressFlag = 0; + longPressFlag = 0; + return; +} + +bool NotifyOnKeyListener::OnKeyAct(UIView &view, const KeyEvent &event) +{ + UNUSED(view); + uint8 state = event.GetState(); + + switch (state) { + case InputDevice::STATE_PRESS: // Short press + OnKeyPress(); + break; +#ifdef __LITEOS_M__ + case InputDevice::STATE_LONG_PRESS: // Long press + OnKeyLongPress(event); + break; +#endif + case InputDevice::STATE_RELEASE: // Release + OnKeyRelease(event); + break; + default: + break; + } + return true; +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c b/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c index 976e3c5c0..6f45b72ff 100644 --- a/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c +++ b/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c @@ -16,7 +16,6 @@ #include "soc_dpu_type.h" #include "soc_mipi_tx.h" #include "pmu_ldo.h" -#include "soc_gmmu_api.h" #include "pm_lp_stub.h" #include "hal_pmu_ldo.h" #include "cmsis_os2.h" @@ -151,13 +150,6 @@ static uint32_t action_display_lcd_on() POWER_DISPLAY_PRINT_ERR(0, "drv vau resume error ret=%x\r\n", ret); return ERRCODE_FAIL; } -#ifdef SUPPORT_GPU_GMMU - ret = drv_gmmu_resume(NULL); - if (ret != 0) { - POWER_DISPLAY_PRINT_ERR(0, "drv gmmu resume error ret=%x\r\n", ret); - return ERRCODE_FAIL; - } -#endif ret = uapi_lcd_init(); if (ret != 0 && ret != EXT_ERR_MIPI_ALREADY_INIT) { POWER_DISPLAY_PRINT_ERR(0, "LCD init error ret=%x\r\n", ret); @@ -215,13 +207,7 @@ static uint32_t action_display_lcd_off() POWER_DISPLAY_PRINT_ERR(0, "drv dpu suspend error ret=%x\r\n", ret); } #endif -#ifdef SUPPORT_GPU_GMMU - ret = drv_gmmu_suspend(NULL); - if (ret != 0) { - POWER_DISPLAY_PRINT_ERR(0, "drv gmmu suspend error ret=%x\r\n", ret); - return ERRCODE_FAIL; - } -#endif + ret = uapi_lcd_deinit(); if (ret != 0) { POWER_DISPLAY_PRINT_ERR(0, "lcd deinit error ret=%x\r\n", ret); @@ -291,6 +277,7 @@ int32_t action_display_execute_entry(uint16_t action_bitmap, uint16_t new_state, } POWER_DISPLAY_PRINT_DEBUG(0, "turn off success."); } + sc->press_state = false; sc->current_state = new_state; return ret; diff --git a/code/sdk/application/wearable/service/xiaodu_voice/xiaodu_voice.cpp b/code/sdk/application/wearable/service/xiaodu_voice/xiaodu_voice.cpp index ac4f7fffb..6ca6ae711 100644 --- a/code/sdk/application/wearable/service/xiaodu_voice/xiaodu_voice.cpp +++ b/code/sdk/application/wearable/service/xiaodu_voice/xiaodu_voice.cpp @@ -79,7 +79,8 @@ static errcode_t pcm_stream_task_body(void *data) for (;;) { osStatus_t ret = osMessageQueueGet(g_pcm_stream_msg_queue_id, &msg, nullptr, osWaitForever); if (ret != osOK) { - continue; + msg.msg_id = MSGCENTER_TYPE_ID_XIAODU_END_RECORD; + msg.data = nullptr; } if (msg.msg_id == MSGCENTER_TYPE_ID_XIAODU_SEND_PCM_STREAM) { res = msg_center_xiaodu_send_pcm_stream(MSGCENTER_CMD_XIAODU, MSGCENTER_TYPE_ID_XIAODU_SEND_PCM_STREAM, diff --git a/code/sdk/application/wstp/at_service/app/app_at_process.c b/code/sdk/application/wstp/at_service/app/app_at_process.c index d3f4738da..b12ef2117 100644 --- a/code/sdk/application/wstp/at_service/app/app_at_process.c +++ b/code/sdk/application/wstp/at_service/app/app_at_process.c @@ -75,7 +75,6 @@ #include "lpc_core.h" #include "diag_msg.h" #include "pmu_ldo.h" -#include "soc_gmmu_api.h" #include "pinctrl.h" #include "non_os_reboot.h" #include "km.h" @@ -1178,13 +1177,6 @@ uint32_t mcu_pm_lcd_on(uint8_t *para, uint32_t para_len) wstp_print("drv vau resume error ret=%x\r\n", ret); return ERRCODE_FAIL; } -#ifdef SUPPORT_GPU_GMMU - ret = drv_gmmu_resume(NULL); - if (ret != 0) { - wstp_print("drv gmmu resume error ret=%x\r\n", ret); - return ERRCODE_FAIL; - } -#endif ret = uapi_lcd_init(); if (ret != 0 && ret != EXT_ERR_MIPI_ALREADY_INIT) { wstp_print("LCD init error ret=%x\r\n", ret); @@ -1674,13 +1666,6 @@ uint32_t mcu_pm_lcd_off(uint8_t *para, uint32_t para_len) wstp_print("drv dpu suspend error ret=%x\r\n", ret); return ERRCODE_FAIL; } -#endif -#ifdef SUPPORT_GPU_GMMU - ret = drv_gmmu_suspend(NULL); - if (ret != 0) { - wstp_print("drv gmmu suspend error ret=%x\r\n", ret); - return ERRCODE_FAIL; - } #endif ret = uapi_lcd_deinit(); if (ret != 0) { @@ -1716,7 +1701,8 @@ uint32_t mcu_pm_remove_vote(uint8_t *para, uint32_t para_len) unused(para_len); uint8_t cnt = pm_veto_get_id_cnt(PM_ID_DEBUG); - if (cnt == 1) { + if (cnt > 0) { + wstp_print("MCU remove pm_id_debug vote\r\n"); uapi_pm_remove_sleep_veto(PM_ID_DEBUG); } else { wstp_print("MCU has delete pm_id_debug vote\r\n"); @@ -2704,6 +2690,36 @@ static uint32_t mcu_sched_statistis_stop(uint8_t *para, uint32_t para_len) } #endif +#ifdef CFG_DRIVERS_SDIO +typedef enum { + SDIO_TEST_READ_BYTE = 1, + SDIO_TEST_RESET, + + SDIO_TEST_BUTT, +} SDIO_TEST_CASE_T; + +static uint32_t mcu_sdio_test(uint8_t *para, uint32_t para_len) +{ + unused(para_len); + char *ptr = (char *)para; + uint32_t inputpara = strtoul(ptr, NULL, 0); + + wstp_print("enter mcu_sdio_test input %u \r\n", inputpara); + switch (inputpara) { + case SDIO_TEST_READ_BYTE: + mmc_test_sdio_read_byte(); + break; + case SDIO_TEST_RESET: + mmc_test_sdio_reset(); + break; + default: + break; + } + + return ERRCODE_SUCC; +} +#endif + static const app_process_table g_app_funcs[] = { { RESET, mcu_os_sys_reset }, { FSTEST, mcu_fs_test }, @@ -2810,6 +2826,9 @@ static const app_process_table g_app_funcs[] = { { SCHEDSTART, mcu_sched_statistis_start }, { SCHEDSTOP, mcu_sched_statistis_stop }, #endif +#ifdef CFG_DRIVERS_SDIO + { SDIOTEST, mcu_sdio_test}, +#endif }; void app_at_process(uint8_t *data, uint32_t data_len) diff --git a/code/sdk/application/wstp/at_service/app/app_cmd_manager.c b/code/sdk/application/wstp/at_service/app/app_cmd_manager.c index 455289769..0b2dc24b8 100644 --- a/code/sdk/application/wstp/at_service/app/app_cmd_manager.c +++ b/code/sdk/application/wstp/at_service/app/app_cmd_manager.c @@ -1023,6 +1023,19 @@ static uint32_t app_sched_statistis_stop(uint8_t *para, uint32_t para_len, char } #endif +#ifdef CFG_DRIVERS_SDIO +static uint32_t app_sdio_test(uint8_t *para, uint32_t para_len, char *str_cmd) +{ + unused(str_cmd); + if (para == NULL) { + return ERRCODE_FAIL; + } + + app_pkg_msg_send(SDIOTEST, DIAG_CONTROL_FALSE, para, para_len); + return ERRCODE_SUCC; +} +#endif + static const at_cmd_table_t g_app_cmd[] = { /* 无参数无特殊处理AT命令 */ { "AT^HEAPINFO", parse_heap_info_handle, "" }, @@ -1154,6 +1167,9 @@ static const at_cmd_table_t g_app_cmd[] = { { "AT^SCHEDSTART", app_sched_statistis_start, "" }, { "AT^SCHEDSTOP", app_sched_statistis_stop, "" }, #endif +#ifdef CFG_DRIVERS_SDIO + { "AT^SDIOTEST", app_sdio_test, "" }, +#endif }; at_cmd_table_t *get_app_cmd_table(uint32_t *cmd_count) diff --git a/code/sdk/application/wstp/at_service/app/app_msg_manager.h b/code/sdk/application/wstp/at_service/app/app_msg_manager.h index f07366851..4456e8352 100644 --- a/code/sdk/application/wstp/at_service/app/app_msg_manager.h +++ b/code/sdk/application/wstp/at_service/app/app_msg_manager.h @@ -116,6 +116,7 @@ typedef enum { PERFSTOP = 0x55, SCHEDSTART = 0x56, SCHEDSTOP = 0x57, + SDIOTEST = 0x58, MSG_ID_MAX_BUTT, } app_msg_id; diff --git a/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h b/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h index 9da2ab06e..e0ba960bd 100644 --- a/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h +++ b/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h @@ -33,16 +33,7 @@ extern "C" { #define GRAPHIC_MAX_PARAM_LEN 128 typedef int32_t (*GraphicProcessFunc)(commu_inter_info_t *cmd); -typedef int32_t (*pfn_gmmu_suspend)(void); -typedef int32_t (*pfn_gmmu_resume)(void); -typedef struct { - pfn_gmmu_suspend suspend; - pfn_gmmu_resume resume; -} drv_gmmu_export_func; - -int32_t drv_gmmu_module_init(void); -void drv_gmmu_module_exit(void); int32_t uapi_vau_module_init(void); void uapi_vau_module_exit(void); int32_t uapi_dpu_module_init(void); diff --git a/code/sdk/application/wstp/at_service/graphic/sample/gpu_sample.c b/code/sdk/application/wstp/at_service/graphic/sample/gpu_sample.c index c17e91146..55382c6b9 100644 --- a/code/sdk/application/wstp/at_service/graphic/sample/gpu_sample.c +++ b/code/sdk/application/wstp/at_service/graphic/sample/gpu_sample.c @@ -32,7 +32,6 @@ extern td_s32 vau_dfx_proc_read(int argc, const char *argv[]); extern td_s32 jpeg_dfx_proc_read(int argc, const char *argv[]); -extern td_s32 gmmu_dfx_print_proc_info(int argc, const char *argv[]); static td_void wstp_draw_box(ext_rect *rect, td_u32 stride, td_char *mem_start, td_u32 color, td_u32 bpp) { @@ -359,10 +358,6 @@ td_void wstp_gpu_sample_process(int argc, char *argv[]) } else if (strcmp((char *)argv[0], "jpeg_proc") == 0) { #ifdef SUPPORT_GPU_JPEG jpeg_dfx_proc_read(argc - 1, argv + 1); -#endif - } else if (strcmp((char *)argv[0], "gmmu_proc") == 0) { -#ifdef SUPPORT_GPU_GMMU - gmmu_dfx_print_proc_info(argc - 1, argv + 1); #endif } else { #ifdef SUPPORT_GPU_TEST diff --git a/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp b/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp index 31c0986bc..54163c3ac 100644 --- a/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp +++ b/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp @@ -19,9 +19,10 @@ #include "ability_manager.h" #include "js_fwk_common.h" #include "global.h" -#include "gt_bundle_manager_service.h" +#include "msg_center_customer.h" #include "ApplistModel.h" #include "bundle_manager.h" +#include #ifdef SUPPORT_AT_LOCATION #include "location_sample.h" #include @@ -29,13 +30,14 @@ #ifdef SUPPORT_AT_SENSOR #include "sensor_sample.h" #endif +#include #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0])) -#define OHOSFWK_MAX_ARGC 8 -#define OHOSFWK_MAX_ARGV_LEN 64 +#define OHOSFWK_MAX_ARGC 8 +#define OHOSFWK_MAX_ARGV_LEN 64 -#define OHOSFWK_SUCCESS 0 -#define OHOSFWK_FAILED (-1) +#define OHOSFWK_SUCCESS 0 +#define OHOSFWK_FAILED (-1) static void ReceiveCallback(const uint8_t resultCode, const void *resultMessage) { @@ -62,8 +64,8 @@ static void ReceiveCallback(const uint8_t resultCode, const void *resultMessage) AdapterFree(installMsg); } -static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN], uint32_t* argc) +static int ConvertCmdToParam( + uint8_t *para, uint32_t paraLen, uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN], uint32_t *argc) { uint32_t pos = 0; *argc = 0; @@ -107,7 +109,7 @@ static uint32_t OhosfwkATCmdAmExitJsApp(uint8_t *para, uint32_t paraLen, char *s static uint32_t OhosfwkATCmdBmInstall(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; int ret = ConvertCmdToParam(para, paraLen, argv, &argc); @@ -120,11 +122,11 @@ static uint32_t OhosfwkATCmdBmInstall(uint8_t *para, uint32_t paraLen, char *str WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OHOSFWK ATCMD Installing Package Failed\n"); return ERRCODE_FAIL; } - InstallParam installParam = { .installLocation = 1, .keepData = true }; - if (strcmp("rmdata", (char*)argv[1]) == 0) { + InstallParam installParam = {.installLocation = 1, .keepData = true}; + if (strcmp("rmdata", (char *)argv[1]) == 0) { installParam.keepData = false; } - OHOS::BundleMsClient::GetInstance().Install((char*)argv[0], &installParam, ReceiveCallback); + OHOS::BundleMsClient::GetInstance().Install((char *)argv[0], &installParam, ReceiveCallback); return ERRCODE_SUCC; } @@ -132,22 +134,22 @@ static uint32_t OhosfwkATCmdBmInstall(uint8_t *para, uint32_t paraLen, char *str static uint32_t OhosfwkATCmdBmUninstall(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; - + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); if (ret != OHOSFWK_SUCCESS) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OHOSFWK ATCMD Convert Command Failed\n"); return ERRCODE_FAIL; } - + if (argc != 1) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OHOSFWK ATCMD Uninstalling Package Failed\n"); return ERRCODE_FAIL; } - + char *bundleName = (char *)argv[0]; - ElementName* topAbility = OHOS::AbilityMsClient::GetInstance().GetTopAbility(); + ElementName *topAbility = OHOS::AbilityMsClient::GetInstance().GetTopAbility(); if ((topAbility != nullptr) && (strcmp(topAbility->bundleName, bundleName) == 0)) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "js app is active, first need terminate"); @@ -155,7 +157,7 @@ static uint32_t OhosfwkATCmdBmUninstall(uint8_t *para, uint32_t paraLen, char *s OHOS::AbilityMsClient::GetInstance().TerminateAbility(token); } - InstallParam installParam = { .installLocation = 1, .keepData = false }; + InstallParam installParam = {.installLocation = 1, .keepData = false}; OHOS::BundleMsClient::GetInstance().Uninstall(bundleName, &installParam, ReceiveCallback); FreeElement(topAbility); return ERRCODE_SUCC; @@ -164,7 +166,7 @@ static uint32_t OhosfwkATCmdBmUninstall(uint8_t *para, uint32_t paraLen, char *s static uint32_t OhosfwkATCmdBmSet(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; int ret = ConvertCmdToParam(para, paraLen, argv, &argc); @@ -192,7 +194,7 @@ static uint32_t OhosfwkATCmdBmSet(uint8_t *para, uint32_t paraLen, char *strComm static uint32_t OhosfwkATCmdAmChangeNativeSlice(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; int ret = ConvertCmdToParam(para, paraLen, argv, &argc); if (ret != OHOSFWK_SUCCESS) { @@ -212,7 +214,7 @@ static uint32_t OhosfwkATCmdAmChangeNativeSlice(uint8_t *para, uint32_t paraLen, static uint32_t OhosfwkATCmdAmStartJsApp(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; int ret = ConvertCmdToParam(para, paraLen, argv, &argc); @@ -248,9 +250,9 @@ static uint32_t OhosfwkATCmdDfxJsMemoryInfo(uint8_t *para, uint32_t paraLen, cha static uint32_t OhosfwkATCmdBmGetAppInfo(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; - + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); if (ret != OHOSFWK_SUCCESS) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OHOSFWK ATCMD Convert Command Failed\n"); @@ -268,39 +270,39 @@ static uint32_t OhosfwkATCmdBmGetAppInfo(uint8_t *para, uint32_t paraLen, char * if (ret != OHOSFWK_SUCCESS) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "failed to get bundleInfo!"); } else { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "\n" - "-----------------AppInfo----------------\n" - "bundleName: %s\n" - "appId: %s\n" - "label: %s\n" - "versionCode: %d\n" - "targetApi: %d\n" - "isSystemApp: %s\n" - "compatibleApi: %d\n" - "versionName: %s\n" - "vendor: %s\n" - "numOfModule: %d", - bundleInfo.bundleName, - bundleInfo.appId, - bundleInfo.label, - bundleInfo.versionCode, - bundleInfo.targetApi, - bundleInfo.isSystemApp ? "true" : "false", - bundleInfo.compatibleApi, - bundleInfo.versionName, - bundleInfo.vendor, - bundleInfo.numOfModule - ); - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "\n" - "bigIconPath: %s\n" - "codePath: %s\n" - "dataPath: %s\n" - "--------------AppInfo End---------------\n", - bundleInfo.bigIconPath, - bundleInfo.codePath, - bundleInfo.dataPath - ); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, + "\n" + "-----------------AppInfo----------------\n" + "bundleName: %s\n" + "appId: %s\n" + "label: %s\n" + "versionCode: %d\n" + "targetApi: %d\n" + "isSystemApp: %s\n" + "compatibleApi: %d\n" + "versionName: %s\n" + "vendor: %s\n" + "numOfModule: %d", + bundleInfo.bundleName, + bundleInfo.appId, + bundleInfo.label, + bundleInfo.versionCode, + bundleInfo.targetApi, + bundleInfo.isSystemApp ? "true" : "false", + bundleInfo.compatibleApi, + bundleInfo.versionName, + bundleInfo.vendor, + bundleInfo.numOfModule); + + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, + "\n" + "bigIconPath: %s\n" + "codePath: %s\n" + "dataPath: %s\n" + "--------------AppInfo End---------------\n", + bundleInfo.bigIconPath, + bundleInfo.codePath, + bundleInfo.dataPath); } return ERRCODE_SUCC; } @@ -317,31 +319,46 @@ static uint32_t OhosfwkATCmdBmGetAppList(uint8_t *para, uint32_t paraLen, char * if (ret != OHOSFWK_SUCCESS) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Get bundleInfos Failed\n"); return ERRCODE_FAIL; - }else { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "\n" + } else { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, + "\n" "----------------- AppList Start --------------------\n"); for (int32_t i = 0; i < count; i++) { - + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, - "App:%d-----------------\n" - "label: %s\n" - "bundleName: %s\n", - i+1, - bundleInfos[i].bundleName, - bundleInfos[i].label - ); + "App:%d-----------------\n" + "label: %s\n" + "bundleName: %s\n", + i + 1, + bundleInfos[i].bundleName, + bundleInfos[i].label); } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "\n" + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, + "\n" "----------------- AppList End -----------------------\n"); } return ERRCODE_SUCC; } +void ScanPackagesResultCallback(const uint8_t resultCode, const void* resultMessage) +{ + if (resultCode == 0) { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Scan Packages Succeeded.\n"); + OHOS::ApplistModel::GetInstance().SetInitFlag(false); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Set InitFlag false Succeeded\n"); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Scan Packages Failed.\n"); + if (resultMessage != nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[ERROR] %s\n", reinterpret_cast(resultMessage)); + } + } +} + static uint32_t OhosfwkATCmdChangeLanguage(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; int ret = ConvertCmdToParam(para, paraLen, argv, &argc); @@ -360,18 +377,46 @@ static uint32_t OhosfwkATCmdChangeLanguage(uint8_t *para, uint32_t paraLen, char WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Language changed to %s\n", languageRegion); - bool scanResult = ScanPackages(nullptr); + ScanPackages(ScanPackagesResultCallback); - if (scanResult) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Scan Packages Succeeded"); - } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Scan Packages Failed"); + return ERRCODE_SUCC; +} + +static uint32_t OhosfwkATStartNotify(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "in OhosfwkATStartNotify para:%s\n", para); + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; + uint32_t argc = 0; + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != OHOSFWK_SUCCESS) { return ERRCODE_FAIL; } - - OHOS::ApplistModel::GetInstance().SetInitFlag(false); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Set InitFlag false Succeeded"); - + uint32_t times = 1; + uint32_t msleepTime = 500; + if (argc == 2) { + char *strtimes = (char *)argv[1]; + times = atoi(strtimes); + } else if (argc == 3) { + char *strtimes = (char *)argv[1]; + times = atoi(strtimes); + char *strMsleepTime = (char *)argv[2]; + msleepTime = atoi(strMsleepTime); + } else if (argc < 1) { + return ERRCODE_FAIL; + } + char *topicstr = (char *)argv[0]; + uint16_t topicId = atoi(topicstr); + times = ((msleepTime * times) > 60000) ? 1 : times; + for (uint32_t i = 0; i < times; i++) { + ret = MsgCenterNotifyProc(topicId, nullptr); + if (ret != true) { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "times:%d faild\n", i); + return ERRCODE_FAIL; + } + if (i != times - 1) { + usleep(1000 * msleepTime); + } + } return ERRCODE_SUCC; } @@ -393,7 +438,7 @@ static uint32_t OhosfwkATCmdLocation(uint8_t *para, uint32_t paraLen, char *strC { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "in OhosfwkATCmdLocation para:%s\n", para); unused(strCommonCmd); - uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = { 0 }; + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; uint32_t argc = 0; int ret = ConvertCmdToParam(para, paraLen, argv, &argc); @@ -463,18 +508,19 @@ static uint32_t OhosfwkATCmdSensor(uint8_t *para, uint32_t paraLen, char *strCom } #endif static const at_cmd_table_t g_ohosfwk_cmd[] = { - { (char *)"AT^OHOSFWK_AM_EXIT_JSAPP", OhosfwkATCmdAmExitJsApp, (char *)"00 00 00 00" }, - { (char *)"AT^OHOSFWK_BM_INSTALL", OhosfwkATCmdBmInstall, (char *)"00 00 00 01" }, - { (char *)"AT^OHOSFWK_BM_SET", OhosfwkATCmdBmSet, (char *)"00 00 00 02" }, - { (char *)"AT^OHOSFWK_BM_UNINSTALL", OhosfwkATCmdBmUninstall, (char *)"00 00 00 03" }, - { (char *)"AT^OHOSFWK_AM_CHANGENATIVESLICE", OhosfwkATCmdAmChangeNativeSlice, (char *)"00 00 00 04" }, - { (char *)"AT^OHOSFWK_AM_START_JS_APP", OhosfwkATCmdAmStartJsApp, (char *)"00 00 00 05" }, - { (char *)"AT^OHOSFWK_DFX_JS_MEMORY_INFO", OhosfwkATCmdDfxJsMemoryInfo, (char *)"00 00 00 06" }, - { (char *)"AT^OHOSFWK_CHANGE_LANGUAGE", OhosfwkATCmdChangeLanguage, (char *)"00 00 00 07" }, - { (char *)"AT^OHOSFWK_BM_GET_APPINFO", OhosfwkATCmdBmGetAppInfo, (char *)"00 00 00 10" }, - { (char *)"AT^OHOSFWK_BM_GET_APPLIST", OhosfwkATCmdBmGetAppList, (char *)"00 00 00 11" }, + {(char *)"AT^OHOSFWK_AM_EXIT_JSAPP", OhosfwkATCmdAmExitJsApp, (char *)"00 00 00 00"}, + {(char *)"AT^OHOSFWK_BM_INSTALL", OhosfwkATCmdBmInstall, (char *)"00 00 00 01"}, + {(char *)"AT^OHOSFWK_BM_SET", OhosfwkATCmdBmSet, (char *)"00 00 00 02"}, + {(char *)"AT^OHOSFWK_BM_UNINSTALL", OhosfwkATCmdBmUninstall, (char *)"00 00 00 03"}, + {(char *)"AT^OHOSFWK_AM_CHANGENATIVESLICE", OhosfwkATCmdAmChangeNativeSlice, (char *)"00 00 00 04"}, + {(char *)"AT^OHOSFWK_AM_START_JS_APP", OhosfwkATCmdAmStartJsApp, (char *)"00 00 00 05"}, + {(char *)"AT^OHOSFWK_DFX_JS_MEMORY_INFO", OhosfwkATCmdDfxJsMemoryInfo, (char *)"00 00 00 06"}, + {(char *)"AT^OHOSFWK_CHANGE_LANGUAGE", OhosfwkATCmdChangeLanguage, (char *)"00 00 00 07"}, + {(char *)"AT^OHOSFWK_BM_GET_APPINFO", OhosfwkATCmdBmGetAppInfo, (char *)"00 00 00 10"}, + {(char *)"AT^OHOSFWK_BM_GET_APPLIST", OhosfwkATCmdBmGetAppList, (char *)"00 00 00 11"}, + {(char *)"AT^OHOSFWK_MSG_START_NOTIFY", OhosfwkATStartNotify, (char *)"00 00 00 12"}, #ifdef SUPPORT_AT_LOCATION - { (char *)"AT^OHOSFWK_LOCATION", OhosfwkATCmdLocation, (char *)"00 00 00 08" }, + {(char *)"AT^OHOSFWK_LOCATION", OhosfwkATCmdLocation, (char *)"00 00 00 08"}, #endif #ifdef SUPPORT_AT_SENSOR {(char *)"AT^OHOSFWK_SENSOR", OhosfwkATCmdSensor, (char *)"00 00 00 09"}, diff --git a/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c b/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c index 20390f41b..48e79357e 100644 --- a/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c +++ b/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c @@ -23,18 +23,19 @@ static uint32_t g_clock_ulp_ssb = 3276800; #define RCXO_32K_SEL_MASK 12 #define CALIBRATION_CYCLE_MUL 0x200 #define CALIBRATION_CLOCK_MUL 100 +#define ULP_LOCK_REG 0x5702c510 calendar_regs_t *g_calendar_reg = SSB_CALENDAR_BASE_ADDR; static uint64_t uapi_ulp_systick_get_count(void) { uint64_t count = 0; - + writew(ULP_LOCK_REG, 0x1); count = (uint64_t)readw(ULP_SYSTICK_VAL3) << 48U; count |= (uint64_t)readw(ULP_SYSTICK_VAL2) << 32U; count |= (uint64_t)readw(ULP_SYSTICK_VAL1) << 16U; count |= (uint64_t)readw(ULP_SYSTICK_VAL0); - + writew(ULP_LOCK_REG, 0x0); return count; } diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 53c85cae4..97f89fbc0 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -150,7 +150,7 @@ target = { 'CONFIG_ZDIAG_AUDIO_PROC_SUPPORT', 'CONFIG_ZDIAG_AUDIO_DUMP_SUPPORT', 'CONFIG_ZDIAG_AUDIO_PROBE_SUPPORT', 'CONFIG_SEA_PHS_SUPPORT', 'SUPPORT_BLE', 'SUPPORT_BREDR', 'ENABLE_UIKIT', 'SUPPORT_GPU_JPEG', 'SUPPORT_GPU_GMMU', 'SUPPORT_GPU_OPENVG', 'CONFIG_DIAG_GPU_PROC_SUPPORT', 'SW_UART_DEBUG', 'SAVE_EXC_INFO', 'HASH_MEM_COPY', 'JS_ENABLE', 'CONFIG_LOW_POWER_TEST', 'SUPPORT_OHOSFWK', - 'ENABLE_ECC', 'XTS_SUPPORT', 'SUPPORT_ALIPAY_SEC'], + 'ENABLE_ECC', 'XTS_SUPPORT', 'SUPPORT_ALIPAY_SEC','SUPPORT_RC_CALIBRATION'], 'ram_component': ["algorithm", "dfx_port_brandy", "dfx_update", 'dfx_nv', "osal", "arch_port", "-:testsuite", "liteos_port", 'lcd', 'qspi_display', 'dfx_file_operation', 'psram', 'hal_mipi', 'mipi_tx', 'non_os', 'touch', diff --git a/code/sdk/build/config/target_config/brandy/param_sector/param_sector_no_dsp.json b/code/sdk/build/config/target_config/brandy/param_sector/param_sector_no_dsp.json new file mode 100644 index 000000000..9f83d6e81 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/param_sector/param_sector_no_dsp.json @@ -0,0 +1,58 @@ +{ + "Partition_Tbl":{ + "image_id" : "0x4B87A52D", + "stru_ver" : "0x00010000", + "version" : "0x00000000", + "param_info_description" : [ + "Address Constraints: flash type must fill with relative address, RAM regions must fill with absolute address.", + "Item ID Constraints: ssb type: 0x00 ~ 0x0F, Relative address, Size", + " root public key and signature: 0x10 ~ 0x1F, Relative address, Size", + " firmware on flash: 0x20 ~ 0x2F, Relative address, Size", + " data on flash: 0x30 ~ 0x3F, Relative address, Size", + + "Fixed item id: 0x00: ssb", + " 0x01: ssb_backup", + " 0x10: configure RootPubKey", + " 0x11: signature certificate", + " 0x12: ssb image signature", + " 0x13: signature certificate backup", + " 0x14: ssb image backup signature", + " 0x15: algorithm signature", + " 0x16: recovery signature", + " 0x17: bt_image signature", + " 0x18: dsp_main_image signature", + " 0x19: dsp_overlay_image signature", + " 0x1A: acpu_image signature", + " 0x20: recovery", + " 0x21: bt_image", + " 0x22: dsp_main_image", + " 0x23: dsp_overlay_image", + " 0x24: acpu_image", + " 0x30: nv_data", + " 0x31: fota_data" + ], + "param_info" : [ + ["0x00", "0x00000000", "0x00020000"], + ["0x01", "0x00020000", "0x00020000"], + ["0x10", "0x00040000", "0x00001000"], + ["0x11", "0x00041000", "0x00001000"], + ["0x12", "0x00042000", "0x00001000"], + ["0x13", "0x00043000", "0x00001000"], + ["0x14", "0x00044000", "0x00001000"], + ["0x15", "0x00045000", "0x00001000"], + ["0x16", "0x00046000", "0x00001000"], + ["0x17", "0x00047000", "0x00001000"], + ["0x18", "0xFFFFFFFF", "0x00000000"], + ["0x19", "0xFFFFFFFF", "0x00000000"], + ["0x1a", "0x0004A000", "0x00001000"], + ["0x20", "0x00050000", "0x00040000"], + ["0x21", "0x00090000", "0x00070000"], + ["0x22", "0xFFFFFFFF", "0x00000000"], + ["0x23", "0xFFFFFFFF", "0x00000000"], + ["0x24", "0x00100000", "0x006F9000"], + ["0x30", "0x007F9000", "0x00004000"], + ["0x31", "0x007FD000", "0x00003000"] + ] + }, + "Output_file_prefix":"AIoT" +} diff --git a/code/sdk/build/config/target_config/common_config.py b/code/sdk/build/config/target_config/common_config.py index fb050caec..80b367632 100644 --- a/code/sdk/build/config/target_config/common_config.py +++ b/code/sdk/build/config/target_config/common_config.py @@ -84,7 +84,7 @@ component_set = { 'plugin_demuxer_mjpeg', 'plugin_protocol_https', 'audio_port_common', 'plugin_demuxer_raw'], 'media_target4': ['audio_manager', 'audio_service', 'audio_stream', 'audio_utils', 'media_common', 'audio_hw', 'audio_primary_port', 'audio_bluetooth_port', 'audio_modem_port', 'media_hal_common', - 'audio_port_common', 'media_sample_wrapper'], + 'audio_port_common', 'media_sample_wrapper', 'audio_decrypt'], 'gpu': ['gfx_rm', 'gpu'], 'gpu_test': ['test_gpu'], 'graphic_uikit': ['cjson_static', 'display_gfx', 'display_gralloc', 'display_layer', 'graphic_input', 'graphic_service', diff --git a/code/sdk/build/script/cmake_builder.py b/code/sdk/build/script/cmake_builder.py index 04fa336ca..26326bcfa 100644 --- a/code/sdk/build/script/cmake_builder.py +++ b/code/sdk/build/script/cmake_builder.py @@ -186,7 +186,10 @@ class CMakeBuilder(BuildEnvironment): if "CFG_FLASH_SIZE=16" in defines: self.pack_fwpkg(env.get('chip'), target, "0x1000000") else: - self.pack_fwpkg(env.get('chip'), target, "0x800000") + if "CFG_LOAD_FROM_FS" in defines: + self.pack_fwpkg(env.get('chip'), target, "0x800000", "True") + else: + self.pack_fwpkg(env.get('chip'), target, "0x800000") if not run_custom_cmd(env, target, 'build_post'): self.print_build_result(target, 1) @@ -394,11 +397,11 @@ class CMakeBuilder(BuildEnvironment): print(f"ERROR! :{bin1} is not same with {bin2}") sys.exit(1) - def pack_fwpkg(self, chip, target_name, flash_size): + def pack_fwpkg(self, chip, target_name, flash_size, no_dsp="False"): # bin packet all in one packet_script_path = os.path.join(pkg_tools_path, 'packet.py') print("packet ing...") - errcode = exec_shell([self.python_path, packet_script_path, chip, target_name, flash_size], None, True) + errcode = exec_shell([self.python_path, packet_script_path, chip, target_name, flash_size, no_dsp], None, True) if errcode != 0: print("packet error!") self.print_build_result(target_name, errcode) diff --git a/code/sdk/drivers/adapter/ohos_3.2/iot_gpio.c b/code/sdk/drivers/adapter/ohos_3.2/iot_gpio.c index f40ea0d18..d45609946 100644 --- a/code/sdk/drivers/adapter/ohos_3.2/iot_gpio.c +++ b/code/sdk/drivers/adapter/ohos_3.2/iot_gpio.c @@ -85,6 +85,9 @@ unsigned int IoTGpioGetInputVal(unsigned int id, IotGpioValue *val) static void GpioCallbackFunc(pin_t id, uintptr_t arg) { unused(arg); + if (id >= PIN_NONE) { + return; + } if (g_iot_gpio_callback[id].func) { g_iot_gpio_callback[id].func(g_iot_gpio_callback[id].arg); } @@ -105,6 +108,9 @@ unsigned int IoTGpioRegisterIsrFunc(unsigned int id, IotGpioIntType intType, Iot } else { return IOT_FAILURE; } + if (id >= PIN_NONE) { + return IOT_FAILURE; + } g_iot_gpio_callback[id].func = func; g_iot_gpio_callback[id].arg = arg; if (uapi_gpio_register_isr_func((pin_t)id, trigger, (gpio_callback_t)GpioCallbackFunc) != ERRCODE_SUCC) { @@ -115,6 +121,9 @@ unsigned int IoTGpioRegisterIsrFunc(unsigned int id, IotGpioIntType intType, Iot unsigned int IoTGpioUnregisterIsrFunc(unsigned int id) { + if (id >= PIN_NONE) { + return IOT_FAILURE; + } if (uapi_gpio_unregister_isr_func((pin_t)id) != ERRCODE_SUCC) { return IOT_FAILURE; } diff --git a/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h b/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h index f1a7063ba..d73f6b8c6 100644 --- a/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h +++ b/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h @@ -46,12 +46,21 @@ const hal_pio_config_t g_pio_function_config[PIN_MAX_NUMBER] = { { HAL_PIO_FUNC_OPI, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_ENBALE }, // S_EGPIO24 { HAL_PIO_FUNC_OPI, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_ENBALE }, // S_EGPIO25 +#ifndef CFG_DRIVERS_SDIO { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_HGPIO0 sdio { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_HGPIO1 { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_HGPIO2 { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_HGPIO3 { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_HGPIO4 { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_HGPIO5 +#else + { HAL_PIO_FUNC_SDIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_UP, HAL_PIO_IE_ENBALE }, // S_HGPIO0 sdio + { HAL_PIO_FUNC_SDIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_UP, HAL_PIO_IE_ENBALE }, // S_HGPIO1 + { HAL_PIO_FUNC_SDIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_UP, HAL_PIO_IE_ENBALE }, // S_HGPIO2 + { HAL_PIO_FUNC_SDIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_UP, HAL_PIO_IE_ENBALE }, // S_HGPIO3 + { HAL_PIO_FUNC_SDIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE }, // S_HGPIO4 + { HAL_PIO_FUNC_SDIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_UP, HAL_PIO_IE_ENBALE }, // S_HGPIO5 +#endif #if (defined CFG_DRIVERS_NANDFLASH) { HAL_PIO_FUNC_QSPI1, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE }, // S_HGPIO6 { HAL_PIO_FUNC_QSPI1, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_ENBALE }, // S_HGPIO7 diff --git a/code/sdk/drivers/boards/brandy_evb/memory_config/include/memory_config_common.h b/code/sdk/drivers/boards/brandy_evb/memory_config/include/memory_config_common.h index ea5ae13c3..03a326d15 100644 --- a/code/sdk/drivers/boards/brandy_evb/memory_config/include/memory_config_common.h +++ b/code/sdk/drivers/boards/brandy_evb/memory_config/include/memory_config_common.h @@ -132,6 +132,7 @@ * 分区表配置: * 16M:build\config\target_config\brandy\param_sector\param_sector_16M.json * 8M:build\config\target_config\brandy\param_sector\param_sector.json + * 8M no_dsp:build\config\target_config\brandy\param_sector\param_sector_no_dsp.json * 打包脚本: * tools\pkg\chip_packet\brandy\packet.py */ diff --git a/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h b/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h index f4f0e772c..5d7028ea7 100644 --- a/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h +++ b/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h @@ -34,6 +34,15 @@ #define HIFI0_CODEC_PAGES 448 #define APP_IMAGE_PAGES 2048 #else +#if defined(CFG_LOAD_FROM_FS) +#define DTB_IMAGE_PAGES 0 +#define RECOVERY_IMAGE_PAGES 64 +#define RESERVE_IMAGE_PAGES 0 +#define BT_IMAGE_PAGES 112 +#define HIFI0_IMAGE_PAGES 0 +#define HIFI0_CODEC_PAGES 0 +#define APP_IMAGE_PAGES 1785 +#else #define DTB_IMAGE_PAGES 0 #define RECOVERY_IMAGE_PAGES 64 #define RESERVE_IMAGE_PAGES 0 @@ -42,6 +51,7 @@ #define HIFI0_CODEC_PAGES 320 #define APP_IMAGE_PAGES 1353 #endif +#endif #define NV_IMAGE_PAGES 4 #define FOTA_IMAGE_PAGES 3 #define FOTA_IMAGE_START 0x770000 @@ -250,6 +260,9 @@ #define SND_PORT_AEF_TYPE 0x180 // 参考 soc_uapi_aef.h 中 UAPI_AEF_TYPE_SMARTPA 枚举 #endif #define SND_PORT_AEF_ENABLE true // true代表开启aef算法,false代表关闭aef算法 + +#define OPUS_ENC_BIT_RATE 16000 // opus编码码率 +#define MP3_ENC_BIT_RATE 16000 // mp3编码码率 /** * @} */ diff --git a/code/sdk/drivers/boards/brandy_evb/product/product_evb_standard.h b/code/sdk/drivers/boards/brandy_evb/product/product_evb_standard.h index 0ee13ad82..bd94392e9 100644 --- a/code/sdk/drivers/boards/brandy_evb/product/product_evb_standard.h +++ b/code/sdk/drivers/boards/brandy_evb/product/product_evb_standard.h @@ -222,6 +222,9 @@ #define SND_PORT_AEF_TYPE 0x180 // 参考 soc_uapi_aef.h 中 UAPI_AEF_TYPE_SMARTPA 枚举 #endif #define SND_PORT_AEF_ENABLE true // true代表开启aef算法,false代表关闭aef算法 + +#define OPUS_ENC_BIT_RATE 16000 // opus编码码率 +#define MP3_ENC_BIT_RATE 16000 // mp3编码码率 /** * @} */ diff --git a/code/sdk/drivers/chips/brandy/clocks_core/drivers/acore/clocks_core.c b/code/sdk/drivers/chips/brandy/clocks_core/drivers/acore/clocks_core.c index ded098e9b..fa0f84a49 100644 --- a/code/sdk/drivers/chips/brandy/clocks_core/drivers/acore/clocks_core.c +++ b/code/sdk/drivers/chips/brandy/clocks_core/drivers/acore/clocks_core.c @@ -257,7 +257,6 @@ uint16_t get_sdiom_freq_level(clocks_clk_src_t src) static void mcu_clocks_set_freq(system_mcu_core_clk_cfg_t sys_mcu_clks) { - uint16_t level = CLOCKS_SDIO_FREQ_32M; clocks_clk_src_t mcu_core_clk = sys_mcu_clks.mcu_clk.clk_src; uint8_t mcu_clk_div = sys_mcu_clks.mcu_clk.clk_div; clocks_clk_src_t psram_clk = sys_mcu_clks.psram_clk.clk_src; @@ -266,23 +265,23 @@ static void mcu_clocks_set_freq(system_mcu_core_clk_cfg_t sys_mcu_clks) uint8_t mem_clk_div = sys_mcu_clks.mem_clk.clk_div; clocks_clk_src_t flash_clk = sys_mcu_clks.flash_clk.clk_src; uint8_t flash_clk_div = sys_mcu_clks.flash_clk.clk_div; - clocks_clk_src_t sdiom_clk = sys_mcu_clks.sdiom_clk.clk_src; - uint8_t sdiom_clk_div = sys_mcu_clks.sdiom_clk.clk_div; clocks_clk_src_t gpu_clk = sys_mcu_clks.gpu_clk.clk_src; uint8_t gpu_clk_div = sys_mcu_clks.gpu_clk.clk_div; clocks_clk_src_t spi_clk = sys_mcu_clks.spi_clk.clk_src; uint8_t spi_clk_div = sys_mcu_clks.spi_clk.clk_div; + clocks_clk_src_t sdiom_clk = sys_mcu_clks.sdiom_clk.clk_src; + uint8_t sdiom_clk_div = sys_mcu_clks.sdiom_clk.clk_div; mcu_clock_set_freq(mcu_core_clk, mcu_clk_div); uint32_t irq_status = osal_irq_lock(); system_ccrg_clock_config(CLOCKS_CCRG_MODULE_XIP_OPI, psram_clk, psram_clk_div); system_ccrg_clock_config(CLOCKS_CCRG_MODULE_MEM_BUS, mem_clk, mem_clk_div); system_ccrg_clock_config(CLOCKS_CCRG_MODULE_XIP_QSPI, flash_clk, flash_clk_div); -#ifdef CFG_DRIVERS_MMC - level = get_sdiom_freq_level(sdiom_clk); - if (g_sdiom_handler != NULL) { g_sdiom_handler(level); } -#else - system_ccrg_clock_config(CLOCKS_CCRG_MODULE_SDIOM, sdiom_clk, sdiom_clk_div); + /* NANDFLASH对SDIOM有依赖,如果不配置的话,sdiom会固定选择PLL时钟源,功耗有损失 */ +#ifdef CFG_DRIVERS_NANDFLASH + if (is_sdio_working() == false) { + system_ccrg_clock_config(CLOCKS_CCRG_MODULE_SDIOM, sdiom_clk, sdiom_clk_div); + } #endif system_ccrg_clock_config(CLOCKS_CCRG_MODULE_GPU, gpu_clk, gpu_clk_div); system_ccrg_clock_config(CLOCKS_CCRG_MODULE_MCU_PERP_SPI, spi_clk, spi_clk_div); diff --git a/code/sdk/drivers/chips/brandy/porting/button/button_porting.c b/code/sdk/drivers/chips/brandy/porting/button/button_porting.c index 6b7abcb85..8cf61c474 100644 --- a/code/sdk/drivers/chips/brandy/porting/button/button_porting.c +++ b/code/sdk/drivers/chips/brandy/porting/button/button_porting.c @@ -19,6 +19,7 @@ bool g_startup_finish_flag = false; uint16_t g_ulp_wkup_flag = 0; static uint32_t g_clock_ulp = 3276800; +static uint8_t g_button_vetoed = 0; void set_startup_finish_flag(void) { @@ -353,6 +354,25 @@ static void porting_button_remove_veto(uint8_t id) } } +/*porting_button_add_veto和porting_button_remove_veto为补丁合入*/ +#if 0 +static void porting_button_add_veto(void) +{ + if (g_button_vetoed == 0) { + uapi_pm_add_sleep_veto(PM_ID_BUTTON); + g_button_vetoed = 1; + } +} + +static void porting_button_remove_veto(void) +{ + if (g_button_vetoed == 1) { + uapi_pm_remove_sleep_veto(PM_ID_BUTTON); + g_button_vetoed = 0; + } +} +#endif + button_peripheral_api g_brandy_button_api = { .button_pmu_pwr_cfg = porting_button_pmu_pwr_cfg, .button_check_interrupt = porting_button_check_int, diff --git a/code/sdk/drivers/drivers/driver/audio/CMakeLists.txt b/code/sdk/drivers/drivers/driver/audio/CMakeLists.txt index e04be0dbb..c64d6a4b9 100644 --- a/code/sdk/drivers/drivers/driver/audio/CMakeLists.txt +++ b/code/sdk/drivers/drivers/driver/audio/CMakeLists.txt @@ -20,4 +20,29 @@ if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/source/CMakeLists.txt) elseif(EXISTS ${BIN_DIR}/${PROJECT_CHIP_DIR}/libs/audio/CMakeLists.txt) set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include) add_subdirectory(${BIN_DIR}/${PROJECT_CHIP_DIR}/libs/audio audio) +else() + set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include) + set(AUDIO_LIST "audio_api" "audio_core" "audio_drv" "audio_sample" "audio_vendor") + + set(COMPONENT_LIST ${AUDIO_LIST}) + set(AUDIO_LIB_LIST) + + set(SAP_BOARD ${BOARD}) + # Switch audio libs dir for brandy evb4 + if("BRANDY_PRODUCT_EVB4" IN_LIST DEFINES) + string(APPEND SAP_BOARD "4") + endif() + + set(LIBRARY_OUTPUT_PATH ${BIN_DIR}/${CHIP}/libs/audio/${SAP_BOARD}_${APPLICATION}/${OS}) + foreach(COMPONENT ${COMPONENT_LIST}) + set(COMPONENT_NAME ${COMPONENT}) + if (NOT ${COMPONENT_NAME} IN_LIST TARGET_COMPONENT) + continue() + endif() + find_library(LIBS${COMPONENT_NAME} "lib${COMPONENT_NAME}.a" ${LIBRARY_OUTPUT_PATH}) + set(AUDIO_LIB_LIST ${AUDIO_LIB_LIST} ${LIBS${COMPONENT_NAME}}) + build_component() + endforeach() + + target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${AUDIO_LIB_LIST} -Wl,--no-whole-archive ) endif() diff --git a/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_audio_sys.h b/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_audio_sys.h index 088fa00b0..d85100eda 100644 --- a/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_audio_sys.h +++ b/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_audio_sys.h @@ -140,6 +140,19 @@ td_s32 uapi_audio_set_tws_role(uapi_audio_tws_role tws_role); */ td_s32 uapi_audio_set_dsp_log_level(td_u32 log_level); +/** + * @if Eng + * @brief Set DSP binary file path. + * @retval SUCCESS Success. + * @retval FAILURE Failure. + * @else + * @brief 设置DSP二进制文件路径 + * @retval SUCCESS 成功 + * @retval FAILURE 失败 + * @endif + */ +td_s32 uapi_audio_set_dsp_file_path(const td_char *file_path, td_u32 len); + /** * @} */ diff --git a/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_sound.h b/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_sound.h index 61fe06256..298c129f8 100644 --- a/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_sound.h +++ b/code/sdk/drivers/drivers/driver/audio/include/soc_uapi_sound.h @@ -265,6 +265,9 @@ typedef enum { UAPI_SND_AEF_PROFILE_MUSIC, UAPI_SND_AEF_PROFILE_VOIP, UAPI_SND_AEF_PROFILE_RINGTONE, + UAPI_SND_AEF_PROFILE_EXT0, + UAPI_SND_AEF_PROFILE_EXT1, + UAPI_SND_AEF_PROFILE_EXT2, UAPI_SND_AEF_PROFILE_VOIP_CAT1, UAPI_SND_AEF_PROFILE_MAX, } uapi_snd_aef_profile; diff --git a/code/sdk/drivers/drivers/driver/audio/source/api/include/mpi_sys.h b/code/sdk/drivers/drivers/driver/audio/source/api/include/mpi_sys.h index a7b6c2e51..d1348c60b 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/api/include/mpi_sys.h +++ b/code/sdk/drivers/drivers/driver/audio/source/api/include/mpi_sys.h @@ -33,6 +33,8 @@ td_s32 mpi_audio_set_tws_role(audio_tws_role tws_role); td_s32 mpi_audio_set_dsp_log_level(td_u32 log_level); +td_s32 mpi_audio_set_dsp_file_path(const td_char *file_path, td_u32 len); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/drivers/driver/audio/source/api/sys/mpi_sys.c b/code/sdk/drivers/drivers/driver/audio/source/api/sys/mpi_sys.c index 50b8148b5..1b44dfebc 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/api/sys/mpi_sys.c +++ b/code/sdk/drivers/drivers/driver/audio/source/api/sys/mpi_sys.c @@ -28,7 +28,7 @@ extern "C" { #define mpi_sys_check_inited() \ do { \ if (g_mpi_sys_init_cnt == 0) { \ - return ERR_ADEC_NOT_INIT; \ + return ERR_SYS_NOT_INIT; \ } \ } while (0) @@ -293,6 +293,28 @@ td_s32 mpi_audio_set_dsp_log_level(td_u32 log_level) return AUDIO_SUCCESS; } +td_s32 mpi_audio_set_dsp_file_path(const td_char *file_path, td_u32 len) +{ + td_s32 ret; + sap_drv_str drv_str; + + mpi_sys_check_inited(); + mpi_sys_lock(); + + audio_api_time_consum_stat(); + + drv_str.str = file_path; + drv_str.len = len; + ret = audio_ioctl(g_mpi_sys_fd, CMD_IOCTL_SYS_SET_DSP_FILE_PATH, (td_void *)&drv_str); + if (ret != AUDIO_SUCCESS) { + mpi_sys_unlock(); + return ret; + } + + mpi_sys_unlock(); + return AUDIO_SUCCESS; +} + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/drivers/driver/audio/source/api/sys/uapi_sys.c b/code/sdk/drivers/drivers/driver/audio/source/api/sys/uapi_sys.c index 763d3c831..4cecd29db 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/api/sys/uapi_sys.c +++ b/code/sdk/drivers/drivers/driver/audio/source/api/sys/uapi_sys.c @@ -93,6 +93,11 @@ td_s32 uapi_audio_set_dsp_log_level(td_u32 log_level) return mpi_audio_set_dsp_log_level(log_level); } +td_s32 uapi_audio_set_dsp_file_path(const td_char *file_path, td_u32 len) +{ + return mpi_audio_set_dsp_file_path(file_path, len); +} + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4_liteos_cfg.mak b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4_liteos_cfg.mak index 1cb3f512a..162e4b1e1 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4_liteos_cfg.mak +++ b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4_liteos_cfg.mak @@ -152,6 +152,7 @@ CFG_SAP_AW88166_I2C_ADDR=0x34 CFG_SAP_SEA_SEE_1MIC_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_WNR_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_NNSPK_SUPPORT=y +CFG_SAP_SEA_SEE_1MIC_EQ_SUPPORT=y # CFG_SAP_SEA_SEE_1MIC_PROTECT_SUPPORT is not set # CFG_SAP_SEA_SEE_2MIC_SUPPORT is not set # CFG_SAP_SEA_VQE_DEF_SUPPORT is not set diff --git a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4max_liteos_cfg.mak b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4max_liteos_cfg.mak index 2e4d1a13a..66c1fb3e7 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4max_liteos_cfg.mak +++ b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4max_liteos_cfg.mak @@ -152,6 +152,7 @@ CFG_SAP_AW88166_I2C_ADDR=0x34 CFG_SAP_SEA_SEE_1MIC_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_WNR_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_NNSPK_SUPPORT=y +CFG_SAP_SEA_SEE_1MIC_EQ_SUPPORT=y # CFG_SAP_SEA_SEE_1MIC_PROTECT_SUPPORT is not set # CFG_SAP_SEA_SEE_2MIC_SUPPORT is not set # CFG_SAP_SEA_VQE_DEF_SUPPORT is not set diff --git a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4mini_liteos_cfg.mak b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4mini_liteos_cfg.mak index 58ae19349..034e320f2 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4mini_liteos_cfg.mak +++ b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb4mini_liteos_cfg.mak @@ -152,6 +152,7 @@ CFG_SAP_AW88166_I2C_ADDR=0x34 CFG_SAP_SEA_SEE_1MIC_SUPPORT=y # CFG_SAP_SEA_SEE_1MIC_WNR_SUPPORT is not set # CFG_SAP_SEA_SEE_1MIC_NNSPK_SUPPORT is not set +# CFG_SAP_SEA_SEE_1MIC_EQ_SUPPORT is not set # CFG_SAP_SEA_SEE_1MIC_PROTECT_SUPPORT is not set # CFG_SAP_SEA_SEE_2MIC_SUPPORT is not set # CFG_SAP_SEA_VQE_DEF_SUPPORT is not set diff --git a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb_liteos_cfg.mak b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb_liteos_cfg.mak index 624e9e13a..25c2b4cfe 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb_liteos_cfg.mak +++ b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_evb_liteos_cfg.mak @@ -152,6 +152,7 @@ CFG_SAP_AW88166_I2C_ADDR=0x34 CFG_SAP_SEA_SEE_1MIC_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_WNR_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_NNSPK_SUPPORT=y +CFG_SAP_SEA_SEE_1MIC_EQ_SUPPORT=y # CFG_SAP_SEA_SEE_1MIC_PROTECT_SUPPORT is not set # CFG_SAP_SEA_SEE_2MIC_SUPPORT is not set # CFG_SAP_SEA_VQE_DEF_SUPPORT is not set diff --git a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_fpga_liteos_cfg.mak b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_fpga_liteos_cfg.mak index be995a5fa..b7170bd84 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_fpga_liteos_cfg.mak +++ b/code/sdk/drivers/drivers/driver/audio/source/build/configs/brandy/brandy_fpga_liteos_cfg.mak @@ -152,6 +152,7 @@ CFG_SAP_AW88166_I2C_ADDR=0x34 CFG_SAP_SEA_SEE_1MIC_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_WNR_SUPPORT=y CFG_SAP_SEA_SEE_1MIC_NNSPK_SUPPORT=y +CFG_SAP_SEA_SEE_1MIC_EQ_SUPPORT=y # CFG_SAP_SEA_SEE_1MIC_PROTECT_SUPPORT is not set # CFG_SAP_SEA_SEE_2MIC_SUPPORT is not set # CFG_SAP_SEA_VQE_DEF_SUPPORT is not set diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/CMakeLists.txt b/code/sdk/drivers/drivers/driver/audio/source/drv/CMakeLists.txt index 52f8d9e33..b0636bd3e 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/CMakeLists.txt +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/CMakeLists.txt @@ -70,20 +70,20 @@ set(COMPONENT_SRC ${COMPONENT_SRC} ) endif() -if("${CHIP}" STREQUAL "brandy") -install_sdk(${CMAKE_CURRENT_SOURCE_DIR}/dpm "*") -endif() - -if("${CFG_SAP_DRV_OVERLAY_LOAD_FROM}" STREQUAL "flash") +if("CFG_LOAD_FROM_FS" IN_LIST DEFINES) +set(COMPONENT_SRC ${COMPONENT_SRC} + ${CMAKE_CURRENT_SOURCE_DIR}/common/drv_overlay_load_from_file.c +) +else() set(COMPONENT_SRC ${COMPONENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/common/drv_overlay_load_from_flash.c ) endif() -if("${CFG_SAP_DRV_OVERLAY_LOAD_FROM}" STREQUAL "file") -set(COMPONENT_SRC ${COMPONENT_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/common/drv_overlay_load_from_file.c -) +if("${CHIP}" STREQUAL "brandy") +install_sdk(${CMAKE_CURRENT_SOURCE_DIR}/dpm "*") +install_sdk(${CMAKE_CURRENT_SOURCE_DIR}/common "drv_overlay_load_from_file.c") +install_sdk(${CMAKE_CURRENT_SOURCE_DIR}/common "drv_overlay_load_from_flash.c") endif() #=================================================================================== set(COMPONENT_INC diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_ao.c b/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_ao.c index daaf31549..05c81853d 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_ao.c +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_ao.c @@ -630,6 +630,9 @@ static td_s32 ao_get_aef_param_bin_by_profile(ao_aef_profile aef_profile, td_u8 {AO_AEF_PROFILE_MUSIC, "aef_music.bin"}, {AO_AEF_PROFILE_VOIP, "aef_voip.bin"}, {AO_AEF_PROFILE_RINGTONE, "aef_ringtone.bin"}, + {AO_AEF_PROFILE_EXT0, "aef_ext0.bin"}, + {AO_AEF_PROFILE_EXT1, "aef_ext1.bin"}, + {AO_AEF_PROFILE_EXT2, "aef_ext2.bin"}, }; const td_u32 item_cnt = (td_u32)(sizeof(aef_profile_bin_name) / sizeof(aef_profile_bin_name[0])); diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_proc_ao.c b/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_proc_ao.c index ce9e23c0a..805a011e7 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_proc_ao.c +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/aoe/drv_proc_ao.c @@ -102,7 +102,10 @@ static const aef_profile_name_item g_aef_profile_name_list[] = { {AO_AEF_PROFILE_NONE, "none"}, {AO_AEF_PROFILE_MUSIC, "music"}, {AO_AEF_PROFILE_VOIP, "voip"}, - {AO_AEF_PROFILE_RINGTONE, "RINGTONE"}, + {AO_AEF_PROFILE_RINGTONE, "ringtone"}, + {AO_AEF_PROFILE_EXT0, "ext0"}, + {AO_AEF_PROFILE_EXT1, "ext1"}, + {AO_AEF_PROFILE_EXT2, "ext2"}, }; static const td_char *drv_ao_proc_aef_profile_name(ao_aef_profile profile) diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/arch/drv_sap_intf.c b/code/sdk/drivers/drivers/driver/audio/source/drv/arch/drv_sap_intf.c index e1bcd63f4..5775f6aa6 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/arch/drv_sap_intf.c +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/arch/drv_sap_intf.c @@ -79,6 +79,7 @@ static drv_audio_osal_ioctl_cmd g_sap_sys_cmd_list[CMD_SYS_ID_MAX] = { [CMD_SYS_SET_TWS_MODE] = {CMD_IOCTL_SYS_SET_TWS_MODE, sap_ioctl_sys_set_tws_mode}, [CMD_SYS_SET_TWS_ROLE] = {CMD_IOCTL_SYS_SET_TWS_ROLE, sap_ioctl_sys_set_tws_role}, [CMD_SYS_SET_DSP_LOG_LEVEL] = {CMD_IOCTL_SYS_SET_DSP_LOG_LEVEL, sap_ioctl_sys_set_dsp_log_level}, + [CMD_SYS_SET_DSP_FILE_PATH] = {CMD_IOCTL_SYS_SET_DSP_FILE_PATH, sap_ioctl_sys_set_dsp_file_path}, }; static drv_audio_osal_fileops g_sap_sys_fops = { diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl.h b/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl.h index 20d4186ee..5490e6a50 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl.h +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl.h @@ -75,6 +75,11 @@ typedef struct { td_u32 value; } sap_drv_u32; +typedef struct { + td_char *str; + td_u32 len; +} sap_drv_str; + typedef struct { td_handle track; td_s64 pts; /* us */ @@ -365,6 +370,7 @@ typedef struct { #define CMD_IOCTL_SYS_SET_TWS_MODE _IOW(DEV_ID_SAP_SYS, CMD_SYS_SET_TWS_MODE, td_u8) #define CMD_IOCTL_SYS_SET_TWS_ROLE _IOW(DEV_ID_SAP_SYS, CMD_SYS_SET_TWS_ROLE, td_u8) #define CMD_IOCTL_SYS_SET_DSP_LOG_LEVEL _IOW(DEV_ID_SAP_SYS, CMD_SYS_SET_DSP_LOG_LEVEL, td_u32) +#define CMD_IOCTL_SYS_SET_DSP_FILE_PATH _IOW(DEV_ID_SAP_SYS, CMD_SYS_SET_DSP_FILE_PATH, sap_drv_str) #define CMD_IOCTL_ADP_INIT _IOWR(DEV_ID_SAP_ADP, CMD_ADP_INIT, sap_adp_init) #define CMD_IOCTL_ADP_DEINIT _IO(DEV_ID_SAP_ADP, CMD_ADP_DEINIT) diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl_cmd.h b/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl_cmd.h index fc0d8a0e5..a01278619 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl_cmd.h +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/arch/include/drv_sap_ioctl_cmd.h @@ -19,6 +19,7 @@ enum { CMD_SYS_SET_TWS_MODE, CMD_SYS_SET_TWS_ROLE, CMD_SYS_SET_DSP_LOG_LEVEL, + CMD_SYS_SET_DSP_FILE_PATH, CMD_SYS_ID_MAX, }; diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/common/drv_overlay_load_from_file.c b/code/sdk/drivers/drivers/driver/audio/source/drv/common/drv_overlay_load_from_file.c new file mode 100644 index 000000000..2f48994b3 --- /dev/null +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/common/drv_overlay_load_from_file.c @@ -0,0 +1,345 @@ +/* + * Copyright (c) CompanyNameMagicTag 2020-2020. All rights reserved. + * Description: header file for audio input + * Author: audio + */ + +#include "securec.h" +#include "mem_addr.h" +#include "audio_osal.h" +#include "audio_debug.h" +#include "drv_audio_osal.h" +#include "drv_overlay_load.h" +#include "core_overlay_info.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#define MAX_PATH_LENGTH 64 + +static const td_char *g_dsp_main_file = "dsp_main.bin"; +static const td_char *g_dsp_lib_file = "dsp_overlay.bin"; +static td_char g_dsp_file_path[MAX_PATH_LENGTH] = {0}; + +td_s32 overlay_set_dsp_file_path(const char *file_path, td_u32 len) +{ + td_s32 ret; + td_u32 dsp_main_file_length = strlen(g_dsp_main_file); + td_u32 dsp_lib_file_length = strlen(g_dsp_lib_file); + td_u32 max_file_length = (dsp_main_file_length > dsp_lib_file_length) ? dsp_main_file_length : dsp_lib_file_length; + + if (len + max_file_length >= MAX_PATH_LENGTH) { + sap_err_log_u32(len); + sap_err_log_info("file path is too long"); + return ERR_SYS_MEM_OVERLOAD; + } + + ret = memcpy_s(g_dsp_file_path, MAX_PATH_LENGTH - 1, file_path, len); + if (ret != EOK) { + sap_err_log_fun(memcpy_s, ret); + return ERR_SYS_MEM_COPY; + } + + return AUDIO_SUCCESS; +} + +static td_s32 overlay_load_elf(audio_core_id core_id, td_void *flip) +{ + td_u32 i, sec_cnt; + td_bool tcm_flag; + td_u32 phys_addr; + td_u32 *virt_addr = TD_NULL; + td_char *sec_buf = TD_NULL; + struct { + td_u32 addr; + td_u32 size; + } sec_hdr; + + if (drv_audio_osal_klib_fread((td_char *)&sec_cnt, sizeof(sec_cnt), flip) != sizeof(sec_cnt)) { + return ERR_SYS_NOT_AVAILABLE; + } + + for (i = 0; i < sec_cnt; i++) { + if (drv_audio_osal_klib_fread((td_char *)&sec_hdr, sizeof(sec_hdr), flip) != sizeof(sec_hdr)) { + return ERR_SYS_NOT_AVAILABLE; + } + + if (is_4byte_aligned(sec_hdr.addr) != TD_TRUE || is_4byte_aligned(sec_hdr.size) != TD_TRUE) { + audio_log_err("addr=%#x/size=%#x, not aligned to 4 bytes", sec_hdr.addr, sec_hdr.size); + return ERR_SYS_VERIFY_FAIL; + } + + phys_addr = drv_overlay_map_addr(core_id, sec_hdr.addr, &tcm_flag); + virt_addr = audio_osal_address_map((td_ulong)phys_addr, sec_hdr.size); + if (virt_addr == TD_NULL) { + return ERR_SYS_MEM_EXCEPTION; + } + + if (tcm_flag) { + /* Load IRAM/DRAM with 32bit operation */ + sec_buf = audio_osal_malloc_aligned(sec_hdr.size, sizeof(td_u32)); + if (sec_buf == TD_NULL) { + audio_osal_address_unmap((td_ulong)phys_addr, virt_addr); + return ERR_SYS_MEM_ALLOC; + } + if (drv_audio_osal_klib_fread((td_char *)sec_buf, sec_hdr.size, flip) != sec_hdr.size) { + audio_osal_free_aligned(sec_buf); + audio_osal_address_unmap((td_ulong)phys_addr, virt_addr); + return ERR_SYS_NOT_AVAILABLE; + } + drv_overlay_copy_section(virt_addr, (const td_u32 *)sec_buf, sec_hdr.size); + audio_osal_free_aligned(sec_buf); + } else { + if (drv_audio_osal_klib_fread((td_char *)virt_addr, sec_hdr.size, flip) != sec_hdr.size) { + audio_osal_address_unmap((td_ulong)phys_addr, virt_addr); + return ERR_SYS_NOT_AVAILABLE; + } + } + + audio_osal_dcache_region_wb((td_ulong)phys_addr, virt_addr, sec_hdr.size); + audio_osal_address_unmap((td_ulong)phys_addr, virt_addr); + } + + return AUDIO_SUCCESS; +} + +static td_s32 overlay_get_file_from_flash(const char *file, td_u32 flash_addr, td_u32 flash_len) +{ +#ifdef SAP_FLASH_FIRMWARE_SUPPORT + td_void *flip = TD_NULL; + + audio_log_warn("save %#x %#x to %s\n", flash_addr, flash_len, file); + flip = drv_audio_osal_klib_fopen(file, DRV_AUDIO_OSAL_O_RDWR | DRV_AUDIO_OSAL_O_CREAT, 0777); /* 0777: priv mode */ + if (flip == TD_NULL) { + audio_log_err("open %s failed\n", file); + return ERR_SYS_OPEN_FAILED; + } + + if (drv_audio_osal_klib_fwrite((td_char *)flash_addr, flash_len, flip) != flash_len) { + audio_log_err("Write %s failed\n", file); + return ERR_SYS_MEM_COPY; + } + + audio_log_warn("Save %s Success.\n", file); + drv_audio_osal_klib_fclose(flip); +#endif + audio_unused(file); + audio_unused(flash_addr); + audio_unused(flash_len); + return AUDIO_SUCCESS; +} + +static td_void *overlay_open_file(const char *file, td_u32 flash_addr, td_u32 flash_len) +{ + td_s32 ret; + td_void *flip = TD_NULL; + td_char full_path[MAX_PATH_LENGTH] = {0}; + + ret = snprintf_s(full_path, MAX_PATH_LENGTH - 1, MAX_PATH_LENGTH - 1, "%s%s", g_dsp_file_path, file); + if (ret < 0) { + sap_err_log_s32(ret); + return ERR_SYS_MEM_COPY; + } + + flip = drv_audio_osal_klib_fopen(full_path, DRV_AUDIO_OSAL_O_RDONLY, 0); + if (flip == TD_NULL) { + ret = overlay_get_file_from_flash(full_path, flash_addr, flash_len); + if (ret != AUDIO_SUCCESS) { + sap_err_log_fun(overlay_get_file_from_flash, ret); + return TD_NULL; + } + + flip = drv_audio_osal_klib_fopen(full_path, DRV_AUDIO_OSAL_O_RDONLY, 0); + if (flip == TD_NULL) { + sap_err_log_fun(drv_audio_osal_klib_fopen, ERR_SYS_OPEN_FAILED); + return TD_NULL; + } + } + + return flip; +} + +static td_s32 overlay_update_section_list(audio_core_id core_id, td_void *flip) +{ + td_u32 i; + td_u32 sec_cnt; + td_bool tcm_flag; + struct { + td_u32 addr; + td_u32 size; + } sec_hdr; + + drv_overlay_clear_section_list(); + + drv_audio_osal_klib_fseek(0, SEEK_SET, flip); + if (drv_audio_osal_klib_fread((td_char *)&sec_cnt, sizeof(sec_cnt), flip) != sizeof(sec_cnt)) { + return ERR_SYS_NOT_AVAILABLE; + } + + for (i = 0; i < sec_cnt; i++) { + if (drv_audio_osal_klib_fread((td_char *)&sec_hdr, sizeof(sec_hdr), flip) != sizeof(sec_hdr)) { + return ERR_SYS_NOT_AVAILABLE; + } + + (td_void)drv_overlay_map_addr(core_id, sec_hdr.addr, &tcm_flag); + drv_overlay_add_section_item(core_id, sec_hdr.addr, sec_hdr.size); + + drv_audio_osal_klib_fseek(sec_hdr.size, SEEK_CUR, flip); + } + + return AUDIO_SUCCESS; +} + +static td_s32 overlay_unpack_lib(const td_char *lib_name, td_void *flip, td_u32 *lib_size) +{ + td_u32 i, sec_cnt = 0; + struct { + td_char name[OVERLAY_NAME_LEN]; + td_u32 size; + } sec_hdr; + + if (drv_audio_osal_klib_fread((td_char *)&sec_cnt, sizeof(td_u32), flip) != sizeof(td_u32)) { + sap_err_log_fun(drv_audio_osal_klib_fread, AUDIO_FAILURE); + return ERR_SYS_NOT_AVAILABLE; + } + + for (i = 0; i < sec_cnt; i++) { + if (drv_audio_osal_klib_fread((td_char *)&sec_hdr, sizeof(sec_hdr), flip) != sizeof(sec_hdr)) { + sap_err_log_fun(drv_audio_osal_klib_fread, AUDIO_FAILURE); + return ERR_SYS_NOT_AVAILABLE; + } + + sap_trace_log_str(sec_hdr.name); + if (audio_osal_strncmp(sec_hdr.name, sizeof(sec_hdr.name), lib_name, sizeof(sec_hdr.name)) == 0) { + sap_warn_log_str(sec_hdr.name); + if (lib_size == TD_NULL) { + return ERR_SYS_NULL_PTR; + } + *lib_size = sec_hdr.size; + return AUDIO_SUCCESS; + } + + if (drv_audio_osal_klib_fseek(sec_hdr.size, OSAL_SEEK_CUR, flip) < 0) { + sap_err_log_fun(drv_audio_osal_klib_fseek, AUDIO_FAILURE); + return ERR_SYS_NOT_AVAILABLE; + } + } + + return ERR_SYS_NOT_SUPPORTED; +} + +td_s32 drv_overlay_get_lib(const td_char *lib_name, td_u8 *lib_buf, td_u32 *lib_buf_size) +{ + td_s32 ret; + td_u32 lib_size; + td_u8 *lib = TD_NULL; + td_void *flip = TD_NULL; + + sys_check_null_ptr_return(lib_name); + sys_check_null_ptr_return(lib_buf); + sys_check_null_ptr_return(lib_buf_size); + + flip = overlay_open_file(g_dsp_lib_file, FLASH_DSP_OVERLAY_ADDR, FLASH_DSP_OVERLAY_SIZE); + if (flip == TD_NULL) { + sap_err_log_fun(overlay_open_file, flip); + return ERR_SYS_OPEN_FAILED; + } + + ret = overlay_unpack_lib(lib_name, flip, &lib_size); + if (ret != AUDIO_SUCCESS) { + sap_err_log_fun(overlay_unpack_lib, ret); + goto out0; + } + + if (lib_size > *lib_buf_size) { /* input buf size check */ + sap_err_log_str(lib_size); + ret = ERR_SYS_BUF_OVERFLOW; + goto out0; + } + + if (drv_audio_osal_klib_fread((td_char *)lib_buf, lib_size, flip) != lib_size) { + ret = ERR_SYS_NOT_AVAILABLE; + goto out0; + } + + *lib_buf_size = lib_size; /* output buf actual data size */ + +out0: + drv_audio_osal_klib_fclose(flip); + return ret; +} + +td_s32 drv_overlay_load_main_program(audio_core_id core_id) +{ + td_s32 ret; + td_void *flip = TD_NULL; + + flip = overlay_open_file(g_dsp_main_file, FLASH_DSP_MAIN_ADDR, FLASH_DSP_MAIN_SIZE); + if (flip == TD_NULL) { + return ERR_SYS_OPEN_FAILED; + } + + ret = overlay_load_elf(core_id, flip); + if (ret != AUDIO_SUCCESS) { + sap_err_log_fun(overlay_load_elf, ret); + drv_audio_osal_klib_fclose(flip); + return ret; + } + + overlay_update_section_list(core_id, flip); + drv_audio_osal_klib_fclose(flip); + + return AUDIO_SUCCESS; +} + +td_s32 drv_overlay_load_lib_program(audio_core_id core_id, audio_lib_id type, td_u32 index) +{ + td_s32 ret; + td_u32 lib_size; + const td_char *lib_name = TD_NULL; + td_void *flip = TD_NULL; + + if (type >= AUDIO_LIB_MAX) { + sap_err_log_s32(type); + return ERR_SYS_INVALID_PARAM; + } + + lib_name = drv_overlay_find_and_reset_lib(core_id, type, index); + if (lib_name == TD_NULL) { + sap_err_log_fun(drv_overlay_find_and_reset_lib, lib_name); + return ERR_SYS_NOT_SUPPORTED; + } + + flip = overlay_open_file(g_dsp_lib_file, FLASH_DSP_OVERLAY_ADDR, FLASH_DSP_OVERLAY_SIZE); + if (flip == TD_NULL) { + sap_err_log_fun(overlay_open_file, flip); + return ERR_SYS_OPEN_FAILED; + } + + ret = overlay_unpack_lib(lib_name, flip, &lib_size); + if (ret != AUDIO_SUCCESS) { + sap_err_log_fun(overlay_unpack_lib, ret); + drv_audio_osal_klib_fclose(flip); + return ret; + } + + ret = overlay_load_elf(core_id, flip); + if (ret != AUDIO_SUCCESS) { + sap_err_log_fun(overlay_load_elf, ret); + drv_audio_osal_klib_fclose(flip); + return ret; + } + + drv_audio_osal_klib_fclose(flip); + audio_unused(core_id); + return AUDIO_SUCCESS; +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/common/drv_overlay_load_from_flash.c b/code/sdk/drivers/drivers/driver/audio/source/drv/common/drv_overlay_load_from_flash.c index 508b9ebd2..dd235f115 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/common/drv_overlay_load_from_flash.c +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/common/drv_overlay_load_from_flash.c @@ -39,6 +39,13 @@ extern "C" { #endif #endif +td_s32 overlay_set_dsp_file_path(const char *file_path, td_u32 len) +{ + audio_unused(file_path); + audio_unused(len); + return AUDIO_SUCCESS; +} + static td_s32 overlay_load_elf(audio_core_id core_id, const td_u8 *lib, td_u32 size) { td_u32 i, sec_cnt; diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/common/include/drv_overlay_load.h b/code/sdk/drivers/drivers/driver/audio/source/drv/common/include/drv_overlay_load.h index b4448ce32..6fdfbd0be 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/common/include/drv_overlay_load.h +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/common/include/drv_overlay_load.h @@ -23,6 +23,8 @@ static inline td_void drv_overlay_copy_section(td_u32 *to, const td_u32 *from, t } } +td_s32 overlay_set_dsp_file_path(const char *file_path, td_u32 len); + td_u32 drv_overlay_map_addr(audio_core_id core_id, td_u32 addr, td_bool *tcm_flag); td_s32 drv_overlay_add_section_item(audio_core_id core_id, td_u32 addr, td_u32 size); diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/include/drv_sys.h b/code/sdk/drivers/drivers/driver/audio/source/drv/include/drv_sys.h index b0d040fae..b5f04532e 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/include/drv_sys.h +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/include/drv_sys.h @@ -35,6 +35,8 @@ td_s32 sap_ioctl_sys_set_tws_role(td_u32 cmd, td_void *arg, td_void *file); td_s32 sap_ioctl_sys_set_dsp_log_level(td_u32 cmd, td_void *arg, td_void *file); +td_s32 sap_ioctl_sys_set_dsp_file_path(td_u32 cmd, td_void *arg, td_void *file); + td_s32 drv_msg_sys_module_init(audio_core_id core_id); td_s32 sys_read_proc(td_void *file, td_void *private); diff --git a/code/sdk/drivers/drivers/driver/audio/source/drv/sys/drv_sys.c b/code/sdk/drivers/drivers/driver/audio/source/drv/sys/drv_sys.c index 77973d08c..00ae1e723 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/drv/sys/drv_sys.c +++ b/code/sdk/drivers/drivers/driver/audio/source/drv/sys/drv_sys.c @@ -226,24 +226,6 @@ static td_s32 drv_sys_init(audio_core_id drv_cid, audio_core_id core_cid) return ret; } -#if (SAP_CHIP_TYPE != socmn1) - hal_dsp_set_power_on(core_cid, TD_TRUE); - - ret = drv_sys_load_image(core_cid); - if (ret != AUDIO_SUCCESS) { - sap_err_log_fun(drv_sys_load_image, ret); - drv_sap_msg_stop(core_cid); - hal_dsp_reset(core_cid); - hal_dsp_deinit(core_cid); - drv_ipc_deinit(drv_cid, core_cid); - return ret; - } - - drv_overlay_backup_tcm(core_cid); - - hal_dsp_set_power_on(core_cid, TD_FALSE); -#endif - audio_func_exit(); return AUDIO_SUCCESS; } @@ -427,6 +409,11 @@ static td_s32 drv_sys_set_state(audio_core_id core_cid, audio_sys_state state) return AUDIO_SUCCESS; } +static td_s32 drv_sys_set_dsp_file_path(const td_char *file_path, td_u32 len) +{ + return overlay_set_dsp_file_path(file_path, len); +} + td_s32 sap_ioctl_sys_init(td_u32 cmd, td_void *arg, td_void *file) { td_s32 ret; @@ -569,6 +556,15 @@ td_s32 sap_ioctl_sys_set_dsp_log_level(td_u32 cmd, td_void *arg, td_void *file) return drv_msg_sys_set_dsp_log_level(log_level); } +td_s32 sap_ioctl_sys_set_dsp_file_path(td_u32 cmd, td_void *arg, td_void *file) +{ + sap_drv_str *drv_str = (sap_drv_str *)arg; + audio_unused(cmd); + audio_unused(file); + + return drv_sys_set_dsp_file_path(drv_str->str, drv_str->len); +} + static td_s32 drv_msg_sys_active(audio_core_id to) { return drv_sys_set_state(to, AUDIO_SYS_ACTIVE); diff --git a/code/sdk/drivers/drivers/driver/audio/source/include/ao_struct.h b/code/sdk/drivers/drivers/driver/audio/source/include/ao_struct.h index bb6b27aeb..ed848de58 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/include/ao_struct.h +++ b/code/sdk/drivers/drivers/driver/audio/source/include/ao_struct.h @@ -189,6 +189,9 @@ typedef enum { AO_AEF_PROFILE_MUSIC, AO_AEF_PROFILE_VOIP, AO_AEF_PROFILE_RINGTONE, + AO_AEF_PROFILE_EXT0, + AO_AEF_PROFILE_EXT1, + AO_AEF_PROFILE_EXT2, AO_AEF_PROFILE_MAX, } ao_aef_profile; diff --git a/code/sdk/drivers/drivers/driver/audio/source/include/sea_aef.h b/code/sdk/drivers/drivers/driver/audio/source/include/sea_aef.h index d1f16b72a..c20d046e6 100644 --- a/code/sdk/drivers/drivers/driver/audio/source/include/sea_aef.h +++ b/code/sdk/drivers/drivers/driver/audio/source/include/sea_aef.h @@ -22,6 +22,7 @@ extern "C" { #define AUDIO_BIN_LEN 320 // half of fft length #define AUDIO_INPUT_FS 16000 // input samplerate #define AUDIO_PROCESS_FS 16000 // process samplerate +#define AUDIO_EQ_BAND_NUM 20 #define AUDIO_VQE_VERSION_LEN 64 // 版本号字符串长度 #define AUDIO_VQE_48K_SAMPLERATE 48000 // 48000采样率定义 @@ -385,8 +386,9 @@ typedef struct tag_param_struct { // AGC使能开关; 范围:{0,1}; 默认值:1; 错误码:-58; td_u8 agc_enable; td_u8 fmp_enable; + td_u8 eq_enable; // 保留位 - td_u8 reserve4[AUDIO_VQE_COM_PAD_2]; + td_u8 reserve4; // ####### AEC参数 // 非线性开关; 范围:{0,1}; 默认值:1; 错误码:-231; @@ -513,6 +515,9 @@ typedef struct tag_param_struct { td_s8 comfort_intensity; /* noise compensation level, 1-10, default:3 */ td_s8 mode2; /* no-echo_area, 0->headset, 1->handsfree, 2->headphone */ td_s8 fmp_reserved[5]; /* reserved */ + + /* eq */ + td_s8 eq_band_gain[AUDIO_EQ_BAND_NUM]; } audio_vqe_param_struct; diff --git a/code/sdk/drivers/drivers/driver/button/button.c b/code/sdk/drivers/drivers/driver/button/button.c index 21e79e79c..0f6e94d8b 100644 --- a/code/sdk/drivers/drivers/driver/button/button.c +++ b/code/sdk/drivers/drivers/driver/button/button.c @@ -58,7 +58,6 @@ bool g_timer_is_running = false; bool g_gpio_timer_is_running = false; msg_send_callback_t g_msg_send_cb = NULL; pin_t g_gpio_key_record = 0; -uint8_t g_buttom_vetoed = 0; static const char* g_state_str[PRESSED_MAX] = { "BUTTON_PRESSED", @@ -156,10 +155,7 @@ static void button_irq_callback(pin_t pin) button_api->button_clear_interrupt(pin); button_press_state_t press_state = button_get_press_state(pin); button_send_msg(BUTTON_PWREN_ID, press_state); - if (g_buttom_vetoed == 0) { - button_api->button_add_veto(); - g_buttom_vetoed = 1; - } + button_api->button_add_veto(); button_timer_start_check_released(); } @@ -256,10 +252,7 @@ static void button_check_released_timer_callback(uint32_t data) button_press_state_t press_state; press_state = button_get_press_state(PIN_NONE); if (press_state == 1) { - if (g_buttom_vetoed == 1) { - button_api->button_remove_veto(); - g_buttom_vetoed = 0; - } + button_api->button_remove_veto(); button_send_msg(1, RELEASED); } else { button_timer_start_check_released(); diff --git a/code/sdk/drivers/drivers/driver/ipc/ipc_old/shared/ipc.c b/code/sdk/drivers/drivers/driver/ipc/ipc_old/shared/ipc.c index 1b09891fa..42668534f 100644 --- a/code/sdk/drivers/drivers/driver/ipc/ipc_old/shared/ipc.c +++ b/code/sdk/drivers/drivers/driver/ipc/ipc_old/shared/ipc.c @@ -16,6 +16,7 @@ #include "systick_porting.h" #include "watchdog_porting.h" #include "watchdog.h" +#include "preserve.h" #if !defined(BUILD_APPLICATION_SSB) && !defined(UNIT_TEST) #include "cpu_trace.h" #ifdef BUILD_APPLICATION_STANDARD @@ -116,6 +117,10 @@ static inline void ipc_to_bcore_timeout_proc(cores_t dst) if (dst == CORES_BT_CORE) { g_ipc_to_bcore_continuous_fail_nums++; if (g_ipc_to_bcore_continuous_fail_nums > IPC_CONTINUOUS_FAIL_MAX) { +#if defined SAVE_EXC_INFO + save_btram_file_to_fs(); + save_btrace_file_to_fs(); +#endif panic(PANIC_BT_STS_ABNORMAL, __LINE__); } } diff --git a/code/sdk/drivers/drivers/driver/lcd/lcd_config.h b/code/sdk/drivers/drivers/driver/lcd/lcd_config.h index 458077efc..99305c734 100644 --- a/code/sdk/drivers/drivers/driver/lcd/lcd_config.h +++ b/code/sdk/drivers/drivers/driver/lcd/lcd_config.h @@ -12,6 +12,10 @@ #include "soc_mipi_tx.h" #include "debug_print.h" +#ifdef BUILD_RECOVERY_IMAGE +#define lcd_err(x, ...) +#define lcd_print(fmt, ...) +#else #define lcd_err(x, ...) \ do { \ PRINT("%s(%d): "x, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ @@ -21,7 +25,7 @@ do { \ PRINT(fmt, ##__VA_ARGS__); \ } while (0) - +#endif #define DEFAULT_BRIGHTNESS 255 typedef enum { diff --git a/code/sdk/drivers/drivers/driver/mipi/shared/mipi_tx.h b/code/sdk/drivers/drivers/driver/mipi/shared/mipi_tx.h index f8af2ca86..0690e07b8 100644 --- a/code/sdk/drivers/drivers/driver/mipi/shared/mipi_tx.h +++ b/code/sdk/drivers/drivers/driver/mipi/shared/mipi_tx.h @@ -34,10 +34,14 @@ PRINT(fmt, ##__VA_ARGS__); \ } while (0) +#ifdef BUILD_RECOVERY_IMAGE +#define mipi_tx_err(x, ...) +#else #define mipi_tx_err(x, ...) \ do { \ PRINT(x, ##__VA_ARGS__); \ } while (0) +#endif #define mipi_tx_check_null_ptr_return(ptr) \ do { \ diff --git a/code/sdk/drivers/drivers/driver/mmc/core/block.c b/code/sdk/drivers/drivers/driver/mmc/core/block.c index 514dcd329..029e452a6 100644 --- a/code/sdk/drivers/drivers/driver/mmc/core/block.c +++ b/code/sdk/drivers/drivers/driver/mmc/core/block.c @@ -36,6 +36,8 @@ #include "mmc_private.h" #include "mmcreg.h" #include "pm_veto.h" +#include "clocks_config.h" +#include "clocks_core.h" static uint32_t part_node_cnt = 0; #ifdef CONFIG_DRIVERS_MMC_RW_IN_EXC @@ -49,14 +51,21 @@ static dpal_spinlock rw_spinlock; #define BLOCK_MSLEEP10 10 struct mmcsd_part *g_local_part[MAX_PART_COUNT]; -static void mmc_init_before_handler(void) +static void mmc_clk_set_before_handler(void) { - if (!mmc_get_sleep_init_flag() && mmc_get_first_init_flag()) { - emmc_recovery_init(); - mmc_set_sleep_init_flag(true); + system_freq_t sys_freq = get_system_freq(); + system_mcu_core_clk_cfg_t mcu_freq = clocks_system_mcu_freq_get(sys_freq.system_mcu_freq); + /* 当mcu处于高频模式下,尝试emmc使用前切到高频模式。是否真正切换,还依赖emmc卡的能力能支持高频模式 */ + if (mcu_freq.mcu_clk.clk_src == CLOCKS_CLK_SRC_PLL) { + mmc_set_internal_clk(CLOCKS_SDIO_FREQ_H); } } +static void mmc_clk_set_after_handler(void) +{ + mmc_set_internal_clk(CLOCKS_SDIO_FREQ_50M); +} + static inline void set_local_part_node(struct mmcsd_part *part, int index) { g_local_part[index] = part; @@ -200,7 +209,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, FAR u_char *buffer, mmc_err("failed to find mmc device!\n"); return (-EINVAL); } - mmc_init_before_handler(); + mmc_clk_set_before_handler(); uapi_pm_add_sleep_veto(PM_ID_STORAGE); dpal_atomic_inc(&part->atom_reqs); if (part->part_status != PART_NORMAL) { @@ -222,6 +231,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, FAR u_char *buffer, out: dpal_atomic_dec(&part->atom_reqs); uapi_pm_remove_sleep_veto(PM_ID_STORAGE); + mmc_clk_set_after_handler(); return ((ret == 0) ? -EAGAIN : (ssize_t)ret); } @@ -237,7 +247,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, FAR const u_char *buffer, mmc_err("failed to find mmc device!\n"); return (-EINVAL); } - mmc_init_before_handler(); + mmc_clk_set_before_handler(); uapi_pm_add_sleep_veto(PM_ID_STORAGE); dpal_atomic_inc(&part->atom_reqs); if (part->part_status != PART_NORMAL) { @@ -259,6 +269,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, FAR const u_char *buffer, out: dpal_atomic_dec(&part->atom_reqs); uapi_pm_remove_sleep_veto(PM_ID_STORAGE); + mmc_clk_set_after_handler(); return ((ret == 0) ? -EAGAIN : (ssize_t)ret); } @@ -387,7 +398,7 @@ static int mmcsd_geometry(FAR struct inode *inode, FAR struct geometry *geometry } sc = part->sc; dev = sc->dev; - mmc_init_before_handler(); + mmc_clk_set_before_handler(); uapi_pm_add_sleep_veto(PM_ID_STORAGE); dpal_atomic_inc(&part->atom_reqs); if (part->part_status != PART_NORMAL) { @@ -406,6 +417,7 @@ static int mmcsd_geometry(FAR struct inode *inode, FAR struct geometry *geometry geometry->geo_sectorsize = (size_t)mmc_get_sector_size(dev); dpal_atomic_dec(&part->atom_reqs); uapi_pm_remove_sleep_veto(PM_ID_STORAGE); + mmc_clk_set_after_handler(); return (ENOERR); } @@ -434,7 +446,7 @@ static int mmcsd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg) struct mmc_ivars *ivar = device_get_ivars(dev); uint32_t au_reg_value; - mmc_init_before_handler(); + mmc_clk_set_before_handler(); uapi_pm_add_sleep_veto(PM_ID_STORAGE); dpal_atomic_inc(&part->atom_reqs); if (part->part_status != PART_NORMAL) { @@ -457,6 +469,7 @@ static int mmcsd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg) } dpal_atomic_dec(&part->atom_reqs); uapi_pm_remove_sleep_veto(PM_ID_STORAGE); + mmc_clk_set_after_handler(); return (ENOERR); } @@ -636,7 +649,7 @@ static ssize_t mmc_rw(int index, char *buffer, uint32_t start_sector, uint32_t n uint32_t sector_now = nsectors; uint32_t sector_count; ssize_t ret; - mmc_init_before_handler(); + mmc_clk_set_before_handler(); uapi_pm_add_sleep_veto(PM_ID_STORAGE); do { sector_count = (sector_now >= MMC_RAW_WRITE_MAX_SECTOR) ? MMC_RAW_WRITE_MAX_SECTOR : sector_now; @@ -651,6 +664,7 @@ static ssize_t mmc_rw(int index, char *buffer, uint32_t start_sector, uint32_t n buffer += sector_count << 9; /* every sector size is 512 (1 << 9) */ } while (sector_now != 0); uapi_pm_remove_sleep_veto(PM_ID_STORAGE); + mmc_clk_set_after_handler(); return ((ssize_t)nsectors); } diff --git a/code/sdk/drivers/drivers/driver/mmc/host/sdhci/brandy/mmc_sdhci.c b/code/sdk/drivers/drivers/driver/mmc/host/sdhci/brandy/mmc_sdhci.c index 1c0f7d712..7b1b31fc0 100644 --- a/code/sdk/drivers/drivers/driver/mmc/host/sdhci/brandy/mmc_sdhci.c +++ b/code/sdk/drivers/drivers/driver/mmc/host/sdhci/brandy/mmc_sdhci.c @@ -32,6 +32,9 @@ #include "sdhci_private.h" #include "hci_helper.h" #include "mmc_adapt.h" +#include "mmcvar.h" +#include "mmc_private.h" +#include "sdio.h" #include "chip_core_definition.h" #include "common_def.h" #include "clocks_switch.h" @@ -52,33 +55,67 @@ #define EMMC_SAVE_BUS_TIMING_MMC_DDR52 4 #define EMMC_SAVE_BUS_TIMING_MMC_HS400 7 #define EMMC_CMD0_RESET_WAIT_TIME 900 -#define PM_EMMC_CCLK_DIV_REG 0x52000100 -#define PM_SD_HOST_CCLK_DIV_REG 0x52000110 + #define RC_CLK_VALUE 49152000 #define XO_CLK_VALUE 32000000 #define XO_DLL2_CLK_VALUE 64000000 #define PLL_CLK_VALUE 884736000 -#define PM_SDIOM_CLK_REG 0x55000628 -#define PM_EMMC_DIV_REG 0x52000120 + +#ifndef SDHCI_ERR_INT_STAT_EN +#define SDHCI_ERR_INT_STAT_EN 0x36 +#endif + +#ifndef SDHCI_ERR_INT_SIGNAL_EN +#define SDHCI_ERR_INT_SIGNAL_EN 0x3A +#endif +#ifndef SDHCI_MBIU_CTRL +#define SDHCI_MBIU_CTRL 0x510 +#endif typedef struct { uint16_t sdiom_clk_reg; - uint16_t emmc_cclk_reg; - uint16_t emmc_div_reg; + uint16_t clk_div1_reg; // EMMC_CCLK_DIV or SD_HOST_CCLK_DIV + uint16_t clk_div2_reg; // EMMC_DIV or SDIO_HOST_CKDIV uint16_t sd_bus_reg; uint16_t mbiu_ctrl; uint32_t timing; uint32_t bus_width; uint32_t at_ctrl; uint32_t at_stat; + uint16_t clk_ctrl; + uint16_t power_ctrl; uint16_t host_ctrl1; uint16_t host_ctrl2; + uint32_t int_en; // int & err_int + uint32_t int_sig_en; // int_sig & err_int_sig } mmc_save_info_t; -static mmc_save_info_t g_mmc_cur_info = { 0 }; +typedef enum { + SDIOM_SEL_LP_MODE, // 功耗优先, 两路mmc需求不一致选低的 + SDIOM_SEL_PERF_MODE, // 性能优先,两路mmc需求不一致选高的 + SDIOM_SEL_MODE_MAX, +} sdiom_select_mode_t; +uint8_t g_sdiom_sel_mode = SDIOM_SEL_LP_MODE; + +uint32_t g_sdiom_cfg_clk[MAX_MMC_NUM] = {0, 0}; +system_sdio_freq_t g_sdiom_mmc_sel[MAX_MMC_NUM] = {CLOCKS_SDIO_FREQ_MAX, CLOCKS_SDIO_FREQ_MAX}; +system_sdio_freq_t g_sdiom_cur_sel = CLOCKS_SDIO_FREQ_MAX; + + +static mmc_save_info_t g_mmc_cur_info[MAX_MMC_NUM] = { {0}, {0} }; bool g_mmc_sleep_inited = false; bool g_mmc_inited = false; -static enum mmc_bus_timing g_max_timing = bus_timing_normal; +static enum mmc_bus_timing g_max_timing[MAX_MMC_NUM] = {bus_timing_normal, bus_timing_normal}; + +uint32_t g_clk_div1_reg[MAX_MMC_NUM] = {EMMC_CCLK_DIV_REG, SD_HOST_CCLK_DIV_REG}; +uint32_t g_clk_div2_reg[MAX_MMC_NUM] = {EMMC_DIV_REG, SDIO_HOST_CCLK_DIV_REG}; +uint32_t g_tunning_coarse_mode[MAX_MMC_NUM] = {EMMC_TUNING_COARSE_MODE, SDIO_TUNING_COARSE_MODE}; +uint32_t g_tunning_bm0_reg[MAX_MMC_NUM] = {EMMC_TUNING_BM0_REG, SD_HOST_TUNING_BM0_REG}; +uint32_t g_tunning_bm0_value[MAX_MMC_NUM] = {EMMC_TUNING_BM0_VAL, SDIO_TUNING_BM0_VAL}; +uint32_t g_tunning_bm1_reg[MAX_MMC_NUM] = {EMMC_TUNING_BM1_REG, SD_HOST_TUNING_BM1_REG}; +uint32_t g_tunning_bm1_value[MAX_MMC_NUM] = {EMMC_TUNING_BM1_VAL, SDIO_TUNING_BM1_VAL}; + +uint32_t mmc_get_clock_value(uint32_t id); void mmc_set_first_init_flag(bool flag) { @@ -100,47 +137,177 @@ bool mmc_get_sleep_init_flag(void) return g_mmc_sleep_inited; } -mmc_save_info_t* sdhci_get_save_info(void) +/* + * 函 数 名 : mmc_sdhci_suspend + * 功能描述 : 低功耗suspend接口, 保存所有mmc slot工作必须的寄存器 + */ +void mmc_sdhci_suspend(void) { - return &g_mmc_cur_info; + int32_t i; + struct hci_softc *sc = NULL; + + for (i = 0; i < MAX_MMC_NUM; i++) { + sc = get_mmc_resource(i); + if (sc == NULL || sc->slot == NULL || ((struct sdhci_slot*)sc->slot)->dev == NULL) { + continue; + } + + reg16_setbit(g_clk_div1_reg[i], 0); // clk en + g_mmc_cur_info[i].timing = regw_getbits(sc->base, SDHCI_HOST_CONTROL2, 0x0, LEN_3BIT); // for speed mode + g_mmc_cur_info[i].at_ctrl = hci_readl(sc, SDHCI_AUTO_TUNING_CTRL); + g_mmc_cur_info[i].at_stat = regw_getbits(sc->base, SDHCI_AUTO_TUNING_STATUS, 0x0, LEN_8BIT); // for phase + if (reg8_getbit(sc->base + SDHCI_HOST_CONTROL, EXT_DAT_XFER_BIT) == 1) { + g_mmc_cur_info[i].bus_width = EMMC_SAVE_BUS_WIDTH_8BIT; + } else { + if (reg8_getbit(sc->base + SDHCI_HOST_CONTROL, 0x1) == 1) { + g_mmc_cur_info[i].bus_width = EMMC_SAVE_BUS_WIDTH_4BIT; + } else { + g_mmc_cur_info[i].bus_width = EMMC_SAVE_BUS_WIDTH_1BIT; + } + } + g_mmc_cur_info[i].sdiom_clk_reg = readw(SDIOM_CR_REG); + g_mmc_cur_info[i].clk_div1_reg = readw(g_clk_div1_reg[i]); + g_mmc_cur_info[i].clk_div2_reg = readw(g_clk_div2_reg[i]); + g_mmc_cur_info[i].sd_bus_reg = readw(SDIO_BUS_CGDIV_REG); + g_mmc_cur_info[i].mbiu_ctrl = hci_readw(sc, SDHCI_MBIU_CTRL); + g_mmc_cur_info[i].clk_ctrl = hci_readw(sc, SDHCI_CLOCK_CONTROL); + g_mmc_cur_info[i].power_ctrl = hci_readb(sc, SDHCI_POWER_CONTROL); + g_mmc_cur_info[i].host_ctrl1 = hci_readb(sc, SDHCI_HOST_CONTROL); + g_mmc_cur_info[i].host_ctrl2 = hci_readw(sc, SDHCI_HOST_CONTROL2); + g_mmc_cur_info[i].int_en = hci_readl(sc, SDHCI_INT_ENABLE); + g_mmc_cur_info[i].int_sig_en = hci_readl(sc, SDHCI_SIGNAL_ENABLE); +#if MMC_BOARD_DEBUG_ON + PRINT("mmc%d save sdiom=0x%x, clk_div1=0x%x, clk_div2=0x%x, timing=%d, phase=%d, bus_width=%d\r\n", + i, g_mmc_cur_info[i].sdiom_clk_reg, g_mmc_cur_info[i].clk_div1_reg, g_mmc_cur_info[i].clk_div2_reg, + g_mmc_cur_info[i].timing, g_mmc_cur_info[i].at_stat, g_mmc_cur_info[i].bus_width); + PRINT("mmc%d save clk_ctrl=0x%x, power_ctrl=0x%x, host_ctrl1=0x%x, host_ctrl2=0x%x\r\n", + i, g_mmc_cur_info[i].clk_ctrl, g_mmc_cur_info[i].power_ctrl, g_mmc_cur_info[i].host_ctrl1, + g_mmc_cur_info[i].host_ctrl2); + PRINT("mmc%d save int_en=0x%x, sig_en=0x%x\r\n", i, g_mmc_cur_info[i].int_en, g_mmc_cur_info[i].int_sig_en); +#endif + reg16_clrbit(g_clk_div1_reg[i], 0); // clk disable + } + mmc_set_sleep_init_flag(false); } -void emmc_save_info(void) +/* + * 函 数 名 : mmc_sdhci_resume + * 功能描述 : 低功耗resume接口, 恢复所有mmc slot工作必须的寄存器 + */ +void mmc_sdhci_resume(void) { - uint32_t tmp_div; - if (!mmc_get_sleep_init_flag()) { - return; - } - reg16_setbit(PM_EMMC_CCLK_DIV_REG, 0); - g_mmc_cur_info.timing = regw_getbits(HOST_CTRL2, 0, 0x0, LEN_3BIT); // for speed mode - g_mmc_cur_info.at_ctrl = readl(AT_CTRL); - g_mmc_cur_info.at_stat = regw_getbits(AT_STAT, 0, 0x0, LEN_8BIT); // for phase - if (reg8_getbit(HOST_CTRL1, EXT_DAT_XFER_BIT) == 1) { - g_mmc_cur_info.bus_width = EMMC_SAVE_BUS_WIDTH_8BIT; - } else { - if (reg8_getbit(HOST_CTRL1, 0x1) == 1) { - g_mmc_cur_info.bus_width = EMMC_SAVE_BUS_WIDTH_4BIT; - } else { - g_mmc_cur_info.bus_width = EMMC_SAVE_BUS_WIDTH_1BIT; + int32_t i; + struct hci_softc *sc; + + for (i = 0; i < MAX_MMC_NUM; i++) { + sc = get_mmc_resource(i); + if (sc == NULL || sc->slot == NULL || ((struct sdhci_slot*)sc->slot)->dev == NULL) { + continue; + } +#if MMC_BOARD_DEBUG_ON + PRINT("mmc%d resume all saved reg\r\n", i); +#endif + writew(SDIOM_CR_REG, g_mmc_cur_info[i].sdiom_clk_reg); + writew(g_clk_div1_reg[i], g_mmc_cur_info[i].clk_div1_reg); + writew(g_clk_div2_reg[i], g_mmc_cur_info[i].clk_div2_reg); + writew(SDIO_BUS_CGDIV_REG, g_mmc_cur_info[i].sd_bus_reg); + reg16_setbit(sc->base + SDHCI_CLOCK_CONTROL, 0x0); // offset:2c bit0 internal clk en + reg16_setbit(sc->base + SDHCI_CLOCK_CONTROL, 0x3); // offset:2c bit3 pll enable + reg16_setbit(sc->base + SDHCI_CLOCK_CONTROL, 0x2); // offset:2c bit2 sd clk enable + while (reg16_getbit(sc->base + SDHCI_CLOCK_CONTROL, 0x1) != 1) { ; } // wait clock is stability + + hci_writeb(sc, SDHCI_TIMEOUT_CONTROL, 0xe); + hci_writew(sc, SDHCI_CLOCK_CONTROL, g_mmc_cur_info[i].clk_ctrl); + hci_writeb(sc, SDHCI_POWER_CONTROL, g_mmc_cur_info[i].power_ctrl); + hci_writeb(sc, SDHCI_HOST_CONTROL, g_mmc_cur_info[i].host_ctrl1); + hci_writew(sc, SDHCI_HOST_CONTROL2, g_mmc_cur_info[i].host_ctrl2); + hci_writel(sc, SDHCI_INT_ENABLE, g_mmc_cur_info[i].int_en); + hci_writel(sc, SDHCI_SIGNAL_ENABLE, g_mmc_cur_info[i].int_sig_en); + + hci_writew(sc, SDHCI_MBIU_CTRL, g_mmc_cur_info[i].mbiu_ctrl); + writew(g_tunning_bm0_reg[i], g_tunning_bm0_value[i]); + writew(g_tunning_bm1_reg[i], g_tunning_bm1_value[i]); + hci_writel(sc, SDHCI_AUTO_TUNING_CTRL, g_mmc_cur_info[i].at_ctrl); + reg16_setbits(sc->base + SDHCI_AUTO_TUNING_STATUS, 0, LEN_8BIT, g_mmc_cur_info[i].at_stat); + // The fixed clock is less than or equal to 52 MHz, and the tuning clock is not used. + if (mmc_get_clock_value(i) <= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { + reg16_clrbit(sc->base + SDHCI_HOST_CONTROL2, SAMPLE_CLK_SEL_BIT); } } - g_mmc_cur_info.sdiom_clk_reg = readw(SDIOM_CR_REG); - g_mmc_cur_info.emmc_cclk_reg = readw(EMMC_CCLK_DIV_REG); - g_mmc_cur_info.emmc_div_reg = readw(EMMC_DIV_REG); - g_mmc_cur_info.sd_bus_reg = readw(SDIO_BUS_CGDIV_REG); - g_mmc_cur_info.mbiu_ctrl = readw(MBIIU_CTRL); - g_mmc_cur_info.host_ctrl1 = readb(HOST_CTRL1); - g_mmc_cur_info.host_ctrl2 = readw(HOST_CTRL2); - -#if EMMC_BOARD_DEBUG_ON - PRINT("emmc save sdiom_reg=%x, emmc_cclk_reg=%x, emmc_div_reg=%x, timing=%d, phase=%d, bus_width=%d\r\n", - g_mmc_cur_info.sdiom_clk_reg, g_mmc_cur_info.emmc_cclk_reg, g_mmc_cur_info.emmc_div_reg, - g_mmc_cur_info.timing, g_mmc_cur_info.at_stat, g_mmc_cur_info.bus_width); + mmc_set_sleep_init_flag(true); +} + +#ifdef CFG_DRIVERS_SDIO +/* + * 函 数 名 : mmc_sdhci_sdio_reset + * 功能描述 : sdio slave设备上下电重启后,调用本接口恢复连接 + * 参数 :func:slave设备驱动中保存的sdio_func指针 + */ +void mmc_sdhci_sdio_reset(struct sdio_func* func) +{ + struct mmc_softc *mmc_sc = device_get_parent(func->sc->dev); +#ifdef DPALCFG_DRIVERS_SDIO + sdio_reset_comm(func); #endif - reg16_clrbit(PM_EMMC_CCLK_DIV_REG, 0); - mmc_set_sleep_init_flag(false); + sdio_en_func(func); + mmc_sc->card_init_status = MMC_CARD_INIT; +} + +struct sdio_func* mmc_get_sdio_func(int fn) +{ + struct hci_softc *sc = NULL; + struct mmc_softc *mmc_sc; + + sc = get_mmc_resource(1); + if (sc == NULL || sc->slot == NULL || ((struct sdhci_slot*)sc->slot)->dev == NULL) { + return NULL; + } + mmc_sc = device_get_softc(((struct sdhci_slot*)sc->slot)->dev); + if (mmc_sc == NULL || mmc_sc->child_list[0] == NULL) { + return NULL; + } + device_t child = mmc_sc->child_list[0]; + uint16_t manf_id = (uint16_t)mmc_get_cis_manid(child); + uint16_t device_id = (uint16_t)mmc_get_cis_proid(child); + + dprintf("%s manf_id: 0x%x, device_id: 0x%x\r\n", __FUNCTION__, manf_id, device_id); + return sdio_get_func(fn, manf_id, device_id); } +int mmc_test_sdio_read_byte(void) +{ + uint32_t addr = 0x0; + int err; + uint8_t byte; + + struct sdio_func* func = mmc_get_sdio_func(1); + if (func == NULL) { + return -ENODEV; + } + // 读CCCR寄存器 + for (addr = 0; addr < 0x10; addr++) { + byte = sdio_func0_read_byte(func, addr, &err); + dprintf("%s func0 address: 0x%x, result: 0x%x, err = %d\r\n", __FUNCTION__, addr, byte, err); + } + // 读func1地址 + for (addr = 0; addr < 0x10; addr++) { + byte = sdio_read_byte(func, addr, &err); + dprintf("%s func1 address: 0x%x, result: 0x%x, err = %d\r\n", __FUNCTION__, addr, byte, err); + } + + return err; +} + +void mmc_test_sdio_reset(void) +{ + struct sdio_func* func = mmc_get_sdio_func(1); + if (func == NULL) { + return; + } + mmc_sdhci_sdio_reset(func); +} +#endif + void emmc_send_cmd1(uint32_t args, uint16_t cmd, uint32_t *resp) { uint16_t rd_data = 0; @@ -220,7 +387,7 @@ void emmc_send_cmd(uint32_t args, uint16_t cmd, uint8_t flag, uint32_t *resp) if (cnt == RETRY_CNT2) { PRINT("cmd=%x ERR INT=%x\r\n", cmd, readw(ERROR_INT_STAT)); } reg16_setbit(NORMAL_INT_STAT, 0x0); *resp = readl(RESP01); -#if EMMC_BOARD_DEBUG_ON +#if MMC_BOARD_DEBUG_ON PRINT("CMD=%x, arg=%x, resp=%x\r\n", cmd, args, *resp); #endif } @@ -243,7 +410,7 @@ void emmc_send_cmd_r2(uint32_t args, uint16_t cmd, uint32_t *resp) resp[1] = readl(RESP23); // 1 for responese 71-40 bits of the Response Field resp[2] = readl(RESP45); // 2 for responese 103-72 bits of the Response Field resp[3] = readl(RESP67); // 3 for responese 135-104 bits of the Response Field -#if EMMC_BOARD_DEBUG_ON +#if MMC_BOARD_DEBUG_ON PRINT("CMD-r2=%x, arg=%x, resp:%x %x %x %x\r\n", cmd, args, resp[0], resp[1], resp[2], resp[3]); // 2,3 fro resp #endif } @@ -296,42 +463,19 @@ void emmc_set_timing_and_buswidth(uint32_t bus_width, uint32_t timing) if (width_flag == 1) { emmc_send_cmd6(width_args, CMD6_INDEX, &resp); } if (timing_flag == 1) { emmc_send_cmd6(timing_args, CMD6_INDEX, &resp); } -#if EMMC_BOARD_DEBUG_ON - PRINT("timing=%x width_args=%x tuning=%x \r\n", timing, width_args, g_mmc_cur_info.at_stat); +#if MMC_BOARD_DEBUG_ON + PRINT("timing=%x width_args=%x tuning=%x \r\n", timing, width_args, g_mmc_cur_info[0].at_stat); #endif } -static void emmc_reg_init(void) -{ - writew(PERI_EMMC_CRG_RST_CTL, 0); - writew(PERI_EMMC_CRG_RST_CTL, SOFT_RST_GLB_SDIO_DERESET); - init_emmc_pinmux(); - - // set emmc clk 400k - writew(SDIOM_CR_REG, 0x3); - writew(EMMC_CCLK_DIV_REG, 0x5507); - writew(EMMC_DIV_REG, 0x13); - reg16_setbit(CLK_CTRL, 0x0); // offset:2c bit0 internal clk en - reg16_setbit(CLK_CTRL, 0x3); // offset:2c bit3 pll enable - reg16_setbit(CLK_CTRL, 0x2); // offset:2c bit2 sd clk enable - while (reg16_getbit(CLK_CTRL, 0x1) != 1) { ; } // wait clock is stability - writeb(TOUT_CTRL, 0xe); - - writeb(PWR_CTRL, POWR_ON_1_8V); // pwr ctrl, 1.8v - writew(NORMAL_INT_STAT_EN, NORMAL_ERR_INT_EN); // normal int enable - writew(ERROR_INT_STAT_EN, NORMAL_ERR_INT_EN); // normal signal enable - writew(NORMAL_INT_SIGNAL_EN, ALL_NORMAL_ERR_INT); // error int enable - writew(ERROR_INT_SIGNAL_EN, ALL_NORMAL_ERR_INT); // error signal enable - reg16_setbit(EMMC_CTRL, 0x0); // set emmc -} - -uint32_t emmc_get_clock_value(void) +uint32_t mmc_get_clock_value(uint32_t id) { - uint8_t clk_flag = (readw(PM_SDIOM_CLK_REG) & 0xE) >> 0x1; + uint8_t clk_flag = (readw(SDIOM_CR_REG) & 0xE) >> 0x1; uint32_t source_clk_val = XO_CLK_VALUE; uint16_t div1 = 1; uint16_t div2 = 1; uint16_t div3 = 1; + if (clk_flag == 0x1) { source_clk_val = XO_CLK_VALUE; } else if (clk_flag == 0x2) { @@ -341,105 +485,20 @@ uint32_t emmc_get_clock_value(void) } else { // rc or no defined source_clk_val = RC_CLK_VALUE; } - if (reg16_getbit(PM_SDIOM_CLK_REG, 0x4) == 1) { - div1 = regw_getbits(PM_SDIOM_CLK_REG, 0, 0x5, 0x4); + if (reg16_getbit(SDIOM_CR_REG, 0x4) == 1) { + div1 = regw_getbits(SDIOM_CR_REG, 0, 0x5, 0x4); } - if (reg16_getbit(PM_EMMC_CCLK_DIV_REG, 0x1) == 1) { - div2 = regw_getbits(PM_EMMC_CCLK_DIV_REG, 0, 0x4, 0x8); + if (reg16_getbit(g_clk_div1_reg[id], 0x1) == 1) { + div2 = regw_getbits(g_clk_div1_reg[id], 0, 0x4, 0x8); } - if (reg16_getbit(PM_EMMC_DIV_REG, 0x0) == 1) { - div3 = regw_getbits(PM_EMMC_DIV_REG, 0, 0x4, 0x3); + if (reg16_getbit(g_clk_div2_reg[id], 0x0) == 1) { + div3 = regw_getbits(g_clk_div2_reg[id], 0, 0x4, 0x3); } -#if EMMC_BOARD_DEBUG_ON - PRINT(" value =%lu, div1=%d div2=%d, div3=%d\r\n", source_clk_val, div1, div2, div3); +#if MMC_BOARD_DEBUG_ON + PRINT("clk_flag=%d, value=%lu, div1=%d div2=%d, div3=%d\r\n", clk_flag, source_clk_val, div1, div2, div3); #endif return (source_clk_val / div1 / div2 / div3); } -static void emmc_recovery_register(void) -{ - // set emmc clk 400k - writew(SDIOM_CR_REG, 0x3); - writew(EMMC_CCLK_DIV_REG, 0x5507); - writew(EMMC_DIV_REG, 0x13); - reg16_setbit(CLK_CTRL, 0x0); // offset:2c bit0 internal clk en - reg16_setbit(CLK_CTRL, 0x3); // offset:2c bit3 pll enable - reg16_setbit(CLK_CTRL, 0x2); // offset:2c bit2 sd clk enable - while (reg16_getbit(CLK_CTRL, 0x1) != 1) { ; } // wait clock is stability - writeb(TOUT_CTRL, 0xe); - - writeb(PWR_CTRL, POWR_ON_1_8V); // pwr ctrl, 1.8v - writew(NORMAL_INT_STAT_EN, NORMAL_ERR_INT_EN); // normal int enable - writew(ERROR_INT_STAT_EN, NORMAL_ERR_INT_EN); // normal signal enable - writew(NORMAL_INT_SIGNAL_EN, ALL_NORMAL_ERR_INT); // error int enable - writew(ERROR_INT_SIGNAL_EN, ALL_NORMAL_ERR_INT); // error signal enable - reg16_setbit(EMMC_CTRL, 0x0); // set emmc - writeb(HOST_CTRL1, g_mmc_cur_info.host_ctrl1); - writew(HOST_CTRL2, g_mmc_cur_info.host_ctrl2); - writew(SDIOM_CR_REG, g_mmc_cur_info.sdiom_clk_reg); - writew(EMMC_CCLK_DIV_REG, g_mmc_cur_info.emmc_cclk_reg); - writew(EMMC_DIV_REG, g_mmc_cur_info.emmc_div_reg); - writew(SDIO_BUS_CGDIV_REG, g_mmc_cur_info.sd_bus_reg); - writew(MBIIU_CTRL, g_mmc_cur_info.mbiu_ctrl); - writew(EMMC_TUNING_BM0_REG, EMMC_TUNING_BM0_VAL); - writew(EMMC_TUNING_BM1_REG, EMMC_TUNING_BM1_VAL); - writel(AT_CTRL, g_mmc_cur_info.at_ctrl); - reg16_setbits(AT_STAT, 0, LEN_8BIT, g_mmc_cur_info.at_stat); - // The fixed clock is less than or equal to 52 MHz, and the tuning clock is not used. - if (emmc_get_clock_value() <= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { - reg16_clrbit(HOST_CTRL2, SAMPLE_CLK_SEL_BIT); - } -} -void emmc_recovery_init(void) -{ - uint32_t irq_sts = osal_irq_lock(); - uint64_t time1 = uapi_tcxo_get_us(); - uint64_t time9 = 0; -#ifdef EMMC_RECOVERY_WITH_REENUME - uint32_t args = 0; - uint32_t resp = 0; - uint32_t resp_r2[4] = { 0 }; - uint32_t flag = 1; - mmc_save_info_t* ptr_mmc = sdhci_get_save_info(); - uint32_t timing = ptr_mmc->timing; - uint32_t bus_width = ptr_mmc->bus_width; - - emmc_reg_init(); - tcxo_port_delay_us(1200); // wait 1200 cnt (1ms) - emmc_send_cmd(0x0, CMD0_INDEX, 0, &resp); // cmd0 - tcxo_port_delay_us(1000); // wait 1000 cnt (900us) ok - resp = 0; - emmc_send_cmd1(CMD1_ARGS, CMD1_INDEX, &resp); - emmc_send_cmd_r2(0x0, CMD2_INDEX, resp_r2); // cmd2 - emmc_send_cmd(CMD3_ARGS, CMD3_INDEX, 1, &resp); // cmd3 - emmc_send_cmd_r2(CMD9_ARGS, CMD9_INDEX, resp_r2); // cmd9 - emmc_send_cmd(CMD7_ARGS, CMD7_INDEX, 1, &resp); // cmd7 - emmc_set_timing_and_buswidth(bus_width, timing); - // recovery for clock and phase - writeb(HOST_CTRL1, g_mmc_cur_info.host_ctrl1); - writew(HOST_CTRL2, g_mmc_cur_info.host_ctrl2); - writew(SDIOM_CR_REG, g_mmc_cur_info.sdiom_clk_reg); - writew(EMMC_CCLK_DIV_REG, g_mmc_cur_info.emmc_cclk_reg); - writew(EMMC_DIV_REG, g_mmc_cur_info.emmc_div_reg); - writew(SDIO_BUS_CGDIV_REG, g_mmc_cur_info.sd_bus_reg); - writew(MBIIU_CTRL, g_mmc_cur_info.mbiu_ctrl); - writew(EMMC_TUNING_BM0_REG, EMMC_TUNING_BM0_VAL); - writew(EMMC_TUNING_BM1_REG, EMMC_TUNING_BM1_VAL); - writel(AT_CTRL, g_mmc_cur_info.at_ctrl); - reg16_setbits(AT_STAT, 0, LEN_8BIT, g_mmc_cur_info.at_stat); - // The fixed clock is less than or equal to 52 MHz, and the tuning clock is not used. - if (emmc_get_clock_value() <= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { - reg16_clrbit(HOST_CTRL2, SAMPLE_CLK_SEL_BIT); - } -#else - emmc_recovery_register(); -#endif - time9 = uapi_tcxo_get_us(); - osal_irq_restore(irq_sts); -#if EMMC_BOARD_DEBUG_ON - PRINT("OK~ time1=%llu tim9=%llu, time=%llu\r\n", time1, time9, time9-time1); -#endif - reg16_clrbit(PM_EMMC_CCLK_DIV_REG, 0); -} static void hal_mmc_set_preset_val(struct hci_softc *sc, bool en) { @@ -471,7 +530,7 @@ static int mmc_voltage_switch(struct hci_softc *sc, uint32_t vccq) break; } -#if (EMMC_BOARD_DEBUG_ON) +#if (MMC_BOARD_DEBUG_ON) device_printf(sc->dev, "vccq:[%u], pwr:[%u].\n", vccq, pwr); #endif @@ -499,45 +558,73 @@ static void mmc_set_sd_bus_clk_div(uint32_t div_reg, uint32_t freq_div) DPAL_WRITE_UINT16(value, div_reg); } -static void mmc_set_sdiom_src_clk(uint32_t cfg_clock, uint32_t *freq_div, uint32_t *second_freq_div) +static void mmc_calc_sdiom_clk_div(system_sdio_freq_t freq_level, uint32_t cfg_clock, + uint32_t *freq_div, uint32_t *second_freq_div) { - system_sdio_freq_t sdiom_freq_level; + uint32_t sdiom_freq_val[CLOCKS_SDIO_FREQ_MAX] = { + SDIOM_SRC_CLK_LOW_FREQ_VAL, SDIOM_SRC_CLK_FREQ_LVL_50M_VAL, + SDIOM_SRC_CLK_FREQ_LVL_64M_VAL, SDIOM_SRC_CLK_HIGH_FREQ_LVL_VAL + }; *second_freq_div = 1; + if (cfg_clock <= sdiom_freq_val[freq_level]) { + *freq_div = sdiom_freq_val[freq_level] / cfg_clock; + if (freq_level == CLOCKS_SDIO_FREQ_32M || freq_level == CLOCKS_SDIO_FREQ_H) { + if (sdiom_freq_val[freq_level] % cfg_clock != 0) { *freq_div += 1; } + } + } else { + *freq_div = 1; + } + + if (*freq_div > 0xFF) { + dprintf("%s, div:[%u] error\r\n", __FUNCTION__, *freq_div); + freq_level = CLOCKS_SDIO_FREQ_32M; + *freq_div = 1; + } +#if (MMC_BOARD_DEBUG_ON) + dprintf("clk_level[%u], freq_div[%u], second_freq_div[%u], sdiom_freq_val[%u], cfg_clock[%u]!\n", + freq_level, *freq_div, *second_freq_div, sdiom_freq_val[freq_level], cfg_clock); +#endif +} +static system_sdio_freq_t mmc_select_sdiom_src_clk(struct hci_softc *sc, uint32_t cfg_clock) +{ + uint32_t co_num = (sc->num == 0) ? 1 : 0; // 同时钟源共存的另外一个mmc + system_sdio_freq_t freq_level; + + g_sdiom_cfg_clk[sc->num] = cfg_clock; if (cfg_clock <= SDIOM_SRC_CLK_LOW_FREQ_VAL) { - sdiom_freq_level = CLOCKS_SDIO_FREQ_32M; - *freq_div = SDIOM_SRC_CLK_LOW_FREQ_VAL / cfg_clock; - if (SDIOM_SRC_CLK_LOW_FREQ_VAL % cfg_clock != 0) { *freq_div += 1; } + freq_level = CLOCKS_SDIO_FREQ_32M; +#ifndef CFG_DRIVERS_NANDFLASH } else if (cfg_clock <= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { - sdiom_freq_level = CLOCKS_SDIO_FREQ_50M; - *freq_div = 1; + freq_level = CLOCKS_SDIO_FREQ_50M; } else if (cfg_clock == SDIOM_SRC_CLK_FREQ_LVL_64M_VAL) { - sdiom_freq_level = CLOCKS_SDIO_FREQ_64M; - *freq_div = 1; + freq_level = CLOCKS_SDIO_FREQ_64M; } else if (cfg_clock <= SDIOM_SRC_CLK_HIGH_FREQ_LVL_VAL) { - sdiom_freq_level = CLOCKS_SDIO_FREQ_H; - *freq_div = SDIOM_SRC_CLK_HIGH_FREQ_LVL_VAL / cfg_clock; - if (SDIOM_SRC_CLK_HIGH_FREQ_LVL_VAL % cfg_clock != 0) { *freq_div += 1; } + freq_level = CLOCKS_SDIO_FREQ_H; } else { - sdiom_freq_level = CLOCKS_SDIO_FREQ_32M; - *freq_div = 1; + freq_level = CLOCKS_SDIO_FREQ_H; } - if (!clocks_set_sdio_freq(sdiom_freq_level)) { -#if (EMMC_BOARD_DEBUG_ON) - dprintf("%s, sdiom_freq_level:[%u] error\r\n", __FUNCTION__, sdiom_freq_level); -#endif +#else // NANDFLASH + SDIO共存场景, 固定选高频 + } else { + freq_level = CLOCKS_SDIO_FREQ_H; } +#endif + /* 记录下原始的选择 */ + g_sdiom_mmc_sel[sc->num] = freq_level; -#if (EMMC_BOARD_DEBUG_ON) - if (*freq_div > 0xFF) { - dprintf("%s, div:[%u] error\r\n", __FUNCTION__, *freq_div); + /* 根据同router的另外一个mmc确定最终的选择 */ + if (g_sdiom_mmc_sel[co_num] != CLOCKS_SDIO_FREQ_MAX) { + if (g_sdiom_sel_mode == SDIOM_SEL_LP_MODE) { + freq_level = (g_sdiom_mmc_sel[co_num] > freq_level) ? freq_level : g_sdiom_mmc_sel[co_num]; + } else { + freq_level = (g_sdiom_mmc_sel[co_num] > freq_level) ? g_sdiom_mmc_sel[co_num] : freq_level; + } } - dprintf("clk_level:[%u], freq_div:[%u], second_freq_div:[%u], cfg_clock: [%u]!\n", - sdiom_freq_level, *freq_div, *second_freq_div, cfg_clock); -#endif + + return freq_level; } -static void mmc_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div) +static void emmc_host_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div) { uint16_t value; @@ -549,7 +636,7 @@ static void mmc_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div) value &= ~SDIO_EMMC_DIV_NUM_MASK; value |= (uint16_t)(freq_div << SDIO_EMMC_DIV_NUM_POST_SHIFT); value |= EMMC_CARD_CLK_INV_SET; -#if (EMMC_BOARD_DEBUG_ON) +#if (MMC_BOARD_DEBUG_ON) dprintf("%s, freq_div:[%u] value:[%x]!\n", __FUNCTION__, freq_div, value); #endif // 当0x52000100的bit13设置emmc cclk tuning coarse mode后,soc要求其分频系数必须大于等于2 @@ -563,9 +650,11 @@ static void mmc_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div) DPAL_WRITE_UINT16(value, div_reg); value |= EMMC_EMMC_CCLK_EN; DPAL_WRITE_UINT16(value, div_reg); + + tcxo_port_delay_us(60); // wait 60us } -static void mmc_set_second_level_clk_div(uint32_t div_reg, uint32_t freq_div) +static void emmc_host_set_second_level_clk_div(uint32_t div_reg, uint32_t freq_div) { uint16_t value; @@ -587,7 +676,26 @@ static void mmc_set_second_level_clk_div(uint32_t div_reg, uint32_t freq_div) DPAL_WRITE_UINT16(value, div_reg); } -static void mmc_host_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div) +static void emmc_host_set_clk_div(system_sdio_freq_t sdiom_freq_level, uint32_t real_clock) +{ + uint32_t freq_div = 1; + uint32_t sec_freq_div = 1; + + if (real_clock == 0) { + return; + } + /* 根据所选的sdiom时钟源和目标时钟频率,计算分频比 */ + mmc_calc_sdiom_clk_div(sdiom_freq_level, real_clock, &freq_div, &sec_freq_div); + if (real_clock <= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { + reg16_clrbit(EMMC_CCLK_DIV_REG, EMMC_TUNING_COARSE_MODE_BIT); + } else { + reg16_setbit(EMMC_CCLK_DIV_REG, EMMC_TUNING_COARSE_MODE_BIT); + } + emmc_host_set_first_level_clk_div(EMMC_CCLK_DIV_REG, freq_div); + emmc_host_set_second_level_clk_div(EMMC_DIV_REG, sec_freq_div); +} + +static void sdio_host_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div) { uint16_t value; value = DPAL_GET_UINT16(div_reg); @@ -598,6 +706,7 @@ static void mmc_host_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div DPAL_WRITE_UINT16(value, div_reg); value &= ~SDIO_EMMC_DIV_NUM_MASK; value |= (uint16_t)(freq_div << SDIO_EMMC_DIV_NUM_POST_SHIFT); + value |= SDIO_HOST_CARD_CLK_INV_SET; DPAL_WRITE_UINT16(value, div_reg); value |= SDIO_CCLK_ORI_DIV_EN; DPAL_WRITE_UINT16(value, div_reg); @@ -607,9 +716,13 @@ static void mmc_host_set_first_level_clk_div(uint32_t div_reg, uint32_t freq_div DPAL_WRITE_UINT16(value, div_reg); value = DPAL_GET_UINT16(div_reg); +#if (MMC_BOARD_DEBUG_ON) + dprintf("%s, freq_div:[%u],value:[%x]!\n", __FUNCTION__, freq_div, value); +#endif + tcxo_port_delay_us(60); // wait 60us } -static void mmc_host_set_second_level_clk_div(uint32_t div_reg, uint32_t freq_div) +static void sdio_host_set_second_level_clk_div(uint32_t div_reg, uint32_t freq_div) { uint16_t value; @@ -622,34 +735,61 @@ static void mmc_host_set_second_level_clk_div(uint32_t div_reg, uint32_t freq_di DPAL_WRITE_UINT16(value, div_reg); } -unsigned int mmc_set_clock_with_way2(struct hci_softc *sc, unsigned int cfg_clock) +static void sdio_host_set_clk_div(system_sdio_freq_t sdiom_freq_level, uint32_t real_clock) { - uint32_t first_freq_div = 0; - uint32_t freq_div = 0; - uint32_t second_freq_div = 0; + uint32_t freq_div = 1; uint32_t sec_freq_div = 1; + + if (real_clock == 0) { + return; + } + /* 根据所选的sdiom时钟源和目标时钟频率,计算分频比 */ + mmc_calc_sdiom_clk_div(sdiom_freq_level, real_clock, &freq_div, &sec_freq_div); + if (real_clock <= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { + reg16_clrbit(SD_HOST_CCLK_DIV_REG, SDIO_TUNING_COARSE_MODE_BIT); + } else { + reg16_setbit(SD_HOST_CCLK_DIV_REG, SDIO_TUNING_COARSE_MODE_BIT); + } + sdio_host_set_first_level_clk_div(SD_HOST_CCLK_DIV_REG, freq_div); + sdio_host_set_second_level_clk_div(SDIO_HOST_CCLK_DIV_REG, sec_freq_div); +} + +unsigned int mmc_set_clock_with_way2(struct hci_softc *sc, unsigned int cfg_clock) +{ + system_sdio_freq_t sdiom_freq_level; uint32_t real_clock = cfg_clock; + uint32_t change = true; if (cfg_clock > sc->caps.max_clk) { -#if EMMC_BOARD_DEBUG_ON - dprintf("%s, clock:[%u] is greater than the max_clk:[%u]!\n", __FUNCTION__, cfg_clock, sc->caps.max_clk); -#endif real_clock = sc->caps.max_clk; } - mmc_set_sdiom_src_clk(real_clock, &freq_div, &sec_freq_div); +#if MMC_BOARD_DEBUG_ON + dprintf("mmc%d cfg_clock[%u],max_clk:[%u],real_clock:[%u]\n", sc->num, cfg_clock, sc->caps.max_clk, real_clock); +#endif + sdiom_freq_level = mmc_select_sdiom_src_clk(sc, real_clock); + if (!clocks_set_sdio_freq(sdiom_freq_level)) { + return 0; + } + change = (sdiom_freq_level != g_sdiom_cur_sel) ? true : false; if (sc->num == 0) { - first_freq_div = EMMC_CCLK_DIV_REG; - second_freq_div = EMMC_DIV_REG; - mmc_set_first_level_clk_div(first_freq_div, freq_div); - mmc_set_second_level_clk_div(second_freq_div, sec_freq_div); + emmc_host_set_clk_div(sdiom_freq_level, real_clock); + if (change == true) { +#if (MMC_BOARD_DEBUG_ON) + dprintf("%s, sdiom change, update mmc1, cfg_clk[%d]\r\n", __FUNCTION__, g_sdiom_cfg_clk[1]); +#endif + sdio_host_set_clk_div(sdiom_freq_level, g_sdiom_cfg_clk[1]); // 源时钟有切换,另一路mmc要重配 + } #ifdef DPALCFG_DRIVERS_SDIO } else if (sc->num == 1) { - first_freq_div = SD_HOST_CCLK_DIV_REG; - second_freq_div = SDIO_HOST_CCLK_DIV_REG; - mmc_host_set_first_level_clk_div(first_freq_div, freq_div); - mmc_host_set_second_level_clk_div(second_freq_div, sec_freq_div); + sdio_host_set_clk_div(sdiom_freq_level, real_clock); + if (change == true) { +#if (MMC_BOARD_DEBUG_ON) + dprintf("%s, sdiom change, update mmc0, cfg_clk[%d]\r\n", __FUNCTION__, g_sdiom_cfg_clk[0]); +#endif + emmc_host_set_clk_div(sdiom_freq_level, g_sdiom_cfg_clk[0]); // 源时钟有切换,另一路mmc要重配 + } #endif } - + g_sdiom_cur_sel = sdiom_freq_level; mmc_set_sd_bus_clk_div(SDIO_BUS_CGDIV_REG, 1); return 0; @@ -679,18 +819,18 @@ static uint32_t sdhci_get_config_clock(struct hci_softc *sc, uint32_t clock) { uint32_t actual_clock = clock; if (clock > sc->caps.max_clk) { -#if EMMC_BOARD_DEBUG_ON +#if MMC_BOARD_DEBUG_ON dprintf("%s, clock:[%u] is greater than the max_clk:[%u]!\n", __FUNCTION__, clock, sc->caps.max_clk); #endif actual_clock = sc->caps.max_clk; } - switch (g_max_timing) { + switch (g_max_timing[sc->num]) { case bus_timing_mmc_hs: case bus_timing_uhs_sdr50: case bus_timing_uhs_ddr50: case bus_timing_mmc_ddr52: case bus_timing_sd_hs: - if (actual_clock >= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { + if (actual_clock >= SDIOM_SRC_CLK_FREQ_LVL_49M_VAL) { actual_clock = SDIOM_SRC_CLK_FREQ_LVL_49M_VAL; } break; @@ -700,7 +840,7 @@ static uint32_t sdhci_get_config_clock(struct hci_softc *sc, uint32_t clock) return actual_clock; } -uint32_t sdhci_set_clock(struct hci_softc *sc, uint32_t clock) +uint32_t mmc_sdhci_set_clock(struct hci_softc *sc, uint32_t clock) { unsigned int ret; static uint8_t inited = false; @@ -710,14 +850,11 @@ uint32_t sdhci_set_clock(struct hci_softc *sc, uint32_t clock) return clock; } actual_clk = sdhci_get_config_clock(sc, clock); -#if EMMC_BOARD_DEBUG_ON - dprintf("%s, clk:%u,a_clk:%u,resource:[0x%x]!\n", __FUNCTION__, clock, actual_clk, DPAL_GET_UINT16(SDIOM_CR_REG)); +#if MMC_BOARD_DEBUG_ON + dprintf("mmc%d clk:%u,a_clk:%u,max_timing[%d],resource:[0x%x]!\n", sc->num, + clock, actual_clk, g_max_timing[sc->num], DPAL_GET_UINT16(SDIOM_CR_REG)); #endif - if (actual_clk <= SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { - reg16_clrbit(BRANDY_EXTERNAL_EMMC_CCLK_DIV, EMMC_TUNING_COARSE_MODE_BIT); - } else { - reg16_setbit(BRANDY_EXTERNAL_EMMC_CCLK_DIV, EMMC_TUNING_COARSE_MODE_BIT); - } + ret = hal_mmc_set_soc_clock(sc, actual_clk); if (ret != 0) { device_printf(sc->dev, "set clock fail!\n"); @@ -730,36 +867,61 @@ uint32_t sdhci_set_clock(struct hci_softc *sc, uint32_t clock) hci_writeb(sc, SDHCI_AXI_MBIIU_CTRL, val); inited = true; } -#ifdef CFG_SDIO_EMMC_COEXIST - if (sc->num == 0) { -#endif + // After the tuning phase value is configured, the tuning clk function is automatically enabled. if (actual_clk > SDIOM_SRC_CLK_FREQ_LVL_50M_VAL) { - reg16_clrbit(HOST_CTRL2, SAMPLE_CLK_SEL_BIT); - reg16_clrbit(AT_CTRL, 0x4); // 0x4 means SW_TUNE_EN - dpal_writel(sc->tuning_phase, AT_STAT); - reg16_setbit(HOST_CTRL2, SAMPLE_CLK_SEL_BIT); + reg16_clrbit(sc->base + SDHCI_HOST_CONTROL2, SAMPLE_CLK_SEL_BIT); + hci_clearl(sc, SDHCI_AUTO_TUNING_CTRL, SDHCI_SW_TUNING_EN); // bit4 + hci_writel(sc, SDHCI_AUTO_TUNING_STATUS, sc->tuning_phase); + reg16_setbit(sc->base + SDHCI_HOST_CONTROL2, SAMPLE_CLK_SEL_BIT); // The fixed clock is less than or equal to 52 MHz, and the tuning clock is not used. } else { - reg16_clrbit(HOST_CTRL2, SAMPLE_CLK_SEL_BIT); - } -#ifdef CFG_SDIO_EMMC_COEXIST + reg16_clrbit(sc->base + SDHCI_HOST_CONTROL2, SAMPLE_CLK_SEL_BIT); } + +#if MMC_BOARD_DEBUG_ON + dprintf("%s,clk_src=0x%X, at_ctrl=0x%X, at_stat=0x%X, host2_ctrl=0x%X, tuning_phase=0x%X\r\n", + __FUNCTION__, readw(SDIOM_CR_REG), hci_readl(sc, SDHCI_AUTO_TUNING_CTRL), + hci_readl(sc, SDHCI_AUTO_TUNING_STATUS), hci_readw(sc, SDHCI_HOST_CONTROL2), sc->tuning_phase); #endif -#if EMMC_BOARD_DEBUG_ON - dprintf("%s,clk_src=0x%X, at_ctrl=0x%X, at_stat=0x%X, host2_ctrl=0x%X, tuning_phase=0x%X\r\n", __FUNCTION__, - readw(SDIOM_CR_REG), readw(AT_CTRL), readw(AT_STAT), readw(HOST_CTRL2), sc->tuning_phase); -#endif + tcxo_port_delay_us(60); // wait 60us return actual_clk; } +uint8_t is_sdio_working(void) +{ + struct hci_softc *sc = get_mmc_resource(1); + + if (sc == NULL || sc->slot == NULL) { + return false; + } + struct mmc_softc *mmc_sc = device_get_softc(((struct sdhci_slot*)sc->slot)->dev); + if (mmc_sc == NULL || mmc_sc->child_count == 0) { + return false; + } + + return (mmc_sc->card_init_status == MMC_CARD_INIT) ? true : false; +} void mmc_set_internal_clk(uint16_t clk_level) { + /* sdio和emmc共存情况下, 外部不能更改emmc的时钟源 */ + if (is_sdio_working() == true) { + return; + } + struct hci_softc *sc = get_mmc_resource(0); uint32_t g_sdiom_val[CLOCKS_SDIO_FREQ_MAX] = { CLOCKS_SDIO_FREQ_32M_VAL, CLOCKS_SDIO_FREQ_50M_VAL, CLOCKS_SDIO_FREQ_64M_VAL, CLOCKS_SDIO_FREQ_H_VAL }; - clocks_clk_cfg_t sdio_freq = clocks_system_sdio_freq_get(clk_level); - sdhci_set_clock(sc, g_sdiom_val[clk_level]); + + static uint16_t cur_level = CLOCKS_SDIO_FREQ_MAX; + if (clk_level == cur_level) { + return; + } + cur_level = clk_level; +#if MMC_BOARD_DEBUG_ON + dprintf("%s, clk_level %d\r\n", __FUNCTION__, clk_level); +#endif + mmc_sdhci_set_clock(sc, g_sdiom_val[clk_level]); } static void sdhci_set_drv_phase(uint32_t host_id, uint32_t phase) @@ -806,14 +968,14 @@ static void sdhci_subplatform_init(const struct hci_softc *sc, hci_caps *cfg_inf device_printf(sc->dev, "LOSCFG_DRIVERS_EMMC selected\n"); cfg_info->caps |= HCI_SLOTTYPE_EMBEDDED; cfg_info->caps |= HCI_CAN_DO_8BITBUS; - cfg_info->quirks |= SDHCI_QUIRK_SIG_1V8_ONLY; /* signal 1.2V unsupported */ + cfg_info->quirks |= SDHCI_QUIRK_SIG_1V8_ONLY; #ifdef DPALCFG_DRIVERS_SDIO } else if (sc->num == 1) { /* SDIO device */ - // brandy最高频率有限制 - cfg_info->max_clk = SDIOM_SRC_CLK_FREQ_LVL_49M_VAL; + // brandy最高频率按最高能力配置 + cfg_info->max_clk = SDIOM_SRC_CLK_FREQ_LVL_98M_VAL; cfg_info->min_clk = CONFIG_MMC1_CCLK_MIN; cfg_info->caps |= HCI_SLOTTYPE_SDIO; - cfg_info->quirks |= SDHCI_QUIRK_SIG_3V3_ONLY; /* signal 1.2V 1.8V unsupported */ + cfg_info->quirks |= SDHCI_QUIRK_SIG_1V8_ONLY; cfg_info->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; cfg_info->caps &= ~HCI_CAN_VDD_180; cfg_info->caps &= ~HCI_CAN_DO_8BITBUS; @@ -838,6 +1000,10 @@ static void sdhci_platform_init(struct hci_softc *sc) cfg_info->caps2 &= ~HCI_CAN_MMC_HS400ES; sdhci_subplatform_init(sc, cfg_info); +#if MMC_BOARD_DEBUG_ON + dprintf("%s, hci_caps:caps[0x%x],caps2[0x%x],quirks[0x%x],max_clk[0x%x],min_clk[0x%x]\r\n", __FUNCTION__, + cfg_info->caps, cfg_info->caps2, cfg_info->quirks, cfg_info->min_clk); +#endif } @@ -899,19 +1065,22 @@ static void sdhci_en_drv_dll_sample(struct hci_softc *sc, uint32_t en) { uint16_t val = 0; -#if EMMC_BOARD_DEBUG_ON +#if MMC_BOARD_DEBUG_ON dprintf("%s, en:[%u]\r\n", __FUNCTION__, en); #endif - + if (sc->num >= MAX_MMC_NUM) { + dprintf("%s, sc->num:[%u]\r\n", __FUNCTION__, sc->num); + return; + } if (en != 0) { hci_setl(sc, SDHCI_AUTO_TUNING_CTRL, SDHCI_SW_TUNING_EN); - val = DPAL_GET_UINT16(EMMC_CCLK_DIV_REG); - val |= EMMC_TUNING_COARSE_MODE; - DPAL_WRITE_UINT16(val, EMMC_CCLK_DIV_REG); + val = DPAL_GET_UINT16(g_clk_div1_reg[sc->num]); + val |= g_tunning_coarse_mode[sc->num]; + DPAL_WRITE_UINT16(val, g_clk_div1_reg[sc->num]); - DPAL_WRITE_UINT16(EMMC_TUNING_BM0_VAL, EMMC_TUNING_BM0_REG); - DPAL_WRITE_UINT16(EMMC_TUNING_BM1_VAL, EMMC_TUNING_BM1_REG); + DPAL_WRITE_UINT16(g_tunning_bm0_value[sc->num], g_tunning_bm0_reg[sc->num]); + DPAL_WRITE_UINT16(g_tunning_bm1_value[sc->num], g_tunning_bm1_reg[sc->num]); } else { hci_clearl(sc, SDHCI_AUTO_TUNING_CTRL, SDHCI_SW_TUNING_EN); } @@ -934,9 +1103,9 @@ static void sdhci_set_mmc_io_driver(const struct hci_softc *sc, uint32_t host_id unused(timing); } -static bool sdhci_judge_dll_sample(uint32_t timing) +static bool sdhci_judge_dll_sample(struct hci_softc *sc, uint32_t timing) { - if (g_max_timing < timing) { g_max_timing = timing; } + if (g_max_timing[sc->num] < timing) { g_max_timing[sc->num] = timing; } if (timing == bus_timing_mmc_hs || timing == bus_timing_sd_hs || timing == bus_timing_normal || timing == bus_timing_uhs_sdr25) { return false; @@ -990,10 +1159,10 @@ static void sdhci_set_phase(struct hci_softc *sc, uint32_t timing) phase = 0; } } - en_flag = sdhci_judge_dll_sample(timing); -#if EMMC_BOARD_DEBUG_ON - device_printf(sc->dev, "timing:%u, g_max_timing =%u, phase:0x%x, drv_phase:0x%x, en_flag:%d \n", timing, - g_max_timing, phase, drv_phase, en_flag); + en_flag = sdhci_judge_dll_sample(sc, timing); +#if MMC_BOARD_DEBUG_ON + device_printf(sc->dev, "%s timing:%u, g_max_timing =%u, phase:0x%x, drv_phase:0x%x, en_flag:%d \n", __FUNCTION__, + timing, g_max_timing[sc->num], phase, drv_phase, en_flag); #endif sdhci_set_drv_phase(sc->num, drv_phase); sdhci_en_drv_dll_sample(sc, en_flag); @@ -1030,11 +1199,13 @@ void mmc_dump_regs(struct hci_softc *sc) void mmc_ext_clk_switch(struct hci_softc *sc, bool enable) { - unused(sc); - if (enable) { - reg16_setbit(BRANDY_EXTERNAL_EMMC_CCLK_DIV, 0); - } else { - reg16_clrbit(BRANDY_EXTERNAL_EMMC_CCLK_DIV, 0); + /* sdio slave主动发消息可能需要时钟, master不关时钟 */ + if (sc->num == 0) { + if (enable) { + reg16_setbit(g_clk_div1_reg[sc->num], 0); + } else { + reg16_clrbit(g_clk_div1_reg[sc->num], 0); + } } } @@ -1044,7 +1215,7 @@ void init_slot_methods(int slot, hci_slot_ops *slot_ops) slot_ops->pre_clock = sdhci_pre_set_clock; slot_ops->post_clock = sdhci_post_clock; - slot_ops->set_clock = sdhci_set_clock; + slot_ops->set_clock = mmc_sdhci_set_clock; slot_ops->extra_init = sdhci_extra_init; slot_ops->slot_init = sdhci_slot_init; slot_ops->set_phase = sdhci_set_phase; diff --git a/code/sdk/drivers/drivers/driver/mmc/include/soc_mmc.h b/code/sdk/drivers/drivers/driver/mmc/include/soc_mmc.h index 775308969..9cd6c83ab 100644 --- a/code/sdk/drivers/drivers/driver/mmc/include/soc_mmc.h +++ b/code/sdk/drivers/drivers/driver/mmc/include/soc_mmc.h @@ -37,7 +37,9 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -#define EMMC_BOARD_DEBUG_ON 0 +#ifndef MMC_BOARD_DEBUG_ON +#define MMC_BOARD_DEBUG_ON 0 +#endif #define GLB_CTL_M_RB_BASE 0x57000000 #define M_CTL_RB_BASE 0x52000000 @@ -75,7 +77,6 @@ extern "C" { #define BRANDY_EMMC_REG_END 0x52063FFF // emmc external clk EMMC_CCLK_DIV #define BRANDY_EXTERNAL_EMMC_CCLK_DIV 0x52000100 -#define EMMC_TUNING_COARSE_MODE_BIT 0xD #define PERI_EMMC_CRG_RST_CTL (GLB_CTL_M_RB_BASE + 0xc8) #define SOFT_RST_GLB_SDIO_CRG_N BIT(0) @@ -155,31 +156,41 @@ extern "C" { #define CMD6_INDEX 0x61b #define EMMC_CCLK_DIV_REG (M_CTL_RB_BASE + 0x0100) -#define EMMC_CCLK_ORI_DIV_NUM_MASK 0x0FF0 -#define EMMC_CCLK_ORI_DIV_NUM_2 0x20 +#define EMMC_TUNING_COARSE_MODE_BIT (13) +#define EMMC_TUNING_COARSE_MODE BIT(13) + +#define EMMC_CCLK_ORI_DIV_NUM_MASK 0x0FF0 +#define EMMC_CCLK_ORI_DIV_NUM_2 0x20 #define EMMC_TUNING_BM0_REG (M_CTL_RB_BASE + 0x104) #define EMMC_TUNING_BM1_REG (M_CTL_RB_BASE + 0x108) -#define SD_HOST_CCLK_DIV_REG (M_CTL_RB_BASE + 0x0110) -#define SDIO_HOST_CCLK_DIV_REG (M_CTL_RB_BASE + 0x014C) +#define EMMC_TUNING_BM0_VAL (0x4244) +#define EMMC_TUNING_BM1_VAL (0x777) -#define SDIO_HOST_CLKEN BIT(0) -#define SDIO_CCLK_ORI_DIV_EN BIT(1) -#define SDIO_CCLK_ORI_LOAD_DIV_EN BIT(2) -#define SDIO_HOST_DIV_EN BIT(0) -#define SDIO_HOST_DIV_SHFIT 1 -#define SDIO_HOST_DIV_MASK 0xE +#define SD_HOST_CCLK_DIV_REG (M_CTL_RB_BASE + 0x0110) +#define SDIO_HOST_CLKEN BIT(0) +#define SDIO_CCLK_ORI_DIV_EN BIT(1) +#define SDIO_CCLK_ORI_LOAD_DIV_EN BIT(2) +#define SDIO_TUNING_COARSE_MODE_BIT (3) +#define SDIO_TUNING_COARSE_MODE BIT(SDIO_TUNING_COARSE_MODE_BIT) +#define SDIO_HOST_CARD_CLK_INV_SET BIT(13) + +#define SD_HOST_TUNING_BM0_REG (M_CTL_RB_BASE + 0x114) +#define SD_HOST_TUNING_BM1_REG (M_CTL_RB_BASE + 0x118) +#define SDIO_TUNING_BM0_VAL (0x4244) +#define SDIO_TUNING_BM1_VAL (0x777) #define EMMC_DIV_REG (M_CTL_RB_BASE + 0x0120) #define SDIO_BUS_CGDIV_REG (M_CTL_RB_BASE + 0x0124) -#define SD_BUS_CLKEN BIT(0) -#define SD_BUS_DIV_EN BIT(1) -#define SD_BUS_LOAD_DIV_EN BIT(8) -#define SD_BUS_DIV_NUM_MASK 0xF8 // bit3---bit7 -#define SD_BUS_DIV_NUM_POST_SHIFT 3 +#define SD_BUS_CLKEN BIT(0) +#define SD_BUS_DIV_EN BIT(1) +#define SD_BUS_LOAD_DIV_EN BIT(8) +#define SD_BUS_DIV_NUM_MASK 0xF8 // bit3---bit7 +#define SD_BUS_DIV_NUM_POST_SHIFT 3 -#define EMMC_TUNING_BM0_VAL (0x4244) -#define EMMC_TUNING_BM1_VAL (0x777) -#define EMMC_TUNING_COARSE_MODE BIT(13) +#define SDIO_HOST_CCLK_DIV_REG (M_CTL_RB_BASE + 0x014C) +#define SDIO_HOST_DIV_EN BIT(0) +#define SDIO_HOST_DIV_SHFIT 1 +#define SDIO_HOST_DIV_MASK 0xE #define DWC_MSHC_PTR_VENDOR1 0x500 #define SDHCI_MSHC_CTRL (DWC_MSHC_PTR_VENDOR1 + 0x08) @@ -273,11 +284,13 @@ void init_emmc_pinmux(void); void sdio_drv_context_init(void); void init_sdio_pinmux(void); +uint8_t is_sdio_working(void); void mmc_set_internal_clk(uint16_t clk_level); void mmc_set_first_init_flag(bool flag); bool mmc_get_first_init_flag(void); void mmc_set_sleep_init_flag(bool flag); bool mmc_get_sleep_init_flag(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/include/middleware/services/bts/ble/bts_le_gap.h b/code/sdk/include/middleware/services/bts/ble/bts_le_gap.h index 124bebf5c..8c04fb6cd 100644 --- a/code/sdk/include/middleware/services/bts/ble/bts_le_gap.h +++ b/code/sdk/include/middleware/services/bts/ble/bts_le_gap.h @@ -306,9 +306,13 @@ typedef struct { */ typedef struct { uint32_t min_interval; /*!< @if Eng Min interval[N * 0.625ms] - @else 最小的广播间隔[N * 0.625ms] @endif */ + The value range: 0x0020 to 0x4000 + @else 最小的广播间隔[N * 0.625ms] + 可取值范围: 0x0020 to 0x4000 @endif */ uint32_t max_interval; /*!< @if Eng Max interval[N * 0.625ms] - @else 最大的广播间隔[N * 0.625ms] @endif */ + The value range: 0x0020 to 0x4000 + @else 最大的广播间隔[N * 0.625ms] + 可取值范围: 0x0020 to 0x4000 @endif */ uint8_t adv_type; /*!< @if Eng Advertising type { @ref gap_ble_adv_type_t } @else 广播类型 { @ref gap_ble_adv_type_t } @endif */ bd_addr_t own_addr; /*!< @if Eng own address diff --git a/code/sdk/include/middleware/services/bts/br/bts_br_gap.h b/code/sdk/include/middleware/services/bts/br/bts_br_gap.h index 83ba6e514..d37cf2651 100644 --- a/code/sdk/include/middleware/services/bts/br/bts_br_gap.h +++ b/code/sdk/include/middleware/services/bts/br/bts_br_gap.h @@ -1381,6 +1381,29 @@ typedef void (*gap_read_remote_rssi_event_callback)(const bd_addr_t *bd_addr, in */ typedef void (*gap_is_accept_conn_on_safe_mode_callback)(const bd_addr_t *bd_addr, bool *res); +/** + * @if Eng + * @brief Callback function for a new connection is rejected. + * @par When registered, this callback notifys application a connect request is rejected. + * @attention NULL + * @param [in] bd_addr #const bd_addr_t *, the address of the remote device. + * @retval #void no return value. + * @par Dependency: + * @li bts_gap.h + * @see gap_call_backs_t + * @else + * @brief 通知上层应用有个新的连接请求被拒绝了。 + * @par 注册该回调函数之后,bluetooth调用该回调函数通知上层应用有个新的连接请求被拒绝了。 + * @attention 无 + * @param [in] 远端设备地址。 + * @retval #void 无返回值。 + * @par 依赖: + * @li bts_gap.h + * @see gap_call_backs_t + * @endif + */ +typedef void (*gap_connect_rejection_report_callback)(const bd_addr_t *bd_addr); + /** * @if Eng * @brief Struct of GAP callback functions. @@ -1479,6 +1502,26 @@ errcode_t gap_reconnect_media_device(const bd_addr_t *addr); */ errcode_t gap_bt_set_flow_limit(uint16_t flow_limit); +/** + * @if Eng + * @brief Register callback function for connection rejected event notification. + * @par Register callback function for connection rejected event notification. + * @attention NULL + * @param [in] func #gap_connect_rejection_report_callback, a pointer to the callback func. + * @retval #void no return value. + * @par Dependency: + * @li bts_br_gap.h + * @else + * @brief 注册拒绝新手机连接事件上报回调函数。 + * @par 注册拒绝新手机连接事件上报回调函数。 + * @attention 无 + * @param [in] 指向回调函数的指针。 + * @retval #void 无 + * @par 依赖: + * @li bts_br_gap.h + * @endif + */ +void gap_register_br_connect_rejection_report_callback(gap_connect_rejection_report_callback func); /** * @} */ diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/DialBinParser.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/DialBinParser.cpp.xml index 96db38ffd..5d00528fc 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/DialBinParser.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/DialBinParser.cpp.xml @@ -51,5 +51,5 @@ - + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/connection_manager.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/connection_manager.c.xml index 367088e9c..c50fc815a 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/connection_manager.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/connection_manager.c.xml @@ -1,134 +1,135 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/display_vau.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/display_vau.c.xml index 50d858333..eb9dbcfde 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/display_vau.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/display_vau.c.xml @@ -4,48 +4,48 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/gt_bundle_manager_service.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/gt_bundle_manager_service.cpp.xml index 36ff0e5de..9b33e8b21 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/gt_bundle_manager_service.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/gt_bundle_manager_service.cpp.xml @@ -11,22 +11,22 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_router.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_router.cpp.xml index d6361bbe2..5b59b0cd9 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_router.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_router.cpp.xml @@ -1,9 +1,9 @@ - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/kaleidoscope_utils.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/kaleidoscope_utils.cpp.xml index 36429c182..f6f2241a0 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/kaleidoscope_utils.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/kaleidoscope_utils.cpp.xml @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lite_m_gfx_engine.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lite_m_gfx_engine.cpp.xml index 96e437217..6335574cb 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lite_m_gfx_engine.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lite_m_gfx_engine.cpp.xml @@ -1,33 +1,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/local_device_manager.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/local_device_manager.c.xml index 009013e0b..f47f970f3 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/local_device_manager.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/local_device_manager.c.xml @@ -1,99 +1,102 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/map_svg_parser.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/map_svg_parser.cpp.xml index 450f0ad0d..3eb448a53 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/map_svg_parser.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/map_svg_parser.cpp.xml @@ -1,72 +1,72 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/particle_cell.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/particle_cell.cpp.xml index 96f235557..7728e64cd 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/particle_cell.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/particle_cell.cpp.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_canvas_ext.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_canvas_ext.cpp.xml index e4dfd6b9e..eadc53d97 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_canvas_ext.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_canvas_ext.cpp.xml @@ -12,22 +12,19 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view.cpp.xml index 84ce80756..020c30b28 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view.cpp.xml @@ -1,5 +1,3 @@ - - - - + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view2.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view2.cpp.xml index 6692b1031..7d8f1b6da 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view2.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view2.cpp.xml @@ -1,8 +1,8 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_cross_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_cross_view.cpp.xml new file mode 100644 index 000000000..2cf8d0c76 --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_cross_view.cpp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_hexagons_list.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_hexagons_list.cpp.xml index 306511b9c..382f041e4 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_hexagons_list.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_hexagons_list.cpp.xml @@ -1,8 +1,7 @@ - - - - - - - + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_icosahedron_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_icosahedron_view.cpp.xml index 116feac34..fb9539fb2 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_icosahedron_view.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_icosahedron_view.cpp.xml @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_kaleidoscope_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_kaleidoscope_view.cpp.xml index ff156f1a3..2b0896b75 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_kaleidoscope_view.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_kaleidoscope_view.cpp.xml @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_label_button_ext.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_label_button_ext.cpp.xml index 16ce6bf0c..a8328b5e5 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_label_button_ext.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_label_button_ext.cpp.xml @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_map_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_map_view.cpp.xml index 1616369b2..72307b6e2 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_map_view.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_map_view.cpp.xml @@ -1,3 +1,3 @@ - - + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_particle_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_particle_view.cpp.xml index 1d4e077f1..250a2e98b 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_particle_view.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_particle_view.cpp.xml @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_roller_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_roller_view.cpp.xml index e83f04945..c49070ab1 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_roller_view.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_roller_view.cpp.xml @@ -1,13 +1,13 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_slipflow_view.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_slipflow_view.cpp.xml index 09fbb6be3..d7bf5b13d 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_slipflow_view.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_slipflow_view.cpp.xml @@ -1,3 +1,3 @@ - - + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_transform_group.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_transform_group.cpp.xml index 959e20259..641ec4346 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_transform_group.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_transform_group.cpp.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_waterfall_list.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_waterfall_list.cpp.xml index 882e0819b..1dab66770 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_waterfall_list.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_waterfall_list.cpp.xml @@ -1,6 +1,6 @@ - - - - - + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/audio/build_hso_cfg/hso_database/xml/base/dsp_core/core_msg_aenc.c.xml b/code/sdk/interim_binary/brandy/audio/build_hso_cfg/hso_database/xml/base/dsp_core/core_msg_aenc.c.xml index e1843bffe..616c20ffe 100644 --- a/code/sdk/interim_binary/brandy/audio/build_hso_cfg/hso_database/xml/base/dsp_core/core_msg_aenc.c.xml +++ b/code/sdk/interim_binary/brandy/audio/build_hso_cfg/hso_database/xml/base/dsp_core/core_msg_aenc.c.xml @@ -4,11 +4,11 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hdb/hdbcfg/mss_prim_db.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hdb/hdbcfg/mss_prim_db.xml index eccf3bbe4..88fd9bba1 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hdb/hdbcfg/mss_prim_db.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hdb/hdbcfg/mss_prim_db.xml @@ -1379,9 +1379,9 @@ - - - + + + @@ -1977,10 +1977,10 @@ - - - - + + + + @@ -2030,8 +2030,9 @@ - - + + + @@ -3056,6 +3057,7 @@ + @@ -3682,12 +3684,12 @@ - - - - - - + + + + + + @@ -4367,8 +4369,10 @@ - - + + + + diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_common.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_common.c.xml index 2b0480e36..92c1641f5 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_common.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_common.c.xml @@ -1,3 +1,5 @@ - - + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_hlp_ram.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_hlp_ram.c.xml index fb8a3f082..5d296f95e 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_hlp_ram.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_hlp_ram.c.xml @@ -1,3 +1,4 @@ - - + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hfp_ag_ram.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hfp_ag_ram.c.xml new file mode 100644 index 000000000..fbf1f8255 --- /dev/null +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hfp_ag_ram.c.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hfp_fsm_ram.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hfp_fsm_ram.c.xml index 1b2cf27c1..b2419dab8 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hfp_fsm_ram.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hfp_fsm_ram.c.xml @@ -1,5 +1,5 @@ - - - + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_bth.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_bth.c.xml index fc93e1590..282f5e56e 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_bth.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_bth.c.xml @@ -1,6 +1,6 @@ - - - - + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_hlp.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_hlp.c.xml index a8b8232f3..b484efd95 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_hlp.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_hlp.c.xml @@ -6,10 +6,10 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_brandy_service.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_brandy_service.a index 446451751..807cef0bb 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_brandy_service.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_brandy_service.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_sdk.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_sdk.a index 11b9eba35..02ddfb287 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_sdk.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/ble/libbt_host_sdk.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_brandy_service.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_brandy_service.a index 1d31253f4..91cdef901 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_brandy_service.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_brandy_service.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_sdk.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_sdk.a index 3369daf0d..bacaa3ce0 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_sdk.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_sdk.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_brandy_service.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_brandy_service.a index 7be9c9406..7cc5f9f80 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_brandy_service.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_brandy_service.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_sdk.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_sdk.a index bdfb016d2..3df28f9a5 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_sdk.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/ble/libbt_host_sdk.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_audio_manager_wrapper.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_audio_manager_wrapper.a index 9a77e7d74..8a914dc23 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_audio_manager_wrapper.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_audio_manager_wrapper.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_service.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_service.a index a2335f245..79cb1c332 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_service.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_service.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_sdk.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_sdk.a index 785f859ac..58a913fa6 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_sdk.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_sdk.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_brandy_service.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_brandy_service.a index 3cd1b9a56..1abdef2fb 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_brandy_service.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_brandy_service.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_sdk.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_sdk.a index 1406c4a6b..6ba40df7d 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_sdk.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/ble/libbt_host_sdk.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_brandy_service.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_brandy_service.a index 45288312c..2a62b43f1 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_brandy_service.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_brandy_service.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_sdk.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_sdk.a index a220bf26a..1dd7bc776 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_sdk.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/mini/br/libbt_host_sdk.a differ diff --git a/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/targets/brandy_app/include/soc/mmc.h b/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/targets/brandy_app/include/soc/mmc.h index cbfcc8656..111601017 100644 --- a/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/targets/brandy_app/include/soc/mmc.h +++ b/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/targets/brandy_app/include/soc/mmc.h @@ -16,7 +16,9 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ +#ifndef EMMC_BOARD_DEBUG_ON #define EMMC_BOARD_DEBUG_ON 0 +#endif #define MAX_MMC_NUM 2 diff --git a/code/sdk/kernel/osal/CMakeLists.txt b/code/sdk/kernel/osal/CMakeLists.txt index 3742933a9..86e6cd3a7 100644 --- a/code/sdk/kernel/osal/CMakeLists.txt +++ b/code/sdk/kernel/osal/CMakeLists.txt @@ -71,7 +71,7 @@ elseif(${OS} STREQUAL "freertos") ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_device.c ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_drvbox.c ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_event.c - # ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_fileops.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_fileops.c ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_interrupt.c # ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_math.c ${CMAKE_CURRENT_SOURCE_DIR}/src/${src_sub}/osal_msgqueue.c diff --git a/code/sdk/kernel/osal/src/freertos/osal_fileops.c b/code/sdk/kernel/osal/src/freertos/osal_fileops.c new file mode 100644 index 000000000..d7b73c0f3 --- /dev/null +++ b/code/sdk/kernel/osal/src/freertos/osal_fileops.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2022. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include "soc_osal.h" +#include "osal_inner.h" + +void *osal_klib_fopen(const char *filename, int flags, int mode) +{ + int *filp = NULL; + int fd = open(filename, flags, mode); + if (fd < 0) { + osal_log("open failed! fd = %d, errno = %d\n", fd, get_errno()); + return NULL; + } else { + filp = (int *)pvPortMalloc(sizeof(int)); + if (filp == NULL) { + osal_log("pvPortMalloc failed!\n"); + close(fd); + return NULL; + } + *filp = fd; + } + return (void *)filp; +} + +void osal_klib_fclose(void *filp) +{ + if (filp == NULL) { + osal_log("parameter invalid!\n"); + return; + } + close(*(int *)filp); + vPortFree(filp); +} + +int osal_klib_fwrite(const char *buf, unsigned long size, void *filp) +{ + if (filp == NULL) { + osal_log("parameter invalid!\n"); + return OSAL_FAILURE; + } + return write(*(int *)filp, buf, size); +} + +int osal_klib_fread(char *buf, unsigned long size, void *filp) +{ + if (filp == NULL) { + osal_log("parameter invalid!\n"); + return OSAL_FAILURE; + } + return read(*(int *)filp, buf, size); +} + +int osal_klib_fseek(long long offset, int whence, void *filp) +{ + int ret; + off_t res; + if (filp == NULL || offset > INT32_MAX) { + osal_log("parameter invalid!\n"); + return OSAL_FAILURE; + } + res = lseek(*(int *)filp, (off_t)offset, whence); + ret = (int)res; + if (res != (off_t)ret) { + ret = OSAL_EOVERFLOW; + } + return ret; +} \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/dfx/diag_audio.h b/code/sdk/middleware/chips/brandy/dfx/diag_audio.h index f703ca625..2494da26f 100644 --- a/code/sdk/middleware/chips/brandy/dfx/diag_audio.h +++ b/code/sdk/middleware/chips/brandy/dfx/diag_audio.h @@ -12,7 +12,7 @@ #include "errcode.h" #include "diag.h" -#define NV_AUDIO_VQE_PARAM_SIZE 48 +#define NV_AUDIO_VQE_PARAM_SIZE 53 typedef struct { uint32_t size; diff --git a/code/sdk/middleware/chips/brandy/dfx/include/log_def_gui.h b/code/sdk/middleware/chips/brandy/dfx/include/log_def_gui.h index 54d3e0cb5..4a2f4b5ed 100644 --- a/code/sdk/middleware/chips/brandy/dfx/include/log_def_gui.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/log_def_gui.h @@ -411,6 +411,7 @@ typedef enum { IMAGE_CACHE_MANAGER_CPP, DISPLAY_VAU_C, DISPLAY_GRALLOC_C, + DISPLAY_GMMU_C, MEM_POOL_LOS_C, DISPLAY_LAYER_C, CUBE_ROTATE_VIEW_CPP, @@ -431,6 +432,7 @@ typedef enum { UI_COVERFLOW_VIEW2_CPP, UI_SLIPFLOW_VIEW_CPP, UI_ROLLER_VIEW_CPP, + UI_CROSS_VIEW_CPP, UI_ICOSAHEDRON_VIEW_CPP, UI_MAP_VIEW_CPP, MAP_SVG_PARSER_CPP, @@ -454,6 +456,11 @@ typedef enum { UI_LIST_NESTED_CPP, UI_PARTICLE_VIEW_CPP, PARTICLE_CELL_CPP, + VIDEOCARD_CPP, + DIALBINPARSERV3_CPP, + DIALTIMEPUBLISHER_CPP, + DIALSEQUENCECONTAINER_CPP, + WATCHINTERFACE_CPP, FILE_ID_MAX = 1024, } log_file_list_enum_gui_t; #endif diff --git a/code/sdk/middleware/chips/brandy/dfx/include/soc_diag_cmd_id.h b/code/sdk/middleware/chips/brandy/dfx/include/soc_diag_cmd_id.h index 9af7894d1..815babfa3 100644 --- a/code/sdk/middleware/chips/brandy/dfx/include/soc_diag_cmd_id.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/soc_diag_cmd_id.h @@ -138,7 +138,6 @@ /* gpu cmd [0xa0, 0xaf] */ #define DIAG_CMD_GPU_VAU_PROC diag_cmd_id_comb(0xa0) #define DIAG_CMD_GPU_DPU_PROC diag_cmd_id_comb(0xa1) -#define DIAG_CMD_GPU_GMMU_PROC diag_cmd_id_comb(0xa2) #define DIAG_CMD_GPU_JPEG_PROC diag_cmd_id_comb(0xa3) #define DIAG_CMD_GPU_DPU_PRINT diag_cmd_id_comb(0xa4) diff --git a/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.c b/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.c index c7bcde5f0..55fd5cec1 100644 --- a/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.c +++ b/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.c @@ -11,10 +11,20 @@ #include "sys/stat.h" #include "fcntl.h" #include "unistd.h" +#include "stdio.h" +#if defined(BUILD_APPLICATION_STANDARD) && !defined(BUILD_RECOVERY_IMAGE) +#include "diag_filter.h" +#endif #define STATUS_ADDRESS 0x5702C1E8 #define VBUS_INSERT_POS 4 #define PWREN_PRESS_POS 3 +#define B_IS_WAKE_UP_REG 0x57000500 +#define B_MAINTENANCE_1 0x59008500 +#define B_MAINTENANCE_2 0x570007a4 +#define B_MAINTENANCE_3 0x570007a0 +#define B_MAINTENANCE_PC_L 0x570007a8 +#define B_MAINTENANCE_PC_H 0x570007ac bool is_first_power_on(void) { @@ -100,4 +110,22 @@ int32_t write_fileinfo(const char *path, uint32_t offset, const uint8_t *buf, ui return -1; } return len; +} + +void config_maintenance_b_function(void) +{ +#if defined(BUILD_APPLICATION_STANDARD) && !defined(BUILD_RECOVERY_IMAGE) + diag_highest_level_proc(2); + while(readw(B_IS_WAKE_UP_REG) != 0) { + diag_highest_level_proc(2); + } + writew(B_MAINTENANCE_1,1); + uint8_t before = readb(B_MAINTENANCE_2); + before = before | 0x1; + writeb(B_MAINTENANCE_2, before); + printf("0x59008500 %x \r\n", readw(B_MAINTENANCE_1)); + printf("0x570007a4 %x \r\n", readw(B_MAINTENANCE_2)); + printf("0x570007a0 %x \r\n", readw(B_MAINTENANCE_3)); + printf("0x570007a8 =%x,0x570007ac =%x \r\n", readw(0x570007a8), readw(0x570007ac)); +#endif } \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.h b/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.h index 003e01a90..ffc4f6630 100644 --- a/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.h +++ b/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.h @@ -34,4 +34,10 @@ bool is_pwren_press(void); * @return write length */ int32_t write_fileinfo(const char *path, uint32_t offset, const uint8_t *buf, uint32_t size); + +/** + * @brief Configure B-core maintenance function + * @return null + */ +void config_maintenance_b_function(void); #endif diff --git a/code/sdk/middleware/chips/brandy/exception/chip_system_time.c b/code/sdk/middleware/chips/brandy/exception/chip_system_time.c index 28531feff..02e2775cb 100644 --- a/code/sdk/middleware/chips/brandy/exception/chip_system_time.c +++ b/code/sdk/middleware/chips/brandy/exception/chip_system_time.c @@ -8,34 +8,38 @@ #include "chip_system_time.h" -#define SECONDS_PER_MINUTE 60 /* second per minute */ -#define MINUTES_PER_HOUR 60 /* second per minute */ -#define MSEC_PER_SEC 1000 -#define USEC_PER_MSEC 1000 -#define TZ_ADDRESS 0x5702C014 -#define MAX_TIMEZONE_HOURS 24 -#define TIME_MAX 64 +#define SECONDS_PER_MINUTE 60 /* second per minute */ +#define MINUTES_PER_HOUR 60 /* second per minute */ +#define MSEC_PER_SEC 1000 +#define USEC_PER_MSEC 1000 +#define TZ_ADDRESS 0x5702C014 +#define MAX_TIMEZONE_HOURS 24 +#define TIME_MAX 64 +#define ONE_DAY_MIN 1440 +#define BEIJING_TIMEZONE 480 +#define MIN_INTERVAL 15 +#define CUSTOM_PER_HOUR (60 / MIN_INTERVAL) void print_time(calendar_t *date) { printf("CALLENDAR:year = %d, month = %d, day = %d, hour = %d, minute = %d, second = %d \r\n", - date->year, - date->mon, - date->day, - date->hour, - date->min, - date->sec); + date->year, + date->mon, + date->day, + date->hour, + date->min, + date->sec); } void print_time_2(struct tm *date) { printf("TM:year = %d, month = %d, day = %d, hour = %d, minute = %d, second = %d \r\n", - date->tm_year + 1900, - date->tm_mon, - date->tm_mday, - date->tm_hour, - date->tm_min, - date->tm_sec); + date->tm_year, + date->tm_mon, + date->tm_mday, + date->tm_hour, + date->tm_min, + date->tm_sec); } static uint16_t get_timezone(void) @@ -50,6 +54,24 @@ static void set_timezone(uint16_t timezone) writew(TZ_ADDRESS, tz_zone); } +int get_timezone_min(void) +{ + uint16_t sdk_zone = get_timezone(); + if (sdk_zone > (CUSTOM_PER_HOUR * MAX_TIMEZONE_HOURS)) + return BEIJING_TIMEZONE; + int zone = 0; + // 东边 1-12H, 西边 13-24H + if (sdk_zone > (12 * CUSTOM_PER_HOUR)) // 西边 + { + zone = (sdk_zone - (12 * CUSTOM_PER_HOUR)) * MIN_INTERVAL * (-1); + } + else // 东边 + { + zone = sdk_zone * MIN_INTERVAL; + } + return zone; +} + void save_time(void) { uint64_t time_sec = get_local_timestamp(); @@ -57,7 +79,7 @@ void save_time(void) uapi_calendar_set_timestamp(time_sec); } -uint32_t get_current_timestamp(void) +uint32_t get_current_timestamp(void) // 0时区timestamp { uint32_t timestamp = 0; struct timeval current_time = {0}; @@ -70,22 +92,26 @@ uint32_t get_current_timestamp(void) return timestamp; } -uint32_t get_local_timestamp(void) +uint32_t get_local_timestamp(void) // 本地时区timestamp { - uint32_t timestamp = get_current_timestamp() + get_timezone() * MINUTES_PER_HOUR * SECONDS_PER_MINUTE; + uint32_t timestamp = get_current_timestamp() + get_timezone_min() * SECONDS_PER_MINUTE; return timestamp; } -void get_current_time(struct timeval *tv, struct tm *tm) +void get_local_time(struct tm *tm) { - char timebuf[TIME_MAX] = {0}; - if (gettimeofday(tv, NULL)) { - return; - } - localtime_r(&tv->tv_sec, tm); + uint32_t timestamp = get_current_timestamp(); + localtime_r(×tamp, tm); + tm->tm_year = tm->tm_year + 1900, + tm->tm_mon = tm->tm_mon + 1; +} + +void get_current_time(struct tm *tm) +{ + uint32_t timestamp = get_current_timestamp() - (get_timezone_min() * 60); + localtime_r(×tamp, tm); + tm->tm_year = tm->tm_year + 1900, tm->tm_mon = tm->tm_mon + 1; - printf("get_current_time tv_tv_sec = %d \r\n", tv->tv_sec); - print_time_2(tm); } void restore_time(void) @@ -97,55 +123,59 @@ void restore_time(void) uapi_calendar_get_timestamp(&sec); printf("callendar timestamp = %lld \r\n", sec); sec = sec / MSEC_PER_SEC; - sync_time(sec, get_timezone()); + // 东边 1-12H, 西边 13-24H, 需在这里转换成 -1到-12 + uint16_t timezone = get_timezone(); + int timezone_trans = timezone > (12 * CUSTOM_PER_HOUR) ? ((timezone - (12 * CUSTOM_PER_HOUR)) * (-1)) : timezone; + timezone_trans *= MIN_INTERVAL; + sync_time(sec, timezone_trans); } -uint32_t sync_time(uint32_t timestamp, uint32_t timezone) +uint32_t sync_time(uint32_t timestamp, int timezone) { printf("sync time timestamp %d, timezone %d \r\n", timestamp, timezone); uint32_t seconds; - if (timezone > MAX_TIMEZONE_HOURS) { + if (timezone > ONE_DAY_MIN) { return ERRCODE_FAIL; } if (timestamp == 0) { return ERRCODE_FAIL; - } else if (timestamp <= (timezone * MINUTES_PER_HOUR * SECONDS_PER_MINUTE)) { - seconds = 0; } else { - seconds = timestamp - (timezone * MINUTES_PER_HOUR * SECONDS_PER_MINUTE); + seconds = timestamp - (timezone * SECONDS_PER_MINUTE); } - set_timezone(timezone); + + // 东边1-12H, 西边13-24H + uint32_t timezone_trans = (timezone / MIN_INTERVAL) < 0 ? abs(timezone / MIN_INTERVAL) + (12 * CUSTOM_PER_HOUR) : (timezone / MIN_INTERVAL); + set_timezone(timezone_trans); struct timeval tv = {0}; struct timezone tzone = {0}; tv.tv_sec = seconds; tv.tv_usec = 0; tzone.tz_dsttime = 0; - tzone.tz_minuteswest = timezone * MINUTES_PER_HOUR; + tzone.tz_minuteswest = timezone; return settimeofday(&tv, &tzone); } void test_bandy_time(void) { struct tm tm; - struct timeval tv; - uint32_t time = 1716044461; // 2024-5-18 15:1:1 + uint32_t time = 1716044461; // 2024-5-18 15:1:1 printf("--------SYNC TIME----------\r\n"); get_current_timestamp(); - get_current_time(&tv, &tm); - sync_time(time, 8); + get_current_time(&tm); + sync_time(time, 480); get_current_timestamp(); - get_current_time(&tv, &tm); + get_current_time(&tm); printf("--------SAVE TIME----------\r\n"); get_current_timestamp(); - get_current_time(&tv, &tm); + get_current_time(&tm); save_time(); get_current_timestamp(); - get_current_time(&tv, &tm); + get_current_time(&tm); printf("--------RESTORE TIME----------\r\n"); get_current_timestamp(); - get_current_time(&tv, &tm); + get_current_time(&tm); restore_time(); get_current_timestamp(); - get_current_time(&tv, &tm); + get_current_time(&tm); } -#endif \ No newline at end of file +#endif diff --git a/code/sdk/middleware/chips/brandy/exception/chip_system_time.h b/code/sdk/middleware/chips/brandy/exception/chip_system_time.h index d2f2e7744..66eb43624 100644 --- a/code/sdk/middleware/chips/brandy/exception/chip_system_time.h +++ b/code/sdk/middleware/chips/brandy/exception/chip_system_time.h @@ -7,6 +7,11 @@ #ifndef CHIP_SYSTEM_TIME_H #define CHIP_SYSTEM_TIME_H +#ifdef __cplusplus +extern "C" +{ +#endif + #ifndef BUILD_APPLICATION_SSB #include #include @@ -38,7 +43,9 @@ uint32_t get_current_timestamp(void); * @brief Get the current system time as a timeval struct and a tm * @return void. */ -void get_current_time(struct timeval *tv, struct tm *tm); +void get_current_time(struct tm *tm); + +void get_local_time(struct tm *tm); /** * @brief Restore the system time from the saved non-volatile @@ -46,17 +53,23 @@ void get_current_time(struct timeval *tv, struct tm *tm); */ void restore_time(void); +/** + * @brief get timezone minute + * @return timezone minute. + */ +int get_timezone_min(void); + /** * @brief Synchronize the system time with the given timestamp and timezone * @return void. */ -uint32_t sync_time(uint32_t timestamp, uint32_t timezone); +uint32_t sync_time(uint32_t timestamp, int timezone); /** * @brief use for test * @return void. */ -void test_time(void); +void test_bandy_time(void); /** * @brief Get the current system time as a local timestamp with timezone offset @@ -64,4 +77,8 @@ void test_time(void); */ uint32_t get_local_timestamp(void); #endif -#endif \ No newline at end of file + +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/eng/acore/app.json b/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/eng/acore/app.json index f9947f297..7b85e9959 100644 --- a/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/eng/acore/app.json +++ b/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/eng/acore/app.json @@ -69,24 +69,26 @@ "key_status": "alive", "structure_type": "audio_vqe_param_t", "attributions": 1, - "value": [48, [0, 0, 0, 0, 16843009, 33620225, 16000, 16000, - 1024, 100, 0, 0, 16842753, 257, 257, 256, + "value": [53, [0, 0, 0, 0, 16843009, 33620225, 16000, 16000, + 1024, 100, 0, 0, 16842753, 65793, 257, 256, 16778116, 16844032, 4, 0, 458824, 11796580, 327946, 1310720005, 65576964, 1000, 21499085, 67108874, 327680, 655367, 2126009683, 654734439, 1, 0, 0, 0, 0, 0, 5308380, 655336, - 4286447619, 64536, 500, 16384, 3277, 0, 66049, 0]] + 4286447619, 64536, 500, 16384, 3277, 0, 66049, 0, + 16711166, 2, 34145024, 33751810, 0]] }, "audio_vqe_kws_param":{ "key_id": "0x320D", "key_status": "alive", "structure_type": "audio_vqe_param_t", "attributions": 1, - "value": [48, [0, 0, 0, 0, 16843009, 33554689, 16000, 16000, - 1024, 100, 1985229328, 1985229328, 16843009, 257, 257, 256, + "value": [53, [0, 0, 0, 0, 16843009, 33554689, 16000, 16000, + 1024, 100, 1985229328, 1985229328, 16843009, 65793, 257, 256, 16778116, 1280, 4, 0, 458824, 11796580, 327690, 13107205, 65576964, 1000, 679102459, 67108874, 327680, 655367, 2126009683, 654734439, 1, 0, 0, 0, 0, 0, 10551272, 655336, 4286447619, 64536, - 500, 16384, 3277, 0, 66049, 0]] + 500, 16384, 3277, 0, 66049, 0, + 16711166, 2, 34145024, 33751810, 0]] } } } diff --git a/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/user/acore/app.json b/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/user/acore/app.json index c577233d7..05cb8c948 100644 --- a/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/user/acore/app.json +++ b/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/user/acore/app.json @@ -69,24 +69,26 @@ "key_status": "alive", "structure_type": "audio_vqe_param_t", "attributions": 1, - "value": [48, [0, 0, 0, 0, 16843009, 33620225, 16000, 16000, - 1024, 100, 0, 0, 16842753, 257, 257, 256, + "value": [53, [0, 0, 0, 0, 16843009, 33620225, 16000, 16000, + 1024, 100, 0, 0, 16842753, 65793, 257, 256, 16778116, 16844032, 4, 0, 458824, 11796580, 327946, 1310720005, 65576964, 1000, 21499085, 67108874, 327680, 655367, 2126009683, 654734439, 1, 0, 0, 0, 0, 0, 5308380, 655336, - 4286447619, 64536, 500, 16384, 3277, 0, 66049, 0]] + 4286447619, 64536, 500, 16384, 3277, 0, 66049, 0, + 16711166, 2, 34145024, 33751810, 0]] }, "audio_vqe_kws_param":{ "key_id": "0x320D", "key_status": "alive", "structure_type": "audio_vqe_param_t", "attributions": 1, - "value": [48, [0, 0, 0, 0, 16843009, 33554689, 16000, 16000, - 1024, 100, 1985229328, 1985229328, 16843009, 257, 257, 256, + "value": [53, [0, 0, 0, 0, 16843009, 33554689, 16000, 16000, + 1024, 100, 1985229328, 1985229328, 16843009, 65793, 257, 256, 16778116, 1280, 4, 0, 458824, 11796580, 327690, 13107205, 65576964, 1000, 679102459, 67108874, 327680, 655367, 2126009683, 654734439, 1, 0, 0, 0, 0, 0, 10551272, 655336, 4286447619, 64536, - 500, 16384, 3277, 0, 66049, 0]] + 500, 16384, 3277, 0, 66049, 0, + 16711166, 2, 34145024, 33751810, 0]] } } } diff --git a/code/sdk/middleware/chips/brandy/nv/nv_config/include/common.h b/code/sdk/middleware/chips/brandy/nv/nv_config/include/common.h index 2f3fc7d97..e409bf702 100644 --- a/code/sdk/middleware/chips/brandy/nv/nv_config/include/common.h +++ b/code/sdk/middleware/chips/brandy/nv/nv_config/include/common.h @@ -96,7 +96,7 @@ typedef struct { } bth_product_data_config_t; /* 3A prams */ -#define NV_AUDIO_VQE_PARAM_SIZE 48 +#define NV_AUDIO_VQE_PARAM_SIZE 53 typedef struct { uint32_t size; uint32_t data[NV_AUDIO_VQE_PARAM_SIZE]; diff --git a/code/sdk/middleware/chips/brandy/pm/pm.c b/code/sdk/middleware/chips/brandy/pm/pm.c index 5c73dc2df..150c65d29 100644 --- a/code/sdk/middleware/chips/brandy/pm/pm.c +++ b/code/sdk/middleware/chips/brandy/pm/pm.c @@ -15,6 +15,7 @@ #include "watchdog_porting.h" #include "securec.h" #include "pmu_interrupt.h" +#include "calendar_porting.h" typedef struct { uint32_t slp_ms; @@ -169,6 +170,7 @@ void uapi_sys_force_mcu_only_deep_sleep_mode(uint32_t arg) void uapi_sys_shipmode(uint32_t arg) { + uapi_calendar_calibration_enable(); UNUSED(arg); uint32_t irq = osal_irq_lock(); uapi_pm_control(PM_BT_POWER_OFF); diff --git a/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c b/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c index c5fda7584..5c49a6646 100644 --- a/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c +++ b/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c @@ -139,6 +139,10 @@ void pm_core_suspend(void) uapi_dma_close(); uapi_dma_deinit(); display_suspend(); + +#if defined(CFG_DRIVERS_MMC) || defined(CFG_DRIVERS_SDIO) + mmc_sdhci_suspend(); +#endif storage_device_suspend(); opi_psram_suspend(); qspi0_suspend(); @@ -166,7 +170,9 @@ void pm_core_suspend_min(void) uart_h1_suspend(); uapi_dma_close(); uapi_dma_deinit(); - +#if defined(CFG_DRIVERS_MMC) || defined(CFG_DRIVERS_SDIO) + mmc_sdhci_suspend(); +#endif storage_device_suspend(); opi_psram_suspend(); qspi0_suspend(); @@ -213,6 +219,9 @@ void pm_core_resume_min(void) clocks_system_resume_clock(); uapi_dma_init(); uapi_dma_open(); +#if defined(CFG_DRIVERS_MMC) || defined(CFG_DRIVERS_SDIO) + mmc_sdhci_resume(); +#endif storage_device_resume(); reg16_setbit(0x520003e4, 0x0); // set mcpu_clken_slp in MSUB_SLP_CFG @@ -256,6 +265,9 @@ void pm_core_resume(void) uapi_dma_init(); uapi_dma_open(); cpu_trace_enable_mcpu_repeat(); +#if defined(CFG_DRIVERS_MMC) || defined(CFG_DRIVERS_SDIO) + mmc_sdhci_resume(); +#endif storage_device_resume(); display_resume(); if (non_os_get_nmi_raw_status() == 0x2) { diff --git a/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_lp_stub.c b/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_lp_stub.c index 7b33a9ef3..5ec95f8c9 100644 --- a/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_lp_stub.c +++ b/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_lp_stub.c @@ -15,9 +15,7 @@ #include "i2c_porting.h" #include "spi_porting.h" #include "uart_porting.h" -#ifdef CFG_DRIVERS_MMC #include "soc_mmc.h" -#endif #include "chip_io.h" #define UART_SUSPEND_REGS_NUM 8 @@ -68,8 +66,6 @@ void storage_device_suspend(void) #ifdef CFG_DRIVERS_NANDFLASH reg16_setbit(QSPI1_NANDFLASH_CS0_PAD, PAD_PS_BIT); reg16_setbit(QSPI1_NANDFLASH_CS0_PAD, PAD_PE_BIT); // make CS1 to high in deepsleep. -#elif defined (CFG_DRIVERS_MMC) - emmc_save_info(); #endif } @@ -129,10 +125,6 @@ void display_suspend(void) #ifndef QSPI_DISPLAY ret = drv_dpu_suspend(NULL); if (ret != 0) { PRINT("drv dpu suspend ret =%d\n", ret); } -#endif -#ifdef SUPPORT_GPU_GMMU - ret = drv_gmmu_suspend(NULL); - if (ret != 0) { PRINT("drv_gmmu_suspend ret =%d\n", ret); } #endif lcd_bus_api *bus_api = lcd_get_bus_api(); ret = bus_api->bus_suspend(); @@ -175,9 +167,6 @@ void display_resume(void) (void)drv_jpeg_resume(NULL); #endif (void)drv_vau_resume(NULL); -#ifdef SUPPORT_GPU_GMMU - (void)drv_gmmu_resume(NULL); -#endif if (g_resume_touch_flag != 0) { touch_resume_for_i2c(); } } #endif @@ -199,11 +188,11 @@ void pm_misc_regs_resume(void) writel(M_AXI_BRG_LP_CFG0, M_AXI_BRG_LP_DEFAULT_VAL); // M_axi writel(EFUSE_CTL_CFG, EFUSE_ALL_ENABLE); // enable efuse #ifdef CFG_DRIVERS_NANDFLASH - reg16_clrbit(PM_SD_HOST_CCLK_DIV_REG, 0); // close sd host clock enable. - reg16_clrbit(PM_EMMC_CCLK_DIV_REG, 0); // close sd mmc clock enable. + reg16_clrbit(EMMC_CCLK_DIV_REG, 0); // close sd mmc clock enable. #endif -#ifdef CFG_DRIVERS_MMC - reg16_clrbit(PM_SD_HOST_CCLK_DIV_REG, 0); // close sd host clock enable. + +#ifndef CFG_DRIVERS_SDIO + reg16_clrbit(SD_HOST_CCLK_DIV_REG, 0); // close sdio host clock enable. #endif hal_pmu_set_cmu_xo_trim(HAL_PMU_XO_CORE_DS_1_025X); } diff --git a/code/sdk/middleware/services/gpu/api/CMakeLists.txt b/code/sdk/middleware/services/gpu/api/CMakeLists.txt index 339404992..ab8d0d963 100644 --- a/code/sdk/middleware/services/gpu/api/CMakeLists.txt +++ b/code/sdk/middleware/services/gpu/api/CMakeLists.txt @@ -6,9 +6,6 @@ add_subdirectory(dpu) add_subdirectory(vau) add_subdirectory(rm) -if("SUPPORT_GPU_GMMU" IN_LIST DEFINES) - add_subdirectory(gmmu) -endif() if("SUPPORT_GPU_OPENVG" IN_LIST DEFINES) add_subdirectory(openvg) endif() diff --git a/code/sdk/middleware/services/gpu/api/rm/CMakeLists.txt b/code/sdk/middleware/services/gpu/api/rm/CMakeLists.txt index c6faaf16d..80c61abf9 100644 --- a/code/sdk/middleware/services/gpu/api/rm/CMakeLists.txt +++ b/code/sdk/middleware/services/gpu/api/rm/CMakeLists.txt @@ -1,10 +1,23 @@ set(COMPONENT_NAME "gfx_rm") set(SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/src/vau_stroke_dash.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vau_arc.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vau_stroke_path.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vau_math.c + ${CMAKE_CURRENT_SOURCE_DIR}/rm/src/vau_stroke_dash.c + ${CMAKE_CURRENT_SOURCE_DIR}/rm/src/vau_arc.c + ${CMAKE_CURRENT_SOURCE_DIR}/rm/src/vau_stroke_path.c + ${CMAKE_CURRENT_SOURCE_DIR}/rm/src/vau_math.c + + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/clock/gmmu_clock.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/context/gmmu_context.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/dev/gmmu_dev.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/dfx/gmmu_dfx.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/hal/gmmu_hal.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/intf/drv_gmmu_intf.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/ioctl/gmmu_ioctl.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/isr/gmmu_isr.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/mem/gmmu_mem.c + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/base/gmmu_comm.c + + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/api/src/soc_gmmu_api.c ) set(PUBLIC_HEADER @@ -15,7 +28,23 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/utils/common_headers/drivers/gpu ${ROOT_DIR}/middleware/services/gpu/api/vau/debug ${ROOT_DIR}/middleware/services/gpu/drv/vau/mem - ${CMAKE_CURRENT_SOURCE_DIR}/inc + ${ROOT_DIR}/middleware/services/gpu/drv/comm + ${ROOT_DIR}/middleware/services/gpu/drv/include/ + ${CMAKE_CURRENT_SOURCE_DIR}/rm/inc + + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/base + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/clock + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/context + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/dev + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/dfx + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/hal + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/include + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/intf + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/ioctl + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/isr + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/drv/mem + + ${CMAKE_CURRENT_SOURCE_DIR}/gmmu/api/inc ) set(PUBLIC_DEFINES diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-cli/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-cli/libgfx_rm.a index f4bfdaa75..c6dbfdd1b 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-cli/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-cli/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-ser/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-ser/libgfx_rm.a index e43cf5e5c..86859b75b 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-ser/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-auto-ota-ser/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230-r/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230-r/libgfx_rm.a index fa2aee123..4adaa7e6f 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230-r/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230-r/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230/libgfx_rm.a index d4ddcbd5a..deccbf1bd 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-fd230/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-r/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-r/libgfx_rm.a index fa2aee123..4adaa7e6f 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-r/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-r/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts-r/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts-r/libgfx_rm.a index fa2aee123..4adaa7e6f 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts-r/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts-r/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts/libgfx_rm.a index d4ddcbd5a..deccbf1bd 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js-xts/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js/libgfx_rm.a index d4ddcbd5a..deccbf1bd 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-native-js/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-native-js/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target1-r/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target1-r/libgfx_rm.a index 4bf6cdcc0..e29c3e3aa 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target1-r/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target1-r/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target1/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target1/libgfx_rm.a index bf6ac5bba..350f9fbda 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target1/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target1/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target3-r/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target3-r/libgfx_rm.a index 9ef1e0ad3..084c2e902 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target3-r/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target3-r/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target3/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target3/libgfx_rm.a index 47710ae8c..0c0b185a6 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target3/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target3/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target4-r/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target4-r/libgfx_rm.a index 7d9784893..3d9e75be5 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target4-r/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target4-r/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target4/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target4/libgfx_rm.a index 0df0a2999..0c52ab9ed 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target4/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target4/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target5-r/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target5-r/libgfx_rm.a index 94b8bb3f8..232248462 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target5-r/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target5-r/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-target5/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-target5/libgfx_rm.a index b73c4b286..90be983ef 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-target5/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-target5/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/brandy-xts/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/brandy-xts/libgfx_rm.a index ed1e9d983..742841344 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/brandy-xts/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/brandy-xts/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/rm/gmmu/api/inc/soc_gmmu_api.h b/code/sdk/middleware/services/gpu/api/rm/gmmu/api/inc/soc_gmmu_api.h new file mode 100644 index 000000000..cf46df383 --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/gmmu/api/inc/soc_gmmu_api.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2023. All rights reserved. + * Description: gmmu api interface + * Author: + * Create: 2021-10-15 + */ + +#ifndef SOC_GMMU_API_H +#define SOC_GMMU_API_H + +#include "td_type.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/** + * @defgroup gmmu_type gmmu_type + * @ingroup gpu_api + * @{ + */ + +/*-------------------------------- macro define -------------------------------------------*/ + +#define GMMU_BUF_CNT 2 + +/*-------------------------------- struct define ------------------------------------------*/ + +/** + * @if Eng + * @brief Gmmu memory attributes. + * @else + * @brief gmmu内存属性 + * @endif + */ +typedef struct gmmu_attr_struct { + td_u8 bpp; /*!< @if Eng Pixel Depth. + @else 像素深度 @endif */ + td_u32 width; /*!< @if Eng Memory Width. + @else 内存宽度 @endif */ + td_u32 height; /*!< @if Eng Memory height. + @else 内存高度 @endif */ + td_u8 offset; /*!< @if Eng Pixel offset for fine tuning lut contours. + @else 像素偏移,用于微调lut轮廓 @endif */ +} *gmmu_attr_ptr; + +/** + * @if Eng + * @brief gmmu buffer attribute. + * @else + * @brief gmmu buffer属性 + * @endif + */ +typedef struct gmmu_buf_struct { + td_u32 stride; /*!< @if Eng Gmmu buffer line spacing. + @else gmmu buffer行间距 @endif */ + td_u32 size; /*!< @if Eng Pixel Depth. + @else gmmu buffer 大小@endif */ + td_u32 buffer[GMMU_BUF_CNT]; /*!< @if Eng Pixel Depth. + @else gmmu buffer地址 @endif */ +} *gmmu_buf_ptr; + +/** + * @} + */ + +/** + * @defgroup gmmu_api gmmu_api + * @ingroup gpu_api + * @{ + */ + +/*-------------------------------- func declares ------------------------------------------*/ + +/** + * @if Eng + * @brief Initializing the Gmmu Memory. + * @param [in] Width, height, and pixel depth required for memory initialization. + * @retval EXT_SUCCESS Success. + * @retval Other Failure. + * @else + * @brief Gmmu 内存初始化 + * @param [in] gmmu_attr 内存初始化需要的宽高,像素深度信息 + * @retval EXT_SUCCESS 成功 + * @retval Other 失败 + * @endif + */ +td_s32 uapi_gmmu_init(const gmmu_attr_ptr gmmu_attr); + +/** + * @if Eng + * @brief Gmmu Memory Deinitialization. + * @else + * @brief Gmmu 内存去初始化 + * @endif + */ +td_void uapi_gmmu_deinit(td_void); + +/** + * @if Eng + * @brief Gmmu buffer application. + * @param [in] gmmu_buf Memory information about the gmmu buffer + * @else + * @brief Gmmu 内存申请 + * @param [in] gmmu_buf gmmu buffer的内存信息 + * @endif + */ +td_void uapi_gmmu_alloc(gmmu_buf_ptr gmmu_buf); + +/** + * @if Eng + * @brief Gmmu buffer free. + * @param [in] gmmu_buf Memory information about the gmmu buffer + * @else + * @brief Gmmu 内存释放 + * @param [in] gmmu_buf gmmu buffer的内存信息 + * @endif + */ +td_void uapi_gmmu_free(gmmu_buf_ptr gmmu_buf); + +/** + * @} + */ + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* SOC_GMMU_API_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_intf.h b/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_intf.h new file mode 100644 index 000000000..0b0724e24 --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_intf.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: drv gmmu intf + */ + +#ifndef DRV_GRAPHICS_DRV_GMMU_INTF_H +#define DRV_GRAPHICS_DRV_GMMU_INTF_H + +#include "td_type.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/*-------------------------------- macro define -------------------------------------------*/ + +typedef td_s32 (*pfn_gmmu_suspend)(td_void); +typedef td_s32 (*pfn_gmmu_resume)(td_void); + +/*-------------------------------- struct define ------------------------------------------*/ + +typedef struct { + pfn_gmmu_suspend suspend; + pfn_gmmu_resume resume; +} drv_gmmu_export_func; + +/*-------------------------------- func declares ------------------------------------------*/ + +td_s32 drv_gmmu_module_init(td_void); +td_void drv_gmmu_module_exit(td_void); + +td_s32 drv_gmmu_suspend(td_void *private_data); +td_s32 drv_gmmu_resume(td_void *private_data); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* DRV_GRAPHICS_DRV_GMMU_INTF_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_ioctl.h b/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_ioctl.h new file mode 100644 index 000000000..ed3528ad5 --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_ioctl.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: drv gmmu ioctl + */ + +#ifndef DRV_GRAPHICS_DRV_GMMU_IOCTL_H +#define DRV_GRAPHICS_DRV_GMMU_IOCTL_H + +#include +#include "td_base.h" +#include "drv_gmmu_struct.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/*-------------------------------- macro define -------------------------------------------*/ + +#define GMMU_DEV_NAME "/dev/gmmu" + +#define DRV_GMMU_CMD_CONFIG 0 + +td_s32 gmmu_open(const td_char *path_name, td_s32 flags, td_s32 mode); +td_s32 gmmu_ioctl(td_s32 module_idx, td_ulong ioctl_cmd, td_void *para); +td_s32 gmmu_close(td_s32 module_idx); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* DRV_GRAPHICS_DRV_GMMU_IOCTL_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_struct.h b/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_struct.h new file mode 100644 index 000000000..2b10a0fff --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/gmmu/drv/include/drv_gmmu_struct.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: drv gmmu struct + */ + +#ifndef DRV_GRAPHICS_DRV_GMMU_STRUCT_H +#define DRV_GRAPHICS_DRV_GMMU_STRUCT_H + +#include "td_type.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/*-------------------------------- macro define -------------------------------------------*/ + +#define DRV_GMMU_MASK 0x0123456789ABCDEF + +/*-------------------------------- struct define ------------------------------------------*/ + +typedef struct { + td_u64 mask; + td_u8 input_bpp; + td_u32 input_width; + td_u32 input_height; + td_u8 offset; + td_u32 output_size; + td_u32 output_stride; + td_u32 output_addr0; + td_u32 output_addr1; +} drv_gmmu_mgr; + +/*-------------------------------- func declares ------------------------------------------*/ + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* DRV_GRAPHICS_DRV_GMMU_STRUCT_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_arc.h b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_arc.h new file mode 100644 index 000000000..7bace23ba --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_arc.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: vau_arc + */ + +#ifndef RM_BASIC_ARC_H +#define RM_BASIC_ARC_H + +#include "soc_vau_type.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#ifndef CIRCLE_TO_BEZIER_H_90_DEG +#define CIRCLE_TO_BEZIER_H_90_DEG 0.551915024494f +#endif + +typedef struct { + float x; + float y; +} float_point; + +typedef struct { + float rx; + float ry; + td_float cos_phi; + td_float sin_phi; + td_float xhalf; + td_float yhalf; + td_float x1p; + td_float y1p; + float_point r2; + td_float x12p; + td_float y12p; + td_float cr; + td_float dq; + td_float pq; + td_float sc; + td_float cxp; + td_float cyp; + td_float cx; + td_float cy; + td_float theta; + td_float delta; +} local_arc_params; + +typedef struct { + float_point en1; + float_point en2; + float_point edn1; + float_point edn2; + td_u8 split_len; + td_u8 t_len; + td_float alpha; + td_float step; + td_float alpha_t; + td_float theta; + td_float delta; + float_point r; + float_point c; + float_point angles; + td_float cos_phi; + td_float sin_phi; + td_float interval; +} local_bezier_points; + +float_point *create_arc_utility(const float_point *center, float r, float start_angle, float angle_extend, int *num); +float_point *create_arc_cmd(const float_point *start, const float_point *end, unsigned char cmd, float r, int *num); +void destroy_arc_path(float_point *cubic); +td_s32 vau_draw_create_arc_fit_path(const ext_vau_path *org, ext_vau_path *fit); +td_void vau_draw_destroy_arc_fit_path(ext_vau_path *path); +float_point *create_elliptical_arc_utility(float_point p[2], unsigned char cmd, float_point r, float phi, int *num); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* RM_BASIC_ARC_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_math.h b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_math.h new file mode 100644 index 000000000..f038bb7e3 --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_math.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. + * Description : vau math file + */ + +#ifndef API_RM_VAU_MATH_H +#define API_RM_VAU_MATH_H + +#include +#include "td_base.h" +#include "soc_vau_type.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#define VAU_TRIGO_SHIFT 15 +#ifndef CIRCLE_TO_BEZIER_H_90_DEG +#define CIRCLE_TO_BEZIER_H_90_DEG 0.551915024494f +#endif + +#define HALF_M_PI (M_PI / 2) + +#define deg_to_rad(a) ((a) * M_PI / 180.0f) +#define rad_to_deg(a) ((a) * 180.0f / M_PI) + +#define vau_matrix_x(m, x, y) ((x) * (m)[0][0] + (y) * (m)[0][1] + (m)[0][2]) +#define vau_matrix_y(m, x, y) ((x) * (m)[1][0] + (y) * (m)[1][1] + (m)[1][2]) + +static inline td_bool double_is_equal(double a, double b) +{ + return fabs(a - b) <= 1e-6; +} + +typedef struct { + float x; + float y; +} vau_point_float, vau_vector; + +td_float vau_math_fabs(td_float x); +td_float vau_math_fsqrt(td_float x); +td_float vau_math_inv_fsqrt(td_float x); +td_s32 vau_math_min(td_s32 a, td_s32 b); +td_float vau_math_min_f(td_float a, td_float b); +td_s32 vau_math_max(td_s32 a, td_s32 b); +td_float vau_math_max_f(td_float a, td_float b); +td_float vau_math_clamp(td_float value, td_float min_value, td_float max_value); +td_bool vau_math_float_is_equal(td_float a, td_float b); +td_bool vau_math_float_is_zero(td_float x); +td_void vau_matrix_identity(ext_vau_matrix *m); +td_void vau_matrix_mult(ext_vau_matrix *m, const ext_vau_matrix *m2); +td_void vau_matrix_trans(ext_vau_matrix *m, float tx, float ty); +td_void vau_matrix_scale(ext_vau_matrix *m, float sx, float sy); +td_void vau_matrix_shear(ext_vau_matrix *m, float shx, float shy); +td_void vau_matrix_rotate(ext_vau_matrix *m, float angle); +td_void vau_matrix_reflect_x(ext_vau_matrix *m); +td_void vau_matrix_reflect_y(ext_vau_matrix *m); +td_void vau_matrix_reflect_o(ext_vau_matrix *m); +td_s32 vector_dot_product_sign(const vau_vector *v1, const vau_vector *v2); +td_float fast_inv_sqrt(td_float x); +bool float_is_nan(float a); +float vau_circle_to_bezier_h(float rad); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ +#endif /* API_RM_VAU_MATH_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_split_bezier.h b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_split_bezier.h new file mode 100644 index 000000000..05ed6be35 --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_split_bezier.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: render path basic + */ + +#ifndef VAU_SPLIT_BEZIER_H +#define VAU_SPLIT_BEZIER_H + +#include "vau_stroke_dash.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +td_u32 cubic_split_agg(const vau_point_float *cubic, vau_point_float *line_points, td_u32 point_num); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* VAU_SPLIT_BEZIER_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_stroke_dash.h b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_stroke_dash.h new file mode 100644 index 000000000..9e0108621 --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_stroke_dash.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: render path basic + */ + +#ifndef VAU_STROKE_DASH_H +#define VAU_STROKE_DASH_H + +#include "soc_vau_type.h" +#include "vau_math.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#define VAU_CUBIC_BEZIER_POINT_NUM 4 + +typedef struct { + float x; + float y; +} vau_path_line_to; + +typedef struct { + float x0; /* ctrl point */ + float y0; /* ctrl point */ + float x1; /* end point */ + float y1; /* end point */ +} vau_path_quad_to; + +typedef struct { + float x0; /* ctrl point */ + float y0; /* ctrl point */ + float x1; /* ctrl point */ + float y1; /* ctrl point */ + float x2; /* end point */ + float y2; /* end point */ +} vau_path_cubic_to; + +typedef struct { + vau_point_float s; + vau_point_float p; + vau_point_float o; + td_uchar cmd; + td_u32 offset; + td_u32 data_num; + vau_path_line_to line_to; + vau_path_quad_to quad_to; + vau_path_cubic_to cubic_to; + vau_point_float cubic[VAU_CUBIC_BEZIER_POINT_NUM]; + td_bool rel; +} local_stroke_dash_path; + +td_s32 vau_create_stroke_dash_path(const ext_vau_path *path, const ext_vau_stroke_attr *stroke, + ext_vau_path *dash_path); +td_void vau_destroy_stroke_dash_path(ext_vau_path *dash_path); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* VAU_STROKE_DASH_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_stroke_path.h b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_stroke_path.h new file mode 100644 index 000000000..c5ec13155 --- /dev/null +++ b/code/sdk/middleware/services/gpu/api/rm/rm/inc/vau_stroke_path.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: stroke path + */ + +#ifndef STROKE_INC_VAU_STROKE_PATH_H +#define STROKE_INC_VAU_STROKE_PATH_H + +#include "soc_vau_type.h" +#include "vau_stroke_dash.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +typedef enum { + EXT_BEZIER_MODE_LINE_AVG, + EXT_BEZIER_MODE_BEZIER_4, + EXT_BEZIER_MODE_BEZIER_CLOSE, + EXT_BEZIER_MODE_BEZIER_MONO, + EXT_BEZIER_MODE_BEZIER_ELIA, + EXT_BEZIER_MODE_BEZIER_ELIA_4, + EXT_BEZIER_MODE_BEZIER_ELIA_CLOSE, + EXT_BEZIER_MODE_LINE_FREETYPE, + EXT_BEZIER_MODE_LINE_AGG, + EXT_BEZIER_MODE_MAX +} ext_vau_bezier_stroke_split_mode; + +typedef struct { + vau_vector v; + vau_point_float c1; + vau_point_float c2; + vau_point_float p4; + float h; + float p1p3; + float p1p4; + float p3p4; + float sin; + float cos; +} local_stroke_add_round; + +typedef struct { + td_s32 x1; + td_s32 y1; + td_s32 x2; + td_s32 y2; +} ext_vau_line_fixed; + +typedef struct { + td_u32 i; + float sx; + float sy; + float px; + float py; + float ox; + float oy; + td_uchar cmd; + td_u32 offset; + td_u32 data_num; + vau_path_line_to line_to; + vau_path_quad_to quad_to; + vau_path_cubic_to cubic_to; + ext_vau_line_fixed line_inner; + ext_vau_line_fixed line_outer; + td_u32 cubic_split_count; + vau_point_float p0; + vau_point_float p1; + vau_point_float left; + vau_point_float right; + td_bool rel; + float width; + float half_width; + td_bool has_close; + td_u32 sub_index; + int l_count; + int c_count; + td_bool add_join; + td_bool add_cap; + td_s32 ret; + float rx; + float ry; + td_u32 point_num; + td_u32 cubic_split_count_out; +} local_parse_stroke_path; + +typedef struct { + float miter_limit; + float half_width; +} vau_line_cap_param; + +typedef struct { + td_bool add_join; + td_bool add_cap; +} vau_join_cap_flag; + +td_s32 vau_create_stroke_to_fill_path(const ext_vau_path *path, const ext_vau_stroke_attr *stroke_attr, + ext_vau_path *fill_path, ext_vau_fill_attr *fill_attr, ext_vau_bezier_stroke_split_mode mode); +td_void vau_destroy_stroke_to_fill_path(ext_vau_path *fill_path); +td_u32 cubic_bezier_subdivision(const vau_point_float *points, vau_point_float *points_subdivision); +td_void split_cubic_to_line_average(const vau_point_float *cubic, vau_point_float *line_points, td_u32 point_num); +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* STROKE_INC_VAU_STROKE_PATH_H */ diff --git a/code/sdk/middleware/services/gpu/api/rm/testsuite-brandy-sdk/libgfx_rm.a b/code/sdk/middleware/services/gpu/api/rm/testsuite-brandy-sdk/libgfx_rm.a index ee6e11184..5943d14d0 100644 Binary files a/code/sdk/middleware/services/gpu/api/rm/testsuite-brandy-sdk/libgfx_rm.a and b/code/sdk/middleware/services/gpu/api/rm/testsuite-brandy-sdk/libgfx_rm.a differ diff --git a/code/sdk/middleware/services/gpu/api/vau/CMakeLists.txt b/code/sdk/middleware/services/gpu/api/vau/CMakeLists.txt index 1215c09fa..906a9a8ba 100644 --- a/code/sdk/middleware/services/gpu/api/vau/CMakeLists.txt +++ b/code/sdk/middleware/services/gpu/api/vau/CMakeLists.txt @@ -16,7 +16,7 @@ set(GPU_SRC_LIST "${GPU_SRC_LIST}" "${vau_api_list}" CACHE INTERNAL "platform sr set( vau_api_header_list - ${ROOT_DIR}/middleware/services/gpu/api/rm/inc + ${ROOT_DIR}/middleware/services/gpu/api/rm/rm/inc/ ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/draw ${CMAKE_CURRENT_SOURCE_DIR}/matrix diff --git a/code/sdk/middleware/services/gpu/drv/CMakeLists.txt b/code/sdk/middleware/services/gpu/drv/CMakeLists.txt index ced28b741..6641c9fd3 100644 --- a/code/sdk/middleware/services/gpu/drv/CMakeLists.txt +++ b/code/sdk/middleware/services/gpu/drv/CMakeLists.txt @@ -5,9 +5,6 @@ Create: 2021-03-15 ]] add_subdirectory(dpu) add_subdirectory(vau) -if("SUPPORT_GPU_GMMU" IN_LIST DEFINES) - add_subdirectory(gmmu) -endif() if("SUPPORT_GPU_JPEG" IN_LIST DEFINES) add_subdirectory(jpeg) endif() diff --git a/code/sdk/middleware/services/gpu/drv/vau/CMakeLists.txt b/code/sdk/middleware/services/gpu/drv/vau/CMakeLists.txt index c2650e33a..f9b1f49b2 100644 --- a/code/sdk/middleware/services/gpu/drv/vau/CMakeLists.txt +++ b/code/sdk/middleware/services/gpu/drv/vau/CMakeLists.txt @@ -35,5 +35,6 @@ set( ${CMAKE_CURRENT_SOURCE_DIR}/list ${CMAKE_CURRENT_SOURCE_DIR}/mem ${CMAKE_CURRENT_SOURCE_DIR}/node + ${ROOT_DIR}/middleware/services/gpu/api/rm/gmmu/drv/include ) set(GPU_INC_LIST "${GPU_INC_LIST}" "${vau_drv_header_list}" CACHE INTERNAL "platform src obj list" FORCE) \ No newline at end of file diff --git a/code/sdk/middleware/services/gpu/drv/vau/intf/drv_vau_intf.c b/code/sdk/middleware/services/gpu/drv/vau/intf/drv_vau_intf.c index 784391a66..15a27a301 100644 --- a/code/sdk/middleware/services/gpu/drv/vau/intf/drv_vau_intf.c +++ b/code/sdk/middleware/services/gpu/drv/vau/intf/drv_vau_intf.c @@ -16,6 +16,7 @@ #include "vau_pre_process.h" #include "vau_handle.h" #include "drv_vau_struct.h" +#include "drv_gmmu_intf.h" #define DRV_VAU_IOCTL_CMD_NUM 20 @@ -69,6 +70,10 @@ td_s32 drv_vau_suspend(td_void *private_data) drv_vau_set_suspend_flag(TD_TRUE); vau_dbg("vau suspend ok"); +#ifdef SUPPORT_GPU_GMMU + (td_void)drv_gmmu_suspend(NULL); +#endif + return ret; } @@ -90,6 +95,10 @@ td_s32 drv_vau_resume(td_void *private_data) drv_vau_set_suspend_flag(TD_FALSE); vau_dbg("vau resume ok"); +#ifdef SUPPORT_GPU_GMMU + (void)drv_gmmu_resume(NULL); +#endif + return EXT_SUCCESS; } @@ -220,7 +229,13 @@ static td_void vau_unregister_device(td_void) td_s32 uapi_vau_module_init(void) { td_s32 ret; - +#ifdef SUPPORT_GPU_GMMU + ret = drv_gmmu_module_init(); + if (ret != EXT_SUCCESS) { + vau_err("drv_gmmu_module_init failed, ret=%#x!", ret); + return ret; + } +#endif vau_ip_dcmp_tmp(); ret = vau_mem_init(); diff --git a/code/sdk/middleware/services/gpu/drv/vau/mem/vau_mem.c b/code/sdk/middleware/services/gpu/drv/vau/mem/vau_mem.c index 30e6f390e..3e550236b 100644 --- a/code/sdk/middleware/services/gpu/drv/vau/mem/vau_mem.c +++ b/code/sdk/middleware/services/gpu/drv/vau/mem/vau_mem.c @@ -378,6 +378,7 @@ td_uchar *vau_mem_alloc(vau_mem_type mem_type, td_u32 size) osal_spin_lock_irqsave(&(g_mem_info[mem_type].mem_lock), &lockflags); if (osal_list_empty(&g_mem_free_list_head[mem_type]) != 0) { + osal_spin_unlock_irqrestore(&(g_mem_info[mem_type].mem_lock), &lockflags); vau_err("mem_free_list[%d] is empty!", mem_type); return TD_NULL; } diff --git a/code/sdk/middleware/services/gui/hal/common/include/graphic_hardware_config.h b/code/sdk/middleware/services/gui/hal/common/include/graphic_hardware_config.h index a6a8cdded..f834f49ba 100644 --- a/code/sdk/middleware/services/gui/hal/common/include/graphic_hardware_config.h +++ b/code/sdk/middleware/services/gui/hal/common/include/graphic_hardware_config.h @@ -47,7 +47,11 @@ * @brief Enable JPEG preview which includes decoding jpeg file and cacheing decoded data. */ #ifdef SUPPORT_GPU_JPEG +#ifdef XTS_SUPPORT +#define CAPABILITY_HW_JPEG_DECODE 0 +#else #define CAPABILITY_HW_JPEG_DECODE 1 +#endif #else #define CAPABILITY_HW_JPEG_DECODE 0 #endif @@ -90,7 +94,14 @@ * @brief Hardware acceleration for drawing cubic bezier curve. Prerequirement is ENABLE_VGU_ENGINE is 1. */ #define CAPABILITY_HWDRAW_CURVE 0 - +/** + * @brief Hardware acceleration for drawing rect. Prerequirement is ENABLE_VGU_ENGINE is 1. + */ +#define CAPABILITY_HWDRAW_RECT 0 +/** + * @brief Hardware acceleration for filling small size. Prerequirement is ENABLE_VGU_ENGINE is 1. + */ +#define CAPABILITY_HWDRAW_SMALL_SIZE 0 /** * @brief Whether open offline dial. */ @@ -109,7 +120,7 @@ /** * @brief Use double buffer for rendering process. */ - + #ifndef DOUBLE_BUFFER #define DOUBLE_BUFFER 1 #endif diff --git a/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt b/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt index 7329aacc4..2bde27dd2 100644 --- a/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt +++ b/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt @@ -10,6 +10,7 @@ set(COMPONENT_NAME "display_gfx") set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/display_vau.c ${CMAKE_CURRENT_SOURCE_DIR}/src/yuv_to_rgb.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/display_gmmu.c ${PROJECT_ROOT_DIR}/hal/common/src/barcode128.c ) @@ -21,6 +22,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include ${ROOTDIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include ${UIKIT_ROOT_DIR}/proprietary/src/utils/innerkits + ${ROOTDIR}/middleware/services/gpu/api/rm/gmmu/api/inc ) set(PRIVATE_DEFINES @@ -84,6 +86,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/mempool/include ${ROOTDIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include ${UIKIT_ROOT_DIR}/proprietary/src/utils/innerkits + ${ROOTDIR}/middleware/services/gpu/api/rm/gmmu/api/inc ) set(PRIVATE_DEFINES @@ -136,6 +139,7 @@ set(PUBLIC_HEADER set(PRIVATE_HEADER ${ROOTDIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include ${UIKIT_ROOT_DIR}/proprietary/src/utils/innerkits + ${ROOTDIR}/middleware/services/gpu/api/rm/gmmu/api/inc ) set(PRIVATE_DEFINES diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-cli/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-cli/libdisplay_gfx.a index 1a92aed1a..97b71926a 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-cli/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-cli/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-ser/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-ser/libdisplay_gfx.a index db41b910f..f3d611c92 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-ser/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-auto-ota-ser/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-native-js-fd230/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-native-js-fd230/libdisplay_gfx.a index 8606c8a32..f1571801f 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-native-js-fd230/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-native-js-fd230/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-native-js-xts/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-native-js-xts/libdisplay_gfx.a index 8606c8a32..f1571801f 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-native-js-xts/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-native-js-xts/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-native-js/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-native-js/libdisplay_gfx.a index 8606c8a32..f1571801f 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-native-js/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-native-js/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-target1/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-target1/libdisplay_gfx.a index 4db2f0078..9a5cb4e15 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-target1/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-target1/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-target3/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-target3/libdisplay_gfx.a index c480c01d7..fdd8ba175 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-target3/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-target3/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-target5/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-target5/libdisplay_gfx.a index 96e3ae958..a9ffd5f1b 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-target5/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-target5/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/brandy-xts/libdisplay_gfx.a b/code/sdk/middleware/services/gui/hal/display/brandy-xts/libdisplay_gfx.a index 61aae4201..dfaf9472e 100644 Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-xts/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-xts/libdisplay_gfx.a differ diff --git a/code/sdk/middleware/services/gui/hal/display/include/display_gmmu_internal.h b/code/sdk/middleware/services/gui/hal/display/include/display_gmmu_internal.h new file mode 100644 index 000000000..4279ac981 --- /dev/null +++ b/code/sdk/middleware/services/gui/hal/display/include/display_gmmu_internal.h @@ -0,0 +1,29 @@ +/* +Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025. All rights reserved. +*/ + +#ifndef DISPLAY_GMMU_INTERNAL_H +#define DISPLAY_GMMU_INTERNAL_H +#include "display_type.h" + +#define INTERNAL_GMMU_BUF_CNT 2 + +typedef struct { + td_u32 stride; /* Gmmu buffer line spacing. */ + td_u32 size; /* Gmmu buffer Size. */ + td_u32 buffer[INTERNAL_GMMU_BUF_CNT]; /* Gmmu buffer Addr. */ +} GmmuBuf; + +typedef struct { + td_u8 bpp; /* Pixel Depth. */ + td_u32 width; /* Memory Width. */ + td_u32 height; /* height. */ + td_u8 offset; /* Pixel offset for fine tuning lut contours. */ +} GmmuAttr; + +td_s32 GmmuInit(const GmmuAttr *gmmu_attr); +td_void GmmuAlloc(GmmuBuf *gmmu_buf); +td_void GmmuFree(GmmuBuf *gmmu_buf); +td_void GmmuDeinit(td_void); + +#endif /* DISPLAY_GMMU_INTERNAL_H */ diff --git a/code/sdk/middleware/services/gui/hal/display/src/display_gralloc.c b/code/sdk/middleware/services/gui/hal/display/src/display_gralloc.c index fde932976..11a0af64f 100644 --- a/code/sdk/middleware/services/gui/hal/display/src/display_gralloc.c +++ b/code/sdk/middleware/services/gui/hal/display/src/display_gralloc.c @@ -22,8 +22,10 @@ #endif #include "mem_pool_los.h" #include "mem_pool_types.h" -#include "soc_gmmu_api.h" #include "graphic_hardware_config.h" +#if ENABLE_GMMU +#include "display_gmmu_internal.h" +#endif #define MAX_MALLOC_SIZE 0x10000000L #define FB_COUNT 2 @@ -61,7 +63,7 @@ TryToFreeFontCacheCallback g_tryToFreeFontCacheCallback = NULL; #if ENABLE_GMMU static bool g_gmmuAllocated[FB_COUNT] = {false, false}; -struct gmmu_buf_struct g_gmmuMem = { 0 }; +GmmuBuf g_gmmuMem = { 0 }; #else static AddrInfo FBInfo[FB_COUNT] = { {false, MEM_POOL_UI_FB, MEM_POOL_UI_FB_SIZE / 2}, @@ -330,11 +332,11 @@ int32_t GrallocInitialize(GrallocFuncs **funcs) *funcs = gFuncs; #if ENABLE_GMMU - struct gmmu_attr_struct gmmuAtr = {LAYER_BPP, RESOLUTION_WIDTH, RESOLUTION_HEIGHT}; - if (uapi_gmmu_init(&gmmuAtr) != DISPLAY_SUCCESS) { + GmmuAttr gmmuAtr = {LAYER_BPP, RESOLUTION_WIDTH, RESOLUTION_HEIGHT}; + if (GmmuInit(&gmmuAtr) != DISPLAY_SUCCESS) { return DISPLAY_FAILURE; } - uapi_gmmu_alloc(&g_gmmuMem); + GmmuAlloc(&g_gmmuMem); #endif DISP_LOGI("gralloc initialize success\n"); return DISPLAY_SUCCESS; @@ -350,8 +352,8 @@ int32_t GrallocUninitialize(GrallocFuncs *funcs) DISP_LOGI("gralloc uninitialize success\n"); #if ENABLE_GMMU - uapi_gmmu_free(&g_gmmuMem); - uapi_gmmu_deinit(); + GmmuFree(&g_gmmuMem); + GmmuDeinit(); #endif return DISPLAY_SUCCESS; } diff --git a/code/sdk/middleware/services/gui/lvgl/brandy-target1/liblvgl_proprietary_mini.a b/code/sdk/middleware/services/gui/lvgl/brandy-target1/liblvgl_proprietary_mini.a index a5c531160..289f8855e 100644 Binary files a/code/sdk/middleware/services/gui/lvgl/brandy-target1/liblvgl_proprietary_mini.a and b/code/sdk/middleware/services/gui/lvgl/brandy-target1/liblvgl_proprietary_mini.a differ diff --git a/code/sdk/middleware/services/gui/lvgl/brandy-target5/liblvgl_proprietary.a b/code/sdk/middleware/services/gui/lvgl/brandy-target5/liblvgl_proprietary.a index 603f11fd4..3abe5ed13 100644 Binary files a/code/sdk/middleware/services/gui/lvgl/brandy-target5/liblvgl_proprietary.a and b/code/sdk/middleware/services/gui/lvgl/brandy-target5/liblvgl_proprietary.a differ diff --git a/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-cli/libuikit_ext.a b/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-cli/libuikit_ext.a index 4d0915c3f..b06968c15 100644 Binary files a/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-cli/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-cli/libuikit_ext.a differ diff --git a/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-ser/libuikit_ext.a b/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-ser/libuikit_ext.a index a865dbbd3..ecbaad890 100644 Binary files a/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-ser/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-auto-ota-ser/libuikit_ext.a differ diff --git a/code/sdk/middleware/services/gui/uikit/brandy-native-js-fd230/libuikit_ext.a b/code/sdk/middleware/services/gui/uikit/brandy-native-js-fd230/libuikit_ext.a index c5f87106b..81ecca508 100644 Binary files a/code/sdk/middleware/services/gui/uikit/brandy-native-js-fd230/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-native-js-fd230/libuikit_ext.a differ diff --git a/code/sdk/middleware/services/gui/uikit/brandy-native-js-xts/libuikit_ext.a b/code/sdk/middleware/services/gui/uikit/brandy-native-js-xts/libuikit_ext.a index c5f87106b..81ecca508 100644 Binary files a/code/sdk/middleware/services/gui/uikit/brandy-native-js-xts/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-native-js-xts/libuikit_ext.a differ diff --git a/code/sdk/middleware/services/gui/uikit/brandy-native-js/libuikit_ext.a b/code/sdk/middleware/services/gui/uikit/brandy-native-js/libuikit_ext.a index c5f87106b..81ecca508 100644 Binary files a/code/sdk/middleware/services/gui/uikit/brandy-native-js/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-native-js/libuikit_ext.a differ diff --git a/code/sdk/middleware/services/gui/uikit/brandy-target3/libuikit_ext.a b/code/sdk/middleware/services/gui/uikit/brandy-target3/libuikit_ext.a index 1fa3226cd..cad2383a7 100644 Binary files a/code/sdk/middleware/services/gui/uikit/brandy-target3/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-target3/libuikit_ext.a differ diff --git a/code/sdk/middleware/services/gui/uikit/brandy-xts/libuikit_ext.a b/code/sdk/middleware/services/gui/uikit/brandy-xts/libuikit_ext.a index 33528f555..55fc828a4 100644 Binary files a/code/sdk/middleware/services/gui/uikit/brandy-xts/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-xts/libuikit_ext.a differ diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/common/graphic_hardware_types.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/common/graphic_hardware_types.h index 4c3e15e9a..24c067d11 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/common/graphic_hardware_types.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/common/graphic_hardware_types.h @@ -127,6 +127,10 @@ struct RadialGradient { /** * @brief Sweep gradient params. + * @param centerX Indicates the x coordinate of the circle center. + * @param centerY Indicates the y coordinate of the circle center. + * @param startAngle Indicates the start angle of the sector. Value 0 indicates the 12-o'clock direction, + * and 90 indicates the 3-o'clock direction. */ struct SweepGradient { int16_t centerX; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/kaleidoscope_utils.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/kaleidoscope_utils.h index 7ed170fab..1dbb4780b 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/kaleidoscope_utils.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/kaleidoscope_utils.h @@ -72,7 +72,8 @@ private: Path imgPath_ = {0}; float thetaVal_ = 0.0f; float radius_ = 0.0f; - Point point_ = {0, 0}; + float x_ = 0.0f; + float y_ = 0.0f; Point startPoint_ = {0, 0}; bool isInternalMem_ = false; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_canvas_ext.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_canvas_ext.h index d7390c18a..105b471e2 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_canvas_ext.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_canvas_ext.h @@ -375,7 +375,7 @@ public: * @return Returns index value that relates to a path object. Returns -1 when any error occurs. */ int16_t DrawSector(const Point& center, uint16_t radius, - int16_t startAngle, int16_t endAngle, const PaintExt& paint); + float startAngle, float endAngle, const PaintExt& paint); /** * @brief Draws an arc. diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_card_page.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_card_page.h index 9e90eb04b..34a0a76e1 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_card_page.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_card_page.h @@ -52,7 +52,7 @@ public: ~UICardPage() override {} /* * - * @brief This function is invoked when the function SetHorCurrentPage() is called. + * @brief This function is invoked when the function SetHorCurrentPage() or Presenter:OnResume() is called. * @since 1.0 * @version 1.0 */ @@ -114,6 +114,27 @@ public: */ virtual void CoverEnd(bool isCovered) {} + /* * + * @brief This function is invoked when SetVerCurrentPage is called and horizontal page is covered. + * @since 1.0 + * @version 1.0 + */ + virtual void OnCovered(void) {} + + /* * + * @brief This function is invoked when SetVerCurrentPage is called and horizontal page is not covered. + * @since 1.0 + * @version 1.0 + */ + virtual void OnUncovered(void) {} + + /* * + * @brief This function is invoked when Presenter::OnPause is called. + * @since 1.0 + * @version 1.0 + */ + virtual void OnPause(void) {} + /* * * @brief Set coverable state. * @since 1.0 diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_cross_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_cross_view.h index 3ffc31d17..114ee722f 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_cross_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_cross_view.h @@ -124,6 +124,13 @@ public: */ void SetHorCurrentPage(uint16_t index, bool loadAdjacent = true); + /* * + * @brief Set the current page index of vertical direction. + * @since 1.0 + * @version 1.0 + */ + void SetVerCurrentPage(uint16_t index); + /* * * @brief Get the current page index of target direction. * @since 1.0 @@ -213,11 +220,12 @@ public: } /** - * @brief Set background blur radius. Default value is 10. + * @brief Set background blur radius. Default value is 10.0f, The effective range is [0.0f ~ 32.0f]. * @since 1.0 * @version 1.0 */ - void SetBlurRadius(uint16_t radius) { + void SetBlurRadius(float radius) + { blurRadius_ = radius; } @@ -232,7 +240,7 @@ public: private: using UIViewGroup::Remove; - uint16_t blurRadius_ = 10; + float blurRadius_ = 10.0f; void UpdateCardPageIndex(); static constexpr uint16_t INVALID_VIEW_INDEX = 0xff; bool loop_ = false; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_particle_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_particle_view.h index f4c7d7483..d7e9fb3ee 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_particle_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_particle_view.h @@ -134,6 +134,11 @@ public: */ void ClearParticles(); + UIViewType GetViewType() const override + { + return UI_PARTICLE_VIEW; + } + private: void ProcessParticleCells(); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_roller_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_roller_view.h index 68fc2e279..4247d373f 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_roller_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_roller_view.h @@ -148,6 +148,34 @@ public: return onScrollListener_; } + class OnChildStateListener : public HeapBase { + public: + /** + * @brief Callback function when the status of a child control changes. + * + * @param view Object of the child control whose state changes. + * This object is a control of the UIViewGroup type. + * If roller is in mirror mode, the object will contain two subcomponents. + * The head is normal image,tail is mirror image. + * If there is no mirroring mode,only have normal images. + * @param angle Rotation angle of the child control in the current.range: 0-360 + */ + virtual bool StateChange(UIView* view, float angle) = 0; + virtual ~OnChildStateListener() {} + }; + + /** + * @brief Listens for the change of the angle status of the child control. + * + * @param Object of class OnChildStateListener. + * @since 1.0 + * @version 1.0 + */ + void SetChildStateListener(OnChildStateListener* listener) + { + onChildStateListener_ = listener; + } + /** * @brief Get current mode. */ @@ -164,6 +192,17 @@ public: */ void SetCamY(int16_t y); + /** + * @brief Obtains the view name. + * @param view Specifies the view to be obtained. + */ + static std::string GetRollerItemName(UIView* view); + + bool IsShowMirrorMode() + { + return isShowMirrorImg_; + } + UIViewType GetViewType() const override { return UI_ROLLER_VIEW; @@ -173,6 +212,7 @@ public: bool OnDragEvent(const DragEvent& event) override; bool OnDragEndEvent(const DragEvent& event) override; #if ENABLE_ROTATE_INPUT + bool OnRotateStartEvent(const RotateEvent& event) override; bool OnRotateEvent(const RotateEvent& event) override; bool OnRotateEndEvent(const RotateEvent& event) override; #endif @@ -288,6 +328,7 @@ private: static constexpr float TRANSITION_COEFFICIENT = 0.2; OnModeChangeListener* onModeChangeListener_ = nullptr; OnScrollListener* onScrollListener_ = nullptr; + OnChildStateListener* onChildStateListener_ = nullptr; float ConvertDistanceToAngle(int16_t distance); bool IsInCurrentItemRange(float angle); void InitImg(UIView* img); @@ -336,6 +377,10 @@ private: uint16_t itemPadding_ = 0; bool needLayout_ = false; UIViewGroup* currentItem_ = nullptr; +#if ENABLE_VIBRATOR + UIViewGroup* lastItem_ = nullptr; + bool needVibration_ = false; +#endif UIViewGroup* alignItem_ = nullptr; bool isShowMirrorImg_; float alignAngle_ = 0.0f; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/dfx/dfx_frame_trace.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/dfx/dfx_frame_trace.h index 9e1d45094..bd9f056d2 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/dfx/dfx_frame_trace.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/dfx/dfx_frame_trace.h @@ -72,6 +72,9 @@ enum class FrameTraceType { HW_DRAW_FLUSH, HW_DRAW_WAIT, HW_DRAW_ARC_RECT, + HW_DRAW_LINE, + HW_DRAW_ARC, + HW_DRAW_CUBICBEZIER, DRAW_MAX }; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/font/font_global_manager.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/font/font_global_manager.h index 535456fc3..28081ffc3 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/font/font_global_manager.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/font/font_global_manager.h @@ -32,15 +32,24 @@ struct FontParam { class FontGlobalManager : public HeapBase { public: + class LangChangeListener { + public: + virtual void OnLangChange(uint8_t langId) = 0; + virtual ~LangChangeListener() {} + }; char* GetText(uint16_t textId); bool RegisterLanguageInfo(const char** resFile, uint8_t totalLangId, uint8_t defaultLangId); void UnRegisterLanguageInfo(); void SetCurrentLangId(uint8_t langId); + uint8_t GetCurrentLangId() const + { + return currentLangId_; + } FontParam GetFontParam(uint16_t textId); uint8_t GetTotalLangId(); static FontGlobalManager* GetInstance(); static constexpr uint16_t INVALID_TEXT_ID = 0xFFFF; - static constexpr uint8_t INVALIDE_LANG_ID = 0xFF; + static constexpr uint8_t INVALID_LANG_ID = 0xFF; private: void RefreshViews(UIView* rootView); @@ -51,7 +60,7 @@ private: LangBinInfo* GetLangBinInfo(); bool ReallocStringInfos(uint8_t totalLangId); StringsInfo* stringsInfos_ = nullptr; - uint8_t currentLangId_ = INVALIDE_LANG_ID; // 0xFF: the max lang id + uint8_t currentLangId_ = INVALID_LANG_ID; // 0xFF: the max lang id uint8_t totalLangId_ = 0; }; } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_event_handler.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_event_handler.cpp index eacb14266..5513029db 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_event_handler.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_event_handler.cpp @@ -44,10 +44,10 @@ void GraphicEventHandler::Run() void GraphicEventHandler::PostGraphicEvent(const GraphicEvent& event, bool exitLowPower) { + queueMutex_.Lock(); if (exitLowPower) { LowPowerManager::GetInstance()->ExitLowPower(); } - queueMutex_.Lock(); eventQueue_.push(event); pthreadCond_.Signal(); queueMutex_.Unlock(); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_nested.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_nested.cpp index 9f7f30ff8..5bbd1cc97 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_nested.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_nested.cpp @@ -15,11 +15,19 @@ UIListNested::UIListNested(uint8_t direction) : UIList(direction) bool UIListNested::OnDragStartEvent(const DragEvent& event) { - if (reboundSize_ != 0) { - for (uint8_t i = 0; i < sizeof(isIntercepts_) / sizeof(bool); ++i) { - isIntercepts_[i] = true; - } + if (reboundSizeTop_ != 0) { + isIntercepts_[DragEvent::DIRECTION_TOP_TO_BOTTOM] = true; + } + if (reboundSizeBottom_ != 0) { + isIntercepts_[DragEvent::DIRECTION_BOTTOM_TO_TOP] = true; + } + if (reboundSizeLeft_ != 0) { + isIntercepts_[DragEvent::DIRECTION_LEFT_TO_RIGHT] = true; + } + if (reboundSizeRight_ != 0) { + isIntercepts_[DragEvent::DIRECTION_RIGHT_TO_LEFT] = true; } + uint8_t dragDirection; if (MATH_ABS(event.GetDeltaX()) >= MATH_ABS(event.GetDeltaY())) { dragDirection = HORIZONTAL; @@ -48,14 +56,14 @@ bool UIListNested::OnDragEvent(const DragEvent& event) if (direction_ == VERTICAL) { outOfBounds[DragEvent::DIRECTION_TOP_TO_BOTTOM] = - childrenHead_->GetY() >= scrollBlankSize_ + childrenHead_->GetStyle(STYLE_MARGIN_TOP); + childrenHead_->GetY() >= scrollBlankSizeTop_ + childrenHead_->GetStyle(STYLE_MARGIN_TOP); outOfBounds[DragEvent::DIRECTION_BOTTOM_TO_TOP] = childrenTail_->GetRelativeRect().GetBottom() <= - listHeight - scrollBlankSize_ - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM); + listHeight - scrollBlankSizeBottom_ - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM); } else { outOfBounds[DragEvent::DIRECTION_LEFT_TO_RIGHT] = - childrenHead_->GetX() >= scrollBlankSize_ + childrenHead_->GetStyle(STYLE_MARGIN_LEFT); + childrenHead_->GetX() >= scrollBlankSizeLeft_ + childrenHead_->GetStyle(STYLE_MARGIN_LEFT); outOfBounds[DragEvent::DIRECTION_RIGHT_TO_LEFT] = childrenTail_->GetRelativeRect().GetRight() <= - listWidth - scrollBlankSize_ - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT); + listWidth - scrollBlankSizeRight_ - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT); } bool transfer = false; @@ -87,13 +95,35 @@ bool UIListNested::OnDragEndEvent(const DragEvent& event) void UIListNested::SetBoundaryIntercept(uint8_t direction, bool isIntercept) { - if (direction > DragEvent::DIRECTION_BOTTOM_TO_TOP) { - return; - } - if (reboundSize_ != 0) { - GRAPHIC_LOGE("rebound size is not zero!"); - return; + switch (direction) { + case DragEvent::DIRECTION_LEFT_TO_RIGHT: + if (reboundSizeLeft_ != 0) { + GRAPHIC_LOGE("reboundSizeLeft_ is not zero!"); + return; + } + break; + case DragEvent::DIRECTION_RIGHT_TO_LEFT: + if (reboundSizeRight_ != 0) { + GRAPHIC_LOGE("reboundSizeRight_ is not zero!"); + return; + } + break; + case DragEvent::DIRECTION_TOP_TO_BOTTOM: + if (reboundSizeTop_ != 0) { + GRAPHIC_LOGE("reboundSizeTop_ is not zero!"); + return; + } + break; + case DragEvent::DIRECTION_BOTTOM_TO_TOP: + if (reboundSizeBottom_ != 0) { + GRAPHIC_LOGE("reboundSizeBottom_ is not zero!"); + return; + } + break; + default: + return; } + uint8_t dragDirection = (direction == DragEvent::DIRECTION_LEFT_TO_RIGHT || direction == DragEvent::DIRECTION_RIGHT_TO_LEFT) ? HORIZONTAL : VERTICAL; if (dragDirection != direction_) { diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_scroll_view_nested.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_scroll_view_nested.cpp index 25b8f72c1..6687ff02e 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_scroll_view_nested.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_scroll_view_nested.cpp @@ -15,6 +15,19 @@ UIScrollViewNested::UIScrollViewNested(uint8_t direction) : UIScrollView() bool UIScrollViewNested::OnDragStartEvent(const DragEvent& event) { + if (reboundSizeTop_ != 0) { + isIntercepts_[DragEvent::DIRECTION_TOP_TO_BOTTOM] = true; + } + if (reboundSizeBottom_ != 0) { + isIntercepts_[DragEvent::DIRECTION_BOTTOM_TO_TOP] = true; + } + if (reboundSizeLeft_ != 0) { + isIntercepts_[DragEvent::DIRECTION_LEFT_TO_RIGHT] = true; + } + if (reboundSizeRight_ != 0) { + isIntercepts_[DragEvent::DIRECTION_RIGHT_TO_LEFT] = true; + } + uint8_t dragDirection; if (MATH_ABS(event.GetDeltaX()) >= MATH_ABS(event.GetDeltaY())) { dragDirection = HORIZONTAL; @@ -40,11 +53,12 @@ bool UIScrollViewNested::OnDragEvent(const DragEvent& event) int16_t scrollHeight = GetHeight(); bool outOfBounds[4] = {false, false, false, false}; // 4: the number of direction if (direction_ == VERTICAL) { - outOfBounds[DragEvent::DIRECTION_TOP_TO_BOTTOM] = childRect.GetTop() >= scrollBlankSize_; - outOfBounds[DragEvent::DIRECTION_BOTTOM_TO_TOP] = childRect.GetBottom() <= scrollHeight - scrollBlankSize_; + outOfBounds[DragEvent::DIRECTION_TOP_TO_BOTTOM] = childRect.GetTop() >= scrollBlankSizeTop_; + outOfBounds[DragEvent::DIRECTION_BOTTOM_TO_TOP] = + childRect.GetBottom() <= scrollHeight - scrollBlankSizeBottom_; } else { - outOfBounds[DragEvent::DIRECTION_LEFT_TO_RIGHT] = childRect.GetLeft() >= scrollBlankSize_; - outOfBounds[DragEvent::DIRECTION_RIGHT_TO_LEFT] = childRect.GetRight() <= scrollWidth - scrollBlankSize_; + outOfBounds[DragEvent::DIRECTION_LEFT_TO_RIGHT] = childRect.GetLeft() >= scrollBlankSizeLeft_; + outOfBounds[DragEvent::DIRECTION_RIGHT_TO_LEFT] = childRect.GetRight() <= scrollWidth - scrollBlankSizeRight_; } bool transfer = false; @@ -77,9 +91,35 @@ bool UIScrollViewNested::OnDragEndEvent(const DragEvent& event) void UIScrollViewNested::SetBoundaryIntercept(uint8_t direction, bool isIntercept) { - if (direction > DragEvent::DIRECTION_BOTTOM_TO_TOP) { - return; + switch (direction) { + case DragEvent::DIRECTION_LEFT_TO_RIGHT: + if (reboundSizeLeft_ != 0) { + GRAPHIC_LOGE("reboundSizeLeft_ is not zero!"); + return; + } + break; + case DragEvent::DIRECTION_RIGHT_TO_LEFT: + if (reboundSizeRight_ != 0) { + GRAPHIC_LOGE("reboundSizeRight_ is not zero!"); + return; + } + break; + case DragEvent::DIRECTION_TOP_TO_BOTTOM: + if (reboundSizeTop_ != 0) { + GRAPHIC_LOGE("reboundSizeTop_ is not zero!"); + return; + } + break; + case DragEvent::DIRECTION_BOTTOM_TO_TOP: + if (reboundSizeBottom_ != 0) { + GRAPHIC_LOGE("reboundSizeBottom_ is not zero!"); + return; + } + break; + default: + return; } + uint8_t dragDirection = (direction == DragEvent::DIRECTION_LEFT_TO_RIGHT || direction == DragEvent::DIRECTION_RIGHT_TO_LEFT) ? HORIZONTAL : VERTICAL; if (dragDirection != direction_) { diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_cmd.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_cmd.cpp index 344e953a9..d2f908ef3 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_cmd.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_cmd.cpp @@ -32,7 +32,11 @@ #include "dfx/dfx_frame_trace.h" #include "common/low_power_manager.h" #include "common/image_cache_manager.h" - +#include "common/input_device_manager.h" +#include "common/task_manager.h" +#include "graphic_service_wrapper.h" +#include "graphic_event_handler.h" +#include "animator/animator_manager.h" #if ENABLE_DEBUG #include "common/key_code.h" #include "dfx/event_injector.h" @@ -93,6 +97,15 @@ void DumpState(int argc, char *argv[]) printf(" NativeRunninng: %d\n", GraphicService::GetInstance()->IsNativeRunning()); printf(" IsScreenOn: %d\n", GraphicService::GetInstance()->IsScreenOn()); printf(" GraphicTaskTriggeredCount: %d\n", GraphicService::GetInstance()->GetGraphicTaskTriggeredCount()); + printf(" LowPower:\n"); + printf(" Frequence: %d\n", GetFrequence()); + printf(" Task: total num: %d\n", TaskManager::GetInstance()->GetTotalTaskNum()); + printf(" Animator: total num: %d, active num: %d\n", + AnimatorManager::GetInstance()->GetTotalAnimatorNum(), + AnimatorManager::GetInstance()->GetActiveAnimatorNum()); + printf(" InputEvent Exist: %d\n", InputDeviceManager::GetInstance()->IsEventExist()); + printf(" PendingFrame: %d\n", LiteMGfxEngine::GetInstance()->HasPendingFrame()); + printf(" SufaceView Exist: %d\n", LowPowerManager::GetInstance()->IsLiteSurfaceInRootView()); } void LeakPanic(int argc, char *argv[]) @@ -378,6 +391,15 @@ void ShowTime(int argc, char *argv[]) } } +void ForceRefresh(int argc, char *argv[]) +{ + if (argc == 0) { + GraphicService::GetInstance()->PostGraphicEvent([]() { RootView::GetInstance()->Invalidate(); }); + } else { + printf("param err.\n"); + } +} + void HideFPS(int argc, char *argv[]) { FPSTask::GetInstance()->HideFPS(); @@ -547,6 +569,7 @@ struct DfxCmd g_dfxCmdList[] = { {"hidefps", OHOS::HideFPS}, {"showfps", OHOS::ShowFPS}, {"showtime", OHOS::ShowTime}, + {"refresh", OHOS::ForceRefresh}, #if ENABLE_MEMORY_CHECK {"dumpstate", OHOS::DumpState}, {"dumpmem", OHOS::DumpMemoryCmd}, @@ -574,7 +597,9 @@ bool ExecUikitDfxByCmdType(int argc, char *argv[]) for (i = 0; i < sizeof(g_dfxCmdList) / sizeof(g_dfxCmdList[0]); i++) { if (!strcmp(g_dfxCmdList[i].cmdType, argv[0])) { - OHOS::LowPowerManager::GetInstance()->ExitLowPower(); + if (strcmp(argv[0], "dumpstate") != 0) { + OHOS::LowPowerManager::GetInstance()->ExitLowPower(); + } g_dfxCmdList[i].func(argc - 1, &argv[1]); return true; } diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_dom_dump.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_dom_dump.cpp index b3ce83ca2..d50f6a3d9 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_dom_dump.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_dom_dump.cpp @@ -89,6 +89,7 @@ static const struct { {UI_TRANSFORM_LIST, "UI_TRANSFORM_LIST"}, {UI_COVER_FLOW_2, "UI_COVER_FLOW_2"}, {UI_SPHERE_VIEW, "UI_SPHERE_VIEW"}, + {UI_PARTICLE_VIEW, "UI_PARTICLE_VIEW"}, {UI_NUMBER_MAX, "UI_NUMBER_MAX"}, }; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_frame_trace.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_frame_trace.cpp index 06b7cf607..2201b6b3d 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_frame_trace.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_frame_trace.cpp @@ -37,6 +37,9 @@ static struct { {FrameTraceType::HW_DRAW_FLUSH, "hw_flush"}, {FrameTraceType::HW_DRAW_WAIT, "hw_wait"}, {FrameTraceType::HW_DRAW_ARC_RECT, "hw_arc_rect"}, + {FrameTraceType::HW_DRAW_LINE, "hw_line"}, + {FrameTraceType::HW_DRAW_ARC, "hw_arc"}, + {FrameTraceType::HW_DRAW_CUBICBEZIER, "hw_bezier"}, }; int DfxFrameTrace::evtCnt_ = 0; @@ -240,11 +243,13 @@ void DfxFrameTrace::ShowEventRecord() const printf("Total: E %d, T %d, F %d\n", evtCnt_, tskCnt_, frmCnt_); for (EventRecord *it = events_; it != nullptr; it = it->next) { EventRecord &evt = *it; - printf("\nE %d: %llu\n", evtIndex, GetDuration(evt.startTime, evt.endTime)); + printf("\nE %d: %llu, (%llu, %llu)\n", evtIndex, GetDuration(evt.startTime, evt.endTime), + evt.startTime, evt.endTime); taskIndex = 0; for (TaskRecord *it1 = evt.tasks; it1 != nullptr; it1 = it1->next) { TaskRecord &tsk = *it1; - printf(" T %d: %llu\n", taskIndex, GetDuration(tsk.startTime, tsk.endTime)); + printf(" T %d: %llu, (%llu, %llu)\n", taskIndex, GetDuration(tsk.startTime, tsk.endTime), + tsk.startTime, tsk.endTime); if (tsk.frameInfo != nullptr) { ShowFrameRecord(tsk.frameInfo); } diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dock/lite_key_device.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dock/lite_key_device.cpp index 2a7253052..9373c86b2 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dock/lite_key_device.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dock/lite_key_device.cpp @@ -36,11 +36,11 @@ void LiteKeyDevice::DispatchEvent(const DeviceData& data) } KeyEvent event({data.keyId, data.state}); RootView::GetInstance()->OnKeyEvent(event); - #ifdef SUPPORT_OHOSFWK +#ifdef SUPPORT_OHOSFWK if (!GraphicService::GetInstance()->IsNativeRunning()) { OHOS::ACELite::KeyListener::GetInstance()->OnKeyEvent(event); } - #endif +#endif } bool LiteKeyDevice::IsEventEmpty() diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.cpp index ca7d64cc4..13e48015c 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.cpp @@ -35,7 +35,7 @@ static bool AllocImageInfo(ImageInfo& info, uint16_t width, uint16_t height, Col } void ClipImg::ClipImgByPath(ImageInfo& dstInfo, ImageInfo& srcInfo, const Path* path, Rect* srcImgArea, - const Matrix4* pathMatrix, const Matrix4* imgMatrix) + const Matrix4* pathMatrix, const Matrix4* imgMatrix, bool isAlphaFF) { if (path == nullptr || path->cmds == nullptr || path->data == nullptr) { return; @@ -43,7 +43,11 @@ void ClipImg::ClipImgByPath(ImageInfo& dstInfo, ImageInfo& srcInfo, const Path* uintptr_t handle = LiteMGfxEngine::GetInstance()->InitPath(true); LiteMGfxEngine::GetInstance()->SetPathData(handle, path->cmdNum, path->cmds, path->dataNum, path->data); - LiteMGfxEngine::GetInstance()->ClipImgByPath(dstInfo, srcInfo, handle, srcImgArea, pathMatrix, imgMatrix); + if (isAlphaFF) { + LiteMGfxEngine::GetInstance()->ClipImgByPath(dstInfo, srcInfo, handle, srcImgArea, pathMatrix, imgMatrix, true); + } else { + LiteMGfxEngine::GetInstance()->ClipImgByPath(dstInfo, srcInfo, handle, srcImgArea, pathMatrix, imgMatrix); + } } ImageInfo ClipImg::ClipImgByCircle(ImageInfo& srcInfo, Point center, int16_t radius, diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.h index f16b708b2..5d55adf5b 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.h @@ -19,7 +19,7 @@ namespace OHOS { class ClipImg : public HeapBase { public: static void ClipImgByPath(ImageInfo& dstInfo, ImageInfo& srcInfo, const Path* path, Rect* srcImgArea, - const Matrix4* pathMatrix, const Matrix4* imgMatrix); + const Matrix4* pathMatrix, const Matrix4* imgMatrix, bool isAlphaFF = false); static ImageInfo ClipImgByCircle(ImageInfo& srcInfo, Point center, int16_t radius, ColorMode mode = RGB888, bool immediatelySync = false); static ImageInfo ClipImgByRect(ImageInfo& srcInfo, Rect* srcImgArea, Rect clipArea, ColorMode mode = RGB888); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.cpp index 83ac11d41..d7feafbf1 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.cpp @@ -23,10 +23,22 @@ #if ENABLE_VGU_ENGINE && CAPABILITY_HWDRAW_PATH namespace OHOS { constexpr float ARC_TO_BEZIER_90_DEG = 0.551915024494f; -#define RAD_90_DEG (90 / RADIAN_TO_ANGLE) -constexpr int16_t DEG_360 = 360; -constexpr int16_t DEG_90 = 90; -constexpr int16_t DATA_NUM_PER_BEZIER = 6; +constexpr int16_t DATA_NUM_PER_BEZ = 6; +constexpr float PRECISION_ANGLE = 0.01f; + +bool HWDrawUtils::AllocBufferForCmd(uint16_t cmdNum, uint8_t*& addr) +{ + AllocInfo dataInfo; + dataInfo.expectedSize = sizeof(uint8_t) * cmdNum; + dataInfo.usage = HBM_USE_ASSIGN_SIZE | HBM_USE_MEM_PATH; + GrallocBuffer dataBuffer; + if (!GrallocEngines::GetInstance()->AllocBuffer(dataInfo, dataBuffer)) { + GRAPHIC_LOGE("Alloc buffer for data failed."); + return false; + } + addr = reinterpret_cast(dataBuffer.virAddr); + return true; +} bool HWDrawUtils::AllocBufferForData(uint16_t dataNum, float*& addr) { @@ -42,119 +54,136 @@ bool HWDrawUtils::AllocBufferForData(uint16_t dataNum, float*& addr) return true; } -void HWDrawUtils::GetArcControlPoint(float* arcData, const Point& center, float mangicNum, int8_t neg) +void HWDrawUtils::GetArcControlPoint(float* arcData, float centerX, float centerY, float mangicNum, int8_t neg) { - arcData[2] = arcData[0] - (neg * mangicNum * (arcData[1] - center.y)); // 2: index - arcData[3] = arcData[1] + (neg * mangicNum * (arcData[0] - center.x)); // 3: index - arcData[4] = arcData[6] + (neg * mangicNum * (arcData[7] - center.y)); // 4, 6, 7: index - arcData[5] = arcData[7] - (neg * mangicNum * (arcData[6] - center.x)); // 5, 7, 6: index + arcData[2] = arcData[0] - (neg * mangicNum * (arcData[1] - centerY)); // 2: index + arcData[3] = arcData[1] + (neg * mangicNum * (arcData[0] - centerX)); // 3: index + arcData[4] = arcData[6] + (neg * mangicNum * (arcData[7] - centerY)); // 4, 6, 7: index + arcData[5] = arcData[7] - (neg * mangicNum * (arcData[6] - centerX)); // 5, 7, 6: index } -void HWDrawUtils::ConvertCircularDegree(float& angle) +static float ConvertArcDegree(ArcInfo& arc, uint32_t& quaNum, uint32_t& bezNum) { - if (angle >= DEG_360) { - angle = angle - DEG_360 * (angle / DEG_360); + // convert angle in the interface to gpu angle + arc.startAngle = arc.startAngle - QUARTER_IN_DEGREE; + arc.endAngle = arc.endAngle - QUARTER_IN_DEGREE; + float deltaAngle = abs(arc.endAngle - arc.startAngle); + if (FloatMore(deltaAngle, CIRCLE_IN_DEGREE, PRECISION_ANGLE)) { + arc.startAngle = 0.0f; + arc.endAngle = CIRCLE_IN_DEGREE; + quaNum = 4; // 4: num of quaerter in circle + bezNum = 4; // 4: num of quaerter in circle + return 0.0f; } - if (angle - DEG_90 >= 0) { - angle -= DEG_90; - } else { - angle = DEG_360 - (DEG_90 - angle); + int neg = (arc.startAngle < arc.endAngle) ? 1 : -1; + uint32_t deltaAngleInt = static_cast(deltaAngle); + if (FloatEqual(deltaAngle - deltaAngleInt, 1.0f, PRECISION_ANGLE)) { + deltaAngleInt += 1; } + quaNum = deltaAngleInt / QUARTER_IN_DEGREE; + float remain = deltaAngle - quaNum * QUARTER_IN_DEGREE; + bezNum = FloatMore(remain, 0.0f, PRECISION_ANGLE) ? quaNum + 1: quaNum; + return remain; } -int8_t HWDrawUtils::GetArcData(float* arcData, const Point& center, - uint16_t radius, float startAngle, float endAngle) +void HWDrawUtils::GetArcData(float* arcData, const ArcInfo& arc, uint32_t quaNum, float remain) { - int neg = (startAngle < endAngle) ? 1 : -1; - float angleExtend = endAngle - startAngle; - int loop = static_cast(angleExtend) * neg / DEG_90; - - ConvertCircularDegree(startAngle); - float startAngleRad = startAngle / RADIAN_TO_ANGLE; - float extendRad = angleExtend / RADIAN_TO_ANGLE; - float endAngleRad = startAngleRad + extendRad; - - arcData[0] = center.x + radius * cos(startAngleRad); - arcData[1] = center.y + radius * sin(startAngleRad); - int8_t bezierSegmentCount = 0; - float a = startAngleRad + neg * RAD_90_DEG; - for (int i = 0; i < loop; ++i) { - arcData[DATA_NUM_PER_BEZIER * bezierSegmentCount + 6] = center.x + radius * cos(a); // 6: x offset - arcData[DATA_NUM_PER_BEZIER * bezierSegmentCount + 7] = center.y + radius * sin(a); // 7: y offset - GetArcControlPoint(&arcData[DATA_NUM_PER_BEZIER * bezierSegmentCount], center, ARC_TO_BEZIER_90_DEG, neg); - ++bezierSegmentCount; - a += (neg * RAD_90_DEG); // when neg == 1, then clockwise; when neg == -1, counter clockwise + Point center = arc.center; + int16_t radius = arc.radius; + int neg = (arc.startAngle < arc.endAngle) ? 1 : -1; + + arcData[0] = center.x + radius * Sin(QUARTER_IN_DEGREE - arc.startAngle); + arcData[1] = center.y + radius * Sin(arc.startAngle); + float angle = arc.startAngle; + for (uint32_t i = 0; i < quaNum; ++i) { + angle += (neg * QUARTER_IN_DEGREE); // when neg == 1, then clockwise; when neg == -1, counter clockwise + arcData[DATA_NUM_PER_BEZ * i + 6] = center.x + radius * Sin(QUARTER_IN_DEGREE - angle); // 6: offset + arcData[DATA_NUM_PER_BEZ * i + 7] = center.y + radius * Sin(angle); // 7: offset + GetArcControlPoint(&arcData[DATA_NUM_PER_BEZ * i], center.x, center.y, ARC_TO_BEZIER_90_DEG, neg); } - a = RAD_90_DEG - (a - endAngleRad) * neg; - if (a > 1e-5) { - arcData[DATA_NUM_PER_BEZIER * bezierSegmentCount + 6] = center.x + radius * cos(endAngleRad); // 6: x offset - arcData[DATA_NUM_PER_BEZIER * bezierSegmentCount + 7] = center.y + radius * sin(endAngleRad); // 7: y offset + if (FloatMore(remain, 0.0f, PRECISION_ANGLE)) { + arcData[DATA_NUM_PER_BEZ * quaNum + 6] = center.x + radius * Sin(QUARTER_IN_DEGREE - arc.endAngle); // 6: offset + arcData[DATA_NUM_PER_BEZ * quaNum + 7] = center.y + radius * Sin(arc.endAngle); // 7: offset // 4.0: multiplier, 3.0: divider, 2: divider - float magicNum = 4.0f / 3.0f * (1 - cos(a / 2)) / sin(a / 2); - GetArcControlPoint(&arcData[DATA_NUM_PER_BEZIER * bezierSegmentCount], center, magicNum, neg); - ++bezierSegmentCount; + float magicNum = 4.0f / 3.0f * (1 - Sin(QUARTER_IN_DEGREE - remain / 2)) / Sin(remain / 2); + GetArcControlPoint(&arcData[DATA_NUM_PER_BEZ * quaNum], center.x, center.y, magicNum, neg); } - return bezierSegmentCount; } -void HWDrawUtils::Obtain30DegSectorPath(const ArcInfo& arc, uint8_t* cmd, float* data) +void HWDrawUtils::Obtain30DegSectorPath(const ArcInfo& arc, float x, float y, uint8_t* cmd, float* data) { - float startAngle = arc.startAngle; - float endAngle = arc.endAngle; - float angleExtend = endAngle - startAngle; + // convert angle in the interface to gpu angle + float startAngle = (arc.startAngle - QUARTER_IN_DEGREE) / RADIAN_TO_ANGLE; + // make sure the range is accurate, not use (arc.endAngle - QUARTER_IN_DEGREE) / RADIAN_TO_ANGLE + float endAngle = startAngle + (arc.endAngle - arc.startAngle) / RADIAN_TO_ANGLE; float neg = (startAngle < endAngle) ? 1 : -1; - ConvertCircularDegree(startAngle); - float startAngleRad = startAngle / RADIAN_TO_ANGLE; - float extendRad = static_cast(angleExtend) / RADIAN_TO_ANGLE; - float endAngleRad = startAngleRad + extendRad; - cmd[0] = CMD_MOVE_TO; cmd[1] = CMD_LINE_TO; cmd[2] = CMD_CUBIC_TO; // 2: index cmd[3] = CMD_CLOSE; // 3: index - float a = startAngleRad + neg * RAD_90_DEG; - a = RAD_90_DEG - (a - endAngleRad) * neg; - - data[0] = arc.center.x; - data[1] = arc.center.y; - data[2] = arc.center.x + arc.radius * cos(startAngleRad); // 2: index - data[3] = arc.center.y + arc.radius * sin(startAngleRad); // 3: index - data[8] = arc.center.x + arc.radius * cos(endAngleRad); // 8: index - data[9] = arc.center.y + arc.radius * sin(endAngleRad); // 9: index - + float a = (endAngle - startAngle) * neg; + data[0] = x; + data[1] = y; + data[2] = x + arc.radius * cos(startAngle); // 2: index + data[3] = y + arc.radius * sin(startAngle); // 3: index + data[8] = x + arc.radius * cos(endAngle); // 8: index + data[9] = y + arc.radius * sin(endAngle); // 9: index float magicNum = 4.0f / 3.0f * (1 - cos(a / 2)) / sin(a / 2); // 2: divisor - GetArcControlPoint(&data[2], arc.center, magicNum, neg); // 2: index + GetArcControlPoint(&data[2], x, y, magicNum, neg); // 2: index } -bool HWDrawUtils::ObtainArcPath(const ArcInfo& arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data) +bool HWDrawUtils::ObtainArcPath(ArcInfo arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data) { - float startAngle = arc.startAngle; - float endAngle = arc.endAngle; - - int16_t num = (abs(endAngle - startAngle) / DEG_90 + 1) * DATA_NUM_PER_BEZIER + 2; // 2: coordinate num - AllocInfo cmdInfo; - cmdInfo.expectedSize = sizeof(uint8_t) * (num + 1); - cmdInfo.usage = HBM_USE_ASSIGN_SIZE | HBM_USE_MEM_PATH; - GrallocBuffer cmdBuffer; - if (!GrallocEngines::GetInstance()->AllocBuffer(cmdInfo, cmdBuffer)) { - GRAPHIC_LOGE("Alloc buffer for cmd failed."); + uint32_t quaNum = 0; + uint32_t bezNum = 0; + float remain = ConvertArcDegree(arc, quaNum, bezNum); + + cmdNum = bezNum + 1; + dataNum = bezNum * DATA_NUM_PER_BEZ + 2; // 2: the number of start point path data + if (!AllocBufferForCmd(cmdNum, cmds)) { return false; } - cmds = (uint8_t *)cmdBuffer.virAddr; - if (!AllocBufferForData(num, data)) { + if (!AllocBufferForData(dataNum, data)) { GrallocEngines::GetInstance()->FreeBuffer(cmds); cmds = nullptr; return false; } - int8_t bezierSegmentCount = GetArcData(data, arc.center, arc.radius, startAngle, endAngle); - dataNum = DATA_NUM_PER_BEZIER * bezierSegmentCount + 2; // 2: coordinate num - cmdNum = bezierSegmentCount + 1; + GetArcData(data, arc, quaNum, remain); cmds[0] = CMD_MOVE_TO; - for (int i = 1; i <= bezierSegmentCount; i++) { + for (int i = 1; i < cmdNum; i++) { + cmds[i] = CMD_CUBIC_TO; + } + return true; +} + +bool HWDrawUtils::ObtainSectorPath(ArcInfo arc, uint32_t& cmdNum, uint8_t*& cmds, + uint32_t& dataNum, float*& data) +{ + uint32_t quaNum = 0; + uint32_t bezNum = 0; + float remain = ConvertArcDegree(arc, quaNum, bezNum); + + cmdNum = bezNum + 3; // 3: num of cmds, which are assigned in the below code + dataNum = bezNum * DATA_NUM_PER_BEZ + 4; // 4: the number of path data, include center and start point + if (!AllocBufferForCmd(cmdNum, cmds)) { + return false; + } + if (!AllocBufferForData(dataNum, data)) { + GrallocEngines::GetInstance()->FreeBuffer(cmds); + cmds = nullptr; + return false; + } + data[0] = arc.center.x; + data[1] = arc.center.y; + GetArcData(data + 2, arc, quaNum, remain); // 2: offset + cmds[0] = CMD_MOVE_TO; + cmds[1] = CMD_LINE_TO; + cmds[cmdNum - 1] = CMD_CLOSE; + for (int i = 2; i < cmdNum - 1; i++) { cmds[i] = CMD_CUBIC_TO; } return true; @@ -168,15 +197,9 @@ bool HWDrawUtils::ObtainCirclePath(const ArcInfo& arc, uint32_t& cmdNum, Point center = arc.center; cmdNum = 5; // 5: Circle path command number is 5 - AllocInfo cmdInfo; - cmdInfo.expectedSize = sizeof(uint8_t) * cmdNum; - cmdInfo.usage = HBM_USE_ASSIGN_SIZE | HBM_USE_MEM_PATH; - GrallocBuffer cmdBuffer; - if (!GrallocEngines::GetInstance()->AllocBuffer(cmdInfo, cmdBuffer)) { - GRAPHIC_LOGE("Alloc buffer for cmd failed."); + if (!AllocBufferForCmd(cmdNum, cmds)) { return false; } - cmds = (uint8_t *)cmdBuffer.virAddr; dataNum = 26; // Circle path data number is 26 if (!AllocBufferForData(dataNum, data)) { GrallocEngines::GetInstance()->FreeBuffer(cmds); @@ -222,16 +245,9 @@ bool HWDrawUtils::ObtainCirclePath(const ArcInfo& arc, uint32_t& cmdNum, bool HWDrawUtils::ObtainRectPathWithRadius(const Rect& rect, Path& path, int16_t radius) { path.cmdNum = 10; // 10: Circle path command number is 10 - AllocInfo cmdInfo; - cmdInfo.expectedSize = sizeof(uint8_t) * path.cmdNum; - cmdInfo.usage = HBM_USE_ASSIGN_SIZE | HBM_USE_MEM_PATH; - GrallocBuffer cmdBuffer; - if (!GrallocEngines::GetInstance()->AllocBuffer(cmdInfo, cmdBuffer)) { - GRAPHIC_LOGE("Alloc buffer for cmd failed."); + if (!AllocBufferForCmd(path.cmdNum, path.cmds)) { return false; } - path.cmds = (uint8_t *)cmdBuffer.virAddr; - path.cmds[0] = CMD_MOVE_TO; path.cmds[1] = CMD_LINE_TO; path.cmds[2] = CMD_CUBIC_TO; // 2: cmd index @@ -288,17 +304,13 @@ void HWDrawUtils::GetFilledRoundRectData(float* data, uint16_t radius, const Rec data[32] = x1; // 32: index data[33] = y1 + r; // 33: index - Point center1 = {x1 + r, y2 - r}; - GetArcControlPoint(&data[2], center1, ARC_TO_BEZIER_90_DEG, -1); // 2: index + GetArcControlPoint(&data[2], x1 + r, y2 - r, ARC_TO_BEZIER_90_DEG, -1); // 2: index - Point center2 = {x2 - r, y2 - r}; - GetArcControlPoint(&data[10], center2, ARC_TO_BEZIER_90_DEG, -1); // 10: index + GetArcControlPoint(&data[10], x2 - r, y2 - r, ARC_TO_BEZIER_90_DEG, -1); // 10: index - Point center3 = {x2 - r, y1 + r}; - GetArcControlPoint(&data[18], center3, ARC_TO_BEZIER_90_DEG, -1); // 18: index + GetArcControlPoint(&data[18], x2 - r, y1 + r, ARC_TO_BEZIER_90_DEG, -1); // 18: index - Point center4 = {x1 + r, y1 + r}; - GetArcControlPoint(&data[26], center4, ARC_TO_BEZIER_90_DEG, -1); // 26: index + GetArcControlPoint(&data[26], x1 + r, y1 + r, ARC_TO_BEZIER_90_DEG, -1); // 26: index } } #endif diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.h index e0efe0225..86d3b0403 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.h @@ -29,17 +29,18 @@ public: static HWDrawUtils instance; return &instance; } - bool ObtainArcPath(const ArcInfo& arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data); + bool ObtainArcPath(ArcInfo arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data); + bool ObtainSectorPath(ArcInfo arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data); bool ObtainCirclePath(const ArcInfo& arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data); + bool AllocBufferForCmd(uint16_t cmdNum, uint8_t*& addr); bool AllocBufferForData(uint16_t dataNum, float*& addr); - void Obtain30DegSectorPath(const ArcInfo& arc, uint8_t* cmd, float* data); + void Obtain30DegSectorPath(const ArcInfo& arc, float x, float y, uint8_t* cmd, float* data); bool ObtainRectPathWithRadius(const Rect& rect, Path& path, int16_t radius); private: HWDrawUtils() {} virtual ~HWDrawUtils() {} - int8_t GetArcData(float* arcData, const Point& center, uint16_t radius, float startAngle, float endAngle); - void GetArcControlPoint(float* arcData, const Point& center, float mangicNum, int8_t neg); - void ConvertCircularDegree(float& angle); + void GetArcData(float* arcData, const ArcInfo& arc, uint32_t quaNum, float bezMore); + void GetArcControlPoint(float* arcData, float centerX, float centerY, float mangicNum, int8_t neg); void GetFilledRoundRectData(float* data, uint16_t radius, const Rect& rect); }; } diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/engines/gfx/lite_m_gfx_engine.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/engines/gfx/lite_m_gfx_engine.h index 6bed8efec..4f42d2086 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/engines/gfx/lite_m_gfx_engine.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/engines/gfx/lite_m_gfx_engine.h @@ -102,7 +102,7 @@ public: const Rect& subRect, const BlendOption& blendOption) override; - void Blur(BufferInfo& dst, uint16_t radius) override; + void Blur(BufferInfo& dst, float radius) override; void Fill(BufferInfo& dst, const Rect& fillArea, @@ -129,7 +129,7 @@ public: VGUStrokeAttr* strokeAttr, VGUFillAttr* fillAttr, VGUMatrix3* matrix); void ClipImgByPath(ImageInfo& dstInfo, ImageInfo& srcInfo, uintptr_t path, Rect* srcImgArea, - const Matrix4* pathMatrix, const Matrix4* imgMatrix); + const Matrix4* pathMatrix, const Matrix4* imgMatrix, bool isAlphaFF = false); bool Convert2VGUFormat(const ColorMode& colorMode, VGUPixelFormat& dstColorFmt) const; void AddHardwareLayer(IHardwareView* view) @@ -170,7 +170,10 @@ private: ReleasePath(); } - void DrawRoundRect(BufferInfo& dst, const Rect& fillArea, const Style& style, const Rect& dirtyRect); + void DrawRectWithRound(BufferInfo& dst, const Rect& rect, const Style& style, const Rect& dirtyRect, + OpacityType opacity); + void DrawRectWithoutRound(BufferInfo& dst, const Rect& rect, const Style& style, const Rect& dirtyRect, + OpacityType opacity); List pathList_ = {}; void ReleasePath(); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/imgdecode/hw_jpeg_decoder.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/imgdecode/hw_jpeg_decoder.cpp index 322b4cae0..3a2af9a06 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/imgdecode/hw_jpeg_decoder.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/imgdecode/hw_jpeg_decoder.cpp @@ -80,7 +80,7 @@ RetCode HWJpegDecoder::CreateDecoder(ImgResDsc& dsc) src.vir_buf = reinterpret_cast(filedata_); src.phy_buf = reinterpret_cast(src.vir_buf); src.size = g_fileLen; - dinfo_.scale = JPEG_SCALE_1; + dinfo_.scale = JPEG_SCALE_1; // suggest to customize the scaling ratio based on the file name. dinfo_.output_yuv420sp = true; int ret = uapi_jpeg_decomress_create(&dinfo_, &src, true); @@ -98,9 +98,10 @@ RetCode HWJpegDecoder::GetHeader(ImgResDsc& dsc) return RetCode::FAIL; } - dsc.imgInfo.header.width = dinfo_.image_width; - dsc.imgInfo.header.height = dinfo_.image_height; + dsc.imgInfo.header.width = dinfo_.output_width; + dsc.imgInfo.header.height = dinfo_.output_height; dsc.imgInfo.header.colorMode = RGB888; + dsc.imgInfo.header.compressMode = 0; return RetCode::OK; } @@ -150,8 +151,8 @@ RetCode HWJpegDecoder::ConvertYUVToRGB(ImgResDsc& dsc, jpeg_dst_struct* dst) uint8_t* uvStart = reinterpret_cast(dst->vir_buf) + dst->uv_offset; uint32_t uvLength = dinfo_.output.size[1]; - uint16_t imgWidth = dinfo_.image_width; - uint16_t imgHeight = dinfo_.image_height; + uint16_t imgWidth = dinfo_.output_width; + uint16_t imgHeight = dinfo_.output_height; uint16_t alignedImgWidth = ALIGN_BYTE(imgWidth, BYTE_ALIGNMENT); uint32_t rgbSize = alignedImgWidth * imgHeight * 3; // 3: bpp of RGB888 ImageInfo tempImgInfo = {0}; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/hals/gralloc_engines.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/hals/gralloc_engines.cpp index aca7b257a..e07764dbd 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/hals/gralloc_engines.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/hals/gralloc_engines.cpp @@ -83,7 +83,8 @@ bool GrallocEngines::AllocBuffer(const AllocInfo& info, GrallocBuffer& buffer) #endif #if ENABLE_MEMORY_CHECK if (isMonitorEnabled_) { - printf("[Alloc] addr = %p, size = %d, usage = %llu\n", bufferHandle->virAddr, bufferHandle->size, bufferHandle->usage); + printf("[Alloc] addr = %p, size = %d, usage = %llu\n", + bufferHandle->virAddr, bufferHandle->size, bufferHandle->usage); } #endif if ((info.usage & HBM_USE_MEM_YUV) == HBM_USE_MEM_YUV) { 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 9725426b4..e36876618 100644 --- 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 @@ -138,7 +138,12 @@ bool MemCheck::MemAdd(int size, uintptr_t address) } lock_.Unlock(); #ifdef __LITEOS__ +#ifdef LOSCFG_BACKTRACE + GRAPHIC_LOGE("Mem leak! Check backtrace!"); + LOS_BackTrace(); +#else LOS_Panic("mem leak here!\n"); +#endif #endif } diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow2.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow2.cpp index a4d3de698..0d9c09e32 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow2.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow2.cpp @@ -25,22 +25,18 @@ namespace OHOS { namespace { -struct FaceInfo { - const char* name; - const char* path; -} ; - static constexpr uint8_t COVERFLOW_MAX_PAGE_NUM = 6; -static FaceInfo g_faceInfo[COVERFLOW_MAX_PAGE_NUM] = { - {"1 rainbow", RES_PATH"/rainbow.bin"}, - {"2 kaleidoscope", RES_PATH"/kaleidoscope.bin"}, - {"3 planet", RES_PATH"/planet.bin"}, - {"4 rainbow", RES_PATH"/rainbow.bin"}, - {"5 kaleidoscope", RES_PATH"/kaleidoscope.bin"}, - {"6 planet", RES_PATH"/planet.bin"} +const char* g_faceInfo[COVERFLOW_MAX_PAGE_NUM] = { + RES_PATH"/rainbow.bin", + RES_PATH"/kaleidoscope.bin", + RES_PATH"/planet.bin", + RES_PATH"/rainbow.bin", + RES_PATH"/kaleidoscope.bin", + RES_PATH"/planet.bin" }; -const char* addImgPath = RES_PATH"/add.bin"; -const char* subImgPath = RES_PATH"/sub.bin"; + +static const char* ADD_IMG_PATH = RES_PATH"/add.bin"; +static const char* SUB_IMG_PATH = RES_PATH"/sub.bin"; static constexpr uint8_t PAGE_MARGIN = 20; static constexpr uint16_t PAGE_WIDTH = 250; static constexpr uint16_t PAGE_HEIGHT = 250; @@ -111,14 +107,14 @@ void UITestCoverflow2::UITestCoverflow2001() UIImageView* image = new UIImageView(); image->Resize(IMAGE_WIDTH, IMAGE_HEIGHT); page->Add(image); - ImageInfo* src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(g_faceInfo[i].path)); + ImageInfo* src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(g_faceInfo[i])); image->SetSrc(src); image->LayoutCenterOfParent(); UIImageView* imageSub = new UIImageView(); imageSub->SetPosition(200, 0, 50, 50); // 200: x position 50: width and height page->Add(imageSub); - src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(subImgPath)); + src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(SUB_IMG_PATH)); imageSub->SetSrc(src); imageSub->SetTouchable(true); imageSub->SetOnClickListener(this); @@ -131,7 +127,7 @@ void UITestCoverflow2::UITestCoverflow2001() void UITestCoverflow2::CreateAddButton() { UITransformGroup* page = new UITransformGroup(); - page->SetPosition(0, 100, PAGE_WIDTH, PAGE_HEIGHT); + page->SetPosition(0, 100, PAGE_WIDTH, PAGE_HEIGHT); // 100: y if (addImage_ == nullptr) { addImage_ = new UIImageView(); @@ -145,7 +141,7 @@ void UITestCoverflow2::CreateAddButton() page->Add(addImage_); addImage_->LayoutCenterOfParent(); - ImageInfo* src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(addImgPath)); + ImageInfo* src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(ADD_IMG_PATH)); addImage_->SetSrc(src); coverflow_->Add(page); } @@ -158,8 +154,7 @@ void UITestCoverflow2::CreateTitleLabel() label_->SetPosition(127, 50, 200, 50); // 127 50 200 50: label position label_->SetTextColor(Color::White()); label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - lastIndex_ = coverflow_->GetCurrentPage(); - label_->SetText(g_faceInfo[lastIndex_].name); + label_->SetText("[ITEM_NAME]"); label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); container_->Add(label_); } @@ -168,7 +163,7 @@ bool UITestCoverflow2::OnClick(UIView& view, const ClickEvent& event) { if (&view == addImage_) { UITransformGroup* page = new UITransformGroup(); - page->SetPosition(0, 100, PAGE_WIDTH, PAGE_HEIGHT); + page->SetPosition(0, 100, PAGE_WIDTH, PAGE_HEIGHT); // 100: y UIImageView* image = new UIImageView(); image->Resize(IMAGE_WIDTH, IMAGE_HEIGHT); @@ -180,7 +175,7 @@ bool UITestCoverflow2::OnClick(UIView& view, const ClickEvent& event) UIImageView* imageSub = new UIImageView(); imageSub->SetPosition(200, 0, 50, 50); // 200: x position 50: width and height page->Add(imageSub); - src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(subImgPath)); + src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(SUB_IMG_PATH)); imageSub->SetSrc(src); imageSub->SetTouchable(true); imageSub->SetOnClickListener(this); @@ -218,9 +213,6 @@ bool UITestCoverflow2::OnScroll(uint16_t distance) } if (newCenterIndex != lastIndex_ && newCenterIndex < COVERFLOW_MAX_PAGE_NUM) { lastIndex_ = newCenterIndex; - label_->SetText(g_faceInfo[newCenterIndex].name); - } else if (newCenterIndex >= COVERFLOW_MAX_PAGE_NUM) { - label_->SetText(""); } Rect curViewRect = coverflow_->GetViewByIndex(lastIndex_)->GetOrigRect(); diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.cpp index 32b202be3..c95805f19 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.cpp @@ -211,6 +211,22 @@ void UITestCross::VideoPage::CoverEnd(bool isCovered) } } +void UITestCross::VideoPage::OnCovered() +{ + videoPlay_->PauseVideoPlay(); + animator_->Stop(); +} + +void UITestCross::VideoPage::OnUncovered() +{ + if (videoPlay_->isPause_) { + videoPlay_->ResumeVideoPlay(); + } else if (!videoPlay_->isPlayed_) { + videoPlay_->StartVideoPlay(); + } + animator_->Start(); +} + void UITestCross::VideoPage::StartVideo(void) { if (videoPlay_ != nullptr && animator_ != nullptr) { @@ -251,6 +267,8 @@ void UITestCross::SetUp() video_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); video_->PageInit(); video_->StartVideo(); + video_->SetTouchable(true); + video_->SetOnClickListener(this); #endif SetUpPage(&card1_, CROSS_CAT); SetUpPage(&card2_, CROSS_DOVE); @@ -278,6 +296,8 @@ void UITestCross::SetUp() down_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); down_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); down_->SetViewId("messageView"); + down_->SetTouchable(true); + down_->SetOnClickListener(this); UILabel *msg = new UILabel(); msg->SetPosition(177, 212, 100, 30); // 177, 212, 100, 30: Left, right, width, height. msg->SetText("无消息"); @@ -335,4 +355,27 @@ const UIView* UITestCross::GetTestView() { return container_; } + +bool UITestCross::OnClick(UIView& view, const ClickEvent& event) +{ + if (&view == down_) { + static uint16_t pageIndex = 0; + container_->SetVerCurrentPage(pageIndex); + printf("SetVerCurrentPage: %d", pageIndex); + pageIndex++; + if (pageIndex > 1) { + pageIndex = 0; + } + } else if (&view == video_) { + static uint16_t pageIndexFromCenter = 0; + container_->SetVerCurrentPage(pageIndexFromCenter); + printf("SetVerCurrentPage: %d", pageIndexFromCenter); + if (pageIndexFromCenter == 0) { + pageIndexFromCenter = 2; // 2: index + } else { + pageIndexFromCenter = 0; + } + } + return true; +} } diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.h index 1f07b3844..d8535a399 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.h @@ -21,7 +21,7 @@ #endif namespace OHOS { -class UITestCross : public UITest { +class UITestCross : public UITest, UIView::OnClickListener { public: class VideoAnimatorCallback : public AnimatorCallback { public: @@ -44,6 +44,8 @@ public: void ScrollEnd(bool isActive) override; void CoverBegin(bool isCovered) override; void CoverEnd(bool isCovered) override; + void OnCovered() override; + void OnUncovered() override; void PageInit(void); void StartVideo(void); @@ -62,6 +64,7 @@ public: void SetUp() override; void TearDown() override; const UIView* GetTestView() override; + bool OnClick(UIView& view, const ClickEvent& event) override; private: UICrossView* container_ = nullptr; diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.cpp index bf56cbea3..83db4663c 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.cpp @@ -24,6 +24,34 @@ const static int16_t X_300 = 300; const static int16_t WIDTH_100 = 100; const static int16_t HEIGHT_50 = 50; +void SectorAnimatorCallback::Callback(UIView *view) +{ + UICanvasExt* canvas = dynamic_cast(view); + if (canvas == nullptr) { + GRAPHIC_LOGE("callback view is not UICanvasExt"); + return; + } + canvas->Clear(); + sectorAngle_ += angleStep_; + sectorRange_ += rangeStep_; + if (FloatMore(sectorRange_, CIRCLE_IN_DEGREE)) { + sectorRange_ = 1; + } + if (FloatMore(sectorAngle_, 3600.f)) { // 3600.f: to avoid float overflow + sectorAngle_ = -3600.0f; // 3600.f: to avoid float overflow + } + // 300: x coordinates, 250: y coordinates, 10 ahead degree to avoid boundary problem + SweepGradient sweep = {200, 250, static_cast(sectorAngle_ - 10)}; + PaintExt paint; + ColorStop stops[2] = {{0, 0x00FFFF00}, {1, 0xFFFFFF00}}; + paint.SetStyle(Paint::PaintStyle::FILL_STYLE); + paint.SetSweepGradient(sweep, stops, 2); // 2: sweep stops count + paint.SetAntialiased(true); + + // 300, 250, 130, sector parameters: x , y, radius + canvas->DrawSector({200, 250}, 130, sectorAngle_, sectorAngle_ + sectorRange_, paint); +} + void UITestCanvasExt::SetUp() { if (container_ == nullptr) { @@ -40,13 +68,25 @@ void UITestCanvasExt::SetUp() canvas_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); container_->Add(canvas_); - SetUpBtn(add123Btn_, "Add 123", X_300, 0); // 0: Y coordinate - SetUpBtn(addSquareBtn_, "Add Square", X_300, 60); // 60: Y coordinate + SetUpBtn(addSquareBtn_, "Add Square", X_300, 0); // 0: Y coordinate + SetUpBtn(addSectorBtn_, "Add Sector", X_300, 60); // 60: Y coordinate SetUpBtn(clearBtn_, "Clear", X_300, 120); // 120: Y coordinate SetUpBtn(transBtn_, "Y: +150", X_300, 180); // 180: Y coordinate SetUpBtn(scaleBtn_, "Scale 0.5", X_300, 240); // 240: Y coordinate SetUpBtn(rotateBtn_, "Rotate 90", X_300, 300); // 300: Y coordinate SetUpBtn(matrixBtn_, "Matrix", X_300, 360); // 360: Y coordinate + sectorCallBack_ = new SectorAnimatorCallback(); + if (sectorCallBack_ == nullptr) { + GRAPHIC_LOGE("CallBack new fail"); + return; + } + sectorAnimator_ = new Animator(sectorCallBack_, canvas_, 0, true); + if (sectorAnimator_ == nullptr) { + delete sectorCallBack_; + sectorCallBack_ = nullptr; + GRAPHIC_LOGE("Animator new fail"); + return; + } } void UITestCanvasExt::SetUpBtn(UILabelButton*& btn, const char* text, int16_t x, int16_t y) @@ -68,9 +108,17 @@ void UITestCanvasExt::SetUpBtn(UILabelButton*& btn, const char* text, int16_t x, void UITestCanvasExt::TearDown() { DeleteChildren(container_); + if (sectorCallBack_ != nullptr) { + delete sectorCallBack_; + sectorCallBack_ = nullptr; + } + if (sectorAnimator_ != nullptr) { + delete sectorAnimator_; + sectorAnimator_ = nullptr; + } container_ = nullptr; canvas_ = nullptr; - add123Btn_ = nullptr; + addSectorBtn_ = nullptr; addSquareBtn_ = nullptr; clearBtn_ = nullptr; transBtn_ = nullptr; @@ -117,8 +165,10 @@ void UITestCanvasExt::DrawSquare(UICanvasExt* canvas) bool UITestCanvasExt::OnClick(UIView& view, const ClickEvent& event) { if (&view == addSquareBtn_) { + sectorAnimator_->Stop(); DrawSquare(canvas_); } else if (&view == clearBtn_) { + sectorAnimator_->Stop(); canvas_->Clear(); } else if (&view == transBtn_) { canvas_->Translate({0, 100}); // 100: y offset @@ -131,8 +181,8 @@ bool UITestCanvasExt::OnClick(UIView& view, const ClickEvent& event) Matrix3 mat(1, 0, 0, 0, 1, 0, 0, 50, 1); // 50: Y trans by 50 canvas_->SetMatrix(mat, matrixIndex_); } - } else if (&view == add123Btn_) { - Draw123(canvas_); + } else if (&view == addSectorBtn_) { + DrawSector(canvas_); } return true; } @@ -292,6 +342,13 @@ void UITestCanvasExt::DrawArc(UICanvasExt* canvas) canvas->DrawArc({cx, cy}, 40, 540, 630, paint); // 40, 540, 630: radius, startAngle, endAngle } +void UITestCanvasExt::DrawSector(UICanvasExt* canvas) +{ + if (sectorAnimator_ != nullptr) { + sectorAnimator_->Start(); + } +} + void UITestCanvasExt::DrawPattern(UICanvasExt* canvas) { PaintExt paint; diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.h index 6d0bccdec..ffe4ca44d 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_draw/ui_test_canvas_ext.h @@ -24,6 +24,18 @@ #include "common/image_cache_manager.h" namespace OHOS { #if ENABLE_VGU_ENGINE && CAPABILITY_HWDRAW_PATH +class SectorAnimatorCallback : public AnimatorCallback { +public: + SectorAnimatorCallback() {} + ~SectorAnimatorCallback() override {} + void Callback(UIView *view) override; +private: + float sectorAngle_ = -3600.0f; + float sectorRange_ = 0.0f; + float angleStep_ = 4.0f; + float rangeStep_ = 4.0f; +}; + class UITestCanvasExt : public UITest, public UIView::OnClickListener { public: UITestCanvasExt() {} @@ -43,18 +55,21 @@ private: void DrawRect(UICanvasExt* canvas); void DrawLine(UICanvasExt* canvas); void DrawArc(UICanvasExt* canvas); + void DrawSector(UICanvasExt* canvas); void SetUpBtn(UILabelButton*& btn, const char* text, int16_t x, int16_t y); void DrawPattern(UICanvasExt* canvas); int16_t matrixIndex_ = -1; UICanvasExt* canvas_ = nullptr; UILabelButton* addSquareBtn_ = nullptr; - UILabelButton* add123Btn_ = nullptr; + UILabelButton* addSectorBtn_ = nullptr; UILabelButton* clearBtn_ = nullptr; UILabelButton* transBtn_ = nullptr; UILabelButton* scaleBtn_ = nullptr; UILabelButton* rotateBtn_ = nullptr; UILabelButton* matrixBtn_ = nullptr; UIScrollView* container_ = nullptr; + SectorAnimatorCallback *sectorCallBack_ = nullptr; + Animator *sectorAnimator_ = nullptr; ImageInfo* img_ = nullptr; }; #endif diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_font/ui_test_multi_font.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_font/ui_test_multi_font.cpp index 3d18ce816..930546466 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_font/ui_test_multi_font.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_font/ui_test_multi_font.cpp @@ -117,14 +117,16 @@ void UITestMultiFont::TestArabicAndChinese() UILabelExt* label = new UILabelExt(); label->SetPosition(labelX_, labelY_, WIDTH, HEIGHT); label->SetFont("HarmonyOS_Sans_Naskh_Arabic_Light.ttf", DEFAULT_VECTOR_FONT_SIZE); - label->SetText("中文和阿拉伯语混排。الأسانسير، علشان القطط ماتاكلش منها. وننساها، ونعود الى أوراقنا موصدين الباب بإحكام."); + label->SetText("中文和阿拉伯语混排。" + "الأسانسير، علشان القطط ماتاكلش منها. وننساها، ونعود الى أوراقنا موصدين الباب بإحكام."); container_->Add(label); labelY_ += HEIGHT + GAP_50; UILabelExt* label1 = new UILabelExt(); label1->SetPosition(labelX_, labelY_, WIDTH, HEIGHT); label1->SetFont("HarmonyOS_Sans_Naskh_Arabic_Light.ttf", DEFAULT_VECTOR_FONT_SIZE); - label1->SetText("中文和阿拉伯语混排。الأسانسير، علشان القطط ماتاكلش منها. وننساها، ونعود الى أوراقنا موصدين الباب بإحكام."); + label1->SetText("中文和阿拉伯语混排。" + "الأسانسير، علشان القطط ماتاكلش منها. وننساها، ونعود الى أوراقنا موصدين الباب بإحكام."); label1->SetDirect(TEXT_DIRECT_RTL); container_->Add(label1); labelY_ += HEIGHT + GAP_50; @@ -132,7 +134,8 @@ void UITestMultiFont::TestArabicAndChinese() UILabelExt* label2 = new UILabelExt(); label2->SetPosition(labelX_, labelY_, WIDTH, HEIGHT); label2->SetFont("HarmonyOS_Sans_Naskh_Arabic_Light.ttf", DEFAULT_VECTOR_FONT_SIZE); - label2->SetText("1. تشبع الأكسجين في الدم (SpO2) هو النسبة المئوية للهيموغلوبين المؤكسد (HbO2) في الدم، وهو عامل فسيولوجي مهم للحفاظ على وظائف الجسم الطبيعية."); + label2->SetText("1. تشبع الأكسجين في الدم (SpO2) هو النسبة المئوية للهيموغلوبين المؤكسد (HbO2)" + " في الدم، وهو عامل فسيولوجي مهم للحفاظ على وظائف الجسم الطبيعية."); label2->SetDirect(TEXT_DIRECT_RTL); container_->Add(label2); labelY_ += HEIGHT + GAP_50; @@ -140,7 +143,8 @@ void UITestMultiFont::TestArabicAndChinese() UILabelExt* label3 = new UILabelExt(); label3->SetPosition(labelX_, labelY_, WIDTH, HEIGHT); label3->SetFont("HarmonyOS_Sans_Naskh_Arabic_Light.ttf", DEFAULT_VECTOR_FONT_SIZE); - label3->SetText("ABCتشبع الأكسجين في الدم (SpO2) هو النسبة المئوية للهيموغلوبين المؤكسد (HbO2) في الدم، وهو عامل فسيولوجي مهم للحفاظ على وظائف الجسم الطبيعية."); + label3->SetText("ABCتشبع الأكسجين في الدم (SpO2) هو النسبة المئوية للهيموغلوبين المؤكسد (HbO2)" + " في الدم، وهو عامل فسيولوجي مهم للحفاظ على وظائف الجسم الطبيعية."); label3->SetDirect(TEXT_DIRECT_RTL); container_->Add(label3); labelY_ += HEIGHT + GAP_50; diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp index 3f528d96a..f820733d8 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp @@ -13,7 +13,7 @@ void UITestKaleidoscope::KaleidoscopeAnimator::Callback(UIView* view) return; } - kaleidoscopeUtils_->Rotate(0.1f); // 0.1: rotate by 0.1 + kaleidoscopeUtils_->Rotate(0.02f); // 0.02: rotate by 0.02 view->Invalidate(); } @@ -36,7 +36,7 @@ void UITestKaleidoscope::SetUp() container_->Add(kaleidoscope_); kaleidoscope_->RequestFocus(); kaleidoscope_->SetRotateEventFactor(0.2f); // 0.2: rotate event factor - kaleidoscope_->SetRotateAnimatorValue(0.1f); // 0.1: rotate animator value + kaleidoscope_->SetRotateAnimatorValue(0.02f); // 0.02: rotate animator value kaleidoscope_->StartRotateAnimator(); return; } diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.cpp index 68de67d6c..f2b68b624 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.cpp @@ -156,7 +156,6 @@ void UITestListExt::UIListScrollTestFPS() } list_->SetPosition(0, 0, LIST_WIDTH, LIST_HEIGHT); list_->SetAdapter(adapter_); - list_->SetScrollStateListener(this); list_->SetThrowDrag(true); list_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); list_->SetMaxScrollDistance(1000); // 1000: max scroll distance diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.h index 9ff2ec341..c80ea8a1f 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_ext/ui_test_list_ext.h @@ -24,7 +24,7 @@ #include "gfx_utils/sys_info.h" namespace OHOS { -class UITestListExt : public UITest, UIView::OnClickListener, ListScrollListener { +class UITestListExt : public UITest { public: UITestListExt() : data_(nullptr), animator_(nullptr), list_(nullptr), adapter_(nullptr) {} ~UITestListExt() override {} diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.cpp index d9c9e5872..9d8a4b1cb 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.cpp @@ -156,7 +156,6 @@ void UITestListFPS::UIListScrollTestFPS() } list_->SetPosition(0, 0, LIST_WIDTH, LIST_HEIGHT); list_->SetAdapter(adapter_); - list_->SetScrollStateListener(this); list_->SetThrowDrag(true); list_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); list_->SetMaxScrollDistance(1000); // 1000: max scroll distance diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.h index 0a64eb564..0512595e8 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_list_fps/ui_test_list_fps.h @@ -24,7 +24,7 @@ #include "gfx_utils/sys_info.h" namespace OHOS { -class UITestListFPS : public UITest, UIView::OnClickListener, ListScrollListener { +class UITestListFPS : public UITest { public: UITestListFPS() : animator_(nullptr), list_(nullptr), data_(nullptr), adapter_(nullptr) {} ~UITestListFPS() override {} diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.cpp index 5e3b93a1e..3b84dad27 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.cpp @@ -17,6 +17,11 @@ #include "animator/easing_equation.h" namespace OHOS { +const int8_t TEXT_ARRAY_LEN = 8; +const float MIN_BLUR_VALUE = 0.0f; +const float MAX_BLUR_VALUE = 32.0f; +const float BLUR_MODIFY_STEP = 0.4f; + void UITestMessage::SetUp() { container_ = new UIViewGroup(); @@ -28,29 +33,55 @@ void UITestMessage::SetUp() img->SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); container_->Add(img); - start_ = new UILabelButton(); - start_->SetPosition(180, 360, 120, 60); // 180: x, 360: y, 120: width, 60: height - start_->SetText("Start"); - start_->SetOnClickListener(this); - container_->Add(start_); + msgLabel_ = new UILabel(); + msgLabel_->SetPosition(100, 80, 250, 70); // 100, 80, 250, 70: Left, right, width, height. + msgLabel_->SetText("Message: comes..."); + msgLabel_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff505050); + msgLabel_->SetStyle(STYLE_TEXT_COLOR, Color::White().full); + msgLabel_->SetStyle(STYLE_BORDER_RADIUS, 20); // 20: Radius for label boarder. + msgLabel_->SetStyle(STYLE_BACKGROUND_OPA, 150); // 150: Opacity for background. + msgLabel_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35: Font size. + msgLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + container_->Add(msgLabel_); + + add_ = new UILabelButton(); + add_->SetPosition(70, 300, 100, 40); // 70: x, 300: y, 100: width, 40: height + add_->SetText("Add blur"); + add_->SetOnClickListener(this); + container_->Add(add_); + + reduce_ = new UILabelButton(); + reduce_->SetPosition(194, 300, 100, 40); // 194: x, 300: y, 100: width, 40: height + reduce_->SetText("Reduce blur"); + reduce_->SetOnClickListener(this); + container_->Add(reduce_); + + clear_ = new UILabelButton(); + clear_->SetPosition(318, 300, 100, 40); // 318: x, 300: y, 100: width, 40: height + clear_->SetText("Clear blur"); + clear_->SetOnClickListener(this); + container_->Add(clear_); - label_ = new UILabel(); - label_->SetPosition(100, 80, 250, 70); // 100, 80, 250, 70: Left, right, width, height. - label_->SetText("Message: comes..."); - label_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff505050); - label_->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - label_->SetStyle(STYLE_BORDER_RADIUS, 20); // 20: Radius for label boarder. - label_->SetStyle(STYLE_BACKGROUND_OPA, 150); // 150: Opacity for background. - label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35: Font size. - label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - container_->Add(label_); + valueLabel_ = new UILabel(); + valueLabel_->SetPosition(194, 360, 100, 40); // 194, 360, 100, 40: Left, right, width, height. + valueLabel_->SetText("0.00"); + valueLabel_->SetStyle(STYLE_TEXT_COLOR, Color::Red().full); + valueLabel_->SetStyle(STYLE_BORDER_OPA, 0); // 20: Radius for label boarder. + valueLabel_->SetStyle(STYLE_BACKGROUND_OPA, 0); // 150: Opacity for background. + valueLabel_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30: Font size. + valueLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + container_->Add(valueLabel_); } void UITestMessage::TearDown() { - label_->ClearBackgroundBlur(); - DeleteChildren(container_); - container_ = nullptr; + msgLabel_->ClearBackgroundBlur(); + UIViewGroup::RemoveAndDeleteAllRecursively(container_); + msgLabel_ = nullptr; + add_ = nullptr; + reduce_ = nullptr; + clear_ = nullptr; + valueLabel_ = nullptr; } const UIView* UITestMessage::GetTestView() @@ -60,13 +91,22 @@ const UIView* UITestMessage::GetTestView() bool UITestMessage::OnClick(UIView& view, const ClickEvent& event) { - if (!blur_) { - label_->SetBackgroundBlur(10); // 10: blurRadius - } else { - label_->ClearBackgroundBlur(); + if (&view == add_) { + blurVaule_ += BLUR_MODIFY_STEP; + } else if (&view == reduce_) { + blurVaule_ -= BLUR_MODIFY_STEP; + } else if (&view == clear_) { + blurVaule_ = MIN_BLUR_VALUE; } - blur_ = !blur_; - + if (FloatMore(blurVaule_, MAX_BLUR_VALUE)) { + blurVaule_ = MAX_BLUR_VALUE; + } else if (FloatLess(blurVaule_, MIN_BLUR_VALUE)) { + blurVaule_ = MIN_BLUR_VALUE; + } + msgLabel_->SetBackgroundBlur(blurVaule_); + char blurText[TEXT_ARRAY_LEN] = {0}; + snprintf_s(blurText, TEXT_ARRAY_LEN, 4, "%4.1f", blurVaule_); // 4, size of format string + valueLabel_->SetText(blurText); return true; } -} +} \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.h index c85901bb3..0bf3180df 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_message/ui_test_message.h @@ -35,9 +35,12 @@ public: private: UIViewGroup* container_ = nullptr; - UILabel* label_ = nullptr; - UILabelButton* start_ = nullptr; - bool blur_ = false; + UILabel* msgLabel_ = nullptr; + UILabelButton* add_ = nullptr; + UILabelButton* reduce_ = nullptr; + UILabelButton* clear_ = nullptr; + UILabel* valueLabel_ = nullptr; + float blurVaule_ = 0.0f; }; } -#endif +#endif \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.cpp index 12c280aad..3ee280d0f 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.cpp @@ -39,6 +39,27 @@ void UITestRollerView::CreateButton(UILabelButton*& button, const char* text, in container_->Add(button); } +bool UITestRollerView::ChildStateListener::StateChange(UIView* view, float angle) +{ + if (view == nullptr) { + return true; + } + UIViewGroup* group = dynamic_cast(view); + UIImageView* head = dynamic_cast(group->GetChildrenHead()); + UIImageView* tail = dynamic_cast(group->GetChildrenTail()); + if (FloatMore(angle, 90.0f) && FloatLess(angle, 270.0f)) { // 90 270: rotate range + head->SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE / 2); // 2: half of opa + if (roller_->IsShowMirrorMode()) { + tail->SetStyle(STYLE_IMAGE_OPA, 50); // 50: Transparency Value + } + } else { + head->SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); + if (roller_->IsShowMirrorMode()) { + tail->SetStyle(STYLE_IMAGE_OPA, 100); // 100: Transparency Value + } + } + return true; +} void UITestRollerView::CreateNoMirrorRollerView() { noMirrorRollerView_ = new UIRollerView(false); @@ -71,6 +92,11 @@ void UITestRollerView::SetUp() rollerView_->SetItemSize(150, 150); // 150: item size rollerView_->SetThrowDrag(true); rollerView_->SetItemPadding(80); // 80: item padding + if (stateChangeListener_ == nullptr) { + stateChangeListener_ = new ChildStateListener(); + stateChangeListener_->SetRollerView(rollerView_); + rollerView_->SetChildStateListener(stateChangeListener_); + } container_->Add(rollerView_); curRollerView_ = rollerView_; for (uint8_t i = 0; i < ITEM_CNT; i++) { @@ -105,6 +131,7 @@ void UITestRollerView::HideOrShowBtn() offMirrorBtn_->SetVisible(isVisible); isBtnVisible_ = isVisible; } + void UITestRollerView::OnModeChange(UIRollerView* view, RollerViewMode targetMode) { printf("RollerView Change Mode to %d!\n", targetMode); @@ -163,6 +190,11 @@ void UITestRollerView::TearDown() } else { container_->Remove(noMirrorRollerView_); } + + if (stateChangeListener_ != nullptr) { + delete stateChangeListener_; + stateChangeListener_ = nullptr; + } curRollerView_ = nullptr; delete rollerView_; delete noMirrorRollerView_; diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.h index 480ae6039..8a21f1465 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_roller_view/ui_test_roller_view.h @@ -20,7 +20,20 @@ public: const UIView* GetTestView() override; bool OnClick(UIView& view, const ClickEvent& event) override; void OnModeChange(UIRollerView* view, RollerViewMode targetMode) override; + private: + class ChildStateListener : public UIRollerView::OnChildStateListener { + public: + void SetRollerView(UIRollerView* roller) + { + roller_ = roller; + } + + bool StateChange(UIView* view, float angle) override; + private: + UIRollerView* roller_ = nullptr; + }; + void CreateButton(UILabelButton*& button, const char* text, int16_t x, int16_t y); void HideOrShowBtn(); void CreateNoMirrorRollerView(); @@ -35,6 +48,7 @@ private: UILabelButton* switchAnimBtn_ = nullptr; UILabelButton* switchBtn_ = nullptr; UILabelButton* offMirrorBtn_ = nullptr; + ChildStateListener* stateChangeListener_ = nullptr; bool isBtnVisible_ = false; }; } diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp index bca76dcb2..3d8a15f54 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp @@ -132,7 +132,7 @@ void UITestScaleList::UIScaleListTest() list_->SetDragACCLevel(5); // 5: drag acceleration list_->SetYScrollBarVisible(true); - list_->EnableAutoAlign(true); + list_->EnableAutoAlign(false); list_->SetSelectPosition(LIST_HEIGHT / 2); // 2: divisor list_->EnableCrossDragBack(false); list_->SetElastic(true); @@ -140,6 +140,8 @@ void UITestScaleList::UIScaleListTest() list_->SetItemSpace(30); // 30: item space list_->SetAutoAlignTime(300); // 300: align time list_->SetScrollBlankSize(LIST_HEIGHT / 2); // 2: divisor + list_->SetScrollBlankSize(LIST_HEIGHT / 2 - ITEM_HEIGHT / 2, UIAbstractScroll::Direction::BOTTOM); + list_->SetReboundSize(0, UIAbstractScroll::Direction::BOTTOM); list_->SetDragFunc(EasingEquation::QuadEaseOut); } } // namespace OHOS \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_waterfall_list/ui_test_waterfall_list.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_waterfall_list/ui_test_waterfall_list.cpp index ec78616b7..372ac4a79 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_waterfall_list/ui_test_waterfall_list.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_waterfall_list/ui_test_waterfall_list.cpp @@ -139,7 +139,11 @@ void UITestWaterfallList::SetUp() waterfallList_->SetImageDistance(imgDistance_); waterfallList_->SetImageSizeInCenter(imgSize_); waterfallList_->SetScrollBlankSize(0); - waterfallList_->SetReboundSize(imgDistance_ * Sin(60)); // 60, degree + uint16_t layoutHeight = static_cast(imgDistance_ * Sin(60)); // 60: degree, row's layout height + waterfallList_->SetReboundSize(layoutHeight); + waterfallList_->SetScrollBlankSize(layoutHeight, UIAbstractScroll::Direction::TOP); + waterfallList_->SetScrollBlankSize(Screen::GetInstance().GetHeight() / 2 - layoutHeight, // 2: half + UIAbstractScroll::Direction::BOTTOM); waterfallList_->SetThrowDrag(true); waterfallList_->LayoutChildren(true); waterfallList_->SetRotateFactor(10); // 10, empirical coefficient diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.cpp index d4c45c791..dbd4e2e9f 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.cpp @@ -83,6 +83,7 @@ void AnimatorManager::AnimatorTask() ListNode* pos = list_.Begin(); Animator* animator = nullptr; + activeNum_ = 0; while (pos != list_.End()) { animator = pos->data_; if (animator == nullptr) { @@ -91,9 +92,20 @@ void AnimatorManager::AnimatorTask() continue; } if (animator->GetState() == Animator::START) { + activeNum_++; animator->Run(); } pos = pos->next_; } } + +uint16_t AnimatorManager::GetTotalAnimatorNum() +{ + return list_.Size(); +} + +uint16_t AnimatorManager::GetActiveAnimatorNum() +{ + return activeNum_; +} } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.h b/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.h index d60581763..3db8503ba 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.h +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/animator/animator_manager.h @@ -98,6 +98,16 @@ public: */ bool IsActive(); + /** + * @brief Get total number of animators. + */ + uint16_t GetTotalAnimatorNum(); + + /** + * @brief Get number of active animators which was recorded by AnimatorTask(). + */ + uint16_t GetActiveAnimatorNum(); + protected: List list_; AnimatorManager() {} @@ -106,6 +116,7 @@ protected: AnimatorManager& operator=(const AnimatorManager&) = delete; AnimatorManager(AnimatorManager&&) = delete; AnimatorManager& operator=(AnimatorManager&&) = delete; + uint16_t activeNum_ = 0; }; } // namespace OHOS #endif diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/text.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/text.cpp index 585ad39d7..19d9375bd 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/text.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/text.cpp @@ -240,11 +240,11 @@ void Text::Draw(BufferInfo& gfxDstBuffer, } OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.textOpa_); for (int i = 0; i < lineCount; i++) { - if (pos.y > coords.GetBottom()) { + if (pos.y > mask.GetBottom() || pos.y > coords.GetBottom()) { return; } int16_t nextLine = pos.y + lineHeight; - if (nextLine >= coords.GetTop()) { + if (nextLine >= mask.GetTop() && nextLine >= coords.GetTop()) { pos.x = LineStartPos(coords, textLine_[i].linePixelWidth); LabelLineInfo labelLine{pos, offset, mask, lineHeight, textLine_[i].lineBytes, 0, opa, style, &text_[lineBegin], textLine_[i].lineBytes, diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/text_adapter.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/text_adapter.cpp index 1297bee64..1f9c9ae67 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/text_adapter.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/text_adapter.cpp @@ -59,107 +59,94 @@ void TextAdapter::SetFont(const char* name, uint8_t size) UIView* TextAdapter::GetView(UIView* inView, int16_t index) { - UILabel* newView = GetTextView(inView, index); - if (newView == nullptr) { - return nullptr; - } - newView->SetLineBreakMode(lineBreakMode_); - newView->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - if (width_) { - newView->SetWidth(width_); - } - if (height_) { - newView->SetHeight(height_); - } - newView->SetViewIndex(index); - newView->UIView::SetStyle(style_); - newView->GetHeight(); - if (clickListener_) { - newView->SetOnClickListener(clickListener_); - newView->SetTouchable(true); - } - return newView; -} - -UILabel* TextAdapter::GetTextView(UIView* inView, int16_t index) -{ - switch (dataMode_) { - case DYNAMIC_TEXT_MODE: - return GetDynamicText(inView, index); - case CONTINUOUS_INTEGER_MODE: - return GetIntegerText(inView, index); - default: + if (dataMode_ == DYNAMIC_TEXT_MODE) { + if (dynamicText_.IsEmpty() || (index > dynamicText_.Size() - 1) || (index < 0)) { return nullptr; - } -} - -UILabel* TextAdapter::GetDynamicText(UIView* inView, int16_t index) -{ - if (dynamicText_.IsEmpty() || (index > dynamicText_.Size() - 1) || (index < 0)) { + } + } else if (dataMode_ == CONTINUOUS_INTEGER_MODE) { + if ((index < 0) || ((integerTextEnd_ - integerTextStart_) < index)) { + return nullptr; + } + } else { return nullptr; } - ListNode* node = dynamicText_.Begin(); - for (int16_t i = 0; i < index; i++) { - node = node->next_; + UILabel* label = nullptr; + if (inView == nullptr) { + label = CreateUILabel(); + } else { + label = dynamic_cast(inView); } - UILabel* newView = CreateUILabel(inView); - if (newView != nullptr) { - newView->SetText(node->data_); - if (fontName_ == nullptr) { - newView->SetFontId(fontId_); - } else { - newView->SetFont(fontName_, fontSize_); + + if (label != nullptr) { + if (dataMode_ == DYNAMIC_TEXT_MODE) { + ListNode* node = dynamicText_.Begin(); + for (int16_t i = 0; i < index; i++) { + node = node->next_; + } + label->SetText(node->data_); + } else if (dataMode_ == CONTINUOUS_INTEGER_MODE) { + if (!SetIntegerText(label, index)) { + if (label != nullptr && inView == nullptr) { + delete label; + } + return nullptr; + } } - newView->SetDirect(direct_); + label->ReMeasure(); + label->SetViewIndex(index); } - return newView; + return label; } -UILabel* TextAdapter::GetIntegerText(UIView* inView, int16_t index) +bool TextAdapter::SetIntegerText(UILabel* inView, int16_t index) { - if ((index < 0) || ((integerTextEnd_ - integerTextStart_) < index)) { - return nullptr; - } - UILabel* newView = CreateUILabel(inView); - if (newView != nullptr) { + if (inView != nullptr) { char buf[BUF_LEN] = {0}; if (formatter_ != nullptr) { if (!formatter_->Format(integerTextStart_ + index, buf, BUF_LEN)) { - if (inView == nullptr) { - delete newView; - newView = nullptr; - } - return nullptr; + return false; } } else { if (sprintf_s(buf, sizeof(buf), "%02d", integerTextStart_ + index) < 0) { - if (inView == nullptr) { - delete newView; - newView = nullptr; - } - return nullptr; + return false; } } buf[BUF_LEN - 1] = '\0'; - newView->SetText(buf); - if (fontName_ == nullptr) { - newView->SetFontId(fontId_); - } else { - newView->SetFont(fontName_, fontSize_); - } - newView->SetDirect(direct_); + inView->SetText(buf); } - return newView; + return true; } -UILabel* TextAdapter::CreateUILabel(UIView* inView) +UILabel* TextAdapter::CreateUILabel() { - if (inView == nullptr) { - return new UILabel(); + UILabel* newView = new UILabel(); + if (newView == nullptr) { + return nullptr; } - return static_cast(inView); + + newView->SetLineBreakMode(lineBreakMode_); + newView->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + if (width_) { + newView->SetWidth(width_); + } + if (height_) { + newView->SetHeight(height_); + } + + newView->UIView::SetStyle(style_); + if (clickListener_) { + newView->SetOnClickListener(clickListener_); + newView->SetTouchable(true); + } + if (fontName_ == nullptr) { + newView->SetFontId(fontId_); + } else { + newView->SetFont(fontName_, fontSize_); + } + newView->SetDirect(direct_); + return newView; } void TextAdapter::ClearDynamicText() diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_abstract_scroll.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_abstract_scroll.cpp index b1eecd3ec..c733a71c7 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_abstract_scroll.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_abstract_scroll.cpp @@ -240,7 +240,8 @@ bool UIAbstractScroll::DragThrowAnimator(Point currentPos, uint8_t dragDirection, bool dragBack) { - if (!throwDrag_ && (reboundSize_ == 0)) { + if (!throwDrag_ && (reboundSize_ == 0 && reboundSizeTop_ == 0 && reboundSizeBottom_ == 0 && + reboundSizeLeft_ == 0 && reboundSizeRight_ == 0)) { return false; } int16_t dragDistanceX = 0; @@ -248,7 +249,8 @@ bool UIAbstractScroll::DragThrowAnimator(Point currentPos, if (throwDrag_) { CalculateDragDistance(currentPos, lastPos, dragDirection, dragDistanceX, dragDistanceY); } - if (reboundSize_ != 0) { + if (reboundSize_ != 0 || reboundSizeTop_ != 0 || reboundSizeBottom_ != 0 || + reboundSizeLeft_ != 0 || reboundSizeRight_ != 0) { CalculateReboundDistance(dragDistanceX, dragDistanceY); } @@ -281,19 +283,23 @@ void UIAbstractScroll::CalculateDragDistance(Point currentPos, { if ((direction_ == VERTICAL) || (direction_ == HORIZONTAL_AND_VERTICAL)) { dragDistanceY = (currentPos.y - lastPos.y) * DRAG_DISTANCE_COEFFICIENT; - if (dragDistanceY > 0 || (dragDistanceY == 0 && dragDirection == DragEvent::DIRECTION_TOP_TO_BOTTOM)) { - dragDistanceY += GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; - } else if (dragDistanceY < 0 || (dragDistanceY == 0 && dragDirection == DragEvent::DIRECTION_BOTTOM_TO_TOP)) { - dragDistanceY -= GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; + if (currentPos.y != lastPos.y) { + if (dragDistanceY > 0 || (dragDistanceY == 0 && dragDirection == DragEvent::DIRECTION_TOP_TO_BOTTOM)) { + dragDistanceY += GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; + } else if (dragDistanceY < 0 || (dragDistanceY == 0 && dragDirection == DragEvent::DIRECTION_BOTTOM_TO_TOP)) { + dragDistanceY -= GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; + } } } if ((direction_ == HORIZONTAL) || (direction_ == HORIZONTAL_AND_VERTICAL)) { dragDistanceX = (currentPos.x - lastPos.x) * DRAG_DISTANCE_COEFFICIENT; - if (dragDistanceX > 0 || (dragDistanceX == 0 && dragDirection == DragEvent::DIRECTION_LEFT_TO_RIGHT)) { - dragDistanceX += GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; - } else if (dragDistanceX < 0 || (dragDistanceX == 0 && dragDirection == DragEvent::DIRECTION_RIGHT_TO_LEFT)) { - dragDistanceX -= GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; + if (currentPos.x != lastPos.x) { + if (dragDistanceX > 0 || (dragDistanceX == 0 && dragDirection == DragEvent::DIRECTION_LEFT_TO_RIGHT)) { + dragDistanceX += GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; + } else if (dragDistanceX < 0 || (dragDistanceX == 0 && dragDirection == DragEvent::DIRECTION_RIGHT_TO_LEFT)) { + dragDistanceX -= GetMaxDelta() * GetSwipeACCLevel() / DRAG_ACC_FACTOR; + } } } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_circle_progress.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_circle_progress.cpp index 0d614ce8a..eab2bb89c 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_circle_progress.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_circle_progress.cpp @@ -91,23 +91,19 @@ void UICircleProgress::DrawForegroundGradient(BufferInfo& gfxDstBuffer, const Re const Point& point, const uint16_t& radius, const Vector2& angle) { ArcInfo arcInfo = {point, {0, 0}, radius, angle.x_, angle.y_, nullptr}; - if (cmd_ == nullptr) { - cmd_ = static_cast(AllocBufferForPath(MAX_CMD_NUM * sizeof(uint8_t))); - if (cmd_ == nullptr) { - GRAPHIC_LOGE("AllocBufferForPath failed for cmd.\n"); - return; - } - } - if (data_ == nullptr) { - data_ = static_cast(AllocBufferForPath(MAX_DATA_NUM * sizeof(float))); - if (data_ == nullptr) { - GRAPHIC_LOGE("AllocBufferForPath failed for data.\n"); - GrallocEngines::GetInstance()->FreeBuffer(cmd_); - return; - } - } arcInfo.radius -= foregroundStyle_->lineWidth_ / 2; // 2: half + LiteMGfxEngine::GetInstance()->SyncHwDraw(); + if (data_ != nullptr) { + GrallocEngines::GetInstance()->FreeBuffer(reinterpret_cast(data_)); + data_ = nullptr; + } + if (cmd_ != nullptr) { + GrallocEngines::GetInstance()->FreeBuffer(cmd_); + cmd_ = nullptr; + } + cmdNum_ = 0; + dataNum_ = 0; if (!HWDrawUtils::GetInstance()->ObtainArcPath(arcInfo, cmdNum_, cmd_, dataNum_, data_)) { GRAPHIC_LOGE("ObtainArcPath failed.\n"); return; diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp index ce6eacf80..567e748d0 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp @@ -16,6 +16,7 @@ #include #include "hal_tick.h" #include "components/ui_label.h" +#include "components/root_view.h" #include "font/ui_font.h" #include "gfx_utils/graphic_log.h" #include "themes/theme_manager.h" @@ -62,6 +63,26 @@ public: void Callback(UIView* view) override { + UILabel* label = dynamic_cast(view); + if (label == nullptr) { + return; + } + + // Check setAnimState_ and Pause or Stop animation if neccessary. + if (label->CheckAnimState()) { + return; + } + + // If not intersected with rootview, pause animator. + Rect rect = view->GetRect(); + Rect rootRect = RootView::GetInstance()->GetRect(); + if (label != nullptr && !rect.Intersect(rect, rootRect)) { + if (label->hasAnimator_ && label->animator_.animator->GetState() == Animator::START) { + label->animator_.animator->Pause(); + return; + } + } + switch (animatorMode_) { case UILabel::LINE_BREAK_MARQUEE: MarqueeCallback(view); @@ -333,6 +354,16 @@ void UILabel::SetHeight(int16_t height) RefreshLabel(); } } + +void UILabel::Resize(int16_t width, int16_t height) +{ + if (GetWidth() != width || GetHeight() != height) { + UIView::SetWidth(width); + UIView::SetHeight(height); + RefreshLabel(); + } +} + void UILabel::RefreshLabel() { Invalidate(); @@ -345,6 +376,19 @@ void UILabel::RefreshLabel() void UILabel::ReMeasure() { + if (setAnimState_ == Animator::START) { + if (lineBreakMode_ == LINE_BREAK_OSCILLATION || lineBreakMode_ == LINE_BREAK_MARQUEE) { + Rect rect = GetRect(); + Rect rootRect = RootView::GetInstance()->GetRect(); + if (rect.Intersect(rect, rootRect)) { + if (hasAnimator_ && animator_.animator->GetState() == Animator::PAUSE) { + // resume animator if now intersected with rootview. + animator_.animator->Resume(); + } + } + } + } + if (!needRefresh_) { return; } @@ -362,12 +406,15 @@ void UILabel::ReMeasure() switch (lineBreakMode_) { case LINE_BREAK_ADAPT: Resize(textSize.x, textSize.y); + needRefresh_ = false; break; case LINE_BREAK_STRETCH: SetWidth(textSize.x); + needRefresh_ = false; break; case LINE_BREAK_WRAP: SetHeight(textSize.y); + needRefresh_ = false; break; case LINE_BREAK_ELLIPSIS: labelText_->SetTruncateMode(false); @@ -412,8 +459,28 @@ std::string UILabel::GetGuiInfo() const return res; } +bool UILabel::CheckAnimState() +{ + if (setAnimState_ == Animator::START) { + return false; + } + + if (hasAnimator_) { + Animator* anim = animator_.animator; + if (setAnimState_ == Animator::PAUSE && anim->GetState() == Animator::START) { + anim->Pause(); + } else if (setAnimState_ == Animator::STOP && anim->GetState() != Animator::STOP) { + anim->Stop(); + } + } + return true; +} + void UILabel::RemeasureForAnimation(int16_t textWidth, LineBreakMode mode) { + if (setAnimState_ != Animator::START) { + return; + } int16_t rectWidth = GetWidth(); if (textWidth > rectWidth) { offsetX_ = GetRollStartPos(); @@ -435,7 +502,11 @@ void UILabel::RemeasureForAnimation(int16_t textWidth, LineBreakMode mode) animator_.animator = animator; hasAnimator_ = true; } - animator_.animator->Start(); + if (animator_.animator->GetState() == Animator::PAUSE) { + animator_.animator->Resume(); + } else { + animator_.animator->Start(); + } } else { offsetX_ = 0; labelText_->SetAlign(horAlign_, labelText_->GetVerAlign()); @@ -492,4 +563,36 @@ void UILabel::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) origContentRect, offsetX_, style, truncateIndex_, opa); } } + +void UILabel::SetAnimState(uint8_t state) +{ + if (setAnimState_ == state) { + return; + } + + switch (state) { + case Animator::START: + setAnimState_ = Animator::START; + break; + case Animator::STOP: + setAnimState_ = Animator::STOP; + break; + case Animator::PAUSE: + setAnimState_ = Animator::PAUSE; + break; + default: + setAnimState_ = Animator::START; + GRAPHIC_LOGE("Invalid state. Set to Animator::START instead!"); + break; + } +} + +uint8_t UILabel::GetAnimRealState() +{ + if (!hasAnimator_) { + GRAPHIC_LOGE("Do not have animator."); + return Animator::STOP; + } + return animator_.animator->GetState(); +} } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_list.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_list.cpp index 3e758286d..75d331ae9 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_list.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_list.cpp @@ -277,9 +277,11 @@ bool UIList::DragXInner(int16_t distance) if (distance == 0) { return true; } - int16_t reboundSize = reboundSize_; + int16_t reboundSizeLeft = reboundSizeLeft_; + int16_t reboundSizeRight = reboundSizeRight_; if (isLoopList_ || (scrollAnimator_.GetState() != Animator::STOP)) { - reboundSize = 0; + reboundSizeLeft = 0; + reboundSizeRight = 0; } bool ret = 0; do { @@ -292,40 +294,41 @@ bool UIList::DragXInner(int16_t distance) if (distance > 0) { if (childrenHead_ != nullptr) { - if (isElastic_ && (reboundSize > 0) && - (childrenHead_->GetX() > (scrollBlankSize_ + childrenHead_->GetStyle(STYLE_MARGIN_LEFT)))) { - int16_t offset = childrenHead_->GetX() - (scrollBlankSize_ + childrenHead_->GetStyle(STYLE_MARGIN_LEFT)); - if (offset > reboundSize) { - offset = reboundSize; + if (isElastic_ && (reboundSizeLeft > 0) && + (childrenHead_->GetX() > (scrollBlankSizeLeft_ + childrenHead_->GetStyle(STYLE_MARGIN_LEFT)))) { + int16_t offset = childrenHead_->GetX() - + (scrollBlankSizeLeft_ + childrenHead_->GetStyle(STYLE_MARGIN_LEFT)); + if (offset > reboundSizeLeft) { + offset = reboundSizeLeft; } - distance = CalculateElasticDragLen(reboundSize, offset, distance); + distance = CalculateElasticDragLen(reboundSizeLeft, offset, distance); } if ((childrenHead_->GetX() + distance) > - (scrollBlankSize_ + reboundSize + childrenHead_->GetStyle(STYLE_MARGIN_LEFT))) { - distance = - scrollBlankSize_ + reboundSize + childrenHead_->GetStyle(STYLE_MARGIN_LEFT) - childrenHead_->GetX(); + (scrollBlankSizeLeft_ + reboundSizeLeft + childrenHead_->GetStyle(STYLE_MARGIN_LEFT))) { + distance = scrollBlankSizeLeft_ + reboundSizeLeft + childrenHead_->GetStyle(STYLE_MARGIN_LEFT) - + childrenHead_->GetX(); } } } else { if (childrenTail_ != nullptr) { - if (isElastic_ && (reboundSize > 0) && + if (isElastic_ && (reboundSizeRight > 0) && (childrenTail_->GetRelativeRect().GetRight() < - (listWidth - scrollBlankSize_ - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT)))) { - int16_t offset = (listWidth - scrollBlankSize_ - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT)) + (listWidth - scrollBlankSizeRight_ - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT)))) { + int16_t offset = (listWidth - scrollBlankSizeRight_ - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT)) - (childrenTail_->GetRelativeRect().GetRight()); - if (offset > reboundSize) { - offset = reboundSize; + if (offset > reboundSizeRight) { + offset = reboundSizeRight; } - distance = CalculateElasticDragLen(reboundSize, offset, distance); + distance = CalculateElasticDragLen(reboundSizeRight, offset, distance); } if (childrenTail_->GetRelativeRect().GetRight() < - (listWidth - scrollBlankSize_ - reboundSize - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT))) { + (listWidth - scrollBlankSizeRight_ - reboundSizeRight - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT))) { distance = 0; } else if ((childrenTail_->GetRelativeRect().GetRight() + distance) < - (listWidth - scrollBlankSize_ - reboundSize - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT))) { - distance = listWidth - scrollBlankSize_ - reboundSize - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT) - - childrenTail_->GetRelativeRect().GetRight(); + (listWidth - scrollBlankSizeRight_ - reboundSizeRight - childrenTail_->GetStyle(STYLE_MARGIN_RIGHT))) { + distance = listWidth - scrollBlankSizeRight_ - reboundSizeRight - + childrenTail_->GetStyle(STYLE_MARGIN_RIGHT) - childrenTail_->GetRelativeRect().GetRight(); } } } @@ -342,9 +345,11 @@ bool UIList::DragYInner(int16_t distance) if (distance == 0) { return true; } - int16_t reboundSize = reboundSize_; + int16_t reboundSizeTop = reboundSizeTop_; + int16_t reboundSizeBottom = reboundSizeBottom_; if (isLoopList_ || (scrollAnimator_.GetState() != Animator::STOP)) { - reboundSize = 0; + reboundSizeTop = 0; + reboundSizeBottom = 0; } bool ret = 0; do { @@ -357,39 +362,42 @@ bool UIList::DragYInner(int16_t distance) if (distance > 0) { if (childrenHead_ != nullptr) { - if (isElastic_ && (reboundSize > 0) && - (childrenHead_->GetY() > (scrollBlankSize_ + childrenHead_->GetStyle(STYLE_MARGIN_TOP)))) { - int16_t offset = childrenHead_->GetY() - (scrollBlankSize_ + childrenHead_->GetStyle(STYLE_MARGIN_TOP)); - if (offset > reboundSize) { - offset = reboundSize; + if (isElastic_ && (reboundSizeTop > 0) && + (childrenHead_->GetY() > (scrollBlankSizeTop_ + childrenHead_->GetStyle(STYLE_MARGIN_TOP)))) { + int16_t offset = childrenHead_->GetY() - + (scrollBlankSizeTop_ + childrenHead_->GetStyle(STYLE_MARGIN_TOP)); + if (offset > reboundSizeTop) { + offset = reboundSizeTop; } - distance = CalculateElasticDragLen(reboundSize, offset, distance); + distance = CalculateElasticDragLen(reboundSizeTop, offset, distance); } if ((childrenHead_->GetY() + distance) > - (scrollBlankSize_ + reboundSize + childrenHead_->GetStyle(STYLE_MARGIN_TOP))) { - distance = - scrollBlankSize_ + reboundSize + childrenHead_->GetStyle(STYLE_MARGIN_TOP) - childrenHead_->GetY(); + (scrollBlankSizeTop_ + reboundSizeTop + childrenHead_->GetStyle(STYLE_MARGIN_TOP))) { + distance = scrollBlankSizeTop_ + reboundSizeTop + childrenHead_->GetStyle(STYLE_MARGIN_TOP) - + childrenHead_->GetY(); } } } else { if (childrenTail_ != nullptr) { - if (isElastic_ && (reboundSize > 0) && + if (isElastic_ && (reboundSizeBottom > 0) && (childrenTail_->GetRelativeRect().GetBottom() < - (listHeight - scrollBlankSize_ - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM)))) { - int16_t offset = (listHeight - scrollBlankSize_ - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM)) - - (childrenTail_->GetRelativeRect().GetBottom()); - if (offset > reboundSize) { - offset = reboundSize; + (listHeight - scrollBlankSizeBottom_ - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM)))) { + int16_t offset = listHeight - scrollBlankSizeBottom_ - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM) - + childrenTail_->GetRelativeRect().GetBottom(); + if (offset > reboundSizeBottom) { + offset = reboundSizeBottom; } - distance = CalculateElasticDragLen(reboundSize, offset, distance); + distance = CalculateElasticDragLen(reboundSizeBottom, offset, distance); } if (childrenTail_->GetRelativeRect().GetBottom() < - (listHeight - scrollBlankSize_ - reboundSize - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM))) { + (listHeight - scrollBlankSizeBottom_ - reboundSizeBottom - + childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM))) { distance = 0; } else if ((childrenTail_->GetRelativeRect().GetBottom() + distance) < - (listHeight - scrollBlankSize_ - reboundSize - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM))) { - distance = listHeight - scrollBlankSize_ - reboundSize - childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM) - - childrenTail_->GetRelativeRect().GetBottom(); + (listHeight - scrollBlankSizeBottom_ - reboundSizeBottom - + childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM))) { + distance = listHeight - scrollBlankSizeBottom_ - reboundSizeBottom - + childrenTail_->GetStyle(STYLE_MARGIN_BOTTOM) - childrenTail_->GetRelativeRect().GetBottom(); } } } @@ -419,11 +427,20 @@ bool UIList::MoveOffset(int16_t x, int16_t y) void UIList::UpdateScrollBar() { Rect allItemsRect = recycle_.GetAdapterItemsReletiveRect(); - int16_t totalHeight = allItemsRect.GetHeight() + 2 * scrollBlankSize_; // 2: two blank spaces on both sides - int16_t height = GetHeight(); - yScrollBar_->SetForegroundProportion(static_cast(height) / totalHeight); - yScrollBar_->SetScrollProgress(static_cast(scrollBlankSize_ - allItemsRect.GetTop()) / - (totalHeight - height)); + if (yScrollBarVisible_) { + int16_t totalHeight = allItemsRect.GetHeight() + scrollBlankSizeTop_ + scrollBlankSizeBottom_; + int16_t height = GetHeight(); + yScrollBar_->SetForegroundProportion(static_cast(height) / totalHeight); + yScrollBar_->SetScrollProgress(static_cast(scrollBlankSizeTop_ - allItemsRect.GetTop()) / + (totalHeight - height)); + } + if (xScrollBarVisible_) { + int16_t totalWidth = allItemsRect.GetWidth() + scrollBlankSizeLeft_ + scrollBlankSizeRight_; + int16_t width = GetWidth(); + xScrollBar_->SetForegroundProportion(static_cast(width) / totalWidth); + xScrollBar_->SetScrollProgress(static_cast(scrollBlankSizeLeft_ - allItemsRect.GetLeft()) / + (totalWidth - width)); + } RefreshAnimator(); } @@ -838,30 +855,30 @@ void UIList::CalculateReboundDistance(int16_t& dragDistanceX, int16_t& dragDista int16_t right = rect.GetRight(); int16_t scrollWidth = GetWidth(); if ((direction_ == VERTICAL) || (direction_ == HORIZONTAL_AND_VERTICAL)) { - if (top > scrollBlankSize_) { - if ((dragDistanceY + top) > (scrollBlankSize_ + reboundSize_)) { + if (top > scrollBlankSizeTop_) { + if ((dragDistanceY + top) > (scrollBlankSizeTop_ + reboundSizeTop_)) { dragDistanceY = 0; } - dragDistanceY += scrollBlankSize_ - (top + dragDistanceY); + dragDistanceY += scrollBlankSizeTop_ - (top + dragDistanceY); } - if (bottom < (scrollHeight - scrollBlankSize_ - 1)) { - if ((dragDistanceY + bottom) < (scrollHeight - scrollBlankSize_ - reboundSize_ - 1)) { + if (bottom < (scrollHeight - scrollBlankSizeBottom_ - 1)) { + if ((dragDistanceY + bottom) < (scrollHeight - scrollBlankSizeBottom_ - reboundSizeBottom_ - 1)) { dragDistanceY = 0; } - dragDistanceY += scrollHeight - scrollBlankSize_ - 1 - (bottom + dragDistanceY); + dragDistanceY += scrollHeight - scrollBlankSizeBottom_ - 1 - (bottom + dragDistanceY); } } else { - if (left > scrollBlankSize_) { - if ((dragDistanceX + left) > (scrollBlankSize_ + reboundSize_)) { + if (left > scrollBlankSizeLeft_) { + if ((dragDistanceX + left) > (scrollBlankSizeLeft_ + reboundSizeLeft_)) { dragDistanceX = 0; } - dragDistanceX += scrollBlankSize_ - (left + dragDistanceX); + dragDistanceX += scrollBlankSizeLeft_ - (left + dragDistanceX); } - if (right < (scrollWidth - scrollBlankSize_ - 1)) { - if ((dragDistanceX + right) < (scrollWidth - scrollBlankSize_ - reboundSize_ - 1)) { + if (right < (scrollWidth - scrollBlankSizeRight_ - 1)) { + if ((dragDistanceX + right) < (scrollWidth - scrollBlankSizeRight_ - reboundSizeRight_ - 1)) { dragDistanceX = 0; } - dragDistanceX += scrollWidth - scrollBlankSize_ - 1 - (right + dragDistanceX); + dragDistanceX += scrollWidth - scrollBlankSizeRight_ - 1 - (right + dragDistanceX); } } } @@ -875,6 +892,10 @@ void UIList::FixDistance(int16_t& distanceX, int16_t& distanceY) return; } + if (!autoAlign_) { + return; + } + if (direction_ == VERTICAL) { FixVerDistance(distanceY); } else { diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp index 2920622e1..f00e576e5 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp @@ -32,6 +32,7 @@ UIScrollView::UIScrollView() #if ENABLE_VIBRATOR totalRotateLen_ = 0; lastVibratorRotateLen_ = 0; + vibrationLenThreshold_ = DEFAULT_SCROLL_VIEW_VIBRATION_LEN; #endif #if ENABLE_FOCUS_MANAGER focusable_ = true; @@ -105,11 +106,13 @@ bool UIScrollView::OnRotateEvent(const RotateEvent& event) bool lastIsEdge = false; Rect childRect = GetAllChildRelativeRect(); if (direction_ == HORIZONTAL) { - if (childRect.GetLeft() - scrollBlankSize_ >= 0 || childRect.GetRight() + scrollBlankSize_ <= GetWidth()) { + if (childRect.GetLeft() - scrollBlankSizeLeft_ >= 0 || + childRect.GetRight() + scrollBlankSizeRight_ <= GetWidth()) { lastIsEdge = true; } } else { - if (childRect.GetTop() - scrollBlankSize_ >= 0 || childRect.GetBottom() + scrollBlankSize_ <= GetHeight()) { + if (childRect.GetTop() - scrollBlankSizeTop_ >= 0 || + childRect.GetBottom() + scrollBlankSizeBottom_ <= GetHeight()) { lastIsEdge = true; } } @@ -124,19 +127,21 @@ bool UIScrollView::OnRotateEvent(const RotateEvent& event) childRect = GetAllChildRelativeRect(); bool isEdge = false; if (direction_ == HORIZONTAL) { - if (childRect.GetLeft() - scrollBlankSize_ >= 0 || childRect.GetRight() + scrollBlankSize_ <= GetWidth()) { + if (childRect.GetLeft() - scrollBlankSizeLeft_ >= 0 || + childRect.GetRight() + scrollBlankSizeRight_ <= GetWidth()) { isEdge = true; } } else { - if (childRect.GetTop() - scrollBlankSize_ >= 0 || childRect.GetBottom() + scrollBlankSize_ <= GetHeight()) { + if (childRect.GetTop() - scrollBlankSizeTop_ >= 0 || + childRect.GetBottom() + scrollBlankSizeBottom_ <= GetHeight()) { isEdge = true; } } VibratorFunc vibratorFunc = VibratorManager::GetInstance()->GetVibratorFunc(); if (vibratorFunc != nullptr && !isEdge) { uint16_t rotateLen = MATH_ABS(totalRotateLen_ - lastVibratorRotateLen_); - if (rotateLen > DEFAULT_SCROLL_VIEW_VIBRATION_LEN) { - uint16_t vibrationCnt = rotateLen / DEFAULT_SCROLL_VIEW_VIBRATION_LEN; + if (rotateLen > vibrationLenThreshold_) { + uint16_t vibrationCnt = rotateLen / vibrationLenThreshold_; for (uint16_t i = 0; i < vibrationCnt; i++) { GRAPHIC_LOGI("UIScrollView::OnRotateEvent calls TYPE_ONE vibrator"); vibratorFunc(VibratorType::VIBRATOR_TYPE_ONE); @@ -178,29 +183,31 @@ void UIScrollView::ScrollBy(int16_t xDistance, int16_t yDistance) bool UIScrollView::DragXInner(int16_t distance) { Rect childRect = GetAllChildRelativeRect(); - int16_t reboundSize = reboundSize_; + int16_t reboundSizeLeft = reboundSizeLeft_; + int16_t reboundSizeRight = reboundSizeRight_; if (scrollAnimator_.GetState() != Animator::STOP) { - reboundSize = 0; + reboundSizeLeft = 0; + reboundSizeRight = 0; } - if (childRect.GetWidth() <= (GetWidth() - (scrollBlankSize_ << 1)) || + if (childRect.GetWidth() <= (GetWidth() - scrollBlankSizeLeft_ - scrollBlankSizeRight_) || !(direction_ == HORIZONTAL || direction_ == HORIZONTAL_AND_VERTICAL)) { return false; } if (distance > 0) { - if (childRect.GetLeft() > scrollBlankSize_ + reboundSize) { + if (childRect.GetLeft() > scrollBlankSizeLeft_ + reboundSizeLeft) { distance = 0; - } else if ((childRect.GetLeft() + distance) > scrollBlankSize_ + reboundSize) { - distance = scrollBlankSize_ - childRect.GetLeft() + reboundSize; + } else if ((childRect.GetLeft() + distance) > scrollBlankSizeLeft_ + reboundSizeLeft) { + distance = scrollBlankSizeLeft_ - childRect.GetLeft() + reboundSizeLeft; } } else { int16_t childRight = childRect.GetRight(); int16_t scrollWidth = GetWidth(); - if (childRight < scrollWidth - (scrollBlankSize_ + reboundSize)) { + if (childRight < scrollWidth - (scrollBlankSizeRight_ + reboundSizeRight)) { distance = 0; - } else if (childRight + distance < scrollWidth - (scrollBlankSize_ + reboundSize)) { - distance = scrollWidth - (scrollBlankSize_ + reboundSize) - childRight - 1; + } else if (childRight + distance < scrollWidth - (scrollBlankSizeRight_ + reboundSizeRight)) { + distance = scrollWidth - (scrollBlankSizeRight_ + reboundSizeRight) - childRight - 1; } } @@ -210,29 +217,31 @@ bool UIScrollView::DragXInner(int16_t distance) bool UIScrollView::DragYInner(int16_t distance) { Rect childRect = GetAllChildRelativeRect(); - int16_t reboundSize = reboundSize_; + int16_t reboundSizeTop = reboundSizeTop_; + int16_t reboundSizeBottom = reboundSizeBottom_; if (scrollAnimator_.GetState() != Animator::STOP) { - reboundSize = 0; + reboundSizeTop = 0; + reboundSizeBottom = 0; } - if (childRect.GetHeight() <= (GetHeight() - (scrollBlankSize_ << 1)) || + if (childRect.GetHeight() <= (GetHeight() - scrollBlankSizeTop_ - scrollBlankSizeBottom_) || !(direction_ == VERTICAL || direction_ == HORIZONTAL_AND_VERTICAL)) { return false; } if (distance > 0) { - if (childRect.GetTop() > scrollBlankSize_ + reboundSize) { + if (childRect.GetTop() > scrollBlankSizeTop_ + reboundSizeTop) { distance = 0; - } else if ((childRect.GetTop() + distance) > scrollBlankSize_ + reboundSize) { - distance = scrollBlankSize_ - childRect.GetTop() + reboundSize; + } else if ((childRect.GetTop() + distance) > scrollBlankSizeTop_ + reboundSizeTop) { + distance = scrollBlankSizeTop_ - childRect.GetTop() + reboundSizeTop; } } else { int16_t childBottom = childRect.GetBottom(); int16_t scrollHeight = GetHeight(); - if (childBottom < scrollHeight - (scrollBlankSize_ + reboundSize)) { + if (childBottom < scrollHeight - (scrollBlankSizeBottom_ + reboundSizeBottom)) { distance = 0; - } else if (childBottom + distance < scrollHeight - (scrollBlankSize_ + reboundSize)) { - distance = scrollHeight - (scrollBlankSize_ + reboundSize) - childBottom - 1; + } else if (childBottom + distance < scrollHeight - (scrollBlankSizeBottom_ + reboundSizeBottom)) { + distance = scrollHeight - (scrollBlankSizeBottom_ + reboundSizeBottom) - childBottom - 1; } } @@ -261,20 +270,20 @@ void UIScrollView::RefreshScrollBar() { Rect childrenRect = GetAllChildRelativeRect(); /* calculate scrollBar's the proportion of foreground */ - int16_t totalLen = childrenRect.GetHeight() + 2 * scrollBlankSize_; // 2: two blank space on both sizes - int16_t len = GetHeight(); if (yScrollBarVisible_) { + int16_t totalLen = childrenRect.GetHeight() + scrollBlankSizeTop_ + scrollBlankSizeBottom_; + int16_t len = GetHeight(); yScrollBar_->SetForegroundProportion(static_cast(len) / totalLen); /* calculate scrolling progress */ - yScrollBar_->SetScrollProgress(static_cast(scrollBlankSize_ - childrenRect.GetTop()) / + yScrollBar_->SetScrollProgress(static_cast(scrollBlankSizeTop_ - childrenRect.GetTop()) / (totalLen - len)); } if (xScrollBarVisible_) { /* so do x-bar */ - totalLen = childrenRect.GetWidth() + 2 * scrollBlankSize_; // 2: two blank space on both sizes - len = GetWidth(); + int16_t totalLen = childrenRect.GetWidth() + scrollBlankSizeLeft_ + scrollBlankSizeRight_; + int16_t len = GetWidth(); xScrollBar_->SetForegroundProportion(static_cast(len) / totalLen); - xScrollBar_->SetScrollProgress(static_cast(scrollBlankSize_ - childrenRect.GetLeft()) / + xScrollBar_->SetScrollProgress(static_cast(scrollBlankSizeLeft_ - childrenRect.GetLeft()) / (totalLen - len)); } RefreshAnimator(); @@ -289,16 +298,16 @@ void UIScrollView::CalculateReboundDistance(int16_t& dragDistanceX, int16_t& dra int16_t left = rect.GetLeft(); int16_t right = rect.GetRight(); int16_t scrollWidth = GetWidth(); - if (scrollBlankSize_ < top) { - dragDistanceY = scrollBlankSize_ - top; + if (scrollBlankSizeTop_ < top) { + dragDistanceY = scrollBlankSizeTop_ - top; } else if (bottom < scrollHeight - 1) { - dragDistanceY = scrollHeight - scrollBlankSize_ - bottom - 1; + dragDistanceY = scrollHeight - scrollBlankSizeBottom_ - bottom - 1; } - if (scrollBlankSize_ < left) { - dragDistanceX = scrollBlankSize_ - left; + if (scrollBlankSizeLeft_ < left) { + dragDistanceX = scrollBlankSizeLeft_ - left; } else if (right < scrollWidth - 1) { - dragDistanceX = scrollWidth - scrollBlankSize_ - right - 1; + dragDistanceX = scrollWidth - scrollBlankSizeRight_ - right - 1; } } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_swipe_view.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_swipe_view.cpp index 7c4348d90..c4543df20 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_swipe_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_swipe_view.cpp @@ -29,6 +29,7 @@ UISwipeView::UISwipeView(uint8_t direction) #if ENABLE_VIBRATOR lastIndex_ = 0; needVibration_ = false; + vibrateIndex_ = 0; #endif direction_ = direction; tickTime_ = ANIMATOR_TIME; @@ -248,6 +249,7 @@ bool UISwipeView::OnRotateStartEvent(const RotateEvent& event) } #if ENABLE_VIBRATOR needVibration_ = true; + lastIndex_ = vibrateIndex_; #endif return UIView::OnRotateStartEvent(event); } @@ -266,13 +268,13 @@ bool UISwipeView::OnRotateEndEvent(const RotateEvent& event) } RefreshCurrentView(lastRotateLen_, dir); if (curView_ == nullptr) { +#if ENABLE_VIBRATOR + needVibration_ = false; +#endif return UIView::OnRotateEndEvent(event); } SwitchToPage(curIndex_); lastRotateLen_ = 0; -#if ENABLE_VIBRATOR - needVibration_ = false; -#endif return UIView::OnRotateEndEvent(event); } #endif @@ -348,6 +350,9 @@ void UISwipeView::StopAnimator() if (swipeListener_ != nullptr) { swipeListener_->OnSwipe(*this); } +#if ENABLE_VIBRATOR + needVibration_ = false; +#endif } void UISwipeView::SortChild() @@ -478,19 +483,6 @@ void UISwipeView::RefreshCurrentViewInner(int16_t distance, } } } -#if ENABLE_VIBRATOR - VibratorFunc vibratorFunc = VibratorManager::GetInstance()->GetVibratorFunc(); - if (vibratorFunc != nullptr && needVibration_ && curIndex_ != lastIndex_) { - if (!loop_ && (curIndex_ == 0 || curIndex_ == childrenNum_ - 1)) { - vibratorFunc(VibratorType::VIBRATOR_TYPE_THREE); - GRAPHIC_LOGI("UISwipeView::RefreshCurrentViewInner calls TYPE_THREE vibrator"); - } else { - vibratorFunc(VibratorType::VIBRATOR_TYPE_ONE); - GRAPHIC_LOGI("UISwipeView::RefreshCurrentViewInner calls TYPE_ONE vibrator"); - } - lastIndex_ = curIndex_; - } -#endif } void UISwipeView::RefreshCurrentView(int16_t distance, uint8_t dragDirection) @@ -506,6 +498,9 @@ void UISwipeView::MoveChildByOffset(int16_t xOffset, int16_t yOffset) { UIViewGroup::MoveChildByOffset(xOffset, yOffset); MoveHeadOrTailChild(); +#if ENABLE_VIBRATOR + Vibrate(); +#endif } bool UISwipeView::isNeedLoop() @@ -577,4 +572,58 @@ void UISwipeView::CalculateInvalidate() view = view->GetNextSibling(); } } + +#if ENABLE_VIBRATOR +void UISwipeView::Vibrate() +{ + UIView* view = childrenHead_; + int16_t swipeMid; + int16_t (UIView::*pfnGetXOrY)() const; + int16_t (UIView::*pfnGetWidthOrHeight)(); + if (direction_ == HORIZONTAL) { + pfnGetXOrY = &UIView::GetX; + pfnGetWidthOrHeight = &UIView::GetWidthWithMargin; + } else { + pfnGetXOrY = &UIView::GetY; + pfnGetWidthOrHeight = &UIView::GetHeightWithMargin; + } + if (alignMode_ == ALIGN_LEFT) { + swipeMid = 0; + } else if (alignMode_ == ALIGN_RIGHT) { + swipeMid = (this->*pfnGetWidthOrHeight)(); + } else { + swipeMid = (this->*pfnGetWidthOrHeight)() / 2; + } + bool isFind = false; + while (view != nullptr) { + if ((swipeMid >= (view->*pfnGetXOrY)()) && + (swipeMid <= (view->*pfnGetXOrY)() + (view->*pfnGetWidthOrHeight)()) && !isFind) { + vibrateIndex_ = view->GetViewIndex(); + isFind = true; + break; + } + view = view->GetNextSibling(); + } + + if (!isFind) { + if ((childrenHead_->*pfnGetXOrY)() > swipeMid) { + vibrateIndex_ = childrenHead_->GetViewIndex(); + } else { + vibrateIndex_ = childrenTail_->GetViewIndex(); + } + } + + VibratorFunc vibratorFunc = VibratorManager::GetInstance()->GetVibratorFunc(); + if (vibratorFunc != nullptr && needVibration_ && vibrateIndex_ != lastIndex_) { + if (!loop_ && (vibrateIndex_ == 0 || vibrateIndex_ == childrenNum_ - 1)) { + vibratorFunc(VibratorType::VIBRATOR_TYPE_THREE); + GRAPHIC_LOGI("UISwipeView::Vibrate calls TYPE_THREE vibrator"); + } else { + vibratorFunc(VibratorType::VIBRATOR_TYPE_ONE); + GRAPHIC_LOGI("UISwipeView::Vibrate calls TYPE_ONE vibrator"); + } + lastIndex_ = vibrateIndex_; + } +} +#endif } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_view.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_view.cpp index 8686ab55a..50645ddae 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_view.cpp @@ -62,7 +62,7 @@ UIView::UIView() viewExtraMsg_(nullptr), rect_(0, 0, -1, -1), visibleRect_(nullptr), - blurRadius_(0) + blurRadius_(0.0f) { SetupThemeStyles(); } @@ -74,7 +74,7 @@ UIView::~UIView() #endif ClearBackgroundBlur(); if (parent_ != nullptr) { - GRAPHIC_LOGE("UIView::~UIView failed, parent is not nullptr! Need to remove from parent component first %d",parent_->GetViewType()); + GRAPHIC_LOGE("UIView::~UIView failed, parent is not nullptr! Need to remove from parent component first"); } if (transMap_ != nullptr) { delete transMap_; @@ -114,7 +114,7 @@ bool UIView::OnPreDraw(Rect& invalidatedArea) const void UIView::HandleGaussianBlur(BufferInfo& gfxDstBuffer) { - if (visible_ && (blurRadius_ != 0)) { + if (visible_ && (!FloatEqual(blurRadius_, 0.0f))) { BufferInfo gfxTargetBuffer = gfxDstBuffer; Rect mask = {0, 0, gfxTargetBuffer.width - 1, gfxTargetBuffer.height - 1}; if (!fullScreenBlur_) { @@ -471,19 +471,22 @@ void UIView::ResetTransParameter() } } -void UIView::SetBackgroundBlur(uint16_t radius) +void UIView::SetBackgroundBlur(float radius) { - if (RootView::GetInstance()->SetBlurView(this)) { + if (FloatEqual(radius, 0.0f)) { + RootView::GetInstance()->ClearBlurView(this); + blurRadius_ = 0.0f; + } else if (RootView::GetInstance()->SetBlurView(this)) { blurRadius_ = radius; - RootView::GetInstance()->Invalidate(); } + RootView::GetInstance()->Invalidate(); } void UIView::ClearBackgroundBlur() { - if (blurRadius_ != 0) { + if (!FloatEqual(blurRadius_, 0.0f)) { RootView::GetInstance()->ClearBlurView(this); - blurRadius_ = 0; + blurRadius_ = 0.0f; RootView::GetInstance()->Invalidate(); } } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/task_manager.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/task_manager.cpp index c4198fb3d..60f59845f 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/task_manager.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/core/task_manager.cpp @@ -114,6 +114,11 @@ uint32_t TaskManager::GetMinimumCustomerTaskPeriod() } } +uint16_t TaskManager::GetTotalTaskNum() +{ + return list_.Size(); +} + /** * @brief TaskManager::ResetTaskHandlerMutex Reset the running flag. * diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp index c4d04f3c7..9aaa00654 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp @@ -207,9 +207,11 @@ void PointerInputDevice::DispatchDragStartEvent() dragLen_.y += dragStep_.y; if (!isDragging_) { if ((MATH_ABS(dragLen_.x) >= INDEV_DRAG_LIMIT) || (MATH_ABS(dragLen_.y) >= INDEV_DRAG_LIMIT)) { - if ((touchableView_ != nullptr) && !cancelSent_) { - DispatchCancelEvent(); - } + // HISI delete begin + //if ((touchableView_ != nullptr) && !cancelSent_) { + // DispatchCancelEvent(); + //} + // HISI delete end // Send Drag Begin Event. DragEvent evt(curPos_, lastPos_, dragLen_); UIView* parent = draggableView_->GetParent(); @@ -261,6 +263,7 @@ void PointerInputDevice::DispatchDragEndEvent() if (!draggableView_->OnDragEndEvent(evt)) { while (parent != nullptr) { DragEvent evtParent(curPos_, lastPos_, dragLen_); + evtParent.SetPreLastPoint(dragLastPos_); if (parent->OnDragEndEvent(evtParent)) { break; } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/draw/draw_utils.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/draw/draw_utils.cpp index 2d11481c2..96df29315 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/draw/draw_utils.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/draw/draw_utils.cpp @@ -403,14 +403,17 @@ static void DrawEmoji(BufferInfo &gfxDstBuffer, const ImageInfo &info, const Lab if (!mask.Intersect(mask, blendOption.transMap.GetBoxRect())) { return; } - if (!FloatEqual(scaleX, 1.0f) || !FloatEqual(scaleY, 1.0f)) { // to avoid twinkle + Matrix4 matrix = blendOption.transMap.GetTransformMatrix(); + if (!(FloatEqual(matrix[0][0], 1) && FloatEqual(matrix[0][1], 0) && FloatEqual(matrix[0][3], 0) && + FloatEqual(matrix[1][0], 0) && FloatEqual(matrix[1][1], 1) && FloatEqual(matrix[1][3], 0) && // 3: pos + FloatEqual(matrix[3][3], 1))) { // 3: pos, to avoid twinkle mask.SetLeft(mask.GetLeft() + 1); mask.SetRight(mask.GetRight() - 1); mask.SetTop(mask.GetTop() + 1); mask.SetBottom(mask.GetBottom() - 1); } else { // to avoid vau error (srcRect is not euqal to dstRect) when no scale - int16_t srcLeft = mask.GetLeft() - posX; - int16_t srcTop = mask.GetTop() - posY; + int16_t srcLeft = mask.GetLeft() - matrix[3][0]; + int16_t srcTop = mask.GetTop() - matrix[3][1]; src.rect = {srcLeft, srcTop, srcLeft + mask.GetWidth() - 1, srcTop + mask.GetHeight() - 1}; } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/engines/gfx/gfx_engine_manager.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/engines/gfx/gfx_engine_manager.cpp index 31357dc84..9c2db2c54 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/engines/gfx/gfx_engine_manager.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/engines/gfx/gfx_engine_manager.cpp @@ -125,7 +125,7 @@ void BaseGfxEngine::Fill(BufferInfo& dst, const Rect& fillArea, const ColorType DrawUtils::GetInstance()->FillAreaWithSoftWare(dst, fillArea, color, opacity); } -void BaseGfxEngine::Blur(BufferInfo& dst, uint16_t radius) +void BaseGfxEngine::Blur(BufferInfo& dst, float radius) { GRAPHIC_LOGE("Blur not support."); } diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/common/task_manager.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/common/task_manager.h index ba7c4d38e..4216cecdb 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/common/task_manager.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/common/task_manager.h @@ -75,6 +75,11 @@ public: */ uint32_t GetMinimumCustomerTaskPeriod(); + /** + * @brief Get total number of tasks. + */ + uint16_t GetTotalTaskNum(); + protected: List list_; /* the task list */ bool canTaskRun_; diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/engines/gfx/gfx_engine_manager.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/engines/gfx/gfx_engine_manager.h index 108f3ed84..42c122033 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/engines/gfx/gfx_engine_manager.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/innerkits/engines/gfx/gfx_engine_manager.h @@ -130,7 +130,7 @@ public: const ColorType color, const OpacityType opacity); - virtual void Blur(BufferInfo& dst, uint16_t radius); + virtual void Blur(BufferInfo& dst, float radius); virtual uint8_t* AllocBuffer(uint32_t size, uint32_t usage); diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/root_view.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/root_view.h index 496101f01..6db6c05dc 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/root_view.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/root_view.h @@ -341,6 +341,8 @@ public: if (blurView_ == nullptr) { blurView_ = view; return true; + } else if (view == blurView_) { + return true; } else { #ifndef USE_DIAG_LOG GRAPHIC_LOGE("BlurView already exists. Can only set once."); diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/text_adapter.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/text_adapter.h index bd247d1e1..5acc571bc 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/text_adapter.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/text_adapter.h @@ -254,16 +254,14 @@ public: formatter_ = formatter; } protected: - virtual UILabel* GetTextView(UIView* inView, int16_t index); - virtual UILabel* CreateUILabel(UIView* inView); + virtual UILabel* CreateUILabel(); uint8_t dataMode_; private: static constexpr uint8_t DYNAMIC_TEXT_MODE = 0; static constexpr uint8_t CONTINUOUS_INTEGER_MODE = 3; static constexpr uint8_t BUF_LEN = 7; - UILabel* GetDynamicText(UIView* inView, int16_t index); - UILabel* GetIntegerText(UIView* inView, int16_t index); + bool SetIntegerText(UILabel* inView, int16_t index); void ClearDynamicText(); uint8_t fontId_; char* fontName_; diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_abstract_scroll.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_abstract_scroll.h index b9fb42fbf..fc45e4e31 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_abstract_scroll.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_abstract_scroll.h @@ -79,6 +79,14 @@ public: return UI_ABSTRACT_SCROLL; } + enum class Direction { + ALL, + TOP, + BOTTOM, + LEFT, + RIGHT, + }; + /** * @brief Sets the blank size for this scroll view. * @@ -87,38 +95,76 @@ public: * example, the value 0 indicates that the head node can only scroll downwards the top of the * view and the tail node scroll upwards the bottom; the value 10 indicates that the head node * can continue scrolling down by 10 pixels after it reaches the top of the view. + * @param direction Indicates the direction of blank size to set. Default is ALL. Direction can be specified for UIList and UIScrollView. * @since 1.0 * @version 1.0 */ - void SetScrollBlankSize(uint16_t size) + void SetScrollBlankSize(uint16_t size, UIAbstractScroll::Direction direction = UIAbstractScroll::Direction::ALL) { - scrollBlankSize_ = size; + switch (direction) { + case UIAbstractScroll::Direction::ALL: + scrollBlankSize_ = size; + scrollBlankSizeTop_ = size; + scrollBlankSizeBottom_ = size; + scrollBlankSizeLeft_ = size; + scrollBlankSizeRight_ = size; + break; + case UIAbstractScroll::Direction::TOP: + scrollBlankSizeTop_ = size; + break; + case UIAbstractScroll::Direction::BOTTOM: + scrollBlankSizeBottom_ = size; + break; + case UIAbstractScroll::Direction::LEFT: + scrollBlankSizeLeft_ = size; + break; + case UIAbstractScroll::Direction::RIGHT: + scrollBlankSizeRight_ = size; + break; + } } /** - * @brief Sets the maximum scroll distance after a finger lifts the screen. - * - * @param distance Indicates the maximum scroll distance to set. The default value is 0, indicating that the - * scroll distance is not limited. - * @since 1.0 - * @version 1.0 + * @brief Sets the rebound size in a specific direction. + * @param size Indicates the rebound size to set. + * @param direction Indicates the direction of rebound size to set. Default is ALL. Direction can be specified for UIList and UIScrollView. */ - void SetMaxScrollDistance(uint16_t distance) + void SetReboundSize(uint16_t size, UIAbstractScroll::Direction direction = UIAbstractScroll::Direction::ALL) { - maxScrollDistance_ = distance; + switch (direction) { + case UIAbstractScroll::Direction::ALL: + reboundSize_ = size; + reboundSizeTop_ = size; + reboundSizeBottom_ = size; + reboundSizeLeft_ = size; + reboundSizeRight_ = size; + break; + case UIAbstractScroll::Direction::TOP: + reboundSizeTop_ = size; + break; + case UIAbstractScroll::Direction::BOTTOM: + reboundSizeBottom_ = size; + break; + case UIAbstractScroll::Direction::LEFT: + reboundSizeLeft_ = size; + break; + case UIAbstractScroll::Direction::RIGHT: + reboundSizeRight_ = size; + break; + } } /** - * @brief Sets the rebound size, which is the distance a knob moves after being released when it reaches the end of - * a scrollbar. + * @brief Sets the maximum scroll distance after a finger lifts the screen. * - * @param size Indicates the rebound size to set. + * @param distance Indicates the maximum scroll distance to set. The default value is 0, indicating that the + * scroll distance is not limited. * @since 1.0 * @version 1.0 */ - void SetReboundSize(uint16_t size) + void SetMaxScrollDistance(uint16_t distance) { - reboundSize_ = size; + maxScrollDistance_ = distance; } /** @@ -459,6 +505,14 @@ protected: int16_t CalculateElasticDragLen(int16_t maxLen, int16_t currLen, int16_t dragLen); uint16_t scrollBlankSize_ = 0; + uint16_t scrollBlankSizeTop_ = 0; + uint16_t scrollBlankSizeBottom_ = 0; + uint16_t scrollBlankSizeLeft_ = 0; + uint16_t scrollBlankSizeRight_ = 0; + uint16_t reboundSizeTop_ = 0; + uint16_t reboundSizeBottom_ = 0; + uint16_t reboundSizeLeft_ = 0; + uint16_t reboundSizeRight_ = 0; uint16_t reboundSize_ = 0; int16_t accumulatedSize_ = 0; uint16_t elasticTime_ = 200; diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_label.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_label.h index df83008fc..a739d31dc 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_label.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_label.h @@ -415,10 +415,33 @@ public: */ void SetHeight(int16_t height) override; + /** + * @brief Adjusts the size of the view. + * @param width Indicates the new width. + * @param height Indicates the new height. + * @since 1.0 + * @version 1.0 + */ + void Resize(int16_t width, int16_t height) override; + void ReMeasure() override; std::string GetGuiInfo() const override; + /** + * @brief Set animator state. This may not immediately change the state. + * It is used when label has an animator due to LINE_BREAK_MARQUEE or LINE_BREAK_OSCILLATION mode. + * START: Enable animator. Start or Resume animator if it was mannually stopped or paused. + * STOP: Stop animator. Once set, animator cannot be started automatically. + * PAUSE: Pause animator. Once set, animator cannot be resumed automatically. + */ + void SetAnimState(uint8_t state); + + /** + * @brief Get animator's real state. + */ + uint8_t GetAnimRealState(); + #if ENABLE_FONT_VECTOR_GLOBAL virtual void ForceResetText() {}; #endif @@ -452,6 +475,9 @@ private: } animator_; UITextLanguageAlignment horAlign_ = TEXT_ALIGNMENT_LEFT; + + bool CheckAnimState(); + uint8_t setAnimState_ = Animator::START; }; } // namespace OHOS #endif // GRAPHIC_LITE_UI_LABEL_H diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_scroll_view.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_scroll_view.h index c5039a795..40810e831 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_scroll_view.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_scroll_view.h @@ -236,6 +236,16 @@ public: scrollListener_ = scrollListener; } + void SetVibrationLenThreshold(uint16_t value) + { + vibrationLenThreshold_ = value; + } + + uint16_t GetVibrationLenThreshold() const + { + return vibrationLenThreshold_; + } + protected: void StopAnimator() override; bool DragXInner(int16_t distance) override; @@ -250,6 +260,7 @@ private: #if ENABLE_VIBRATOR int16_t totalRotateLen_; int16_t lastVibratorRotateLen_; + uint16_t vibrationLenThreshold_; #endif }; } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_swipe_view.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_swipe_view.h index 884e5c376..963ba93f9 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_swipe_view.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_swipe_view.h @@ -367,6 +367,8 @@ protected: #if ENABLE_VIBRATOR uint16_t lastIndex_; bool needVibration_; + uint16_t vibrateIndex_; + void Vibrate(); #endif private: diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_view.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_view.h index 89e3f184b..02f2943cb 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_view.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_view.h @@ -128,6 +128,7 @@ enum UIViewType : uint8_t { UI_COVER_FLOW_2, UI_WATERFALL_LIST, UI_SPHERE_VIEW, + UI_PARTICLE_VIEW, UI_NUMBER_MAX }; @@ -1663,7 +1664,13 @@ public: void ResetTransParameter(); - void SetBackgroundBlur(uint16_t radius); + /** + * @brief Sets blur radius + * @param radius Indicates the blur effect of different degrees, the valid range is [0.0f, 32.0f] + * @since 1.0 + * @version 1.0 + */ + void SetBackgroundBlur(float radius); void ClearBackgroundBlur(); @@ -1843,7 +1850,7 @@ protected: OnRotateListener* onRotateListener_; #endif ViewExtraMsg* viewExtraMsg_; - uint16_t blurRadius_; + float blurRadius_; uint8_t GetMixOpaScale() const; bool IsInvalid(float percent); diff --git a/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h b/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h index 123a704c5..18e4bb240 100644 --- a/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h +++ b/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h @@ -111,11 +111,19 @@ namespace OHOS { */ #define ENABLE_STATIC_FONT 0 +#ifdef XTS_SUPPORT +#define ENABLE_JPEG_AND_PNG 1 +#else #define ENABLE_JPEG_AND_PNG 0 +#endif /** * @brief Cache the decoded content for Jpeg and Png image */ +#ifdef XTS_SUPPORT +#define CACHE_JPEG_AND_PNG 1 +#else #define CACHE_JPEG_AND_PNG 0 +#endif /** * @brief Customize the memory area when loading image resources */ diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.c b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.c index 396dba73e..b0d37a374 100644 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.c +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.c @@ -697,7 +697,7 @@ static void GetMixWeight(InterruptElement *interruptEl, float materStreamTypeVol } } -bool InterruptMgrGetActiveStream(AudioStreamStrategy *streamStrategy, bool isOutput) +bool InterruptMgrGetActiveStream(AudioStreamStrategy *streamStrategy, AudioStreamType streamType, bool isOutput) { /* 获取流和对应的混音权重 */ ALOGD("isOutput:%d", isOutput); @@ -709,14 +709,18 @@ bool InterruptMgrGetActiveStream(AudioStreamStrategy *streamStrategy, bool isOut AUDIO_LOCK(g_interruptMgrCtx.interruptLock); for (ListIterator it = ListIterBegin(list); it != ListIterEnd(list); it = ListIterNext(list, it)) { InterruptElement *interruptEl = (InterruptElement *)ListIterData(it); - bool isValidActiveStream = !interruptEl->isInterrupted && + /* 可以恢复的流即使被打断,也需要默认是active的 */ + bool isValidActiveStream = (!interruptEl->isInterrupted || IsNeedResumeForStream(interruptEl->streamType)) && interruptEl->streamType == interruptEl->routedStreamDesc.streamDesc.streamType; if (isValidActiveStream) { ret = GetRoutedDeviceForStream(&interruptEl->routedStreamDesc, isOutput); if (ret != AUDIO_SUCCESS) { - ALOGE("Get Routed Device For Stream (0x%x) failed", interruptEl->streamType); - AUDIO_UNLOCK(g_interruptMgrCtx.interruptLock); - return false; + if (interruptEl->streamType == streamType) { + ALOGE("Get Routed Device For Stream (0x%x) failed", interruptEl->streamType); + AUDIO_UNLOCK(g_interruptMgrCtx.interruptLock); + return false; + } + continue; } /* 第一条流作为混音权重 100% */ if (index == 0) { diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.h b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.h index 8fccc23e1..b31d96f08 100644 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.h +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/interrupt_manager.h @@ -41,7 +41,7 @@ void InterruptMgrDeInit(void); bool InterruptMgrCreateStream(AudioSession sessionID, const AudioStreamDescriptor *streamDesc, bool isOutput); bool InterruptMgrDestroyStream(AudioSession sessionID, const AudioStreamDescriptor *streamDesc, bool isOutput); -bool InterruptMgrGetActiveStream(AudioStreamStrategy *streamStrategy, bool isOutput); +bool InterruptMgrGetActiveStream(AudioStreamStrategy *streamStrategy, AudioStreamType streamType, bool isOutput); /* interrupt might already be time out in the stack, handle it */ void InterruptMgrSignalExceptionCheckThread(void); void InterruptMgrHandleException(void); diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/policy_manager.c b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/policy_manager.c index c47dd7e6a..9d079014c 100644 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/policy_manager.c +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/policymanager/src/policy_manager.c @@ -377,18 +377,18 @@ static AudioStreamStrategy *GetStrategyForStreamCreate(AudioSession sessionID, c } ResetActiveStreams(); /* 获取流和对应的混音权重 */ - if (!InterruptMgrGetActiveStream(&g_policyMgrCtx.streamStrategy, isOutput)) { + if (!InterruptMgrGetActiveStream(&g_policyMgrCtx.streamStrategy, streamDesc->streamType, isOutput)) { ResetActiveStreams(); return NULL; } return &g_policyMgrCtx.streamStrategy; } -static AudioStreamStrategy *GetStrategyForStreamResume(bool isOutput) +static AudioStreamStrategy *GetStrategyForStreamResume(const AudioStreamDescriptor *streamDesc, bool isOutput) { ResetActiveStreams(); /* 获取流和对应的混音权重 */ - if (!InterruptMgrGetActiveStream(&g_policyMgrCtx.streamStrategy, isOutput)) { + if (!InterruptMgrGetActiveStream(&g_policyMgrCtx.streamStrategy, streamDesc->streamType, isOutput)) { ResetActiveStreams(); return NULL; } @@ -407,7 +407,7 @@ static AudioStreamStrategy *GetStrategyForStreamDestroy(AudioSession sessionID, return NULL; } /* 获取流和对应的混音权重 */ - if (!InterruptMgrGetActiveStream(&g_policyMgrCtx.streamStrategy, isOutput)) { + if (!InterruptMgrGetActiveStream(&g_policyMgrCtx.streamStrategy, streamDesc->streamType, isOutput)) { ResetActiveStreams(); ALOGE("sessionID:%u get active stream:0x%x failed", sessionID, streamDesc->streamType); return NULL; @@ -427,7 +427,7 @@ AudioStreamStrategy *PolicyMgrGetStrategyForStream(AudioSession sessionID, const return GetStrategyForStreamCreate(sessionID, streamDesc, isOutput); case STREAM_OUT_RESUME: case STREAM_IN_RESUME: - return GetStrategyForStreamResume(isOutput); + return GetStrategyForStreamResume(streamDesc, isOutput); case STREAM_OUT_DESTROY: case STREAM_IN_DESTROY: return GetStrategyForStreamDestroy(sessionID, streamDesc, isOutput); diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/stream_manager.c b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/stream_manager.c index 761706b3a..d602e7f3f 100644 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/stream_manager.c +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/stream_manager.c @@ -668,34 +668,35 @@ ERR: int32_t StreamMgrDestroyStreamOut(uintptr_t handle) { - if (!g_inited) { - return AUDIO_SUCCESS; - } CHK_NULL_RETURN((void*)handle, AUDIO_ERROR, "handle is NULL when destroy"); int32_t streamId; AudioSession sessionId; int32_t ret = GetHandleId(handle, &streamId, &sessionId); CHK_FAILED_RETURN(ret, AUDIO_SUCCESS, AUDIO_ERROR, "get handle failed"); - + MediaMutexLock(g_mutex); // 告知策略模块即将清掉的流 AudioStreamInfo streamInfForDestroy = { 0 }; streamInfForDestroy.streamType = GetStreamType(handle); streamInfForDestroy.sessionID = sessionId; AudioStreamStrategy *strategy = GetStrategyFromPolicyManager(&streamInfForDestroy, (uint32_t)streamId, STREAM_OUT_DESTROY); - CHK_NULL_RETURN(strategy, AUDIO_ERROR, "get strategy fail when destroy out stream"); + if (strategy == NULL) { + ALOGE("get strategy fail when destroy out stream"); + MediaMutexUnLock(g_mutex); + return AUDIO_ERROR; + } #ifdef SUPPORT_SET_DSP_CLOCK_FREQ AudioStreamType streamType = GetStreamType(handle); AudioDeviceType deviceType = (AudioDeviceType)GetStreamDeviceId(handle); #endif // hal 销毁 if (DestroyTrackHandle(handle) != AUDIO_SUCCESS) { + MediaMutexUnLock(g_mutex); return AUDIO_ERROR; } // 更新的话,先把流从管理中删除 // 然后根据新的策略,把老流的信息该更新了 // 通知外界流销毁了 - MediaMutexLock(g_mutex); DeleteOneStream(streamId, true); #ifdef SUPPORT_SET_DSP_CLOCK_FREQ if (IsAllStreamDestroyed(streamType)) { @@ -809,19 +810,16 @@ static int32_t StreamMgrSetTypeVolumeInner(int32_t streamType, float typeVolume, if (streamType == AUDIO_STREAM_VOICE_CALL_VOLTE) { int32_t ret = SetSourceVolume(streamHandle, typeVolume); if (ret == AUDIO_ERROR) { - MediaMutexUnLock(g_mutex); return AUDIO_ERROR; } } else { // 获取混音比例,这个是不是也应该放在 trackcontext 更合适,目前先这么实现 float mixWeight; if (!GetStreamMixWeight(streamHandle, &mixWeight)) { - MediaMutexUnLock(g_mutex); return AUDIO_ERROR; } int32_t ret = SetTrackVolume(streamHandle, typeVolume, mixWeight, NOT_SET_STREAM_VOLUME); if (ret == AUDIO_ERROR) { - MediaMutexUnLock(g_mutex); return AUDIO_ERROR; } } diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/track_handle.c b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/track_handle.c index 6e6ccedf8..32086604d 100644 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/track_handle.c +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audioservice/src/streammanager/src/track_handle.c @@ -89,6 +89,7 @@ int32_t DestroyTrackHandle(uintptr_t handle) { TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); + MediaMutexLock(context->deviceChangeMutex); ALOGI("type is:%s", StringType(context->streamInfo.streamType)); uint32_t validFwDevice = context->userAudioOutDevice == 0 ? context->defalutAudioOutDevice : @@ -107,6 +108,7 @@ EXIT: free(context->keyValueList); context->keyValueList = NULL; } + MediaMutexUnLock(context->deviceChangeMutex); MediaMutexDestroy(&context->deviceChangeMutex); free(context); return ret; @@ -268,7 +270,6 @@ inline static bool IsVolumeValid(float volumeAbout) static int32_t ChangeRouteInner(TrackHandleContext *context, int32_t deviceId) { CHK_NULL_RETURN(context->render, AUDIO_ERROR, "hal render is NULL"); - // 1. process cur stream int32_t ret = ProcessCurStream(context); CHK_FAILED_RETURN(ret, AUDIO_SUCCESS, AUDIO_ERROR, "process cur stream fail"); @@ -316,7 +317,6 @@ static int32_t ChangeRouteInner(TrackHandleContext *context, int32_t deviceId) return ret; } } - context->userAudioOutDevice = (uint32_t)deviceId; return AUDIO_SUCCESS; } @@ -362,14 +362,14 @@ int32_t SetTrackOutputDevice(uintptr_t handle, int32_t deviceId, const AudioStre if (context->state == IDLE) { context->userAudioOutDevice = (uint32_t)deviceId; } else if (context->state == RUNNING) { - (void)context->callback(context->caller, AUDIO_EVENT_OUTPUT_DEVICE_CHANGED, NULL); - if (ChangeRouteInner(context, deviceId) != AUDIO_SUCCESS) { - goto ERR; - } - } else if (context->state == PAUSE) { - context->routeChangedDevice = (uint32_t)deviceId; - } else { - ALOGE("bad state[%d]", context->state); + (void)context->callback(context->caller, AUDIO_EVENT_OUTPUT_DEVICE_CHANGED, NULL); + if (ChangeRouteInner(context, deviceId) != AUDIO_SUCCESS) { + goto ERR; + } + } else if (context->state == PAUSE) { + context->routeChangedDevice = (uint32_t)deviceId; + } else { + ALOGE("bad state[%d]", context->state); goto ERR; } MediaMutexUnLock(context->deviceChangeMutex); @@ -512,10 +512,13 @@ int32_t StartTrack(uintptr_t handle) { TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); + MediaMutexLock(context->deviceChangeMutex); if (context->state == RUNNING) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } if (context->state == STOP) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } // 暂停后恢复分 主动暂停后恢复 和 被动暂停后恢复, @@ -523,19 +526,17 @@ int32_t StartTrack(uintptr_t handle) // 由于目前还不能区分是哪种恢复,因此统一处理 // 被动暂停后恢复典型场景分析: // 例如A1-A2混音,此时B抢占A1A2,待B结束,要恢复A1A2其中一个时(定为Ax),Ax需要重新计算权重 - int32_t ret; if (context->state == PAUSE) { // 蓝牙音乐中途接听蓝牙电话,通话中途手表去使能,此时手机和蓝牙设备同时和手表断开, // 蓝牙音乐恢复和输出设备切换从不同线程触发,同时访问底层蓝牙插件资源,需要加锁保证时序 - MediaMutexLock(context->deviceChangeMutex); - ret = ResumeTrack(context); + int32_t ret = ResumeTrack(context); MediaMutexUnLock(context->deviceChangeMutex); return ret; } - // IDLE 状态要把 hal 创建起来 - ret = CreateAudioRenderHandle(context); + int32_t ret = CreateAudioRenderHandle(context); if (ret != AUDIO_SUCCESS) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } if (!CheckRenderValid(context->render)) { @@ -559,10 +560,12 @@ int32_t StartTrack(uintptr_t handle) if (SetVolumeAndSetMute(context) != AUDIO_SUCCESS) { goto DESTROY_RENDER_HANDLE; } + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; DESTROY_RENDER_HANDLE: DestroyAudioRenderHandle(context); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } @@ -631,7 +634,6 @@ int32_t SetTrackVolume(uintptr_t handle, float typeVolume, float mixWeight, floa MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_BAD_STATE; } - MediaMutexUnLock(context->deviceChangeMutex); if (context->keyValueList != NULL) { if (SetExtraData(context) != AUDIO_SUCCESS) { ALOGI("set volume extra data failed!"); @@ -662,9 +664,11 @@ int32_t SetTrackVolume(uintptr_t handle, float typeVolume, float mixWeight, floa goto ERROR; } } + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; ERROR: + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } @@ -681,15 +685,19 @@ int32_t SetStreamPlayBackSpeed(uintptr_t handle, float speed) TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); // 状态 + MediaMutexLock(context->deviceChangeMutex); if (context->state == STOP) { ALOGE("track[%d] is stop", context->streamId); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } // 调南向 int32_t ret = context->render->SetRenderSpeed(context->render, speed); if (ret != AUDIO_SUCCESS) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } @@ -698,6 +706,7 @@ int32_t StreamWriteTrack(uintptr_t handle, const uint8_t *buffer, uint64_t buffe TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); // 状态 + MediaMutexLock(context->deviceChangeMutex); if (context->state != RUNNING) { // 场景B打断场景A,策略结果是场景A业务暂停,由于中断结果上报和场景B业务启动是异步的, // 因此当场景B业务启动时,场景A业务可能还未响应暂停,此时流管理模块会检查老流状态, @@ -709,10 +718,10 @@ int32_t StreamWriteTrack(uintptr_t handle, const uint8_t *buffer, uint64_t buffe ALOGE("track[%d] is neither running or pause, write failed", context->streamId); } *replyBytes = 0; + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } // 调南向 - MediaMutexLock(context->deviceChangeMutex); if (context->render == NULL) { MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; @@ -751,19 +760,24 @@ int32_t SetTrackMute(uintptr_t handle, bool mute) TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); // 状态 + MediaMutexLock(context->deviceChangeMutex); if (context->state == STOP) { ALOGE("track[%d] state is wrong, mute fail", context->streamId); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_BAD_STATE; } else if (context->state == IDLE) { context->mute = mute; + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } // 调南向 int32_t ret = context->render->volume.SetMute((AudioHandle)context->render, mute); if (ret != AUDIO_SUCCESS) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } context->mute = mute; + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } @@ -780,15 +794,19 @@ int32_t GetStreamChannelId(uintptr_t handle, uint32_t *channelId) { TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); + MediaMutexLock(context->deviceChangeMutex); if (context->state != RUNNING) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_BAD_STATE; } int32_t ret = context->render->attr.GetCurrentChannelId(context->render, channelId); if (ret != AUDIO_SUCCESS) { ALOGE("Get channel id failed: 0x%x", ret); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } ALOGI("Channel id: 0x%x", *channelId); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } @@ -796,7 +814,9 @@ int32_t TrackAttachFrontend(uintptr_t handle, uint32_t frontendId) { TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); + MediaMutexLock(context->deviceChangeMutex); if (context->state != RUNNING) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_BAD_STATE; } @@ -804,14 +824,17 @@ int32_t TrackAttachFrontend(uintptr_t handle, uint32_t frontendId) int convertRet = sprintf_s(keyValuePair, sizeof(keyValuePair), "%s = %u", "attachId", frontendId); if (convertRet == AUDIO_ERROR) { ALOGE("splice key=value str fail[%d]", convertRet); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } int32_t ret = context->render->attr.SetExtraParams((AudioHandle)context->render, keyValuePair); if (ret != AUDIO_SUCCESS) { ALOGE("set front end id failed: 0x%x", ret); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } ALOGI("frontend Id: 0x%x", frontendId); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } @@ -877,15 +900,19 @@ int32_t TrackFlush(uintptr_t handle) TrackHandleContext *context = (TrackHandleContext *)handle; CHK_NULL_RETURN(context, AUDIO_ERROR, "track handle is NULL"); // 状态 + MediaMutexLock(context->deviceChangeMutex); if (context->state != PAUSE) { ALOGE("track[%d] state is wrong, mute fail", context->streamId); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } // 调南向 int32_t ret = context->render->control.Flush((AudioHandle)context->render); if (ret != AUDIO_SUCCESS) { + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } @@ -926,6 +953,7 @@ int32_t SetTrackParam(uintptr_t handle, const char *keyValueList, size_t len) ALOGE("len invalid "); return AUDIO_ERROR; } + MediaMutexLock(context->deviceChangeMutex); if (context->keyValueList != NULL) { free(context->keyValueList); context->keyValueList = NULL; @@ -933,6 +961,7 @@ int32_t SetTrackParam(uintptr_t handle, const char *keyValueList, size_t len) context->keyValueList = malloc(len + 1); if (context->keyValueList == NULL) { ALOGE("malloc failed"); + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } int32_t ret = memcpy_s(context->keyValueList, len + 1, keyValueList, len); @@ -940,16 +969,18 @@ int32_t SetTrackParam(uintptr_t handle, const char *keyValueList, size_t len) ALOGE("memcpy_s failed"); free(context->keyValueList); context->keyValueList = NULL; + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_ERROR; } if (context->render != NULL) { ret = SetExtraData(context); if (ret != AUDIO_SUCCESS) { ALOGE("Set extra data failed! ret = %d", ret); + MediaMutexUnLock(context->deviceChangeMutex); return ret; } } - + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } @@ -962,13 +993,16 @@ int32_t GetTrackParam(uintptr_t handle, char *keyValueList, size_t len) ALOGE("len invalid "); return AUDIO_ERROR; } + MediaMutexLock(context->deviceChangeMutex); if (context->render != NULL) { int32_t ret = context->render->attr.GetExtraParams((AudioHandle)context->render, keyValueList, (int32_t)len); if (ret != AUDIO_SUCCESS) { ALOGE("get extra data failed! ret = %d", ret); + MediaMutexUnLock(context->deviceChangeMutex); return ret; } } + MediaMutexUnLock(context->deviceChangeMutex); return AUDIO_SUCCESS; } diff --git a/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.cpp b/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.cpp index 733262176..28452ab30 100644 --- a/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.cpp +++ b/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.cpp @@ -1075,7 +1075,7 @@ void PlayerControl::ReportRenderPosition(void) CHECK_NULL_RETURN_NONE(sinkManager_, "sinkManager_ nullptr"); sinkManager_->GetRenderPosition(position); if (position >= 0 && currentPosition_ != position) { - if (lastRendPos_ > 0) { + if (lastRendPos_ >= 0) { currentPosition_ = position - lastRendPos_ + firstPosAfterSeek_; } else { currentPosition_ = position; diff --git a/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp b/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp index 1f237e743..a9bf045cb 100644 --- a/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp +++ b/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp @@ -1275,6 +1275,7 @@ int32_t Player::PlayerImpl::GetParameter(Format ¶ms) goto EXIT; } } + MediaMutexUnLock(lock_); return 0; EXIT: MediaMutexUnLock(lock_); diff --git a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h index 19ac2dcbb..1f44dace5 100644 --- a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h +++ b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h @@ -77,7 +77,9 @@ public: bool ResetPlayer(); void ReleaseEventListeners(); - +#ifdef HMF_DECRYPT_DATA_ENABLE + void SetDecryptLibraryPath(char *path, uint32_t len); +#endif void ReleaseSrc(); bool Play(); @@ -118,7 +120,7 @@ public: bool SetAutoPlay(bool autoPlay); - bool SetLoop(bool loop) const; + bool SetLoop(bool loop); bool SetVolume(double volume); @@ -155,6 +157,8 @@ public: void SetOnTimeUpdateListener(AudioEventListener *onTimeUpdateListener); int32_t GetSrcInnerPrefix(const char *src, char *dest); + + bool IsSysSrc(); private: AudioPlayer(); ~AudioPlayer(); @@ -176,9 +180,11 @@ private: bool autoPlay_; bool isRunning_; bool isSysSrc_; + bool isPlayList_; + AudioPlayerLoopMode playLoopMode_ = AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP; MediaThreadIdHandle updateTimeProcess_; AudioStreamType streamType_ = AUDIO_STREAM_MUSIC; }; } // namespace ACELite } // namespace OHOS -#endif // AUDIO_PLAYER_H \ No newline at end of file +#endif // AUDIO_PLAYER_H diff --git a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_module.cpp b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_module.cpp index a13e2c7e6..b1bd861cd 100644 --- a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_module.cpp +++ b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_module.cpp @@ -17,16 +17,17 @@ #include "media_log.h" #include "js_async_work.h" #ifdef HMF_DECRYPT_DATA_ENABLE -#include "js_ability.h" -#include "audio_decrypt.h" +#include "js_ability.h" +#include "audio_decrypt.h" #endif namespace OHOS { namespace ACELite { constexpr char PROP_SUCCESS[] = "success"; constexpr char PROP_COMPLETE[] = "complete"; constexpr char DECRYPT_FILE_PATH[] = "/user/app/user/ace/data/%s/rawfile/lib/audio_decode.bin"; -constexpr uint32_t MAX_PATH_LEN = 128; +constexpr uint32_t MAX_PATH_LEN = 256; constexpr char PATH_PREFIX[] = "internal://"; +constexpr char PATH_SANDBOX_KEYWORD[] = "/assets/entry/"; static Audio::AudioManager& g_amInstance = Audio::AudioManager::GetInstance(); @@ -41,9 +42,6 @@ void AudioModule::OnTerminate() } audioPlayer->ReleaseEventListeners(); audioPlayer->StopUpdateTimeThread(); -#ifdef HMF_DECRYPT_DATA_ENABLE - AUDIO_UnLoadDecryptLibrary(); -#endif } void AudioModule::DefineProperty(JSIValue target, @@ -116,7 +114,7 @@ JSIValue AudioModule::GetPlayState(const JSIValue thisVal, const JSIValue *args, JSI::SetBooleanProperty(data, "muted", audioPlayer->IsMuted()); JSIValue params[1] = { data }; JSI::CallFunction(successCallback, thisVal, params, 1); - JSI::ReleaseValue(successCallback); + JSI::ReleaseValueList(successCallback, data); } JSIValue completeCallback = JSI::GetNamedProperty(options, PROP_COMPLETE); @@ -133,7 +131,17 @@ JSIValue AudioModule::SrcGetter(const JSIValue thisVal, const JSIValue *args, ui MEDIA_UNUSED(thisVal); MEDIA_UNUSED(args); MEDIA_UNUSED(argsSize); - char *src = AudioPlayer::GetInstance()->GetSrc(false); + char *src; + if (!AudioPlayer::GetInstance()->IsSysSrc()) { + char *sysSrc = AudioPlayer::GetInstance()->GetSrc(true); + std::string sysPath(sysSrc); + int size = sysPath.find(PATH_SANDBOX_KEYWORD) + strlen(PATH_SANDBOX_KEYWORD); + std::string path = sysPath.substr(size); + path.insert(0, PATH_PREFIX); + src = const_cast(path.c_str()); + } else { + src = AudioPlayer::GetInstance()->GetSrc(false); + } return (src == nullptr) ? JSI::CreateUndefined() : JSI::CreateString(src); } @@ -155,7 +163,18 @@ JSIValue AudioModule::SrcSetter(const JSIValue thisVal, const JSIValue *args, ui } char *src = JSI::ValueToString(args[0]); bool autoPlay = AudioPlayer::GetInstance()->GetAutoPlay(); - bool ret = AudioPlayer::GetInstance()->SetSrc(src, false); + bool ret = false; + int size = strlen(PATH_PREFIX); + std::string strValue(src); + if (strValue.find(PATH_PREFIX) == 0) { + std::string strNew = strValue.substr(size); + char *innerPath = const_cast(strNew.c_str()); + ret = AudioPlayer::GetInstance()->SetSrc(innerPath, true); + delete src; + } else { + ret = AudioPlayer::GetInstance()->SetSrc(src, false); + } + AudioPlayer::GetInstance()->SetStreamType(g_streamType); if (autoPlay) { AudioPlayer::GetInstance()->Play(); @@ -206,8 +225,8 @@ JSIValue AudioModule::SetSrcList(const JSIValue thisVal, const JSIValue *args, u return JSI::CreateBoolean(false); } srcList.push_back(std::string(absPath)); - } else { - srcList.push_back(strValue); + } else { + srcList.push_back(strValue); } } bool ret = AudioPlayer::GetInstance()->SetSrcList(srcList); @@ -537,14 +556,14 @@ static void InitAdioPlayer() MEDIA_ERR_LOG("get package name fail"); return; } - char decfilePath[256] = {0}; + char decfilePath[MAX_PATH_LEN] = {0}; int32_t ret = snprintf_s(decfilePath, sizeof(decfilePath), sizeof(decfilePath) - 1, DECRYPT_FILE_PATH, bundleName); if (ret < 0) { MEDIA_ERR_LOG("format decrypt file path fail"); return; } - AUDIO_LoadDecryptLibrary(decfilePath); + AudioPlayer::GetInstance()->SetDecryptLibraryPath(decfilePath, MAX_PATH_LEN); #endif } diff --git a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_player.cpp b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_player.cpp index 04d3a22f3..7755d1c45 100644 --- a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_player.cpp +++ b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/src/audio_player.cpp @@ -39,7 +39,6 @@ constexpr uint16_t MAX_VOLUME = 100; constexpr double DEFAULT_VOLUME = 1.0; constexpr double MILLISECONDS_PER_SECOND = 1000.0; constexpr uint32_t MICROSECONDS_PER_SECOND = 1000 * 1000; -constexpr uint32_t MAX_PATH_LEN = 128; char absPath[MAX_PATH_LEN] = {0}; static Audio::AudioManager &g_amInstance = Audio::AudioManager::GetInstance(); @@ -177,7 +176,7 @@ AudioPlayer::AudioPlayer() : onPlayListener_(nullptr), onPauseListener_(nullptr), onStopListener_(nullptr), onLoadedDataListener_(nullptr), onEndedListener_(nullptr), onErrorListener_(nullptr), onTimeUpdateListener_(nullptr), src_(nullptr), srcInner_(nullptr), status_(STATUS_STOP), volume_(DEFAULT_VOLUME), - autoPlay_(false), isRunning_(false), isSysSrc_(false), updateTimeProcess_(nullptr) + autoPlay_(false), isRunning_(false), isSysSrc_(false), isPlayList_(false), updateTimeProcess_(nullptr) {} AudioPlayer::~AudioPlayer() @@ -271,6 +270,7 @@ void AudioPlayer::StopUpdateTimeThread() bool AudioPlayer::ResetPlayer() { ReleaseSrc(); + isPlayList_ = false; if (AudioPlayerService::GetInstance()->Reset() != 0) { MEDIA_ERR_LOG("fail to reset audio."); return false; @@ -303,11 +303,24 @@ void AudioPlayer::ReleaseSrc() (void)memset_s(absPath, MAX_PATH_LEN, 0, MAX_PATH_LEN); } +#ifdef HMF_DECRYPT_DATA_ENABLE +void AudioPlayer::SetDecryptLibraryPath(char *path, uint32_t len) +{ + AudioPlayerService::GetInstance()->SetDecryptLibraryPath(path, len); +} +#endif + bool AudioPlayer::Play() { if (AudioPlayerService::GetInstance()->GetPlayStatus() == (int32_t)AudioPlayerStates::AUDIO_PLAYER_PAUSED) { - return AudioPlayerService::GetInstance()->Resume(); + if (AudioPlayerService::GetInstance()->Resume() != 0) { + MEDIA_ERR_LOG("resume failed!"); + return false; + } + MediaThreadCondSignal(condition_); + status_ = STATUS_PLAY; + return true; } if (AudioPlayerService::GetInstance()->SetAudioStreamType(streamType_) != 0) { MEDIA_ERR_LOG("fail to SetAudioStreamType streamType = %x.", streamType_); @@ -356,6 +369,7 @@ char *AudioPlayer::GetSrc(bool innerFlag) const if (!str.empty()) { (void)memset_s(absPath, MAX_PATH_LEN, 0, MAX_PATH_LEN); if (strcpy_s(absPath, MAX_PATH_LEN, str.c_str()) != EOK) { + MEDIA_ERR_LOG("strcpy_s failed"); return nullptr; } return absPath; @@ -366,11 +380,20 @@ char *AudioPlayer::GetSrc(bool innerFlag) const bool AudioPlayer::SetSrcList(std::vector srcList) { + if (src_ != nullptr || + srcInner_ != nullptr) { + MEDIA_ERR_LOG("the src interface should not be called before setting the playlist!"); + return false; + } int32_t ret = AudioPlayerService::GetInstance()->SetPlayListSource(srcList); if (ret != 0) { MEDIA_ERR_LOG("audio player set play list failed!."); return false; } + isPlayList_ = true; + if (playLoopMode_ != AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP) { + return SetLoop(true); + } return true; } @@ -421,6 +444,9 @@ bool AudioPlayer::GetAutoPlay() const bool AudioPlayer::IsLooping() const { + if (isPlayList_) { + return AudioPlayerService::GetInstance()->IsPlayListLooping(); + } return AudioPlayerService::GetInstance()->IsSingleLooping(); } @@ -477,6 +503,9 @@ bool AudioPlayer::SetSrc(char *src, bool innerFlag) MEDIA_ERR_LOG("fail to Set PlaySource."); return false; } + if (!isPlayList_ && playLoopMode_ != AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP) { + return SetLoop(true); + } return true; } @@ -505,10 +534,17 @@ bool AudioPlayer::SetAutoPlay(bool autoPlay) return true; } -bool AudioPlayer::SetLoop(bool loop) const +bool AudioPlayer::SetLoop(bool loop) { - if (AudioPlayerService::GetInstance()->SetSingleLoop(loop) != 0) { - MEDIA_ERR_LOG("1 argument is required."); + if (isPlayList_) { + playLoopMode_ = loop ? AudioPlayerLoopMode::AUDIO_PLAYER_PLAYLIST_LOOP: + AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP; + } else { + playLoopMode_ = loop ? AudioPlayerLoopMode::AUDIO_PLAYER_SINGLE_LOOP: + AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP; + } + if (AudioPlayerService::GetInstance()->SetPlayLoopMode(playLoopMode_) != 0) { + MEDIA_ERR_LOG("set single loop failed!"); return false; } return true; @@ -637,5 +673,11 @@ void AudioPlayer::SetOnTimeUpdateListener(AudioEventListener *onTimeUpdateListen } onTimeUpdateListener_ = onTimeUpdateListener; } + +bool AudioPlayer::IsSysSrc() +{ + return isSysSrc_; +} + } // namespace ACELite } // namespace OHOS diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/CMakeLists.txt b/code/sdk/middleware/services/media/foundation/sample/wrapper/CMakeLists.txt index 39c6696e9..5b1e3e7d2 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/CMakeLists.txt +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/CMakeLists.txt @@ -86,7 +86,7 @@ if ("${CHIP}" STREQUAL "brandy") ) endif() -set(CCDEFINES ${CCDEFINES} "_GNU_SOURCE" "_XOPEN_SOURCE=700" "LOCAL_VOICE_CALL") +set(CCDEFINES ${CCDEFINES} "_GNU_SOURCE" "_XOPEN_SOURCE=700" "LOCAL_VOICE_CALL" "HMF_DECRYPT_DATA_ENABLE") list(REMOVE_ITEM CCDEFINES VERSION_STANDARD) set(PRIVATE_DEFINES ${CCDEFINES} diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_manager_c_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_manager_c_wrapper.cpp index 2e24acda0..a804a4f72 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_manager_c_wrapper.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_manager_c_wrapper.cpp @@ -734,6 +734,7 @@ static int32_t AudioManagerA2dpInit(AudioManagerA2dpContext *a2dpContext, bool i return AUDIO_SUCCESS; exit: + (void)ConnectBluetoothA2dpDevice(); g_amInstance.SetDeviceConnectionState(IN_BLUETOOTH_A2DP, AUDIO_DEVICE_DISCONNECTED); g_amInstance.DeactivateAudioInterrupt(a2dpContext->interrupt); return ret; diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.cpp index a1988a6e9..c68e63bf0 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.cpp @@ -8,6 +8,11 @@ #include "audio_player_service.h" #include "audio_manager.h" #include "media_log.h" +#include "securec.h" +#ifdef HMF_DECRYPT_DATA_ENABLE +#include "audio_decrypt.h" +#endif // HMF_DECRYPT_DATA_ENABLE + namespace OHOS { static AudioManager &g_amInstance = AudioManager::GetInstance(); @@ -55,7 +60,7 @@ void AudioPlayerService::OnPlaybackComplete() MEDIA_INFO_LOG("on playback complete!"); } MediaMutexLock(mutex_); - if (!isPlayListLoop_) { + if (playerLoopMode_ != AudioPlayerLoopMode::AUDIO_PLAYER_PLAYLIST_LOOP) { MediaMutexUnLock(mutex_); return; } @@ -174,7 +179,7 @@ int32_t AudioPlayerService::AudioPlayInner(void) MEDIA_ERR_LOG("player start failed!"); return ret; } - player_->EnableSingleLooping(isSingleLoop_); + player_->EnableSingleLooping(playerLoopMode_ == AudioPlayerLoopMode::AUDIO_PLAYER_SINGLE_LOOP); currentState_ = AudioPlayerStates::AUDIO_PLAYER_PLAYED; isCutSong_ = false; OnPlay(); @@ -185,7 +190,6 @@ int32_t AudioPlayerService::AudioPlay(void) { player_->SetPlayerCallback(shared_from_this()); int32_t ret = 0; - MediaMutexLock(mutex_); if (currentState_ != AudioPlayerStates::AUDIO_PLAYER_PAUSED) { ret = AudioPlayInner(); if (ret != 0) { @@ -208,13 +212,11 @@ int32_t AudioPlayerService::AudioPlay(void) } } } - MediaMutexUnLock(mutex_); return MEDIA_OK; EXIT: MEDIA_ERR_LOG("play failed"); (void)player_->Reset(); (void)player_->Release(); - MediaMutexUnLock(mutex_); return MEDIA_ERR; } @@ -269,29 +271,33 @@ int32_t AudioPlayerService::RunAudioPlay(void) !isPlaybackStopped_ && !interruptHintStop_) { std::map header; + MediaMutexLock(mutex_); Source source = Source(playList_[playIndex_], header); MEDIA_INFO_LOG("current play source = %s, index = %d", source.GetSourceUri().c_str(), playIndex_); ret = player_->SetSource(source); if (ret != MEDIA_OK) { MEDIA_ERR_LOG("set source failed"); + MediaMutexUnLock(mutex_); (void)DeinitPlayerResources(); return MEDIA_ERR; } ret = player_->Prepare(); if (ret != MEDIA_OK) { MEDIA_ERR_LOG("prepare failed"); + MediaMutexUnLock(mutex_); return ReleasePlayer(); } ret = SetAudioSessionIdAndStreamType(); if (ret != MEDIA_OK) { + MediaMutexUnLock(mutex_); return ReleasePlayer(); } ret = AudioPlay(); if (ret != MEDIA_OK) { + MediaMutexUnLock(mutex_); return ReleasePlayer(); } - MediaMutexLock(mutex_); AudioStopAndExit(); if (!isCutSong_) { playIndex_++; @@ -299,7 +305,7 @@ int32_t AudioPlayerService::RunAudioPlay(void) playIndex_ = 0; } } - if (!isPlayListLoop_) { + if (playerLoopMode_ != AudioPlayerLoopMode::AUDIO_PLAYER_PLAYLIST_LOOP) { MediaMutexUnLock(mutex_); MEDIA_ERR_LOG("isPlayListLoop exit"); break; @@ -373,6 +379,11 @@ AudioPlayerService::AudioPlayerService() : PlayerCallback(), InterruptListener() AudioPlayerService::~AudioPlayerService() { Reset(); + if (loadDecryptPath_ != nullptr) { + delete[] loadDecryptPath_; + loadDecryptPath_ = nullptr; + loadDecryptPathLen_ = 0; + } } std::shared_ptr AudioPlayerService::GetInstance() @@ -404,7 +415,6 @@ int32_t AudioPlayerService::SetPlayListSource(std::vector playlist, } playList_ = playlist; playIndex_ = index; - isPlayListLoop_ = true; return MEDIA_OK; } @@ -436,6 +446,31 @@ int32_t AudioPlayerService::SetBackgroundMode(bool isBackground) return MEDIA_OK; } +#ifdef HMF_DECRYPT_DATA_ENABLE +void AudioPlayerService::SetDecryptLibraryPath(char *path, uint32_t len) +{ + if (loadDecryptPath_ == nullptr) { + loadDecryptPath_ = new char[len]; + loadDecryptPathLen_ = len; + } + if (loadDecryptPathLen_ != len) { + delete[] loadDecryptPath_; + loadDecryptPath_ = new char[len]; + loadDecryptPathLen_ = len; + } + if (loadDecryptPath_ == nullptr) { + MEDIA_ERR_LOG("loadDecryptPath_ new failed!"); + loadDecryptPathLen_ = 0; + return; + } + if (memcpy_s(loadDecryptPath_, loadDecryptPathLen_, path, len) != EOK) { + MEDIA_ERR_LOG("memcpy_s decrypt path failed!"); + delete[] loadDecryptPath_; + loadDecryptPath_ = nullptr; + } +} +#endif + bool AudioPlayerService::IsBackgroundMode(void) { return isBackgroundMode_; @@ -482,6 +517,11 @@ int32_t AudioPlayerService::Start(void) MEDIA_INFO_LOG("audio play is not idle status[%d], can not start!", currentState_); return MEDIA_OK; } +#ifdef HMF_DECRYPT_DATA_ENABLE + if (loadDecryptPath_ != nullptr) { + AUDIO_LoadDecryptLibrary(loadDecryptPath_); + } +#endif int32_t ret = StartPrepare(); if (ret != 0) { return ret; @@ -559,7 +599,14 @@ int32_t AudioPlayerService::Resume(void) int32_t AudioPlayerService::Reset(void) { - (void)Stop(); + if (currentState_ == AudioPlayerStates::AUDIO_PLAYER_IDLE) { + MEDIA_INFO_LOG("currently in IDLE state, no reset is required!"); + return MEDIA_OK; + } + if (currentState_ != AudioPlayerStates::AUDIO_PLAYER_STOPED) { + (void)Stop(); + } + MediaMutexLock(mutex_); playList_.clear(); playIndex_ = 0; isPlaybackCompleted_ = false; @@ -569,13 +616,16 @@ int32_t AudioPlayerService::Reset(void) interruptHintStop_ = false; isBackgroundMode_ = false; playError_ = false; - isSingleLoop_ = false; + playerLoopMode_ = AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP; isCutSong_ = false; - isPlayListLoop_ = false; currentState_ = AudioPlayerStates::AUDIO_PLAYER_IDLE; streamType_ = AUDIO_STREAM_MUSIC; + MediaMutexUnLock(mutex_); (void)MediaMutexDestroy(&mutex_); (void)MediaThreadCondDestroy(&exitCond_); +#ifdef HMF_DECRYPT_DATA_ENABLE + AUDIO_UnLoadDecryptLibrary(); +#endif MEDIA_INFO_LOG("reset success[%d]", currentState_); return MEDIA_OK; } @@ -647,7 +697,7 @@ int32_t AudioPlayerService::Stop(void) return MEDIA_ERR; } if (isPlaybackStopped_ || isPlaybackCompleted_ || interruptHintStop_) { - if (isSingleLoop_) { + if (playerLoopMode_ == AudioPlayerLoopMode::AUDIO_PLAYER_SINGLE_LOOP) { if (!isPlaybackCompleted_) { MEDIA_ERR_LOG("audio play already stopped"); MediaMutexUnLock(mutex_); @@ -719,28 +769,33 @@ int32_t AudioPlayerService::GetPlayStatus(void) return state; } -int32_t AudioPlayerService::SetSingleLoop(bool isLoop) +int32_t AudioPlayerService::SetPlayLoopMode(AudioPlayerLoopMode loopMode) { - isSingleLoop_ = isLoop; - if (player_ == nullptr) { - MEDIA_INFO_LOG("player_ is NULL!"); - return MEDIA_OK; + if (loopMode < AudioPlayerLoopMode::AUDIO_PLAYER_PLAYLIST_LOOP || + loopMode > AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP) { + MEDIA_INFO_LOG("invalid loop mode[%d]!", loopMode); + return MEDIA_ERR; } - return player_->EnableSingleLooping(isSingleLoop_); + playerLoopMode_ = loopMode; + if (player_ != nullptr) { + if (loopMode == AudioPlayerLoopMode::AUDIO_PLAYER_SINGLE_LOOP) { + return player_->EnableSingleLooping(true); + } else { + return player_->EnableSingleLooping(false); + } + } + return MEDIA_OK; } bool AudioPlayerService::IsSingleLooping(void) { - if (player_ == nullptr) { - MEDIA_INFO_LOG("player_ is NULL!"); - return isSingleLoop_; - } - return player_->IsSingleLooping(); + return playerLoopMode_ == AudioPlayerLoopMode::AUDIO_PLAYER_SINGLE_LOOP; } bool AudioPlayerService::IsPlayListLooping(void) { - return isPlayListLoop_; + + return playerLoopMode_ == AudioPlayerLoopMode::AUDIO_PLAYER_PLAYLIST_LOOP; } bool AudioPlayerService::IsPlaying(void) diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.h b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.h index 65e097b82..33ae10ae3 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.h +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_service.h @@ -30,6 +30,12 @@ enum class AudioPlayerStates : int32_t { AUDIO_PLAYER_EXITED, }; +enum class AudioPlayerLoopMode : int32_t { + AUDIO_PLAYER_PLAYLIST_LOOP, + AUDIO_PLAYER_SINGLE_LOOP, + AUDIO_PLAYER_INVAILD_LOOP, +}; + class AudioPlayerServiceCallback { public: AudioPlayerServiceCallback() = default; @@ -51,6 +57,9 @@ public: int32_t SetPlaySource(std::string src); int32_t SetAudioStreamType(AudioStreamType type); int32_t SetBackgroundMode(bool isBackground); +#ifdef HMF_DECRYPT_DATA_ENABLE + void SetDecryptLibraryPath(char *path, uint32_t len); +#endif bool IsBackgroundMode(void); void SetAudioPlayerCallback(const std::shared_ptr &cb); int32_t Start(void); @@ -64,7 +73,7 @@ public: int32_t GetDumpInfo(PlayerDebugInfo *playerInfo); int32_t GetCurrentTime(int64_t &time); int32_t GetPlayStatus(void); - int32_t SetSingleLoop(bool isLoop); + int32_t SetPlayLoopMode(AudioPlayerLoopMode loopMode); bool IsSingleLooping(void); bool IsPlayListLooping(void); bool IsPlaying(void); @@ -99,6 +108,10 @@ private: int32_t StartPrepare(void); void ResetAudioPlayState(void); static void *AudioPlayThread(void *arg); +#ifdef HMF_DECRYPT_DATA_ENABLE + char *loadDecryptPath_= nullptr; + uint32_t loadDecryptPathLen_ = 0; +#endif AudioPlayerStates currentState_ = AudioPlayerStates::AUDIO_PLAYER_IDLE; AudioSession sessionId_ = AUDIO_SESSION_ID_NONE; bool isPlaybackCompleted_ = false; @@ -108,8 +121,8 @@ private: bool interruptHintStop_ = false; bool isBackgroundMode_ = false; bool playError_ = false; - bool isSingleLoop_ = false; bool isCutSong_ = false; + AudioPlayerLoopMode playerLoopMode_ = AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP; shared_ptr player_ = nullptr; MediaMutexHandle mutex_ = nullptr; MediaThreadCondHandle cond_ = nullptr; @@ -118,7 +131,6 @@ private: int32_t playIndex_ = 0; std::vector playList_; AudioStreamType streamType_ = AUDIO_STREAM_MUSIC; - bool isPlayListLoop_ = false; static std::shared_ptr instance_; shared_ptr callBack_ = nullptr; }; diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_test.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_test.cpp index ec387ae95..889cd4491 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_test.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_player_test.cpp @@ -174,7 +174,11 @@ static int32_t SetSingleLoop(int32_t argc, const char **param) if (enableValue != 0) { isLoop = true; } - return AudioPlayerService::GetInstance()->SetSingleLoop(isLoop); + AudioPlayerLoopMode loopMode = AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP; + if (isLoop) { + loopMode == AudioPlayerLoopMode::AUDIO_PLAYER_SINGLE_LOOP; + } + return AudioPlayerService::GetInstance()->SetPlayLoopMode(loopMode); } static int32_t GetCurrentPlaySource(int32_t argc, const char **param) diff --git a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/bluetooth/bluetooth_sub_port.c b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/bluetooth/bluetooth_sub_port.c index ab04077cb..4687d8c4f 100644 --- a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/bluetooth/bluetooth_sub_port.c +++ b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/bluetooth/bluetooth_sub_port.c @@ -2864,11 +2864,9 @@ int32_t AudioBluetoothSubPortCreateTrack(AudioHandle portHandle, const struct Po goto FREE_TRACK_CTX; } - ret = SubPortTrackInit(portCtx, inputAttr, portPin, portTrackCtx); - if (ret != MEDIA_HAL_OK) { + if (SubPortTrackInit(portCtx, inputAttr, portPin, portTrackCtx) != MEDIA_HAL_OK) { goto FREE_TRACK_CTX; } - /* sound + aenc + adp for BLUETOOTH_A2DP_NORMAL workScene */ ret = EstablishTranscodeBackendPipeline(portCtx, portTrackCtx, trackId); if (ret != MEDIA_HAL_OK) { @@ -2884,8 +2882,9 @@ int32_t AudioBluetoothSubPortCreateTrack(AudioHandle portHandle, const struct Po portTrackCtx->trackId = trackId; portCtx->portTrack[trackId] = portTrackCtx; *trackHandle = &portTrackCtx->common; - /* A2dp sink 不占用蓝牙资源和aenc,所以这里默认就是暂停的状态 */ - if (portTrackCtx->workScene == BLUETOOTH_IN_A2DP_NORMAL) { + /* A2dp sink 和 sco 不占用蓝牙资源和aenc,所以这里默认就是暂停的状态 */ + if (portTrackCtx->workScene == BLUETOOTH_IN_A2DP_NORMAL || + portTrackCtx->workScene == BLUETOOTH_SCO) { SetPause(trackId, true); } MediaHalMutexUnLock(portCtx->a2dpTrackMutex); @@ -2934,7 +2933,6 @@ int32_t AudioBluetoothSubPortDestroyTrack(AudioHandle portHandle, AudioHandle tr } /* sound + aenc + adp for BLUETOOTH_A2DP_NORMAL workScene */ ret = AbrogationTranscodeBackendPipeline(portCtx, portTrackCtx); - MediaHalMutexUnLock(portCtx->a2dpTrackMutex); CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "AbrogationTranscodeBackendPipeline failed"); MEDIA_HAL_LOGD(MODULE_NAME, "success trackId (%d)", portTrackCtx->trackId); @@ -2946,6 +2944,7 @@ int32_t AudioBluetoothSubPortDestroyTrack(AudioHandle portHandle, AudioHandle tr } portCtx->portTrack[portTrackCtx->trackId] = NULL; + MediaHalMutexUnLock(portCtx->a2dpTrackMutex); free(portTrackCtx); return MEDIA_HAL_OK; } diff --git a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/common/src/plugin_common.c b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/common/src/plugin_common.c index 9393f64f4..06e4aa7cb 100644 --- a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/common/src/plugin_common.c +++ b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/common/src/plugin_common.c @@ -496,7 +496,16 @@ int32_t AudioSDKAencOpen(td_handle *aencHandle, uapi_aenc_attr aencAttr) MEDIA_HAL_LOGE(MODULE_NAME, "uapi_aenc_set_attr failed: 0x%x, codec id: 0x%x", ret, aencAttr.codec_id); goto CLOSE; } - +#ifndef MELODY_AUDIO_SUPPORT + if (aencAttr.codec_id == UAPI_ACODEC_ID_OPUS) { + uint32_t bitRate = OPUS_ENC_BIT_RATE; + ret = uapi_aenc_set_param(*aencHandle, UAPI_AENC_PARAM_BIT_RATE, &bitRate, sizeof(uint32_t)); + if (ret != MEDIA_HAL_OK) { + MEDIA_HAL_LOGE(MODULE_NAME, "uapi set aenc send cmd bit Rate faild, ret: 0x%x", ret); + goto CLOSE; + } + } +#endif MEDIA_HAL_LOGD(MODULE_NAME, "success"); return MEDIA_HAL_OK; diff --git a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c index af11daa59..092cc9b56 100644 --- a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c +++ b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c @@ -41,8 +41,6 @@ extern "C" { #define MODEM_DOWNLINK_SOUND_PORT_NUM 1 #define MODEM_HEADSET_DOWNLINK_SOUND_PORT_NUM 1 -#define MODEM_HEADSET_DOWNLINK_SOUND_SAMPLE_RATE 16000 -#define MODEM_HEADSET_DOWNLINK_SOUND_CHANNELS 1 #define MODEM_PORT_TRACK_NUM 2 #define SEA_ENABLE "seaenable" @@ -474,13 +472,13 @@ static int32_t AIDevClose(const SubPortTrackContext *portTrackCtx) return MEDIA_HAL_OK; } -static void GetHeadsetDownlinkAOAttr(uapi_snd_attr *sndAttr) +static void GetHeadsetDownlinkAOAttr(uapi_snd_attr *sndAttr, SubPortTrackContext *portTrackCtx) { sndAttr->port_num = MODEM_HEADSET_DOWNLINK_SOUND_PORT_NUM; sndAttr->port_attr[0].out_port = UAPI_SND_OUT_PORT_CAST0; sndAttr->bit_depth = UAPI_AUDIO_BIT_DEPTH_16; - sndAttr->sample_rate = MODEM_HEADSET_DOWNLINK_SOUND_SAMPLE_RATE; - sndAttr->channels = MODEM_HEADSET_DOWNLINK_SOUND_CHANNELS; + sndAttr->sample_rate = portTrackCtx->inputAttr.sampleRate; + sndAttr->channels = portTrackCtx->inputAttr.channelCount; } static int32_t AODevOpen(SubPortTrackContext *portTrackCtx) @@ -505,7 +503,7 @@ static int32_t AODevOpen(SubPortTrackContext *portTrackCtx) MEDIA_HAL_DOFUNC_TIME(ret = uapi_snd_open(&portTrackCtx->uplinkSoundHandle, sndId, &sndAttr)); } else { if (portTrackCtx->workScene == MODEM_HEADSET_DOWNLINK) { - GetHeadsetDownlinkAOAttr(&sndAttr); + GetHeadsetDownlinkAOAttr(&sndAttr, portTrackCtx); } else { GetBuiltinAOAttr(&sndAttr); } diff --git a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c index b76418d43..46071d455 100644 --- a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c +++ b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c @@ -45,6 +45,7 @@ extern "C" { #define SET_SEA_PARAM "setseaparam" #define SET_BIT_RATE "setbitrate" #define SEA_PARAM_LEN 256 +#define MP3_ENC_BIT_RATE_PRECISION 1000 static enum AudioFormat g_supportFormats[] = { AUDIO_FORMAT_PCM_16_BIT, @@ -94,10 +95,13 @@ static SubPortTrackInCapabilities g_caps[] = { { AUDIO_IN_MEDIA, AUDIO_FORMAT_MP3, 16000, 1 }, { AUDIO_IN_MEDIA, AUDIO_FORMAT_SBC, 16000, 1 }, { AUDIO_IN_MEDIA, AUDIO_FORMAT_PCM_16_BIT, 16000, 1 }, + { AUDIO_IN_MEDIA, AUDIO_FORMAT_OPUS, 16000, 1 }, { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_mSBC, 16000, 1 }, { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_AMR_WB, 16000, 1 }, { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_PCM_16_BIT, 8000, 1}, - { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_PCM_16_BIT, 16000, 1} + { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_PCM_16_BIT, 16000, 1}, + { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_OPUS, 16000, 1 }, + { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_MP3, 16000, 1 }, }; static bool IsSupported(const struct PortPluginAttr *inputAttr) @@ -250,9 +254,14 @@ static int32_t AudioSDKOpenInternal(SubPortTrackInContext *portTrackInCtx) aencAttr.param.bit_depth = inputAttrTemp.bitWidth; aencAttr.param.sample_rate = inputAttrTemp.sampleRate; aencAttr.param.samples_per_frame = ((uint32_t)inputAttrTemp.sampleRate) / SAMPLERATE_TO_PTNUMPERFRM; - aencAttr.param.private_data = NULL; - aencAttr.param.private_data_size = 0; - + uint32_t bitRate = MP3_ENC_BIT_RATE / MP3_ENC_BIT_RATE_PRECISION; + if (aencCodecId == UAPI_ACODEC_ID_MP3) { + aencAttr.param.private_data = &bitRate; + aencAttr.param.private_data_size = sizeof(bitRate); + } else { + aencAttr.param.private_data = NULL; + aencAttr.param.private_data_size = 0; + } ret = AudioSDKAencOpen(&portTrackInCtx->aencHandle, aencAttr); if (ret != MEDIA_HAL_OK) { MEDIA_HAL_LOGE(MODULE_NAME, "aenc open failed"); diff --git a/code/sdk/middleware/services/media/hal/format/src/decrypt/src/decrypt_data.c b/code/sdk/middleware/services/media/hal/format/src/decrypt/src/decrypt_data.c index 718a5eddc..1955e95ab 100644 --- a/code/sdk/middleware/services/media/hal/format/src/decrypt/src/decrypt_data.c +++ b/code/sdk/middleware/services/media/hal/format/src/decrypt/src/decrypt_data.c @@ -52,7 +52,6 @@ int32_t DeInitDecrypt(void *context) bufContext->decryptSize = 0; bufContext->pos = -1; bufContext->isNeedDecryptData = false; - AUDIO_UnLoadDecryptLibrary(); return MEDIA_HAL_OK; } diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/diag_gpu_proc.c b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/diag_gpu_proc.c index 18c3399bd..b480bdb29 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/diag_gpu_proc.c +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/diag_gpu_proc.c @@ -72,45 +72,6 @@ STATIC errcode_t diag_dpu_dfx_read(uint16_t cmd_id, diag_option_t *option, void return ret; } -STATIC errcode_t diag_gmmu_dfx_read(uint16_t cmd_id, diag_option_t *option, void *cmd_param) -{ - errcode_t ret = ERRCODE_SUCC; - if (cmd_param == NULL) { - printf(" invalid gmmu_proc cmd: should input 2 params\n"); - return ERRCODE_FAIL; - } - char *gmmu_param[GMMU_PARAM_CNT] = { NULL }; - const td_u8 str_len = 5; - for (td_u32 i = 0; i < GMMU_PARAM_CNT; i++) { - gmmu_param[i] = (char *)dfx_malloc(0, str_len); - if (gmmu_param[i] == NULL) { - if (i == 1) { - dfx_free(0, gmmu_param[0]); - } - return ERRCODE_MALLOC; - } - } - - gpu_gmmu_proc_info_t *gmmu_proc_param = (gpu_gmmu_proc_info_t *)cmd_param; - if (sprintf_s(gmmu_param[0], str_len, "%u\n", gmmu_proc_param->proc_en) == -1) { - dfx_free(0, gmmu_param[0]); - return ERRCODE_FAIL; - } - if (sprintf_s(gmmu_param[1], str_len, "%u\n", gmmu_proc_param->lut_en) == -1) { - dfx_free(0, gmmu_param[0]); - dfx_free(0, gmmu_param[1]); - return ERRCODE_FAIL; - } -#ifdef SUPPORT_GPU_GMMU - ret = (errcode_t)gmmu_dfx_print_proc_info(GMMU_PARAM_CNT, (const td_char **)gmmu_param); -#endif - uapi_diag_report_packet(cmd_id, option, (uint8_t *)("gmmu_proc_read_succ\r\n"), - (uint16_t)strlen("gmmu_proc_read_succ\r\n") + 1, true); - dfx_free(0, gmmu_param[0]); - dfx_free(0, gmmu_param[1]); - return ret; -} - STATIC errcode_t gpu_proc_read(uint16_t cmd_id, void *cmd_param, uint16_t cmd_param_size, diag_option_t *option) { unused(cmd_param_size); @@ -124,8 +85,6 @@ STATIC errcode_t gpu_proc_read(uint16_t cmd_id, void *cmd_param, uint16_t cmd_pa case DIAG_CMD_GPU_DPU_PROC: case DIAG_CMD_GPU_DPU_PRINT: return diag_dpu_dfx_read(cmd_id, option, cmd_param); - case DIAG_CMD_GPU_GMMU_PROC: - return diag_gmmu_dfx_read(cmd_id, option, cmd_param); default: printf("gpu_proc_read:invalid cmd id:%#x.\r\n", cmd_id); ret = ERRCODE_FAIL; diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-cli/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-cli/libx_vfs_private.a index b9c9f0f3c..4f71ebc7b 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-cli/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-cli/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-ser/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-ser/libx_vfs_private.a index efa27053c..dbeea41a3 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-ser/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-auto-ota-ser/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230-r/libx_vfs_private.a index a2d524c6a..d4d36d3e7 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230/libx_vfs_private.a index cf442a30a..5f8467405 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-fd230/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-r/libx_vfs_private.a index a2d524c6a..d4d36d3e7 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts-r/libx_vfs_private.a index a2d524c6a..d4d36d3e7 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts/libx_vfs_private.a index cf442a30a..5f8467405 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-native-js-xts/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-native-js/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-native-js/libx_vfs_private.a index cf442a30a..5f8467405 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-native-js/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-native-js/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target1-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target1-r/libx_vfs_private.a index 21bd179b8..53ac7549c 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target1-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target1-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target1/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target1/libx_vfs_private.a index 752546790..0e2d1efab 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target1/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target1/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target3-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target3-r/libx_vfs_private.a index f5b4aad27..6951132c1 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target3-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target3-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target3/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target3/libx_vfs_private.a index 1586052ca..ade8e668c 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target3/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target3/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target4-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target4-r/libx_vfs_private.a index 5ccbc31c7..2c25d4a38 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target4-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target4-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target4/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target4/libx_vfs_private.a index e9d3ca17e..a8eda5169 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target4/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target4/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target5-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target5-r/libx_vfs_private.a index e48f4db6e..1e71bec3a 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target5-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target5-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-target5/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-target5/libx_vfs_private.a index d161cf161..59e8e59e9 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-target5/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-target5/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-xts-r/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-xts-r/libx_vfs_private.a index 9319cc5b0..9aee13f0d 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-xts-r/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-xts-r/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/brandy-xts/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/brandy-xts/libx_vfs_private.a index b7636e93e..2469af96b 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/brandy-xts/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/brandy-xts/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/vfs/testsuite-brandy-sdk/libx_vfs_private.a b/code/sdk/middleware/utils/fs/vfs/testsuite-brandy-sdk/libx_vfs_private.a index 62f8d098e..23a8abb3e 100644 Binary files a/code/sdk/middleware/utils/fs/vfs/testsuite-brandy-sdk/libx_vfs_private.a and b/code/sdk/middleware/utils/fs/vfs/testsuite-brandy-sdk/libx_vfs_private.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-cli/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-cli/libfs_yaffs2.a index 4a79d5909..07d8ad087 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-cli/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-cli/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-ser/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-ser/libfs_yaffs2.a index a6e2bbca7..dfbf36969 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-ser/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-auto-ota-ser/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230-r/libfs_yaffs2.a index 6f9afa354..7a5f00f84 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230/libfs_yaffs2.a index 4abee5a6e..d5edc8c90 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-fd230/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-r/libfs_yaffs2.a index 6f9afa354..7a5f00f84 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts-r/libfs_yaffs2.a index 6f9afa354..7a5f00f84 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts/libfs_yaffs2.a index 4abee5a6e..d5edc8c90 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js-xts/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js/libfs_yaffs2.a index 4abee5a6e..d5edc8c90 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-native-js/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target1-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target1-r/libfs_yaffs2.a index de17759fe..c4d553a54 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target1-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target1-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target1/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target1/libfs_yaffs2.a index 09c756436..c2b76c448 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target1/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target1/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target3-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target3-r/libfs_yaffs2.a index cbb018c17..005f8eadc 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target3-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target3-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target3/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target3/libfs_yaffs2.a index bfd78d732..ad0320927 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target3/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target3/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target4-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target4-r/libfs_yaffs2.a index 5a633b783..db1bc6962 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target4-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target4-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target4/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target4/libfs_yaffs2.a index 8a952b273..f9c30b3e4 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target4/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target4/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target5-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target5-r/libfs_yaffs2.a index 8720f3ea9..f29370908 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target5-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target5-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-target5/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-target5/libfs_yaffs2.a index 170acd240..918e2f7aa 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-target5/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-target5/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-xts-r/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-xts-r/libfs_yaffs2.a index bf2fba78e..f7a618b65 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-xts-r/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-xts-r/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/brandy-xts/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/brandy-xts/libfs_yaffs2.a index 47c77344e..027f4e2e1 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/brandy-xts/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/brandy-xts/libfs_yaffs2.a differ diff --git a/code/sdk/middleware/utils/fs/yaffs2/testsuite-brandy-sdk/libfs_yaffs2.a b/code/sdk/middleware/utils/fs/yaffs2/testsuite-brandy-sdk/libfs_yaffs2.a index 3e4650da5..e8670d92f 100644 Binary files a/code/sdk/middleware/utils/fs/yaffs2/testsuite-brandy-sdk/libfs_yaffs2.a and b/code/sdk/middleware/utils/fs/yaffs2/testsuite-brandy-sdk/libfs_yaffs2.a differ diff --git a/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc.c b/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc.c index 51864b577..effd2b9aa 100644 --- a/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc.c +++ b/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc.c @@ -2300,6 +2300,8 @@ mmc_go_discovery(struct mmc_softc *sc) sc->squelched++; /* Errors are expected, squelch reporting. */ mmcbr_set_mode(dev, mode_sd); mmc_power_up(sc); + /* delay 100ms, sometimes sdio probe fail for detect as SD, maybe slave power supply not stable */ + mmc_ms_delay(100); mmcbr_set_bus_mode(dev, pushpull); #ifdef DPALCFG_DRIVERS_MMC_DBG if (bootverbose || mmc_debug) @@ -2354,6 +2356,7 @@ mmc_go_discovery(struct mmc_softc *sc) device_printf(sc->dev, "MMC probe: OK (OCR: 0x%08x)\n", ocr); #endif + dprintf("MMC probe: OK (OCR: 0x%08x)\n", ocr); } } else { #ifdef DPALCFG_DRIVERS_MMC_DBG @@ -2361,6 +2364,7 @@ mmc_go_discovery(struct mmc_softc *sc) device_printf(sc->dev, "SD probe: OK (OCR: 0x%08x)\n", ocr); #endif + dprintf("SD probe: OK (OCR: 0x%08x)\n", ocr); if ((ocr & MMC_OCR_LOW_VOLTAGE) && !(host_ocr & MMC_OCR_LOW_VOLTAGE)) { dev_logi(dev, "sd card supports 1.8v, but host can't do.\n"); ocr &= ~MMC_OCR_LOW_VOLTAGE; @@ -2474,6 +2478,7 @@ again: return; err_out: + dprintf("No compatible cards found on bus\n"); dev_logt(sc->dev, "No compatible cards found on bus\n"); if (sc->recovery == false) { err = mmc_delete_cards(sc, false); @@ -3063,8 +3068,13 @@ sdio_reset_comm(const struct sdio_func *func) sc = device_get_softc(device_get_parent(func->sc->dev)); if (sc == NULL || sc->dev == NULL) return (-EIO); + + power_cycle(sc); + host_hw_init(device_get_ivars(sc->dev)); + sc->last_rca = 0; + sc->card_init_status = MMC_CARD_UNINIT; // 需要, 否则中间过程时钟会被关掉 + mmc_idle_cards(sc); - mmcbr_set_clock(sc->dev, mmcbr_get_f_min(sc->dev)); ret = sdio_io_send_op_cond(sc, 0, &ocr); if (ret) @@ -3083,18 +3093,7 @@ sdio_reset_comm(const struct sdio_func *func) if (ret) goto err; - ret = sdio_switch_hispeed(sc, SD_SWITCH_HS_MODE); - if (ret) - goto err; - - mmcbr_set_timing(sc->dev, (int)bus_timing_sd_hs); - mmcbr_set_clock(sc->dev, mmcbr_get_f_max(sc->dev)); - ret = sdio_set_card_bus_width(sc, bus_width_4); - if (ret) - goto err; - - mmcbr_set_bus_width(sc->dev, (int)bus_width_4); - mmcbr_update_ios(sc->dev); + mmc_calculate_clock(sc); return (0); err: diff --git a/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc_subr.c b/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc_subr.c index 3eb946399..fab3fe003 100644 --- a/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc_subr.c +++ b/code/sdk/open_source/freebsd/liteos/drivers/mmc/core/mmc_subr.c @@ -90,7 +90,6 @@ mmc_wait_for_cmd(device_t busdev, device_t dev, struct mmc_command *cmd, cmd->opcode, err); } } - return (err); } diff --git a/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci.h b/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci.h index f977a2108..9fc1ce052 100644 --- a/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci.h +++ b/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci.h @@ -208,7 +208,9 @@ #define SDHCI_INT_STATUS 0x30 #define SDHCI_INT_ENABLE 0x34 +#define SDHCI_ERR_INT_STAT_EN 0x36 #define SDHCI_SIGNAL_ENABLE 0x38 +#define SDHCI_ERR_INT_SIGNAL_EN 0x3A #define SDHCI_INT_RESPONSE 0x00000001 #define SDHCI_INT_DATA_END 0x00000002 #define SDHCI_INT_BLOCK_GAP 0x00000004 diff --git a/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_init.c b/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_init.c index aa5898603..e64f1bc9e 100644 --- a/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_init.c +++ b/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_init.c @@ -388,12 +388,9 @@ hi_sdhci_attach(struct dpal_platform_device *pdev) struct hci_softc *sc; struct sdhci_slot *slot; dpal_resource_t *res; -#ifdef CFG_SDIO_EMMC_COEXIST - static bool emmc_initialized = false; - static bool sdio_initialized = false; -#else - static bool mmc_initialized = false; -#endif + static bool mmc0_initialized = false; + static bool mmc1_initialized = false; + sc = dpal_zalloc(sizeof(struct hci_softc)); if (sc == NULL) return (-ENOMEM); @@ -482,33 +479,22 @@ hi_sdhci_attach(struct dpal_platform_device *pdev) err = set_mmc_resource(sc, slot->num); if (err != 0) goto clear_mmc_proc; -#ifdef CFG_SDIO_EMMC_COEXIST - if (slot->num == 0 && !emmc_initialized) { - emmc_initialized = true; - err = sdhci_thread_create((dpal_tsk_entry_func)sdhci_task, - "cdsw_emmc_task", (uint32_t *)&slot->cd_tsk_id); + + if (slot->num == 0 && !mmc0_initialized) { + mmc0_initialized = true; + err = sdhci_thread_create((dpal_tsk_entry_func)sdhci_task, "cdsw_mmc0_task", (uint32_t *)&slot->cd_tsk_id); if (err) { goto clear_mem_resource; } } - if (slot->num == 1 && !sdio_initialized) { - sdio_initialized = true; - err = sdhci_thread_create((dpal_tsk_entry_func)sdhci_task, - "cdsw_sdio_task", (uint32_t *)&slot->cd_tsk_id); + if (slot->num == 1 && !mmc1_initialized) { + mmc1_initialized = true; + err = sdhci_thread_create((dpal_tsk_entry_func)sdhci_task, "cdsw_mmc1_task", (uint32_t *)&slot->cd_tsk_id); if (err) { goto clear_mem_resource; } } -#else - if (!mmc_initialized) { - mmc_initialized = true; - err = sdhci_thread_create((dpal_tsk_entry_func)sdhci_task, - "cdsw_task", (uint32_t *)&slot->cd_tsk_id); - if (err) { - goto clear_mem_resource; - } - } -#endif + return (0); clear_mem_resource: diff --git a/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_private.h b/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_private.h index 1e3a34474..e0fd70862 100644 --- a/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_private.h +++ b/code/sdk/open_source/freebsd/liteos/drivers/mmc/host/sdhci/sdhci_private.h @@ -43,8 +43,9 @@ #define SDHCI_ASSERT_LOCKED(_slot) mtx_assert((_slot)->mtx, MA_OWNED); //used in sdhci_exec_tuning() #define SDHCI_ASSERT_UNLOCKED(_slot) mtx_assert((_slot)->mtx, MA_NOTOWNED); //not used +#define SDHCI_MBIU_CTRL 0x510 #define SDHCI_EMMC_HW_RESET 0x534 -#define SDHCI_AUTO_TUNING_CTRL 0x540 +#define SDHCI_AUTO_TUNING_CTRL 0x540 #define SDHCI_SW_TUNING_EN 0x00000010 #define SDHCI_AUTO_TUNING_STATUS 0x544 diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/display/interfaces/include/display_vgu.h b/code/sdk/open_source/openharmony/drivers/peripheral/display/interfaces/include/display_vgu.h index b3dc9caaa..04dded13c 100644 --- a/code/sdk/open_source/openharmony/drivers/peripheral/display/interfaces/include/display_vgu.h +++ b/code/sdk/open_source/openharmony/drivers/peripheral/display/interfaces/include/display_vgu.h @@ -480,7 +480,7 @@ typedef struct { * {@link VGResult} otherwise. * @since 3.0 */ - VGUResult (*RenderBlur)(VGUSurface *target, uint16_t blur); + VGUResult (*RenderBlur)(VGUSurface *target, float blur); /* * * @brief Blits one or multiple images to target surface. diff --git a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-cli/libams.a b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-cli/libams.a index d010527c6..9b9821112 100644 Binary files a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-cli/libams.a and b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-cli/libams.a differ diff --git a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-ser/libams.a b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-ser/libams.a index 751983531..c61d30cb4 100644 Binary files a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-ser/libams.a and b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-auto-ota-ser/libams.a differ diff --git a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-fd230/libams.a b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-fd230/libams.a index 8398f08b6..ce7a53da8 100644 Binary files a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-fd230/libams.a and b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-fd230/libams.a differ diff --git a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-xts/libams.a b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-xts/libams.a index 8398f08b6..ce7a53da8 100644 Binary files a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-xts/libams.a and b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js-xts/libams.a differ diff --git a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js/libams.a b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js/libams.a index 8398f08b6..ce7a53da8 100644 Binary files a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js/libams.a and b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-native-js/libams.a differ diff --git a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-xts/libams.a b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-xts/libams.a index 764abd73f..cc6ff5d17 100644 Binary files a/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-xts/libams.a and b/code/sdk/open_source/openharmony/foundation/aafwk/aafwk_lite/brandy-xts/libams.a differ diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/CMakeLists.txt b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/CMakeLists.txt index 80d117424..0c1478344 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/CMakeLists.txt +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/CMakeLists.txt @@ -227,6 +227,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/base/global/resmgr_lite/frameworks/resmgr_lite/include ${ROOT_DIR}/open_source/openharmony/base/global/resmgr_lite/interfaces/innerkits/include ${ROOT_DIR}/open_source/openharmony/foundation/ace/ace_engine_lite/modules/keyinput + ${ROOT_DIR}/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network ${ROOT_DIR}/open_source/openharmony/base/sensors/location/interfaces/kits/include ${ROOT_DIR}/open_source/openharmony/base/sensors/interfaces/kits/native/include ) @@ -266,7 +267,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/components/baidu_map_component.cpp ${CMAKE_CURRENT_SOURCE_DIR}/modules/app_module.cpp ${CMAKE_CURRENT_SOURCE_DIR}/modules/device_module.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/modules/network_module.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modules/network/network_module.cpp ${CMAKE_CURRENT_SOURCE_DIR}/modules/nfc_module.cpp ${CMAKE_CURRENT_SOURCE_DIR}/modules/vibrator_module.cpp ${CMAKE_CURRENT_SOURCE_DIR}/modules/battery_module.cpp diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/js_fwk_common.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/js_fwk_common.h index 546db4892..b7ee4182e 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/js_fwk_common.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/js_fwk_common.h @@ -125,6 +125,7 @@ constexpr char ATTR_HEIGHT[] = "height"; // tab-bar | image-animator constexpr char ATTR_LEFT[] = "left"; // image-animator constexpr char ATTR_TOP[] = "top"; // image-animator constexpr char ATTR_TYPE[] = "type"; +constexpr char ATTR_LOOP[] = "loop"; constexpr char COMMON_STYLE_BACKGROUND_COLOR[] = "backgroundColor"; constexpr char ARG_WATCH_EL[] = "el"; constexpr char ARG_WATCH_ATTR[] = "attr"; diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-cli/libace.a b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-cli/libace.a index 56e327603..b9e83392d 100644 Binary files a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-cli/libace.a and b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-cli/libace.a differ diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-ser/libace.a b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-ser/libace.a index c39cd16a4..7f42d3148 100644 Binary files a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-ser/libace.a and b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-auto-ota-ser/libace.a differ diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-fd230/libace.a b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-fd230/libace.a index a56a99c1e..634ec02d2 100644 Binary files a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-fd230/libace.a and b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-fd230/libace.a differ diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-xts/libace.a b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-xts/libace.a index a56a99c1e..634ec02d2 100644 Binary files a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-xts/libace.a and b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js-xts/libace.a differ diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js/libace.a b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js/libace.a index a56a99c1e..634ec02d2 100644 Binary files a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js/libace.a and b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-native-js/libace.a differ diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-xts/libace.a b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-xts/libace.a index b9fda9533..4c139f258 100644 Binary files a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-xts/libace.a and b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/brandy-xts/libace.a differ diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/canvas_component.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/canvas_component.cpp index 6d9a3aded..86fd6892b 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/canvas_component.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/canvas_component.cpp @@ -963,7 +963,13 @@ jerry_value_t CanvasComponent::Rotate(const jerry_value_t func, } float angle = FloatOf(args[ArgsIndex::IDX_0]); - component->paint_.Rotate(angle); + if (argsNum < ArgsCount::NUM_3) { + component->paint_.Rotate(angle); + } else { + int16_t x = IntegerOf(args[ArgsIndex::IDX_1]); + int16_t y = IntegerOf(args[ArgsIndex::IDX_2]); + component->paint_.Rotate(angle, x, y); + } return UNDEFINED; } diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.cpp index fc8c726ed..fedbd8cb8 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.cpp @@ -80,6 +80,7 @@ Component::Component(jerry_value_t options, jerry_value_t children, AppStyleMana onTouchMoveListener_(nullptr), onTouchCancelListener_(nullptr), onTouchEndListener_(nullptr), + onTouchListener_(nullptr), keyBoardEventListener_(nullptr), #endif onRotateListener_(nullptr), @@ -1123,6 +1124,15 @@ void Component::SetClickEventListener(UIView &view, const jerry_value_t eventFun view.SetTouchable(true); } +void Component::SetViewOnTouchListener(UIView &view) +{ + if (view.GetTouchListener() != nullptr) { + onTouchListener_ = dynamic_cast(view.GetTouchListener()); + } else { + onTouchListener_ = new ViewOnTouchListener(); + } +} + #ifdef JS_TOUCH_EVENT_SUPPORT void Component::SetTouchStartEventListener(UIView &view, jerry_value_t eventFunc, uint16_t eventTypeId) { @@ -1132,7 +1142,9 @@ void Component::SetTouchStartEventListener(UIView &view, jerry_value_t eventFunc return; } - view.SetOnTouchListener(onTouchStartListener_); + SetViewOnTouchListener(view); + onTouchListener_->SetOnTouchStartListener(onTouchStartListener_); + view.SetOnTouchListener(onTouchListener_); view.SetTouchable(true); } @@ -1143,8 +1155,9 @@ void Component::SetTouchMoveEventListener(UIView &view, jerry_value_t eventFunc, HILOG_ERROR(HILOG_MODULE_ACE, "touch start event listener create failed"); return; } - - view.SetOnDragListener(onTouchMoveListener_); + SetViewOnTouchListener(view); + onTouchListener_->SetOnTouchMoveListener(onTouchMoveListener_); + view.SetOnDragListener(onTouchListener_); view.SetTouchable(true); view.SetDraggable(true); } @@ -1157,7 +1170,9 @@ void Component::SetTouchCancelEventListener(UIView &view, jerry_value_t eventFun return; } - view.SetOnTouchListener(onTouchCancelListener_); + SetViewOnTouchListener(view); + onTouchListener_->SetOnTouchCancelListener(onTouchCancelListener_); + view.SetOnTouchListener(onTouchListener_); view.SetTouchable(true); view.SetDraggable(true); } @@ -1170,7 +1185,9 @@ void Component::SetTouchEndEventListener(UIView &view, jerry_value_t eventFunc, return; } - view.SetOnTouchListener(onTouchEndListener_); + SetViewOnTouchListener(view); + onTouchListener_->SetOnTouchEndListener(onTouchEndListener_); + view.SetOnTouchListener(onTouchListener_); view.SetTouchable(true); } @@ -1331,6 +1348,7 @@ void Component::ReleaseCommonEventListeners() ACE_DELETE(onTouchCancelListener_); ACE_DELETE(onTouchMoveListener_); ACE_DELETE(onTouchEndListener_); + ACE_DELETE(onTouchListener_); #endif ACE_DELETE(onSwipeListener_); ACE_DELETE(onRotateListener_); @@ -2021,5 +2039,87 @@ UIView *Component::GetScrollView(const JSValue dom, const jerry_length_t size) return uiview; } +Component::ViewOnTouchListener::ViewOnTouchListener() + : onTouchStartListener_(nullptr), + onTouchCancelListener_(nullptr), + onTouchEndListener_(nullptr), + onTouchMoveListener_(nullptr) +{ +} + +Component::ViewOnTouchListener::~ViewOnTouchListener() +{ + ACE_DELETE(onTouchStartListener_); + ACE_DELETE(onTouchCancelListener_); + ACE_DELETE(onTouchEndListener_); + ACE_DELETE(onTouchMoveListener_); +} + +void Component::ViewOnTouchListener::SetOnTouchStartListener(ViewOnTouchStartListener *startListener) +{ + onTouchStartListener_ = startListener; +} + +void Component::ViewOnTouchListener::SetOnTouchEndListener(ViewOnTouchEndListener *endListener) +{ + onTouchEndListener_ = endListener; +} + +void Component::ViewOnTouchListener::SetOnTouchCancelListener(ViewOnTouchCancelListener *cancelListener) +{ + onTouchCancelListener_ = cancelListener; +} + +void Component::ViewOnTouchListener::SetOnTouchMoveListener(ViewOnTouchMoveListener *moveListener) +{ + onTouchMoveListener_ = moveListener; +} + +bool Component::ViewOnTouchListener::OnPress(UIView &view, const PressEvent &event) +{ + bool ret = false; + if (onTouchStartListener_ != nullptr) { + ret = onTouchStartListener_->OnPress(view, event); + } + return ret; +} + +bool Component::ViewOnTouchListener::OnRelease(UIView &view, const ReleaseEvent &event) +{ + bool ret = false; + if (onTouchEndListener_ != nullptr) { + ret = onTouchEndListener_->OnRelease(view, event); + } + return ret; +} + +bool Component::ViewOnTouchListener::OnCancel(UIView &view, const CancelEvent &event) +{ + bool ret = false; + if (onTouchCancelListener_ != nullptr) { + ret = onTouchCancelListener_->OnCancel(view, event); + } + return ret; +}; + +bool Component::ViewOnTouchListener::OnDrag(UIView &view, const DragEvent &event) +{ + bool ret = false; + if (onTouchMoveListener_ != nullptr) { + ret = onTouchMoveListener_->OnDrag(view, event); + } + return ret; +} + +bool Component::ViewOnTouchListener::OnDragEnd(UIView &view, const DragEvent &event) +{ + bool ret = false; + if (onTouchEndListener_ != nullptr) { + ReleaseEvent evtRelease(event.GetLastPoint()); + ret = onTouchEndListener_->OnRelease(view, evtRelease); + } + return ret; +} + } // namespace ACELite } // namespace OHOS diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.h index eeb469e42..18407fe21 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/component.h @@ -492,6 +492,31 @@ protected: static UIView *GetScrollView(const JSValue dom, const jerry_length_t size); private: + class ViewOnTouchListener final : public UIView::OnTouchListener,public UIView::OnDragListener + { + public: + ViewOnTouchListener(); + ~ViewOnTouchListener(); + + bool OnPress(UIView &view, const PressEvent &event) override; + bool OnRelease(UIView &view, const ReleaseEvent &event) override; + bool OnCancel(UIView &view, const CancelEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView& view, const DragEvent& event) override; + void SetOnTouchStartListener(ViewOnTouchStartListener *startListener); + void SetOnTouchEndListener(ViewOnTouchEndListener *endListener); + void SetOnTouchCancelListener(ViewOnTouchCancelListener *cancelListener); + void SetOnTouchMoveListener(ViewOnTouchMoveListener *moveListener); + + private: + ViewOnTouchStartListener *onTouchStartListener_; + ViewOnTouchCancelListener *onTouchCancelListener_; + ViewOnTouchEndListener *onTouchEndListener_; + ViewOnTouchMoveListener *onTouchMoveListener_; + }; + + void SetViewOnTouchListener(UIView &view); + /** * @brief Used to set animation keyframes, such as transform, background-color, height etc. * it is set as attribute, and support binding to data, so it can be changed dynamically. @@ -633,6 +658,7 @@ private: ViewOnTouchMoveListener *onTouchMoveListener_; ViewOnTouchCancelListener *onTouchCancelListener_; ViewOnTouchEndListener *onTouchEndListener_; + ViewOnTouchListener *onTouchListener_; KeyBoardEventListener *keyBoardEventListener_; #endif KeyInputEventListener *onKeyInputListener_; diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.cpp index 6e7856091..ae9237f38 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.cpp @@ -101,6 +101,7 @@ PickerViewComponent::PickerViewComponent(jerry_value_t options, jerry_value_t ch selectedFontSize_(PICKER_SELECTED_FONT_SIZE), selectedFontFamily_(nullptr), pickerItemHeight_(PICKER_ITEM_HEIGHT), + loopState_(true), textSelected_(0), pTextArray_(nullptr), textArraySize_(0), @@ -134,6 +135,7 @@ bool PickerViewComponent::CreateNativeViews() { bool result = false; pickerType_ = GetPickerType(); + SetPickerLoopState(); switch (pickerType_) { case PickerType::TEXT: { result = CreateTextPicker(); @@ -183,7 +185,7 @@ bool PickerViewComponent::CreateTextPicker() HILOG_ERROR(HILOG_MODULE_ACE, "PickerViewComponent: create text picker failed!"); return false; } - uiPicker->SetLoopState(true); + uiPicker->SetLoopState(loopState_); textPickerListener_ = new TextPickerListener(); if (textPickerListener_ == nullptr) { HILOG_ERROR(HILOG_MODULE_ACE, "PickerViewComponent: create text picker listener failed!"); @@ -203,9 +205,9 @@ bool PickerViewComponent::CreateTimePicker() HILOG_ERROR(HILOG_MODULE_ACE, "PickerViewComponent: create time picker failed"); return false; } - uiTimePicker->SetLoopState(uiTimePicker->PICKER_HOUR, true); - uiTimePicker->SetLoopState(uiTimePicker->PICKER_MIN, true); - uiTimePicker->SetLoopState(uiTimePicker->PICKER_SEC, true); + uiTimePicker->SetLoopState(uiTimePicker->PICKER_HOUR, loopState_); + uiTimePicker->SetLoopState(uiTimePicker->PICKER_MIN, loopState_); + uiTimePicker->SetLoopState(uiTimePicker->PICKER_SEC, loopState_); timePickerListener_ = new TimePickerListener(); if (timePickerListener_ == nullptr) { HILOG_ERROR(HILOG_MODULE_ACE, "PickerViewComponent: create time picker listener failed"); @@ -617,6 +619,13 @@ char *PickerViewComponent::GetStringAttrByName(const char * const name, uint16_t return strValue; } +void PickerViewComponent::SetPickerLoopState() +{ + uint16_t length = 0; + char *typeStr = GetStringAttrByName(ATTR_LOOP, length); + loopState_ = strcmp(typeStr, "false") == 0 ? false : true; +} + PickerViewComponent::PickerType PickerViewComponent::GetPickerType() const { uint16_t length = 0; @@ -762,8 +771,6 @@ bool PickerViewComponent::SetTextPickerRange(jerry_value_t rangeValue) // can not loop when pickerview has one child if (textArraySize_ == 1) { textPicker->SetLoopState(false); - } else { - textPicker->SetLoopState(true); } return true; } diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.h index 8a537cba2..85fe4e93f 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/picker_view_component.h @@ -216,6 +216,7 @@ private: bool CreateDatePicker(); #endif // FEATURE_COMPONENT_DATE_PICKER bool SetPickerSelected(jerry_value_t selectedValue); + void SetPickerLoopState(); void SetPickerListener(jerry_value_t funcValue) const; bool SetTextPickerRange(jerry_value_t rangeValue); void ReleaseTextRange(); @@ -232,6 +233,7 @@ private: uint8_t selectedFontSize_; char* selectedFontFamily_; uint16_t pickerItemHeight_; + bool loopState_; // text picker-view attributes uint16_t textSelected_; diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/slider_component.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/slider_component.cpp index 7151e8c5a..86005ee07 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/slider_component.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/slider_component.cpp @@ -198,10 +198,8 @@ void SliderComponent::SetWidthAndHeight() sliderView_.SetHeight(visibleHeight); sliderView_.SetWidth(visibleWidth); if (direction_ == UISlider::Direction::DIR_BOTTOM_TO_TOP) { - sliderView_.SetValidWidth(SLIDER_WIDTH); sliderView_.SetValidHeight(visibleHeight - DEFAULT_PADDING); } else { - sliderView_.SetValidHeight(SLIDER_WIDTH); sliderView_.SetValidWidth(visibleWidth - DEFAULT_PADDING); } } diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/context/js_timer_list.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/context/js_timer_list.h index 0980ebf0b..ed9409441 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/context/js_timer_list.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/context/js_timer_list.h @@ -13,7 +13,6 @@ * limitations under the License. */ - #ifndef OHOS_ACELITE_JS_TIMER_LIST_H #define OHOS_ACELITE_JS_TIMER_LIST_H @@ -35,7 +34,8 @@ public: * @fn TimerList::TimerList() * @brief Constructor */ - TimerList() : timerListHead_(nullptr), index_(0) {} + TimerList() : timerListHead_(nullptr), index_(0) + {} /** * @fn TimerList::~TimerList() @@ -65,15 +65,29 @@ public: jerry_value_t AddTimer(timerHandle_t timerId, Arguments *&arg); - TimerNode* GetTimer(uint8_t id); + TimerNode *GetTimer(uint8_t id); void DeleteTimer(uint8_t timer); void ReleaseArguments(Arguments *&argument); - uint8_t GetIndex() + /** + * @brief Get the next available index 0~255 for timer. + * @return int16_t. Returns the unused index. if there is no index, -1 is returned. + */ + int16_t GetIndex() { - return ++index_; + uint8_t loopTimes = 0; + index_++; + while (GetTimer(index_) != nullptr) { + if (loopTimes >= UINT8_MAX) { + return -1; + } + // index_ = (index_ + 1) % 256; + index_++; + loopTimes++; + } + return index_; } private: @@ -82,7 +96,7 @@ private: TimerNode *timerListHead_; uint8_t index_; }; -} // namespace ACELite -} // namespace OHOS -#endif // FEATURE_TIMER_MODULE -#endif // OHOS_ACELITE_JS_TIMER_LIST_H +} // namespace ACELite +} // namespace OHOS +#endif // FEATURE_TIMER_MODULE +#endif // OHOS_ACELITE_JS_TIMER_LIST_H diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/keyinput/keyinput.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/keyinput/keyinput.cpp index 6c47db112..24600663e 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/keyinput/keyinput.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/keyinput/keyinput.cpp @@ -18,6 +18,7 @@ #include "adapter.h" #include "js_ability_impl.h" #include "ace_log.h" +#include "abilityms_slite_client.h" typedef struct : public OHOS::HeapBase { char *msgBody; @@ -366,7 +367,13 @@ void OHOS::ACELite::KeyListener::OnRelease(const KeyEvent &event) SendToJS(event); } else if (isPress_ && !isLongPress_) { if (event.GetKeyId() == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { - JsAppContext::GetInstance()->TerminateAbility(); + ElementName *elementName = OHOS::AbilityMsClient::GetInstance().GetTopAbility(); + if (elementName != nullptr) { + OHOS::AbilityMsClient::GetInstance().ForceStop(elementName->bundleName); + FreeElement(elementName); + } else { + HILOG_ERROR(HILOG_MODULE_ACE, "KeyListener: OnRelease elementName is nullptr"); + } } } isPress_ = false; diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_listener.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_listener.h new file mode 100644 index 000000000..8d76a8cb0 --- /dev/null +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_listener.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) CompanyNameMagicTag. 2024-2025. All rights reserved. + * Description: network wrapper + * Author: SoftwarePlatform Group + * Create: 2024-08-10 + */ + +#ifndef OHOS_ACELITE_NETWORK_LISTENER_H +#define OHOS_ACELITE_NETWORK_LISTENER_H + +#ifdef __cplusplus +extern "C" { +#endif + +// 网络类型枚举 +typedef enum { + NETWORK_TYPE_WIFI = 0, + NETWORK_TYPE_BLUETOOTH, + NETWORK_TYPE_BLUETOOTH_LE, + NETWORK_TYPE_UNKNOWN +} NetworkType; + +// 连接状态枚举 +typedef enum { + CONNECTION_STATUS_CONNECTING = 0, + CONNECTION_STATUS_CONNECTED, + CONNECTION_STATUS_DISCONNECTING, + CONNECTION_STATUS_DISCONNECTED, + CONNECTION_STATUS_UNKNOWN +} ConnectionState; + +void net_connect_status_change(uint8_t type, uint8_t netConnectState); +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_module.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_module.cpp new file mode 100644 index 000000000..b58a44585 --- /dev/null +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_module.cpp @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ace_log.h" +#include "js_app_context.h" +#include "js_async_work.h" +#include "product_adapter.h" +#include +#include +#include "network_module.h" +#include "BluetoothModel.h" +#include "msg_center_protocol.h" +#include "bts_le_gap.h" +#include "network_listener.h" + +namespace OHOS { +namespace ACELite { +std::map NetWorkModule::callbackSet; + +void NetWorkModule::TriggerCallbackListener(uint8_t type, uint8_t netConnectState) +{ + auto it = callbackSet.find(type); + if (it != callbackSet.end()) { + NetCallBack *callback = it->second; + callback->netParam.state = netConnectState; + callback->netParam.net_type = type; + if (!JsAsyncWork::DispatchAsyncWork(AsyncExecuteCallback, const_cast(callback))) { + HILOG_ERROR(HILOG_MODULE_ACE, "dispatch async work failed."); + } + } +} + +static bool ValidJsValue(JSIValue value) +{ + return (value != nullptr) && (!JSI::ValueIsUndefined(value)); +} + +static uint8_t GetNetConnectState(uint8_t net_type) +{ + uint8_t state; + switch (net_type) { + case NETWORK_TYPE_WIFI: + break; + case NETWORK_TYPE_BLUETOOTH: + state = OHOS::BluetoothModel::GetInstance()->GetAclConnected() ? CONNECTION_STATUS_CONNECTED + : CONNECTION_STATUS_DISCONNECTED; + break; + case NETWORK_TYPE_BLUETOOTH_LE: + state = (msg_center_get_ble_conn_state() == GAP_BLE_STATE_CONNECTED) ? CONNECTION_STATUS_CONNECTED + : CONNECTION_STATUS_DISCONNECTED; + break; + default: + state = CONNECTION_STATUS_UNKNOWN; + break; + } + return state; +} + +const JSIValue GetNetworkStateString(uint8_t type, uint8_t state) +{ + // 网络类型 + const char *networkType; + switch (type) { + case NETWORK_TYPE_WIFI: + networkType = "WIFI"; + break; + case NETWORK_TYPE_BLUETOOTH: + networkType = "Bluetooth"; + break; + case NETWORK_TYPE_BLUETOOTH_LE: + networkType = "Bluetooth LE"; + break; + default: + networkType = "Unknown Network Type"; + break; + } + + // 连接状态 + const char *connectionState; + switch (state) { + case CONNECTION_STATUS_CONNECTING: + connectionState = "Connecting"; + break; + case CONNECTION_STATUS_CONNECTED: + connectionState = "Connected"; + break; + case CONNECTION_STATUS_DISCONNECTED: + connectionState = "Disconnected"; + break; + default: + connectionState = "Unknown State"; + break; + } + + // 静态字符串缓冲区,用于返回结果 + static char description[MAX_STATUS_LENGTH]; + int ret = + snprintf_s(description, sizeof(description), sizeof(description) - 1, "%s: %s", networkType, connectionState); + if (ret <= 0) { + HILOG_ERROR(HILOG_MODULE_ACE, "result buff is too long"); + } + JSIValue result = JSI::CreateObject(); + JSI::SetStringProperty(result, "type", networkType); + JSI::SetNumberProperty(result, "state", state); + JSI::SetStringProperty(result, "description", description); + return result; +} + +void NetWorkModule::AsyncExecuteCallback(void *arg) +{ + NetCallBack *callback = static_cast(arg); + if (ValidJsValue(callback->net_connect_callback)) { + JSIValue result = GetNetworkStateString(callback->netParam.net_type, callback->netParam.state); + JSIValue argv[ARGC_ONE] = {result}; + JSI::CallFunction(callback->net_connect_callback, callback->net_connect_thisVal, argv, ARGC_ONE); + JSI::ReleaseValue(result); + } +} + +JSIValue NetWorkModule::RegisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) +{ + uint8_t type; + JSIValue callbackArg; + if (argsNum == 1) { + type = NETWORK_TYPE_BLUETOOTH; + callbackArg = args[0]; + } else if (argsNum == 2) { + if (args == nullptr || JSI::ValueIsUndefined(args[0])) { + HILOG_ERROR(HILOG_MODULE_ACE, "Invalid type argument for registering net connection callback"); + return JSI::CreateUndefined(); + } + type = JSI::ValueToNumber(args[0]); + callbackArg = args[1]; + } else { + HILOG_ERROR(HILOG_MODULE_ACE, "Invalid number of arguments for registering net connection callback"); + return JSI::CreateUndefined(); + } + auto it = callbackSet.find(type); + if (it != callbackSet.end()) { + NetCallBack *callback = it->second; + // 从 map 中移除该回调 + callbackSet.erase(it); + // 如果找到了对应的回调,先清理旧的回调 + Clean(callback); + } + NetCallBack *newCallback = new (std::nothrow) NetCallBack(); + if (newCallback == nullptr) { + HILOG_ERROR(HILOG_MODULE_ACE, "Failed to allocate memory for NetCallBack"); + return JSI::CreateUndefined(); + } + // 保存新的回调 + newCallback->net_connect_thisVal = JSI::AcquireValue(thisVal); + newCallback->net_connect_callback = JSI::AcquireValue(callbackArg); + if (newCallback->net_connect_callback == nullptr) { + HILOG_ERROR(HILOG_MODULE_ACE, "Failed to register net connection callback"); + delete newCallback; + return JSI::CreateUndefined(); + } + newCallback->netParam.net_type = type; + callbackSet[type] = newCallback; + uint8_t state = GetNetConnectState(type); + net_connect_status_change(type, state); + return JSI::CreateUndefined(); +} + +JSIValue NetWorkModule::UnregisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) +{ + if (args == nullptr || argsNum == 0) { + HILOG_ERROR(HILOG_MODULE_ACE, "Invalid arguments for unregistering net connection callback"); + return JSI::CreateUndefined(); + } + + uint8_t type; + if (argsNum < 1) { + type = NETWORK_TYPE_BLUETOOTH; + } else { + if (JSI::ValueIsUndefined(args[0])) { + HILOG_ERROR(HILOG_MODULE_ACE, "Invalid type argument for unregistering net connection callback"); + return JSI::CreateUndefined(); + } + type = JSI::ValueToNumber(args[0]); + } + auto it = callbackSet.find(type); + if (it != callbackSet.end()) { + NetCallBack *callback = it->second; + callbackSet.erase(it); + Clean(callback); + } else { + HILOG_ERROR(HILOG_MODULE_ACE, "No callback registered for the given type"); + } + + return JSI::CreateUndefined(); +} + +JSIValue NetWorkModule::GetConnectState(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) +{ + uint8_t net_type = NETWORK_TYPE_UNKNOWN; + if (argsNum < 1) { + net_type = NETWORK_TYPE_BLUETOOTH; + } else { + net_type = (uint8_t)JSI::ValueToNumber(args[0]); + } + uint8_t state = GetNetConnectState(net_type); + return GetNetworkStateString(net_type, state); +} + +void NetWorkModule::Clean(NetCallBack *callbackToClean) +{ + if (callbackToClean == nullptr) { + return; + } + // 释放回调函数资源 + if (callbackToClean->net_connect_callback && JSI::ValueIsFunction(callbackToClean->net_connect_callback)) { + JSI::ReleaseValue(callbackToClean->net_connect_callback); + } + // 释放回调上下文资源 + if (callbackToClean->net_connect_thisVal && !JSI::ValueIsUndefined(callbackToClean->net_connect_thisVal)) { + JSI::ReleaseValue(callbackToClean->net_connect_thisVal); + } + // 删除回调对象 + delete callbackToClean; +} + +void NetWorkModule::OnTerminate() +{ + for (auto it = callbackSet.begin(); it != callbackSet.end();) { + NetCallBack *callback = it->second; + callbackSet.erase(it); + // 移除多余的迭代器重置代码 + Clean(callback); + // 从 map 中移除该回调 + it = callbackSet.begin(); + } +} + +void InitNetWorkModule(JSIValue exports) +{ + JSI::SetModuleAPI(exports, "registerConnectListener", NetWorkModule::RegisterConnectListener); + JSI::SetModuleAPI(exports, "unregisterConnectListener", NetWorkModule::UnregisterConnectListener); + JSI::SetModuleAPI(exports, "getConnectState", NetWorkModule::GetConnectState); + JSI::SetOnTerminate(exports, NetWorkModule::OnTerminate); +} + +} // namespace ACELite +} // namespace OHOS + +#ifdef __cplusplus +extern "C" { +#endif + +void net_connect_status_change(uint8_t type, uint8_t netConnectState) +{ + OHOS::ACELite::NetWorkModule::TriggerCallbackListener(type, netConnectState); +} + +#ifdef __cplusplus +} +#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_module.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_module.h new file mode 100644 index 000000000..fc8061b2b --- /dev/null +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network/network_module.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) CompanyNameMagicTag. 2024-2025. All rights reserved. + * Description: network wrapper + * Author: SoftwarePlatform Group + * Create: 2024-08-10 + */ + +#ifndef OHOS_ACELITE_NETWORK_MODULE_H +#define OHOS_ACELITE_NETWORK_MODULE_H + +#include +#include "acelite_config.h" +#include "jsi.h" +#include +#include "js_async_work.h" +#include "non_copyable.h" +#include "product_adapter.h" +#include "abilityms_slite_client.h" +#include "network_listener.h" + +namespace OHOS { +namespace ACELite { +#define MAX_STATUS_LENGTH 128 + +struct NetParam { + uint8_t net_type = -1; + uint8_t state; +}; + +struct NetCallBack { + JSIValue net_connect_callback = nullptr; + JSIValue net_connect_thisVal = nullptr; + NetParam netParam; +}; + +class NetWorkModule final : public MemoryHeap { +public: + ACE_DISALLOW_COPY_AND_MOVE(NetWorkModule); + NetWorkModule() = default; + ~NetWorkModule() = default; + static std::map callbackSet; + static JSIValue RegisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); + static JSIValue UnregisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); + static JSIValue GetConnectState(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); + static void AsyncExecuteCallback(void *arg); + static void TriggerCallbackListener(uint8_t type, uint8_t netConnectState); + static void OnTerminate(); + static void Clean(NetCallBack* callbackToClean); +}; + +} // namespace ACELite +} // namespace OHOS + +#endif diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-cli/libbms.a b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-cli/libbms.a index 9aa178a27..9826884cd 100644 Binary files a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-cli/libbms.a and b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-cli/libbms.a differ diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-ser/libbms.a b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-ser/libbms.a index 636c899e5..33284f522 100644 Binary files a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-ser/libbms.a and b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-auto-ota-ser/libbms.a differ diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-fd230/libbms.a b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-fd230/libbms.a index 36de95104..3faa0d3fd 100644 Binary files a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-fd230/libbms.a and b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-fd230/libbms.a differ diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-xts/libbms.a b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-xts/libbms.a index 36de95104..3faa0d3fd 100644 Binary files a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-xts/libbms.a and b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js-xts/libbms.a differ diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js/libbms.a b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js/libbms.a index 36de95104..3faa0d3fd 100644 Binary files a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js/libbms.a and b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-native-js/libbms.a differ diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-xts/libbms.a b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-xts/libbms.a index 97023f49b..8d7c947fb 100644 Binary files a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-xts/libbms.a and b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/brandy-xts/libbms.a differ diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h index 04f7681d2..f00d9fa1c 100644 --- a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h +++ b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h @@ -39,6 +39,15 @@ typedef enum { BUNDLE_UNINSTALL_FAIL = 5 } InstallState; +typedef enum { + SCAN_PACKAGE_OK = 0, + SCAN_PACKAGE_DOING = 1, + SCAN_PACKAGE_FAIL = 2, + SCAN_PACKAGE_INVALID_DIR = 3, + SCAN_PACKAGE_MEMORY_ERROR = 4, + SCAN_PACKAGE_PATH_ERROR = 5 +} ScanPackagesResultState; + typedef struct { char *bundleName; char *label; diff --git a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/services/bundlemgr_lite/include/gt_bundle_manager_service.h b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/services/bundlemgr_lite/include/gt_bundle_manager_service.h index de9e3c9ac..18bf1d426 100644 --- a/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/services/bundlemgr_lite/include/gt_bundle_manager_service.h +++ b/code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/services/bundlemgr_lite/include/gt_bundle_manager_service.h @@ -62,7 +62,7 @@ public: uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo& bundleInfo); uint8_t GetBundleInfos(const int flags, BundleInfo **bundleInfos, int32_t *len); uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len); - void ScanPackages(); + void ScanPackages(InstallerCallback ScanPackagesResultCallback); BundleInfo *QueryBundleInfo(const char *bundleName); void RemoveBundleInfo(const char *bundleName); void AddBundleInfo(BundleInfo *info); @@ -87,7 +87,8 @@ private: GtManagerService(); ~GtManagerService(); void ScanSystemApp(const cJSON *uninstallRecord, List *systemPathList); - void ScanThirdApp(const char *appDir, const List *systemPathList); + void ScanThirdApp(const char *appDir, const List *systemPathList, + InstallerCallback ScanPackagesResultCallback); void InstallAllSystemBundle(InstallerCallback installerCallback); bool ReloadBundleInfo(const char *profileDir, const char *appId, bool isSystemApp); void ReloadEntireBundleInfo(const char *appPath, const char *bundleName, List *systemPathList, diff --git a/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h b/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h index 19ac2dcbb..1f44dace5 100644 --- a/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h +++ b/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_player.h @@ -77,7 +77,9 @@ public: bool ResetPlayer(); void ReleaseEventListeners(); - +#ifdef HMF_DECRYPT_DATA_ENABLE + void SetDecryptLibraryPath(char *path, uint32_t len); +#endif void ReleaseSrc(); bool Play(); @@ -118,7 +120,7 @@ public: bool SetAutoPlay(bool autoPlay); - bool SetLoop(bool loop) const; + bool SetLoop(bool loop); bool SetVolume(double volume); @@ -155,6 +157,8 @@ public: void SetOnTimeUpdateListener(AudioEventListener *onTimeUpdateListener); int32_t GetSrcInnerPrefix(const char *src, char *dest); + + bool IsSysSrc(); private: AudioPlayer(); ~AudioPlayer(); @@ -176,9 +180,11 @@ private: bool autoPlay_; bool isRunning_; bool isSysSrc_; + bool isPlayList_; + AudioPlayerLoopMode playLoopMode_ = AudioPlayerLoopMode::AUDIO_PLAYER_INVAILD_LOOP; MediaThreadIdHandle updateTimeProcess_; AudioStreamType streamType_ = AUDIO_STREAM_MUSIC; }; } // namespace ACELite } // namespace OHOS -#endif // AUDIO_PLAYER_H \ No newline at end of file +#endif // AUDIO_PLAYER_H diff --git a/code/sdk/open_source/openharmony/test/xts/acts/commonlibrary_lite/file_hal/src/utils_file_reli_test.c b/code/sdk/open_source/openharmony/test/xts/acts/commonlibrary_lite/file_hal/src/utils_file_reli_test.c index 1fc220c91..fa7a97edc 100644 --- a/code/sdk/open_source/openharmony/test/xts/acts/commonlibrary_lite/file_hal/src/utils_file_reli_test.c +++ b/code/sdk/open_source/openharmony/test/xts/acts/commonlibrary_lite/file_hal/src/utils_file_reli_test.c @@ -75,7 +75,8 @@ LITE_TEST_CASE(UtilsFileReliTestSuite, testCreateFileAfterMaxFilesOpened, Functi TEST_ASSERT_GREATER_THAN_INT(0, fd32[i]); } // Open the 33th file - char* fileName33 = "/user/testReli101-33"; + char fileName33[LENGTH_OF_FILE_NAME_BUF] = { 0 }; + (void)sprintf_s(fileName33, sizeof(fileName33), "%s%d", "/user/testReli101-", MAX_NUM_OF_OPENED_FILES + 1); int fd33 = UtilsFileOpen(fileName33, O_RDWR_FS | O_CREAT_FS, 0); TEST_ASSERT_EQUAL_INT(-1, fd33); // Close file diff --git a/code/sdk/open_source/openharmony/third_party/freetype/src/smooth/ftgrays.c b/code/sdk/open_source/openharmony/third_party/freetype/src/smooth/ftgrays.c index 0c90cfe8f..9ecc442da 100644 --- a/code/sdk/open_source/openharmony/third_party/freetype/src/smooth/ftgrays.c +++ b/code/sdk/open_source/openharmony/third_party/freetype/src/smooth/ftgrays.c @@ -1730,9 +1730,10 @@ typedef ptrdiff_t FT_PtrDist; band--; continue; } - else if ( error != ErrRaster_Memory_Overflow ) + else if ( error != ErrRaster_Memory_Overflow ) { ft_sfree(buffer); return 1; + } /* render pool overflow; we will reduce the render band by half */ width >>= 1; diff --git a/code/sdk/open_source/openharmony/third_party/jerryscript/CMakeLists.txt b/code/sdk/open_source/openharmony/third_party/jerryscript/CMakeLists.txt index d8e269378..718648ebe 100644 --- a/code/sdk/open_source/openharmony/third_party/jerryscript/CMakeLists.txt +++ b/code/sdk/open_source/openharmony/third_party/jerryscript/CMakeLists.txt @@ -285,7 +285,7 @@ set(PUBLIC_DEFINES ) set(PRIVATE_DEFINES - JERRY_GLOBAL_HEAP_SIZE=512 + JERRY_GLOBAL_HEAP_SIZE=576 JERRY_ERROR_MESSAGES=1 JERRY_LINE_INFO=1 JERRY_FUNCTION_NAME diff --git a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-cli/libjerryscript.a b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-cli/libjerryscript.a index 4440eca84..fba453f3b 100644 Binary files a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-cli/libjerryscript.a and b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-cli/libjerryscript.a differ diff --git a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-ser/libjerryscript.a b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-ser/libjerryscript.a index b24695a43..f3d1edece 100644 Binary files a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-ser/libjerryscript.a and b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-auto-ota-ser/libjerryscript.a differ diff --git a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-fd230/libjerryscript.a b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-fd230/libjerryscript.a index b5fc18bc6..934e94816 100644 Binary files a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-fd230/libjerryscript.a and b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-fd230/libjerryscript.a differ diff --git a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-xts/libjerryscript.a b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-xts/libjerryscript.a index b5fc18bc6..934e94816 100644 Binary files a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-xts/libjerryscript.a and b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js-xts/libjerryscript.a differ diff --git a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js/libjerryscript.a b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js/libjerryscript.a index b5fc18bc6..934e94816 100644 Binary files a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js/libjerryscript.a and b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-native-js/libjerryscript.a differ diff --git a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-xts/libjerryscript.a b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-xts/libjerryscript.a index 054a02afb..5548a92d9 100644 Binary files a/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-xts/libjerryscript.a and b/code/sdk/open_source/openharmony/third_party/jerryscript/brandy-xts/libjerryscript.a differ diff --git a/code/sdk/open_source/openharmony/utils/native/lite/file/src/file_impl_hal/file.c b/code/sdk/open_source/openharmony/utils/native/lite/file/src/file_impl_hal/file.c index cef74a2bb..74e4481cb 100644 --- a/code/sdk/open_source/openharmony/utils/native/lite/file/src/file_impl_hal/file.c +++ b/code/sdk/open_source/openharmony/utils/native/lite/file/src/file_impl_hal/file.c @@ -63,7 +63,11 @@ int UtilsFileCopy(const char* src, const char* dest) if ((src == NULL) || (dest == NULL)) { return EC_FAILURE; } +#ifdef XTS_SUPPORT + int fpSrc = UtilsFileOpen(src, O_RDWR_FS, 0); +#else int fpSrc = UtilsFileOpen(src, O_RDONLY_FS, 0); +#endif if (fpSrc < 0) { return fpSrc; } diff --git a/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/filekit/src/nativeapi_fs.cpp b/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/filekit/src/nativeapi_fs.cpp index 2f6f2359b..44a4b6ea2 100644 --- a/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/filekit/src/nativeapi_fs.cpp +++ b/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/filekit/src/nativeapi_fs.cpp @@ -27,6 +27,8 @@ namespace ACELite { namespace { char g_uriFullPath[FILE_NAME_MAX_LEN + 1] = {0}; const unsigned int PREFIX_LEN = strlen(FILE_PREFIX); +const char *trustPath = "/user/music"; +const int trustPathSize = strlen(trustPath); bool IsValidPath(const char* path) { @@ -38,15 +40,28 @@ bool IsValidPath(const char* path) if (pathLen > URI_NAME_MAX_LEN) { return false; } - if ((pathLen < PREFIX_LEN) || (strncmp(path, FILE_PREFIX, PREFIX_LEN) != 0)) { + + bool isTrustPath = (strncmp(path, trustPath, trustPathSize) == 0); + if (!isTrustPath && (strncmp(path, FILE_PREFIX, PREFIX_LEN) != 0)) { + return false; + } + + if (isTrustPath && (pathLen < strlen(trustPath))) { return false; } + + if ((strncmp(path, FILE_PREFIX, PREFIX_LEN) == 0) && (pathLen < PREFIX_LEN)) { + return false; + } + if ((strstr(path, "/./") != nullptr) || (strstr(path, "/../") != nullptr)) { return false; } - if (strpbrk(path + PREFIX_LEN, "\"*+,:;<=>\?[]|\x7F")) { + + if (strpbrk(path + (isTrustPath ? trustPathSize : PREFIX_LEN), "\"*+,:;<=>\?[]|\x7F")) { return false; } + return true; } @@ -56,15 +71,24 @@ int GetFullPath(const char* uri, char* fullPath, int len) return ERROR_CODE_PARAM; } const char* dataPath = GetDataPath(); + int size = PREFIX_LEN; + bool isTrustPath = (strncmp(uri, trustPath, strlen(trustPath)) == 0); + if (isTrustPath) { + size = 0; + } + if (dataPath == nullptr) { return ERROR_CODE_PARAM; } + if (memset_s(fullPath, len, 0x0, len) != EOK) { return ERROR_CODE_GENERAL; } - if (sprintf_s(fullPath, len, "%s%s", dataPath, uri + PREFIX_LEN) < 0) { + + if (sprintf_s(fullPath, len, "%s%s", (isTrustPath ? "" : dataPath), uri + size) < 0) { return ERROR_CODE_GENERAL; } + return NATIVE_SUCCESS; } diff --git a/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/kvstorekit/src/nativeapi_kv.cpp b/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/kvstorekit/src/nativeapi_kv.cpp index 8067bf8d6..005a9bf6b 100644 --- a/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/kvstorekit/src/nativeapi_kv.cpp +++ b/code/sdk/open_source/openharmony/utils/native/lite/js/builtin/kvstorekit/src/nativeapi_kv.cpp @@ -289,17 +289,31 @@ JSIValue NativeapiKv::Delete(const JSIValue thisVal, const JSIValue* args, uint8 JSIValue NativeapiKv::Clear(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum) { - JSIValue undefValue = JSI::CreateUndefined(); + JSIValue retValue = JSI::CreateUndefined(); + + if (args == nullptr || argsNum == 0 || !NativeapiCommon::IsValidJSIValue(args, argsNum)) { + retValue = JSI::CreateErrorWithCode(-1, "Invalid arguments"); + return retValue; + } + FuncParams* params = new(std::nothrow) FuncParams(); if (params == nullptr) { - return undefValue; + retValue = JSI::CreateErrorWithCode(-1, "Failed to allocate FuncParams"); + return retValue; } + params->thisVal = JSI::AcquireValue(thisVal); - if (NativeapiCommon::IsValidJSIValue(args, argsNum)) { - params->args = JSI::AcquireValue(args[0]); + params->args = JSI::AcquireValue(args[0]); + + bool isSuccess = JsAsyncWork::DispatchAsyncWork(reinterpret_cast(ExecuteClear), reinterpret_cast(params)); + if (!isSuccess) { + JSI::ReleaseValue(params->thisVal); + JSI::ReleaseValue(params->args); + delete params; + retValue = JSI::CreateErrorWithCode(-1, "Async work dispatch failed"); } - JsAsyncWork::DispatchAsyncWork(reinterpret_cast(ExecuteClear), reinterpret_cast(params)); - return undefValue; + + return retValue; } } // ACELite } // OHOS diff --git a/code/sdk/protocol/bt/host/bt/bts/brandy_service/service/src/base/connection_manager.h b/code/sdk/protocol/bt/host/bt/bts/brandy_service/service/src/base/connection_manager.h index 2eff618d3..f7735f675 100644 --- a/code/sdk/protocol/bt/host/bt/bts/brandy_service/service/src/base/connection_manager.h +++ b/code/sdk/protocol/bt/host/bt/bts/brandy_service/service/src/base/connection_manager.h @@ -44,6 +44,7 @@ typedef enum { CONN_MSG_ID_REPORT_LOCAL_ADDR_CHANGED, /* 本地设备地址变化上报 */ CONN_MSG_ID_REPORT_PAIR_STATUS_CHANGED, /* 设备配对变化上报 */ CONN_MSG_ID_REPORT_REMOTE_RSSI, /* 远端设备RSSI上报 */ + CONN_MSG_ID_REPORT_CONN_REJECTED, /* 拒绝新设备连接上报 */ } connection_manager_msg_id; typedef enum { diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ams_client.h b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ams_client.h index f47a9f580..82c5ced66 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ams_client.h +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ams_client.h @@ -235,7 +235,7 @@ typedef enum { * @endif */ typedef struct { - struct osal_list_head node; + struct osal_list_head node; /*!< @if Eng List node @else 链表节点 @endif */ uint8_t client_id; /*!< @if Eng client id @else 客户端ID @endif */ uint16_t conn_id; /*!< @if Eng connect id @else 连接ID @endif */ uint16_t start_handle; /*!< @if Eng start handle @else 服务开始handle @endif */ diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ancs_client.h b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ancs_client.h index 8a2d7cc3b..e41829737 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ancs_client.h +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ancs_client.h @@ -276,6 +276,7 @@ typedef struct { * @endif */ typedef struct { + struct osal_list_head node; /*!< @if Eng List node @else 链表节点 @endif */ uint8_t att_id; /*!< @if Eng Attribute id @else 属性ID @endif */ uint16_t att_length; /*!< @if Eng Attribute length @else 属性长度 @endif */ uint8_t *att; /*!< @if Eng Attribute value @else 属性值 @endif */ diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gap.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gap.c index 33d987cd5..d0526c8c9 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gap.c +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gap.c @@ -921,6 +921,13 @@ static void sample_gap_is_accept_conn_on_safe_mode_callback(const bd_addr_t *bd_ *res = g_sample_gap_accept_conn; } +static void sample_gap_connect_reject_rpt_callback(const bd_addr_t *bd_addr) +{ + bts_sample_log("conn_request_notify_callback addr: ****%02x%02x%02x%02x\n", + bd_addr->addr[3], bd_addr->addr[2], /* addr下标 2 3 */ + bd_addr->addr[1], bd_addr->addr[0]); /* addr下标 0 1 */ +} + /* 注册回调 params: sample_mode fill_callbacks */ void btsrv_at_cmd_gap_register_callbacks(void) { @@ -941,10 +948,11 @@ void btsrv_at_cmd_gap_register_callbacks(void) sample_gap_remote_cod_changed_callback, sample_gap_remote_battery_level_changed_callback, sample_gap_read_remote_rssi_event_callback, - sample_gap_is_accept_conn_on_safe_mode_callback + sample_gap_is_accept_conn_on_safe_mode_callback, }; int ret = gap_register_callbacks(&cb); bts_sample_log("gap reg cbk ret %x\n", ret); + gap_register_br_connect_rejection_report_callback(sample_gap_connect_reject_rpt_callback); } /* 注册回调 params: sample_mode fill_callbacks */ @@ -965,6 +973,7 @@ static void btsrv_sample_cmd_gap_register_callbacks(const char **params, int32_t int ret; if ((sample_mode & 0x1) != 0) { ret = gap_register_callbacks(NULL); + gap_register_br_connect_rejection_report_callback(NULL); } else if (fill_callbacks != 0) { gap_call_backs_t cb = { sample_gap_state_changed_callback, @@ -983,14 +992,16 @@ static void btsrv_sample_cmd_gap_register_callbacks(const char **params, int32_t sample_gap_remote_cod_changed_callback, sample_gap_remote_battery_level_changed_callback, sample_gap_read_remote_rssi_event_callback, - sample_gap_is_accept_conn_on_safe_mode_callback + sample_gap_is_accept_conn_on_safe_mode_callback, }; ret = gap_register_callbacks(&cb); bts_sample_log("gap_register_callbacks with funcs ret(int): %x\n", ret); + gap_register_br_connect_rejection_report_callback(sample_gap_connect_reject_rpt_callback); } else { gap_call_backs_t cb = { 0, }; ret = gap_register_callbacks(&cb); bts_sample_log("gap_register_callbacks test ret(int): %x\n", ret); + gap_register_br_connect_rejection_report_callback(NULL); } } diff --git a/code/sdk/protocol/bt/host/bt/bts/sdk/inc/stack_api/stack_gap_if.h b/code/sdk/protocol/bt/host/bt/bts/sdk/inc/stack_api/stack_gap_if.h index bfef91a10..a1258efa0 100644 --- a/code/sdk/protocol/bt/host/bt/bts/sdk/inc/stack_api/stack_gap_if.h +++ b/code/sdk/protocol/bt/host/bt/bts/sdk/inc/stack_api/stack_gap_if.h @@ -84,6 +84,7 @@ enum { BTSDK_ADD_DEVICE_TO_WHITE_LIST, BTSDK_REMOVE_DEVICE_FROM_WHITE_LIST, BTSDK_CLEAR_WHITE_LIST, + BTSDK_CONNECTION_REJECT_REPORT, BTSDK_ENUM_MAX // let it at the bottom of the array }; @@ -393,6 +394,10 @@ typedef struct { bth_addr_t bd_addr; } connect_req_ind_struct; +typedef struct { + bth_addr_t bd_addr; +} connect_reject_info; + typedef struct { uint8_t op; void *func; @@ -440,6 +445,7 @@ typedef void (btsdk_inquiry_complete_ind_func)(void); typedef void (btsdk_authorization_req_ind_func)(uint32_t svc_hdl, uint32_t dev_hdl); typedef uint8_t (btsdk_connection_request_ind_func)(uint32_t dev_hdl, uint32_t dev_class, uint8_t link_type, const uint8_t *remote_addr, uint8_t addr_len); +typedef uint8_t (btsdk_connection_reject_rpt_func)(const uint8_t *remote_addr, uint8_t addr_len); typedef void (btsdk_connection_complete_ind_func)(uint32_t dev_hdl, bt_sdk_conn_dev_info_t *conn_dev_info); typedef void (btsdk_disconnection_complete_ind_func)(uint32_t dev_hdl, uint32_t reason); typedef void (btsdk_connection_event_ind_func)(uint32_t conn_hdl, uint16_t event, uint8_t *arg); diff --git a/code/sdk/tools/pkg/bin/brandy/bt.bin b/code/sdk/tools/pkg/bin/brandy/bt.bin index 41a21bc52..8bdf8cec2 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/bt.bin and b/code/sdk/tools/pkg/bin/brandy/bt.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_main.bin b/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_main.bin index 9254d5204..47dbba122 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_main.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_main.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_overlay.bin b/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_overlay.bin index c1b466dd1..a4b84186f 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_overlay.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/max/dsp_overlay.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_main.bin b/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_main.bin index a63c4bbba..ddeea8447 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_main.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_main.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_overlay.bin b/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_overlay.bin index ee819d6dc..de08c7886 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_overlay.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/mini/dsp_overlay.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_main.bin b/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_main.bin index cf62a776e..54ec7597e 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_main.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_main.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_overlay.bin b/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_overlay.bin index 5ca2ce140..7878450c5 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_overlay.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/ultra/dsp_overlay.bin differ diff --git a/code/sdk/tools/pkg/chip_packet/brandy/packet.py b/code/sdk/tools/pkg/chip_packet/brandy/packet.py index 74eeb585d..80a4fa701 100644 --- a/code/sdk/tools/pkg/chip_packet/brandy/packet.py +++ b/code/sdk/tools/pkg/chip_packet/brandy/packet.py @@ -24,16 +24,19 @@ from param_packet import gen_flash_part_bin from nv_binary import nv_begin # brandy packet -def build_brandy_other_bin(pack_style_str, flash_size): +def build_brandy_other_bin(pack_style_str, flash_size, no_dsp): ''' build brandy partition and nv ''' chip_dir = os.path.join(SDK_DIR, "build", "config", "target_config", "brandy") # 分区配置文件路径 partition_cfg = os.path.join(chip_dir, "param_sector") - if flash_size.endswith("0x1000000"): + if flash_size == "0x1000000": partition_cfg = os.path.join(partition_cfg, "param_sector_16M.json") else: - partition_cfg = os.path.join(partition_cfg, "param_sector.json") - print("partition_cfg {}".format(partition_cfg)) + if (no_dsp == "True"): + partition_cfg = os.path.join(partition_cfg, "param_sector_no_dsp.json") + else: + partition_cfg = os.path.join(partition_cfg, "param_sector.json") + partition_bin = os.path.join(SDK_DIR, "output", "brandy", "partition_table.bin") # nv配置文件路径 nv_config_json = os.path.join(chip_dir, "nv_bin_cfg") @@ -114,6 +117,60 @@ def make_all_in_one_packet_8M(pack_style_str): print(e) exit(-1) +def make_all_in_one_packet_no_dsp(pack_style_str): + # make all in one packet + bin_dir = os.path.join(PKG_DIR, "bin", "brandy") + application_dir = os.path.join(SDK_DIR, + "output", + "brandy", + "acore", + pack_style_str) + recovery_target = "%s-r" % pack_style_str + recovery_target = recovery_target.replace('-user', '') + recovery_bin = os.path.join(SDK_DIR, + "output", + "brandy", + "acore", + recovery_target, + "recovery.bin") + recovery_bx = recovery_bin + "|0x70050000|0x40000|100" + + upload_app_fwpkg = os.path.join(PKG_DIR, "fwpkg", "brandy", "upload_app.fwpkg") + + ssb = os.path.join(SDK_DIR, "output", "brandy", "acore", "brandy-ssb", "ssb.bin") + if not os.path.exists(ssb): + ssb = os.path.join(bin_dir, "ssb.bin") + print("ssb_path: ", ssb) + ssb_bx = ssb + "|0x70000000|0x20000|0" + + partition = os.path.join(SDK_DIR, "output", "brandy", "partition_table.bin") + partition_bx = partition + "|0x7004F000|0x1000|100" + nv = os.path.join(SDK_DIR, "output", "brandy", "nv_bin", "brandy_all_nv.bin") + nv_bx = nv + "|0x707F9000|0x4000|100" + + app = os.path.join(application_dir, "application.bin") + app_bx = app + "|0x70100000|0x6F9000|18" + + bt = os.path.join(bin_dir, "bt.bin") + bt_bx = bt + "|0x70090000|0x70000|20" + + fs = os.path.join(application_dir, "file.bin") + fs_bx = fs + "|0xFFFFFFFF|0xFFFFFFFF|101" + + try: + packet_post_agvs = list() + packet_post_agvs.append(ssb_bx) + packet_post_agvs.append(partition_bx) + packet_post_agvs.append(app_bx) + packet_post_agvs.append(recovery_bx) + packet_post_agvs.append(bt_bx) + packet_post_agvs.append(nv_bx) + packet_post_agvs.append(fs_bx) + packet_bin(upload_app_fwpkg, packet_post_agvs) + except Exception as e: + print(e) + exit(-1) + def make_all_in_one_packet_16M(pack_style_str): # make all in one packet bin_dir = os.path.join(PKG_DIR, "bin", "brandy") @@ -179,13 +236,16 @@ def make_all_in_one_packet_16M(pack_style_str): exit(-1) -def make_all_in_one_packet(pack_style_str, flash_size): +def make_all_in_one_packet(pack_style_str, flash_size, no_dsp): # make all in one packet - build_brandy_other_bin(pack_style_str, flash_size) - if flash_size.endswith("0x1000000"): + build_brandy_other_bin(pack_style_str, flash_size, no_dsp) + if flash_size == "0x1000000": make_all_in_one_packet_16M(pack_style_str) else: - make_all_in_one_packet_8M(pack_style_str) + if no_dsp == "True": + make_all_in_one_packet_no_dsp(pack_style_str) + else: + make_all_in_one_packet_8M(pack_style_str) def is_packing_files_exist(soc, pack_style_str): """ diff --git a/code/sdk/tools/pkg/packet.py b/code/sdk/tools/pkg/packet.py index 366688f9b..2656055ba 100644 --- a/code/sdk/tools/pkg/packet.py +++ b/code/sdk/tools/pkg/packet.py @@ -18,6 +18,7 @@ def main(): build_soc = sys.argv[1] build_target = sys.argv[2] flash_size = sys.argv[3] + no_dsp = sys.argv[4] load_fmt = "chip_packet.%s.packet" %build_soc load_mod = importlib.import_module(load_fmt) @@ -27,7 +28,7 @@ def main(): lost = ";".join(lost_file) print(f"cannot find {lost}") exit(-1) - load_mod.make_all_in_one_packet(build_target, flash_size) + load_mod.make_all_in_one_packet(build_target, flash_size, no_dsp) if __name__ == "__main__": main()