From: SnickerSun Date: Mon, 27 May 2024 01:45:27 +0000 (+0800) Subject: update patch_602_base_to_0521 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~431 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=785a3c00b7c4610a7d26065c7cd2a824241fe511;p=mirrors%2FFD230.git update patch_602_base_to_0521 --- diff --git a/SDK_1.1.10.602_0425patch.txt b/0425.patch.txt similarity index 100% rename from SDK_1.1.10.602_0425patch.txt rename to 0425.patch.txt diff --git a/SDK_1.1.10.602.txt b/SDK_1.1.10.602.txt new file mode 100644 index 000000000..a28a1c30b --- /dev/null +++ b/SDK_1.1.10.602.txt @@ -0,0 +1,3 @@ +SDK version:1.1.10.602 + + diff --git a/code/sdk/application/brandy/brandy_standard/thread_init.c b/code/sdk/application/brandy/brandy_standard/thread_init.c index d46b9897c..c07063027 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_init.c @@ -22,12 +22,8 @@ #include "pm_sleep.h" #include "pm_lpc.h" #include "pm_control.h" -#include "upg.h" -#include "upg_definitions.h" -#include "nv.h" #include "dfx_system_init.h" #include "cpu_load.h" -#include "nv_upg.h" #ifdef SUPPORT_AT_CMD #include "at_cmd_api.h" @@ -76,6 +72,8 @@ #include "clocks_config.h" #include "sys/time.h" #include "time.h" +#include "log_panic.h" +#include "nandflash_config.h" #define EMMC_BASE_ADDR 0x52062000 @@ -88,6 +86,7 @@ #define TASK_PRIORITY_SDK (osPriority_t)(31) #define TASK_PRIORITY_DFX_MSG (osPriority_t)(18) #define TASK_PRIORITY_TRANSMIT (osPriority_t)(20) +#define TASK_PRIORITY_SAVE_FILE (osPriority_t)(36) #define BTH_SDK_STACK_SIZE 0xC00 #define AT_GRAPHIC_STACK_SIZE 0xC00 @@ -99,10 +98,7 @@ #define PM_DISPLAY_MSG_STACK_SIZE 0xc00 #define AT_OHOSFWK_STACK_SIZE 0xC00 #define APP_MAIN_STACK_SIZE 0xC00 - -#define UPG_HEAD_MAGIC 0x55AA55AA -#define UPG_END_MAGIC 0xAA55AA55 -#define UPG_FLAG_MAGIC 0xFFFFFFFF +#define SAVE_FILE_STACK_SIZE 0xC00 #define TIME_MAX 64 #define USEC_TO_MILLI 1000 @@ -120,6 +116,8 @@ void system_time_cali(void); #ifdef SUPPORT_32K_MEAS void uapi_32k_systick_measurements(void); #endif +osSemaphoreId_t g_semaphore_save = NULL; +void save_file_main(void); static uint32_t g_app_delay_ms = TASK_COMMON_APP_DELAY_MS; app_task_definition_t g_app_tasks[] = { @@ -176,8 +174,41 @@ app_task_definition_t g_app_tasks[] = { (osThreadFunc_t)power_display_msg_thread, NULL, (CreateQueueFunction_t)power_display_task_init, USE_DTCM_MEM }, #endif + { { "save_file", 0, NULL, 0, NULL, SAVE_FILE_STACK_SIZE, TASK_PRIORITY_SAVE_FILE, 0, 0 }, + (osThreadFunc_t)save_file_main, NULL, NULL, USE_EXTEND_MEM }, }; +osSemaphoreId_t get_save_file_semaphore(void) +{ + return g_semaphore_save; +} + +void save_file_main(void) +{ + g_semaphore_save = osSemaphoreNew(1, 0, NULL); + if (!g_semaphore_save) { + panic(PANIC_LOG, LOG_PANIC_MUTEX_NOT_READY); + return; + } + for (;;) { + // If there has been log indicator get run again + if (osKernelGetState() == osKernelRunning) { + if (osSemaphoreAcquire(g_semaphore_save, osWaitForever) != osOK) { + panic(PANIC_LOG, LOG_PANIC_MUTEX_NOT_READY); + } + nand_driver_init(SPEED_SLOW); + set_trans_type(TRANS_BY_CPU_SINGLE_LINE); +#if defined SAVE_EXC_INFO + save_preserve_file_to_nand(); + save_btram_file_to_nand(); + save_btrace_file_to_nand(); +#endif + hal_reboot_chip(); + } + osDelay(1000); + } +} + void set_app_delay_time(uint32_t time) { g_app_delay_ms = time; @@ -242,40 +273,6 @@ static void print_system_sleep_info(void) #endif } -#ifdef CONFIG_OTA_UPDATE_SUPPORT -static void upg_check_upgrade(void) -{ - uint32_t fota_address = 0; - errcode_t ret_val = (errcode_t)upg_get_upgrade_flag_flash_start_addr(&fota_address); - if (ret_val != ERRCODE_SUCC) { - return; - } - - fota_upgrade_flag_area_t upg_flag_info; - ret_val = (errcode_t)upg_flash_read(fota_address, sizeof(fota_upgrade_flag_area_t), (uint8_t *)(&upg_flag_info)); - if (ret_val != ERRCODE_SUCC) { - return; - } - - if (!(upg_flag_info.head_magic == UPG_HEAD_MAGIC && - upg_flag_info.head_end_magic == UPG_END_MAGIC && - upg_flag_info.complete_flag == UPG_FLAG_MAGIC)) { - /* 不需要升级直接返回 */ - PRINT("No need to upgrade...\r\n"); - return; - } - - PRINT("upgrading.......\r\n"); - ret_val = uapi_upg_start(); - if (ret_val != ERRCODE_SUCC) { - PRINT("upgrade failed, ret = 0x%x\r\n", ret_val); - } else { - PRINT("upgrade success\r\n"); - } - upg_reboot(); -} -#endif - #ifdef SUPPORT_32K_MEAS /* 使用32M tcxo 测量 systick的32K频率值 */ void uapi_32k_systick_measurements(void) @@ -312,12 +309,7 @@ void system_time_cali(void) static void app_main(const void *unused) { unused(unused); -#ifdef CONFIG_OTA_UPDATE_SUPPORT - upg_check_upgrade(); -#endif dfx_set_log_enable(); - /* nv init and file system init must be before nv_upg_upgrade_task_process */ - (void)nv_upg_upgrade_task_process(); #ifdef SUPPORT_MEDIA_AUDIO_MANAGER bool success = AudioManagerInit(); PRINT("audio manager init %s\r\n", success ? "ok" : "error"); 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 a812c9efc..93c7f41df 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c @@ -51,11 +51,19 @@ #include "ohosfwk_startup.h" #endif #include "clocks_config.h" +#include "board_init.h" +#include "upg.h" +#include "upg_definitions.h" +#include "nv.h" +#include "nv_upg.h" #define EMMC_BASE_ADDR 0x52062000 #define TASK_PRIORITY_APP (osPriority_t)(17) #define TICK_TEN_MS (10U) #define WAIT_BT_BOOTUP_TIME 200U +#define UPG_HEAD_MAGIC 0x55AA55AA +#define UPG_END_MAGIC 0xAA55AA55 +#define UPG_FLAG_MAGIC 0xFFFFFFFF static void thread_main(const void *unused); void bt_acore_btc_ipc_receive_init(void); @@ -241,6 +249,40 @@ static void force_to_sleep(void) } } +#ifdef CONFIG_OTA_UPDATE_SUPPORT +static void upg_check_upgrade(void) +{ + uint32_t fota_address = 0; + errcode_t ret_val = (errcode_t)upg_get_upgrade_flag_flash_start_addr(&fota_address); + if (ret_val != ERRCODE_SUCC) { + return; + } + + fota_upgrade_flag_area_t upg_flag_info; + ret_val = (errcode_t)upg_flash_read(fota_address, sizeof(fota_upgrade_flag_area_t), (uint8_t *)(&upg_flag_info)); + if (ret_val != ERRCODE_SUCC) { + return; + } + + if (!(upg_flag_info.head_magic == UPG_HEAD_MAGIC && + upg_flag_info.head_end_magic == UPG_END_MAGIC && + upg_flag_info.complete_flag == UPG_FLAG_MAGIC)) { + /* 不需要升级直接返回 */ + PRINT("No need to upgrade...\r\n"); + return; + } + + PRINT("upgrading.......\r\n"); + ret_val = uapi_upg_start(); + if (ret_val != ERRCODE_SUCC) { + PRINT("upgrade failed, ret = 0x%x\r\n", ret_val); + } else { + PRINT("upgrade success\r\n"); + } + upg_reboot(); +} +#endif + static void thread_main(const void *unused) { PRINT("thread_main start "NEWLINE); @@ -281,6 +323,11 @@ static void thread_main(const void *unused) #endif board_version_class_print(); uapi_watchdog_kick(); +#ifdef CONFIG_OTA_UPDATE_SUPPORT + upg_check_upgrade(); +#endif + /* nv init and file system init must be before nv_upg_upgrade_task_process */ + (void)nv_upg_upgrade_task_process(); thread_init(); button_app_init(); uapi_calendar_init(); diff --git a/code/sdk/application/wearable/alipay/service/CMakeLists.txt b/code/sdk/application/wearable/alipay/service/CMakeLists.txt index 7bf23a649..f6a8a07d3 100644 --- a/code/sdk/application/wearable/alipay/service/CMakeLists.txt +++ b/code/sdk/application/wearable/alipay/service/CMakeLists.txt @@ -1,4 +1,6 @@ set(COMPONENT_NAME "alipay_service") +set(MODULE_NAME "app") +set(AUTO_DEF_FILE_ID TRUE) set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c b/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c index 685e0e811..5322e54c5 100644 --- a/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c +++ b/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c @@ -14,6 +14,9 @@ #include "osal_task.h" #include "alipay_feature.h" #include "securec.h" +#ifdef JS_ENABLE +#include "msg_center_msg.h" +#endif /* Gatt service UUID */ #define ALIPAYY_SERVICE_ID 0x0238 @@ -155,9 +158,16 @@ static void svr_alipay_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t conn_state, pair_state); g_alipay_conn_id = conn_id; if (GAP_BLE_STATE_DISCONNECTED == conn_state) { // restart ble adv when disconnected + #ifdef JS_ENABLE + /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ + SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, NULL, 0); + #endif svr_alipay_ble_adv_start(); } else { svr_alipay_set_adv_start_state(false); + #ifdef JS_ENABLE + SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, NULL, 0); + #endif } } diff --git a/code/sdk/application/wearable/alipay/service/alipay_feature.h b/code/sdk/application/wearable/alipay/service/alipay_feature.h index 12a7aec6d..3616c962b 100644 --- a/code/sdk/application/wearable/alipay/service/alipay_feature.h +++ b/code/sdk/application/wearable/alipay/service/alipay_feature.h @@ -18,16 +18,26 @@ extern "C" { #include #include "stdbool.h" #include "errcode.h" +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) +#include "soc_diag_util.h" +#include "log_oam_logger.h" +#include "log_def.h" +#else #include "debug_print.h" +#endif #define APP_SUCCESS 0 #define APP_FAILURE (-1) -#ifdef ALIPAY_HSO_DEBUG_LOG -#define ALIPAY_PRINT_ERR(log_num, fmt, args...) uapi_diag_error_log(0, fmt, ##arg) -#define ALIPAY_PRINT_WARN(log_num, fmt, args...) uapi_diag_warning_log(0, fmt, ##arg) -#define ALIPAY_PRINT_INFO(log_num, fmt, args...) uapi_diag_info_log(0, fmt, ##arg) -#define ALIPAY_PRINT_DEBUG(log_num, fmt, args...) +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) +#define ALIPAY_PRINT_ERR(log_num, fmt, arg...) uapi_diag_error_log(0, fmt, ##arg) +#define ALIPAY_PRINT_WARN(log_num, fmt, arg...) uapi_diag_warning_log(0, fmt, ##arg) +#define ALIPAY_PRINT_INFO(log_num, fmt, arg...) uapi_diag_info_log(0, fmt, ##arg) +#ifdef WEARABLE_LOG_DEBUG +#define ALIPAY_PRINT_DEBUG(log_num, fmt, arg...) uapi_diag_debug_log(0, fmt, ##arg) +#else +#define ALIPAY_PRINT_DEBUG(log_num, fmt, arg...) +#endif #else #define ALIPAY_PRINT_ERR(log_num, fmt, arg...) PRINT("[ALIPAY SVR E/] %s: " fmt "\r\n", __FUNCTION__, ##arg) #define ALIPAY_PRINT_WARN(log_num, fmt, arg...) PRINT("[ALIPAY SVR W/] %s: " fmt "\r\n", __FUNCTION__, ##arg) diff --git a/code/sdk/application/wearable/nativeabilityfwk/CMakeLists.txt b/code/sdk/application/wearable/nativeabilityfwk/CMakeLists.txt index cbd47f638..93f05aa2e 100644 --- a/code/sdk/application/wearable/nativeabilityfwk/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeabilityfwk/CMakeLists.txt @@ -19,6 +19,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits ${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 ) @@ -31,6 +32,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/TransitionManager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/transition/ZoomTransition.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/transition/HexagonsTransition.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/transition/BackToHexagonsTransition.cpp ) set(COMPONENT_PUBLIC_CCFLAGS diff --git a/code/sdk/application/wearable/nativeabilityfwk/include/TransitionType.h b/code/sdk/application/wearable/nativeabilityfwk/include/TransitionType.h index c969472db..092c452a5 100644 --- a/code/sdk/application/wearable/nativeabilityfwk/include/TransitionType.h +++ b/code/sdk/application/wearable/nativeabilityfwk/include/TransitionType.h @@ -12,6 +12,7 @@ enum class TransitionType { TRANSITION_INVALID = 0, TRANSITION_ZOOM, TRANSITION_HEXAGONS, + TRANSITION_BACK_TO_HEXAGONS, TRANSITION_MAX }; } diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/SliceTransition.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/SliceTransition.cpp index 2cecbeb0b..20226e665 100644 --- a/code/sdk/application/wearable/nativeabilityfwk/src/SliceTransition.cpp +++ b/code/sdk/application/wearable/nativeabilityfwk/src/SliceTransition.cpp @@ -62,11 +62,13 @@ SliceTransition::~SliceTransition() void SliceTransition::ClearTransitionResource() { - if (currentSnapshot_->GetImageInfo() != nullptr && currentSnapshot_->GetImageInfo()->data != nullptr) { + if (currentSnapshot_ != nullptr && currentSnapshot_->GetImageInfo() != nullptr && + currentSnapshot_->GetImageInfo()->data != nullptr) { ImageCacheFree(*const_cast(currentSnapshot_->GetImageInfo())); } - if (targetSnapshot_->GetImageInfo() != nullptr && targetSnapshot_->GetImageInfo()->data != nullptr) { + if (targetSnapshot_ != nullptr && targetSnapshot_->GetImageInfo() != nullptr && + targetSnapshot_->GetImageInfo()->data != nullptr) { ImageCacheFree(*const_cast(targetSnapshot_->GetImageInfo())); } if (currentSnapshot_ != nullptr) { diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/transition/BackToHexagonsTransition.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/transition/BackToHexagonsTransition.cpp new file mode 100644 index 000000000..fd7b9ba08 --- /dev/null +++ b/code/sdk/application/wearable/nativeabilityfwk/src/transition/BackToHexagonsTransition.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. + * Description: ZoomTransition + * Author: + * Create: 2024-04 + */ + +#include "BackToHexagonsTransition.h" +#include "TransitionManager.h" +#include "NativeAbility.h" +#include "components/root_view.h" +#include "AppItemView.h" +#include "hal_tick.h" +#include "wearable_log.h" + +namespace OHOS { +REGIST_TRANSITION(TransitionType::TRANSITION_BACK_TO_HEXAGONS, BackToHexagonsTransition, 300, true, false); +static const float CURRENT_SCALE_START = 1.0f; +static const float TARGET_SCALE_END = 1.0f; + +void BackToHexagonsTransition::OnTransitionStart(UIImageView* current, UIView* target) +{ + current_ = current; + target_ = dynamic_cast(target); + if ((target_ == nullptr) || (current_ == nullptr)) { + return; + } + + uint16_t sliceId = NativeAbility::GetInstance().GetPreSliceId(); + UIView* childView = target_->GetChildrenHead(); + while (childView != nullptr) { + HexagonsItemView* itemView = dynamic_cast(childView); + if ((itemView != nullptr) && (itemView->GetViewId() == sliceId)) { + focusIndex_ = itemView->GetViewIndex(); + focusView_ = itemView; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "BackToHexagonsTransition focus %d", focusIndex_); + break; + } + childView = childView->GetNextSibling(); + } + + if (focusView_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "BackToHexagonsTransition no focus view, use default\n"); + focusView_ = target_->GetViewByIndex(0); + } + target_->Scale(1.0f, focusIndex_); + Vector2 pos = target_->GetCurrentPosition(focusIndex_); + int16_t deltaX = MATH_ROUND(target_->GetWidth() / 2.0f - pos.x_); + int16_t deltaY = MATH_ROUND(target_->GetHeight() / 2.0f - pos.y_); + target_->ScrollBy(deltaX, deltaY); + target_->ReMeasure(); + Rect rect = focusView_->GetRect(); + float xScale = current->GetWidth() * 1.0f / rect.GetWidth(); + float yScale = current->GetHeight() * 1.0f / rect.GetHeight(); + tarScaleStart_ = FloatLessEqual(xScale, yScale) ? xScale : yScale; + curScaleEnd_ = 1.0f / tarScaleStart_; +} + +void BackToHexagonsTransition::TransitionAlg(uint32_t time) +{ + if ((current_ == nullptr) || (target_== nullptr) || (focusView_ == nullptr)) { + return; + } + float timeRatio = time * 1.0f / duration_; + + float curScale = timeRatio * (curScaleEnd_ - CURRENT_SCALE_START) + CURRENT_SCALE_START; + current_->Scale(Vector2(curScale, curScale), Vector2(current_->GetWidth() / 2.0f, + current_->GetHeight() / 2.0f)); + uint8_t opa = OPA_OPAQUE + timeRatio * (OPA_TRANSPARENT - OPA_OPAQUE); + current_->SetOpaScale(opa); + + float targetScale = tarScaleStart_ + timeRatio * (TARGET_SCALE_END - tarScaleStart_); + target_->Scale(targetScale, focusIndex_); + focusView_->SetOpaScale(OPA_OPAQUE - opa); +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/transition/BackToHexagonsTransition.h b/code/sdk/application/wearable/nativeabilityfwk/src/transition/BackToHexagonsTransition.h new file mode 100644 index 000000000..2e261b2c2 --- /dev/null +++ b/code/sdk/application/wearable/nativeabilityfwk/src/transition/BackToHexagonsTransition.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. + * Description: ZoomTransition + * Author: + * Create: 2024-04 + */ + +#ifndef HEXAGONS_TRASITION_H +#define HEXAGONS_TRASITION_H +#include "TransitionCallback.h" +#include "components/ui_custom_hexagons_list.h" + +namespace OHOS { +class BackToHexagonsTransition : public TransitionCallback { +public: + BackToHexagonsTransition(uint32_t time, bool enableCurrentSnapshot, bool enableTargetSnapshot) : + TransitionCallback(time, enableCurrentSnapshot, enableTargetSnapshot) {} + ~BackToHexagonsTransition() override {} + void OnTransitionStart(UIImageView* current, UIView* target) override; + void TransitionAlg(uint32_t time) override; +private: + UIImageView* current_ = nullptr; + UICustomHexagonsList* target_ = nullptr; + UIView* focusView_ = nullptr; + uint8_t focusIndex_ = 0; + float curScaleEnd_ = 1.0f; + float tarScaleStart_ = 1.0f; +}; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.cpp index 86c7b646d..80953611b 100644 --- a/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.cpp +++ b/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.cpp @@ -9,14 +9,14 @@ #include "animator/easing_equation.h" #include "components/root_view.h" #include "TransitionManager.h" +#include "wearable_log.h" namespace OHOS { -REGIST_TRANSITION(TransitionType::TRANSITION_HEXAGONS, HexagonsTransition, 800, false, true); +REGIST_TRANSITION(TransitionType::TRANSITION_HEXAGONS, HexagonsTransition, 300, false, true); static constexpr int16_t RANGE = 1000; static const float HEXAGONS_SCALE_INIT = 1.0f; -static const float HEXAGONS_SCALE_END = 2.5f; -static const float HEXAGONS_OPA_START = 255; -static const float HEXAGONS_OPA_END = 0; +static const float HEXAGONS_SCALE_TRANSPARENT = 2.5f; +static const float TARGET_SCALE_END = 1.0f; void HexagonsTransition::OnTransitionStart(UIView* current, UIImageView* target) { @@ -33,17 +33,29 @@ void HexagonsTransition::OnTransitionStart(UIView* current, UIImageView* target) } focusView_ = dynamic_cast(current_->GetViewByIndex(focusIndex_)); if (focusView_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "HexagonsTransition no focus view\n"); return; } current_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); Vector2 delta = Vector2(current_->GetWidth() / 2, current_->GetHeight() / 2) - current_->GetCurrentPosition(focusIndex_); - scaleStart_ = current_->GetGlobalScale(); opaStart_ = current->GetOpaScale(); + scaleStart_ = current_->GetGlobalScale(); + Rect rect = focusView_->GetRect(); + float xScale = target_->GetWidth() * 1.0f / rect.GetWidth(); + float yScale = target_->GetHeight() * 1.0f / rect.GetHeight(); + scaleEnd_ = FloatLessEqual(xScale, yScale) ? xScale : yScale; + + targetXStart_ = rect.GetX(); + targetYStart_ = rect.GetY(); + targetScaleStart_ = 1.0f / scaleEnd_; + uint32_t offsetTime = static_cast((scaleStart_ - HEXAGONS_SCALE_INIT) / - (HEXAGONS_SCALE_END - HEXAGONS_SCALE_INIT) * duration_ * 0.5f); // 0.5 half of duration + (scaleEnd_ - HEXAGONS_SCALE_INIT) * duration_); durationBackup_ = duration_; duration_ = duration_ - offsetTime; + thresholdTime_ = static_cast((HEXAGONS_SCALE_TRANSPARENT - scaleStart_) / (scaleEnd_ - scaleStart_) + * duration_); xDistance_ = delta.x_; yDistance_ = delta.y_; prevX_ = 0; @@ -60,35 +72,30 @@ void HexagonsTransition::TransitionAlg(uint32_t time) return; } float timeRatio = time * 1.0f / duration_; - if (FloatLessEqual(timeRatio, 0.5f)) { // 0.5f, half of transition - float hexagonsRatio = 2 * timeRatio; - int16_t curX = static_cast(hexagonsRatio * xDistance_); - int16_t curY = static_cast(hexagonsRatio * yDistance_); - current_->ScrollBy(curX - prevX_, curY - prevY_); - prevX_ = curX; - prevY_ = curY; + float opaRatio = time * 1.0f / thresholdTime_; + opaRatio = FloatMore(opaRatio, 1.0f) ? 1.0f : opaRatio; + int16_t curX = static_cast(timeRatio * xDistance_); + int16_t curY = static_cast(timeRatio * yDistance_); + current_->ScrollBy(curX - prevX_, curY - prevY_); + prevX_ = curX; + prevY_ = curY; - float curScale = hexagonsRatio * (HEXAGONS_SCALE_END - scaleStart_) + scaleStart_; - uint8_t opa = hexagonsRatio * (HEXAGONS_OPA_END - opaStart_) + opaStart_; - focusView_->SetOpaScale(opa); - current_->Scale(curScale, focusIndex_); - Rect rect = focusView_->GetRect(); - target_->SetPosition(rect.GetX(), rect.GetY()); - targetMiddleScale_ = Vector2(rect.GetWidth() * 1.0f / target_->GetWidth(), - rect.GetHeight() * 1.0f / target_->GetHeight()); - target_->Scale(targetMiddleScale_, Vector2(0.0f, 0.0f)); - } else if (FloatLessEqual(timeRatio, 1.0f)) { - current_->SetVisible(false); - Vector2 targetScale = {2 * (timeRatio - 0.5f) * (1.0f - targetMiddleScale_.x_) + targetMiddleScale_.x_, - 2 * (timeRatio - 0.5f) * (1.0f - targetMiddleScale_.y_) + targetMiddleScale_.y_}; - target_->SetPosition(0, 0); - target_->Scale(targetScale, Vector2(target_->GetWidth() / 2.0f, target_->GetHeight() / 2.0f)); - } + float curScale = timeRatio * (scaleEnd_ - scaleStart_) + scaleStart_; + uint8_t opa = opaRatio * (OPA_TRANSPARENT - opaStart_) + opaStart_; + focusView_->SetOpaScale(opa); + current_->Scale(curScale, focusIndex_); + + int16_t targetXPos = static_cast((1.0f - timeRatio) * targetXStart_); + int16_t targetYPos = static_cast((1.0f - timeRatio) * targetYStart_); + target_->SetPosition(targetXPos, targetYPos); + float targetScale = targetScaleStart_ + timeRatio * (1.0f - targetScaleStart_); + target_->Scale(Vector2(targetScale, targetScale), Vector2(0.0f, 0.0f)); + uint8_t targetOpa = timeRatio * (OPA_OPAQUE - OPA_TRANSPARENT) + OPA_TRANSPARENT; + target_->SetOpaScale(targetOpa); } void HexagonsTransition::OnTransitionEnd() { duration_ = durationBackup_; } - -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.h b/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.h index a7315dbfc..46dd72ec2 100644 --- a/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.h +++ b/code/sdk/application/wearable/nativeabilityfwk/src/transition/HexagonsTransition.h @@ -24,14 +24,18 @@ private: UICustomHexagonsList* current_ = nullptr; UIImageView* target_ = nullptr; UIImageView* focusView_ = nullptr; - Vector2 targetMiddleScale_ = {0, 0}; uint8_t focusIndex_ = 0; float scaleStart_ = 1.0f; + float scaleEnd_ = 1.0f; uint8_t opaStart_ = 255; int16_t xDistance_ = 0; int16_t yDistance_ = 0; int16_t prevX_ = 0; int16_t prevY_ = 0; + float thresholdTime_ = 0.0f; + int16_t targetXStart_ = 0; + int16_t targetYStart_ = 0; + float targetScaleStart_ = 1.0f; }; } // namespace OHOS #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 35ef952d3..0e72a0e7e 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -265,6 +265,7 @@ set(SOURCES ${UI_SAMPLE_ROOT}/components/ui_test_cube_rotate/cube_rotate_view.cpp ${UI_SAMPLE_ROOT}/components/ui_test_cube_rotate/ui_test_cube_rotate.cpp ${UI_SAMPLE_ROOT}/components/ui_test_video_play/ui_test_video_play.cpp + ${UI_SAMPLE_ROOT}/components/ui_test_keyboard/ui_test_keyboard.cpp ${UI_SAMPLE_ROOT}/components/ui_test_hexagons_list/ui_test_hexagons_list.cpp ${UI_SAMPLE_ROOT}/components/ui_test_coverflow/ui_test_coverflow.cpp ${UI_SAMPLE_ROOT}/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp @@ -336,6 +337,7 @@ set(COMPONENT_CCFLAGS -Wno-c++11-narrowing -Wno-error=unused-function -Wno-missing-field-initializers + -Werror=return-type ) set(WHOLE_LINK 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 0be241e38..c8cd31ca6 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -28,6 +28,7 @@ #include "bt_audio_hal_interface.h" #include "audio_manager_c_wrapper.h" #include "bts_avrcp_target.h" +#include "msg_center_msg.h" namespace OHOS { @@ -761,15 +762,17 @@ void BluetoothModel::BtGapAclStateChangedHandle(gap_acl_state_t state, unsigned if (!tag) { AddConnedDevicesCase(*onClickBtCaseInfo); } - ACLConnectionSuss(bdAddr); } else { ACLConnectionFail(bdAddr); } if ((state == GAP_ACL_STATE_CONNECTED) || (state == GAP_ACL_STATE_LE_CONNECTED)) { if (BluetoothModel::GetInstance()->ConnectRemoteCheck(&bdAddr)) { - bool retA2dp = a2dp_src_connect(&bdAddr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connect result %d", retA2dp); + int32_t retA2dp = a2dp_src_connect(&bdAddr); + if (retA2dp) { + ACLConnectionFail(bdAddr); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connect result 0x%x", retA2dp); } else { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ingore a2dp_src_connect"); } @@ -836,10 +839,12 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) if (connState == PROFILE_STATE_CONNECTED) { avrcp_ct_connect(bdAddr); PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_CONNECTED); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr)); } if (connState == PROFILE_STATE_DISCONNECTED) { PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_DISCONNECTED); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr)); } } @@ -867,9 +872,12 @@ static void BleConnStateChangeCallback(unsigned short connId, bd_addr_t *addr, g WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleConnStateChangeCallback connId 0x%x, connState 0x%x, pairState 0x%x", connId, connState, pairState); if (GAP_BLE_STATE_DISCONNECTED == connState) { // restart ble adv when disconnected + /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ + SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); BleAdvStart(); } else { BluetoothModel::GetInstance()->SetAdvStartState(false); + SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); } } 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 b3d48751d..68aeab844 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp @@ -442,11 +442,15 @@ static void WatchFinishHandle(void) static void ChangeStatusScreendisplay(int lastStatus) { if (GetScoConnectState() != HFP_SCO_STATE_CONNECTED) { - if (lastStatus == OPERATE_INCOMING) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] lastStatus OPERATE_INCOMING"); - } else if (GetCurrCallNum() == 1 && (lastStatus == OPERATE_DIALING || - lastStatus == OPERATE_ALERTING)) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] lastStatus OPERATE_ALERTING"); + if (lastStatus == HFP_HF_CALL_STATE_ACTIVE) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] STATE_ACTIVE"); + StatusReset(); + return; + } else if (lastStatus == HFP_HF_CALL_STATE_INCOMING) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] STATE_INCOMING"); + } else if (GetCurrCallNum() == 1 && (lastStatus == HFP_HF_CALL_STATE_DIALING || + lastStatus == HFP_HF_CALL_STATE_ALERTING)) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] STATE_ALERTING"); } else if (GetCurrCallNum() > 1) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] GetCurrCallNum MULITE"); DisableCallingTimer(); 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 bce8f5d5c..1d34972dc 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp @@ -65,7 +65,11 @@ void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) { if (MainCallingPresenter::GetInstance() != nullptr && CallerLogModel::GetInstance()->GetCallStatus()) { if (CallerLogModel::GetInstance()->GetVolumeScreenStatus()) { - volumeSliderEventListener = VolumeSliderEventListener::GetInstance(); + VolumeSettingView *settingView = MainCallingPresenter::GetInstance()->GetvolumeSetting(); + if (settingView == nullptr) { + return; + } + volumeSliderEventListener = settingView->GetVolumeEventListener(); if (volumeSliderEventListener == nullptr) { return; } @@ -77,7 +81,11 @@ void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) } if (IsNotifyCallStatus()) { if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) { - volumeSliderEventListener = VolumeSliderEventListener::GetInstance(); + VolumeSettingView *settingView = GetvolumeSetting(); + if (settingView == nullptr) { + return; + } + volumeSliderEventListener = settingView->GetVolumeEventListener(); if (volumeSliderEventListener == nullptr) { return; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingPresenter.h index f18dac441..07a41562c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingPresenter.h @@ -33,11 +33,12 @@ typedef enum : uint8_t { VOLUMEDRAG = 2, } VolumeChangeStatus; +class VolumeSettingView; class VolumeSliderEventListener : public UISlider::UISliderEventListener, public UIView::OnClickListener, public UIView::OnDragListener { public: - VolumeSliderEventListener(); + VolumeSliderEventListener(VolumeSettingView *volumeSetting); ~VolumeSliderEventListener(); static VolumeSliderEventListener *GetInstance(); void OnChange(int32_t progress) override; @@ -50,6 +51,7 @@ public: private: int16_t preSound{0}; int16_t playerCoefficients{0}; + VolumeSettingView *volumeSettingView{nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h index 365ced2c4..63a201e97 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingView.h @@ -24,13 +24,13 @@ class VolumeSettingView : public UIViewGroup { public: VolumeSettingView(); ~VolumeSettingView(); - static VolumeSettingView *GetInstance(void); int16_t sounding{0}; UISlider *GetProgress(void); bool SetUpVolume(void); UIButton *GetIncreaseButton(void); UIButton *GetDecreaseButton(void); + VolumeSliderEventListener *GetVolumeEventListener(void); private: VolumeSliderEventListener *listener{nullptr}; UISlider *progress{nullptr}; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingPresenter.cpp index 96e362cb8..7ca2d4c07 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingPresenter.cpp @@ -25,26 +25,16 @@ namespace OHOS { extern "C" { #endif -static VolumeSliderEventListener *g_pVolumeSliderEventListener = nullptr; - constexpr int16_t SOUND_CHANGE = 10; -VolumeSliderEventListener::VolumeSliderEventListener() +VolumeSliderEventListener::VolumeSliderEventListener(VolumeSettingView *volumeSetting) : volumeSettingView(volumeSetting) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener new"); - g_pVolumeSliderEventListener = this; } VolumeSliderEventListener::~VolumeSliderEventListener() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener::~VolumeSliderEventListener"); - g_pVolumeSliderEventListener = nullptr; -} - -VolumeSliderEventListener *VolumeSliderEventListener::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener GetInstance"); - return g_pVolumeSliderEventListener; } bool VolumeSliderEventListener::OnClick(UIView& view, const ClickEvent& event) @@ -67,11 +57,6 @@ bool VolumeSliderEventListener::OnClick(UIView& view, const ClickEvent& event) void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status) { ImageInfo *image; - VolumeSettingView *volumeSettingView = VolumeSettingView::GetInstance(); - if (volumeSettingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick:volumeSettingView new fail"); - return; - } UISlider *progress = volumeSettingView->GetProgress(); if (progress == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick:progress new fail"); @@ -172,11 +157,6 @@ void VolumeSliderEventListener::OnChange(int32_t value) bool VolumeSliderEventListener::OnDrag(UIView& view, const DragEvent& event) { - VolumeSettingView *volumeSettingView = VolumeSettingView::GetInstance(); - if (volumeSettingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnDrag::volumeSettingView new fail"); - return false; - } if (strcmp(view.GetViewId(), VOLUME_VIEW) == 0) { if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener::OnDrag"); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingView.cpp index c4d3bad80..e8eeb4df7 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingView.cpp @@ -10,7 +10,6 @@ #include "ui_resource_image.h" namespace OHOS { -static VolumeSettingView *g_pVolumeSettingView{nullptr}; static constexpr uint16_t BUTTON_X = 182; static constexpr uint16_t BUTTON_Y = 0; static constexpr uint16_t BUTTON_Y2 = 363; @@ -27,18 +26,15 @@ constexpr int16_t VOLUME_ERROR = (-1); VolumeSettingView::VolumeSettingView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSettingView::VolumeSettingView"); - g_pVolumeSettingView = this; } VolumeSettingView::~VolumeSettingView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSettingView::~VolumeSettingView"); RemoveAll(); - - UIView::OnClickListener *click = increaseButton->GetOnClickListener(); - if (click != nullptr) { - delete click; - click = nullptr; + if (listener != nullptr) { + delete listener; + listener = nullptr; } delete increaseButton; increaseButton = nullptr; @@ -48,13 +44,6 @@ VolumeSettingView::~VolumeSettingView() delete progress; progress = nullptr; - - g_pVolumeSettingView = nullptr; -} - -VolumeSettingView *VolumeSettingView::GetInstance(void) -{ - return g_pVolumeSettingView; } bool VolumeSettingView::SetUpVolume(void) @@ -78,7 +67,7 @@ bool VolumeSettingView::SetUpVolume(void) progress->SetRange(VOLUME_MAX, VOLUME_MIN); if (listener == nullptr) { - listener = new VolumeSliderEventListener(); + listener = new VolumeSliderEventListener(this); if (listener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener new fail"); return false; @@ -88,9 +77,8 @@ bool VolumeSettingView::SetUpVolume(void) progress->SetOnClickListener(listener); progress->SetOnDragListener(listener); progress->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); - UIView::OnDragListener *volDragListener = (UIView::OnDragListener *)OHOS::VolumeSliderEventListener::GetInstance(); SetViewId(VOLUME_VIEW); - SetOnDragListener(volDragListener); + SetOnDragListener(listener); SetDraggable(true); SetTouchable(true); Add(progress); @@ -117,7 +105,6 @@ UIButton *VolumeSettingView::GetDecreaseButton(void) int VolumeSettingView::ShowVolume(void) { ImageInfo *image; - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::VolumeSliderEventListener::GetInstance(); if (increaseButton == nullptr) { increaseButton = new UIButton(); if (increaseButton == nullptr) { @@ -129,7 +116,7 @@ int VolumeSettingView::ShowVolume(void) increaseButton->SetViewId(INCREASE_BUTTON); image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_INCREASE_BUTTON, PLAYER_IAMGES); increaseButton->SetImageSrc(image, image); - increaseButton->SetOnClickListener(clickListener); + increaseButton->SetOnClickListener(listener); Add(increaseButton); if (decreaseButton == nullptr) { @@ -143,9 +130,15 @@ int VolumeSettingView::ShowVolume(void) decreaseButton->SetViewId(DECREASE_BUTTON); image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_DECREASE_BUTTON, PLAYER_IAMGES); decreaseButton->SetImageSrc(image, image); - decreaseButton->SetOnClickListener(clickListener); + decreaseButton->SetOnClickListener(listener); Add(decreaseButton); return VOLUME_OK; } + +VolumeSliderEventListener *VolumeSettingView::GetVolumeEventListener(void) +{ + return listener; +} + } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/makephone/include/MainCallingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/makephone/include/MainCallingPresenter.h index 3b7b8c542..dd1ef4e1b 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/makephone/include/MainCallingPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/makephone/include/MainCallingPresenter.h @@ -31,12 +31,12 @@ public: bool CallingViewDisplay(); bool InitPointerValue(); bool OnClick(UIView& view, const ClickEvent& event) override; + VolumeSettingView *GetvolumeSetting(); private: int changeImage{0}; bool HintsHandupClick(); KeyInputListener *keyActListenr{nullptr}; VolumeSettingView *volumeSetting{nullptr}; - UIViewGroup *volumeSettingView{nullptr}; }; } 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 93f2560c3..544d77562 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp @@ -30,9 +30,8 @@ MainCallingPresenter::~MainCallingPresenter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::~MainCallingPresenter"); RootView::GetInstance()->RemoveAll(); - if (volumeSettingView != nullptr) { - delete volumeSettingView; - volumeSettingView = nullptr; + if (volumeSetting != nullptr) { + delete volumeSetting; volumeSetting = nullptr; } g_pMainView = nullptr; @@ -70,7 +69,7 @@ void MainCallingPresenter::OnStop(void) void MainCallingPresenter::HonrsViewChange() { - if (volumeSettingView == nullptr) { + if (volumeSetting == nullptr) { volumeSetting = new VolumeSettingView(); if (volumeSetting == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSetting nullptr err"); @@ -85,10 +84,9 @@ void MainCallingPresenter::HonrsViewChange() ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); volumeSetting->GetDecreaseButton()->SetImageSrc(image, image); } - volumeSettingView = volumeSetting; - RootView::GetInstance()->Add(volumeSettingView); + RootView::GetInstance()->Add(volumeSetting); } - VolumeSliderEventListener *volumeSliderEventListener = VolumeSliderEventListener::GetInstance(); + VolumeSliderEventListener *volumeSliderEventListener = volumeSetting->GetVolumeEventListener(); if (volumeSliderEventListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSliderEventListener nullptr err"); return; @@ -105,7 +103,7 @@ void MainCallingPresenter::HonrsViewChange() view_->GetCallingGroup()->SetVisible(false); view_->GetWaitingGroup()->SetVisible(false); - volumeSettingView->SetVisible(true); + volumeSetting->SetVisible(true); // 刷新UI RootView::GetInstance()->Invalidate(); } @@ -232,4 +230,9 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) } return true; } + +VolumeSettingView *MainCallingPresenter::GetvolumeSetting() +{ + return volumeSetting; +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp index f3641a545..7a9d9481d 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp @@ -24,6 +24,8 @@ #include "service_id_define.h" #include "samgr_lite.h" #include "ui_service.h" +#include "msg_center_msg.h" + #ifdef __cplusplus extern "C" { #endif @@ -596,6 +598,7 @@ static void ConnStateChanged(const bd_addr_t *bdAddr, profile_connect_state_t st WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT connected"); BtConnectedPro(bdAddr); SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); + SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); break; case PROFILE_STATE_DISCONNECTING: // 蓝牙连接断连 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT disconnecting"); @@ -604,6 +607,7 @@ static void ConnStateChanged(const bd_addr_t *bdAddr, profile_connect_state_t st WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT disconnected"); BtDisconnectedPro(); SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); + SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); break; default: break; @@ -628,7 +632,7 @@ static void ScoConnectPro(void) hfp_hf_calls_info_t call = {0}; HfpIncomingEventPublish(TOPIC_EVENT_HFP_PHONE_TO_WATCH, call); } - + PostGraphicEvent(AudioSetup); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[ScoConnectPro] audioState:%d", g_audioState); } @@ -1184,6 +1188,7 @@ static void CallChangeActivePro(const hfp_hf_calls_info_t *call) if (phoneCall == nullptr) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallChangeActivePro] Active no this call"); AddCurrCallToCallList(call); + TransCallToMobilePhone(); return; } 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 cd2d0f4a3..98510eb9e 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp @@ -551,7 +551,7 @@ void ButtonOnClickListener::SoundButtonOnClick() ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); volumeSettingView->GetDecreaseButton()->SetImageSrc(image, image); } - VolumeSliderEventListener *volumeSliderEventListener = VolumeSliderEventListener::GetInstance(); + VolumeSliderEventListener *volumeSliderEventListener = volumeSettingView->GetVolumeEventListener(); if (volumeSliderEventListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundButtonOnClick volumeSliderEventListener nullptr err"); return; 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 c26ec330a..93f3e8355 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 @@ -4,7 +4,7 @@ * Author: * Create: 2021-11-23 */ - +#include #include "MainModel.h" #include "SetDialModel.h" #include "kv_store.h" @@ -27,7 +27,12 @@ namespace OHOS { { dialInfoList.clear(); LoadAllDialFromRam(); + size_t dialSize = dialInfoList.size(); LoadAllDialFromFs(); + /* 只排序离线表盘 */ + std::sort(dialInfoList.begin() + dialSize, dialInfoList.end(), [](const SetDialInfo& f, const SetDialInfo& n) { + return f.dialName < n.dialName; + }); } void SetDialModel::LoadAllDialFromRam() @@ -152,20 +157,16 @@ namespace OHOS { for (auto iter : dialInfoList) { if (dialSetting.dialFlag) { if (strcmp(iter.dialFullName.c_str(), dialSetting.dialFullName.c_str()) == 0) { - break; + return index; } } else { - if (iter.id == dialSetting.dialId ) { - break; + if ((!iter.dialFlag) && (iter.id == dialSetting.dialId)) { + return index; } } index++; } - if (index >= dialInfoList.size()) { - return 0; - } else { - return index; - } + return 0; } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp index 1b21157c6..63a84c7fb 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp @@ -47,7 +47,7 @@ namespace OHOS { if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice(VIEW_APPLIST)"); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return false; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/uisample/uitest/framework/src/ui_test_group.cpp b/code/sdk/application/wearable/nativeapp/nativeui/uisample/uitest/framework/src/ui_test_group.cpp index a6307df44..3e4da3ccf 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/uisample/uitest/framework/src/ui_test_group.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/uisample/uitest/framework/src/ui_test_group.cpp @@ -24,6 +24,9 @@ #include "ui_test_countdown/ui_test_countdown.h" #include "ui_test_running_ball/ui_test_running_ball.h" #endif +#if ENABLE_SOFT_KEYBOARD +#include "ui_test_keyboard/ui_test_keyboard.h" +#endif #include "ui_test_tiger/ui_test_tiger.h" #include "ui_test_hexagons_list/ui_test_hexagons_list.h" #include "ui_test_video_play/ui_test_video_play.h" @@ -59,6 +62,9 @@ void UITestGroup::SetUpTestCase() #if ENABLE_VGU_ENGINE && CAPABILITY_HWDRAW_PATH testCaseList_->PushBack(TestCaseInfo{"倒计时", new UITestCountdown()}); testCaseList_->PushBack(TestCaseInfo{"动画曲线", new UITestRunningBall()}); +#endif +#if ENABLE_SOFT_KEYBOARD + testCaseList_->PushBack(TestCaseInfo{"软键盘", new UITestKeyboard()}); #endif testCaseList_->PushBack(TestCaseInfo{"视频播放", new UITestVideoPlay()}); } diff --git a/code/sdk/application/wearable/ohos_deps/wearable_log.h b/code/sdk/application/wearable/ohos_deps/wearable_log.h index f2a059031..c5180fcbf 100644 --- a/code/sdk/application/wearable/ohos_deps/wearable_log.h +++ b/code/sdk/application/wearable/ohos_deps/wearable_log.h @@ -13,7 +13,7 @@ extern "C" { #endif #endif -#ifdef USE_DIAG_LOG +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) #include "soc_diag_util.h" #include "log_oam_logger.h" #include "log_def.h" @@ -48,12 +48,16 @@ typedef enum { WEARABLE_LOG_MODULE_MAX } WearableLogModuleType; -#ifdef USE_DIAG_LOG +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) #define WEARABLE_LOGE(mod, fmt, arg...) uapi_diag_error_log(0, fmt, ##arg) #define WEARABLE_LOGW(mod, fmt, arg...) uapi_diag_warning_log(0, fmt, ##arg) #define WEARABLE_LOGI(mod, fmt, arg...) uapi_diag_info_log(0, fmt, ##arg) +#ifdef WEARABLE_LOG_DEBUG #define WEARABLE_LOGD(mod, fmt, arg...) uapi_diag_debug_log(0, fmt, ##arg) #else +#define WEARABLE_LOGD(mod, fmt, arg...) +#endif +#else #define WEARABLE_LOGE(mod, fmt, arg...) PRINT("[WEARABLE E/] %s: " fmt "\n", __FUNCTION__, ##arg) #define WEARABLE_LOGW(mod, fmt, arg...) PRINT("[WEARABLE W/] %s: " fmt "\n", __FUNCTION__, ##arg) #define WEARABLE_LOGI(mod, fmt, arg...) PRINT("[WEARABLE I/] %s: " fmt "\n", __FUNCTION__, ##arg) 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 0aa918900..914878b09 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 cef97c6b8..8c53ae5ad 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.h b/code/sdk/application/wearable/service/msg_center/include/msg_center.h index fb41aa590..c8d8e86ac 100644 --- a/code/sdk/application/wearable/service/msg_center/include/msg_center.h +++ b/code/sdk/application/wearable/service/msg_center/include/msg_center.h @@ -13,11 +13,10 @@ * limitations under the License. */ -#ifndef OHOS_MAIN_SERVICE_H -#define OHOS_MAIN_SERVICE_H +#ifndef MSG_CENTER_H +#define MSG_CENTER_H #include - #include "service.h" #include "iunknown.h" #include "broadcast_feature.h" @@ -38,6 +37,7 @@ typedef enum { typedef struct MsgCenterFeatureApi { INHERIT_IUNKNOWN; + int32_t (*SendMsg)(int32_t msgId, uint32_t msgValue, void *data, int32_t dataLen); } MsgCenterFeatureApi; typedef struct MsgCenter { diff --git a/code/sdk/application/wearable/service/msg_center/include/msg_center_msg.h b/code/sdk/application/wearable/service/msg_center/include/msg_center_msg.h new file mode 100644 index 000000000..f32c9b7f9 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/include/msg_center_msg.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: broadcast service api + * Author: CompanyName + * Create: 2021-11-11 + */ + +#ifndef MSG_CENTER_MSG_H +#define MSG_CENTER_MSG_H + +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + BT_DISCONNECTED_TO_MSGCENTER, + BT_CONNECTED_TO_MSGCENTER, + MSGCENTER_ADD_SLEEP_VETO, + MSGCENTER_RM_SLEEP_VETO, +} MsgCenterServiceMsgId; + +void SendMsgToMsgCenterService(int32_t msgId, uint32_t msgValue, void *data, int32_t dataLen); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file 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 0b0b14d1e..09e682472 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 @@ -40,6 +40,12 @@ extern "C" { #define FILE_SPILT_MAX_SIZE 970 /* SPP包不能超过990字节 */ #define FILE_NAME_MAX_LEN 100 +typedef enum msg_center_pcm_end_flag { + PCM_END_FLAG_AI_CHAT, /* AI对话 */ + PCM_END_FLAG_WATCH_FACE, /* 表盘 */ + PCM_END_FLAG_VECTOR_NAVI, /* 矢量地图 */ +} msg_center_pcm_end_flag_t; + typedef enum msg_center_xiaodu_type_id { MSGCENTER_TYPE_ID_XIAODU_START = 0x1, MSGCENTER_TYPE_ID_XIAODU_RECV_XIAODU_INFO, @@ -117,6 +123,10 @@ typedef enum msg_center_vector_navi_type_id { MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_GEOCODE_SEARCH, MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_REGEOCODE_SEARCH, MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_REGEOCODE_SEARCH, + /* 地图私有协议 */ + MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_DESTROY_PAGE, + MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_DISCONNECTED, + MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED, } msg_center_vector_navi_type_id_t; typedef enum msg_center_alipay_type_id { @@ -281,6 +291,7 @@ static const char *g_vector_navi_str_tb[] = { "rec_geocode_search", "req_regeocode_search", "rec_regeocode_search", + "req_destroy_page", }; static inline const char* vector_navi_get_str(uint8_t type) @@ -295,6 +306,8 @@ int32_t msg_center_fill_tlv(msg_center_pkt_tlv_t *tlv, uint8_t type, uint8_t *va errcode_t msg_center_send_data(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); void msg_center_split_file(char *origin_file, int size, char *flist); void msg_center_combine_file(char *flist, char *target_file_name); +diag_frame_fid_t msg_center_get_trans_channel(); +void msg_center_set_trans_channel(diag_frame_fid_t select); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h index 59671baec..82210db63 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h @@ -15,11 +15,13 @@ enum class CallTimerType { }; namespace OHOS { +class VolumeSettingView; UIViewGroup* CreatePhoneCallView(void); UIViewGroup* CreateCallingView(void); UIViewGroup* CreateMultiplePhoneView(void); UIViewGroup* CreateWaitingHintsView(void); void HonrsViewChange(void); +VolumeSettingView *GetvolumeSetting(void); void FreeCallingView(void); void FreePhoneCallView(void); void FreeMultiplePhoneCallView(void); diff --git a/code/sdk/application/wearable/service/msg_center/include/vendor_app/baidu_app.h b/code/sdk/application/wearable/service/msg_center/include/vendor_app/baidu_app.h index 71d268ab7..678a202b0 100644 --- a/code/sdk/application/wearable/service/msg_center/include/vendor_app/baidu_app.h +++ b/code/sdk/application/wearable/service/msg_center/include/vendor_app/baidu_app.h @@ -116,6 +116,7 @@ errcode_t msg_center_vector_navi_req_geocode_search(uint8_t cmd_id, uint8_t type errcode_t msg_center_vector_navi_rec_geocode_search(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); errcode_t msg_center_vector_navi_req_regeocode_search(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); errcode_t msg_center_vector_navi_rec_regeocode_search(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_vector_navi_req_destroy_page(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/application/wearable/service/msg_center/libs/libbaidumapsdk.a b/code/sdk/application/wearable/service/msg_center/libs/libbaidumapsdk.a index 3fdb0f0db..906a03f5d 100644 Binary files a/code/sdk/application/wearable/service/msg_center/libs/libbaidumapsdk.a and b/code/sdk/application/wearable/service/msg_center/libs/libbaidumapsdk.a differ diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_cmd.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_cmd.cpp index 97f83291f..36d52ce5c 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_cmd.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_cmd.cpp @@ -88,6 +88,10 @@ msg_center_cmd_map_t g_msg_center_type_tbl[] = { { MSGCENTER_CMD_VECTOR_NAVI, MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_GEOCODE_SEARCH, msg_center_vector_navi_rec_geocode_search}, { MSGCENTER_CMD_VECTOR_NAVI, MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_REGEOCODE_SEARCH, msg_center_vector_navi_req_regeocode_search}, { MSGCENTER_CMD_VECTOR_NAVI, MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_REGEOCODE_SEARCH, msg_center_vector_navi_rec_regeocode_search}, + /* µØÍ¼Ë½ÓÐЭÒé */ + { MSGCENTER_CMD_VECTOR_NAVI, MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_DESTROY_PAGE, msg_center_vector_navi_req_destroy_page}, + { MSGCENTER_CMD_VECTOR_NAVI, MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_DISCONNECTED, NULL}, + { MSGCENTER_CMD_VECTOR_NAVI, MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED, NULL}, #endif #ifdef SUPPORT_ALIPAY_SEC { MSGCENTER_CMD_ALIPAY, MSGCENTER_TYPE_ID_ALIPAY_NETWORK_STATUS, msg_center_alipay_network_status}, diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp index 50ed97180..f16103f3e 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp @@ -64,7 +64,6 @@ static constexpr uint16 FONT_CALLER_SIZE = 40; UIViewGroup* g_phoneView = nullptr; UIViewGroup* g_multiPhoneView = nullptr; UIViewGroup* g_callingView = nullptr; -UIViewGroup* g_volumeSettingView = nullptr; UIViewGroup* g_waitingHintsView = nullptr; VolumeSettingView *g_volumeSetting = nullptr; UIImageView* g_imageAgree = nullptr; @@ -173,7 +172,7 @@ void DisableCallTimer(CallTimerType type) void HonrsViewChange(void) { - if (g_volumeSettingView == nullptr) { + if (g_volumeSetting == nullptr) { g_volumeSetting = new VolumeSettingView(); if (g_volumeSetting == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::g_volumeSetting nullptr err"); @@ -189,20 +188,23 @@ void HonrsViewChange(void) ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); g_volumeSetting->GetDecreaseButton()->SetImageSrc(image, image); } - g_volumeSettingView = g_volumeSetting; - NotificationManager::GetInstance()->screenContainer_->Add(g_volumeSettingView); + NotificationManager::GetInstance()->screenContainer_->Add(g_volumeSetting); } - VolumeSliderEventListener *volumeSliderEventListener = VolumeSliderEventListener::GetInstance(); + VolumeSliderEventListener *volumeSliderEventListener = g_volumeSetting->GetVolumeEventListener(); if (volumeSliderEventListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::volumeSliderEventListener nullptr err"); return; } volumeSliderEventListener->SetPlayerCoefficients(VOLUMEPHONENOTIFY); // 进度条系数 - g_volumeSettingView->SetVisible(true); + g_volumeSetting->SetVisible(true); // 刷新UI RootView::GetInstance()->Invalidate(); } +VolumeSettingView *GetvolumeSetting(void) +{ + return g_volumeSetting; +} static void FreeCallingViewImage(void) { @@ -553,9 +555,8 @@ void FreeMultiplePhoneCallView(void) delete g_multiPhoneView; g_multiPhoneView = nullptr; } - if (g_volumeSettingView != nullptr) { - delete g_volumeSettingView; - g_volumeSettingView = nullptr; + if (g_volumeSetting != nullptr) { + delete g_volumeSetting; g_volumeSetting = nullptr; } } @@ -613,9 +614,8 @@ void FreeCallingView(void) delete g_callingView; g_callingView = nullptr; } - if (g_volumeSettingView != nullptr) { - delete g_volumeSettingView; - g_volumeSettingView = nullptr; + if (g_volumeSetting != nullptr) { + delete g_volumeSetting; g_volumeSetting = nullptr; } } diff --git a/code/sdk/application/wearable/service/msg_center/src/vendor_app/baidu/baidu_app.cpp b/code/sdk/application/wearable/service/msg_center/src/vendor_app/baidu/baidu_app.cpp index 0508c6521..1d6fd9dad 100644 --- a/code/sdk/application/wearable/service/msg_center/src/vendor_app/baidu/baidu_app.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/vendor_app/baidu/baidu_app.cpp @@ -146,8 +146,8 @@ static errcode_t pcm_stream_task_body(void *data) return ERRCODE_FAIL; } } else if (msg.msg_id == MSGCENTER_TYPE_ID_XIAODU_END_RECORD) { - res = msg_center_xiaodu_send_end_record(MSGCENTER_CMD_XIAODU, MSGCENTER_TYPE_ID_XIAODU_END_RECORD, nullptr, - 0); + res = msg_center_xiaodu_send_end_record(MSGCENTER_CMD_XIAODU, MSGCENTER_TYPE_ID_XIAODU_END_RECORD, msg.data, + msg.len); if (res != ERRCODE_SUCC) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "send pcm stream failed"); return ERRCODE_FAIL; @@ -427,14 +427,14 @@ errcode_t msg_center_xiaodu_send_pcm_stream(uint8_t cmd_id, uint8_t type, void * errcode_t msg_center_xiaodu_send_end_record(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { errcode_t ret = ERRCODE_SUCC; - uint8_t end_record_flag = 0; - ret = msg_center_send_data(cmd_id, type, &end_record_flag, sizeof(end_record_flag)); + ret = msg_center_send_data(cmd_id, type, usr_data, usr_len); if (ret != ERRCODE_SUCC) { return ERRCODE_FAIL; } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "send pcm stream end.\r\n"); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "send pcm stream end, usr_data = %d, usr_len = %d\r\n", + *(uint8_t *)usr_data, usr_len); /* usr_data参考协议msg_center_pcm_end_flag_t */ pcm_stream_del_queue(); return ERRCODE_SUCC; } @@ -742,7 +742,7 @@ static errcode_t msg_center_vector_navi_req_common_proc(uint8_t cmd_id, uint8_t } WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "%s, usr_data = %s, usr_len = %d\r\n", vector_navi_get_str(type), - usr_data, usr_len); + usr_data == NULL ? NULL : usr_data, usr_len); return ERRCODE_SUCC; } @@ -752,7 +752,25 @@ static bool is_vector_navi_longbuf(uint8_t type) type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_REGEOCODE_SEARCH || type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_ROUTE_RIDING_SEARCH || type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_ROUTE_WALKING_SEARCH || - type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_ROUTE_TRANSIT_SEARCH) { + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_ROUTE_TRANSIT_SEARCH || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_REMAIN_ROUTE_UPDATE || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_RE_ROUTE_COMPLETE) { + return true; + } else { + return false; + } +} + +static bool has_two_callback(uint8_t type) +{ + if (type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_GEOCODE_SEARCH || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_REGEOCODE_SEARCH || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_RECV_POI || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_ROUTE_RIDING_SEARCH || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_ROUTE_WALKING_SEARCH || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_ROUTE_TRANSIT_SEARCH || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_AUTH_LICENSE || + type == MSGCENTER_TYPE_ID_VECTOR_NAVI_REC_NAVI_INIT) { return true; } else { return false; @@ -773,6 +791,14 @@ static errcode_t msg_center_vector_navi_rec_common_proc(uint8_t cmd_id, uint8_t return ERRCODE_FAIL; } + #if defined(SUPPORT_POWER_MANAGER) + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) { + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(600000); // 600000ms + #endif + char *data = (char *)malloc(payload_len + 1); if (data == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "%s: malloc failed.\r\n", vector_navi_get_str(type)); @@ -784,8 +810,16 @@ static errcode_t msg_center_vector_navi_rec_common_proc(uint8_t cmd_id, uint8_t data[payload_len] = '\0'; WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "%s -- > %s\r\n", vector_navi_get_str(type), tlv_payload); - if (is_vector_navi_longbuf(type)) { + if (is_vector_navi_longbuf(type) && payload_len != 1) { msg_center_transfer_longbuf(data, type); + } else if (has_two_callback(type) && payload_len == 1) { + if (strcmp(data, "1") == 0) { + BaidumapSendMsgToJS(data, type); + } else if ((strcmp(data, "0") == 0)) { + BaidumapFailSendMsgToJS(data, type); + } else { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "%s, app should trans 0 or 1\r\n", vector_navi_get_str(type)); + } } else { BaidumapSendMsgToJS(data, type); } @@ -1045,6 +1079,11 @@ errcode_t msg_center_vector_navi_rec_regeocode_search(uint8_t cmd_id, uint8_t ty return msg_center_vector_navi_rec_common_proc(cmd_id, type, usr_data, usr_len); } +errcode_t msg_center_vector_navi_req_destroy_page(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) +{ + return msg_center_vector_navi_req_common_proc(cmd_id, type, usr_data, usr_len); +} + #ifdef __cplusplus } #endif diff --git a/code/sdk/application/wearable/service/power_manager/CMakeLists.txt b/code/sdk/application/wearable/service/power_manager/CMakeLists.txt index 9d70515d0..42b441b58 100644 --- a/code/sdk/application/wearable/service/power_manager/CMakeLists.txt +++ b/code/sdk/application/wearable/service/power_manager/CMakeLists.txt @@ -1,4 +1,6 @@ set(COMPONENT_NAME "power_manager") +set(MODULE_NAME "app") +set(AUTO_DEF_FILE_ID TRUE) set(PUBLIC_HEADER ) diff --git a/code/sdk/application/wearable/service/power_manager/include/power_display_service.h b/code/sdk/application/wearable/service/power_manager/include/power_display_service.h index bfe7eecdd..6c8cc5f43 100644 --- a/code/sdk/application/wearable/service/power_manager/include/power_display_service.h +++ b/code/sdk/application/wearable/service/power_manager/include/power_display_service.h @@ -11,7 +11,13 @@ #include "stdint.h" #include "stdbool.h" #include "errcode.h" +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) +#include "soc_diag_util.h" +#include "log_oam_logger.h" +#include "log_def.h" +#else #include "debug_print.h" +#endif #ifdef __cplusplus #if __cplusplus @@ -34,11 +40,15 @@ extern "C" { /* * 获取对应动作的掩码 */ #define GET_ACTION_MASK(action) (1 << ((uint32_t)(action))) -#ifdef DISPLAY_HSO_DEBUG_LOG -#define POWER_DISPLAY_PRINT_ERR(log_num, fmt, args...) uapi_diag_error_log(0, fmt, ##arg) -#define POWER_DISPLAY_PRINT_WARN(log_num, fmt, args...) uapi_diag_warning_log(0, fmt, ##arg) -#define POWER_DISPLAY_PRINT_INFO(log_num, fmt, args...) uapi_diag_info_log(0, fmt, ##arg) -#define POWER_DISPLAY_PRINT_DEBUG(log_num, fmt, args...) +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) +#define POWER_DISPLAY_PRINT_ERR(log_num, fmt, arg...) uapi_diag_error_log(0, fmt, ##arg) +#define POWER_DISPLAY_PRINT_WARN(log_num, fmt, arg...) uapi_diag_warning_log(0, fmt, ##arg) +#define POWER_DISPLAY_PRINT_INFO(log_num, fmt, arg...) uapi_diag_info_log(0, fmt, ##arg) +#ifdef WEARABLE_LOG_DEBUG +#define POWER_DISPLAY_PRINT_DEBUG(log_num, fmt, arg...) uapi_diag_debug_log(0, fmt, ##arg) +#else +#define POWER_DISPLAY_PRINT_DEBUG(log_num, fmt, arg...) +#endif #else #define POWER_DISPLAY_PRINT_ERR(log_num, fmt, arg...) PRINT("[POWER_MANAGER E/] %s: " fmt "\r\n", __FUNCTION__, ##arg) #define POWER_DISPLAY_PRINT_WARN(log_num, fmt, arg...) PRINT("[POWER_MANAGER W/] %s: " fmt "\r\n", __FUNCTION__, ##arg) 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 e4efdeeb6..3509a7101 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 @@ -190,7 +190,6 @@ static uint32_t action_display_lcd_off() ext_errno ret = drv_vau_suspend(NULL); if (ret != 0) { POWER_DISPLAY_PRINT_ERR(0, "drv vau suspend error ret=%x\r\n", ret); - return ERRCODE_FAIL; } #ifdef SUPPORT_GPU_JPEG (void)drv_jpeg_suspend(NULL); @@ -199,7 +198,6 @@ static uint32_t action_display_lcd_off() ret = drv_dpu_suspend(NULL); if (ret != 0) { POWER_DISPLAY_PRINT_ERR(0, "drv dpu suspend error ret=%x\r\n", ret); - return ERRCODE_FAIL; } #endif #ifdef SUPPORT_GPU_GMMU 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 a4921fd4e..1e1c08001 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 @@ -128,11 +128,6 @@ #define LCD_FILL_COLOR_ADDR 0x60280000 #endif -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG 0x57000014 -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL 0xb66 -#define PM_MCU_SEND_IPC_WKUP_BT_REG 0x52000034 -#define PM_MCU_SEND_IPC_WKUP_BT_VAL 0x2 -#define BT_RESET_DELAY 500 #define POWER_KEY_PARAM_LEN 0x2 #define CALENDAR_PARAM_LEN 0x6 #ifdef CFG_DRIVERS_MMC @@ -416,10 +411,7 @@ uint32_t mcu_os_sys_reset(uint8_t *para, uint32_t para_len) send_spp_diag_msg(g_app_diag_flag, &g_mcu_diag_header, res, DIAG_RES_LEN); reset_deal_with_fs(); - // when bt at sleep, need wkup bt before soft reset - writew(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG, PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL); - writew(PM_MCU_SEND_IPC_WKUP_BT_REG, PM_MCU_SEND_IPC_WKUP_BT_VAL); - uapi_tcxo_delay_ms(BT_RESET_DELAY); + set_cpu_utils_reset_cause(REBOOT_CAUSE_APPLICATION_SYSRESETREQ); hal_reboot_chip(); return ERRCODE_SUCC; @@ -1200,10 +1192,7 @@ uint32_t mcu_pm_into_force_ds_mode(uint8_t *para, uint32_t para_len) { unused(para); unused(para_len); - // when bt at sleep, need wkup bt before soft reset - writew(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG, PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL); - writew(PM_MCU_SEND_IPC_WKUP_BT_REG, PM_MCU_SEND_IPC_WKUP_BT_VAL); - uapi_tcxo_delay_ms(BT_RESET_DELAY); + set_cpu_utils_reset_cause(REBOOT_CAUSE_APPLICATION_SYSRESETREQ); writew(0x5702C010, 0x5A5A); hal_reboot_chip(); diff --git a/code/sdk/build/cmake/build_component.cmake b/code/sdk/build/cmake/build_component.cmake index 8da417e97..d494bbb1e 100644 --- a/code/sdk/build/cmake/build_component.cmake +++ b/code/sdk/build/cmake/build_component.cmake @@ -93,8 +93,10 @@ macro(build_library) else() if(DEFINED LIB) else() - message(STATUS "${SOURCES0} is not found, finding lib${COMPONENT_NAME}.a in ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_COMMAND}") - find_library(LINK_LIB_${COMPONENT_NAME} "lib${COMPONENT_NAME}.a" ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_COMMAND}) + set(TARGET_COMMAND_TMP ${TARGET_COMMAND}) + string(REPLACE "-user" "" TARGET_COMMAND_TMP ${TARGET_COMMAND_TMP}) + message(STATUS "${SOURCES0} is not found, finding lib${COMPONENT_NAME}.a in ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_COMMAND_TMP}") + find_library(LINK_LIB_${COMPONENT_NAME} "lib${COMPONENT_NAME}.a" ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_COMMAND_TMP}) if(NOT LINK_LIB_${COMPONENT_NAME}) message(FATAL_ERROR "${SOURCES0} is not found && lib${COMPONENT_NAME}.a not find") endif() diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 370331fda..4ec968814 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -127,6 +127,12 @@ target = { 'packet': True, 'fs_image': False }, + #native-js-user: liteos + uikit + nandflash + mipi + psram + audio 典型合封UIKIT版本 + #离线日志版本 + 'brandy-native-js-user': { + 'base_target_name': 'brandy-native-js', + 'defines': ['-:SW_UART_DEBUG'], + }, #native-xts: liteos + uikit + nandflash + mipi + psram + audio 典型合封UIKIT版本 'brandy-xts': { 'board': 'evb', @@ -281,10 +287,11 @@ target_group = { 'pack_brandy_target4': ['brandy-ssb', 'brandy-target4-r', 'brandy-target4'], 'pack_brandy_target5': ['brandy-ssb', 'brandy-target5-r', 'brandy-target5'], 'pack_brandy_native_js': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js'], + 'pack_brandy_native_js_user': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-user'], 'pack_brandy_xts': ['brandy-ssb', 'brandy-xts-r', 'brandy-xts'], 'brandy_all': ['brandy-ssb', - 'brandy-target1', 'brandy-target3', 'brandy-target4', 'brandy-target5', 'brandy-native-js', 'brandy-xts', + 'brandy-target1', 'brandy-target3', 'brandy-target4', 'brandy-target5', 'brandy-native-js', 'brandy-native-js-user', 'brandy-xts', 'brandy-target1-r', 'brandy-target3-r', 'brandy-target4-r', 'brandy-target5-r', 'brandy-native-js-r', 'brandy-xts-r', 'testsuite-brandy-sdk'] } diff --git a/code/sdk/build/config/target_config/brandy/nv_bin_cfg/mk_nv_bin_cfg_eng.json b/code/sdk/build/config/target_config/brandy/nv_bin_cfg/mk_nv_bin_cfg_eng.json new file mode 100644 index 000000000..d79f52360 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/nv_bin_cfg/mk_nv_bin_cfg_eng.json @@ -0,0 +1,10 @@ +{ + "OUT_BIN_DIR" : "output/brandy/nv_bin", + "OUT_BIN_NAME" : "brandy_all_nv.bin", + "BUILD_TEMP_PATH" : "output/brandy", + + "NV_TARGET_JSON_PATH" : "middleware/chips/brandy/nv/nv_config/cfg/nv_target.json", + "NV_RELATIVE_PATH" : "output/brandy/nv_bin/temp", + "NV_DEFAULT_CFG_DIR" : "middleware/chips/brandy/nv/nv_config/cfg/eng", + "DATABASE_TXT_FILE" : "output/brandy/nv_bin" +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/nv_bin_cfg/mk_nv_bin_cfg_user.json b/code/sdk/build/config/target_config/brandy/nv_bin_cfg/mk_nv_bin_cfg_user.json new file mode 100644 index 000000000..e42ffa6c9 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/nv_bin_cfg/mk_nv_bin_cfg_user.json @@ -0,0 +1,10 @@ +{ + "OUT_BIN_DIR" : "output/brandy/nv_bin", + "OUT_BIN_NAME" : "brandy_all_nv.bin", + "BUILD_TEMP_PATH" : "output/brandy", + + "NV_TARGET_JSON_PATH" : "middleware/chips/brandy/nv/nv_config/cfg/nv_target.json", + "NV_RELATIVE_PATH" : "output/brandy/nv_bin/temp", + "NV_DEFAULT_CFG_DIR" : "middleware/chips/brandy/nv/nv_config/cfg/user", + "DATABASE_TXT_FILE" : "output/brandy/nv_bin" +} \ No newline at end of file diff --git a/code/sdk/build/script/cmake_builder.py b/code/sdk/build/script/cmake_builder.py index 65e14deb5..3972fe7bc 100644 --- a/code/sdk/build/script/cmake_builder.py +++ b/code/sdk/build/script/cmake_builder.py @@ -27,16 +27,28 @@ class CMakeBuilder(BuildEnvironment): self.sdk = None self.pack_tool = None - def get_build_cmd(self, env): + def get_component(self, env): com_config = CommonConfig(env.get('arch')) - ext_cmd = [] - for component in self.component: + components = [] + if env.get('just_build_components', False): + just_build_components = env.get('just_build_components', False) + else: + just_build_components = self.component + for component in just_build_components: if component in env.get('ram_component', False): - ext_cmd.append(component) - if component in env.get('ram_component_set', False): - for comm in com_config.get_component_set(component): - if comm in env.get('ram_component', False): - ext_cmd.append(comm) + components.append(component) + continue + if component not in env.get('ram_component_set', False): + continue + for comm in com_config.get_component_set(component): + if comm in env.get('ram_component', False): + components.append(comm) + return components + + def get_build_cmd(self, env): + ext_cmd = [] + components = self.get_component(env) + ext_cmd.extend(components) if self.generator == 'Ninja': return ['ninja'] + ext_cmd + ['-j%d' % self.thread] else: @@ -114,6 +126,10 @@ class CMakeBuilder(BuildEnvironment): return self.compile_target(target, env) + + if env.get('just_build_components'): + return + if env.get("fs_image"): fs_image_path = os.path.join(root_path, 'build', 'config', 'target_config', env.get('chip'), 'mk_fs_image') fs_script_path = os.path.join(fs_image_path, 'mkyaffs2tool.py') @@ -268,11 +284,17 @@ class CMakeBuilder(BuildEnvironment): _excute(self.cmake_cmd, log_file, self.dump) _excute(self.get_build_cmd(env), log_file, self.dump) else: - _excute(["cmake", "--build", output_path, '-j%d' % self.thread], log_file, self.dump) - - if len(self.component) > 0: - print("######### Build target:%s, component:[%s] success" % (target_name, ' '.join(self.component))) - exit(0) + ext_cmd = [] + components_target = self.get_component(env) + print(components_target) + if components_target: + ext_cmd = ['--target'] + components_target + _excute(["cmake", "--build", output_path, '-j%d' % self.thread] + ext_cmd, log_file, self.dump) + + if len(self.get_component(env)) > 0: + os.chdir(org_work_path) + print("######### Build target:%s, component:[%s] success" % (target_name, ' '.join(self.get_component(env)))) + return 0 if env.is_enable_hso() and not nhso: cmd = self.get_build_cmd(env) diff --git a/code/sdk/build/script/parse_tool/parse_elf.py b/code/sdk/build/script/parse_tool/parse_elf.py index c99f7989d..50df9d592 100644 --- a/code/sdk/build/script/parse_tool/parse_elf.py +++ b/code/sdk/build/script/parse_tool/parse_elf.py @@ -881,7 +881,7 @@ class ParseCtrl(): """ if self.parse_debug_info_phase_0==True: return - with open(file,'r') as fp: + with open(file,'r',encoding='utf-8') as fp: lines=fp.readlines() self.parse_debug_info_lines(lines) self.parse_debug_info_phase_0=True diff --git a/code/sdk/build/script/sdk_generator/sdk_generator.py b/code/sdk/build/script/sdk_generator/sdk_generator.py index ee54a133f..5f7115d93 100644 --- a/code/sdk/build/script/sdk_generator/sdk_generator.py +++ b/code/sdk/build/script/sdk_generator/sdk_generator.py @@ -8,7 +8,9 @@ import sys import time from utils.build_utils import root_path, script_path, target_config_path, output_root -from utils.build_utils import pkg_tools_path, jlink_tools_path, lzma_tools_path, sign_tools_path, memcheck_tools_path, factory_tools_path, derived_tools_path +from utils.build_utils import pkg_tools_path, jlink_tools_path, lzma_tools_path, sign_tools_path +from utils.build_utils import memcheck_tools_path, factory_tools_path, derived_tools_path +from utils.build_utils import ohos_tools_path from utils.build_utils import CopyModule, exec_shell, cmp_file, rm_pyc, rm_all, fn_get_subdirs from enviroment import TargetEnvironment from sdk_generator.target_config_genarator import genarate_reserve_config @@ -24,6 +26,7 @@ sdk_copy_common_files = [ os.path.join(memcheck_tools_path), os.path.join(factory_tools_path, 'factory_tools'), os.path.join(derived_tools_path), + os.path.join(ohos_tools_path), ] sdk_close_components = [ diff --git a/code/sdk/build/script/utils/build_utils.py b/code/sdk/build/script/utils/build_utils.py index c43cacaf3..2bed7607d 100644 --- a/code/sdk/build/script/utils/build_utils.py +++ b/code/sdk/build/script/utils/build_utils.py @@ -33,6 +33,7 @@ sign_tools_path = os.path.join(root_path, 'tools', 'bin', 'sign_tool') memcheck_tools_path = os.path.join(root_path, 'tools', 'bin', 'memcheck') factory_tools_path = os.path.join(root_path, 'tools', 'bin', 'factory_tools') derived_tools_path = os.path.join(root_path, 'tools', 'bin', 'derived_key_tool') +ohos_tools_path = os.path.join(root_path, 'tools', 'bin', 'ohos_tools') """ Colors defines. To highlight important output. diff --git a/code/sdk/drivers/chips/brandy/porting/button/CMakeLists.txt b/code/sdk/drivers/chips/brandy/porting/button/CMakeLists.txt index 1fe38eb24..b4c8bb6d3 100644 --- a/code/sdk/drivers/chips/brandy/porting/button/CMakeLists.txt +++ b/code/sdk/drivers/chips/brandy/porting/button/CMakeLists.txt @@ -9,7 +9,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} ) set(WHOLE_LINK diff --git a/code/sdk/drivers/chips/brandy/porting/rtc_unified/CMakeLists.txt b/code/sdk/drivers/chips/brandy/porting/rtc_unified/CMakeLists.txt index 038bbdf85..00bfa92c0 100644 --- a/code/sdk/drivers/chips/brandy/porting/rtc_unified/CMakeLists.txt +++ b/code/sdk/drivers/chips/brandy/porting/rtc_unified/CMakeLists.txt @@ -9,7 +9,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} ) set(PRIVATE_HEADER diff --git a/code/sdk/drivers/chips/brandy/porting/security/efuse/CMakeLists.txt b/code/sdk/drivers/chips/brandy/porting/security/efuse/CMakeLists.txt index 3811efaea..96ab63138 100644 --- a/code/sdk/drivers/chips/brandy/porting/security/efuse/CMakeLists.txt +++ b/code/sdk/drivers/chips/brandy/porting/security/efuse/CMakeLists.txt @@ -9,7 +9,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} ) set(WHOLE_LINK diff --git a/code/sdk/drivers/drivers/driver/adc/CMakeLists.txt b/code/sdk/drivers/drivers/driver/adc/CMakeLists.txt index 8e1958e01..890eba060 100644 --- a/code/sdk/drivers/drivers/driver/adc/CMakeLists.txt +++ b/code/sdk/drivers/drivers/driver/adc/CMakeLists.txt @@ -12,7 +12,6 @@ set(PRIVATE_HEADER ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} ) set(PRIVATE_DEFINES diff --git a/code/sdk/drivers/drivers/driver/calendar/CMakeLists.txt b/code/sdk/drivers/drivers/driver/calendar/CMakeLists.txt index ae56c7def..ddff7781f 100644 --- a/code/sdk/drivers/drivers/driver/calendar/CMakeLists.txt +++ b/code/sdk/drivers/drivers/driver/calendar/CMakeLists.txt @@ -9,7 +9,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} ) set(PRIVATE_HEADER diff --git a/code/sdk/drivers/drivers/driver/efuse/CMakeLists.txt b/code/sdk/drivers/drivers/driver/efuse/CMakeLists.txt index 6e1caeefc..f5765bf0e 100644 --- a/code/sdk/drivers/drivers/driver/efuse/CMakeLists.txt +++ b/code/sdk/drivers/drivers/driver/efuse/CMakeLists.txt @@ -12,7 +12,6 @@ set(PRIVATE_HEADER ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} ) set(PRIVATE_DEFINES diff --git a/code/sdk/drivers/drivers/driver/rtc_unified/CMakeLists.txt b/code/sdk/drivers/drivers/driver/rtc_unified/CMakeLists.txt index 3d1437d2d..51d3d9d84 100644 --- a/code/sdk/drivers/drivers/driver/rtc_unified/CMakeLists.txt +++ b/code/sdk/drivers/drivers/driver/rtc_unified/CMakeLists.txt @@ -9,7 +9,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} ) set(PRIVATE_HEADER diff --git a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c index d74083a98..e729a5a34 100644 --- a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c +++ b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c @@ -113,12 +113,7 @@ static void report_or_enqueue_event(input_event_info* touch_info, struct ts_driv static void report_event_to_power_manager(input_event_info *touch_info) { if (g_power_manager_cb != NULL) { - input_dev_data_t data; - convert_touch_info(&data, touch_info); - if (data.state == INDEV_STATE_UNKNOWN) { - return; - } - g_power_manager_cb(data.state, 0); + g_power_manager_cb(touch_info->tp_event, 0); } return; } diff --git a/code/sdk/drivers/drivers/hal/ipc/hal_ipc_old/hal_ipc.c b/code/sdk/drivers/drivers/hal/ipc/hal_ipc_old/hal_ipc.c index 9d955ebfa..99b87bb2f 100644 --- a/code/sdk/drivers/drivers/hal/ipc/hal_ipc_old/hal_ipc.c +++ b/code/sdk/drivers/drivers/hal/ipc/hal_ipc_old/hal_ipc.c @@ -7,13 +7,27 @@ #include "hal_ipc.h" #include "arch_barrier.h" +#include "chip_io.h" +#define IPC_TRY_SEND_MAX 10000 +#define BT_DEEPSLEEP_FLAG 0x5a5a +#define IPC_TRY_INTERVAL_TIME 100 /* * MCPU core trigger a interrupt to BCPU core. */ void hal_ipc_interrupt_security(void) { - MCPU_SOFT_INT_SET |= M_TO_BCPU_INT_OFFSET; + volatile uint32_t cnt = IPC_TRY_SEND_MAX; + while (cnt > 0) { + if (readw(GLB_CTL_B_RB_BASE + 0x1C) != BT_DEEPSLEEP_FLAG) { + if (cnt < IPC_TRY_SEND_MAX) { + uapi_tcxo_delay_us(IPC_TRY_INTERVAL_TIME); + } + MCPU_SOFT_INT_SET |= M_TO_BCPU_INT_OFFSET; + break; + } + cnt--; + } } /* diff --git a/code/sdk/drivers/drivers/hal/reboot/hal_reboot.c b/code/sdk/drivers/drivers/hal/reboot/hal_reboot.c index 13d6d7a4d..e09b25251 100644 --- a/code/sdk/drivers/drivers/hal/reboot/hal_reboot.c +++ b/code/sdk/drivers/drivers/hal/reboot/hal_reboot.c @@ -47,16 +47,45 @@ #define HAL_ULP_AON_GENERAL_REG (ULP_AON_CTL_RB_ADDR + 0x14) #define HAL_ULP_AON_NO_POWEROFF_FLAG 0xA5A5 -static uint16_t g_reset_cause = REBOOT_CAUSE_UNKNOWN; +#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG 0x57000014 +#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL 0xb66 +#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_ACK 0x499 +#define PM_MCU_SEND_IPC_WKUP_BT_REG 0x52000034 +#define PM_MCU_SEND_IPC_WKUP_BT_VAL 0x2 +#define PM_WAIT_BT_WAKEUP_DELAY 100 +#define HAL_REBOOT_WAIT_ACK_TRY_TIMES 60 +#define BT_RESET_DELAY 500 +#define POS_NO_POWEROFF 15 +#define POS_FIRST_POWERON 14 +static uint16_t g_reset_cause = REBOOT_CAUSE_UNKNOWN; void hal_reboot_set_ulp_aon_no_poweroff_flag(void) { - reg16_write(HAL_ULP_AON_GENERAL_REG, HAL_ULP_AON_NO_POWEROFF_FLAG); + reg16_setbit(HAL_ULP_AON_GENERAL_REG, POS_NO_POWEROFF); } bool hal_reboot_get_ulp_aon_no_poweroff_flag(void) { - if (reg16(HAL_ULP_AON_GENERAL_REG) == HAL_ULP_AON_NO_POWEROFF_FLAG) { + if (reg16_getbit(HAL_ULP_AON_GENERAL_REG, POS_NO_POWEROFF)) { + return true; + } else { + return false; + } +} + +void hal_reboot_set_first_power_on_flag(void) +{ + reg16_setbit(HAL_ULP_AON_GENERAL_REG, POS_FIRST_POWERON); +} + +void hal_reboot_clear_first_power_on_flag(void) +{ + reg16_clrbit(HAL_ULP_AON_GENERAL_REG, POS_FIRST_POWERON); +} + +bool hal_reboot_get_first_power_on_flag(void) +{ + if (reg16_getbit(HAL_ULP_AON_GENERAL_REG, POS_FIRST_POWERON)) { return true; } else { return false; @@ -102,6 +131,23 @@ void hal_reboot_chip(void) set_cpu_utils_system_boot_magic(); #ifdef SUPPORT_GPIO gpio_ulp_int_en(false); // when soft reset, ulp area is not cleared. +#endif + // when bt at sleep, need wkup bt before soft reset +#if !defined(BUILD_APPLICATION_SSB) + uint16_t lock_cnt = 0; + uint16_t max_lock_cnt = HAL_REBOOT_WAIT_ACK_TRY_TIMES; + writew(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG, PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL); + writew(PM_MCU_SEND_IPC_WKUP_BT_REG, PM_MCU_SEND_IPC_WKUP_BT_VAL); + while((readw(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG) != PM_SLEEP_SOFT_RESET_FORCE_WKUP_ACK) && \ + (lock_cnt < max_lock_cnt)) { + PRINT("bt not send ack[%x],don't to reset,try %d.\n", readw(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG), lock_cnt); + uapi_tcxo_delay_ms(PM_WAIT_BT_WAKEUP_DELAY); + lock_cnt++; + } +#else + writew(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG, PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL); + writew(PM_MCU_SEND_IPC_WKUP_BT_REG, PM_MCU_SEND_IPC_WKUP_BT_VAL); + uapi_tcxo_delay_ms(BT_RESET_DELAY); #endif // Request the reset & wait for it... regw_clrbit(HAL_CHIP_RESET_REG, HAL_CHIP_RESET_REG_OFFSET, HAL_CHIP_RESET_REG_ENABLE_RESET_BIT); diff --git a/code/sdk/drivers/drivers/hal/reboot/hal_reboot.h b/code/sdk/drivers/drivers/hal/reboot/hal_reboot.h index a6b0fcb88..ed0140cde 100644 --- a/code/sdk/drivers/drivers/hal/reboot/hal_reboot.h +++ b/code/sdk/drivers/drivers/hal/reboot/hal_reboot.h @@ -49,6 +49,22 @@ void hal_reboot_set_ulp_aon_no_poweroff_flag(void); */ bool hal_reboot_get_ulp_aon_no_poweroff_flag(void); +/** + * @brief Set a universal register of the ULP region to a fix value to indicate that is first power-on + */ +void hal_reboot_set_first_power_on_flag(void); + +/** + * @brief clear a universal register of the ULP region to a fix value to indicate that is not first power-on + */ +void hal_reboot_clear_first_power_on_flag(void); + +/** + * @brief Get is first power-on + * @return true first power-on, false is re-poweron + */ +bool hal_reboot_get_first_power_on_flag(void); + /** * @} */ 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 93b3fc6f7..416f5b6bf 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 @@ -103,6 +103,24 @@ extern "C" { */ #define SERVICE_INFORMATION 0x800000 +/** + * @if Eng + * @brief The Class of Device Audio or Vido. + * @else + * @brief 音配设备类型。 + * @endif + */ +#define DEVICE_MAJOR_CLASS_AUDIO_VIDEO 0x400 + +/** + * @if Eng + * @brief The Class of Device Phone. + * @else + * @brief 手机设备类型。 + * @endif + */ +#define DEVICE_MAJOR_CLASS_PHONE 0x200 + /** * @if Eng * @brief Enum of Bluetooth stack state. @@ -772,6 +790,29 @@ errcode_t gap_disconnect_remote_device(const bd_addr_t *addr); */ errcode_t gap_connect_remote_device(const bd_addr_t *addr); +/** + * @if Eng + * @brief Use this funtion to set the inquiry parameters. + * @par Use this funtion to set the inquiry parameters. + * @attention NULL + * @param [in] device_class #uint32_t, class of device to report. + * @param [in] max_num #uint8_t, max number of response devices. + * @retval error code + * @par Dependency: + * @li bts_gap.h + * @else + * @brief 设置扫描参数。 + * @par 设置扫描参数。 + * @attention 无 + * @param [in] device_class 设备类型。 + * @param [in] max_num 最大上报数量。 + * @retval 执行结果错误码。 + * @par 依赖: + * @li bts_gap.h + * @endif + */ +errcode_t gap_br_set_inquiry_paramters(uint32_t device_class, uint8_t max_num); + /** * @if Eng * @brief Use this funtion to start BT discovery. @@ -1391,6 +1432,29 @@ typedef struct { */ int gap_register_callbacks(gap_call_backs_t *func); +/** + * @if Eng + * @brief Use this funtion to reconnect a media device. + * @par Use this funtion to reconnect a media device. + * @attention NULL + * @param [in] addr #const bd_addr_t *, address of the device. + * @retval #true Execute successfully. + * @retval #false Execution failed. + * @par Dependency: + * @li bts_gap.h + * @else + * @brief 回连媒体设备。 + * @par 回连媒体设备。 + * @attention 无 + * @param [in] 要回连的设备地址。 + * @retval #true 连接成功。 + * @retval #false 连接失败。 + * @par 依赖: + * @li bts_gap.h + * @endif + */ +errcode_t gap_reconnect_media_device(const bd_addr_t *addr); + /** * @} */ diff --git a/code/sdk/include/middleware/services/bts/common/bts_feature.h b/code/sdk/include/middleware/services/bts/common/bts_feature.h new file mode 100644 index 000000000..5c13978ab --- /dev/null +++ b/code/sdk/include/middleware/services/bts/common/bts_feature.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2024. All rights reserved. + * Description: BTS FEATURE module. + */ + +/** + * @defgroup bluetooth_bts_feature BTS FEATURE API + * @ingroup bluetooth + * @{ + */ + + +#ifndef BTS_FEATURE_H +#define BTS_FEATURE_H + +#include +#include +#include "errcode.h" +#include "bts_def.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @if Eng + * @brief Struct of BT stack feature. + * @else + * @brief 蓝牙特性位图。 + * @endif + */ +typedef struct { + uint32_t bt_auto_reconnect_closed:1; /*!< @if Eng BT reconnect feature. + @else 蓝牙回连特性。 @endif */ + uint32_t reserved:31; /*!< @if Eng Featrues reserved for future. + @else 保留字段。 @endif */ +} bts_feature_t; + +/** + * @if Eng + * @brief Set BTS Features supported. + * @par Set BTS Features supported. + * @attention NULL + * @param [in] feature #bts_feature_t, a bitmap indicate supported features. + * @retval #BT_STATUS_SUCCESS Excute successfully. + * @retval #Other Error code, @ref bt_status_t + * @par Dependency: + * @li bts_feature.h + * @see + * @else + * @brief 设置想要使用的特性。 + * @par 设置想要使用的特性。 + * @attention 无 + * @param [in] 特性位图。 @ref bts_feature_t + * @retval #BT_STATUS_SUCCESS 执行成功。 + * @retval #Other 错误码, @ref bt_status_t。 + * @par 依赖: + * @li bts_feature.h + * @see + * @endif + */ +errcode_t bts_set_features(bts_feature_t *feature); + +/** + * @if Eng + * @brief Use this funtion to get BTS features supported. + * @par Use this funtion to get BTS features supported. + * @attention NULL. + * @param NULL. + * @retval BT features bitmap. see @ref bts_feature_t + * @par Dependency: + * @li bts_feature.h + * @else + * @brief 获取BT协议栈支持的特性。 + * @par 获取BT协议栈支持的特性。 + * @attention 无 + * @param 无 + * @retval BT 特性位图。 参考 @ref bts_feature_t + * @par 依赖: + * @li bts_feature.h + * @endif + */ +bts_feature_t bts_get_features(void); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style.cpp.xml index 9510415a8..3505361f8 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style.cpp.xml @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style_item.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style_item.cpp.xml index fbc65aa03..41741a128 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style_item.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style_item.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/app_style_manager.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style_manager.cpp.xml index c12bf10d5..7b7e87f85 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style_manager.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/app_style_manager.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/appsys_bms_cmd.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/appsys_bms_cmd.cpp.xml index 4fc2d0358..91cdbc7a6 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/appsys_bms_cmd.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/appsys_bms_cmd.cpp.xml @@ -1,19 +1,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/async_task_manager.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/async_task_manager.cpp.xml index 761c46530..da5ee9294 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/async_task_manager.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/async_task_manager.cpp.xml @@ -1,6 +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/btsrv_gatt_client.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsrv_gatt_client.c.xml index f33750d87..12aa0327c 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsrv_gatt_client.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsrv_gatt_client.c.xml @@ -63,16 +63,16 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsrv_gatt_server.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsrv_gatt_server.c.xml index 05dd35477..f22cc8af2 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsrv_gatt_server.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsrv_gatt_server.c.xml @@ -111,13 +111,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/btsv_l2cap_chan.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsv_l2cap_chan.c.xml index 7aea144aa..6663e84d6 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsv_l2cap_chan.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/btsv_l2cap_chan.c.xml @@ -3,9 +3,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/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 e487e2d61..886042363 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,127 +1,133 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/descriptor_utils.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/descriptor_utils.cpp.xml index b261f5fc5..927a87a30 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/descriptor_utils.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/descriptor_utils.cpp.xml @@ -1,6 +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/dft_impl.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/dft_impl.cpp.xml index 8749a4926..3e6f360af 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/dft_impl.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/dft_impl.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/dfx_assist.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/dfx_assist.cpp.xml index 33085c0b9..bd45882b9 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/dfx_assist.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/dfx_assist.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/event_util.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/event_util.cpp.xml index 2af67a1a4..fb1e68e15 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/event_util.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/event_util.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/fatal_handler.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/fatal_handler.cpp.xml index f7dd78504..e1b3f67cf 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/fatal_handler.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/fatal_handler.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/gt_bundle_installer.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/gt_bundle_installer.cpp.xml index f2218a25a..6c735f040 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/gt_bundle_installer.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/gt_bundle_installer.cpp.xml @@ -1,33 +1,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 4651a2439..0b41cd54a 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 @@ -30,5 +30,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/image_cache_manager.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/image_cache_manager.cpp.xml index e6d452d6e..2777196cc 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/image_cache_manager.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/image_cache_manager.cpp.xml @@ -1,13 +1,32 @@ - - - - - + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ 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_ability.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_ability.cpp.xml index 7d25e5b58..c0397f67f 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_ability.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_ability.cpp.xml @@ -1,16 +1,16 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + \ 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_ability_impl.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_ability_impl.cpp.xml index 29f309bf5..2f88837a3 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_ability_impl.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_ability_impl.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/js_app_context.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_app_context.cpp.xml index c56e1a819..e2684fa88 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_app_context.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_app_context.cpp.xml @@ -1,15 +1,15 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + \ 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_app_environment.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_app_environment.cpp.xml index b37a76d6d..edbeccf34 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_app_environment.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_app_environment.cpp.xml @@ -1,6 +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/js_debugger_config.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_debugger_config.cpp.xml index 5b1487ddb..14b504287 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_debugger_config.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_debugger_config.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/js_fwk_common.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_fwk_common.cpp.xml index 3b0d44430..8bfb5fa7e 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_fwk_common.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_fwk_common.cpp.xml @@ -1,46 +1,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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_page_state.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_page_state.cpp.xml index 2b3ff6201..4247ae37f 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_page_state.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_page_state.cpp.xml @@ -1,11 +1,11 @@ - - - - - - - - - - + + + + + + + + + + \ 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_page_state_machine.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_page_state_machine.cpp.xml index 065db362b..d53ccf521 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_page_state_machine.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_page_state_machine.cpp.xml @@ -1,22 +1,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_profiler.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_profiler.cpp.xml index e75501296..1e7dbea75 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_profiler.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/js_profiler.cpp.xml @@ -1,14 +1,14 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + \ 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 a38c90764..cc56b3574 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/jsi.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/jsi.cpp.xml index 46264eaac..c9bf4d9bb 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/jsi.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/jsi.cpp.xml @@ -1,98 +1,98 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..3b813ecea --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/kaleidoscope_utils.cpp.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lazy_load_manager.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lazy_load_manager.cpp.xml index 007b214d7..d36cfcc93 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lazy_load_manager.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/lazy_load_manager.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/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 df964eed8..abaa4dab8 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 @@ -17,17 +17,17 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + \ 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 24e22b236..b3843def9 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,87 +1,90 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/locale_util.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/locale_util.cpp.xml index c81179b9b..e509a74e5 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/locale_util.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/locale_util.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/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 new file mode 100644 index 000000000..3fabf8d45 --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/map_svg_parser.cpp.xml @@ -0,0 +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/mem_util.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/mem_util.cpp.xml index a146bd509..08d3265af 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/mem_util.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/mem_util.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/number_parser.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/number_parser.cpp.xml index 1c0c3e2b0..0a4f564ca 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/number_parser.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/number_parser.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/platform_adapter.cpp.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/platform_adapter.cpp.xml index 41383d409..fee5236db 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/platform_adapter.cpp.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/platform_adapter.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/remote_device_manager.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/remote_device_manager.c.xml index 782222904..b4df39fc3 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/remote_device_manager.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/remote_device_manager.c.xml @@ -9,58 +9,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/sdk_general_gatt.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/sdk_general_gatt.c.xml index 8856e20b6..f4d0e899b 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/sdk_general_gatt.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/sdk_general_gatt.c.xml @@ -9,59 +9,59 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/stack_gap_if.c.xml b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/stack_gap_if.c.xml index 1812a70b4..2487c86cd 100644 --- a/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/stack_gap_if.c.xml +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/stack_gap_if.c.xml @@ -1,20 +1,20 @@ - - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..9cb8a703c --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_coverflow_view.cpp.xml @@ -0,0 +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_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 new file mode 100644 index 000000000..ff2fbb76a --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_hexagons_list.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_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 new file mode 100644 index 000000000..e4a5ae044 --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_icosahedron_view.cpp.xml @@ -0,0 +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 new file mode 100644 index 000000000..f39f1c7dd --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_kaleidoscope_view.cpp.xml @@ -0,0 +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_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 new file mode 100644 index 000000000..6b960ad9a --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_map_view.cpp.xml @@ -0,0 +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_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 new file mode 100644 index 000000000..6c53c2df6 --- /dev/null +++ b/code/sdk/interim_binary/brandy/acore/build_hso_cfg/hso_database/xml/base/closed_comp/ui_roller_view.cpp.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ 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.c.xml b/code/sdk/interim_binary/brandy/audio/build_hso_cfg/hso_database/xml/base/dsp_core/core_msg.c.xml index 8737d90a0..4deeda727 100644 --- a/code/sdk/interim_binary/brandy/audio/build_hso_cfg/hso_database/xml/base/dsp_core/core_msg.c.xml +++ b/code/sdk/interim_binary/brandy/audio/build_hso_cfg/hso_database/xml/base/dsp_core/core_msg.c.xml @@ -1,52 +1,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 f50202ba7..3ab2f0f3f 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 @@ -86,7 +86,7 @@ - + @@ -178,7 +178,7 @@ - + @@ -206,9 +206,9 @@ - - - + + + @@ -286,7 +286,7 @@ - + @@ -513,7 +513,7 @@ - + @@ -613,13 +613,13 @@ - - - - - - - + + + + + + + @@ -781,7 +781,7 @@ - + @@ -802,7 +802,7 @@ - + @@ -918,6 +918,10 @@ + + + + @@ -1036,15 +1040,17 @@ - - - - - - - - - + + + + + + + + + + + @@ -1100,21 +1106,20 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + @@ -1137,11 +1142,11 @@ - - + + - - + + @@ -1178,6 +1183,7 @@ + @@ -1219,8 +1225,9 @@ - - + + + @@ -1625,22 +1632,23 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -1907,14 +1915,17 @@ - - - - - - - - + + + + + + + + + + + @@ -1954,9 +1965,10 @@ - - - + + + + @@ -2006,9 +2018,9 @@ - + - + @@ -2158,16 +2170,17 @@ - - - - - - - - - - + + + + + + + + + + + @@ -2313,21 +2326,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -2345,74 +2358,72 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2431,6 +2442,7 @@ + @@ -2499,10 +2511,10 @@ - - - - + + + + @@ -2585,6 +2597,8 @@ + + @@ -2614,8 +2628,8 @@ - - + + @@ -2690,13 +2704,14 @@ - - - - - - - + + + + + + + + @@ -3031,9 +3046,10 @@ - - - + + + + @@ -3072,56 +3088,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3276,18 +3291,27 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -3335,10 +3359,10 @@ - - - - + + + + @@ -3377,23 +3401,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -3432,18 +3456,28 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -3522,38 +3556,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3621,8 +3655,11 @@ - - + + + + + @@ -3634,7 +3671,7 @@ - + @@ -3849,11 +3886,13 @@ - - - - - + + + + + + + @@ -4304,7 +4343,7 @@ - + @@ -4336,32 +4375,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4524,40 +4565,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/att_gatt.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/att_gatt.c.xml index 79aaed9e8..a75cd461a 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/att_gatt.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/att_gatt.c.xml @@ -1,14 +1,24 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_core.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_core.c.xml index 7520b7a55..0c2bfe4de 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_core.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_core.c.xml @@ -50,19 +50,18 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general.c.xml index f1f75bfbd..4a9232f13 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general.c.xml @@ -1,69 +1,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general_gatt.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general_gatt.c.xml index c808c18a0..a9b35a427 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general_gatt.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ble_general_gatt.c.xml @@ -34,54 +34,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_gap.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_gap.c.xml index e38f9ce3c..6c194ad5e 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_gap.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_ahi_gap.c.xml @@ -1,33 +1,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_main.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_main.c.xml index 40238267a..bbe9874bc 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_main.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_main.c.xml @@ -1,8 +1,8 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_mpc_adpt_gatt.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_mpc_adpt_gatt.c.xml index 6d8251840..b4a447d57 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_mpc_adpt_gatt.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_mpc_adpt_gatt.c.xml @@ -61,14 +61,15 @@ - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_sleep.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_sleep.c.xml index 1d994423b..8c40a46d5 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_sleep.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_sleep.c.xml @@ -1,14 +1,14 @@ - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_tran_task.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_tran_task.c.xml index b6a0dc18a..45cfe4c19 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_tran_task.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/bt_tran_task.c.xml @@ -1,27 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/fsm.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/fsm.c.xml index cec3cd9ed..62c052b1a 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/fsm.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/fsm.c.xml @@ -1,6 +1,8 @@ - - - - - + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_comm.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_comm.c.xml index 363dc3af0..63850e37a 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_comm.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_comm.c.xml @@ -1,11 +1,13 @@ - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_le.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_le.c.xml index 2d0bcaa81..da45fb165 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_le.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/gap_hlp_le.c.xml @@ -1,17 +1,18 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + \ 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_core_ram.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_core_ram.c.xml index ef7adc351..0bdff1a17 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_core_ram.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_core_ram.c.xml @@ -1,9 +1,12 @@ - - - - - - - - + + + + + + + + + + + \ 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_data_proc.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_data_proc.c.xml index ea716cded..e9bfbf636 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_data_proc.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_data_proc.c.xml @@ -1,16 +1,16 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + \ 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_ev_le.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_ev_le.c.xml index 648aeab66..fbf25fbf9 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_ev_le.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_ev_le.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/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 e060f2451..720dfbcdc 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,3 @@ - + \ 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_link_br.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_link_br.c.xml index 0e17c349a..043c21b70 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_link_br.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_link_br.c.xml @@ -1,5 +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/hci_link_le.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_link_le.c.xml new file mode 100644 index 000000000..7726db44f --- /dev/null +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/hci_link_le.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/ipc_irq.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ipc_irq.c.xml new file mode 100644 index 000000000..d492b4ac6 --- /dev/null +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/ipc_irq.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/llc_bis_hci_ram.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/llc_bis_hci_ram.c.xml index db9492441..fc0673569 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/llc_bis_hci_ram.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/llc_bis_hci_ram.c.xml @@ -1,2 +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/lld_per_ram.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/lld_per_ram.c.xml index 6f0e8e256..53c207824 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/lld_per_ram.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/lld_per_ram.c.xml @@ -1,2 +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/log_oml_exception.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/log_oml_exception.c.xml index 5129a41b6..aedb9eca9 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/log_oml_exception.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/log_oml_exception.c.xml @@ -1,2 +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/osdep.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/osdep.c.xml index def1f92ce..abaece3a8 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/osdep.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/osdep.c.xml @@ -1,8 +1,9 @@ - - - - - - - + + + + + + + + \ 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_btdfx.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_btdfx.c.xml index c1cf4a5a2..99ca52a25 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_btdfx.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_btdfx.c.xml @@ -1,2 +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/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 9f07411be..85e002ab5 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,4 +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_ea.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_ea.c.xml index dddfc3052..f17b4dd3f 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_ea.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_ea.c.xml @@ -1,2 +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/patch_ld_acl.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_ld_acl.c.xml index f07fb9d46..02a450702 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_ld_acl.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_ld_acl.c.xml @@ -1,2 +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/patch_llc.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc.c.xml index fe553a93d..cf9158df9 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc.c.xml @@ -1,2 +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/patch_llc_bis_util.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc_bis_util.c.xml index 86fb48666..67e4fa3f8 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc_bis_util.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc_bis_util.c.xml @@ -1,2 +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/patch_llc_llcp.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc_llcp.c.xml new file mode 100644 index 000000000..1ecab8adb --- /dev/null +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llc_llcp.c.xml @@ -0,0 +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_lld_bis.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis.c.xml index d3c08e744..fd1decc85 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis.c.xml @@ -1,2 +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/patch_lld_bis_evt.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis_evt.c.xml index a6d92f090..20d9c779d 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis_evt.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis_evt.c.xml @@ -1,2 +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/patch_lld_bis_pdu.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis_pdu.c.xml index fe3c01148..852bea28a 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis_pdu.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_bis_pdu.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_lld_evt.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_evt.c.xml index 616cab1a2..563f73f3d 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_evt.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_evt.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_lld_pdu.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_pdu.c.xml new file mode 100644 index 000000000..6cdef533a --- /dev/null +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_lld_pdu.c.xml @@ -0,0 +1,3 @@ + + + \ 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_llm_util.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llm_util.c.xml index 951927695..e806e6c25 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llm_util.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/patch_llm_util.c.xml @@ -1,4 +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/sdk_gap_conn_management.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gap_conn_management.c.xml index eb1b6bbcd..14ad471e7 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gap_conn_management.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gap_conn_management.c.xml @@ -1,2 +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/sdk_gatt.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gatt.c.xml index e4f71434e..5b560d155 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gatt.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gatt.c.xml @@ -1,18 +1,18 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + \ 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_gatt_hlp.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gatt_hlp.c.xml index da868766d..481ab07e7 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gatt_hlp.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_gatt_hlp.c.xml @@ -1,37 +1,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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_hfp.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_hfp.c.xml index f19cb4195..fcab8d50d 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_hfp.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/sdk_hfp.c.xml @@ -1,9 +1,9 @@ - - + + - - + + 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 5949061b2..af8daa1de 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 @@ -1,3 +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/smp_ui.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/smp_ui.c.xml new file mode 100644 index 000000000..8c7cf1015 --- /dev/null +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/smp_ui.c.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/tladapter.c.xml b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/tladapter.c.xml index 304102381..bab79cb6e 100644 --- a/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/tladapter.c.xml +++ b/code/sdk/interim_binary/brandy/bt/build_hso_cfg/hso_database/xml/base/bt_core/tladapter.c.xml @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_audio_manager_wrapper.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_audio_manager_wrapper.a index e61fe554c..1557c5e72 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_audio_manager_wrapper.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/freertos/br/libbt_host_audio_manager_wrapper.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 8df753eee..61b8bb284 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 861e04f93..3f240eea4 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/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 baac1e339..1a804b7a8 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 653fee490..f2197678a 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 50c5f685e..b164a1ffb 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/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 3e0841b4e..1799e1667 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 da48fbd0b..6fdd6682c 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/middleware/chips/brandy/dfx/CMakeLists.txt b/code/sdk/middleware/chips/brandy/dfx/CMakeLists.txt index 5d784c2aa..4b5183c4b 100644 --- a/code/sdk/middleware/chips/brandy/dfx/CMakeLists.txt +++ b/code/sdk/middleware/chips/brandy/dfx/CMakeLists.txt @@ -11,6 +11,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/last_dump_adapt.c ${CMAKE_CURRENT_SOURCE_DIR}/sample_data_adapt.c ${CMAKE_CURRENT_SOURCE_DIR}/zdiag_adapt_sdt.c + ${CMAKE_CURRENT_SOURCE_DIR}/mon_log_output.c ) set(PUBLIC_HEADER @@ -19,14 +20,27 @@ set(PUBLIC_HEADER ) set(PRIVATE_HEADER + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/diag_system_cmd/include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/diag_system_cmd/dfx_include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/diag_mocked_shell/include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/last_dump/dfx_include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/last_dump/include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/sample_data/dfx_include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/sample_data/include ${ROOT_DIR}/include/middleware/services/bts ${ROOT_DIR}/include/middleware/services/bts/ble ${ROOT_DIR}/include/middleware/services/bts/br ${ROOT_DIR}/include/middleware/services/bts/common ) -set(PRIVATE_DEFINES -) +if("${TARGET_COMMAND}" MATCHES "-user$") + set(PRIVATE_DEFINES + USER_VERSION + ) +else() + set(PRIVATE_DEFINES + ) +endif() set(PUBLIC_DEFINES ) diff --git a/code/sdk/middleware/chips/brandy/dfx/dfx_system_init.c b/code/sdk/middleware/chips/brandy/dfx/dfx_system_init.c index b843c9fe0..f7a112ad8 100644 --- a/code/sdk/middleware/chips/brandy/dfx/dfx_system_init.c +++ b/code/sdk/middleware/chips/brandy/dfx/dfx_system_init.c @@ -86,6 +86,8 @@ #include "key_id.h" #endif +#include "mon_log_output.h" + #define DFX_MSG_TASK_PRIO 5 const diag_cmd_reg_obj_t g_diag_default_cmd_tbl[] = { @@ -108,8 +110,8 @@ const diag_cmd_reg_obj_t g_diag_default_cmd_tbl[] = { { DIAG_CMD_ID_DBG_STAT_QUERY, DIAG_CMD_ID_DBG_STAT_QUERY, diag_cmd_stat_query }, }; -static unsigned long g_dfx_osal_queue_id; -static unsigned long g_dfx_transmit_queue_id; +static unsigned long g_dfx_osal_queue_id = DFX_INVALID_QUEUE_ID; +static unsigned long g_dfx_transmit_queue_id = DFX_INVALID_QUEUE_ID; static errcode_t register_default_diag_cmd(void) { @@ -412,6 +414,11 @@ errcode_t dfx_system_init(void) if (ret != ERRCODE_SUCC) { return ret; } +#ifdef USER_VERSION + diag_highest_level_proc(DIAG_LOG_LEVEL_WARN); + mon_log_output_ctrl_init(); + mon_log_output_enable(true); +#endif return ERRCODE_SUCC; } diff --git a/code/sdk/middleware/chips/brandy/dfx/include/dfx_adapt_layer.h b/code/sdk/middleware/chips/brandy/dfx/include/dfx_adapt_layer.h index e705c6d69..90d439920 100644 --- a/code/sdk/middleware/chips/brandy/dfx/include/dfx_adapt_layer.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/dfx_adapt_layer.h @@ -24,6 +24,7 @@ #include "debug_print.h" #define DFX_CHIP_WS_TV_SEC 1663739960 +#define DFX_INVALID_QUEUE_ID 0xFFFFFFFF typedef enum { FLASH_OP_TYPE_OTA, @@ -101,6 +102,11 @@ static inline errcode_t dfx_event_write(dfx_event_id_t event_id) /* Msg 接口 */ static inline errcode_t dfx_msg_write(uint32_t msg_id, uint8_t *msg, uint16_t msg_len, bool wait) { + unsigned long queue_id = dfx_get_osal_queue_id(); + if (queue_id == DFX_INVALID_QUEUE_ID) { + return ERRCODE_FAIL; + } + unsigned int timeout = (wait) ? OSAL_MSGQ_WAIT_FOREVER : 0; uint8_t msg_data[DFX_MSG_MAX_SIZE + DFX_MSG_ID_LEN]; @@ -110,7 +116,7 @@ static inline errcode_t dfx_msg_write(uint32_t msg_id, uint8_t *msg, uint16_t ms return ERRCODE_FAIL; } - return (errcode_t)osal_msg_queue_write_copy(dfx_get_osal_queue_id(), + return (errcode_t)osal_msg_queue_write_copy(queue_id, msg_data, DFX_MSG_MAX_SIZE + DFX_MSG_ID_LEN, timeout); } @@ -124,6 +130,10 @@ static inline errcode_t transmit_msg_write(uint32_t msg_id, uint8_t *msg, uint16 #if (defined(MEMORY_MINI)) return dfx_msg_write(msg_id, msg, msg_len, wait); #else + unsigned long queue_id = dfx_get_transmit_queue_id(); + if (queue_id == DFX_INVALID_QUEUE_ID) { + return ERRCODE_FAIL; + } unsigned int timeout = (wait) ? OSAL_MSGQ_WAIT_FOREVER : 0; uint8_t msg_data[DFX_MSG_MAX_SIZE + DFX_MSG_ID_LEN]; @@ -133,7 +143,7 @@ static inline errcode_t transmit_msg_write(uint32_t msg_id, uint8_t *msg, uint16 return ERRCODE_FAIL; } - return (errcode_t)osal_msg_queue_write_copy(dfx_get_transmit_queue_id(), + return (errcode_t)osal_msg_queue_write_copy(queue_id, msg_data, DFX_MSG_MAX_SIZE + DFX_MSG_ID_LEN, timeout); #endif } diff --git a/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h b/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h index 88b93444f..8fed17758 100644 --- a/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h @@ -214,6 +214,16 @@ typedef enum { SETDESKTOPMODEL_CPP, SETDESKTOPVIEW_CPP, SETDESKTOPPRESENTER_CPP, + DISPLAY_STATE_MACHINE_C, + POWER_DISPLAY_SERVICE_C, + GUI_EVENT_FILTER_C, + SLICE_EVENT_FILTER_C, + TIMER_EVENT_FILTER_C, + DISPLAY_ACTION_C, + TIMER_ACTION_C, + TOUCH_ACTION_C, + ALIPAY_FEATURE_C, + ALIPAY_BLUETOOTH_C, APP_FILE_ID_MAX = 1024, } log_file_list_enum_app_t; diff --git a/code/sdk/middleware/chips/brandy/dfx/include/log_def_bth.h b/code/sdk/middleware/chips/brandy/dfx/include/log_def_bth.h index ac8417030..2bc496e41 100644 --- a/code/sdk/middleware/chips/brandy/dfx/include/log_def_bth.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/log_def_bth.h @@ -128,6 +128,10 @@ typedef enum { STACK_PAN_IF_C, STACK_PBAP_IF_C, STACK_SPP_IF_C, + SAMPLE_BLE_ANCS_C, + BLE_ANCS_CLIENT_C, + SAMPLE_BLE_AMS_C, + BLE_AMS_CLIENT_C, BTH_FILE_ID_MAX = 1024, } log_file_list_enum_bth_t; #endif 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 fd6ffc461..df22386cc 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 @@ -425,10 +425,15 @@ typedef enum { UI_KALEIDOSCOPE_VIEW_CPP, KALEIDOSCOPE_UTILS_CPP, UI_COVERFLOW_VIEW_CPP, + UI_ROLLER_VIEW_CPP, + UI_ICOSAHEDRON_VIEW_CPP, UI_MAP_VIEW_CPP, MAP_SVG_PARSER_CPP, SLICETRANSITION_CPP, TRANSITIONMANAGER_CPP, + UI_PINYIN_CANDIDATE_CPP, + HEXAGONSTRANSITION_CPP, + BACKTOHEXAGONSTRANSITION_CPP, FILE_ID_MAX = 1024, } log_file_list_enum_gui_t; #endif diff --git a/code/sdk/middleware/chips/brandy/dfx/include/log_def_pf.h b/code/sdk/middleware/chips/brandy/dfx/include/log_def_pf.h index 98052e3ce..9a5c1793b 100644 --- a/code/sdk/middleware/chips/brandy/dfx/include/log_def_pf.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/log_def_pf.h @@ -78,6 +78,7 @@ typedef enum { DFX_CHANNEL_C, SAMPLE_DATA_ADAPT_C, ZDIAG_ADAPT_SDT_C, + MON_LOG_OUTPUT_C, DIAG_CMD_DST_C, DIAG_DEBUG_C, DIAG_FILTER_C, diff --git a/code/sdk/middleware/chips/brandy/dfx/include/zdiag_config.h b/code/sdk/middleware/chips/brandy/dfx/include/zdiag_config.h index 57b76e2f1..47a0f8d5c 100644 --- a/code/sdk/middleware/chips/brandy/dfx/include/zdiag_config.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/zdiag_config.h @@ -7,7 +7,7 @@ #ifndef ZDIAG_CONFIG_H #define ZDIAG_CONFIG_H -#define DFX_OFFLINE_LOG_MUTI_FILE_NUM 20 /* 离线日志最大文件个数 */ +#define DFX_OFFLINE_LOG_MUTI_FILE_NUM 5 /* 离线日志最大文件个数 */ #define DFX_OFFLINE_LOG_FILE_SIZE (1024 * 1024) /* 离线日志每个文件最大字节数 */ #define DFX_OFFLINE_LOG_PATH "/user/log/" /* 离线日志存放路径 */ #define DFX_OFFLINE_LOG_NAME "log_file_diag.bin" /* 离线日志文件名 */ diff --git a/code/sdk/middleware/chips/brandy/dfx/mon_log_output.c b/code/sdk/middleware/chips/brandy/dfx/mon_log_output.c new file mode 100644 index 000000000..f14594743 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/dfx/mon_log_output.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved. \n + * Description: log output monitor. + */ + +#include +#include +#include +#include +#include +#include +#include "common_def.h" +#include "mon_log_output.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ +#define MODULEID_COUNT (MODULEID_BUTT + 2) +STATIC uint32_t g_mon_logcnt_max[MODULEID_COUNT] = { 0, + MAX_LOGCNT_BT, + 0, + MAX_LOGCNT_DSP, + MAX_LOGCNT_PF, + MAX_LOGCNT_MEDIA, + 0, + MAX_LOGCNT_APP, + MAX_LOGCNT_GPU, + MAX_LOGCNT_GUI, + 0, + MAX_LOGCNT_BTH, + MAX_LOGCNT_OHOS, + 0, + MAX_LOGCNT_BT_STATUS, + MAX_LOGCNT_BT_OTA }; +STATIC uint32_t g_mon_logcnt_ctrl[MODULEID_COUNT] = { 0 }; +STATIC osal_timer g_logcnt_timer = { 0 }; +STATIC bool g_logcnt_en = false; + +STATIC void mon_logcnt_enable(void) +{ + for (uint32_t i = 0; i < MODULEID_COUNT; i++) { + g_mon_logcnt_ctrl[i] = 0; + } + + osal_timer_start(&g_logcnt_timer); +} + +STATIC void mon_log_output_timer_alert(unsigned long data) +{ + unused(data); + mon_logcnt_enable(); +} + +STATIC bool mon_logcnt_process(uint8_t mid, uint8_t level) +{ + unused(level); + if (mid >= MODULEID_COUNT) { + return false; + } + + if ((g_logcnt_en == true) && (g_mon_logcnt_max[mid] < g_mon_logcnt_ctrl[mid])) { + return false; + } + + g_mon_logcnt_ctrl[mid]++; + return true; +} + +void mon_log_output_ctrl_init(void) +{ + g_logcnt_timer.handler = mon_log_output_timer_alert; + g_logcnt_timer.data = 0; + g_logcnt_timer.interval = MON_LOG_CNT_CLEAR_TIMEOUT; + + if (osal_timer_init(&g_logcnt_timer) < 0) { + uapi_diag_error_log(0, "Create logcnt timer failed!"); + return; + } + + /* register log file hook */ + uapi_diag_register_msg_flow_control_hook(mon_logcnt_process); + + osal_timer_start(&g_logcnt_timer); +} + +uint32_t *mon_log_output_get_counter(void) +{ + return &g_mon_logcnt_ctrl; +} + +void mon_log_output_enable(bool enable) +{ + if (g_logcnt_en == enable) { + return; /* Same settings, do nothing */ + } + + g_logcnt_en = enable; + + if (enable == true) { + mon_logcnt_enable(); /* start over counting */ + } else { + osal_timer_stop(&g_logcnt_timer); /* continue counting, but do not clear */ + } +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + diff --git a/code/sdk/middleware/chips/brandy/dfx/mon_log_output.h b/code/sdk/middleware/chips/brandy/dfx/mon_log_output.h new file mode 100644 index 000000000..59c1a5aa9 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/dfx/mon_log_output.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved. \n + * Description: log output monitor. + */ + +#ifndef MON_LOG_OUTPUT_H +#define MON_LOG_OUTPUT_H + +#include "stdint.h" +#include "stdbool.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#define MON_LOG_CNT_CLEAR_TIMEOUT (1000 * 60 * 15) /* 15 min */ +#define MAX_LOGCNT_BT 9000 +#define MAX_LOGCNT_DSP 1000 +#define MAX_LOGCNT_PF 2000 +#define MAX_LOGCNT_MEDIA 1000 +#define MAX_LOGCNT_APP 5000 +#define MAX_LOGCNT_GPU 2000 +#define MAX_LOGCNT_GUI 1000 +#define MAX_LOGCNT_BTH 3000 +#define MAX_LOGCNT_OHOS 1000 +#define MAX_LOGCNT_BT_STATUS 3000 +#define MAX_LOGCNT_BT_OTA 3000 + +void mon_log_output_ctrl_init(void); +uint32_t *mon_log_output_get_counter(void); +void mon_log_output_enable(bool enable); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif diff --git a/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c b/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c index 7b3c3c0ef..ea74ec417 100644 --- a/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c +++ b/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c @@ -338,7 +338,9 @@ void diag_debug_cmd_proc(uint8_t *data, uint32_t len) void diag_auto_log_report_enable(void) { uint32_t level[] = { +#ifndef USER_VERSION DIAG_LOG_LEVEL_DBG, +#endif DIAG_LOG_LEVEL_INFO, DIAG_LOG_LEVEL_WARN, DIAG_LOG_LEVEL_ERROR, @@ -354,6 +356,7 @@ void diag_auto_log_report_enable(void) LOG_OTA_MODULE, LOG_OHOSMODULE, LOG_BTHMODULE, + LOG_GPUMODULE, }; #ifndef FT_SINGLE_UART diff --git a/code/sdk/middleware/chips/brandy/exception/CMakeLists.txt b/code/sdk/middleware/chips/brandy/exception/CMakeLists.txt index 9e0d1e43b..27c362549 100644 --- a/code/sdk/middleware/chips/brandy/exception/CMakeLists.txt +++ b/code/sdk/middleware/chips/brandy/exception/CMakeLists.txt @@ -3,7 +3,6 @@ # Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. #=============================================================================== set(COMPONENT_NAME "dfx_exception") - if(${ARCH_FAMILY} STREQUAL "arm") set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exception_arm.s @@ -13,9 +12,13 @@ elseif (${ARCH_FAMILY} STREQUAL "riscv") set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exception_riscv.s ${CMAKE_CURRENT_SOURCE_DIR}/exception_riscv.c + ${CMAKE_CURRENT_SOURCE_DIR}/chip_system_time.c + ${CMAKE_CURRENT_SOURCE_DIR}/chip_exception_utils.c + ${CMAKE_CURRENT_SOURCE_DIR}/exception_dump.c ) endif() + set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.c b/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.c new file mode 100644 index 000000000..0af3409a1 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.c @@ -0,0 +1,35 @@ +/** + * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Description: utils + * Author: + * Create: + */ +#include "chip_exception_utils.h" +#include +#include "hal_reboot.h" +#include "chip_io.h" + +#define STATUS_ADDRESS 0x5702C1E8 +#define VBUS_INSERT_POS 4 +#define PWREN_PRESS_POS 3 + +bool is_first_power_on(void) +{ + return hal_reboot_get_first_power_on_flag(); +} + +bool is_vbus_insert(void) +{ + if (reg32_getbit(STATUS_ADDRESS, VBUS_INSERT_POS)) { + return true; + } + return false; +} + +bool is_pwren_press(void) +{ + if (reg32_getbit(STATUS_ADDRESS, PWREN_PRESS_POS)) { + return true; + } + return false; +} \ 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 new file mode 100644 index 000000000..2a7a67998 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/exception/chip_exception_utils.h @@ -0,0 +1,31 @@ +/** + * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Description: utils + * Author: + * Create: + */ +#ifndef CHIP_EXCEPTION_UTILS_H +#define CHIP_EXCEPTION_UTILS_H + +#include +#include +#include + +/** + * @brief Check if this is the first power-on since the device was battery-powered. + * @return true if this is the first power-on, false otherwise. + */ +bool is_first_power_on(void); + +/** + * @brief Check if the VBUS (power supply) is inserted. + * @return true if VBUS is inserted, false otherwise. + */ +bool is_vbus_insert(void); + +/** + * @brief Check if the power button (PWREN) is being pressed. + * @return true if PWREN is pressed, false otherwise. + */ +bool is_pwren_press(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 new file mode 100644 index 000000000..36c21313f --- /dev/null +++ b/code/sdk/middleware/chips/brandy/exception/chip_system_time.c @@ -0,0 +1,152 @@ +/** + * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Description: get time + * Author: + * Create: + */ +#ifndef BUILD_APPLICATION_SSB + +#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 + +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); +} + +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); +} + +static uint16_t get_timezone(void) +{ + return readw(TZ_ADDRESS) & 0x00FF; +} + +static void set_timezone(uint16_t timezone) +{ + uint16_t tz_zone = readw(TZ_ADDRESS) & 0xFF00; + tz_zone = tz_zone | timezone; + writew(TZ_ADDRESS, tz_zone); +} + +void save_time(void) +{ + uint64_t time_sec = get_local_timestamp(); + time_sec = time_sec * MSEC_PER_SEC; + uapi_calendar_set_timestamp(time_sec); +} + +uint32_t get_current_timestamp(void) +{ + uint32_t timestamp = 0; + struct timeval current_time = {0}; + if (gettimeofday(¤t_time, NULL)) { + return 0; + } + struct tm tm; + localtime_r(¤t_time.tv_sec, &tm); + timestamp = (uint32_t)current_time.tv_sec; + return timestamp; +} + +uint32_t get_local_timestamp(void) +{ + uint32_t timestamp = get_current_timestamp() + get_timezone() * MINUTES_PER_HOUR * SECONDS_PER_MINUTE; + return timestamp; +} + +void get_current_time(struct timeval *tv, struct tm *tm) +{ + char timebuf[TIME_MAX] = {0}; + if (gettimeofday(tv, NULL)) { + return; + } + localtime_r(&tv->tv_sec, tm); + 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) +{ + uapi_ulp_systick_soc_calibration(); + calendar_t date; + uapi_calendar_get_datetime(&date); + print_time(&date); + uint64_t sec; + uapi_calendar_get_timestamp(&sec); + printf("callendar timestamp = %lld \r\n", sec); + sec = sec / MSEC_PER_SEC; + sync_time(sec, get_timezone()); +} + +uint32_t sync_time(uint32_t timestamp, uint32_t timezone) +{ + printf("sync time timestamp %d, timezone %d \r\n", timestamp, timezone); + uint32_t seconds; + if (timezone > MAX_TIMEZONE_HOURS) { + 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); + } + set_timezone(timezone); + 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; + 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 + printf("--------SYNC TIME----------\r\n"); + get_current_timestamp(); + get_current_time(&tv, &tm); + sync_time(time, 8); + get_current_timestamp(); + get_current_time(&tv, &tm); + printf("--------SAVE TIME----------\r\n"); + get_current_timestamp(); + get_current_time(&tv, &tm); + save_time(); + get_current_timestamp(); + get_current_time(&tv, &tm); + printf("--------RESTORE TIME----------\r\n"); + get_current_timestamp(); + get_current_time(&tv, &tm); + restore_time(); + get_current_timestamp(); + get_current_time(&tv, &tm); +} +#endif \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/exception/chip_system_time.h b/code/sdk/middleware/chips/brandy/exception/chip_system_time.h new file mode 100644 index 000000000..d2f2e7744 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/exception/chip_system_time.h @@ -0,0 +1,67 @@ +/** + * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Description: time + * Author: + * Create: + */ +#ifndef CHIP_SYSTEM_TIME_H +#define CHIP_SYSTEM_TIME_H + +#ifndef BUILD_APPLICATION_SSB +#include +#include +#include +#include "calendar.h" +#include "chip_io.h" +#include "errcode.h" +#include "time.h" +#include "sys/time.h" +/** + * @brief Print the time represented by the given calendar date + * @return void. + */ +void print_time(calendar_t *date); + +/** + * @brief Save the current system time to non-volatile memory + * @return void. + */ +void save_time(void); + +/** + * @brief Get the current system time as a Unix timestamp + * @return void. + */ +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); + +/** + * @brief Restore the system time from the saved non-volatile + * @return void. + */ +void restore_time(void); + +/** + * @brief Synchronize the system time with the given timestamp and timezone + * @return void. + */ +uint32_t sync_time(uint32_t timestamp, uint32_t timezone); + +/** + * @brief use for test + * @return void. + */ +void test_time(void); + +/** + * @brief Get the current system time as a local timestamp with timezone offset + * @return void. + */ +uint32_t get_local_timestamp(void); +#endif +#endif \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/exception/exception_dump.c b/code/sdk/middleware/chips/brandy/exception/exception_dump.c new file mode 100644 index 000000000..6d42aea84 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/exception/exception_dump.c @@ -0,0 +1,99 @@ +/** + * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Description: dump + * Author: + * Create: + */ +#include "exception_dump.h" +#include +#include +#include "exception.h" +#include "memory_config.h" +#include "time.h" +#include "sys/time.h" +#include "chip_io.h" +#ifdef CFG_DRIVERS_NANDFLASH +#include "nandflash_config.h" + +#define PSRAM_DUMP_TO_FILE_LENGTH 0x40000 // 256KB + +void exception_dump_memory_to_file(char *file_name, uint32_t dump_time, uintptr_t startAddr, uint32_t length) +{ + char *str = (char *)malloc(200); + memset_s(str, 200, 0, 200); + sprintf(str, file_name, dump_time); + exc_info_write(str, 0, (const uint8_t *)startAddr, length); +} + +typedef struct { + char *name; + uintptr_t start_addr; + uint32_t len; +} mem_dump_to_file_t; + +static const mem_dump_to_file_t g_mem_dump_to_file_info[] = { + {"/user/exc/APP_DTCM_ORIGIN_%d.bin", APP_DTCM_ORIGIN, APP_DTCM_LENGTH}, + {"/user/exc/MCPU_TRACE_MEM_REGION_%d.bin", MCPU_TRACE_MEM_REGION_START, CPU_TRACE_MEM_REGION_LENGTH}, + {"/user/exc/PSRAM_ORIGIN_%d.bin", PSRAM_APP_DATA_ADDR, PSRAM_DUMP_TO_FILE_LENGTH}, +}; + +void dump_mem_to_file(uint32_t time_sec) +{ + uint16_t count = (uint16_t)(sizeof(g_mem_dump_to_file_info) / sizeof(mem_dump_to_file_t)); + for (uint8_t i = 0; i < count; i++) { + exception_dump_memory_to_file(g_mem_dump_to_file_info[i].name, + time_sec, + g_mem_dump_to_file_info[i].start_addr, + g_mem_dump_to_file_info[i].len); + } +} +#endif + +#ifdef CFG_DUMP_REG_SUPPORT +char *g_regist_str = "[PMU1_B_SOC_PWR_EN_REG %x, %x]\r\n + [PMU1_BT_CBB_PWR_EN_REG %x, %x]\r\n + [PMU1_BMEM_PWR_EN_REG %x, %x]\r\n + [PMU1_BT_EM_PWR_EN_REG %x, %x]\r\n + [PMU1_MCU_HS_PWR_EN_REG %x, %x]\r\n + [PMU1_DSUB_PWR_EN_REG %x, %x]\r\n + [PMU1_ASUB_PWR_EN_REG %x, %x]\r\n + [PMU1_S_EGPIO_PWR_EN_REG %x, %x]\r\n + [PMU1_BT_RF_PWR_EN_REG %x, %x]\r\n + [PMU1_MCU_PWR_EN_REG %x, %x]\r\n + [PMU1_MEM_PWR_EN_REG %x, %x]\r\n + [PMU1_COM_PWR_EN_REG %x, %x]"; +static const char *g_reg_path = "/user/exc/reg_path%d.txt"; + +void dump_reg_to_file(uint32_t time_sec) +{ + char *file_name = (char *)malloc(100); + sprintf(file_name, g_reg_path, time_sec); + char *str = (char *)malloc(500); + uint32_t ctrl_base = 0x57004000; + sprintf(str, g_regist_str, + ctrl_base + 0x20, readl(ctrl_base + 0x20), + ctrl_base + 0x24, readl(ctrl_base + 0x24), + ctrl_base + 0x28, readl(ctrl_base + 0x28), + ctrl_base + 0x2c, readl(ctrl_base + 0x2c), + ctrl_base + 0x30, readl(ctrl_base + 0x30), + ctrl_base + 0x34, readl(ctrl_base + 0x34), + ctrl_base + 0x38, readl(ctrl_base + 0x38), + ctrl_base + 0x5c, readl(ctrl_base + 0x5c), + ctrl_base + 0x60, readl(ctrl_base + 0x60), + ctrl_base + 0x64, readl(ctrl_base + 0x64), + ctrl_base + 0x68, readl(ctrl_base + 0x68), + ctrl_base + 0x78, readl(ctrl_base + 0x78)); + exc_info_write(file_name, 0, (uint8_t *)str, strlen(str)); +} +#endif + +void dump_all_to_file(void) +{ + uint32_t timestamp = get_local_timestamp(); +#ifdef CFG_DRIVERS_NANDFLASH + dump_mem_to_file(timestamp); +#endif +#ifdef CFG_DUMP_REG_SUPPORT + dump_reg_to_file(timestamp); +#endif +} \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/exception/exception_dump.h b/code/sdk/middleware/chips/brandy/exception/exception_dump.h new file mode 100644 index 000000000..e375ec13c --- /dev/null +++ b/code/sdk/middleware/chips/brandy/exception/exception_dump.h @@ -0,0 +1,16 @@ +/** + * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Description: dump + * Author: + * Create: + */ +#ifndef EXCEPTION_DUMP_H +#define EXCEPTION_DUMP_H + +/** + * @brief support nandflash storage dump sysmem to file. + * @return void. + */ +void dump_all_to_file(void); + +#endif \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/exception/exception_riscv.c b/code/sdk/middleware/chips/brandy/exception/exception_riscv.c index d618a8a9c..0a0e6d102 100644 --- a/code/sdk/middleware/chips/brandy/exception/exception_riscv.c +++ b/code/sdk/middleware/chips/brandy/exception/exception_riscv.c @@ -13,6 +13,8 @@ #include "non_os_reboot.h" #include "watchdog_porting.h" #include "flash.h" +#include "exception_dump.h" + #if defined(BUILD_APPLICATION_STANDARD) && !defined(BUILD_RECOVERY_IMAGE) #include "nv.h" #endif @@ -137,12 +139,7 @@ static const char *g_exc_info_path = "/user/exc/exc_info.bin"; static volatile uint32_t g_bt_nmi_reboot = 0; static volatile uint32_t g_bt_nmi_mask = 0; #endif -#if MASTER_BY_BRANDY_ONLY -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG 0x57000014 -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL 0xb66 -#define PM_MCU_SEND_IPC_WKUP_BT_REG 0x52000034 -#define PM_MCU_SEND_IPC_WKUP_BT_BIT 0x1 -#endif + bool get_exception_status(void) { @@ -833,6 +830,7 @@ static errcode_t exc_info_write_local(exc_info_save_t *exc_info_save, uint32_t e nand_driver_init(SPEED_SLOW); set_trans_type(TRANS_BY_CPU_SINGLE_LINE); ret = exc_info_write(g_exc_info_path, 0, (const uint8_t *)exc_info_save, exc_size); + dump_all_to_file(); #endif #ifdef CFG_DRIVERS_MMC char *exc_info_buffer = (char *)osal_kmalloc_align(ONE_SECTOR_SIZE, 0, MMC_BUFFER_ALIGN); @@ -921,7 +919,7 @@ void do_hard_fault_handler(exc_context_t *exc_buf_addr) uapi_flash_switch_to_xip_mode(CHIP_FLASH_ID); #if (CORE == MASTER_BY_ALL) && (CORE != WIFI) if (g_is_repeat_exc == true) { - cpu_utils_reset_chip_with_log((cores_t)MASTER_BY_ALL, REBOOT_CAUSE_APPLICATION_HARDFAULT); + cpu_utils_reset_chip_with_log((cores_t)MASTER_BY_ALL, REBOOT_CAUSE_APPLICATION_SECOND_FAULT); } /* If the process is restarted at the end of an abnormal process, the value of this variable is false. */ /* Do not need to manually set false at the end. */ @@ -979,11 +977,6 @@ void reset_deal_with_fs(void) static void deal_with_exception(exc_context_t *exc_buf_addr, uint32_t exc_type, reboot_cause_t reset_cause) { UNUSED(reset_cause); -#if MASTER_BY_BRANDY_ONLY - // when bt at sleep, need wkup bt before soft reset - writew(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG, PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL); - reg16_setbit(PM_MCU_SEND_IPC_WKUP_BT_REG, PM_MCU_SEND_IPC_WKUP_BT_BIT); -#endif #if defined(BUILD_APPLICATION_STANDARD) && (CORE == MASTER_BY_ALL) set_exception_time_stamp(); // Record the reason before wait, so apps can get the reason. 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 new file mode 100644 index 000000000..e71b83266 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/eng/acore/app.json @@ -0,0 +1,92 @@ +{ + "common":{ + "module_id": "0x0", + "secure_conn":{ + "key_id": "0x2001", + "key_status": "alive", + "structure_type": "ext_nv_secure_conn_t", + "attributions": 1, + "value": [[ + 243, 241, 252, 189, 233, 154, 35, 34, 155, 96, 183, 133, 229, 196, 190, 222, 180, 146, 211, 63, + 59, 38, 229, 100, 24, 165, 216, 53, 120, 133, 104, 166, 31, 6, 220, 125, 87, 47, 131, 42, 74, + 240, 107, 111, 146, 239, 251, 229, 146, 99, 46, 4, 38, 183, 99, 2, 47, 215, 88, 151, 178, 198, + 148, 222, 135, 2, 156, 203, 192, 138, 178, 118, 6, 110, 40, 38, 235, 31, 220, 118, 53, 75, 152, + 32, 246, 4, 225, 131, 242, 96, 176, 20, 131, 184, 39, 88, 96, 7, 205, 231, 158, 10, 136, 178, + 32, 19, 156, 88, 133, 93, 18, 251, 35, 146, 58, 83, 25, 188, 84, 151, 99, 38, 102, 48, 240, 214, + 157, 197, 88, 160, 224, 71, 174, 4, 216, 234, 117, 87, 53, 132, 204, 99, 62, 201, 61, 116, 186, + 29, 201, 172, 140, 176, 226, 123, 55, 95, 18, 197, 30, 244, 19, 143, 112, 12, 29, 162, 188, 208, + 48, 242, 108, 76, 170, 139, 140, 198, 177, 233, 251, 57, 91, 10, 70, 117, 231, 226, 67, 26, 55, + 249, 144, 165, 75, 125, 215, 220, 190, 199, 116, 40, 221, 0, 17, 90, 25, 11, 47, 177, 255, 218, + 153, 254, 127, 237, 211, 170, 174, 104, 76, 47, 136, 193, 0, 147, 157, 74, 213, 180, 143, 240, + 173, 98, 90, 27, 30, 213, 217, 247, 50, 147, 202, 224, 54, 147, 34, 19, 177, 128, 27, 123, 101, + 242, 36, 68, 71, 184, 62, 166, 134, 86, 98, 216, 120, 123, 191, 49, 135, 105, 187, 38, 241, 125, + 26, 80, 141, 151, 222, 240, 253, 115, 102, 86, 118, 153, 214, 4, 209, 186, 110, 50, 105, 194, + 100, 125, 242, 51, 117, 118, 107, 164, 133, 229, 157, 221, 114, 121, 152, 204, 57, 119, 176, + 167, 75, 208, 156, 243, 138, 176, 50, 102, 121, 69, 22, 21, 225, 41, 216, 247, 133, 47, 129, 74, + 20, 79, 236, 42, 38, 134, 68, 224, 200, 42, 223, 23, 191, 88, 221, 31, 133, 145, 171, 46, 98, 4, + 202, 160, 0, 89, 222, 92, 67, 160, 163, 185, 52, 70, 129, 62, 112, 1, 223, 187, 218, 241, 25, + 215, 129, 196, 249, 32, 201, 96, 249, 165 + ], + [15,238,119,231,29,44,120,58,55,14,80,125,220,227,124,8,39,0,104,162],20] + }, + "offline_enable_flag":{ + "key_id": "0x2002", + "key_status": "alive", + "structure_type": "uint8_t", + "attributions": 1, + "value": 0 + }, + "btsrv_local_device_info":{ + "key_id": "0x2101", + "key_status": "alive", + "structure_type": "btsrv_local_device_info_t", + "attributions": 1, + "value": [[40,17,6,133,105, 89],0,0,["W","a","t","c","h","D","e","m","o",0]] + }, + "btsrv_paired_device_info":{ + "key_id": "0x2102", + "key_status": "alive", + "structure_type": "btsrv_paired_device_info_t", + "attributions": 1, + "value": [0] + }, + "btsrv_tx_power_info":{ + "key_id": "0x2103", + "key_status": "", + "structure_type": "btsrv_calibration_config_t", + "attributions": 1, + "value": [8,[75,75,75,75,55,55,95,95],[2,15,27,31,41,51,66,77],[-28,1818,-6745],0,14,14,14,12,0,0,0,0] + }, + "bth_host_config": { + "key_id": "0x2104", + "key_status": "alive", + "structure_type": "bth_product_data_config_t", + "attributions": 1, + "value": [0] + }, + "audio_vqe_param":{ + "key_id": "0x320C", + "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, + 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]] + }, + "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, + 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]] + } + } +} 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 new file mode 100644 index 000000000..11a5df878 --- /dev/null +++ b/code/sdk/middleware/chips/brandy/nv/nv_config/cfg/user/acore/app.json @@ -0,0 +1,92 @@ +{ + "common":{ + "module_id": "0x0", + "secure_conn":{ + "key_id": "0x2001", + "key_status": "alive", + "structure_type": "ext_nv_secure_conn_t", + "attributions": 1, + "value": [[ + 243, 241, 252, 189, 233, 154, 35, 34, 155, 96, 183, 133, 229, 196, 190, 222, 180, 146, 211, 63, + 59, 38, 229, 100, 24, 165, 216, 53, 120, 133, 104, 166, 31, 6, 220, 125, 87, 47, 131, 42, 74, + 240, 107, 111, 146, 239, 251, 229, 146, 99, 46, 4, 38, 183, 99, 2, 47, 215, 88, 151, 178, 198, + 148, 222, 135, 2, 156, 203, 192, 138, 178, 118, 6, 110, 40, 38, 235, 31, 220, 118, 53, 75, 152, + 32, 246, 4, 225, 131, 242, 96, 176, 20, 131, 184, 39, 88, 96, 7, 205, 231, 158, 10, 136, 178, + 32, 19, 156, 88, 133, 93, 18, 251, 35, 146, 58, 83, 25, 188, 84, 151, 99, 38, 102, 48, 240, 214, + 157, 197, 88, 160, 224, 71, 174, 4, 216, 234, 117, 87, 53, 132, 204, 99, 62, 201, 61, 116, 186, + 29, 201, 172, 140, 176, 226, 123, 55, 95, 18, 197, 30, 244, 19, 143, 112, 12, 29, 162, 188, 208, + 48, 242, 108, 76, 170, 139, 140, 198, 177, 233, 251, 57, 91, 10, 70, 117, 231, 226, 67, 26, 55, + 249, 144, 165, 75, 125, 215, 220, 190, 199, 116, 40, 221, 0, 17, 90, 25, 11, 47, 177, 255, 218, + 153, 254, 127, 237, 211, 170, 174, 104, 76, 47, 136, 193, 0, 147, 157, 74, 213, 180, 143, 240, + 173, 98, 90, 27, 30, 213, 217, 247, 50, 147, 202, 224, 54, 147, 34, 19, 177, 128, 27, 123, 101, + 242, 36, 68, 71, 184, 62, 166, 134, 86, 98, 216, 120, 123, 191, 49, 135, 105, 187, 38, 241, 125, + 26, 80, 141, 151, 222, 240, 253, 115, 102, 86, 118, 153, 214, 4, 209, 186, 110, 50, 105, 194, + 100, 125, 242, 51, 117, 118, 107, 164, 133, 229, 157, 221, 114, 121, 152, 204, 57, 119, 176, + 167, 75, 208, 156, 243, 138, 176, 50, 102, 121, 69, 22, 21, 225, 41, 216, 247, 133, 47, 129, 74, + 20, 79, 236, 42, 38, 134, 68, 224, 200, 42, 223, 23, 191, 88, 221, 31, 133, 145, 171, 46, 98, 4, + 202, 160, 0, 89, 222, 92, 67, 160, 163, 185, 52, 70, 129, 62, 112, 1, 223, 187, 218, 241, 25, + 215, 129, 196, 249, 32, 201, 96, 249, 165 + ], + [15,238,119,231,29,44,120,58,55,14,80,125,220,227,124,8,39,0,104,162],20] + }, + "offline_enable_flag":{ + "key_id": "0x2002", + "key_status": "alive", + "structure_type": "uint8_t", + "attributions": 1, + "value": 1 + }, + "btsrv_local_device_info":{ + "key_id": "0x2101", + "key_status": "alive", + "structure_type": "btsrv_local_device_info_t", + "attributions": 1, + "value": [[40,17,6,133,105, 89],0,0,["W","a","t","c","h","D","e","m","o",0]] + }, + "btsrv_paired_device_info":{ + "key_id": "0x2102", + "key_status": "alive", + "structure_type": "btsrv_paired_device_info_t", + "attributions": 1, + "value": [0] + }, + "btsrv_tx_power_info":{ + "key_id": "0x2103", + "key_status": "", + "structure_type": "btsrv_calibration_config_t", + "attributions": 1, + "value": [8,[75,75,75,75,55,55,95,95],[2,15,27,31,41,51,66,77],[-28,1818,-6745],0,14,14,14,12,0,0,0,0] + }, + "bth_host_config": { + "key_id": "0x2104", + "key_status": "alive", + "structure_type": "bth_product_data_config_t", + "attributions": 1, + "value": [0] + }, + "audio_vqe_param":{ + "key_id": "0x320C", + "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, + 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]] + }, + "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, + 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]] + } + } +} diff --git a/code/sdk/middleware/chips/brandy/pm/include/pm_definition.h b/code/sdk/middleware/chips/brandy/pm/include/pm_definition.h index 83382192b..7343313a3 100644 --- a/code/sdk/middleware/chips/brandy/pm/include/pm_definition.h +++ b/code/sdk/middleware/chips/brandy/pm/include/pm_definition.h @@ -40,6 +40,7 @@ typedef enum { PM_ID_TOUCH, PM_ID_JPEG, PM_ID_JS, + PM_ID_MSGCENTER, PM_ID_MAX, } pm_id_t; 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 fffa3d341..c32fc63a4 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 @@ -211,8 +211,8 @@ void pm_core_resume_min(void) clocks_system_resume_clock(); uapi_dma_init(); uapi_dma_open(); + cpu_trace_enable_mcpu_repeat(); storage_device_resume(); - reg16_setbit(0x520003e4, 0x0); // set mcpu_clken_slp in MSUB_SLP_CFG reg16_setbit(0x520003e4, 0x1); // set mcpu_hclken_slp in MSUB_SLP_CFG clocks_auto_cg_config(); diff --git a/code/sdk/middleware/chips/brandy/pm/service/pm_sleep.c b/code/sdk/middleware/chips/brandy/pm/service/pm_sleep.c index 71da1bbda..4d58f1861 100644 --- a/code/sdk/middleware/chips/brandy/pm/service/pm_sleep.c +++ b/code/sdk/middleware/chips/brandy/pm/service/pm_sleep.c @@ -30,11 +30,6 @@ #define PM_SLEEP_SEL_EVENT 0x777 #define PM_SLEEP_TRACE_DEF_VAL 0x5a5a #define PM_OS_US_TO_MS 1000 -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG 0x57000014 -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL 0xb66 -#define PM_MCU_SEND_IPC_WKUP_BT_REG 0x52000034 -#define PM_MCU_SEND_IPC_WKUP_BT_VAL 0x2 -#define BT_RESET_DELAY 10 enum { PM_SLEEP_STATE_IDLE, @@ -176,9 +171,6 @@ void pm_enter_deep_sleep_wfi(void) void pm_wkup_event_by_ulp_callback(void) { - writew(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG, PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL); - writew(PM_MCU_SEND_IPC_WKUP_BT_REG, PM_MCU_SEND_IPC_WKUP_BT_VAL); - uapi_tcxo_delay_ms(BT_RESET_DELAY); set_cpu_utils_reset_cause(REBOOT_CAUSE_APPLICATION_SYSRESETREQ); hal_reboot_chip(); } diff --git a/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c b/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c index 524e6708c..b414a90f0 100644 --- a/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c +++ b/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c @@ -31,11 +31,6 @@ #define MS_ID_ADDR 0xF8 #define CHIP_ID_ADDR OTP_CHIP_ID_START -#define TCXO_REBOOT_DELAY 500ULL -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG 0x57000014 -#define PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL 0xb66 -#define PM_MCU_SEND_IPC_WKUP_BT_REG 0x52000034 -#define PM_MCU_SEND_IPC_WKUP_BT_VAL 0x2 #define SUB_RSA4096_PUBKEY_N_OFFSET 24 #define uapi_array_size(_array) (sizeof(_array) / sizeof((_array)[0])) @@ -187,11 +182,6 @@ errcode_t upg_get_fota_partiton_area_addr(uint32_t *start_address, uint32_t *siz */ void upg_reboot(void) { - // when bt at sleep, need wkup bt before soft reset - writew(PM_SLEEP_SOFT_RESET_FORCE_WKUP_REG, PM_SLEEP_SOFT_RESET_FORCE_WKUP_VAL); - writew(PM_MCU_SEND_IPC_WKUP_BT_REG, PM_MCU_SEND_IPC_WKUP_BT_VAL); - /* 重启前睡眠500ms */ - uapi_tcxo_delay_ms((uint64_t)TCXO_REBOOT_DELAY); cpu_utils_set_system_status_by_cause(REBOOT_CAUSE_UPG_COMPLETION); hal_reboot_chip(); } diff --git a/code/sdk/middleware/services/gpu/drv/dpu/hal/dpu_hal.c b/code/sdk/middleware/services/gpu/drv/dpu/hal/dpu_hal.c index 418dcd190..18775ee76 100644 --- a/code/sdk/middleware/services/gpu/drv/dpu/hal/dpu_hal.c +++ b/code/sdk/middleware/services/gpu/drv/dpu/hal/dpu_hal.c @@ -30,7 +30,6 @@ static td_void dpu_hal_reg_unmap(void) { if (g_dpu_reg != TD_NULL) { osal_iounmap((void *)g_dpu_reg, sizeof(dpu_regs_type)); - g_dpu_reg = TD_NULL; } return; } diff --git a/code/sdk/middleware/services/gpu/drv/dpu/intf/drv_dpu_intf.c b/code/sdk/middleware/services/gpu/drv/dpu/intf/drv_dpu_intf.c index 910a65103..76d758040 100644 --- a/code/sdk/middleware/services/gpu/drv/dpu/intf/drv_dpu_intf.c +++ b/code/sdk/middleware/services/gpu/drv/dpu/intf/drv_dpu_intf.c @@ -32,6 +32,16 @@ static td_s32 drv_dpu_close(td_void *private_data) return EXT_SUCCESS; } +static td_void drv_dpu_set_suspend_flag(td_bool flag) +{ + unsigned long flags = 0; + dpu_disp_info *disp_info = dpu_disp_get_info(); + + osal_spin_lock_irqsave(&disp_info->disp_lock, &flags); + g_dpu_suspend_flag = flag; + osal_spin_unlock_irqrestore(&disp_info->disp_lock, &flags); +} + td_s32 drv_dpu_suspend(td_void *private_data) { uapi_unused(private_data); @@ -40,16 +50,18 @@ td_s32 drv_dpu_suspend(td_void *private_data) return EXT_SUCCESS; } + td_s32 ret = dpu_wait_all_finish(); + dpu_dfx_info *dfx_info = dpu_dfx_get_info(); dfx_info->suspend_cnt++; dpu_dbg("dpu suspend start"); dpu_hal_deinit(); dpu_layer_suspend(); - g_dpu_suspend_flag = TD_TRUE; + drv_dpu_set_suspend_flag(TD_TRUE); dpu_dbg("dpu suspend ok"); - return EXT_SUCCESS; + return ret; } td_s32 drv_dpu_resume(td_void *private_data) @@ -67,7 +79,7 @@ td_s32 drv_dpu_resume(td_void *private_data) dpu_hal_init(); dpu_layer_resume(); dpu_disp_chl_cfg(); - g_dpu_suspend_flag = TD_FALSE; + drv_dpu_set_suspend_flag(TD_FALSE); dpu_dbg("dpu resume ok"); return EXT_SUCCESS; diff --git a/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.c b/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.c index e0cef8e1e..03446a407 100644 --- a/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.c +++ b/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.c @@ -151,10 +151,13 @@ td_void dpu_isr_deinit(void) td_void dpu_isr_wait_finish(void) { td_s32 ret; + dpu_dfx_info *dfx_info = dpu_dfx_get_info(); ret = osal_wait_timeout_interruptible(&g_dpu_isr_info.finish_event, isr_get_finish_done, TD_NULL, 500); /* 500 ms */ if (ret <= 0) { + dfx_info->refresh_total = 0; + dfx_info->frm_done_total = 0; dpu_err("osal_wait_timeout!!!!"); return; } @@ -182,3 +185,26 @@ td_void dpu_isr_clear_finish_flag(void) { g_dpu_isr_info.finish_done = 0; } + +td_s32 dpu_wait_all_finish(td_void) +{ + unsigned long flag = 0; + dpu_dfx_info *dfx_info = dpu_dfx_get_info(); + const td_u32 wait_time = 200; + td_u32 cnt = 0; + + while (cnt++ < wait_time) { + osal_spin_lock_irqsave(&g_dpu_isr_info.isr_lock, &flag); + if (dfx_info->refresh_total == dfx_info->frm_done_total) { + osal_spin_unlock_irqrestore(&g_dpu_isr_info.isr_lock, &flag); + break; + } + osal_spin_unlock_irqrestore(&g_dpu_isr_info.isr_lock, &flag); + osal_udelay(100); // 100us + } + if (cnt >= wait_time) { + dpu_err("dpu_wait_all_finish timeout!!!!"); + return EXT_FAILURE; + } + return EXT_SUCCESS; +} diff --git a/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.h b/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.h index b8ab24189..4dedbc677 100644 --- a/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.h +++ b/code/sdk/middleware/services/gpu/drv/dpu/isr/dpu_isr.h @@ -21,6 +21,7 @@ td_void dpu_isr_deinit(void); td_void dpu_isr_wait_finish(void); td_void dpu_isr_wait_te_signal(void); td_void dpu_isr_clear_finish_flag(void); +td_s32 dpu_wait_all_finish(td_void); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/middleware/services/gpu/drv/jpeg/dfx/jpeg_dfx.h b/code/sdk/middleware/services/gpu/drv/jpeg/dfx/jpeg_dfx.h index b4268d12e..02439a845 100644 --- a/code/sdk/middleware/services/gpu/drv/jpeg/dfx/jpeg_dfx.h +++ b/code/sdk/middleware/services/gpu/drv/jpeg/dfx/jpeg_dfx.h @@ -50,6 +50,8 @@ typedef struct { td_float start_cost; td_float get_status_cost; td_float init_cost; + td_u32 create_cnt; + td_u32 destroy_cnt; } drv_jpeg_dfx_info; diff --git a/code/sdk/middleware/services/gpu/drv/jpeg/intf/drv_jpeg_intf.c b/code/sdk/middleware/services/gpu/drv/jpeg/intf/drv_jpeg_intf.c index a3f8e7a6b..de4d1156b 100644 --- a/code/sdk/middleware/services/gpu/drv/jpeg/intf/drv_jpeg_intf.c +++ b/code/sdk/middleware/services/gpu/drv/jpeg/intf/drv_jpeg_intf.c @@ -69,13 +69,24 @@ static td_s32 drv_jpeg_close(td_void *private_data) return EXT_SUCCESS; } +static td_void drv_jpeg_set_suspend_flag(td_bool flag) +{ + unsigned long flags = 0; + drv_jpeg_context *jpeg_context = jpeg_context_get(); + + osal_spin_lock_irqsave(&jpeg_context->lock, &flags); + g_jpeg_suspend_flag = flag; + osal_spin_unlock_irqrestore(&jpeg_context->lock, &flags); +} + td_s32 drv_jpeg_suspend(td_void *private_data) { uapi_unused(private_data); - + + td_s32 ret = jpeg_wait_all_finish(); jpeg_suspend(); - g_jpeg_suspend_flag = TD_TRUE; - return EXT_SUCCESS; + drv_jpeg_set_suspend_flag(TD_TRUE); + return ret; } td_s32 drv_jpeg_resume(td_void *private_data) @@ -83,7 +94,7 @@ td_s32 drv_jpeg_resume(td_void *private_data) uapi_unused(private_data); jpeg_resume(); - g_jpeg_suspend_flag = TD_FALSE; + drv_jpeg_set_suspend_flag(TD_FALSE); return EXT_SUCCESS; } diff --git a/code/sdk/middleware/services/gpu/drv/jpeg/ioctl/jpeg_ioctl.c b/code/sdk/middleware/services/gpu/drv/jpeg/ioctl/jpeg_ioctl.c index d000e458b..c76b33a96 100644 --- a/code/sdk/middleware/services/gpu/drv/jpeg/ioctl/jpeg_ioctl.c +++ b/code/sdk/middleware/services/gpu/drv/jpeg/ioctl/jpeg_ioctl.c @@ -275,6 +275,8 @@ td_s32 jpeg_ioctl_decomress_create(td_u32 cmd, td_void *arg, td_void *file) uapi_unused(file); uapi_unused(arg); + drv_jpeg_dfx_info *jpeg_dfx_info = jpeg_dfx_get_info(); + jpeg_dfx_info->create_cnt++; uapi_pm_add_sleep_veto(PM_ID_JPEG); return EXT_SUCCESS; } @@ -285,6 +287,8 @@ td_s32 jpeg_ioctl_decompress_destroy(td_u32 cmd, td_void *arg, td_void *file) uapi_unused(file); uapi_unused(arg); + drv_jpeg_dfx_info *jpeg_dfx_info = jpeg_dfx_get_info(); + jpeg_dfx_info->destroy_cnt++; uapi_pm_remove_sleep_veto(PM_ID_JPEG); return EXT_SUCCESS; } diff --git a/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.c b/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.c index 040d5ef6f..2f7babb90 100644 --- a/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.c +++ b/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.c @@ -54,3 +54,27 @@ td_s32 jpeg_isr_init(td_void) return EXT_SUCCESS; } + +td_s32 jpeg_wait_all_finish(td_void) +{ + unsigned long flag = 0; + drv_jpeg_dfx_info *dfx_info = jpeg_dfx_get_info(); + const td_u32 wait_time = 200; + td_u32 cnt = 0; + drv_jpeg_context *jpeg_context = jpeg_context_get(); + + while (cnt++ < wait_time) { + osal_spin_lock_irqsave(&jpeg_context->lock, &flag); + if (dfx_info->create_cnt == dfx_info->destroy_cnt) { + osal_spin_unlock_irqrestore(&jpeg_context->lock, &flag); + break; + } + osal_spin_unlock_irqrestore(&jpeg_context->lock, &flag); + osal_udelay(100); // 100us + } + if (cnt >= wait_time) { + jpeg_err("jpeg_wait_all_finish timeout"); + return EXT_FAILURE; + } + return EXT_SUCCESS; +} diff --git a/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.h b/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.h index dd887f623..edc95d08d 100644 --- a/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.h +++ b/code/sdk/middleware/services/gpu/drv/jpeg/isr/jpeg_isr.h @@ -15,6 +15,7 @@ extern "C" { #endif td_s32 jpeg_isr_init(td_void); +td_s32 jpeg_wait_all_finish(td_void); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/middleware/services/gpu/drv/vau/dfx/vau_dfx.c b/code/sdk/middleware/services/gpu/drv/vau/dfx/vau_dfx.c index fc41f483d..d2ea85af5 100644 --- a/code/sdk/middleware/services/gpu/drv/vau/dfx/vau_dfx.c +++ b/code/sdk/middleware/services/gpu/drv/vau/dfx/vau_dfx.c @@ -30,7 +30,7 @@ typedef struct { static td_s32 vau_dfx_help(int argc, const char *argv[]); static inline td_void vau_dfx_print_func_info(void); -static inline td_void vau_dfx_print_func_time_info(void); +static td_void vau_dfx_print_func_time_info(void); static td_void vau_dfx_print_func_cnt_info(void); /*-------------------------------- par define ---------------------------------------------*/ @@ -79,8 +79,10 @@ static inline td_void vau_dfx_print_func_info(td_void) vau_print("end func info: ------------------------------------\n"); } -static inline td_void vau_dfx_print_func_time_info(td_void) +static td_void vau_dfx_print_func_time_info(td_void) { + uapi_reg_read(HAL_VAU_LIST_PFCNT, g_vau_dfx_info.func_info.time_info.list_pfcnt); + vau_print("-----------time info-----------\n"); vau_print("create_cost(us) :%u\n", (td_u32)(g_vau_dfx_info.func_info.time_info.create_cost)); vau_print("destroy_cost(us) :%u\n", (td_u32)(g_vau_dfx_info.func_info.time_info.destroy_cost)); diff --git a/code/sdk/middleware/services/gpu/drv/vau/hal/vau_hal_apb.c b/code/sdk/middleware/services/gpu/drv/vau/hal/vau_hal_apb.c index 1284292f8..2b10d0c56 100644 --- a/code/sdk/middleware/services/gpu/drv/vau/hal/vau_hal_apb.c +++ b/code/sdk/middleware/services/gpu/drv/vau/hal/vau_hal_apb.c @@ -227,7 +227,7 @@ td_void vau_hal_apb_vector_draw_init(td_void) u_vau_draw_cvrg_weight1 weight1; quad.bits.threshold_quad = 0.125; /* 0.125 : default threshold for quad split */ - cubic.bits.threshold_cubic = 0.125; /* 0.125 : default threshold for cubic split */ + cubic.bits.threshold_cubic = 1.0f; /* 0.125 : default threshold for cubic split */ weight0.bits.weight0 = 32; /* 32 default weithg for 8x */ weight0.bits.weight1 = 32; /* 32 default weithg for 8x */ 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 c8e99cb32..b40575693 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 @@ -14,6 +14,7 @@ #include "vau_hal.h" #include "vau_dfx.h" #include "vau_pre_process.h" +#include "vau_handle.h" #define DRV_VAU_IOCTL_CMD_NUM 20 @@ -33,19 +34,30 @@ static td_s32 drv_vau_close(td_void *private_data) return EXT_SUCCESS; } +static td_void drv_vau_set_suspend_flag(td_bool flag) +{ + unsigned long flags = 0; + vau_handle_mgr *vau_handle_list = vau_handle_list_get(); + + osal_spin_lock_irqsave(&vau_handle_list->lock, &flags); + g_vau_suspend_flag = flag; + osal_spin_unlock_irqrestore(&vau_handle_list->lock, &flags); +} + td_s32 drv_vau_suspend(td_void *private_data) { uapi_unused(private_data); + td_s32 ret = drv_vau_wait_all_done(); vau_dfx_info *dfx_info = vau_dfx_get_info(); dfx_info->suspend_cnt++; vau_dbg("vau suspend start"); vau_hal_suspend(); - g_vau_suspend_flag = TD_TRUE; + drv_vau_set_suspend_flag(TD_TRUE); vau_dbg("vau suspend ok"); - return EXT_SUCCESS; + return ret; } td_s32 drv_vau_resume(td_void *private_data) @@ -63,7 +75,7 @@ td_s32 drv_vau_resume(td_void *private_data) #ifdef CONFIG_CLDO1PD_SUPPORT vau_mem_draw_pool_init(); #endif - g_vau_suspend_flag = TD_FALSE; + drv_vau_set_suspend_flag(TD_FALSE); vau_dbg("vau resume ok"); return EXT_SUCCESS; diff --git a/code/sdk/middleware/services/gpu/drv/vau/list/vau_list.c b/code/sdk/middleware/services/gpu/drv/vau/list/vau_list.c index 98f53d3fc..60e784c87 100644 --- a/code/sdk/middleware/services/gpu/drv/vau/list/vau_list.c +++ b/code/sdk/middleware/services/gpu/drv/vau/list/vau_list.c @@ -433,7 +433,6 @@ td_s32 vau_list_submit_job(td_handle handle, td_u32 time_out, td_size_t lockflags = 0; td_bool asynflag = 0; td_u32 tmp_time_out = time_out; - vau_dfx_info *vau_info = vau_dfx_get_info(); if ((tmp_time_out == 0) || (tmp_time_out > 2000)) { /* 2000ms */ tmp_time_out = 2000; /* max 2000ms */ @@ -456,7 +455,6 @@ td_s32 vau_list_submit_job(td_handle handle, td_u32 time_out, wait_ret = osal_wait_timeout_interruptible(&g_vau_block_job_wq, vau_osal_wait_check, (td_void *)&job->notify_type, tmp_time_out); osal_spin_lock_irqsave(&g_vau_sw_job_list->lock, &lockflags); - uapi_reg_read(HAL_VAU_LIST_PFCNT, vau_info->func_info.time_info.list_pfcnt); job->wait_for_done_count--; ret = vau_list_wake_up_job(job, asynflag, &wait_ret); osal_spin_unlock_irqrestore(&g_vau_sw_job_list->lock, &lockflags); diff --git a/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt b/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt index 1986740b3..3151d9768 100644 --- a/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt +++ b/code/sdk/middleware/services/gui/hal/display/CMakeLists.txt @@ -45,6 +45,7 @@ set(COMPONENT_CCFLAGS -Wno-unused-function -Wno-incompatible-pointer-types -Wno-incompatible-pointer-types-discards-qualifiers + -Werror=return-type ) set(WHOLE_LINK @@ -63,7 +64,7 @@ build_component() #=============================================================================== set(COMPONENT_NAME "display_gralloc") -set(SOURCES_GRALLOC +set(SOURCES_GRALLOC ${CMAKE_CURRENT_SOURCE_DIR}/src/display_gralloc.c ${CMAKE_CURRENT_SOURCE_DIR}/mempool/src/mem_pool_los.c ) @@ -97,6 +98,7 @@ list(APPEND CFLAG -Wno-missing-field-initializers) set(COMPONENT_CCFLAGS ${CFLAG} -Wno-sign-compare + -Werror=return-type ) set(WHOLE_LINK @@ -144,6 +146,7 @@ set(COMPONENT_CCFLAGS ${CFLAG} -Wno-unused-parameter -Wno-unused-function + -Werror=return-type ) set(WHOLE_LINK 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 5a5634b10..8eb8684f3 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 9f80e8f22..9ad11a06f 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 d9221a38c..9c321175b 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 6ce97393d..dde8b6f1e 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 3707dea21..a8b77c937 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/input/CMakeLists.txt b/code/sdk/middleware/services/gui/hal/input/CMakeLists.txt index c8b06bfd6..4962c481c 100644 --- a/code/sdk/middleware/services/gui/hal/input/CMakeLists.txt +++ b/code/sdk/middleware/services/gui/hal/input/CMakeLists.txt @@ -33,6 +33,7 @@ set(COMPONENT_CCFLAGS ${CFLAG} -Wno-incompatible-function-pointer-types -Wno-implicit-function-declaration + -Werror=return-type ) set(WHOLE_LINK diff --git a/code/sdk/middleware/services/gui/uikit/CMakeLists.txt b/code/sdk/middleware/services/gui/uikit/CMakeLists.txt index a3f07071f..3abb11ebb 100644 --- a/code/sdk/middleware/services/gui/uikit/CMakeLists.txt +++ b/code/sdk/middleware/services/gui/uikit/CMakeLists.txt @@ -47,6 +47,7 @@ set(public_configs -Wno-tautological-pointer-compare -Wno-unused-private-field -Wno-unused-function + -Werror=return-type ) # build graphic utils @@ -180,6 +181,7 @@ set(COMPONENT_CCFLAGS -Wno-tautological-pointer-compare -Wno-unused-private-field -Wno-unused-function + -Werror=return-type ) set(WHOLE_LINK @@ -212,9 +214,11 @@ set(COMPONENT_SRC ${PROP_UI_SRC}/components_ext/ui_cross_view.cpp ${PROP_UI_SRC}/components_ext/kaleidoscope_utils.cpp ${PROP_UI_SRC}/components_ext/ui_kaleidoscope_view.cpp + ${PROP_UI_SRC}/components_ext/ui_roller_view.cpp ${PROP_UI_SRC}/components_ext/ui_map_view.cpp ${PROP_UI_SRC}/components_ext/map_svg_parser.cpp ${PROP_UI_SRC}/components_ext/ui_coverflow_view.cpp + ${PROP_UI_SRC}/components_ext/ui_icosahedron_view.cpp ) set(SOURCES @@ -257,6 +261,7 @@ set(COMPONENT_CCFLAGS -Wno-tautological-pointer-compare -Wno-unused-private-field -Wno-unused-function + -Werror=return-type ) set(WHOLE_LINK 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 304b659c1..d629f4128 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 c3b85553a..8ec26e3ed 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 958bb08f9..334912403 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_utils.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/common/graphic_utils.h new file mode 100644 index 000000000..7fdd0b1a3 --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/common/graphic_utils.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + */ + +#ifndef DEFER_UTILS_H +#define DEFER_UTILS_H + +#include +#include "gfx_utils/image_info.h" +#include "gfx_utils/graphic_math.h" + +namespace OHOS { +#ifndef defer +struct defer_dummy {}; +template struct deferrer { F f; ~deferrer() { f(); } }; +template deferrer operator*(defer_dummy, F f) { return {f}; } +#define DEFER_(LINE) zz_defer##LINE +#define DEFER(LINE) DEFER_(LINE) +#define defer auto DEFER(__LINE__) = defer_dummy{} *[&]() +#endif // defer +} // OHOS +#endif // DEFER_UTILS_H \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/common/image_cache_manager.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/common/image_cache_manager.h index e497fe0e2..095a9f1b0 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/common/image_cache_manager.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/common/image_cache_manager.h @@ -106,6 +106,11 @@ public: void* FreeAndGetBuf(const AllocInfo& info, GrallocBuffer& buffer); + /** + * @brief Dump image information. + */ + void Dump(); + private: struct ImageNode; struct MultiImageInfo { 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 87ec4e93a..7ed170fab 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 @@ -58,6 +58,12 @@ public: */ ImageInfoExt* GetKaleidoscopeInfo(); + /** + * @brief Get pointer to source ImageInfo struct. + * @return Return pointer to source ImageInfo struct. + */ + const ImageInfo* GetSrcImgInfo(); + private: ImageInfo* imgInfo_ = nullptr; ImageInfoExt* kaleidoscopeInfo_ = nullptr; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_coverflow_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_coverflow_view.h index ee54206e2..c94aa7228 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_coverflow_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_coverflow_view.h @@ -89,12 +89,14 @@ public: uint8_t GetDirection() const = delete; protected: bool DragXInner(int16_t distance) override; + void RefreshCurrentView(int16_t distance, uint8_t dragDirection); private: void UpdatePerspectiveMatrix(); void ReMeasure(void) override; void TransformImage(UIImageView* view); void DeleteGroup(UIViewGroup* group); + bool CalCurViewInfo(); using UISwipeView::Add; using UISwipeView::Remove; @@ -110,6 +112,7 @@ private: uint8_t mirrorOpa_; bool isShowMirrorImg_; UIView* lastView_; + uint16_t swipeMid_; }; } // namespace OHOS #endif // UI_COVERFLOW_VIEW_H diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_hexagons_list.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_hexagons_list.h index 5a7e3d11d..7d287c554 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_hexagons_list.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_hexagons_list.h @@ -184,10 +184,16 @@ public: */ Vector2 GetCurrentPosition(uint8_t index); + UIViewType GetViewType() const override + { + return UI_HEXAGONS_LIST; + } + + void ReMeasure() override; + protected: bool DragXInner(int16_t distance) override; bool DragYInner(int16_t distance) override; - void ReMeasure() override; /** * @brief Get center position of the special(index) image when scale and center image index in screen is specified * @@ -214,7 +220,7 @@ private: uint16_t maxLap_ = 0; uint16_t maxAngleInMaxLap_ = 0; Graphic::Vector polygonPoints_{10}; - uint16_t imgDistance_{0}; + float imgDistance_{0}; uint16_t oriImgDistance_{0}; float oriScaleFactor_{0.23f}; int16_t imgSizeInCenter_{0}; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_icosahedron_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_icosahedron_view.h new file mode 100644 index 000000000..e483fa414 --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_icosahedron_view.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024 CompanyNameMagicTag. + * 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. + */ + +#ifndef UI_ICOSAHEDRON_VIEW_H +#define UI_ICOSAHEDRON_VIEW_H +#include "components/ui_abstract_scroll.h" +#include "gfx_utils/graphic_math.h" +#include "components_ext/triangular_plane.h" + +namespace OHOS { +class UIIcosahedronView : public UIAbstractScroll { +public: + UIIcosahedronView(); + virtual ~UIIcosahedronView(); + + /** + * @brief Set the edge length of the icosahedron. + * + * @param sideLen edge length of body shape. + */ + void SetSideLength(uint16_t sideLen); + + /** + * @brief Add a one-sided view to the icosahedron. + * + * @param view Single-sided corresponding view.Only supported ui image view. + */ + void Add(UIView* view) override; + + /** + * @brief Refresh icosahedral position.physique position will be reset after refreshing + */ + void RefreshIcosahedron(); + + /** + * @brief Rotates the icosahedral in 3d. + * + * @param angle Indicates the rotation angle. + * @param pivotStart Indicates the coordinates of the rotation start pivot. + * @param pivotEnd Indicates the coordinates of the rotation end pivot. + */ + bool RotatePlanes(int16_t angle, const Vector3& pivotStart, const Vector3& pivotEnd); + + UIViewType GetViewType() const override + { + return UI_ICOSAHEDRON_VIEW; + } + +protected: + bool OnDragStartEvent(const DragEvent& event); + bool OnDragEvent(const DragEvent& event); + bool OnDragEndEvent(const DragEvent& event); + bool DragXInner(int16_t distance) override + { + return true; + } + + bool DragYInner(int16_t distance) override + { + return true; + } + +private: + class inertiaAnimatorCallback : public AnimatorCallback { + public: + inertiaAnimatorCallback() : rotateTimes_(0), curtTime_(0), angle_(0) + { + } + + virtual ~inertiaAnimatorCallback() {} + + void SetRotateTimes(uint16_t times) + { + curtTime_ = 0; + rotateTimes_ = times; + } + + void SetRotateAngle(int16_t angle) + { + angle_ = angle; + } + + void SetRotateAxis(const Vector3& rotateStart, const Vector3& rotateEnd) + { + rotateStart_ = rotateStart; + rotateEnd_ = rotateEnd; + } + + virtual void Callback(UIView* view) override; + + private: + uint16_t rotateTimes_; + uint16_t curtTime_; + int16_t angle_; + Vector3 rotateStart_; + Vector3 rotateEnd_; + }; + Matrix4 CalculateRotateMatrix(TriangularPlane dst); + Point startPoint_; + uint16_t sideLen_; + + TriangularPlane plane_[20]; // 20: plane number + Matrix4 imgMatrix_; + Matrix4 sphereMatrix_; + Matrix4 lastSphereMatrix_; + bool isUpdateSideLen_ = true; + + Animator inertiaAnimator_; + inertiaAnimatorCallback inertiaCallback_; + float lastAngle_; +}; +} // namespace OHOS +#endif // UI_ICOSAHEDRON_H \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_kaleidoscope_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_kaleidoscope_view.h index 885176967..f2c5312cd 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_kaleidoscope_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_kaleidoscope_view.h @@ -96,6 +96,9 @@ public: void StopRotateAnimator(); void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) override; + + void DumpImgInfo() override; + private: class RotateCallback : public AnimatorCallback { public: diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_list_ext.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_list_ext.h index cb79caeee..f39d0bf37 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_list_ext.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_list_ext.h @@ -59,7 +59,7 @@ public: * @since 1.0 * @version 1.0 */ - UIListExt(uint8_t direction) + explicit UIListExt(uint8_t direction) { SetDirection(direction); } diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_lite_surface_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_lite_surface_view.h index 352eedb94..b34781850 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_lite_surface_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_lite_surface_view.h @@ -169,16 +169,6 @@ public: return UI_LITE_SURFACE_VIEW; } - /** - * @brief Check if first video frame came. - * @since 1.0 - * @version 1.0 - */ - bool IsFirstFrameCame() - { - return isFirstFrameCome_; - } - /** * @brief Set preview image info. * @since 1.0 @@ -186,12 +176,13 @@ public: */ void SetPreview(ImageInfo* info); + void DumpImgInfo() override; + private: UILiteSurfaceView(const UILiteSurfaceView&) = delete; UILiteSurfaceView &operator=(const UILiteSurfaceView&) = delete; void InitLayer(); - bool isStopped_ = false; - bool isFirstFrameCome_ = false; + bool isStopped_ = true; bool isLayerInit_ : 1; uint8_t flushCount_; LiteSurface* surface_ = nullptr; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_map_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_map_view.h index 1b1310ab6..f7f5b2619 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_map_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_map_view.h @@ -151,7 +151,6 @@ private: bool needUpdate_ = false; ImageInfo cacheInfo_ = {{0}}; MapSVGParser parser_; - uint8_t* data_ = nullptr; char* filePath_ = nullptr; PathDetail* pathArray_ = nullptr; uint8_t pathCount_ = 0; @@ -164,7 +163,9 @@ private: uint8_t fontSize_ = 0; uint32_t poiMask_ = 0; float scale_ = 1.0f; + bool isSetSVG_ = false; + void InitMapInfo(); void DrawPath(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea); void DrawText(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, TextDetail& info, Point offset = {0, 0}, bool isPOIText = false); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_menu_item.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_menu_item.h index 5463c07fc..5ab2c078b 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_menu_item.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_menu_item.h @@ -48,6 +48,9 @@ namespace OHOS { */ class UIMenuItem : public UIButton { public: + UIMenuItem(const UIMenuItem &) = delete; + UIMenuItem &operator=(const UIMenuItem &) = delete; + /** * @brief Scale align mode. */ @@ -91,7 +94,7 @@ public: * @since 1.0 * @version 1.0 */ - void SetImageSrc(const char* ImgSrc); + void SetImageSrc(const char* imgSrc); /** * @brief Sets the image info for menu image. @@ -99,7 +102,7 @@ public: * @since 1.0 * @version 1.0 */ - void SetImageSrc(const ImageInfo* ImgSrc); + void SetImageSrc(const ImageInfo* imgSrc); /** * @brief Sets the text for this item. @@ -288,6 +291,8 @@ public: void ReMeasure() override; void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) override; + void DumpImgInfo() override; + private: UIImageView* image_ = nullptr; Style textStyle_; 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 new file mode 100644 index 000000000..24465f648 --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_roller_view.h @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2024 CompanyNameMagicTag. + * 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. + */ + +#ifndef UI_ROLLER_VIEW_H +#define UI_ROLLER_VIEW_H +#include +#include "components/ui_abstract_scroll.h" + +namespace OHOS { + +enum RollerViewMode { + DISPLAY, // Display all items in roller form. + COVER, // Display current item at full size. + TRANSITION, // used internally. +}; + +class UIRollerView : public UIAbstractScroll { +public: + UIRollerView(); + virtual ~UIRollerView() override; + + /** + * @brief Set item size, which is the size of image in DisplayMode. + */ + void SetItemSize(uint16_t width, uint16_t height); + + /** + * @brief Set item padding. + */ + void SetItemPadding(uint16_t padding); + + /** + * @brief Set mirror img opacity. + */ + void SetMirrorOpacity(uint8_t opa); + + /** + * @brief Set sensitivity factor. + * Drag distance will be converted to angle, and will multiply by this factor. + */ + void SetSensitivityFactor(float sensitivity); + + /** + * @brief Get sensitivity factor. Default value is 1.0. + */ + float GetSensitivityFactor(); + + /** + * @brief Add an item. + */ + void AddItem(std::string name, const ImageInfo* src); + + /** + * @brief Remove an item. + */ + void RemoveItem(std::string name); + + /** + * @brief Clear all items. + */ + void ClearAll(); + + /** + * @brief Get current item name. + */ + std::string GetCurrentItemName(); + + /** + * @brief Get current item, which contains 2 imgs. + */ + UIViewGroup* GetCurrentItem(); + + /** + * @brief Set current item. + */ + void SetCurrentItem(std::string name, bool enableAnimator = false); + + /** + * @brief Set current mode, choose from [DISPLAY, COVER]. + */ + void SetMode(RollerViewMode mode, bool enableAnimator = false); + + /** + * @brief Mode change listener. + */ + class OnModeChangeListener : public HeapBase { + public: + /** + * @brief Called when RollerViewMode is changed. + */ + virtual void OnModeChange(UIRollerView* view, RollerViewMode targetMode) = 0; + virtual ~OnModeChangeListener() {} + }; + + /** + * @brief Get OnModeChangeListener. + */ + OnModeChangeListener*& GetOnModeChangeListener() + { + return onModeChangeListener_; + } + + /** + * @brief Set OnModeChangeListener. + */ + void SetOnModeChangeListener(OnModeChangeListener* onModeChangeListener) + { + onModeChangeListener_ = onModeChangeListener; + } + + /** + * @brief Get current mode. + */ + RollerViewMode GetMode(); + + /** + * @brief Set camera distance. If not set, default distance is 1000. + */ + void SetCamDistance(int16_t distance); + + /** + * @brief Set absolute y coordinate of camera. + Default value is GetY() - GetHeight() / 3. + */ + void SetCamY(int16_t y); + + UIViewType GetViewType() const override + { + return UI_ROLLER_VIEW; + } + + bool OnDragStartEvent(const DragEvent& event) override; + bool OnDragEvent(const DragEvent& event) override; + bool OnDragEndEvent(const DragEvent& event) override; + + void SetDirection(uint8_t direction) = delete; + uint8_t GetDirection() const = delete; + void SetLoopState(bool loop) = delete; + +protected: + bool DragXInner(int16_t distance); + bool DragYInner(int16_t distance) + { + return true; + } + +private: + class AlignAnimatorCallback : public AnimatorCallback { + public: + AlignAnimatorCallback() + : curTime_(0), + animTime_(0), + angle_(0), + previousAngle_(0) + { + } + + virtual ~AlignAnimatorCallback() {} + + void SetAnimTimes(uint16_t times) + { + animTime_ = times; + } + + void SetAngle(float angle) + { + angle_ = angle; + } + + void ResetCallback() + { + angle_ = 0; + previousAngle_ = 0; + animTime_ = 0; + curTime_ = 0; + } + + virtual void Callback(UIView* view) override; + + uint16_t curTime_; + uint16_t animTime_; + float previousAngle_; + float angle_; + }; + + class TransitionAnimatorCallback : public AnimatorCallback { + public: + TransitionAnimatorCallback() : curTime_(0), animTime_(0), + startScaleX_(0), startScaleY_(0), endScaleX_(0), endScaleY_(0), + camPos_({0, 0}), targetCamPos_({0, 0}) + { + } + + virtual ~TransitionAnimatorCallback() {} + + void SetAnimTimes(uint16_t times) + { + animTime_ = times; + } + + void SetScaleFactor(float startScaleX, float startScaleY, float endScaleX, float endScaleY) + { + startScaleX_ = startScaleX; + startScaleY_ = startScaleY; + endScaleX_ = endScaleX; + endScaleY_ = endScaleY; + } + + void SetCamPosition(Point previousCamPos, Point targetCamPos) + { + camPos_ = previousCamPos; + targetCamPos_ = targetCamPos; + } + + void ResetCallback() + { + curTime_ = 0; + animTime_ = 0; + startScaleX_ = 0; + startScaleY_ = 0; + endScaleX_ = 0; + endScaleY_ = 0; + camPos_ = {0, 0}; + targetCamPos_ = {0, 0}; + } + + virtual void Callback(UIView* view) override; + + uint16_t curTime_; + uint16_t animTime_; + float startScaleX_; + float startScaleY_; + float endScaleX_; + float endScaleY_; + Point camPos_; + Point targetCamPos_; + }; + + /* calculate swipe anim period: angle offset / ANGLE_COEFFICIENT. Minimum swipe anim period is MIN_DRAG_TIMES. */ + static constexpr uint8_t ANGLE_COEFFICIENT = 5; + /* the minimum period of mode transition animator. */ + static constexpr uint8_t MIN_TRANSITION_TIMES = 5; + /* calculate mode transition animator period: scale offset / TRANSITION_COEFFICIENT. */ + static constexpr float TRANSITION_COEFFICIENT = 0.2; + OnModeChangeListener* onModeChangeListener_; + float ConvertDistanceToAngle(int16_t distance); + bool IsInCurrentItemRange(float angle); + void InitImg(UIView* img); + void DoCalculation(); + void PrepAlign(float angle); + void SetCamPosInner(Point position); + void StartTransitionAnim(); + void StopTransitionAnim(); + void ReflectImg(UIView* img, UIView* mirror); + void ReMeasure(void) override; + void LayoutItem(); + void TransformByAngle(float angle); + void TransformItemGroup(UIView* view, float angle); + void DelItemGroup(UIViewGroup* group); + void ResetState(); + void StartAlignAnim(); + void StopAlignAnim(); + void MoveHeadOrTail(); + void HandleMode(); + void HandleAlign(); + void UpdateCam(); + + Animator alignAnim_; + AlignAnimatorCallback alignCallback_; + + Animator transitionAnim_; + TransitionAnimatorCallback transitionCallback_; + + int16_t camY_ = 0; + bool isCamYSet_ = false; + RollerViewMode mode_ = DISPLAY; + RollerViewMode targetMode_ = DISPLAY; + bool switchModeWithAnim_ = false; + bool alignWithAnim_ = false; + UIView* coverPreviousItem_ = nullptr; + uint16_t itemWidth_ = 0; + uint16_t itemHeight_ = 0; + uint8_t mirrorOpa_ = 100; + float radius_ = 0.0f; + float perimeter_ = 0.0f; + float sensitivityFactor_ = 1.0f; + float anglePerItem_ = 0.0f; + Point camPosition_ = {0, 0}; + Point displayCamPosition_ = {0, 0}; + uint16_t cameraDistance_ = 1000; + uint16_t itemPadding_ = 0; + bool needLayout_ = false; + UIViewGroup* currentItem_ = nullptr; + UIViewGroup* alignItem_ = nullptr; + float alignAngle_ = 0.0f; +}; +} // namespace OHOS +#endif // UI_ROLLER_VIEW_H diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_sweep_clock.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_sweep_clock.h index 73dafd3a2..c21b68214 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_sweep_clock.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_sweep_clock.h @@ -410,6 +410,8 @@ public: */ void SetWorkMode(WorkMode newMode) override; + void DumpImgInfo() override; + private: Hand hourHand_; Hand minuteHand_; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service.h index 15f0f332e..fa8d6a03c 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service.h @@ -101,6 +101,16 @@ public: */ bool InitGraphicService(); + /** + * @brief GPU Reset start. + */ + void GpuResetStart(void); + + /** + * @brief GPU Reset end. + */ + void GpuResetEnd(void); + #ifdef ENABLE_CMSIS static void NativeMainThread(void* args); static void RtcEventThread(void* args); @@ -118,6 +128,7 @@ private: static OHOS::GraphicMutex rtcEventMutex_; static OHOS::GraphicCond rtcEventCond_; static bool fullRefreshFlag_; + bool isGpuReseting = false; void DecreaseTriggerCount(); void SetUpRootView(); GraphicService(); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service_wrapper.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service_wrapper.h index a522c8dd5..95b859e49 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service_wrapper.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/include/service/graphic_service_wrapper.h @@ -64,6 +64,16 @@ void ShowGraphicLogo(void); */ void HideGraphicLogo(void); +/** + * @brief GPU Reset start. + */ +void GpuResetStart(void); + +/** + * @brief GPU Reset end. + */ +void GpuResetEnd(void); + #ifdef __cplusplus }; #endif diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/common/ui_barcode.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/common/ui_barcode.cpp index 987dfc771..6638e1bae 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/common/ui_barcode.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/common/ui_barcode.cpp @@ -140,8 +140,8 @@ bool UIBarcode::FillImageInfo() GRAPHIC_LOGE("actualLength is 0 or actualLength > width"); return false; } - uint32_t step = width / actualLength; - imageInfo_.header.width = actualLength * step; + uint32_t step = static_cast(width / actualLength); + imageInfo_.header.width = static_cast(actualLength) * step; imageInfo_.header.height = height; imageInfo_.header.colorMode = RGB565; stride_ = DisplayDev::GetInstance()->CalcStride(imageInfo_.header.width, PIXEL_FMT_RGB_565); @@ -166,12 +166,12 @@ void UIBarcode::FillBarCodeColor(ImageInfo& imageInfo, int32_t actualLength, uin { uint8_t* data = const_cast(imageInfo.data); - for (uint32_t i = 0; i < actualLength; i++) { + for (uint32_t i = 0; i < static_cast(actualLength); i++) { if ((*(destData + i)) == 0) { continue; } - int16_t codeOffset = i * offset * 2; // 2: rgb565 has 2 byte per pixel + int16_t codeOffset = static_cast(i * offset * 2); // 2: rgb565 has 2 byte per pixel for (uint32_t k = 0; k < offset; k++) { *(data + codeOffset + k * 2) = 0; // 2: rgb565 has 2 byte per pixel *(data + codeOffset + k * 2 + 1) = 0; // 2: rgb565 has 2 byte per pixel diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_input_method.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_input_method.cpp index 963891f97..f6da2932b 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_input_method.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_input_method.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ -#include "input_method/ui_input_method.h" +#include #include "common/screen.h" #include "components/root_view.h" -#include "font/ui_font.h" #include "input_method/ui_soft_keyboard.h" +#include "input_method/ui_input_method.h" #if ENABLE_SOFT_KEYBOARD namespace OHOS { @@ -26,6 +26,7 @@ enum class SYS_IMT_TYPE { SYS_IME_CAP, SYS_IME_NUMBER, SYS_IME_SYMBOL, + SYS_IME_PINYIN, SYS_IME_ALL, }; UIInputMethod::UIInputMethod() @@ -34,6 +35,7 @@ UIInputMethod::UIInputMethod() customSoftKeyboard_.PushBack(UICapitalSoftKeyboard::GetInstance()); customSoftKeyboard_.PushBack(UINumberSoftKeyboard::GetInstance()); customSoftKeyboard_.PushBack(UISymbolSoftKeyboard::GetInstance()); + customSoftKeyboard_.PushBack(UIPinyinSoftKeyboard::GetInstance()); curSoftKeyboard_ = customSoftKeyboard_[static_cast(SYS_IMT_TYPE::SYS_IME_EN)]; } @@ -54,6 +56,15 @@ UIInputMethod::~UIInputMethod() previeBox_ = nullptr; } + if (pinyinPreview_ != nullptr) { + delete pinyinPreview_; + pinyinPreview_ = nullptr; + } + + ClearPinyinTable(); + + ClearHanziCandidate(); + curSoftKeyboard_ = nullptr; isInit_ = false; } @@ -70,15 +81,16 @@ void UIInputMethod::OnShow(InputMethodManager::InputMethodParam& param) GRAPHIC_LOGD("UI system soft keyboard has been shown\n"); return; } + SetupPinyinTable(); InitInputMethod(); // update edit text edit_ = static_cast(param.view); if (previeBox_ != nullptr) { previeBox_->SetInputType(param.inputType); + previeBox_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, UITextPreviewBox::DEFAULT_EDIT_FONT_SIZE); previeBox_->SetText(param.text.c_str()); previeBox_->Focus(); - previeBox_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, UITextPreviewBox::DEFAULT_EDIT_FONT_SIZE); if (edit_ != nullptr) { previeBox_->SetStyle(STYLE_LINE_HEIGHT, edit_->GetStyle(STYLE_LINE_HEIGHT)); previeBox_->SetMaxLength(edit_->GetMaxLength()); @@ -117,7 +129,7 @@ void UIInputMethod::OnHide() InputMethodManager::GetInstance().OnKeyboardHide(); } -void UIInputMethod::Input(UI_KEYCODE &key) +void UIInputMethod::Input(UI_KEYCODE key) { if (key >= UI_KEYCODE::UI_KEY_SOFT_KEYBOARD) { ChangSoftKeyboard(key); @@ -128,6 +140,61 @@ void UIInputMethod::Input(UI_KEYCODE &key) } } +void UIInputMethod::InputPinyin(UI_KEYCODE key) +{ + // process pinyin logic here + if (key >= UI_KEYCODE::UI_KEY_SOFT_KEYBOARD) { + if (curKeyboardIndex_ == static_cast(SYS_IMT_TYPE::SYS_IME_PINYIN)) { + HidePinyinPreview(); + HideHanziPageList(); + } + ChangSoftKeyboard(key); + return; + } + if (curSoftKeyboard_ == nullptr) { + return; + } + + switch (key) { + case UI_KEYCODE::UI_KEY_ENTER: + HidePinyinPreview(); + HideHanziPageList(); + DealSendKey(); + break; + case UI_KEYCODE::UI_KEY_DEL: + if (pinyinPreview_ && pinyinPreview_->IsVisible()) { + DealPinyinDelKey(); + } else { + DealDelKey(); + } + break; + default: + if (key >= UI_KEYCODE::UI_KEY_a && key <= UI_KEYCODE::UI_KEY_z) { + InsertPinyin(key); + } else { + DealNormalKey(key); + } + break; + } +} + +void UIInputMethod::ShowHanziPageList() +{ + if (hanziList_ == nullptr || pinyinPreview_ == nullptr) { + return; + } + if (pinyinPreview_->GetText() != nullptr && strlen(pinyinPreview_->GetText()) != 0) { + hanziList_->SetVisible(true); + } +} + +void UIInputMethod::HideHanziPageList() +{ + if (hanziList_ != nullptr) { + hanziList_->SetVisible(false); + } +} + uint8_t UIInputMethod::HideOptionBox() { if ((optionBox_ == nullptr) || !optionBox_->IsVisible()) { @@ -152,10 +219,32 @@ void UIInputMethod::ShowOptionBox(UIView *view, UI_KEYCODE *keys, uint8_t num) return; } +bool UIInputMethod::OnClick(UIView& view, const ClickEvent& event) +{ + if (previeBox_ == nullptr) { + return false; + } + UILabelButton *btn = dynamic_cast(&view); + if (btn == nullptr) { + return false; + } + + std::string u8hanzi; + const char *hanzi = btn->GetText(); + if (hanzi != nullptr) { + u8hanzi = hanzi; + } + previeBox_->InsertHanzi(u8hanzi); + HideHanziPageList(); + HidePinyinPreview(); + return true; +} + void UIInputMethod::DealSendKey() { std::string inputText = previeBox_->GetText(); InputMethodManager::GetInstance().InsertText(inputText); + ClearPinyinTable(); InputMethodManager::GetInstance().HideInputMethod(); } @@ -166,7 +255,92 @@ void UIInputMethod::DealDelKey() } } -void UIInputMethod::DealFunctionKey(UI_KEYCODE &keyCode) +void UIInputMethod::DealPinyinDelKey() +{ + if (pinyinPreview_ == nullptr) { + return; + } + const char *str = pinyinPreview_->GetText(); + std::string pinyin; + if (str != nullptr && strlen(str) > 0) { + pinyin = str; + } + if (pinyin.length() > 0) { + pinyin = pinyin.substr(0, pinyin.length() - 1); + pinyinPreview_->SetText(pinyin.c_str()); + } + const char *text = pinyinPreview_->GetText(); + if (text == nullptr || strlen(text) == 0) { + pinyinPreview_->SetVisible(false); + HideHanziPageList(); + return; + } + + // find pinyin hanzi, and display! + UpdateHanziOption(text); +} + +void UIInputMethod::HidePinyinPreview() +{ + if (pinyinPreview_ != nullptr) { + pinyinPreview_->SetText(""); + pinyinPreview_->SetVisible(false); + } +} + +void UIInputMethod::ShowPinyinPreview() +{ + if (pinyinPreview_ != nullptr) { + pinyinPreview_->SetVisible(true); + } +} + +void UIInputMethod::ClearHanziCandidate() +{ + if (hanziAdapter_ != nullptr) { + delete hanziAdapter_; + hanziAdapter_ = nullptr; + } + if (hanziList_ != nullptr) { + delete hanziList_; + hanziList_ = nullptr; + } + memset_s(hanziMatched_, sizeof(hanziMatched_), 0, + sizeof(hanziMatched_)); +} + +void UIInputMethod::SetupHanziCandidate() +{ + if (inputMethod_ == nullptr) { + return; + } + ClearHanziCandidate(); + int16_t x = 28; + int16_t y = 200; + int16_t w = 398; + int16_t h = 50; + int8_t gap = 2; + int16_t buttonGap = (w - gap) / DEFAULT_NUMPERPAGE; + int16_t btnWidth = buttonGap - gap; + int16_t btnHeight = h - gap * 2; // 2: half + + hanziAdapter_ = new HanziAdapter; + // set height, set width, set data + hanziAdapter_->SetWidthAndHeight(w, h); + hanziAdapter_->SetClickListener(this); + + hanziList_ = new UIList(UIList::HORIZONTAL); + // set position, font, adapter, listener, and add to inputmethod + hanziList_->SetPosition(x, y, w, h); + hanziList_->SetStyle(STYLE_BACKGROUND_COLOR, 0xFFE8EAEE); + hanziList_->SetIntercept(false); + hanziList_->SetAdapter(hanziAdapter_); + hanziList_->SetScrollStateListener(this); + hanziList_->SetVisible(false); + inputMethod_->Add(hanziList_); +} + +void UIInputMethod::DealFunctionKey(UI_KEYCODE keyCode) { if (curSoftKeyboard_ != nullptr) { switch (keyCode) { @@ -182,7 +356,7 @@ void UIInputMethod::DealFunctionKey(UI_KEYCODE &keyCode) } } -void UIInputMethod::DealNormalKey(UI_KEYCODE &keyCode) +void UIInputMethod::DealNormalKey(UI_KEYCODE keyCode) { if (previeBox_ != nullptr) { UITextPreviewBox::TextPreviewBoxMode mode = previeBox_->GetEditMode(); @@ -200,7 +374,7 @@ void UIInputMethod::DealNormalKey(UI_KEYCODE &keyCode) } } -void UIInputMethod::ChangSoftKeyboard(UI_KEYCODE &keyCode) +void UIInputMethod::ChangSoftKeyboard(UI_KEYCODE keyCode) { switch (keyCode) { case UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_EN: @@ -215,6 +389,9 @@ void UIInputMethod::ChangSoftKeyboard(UI_KEYCODE &keyCode) case UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_SYMBOL: curKeyboardIndex_ = static_cast(SYS_IMT_TYPE::SYS_IME_SYMBOL); break; + case UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_PINYIN: + curKeyboardIndex_ = static_cast(SYS_IMT_TYPE::SYS_IME_PINYIN); + break; default: curKeyboardIndex_++; break; @@ -234,7 +411,7 @@ void UIInputMethod::ChangSoftKeyboard(UI_KEYCODE &keyCode) inputMethod_->Invalidate(); } -void UIInputMethod::InsertChar(UI_KEYCODE& keyCode) +void UIInputMethod::InsertChar(UI_KEYCODE keyCode) { if (previeBox_ != nullptr) { previeBox_->InsertChar(keyCode); @@ -242,6 +419,60 @@ void UIInputMethod::InsertChar(UI_KEYCODE& keyCode) return; } +void UIInputMethod::InsertPinyin(UI_KEYCODE pinyin) +{ + if (pinyinPreview_ == nullptr) { + return; + } + char ch = static_cast(pinyin); + std::string originPinyin; + const char *str = pinyinPreview_->GetText(); + if (str != nullptr && strlen(str) > 0) { + originPinyin = str; + } + originPinyin = originPinyin + ch; + pinyinPreview_->SetText(originPinyin.c_str()); + pinyinPreview_->SetVisible(true); + const char *text = pinyinPreview_->GetText(); + if (text == nullptr) { + return; + } + + // find pinyin hanzi, and display! + UpdateHanziOption(text); +} + +void UIInputMethod::UpdateHanziOption(const std::string &pinyin) +{ + if (pinyin.empty() || pinyinTable_ == nullptr) { + return; + } + + PinyinState res = pinyinTable_->FindHanzi(pinyin); + if (res != PinyinState::SUCCESS) { + GRAPHIC_LOGE("%s", pinyinTable_->DebugInfo(res).c_str()); + return; + } + + uint8_t matchnum = pinyinTable_->GetMatchHanziNum(); + if (matchnum == 0) { + return; + } + + memset_s(hanziMatched_, sizeof(hanziMatched_), + 0, sizeof(hanziMatched_)); + res = pinyinTable_->GetAllHanzi(hanziMatched_, + sizeof(hanziMatched_) / sizeof(hanziMatched_[0])); + if (res != PinyinState::SUCCESS) { + GRAPHIC_LOGE("%s", pinyinTable_->DebugInfo(res).c_str()); + return; + } + hanziAdapter_->SetData(hanziMatched_, matchnum); + hanziList_->ScrollTo(0); + hanziList_->SetVisible(true); + hanziList_->RefreshList(); +} + void UIInputMethod::InitInputMethod() { if (isInit_) { @@ -261,6 +492,8 @@ void UIInputMethod::InitInputMethod() SetupOptionBox(); SetupSoftKeyboard(); SetupTextPreviewBox(); + SetupHanziCandidate(); + SetupPinyinPreviewBox(); isInit_ = true; } @@ -301,5 +534,117 @@ void UIInputMethod::SetupTextPreviewBox() inputMethod_->Add(previeBox_); } } + +void UIInputMethod::SetupPinyinPreviewBox() +{ + if (pinyinPreview_ != nullptr) { + return; + } + pinyinPreview_ = new UILabel; + int16_t x = 28; + int16_t y = 160; + int16_t w = 77; + int16_t h = 30; + pinyinPreview_->SetPosition(x, y, w, h); + pinyinPreview_->SetStyle(STYLE_BACKGROUND_COLOR, 0xFFE8EAEE); + pinyinPreview_->SetStyle(STYLE_BORDER_RADIUS, 10); // 10: border radius + pinyinPreview_->SetText(""); + pinyinPreview_->SetTouchable(false); + pinyinPreview_->SetTextColor(Color::Black()); + pinyinPreview_->SetViewId("input_pinyin_text_view_id"); + pinyinPreview_->SetVisible(false); + + inputMethod_->Add(pinyinPreview_); +} + +void UIInputMethod::SetupPinyinTable() +{ + if (pinyinTable_ != nullptr) { + return; + } + pinyinTable_ = new PinyinCandidate(); + if (pinyinTable_ == nullptr) { + return; + } + +#ifndef WIN32 + PinyinState state = pinyinTable_->Init("/user/res/pymb.bin"); +#else + PinyinState state = pinyinTable_->Init(RES_PATH"/pymb.bin"); +#endif + if (state != PinyinState::SUCCESS) { + ClearPinyinTable(); + } +} + +void UIInputMethod::ClearPinyinTable() +{ + if (pinyinTable_ != nullptr) { + delete pinyinTable_; + pinyinTable_ = nullptr; + } +} + +UIView* UIInputMethod::HanziAdapter::GetView(UIView* inView, int16_t index) +{ + if (data_ == nullptr || size_ == 0) { + return nullptr; + } + if (index < 0 || index >= static_cast(size_)) { + return nullptr; + } + + UILabelButton* item = dynamic_cast(inView); + if (item == nullptr) { + int16_t gap = 2; + item = new UILabelButton; + item->SetPosition(0, 0); + item->Resize(GetItemWidthWithMargin(index) - gap, GetItemHeightWithMargin(index)); + } + item->SetOnClickListener(clickListener_); + item->SetText(reinterpret_cast(data_[index])); + item->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40: means font size + item->SetViewIndex(index); + item->SetAlign(TEXT_ALIGNMENT_CENTER); + item->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::RELEASED); + item->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::PRESSED); + item->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::INACTIVE); + item->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::RELEASED); + item->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); + item->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::INACTIVE); + item->SetTextColor(Color::Black()); + return item; +} + +uint16_t UIInputMethod::HanziAdapter::GetCount() +{ + return size_; +} + +int16_t UIInputMethod::HanziAdapter::GetItemWidthWithMargin(int16_t index) +{ + return width_ * 1.0 / UIInputMethod::DEFAULT_NUMPERPAGE; +} + +int16_t UIInputMethod::HanziAdapter::GetItemHeightWithMargin(int16_t index) +{ + return height_; +} + +bool UIInputMethod::HanziAdapter::SetWidthAndHeight(int16_t w, int16_t h) +{ + if (w > 0 && h > 0) { + width_ = w; + height_ = h; + return true; + } + return false; +} + +void UIInputMethod::HanziAdapter::SetData(int8_t hanzi[][PinyinCandidate::IME_HZLENTH], uint8_t len) +{ + data_ = hanzi; + size_ = len; +} } // namespace OHOS #endif // ENABLE_SOFT_KEYBOARD diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_keyboard_button.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_keyboard_button.cpp index e22d60f16..f3175a649 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_keyboard_button.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_keyboard_button.cpp @@ -15,6 +15,7 @@ #include "input_method/ui_keyboard_button.h" #include "input_method/ui_input_method.h" +#include "input_method/ui_soft_keyboard.h" #if ENABLE_SOFT_KEYBOARD namespace OHOS { @@ -66,6 +67,9 @@ void UIKeyboardButton::GetFuncKeyText(UI_KEYCODE key, std::string &tmpText) case UI_KEYCODE::UI_KEY_ENTER: tmpText += "Send"; break; + case UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_PINYIN: + tmpText += "中"; + break; case UI_KEYCODE::UI_KEY_DEL: tmpText += "Del"; break; @@ -91,10 +95,6 @@ void UIKeyboardButton::GetFuncKeyText(UI_KEYCODE key, std::string &tmpText) void UIKeyboardButton::SetButtonText() { - if (keyCode_ == nullptr) { - return; - } - std::string tmpText; for (uint8_t i = 0; i < keyNum_; i++) { UI_KEYCODE key = keyCode_[i]; @@ -118,6 +118,11 @@ void UIKeyboardButton::Clear() bool UIKeyboardButton::OnClickEvent(const ClickEvent& event) { if (keyNum_ == 1) { + UIPinyinSoftKeyboard *parent = dynamic_cast(GetParent()); + if (parent != nullptr) { + UIInputMethod::GetInstance()->InputPinyin(keyCode_[0]); + return true; + } UIInputMethod::GetInstance()->Input(keyCode_[0]); } return true; @@ -126,6 +131,10 @@ bool UIKeyboardButton::OnClickEvent(const ClickEvent& event) bool UIKeyboardButton::OnPressEvent(const PressEvent& event) { if (keyNum_ > 1) { + UIPinyinSoftKeyboard *parent = dynamic_cast(GetParent()); + if (parent != nullptr) { + UIInputMethod::GetInstance()->HideHanziPageList(); + } UIInputMethod::GetInstance()->ShowOptionBox(this, keyCode_, keyNum_); } return true; @@ -134,7 +143,13 @@ bool UIKeyboardButton::OnPressEvent(const PressEvent& event) bool UIKeyboardButton::OnReleaseEvent(const ReleaseEvent& event) { if (keyNum_ > 1) { + UIPinyinSoftKeyboard *parent = dynamic_cast(GetParent()); uint8_t keyIndex = UIInputMethod::GetInstance()->HideOptionBox(); + if (parent != nullptr) { + UIInputMethod::GetInstance()->ShowHanziPageList(); + UIInputMethod::GetInstance()->InputPinyin(keyCode_[keyIndex]); + return true; + } UIInputMethod::GetInstance()->Input(keyCode_[keyIndex]); } return true; @@ -143,7 +158,13 @@ bool UIKeyboardButton::OnReleaseEvent(const ReleaseEvent& event) bool UIKeyboardButton::OnDragEndEvent(const DragEvent& event) { if (keyNum_ > 1) { + UIPinyinSoftKeyboard *parent = dynamic_cast(GetParent()); uint8_t keyIndex = UIInputMethod::GetInstance()->HideOptionBox(); + if (parent != nullptr) { + UIInputMethod::GetInstance()->ShowHanziPageList(); + UIInputMethod::GetInstance()->InputPinyin(keyCode_[keyIndex]); + return true; + } UIInputMethod::GetInstance()->Input(keyCode_[keyIndex]); } return true; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_ext.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_ext.cpp index 1eaaacbc2..628788d7d 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_ext.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_ext.cpp @@ -35,12 +35,12 @@ void UIListExt::ReMeasure() if (direction_ == VERTICAL) { int offset = (y + view->GetHeight() / 2 - midY); int temp = EasingEquation::SineEaseIn(0, scaleFactor_, abs(offset), scaleFactor_); - float scale = 1.0 - ((float)temp / scaleFactor_); + float scale = 1.0 - (static_cast(temp) / scaleFactor_); view->Scale(Vector2(scale, scale), view->GetScaleCenter()); } else { int offset = (x + view->GetWidth() / 2 - midX); int temp = EasingEquation::SineEaseIn(0, scaleFactor_, abs(offset), scaleFactor_); - float scale = 1.0 - ((float)temp / scaleFactor_); + float scale = 1.0 - (static_cast(temp) / scaleFactor_); view->Scale(Vector2(scale, scale), view->GetScaleCenter()); } view = static_cast(view->GetNextSibling()); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_lite_surface_view.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_lite_surface_view.cpp index 3484e4ad2..fcee55372 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_lite_surface_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_lite_surface_view.cpp @@ -26,6 +26,11 @@ #include "common/low_power_manager.h" #include "components/ui_lite_surface_view.h" + +#ifndef UIKIT_SKIP_LINE +#define UIKIT_SKIP_LINE 1 +#endif + namespace OHOS { static constexpr int16_t YUV_WIDTH_ALIGNMENT = 128; UILiteSurfaceView::UILiteSurfaceView() : isLayerInit_(false), flushCount_(0) @@ -186,31 +191,26 @@ void UILiteSurfaceView::InitLayer() #ifdef VERSION_IOT bool UILiteSurfaceView::GetBitmap(ImageInfo& bitmap) { - if (!isFirstFrameCome_) { + if (lastFlushedBuffer_ == nullptr) { UIView::GetBitmap(bitmap); } else { - SurfaceBuffer* buff; - if (lastFlushedBuffer_ != nullptr) { - buff = lastFlushedBuffer_; - } else { - buff = surface_->GetBackBuf(); - } - - if (buff == nullptr) { - GRAPHIC_LOGE("buff is null!\n"); - return false; - } CscYuvBuf yuv = {0}; - yuv.yAddr = reinterpret_cast(buff->addr); - yuv.uvAddr = static_cast(yuv.yAddr) + ALIGN_BYTE(buff->width, YUV_WIDTH_ALIGNMENT) * buff->height; - yuv.width = buff->width; - yuv.height = buff->height; - yuv.yStride = ALIGN_BYTE(buff->width, YUV_WIDTH_ALIGNMENT); - yuv.uvStride = ALIGN_BYTE(buff->width, YUV_WIDTH_ALIGNMENT); + yuv.yAddr = reinterpret_cast(lastFlushedBuffer_->addr); + yuv.uvAddr = static_cast(yuv.yAddr) + ALIGN_BYTE(lastFlushedBuffer_->width, YUV_WIDTH_ALIGNMENT) * + lastFlushedBuffer_->height; + yuv.width = lastFlushedBuffer_->width; + yuv.height = lastFlushedBuffer_->height; + yuv.yStride = ALIGN_BYTE(lastFlushedBuffer_->width, YUV_WIDTH_ALIGNMENT); + yuv.uvStride = ALIGN_BYTE(lastFlushedBuffer_->width, YUV_WIDTH_ALIGNMENT); CscRgbBuf rgb = {0}; - rgb.width = buff->width; - rgb.height = buff->height; +#if UIKIT_SKIP_LINE + rgb.width = lastFlushedBuffer_->width / 2; // 2: half + rgb.height = lastFlushedBuffer_->height / 2; // 2: half +#else + rgb.width = lastFlushedBuffer_->width; + rgb.height = lastFlushedBuffer_->height; +#endif rgb.stride = ALIGN_BYTE(rgb.width, BYTE_ALIGNMENT) * 3; // 3: 3 bytes for rgb888 bitmap.header.colorMode = RGB888; @@ -221,7 +221,11 @@ bool UILiteSurfaceView::GetBitmap(ImageInfo& bitmap) bitmap.header.reserved = 0; rgb.addr = reinterpret_cast(ImageCacheMalloc(bitmap)); if (rgb.addr != nullptr) { +#if UIKIT_SKIP_LINE + CscConvertYuvToRgbWithSkipLP(&rgb, &yuv); +#else CscConvertYuvToRgb(&rgb, &yuv); +#endif } else { GRAPHIC_LOGE("UILiteSurfaceView::GetBitmap img alloc failed! size: 0x%x\n", bitmap.dataSize); } @@ -245,6 +249,9 @@ void UILiteSurfaceView::BlitBitmapToFb(BufferInfo& gfxDstBuffer, const Rect& inv Rect rect = GetRect(); rect.Intersect(rect, invalidatedArea); BlendOption blendOption; +#if UIKIT_SKIP_LINE + blendOption.transMap.Scale(Vector2{2.0, 2.0}, Vector2{0, 0}); // 2.0: scale 2 +#endif blendOption.opacity = OPA_OPAQUE; blendOption.mode = BLEND_SRC_OVER; BaseGfxEngine::GetInstance()->Blit(gfxDstBuffer, {0, 0}, src, rect, blendOption); @@ -278,7 +285,7 @@ void UILiteSurfaceView::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidated return; } - if (!isFirstFrameCome_ && preView_ != nullptr) { + if ((isStopped_ || lastFlushedBuffer_ == nullptr) && preView_ != nullptr) { const ImageInfo* info = preView_->GetImageInfo(); Rect coords(GetX(), GetY(), GetX() + info->header.width - 1, GetY() + info->header.height - 1); preView_->DrawImage(gfxDstBuffer, coords, invalidatedArea, *style_, opaScale_); @@ -286,12 +293,13 @@ void UILiteSurfaceView::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidated } #ifdef VERSION_IOT - if (isFirstFrameCome_ && RootView::GetInstance()->GetSnapshotFlag()) { + if (lastFlushedBuffer_ != nullptr && RootView::GetInstance()->GetSnapshotFlag()) { ImageInfo bitmap; - GetBitmap(bitmap); - BlitBitmapToFb(gfxDstBuffer, invalidatedArea, bitmap); - ImageCacheFree(bitmap); - return; + if (GetBitmap(bitmap)) { + BlitBitmapToFb(gfxDstBuffer, invalidatedArea, bitmap); + ImageCacheFree(bitmap); + return; + } } #endif @@ -317,7 +325,6 @@ void UILiteSurfaceView::OnBufferAvailable() bool isLastFrame = (back->format == PIXEL_FMT_BUTT); if (isLastFrame) { back->format = PIXEL_FMT_YCBCR_420_SP; - isFirstFrameCome_ = false; flushCount_ = 0; } else { ++flushCount_; @@ -325,10 +332,10 @@ void UILiteSurfaceView::OnBufferAvailable() lock_.Unlock(); if (isLastFrame) { + isStopped_ = true; GraphicService::GetInstance()->PostGraphicEvent( [&] { if (surface_ != nullptr) { - isStopped_ = true; DisplayDev::GetInstance()->SetLayerColorKey(LAYER_0, false, 0); LiteMGfxEngine::GetInstance()->ClearHardwareLayer(); LiteMGfxEngine::GetInstance()->EnableAsyncMode(true); @@ -337,15 +344,14 @@ void UILiteSurfaceView::OnBufferAvailable() lastFlushedBuffer_ = nullptr; } }); - } else if (!isFirstFrameCome_) { + } else if (isStopped_) { + isStopped_ = false; GraphicService::GetInstance()->PostGraphicEvent( [&] { LiteMGfxEngine::GetInstance()->EnableAsyncMode(false); LiteMGfxEngine::GetInstance()->AddHardwareLayer(this); DisplayDev::GetInstance()->SetLayerColorKey(LAYER_0, true, colorKey_.full); InitLayer(); - isStopped_ = false; - isFirstFrameCome_ = true; }); } @@ -364,4 +370,13 @@ void UILiteSurfaceView::SetPreview(ImageInfo* info) preView_->SetSrc(info); } } + +void UILiteSurfaceView::DumpImgInfo() +{ + if (preView_ != nullptr) { + printf("view[%p]: viewType = %d\n", this, GetViewType()); + const ImageInfo* info = preView_->GetImageInfo(); + PrintImgInfo(info); + } +} } diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_menu_item.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_menu_item.cpp index d4c799a8b..37a8fc7f3 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_menu_item.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_menu_item.cpp @@ -43,20 +43,19 @@ UIMenuItem::~UIMenuItem() void UIMenuItem::SetScaleCenter() { - Rect rect = GetOrigRect(); if (transAlignMode_ == ScaleAlignMode::ALIGN_TEXT_LEFT) { - textScaleCenter_ = Vector2{0.0, textRect_.GetHeight() / 2}; - imgScaleCenter_ = Vector2{textRect_.GetLeft() - imgRect_.GetLeft(), textRect_.GetHeight() / 2}; - itemScaleCenter_ = Vector2{textRect_.GetLeft(), textRect_.GetHeight() / 2}; + textScaleCenter_ = Vector2{0.0, textRect_.GetHeight() / 2.0f}; + imgScaleCenter_ = Vector2{textRect_.GetLeft() - imgRect_.GetLeft(), textRect_.GetHeight() / 2.0f}; + itemScaleCenter_ = Vector2{textRect_.GetLeft(), textRect_.GetHeight() / 2.0f}; } else if (transAlignMode_ == ScaleAlignMode::ALIGN_IMAGE_LEFT) { - textScaleCenter_ = Vector2{imgRect_.GetLeft() - textRect_.GetLeft(), imgRect_.GetHeight() / 2}; - imgScaleCenter_ = Vector2{0.0, imgRect_.GetHeight() / 2}; - itemScaleCenter_ = Vector2{imgRect_.GetLeft(), imgRect_.GetHeight() / 2}; + textScaleCenter_ = Vector2{imgRect_.GetLeft() - textRect_.GetLeft(), imgRect_.GetHeight() / 2.0f}; + imgScaleCenter_ = Vector2{0.0, imgRect_.GetHeight() / 2.0f}; + itemScaleCenter_ = Vector2{imgRect_.GetLeft(), imgRect_.GetHeight() / 2.0f}; } else if (transAlignMode_ == ScaleAlignMode::ALIGN_ITEM_CENTER) { Rect rect = GetOrigRect(); - itemScaleCenter_ = Vector2{rect.GetX() + rect.GetWidth() / 2, rect.GetHeight() / 2}; - textScaleCenter_ = Vector2{itemScaleCenter_.x_ - textRect_.GetLeft(), rect.GetHeight() / 2}; - imgScaleCenter_ = Vector2{itemScaleCenter_.x_ - imgRect_.GetLeft(), rect.GetHeight() / 2}; + itemScaleCenter_ = Vector2{rect.GetX() + rect.GetWidth() / 2.0f, rect.GetHeight() / 2.0f}; + textScaleCenter_ = Vector2{itemScaleCenter_.x_ - textRect_.GetLeft(), rect.GetHeight() / 2.0f}; + imgScaleCenter_ = Vector2{itemScaleCenter_.x_ - imgRect_.GetLeft(), rect.GetHeight() / 2.0f}; } } @@ -99,7 +98,7 @@ void UIMenuItem::ReMeasure() UpdateTransformMap(); } -void UIMenuItem::SetImageSrc(const char* ImgSrc) +void UIMenuItem::SetImageSrc(const char* imgSrc) { if (image_ == nullptr) { image_ = new UIImageView(); @@ -110,12 +109,12 @@ void UIMenuItem::SetImageSrc(const char* ImgSrc) image_->SetResizeMode(resizeMode_); image_->SetAutoEnable(false); } - image_->SetSrc(ImgSrc); + image_->SetSrc(imgSrc); UpdateRect(); SetScaleCenter(); } -void UIMenuItem::SetImageSrc(const ImageInfo* ImgSrc) +void UIMenuItem::SetImageSrc(const ImageInfo* imgSrc) { if (image_ == nullptr) { image_ = new UIImageView(); @@ -126,7 +125,7 @@ void UIMenuItem::SetImageSrc(const ImageInfo* ImgSrc) image_->SetResizeMode(resizeMode_); image_->SetAutoEnable(false); } - image_->SetSrc(ImgSrc); + image_->SetSrc(imgSrc); UpdateRect(); SetScaleCenter(); } @@ -136,7 +135,7 @@ void UIMenuItem::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetRect(), invalidatedArea, *style_, opaScale_); if (text_ != nullptr) { Rect rect; - rect.Join(invalidatedArea, textRect_); + rect.Intersect(invalidatedArea, textRect_); if (rect.GetLeft() < 0) { rect.SetLeft(0); } @@ -153,4 +152,15 @@ void UIMenuItem::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) image_->OnDraw(gfxDstBuffer, invalidatedArea); } } + +void UIMenuItem::DumpImgInfo() +{ + if (image_ == nullptr) { + return; + } + printf("view[%p]: viewType = %d\n", this, GetViewType()); + const ImageInfo* info = image_->GetImageInfo(); + PrintImgInfo(info); +} + } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_pinyin_candidate.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_pinyin_candidate.cpp new file mode 100644 index 000000000..59d9a30e3 --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_pinyin_candidate.cpp @@ -0,0 +1,364 @@ +/* + * Copyright (c) 2022 CompanyNameMagicTag. + * 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 +#include +#include "common/graphic_utils.h" +#include "input_method/ui_pinyin_candidate.h" + +#if ENABLE_SOFT_KEYBOARD +namespace OHOS { + +PinyinCandidate::PinyinCandidate() +{ + memset_s(m_pyTabBuf, sizeof(m_pyTabBuf), 0, sizeof(m_pyTabBuf)); + memset_s(m_hzTabBuf, sizeof(m_hzTabBuf), 0, sizeof(m_hzTabBuf)); +} + +PinyinCandidate::~PinyinCandidate() +{ +} + +PinyinCandidate::PinyinState PinyinCandidate::InitPinyinTablePath(const std::string &path) +{ + size_t len = path.length(); + char *tablePath = new char[len + 1]; + defer { + delete []tablePath; + }; + if (tablePath == nullptr) { + GRAPHIC_LOGE("the length of path is too long."); + return PinyinState::MEM_ALLOC_ERROR; + } + int32_t ret = snprintf_s(tablePath, len + 1, len, "%s", path.c_str()); + if (ret == -1) { + GRAPHIC_LOGE("Secure fuction issue."); + return PinyinState::MEM_COPY_ERROR; + } + char truePath[PATH_MAX + 1] = {0x00}; +#ifndef WIN32 + if ((path.length() == 0) || (realpath(tablePath, truePath) == nullptr)) { + GRAPHIC_LOGE("The path of pin yin table is invalid."); + return PinyinState::INVALID_PATH; + } +#else + memcpy_s(truePath, sizeof(truePath), tablePath, len + 1); +#endif + m_pinyinTablePath = truePath; + return PinyinState::SUCCESS; +} + +int32_t PinyinCandidate::SetLv2NumPerPage(uint8_t num) +{ + if ((num < 1) || (num > 10)) { // 10是汉字候选码的个数 + return -1; + } else { + m_lv2NumPerPage = num; + return 0; + } +} + +PinyinCandidate::PinyinState PinyinCandidate::Init(const std::string &path) +{ + PinyinState pathState = InitPinyinTablePath(path); + if (pathState != PinyinState::SUCCESS) { + return pathState; + } + InitEx(); + return PinyinState::SUCCESS; +} + +void PinyinCandidate::InitEx(void) +{ + int32_t ret; + size_t len = m_pinyinTablePath.length(); + char *table = new char[len + 1]; + defer { + delete []table; + }; + if (table == nullptr) { + GRAPHIC_LOGE("Malloc mem fails."); + return; + } + + ret = snprintf_s(table, len + 1, len, "%s", m_pinyinTablePath.c_str()); + if (ret == -1) { + GRAPHIC_LOGE("Secure fuction issue."); + return; + } + + ret = LoadCodeTable((const int8_t *)table); + if (ret != 0) { + GRAPHIC_LOGE("LoadCodeTable failed!"); + } +} + +std::string PinyinCandidate::DebugInfo(PinyinCandidate::PinyinState state) const +{ + static const struct { + PinyinState state; + std::string info; + } infoTable[] = { + {PinyinState::SUCCESS, "SUCCESS"}, + {PinyinState::INVALID_PINYIN, "INVALID_PINYIN"}, + {PinyinState::INVALID_PATH, "INVALID_PATH"}, + {PinyinState::MEM_NOT_ENOUGH, "MEM_NOT_ENOUGH"}, + {PinyinState::MEM_SET_ERROR, "MEM_SET_ERROR"}, + {PinyinState::MEM_COPY_ERROR, "MEM_COPY_ERROR"}, + {PinyinState::MEM_ALLOC_ERROR, "MEM_ALLOC_ERROR"}, + {PinyinState::INVALID_PAGE_INDEX, "INVALID_PAGE_INDEX"}, + }; + for (size_t i = 0; i < sizeof(infoTable) / sizeof(infoTable[0]); ++i) { + if (infoTable[i].state == state) { + return infoTable[i].info; + } + } + return "not defined!"; +} + +PinyinCandidate::PinyinState PinyinCandidate::FindHanzi(const std::string &sourceStr) +{ + if (sourceStr.length() > IME_PYMAXLENTH) { + return PinyinState::INVALID_PINYIN; + } + + bool candidateFlag = false; + + hanziStatus_.m_currentHzPage = 0; + hanziStatus_.m_currentHzIndex = 0; + hanziStatus_.m_matchHzNumber = 0; + pinyinStatus_.m_currentPyIndex = sourceStr[0] - 'a'; + + if (pinyinStatus_.m_currentPyIndex >= MAXCHARNUM) { + return PinyinState::INVALID_PINYIN; + } + + uint8_t index; + for (index = 0; index < MAXSAMEPREFIXPY; index++) { + if (strncmp(sourceStr.c_str(), + reinterpret_cast(m_pyTabBuf[pinyinStatus_.m_currentPyIndex][index].pinyin), + sourceStr.length()) == 0) { + candidateFlag = true; + break; + } + } + + if (candidateFlag == false) { + GRAPHIC_LOGE("查找拼音索引出错!!\n"); + return PinyinState::INVALID_PINYIN; + } + + hanziStatus_.m_currentHzIndex = m_pyTabBuf[pinyinStatus_.m_currentPyIndex][index].hzIndex; + hanziStatus_.m_matchHzNumber = m_pyTabBuf[pinyinStatus_.m_currentPyIndex][index].hzNum; + if (m_lv2NumPerPage != 0) { + hanziStatus_.m_matchHZPageNumber = + static_cast(ceil(1.0 * hanziStatus_.m_matchHzNumber / m_lv2NumPerPage)); + } + + return PinyinState::SUCCESS; +} + +PinyinCandidate::PinyinState PinyinCandidate::GetHanziPage( + uint8_t pageNumber, int8_t candidate[][IME_HZLENTH], uint8_t len) +{ + if (len < m_lv2NumPerPage) { + /* 存放结果的字符串长度小于要求长度 */ + return PinyinState::MEM_NOT_ENOUGH; + } + + if (pageNumber >= GetHanziPagesNum()) { + return PinyinState::INVALID_PAGE_INDEX; + } + + for (uint8_t i = 0; i < m_lv2NumPerPage; i++) { + uint16_t curIndex = hanziStatus_.m_currentHzIndex + (pageNumber * m_lv2NumPerPage) + i; + if (curIndex >= (hanziStatus_.m_currentHzIndex + hanziStatus_.m_matchHzNumber)) { + break; + } + + if (curIndex >= MAXHZNUM) { + break; + } + + candidate[i][0] = + (int8_t)(m_hzTabBuf[curIndex] + .hz >> + 16); // Shift right by 16 bytes and get the storage bitin the encoding format + candidate[i][1] = + (int8_t)(m_hzTabBuf[curIndex] + .hz >> + 8); // Shift right by 8 bytes and get the storage bit in the encoding format + candidate[i][2] = // 2 is the index of the Array + (int8_t)(m_hzTabBuf[curIndex] + .hz); + } + return PinyinState::SUCCESS; +} + +PinyinCandidate::PinyinState PinyinCandidate::GetFwdHanziPage(int8_t candidate[][IME_HZLENTH], uint8_t len) +{ + if (hanziStatus_.m_currentHzPage > 0) { + --hanziStatus_.m_currentHzPage; + return GetHanziPage(hanziStatus_.m_currentHzPage, candidate, len); + } + return PinyinState::INVALID_PAGE_INDEX; +} + +PinyinCandidate::PinyinState PinyinCandidate::GetCurHanziPage(int8_t candidate[][IME_HZLENTH], uint8_t len) +{ + return GetHanziPage(hanziStatus_.m_currentHzPage, candidate, len); +} + +PinyinCandidate::PinyinState PinyinCandidate::GetNxtHanziPage(int8_t candidate[][IME_HZLENTH], uint8_t len) +{ + if (hanziStatus_.m_currentHzPage + 1 < GetHanziPagesNum()) { + ++hanziStatus_.m_currentHzPage; + return GetHanziPage(hanziStatus_.m_currentHzPage, candidate, len); + } + return PinyinState::INVALID_PAGE_INDEX; +} + +PinyinCandidate::PinyinState PinyinCandidate::GetAllHanzi(int8_t candidate[][IME_HZLENTH], uint8_t len) +{ + if (len < hanziStatus_.m_matchHzNumber) { + return PinyinState::MEM_NOT_ENOUGH; + } + + for (uint16_t i = hanziStatus_.m_currentHzIndex; i < hanziStatus_.m_currentHzIndex + hanziStatus_.m_matchHzNumber; + ++i) { + if (i >= MAXHZNUM) { + break; + } + candidate[i - hanziStatus_.m_currentHzIndex][0] = + static_cast(m_hzTabBuf[i] + .hz >> + 16); // Shift right by 16 bytes and get the storage bitin the encoding format + candidate[i - hanziStatus_.m_currentHzIndex][1] = + static_cast(m_hzTabBuf[i] + .hz >> + 8); // Shift right by 8 bytes and get the storage bit in the encoding format + candidate[i - hanziStatus_.m_currentHzIndex][2] = // 2 is the index of the Array + static_cast(m_hzTabBuf[i] + .hz); + } + return PinyinState::SUCCESS; +} + +int32_t PinyinCandidate::LoadCodeTable(const int8_t *filePath) +{ + int32_t ret; + FILE *tableFile = nullptr; + uint32_t bufLen; + char resolvedPath[PATH_MAX + 1] = {0}; + +#ifndef WIN32 + if (realpath((const char *)filePath, resolvedPath) == nullptr) { + return -1; + } +#else + memcpy_s(resolvedPath, sizeof(resolvedPath), filePath, strlen(reinterpret_cast(filePath)) + 1); +#endif + + tableFile = fopen((const char *)resolvedPath, "rb"); + if (tableFile == nullptr) { + return -1; + } + + ret = memset_s(m_hzTabBuf, sizeof(m_hzTabBuf), 0, sizeof(m_hzTabBuf)); + if (ret != EOK) { + (void)fclose(tableFile); + return -1; + } + + ret = memset_s(m_pyTabBuf, sizeof(m_pyTabBuf), 0, sizeof(m_pyTabBuf)); + if (ret != EOK) { + (void)fclose(tableFile); + return -1; + } + + bufLen = fread(m_hzTabBuf, 1, sizeof(m_hzTabBuf), tableFile); + if (bufLen != sizeof(m_hzTabBuf)) { + (void)fclose(tableFile); + return -1; + } + + if (fread(m_pyTabBuf, 1, sizeof(m_pyTabBuf), tableFile) != sizeof(m_pyTabBuf)) { + (void)fclose(tableFile); + return -1; + } + + (void)fclose(tableFile); + + return 0; +} + +int32_t PinyinCandidate::RecoverCodeTable(const int8_t *filePath, const int8_t *BackupPath) +{ + FILE *tableFile = nullptr; + FILE *backupFile = nullptr; + uint32_t fileSizeCounter = 0; + int32_t temp = 0; + char resolvedPath1[PATH_MAX + 1] = {0}; + char resolvedPath2[PATH_MAX + 1] = {0}; + +#ifndef WIN32 + if (realpath((const char *)filePath, resolvedPath1) == nullptr) { + return -1; + } + + if (realpath((const char *)BackupPath, resolvedPath2) == nullptr) { + return -1; + } +#endif + + /* 只写方式打开 */ + tableFile = fopen(reinterpret_cast(resolvedPath1), "w"); + if (tableFile == nullptr) { + return -1; + } + + /* 只读方式打开 */ + backupFile = fopen(reinterpret_cast(resolvedPath2), "r"); + if (backupFile == nullptr) { + (void)fclose(tableFile); + return -1; + } + + while (1) { + temp = fgetc(backupFile); + if ((temp == EOF) || (feof(backupFile) != 0)) { + break; + } + + fputc((int8_t)temp, tableFile); + fileSizeCounter++; + if (fileSizeCounter > (sizeof(m_hzTabBuf) + sizeof(m_pyTabBuf))) { + /* 防止出错造成死循环 */ + break; + } + } + + fclose(tableFile); + fclose(backupFile); + if (fileSizeCounter == (sizeof(m_hzTabBuf) + sizeof(m_pyTabBuf))) { + GRAPHIC_LOGD("Code table file recover successed!"); + return 0; + } else { + return -1; + } +} + +} // namespace OHOS +#endif // ENABLE_SOFT_KEYBOARD \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_soft_keyboard.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_soft_keyboard.cpp index e5e5f5754..d947fe105 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_soft_keyboard.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_soft_keyboard.cpp @@ -288,7 +288,8 @@ void UIEnglishSoftKeyboard::CreateKeyButtons() { std::vector keySet { {{COL_2_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_CAP, - UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_NUMBER, UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_SYMBOL}}, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_NUMBER, UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_SYMBOL, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_PINYIN}}, {{COL_3_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_a, UI_KEYCODE::UI_KEY_b, UI_KEYCODE::UI_KEY_c}}, {{COL_4_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_d, UI_KEYCODE::UI_KEY_e, UI_KEYCODE::UI_KEY_f}}, {{COL_2_X, ROW_2_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_g, UI_KEYCODE::UI_KEY_h, UI_KEYCODE::UI_KEY_i}}, @@ -318,7 +319,8 @@ void UICapitalSoftKeyboard::CreateKeyButtons() { std::vector keySet { {{COL_2_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_EN, - UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_NUMBER, UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_SYMBOL}}, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_NUMBER, UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_SYMBOL, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_PINYIN}}, {{COL_3_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_A, UI_KEYCODE::UI_KEY_B, UI_KEYCODE::UI_KEY_C}}, {{COL_4_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_D, UI_KEYCODE::UI_KEY_E, UI_KEYCODE::UI_KEY_F}}, {{COL_2_X, ROW_2_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_G, UI_KEYCODE::UI_KEY_H, UI_KEYCODE::UI_KEY_I}}, @@ -355,8 +357,9 @@ void UINumberSoftKeyboard::CreateKeyButtons() {{COL_3_X, ROW_2_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_0}}, {{COL_4_X, ROW_2_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_ASTERISK, UI_KEYCODE::UI_KEY_SLASH, UI_KEYCODE::UI_KEY_EQUAL}}, - {{COL_2_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_CAP}}, - {{COL_3_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_EN}}, + {{COL_2_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_CAP, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_EN}}, + {{COL_3_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_PINYIN}}, {{COL_4_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_SYMBOL}}, // FUNCTION_KEY {{COL_1_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_DEL}}, @@ -377,7 +380,8 @@ void UISymbolSoftKeyboard::CreateKeyButtons() { std::vector keySet { {{COL_2_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_CAP, - UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_EN, UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_NUMBER}}, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_EN, UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_PINYIN, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_NUMBER}}, {{COL_3_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_EXCLAM, UI_KEYCODE::UI_KEY_DOUBLEQUOTE, UI_KEYCODE::UI_KEY_NUMBERSIGN}}, {{COL_4_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_DOLLAR, UI_KEYCODE::UI_KEY_PERCENT, @@ -402,5 +406,37 @@ void UISymbolSoftKeyboard::CreateKeyButtons() SetupKeyButton(key); } } + +void UIPinyinSoftKeyboard::CreateKeyButtons() +{ + std::vector keySet { + {{COL_2_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_EN, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_CAP, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_NUMBER, + UI_KEYCODE::UI_KEY_SOFT_KEYBOARD_SYMBOL}}, + {{COL_3_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_a, UI_KEYCODE::UI_KEY_b, UI_KEYCODE::UI_KEY_c}}, + {{COL_4_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_d, UI_KEYCODE::UI_KEY_e, UI_KEYCODE::UI_KEY_f}}, + {{COL_2_X, ROW_2_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_g, UI_KEYCODE::UI_KEY_h, UI_KEYCODE::UI_KEY_i}}, + {{COL_3_X, ROW_2_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_j, UI_KEYCODE::UI_KEY_k, UI_KEYCODE::UI_KEY_l}}, + {{COL_4_X, ROW_2_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_m, UI_KEYCODE::UI_KEY_n, UI_KEYCODE::UI_KEY_o}}, + {{COL_2_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_p, UI_KEYCODE::UI_KEY_q, UI_KEYCODE::UI_KEY_r, + UI_KEYCODE::UI_KEY_s}}, + {{COL_3_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_t, UI_KEYCODE::UI_KEY_u, UI_KEYCODE::UI_KEY_v}}, + {{COL_4_X, ROW_3_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_w, UI_KEYCODE::UI_KEY_x, UI_KEYCODE::UI_KEY_y, + UI_KEYCODE::UI_KEY_z}}, + // FUNCTION_KEY + {{COL_1_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_DEL}}, + {{COL_5_X, ROW_1_Y, KEY_WIDTH, KEY_HEIGHT}, {UI_KEYCODE::UI_KEY_ENTER}}, + }; + for (auto key : keySet) { + SetupKeyButton(key); + } +} + +UIPinyinSoftKeyboard* UIPinyinSoftKeyboard::GetInstance() +{ + static UIPinyinSoftKeyboard pinyinSoftkeyboard; + return &pinyinSoftkeyboard; +} } // namespace OHOS #endif // ENABLE_SOFT_KEYBOARD diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_sweep_clock.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_sweep_clock.cpp index b4fb207ee..86515b8fa 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_sweep_clock.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_sweep_clock.cpp @@ -434,5 +434,37 @@ void UISweepClock::UpdateClock(bool clockInit) CalculateRedrawArea(rect, secondHand_, clockInit); } } + +void UISweepClock::DumpImgInfo() +{ + printf("view[%p]: viewType = %d\n", this, GetViewType()); + if ((hourHand_.drawtype_ == DrawType::DRAW_IMAGE) && (hourHand_.image_.GetSrcType() == IMG_SRC_VARIABLE)) { + const ImageInfo* info = hourHand_.image_.GetImageInfo(); + PrintImgInfo(info); + } + if ((minuteHand_.drawtype_ == DrawType::DRAW_IMAGE) && (minuteHand_.image_.GetSrcType() == IMG_SRC_VARIABLE)) { + const ImageInfo* info = minuteHand_.image_.GetImageInfo(); + PrintImgInfo(info); + } + if ((secondHand_.drawtype_ == DrawType::DRAW_IMAGE) && (secondHand_.image_.GetSrcType() == IMG_SRC_VARIABLE)) { + const ImageInfo* info = secondHand_.image_.GetImageInfo(); + PrintImgInfo(info); + } + + if ((hourHandCircle_.circleImg_.GetSrcType() == IMG_SRC_VARIABLE)) { + const ImageInfo* info = hourHandCircle_.circleImg_.GetImageInfo(); + PrintImgInfo(info); + } + + if ((minuteHandCircle_.circleImg_.GetSrcType() == IMG_SRC_VARIABLE)) { + const ImageInfo* info = minuteHandCircle_.circleImg_.GetImageInfo(); + PrintImgInfo(info); + } + + if ((secondHandCircle_.circleImg_.GetSrcType() == IMG_SRC_VARIABLE)) { + const ImageInfo* info = secondHandCircle_.circleImg_.GetImageInfo(); + PrintImgInfo(info); + } +} } #endif diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_text_preview_box.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_text_preview_box.cpp index bfca7ed25..51355dd80 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_text_preview_box.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_text_preview_box.cpp @@ -135,6 +135,8 @@ void UITextPreviewBox::GetLineInfo(LineInfo& lineInfo) if (text == nullptr) { return; } + std::string u8str(text); + std::wstring u16str; UIFont::GetInstance()->SetCurrentFontId(inputText_->GetFontId(), inputText_->GetFontSize()); lineInfo.lineHeight = GetStyleConst().GetStyle(STYLE_LINE_HEIGHT); if (lineInfo.lineHeight == 0) { @@ -147,8 +149,9 @@ void UITextPreviewBox::GetLineInfo(LineInfo& lineInfo) uint32_t begin = 0; while ((begin < textLen) && (text[begin] != '\0') && (lineNum < GetMaxLength())) { uint32_t count = inputText_->GetTextLine(begin, textLen, GetContentRect().GetWidth(), lineNum, 0); + u16str = Utf8ToUtf16(u8str.substr(begin, count)); begin += count; - lineInfo.charCountPerLine.push_back(count); + lineInfo.charCountPerLine.push_back(u16str.length()); lineNum++; } } @@ -184,18 +187,45 @@ void UITextPreviewBox::InitCursor() void UITextPreviewBox::InsertChar(UI_KEYCODE& keyCode) { - std::string temp = tempText_; - temp.insert(cursorIndex_, 1, static_cast(keyCode)); - if (!CheckSpaceLeft(temp.c_str())) { + std::wstring temp = tempText_; + std::string str; + temp.insert(cursorIndex_, 1, static_cast(keyCode)); + str = Utf16ToUtf8(temp); + if (!CheckSpaceLeft(str.c_str())) { GRAPHIC_LOGE("Character length exceeded. Fail to input the letter."); return; } - tempText_.insert(cursorIndex_, 1, static_cast(keyCode)); + tempText_.insert(cursorIndex_, 1, static_cast(keyCode)); uint16_t width = UIFont::GetInstance()->GetWidth(static_cast(keyCode), 0); widthOfChars_.insert(widthOfChars_.begin() + cursorIndex_, width); - UIEditText::SetText(tempText_.c_str()); + str = Utf16ToUtf8(tempText_); + UIEditText::SetText(str.c_str()); + GetLineInfo(lineInfo_); + + cursorIndex_++; + HandleCursorPosByIndex(); +} + +void UITextPreviewBox::InsertHanzi(const std::string &u8hanzi) +{ + std::wstring temp = tempText_; + std::string str; + std::wstring u16hanzi = Utf8ToUtf16(u8hanzi); + temp.insert(cursorIndex_, 1, u16hanzi[0]); + str = Utf16ToUtf8(temp); + if (!CheckSpaceLeft(str.c_str())) { + GRAPHIC_LOGE("Character length exceeded. Fail to input the letter."); + return; + } + + tempText_.insert(cursorIndex_, 1, u16hanzi[0]); + uint16_t width = UIFont::GetInstance()->GetWidth(u16hanzi[0], 0); + widthOfChars_.insert(widthOfChars_.begin() + cursorIndex_, width); + + str = Utf16ToUtf8(tempText_); + UIEditText::SetText(str.c_str()); GetLineInfo(lineInfo_); cursorIndex_++; @@ -210,7 +240,8 @@ void UITextPreviewBox::DeleteChar() tempText_.erase(cursorIndex_ - 1, 1); widthOfChars_.erase(widthOfChars_.begin() + cursorIndex_ - 1); - UIEditText::SetText(tempText_.c_str()); + std::string temp = Utf16ToUtf8(tempText_); + UIEditText::SetText(temp.c_str()); GetLineInfo(lineInfo_); cursorIndex_--; @@ -307,13 +338,15 @@ void UITextPreviewBox::SetText(std::string text) widthOfChars_.clear(); tempText_.clear(); - tempText_ = text; - for (uint16_t i = 0; i < text.length(); i++) { - uint16_t width = UIFont::GetInstance()->GetWidth(text[i], 0); + tempText_ = Utf8ToUtf16(text); + UIEditText::SetText(text.c_str()); + UIFont::GetInstance()->SetCurrentFontId(inputText_->GetFontId(), inputText_->GetFontSize()); + + for (uint16_t i = 0; i < tempText_.length(); i++) { + uint16_t width = UIFont::GetInstance()->GetWidth(tempText_[i], 0); widthOfChars_.push_back(width); } - UIEditText::SetText(tempText_.c_str()); GetLineInfo(lineInfo_); cursorIndex_ = widthOfChars_.size(); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/hor_swipe_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/hor_swipe_view.h index 1900882a7..5a5fb8e8b 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/hor_swipe_view.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/hor_swipe_view.h @@ -25,7 +25,7 @@ public: * @since 1.0 * @version 1.0 */ - virtual ~HorSwipeView() {} + ~HorSwipeView() override {} bool DragXInner(int16_t distance) override; bool OnDragEvent(const DragEvent& event) override; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/map_svg_parser.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/map_svg_parser.h index e7473193d..4cae67612 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/map_svg_parser.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/map_svg_parser.h @@ -15,6 +15,7 @@ #ifndef GRAPHIC_LITE_MAP_SVG_PARSER_H #define GRAPHIC_LITE_MAP_SVG_PARSER_H #include +#include #include "gfx_utils/color.h" namespace OHOS { @@ -88,7 +89,10 @@ public: MapSVGParser(void); virtual ~MapSVGParser(void); + bool SetSVG(const std::string& file); bool SetSVG(uint8_t* data, uint32_t length); + void ClearSVG(); + Color24 GetBackGroundColor(void); uint32_t GetImageOffset(void); void GetSize(int16_t& width, int16_t& height); @@ -100,7 +104,6 @@ public: PathStyle* GetPathStyleByIndex(uint8_t index); TextDetail* GetTextByIndex(uint8_t index); ImageDetail* GetImageByIndex(uint8_t index); - void ClearSVG(); private: struct MapHeader { @@ -119,9 +122,10 @@ private: }; static constexpr uint8_t PARSER_TYPE_NUM = 5; - using MapTypeParserInit = uint32_t (MapSVGParser::*)( - uint8_t *data, uint32_t length, uint32_t offset, uint8_t count); - using MapTypeParserDeinit = void (MapSVGParser::*)(uint8_t count); + using MapTypeReadByData = uint32_t (MapSVGParser::*)(uint8_t *data, uint32_t length, + uint32_t offset, uint8_t count); + using MapTypeReadByPath = uint32_t (MapSVGParser::*)(FILE* fp, uint8_t count); + using MapTypeRelease = void (MapSVGParser::*)(uint8_t count); uint32_t ReadMapNode(uint8_t* data, uint32_t length, uint32_t offset); uint32_t ReadPathStyle(uint8_t* data, uint32_t length, uint32_t offset); @@ -130,23 +134,35 @@ private: uint32_t ReadMapImg(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count); uint32_t ReadMapRoad(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count); uint32_t ReadMapPOI(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count); - uint32_t ReadImage(uint8_t* data, uint32_t length, uint32_t offset); + + uint32_t ReadMapNode(FILE* fp); + uint32_t ReadPathStyle(FILE* fp); + uint32_t ReadMapPath(FILE* fp, uint8_t count); + uint32_t ReadMapText(FILE* fp, uint8_t count); + uint32_t ReadMapImg(FILE* fp, uint8_t count); + uint32_t ReadMapRoad(FILE* fp, uint8_t count); + uint32_t ReadMapPOI(FILE* fp, uint8_t count); void ReleaseMapPath(uint8_t count); void ReleaseMapText(uint8_t count); void ReleaseMapImg(uint8_t count); void ReleaseMapRoad(uint8_t count); void ReleaseMapPOI(uint8_t count); + void ReleaseResource(void); bool AllocPath(PathDetail& path, uint32_t cmdNum, uint32_t dataNum); - MapTypeParserInit parserInitFunc[PARSER_TYPE_NUM] = { &MapSVGParser::ReadMapPath, &MapSVGParser::ReadMapText, - &MapSVGParser::ReadMapImg, &MapSVGParser::ReadMapRoad, - &MapSVGParser::ReadMapPOI }; - MapTypeParserDeinit parserDeinitFunc[PARSER_TYPE_NUM] = { + MapTypeReadByData readByDataFunc[PARSER_TYPE_NUM] = { + &MapSVGParser::ReadMapPath, &MapSVGParser::ReadMapText, &MapSVGParser::ReadMapImg, + &MapSVGParser::ReadMapRoad, &MapSVGParser::ReadMapPOI }; + + MapTypeReadByPath readByPathFunc[PARSER_TYPE_NUM] = { + &MapSVGParser::ReadMapPath, &MapSVGParser::ReadMapText, &MapSVGParser::ReadMapImg, + &MapSVGParser::ReadMapRoad, &MapSVGParser::ReadMapPOI }; + + MapTypeRelease releaseFunc[PARSER_TYPE_NUM] = { &MapSVGParser::ReleaseMapPath, &MapSVGParser::ReleaseMapText, &MapSVGParser::ReleaseMapImg, - &MapSVGParser::ReleaseMapRoad, &MapSVGParser::ReleaseMapPOI - }; + &MapSVGParser::ReleaseMapRoad, &MapSVGParser::ReleaseMapPOI }; MapHeader mapHeader_ = {0}; MapNode* nodeArray_ = nullptr; @@ -162,6 +178,7 @@ private: POIDetail* poiArray_ = nullptr; uint8_t poiCount_ = 0; uint8_t* data_ = nullptr; + std::string file_; }; } #endif // GRAPHIC_LITE_MAP_SVG_PARSER_H diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/core/input_method_manager.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/core/input_method_manager.cpp index a10a3970d..270136994 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/core/input_method_manager.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/core/input_method_manager.cpp @@ -36,9 +36,9 @@ void InputMethodManager::ShowInputMethod(UIView* view) return; } - inputView_ = view; UIViewType viewType = view->GetViewType(); if (viewType == UI_EDIT_TEXT) { + inputView_ = view; // 点击光标会导致字符串丢失,此处修改可以避免这个问题 UIEditText* tmpView = reinterpret_cast(view); InputMethodParam param; param.view = view; 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 5f8018366..b2771f1b1 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 @@ -28,6 +28,7 @@ #include "securec.h" #include "dfx/dfx_record.h" #include "common/low_power_manager.h" +#include "common/image_cache_manager.h" #if ENABLE_DEBUG #include "common/key_code.h" @@ -75,6 +76,31 @@ void DumpMemoryCmd(int argc, char *argv[]) { MemCheck::GetInstance()->DumpMemInfo(); } + +void DumpImgCmd(int argc, char *argv[]) +{ + ImageCacheManager::GetInstance().Dump(); + + printf("\n\n"); + printf("========================DumpImgInfoRecursive========================\n"); + RootView::GetInstance()->DumpImgInfoRecursive(); +} + +void SetMemMonitorCmd(int argc, char *argv[]) +{ + if (argc != 1) { + GRAPHIC_LOGE("param err.\n"); + return; + } + if (strcmp(argv[0], "0") == 0) { + GrallocEngines::GetInstance()->SetMemMonitor(false); + } else if (strcmp(argv[0], "1") == 0) { + GrallocEngines::GetInstance()->SetMemMonitor(true); + } else { + GRAPHIC_LOGE("param err.\n"); + return; + } +} #endif static bool ConvertToInt(const char* input, uint16_t& value) @@ -471,6 +497,8 @@ struct DfxCmd g_dfxCmdList[] = { {"showtime", OHOS::ShowTime}, #if ENABLE_MEMORY_CHECK {"dumpmem", OHOS::DumpMemoryCmd}, + {"mem_monitor", OHOS::SetMemMonitorCmd}, + {"dumpimg", OHOS::DumpImgCmd}, #endif #if ENABLE_DEBUG {"inject_rotate", OHOS::InjectRotateEvent}, diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_record.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_record.cpp index 1785e8899..2d84cd6b7 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_record.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/dfx/dfx_record.cpp @@ -156,7 +156,7 @@ void DfxRenderReset() void DfxRecordShow() { if (g_dfxShow == ShowType::DFX_SHOW_ULPS) { - GRAPHIC_LOGP("g_ulpsExit: %d, g_flush: %d\n", g_ulpsExit, g_flush); + GRAPHIC_LOGP("g_ulpsExit: %u, g_flush: %u\n", g_ulpsExit, g_flush); return; } diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/swipe_effect/cube_effect.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/swipe_effect/cube_effect.cpp new file mode 100644 index 000000000..748f45e13 --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/swipe_effect/cube_effect.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2022 CompanyNameMagicTag. + * 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 "securec.h" +#include "common/screen.h" +#include "cube_effect.h" + +namespace OHOS { +namespace { +static constexpr int16_t EASE_RANGE = 100; +static constexpr int16_t CAMERA_DISTANCE = 500; +static constexpr int16_t ROTATE_RANGE_MAX = 90; +} + +void CubeEffect::OnSwipe(UISwipeView& view) +{ + if (preLeftCard != nullptr) { + preLeftCard->ResetTransParameter(); + preLeftCard = nullptr; + container_->UIViewGroup::Remove(&leftImg_); + leftImg_.ResetTransParameter(); + } + + if (preRightCard != nullptr) { + preRightCard->ResetTransParameter(); + preRightCard = nullptr; + container_->UIViewGroup::Remove(&rightImg_); + rightImg_.ResetTransParameter(); + } +} + +void CubeEffect::TransformCard(UIView* leftCard, UIView* rightCard, int16_t xOffset) +{ + int16_t width = Screen::GetInstance().GetWidth(); + + float angle = ROTATE_RANGE_MAX * MATH_ABS(xOffset) / (float)width; + + uint16_t leftW = leftCard->GetWidth(); + Vector3 leftRotateStart = {leftW + 1, 0, 0}; + Vector3 leftRotateEnd = {leftW + 1, 1, 0}; + Vector3 rightRotateStart = {-1, 0, 0}; + Vector3 rightRotateEnd = {-1, 1, 0}; + if (xOffset > 0) { + leftCard->Rotate((angle - ROTATE_RANGE_MAX), leftRotateStart, leftRotateEnd); + rightCard->Rotate(angle, rightRotateStart, rightRotateEnd); + } else if (xOffset < 0) { + leftCard->Rotate(-angle, leftRotateStart, leftRotateEnd); + rightCard->Rotate((ROTATE_RANGE_MAX - angle), rightRotateStart, rightRotateEnd); + } else { + leftCard->ResetTransParameter(); + rightCard->ResetTransParameter(); + } +} + +void CubeEffect::TransformMirrorCard(UIView& leftCard, UIView& rightCard, int16_t xOffset) +{ + int16_t width = Screen::GetInstance().GetWidth(); + int16_t height = Screen::GetInstance().GetHeight(); + float angle = ROTATE_RANGE_MAX * MATH_ABS(xOffset) / (float)width; + + Matrix4 perspectiveMatrix; + perspectiveMatrix[2][2] = 0; // 2 : index + perspectiveMatrix[2][3] = -1.0f / CAMERA_DISTANCE; // 2 3 : index 1000:cam distance + + int16_t leftRigth = leftCard.GetOrigRect().GetRight(); + int16_t leftBottom = leftCard.GetOrigRect().GetBottom(); + Matrix4 leftMatrix = Matrix4::Rotate(180.0f, {0, leftBottom, 0}, {1.0, leftBottom, 0}); + Vector3 leftRotateStart = {leftRigth, 0, 0}; + Vector3 leftRotateEnd = {leftRigth, 1, 0}; + Matrix4 leftTranslateFromCamera = Matrix4::Translate(Vector3(-leftRigth, -(height >> 1), 0)); + Matrix4 leftTranslateToCamera = Matrix4::Translate(Vector3(leftRigth, (height >> 1), 0)); + + int16_t rightBottom = rightCard.GetOrigRect().GetBottom(); + Matrix4 rightMatrix = Matrix4::Rotate(180.0f, {0, rightBottom, 0}, {1.0, rightBottom, 0}); + Vector3 rightRotateStart = {0, 0, 0}; + Vector3 rightRotateEnd = {0, 1, 0}; + Matrix4 rightTranslateFromCamera = Matrix4::Translate(Vector3(0, -(height >> 1), 0)); + Matrix4 rightTranslateToCamera = Matrix4::Translate(Vector3(0, (height >> 1), 0)); + if (xOffset > 0) { + leftMatrix = Matrix4::Rotate((angle - ROTATE_RANGE_MAX), leftRotateStart, leftRotateEnd) * leftMatrix; + leftMatrix = leftTranslateToCamera * (perspectiveMatrix * leftTranslateFromCamera) * leftMatrix; + leftMatrix = Matrix4::Translate({-(width - xOffset), 0, 0}) * leftMatrix; + + rightMatrix = Matrix4::Rotate(angle, rightRotateStart, rightRotateEnd) * rightMatrix; + rightMatrix = rightTranslateToCamera * (perspectiveMatrix * rightTranslateFromCamera) * rightMatrix; + rightMatrix = Matrix4::Translate({xOffset, 0, 0}) * rightMatrix; + } else { + leftMatrix = Matrix4::Rotate(-angle, leftRotateStart, leftRotateEnd) * leftMatrix; + leftMatrix = leftTranslateToCamera * (perspectiveMatrix * leftTranslateFromCamera) * leftMatrix; + leftMatrix = Matrix4::Translate({xOffset, 0, 0}) * leftMatrix; + + rightMatrix = + Matrix4::Rotate((ROTATE_RANGE_MAX - angle), rightRotateStart, rightRotateEnd) * rightMatrix; + rightMatrix = rightTranslateToCamera * (perspectiveMatrix * rightTranslateFromCamera) * rightMatrix; + rightMatrix = Matrix4::Translate({width + xOffset, 0, 0}) * rightMatrix; + } + TransformMap tempTrans; + tempTrans.SetMatrix(leftMatrix); + leftCard.SetTransformMap(tempTrans); + + tempTrans.SetMatrix(rightMatrix); + rightCard.SetTransformMap(tempTrans); +} + +void CubeEffect::CommonAlg(UIView* leftCard, UIView* rightCard, int16_t xOffset) +{ + if (leftCard == nullptr || rightCard == nullptr) { + return; + } + + if (preLeftCard == nullptr) { + leftImg_.SetStyle(STYLE_IMAGE_OPA, 90); // 90: degree + rightImg_.SetStyle(STYLE_IMAGE_OPA, 90); // 90: degree + container_->UIViewGroup::Add(&leftImg_); + container_->UIViewGroup::Add(&rightImg_); + } + + int16_t width = Screen::GetInstance().GetWidth(); + int16_t height = Screen::GetInstance().GetHeight(); + int16_t middleWidth = width / 2; + if (leftCard != preLeftCard && rightCard != preRightCard) { + leftImg_.SetPosition(0, 0, width, height); + if (leftCard->GetViewType() == UI_IMAGE_VIEW) { + leftImg_.SetSrc(static_cast(leftCard)->GetImageInfo()); + } + preLeftCard = leftCard; + preLeftCard->SetCameraPosition(Vector2(leftCard->GetWidth(), leftCard->GetHeight() / 2)); // 2: half + preLeftCard->SetCameraDistance(CAMERA_DISTANCE); + rightImg_.SetPosition(0, 0, width, height); + if (rightCard->GetViewType() == UI_IMAGE_VIEW) { + rightImg_.SetSrc(static_cast(rightCard)->GetImageInfo()); + } + preRightCard = rightCard; + preRightCard->SetCameraPosition(Vector2(0, rightCard->GetHeight() / 2)); // 2: half + preRightCard->SetCameraDistance(CAMERA_DISTANCE); + } + + TransformCard(preLeftCard, preRightCard, xOffset); + TransformMirrorCard(leftImg_, rightImg_, xOffset); +} + +void CubeEffect::CardSwipeAlg(UIImageView* leftCard, UIImageView* rightCard, int16_t xOffset) +{ + CommonAlg(leftCard, rightCard, xOffset); +} + +void CubeEffect::CardSwipeAlg(UICardPage* leftCard, UICardPage* rightCard, int16_t xOffset) +{ + CommonAlg(leftCard, rightCard, xOffset); +} +} diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/swipe_effect/cube_effect.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/swipe_effect/cube_effect.h new file mode 100644 index 000000000..751d99e2f --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/swipe_effect/cube_effect.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 CompanyNameMagicTag. + * 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. + */ + +#ifndef UI_CUBE_EFFECT_H +#define UI_CUBE_EFFECT_H +#include "components/ui_cross_view.h" + +namespace OHOS { +class CubeEffect : public CardSwipe, public UISwipeView::OnSwipeListener { +public: + CubeEffect(void) {} + ~CubeEffect() override {} + void CardSwipeAlg(UICardPage* leftCard, UICardPage* rightCard, int16_t xOffset) override; + void CardSwipeAlg(UIImageView* leftCard, UIImageView* rightCard, int16_t xOffset) override; + void OnSwipe(UISwipeView& view) override; + + void SetContainer(UICrossView* view) + { + container_ = view; + } + +private: + UIImageView leftImg_; + UIImageView rightImg_; + UIView* preLeftCard = nullptr; + UIView* preRightCard = nullptr; + UICrossView* container_ = nullptr; + + void CommonAlg(UIView* leftCard, UIView* rightCard, int16_t xOffset); + void TransformCard(UIView* leftCard, UIView* rightCard, int16_t xOffset); + void TransformMirrorCard(UIView& leftCard, UIView& rightCard, int16_t xOffset); +}; +} // OHOS +#endif // UI_CUBE_EFFECT_H \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_input_method.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_input_method.h index d925c2145..3cf98c7c2 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_input_method.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_input_method.h @@ -16,11 +16,15 @@ #ifndef GRAPHIC_LITE_UI_SOFT_KEYBOARD_H #define GRAPHIC_LITE_UI_SOFT_KEYBOARD_H +#include "components/ui_label.h" +#include "components/ui_label_button.h" +#include "components/ui_list.h" #include "common/input_method_manager.h" #include "components/ui_edit_text.h" #include "input_method/ui_abstract_soft_keyboard.h" #include "input_method/ui_option_box.h" #include "input_method/ui_text_preview_box.h" +#include "input_method/ui_pinyin_candidate.h" #include "gfx_utils/vector.h" #if ENABLE_SOFT_KEYBOARD @@ -28,8 +32,35 @@ namespace OHOS { /** * @brief Provides the functions related to UIInputMethod. */ -class UIInputMethod : public InputMethodManager::InputMethodListener { +class UIInputMethod : public InputMethodManager::InputMethodListener, + public UIView::OnClickListener, public ListScrollListener { + class HanziAdapter : public AbstractAdapter { + public: + ~HanziAdapter() override {}; + HanziAdapter() {}; + HanziAdapter(const HanziAdapter&) = delete; + HanziAdapter& operator=(const HanziAdapter&) = delete; + UIView* GetView(UIView* inView, int16_t index) override; + int16_t GetItemWidthWithMargin(int16_t index) override; + int16_t GetItemHeightWithMargin(int16_t index) override; + uint16_t GetCount() override; + bool SetWidthAndHeight(int16_t w, int16_t h); + void SetData(int8_t hanzi[][PinyinCandidate::IME_HZLENTH], uint8_t len); + void SetClickListener(UIView::OnClickListener* clickListener) + { + clickListener_ = clickListener; + } + + private: + UIView::OnClickListener* clickListener_ = nullptr; + int8_t (*data_)[PinyinCandidate::IME_HZLENTH] = nullptr; + uint8_t size_ = 0; + int16_t width_ = 0; + int16_t height_ = 0; + }; public: + static constexpr uint8_t DEFAULT_NUMPERPAGE = 5; + static constexpr uint8_t MAX_HANZIMATCHED = 255; static UIInputMethod* GetInstance(); /** @@ -47,7 +78,13 @@ public: * @brief Enter a key value in the input method. * @param keys key value, see UI_KEYCODE. */ - void Input(UI_KEYCODE &key); + void Input(UI_KEYCODE key); + + void InputPinyin(UI_KEYCODE key); + + void ShowHanziPageList(); + + void HideHanziPageList(); /** * @brief Hide soft keyboad option box. @@ -62,6 +99,7 @@ public: */ void ShowOptionBox(UIView *view, UI_KEYCODE *keys, uint8_t num); + bool OnClick(UIView& view, const ClickEvent& event) override; private: UIInputMethod(); ~UIInputMethod() override; @@ -71,18 +109,37 @@ private: void SetupOptionBox(); void SetupSoftKeyboard(); void SetupTextPreviewBox(); - void InsertChar(UI_KEYCODE &keyCode); - void ChangSoftKeyboard(UI_KEYCODE &keyCode); - void DealFunctionKey(UI_KEYCODE& keyCode); - void DealNormalKey(UI_KEYCODE &keyCode); + void InsertChar(UI_KEYCODE keyCode); + void InsertPinyin(UI_KEYCODE pinyin); + void UpdateHanziOption(const std::string &pinyin); + void ChangSoftKeyboard(UI_KEYCODE keyCode); + void DealFunctionKey(UI_KEYCODE keyCode); + void DealNormalKey(UI_KEYCODE keyCode); void DealSendKey(); void DealDelKey(); + void DealPinyinDelKey(); UIViewGroup* inputMethod_ = nullptr; UITextPreviewBox* previeBox_ = nullptr; // soft keyboard edit box UIEditText* edit_ = nullptr; // user creat edit box UIOptionBox* optionBox_ = nullptr; // Preselection box + UILabel* pinyinPreview_ = nullptr; // pinyin preview box + void SetupPinyinPreviewBox(); + void HidePinyinPreview(); + void ShowPinyinPreview(); + + UIList *hanziList_ = nullptr; // hanzi candidates + HanziAdapter *hanziAdapter_ = nullptr; // hanzi adapter + int8_t hanziMatched_[MAX_HANZIMATCHED][PinyinCandidate::IME_HZLENTH]; + void ClearHanziCandidate(); + void SetupHanziCandidate(); + + PinyinCandidate* pinyinTable_ = nullptr; // pinyin and hanzi find table + void SetupPinyinTable(); + void ClearPinyinTable(); + using PinyinState = PinyinCandidate::PinyinState; + UIAbstractSoftKeyboard* curSoftKeyboard_ = nullptr; uint8_t curKeyboardIndex_ = 0; Graphic::Vector customSoftKeyboard_; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_keyboard_codetable.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_keyboard_codetable.h index ecd6bb293..168b576b8 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_keyboard_codetable.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_keyboard_codetable.h @@ -140,6 +140,7 @@ enum class UI_KEYCODE : uint8_t { UI_KEY_SOFT_KEYBOARD_CAP = 0xF7, UI_KEY_SOFT_KEYBOARD_NUMBER = 0xF8, UI_KEY_SOFT_KEYBOARD_SYMBOL = 0xF9, + UI_KEY_SOFT_KEYBOARD_PINYIN = 0xFA, UI_KEY_BUTT = 0XFF, }; diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_pinyin_candidate.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_pinyin_candidate.h new file mode 100644 index 000000000..640554b78 --- /dev/null +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_pinyin_candidate.h @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2022 CompanyNameMagicTag. + * 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. + */ + +#ifndef GRAPHIC_LITE_UI_PINYIN_CANDIDATE_H +#define GRAPHIC_LITE_UI_PINYIN_CANDIDATE_H +#include "components/ui_label.h" +#include "components/ui_view_group.h" +#include "gfx_utils/vector.h" +#include "graphic_config.h" +#include "input_method/ui_keyboard_codetable.h" + +#if ENABLE_SOFT_KEYBOARD + +namespace OHOS { +class PinyinCandidate : public HeapBase { +public: + enum class PinyinState : int32_t { + SUCCESS = 0, + INVALID_PINYIN, // input source str is invalid + INVALID_PATH, + MEM_NOT_ENOUGH, + MEM_SET_ERROR, + MEM_COPY_ERROR, + MEM_ALLOC_ERROR, + INVALID_PAGE_INDEX, + }; + static const uint32_t IME_PYMAXLENTH = 8; // 单个拼音的最大字母个数 + static const uint32_t IME_HZLENTH = 4; // 单个汉字占内存大小 + static const uint8_t MAXSAMEPREFIXPY = 45; // 前缀相同的拼音的最大个数 + static const int32_t MAXHZNUM = 0x2192; // 汉字的总共个数 + static const uint8_t MAXNUMBEROFCHAR = 5; // 5 is the Maximum number of characters on key + static const uint8_t MAXCHARNUM = 26; // 26 characters, a ~ z + static const uint32_t MAX_TABLE_LEN = 12; // 12 is the max Length of Table + static const uint32_t MAX_TABLE_MEMBER_LEN = 5; // 5 is the max length of Tabel Member + + PinyinCandidate(const PinyinCandidate&) = delete; + PinyinCandidate& operator=(const PinyinCandidate&) = delete; + ~PinyinCandidate(); + PinyinCandidate(); + + std::string DebugInfo(PinyinState state) const; + PinyinState FindHanzi(const std::string &sourceStr); + PinyinState GetHanziPage(uint8_t pageNumber, int8_t candidate[][IME_HZLENTH], uint8_t len); + PinyinState GetFwdHanziPage(int8_t candidate[][IME_HZLENTH], uint8_t len); + PinyinState GetCurHanziPage(int8_t candidate[][IME_HZLENTH], uint8_t len); + PinyinState GetNxtHanziPage(int8_t candidate[][IME_HZLENTH], uint8_t len); + PinyinState GetAllHanzi(int8_t candidate[][IME_HZLENTH], uint8_t len); + uint8_t GetHanziPagesNum() const + { + return hanziStatus_.m_matchHZPageNumber; + } + uint8_t GetMatchHanziNum() const + { + return hanziStatus_.m_matchHzNumber; + } + uint8_t GetHanziPageIndex() const + { + return hanziStatus_.m_currentHzPage; + } + + PinyinState Init(const std::string &path); + + /* 设定每页显示二级候选码的个数 */ + int32_t SetLv2NumPerPage(uint8_t num); + uint8_t GetLv2NumPerPage() + { + return m_lv2NumPerPage; + } + +protected: + /* 从外部文件装载候选码 */ + int32_t LoadCodeTable(const int8_t *filePath); + /* 修复损坏的码表文件 */ + int32_t RecoverCodeTable(const int8_t *filePath, const int8_t *backupPath); + +private: + /* init pinyin table path */ + PinyinState InitPinyinTablePath(const std::string &path); + void InitEx(void); + + /* 以下两结构组成了拼音码表,并且以只读方式保存, + * 今后扩展词频调整,则将词频数据以另外文件单独保存, + * FreqTableIndex数据成员用于实现拼音码表中的结构与词频表中的记录相映射 + */ + struct PYTab { + int8_t pinyin[IME_PYMAXLENTH]; + uint32_t freqTableIndex; // 指向本结构在频率记录表中的位置 + uint16_t hzIndex; + uint8_t hzNum; // 拼音对应的汉字个数 + }; + + struct HZTab { + uint32_t hz; + uint16_t freqTableIndex; // 指向本结构在频率记录表中的位置 + }; + + uint8_t m_lv2NumPerPage = 5; // 5 是二级候选码每页显示的个数 + + /* 拼音码表的缓存 */ + PYTab m_pyTabBuf[MAXCHARNUM][MAXSAMEPREFIXPY]; + HZTab m_hzTabBuf[MAXHZNUM] = {0, 0}; // 汉字码表缓存 + + struct { + uint8_t m_currentPyPage = 0; // current pinyin page number + uint8_t m_matchPyPage = 0; // matched pinyin page num + int8_t m_matchPyStartIndex = -1; /* 在码表中与指定拼音匹配的拼音的起始索引 */ + int8_t m_matchPyEndIndex = -1; /* 在码表中与指定拼音匹配的结束索引 */ + uint8_t m_matchPyNumber = 0; /* 与指定拼音匹配的候选码数量 */ + uint8_t m_currentPyIndex = 0; + } pinyinStatus_; + struct { + uint16_t m_currentHzIndex = 0; + uint8_t m_matchHzNumber = 0; + uint8_t m_matchHZPageNumber = 0; + uint8_t m_currentHzPage = 0; + } hanziStatus_; + + std::string m_pinyinTablePath = ""; +}; +} // namespace OHOS +#endif // ENABLE_SOFT_KEYBOARD +#endif // GRAPHIC_LITE_UI_PINYIN_CANDIDATE_H \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_soft_keyboard.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_soft_keyboard.h index 3be731ad6..11202ca44 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_soft_keyboard.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_soft_keyboard.h @@ -83,6 +83,15 @@ public: void CreateKeyButtons() override; static UISymbolSoftKeyboard* GetInstance(); }; + +class UIPinyinSoftKeyboard : public UIAbstractSoftKeyboard { +public: + UIPinyinSoftKeyboard() {} + ~UIPinyinSoftKeyboard() override {} + void CreateKeyButtons() override; + static UIPinyinSoftKeyboard* GetInstance(); +}; + } // namespace OHOS #endif // ENABLE_SOFT_KEYBOARD #endif // GRAPHIC_LITE_UI_INPUT_METHOD_H diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_text_preview_box.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_text_preview_box.h index cd8151dee..eaeb6446d 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_text_preview_box.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/input_method/ui_text_preview_box.h @@ -16,6 +16,9 @@ #ifndef GRAPHIC_LITE_UI_EDIT_TEXT_H #define GRAPHIC_LITE_UI_EDIT_TEXT_H +#include +#include +#include #include #include "components/ui_edit_text.h" #include "input_method/ui_keyboard_codetable.h" @@ -66,6 +69,7 @@ public: void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) override; bool OnClickEvent(const ClickEvent& event) override; void InsertChar(UI_KEYCODE& keyCode); + void InsertHanzi(const std::string &u8hanzi); void DeleteChar(); void SetText(std::string text); @@ -91,13 +95,26 @@ protected: void GetLineInfo(LineInfo& lineInfo); private: + std::wstring Utf8ToUtf16(const std::string &text) const + { + std::wstring_convert, wchar_t> convert; + std::wstring wideText = convert.from_bytes(text); + return wideText; + } + + std::string Utf16ToUtf8(const std::wstring &wtext) const + { + std::wstring_convert, wchar_t> convert; + return convert.to_bytes(wtext); + } + uint32_t cursorIndex_ = 0; bool isCursorInited_ = false; CursorCallback cursorCallback_; Animator *cursorAnimator_ = nullptr; UIView *cursorView_ = nullptr; LineInfo lineInfo_ = {{0}}; - std::string tempText_; + std::wstring tempText_; std::vector widthOfChars_; TextPreviewBoxMode editMode_ = TEXT_PREVIEW_BOX_MODE_INSERT; 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 2ff3022db..3a98cda47 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 @@ -59,6 +59,11 @@ bool GrallocEngines::AllocBufferOnce(const AllocInfo& info, GrallocBuffer& buffe buffer.virAddr = bufferHandle->virAddr; #if ENABLE_GMMU buffer.stride = static_cast(bufferHandle->stride); +#endif +#if ENABLE_MEMORY_CHECK + if (isMonitorEnabled_) { + printf("[Alloc] addr = %p, size = %d, usage = %llu\n", bufferHandle->virAddr, bufferHandle->size, bufferHandle->usage); + } #endif return true; } @@ -109,6 +114,11 @@ void GrallocEngines::FreeBuffer(uint8_t* virAddr) yuvBufCnt_--; } g_buffers.erase(iter); +#if ENABLE_MEMORY_CHECK + if (isMonitorEnabled_) { + printf("[Free] addr = %p, size = %d, usage = %llu\n", virAddr, handle->size, handle->usage); + } +#endif grallocFuncs_->FreeMem(handle); } } @@ -174,5 +184,11 @@ void GrallocEngines::DumpMem() printf("total size: font %d (count: %d, max: %d), image %d, path %d, fb %d, mapbuffer:%d, yuv %d\n", fontCacheSize, fontCount, fontMax, imageCacheSize, pathCacheSize, fbSize, mapBufferSize, yuvCacheSize); } + +void GrallocEngines::SetMemMonitor(bool enable) +{ + isMonitorEnabled_ = enable; +} + #endif } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_custom.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_custom.cpp index 1c8ed681a..01f4c1c21 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_custom.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/frameworks/mem_custom.cpp @@ -29,7 +29,7 @@ void* ImageCacheMalloc(ImageInfo& info) allocInfo.usage = HBM_USE_ASSIGN_SIZE; GrallocBuffer buffer; if (!GrallocEngines::GetInstance()->AllocBuffer(allocInfo, buffer)) { - GRAPHIC_LOGE("AllocBuffer failed."); + GRAPHIC_LOGE("ImageCacheMalloc failed! size = %u", info.dataSize); return nullptr; } info.phyAddr = reinterpret_cast(buffer.phyAddr); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/innerkits/hals/gralloc_engines.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/innerkits/hals/gralloc_engines.h index 960ee09e9..138bad1b5 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/innerkits/hals/gralloc_engines.h +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/utils/innerkits/hals/gralloc_engines.h @@ -43,12 +43,14 @@ public: void FreeBuffer(uint8_t* virAddr); #if ENABLE_MEMORY_CHECK void DumpMem(); + void SetMemMonitor(bool enable); #endif private: GrallocEngines() : grallocFuncs_(nullptr) {} ~GrallocEngines() {} uint8_t yuvBufCnt_ = 0; GrallocFuncs* grallocFuncs_; + bool isMonitorEnabled_ = false; }; } // end namespace #endif // GRAPHIC_LITE_GRALLOC_ENGINES_H diff --git a/code/sdk/middleware/services/gui/uikit/res/pymb.bin b/code/sdk/middleware/services/gui/uikit/res/pymb.bin new file mode 100644 index 000000000..cbf2ea9d2 Binary files /dev/null and b/code/sdk/middleware/services/gui/uikit/res/pymb.bin differ diff --git a/code/sdk/middleware/services/gui/uikit/sample/CMakeLists.txt b/code/sdk/middleware/services/gui/uikit/sample/CMakeLists.txt index da574a539..4100ec8b3 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/CMakeLists.txt +++ b/code/sdk/middleware/services/gui/uikit/sample/CMakeLists.txt @@ -37,6 +37,7 @@ set(PRIVATE_HEADER ${UIKIT_ROOT_DIR}/proprietary/include/service ${UIKIT_ROOT_DIR}/proprietary/src/utils/innerkits ${UIKIT_ROOT_DIR}/proprietary/src/ui/frameworks + ${UIKIT_ROOT_DIR}/proprietary/src/ui/innerkits ${PROJECT_ROOT_DIR}/hal/input/include ${ROOTDIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include ${ROOTDIR}/open_source/openharmony/third_party/bounds_checking_function/include @@ -79,6 +80,7 @@ set(COMPONENT_CCFLAGS -Wno-missing-declarations -Wno-tautological-pointer-compare -Wno-unused-private-field + -Werror=return-type ) set(WHOLE_LINK diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.cpp index 78ecc57a0..c3730a28c 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.cpp @@ -175,7 +175,7 @@ bool UITestClockDial::HorizontalViewInit(void) pageStatus[maxPage - 1] = true; } listener = new SwipeListener(); - listener->setCallback(calback); + listener->SetCallback(calback); mainSwipeGroup->SetOnSwipeListener(listener); GRAPHIC_LOGD("UITestClockDial::InitPage over\n"); return true; @@ -299,7 +299,7 @@ void UITestClockDial::PreLoad(uint16_t index) } else { if (!pageStatus[index - 1]) { if (!recordCard[index - 1]->InitView()) { - GRAPHIC_LOGE("PreLoad PAGE:%d\n", index - 1); + GRAPHIC_LOGE("PreLoad PAGE:%u\n", index - 1); return; } pageStatus[index - 1] = true; @@ -310,7 +310,7 @@ void UITestClockDial::PreLoad(uint16_t index) } if (!pageStatus[index + 1]) { if (!recordCard[index + 1]->InitView()) { - GRAPHIC_LOGE("PreLoad PAGE:%d\n", index + 1); + GRAPHIC_LOGE("PreLoad PAGE:%u\n", index + 1); return; } pageStatus[index + 1] = true; diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h index 53ba272ca..00d6e6353 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/ui_test_clock_dial.h @@ -41,7 +41,7 @@ public: ~SwipeListener() override {} void OnSwipe(UISwipeView& view) override; - void setCallback(ZoomEffect* calback) + void SetCallback(ZoomEffect* calback) { calback_ = calback; } diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.cpp index 6e9ce0650..2291781e5 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.cpp @@ -146,6 +146,9 @@ void UITestCoverflow::UITestCoverflowView001() } coverflow_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); coverflow_->SetIntercept(true); + coverflow_->SetThrowDrag(true); + coverflow_->SetSwipeACCLevel(150); // 150: set drag compensation distance + coverflow_->SetDragACCLevel(16); // 16: set drag time duration level for (uint8_t i = 0; i < COVERFLOW_PRELOAD_PAGE_NUM; i++) { ImageInfo* src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(g_faceInfo[i].path)); coverflow_->Add(g_faceInfo[i].name, src); 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 9423f7515..5890f17be 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 @@ -36,8 +36,10 @@ public: #ifndef _WIN32 class VideoPage : public UICardPage { public: + VideoPage(const VideoPage &) = delete; + VideoPage &operator=(const VideoPage &) = delete; VideoPage(void) {} - ~VideoPage(); + ~VideoPage() override; void ScrollBegin(bool isActive) override; void ScrollEnd(bool isActive) override; void CoverBegin(bool isCovered) override; diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cube_rotate/cube_rotate_view.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cube_rotate/cube_rotate_view.h index 8999ad003..202559594 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cube_rotate/cube_rotate_view.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cube_rotate/cube_rotate_view.h @@ -51,7 +51,7 @@ public: bool OnDragStartEvent(const DragEvent& event) override; bool OnDragEvent(const DragEvent& event) override; bool OnDragEndEvent(const DragEvent& event) override; - void RotatePlanes(int angleDelta, const Vector3& rotateStart, const Vector3& rotateEnd); + void RotatePlanes(int angle, const Vector3& rotateStart, const Vector3& rotateEnd); private: Graphic::Vector cubePlane_; diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_svg/ui_test_svg.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_svg/ui_test_svg.h index adaeab534..686d1a58e 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_svg/ui_test_svg.h +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_svg/ui_test_svg.h @@ -43,7 +43,7 @@ private: UIViewGroup* group_ = nullptr; UICanvasExt* canvas_ = nullptr; UILabelButton* btn_ = nullptr; - int16_t index_; + int16_t index_ = 0; }; } #endif // UI_TEST_SVG_H \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_chart.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_chart.cpp index 7be455b52..4f8656daa 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_chart.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_chart.cpp @@ -432,18 +432,30 @@ Path* UIChartPillar::AllocPath(uint32_t cmdNum, uint32_t dataNum) } path->cmdNum = cmdNum; path->dataNum = dataNum; - AllocInfo info; - info.expectedSize = sizeof(uint8_t) * cmdNum + sizeof(float) * dataNum; - info.usage = HBM_USE_ASSIGN_SIZE | HBM_USE_MEM_PATH; + + AllocInfo cmdInfo; GrallocBuffer cmdBuffer; - if (!GrallocEngines::GetInstance()->AllocBuffer(info, cmdBuffer)) { - GRAPHIC_LOGE("Alloc buffer for buffer failed."); + cmdInfo.expectedSize = sizeof(uint8_t) * cmdNum; + cmdInfo.usage = HBM_USE_ASSIGN_SIZE | HBM_USE_MEM_PATH; + if (!GrallocEngines::GetInstance()->AllocBuffer(cmdInfo, cmdBuffer)) { + GRAPHIC_LOGE("Alloc buffer for cmd buffer failed."); delete path; - path = nullptr; return nullptr; } + + AllocInfo dataInfo; + GrallocBuffer dataBuffer; + dataInfo.expectedSize = sizeof(float) * dataNum; + dataInfo.usage = HBM_USE_ASSIGN_SIZE | HBM_USE_MEM_PATH; + if (!GrallocEngines::GetInstance()->AllocBuffer(dataInfo, dataBuffer)) { + GRAPHIC_LOGE("Alloc buffer for data buffer failed."); + delete path; + GrallocEngines::GetInstance()->FreeBuffer(reinterpret_cast(cmdBuffer.virAddr)); + return nullptr; + } + path->cmds = (uint8_t *)cmdBuffer.virAddr; - path->data = reinterpret_cast(path->cmds + cmdNum); + path->data = reinterpret_cast(dataBuffer.virAddr); return path; } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_image_view.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_image_view.cpp index 04569006b..5b2af86c0 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_image_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_image_view.cpp @@ -27,6 +27,7 @@ #ifndef VERSION_LITE #include "gif_lib.h" #endif +#include "draw/draw_utils.h" namespace OHOS { #ifndef VERSION_LITE @@ -567,6 +568,15 @@ void UIImageView::SetSrc(const ImageInfo* src) Invalidate(); } +void UIImageView::DumpImgInfo() +{ + if (image_.GetSrcType() == IMG_SRC_VARIABLE) { + printf("view[%p]: viewType = %d\n", this, GetViewType()); + const ImageInfo* info = image_.GetImageInfo(); + PrintImgInfo(info); + } +} + #ifndef VERSION_LITE void UIImageView::AddAndStartGifAnimator() { 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 a24706eed..b74328075 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 @@ -321,18 +321,16 @@ void UISwipeView::SwitchToPage(int16_t dst, bool needAnimator) yOffset = (GetHeight() >> 1) - (dstView->GetY() + (dstView->GetHeightWithMargin() >> 1)); } - if ((xOffset != 0) || (yOffset != 0)) { - if (scrollAnimator_.GetState() != Animator::STOP) { - UIAbstractScroll::StopAnimator(); - } - if (needAnimator) { - animatorCallback_.SetDragTimes(tickTime_); - animatorCallback_.SetDragStartValue(0, 0); - animatorCallback_.SetDragEndValue(xOffset, yOffset); - scrollAnimator_.Start(); - } else { - MoveChildByOffset(xOffset, yOffset); - } + if (scrollAnimator_.GetState() != Animator::STOP) { + UIAbstractScroll::StopAnimator(); + } + if (needAnimator) { + animatorCallback_.SetDragTimes(tickTime_); + animatorCallback_.SetDragStartValue(0, 0); + animatorCallback_.SetDragEndValue(xOffset, yOffset); + scrollAnimator_.Start(); + } else { + MoveChildByOffset(xOffset, yOffset); } } 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 2ede3705f..3f63d2ea0 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 @@ -26,6 +26,7 @@ #include "gfx_utils/mem_api.h" #include "securec.h" #include "themes/theme_manager.h" +#include namespace OHOS { UIView::UIView() @@ -299,8 +300,8 @@ void UIView::Rotate(int16_t angle, const Vector3& pivotStart, const Vecto } #endif if (transMap_ == nullptr) { - ReMeasure(); transMap_ = new TransformMap(); + ReMeasure(); } bool firstTrans = transMap_->IsInvalid(); Rect joinRect = transMap_->GetBoxRect(); @@ -341,8 +342,8 @@ void UIView::Scale(const Vector3& scale, const Vector3& pivot) } #endif if (transMap_ == nullptr) { - ReMeasure(); transMap_ = new TransformMap(); + ReMeasure(); } bool firstTrans = transMap_->IsInvalid(); Rect joinRect = transMap_->GetBoxRect(); @@ -376,8 +377,8 @@ void UIView::Shear(const Vector2& shearX, const Vector2& shearY, c } #endif if (transMap_ == nullptr) { - ReMeasure(); transMap_ = new TransformMap(); + ReMeasure(); } bool firstTrans = transMap_->IsInvalid(); Rect joinRect = transMap_->GetBoxRect(); @@ -417,8 +418,8 @@ void UIView::Translate(const Vector3& trans) } #endif if (transMap_ == nullptr) { - ReMeasure(); transMap_ = new TransformMap(); + ReMeasure(); } bool firstTrans = transMap_->IsInvalid(); Rect joinRect = transMap_->GetBoxRect(); @@ -444,8 +445,8 @@ bool UIView::IsTransInvalid() void UIView::SetCameraDistance(int16_t distance) { if (transMap_ == nullptr) { - ReMeasure(); transMap_ = new TransformMap(); + ReMeasure(); } Rect joinRect = transMap_->GetBoxRect(); transMap_->SetTransMapRect(GetOrigRect()); @@ -458,8 +459,8 @@ void UIView::SetCameraDistance(int16_t distance) void UIView::SetCameraPosition(const Vector2& position) { if (transMap_ == nullptr) { - ReMeasure(); transMap_ = new TransformMap(); + ReMeasure(); } Rect joinRect = transMap_->GetBoxRect(); transMap_->SetTransMapRect(GetOrigRect()); @@ -517,7 +518,9 @@ void UIView::RequestFocus() void UIView::ClearFocus() { - FocusManager::GetInstance()->ClearFocus(); + if (FocusManager::GetInstance()->GetFocusedView() == this) { + FocusManager::GetInstance()->ClearFocus(); + } } #endif @@ -1193,7 +1196,7 @@ bool UIView::GetBitmap(ImageInfo& bitmap) RootView::GetInstance()->SaveDrawContext(); RootView::GetInstance()->UpdateBufferInfo(&newBufferInfo); RootView::GetInstance()->SetSnapshotFlag(true); - RootView::GetInstance()->Measure(); + RootView::GetInstance()->MeasureView(this); RootView::GetInstance()->DrawTop(this, mask); #if ENABLE_VGU_ENGINE LiteMGfxEngine::GetInstance()->SyncHwDraw(); @@ -1225,4 +1228,27 @@ bool UIView::IsVideoContained() } return false; } + +void UIView::PrintImgInfo(const ImageInfo* info) +{ + if (info == nullptr) { + printf(" ImgInfo[%p]\n", info); + } else { + printf(" ImgInfo[%p]: size = [%d, %d], fmt = %d, data = %p, dataSize = %d, cacheNode = %p\n", + info, info->header.width, info->header.height, info->header.colorMode, info->data, info->dataSize, info->cacheNode); + } +} + +void UIView::DumpImgInfoRecursive() +{ + DumpImgInfo(); + + if (IsViewGroup()) { + UIView* child = static_cast(this)->GetChildrenHead(); + while (child != nullptr) { + child->DumpImgInfoRecursive(); + child = child->GetNextSibling(); + } + } +} } // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_image_view.h b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_image_view.h index e39efb55e..24c62e790 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_image_view.h +++ b/code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_image_view.h @@ -272,6 +272,8 @@ public: void SetWidth(int16_t width) override; void SetHeight(int16_t height) override; + void DumpImgInfo() override; + protected: /** * @brief Represents the width of this image. 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 690be3930..884e5c376 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 @@ -331,7 +331,7 @@ protected: virtual void SwitchToPage(int16_t dst, bool needAnimator = true); void MoveChildByOffset(int16_t xOffset, int16_t yOffset) override; void MoveHeadOrTailChild(); - + virtual void RefreshCurrentView(int16_t distance, uint8_t dragDirection); /** * @brief Indicates that the animation duration is 12 ticks. * @@ -370,7 +370,6 @@ protected: #endif private: - void RefreshCurrentView(int16_t distance, uint8_t dragDirection); void RefreshCurrentViewInner(int16_t distance, uint8_t dragDirection, int16_t (UIView::*pfnGetXOrY)() const, 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 9632e8471..bffed44f7 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 @@ -115,6 +115,9 @@ enum UIViewType : uint8_t { UI_BARCODE, UI_MAP_VIEW, UI_KALEIDOSCOPE_VIEW, + UI_ROLLER_VIEW, + UI_HEXAGONS_LIST, + UI_ICOSAHEDRON_VIEW, UI_NUMBER_MAX }; @@ -1793,6 +1796,10 @@ public: */ bool IsVideoContained(); + void DumpImgInfoRecursive(); + + virtual void DumpImgInfo() {} + protected: bool touchable_ : 1; bool visible_ : 1; @@ -1830,6 +1837,7 @@ protected: bool IsInvalid(float percent); void DrawViewBounds(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea); void UpdateRectInfo(uint8_t key, const Rect& rect); + void PrintImgInfo(const ImageInfo* info); private: Rect rect_; diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiostream/src/cpp/audio_stream_out.cpp b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiostream/src/cpp/audio_stream_out.cpp index d53d4e70a..21b0904da 100644 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiostream/src/cpp/audio_stream_out.cpp +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiostream/src/cpp/audio_stream_out.cpp @@ -132,7 +132,7 @@ int32_t AudioStreamOut::Release() const } int32_t AudioStreamOut::StreamWrite(const uint8_t *buffer, uint64_t userSize, uint64_t &writtenSize, - AudioRendererConfig &renderConfig) const + AudioRendererConfig &renderConfig) const { MediaMutexLock(mutex); int32_t ret = StreamWriteTrack(streamHandle_, buffer, userSize, &writtenSize); 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 a3d02f44d..4d38e1786 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 @@ -272,6 +272,7 @@ PlayerControl::PlayerControl() seekToTimeMs_(-1), sourceType_(SOURCE_TYPE_BUT), firstAudioFrameAfterSeek_(false), + firstPosAfterSeek_(0), fd_(-1), offset_(0), playerSource_(nullptr), @@ -627,15 +628,16 @@ int32_t PlayerControl::OnPlayControlEvent(void *priv, const EventCbType event) c int32_t PlayerControl::PauseResume(void) { CHECK_NULL_RETURN(sinkManager_, HI_ERR_PLAYERCONTROL_NULL_PTR, "sinkManager_ nullptr"); + MediaMutexLock(schMutex_); int32_t ret = sinkManager_->Resume(); if (ret != HI_SUCCESS) { if (ret != NOT_FOUND_ACTIVE_STREAME) { MEDIA_ERR_LOG("resume failed"); hasVideo_ ? NotifyError(PLAYERCONTROL_ERROR_VID_PLAY_FAIL) : NotifyError(PLAYERCONTROL_ERROR_AUD_PLAY_FAIL); } + MediaMutexUnLock(schMutex_); return ret; } - MediaMutexLock(schMutex_); paused_ = false; // played to the end no need to signal if (!IsPlayEos()) { @@ -1134,7 +1136,11 @@ void PlayerControl::ReportRenderPosition(void) CHECK_NULL_RETURN_NONE(sinkManager_, "sinkManager_ nullptr"); sinkManager_->GetRenderPosition(position); if (position >= 0 && currentPosition_ != position) { - currentPosition_ = position; + if (lastRendPos_ > 0) { + currentPosition_ = position - lastRendPos_ + firstPosAfterSeek_; + } else { + currentPosition_ = position; + } EventCallback(PLAYERCONTROL_EVENT_PROGRESS, ¤tPosition_); } } @@ -1217,7 +1223,12 @@ int32_t PlayerControl::DequeueInputDataFromDemuxer(void) if (formatPacket_.data == nullptr && formatPacket_.len == 0) { strmReadEnd_ = true; + formatPacket_.timestampUs = -1; gettimeofday(&streamEndTime_, nullptr); + if (loop_) { + seekToTimeMs_ = 0; + return HI_FAILURE; + } } isAudio_ = (formatPacket_.frameType == FRAME_TYPE_AUDIO) ? true : false; @@ -1281,6 +1292,8 @@ int32_t PlayerControl::QueueInputDataToAudioSink(void) } if (firstAudioFrameAfterSeek_) { firstAudioFrameAfterSeek_ = false; + sinkManager_->GetRenderPosition(lastRendPos_); + firstPosAfterSeek_ = formatPacket_.timestampUs; MEDIA_INFO_LOG("push firstAudioFrameAfterSeek_ success, pts:%lld", formatPacket_.timestampUs); } if (formatPacket_.data != nullptr || formatPacket_.len != 0) { @@ -1836,6 +1849,7 @@ int32_t PlayerControl::DoSeekIfNeed(void) if (seekToTimeMs_ == -1) { return HI_SUCCESS; } + MEDIA_INFO_LOG("seek start"); int32_t ret = AyncSeek(seekToTimeMs_); if (ret != HI_SUCCESS) { MEDIA_ERR_LOG(" AyncSeek failed , ret:%d", ret); @@ -1851,7 +1865,7 @@ int32_t PlayerControl::DoSeekIfNeed(void) seekToTimeMs_ = -1; firstAudioFrameAfterSeek_ = true; firstVideoFrameAfterSeek_ = true; - MEDIA_DEBUG_LOG("seek end"); + MEDIA_INFO_LOG("seek end"); return HI_SUCCESS; } @@ -1919,6 +1933,13 @@ void PlayerControl::PlayerControlCondSignal(void) } } +void PlayerControl::EnableSingleLooping(bool loop) +{ + MediaMutexLock(schMutex_); + loop_ = loop; + MediaMutexUnLock(schMutex_); +} + void PlayerControl::NotifyError(PlayerControlError playerError) const { EventCallback(PLAYERCONTROL_EVENT_ERROR, static_cast(&playerError)); @@ -1948,6 +1969,9 @@ void PlayerControl::FlushDecoder(void) const int32_t PlayerControl::DecoderAndSinkReset(void) { + if (strmReadEnd_ && loop_) { + return HI_SUCCESS; + } int32_t ret; bool isNeedResume = false; ret = sinkManager_->Pause(); @@ -1981,7 +2005,8 @@ int32_t PlayerControl::AyncSeek(int64_t seekTime) MEDIA_INFO_LOG("exec fmt_seek video stream failed, ret:%d", ret); seekTimeInMs = currentPosition_; } - } else if (fmtFileInfo_.s32UsedAudioStreamIndex != HI_DEMUXER_NO_MEDIA_STREAM) { + } + if (fmtFileInfo_.s32UsedAudioStreamIndex != HI_DEMUXER_NO_MEDIA_STREAM) { ret = playerSource_->Seek(fmtFileInfo_.s32UsedAudioStreamIndex, seekTimeInMs, FORMAT_SEEK_MODE_BACKWARD_KEY); if (ret != HI_SUCCESS) { MEDIA_INFO_LOG("exec fmt_seek audio stream failed, ret:%d", ret); diff --git a/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.h b/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.h index 739654cb2..7c8d532fb 100644 --- a/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.h +++ b/code/sdk/middleware/services/media/foundation/player/frameworks/player_control/player/liteplayer.h @@ -125,6 +125,7 @@ public: int32_t GetPlayerFileDumpInfo(PlayerFileDebugInfo &fileDebugInfo); void PlayerControlCondSignal(void); + void EnableSingleLooping(bool loop); protected: int32_t DoRegCallback(const PlayerCtrlCallbackParam &observer); @@ -272,6 +273,7 @@ private: SourceType sourceType_; bool firstAudioFrameAfterSeek_; bool firstVideoFrameAfterSeek_; + int64_t firstPosAfterSeek_; int32_t fd_; uint64_t offset_; std::string filePath_; 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 9e82e2cb3..42dc93487 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 @@ -985,6 +985,9 @@ int32_t Player::PlayerImpl::EnableSingleLooping(bool loop) return -1; } isSingleLoop_ = loop; + if (player_ != nullptr) { + player_->EnableSingleLooping(loop); + } MediaMutexUnLock(lock_); return 0; } diff --git a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h index c4b2f13d2..23c96bbde 100644 --- a/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h +++ b/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h @@ -115,6 +115,15 @@ public: */ static JSIValue SrcGetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** + * the getter of audio srcInner property + * + * @param thisVal Indicates function execute context + * @param args Indicates the function arguments + * @param argsSize Indicates the size of function arguments + */ + static JSIValue SrcInnerGetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** * the setter of audio src property * @@ -124,6 +133,15 @@ public: */ static JSIValue SrcSetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** + * the setter of audio srcInner property + * + * @param thisVal Indicates function execute context + * @param args Indicates the function arguments + * @param argsSize Indicates the size of function arguments + */ + static JSIValue SrcInnerSetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** * the getter of audio currentTime property * 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 3b71da894..30105485e 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 @@ -89,7 +89,7 @@ public: bool Stop(); - char *GetSrc() const; + char *GetSrc(bool innerFlag) const; double GetCurrentTime() const; @@ -107,7 +107,7 @@ public: bool IsPlaying() const; - bool SetSrc(char *src); + bool SetSrc(char *src, bool innerFlag); bool SetCurrentTime(double currentTime) const; @@ -159,6 +159,7 @@ private: static MediaMutexHandle lock_; static MediaThreadCondHandle condition_; static void *UpdateTimeHandler(void *arg); + static int GetSrcInnerPrefix(char *src, char *dest); Media::Player *player_; std::shared_ptr callback_; @@ -170,11 +171,13 @@ private: AudioEventListener *onErrorListener_; AudioEventListener *onTimeUpdateListener_; char *src_; + char *srcInner_; char *status_; double volume_; bool autoPlay_; bool muted_; bool isRunning_; + bool isSysSrc_; MediaThreadIdHandle updateTimeProcess_; }; } // namespace ACELite 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 c830fe084..174b29fac 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 @@ -153,7 +153,8 @@ JSIValue AudioModule::GetPlayState(const JSIValue thisVal, const JSIValue *args, AudioPlayer *audioPlayer = AudioPlayer::GetInstance(); JSIValue data = JSI::CreateObject(); JSI::SetStringProperty(data, "status", audioPlayer->GetStatus()); - JSI::SetStringProperty(data, "src", audioPlayer->GetSrc()); + JSI::SetStringProperty(data, "src", audioPlayer->GetSrc(false)); + JSI::SetStringProperty(data, "srcInner", audioPlayer->GetSrc(true)); JSI::SetNumberProperty(data, "currentTime", audioPlayer->GetCurrentTime()); JSI::SetBooleanProperty(data, "autoplay", audioPlayer->GetAutoPlay()); JSI::SetBooleanProperty(data, "loop", audioPlayer->IsLooping()); @@ -175,7 +176,13 @@ JSIValue AudioModule::GetPlayState(const JSIValue thisVal, const JSIValue *args, JSIValue AudioModule::SrcGetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) { - char *src = AudioPlayer::GetInstance()->GetSrc(); + char *src = AudioPlayer::GetInstance()->GetSrc(false); + return (src == nullptr) ? JSI::CreateUndefined() : JSI::CreateString(src); +} + +JSIValue AudioModule::SrcInnerGetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) +{ + char *src = AudioPlayer::GetInstance()->GetSrc(true); return (src == nullptr) ? JSI::CreateUndefined() : JSI::CreateString(src); } @@ -188,7 +195,24 @@ JSIValue AudioModule::SrcSetter(const JSIValue thisVal, const JSIValue *args, ui ActivateAudioInterrupt(); char *src = JSI::ValueToString(args[0]); bool autoPlay = AudioPlayer::GetInstance()->GetAutoPlay(); - bool ret = AudioPlayer::GetInstance()->SetSrc(src); + bool ret = AudioPlayer::GetInstance()->SetSrc(src, false); + AudioPlayer::GetInstance()->SetAudioSessionId(interrupt->sessionID); + if (autoPlay) { + AudioPlayer::GetInstance()->Play(); + } + return JSI::CreateBoolean(ret); +} + +JSIValue AudioModule::SrcInnerSetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) +{ + if (argsSize < 1) { + MEDIA_ERR_LOG("1 argument is required."); + return JSI::CreateBoolean(false); + } + ActivateAudioInterrupt(); + char *src = JSI::ValueToString(args[0]); + bool autoPlay = AudioPlayer::GetInstance()->GetAutoPlay(); + bool ret = AudioPlayer::GetInstance()->SetSrc(src, true); AudioPlayer::GetInstance()->SetAudioSessionId(interrupt->sessionID); if (autoPlay) { AudioPlayer::GetInstance()->Play(); @@ -435,6 +459,7 @@ void InitAudioModule(JSIValue exports) JSI::SetModuleAPI(exports, "getPlayState", AudioModule::GetPlayState); AudioModule::DefineProperty(exports, "src", AudioModule::SrcGetter, AudioModule::SrcSetter); + AudioModule::DefineProperty(exports, "srcInner", AudioModule::SrcInnerGetter, AudioModule::SrcInnerSetter); AudioModule::DefineProperty(exports, "currentTime", AudioModule::CurrentTimeGetter, AudioModule::CurrentTimeSetter); AudioModule::DefineProperty(exports, "duration", AudioModule::DurationGetter, AudioModule::DurationSetter); AudioModule::DefineProperty(exports, "autoplay", AudioModule::AutoPlayGetter, AudioModule::AutoPlaySetter); 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 5c636780d..a94b564ea 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 @@ -21,6 +21,8 @@ #include "js_async_work.h" #include "media_log.h" #include "audio_manager.h" +#include "bundlems_slite_client.h" +#include "abilityms_slite_client.h" #define DELETE_NOT_NULL(pointer) \ if (pointer != nullptr) \ @@ -38,6 +40,8 @@ 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(); @@ -125,11 +129,13 @@ AudioPlayer::AudioPlayer() : player_(nullptr), onErrorListener_(nullptr), onTimeUpdateListener_(nullptr), src_(nullptr), + srcInner_(nullptr), status_(const_cast(STATUS_STOP)), volume_(DEFAULT_VOLUME), autoPlay_(false), muted_(false), isRunning_(false), + isSysSrc_(false), updateTimeProcess_(nullptr) {} void AudioPlayer::ForkUpdateTimeThread() @@ -184,6 +190,25 @@ void *AudioPlayer::UpdateTimeHandler(void *arg) return nullptr; } +int AudioPlayer::GetSrcInnerPrefix(char *src, char *dest) +{ + int ret; + ElementName* topAbility = OHOS::AbilityMsClient::GetInstance().GetTopAbility(); + if (topAbility != nullptr) { + BundleInfo bundleInfo; + ret = BundleMsClient::GetInstance().GetBundleInfo(topAbility->bundleName, 0, &bundleInfo); + if (ret == 0) { + (void)sprintf_s(dest, MAX_PATH_LEN - 1, "%s/assets/entry/%s", bundleInfo.codePath, src); + return 0; + } else { + MEDIA_ERR_LOG("failed to get bundleInfo!"); + } + } else { + MEDIA_ERR_LOG("failed to get top ability!"); + } + return -1; +} + void AudioPlayer::StopUpdateTimeThread() { MediaMutexLock(lock_); @@ -267,10 +292,14 @@ void AudioPlayer::ReleaseEventListeners() void AudioPlayer::ReleaseSrc() { - if (src_ != nullptr) { + if (src_ != nullptr && isSysSrc_ == true) { ace_free(src_); src_ = nullptr; } + if (srcInner_ != nullptr && isSysSrc_ == false) { + ace_free(srcInner_); + srcInner_ = nullptr; + } } bool AudioPlayer::Play() @@ -321,9 +350,9 @@ bool AudioPlayer::Stop() return true; } -char *AudioPlayer::GetSrc() const +char *AudioPlayer::GetSrc(bool innerFlag) const { - return src_; + return innerFlag ? srcInner_ : src_; } double AudioPlayer::GetCurrentTime() const @@ -387,7 +416,7 @@ bool AudioPlayer::IsPlaying() const return player_->IsPlaying(); } -bool AudioPlayer::SetSrc(char *src) +bool AudioPlayer::SetSrc(char *src, bool innerFlag) { if (src_ != nullptr) { if (!DestoryPlayer()) { @@ -403,14 +432,28 @@ bool AudioPlayer::SetSrc(char *src) return true; } - std::string uri(src); + std::string uri; + if (innerFlag) { + srcInner_ = src; + (void)memset_s(absPath, MAX_PATH_LEN, 0, MAX_PATH_LEN); + if (GetSrcInnerPrefix(src, absPath) != 0) { + MEDIA_ERR_LOG("fail to get absolute path of srcInner."); + return false; + } + uri += absPath; + src_ = absPath; + isSysSrc_ = false; + } else { + uri += src; + src_ = src; + isSysSrc_ = true; + } std::map header; Media::Source source(uri, header); if (player_->SetSource(source) != 0) { MEDIA_ERR_LOG("fail to set audio src property."); return false; } - src_ = src; if (player_->Prepare() != 0) { MEDIA_ERR_LOG("fail to prepare."); return false; diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/video_play_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/video_play_wrapper.cpp index fab4fe7d7..42ef36bdf 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/video_play_wrapper.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/video_play_wrapper.cpp @@ -205,6 +205,7 @@ static int32_t VideoPlay(MediaVideoPlay *videoPlay) (void)videoPlay->player_->Release(); return MEDIA_ERR; } + videoPlay->player_->EnableSingleLooping(videoPlay->isLoop_); MediaMutexLock(videoPlay->mutex_); videoPlay->isPlayed_ = true; if (videoPlay->button_ != nullptr) { @@ -293,6 +294,24 @@ static Source GetVideoPlaySource(MediaVideoPlay *videoPlay) return source; } +static int32_t SetAudioSessionIdAndStreamType(MediaVideoPlay *videoPlay) +{ + int32_t ret = MEDIA_OK; + if (!videoPlay->isPureVideo_) { + ret = videoPlay->player_->SetAudioSessionId(videoPlay->sessionId_); + if (ret != MEDIA_OK) { + MEDIA_ERR_LOG("set audio sessionId failed\n"); + return ret; + } + ret = videoPlay->player_->SetAudioStreamType(AUDIO_STREAM_FITNESS_VIDEO); + if (ret != MEDIA_OK) { + MEDIA_ERR_LOG("set audio stream type failed\n"); + return ret; + } + } + return ret; +} + static int32_t RunVideoPlay(MediaVideoPlay *videoPlay) { bool success = InitPlayerResources(videoPlay); @@ -301,47 +320,32 @@ static int32_t RunVideoPlay(MediaVideoPlay *videoPlay) return MEDIA_ERR; } int32_t ret = 0; - do { - Source source = GetVideoPlaySource(videoPlay); - ret = videoPlay->player_->SetSource(source); - if (ret != 0) { - MEDIA_ERR_LOG("set source failed\n"); - (void)DeinitPlayerResources(videoPlay); - return MEDIA_ERR; - } - ret = videoPlay->player_->Prepare(); - if (ret != 0) { - MEDIA_ERR_LOG("prepare failed\n"); - return ReleasePlayer(videoPlay); - } - if (!videoPlay->isPureVideo_) { - ret = videoPlay->player_->SetAudioSessionId(videoPlay->sessionId_); - if (ret != 0) { - MEDIA_ERR_LOG("set audio sessionId failed\n"); - return ReleasePlayer(videoPlay); - } - ret = videoPlay->player_->SetAudioStreamType(AUDIO_STREAM_FITNESS_VIDEO); - if (ret != 0) { - MEDIA_ERR_LOG("set audio stream type failed\n"); - return ReleasePlayer(videoPlay); - } - } - ret = videoPlay->player_->SetVideoSurface(videoPlay->surface_); - if (ret != 0) { - MEDIA_ERR_LOG("set video surface failed\n"); - return ReleasePlayer(videoPlay); - } - ret = VideoPlay(videoPlay); - if (ret != 0) { - return ReleasePlayer(videoPlay); - } - VideoStopAndExit(videoPlay); - if (videoPlay->isPlaybackStopped_ || - videoPlay->playError_ || - videoPlay->interruptHintStop_) { - break; - } - } while (videoPlay->isLoop_); + Source source = GetVideoPlaySource(videoPlay); + ret = videoPlay->player_->SetSource(source); + if (ret != 0) { + MEDIA_ERR_LOG("set source failed\n"); + (void)DeinitPlayerResources(videoPlay); + return MEDIA_ERR; + } + ret = videoPlay->player_->Prepare(); + if (ret != 0) { + MEDIA_ERR_LOG("prepare failed\n"); + return ReleasePlayer(videoPlay); + } + ret = SetAudioSessionIdAndStreamType(videoPlay); + if (ret != 0) { + return ReleasePlayer(videoPlay); + } + ret = videoPlay->player_->SetVideoSurface(videoPlay->surface_); + if (ret != 0) { + MEDIA_ERR_LOG("set video surface failed\n"); + return ReleasePlayer(videoPlay); + } + ret = VideoPlay(videoPlay); + if (ret != 0) { + return ReleasePlayer(videoPlay); + } + VideoStopAndExit(videoPlay); SendBackgroundFrame(videoPlay); return 0; } diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/video_player_sample_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/video_player_sample_wrapper.cpp index 7faba9cc8..cea092d80 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/video_player_sample_wrapper.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/video_player_sample_wrapper.cpp @@ -311,11 +311,6 @@ static void VideoStopAndExit(shared_ptr player) if (ret != 0) { MEDIA_ERR_LOG("Reset failed"); } - - if (g_isNeedLoop) { - return; - } - ret = player->Release(); if (ret != 0) { MEDIA_ERR_LOG("Release failed"); @@ -376,6 +371,7 @@ static int32_t VideoPlay(VideoPlaySampleContext *context) MEDIA_ERR_LOG("Play failed"); goto RELEASE_PLAYER; } + context->player->EnableSingleLooping(g_isNeedLoop); MediaMutexLock(g_videoPlayContextMutex); #if defined(ENABLE_LVGL) g_isPlayed = true; @@ -432,54 +428,50 @@ static int32_t RunVideoPlay(VideoPlaySampleContext *context) MEDIA_ERR_LOG("init player resources failed"); return -1; } - do { - std::string uri(context->filePath); - std::map header; - Source source(uri, header); - int32_t ret = context->player->SetSource(source); - if (ret != 0) { - MEDIA_ERR_LOG("SetSource failed"); - goto DEINIT_PLAYER; - } - ret = context->player->Prepare(); - if (ret != 0) { - MEDIA_ERR_LOG("Prepare failed"); - goto RELEASE_PLAYER; - } - ret = context->player->SetAudioSessionId(context->sessionId); - if (ret != 0) { - MEDIA_ERR_LOG("SetAudioSessionId failed"); - goto RELEASE_PLAYER; - } - ret = context->player->SetAudioStreamType(AUDIO_STREAM_FITNESS_VIDEO); - if (ret != 0) { - MEDIA_ERR_LOG("SetAudioStreamType failed"); - goto RELEASE_PLAYER; - } + std::string uri(context->filePath); + std::map header; + Source source(uri, header); + int32_t ret = context->player->SetSource(source); + if (ret != 0) { + MEDIA_ERR_LOG("SetSource failed"); + goto DEINIT_PLAYER; + } + ret = context->player->Prepare(); + if (ret != 0) { + MEDIA_ERR_LOG("Prepare failed"); + goto RELEASE_PLAYER; + } + ret = context->player->SetAudioSessionId(context->sessionId); + if (ret != 0) { + MEDIA_ERR_LOG("SetAudioSessionId failed"); + goto RELEASE_PLAYER; + } + ret = context->player->SetAudioStreamType(AUDIO_STREAM_FITNESS_VIDEO); + if (ret != 0) { + MEDIA_ERR_LOG("SetAudioStreamType failed"); + goto RELEASE_PLAYER; + } #if defined(ENABLE_UIKIT) - ret = context->player->SetVideoSurface(context->surface); + ret = context->player->SetVideoSurface(context->surface); #elif defined(ENABLE_LVGL) - ret = context->player->SetVideoSurface(g_surface); + ret = context->player->SetVideoSurface(g_surface); #endif - if (ret != 0) { - MEDIA_ERR_LOG("SetVideoSurface failed"); - goto RELEASE_PLAYER; - } - ret = VideoPlay(context); - if (ret != 0) { - goto RELEASE_PLAYER; - } - VideoStopAndExit(context->player); + if (ret != 0) { + MEDIA_ERR_LOG("SetVideoSurface failed"); + goto RELEASE_PLAYER; + } + ret = VideoPlay(context); + if (ret != 0) { + goto RELEASE_PLAYER; + } + VideoStopAndExit(context->player); #if defined(ENABLE_LVGL) - context->isPlaybackCompleted = false; - if (g_isNeedLoop) { - MediaMutexLock(g_videoPlayContextMutex); - g_isPlayed = false; - g_pause = false; - MediaMutexUnLock(g_videoPlayContextMutex); - } + context->isPlaybackCompleted = false; + MediaMutexLock(g_videoPlayContextMutex); + g_isPlayed = false; + g_pause = false; + MediaMutexUnLock(g_videoPlayContextMutex); #endif - } while (g_isNeedLoop); return 0; RELEASE_PLAYER: diff --git a/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/raw_format.c b/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/raw_format.c index 3bf0235b4..ce9d5b66e 100644 --- a/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/raw_format.c +++ b/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/raw_format.c @@ -202,8 +202,13 @@ static int32_t RawFormatFree(HalHandle fmtHandle, FormatPacket *fmtFrame) static int32_t RawFormatSeek(__attribute__((unused)) HalHandle fmtHandle, __attribute__((unused))int32_t streamIndex, __attribute__((unused)) int64_t toMs, __attribute__((unused)) uint32_t flag) { - MEDIA_HAL_LOGE(MODULE_NAME, "not support"); - return ERR_DEMUXER_NOT_SUPPORT; + RawFormatMember *member = (RawFormatMember *)fmtHandle; + CHK_NULL_RETURN(member, ERR_DEMUXER_INVALID_HANDLE, "input param fmtHandle null"); + CHK_FAILED_RETURN(member->prepared, true, -1, "not prepared"); + CHK_NULL_RETURN(member->ops, ERR_DEMUXER_NULL_PTR, "ops null"); + CHK_NULL_RETURN(member->demuxer, ERR_DEMUXER_NULL_PTR, "demuxer null"); + CHK_NULL_RETURN(member->ops->Seek, ERR_DEMUXER_NULL_PTR, "Seek null"); + return member->ops->Seek(member->demuxer, toMs, flag); } static int32_t RawFormatSeekPos(__attribute__((unused)) HalHandle fmtHandle, int64_t pos, uint32_t whence) diff --git a/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/sbc_demuxer.c b/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/sbc_demuxer.c index 3f7058b84..d48c033c0 100644 --- a/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/sbc_demuxer.c +++ b/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/sbc_demuxer.c @@ -104,6 +104,18 @@ static void SBCDemuxerClose(HalHandle fmtHandle) free(demuxer); } +static void FillFrameCommonInfo(FormatPacket *fmtFrame, int64_t timestamp) +{ + fmtFrame->packetType = PACKET_TYPE_AUDIO; + fmtFrame->trackId = 0; + fmtFrame->isKeyFrame = true; + fmtFrame->timestampUs = timestamp; + fmtFrame->durationUs = -1; + fmtFrame->frameIndex = 0; + fmtFrame->itemCnt = 0; + fmtFrame->item = NULL; +} + static int32_t SBCDemuxerReadFrame(HalHandle fmtHandle, FormatPacket *fmtFrame) { SBCDemuxer *demuxer = (SBCDemuxer *)fmtHandle; @@ -120,15 +132,7 @@ static int32_t SBCDemuxerReadFrame(HalHandle fmtHandle, FormatPacket *fmtFrame) return MEDIA_HAL_NO_MEM; } - size_t readLen = fread(fmtFrame->data, 1, SBC_BLOCK_DATA_SIZE, demuxer->file); - if (readLen == -1) { - free(fmtFrame->data); - fmtFrame->data = NULL; - fmtFrame->len = 0; - MEDIA_HAL_LOGE(MODULE_NAME, "fread falied"); - return MEDIA_HAL_ERR; - } - + uint32_t readLen = fread(fmtFrame->data, 1, SBC_BLOCK_DATA_SIZE, demuxer->file); if (readLen == 0) { free(fmtFrame->data); fmtFrame->data = NULL; @@ -136,14 +140,13 @@ static int32_t SBCDemuxerReadFrame(HalHandle fmtHandle, FormatPacket *fmtFrame) demuxer->eof = true; return RET_FILE_EOF; } - fmtFrame->packetType = PACKET_TYPE_AUDIO; fmtFrame->len = readLen; - + FillFrameCommonInfo(fmtFrame, -1); return MEDIA_HAL_OK; } -static int32_t SBCDemuxerFreeFrame(HalHandle fmtHandle, FormatPacket *fmtFrame) +static int32_t SBCDemuxerFreeFrame(const HalHandle fmtHandle, FormatPacket *fmtFrame) { MEDIA_HAL_UNUSED(fmtHandle); if (fmtFrame->data != NULL) { @@ -155,11 +158,19 @@ static int32_t SBCDemuxerFreeFrame(HalHandle fmtHandle, FormatPacket *fmtFrame) static int32_t SBCDemuxerSeek(HalHandle fmtHandle, int64_t toMs, uint32_t flag) { - MEDIA_HAL_UNUSED(fmtHandle); - MEDIA_HAL_UNUSED(toMs); + SBCDemuxer *demuxer = (SBCDemuxer *)fmtHandle; MEDIA_HAL_UNUSED(flag); - - MEDIA_HAL_LOGE(MODULE_NAME, "not support"); + if (toMs == 0) { + int32_t ret = fseek(demuxer->file, toMs, SEEK_SET); + if (ret != 0) { + MEDIA_HAL_LOGE(MODULE_NAME, "failed to seek to the sbc file header."); + return MEDIA_HAL_ERR; + } + demuxer->eof = false; + } else { + MEDIA_HAL_LOGE(MODULE_NAME, "not support"); + return MEDIA_HAL_ERR; + } return MEDIA_HAL_OK; } diff --git a/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/silk_demuxer.c b/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/silk_demuxer.c index 37c1f3bc7..b0e14defd 100644 --- a/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/silk_demuxer.c +++ b/code/sdk/middleware/services/media/hal/format/plugins/raw_demuxer/silk_demuxer.c @@ -71,6 +71,7 @@ typedef struct { int32_t readLen; int32_t prepared; FILE *file; + int64_t fileSeekStartPosition; } SilkRawDemuxer; static HalHandle SilkDemuxerOpen(const char *url) @@ -111,6 +112,7 @@ static HalHandle SilkDemuxerOpen(const char *url) demuxer->prepared = false; demuxer->firstFrame = true; demuxer->position = 0; + demuxer->fileSeekStartPosition = 0; MEDIA_HAL_LOGI(MODULE_NAME, "buffer Demuxer open"); return (HalHandle)demuxer; FREE: @@ -293,8 +295,21 @@ static int32_t SilkDemuxerFreeFrame(HalHandle fmtHandle, FormatPacket *fmtFrame) static int32_t SilkDemuxerSeek(__attribute__((unused)) HalHandle fmtHandle, __attribute__((unused)) int64_t toMs, __attribute__((unused)) uint32_t flag) { - MEDIA_HAL_LOGE(MODULE_NAME, "not support"); - return MEDIA_HAL_ERR; + SilkRawDemuxer *demuxer = (SilkRawDemuxer *)fmtHandle; + if (toMs == 0) { + int32_t ret = fseek(demuxer->file, demuxer->fileSeekStartPosition, SEEK_SET); + if (ret != 0) { + MEDIA_HAL_LOGE(MODULE_NAME, "failed to seek to the silk file header."); + return MEDIA_HAL_ERR; + } + demuxer->eof = false; + demuxer->position = demuxer->fileSeekStartPosition; + MEDIA_HAL_LOGI(MODULE_NAME, "SilkRawDemuxer seek success = %d!!", ftell(demuxer->file)); + } else { + MEDIA_HAL_LOGE(MODULE_NAME, "not support"); + return MEDIA_HAL_ERR; + } + return MEDIA_HAL_OK; } static int32_t GetBlockSampleRateAndLength(SilkRawDemuxer *demuxer, int32_t *sampleRate, int16_t *length) @@ -341,6 +356,7 @@ static int32_t ProbeScore(SilkRawDemuxer *demuxer, int32_t *score, int32_t offse { demuxer->probeSuccessed = true; demuxer->position = offset + SILK_HEAD_SIZE; + demuxer->fileSeekStartPosition = offset + SILK_HEAD_SIZE; if (fseek(demuxer->file, offset + SILK_HEAD_SIZE, SEEK_SET) != 0) { return MEDIA_HAL_ERR; } diff --git a/code/sdk/middleware/utils/dfx/CMakeLists.txt b/code/sdk/middleware/utils/dfx/CMakeLists.txt index dd8765faa..d5a904b8b 100644 --- a/code/sdk/middleware/utils/dfx/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/CMakeLists.txt @@ -140,6 +140,11 @@ else() ${CMAKE_CURRENT_SOURCE_DIR}/diag_transmit/ ) endif() +set(PRIVATE_HEADER + ${PRIVATE_HEADER} + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/diag_system_cmd/include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/diag_system_cmd/dfx_include +) set(PRIVATE_DEFINES ) @@ -435,6 +440,8 @@ set(PUBLIC_HEADER ) set(PRIVATE_HEADER + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/last_dump/dfx_include + ${ROOT_DIR}/middleware/utils/dfx/diag_dfx_cmd/last_dump/include ) set(PRIVATE_DEFINES diff --git a/code/sdk/middleware/utils/dfx/dfx_reboot/cpu_utils/private/cpu_utils.c b/code/sdk/middleware/utils/dfx/dfx_reboot/cpu_utils/private/cpu_utils.c index f4439d64a..f6e492c78 100644 --- a/code/sdk/middleware/utils/dfx/dfx_reboot/cpu_utils/private/cpu_utils.c +++ b/code/sdk/middleware/utils/dfx/dfx_reboot/cpu_utils/private/cpu_utils.c @@ -43,6 +43,10 @@ #include "nandflash_config.h" #endif +#if !defined(BUILD_RECOVERY_IMAGE) && !defined(BUILD_APPLICATION_SSB) +#include "cmsis_os2.h" +#endif + #if MCU_ONLY static cpu_utils_reboot_cb g_reboot_mcu_cb = NULL; #endif @@ -137,6 +141,7 @@ static void exception_test_init(void) } #ifdef SUPPORT_IPC + static bool cpu_utils_sys_reboot_req(ipc_action_t message, const volatile ipc_payload *payload_p, cores_t src, uint32_t id) { @@ -154,7 +159,7 @@ static bool cpu_utils_sys_reboot_req(ipc_action_t message, const volatile ipc_pa #endif set_update_reset_cause_on_boot(false); #if MCU_ONLY && defined(USE_CMSIS_OS) - log_oml_memory_dump(); + log_bt_req_dump(); #endif #if MCU_ONLY if (g_reboot_mcu_cb != NULL) { // when registering g_reboot_mcu_cb, need to restart chip by yourself. @@ -167,7 +172,20 @@ static bool cpu_utils_sys_reboot_req(ipc_action_t message, const volatile ipc_pa set_trans_type(TRANS_BY_CPU_SINGLE_LINE); #endif reset_deal_with_fs(); - cpu_utils_reset_chip_with_log(src, (reboot_cause_t)reboot_reason); +#if defined(BUILD_APPLICATION_STANDARD) && (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == NO) + PRINT("Reboot by core:%d with reason of 0x%x", src, reboot_reason); +#endif + +#if (CORE == MASTER_BY_ALL) + set_update_reset_cause_on_boot(false); +#endif + cpu_utils_set_system_status_by_cause(reboot_reason); +#if !defined(BUILD_RECOVERY_IMAGE) && !defined(BUILD_APPLICATION_SSB) + /* Give the semaphore to ensure the main logging task will be active */ + (void)osSemaphoreRelease(get_save_file_semaphore()); +#else + hal_reboot_chip(); +#endif return true; } diff --git a/code/sdk/middleware/utils/dfx/dfx_reboot/reboot/shared/non_os_reboot.h b/code/sdk/middleware/utils/dfx/dfx_reboot/reboot/shared/non_os_reboot.h index cfe4cba4e..898bd5c88 100644 --- a/code/sdk/middleware/utils/dfx/dfx_reboot/reboot/shared/non_os_reboot.h +++ b/code/sdk/middleware/utils/dfx/dfx_reboot/reboot/shared/non_os_reboot.h @@ -101,6 +101,7 @@ typedef enum { REBOOT_CAUSE_UPG_COMPLETION = 0x2040, // !< Start of custom reset reasons REBOOT_CAUSE_MON_MEM_ALMOST_EMPTY = 0x2041, + REBOOT_CAUSE_APPLICATION_SECOND_FAULT = 0x2042, REBOOT_CAUSE_APPLICATION_RPC_TIMEOUT = 0x2100, // !< Start of custom reset reasons diff --git a/code/sdk/middleware/utils/dfx/diag/diag_cmd_router/diag_ind_src.c b/code/sdk/middleware/utils/dfx/diag/diag_cmd_router/diag_ind_src.c index 89c3c5be5..7da9d3360 100644 --- a/code/sdk/middleware/utils/dfx/diag/diag_cmd_router/diag_ind_src.c +++ b/code/sdk/middleware/utils/dfx/diag/diag_cmd_router/diag_ind_src.c @@ -28,6 +28,8 @@ #define SUB_MOD_ID_OFFSET 8 #define PKT_DATA_CNT_2 2 +static diag_msg_flow_control_hook g_flow_control_hook = NULL; + STATIC bool zdiag_msg_permit(uint32_t module_id, uint8_t level) { if ((zdiag_is_enable() == false) && (uapi_zdiag_offline_log_is_enable() != true)) { @@ -153,6 +155,12 @@ static errcode_t uapi_diag_report_packet_direct_secure(uint16_t cmd_id, diag_opt return ERRCODE_SUCC; } #endif + +void uapi_diag_register_msg_flow_control_hook(diag_msg_flow_control_hook func) +{ + g_flow_control_hook = func; +} + errcode_t uapi_diag_report_packet(uint16_t cmd_id, diag_option_t *option, const uint8_t *packet, uint16_t packet_size, bool sync) { @@ -308,6 +316,9 @@ errcode_t uapi_zdiag_report_sys_msg_instance(uint32_t module_id, uint32_t msg_id return ERRCODE_FAIL; } + if (g_flow_control_hook != NULL && g_flow_control_hook((uint8_t)module_id, level) == false) { + return ERRCODE_FAIL; + } diag_pkt_handle_init(&pkt, 1); /* data_cnt 为1 */ if (uapi_zdiag_offline_log_is_enable()) { diff --git a/code/sdk/middleware/utils/dfx/diag/include/diag_msg.h b/code/sdk/middleware/utils/dfx/diag/include/diag_msg.h index 0995edff4..a9b5e2390 100644 --- a/code/sdk/middleware/utils/dfx/diag/include/diag_msg.h +++ b/code/sdk/middleware/utils/dfx/diag/include/diag_msg.h @@ -11,9 +11,12 @@ #include "diag_common.h" #include "diag_channel.h" +typedef bool (*diag_msg_flow_control_hook)(uint8_t mid, uint8_t level); + errcode_t diag_msg_proc(uint16_t msg_id, uint8_t *msg, uint32_t msg_len); void uapi_zdiag_set_offline_log_enable(bool enable); bool uapi_zdiag_offline_log_is_enable(void); +void uapi_diag_register_msg_flow_control_hook(diag_msg_flow_control_hook func); #endif diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/CMakeLists.txt b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/CMakeLists.txt index 39443c864..ac54a4e6b 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/CMakeLists.txt @@ -33,6 +33,9 @@ set(SOURCES ) set(PUBLIC_HEADER +) + +set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/diag_system_cmd/include ${CMAKE_CURRENT_SOURCE_DIR}/diag_system_cmd/dfx_include ${CMAKE_CURRENT_SOURCE_DIR}/diag_mocked_shell/include @@ -40,9 +43,6 @@ set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/last_dump/include ${CMAKE_CURRENT_SOURCE_DIR}/sample_data/dfx_include ${CMAKE_CURRENT_SOURCE_DIR}/sample_data/include -) - -set(PRIVATE_HEADER ${CMAKE_SOURCE_DIR}/include/middleware/utils ) set(PRIVATE_DEFINES diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/CMakeLists.txt b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/CMakeLists.txt index ca02b3a8a..93e14b5de 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include ) set(PRIVATE_HEADER diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/zdiag_audio_dump.c b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/zdiag_audio_dump.c index ff233c1ce..f3d67d859 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/zdiag_audio_dump.c +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_dump/zdiag_audio_dump.c @@ -544,10 +544,8 @@ static int32_t dump_open_inst(audio_dump_inst *dump_inst) uapi_adp_attr adp_attr; osThreadAttr_t task_attr = {0}; thread_callback func_call = NULL; - char *real_path = NULL; - real_path = realpath(dump_inst->file_path, NULL); - dump_inst->h_file = fopen(real_path, "wb"); + dump_inst->h_file = fopen(dump_inst->file_path, "wb"); if (dump_inst->h_file == NULL) { diag_dump_log("open %s failed.", dump_inst->file_path); return ERRCODE_FAIL; diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_probe/CMakeLists.txt b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_probe/CMakeLists.txt index 01eb0cb85..0db1fa145 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_probe/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_probe/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include ) set(PRIVATE_HEADER diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_proc/CMakeLists.txt b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_proc/CMakeLists.txt index 9292cf1e3..762672d06 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_proc/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_audio_proc/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include ) set(PRIVATE_HEADER diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/CMakeLists.txt b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/CMakeLists.txt index 8a57d15ec..03865a512 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_gpu_proc/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include ) set(PRIVATE_HEADER diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_nv/CMakeLists.txt b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_nv/CMakeLists.txt index 5650c7e7d..86351c956 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_nv/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_nv/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include ) set(PRIVATE_HEADER diff --git a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_update/CMakeLists.txt b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_update/CMakeLists.txt index 348c5d4d0..c23cf2f54 100644 --- a/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_update/CMakeLists.txt +++ b/code/sdk/middleware/utils/dfx/diag_dfx_cmd/diag_update/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES ) set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include ) set(PRIVATE_HEADER diff --git a/code/sdk/middleware/utils/dfx/log/log_oml_exception.c b/code/sdk/middleware/utils/dfx/log/log_oml_exception.c index 905042f9f..cdf3a5554 100644 --- a/code/sdk/middleware/utils/dfx/log/log_oml_exception.c +++ b/code/sdk/middleware/utils/dfx/log/log_oml_exception.c @@ -46,6 +46,8 @@ #include "last_dump_adapt.h" #endif #endif +#include "chip_io.h" +#include "nandflash_config.h" #define STACK_SIZE 3 @@ -446,6 +448,18 @@ static void log_watch_dog_reconfigure(void) uapi_watchdog_enable(WDT_MODE_INTERRUPT); } +void log_bt_req_dump(void) +{ +#if (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == NO) + log_watch_dog_reconfigure(); +#endif + +#ifdef HSO_SUPPORT + dfx_last_dump(); +#endif + return; +} + void log_oml_memory_dump(void) { #if (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == NO) @@ -453,9 +467,14 @@ void log_oml_memory_dump(void) #if CORE == BT /* BT core has just one block of ram */ uapi_tcxo_delay_ms(DUMP_DELAY); -#elif CORE == APPS +#elif CORE == APPS && !defined(BUILD_RECOVERY_IMAGE) #ifdef HSO_SUPPORT dfx_last_dump(); + nand_driver_init(SPEED_SLOW); + set_trans_type(TRANS_BY_CPU_SINGLE_LINE); +#if defined SAVE_EXC_INFO + save_preserve_file_to_nand(); +#endif #else log_exception_dump_memory(APP_ITCM_ORIGIN, APP_ITCM_LENGTH); log_exception_dump_memory(APP_DTCM_ORIGIN, APP_DTCM_LENGTH); diff --git a/code/sdk/middleware/utils/dfx/preserve/private/preserve.c b/code/sdk/middleware/utils/dfx/preserve/private/preserve.c index 85414eccb..e26b6d8e8 100644 --- a/code/sdk/middleware/utils/dfx/preserve/private/preserve.c +++ b/code/sdk/middleware/utils/dfx/preserve/private/preserve.c @@ -21,6 +21,8 @@ #define RESERVED_PC_INDEX 0 #define RESERVED_LR_INDEX 1 #define RESERVED_SP_INDEX 2 +#define BTRACE_ADDR_EXEC 0x5900E000 +#define BTRACE_ADDR_EXEC_LEN 0X1FF8 // all security core preserve data here, if want to add new,should add tail for compatible befor version #pragma pack(4) @@ -100,6 +102,31 @@ static void system_set_reboot_status_by_crash_cause(void) g_preserve_data_lib.reboot_status = REBOOT_SOFT_PANIC_TRIGGER_STATUS; } } +#if defined SAVE_EXC_INFO +#if !defined(BUILD_RECOVERY_IMAGE) +void save_preserve_file_to_nand(void) +{ + const char *preserve_info_ex_path = "/user/exc/preserve.bin"; + int32_t ret = exc_info_write(preserve_info_ex_path, 0, (uint8_t *)&g_preserve_data_lib, sizeof(preserve_data_t)); + printf("save_preserve_file_to_nand ret:%d.\r\n", ret); +} + +void save_btram_file_to_nand(void) +{ + const char *btram_info_path = "/user/exc/bt_ram_info.bin"; + int32_t ret = + exc_info_write(btram_info_path, 0, (uint8_t *)BT_RAM_ORIGIN_APP_MAPPING, BT_RAM_ORIGIN_APP_MAPPING_LENGTH); + printf("save_btram_file_to_nand ret:%d.\r\n", ret); +} + +void save_btrace_file_to_nand(void) +{ + const char *btrace_info_path = "/user/exc/btrace_info.bin"; + int32_t ret = exc_info_write(btrace_info_path, 0, (uint8_t *)BTRACE_ADDR_EXEC, BTRACE_ADDR_EXEC_LEN); + printf("save_btrace_file_to_nand ret:%d.\r\n", ret); +} +#endif +#endif #ifdef weak weak void watchdog_porting_pmu_reboot(void) @@ -115,8 +142,11 @@ void system_boot_status_init(void) { bool is_hardwdg_timeout = false; if (!hal_reboot_get_ulp_aon_no_poweroff_flag()) { + hal_reboot_set_first_power_on_flag(); hal_reboot_set_ulp_aon_no_poweroff_flag(); memset_s((void *)&g_preserve_data_lib, sizeof(g_preserve_data_lib), 0, sizeof(g_preserve_data_lib)); + } else { + hal_reboot_clear_first_power_on_flag(); } if (g_preserve_data_lib.magic == 0) { // Hard power-off restart diff --git a/code/sdk/middleware/utils/dfx/preserve/public/preserve.h b/code/sdk/middleware/utils/dfx/preserve/public/preserve.h index 638afd0b4..8d735faca 100644 --- a/code/sdk/middleware/utils/dfx/preserve/public/preserve.h +++ b/code/sdk/middleware/utils/dfx/preserve/public/preserve.h @@ -112,6 +112,13 @@ uint32_t get_system_magic(void); void show_reboot_info(void); +#if !defined(BUILD_RECOVERY_IMAGE) +void save_preserve_file_to_nand(void); + +void save_btram_file_to_nand(void); + +void save_btrace_file_to_nand(void); +#endif /** * @} */ diff --git a/code/sdk/open_source/openharmony/base/global/i18n_lite/CMakeLists.txt b/code/sdk/open_source/openharmony/base/global/i18n_lite/CMakeLists.txt index 2166b4a29..572bdff94 100644 --- a/code/sdk/open_source/openharmony/base/global/i18n_lite/CMakeLists.txt +++ b/code/sdk/open_source/openharmony/base/global/i18n_lite/CMakeLists.txt @@ -1,11 +1,11 @@ set(COMPONENT_NAME "i18n") set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/i18n/include - ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/kits/i18n/include ) set(PRIVATE_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/i18n/include + ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/kits/i18n/include ) set(SOURCES diff --git a/code/sdk/open_source/openharmony/base/global/resmgr_lite/CMakeLists.txt b/code/sdk/open_source/openharmony/base/global/resmgr_lite/CMakeLists.txt index 6c4895fed..2cf01e081 100644 --- a/code/sdk/open_source/openharmony/base/global/resmgr_lite/CMakeLists.txt +++ b/code/sdk/open_source/openharmony/base/global/resmgr_lite/CMakeLists.txt @@ -1,11 +1,11 @@ set(COMPONENT_NAME "resmgr") set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/resmgr_lite/include - ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/innerkits/include ) set(PRIVATE_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/resmgr_lite/include + ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/innerkits/include ) set(SOURCES diff --git a/code/sdk/open_source/openharmony/base/security/permission/CMakeLists.txt b/code/sdk/open_source/openharmony/base/security/permission/CMakeLists.txt index ebb566d3b..5a38671bd 100644 --- a/code/sdk/open_source/openharmony/base/security/permission/CMakeLists.txt +++ b/code/sdk/open_source/openharmony/base/security/permission/CMakeLists.txt @@ -6,6 +6,8 @@ set(PUBLIC_HEADER set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/third_party/cJSON + ${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 ) set(SOURCES diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/keys.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/keys.h index c05f28bb6..0e36c5915 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/keys.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/base/keys.h @@ -266,12 +266,14 @@ enum { #endif // FEATURE_COMPONENT_TABS KEYWORD(TEXT, text) // tag name, picker-view attr value KEYWORD(TEXT_ALIGN, textAlign) // text style type + KEYWORD(TEXT_ALIGN_VERTICAL, textAlignVertical) //text style vertical type KEYWORD(TEXT_OVERFLOW, textOverflow) // text style type KEYWORD(TIME, time) // picker-view attr value #ifdef FEATURE_COMPONENT_VIDEO KEYWORD(TIME_UPDATE, timeupdate) // video component timeupdate event tag #endif // FEATURE_COMPONENT_VIDEO KEYWORD(TOP, top) + KEYWORD(BOTTOM, bottom) KEYWORD(TOTAL_ANGLE, total-angle) // circle progress style #ifdef JS_TOUCH_EVENT_SUPPORT KEYWORD(TOUCHCANCEL, touchcancel) // ontouchcancel event 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 16e297962..76ea6a4db 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 de42bae56..f294d808c 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/baidu_map_component.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/baidu_map_component.cpp index 7a40c0209..58a91159a 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/baidu_map_component.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/baidu_map_component.cpp @@ -43,6 +43,12 @@ const char * const BaiduMapComponent::FUNC_START_LISTEN_MY_GEO_LOCATION = "start const char * const BaiduMapComponent::FUNC_STOP_LISTEN_MY_GEO_LOCATION = "stop_listen_my_geo_location"; const char * const BaiduMapComponent::FUNC_GET_MY_GEO_STATUS = "get_my_geo_status"; const char * const BaiduMapComponent::FUNC_GET_MY_GEO_LOCATION = "get_my_geo_location"; +const char * const BaiduMapComponent::FUNC_DRAW_CIRCLE = "draw_circle"; +const char * const BaiduMapComponent::FUNC_DRAW_NAVI_MARKER = "draw_navi_marker"; +const char * const BaiduMapComponent::FUNC_OVERLAYER_CLEAR_CIRCLE = "overlayer_clear_circle"; +const char * const BaiduMapComponent::FUNC_OVERLAYER_CLEAR_MARKER = "overlayer_clear_marker"; +const char * const BaiduMapComponent::FUNC_OVERLAYER_CLEAR_NAVI_MARKER = "overlayer_clear_navi_marker"; +const char * const BaiduMapComponent::FUNC_DESTROY = "destroy"; const FunctionMap BaiduMapComponent::funcMap[] = { {FUNC_SET_ZOOM_EVENT_ENABLED, SetZoomEventEnabled}, @@ -65,7 +71,13 @@ const FunctionMap BaiduMapComponent::funcMap[] = { {FUNC_START_LISTEN_MY_GEO_LOCATION, StartListenMyGeoLocation}, {FUNC_STOP_LISTEN_MY_GEO_LOCATION, StopListenMyGeoLocation}, {FUNC_GET_MY_GEO_STATUS, GetMyGeoStatus}, - {FUNC_GET_MY_GEO_LOCATION, GetMyGeoLocation} + {FUNC_GET_MY_GEO_LOCATION, GetMyGeoLocation}, + {FUNC_DRAW_CIRCLE, DrawCircle}, + {FUNC_DRAW_NAVI_MARKER, DrawNaviMarker}, + {FUNC_OVERLAYER_CLEAR_CIRCLE, OverlayerClearCircle}, + {FUNC_OVERLAYER_CLEAR_MARKER, OverlayerClearMarker}, + {FUNC_OVERLAYER_CLEAR_NAVI_MARKER, OverlayerClearNaviMarker}, + {FUNC_DESTROY, Destroy} }; BaiduMapComponent::BaiduMapComponent(jerry_value_t options, jerry_value_t children, AppStyleManager* styleManager) : Component(options, children, styleManager) @@ -208,6 +220,15 @@ JSValue BaiduMapComponent::DrawMarker(const jerry_value_t func, const jerry_valu return UNDEFINED; } +JSValue BaiduMapComponent::DrawNaviMarker(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"DrawNaviMarker"); + char *json_navi_marker = MallocStringOf(args[0]); + MapComponentApi::getInstance().draw_navi_marker(json_navi_marker); + return UNDEFINED; +} + JSValue BaiduMapComponent::DrawPolygon(const jerry_value_t func, const jerry_value_t context, const jerry_value_t args[], const jerry_length_t argsSize) { @@ -226,6 +247,15 @@ JSValue BaiduMapComponent::DrawPath(const jerry_value_t func, const jerry_value_ return UNDEFINED; } +JSValue BaiduMapComponent::DrawCircle(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"DrawCircle"); + char *json_circle = MallocStringOf(args[0]); + MapComponentApi::getInstance().draw_circle(json_circle); + return UNDEFINED; +} + JSValue BaiduMapComponent::DrawText(const jerry_value_t func, const jerry_value_t context, const jerry_value_t args[], const jerry_length_t argsSize) { @@ -263,6 +293,38 @@ JSValue BaiduMapComponent::GetMyGeoLocation(const jerry_value_t func, const jerr return UNDEFINED; } +JSValue BaiduMapComponent::OverlayerClearCircle(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"OverlayerClearCircle"); + MapComponentApi::getInstance().overlayer_clear_circle(); + return UNDEFINED; +} + +JSValue BaiduMapComponent::OverlayerClearMarker(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"OverlayerClearMarker"); + MapComponentApi::getInstance().overlayer_clear_marker(); + return UNDEFINED; +} + +JSValue BaiduMapComponent::OverlayerClearNaviMarker(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"OverlayerClearNaviMarker"); + MapComponentApi::getInstance().overlayer_clear_navi_marker(); + return UNDEFINED; +} + +JSValue BaiduMapComponent::Destroy(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"Destroy"); + MapComponentApi::getInstance().destroy(); + return UNDEFINED; +} + } // namespace ACELite } // namespace OHOS #endif // FEATURE_COMPONENT_BAIDUMAP \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/baidu_map_component.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/baidu_map_component.h index dbe9680f9..af7ca152a 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/baidu_map_component.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/baidu_map_component.h @@ -157,6 +157,24 @@ public: static JSValue ClearMapOverlayer(const jerry_value_t func, const jerry_value_t context, const jerry_value_t args[], const jerry_length_t argsSize); + /** + * OverlayerClearCircle + */ + static JSValue OverlayerClearCircle(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize); + + /** + * OverlayerClearMarker + */ + static JSValue OverlayerClearMarker(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize); + + /** + * OverlayerClearNaviMarker + */ + static JSValue OverlayerClearNaviMarker(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize); + /** * DrawMarker, Construction point * @@ -165,7 +183,17 @@ public: * @param argsSize Indicates the size of function arguments */ static JSValue DrawMarker(const jerry_value_t func, const jerry_value_t context, - const jerry_value_t args[], const jerry_length_t argsSize); + const jerry_value_t args[], const jerry_length_t argsSize); + + /** + * DrawNaviMarker + * + * @param thisVal Indicates function execute context + * @param args Indicates the function arguments + * @param argsSize Indicates the size of function arguments + */ + static JSValue DrawNaviMarker(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize); /** * DrawPolygon, Constructing Polygons @@ -185,7 +213,17 @@ public: * @param argsSize Indicates the size of function arguments */ static JSValue DrawPath(const jerry_value_t func, const jerry_value_t context, - const jerry_value_t args[], const jerry_length_t argsSize); + const jerry_value_t args[], const jerry_length_t argsSize); + + /** + * DrawCircle + * + * @param thisVal Indicates function execute context + * @param args Indicates the function arguments + * @param argsSize Indicates the size of function arguments + */ + static JSValue DrawCircle(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize); /** * DrawText, Constructed text @@ -229,6 +267,16 @@ public: static JSValue GetMyGeoLocation(const jerry_value_t func, const jerry_value_t context, const jerry_value_t args[], const jerry_length_t argsSize); + /** + * Destroy + * + * @param thisVal Indicates function execute context + * @param args Indicates the function arguments + * @param argsSize Indicates the size of function arguments + */ + static JSValue Destroy(const jerry_value_t func, const jerry_value_t context, + const jerry_value_t args[], const jerry_length_t argsSize); + static const char * const FUNC_SET_ZOOM_EVENT_ENABLED; static const char * const FUNC_ZOOM_IN; static const char * const FUNC_ZOOM_OUT; @@ -250,6 +298,12 @@ public: static const char * const FUNC_STOP_LISTEN_MY_GEO_LOCATION; static const char * const FUNC_GET_MY_GEO_STATUS; static const char * const FUNC_GET_MY_GEO_LOCATION; + static const char * const FUNC_DRAW_CIRCLE; + static const char * const FUNC_DRAW_NAVI_MARKER; + static const char * const FUNC_OVERLAYER_CLEAR_CIRCLE; + static const char * const FUNC_OVERLAYER_CLEAR_MARKER; + static const char * const FUNC_OVERLAYER_CLEAR_NAVI_MARKER; + static const char * const FUNC_DESTROY; static const FunctionMap funcMap[]; protected: diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.cpp index 7970fcb3a..2b0992e55 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.cpp @@ -26,6 +26,10 @@ using namespace OHOS; namespace OHOS { namespace ACELite { + +UITextLanguageAlignment align_horizontal = UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT; +UITextLanguageAlignment align_vertical = UITextLanguageAlignment::TEXT_ALIGNMENT_TOP; + TextComponent::TextComponent(jerry_value_t options, jerry_value_t children, AppStyleManager *styleManager) : Component(options, children, styleManager), fontSize_(DEFAULT_FONT_SIZE), @@ -98,6 +102,9 @@ bool TextComponent::ApplyPrivateStyle(const AppStyleItem *styleItem) case K_LETTER_SPACING: SetTextLetterSpace(uiLabel_, styleItem); break; + case K_TEXT_ALIGN_VERTICAL: + SetTextAlignVertical(uiLabel_, styleItem); + break; case K_TEXT_ALIGN: SetTextAlign(uiLabel_, styleItem); break; @@ -224,32 +231,60 @@ void TextComponent::PostUpdate(uint16_t attrKeyId) } } +void TextComponent::SetTextAlignVertical(UILabel &label, const AppStyleItem *styleItem) const +{ + if (!IsStyleValueTypeString(styleItem)) { + HILOG_ERROR(HILOG_MODULE_ACE, "text text vertical align style value is invalid!"); + return; + } + + const char * const stylePropValue = GetStyleStrValue(styleItem); + uint16_t alignId = KeyParser::ParseKeyId(stylePropValue, GetStyleStrValueLen(styleItem)); + switch (alignId) { + case K_CENTER: + align_vertical = UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER; + break; + case K_BOTTOM: + align_vertical = UITextLanguageAlignment::TEXT_ALIGNMENT_BOTTOM; + break; + case K_TOP: + align_vertical = UITextLanguageAlignment::TEXT_ALIGNMENT_TOP; + break; + default: + HILOG_WARN(HILOG_MODULE_ACE, "text vertical textAlign style value =%s is invalid, using default instead", + stylePropValue); + break; + } + label.SetAlign(align_horizontal, align_vertical); +} + void TextComponent::SetTextAlign(UILabel &label, const AppStyleItem *styleItem) const { if (!IsStyleValueTypeString(styleItem)) { - HILOG_ERROR(HILOG_MODULE_ACE, "text text align style value is invalid!"); + HILOG_ERROR(HILOG_MODULE_ACE, "text text horizontal align style value is invalid!"); return; } - // set ui label text align, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER are support. + const char * const stylePropValue = GetStyleStrValue(styleItem); uint16_t alignId = KeyParser::ParseKeyId(stylePropValue, GetStyleStrValueLen(styleItem)); - UITextLanguageAlignment align = UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT; switch (alignId) { case K_LEFT: - align = UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT; + align_horizontal = UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT; break; case K_RIGHT: - align = UITextLanguageAlignment::TEXT_ALIGNMENT_RIGHT; + align_horizontal = UITextLanguageAlignment::TEXT_ALIGNMENT_RIGHT; break; case K_CENTER: - align = UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER; + align_horizontal = UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER; break; default: - HILOG_WARN(HILOG_MODULE_ACE, "text textAlign style value =%s is invalid, using default instead", + HILOG_WARN(HILOG_MODULE_ACE, "text horizontal textAlign style value =%s is invalid, using default instead", stylePropValue); break; } - label.SetAlign(align, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); + label.SetAlign(align_horizontal, align_vertical); } + + } // namespace ACELite } // namespace OHOS diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.h index fc9a39fed..64778ea6a 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/components/text_component.h @@ -44,6 +44,7 @@ protected: private: // parse js text align style to ui_label void SetTextAlign(UILabel& label, const AppStyleItem* styleItem) const; + void SetTextAlignVertical(UILabel& label, const AppStyleItem* styleItem) const; // parse js text size style to fontSize_ void SetTextSize(const AppStyleItem* styleItem); // parse js text color style to ui_label diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.cpp index d6959b614..ce1cf77bf 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.cpp +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.cpp @@ -37,6 +37,9 @@ typedef struct : public OHOS::HeapBase { constexpr char LON[] = "lon"; constexpr char LAT[] = "lat"; +//BT_CONNECT +constexpr char CONNECT[] = "connectcallback"; +constexpr char DISCONNECT[] = "disconnectcallback"; namespace OHOS { namespace ACELite { @@ -131,6 +134,10 @@ OHOS::ACELite::JSIValue geocode_search_callbackContext = nullptr; OHOS::ACELite::JSIValue regeocode_search_successCallback = nullptr; OHOS::ACELite::JSIValue regeocode_search_failCallback = nullptr; OHOS::ACELite::JSIValue regeocode_search_callbackContext = nullptr; +//BT_connect +OHOS::ACELite::JSIValue bt_connect_successCallback = nullptr; +OHOS::ACELite::JSIValue bt_connect_failCallback = nullptr; +OHOS::ACELite::JSIValue bt_connect_callbackContext = nullptr; static bool CheckIsJsValueDefined(OHOS::ACELite::JSIValue jsValue) { @@ -297,9 +304,17 @@ static void ExecuteSendMsgToJS(void *data) fail = regeocode_search_failCallback; context = regeocode_search_callbackContext; break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED: + success = bt_connect_successCallback; + context = bt_connect_callbackContext; + break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_DISCONNECTED: + success = bt_connect_failCallback; + context = bt_connect_callbackContext; + break; default: - HILOG_ERROR(HILOG_MODULE_ACE, "Invalid command type"); - break; + HILOG_ERROR(HILOG_MODULE_ACE, "Invalid command type"); + break; } @@ -452,6 +467,26 @@ static void ReleaseMsgJsValue(uint8_t type) ReleaseJsValue(regeocode_search_failCallback); ReleaseJsValue(regeocode_search_callbackContext); break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_RIDING_SEARCH: + ReleaseJsValue(route_riding_successCallback); + ReleaseJsValue(route_riding_failCallback); + ReleaseJsValue(route_riding_callbackContext); + break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_WALKING_SEARCH: + ReleaseJsValue(route_walking_successCallback); + ReleaseJsValue(route_walking_failCallback); + ReleaseJsValue(route_walking_callbackContext); + break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_TRANSIT_SEARCH: + ReleaseJsValue(route_transit_successCallback); + ReleaseJsValue(route_transit_failCallback); + ReleaseJsValue(route_transit_callbackContext); + break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED: + ReleaseJsValue(bt_connect_successCallback); + ReleaseJsValue(bt_connect_failCallback); + ReleaseJsValue(bt_connect_callbackContext); + break; default: HILOG_ERROR(HILOG_MODULE_ACE, "ReleaseMsgJsValue Invalid command type"); break; @@ -556,6 +591,34 @@ bool setCallbackFunction(OHOS::ACELite::JSIValue callback,uint8_t type,bool isSu regeocode_search_failCallback = OHOS::ACELite::JSI::AcquireValue(callback); } break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_RIDING_SEARCH: + if (isSuccess) { + route_riding_successCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } else { + route_riding_failCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } + break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_WALKING_SEARCH: + if (isSuccess) { + route_walking_successCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } else { + route_walking_failCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } + break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_TRANSIT_SEARCH: + if (isSuccess) { + route_transit_successCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } else { + route_transit_failCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } + break; + case MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED: + if (isSuccess) { + bt_connect_successCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } else { + bt_connect_failCallback = OHOS::ACELite::JSI::AcquireValue(callback); + } + break; default: HILOG_ERROR(HILOG_MODULE_ACE, "setCallbackFunction Invalid command type"); return false; @@ -595,34 +658,13 @@ JSIValue BaiduMapComponentModule::route_riding_search(const JSIValue thisVal, co char *data = JSI::JsonStringify(args[0]); HILOG_INFO(HILOG_MODULE_ACE,"route_riding_search : %s \n",data); //success Callback & failed Callback - ReleaseJsValue(route_riding_successCallback); - ReleaseJsValue(route_riding_failCallback); - ReleaseJsValue(route_riding_callbackContext); + ReleaseMsgJsValue(MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_RIDING_SEARCH); route_riding_callbackContext = OHOS::ACELite::JSI::AcquireValue(thisVal); OHOS::ACELite::JSIValue successCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], CB_SUCCESS); OHOS::ACELite::JSIValue failCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], CB_FAIL); - - if (!OHOS::ACELite::JSI::ValueIsUndefined(successCallback)) { - if (!OHOS::ACELite::JSI::ValueIsFunction(successCallback)) { - HILOG_ERROR(HILOG_MODULE_ACE, "route_riding_search Success callback value is not a function"); - } else { - route_riding_successCallback = OHOS::ACELite::JSI::AcquireValue(successCallback); - } - } else { - HILOG_ERROR(HILOG_MODULE_ACE, "route_riding_search Success callback value is undefined"); - } - - if (!OHOS::ACELite::JSI::ValueIsUndefined(failCallback)) { - if (!OHOS::ACELite::JSI::ValueIsFunction(failCallback)) { - HILOG_ERROR(HILOG_MODULE_ACE, "route_riding_search Fail callback value is not a function"); - } else { - route_riding_failCallback = OHOS::ACELite::JSI::AcquireValue(failCallback); - } - } else { - HILOG_ERROR(HILOG_MODULE_ACE, "route_riding_search Fail callback value is undefined"); - } - - msg_center_vector_navi_req_dst_by_text(MSGCENTER_CMD_VECTOR_NAVI,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_DST_BY_TEST,data,strlen(data)); + setCallbackFunction(successCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_RIDING_SEARCH,true); + setCallbackFunction(failCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_RIDING_SEARCH,false); + msg_center_vector_navi_req_route_riding_search(MSGCENTER_CMD_VECTOR_NAVI, MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_RIDING_SEARCH,data,strlen(data)); return JSI::CreateBoolean(0); } @@ -632,33 +674,13 @@ JSIValue BaiduMapComponentModule::route_walking_search(const JSIValue thisVal, c char *data = JSI::JsonStringify(args[0]); HILOG_INFO(HILOG_MODULE_ACE,"route_walking_search : %s \n",data); //success Callback & failed Callback - ReleaseJsValue(route_walking_successCallback); - ReleaseJsValue(route_walking_failCallback); - ReleaseJsValue(route_walking_callbackContext); + ReleaseMsgJsValue(MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_WALKING_SEARCH); route_walking_callbackContext = OHOS::ACELite::JSI::AcquireValue(thisVal); OHOS::ACELite::JSIValue successCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], CB_SUCCESS); OHOS::ACELite::JSIValue failCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], CB_FAIL); - - if (!OHOS::ACELite::JSI::ValueIsUndefined(successCallback)) { - if (!OHOS::ACELite::JSI::ValueIsFunction(successCallback)) { - HILOG_ERROR(HILOG_MODULE_ACE, "route_walking_search Success callback value is not a function"); - } else { - route_walking_successCallback = OHOS::ACELite::JSI::AcquireValue(successCallback); - } - } else { - HILOG_ERROR(HILOG_MODULE_ACE, "route_walking_search Success callback value is undefined"); - } - - if (!OHOS::ACELite::JSI::ValueIsUndefined(failCallback)) { - if (!OHOS::ACELite::JSI::ValueIsFunction(failCallback)) { - HILOG_ERROR(HILOG_MODULE_ACE, "route_walking_search Fail callback value is not a function"); - } else { - route_walking_failCallback = OHOS::ACELite::JSI::AcquireValue(failCallback); - } - } else { - HILOG_ERROR(HILOG_MODULE_ACE, "route_walking_search Fail callback value is undefined"); - } - msg_center_vector_navi_req_dst_by_text(MSGCENTER_CMD_VECTOR_NAVI,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_DST_BY_TEST,data,strlen(data)); + setCallbackFunction(successCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_WALKING_SEARCH,true); + setCallbackFunction(failCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_WALKING_SEARCH,false); + msg_center_vector_navi_req_route_walking_search(MSGCENTER_CMD_VECTOR_NAVI,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_WALKING_SEARCH,data,strlen(data)); return JSI::CreateBoolean(0); } @@ -668,33 +690,13 @@ JSIValue BaiduMapComponentModule::route_transit_search(const JSIValue thisVal, c char *data = JSI::JsonStringify(args[0]); HILOG_INFO(HILOG_MODULE_ACE,"route_transit_search : %s \n",data); //success Callback & failed Callback - ReleaseJsValue(route_transit_successCallback); - ReleaseJsValue(route_transit_failCallback); - ReleaseJsValue(route_transit_callbackContext); + ReleaseMsgJsValue(MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_TRANSIT_SEARCH); route_transit_callbackContext = OHOS::ACELite::JSI::AcquireValue(thisVal); OHOS::ACELite::JSIValue successCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], CB_SUCCESS); OHOS::ACELite::JSIValue failCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], CB_FAIL); - - if (!OHOS::ACELite::JSI::ValueIsUndefined(successCallback)) { - if (!OHOS::ACELite::JSI::ValueIsFunction(successCallback)) { - HILOG_ERROR(HILOG_MODULE_ACE, "route_transit_search Success callback value is not a function"); - } else { - route_transit_successCallback = OHOS::ACELite::JSI::AcquireValue(successCallback); - } - } else { - HILOG_ERROR(HILOG_MODULE_ACE, "route_transit_search Success callback value is undefined"); - } - - if (!OHOS::ACELite::JSI::ValueIsUndefined(failCallback)) { - if (!OHOS::ACELite::JSI::ValueIsFunction(failCallback)) { - HILOG_ERROR(HILOG_MODULE_ACE, "route_transit_search Fail callback value is not a function"); - } else { - route_transit_failCallback = OHOS::ACELite::JSI::AcquireValue(failCallback); - } - } else { - HILOG_ERROR(HILOG_MODULE_ACE, "route_transit_search Fail callback value is undefined"); - } - msg_center_vector_navi_req_dst_by_text(MSGCENTER_CMD_VECTOR_NAVI,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_DST_BY_TEST,data,strlen(data)); + setCallbackFunction(successCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_TRANSIT_SEARCH,true); + setCallbackFunction(failCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_TRANSIT_SEARCH,false); + msg_center_vector_navi_req_route_transit_search(MSGCENTER_CMD_VECTOR_NAVI,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_ROUTE_TRANSIT_SEARCH,data,strlen(data)); return JSI::CreateBoolean(0); } @@ -1021,6 +1023,36 @@ JSIValue BaiduMapComponentModule::Regeocode_search(const JSIValue thisVal, const return JSI::CreateBoolean(0); } +/** + * destroy page interface + */ +JSIValue BaiduMapComponentModule::Destroy_page(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"Destroy_page"); + char *data = JSI::JsonStringify(args[0]); + HILOG_INFO(HILOG_MODULE_ACE,"Destroy_page : %s \n",data); + msg_center_vector_navi_req_destroy_page(MSGCENTER_CMD_VECTOR_NAVI,MSGCENTER_TYPE_ID_VECTOR_NAVI_REQ_DESTROY_PAGE,data,strlen(data)); + return JSI::CreateBoolean(0); +} + +/** + * BT connect interface + */ +JSIValue BaiduMapComponentModule::onBTConnect(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) +{ + HILOG_INFO(HILOG_MODULE_ACE,"onBTConnect"); + char *data = JSI::JsonStringify(args[0]); + HILOG_INFO(HILOG_MODULE_ACE,"onBTConnect : %s \n",data); + //success Callback & failed Callback + ReleaseMsgJsValue(MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED); + bt_connect_callbackContext = OHOS::ACELite::JSI::AcquireValue(thisVal); + OHOS::ACELite::JSIValue connectCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], CONNECT); + OHOS::ACELite::JSIValue disconnectCallback = OHOS::ACELite::JSI::GetNamedProperty(args[0], DISCONNECT); + setCallbackFunction(connectCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED,true); + setCallbackFunction(disconnectCallback,MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED,false); + return JSI::CreateBoolean(0); +} + void InitBaiduMapComponentModule(JSIValue exports) { HILOG_INFO(HILOG_MODULE_ACE,"InitBaiduMapComponentModule"); @@ -1065,6 +1097,16 @@ void InitBaiduMapComponentModule(JSIValue exports) JSI::SetModuleAPI(exports, "geocode_search", BaiduMapComponentModule::Geocode_search); JSI::SetModuleAPI(exports, "regeocode_search", BaiduMapComponentModule::Regeocode_search); + /** + * destroy page + */ + JSI::SetModuleAPI(exports, "destroy_page", BaiduMapComponentModule::Destroy_page); + + /** + * BT connect interface + */ + JSI::SetModuleAPI(exports, "onBTConnect", BaiduMapComponentModule::onBTConnect); + } } // namespace ACELite diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.h index 831691806..93a3182cd 100644 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.h +++ b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/baidumapcomponent/baidumap.h @@ -91,6 +91,17 @@ public: static JSIValue Geocode_search(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); static JSIValue Regeocode_search(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + + /** + * destroy page interface + */ + static JSIValue Destroy_page(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + + /** + * bt connect interface + */ + static JSIValue onBTConnect(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + }; void InitBaiduMapComponentModule(JSIValue exports); 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 7c8a4153c..e49a9a0e0 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 ba0b0665a..fd2e7606b 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/distributedschedule/samgr_lite/CMakeLists.txt b/code/sdk/open_source/openharmony/foundation/distributedschedule/samgr_lite/CMakeLists.txt index a49694b68..e0740bbc7 100644 --- a/code/sdk/open_source/openharmony/foundation/distributedschedule/samgr_lite/CMakeLists.txt +++ b/code/sdk/open_source/openharmony/foundation/distributedschedule/samgr_lite/CMakeLists.txt @@ -8,13 +8,13 @@ set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/kits/communication/broadcast ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/kits/registry ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/kits/samgr - ${CMAKE_CURRENT_SOURCE_DIR}/services/samgr/dependency - ${CMAKE_CURRENT_SOURCE_DIR}/services/samgr/registry ) set(PRIVATE_HEADER ${ROOT_DIR}/application/wearable/ohos_deps ${ROOT_DIR}/open_source/openharmony/utils/native/lite/include + ${CMAKE_CURRENT_SOURCE_DIR}/services/samgr/dependency + ${CMAKE_CURRENT_SOURCE_DIR}/services/samgr/registry ${PUBLIC_HEADER} ) diff --git a/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h b/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h index c4b2f13d2..23c96bbde 100644 --- a/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h +++ b/code/sdk/open_source/openharmony/foundation/multimedia/player/interfaces/kits/player_lite/js/builtin/include/audio_module.h @@ -115,6 +115,15 @@ public: */ static JSIValue SrcGetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** + * the getter of audio srcInner property + * + * @param thisVal Indicates function execute context + * @param args Indicates the function arguments + * @param argsSize Indicates the size of function arguments + */ + static JSIValue SrcInnerGetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** * the setter of audio src property * @@ -124,6 +133,15 @@ public: */ static JSIValue SrcSetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** + * the setter of audio srcInner property + * + * @param thisVal Indicates function execute context + * @param args Indicates the function arguments + * @param argsSize Indicates the size of function arguments + */ + static JSIValue SrcInnerSetter(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); + /** * the getter of audio currentTime property * 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 3b71da894..30105485e 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 @@ -89,7 +89,7 @@ public: bool Stop(); - char *GetSrc() const; + char *GetSrc(bool innerFlag) const; double GetCurrentTime() const; @@ -107,7 +107,7 @@ public: bool IsPlaying() const; - bool SetSrc(char *src); + bool SetSrc(char *src, bool innerFlag); bool SetCurrentTime(double currentTime) const; @@ -159,6 +159,7 @@ private: static MediaMutexHandle lock_; static MediaThreadCondHandle condition_; static void *UpdateTimeHandler(void *arg); + static int GetSrcInnerPrefix(char *src, char *dest); Media::Player *player_; std::shared_ptr callback_; @@ -170,11 +171,13 @@ private: AudioEventListener *onErrorListener_; AudioEventListener *onTimeUpdateListener_; char *src_; + char *srcInner_; char *status_; double volume_; bool autoPlay_; bool muted_; bool isRunning_; + bool isSysSrc_; MediaThreadIdHandle updateTimeProcess_; }; } // namespace ACELite 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 f87abf35e..9d650b590 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 747f45171..fc64215d9 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/protocol/bt/host/bt/bts/brandy_service/service/src/base/local_device_manager.h b/code/sdk/protocol/bt/host/bt/bts/brandy_service/service/src/base/local_device_manager.h index d430193dd..027a02ed0 100644 --- a/code/sdk/protocol/bt/host/bt/bts/brandy_service/service/src/base/local_device_manager.h +++ b/code/sdk/protocol/bt/host/bt/bts/brandy_service/service/src/base/local_device_manager.h @@ -49,6 +49,7 @@ enum { LOCAL_MGR_MSG_ID_READ_REMOTE_RSSI_BLE, LOCAL_MGR_MSG_ID_PAIRED_KEYS, /* 上报BLE配对完成密钥 */ LOCAL_MGR_MSG_ID_REPORT_TERMINATE_ADV, /* 上报广播终止结果 */ + LOCAL_MGR_MSG_ID_CONN_PARAM_UPDATE, /* 连接参数更新 */ }; /* 发送本地设备管理模块消息 */ @@ -61,6 +62,7 @@ bool btsrv_is_bluetooth_enable(void); bool btsrv_is_bluetooth_disable(void); bool btsrv_set_local_addr(const bd_addr_t *bd_addr); +bool is_bts_auto_reconnect_enable(void); /* 本地设备运行模式设置和查询 */ uint32_t btsrv_set_local_device_mode(btsrv_local_device_mode mode); diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/include/sample_ble_ams.h b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/include/sample_ble_ams.h new file mode 100644 index 000000000..43ac2d7cc --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/include/sample_ble_ams.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. + * + * Description: AMS Client Test module. + */ +/** + * @defgroup bluetooth_sample_ble_ams AMS TEST API + * @ingroup bluetooth + * @{ + */ + +#ifndef SAMPLE_BLE_AMS_H +#define SAMPLE_BLE_AMS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void ble_ams_client_at_cmd(uint8_t cmd_id, char **params, uint8_t params_cnt); + +/** + * @} + */ +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/include/sample_ble_ancs.h b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/include/sample_ble_ancs.h new file mode 100644 index 000000000..f05e2f927 --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/include/sample_ble_ancs.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. + * + * Description: ANCS Client Test module. + */ +/** + * @defgroup bluetooth_sample_ble_ancs ANCS TEST API + * @ingroup bluetooth + * @{ + */ + +#ifndef SAMPLE_BLE_ANCS_H +#define SAMPLE_BLE_ANCS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void ble_ancs_client_at_cmd(uint8_t cmd_id, char **params, uint8_t params_cnt); + +/** + * @} + */ +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/CMakeLists.txt b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/CMakeLists.txt index 0008d8951..8bdb7abfa 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/CMakeLists.txt +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/CMakeLists.txt @@ -4,5 +4,7 @@ set( ${CMAKE_CURRENT_SOURCE_DIR}/sample_ble_bas.c ${CMAKE_CURRENT_SOURCE_DIR}/sample_ble_hid.c ${CMAKE_CURRENT_SOURCE_DIR}/sample_ble_fmp.c + ${CMAKE_CURRENT_SOURCE_DIR}/sample_ble_ancs.c + ${CMAKE_CURRENT_SOURCE_DIR}/sample_ble_ams.c ) set(BTH_SAMPLE_LIST "${BTH_SAMPLE_LIST}" "${bt_comm_src_list}" CACHE INTERNAL "bt ram obj list" FORCE) diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/sample_ble_ams.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/sample_ble_ams.c new file mode 100644 index 000000000..c150a67ab --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/sample_ble_ams.c @@ -0,0 +1,320 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. + * Description: This module include test function of AMS Client module. + */ +#include +#include +#include +#include "datatype.h" +#include "sdk_general.h" +#include "mpc_dispatch.h" +#include "bt_at_cmd_api.h" +#include "sample_common.h" +#include "ble_ams_client.h" +#include "sample_ble_ams.h" + +#define HEX_BYTE_CHAR_COUNT 2 + +/* AMS客户端接口命令id */ +typedef enum { + BLE_SAMPLE_AMS_CLIENT_REGISTER_CBK = 1, /* 1 注册AMS客户端回调函数 */ + BLE_SAMPLE_AMS_CLIENT_SETUP, /* 2 AMS客户端连接服务端 */ + BLE_SAMPLE_AMS_CLIENT_SUBSCRIBE_REMOTE_COMMNAD, /* 3 订阅远端命令 */ + BLE_SAMPLE_AMS_CLIENT_SUBSCRIBE_ENTITY_UPDATE, /* 4 订阅实体更新 */ + BLE_SAMPLE_AMS_CLIENT_SEND_REMOTE_CMD, /* 5 发送远端命令 */ + BLE_SAMPLE_AMS_CLIENT_REGISTER_INTERESTED_ENTITY_ATT, /* 6 注册感兴趣的实体属性 */ + BLE_SAMPLE_AMS_CLIENT_RETRIEVE_FULL_ENTITY_ATT, /* 7 请求加载完整实体属性 */ + BLE_SAMPLE_AMS_CLIENT_READ_FULL_ENTITY_ATT /* 8 读取完整实体属性 */ +} ble_ams_client_at_cmd_id_t; + +/* 命令处理函数接口 */ +typedef uint8_t (*ble_ams_client_at_func_t)(uint8_t argc, char **argv); + +/* AMS客户端AT命令id与接口对应关系 */ +typedef struct { + ble_ams_client_at_cmd_id_t id; + ble_ams_client_at_func_t func; +} ble_ams_client_at_hdl_info_t; + +/* 当前活跃媒体设备支持的远端命令 */ +ble_ams_remote_cmd_rpt_t *g_remote_cmd_supported = NULL; + +/* AMS服务建立结果回调 */ +static void ble_ams_client_setup_result_cbk(uint8_t client_id, uint16_t conn_id, errcode_t status) +{ + bts_info("[AMSClientSetupCBK]conn_id:%d status:0x%x\r\n", conn_id, status); +} + +/* AMS服务订阅结果回调 */ +static void ble_ams_client_subscribe_result_cbk(uint8_t client_id, uint16_t conn_id, + ams_client_subscribe_type_t type, gatt_status_t status) +{ + bts_info("[AMSClientSubscribeResultCBK]conn_id:%d type:%d status:0x%x\r\n", conn_id, type, status); +} + +/* AMS服务远端支持的命令上报 */ +static void ble_ams_client_remote_cmd_cbk(uint8_t client_id, uint16_t conn_id, + ble_ams_remote_cmd_rpt_t *remote_cmd, errcode_t status) +{ + if (status == ERRCODE_BT_SUCCESS) { + bts_sample_log_no_header("[AMSClientRemoteCMDCBK]conn_id:%d status:0x%x cmd_num=%d ", + conn_id, status, remote_cmd->cmd_num); + if (g_remote_cmd_supported != NULL) { + bt_os_free(g_remote_cmd_supported); + } + uint16_t length = sizeof(ble_ams_remote_cmd_rpt_t) + remote_cmd->cmd_num; + g_remote_cmd_supported = bt_os_new(length); + g_remote_cmd_supported->cmd_num = remote_cmd->cmd_num; + if (memcpy_s(g_remote_cmd_supported->remote_cmd, remote_cmd->cmd_num, + remote_cmd->remote_cmd, remote_cmd->cmd_num) != EOK) { + bts_error("[AMSClientSample] memcpy error!\r\n"); + bt_os_free(g_remote_cmd_supported); + return; + } + bts_sample_log_no_header("supported_cmd="); + for (int i = 0; i < remote_cmd->cmd_num; i++) { + bts_sample_log_no_header("0x%02x", remote_cmd->remote_cmd[i]); + } + bts_sample_log_no_header("\r\n"); + } else { + bts_info("[AMSClientRemoteCMDCBK]conn_id:%d status:0x%x\r\n", conn_id, status); + } +} + +/* AMS服务实体更新上报 */ +static void ble_ams_client_entity_update_cbk(uint8_t client_id, uint16_t conn_id, + ble_ams_entity_update_rpt_t *entity_update, errcode_t status) +{ + if (status == ERRCODE_BT_SUCCESS) { + bts_info( + "[AMSClientEntityUpdateCBK]conn_id:%d status:0x%x entityId=%d att_id=%d update_flags=0x%x value=%s\r\n", + conn_id, status, + entity_update->entity_id, + entity_update->att_id, + entity_update->entity_update_flags, + entity_update->value); + } else { + bts_info("[AMSClientEntityUpdateCBK]conn_id:%d status:0x%x\r\n", conn_id, status); + } +} + +/* AMS客户端写请求响应结果上报 */ +static void ble_ams_client_write_character_rsp_cbk(uint8_t client_id, uint16_t conn_id, + ams_client_write_character_type_t type, + gatt_status_t status) +{ + bts_info("[AMSClientWriteRSPCBK]conn_id:%d type:%d status:0x%x\r\n", conn_id, type, status); +} + +/* AMS客户端读请求响应结果上报 */ +static void ble_ams_client_read_full_attr_result_cbk(uint8_t client_id, uint16_t conn_id, + ble_ams_full_attr_value_t *read_result, + gatt_status_t status) +{ + if (status == ERRCODE_BT_SUCCESS) { + bts_info("[AMSClientReadFullAttrCBK]conn_id:%d status:0x%x value_len=%d value=%s\r\n", + conn_id, status, + read_result->value_len, + read_result->value); + } else { + bts_info("[AMSClientReadFullAttrCBK]conn_id:%d status:0x%x\r\n", conn_id, status); + } +} + +/* 注册AMS服务回调 */ +static uint8_t ble_ams_client_at_cmd_register_cbk(uint8_t argc, char **argv) +{ + ble_ams_client_callbacks_t cbk = {0}; + cbk.setup_cb = ble_ams_client_setup_result_cbk; + cbk.subscribe_cb = ble_ams_client_subscribe_result_cbk; + cbk.remote_cmd_cb = ble_ams_client_remote_cmd_cbk; + cbk.entity_update_cb = ble_ams_client_entity_update_cbk; + cbk.write_rsp_cb = ble_ams_client_write_character_rsp_cbk; + cbk.read_full_attr_result_cb = ble_ams_client_read_full_attr_result_cbk; + errcode_t ret = ble_ams_client_register_callbacks(&cbk); + bts_info("ble ams client register cbk ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* AMS客户端发起服务建立 */ +static uint8_t ble_ams_client_at_cmd_setup(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN2) { + bts_error("ble ams client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + errcode_t ret = ble_ams_client_setup_service(client_id, conn_id); + bts_info("ble ams client setup ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* AMS客户端订阅远端命令特征通知 */ +static uint8_t ble_ams_client_at_cmd_remote_cmd(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN3) { + bts_error("ble ams client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint8_t sub_flag = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + sub_flag = (uint8_t)atoi(argv[BT_INDEX_2]); + if (sub_flag > AMS_CLIENT_NOTIFY_ENABLE) { + bts_error("ble ams client argc invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + errcode_t ret = ble_ams_client_subscribe_remote_cmd(client_id, conn_id, sub_flag); + bts_info("ble ams client sub remote cmd ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* AMS客户端订阅实体更新特征通知 */ +static uint8_t ble_ams_client_at_cmd_entity_update(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN3) { + bts_error("ble ams client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint8_t sub_flag = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + sub_flag = (uint8_t)atoi(argv[BT_INDEX_2]); + if (sub_flag > AMS_CLIENT_NOTIFY_ENABLE) { + bts_error("ble ams client argc invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + errcode_t ret = ble_ams_client_subscribe_entity_update(client_id, conn_id, sub_flag); + bts_info("ble ams client sub entity update ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* AMS客户端发送远端命令 */ +static uint8_t ble_ams_client_at_cmd_send_remote_cmd(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN3) { + bts_error("ble ams client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint8_t remote_cmd = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + remote_cmd = (uint8_t)atoi(argv[BT_INDEX_2]); + if (remote_cmd > AMS_RMT_CMD_ID_BOOKMARK_TRACK) { + bts_error("ble ams client argc invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + errcode_t ret = ble_ams_client_send_remote_cmd(client_id, conn_id, remote_cmd); + bts_info("ble ams client send remote cmd ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* AMS客户端注册感兴趣的实体属性 */ +static uint8_t ble_ams_client_at_cmd_register_interested_entity_att(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN5) { + bts_error("ble ams client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint16_t att_num = 0; + uint8_t entity_id = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + entity_id = (uint8_t)atoi(argv[BT_INDEX_2]); + att_num = (uint16_t)atoi(argv[BT_INDEX_3]); + uint32_t len = strlen(argv[BT_INDEX_4]); + if (len != (att_num * HEX_BYTE_CHAR_COUNT)) { + bts_error("ble ams client argc att_num invalid :%u\r\n", att_num); + return MPC_BT_FAIL; + } + + ble_ams_interested_entity_attr_req_t *attr_req = bt_os_new(sizeof(ble_ams_interested_entity_attr_req_t) + att_num); + attr_req->entity_id = entity_id; + attr_req->att_num = att_num; + if (decode_hex_from_str(argv[BT_INDEX_4], attr_req->att_id) != EXT_ERR_SUCCESS) { + bt_os_free(attr_req); + bts_error("ble ams client decode attr fail!\r\n"); + return MPC_BT_FAIL; + } + errcode_t ret = ble_ams_client_register_interested_entity_attribute(client_id, conn_id, attr_req); + bts_info("ble ams client register interested attr ret:0x%x\r\n", ret); + bt_os_free(attr_req); + return MPC_BT_SUCC; +} + +/* AMS客户端请求加载完整的实体属性 */ +static uint8_t ble_ams_client_at_cmd_retrieve_full_attr(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN4) { + bts_error("ble ams client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint8_t entity_id = 0; + uint8_t attr_id = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + entity_id = (uint8_t)atoi(argv[BT_INDEX_2]); + attr_id = (uint8_t)atoi(argv[BT_INDEX_3]); + + ble_ams_full_entity_attr_cmd_t *full_attr = bt_os_new(sizeof(ble_ams_full_entity_attr_cmd_t)); + full_attr->entity_id = entity_id; + full_attr->att_id = attr_id; + errcode_t ret = ble_ams_client_retrieve_full_entity_attribute(client_id, conn_id, full_attr); + bts_info("ble ams client retrieve full attr ret:0x%x\r\n", ret); + bt_os_free(full_attr); + return MPC_BT_SUCC; +} + +/* AMS客户端读取完整的实体属性 */ +static uint8_t ble_ams_client_at_cmd_read_full_attr(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN2) { + bts_error("ble ams client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + + errcode_t ret = ble_ams_client_read_full_entity_attribute(client_id, conn_id); + bts_info("ble ams client read full attr ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* AMS客户端AT命令与接口对应关系 */ +static ble_ams_client_at_hdl_info_t g_ble_ams_client_at_hdl[] = { + { BLE_SAMPLE_AMS_CLIENT_REGISTER_CBK, ble_ams_client_at_cmd_register_cbk }, + { BLE_SAMPLE_AMS_CLIENT_SETUP, ble_ams_client_at_cmd_setup }, + { BLE_SAMPLE_AMS_CLIENT_SUBSCRIBE_REMOTE_COMMNAD, ble_ams_client_at_cmd_remote_cmd }, + { BLE_SAMPLE_AMS_CLIENT_SUBSCRIBE_ENTITY_UPDATE, ble_ams_client_at_cmd_entity_update }, + { BLE_SAMPLE_AMS_CLIENT_SEND_REMOTE_CMD, ble_ams_client_at_cmd_send_remote_cmd }, + { BLE_SAMPLE_AMS_CLIENT_REGISTER_INTERESTED_ENTITY_ATT, ble_ams_client_at_cmd_register_interested_entity_att }, + { BLE_SAMPLE_AMS_CLIENT_RETRIEVE_FULL_ENTITY_ATT, ble_ams_client_at_cmd_retrieve_full_attr }, + { BLE_SAMPLE_AMS_CLIENT_READ_FULL_ENTITY_ATT, ble_ams_client_at_cmd_read_full_attr }, +}; + +/* AMS客户端AT命令处理入口函数 */ +void ble_ams_client_at_cmd(uint8_t cmd_id, char **params, uint8_t params_cnt) +{ + size_t hdl_cnt = sizeof(g_ble_ams_client_at_hdl) / sizeof(ble_ams_client_at_hdl_info_t); + for (uint8_t i = 0; i < hdl_cnt; i++) { + if (g_ble_ams_client_at_hdl[i].id == cmd_id && g_ble_ams_client_at_hdl[i].func != NULL) { + (void)g_ble_ams_client_at_hdl[i].func(params_cnt, params); + return; + } + } +} \ No newline at end of file diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/sample_ble_ancs.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/sample_ble_ancs.c new file mode 100644 index 000000000..560afcd9b --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/ble_at_sample/src/sample_ble_ancs.c @@ -0,0 +1,401 @@ +/* + * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. + * Description: This module include test function of ANCS Client module. + */ +#include +#include +#include +#include "datatype.h" +#include "sdk_general.h" +#include "mpc_dispatch.h" +#include "bt_at_cmd_api.h" +#include "ble_ancs_client.h" +#include "sample_ble_ancs.h" + +#define TEN 10 +#define ANCS_ATT_BYTE_LENGTH 6 +#define ANCS_DEC_CHAR_COUNT 2 +#define BYTE_BIT_COUNT 8 + +/* ANCS客户端接口命令id */ +typedef enum { + BLE_SAMPLE_ANCS_CLIENT_REGISTER_CBK = 1, /* 1 注册ANCS客户端回调函数 */ + BLE_SAMPLE_ANCS_CLIENT_SETUP, /* 2 ANCS客户端连接服务端 */ + BLE_SAMPLE_ANCS_CLIENT_SUBSCRIBE_NOTITY, /* 3 订阅通知 */ + BLE_SAMPLE_ANCS_CLIENT_SUBSCRIBE_DATA, /* 4 订阅数据 */ + BLE_SAMPLE_ANCS_CLIENT_PERFORM_ACTION, /* 5 执行操作 */ + BLE_SAMPLE_ANCS_CLIENT_NOTIFY_ATT_GET, /* 6 执行操作 */ + BLE_SAMPLE_ANCS_CLIENT_APP_ATT_GET /* 7 执行操作 */ +} ble_ancs_client_at_cmd_id_t; + +/* 命令处理函数接口 */ +typedef uint8_t (*ble_ancs_client_at_func_t)(uint8_t argc, char **argv); + +/* ANCS客户端AT命令id与接口对应关系 */ +typedef struct { + ble_ancs_client_at_cmd_id_t id; + ble_ancs_client_at_func_t func; +} ble_ancs_client_at_hdl_info_t; + +/* ANCS服务建立结果回调 */ +static void ble_ancs_client_setup_result_cbk(uint8_t client_id, uint16_t conn_id, errcode_t status) +{ + bts_info("[ANCSClientSetupCBK]conn_id:%d status:0x%x\r\n", conn_id, status); +} + +/* ANCS服务订阅结果回调 */ +static void ble_ancs_client_subscribe_result_cbk(uint8_t client_id, uint16_t conn_id, + ancs_client_subscribe_type_t type, gatt_status_t status) +{ + bts_info("[ANCSClientSubscribeResultCBK]conn_id:%d type:%d status:0x%x\r\n", conn_id, type, status); +} + +/* ANCS服务命令执行结果回调 */ +static void ble_ancs_client_write_result_cbk(uint8_t client_id, uint16_t conn_id, gatt_status_t status) +{ + bts_info("[ANCSClientCMDResultCBK]conn_id:%d status:0x%x\r\n", conn_id, status); +} + +/* ANCS服务消息通知回调 */ +static void ble_ancs_client_notify_source_cbk(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_src_t *notify_src, errcode_t status) +{ + if (status == ERRCODE_BT_SUCCESS) { + bts_info( + "[ANCSClientNotifySRCCBK]conn_id:%d status:0x%x notify_id:%lu " + "eventId:%d eventFlags:0x%x category_id:%d\r\n", + conn_id, status, + notify_src->notification_uid, + notify_src->event_id, + notify_src->event_flags, + notify_src->category_id); + } else { + bts_error("[ANCSClientNotifySRCCBK]conn_id:%d status:0x%x.\r\n", + conn_id, status); + } +} + +/* ANCS服务通知属性响应结果回调 */ +static void ble_ancs_client_notification_attr_rsp_cbk(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_attr_rsp_t *notify_attr_rsp, errcode_t status) +{ + if (status == ERRCODE_BT_SUCCESS) { + bts_info("[ANCSClientNotifyATTRSPCBK]conn_id:%d status:0x%x notify_uid:%lu\r\n", + conn_id, status, notify_attr_rsp->notification_uid); + + ble_ancs_attr_rsp_t *node = (ble_ancs_attr_rsp_t *)notify_attr_rsp->attr_rsp_lst.head; + uint16_t att_num = 1; + while (node != NULL) { + if (node != NULL) { + bts_info_no_header("[ANCSClientNotifyATTRSPCBK]att id:%d length:%lu att_value:%s\r\n", + node->att_id, node->att_length, node->att); + } + node = lnext(node); + if (att_num == notify_attr_rsp->att_num) { + break; + } + att_num = att_num + 1; + } + } else { + bts_error("[ANCSClientNotifyATTRSPCBK]conn_id:%d status:0x%x.\r\n", + conn_id, status); + } +} + +/* ANCS服务应用属性响应结果回调 */ +static void ble_ancs_client_app_attr_rsp_cbk(uint8_t client_id, uint16_t conn_id, + ble_ancs_app_attr_rsp_t *app_attr_rsp, errcode_t status) +{ + bts_info("[ANCSClientAPPATTRSPCBK]conn_id:%d status:0x%x\r\n", conn_id, status); + if (status == ERRCODE_BT_SUCCESS) { + ble_ancs_attr_rsp_t *node = (ble_ancs_attr_rsp_t *)app_attr_rsp->attr_rsp_lst.head; + uint16_t att_num = 1; + while (node != NULL) { + if (node != NULL && node->att_id == ANCS_APP_ATT_DISPLAY_NAME) { + bts_info_no_header("[ANCSClientAPPATTRSPCBK]app id:%s length:%lu app name:%s\r\n", + app_attr_rsp->app_id.id, node->att_length, node->att); + } + node = lnext(node); + if (att_num == app_attr_rsp->att_num) { + break; + } + att_num = att_num + 1; + } + } else { + bts_error("[ANCSClientAPPATTRSPCBK]conn_id:%d status:0x%x.\r\n", + conn_id, status); + } +} + +/* 注册ancs服务回调 */ +static uint8_t ble_ancs_client_at_cmd_register_cbk(uint8_t argc, char **argv) +{ + ble_ancs_client_callbacks_t cbk = {0}; + cbk.setup_cb = ble_ancs_client_setup_result_cbk; + cbk.subscribe_cb = ble_ancs_client_subscribe_result_cbk; + cbk.write_result_cb = ble_ancs_client_write_result_cbk; + cbk.notify_source_cb = ble_ancs_client_notify_source_cbk; + cbk.notify_attr_cb = ble_ancs_client_notification_attr_rsp_cbk; + cbk.app_attr_cb = ble_ancs_client_app_attr_rsp_cbk; + errcode_t ret = ble_ancs_client_register_callbacks(&cbk); + bts_info("ble ancs client register cbk ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* ANCS服务建立 */ +static uint8_t ble_ancs_client_at_cmd_setup(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN2) { + bts_error("ble ancs client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + errcode_t ret = ble_ancs_client_setup_service(client_id, conn_id); + bts_info("ble ancs client setup ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* 订阅通知 */ +static uint8_t ble_ancs_client_at_cmd_subscribe_notify(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN3) { + bts_error("ble ancs client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint8_t sub_flag = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + sub_flag = (uint8_t)atoi(argv[BT_INDEX_2]); + if (sub_flag > ANCS_CLIENT_NOTIFY_ENABLE) { + bts_error("ble ancs client argc invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + errcode_t ret = ble_ancs_client_subscribe_notification_source(client_id, conn_id, sub_flag); + bts_info("ble ancs client sub notify ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* 订阅数据 */ +static uint8_t ble_ancs_client_at_cmd_subscribe_data(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN3) { + bts_error("ble ancs client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint8_t sub_flag = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + sub_flag = (uint8_t)atoi(argv[BT_INDEX_2]); + if (sub_flag > ANCS_CLIENT_NOTIFY_ENABLE) { + bts_error("ble ancs client argc invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + + errcode_t ret = ble_ancs_client_subscribe_data_source(client_id, conn_id, sub_flag); + bts_info("ble ancs client sub data ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* 执行消息行为(积极或消极行为) */ +static uint8_t ble_ancs_client_at_cmd_perform_action(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN4) { + bts_error("ble ancs client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint32_t notify_uid = 0; + uint8_t action_id = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + notify_uid = (uint32_t)atoi(argv[BT_INDEX_2]); + action_id = (uint8_t)atoi(argv[BT_INDEX_3]); + if (action_id > ANCS_ACTION_RESERVED) { + bts_error("ble ancs client argc invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + ble_ancs_notification_action_req_t action_cmd = {0}; + action_cmd.notification_uid = notify_uid; + action_cmd.action_id = action_id; + errcode_t ret = ble_ancs_client_send_perform_notify_action_cmd(client_id, conn_id, &action_cmd); + bts_info("ble ancs client perform action ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* 十六进制字符转数值 */ +static uint8_t char_2_num(int8_t c) +{ + if (c >= '0' && c <= '9') { + return (uint8_t)(c - '0'); + } else if (c >= 'A' && c <= 'F') { + return (uint8_t)(c - 'A' + TEN); + } else if (c >= 'a' && c <= 'f') { + return (uint8_t)(c - 'a' + TEN); + } else { + return TD_U8_MAX; + } +} + +/* 十六进制字符转数值 */ +static uint8_t str_2_byte(const char *str) +{ + return ((char_2_num(str[0]) << TD_U4_BITS) + char_2_num(str[1])); +} + +/* 十六进制字符转属性请求参数结构体 */ +static void decode_att_req_from_str(const char *str, ble_ancs_attr_req_t *nums) +{ + uint32_t len = strlen(str); + uint32_t cnt = 0; + char *ptr_str = NULL; + uint16_t length_big_byte = 0; + uint16_t length_little_byte = 0; + ptr_str = str; + for (uint32_t i = 0; i < len - 1; i += ANCS_ATT_BYTE_LENGTH) { /* 6个字符为1组,2个字符为一个字节 */ + nums[cnt].att_id = str_2_byte(ptr_str); + ptr_str += ANCS_DEC_CHAR_COUNT; + length_big_byte = (((uint16_t)str_2_byte(ptr_str)) << BYTE_BIT_COUNT); + ptr_str += ANCS_DEC_CHAR_COUNT; + length_little_byte = ((uint16_t)str_2_byte(ptr_str)); + nums[cnt].att_max_length = (uint16_t)(length_big_byte | length_little_byte); + ptr_str += ANCS_DEC_CHAR_COUNT; + cnt++; + } +} + +/* 获取通知属性 */ +static uint8_t ble_ancs_client_at_cmd_get_notify_att(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN5) { + bts_error("ble ancs client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint32_t notify_uid = 0; + uint8_t att_num = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + notify_uid = (uint32_t)atoi(argv[BT_INDEX_2]); + att_num = (uint8_t)atoi(argv[BT_INDEX_3]); + if (att_num == 0) { + bts_error("ble ancs client notify att req att num is zero!\r\n"); + return MPC_BT_FAIL; + } + uint32_t len = strlen(argv[BT_INDEX_4]); + if ((att_num * ANCS_ATT_BYTE_LENGTH) != len) { + bts_error("ble ancs client notify att req att num is wrong!\r\n"); + return MPC_BT_FAIL; + } + + /* 获取来电通知属性 */ + ble_ancs_notification_attr_req_t *notify_attr_req = bt_os_new( + sizeof(ble_ancs_notification_attr_req_t) + (att_num * sizeof(ble_ancs_attr_req_t))); + notify_attr_req->att_num = att_num; + notify_attr_req->notification_uid = notify_uid; + decode_att_req_from_str(argv[BT_INDEX_4], notify_attr_req->attr); + errcode_t ret = ble_ancs_client_send_get_notify_att_cmd(client_id, conn_id, notify_attr_req); + bt_os_free(notify_attr_req); + bts_info("ble ancs client notify att get ret:0x%x\r\n", ret); + return MPC_BT_SUCC; +} + +/* 解析应用属性参数 */ +static uint8_t parse_app_att_req_param(ble_ancs_app_attr_req_t *app_attr_req, + uint16_t app_id_len, uint16_t att_num, char **argv) +{ + app_attr_req->att_num = att_num; + app_attr_req->app_id.len = app_id_len + 1; + uint8_t *id = bt_os_new(app_attr_req->app_id.len); + if (id == NULL) { + bts_error("[ANCSClientSample]app id memnew error!\r\n"); + app_attr_req->app_id.id = NULL; + return MPC_BT_FAIL; + } + if (memcpy_s(id, app_attr_req->app_id.len, (uint8_t *)argv[BT_INDEX_2], app_id_len) != EOK) { + bts_error("[ANCSClientSample]app id memcpy error!\r\n"); + bt_os_free(id); + app_attr_req->app_id.id = NULL; + return MPC_BT_FAIL; + } + *(id + app_id_len) = 0; /* This string is NULL-terminated */ + app_attr_req->app_id.id = id; + + /* 解析应用属性参数 */ + decode_att_req_from_str(argv[BT_INDEX_4], app_attr_req->attr_id); + return MPC_BT_SUCC; +} + +/* 获取应用属性 */ +static uint8_t ble_ancs_client_at_cmd_get_app_att(uint8_t argc, char **argv) +{ + if (argc != BT_AT_PARAM_LEN5) { + bts_error("ble ancs client argc num invalid :%u\r\n", argc); + return MPC_BT_FAIL; + } + + uint8_t client_id = 0; + uint16_t conn_id = 0; + uint8_t att_num = 0; + uint16_t app_id_len = 0; + client_id = (uint8_t)atoi(argv[BT_INDEX_0]); + conn_id = (uint16_t)atoi(argv[BT_INDEX_1]); + app_id_len = strlen(argv[BT_INDEX_2]); + att_num = (uint8_t)atoi(argv[BT_INDEX_3]); + if (att_num == 0) { + bts_error("ble ancs client notify att req att num is zero!\r\n"); + return MPC_BT_FAIL; + } + uint32_t len = strlen(argv[BT_INDEX_4]); + if ((att_num * ANCS_ATT_BYTE_LENGTH) != len) { + bts_error("ble ancs client notify att req att num is wrong!\r\n"); + return MPC_BT_FAIL; + } + + /* 获取应用属性 */ + ble_ancs_app_attr_req_t *app_attr_req = bt_os_new(sizeof(ble_ancs_app_attr_req_t) + (att_num * sizeof(uint8_t))); + uint8_t result = parse_app_att_req_param(app_attr_req, app_id_len, att_num, argv); + if (result != MPC_BT_SUCC) { + if (app_attr_req->app_id.id != NULL) { + bt_os_free(app_attr_req->app_id.id); + } + bt_os_free(app_attr_req); + return result; + } + errcode_t ret = ble_ancs_client_send_get_app_att_cmd(client_id, conn_id, app_attr_req); + bts_info("ble ancs client app att get ret:0x%x\r\n", ret); + bt_os_free(app_attr_req->app_id.id); + bt_os_free(app_attr_req); + return MPC_BT_SUCC; +} + +/* ANCS客户端AT命令与接口对应关系 */ +static ble_ancs_client_at_hdl_info_t g_ble_ancs_client_at_hdl[] = { + { BLE_SAMPLE_ANCS_CLIENT_REGISTER_CBK, ble_ancs_client_at_cmd_register_cbk }, + { BLE_SAMPLE_ANCS_CLIENT_SETUP, ble_ancs_client_at_cmd_setup }, + { BLE_SAMPLE_ANCS_CLIENT_SUBSCRIBE_NOTITY, ble_ancs_client_at_cmd_subscribe_notify }, + { BLE_SAMPLE_ANCS_CLIENT_SUBSCRIBE_DATA, ble_ancs_client_at_cmd_subscribe_data }, + { BLE_SAMPLE_ANCS_CLIENT_NOTIFY_ATT_GET, ble_ancs_client_at_cmd_get_notify_att }, + { BLE_SAMPLE_ANCS_CLIENT_APP_ATT_GET, ble_ancs_client_at_cmd_get_app_att }, + { BLE_SAMPLE_ANCS_CLIENT_PERFORM_ACTION, ble_ancs_client_at_cmd_perform_action }, +}; + +void ble_ancs_client_at_cmd(uint8_t cmd_id, char **params, uint8_t params_cnt) +{ + size_t hdl_cnt = sizeof(g_ble_ancs_client_at_hdl) / sizeof(ble_ancs_client_at_hdl_info_t); + for (uint8_t i = 0; i < hdl_cnt; i++) { + if (g_ble_ancs_client_at_hdl[i].id == cmd_id && g_ble_ancs_client_at_hdl[i].func != NULL) { + (void)g_ble_ancs_client_at_hdl[i].func(params_cnt, params); + return; + } + } +} 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 new file mode 100644 index 000000000..39169e556 --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ams_client.h @@ -0,0 +1,977 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2024. All rights reserved. + * Description: BLE Apple Media Service Client module. + */ + +/** + * @defgroup bluetooth_bts_ams_client AMS CLIENT API + * @ingroup bluetooth + * @{ + */ +#ifndef BLE_AMS_CLIENT_H +#define BLE_AMS_CLIENT_H +#include "errcode.h" +#include "bth_stack.h" +#include "bth_stack_gatt.h" +#include "bts_gatt_client.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @if Eng + * @brief Default value of Client Characteristic Configuration. + * @else + * @brief 客户端特征配置描述符的默认值。 + * @endif + */ +#define BLE_AMS_CLIENT_CHARACTERISTIC_CONFIGURATION_DEFAULT 0x0000 + +/** + * @if Eng + * @brief Client Characteristic Configuration value is notification. + * @else + * @brief 客户端特征配置描述符的值为通知。 + * @endif + */ +#define BLE_AMS_CLIENT_CHARACTERISTIC_CONFIGURATION_NOTIFICATION 0x0001 + +/** + * @if Eng + * @brief Enum of ams notify switch. + * @else + * @brief 通知开关 + * @endif + */ +typedef enum { + AMS_CLIENT_NOTIFY_DISABLE, /*!< @if Eng disable notify @else 关闭通知 @endif */ + AMS_CLIENT_NOTIFY_ENABLE, /*!< @if Eng enable notify @else 开启通知 @endif */ +} ams_client_notify_enable_t; + +/** + * @if Eng + * @brief Enum of remote command + * @else + * @brief 远端命令ID + * @endif + */ +typedef enum { + AMS_RMT_CMD_ID_PLAY = 0, /*!< @if Eng play @else 播放 @endif */ + AMS_RMT_CMD_ID_PAUSE = 1, /*!< @if Eng pause @else 暂停 @endif */ + AMS_RMT_CMD_ID_TOGGLE_PLAY_PAUSE = 2, /*!< @if Eng toggle play or pause @else 切换播放/暂停 @endif */ + AMS_RMT_CMD_ID_NEXT_TRACK = 3, /*!< @if Eng next track @else 下一首 @endif */ + AMS_RMT_CMD_ID_PREVIOUS_TRACK = 4, /*!< @if Eng previous track @else 上一首 @endif */ + AMS_RMT_CMD_ID_VOLUME_UP = 5, /*!< @if Eng volume up @else 调高音量 @endif */ + AMS_RMT_CMD_ID_VOLUME_DOWN = 6, /*!< @if Eng volume down @else 调低音量 @endif */ + AMS_RMT_CMD_ID_ADVANCE_REPEAT_MODE = 7, /*!< @if Eng advance repeat mode @else 高级重复模式 @endif */ + AMS_RMT_CMD_ID_ADVANCE_SHUFFLE_MODE = 8, /*!< @if Eng advance shuffle mode @else 高级随机模式 @endif */ + AMS_RMT_CMD_ID_SKIP_FORWARD = 9, /*!< @if Eng skip forward @else 跳过前一个 @endif */ + AMS_RMT_CMD_ID_SKIP_BACKWARD = 10, /*!< @if Eng skip backward @else 跳过后一个 @endif */ + AMS_RMT_CMD_ID_LIKE_TRACK = 11, /*!< @if Eng like track @else 喜欢 @endif */ + AMS_RMT_CMD_ID_DISLIKE_TRACK = 12, /*!< @if Eng dislike track @else 取消喜欢 @endif */ + AMS_RMT_CMD_ID_BOOKMARK_TRACK = 13, /*!< @if Eng bookmark track @else 标记喜欢或取消喜欢 @endif */ + AMS_RMT_CMD_ID_RESERVED /*!< @if Eng reserved @else 预留命令ID @endif */ +} ams_remote_cmd_id_t; + +/** + * @if Eng + * @brief Enum of entity id + * @else + * @brief 实体ID + * @endif + */ +typedef enum { + AMS_ENTITY_ID_PLAYER = 0, /*!< @if Eng player @else 播放器 @endif */ + AMS_ENTITY_ID_QUEUE = 1, /*!< @if Eng queue @else 播放列表 @endif */ + AMS_ENTITY_ID_TRACK = 2, /*!< @if Eng track @else 曲目 @endif */ + AMS_ENTITY_ID_RESERVED /*!< @if Eng reserved @else 预留实体ID @endif */ +} ams_entity_id_t; + +/** + * @if Eng + * @brief Enum of entity update flags + * @else + * @brief 实体更新标记 + * @endif + */ +typedef enum { + AMS_ENTITY_UPDATE_FLAG_TRUNCATED = (1 << 0), /*!< @if Eng truncated @else 销毁 @endif */ + AMS_ENTITY_UPDATE_FLAG_RESERVED /*!< @if Eng reserved @else 预留标记 @endif */ +} ams_entity_updata_flag_t; + +/** + * @if Eng + * @brief Enum of player attribute id + * @else + * @brief 播放器属性ID + * @endif + */ +typedef enum { + AMS_PALYER_ATT_ID_NAME = 0, /*!< @if Eng name @else 播放器名称 @endif */ + AMS_PALYER_ATT_ID_PLAYBACK_INFO = 1, /*!< @if Eng playback info @else 播放信息 @endif */ + AMS_PALYER_ATT_ID_VOLUME = 2, /*!< @if Eng volume @else 音量,0-1的浮点数 @endif */ + AMS_PALYER_ATT_ID_RESERVED /*!< @if Eng reserved @else 预留属性ID @endif */ +} ams_player_att_id_t; + +/** + * @if Eng + * @brief Enum of queue attribute id + * @else + * @brief 队列属性ID + * @endif + */ +typedef enum { + AMS_QUEUE_ATT_ID_INDEX = 0, /*!< @if Eng index @else 序号,从0开始 @endif */ + AMS_QUEUE_ATT_ID_COUNT = 1, /*!< @if Eng count @else 列表个数 @endif */ + AMS_QUEUE_ATT_ID_SHUFFLE_MODE = 2, /*!< @if Eng shuffle mode @else 随机模式 @endif */ + AMS_QUEUE_ATT_ID_REPEAT_MODE = 3, /*!< @if Eng repeat mode @else 重复模式 @endif */ + AMS_QUEUE_ATT_ID_RESERVED /*!< @if Eng reserved @else 预留属性ID @endif */ +} ams_queue_att_id_t; + + +/** + * @if Eng + * @brief Enum of track attribute id + * @else + * @brief 曲目属性ID + * @endif + */ +typedef enum { + AMS_TRACK_ATT_ID_ARTIST = 0, /*!< @if Eng artist @else 艺术家 @endif */ + AMS_TRACK_ATT_ID_ALBUM = 1, /*!< @if Eng album @else 专辑 @endif */ + AMS_TRACK_ATT_ID_TITLE = 2, /*!< @if Eng title @else 标题 @endif */ + AMS_TRACK_ATT_ID_DURATION = 3, /*!< @if Eng duration @else 音乐时长,秒级,浮点数 @endif */ + AMS_TRACK_ATT_ID_RESERVED /*!< @if Eng reserved @else 预留属性ID @endif */ +} ams_track_att_id_t; + +/** + * @if Eng + * @brief Enum of shuffle mode + * @else + * @brief 随机模式 + * @endif + */ +typedef enum { + AMS_SHUFFLE_MODE_OFF = 0, /*!< @if Eng off @else 关闭 @endif */ + AMS_SHUFFLE_MODE_ONE = 1, /*!< @if Eng one @else 随机模式1 @endif */ + AMS_SHUFFLE_MODE_ALL = 2, /*!< @if Eng all @else 随机模式2 @endif */ + AMS_SHUFFLE_MODE_RESERVED /*!< @if Eng reserved @else 预留随机模式 @endif */ +} ams_shuffle_mode_t; + +/** + * @if Eng + * @brief Enum of repeat mode + * @else + * @brief 重复模式 + * @endif + */ +typedef enum { + AMS_REPEAT_MODE_OFF = 0, /*!< @if Eng off @else 关闭 @endif */ + AMS_REPEAT_MODE_ONE = 1, /*!< @if Eng one @else 重复模式1 @endif */ + AMS_REPEAT_MODE_ALL = 2, /*!< @if Eng all @else 重复模式2 @endif */ + AMS_REPEAT_MODE_RESERVED /*!< @if Eng reserved @else 预留重复模式 @endif */ +} ams_repeat_mode_t; + +/** + * @if Eng + * @brief Enum of subscribe type + * @else + * @brief 订阅类型 + * @endif + */ +typedef enum { + AMS_CLIENT_SUBSCRIBE_REMOTE_CMD = 0, /*!< @if Eng subscribe remote command @else 订阅远端命令 @endif */ + AMS_CLIENT_SUBSCRIBE_ENTITY_UPDATE = 1, /*!< @if Eng subscribe entity update @else 订阅实体更新 @endif */ +} ams_client_subscribe_type_t; + + +/** + * @if Eng + * @brief Enum of write character + * @else + * @brief 写特征类型 + * @endif + */ +typedef enum { + AMS_CLIENT_WRITE_REMOTE_CMD = 0, /*!< @if Eng write remote command @else 写远端命令 @endif */ + AMS_CLIENT_WRITE_ENTITY_UPDATE = 1, /*!< @if Eng write entity update @else 写实体更新 @endif */ + AMS_CLIENT_WRITE_ENTITY_ATTRIBUTE = 2, /*!< @if Eng write entity attribute @else 写实体属性 @endif */ +} ams_client_write_character_type_t; + +/** + * @if Eng + * @brief Enum of ams character. + * @else + * @brief AMS服务特征。 + * @endif + */ +typedef enum { + AMS_CHAR_REMOTE_CMD, /*!< @if Eng remote command @else 远端命令 @endif */ + AMS_CHAR_ENTITY_UPDATE, /*!< @if Eng entity update @else 实体更新 @endif */ + AMS_CHAR_ENTITY_ATTR, /*!< @if Eng entity update @else 实体更新 @endif */ + AMS_CHAR_INVALID, /*!< @if Eng invalid @else 无效特征 @endif */ +} ams_character_t; + +/** + * @if Eng + * @brief Enum of ams error codes. + * @else + * @brief AMS客户端写和读特征响应错误码。 + * @endif + */ +typedef enum { + AMS_ERROR_CODE_INVALID_STATE = 0xA0, /*!< @if Eng Invalid State + @else 无效状态,客户端未发起服务建立 @endif */ + AMS_ERROR_CODE_INVALID_CMD = 0xA1, /*!< @if Eng Invalid command @else 无效命令 @endif */ + AMS_ERROR_CODE_ABSENT_ATTRIBUTE = 0xA2 /*!< @if Eng Absent attribute @else 属性为空 @endif */ +} ams_write_error_code_t; + +/** + * @if Eng + * @brief Struct of ams service. + * @else + * @brief AMS服务。 + * @endif + */ +typedef struct { + 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 */ + uint16_t end_handle; /*!< @if Eng end handle @else 服务结束handle @endif */ + gattc_discovery_character_result_t remote_cmd; /*!< @if Eng remote command @else 远端命令特征 @endif */ + gattc_discovery_character_result_t entity_update; /*!< @if Eng entity update @else 实体更新特征 @endif */ + gattc_discovery_character_result_t entity_attr; /*!< @if Eng entity attribute @else 实体属性特征 @endif */ + uint16_t remote_cmd_ccc_handle; /*!< @if Eng remote command ccc + @else 远端命令特征ccc描述符handle @endif */ + uint16_t entity_update_ccc_handle; /*!< @if Eng entity update ccc + @else 实体更新特征ccc描述符handle @endif */ +} ble_ams_service_t; + +/** + * @if Eng + * @brief Struct of interested entity attribute request. + * @else + * @brief 感兴趣实体属性请求。 + * @endif + */ +typedef struct { + uint8_t entity_id; /*!< @if Eng entity id @else 实体ID @endif */ + uint16_t att_num; /*!< @if Eng the count of attribute @else 属性个数 @endif */ + uint8_t att_id[0]; /*!< @if Eng the array of attribute @else 属性ID数组 @endif */ +} ble_ams_interested_entity_attr_req_t; + +/** + * @if Eng + * @brief Struct of full entity attribute request. + * @else + * @brief 完整实体属性请求。 + * @endif + */ +typedef struct { + uint8_t entity_id; /*!< @if Eng entity id @else 实体ID @endif */ + uint8_t att_id; /*!< @if Eng attribute id @else 属性ID @endif */ +} ble_ams_full_entity_attr_cmd_t; + +/** + * @if Eng + * @brief Struct of supported remote command. + * @else + * @brief 支持的远端命令。 + * @endif + */ +typedef struct { + uint16_t cmd_num; /*!< @if Eng the count of command @else 支持的远端命令个数 @endif */ + uint8_t remote_cmd[0]; /*!< @if Eng the array of remote command @else 支持的远端命令数组 @endif */ +} ble_ams_remote_cmd_rpt_t; + +/** + * @if Eng + * @brief Struct of entity update info. + * @else + * @brief 实体更新信息。 + * @endif + */ +typedef struct { + uint8_t entity_id; /*!< @if Eng entity id @else 实体ID @endif */ + uint8_t att_id; /*!< @if Eng attribute id @else 属性ID @endif */ + uint8_t entity_update_flags; /*!< @if Eng entity update flags @else 实体更新标记 @endif */ + uint16_t value_length; /*!< @if Eng the length of entity value @else 属性值长度 @endif */ + uint8_t value[0]; /*!< @if Eng entity value @else 属性值字节序(字符串,以0结尾),上层应用根据协议解析 @endif */ +} ble_ams_entity_update_rpt_t; + +/** + * @if Eng + * @brief Struct of full entity attribute. + * @else + * @brief 完整实体属性信息。 + * @endif + */ +typedef struct { + uint8_t entity_id; /*!< @if Eng entity id @else 实体ID @endif */ + uint8_t att_id; /*!< @if Eng attribute id @else 属性ID @endif */ + uint16_t value_len; /*!< @if Eng the length of entity value @else 属性值长度 @endif */ + uint8_t value[0]; /*!< @if Eng entity value @else 属性值字节序(字符串,以0结尾) @endif */ +} ble_ams_full_attr_value_t; + + +/** + * @if Eng + * @brief Callback invoked when client setup service complete. + * @par Callback invoked when client setup service complete. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] status error code{ @ref errcode_bt_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_def.h + * @see ble_ams_client_callbacks_t + * @else + * @brief AMS客户端服务建立完成回调函数。 + * @par AMS客户端服务建立完成回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] status 执行结果错误码{ @ref errcode_bt_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_def.h + * @see ble_ams_client_callbacks_t + * @endif + */ +typedef void (*ams_client_setup_result_cbk)(uint8_t client_id, uint16_t conn_id, errcode_t status); + +/** + * @if Eng + * @brief Callback invoked when client subscribe character notify complete. + * @par Callback invoked when client subscribe character notify complete. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] type subscribe type{ @ref ams_client_subscribe_type_t }. + * @param [in] status gatt error code{ @ref gatt_status_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @see ble_ams_client_callbacks_t + * @else + * @brief AMS客户端订阅特征通知结果回调函数。 + * @par AMS客户端订阅特征通知结果回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] type 订阅类型{ @ref ams_client_subscribe_type_t }. + * @param [in] status gatt操作错误码{ @ref gatt_status_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @see ble_ams_client_callbacks_t + * @endif + */ +typedef void (*ams_client_subscribe_result_cbk)(uint8_t client_id, uint16_t conn_id, + ams_client_subscribe_type_t type, gatt_status_t status); + +/** + * @if Eng + * @brief Callback invoked when remote service notify supported remote command. + * @par Callback invoked when remote service notify supported remote command. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] remote_cmd supported remote command{ @ref ble_ams_remote_cmd_rpt_t }. + * @param [in] status error code{ @ref errcode_bt_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_def.h + * @see ble_ams_client_callbacks_t + * @else + * @brief AMS远端服务通知支持的远端命令回调函数。 + * @par AMS远端服务通知支持的远端命令回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] remote_cmd 支持的远端命令{ @ref ble_ams_remote_cmd_rpt_t }. + * @param [in] status 操作错误码{ @ref errcode_bt_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_def.h + * @see ble_ams_client_callbacks_t + * @endif + */ +typedef void (*ams_client_remote_command_rpt_cbk)(uint8_t client_id, uint16_t conn_id, + ble_ams_remote_cmd_rpt_t *remote_cmd, errcode_t status); + +/** + * @if Eng + * @brief Callback invoked when remote service notify entity update info. + * @par Callback invoked when remote service notify entity update info. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] entity_update entity update info{ @ref ble_ams_entity_update_rpt_t }. + * @param [in] status error code{ @ref errcode_bt_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_def.h + * @see ble_ams_client_callbacks_t + * @else + * @brief AMS远端服务通知实体更新信息回调函数。 + * @par AMS远端服务通知实体更新信息回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] entity_update 实体更新信息{ @ref ble_ams_entity_update_rpt_t }. + * @param [in] status 操作错误码{ @ref errcode_bt_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_def.h + * @see ble_ams_client_callbacks_t + * @endif + */ +typedef void (*ams_client_entity_update_rpt_cbk)(uint8_t client_id, uint16_t conn_id, + ble_ams_entity_update_rpt_t *entity_update, errcode_t status); + +/** + * @if Eng + * @brief Callback invoked when client write remote character complete. + * @par Callback invoked when client write remote character complete. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] type character type{ @ref ams_client_write_character_type_t }. + * @param [in] status gatt error code{ @ref gatt_status_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @see ble_ams_client_callbacks_t + * @else + * @brief AMS客户端写对端特征响应回调函数。 + * @par AMS客户端写对端特征响应回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] type 特征类型{ @ref ams_client_write_character_type_t }. + * @param [in] status gatt操作错误码{ @ref gatt_status_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @see ble_ams_client_callbacks_t + * @endif + */ +typedef void (*ams_client_write_character_rsp_cbk)(uint8_t client_id, uint16_t conn_id, + ams_client_write_character_type_t type, + gatt_status_t status); + +/** + * @if Eng + * @brief Callback invoked when client read remote character complete. + * @par Callback invoked when client read remote character complete. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] read_result full attribute value{ @ref ble_ams_full_attr_value_t }. + * @param [in] status gatt error code{ @ref gatt_status_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @see ble_ams_client_callbacks_t + * @else + * @brief AMS客户端读对端特征响应回调函数。 + * @par AMS客户端读对端特征响应回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] read_result 特征值{ @ref ble_ams_full_attr_value_t }. + * @param [in] status gatt操作错误码{ @ref gatt_status_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @see ble_ams_client_callbacks_t + * @endif + */ +typedef void (*ams_client_read_full_attr_result_cbk)(uint8_t client_id, uint16_t conn_id, + ble_ams_full_attr_value_t *read_result, + gatt_status_t status); + +/** + * @if Eng + * @brief Struct of AMS client callback function. + * @else + * @brief AMS 客户端回调函数接口定义。 + * @endif + */ +typedef struct { + ams_client_setup_result_cbk setup_cb; /*!< @if Eng setup callback @else 客户端服务建立完成回调 @endif */ + ams_client_subscribe_result_cbk subscribe_cb; /*!< @if Eng subscribe callback + @else 订阅特征通知结果回调 @endif */ + ams_client_remote_command_rpt_cbk remote_cmd_cb; /*!< @if Eng suppported remote command callback + @else 远端服务通知支持的远端命令回调 @endif */ + ams_client_entity_update_rpt_cbk entity_update_cb; /*!< @if Eng entity update callback + @else 远端服务通知实体更新信息回调 @endif */ + ams_client_write_character_rsp_cbk write_rsp_cb; /*!< @if Eng write response callback + @else 客户端写请求响应回调 @endif */ + ams_client_read_full_attr_result_cbk read_full_attr_result_cb; /*!< @if Eng read response callback + @else 客户端读请求响应回调 @endif */ +} ble_ams_client_callbacks_t; + +/** + * @if Eng + * @brief The interface of AMS client setup service. + * @par The interface of AMS client setup service. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端发起服务建立。 + * @par AMS客户端发起服务建立。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_setup_service(uint8_t client_id, uint16_t conn_id); + +/** + * @if Eng + * @brief The interface of AMS client discovery service result callback. + * @par The interface of AMS client discovery service result callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] service service info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief AMS客户端发现服务结果处理接口。 + * @par AMS客户端发现服务结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] service AMS 服务信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ams_client_discovery_service_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_service_result_t *service); + +/** + * @if Eng + * @brief The interface of AMS client discovery character result callback. + * @par The interface of AMS client discovery character result callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] character character info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief AMS客户端发现特征结果处理接口。 + * @par AMS客户端发现特征结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] character AMS 服务特征信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ams_client_discovery_character_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_character_result_t *character); + +/** + * @if Eng + * @brief The interface of AMS client discovery descriptor result callback. + * @par The interface of AMS client discovery descriptor result callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] descriptor descriptor info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief AMS客户端发现描述符结果处理接口。 + * @par AMS客户端发现描述符结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] descriptor AMS 服务特征描述符信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ams_client_discovery_descriptor_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_descriptor_result_t *descriptor); + +/** + * @if Eng + * @brief The interface of AMS client receive notify info callback. + * @par The interface of AMS client receive notify info callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] data notify info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief AMS客户端接收对端通知信息处理接口。 + * @par AMS客户端接收对端通知信息处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] data 对端通知信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ams_client_notify_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data); + +/** + * @if Eng + * @brief The interface of AMS client write response callback. + * @par The interface of AMS client write response callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] status gatt status {@ref gatt_status_t}. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @see + * @else + * @brief AMS客户端写请求响应结果处理接口。 + * @par AMS客户端写请求响应结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] status gatt 操作结果码 {@ref gatt_status_t}. + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @see + * @endif + */ +void ble_ams_client_write_cbk(uint8_t client_id, uint16_t conn_id, uint16_t handle, gatt_status_t status); + +/** + * @if Eng + * @brief The interface of AMS client read response callback. + * @par The interface of AMS client read response callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] read_result read response result. + * @param [in] status gatt status {@ref gatt_status_t}. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @li bts_gatt_client.h + * @see + * @else + * @brief AMS客户端读请求响应结果处理接口。 + * @par AMS客户端读请求响应结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] read_result 读请求响应结果. + * @param [in] status gatt 操作结果码 {@ref gatt_status_t}. + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ams_client_read_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *read_result, + gatt_status_t status); + +/** + * @if Eng + * @brief The interface of AMS client subscribe remote command character notify. + * @par The interface of AMS client subscribe remote command character notify. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] enable_flag enable/disable flag {@ref ams_client_notify_enable_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端订阅远端命令特征通知接口。 + * @par AMS客户端订阅远端命令特征通知接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] enable_flag 开启/关闭标记。 {@ref ams_client_notify_enable_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_subscribe_remote_cmd(uint8_t client_id, uint16_t conn_id, + ams_client_notify_enable_t enable_flag); + +/** + * @if Eng + * @brief The interface of AMS client subscribe entity update character notify. + * @par The interface of AMS client subscribe entity update character notify. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] enable_flag enable/disable flag {@ref ams_client_notify_enable_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端订阅实体更新特征通知接口。 + * @par AMS客户端订阅实体更新特征通知接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] enable_flag 开启/关闭标记。 {@ref ams_client_notify_enable_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_subscribe_entity_update(uint8_t client_id, uint16_t conn_id, + ams_client_notify_enable_t enable_flag); + +/** + * @if Eng + * @brief The interface of AMS client send remote command. + * @par The interface of AMS client send remote command, it is used for operating remote media action. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] cmd_id command id {@ref ams_remote_cmd_id_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端发送远端命令接口。 + * @par AMS客户端发送远端命令接口,该接口用来控制对端媒体行为,例如播放/暂停,调节音量等 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] cmd_id 命令ID。 {@ref ams_remote_cmd_id_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_send_remote_cmd(uint8_t client_id, uint16_t conn_id, + ams_remote_cmd_id_t cmd_id); + +/** + * @if Eng + * @brief The interface of AMS client register interested entity attribute. + * @par The interface of AMS client register interested entity attribute. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] entity_attr_req interested entity attribute list. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端注册感兴趣的实体属性接口。 + * @par AMS客户端注册感兴趣的实体属性,当该实体属性更新时,对端会发送通知到本端。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] entity_attr_req 感兴趣的实体属性列表。 + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_register_interested_entity_attribute(uint8_t client_id, uint16_t conn_id, + ble_ams_interested_entity_attr_req_t *entity_attr_req); + +/** + * @if Eng + * @brief The interface of AMS client retrieve full entity attribute. + * @par The interface of AMS client retrieve full entity attribute. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] full_attr_req entity attribute. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端请求对端加载完整的实体属性信息接口。 + * @par AMS客户端请求对端加载完整的实体属性信息接口,稍后AMS客户端再发起读请求,读取完整的实体属性信息。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] full_attr_req 实体属性。 + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_retrieve_full_entity_attribute(uint8_t client_id, uint16_t conn_id, + ble_ams_full_entity_attr_cmd_t *full_attr_req); + +/** + * @if Eng + * @brief The interface of AMS client read full entity attribute. + * @par The interface of AMS client read full entity attribute. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端读取完整实体属性信息接口。 + * @par AMS客户端读取完整完整实体属性信息接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_read_full_entity_attribute(uint8_t client_id, uint16_t conn_id); + +/** + * @if Eng + * @brief The interface of AMS client register callback. + * @par The interface of AMS client register callback. + * @attention + * @param [in] func the pointer of callback struct. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief AMS客户端注册回调接口。 + * @par AMS客户端注册回调接口。 + * @attention + * @param [in] func 回调函数结构体指针。 + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ams_client_register_callbacks(ble_ams_client_callbacks_t *func); + +/** + * @if Eng + * @brief The interface of check service uuid whether or not AMS service. + * @par The interface of check service uuid whether or not AMS service. + * @attention + * @param [in] uuid service uuid. + * @retval true or false true:Yes, false:No. + * @par Dependency: + * @li + * @see + * @else + * @brief AMS客户端注册回调接口。 + * @par AMS客户端注册回调接口。 + * @attention + * @param [in] uuid 服务uuid。 + * @retval 是或否 是:是AMS服务,否:不是AMS服务. + * @par 依赖: + * @li + * @see + * @endif + */ +bool is_ble_ams_service(bt_uuid_t *uuid); + +/** + * @if Eng + * @brief The interface of AMS client clear stored remote ams service info by connect id. + * @par The interface of AMS client clear stored remote ams service info by connect id. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @retval #void no return value. + * @par Dependency: + * @li + * @see + * @else + * @brief AMS客户端根据连接ID清理存储的对端AMS服务信息。 + * @par AMS客户端根据连接ID清理存储的对端AMS服务信息。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @retval 无返回值。 + * @par 依赖: + * @li + * @see + * @endif + */ +void ble_ams_client_clear_remote_by_conn(uint8_t client_id, uint16_t conn_id); + +/** + * @if Eng + * @brief The interface of AMS client clear all stored remote ams service info. + * @par The interface of AMS client clear all stored remote ams service info. + * @attention + * @retval #void no return value. + * @par Dependency: + * @li + * @see + * @else + * @brief AMS客户端清理所有存储的对端AMS服务信息。 + * @par AMS客户端清理所有存储的对端AMS服务信息。 + * @attention + * @retval 无返回值。 + * @par 依赖: + * @li + * @see + * @endif + */ +void ble_ams_client_clear_remote_all(void); + +/** + * @} + */ +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file 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 new file mode 100644 index 000000000..4a7190972 --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_ancs_client.h @@ -0,0 +1,947 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2024. All rights reserved. + * Description: BLE Apple Notification Center Service Client module. + */ + +/** + * @defgroup bluetooth_bts_ancs_client ANCS CLIENT API + * @ingroup bluetooth + * @{ + */ +#ifndef BLE_ANCS_CLIENT_H +#define BLE_ANCS_CLIENT_H +#include "errcode.h" +#include "sdk_list.h" +#include "bth_stack.h" +#include "bth_stack_gatt.h" +#include "bts_gatt_client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @if Eng + * @brief Default value of Client Characteristic Configuration. + * @else + * @brief 客户端特征配置描述符的默认值。 + * @endif + */ +#define BLE_ANCS_CLIENT_CHARACTERISTIC_CONFIGURATION_DEFAULT 0x0000 + +/** + * @if Eng + * @brief Client Characteristic Configuration value is notification. + * @else + * @brief 客户端特征配置描述符的值为通知。 + * @endif + */ +#define BLE_ANCS_CLIENT_CHARACTERISTIC_CONFIGURATION_NOTIFICATION 0x0001 + +/** + * @if Eng + * @brief Enum of ancs notify switch. + * @else + * @brief 通知开关枚举值。 + * @endif + */ +typedef enum { + ANCS_CLIENT_NOTIFY_DISABLE, /*!< @if Eng disable notify @else 关闭通知 @endif */ + ANCS_CLIENT_NOTIFY_ENABLE, /*!< @if Eng enable notify @else 开启通知 @endif */ +} ancs_client_notify_enable_t; + +/** + * @if Eng + * @brief Enum of event id + * @else + * @brief 事件ID枚举值 + * @endif + */ +typedef enum { + ANCS_EVENT_ADDED = 0, /*!< @if Eng add @else 新增通知 @endif */ + ANCS_EVENT_MODIFIED = 1, /*!< @if Eng modify @else 修改通知 @endif */ + ANCS_EVENT_REMOEVD = 2, /*!< @if Eng remove @else 移除通知 @endif */ + ANCS_EVENT_RESERVED /*!< @if Eng reserved @else 预留事件ID @endif */ +} ancs_event_id_t; + +/** + * @if Eng + * @brief Enum of event flags + * @else + * @brief 事件标记枚举值 + * @endif + */ +typedef enum { + ANCS_EVENT_FLAG_SILENT = (1 << 0), /*!< @if Eng silent @else 安静 @endif */ + ANCS_EVENT_FLAG_IMPORTANT = (1 << 1), /*!< @if Eng important @else 重要 @endif */ + ANCS_EVENT_FLAG_PREEXISTING = (1 << 2), /*!< @if Eng preexisting @else 先存的 @endif */ + ANCS_EVENT_FLAG_POSITIVE_ACTION = (1 << 3), /*!< @if Eng positive action @else 积极活动 @endif */ + ANCS_EVENT_FLAG_NEGATIVE_ACTION = (1 << 4), /*!< @if Eng negative action @else 消极活动 @endif */ + ANCS_EVENT_FLAG_RESERVED /*!< @if Eng reserved @else 预留事件标记 @endif */ +} ancs_event_flags_t; + +/** + * @if Eng + * @brief Enum of command id + * @else + * @brief 命令ID枚举值 + * @endif + */ +typedef enum { + ANCS_CMD_GET_NOTIFY_ATT = 0, /*!< @if Eng Get notify attribute @else 获取通知属性 @endif */ + ANCS_CMD_GET_APP_ATT = 1, /*!< @if Eng Get app attribute @else 获取应用属性 @endif */ + ANCS_CMD_PERFORM_NOTIFY_ACTION = 2, /*!< @if Eng Perform notify action @else 处理通知 @endif */ + ANCS_CMD_RESERVED /*!< @if Eng reserved @else 预留命令ID @endif */ +} ancs_command_id_t; + +/** + * @if Eng + * @brief Enum of category id + * @else + * @brief 分类ID枚举值 + * @endif + */ +typedef enum { + ANCS_CATEGORY_OTHER = 0, /*!< @if Eng Other @else 其他 @endif */ + ANCS_CATEGORY_INCOMING_CALL = 1, /*!< @if Eng Incoming call @else 来电 @endif */ + ANCS_CATEGORY_MISSED_CALL = 2, /*!< @if Eng Missed call @else 未接来电 @endif */ + ANCS_CATEGORY_VOICE_MAIL = 3, /*!< @if Eng Voice mail @else 语音消息 @endif */ + ANCS_CATEGORY_SOCIAL = 4, /*!< @if Eng Social @else 社交 @endif */ + ANCS_CATEGORY_SCHEDULE = 5, /*!< @if Eng Schedule @else 计划 @endif */ + ANCS_CATEGORY_EMAIL = 6, /*!< @if Eng Email @else 邮件 @endif */ + ANCS_CATEGORY_NEWS = 7, /*!< @if Eng News @else 新闻 @endif */ + ANCS_CATEGORY_HEALTH_FITNESS = 8, /*!< @if Eng Health fitness @else 运动健康 @endif */ + ANCS_CATEGORY_BUSINESS_FINANCE = 9, /*!< @if Eng Business finance @else 商业金融 @endif */ + ANCS_CATEGORY_LOCATION = 10, /*!< @if Eng Location @else 位置 @endif */ + ANCS_CATEGORY_ENTERTAINMENT = 11, /*!< @if Eng Entertainment @else 娱乐 @endif */ + ANCS_CATEGORY_RESERVED /*!< @if Eng reserved @else 预留分类ID @endif */ +} ancs_category_id_t; + + +/** + * @if Eng + * @brief Enum of notify attribute id + * @else + * @brief 通知属性ID枚举值 + * @endif + */ +typedef enum { + ANCS_NOTIFY_ATT_APP_ID = 0, /*!< @if Eng App id @else 应用编号 @endif */ + ANCS_NOTIFY_ATT_TITLE = 1, /*!< @if Eng Title @else 标题 @endif */ + ANCS_NOTIFY_ATT_SUBTITLE = 2, /*!< @if Eng Subtitle @else 副标题 @endif */ + ANCS_NOTIFY_ATT_MESSAGE = 3, /*!< @if Eng Message @else 消息 @endif */ + ANCS_NOTIFY_ATT_MSG_SIZE = 4, /*!< @if Eng Message size @else 消息大小 @endif */ + ANCS_NOTIFY_ATT_DATE = 5, /*!< @if Eng Date @else 日期 @endif */ + ANCS_NOTIFY_ATT_POSITIVE_LABEL = 6, /*!< @if Eng Positive lable @else 积极活动标签 @endif */ + ANCS_NOTIFY_ATT_NEGATIVE_LABEL = 7, /*!< @if Eng Negative lable @else 消极活动标签 @endif */ + ANCS_NOTIFY_ATT_RESERVED /*!< @if Eng reserved @else 预留通知属性ID @endif */ +} ancs_notification_att_id_t; + +/** + * @if Eng + * @brief Enum of app attribute id + * @else + * @brief 应用属性ID枚举值 + * @endif + */ +typedef enum { + ANCS_APP_ATT_DISPLAY_NAME = 0, /*!< @if Eng Display name @else 应用显示名称 @endif */ + ANCS_APP_ATT_RESERVED /*!< @if Eng reserved @else 预留应用属性ID @endif */ +} ancs_app_att_id_t; + +/** + * @if Eng + * @brief Enum of action id + * @else + * @brief 活动ID枚举值 + * @endif + */ +typedef enum { + ANCS_ACTION_POSITIVE = 0, /*!< @if Eng Positive @else 积极活动 @endif */ + ANCS_ACTION_NEGATIVE = 1, /*!< @if Eng Negative @else 消极活动 @endif */ + ANCS_ACTION_RESERVED /*!< @if Eng Reserved @else 预留活动ID @endif */ +} ancs_action_id_t; + +/** + * @if Eng + * @brief Enum of subscribe type + * @else + * @brief 订阅类型 + * @endif + */ +typedef enum { + ANCS_CLIENT_SUBSCRIBE_NOTIFY = 0, /*!< @if Eng Subscribe notify @else 订阅通知 @endif */ + ANCS_CLIENT_SUBSCRIBE_DATA = 1, /*!< @if Eng Subscribe data @else 订阅数据 @endif */ +} ancs_client_subscribe_type_t; + +/** + * @if Eng + * @brief Enum of ancs servie character. + * @else + * @brief ANCS服务特征。 + * @endif + */ +typedef enum { + ANCS_CHAR_NOTIFY_SRC = 0, /*!< @if Eng Notify source @else 通知源 @endif */ + ANCS_CHAR_CTRL_POINT = 1, /*!< @if Eng Control point @else 控制点 @endif */ + ANCS_CHAR_DATA_SRC = 2, /*!< @if Eng Data Source @else 数据源 @endif */ + ANCS_CHAR_INVALID, +} ancs_character_t; + +/** + * @if Eng + * @brief Enum of ancs error codes. + * @else + * @brief ANCS客户端写特征响应错误码。 + * @endif + */ +typedef enum { + ANCS_ERROR_CODE_UNKNOW_CMD = 0xA0, /*!< @if Eng Unknown command @else 未知命令 @endif */ + ANCS_ERROR_CODE_INVALID_CMD = 0xA1, /*!< @if Eng Invalid command @else 无效命令 @endif */ + ANCS_ERROR_CODE_INVALID_PARAM = 0xA2, /*!< @if Eng Invalid parameter @else 无效参数 @endif */ + ANCS_ERROR_CODE_ACTION_FAILED = 0xA3 /*!< @if Eng The action was not performed @else 行为没有被执行 @endif */ +} ancs_write_error_code_t; + +/** + * @if Eng + * @brief Struct of ancs servie. + * @else + * @brief ANCS服务。 + * @endif + */ +typedef struct { + 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 */ + uint16_t end_handle; /*!< @if Eng End handle @else 结束handle @endif */ + gattc_discovery_character_result_t notify_src; /*!< @if Eng Notify source @else 通知源 @endif */ + gattc_discovery_character_result_t ctl_point; /*!< @if Eng Control point @else 控制点 @endif */ + gattc_discovery_character_result_t data_src; /*!< @if Eng Data Source @else 数据源 @endif */ + uint16_t notify_src_ccc_handle; /*!< @if Eng Notify source CCC handle + @else 通知源CCC描述符handle @endif */ + uint16_t data_src_ccc_handle; /*!< @if Eng Data source CCC handle + @else 数据源CCC描述符handle @endif */ +} ble_ancs_service_t; + + +/** + * @if Eng + * @brief Struct of notification info. + * @else + * @brief 通知消息结构体。 + * @endif + */ +typedef struct { + uint8_t event_id; /*!< @if Eng Event id {@ref ancs_event_id_t} + @else 事件ID {@ref ancs_event_id_t} @endif */ + uint8_t event_flags; /*!< @if Eng Event flags {@ref ancs_event_flags_t} + @else 事件标记 {@ref ancs_event_flags_t} @endif */ + uint8_t category_id; /*!< @if Eng Category id {@ref ancs_category_id_t} + @else 分类ID {@ref ancs_category_id_t} @endif */ + uint8_t category_count; /*!< @if Eng Category count @else 分类消息个数 @endif */ + uint32_t notification_uid; /*!< @if Eng Notify uuid @else 通知ID @endif */ +} ble_ancs_notification_src_t; + +/** + * @if Eng + * @brief Struct of attribute request + * @else + * @brief 属性请求结构体。 + * @endif + */ +typedef struct { + uint8_t att_id; /*!< @if Eng Attribute id @else 属性ID @endif */ + uint16_t att_max_length; /*!< @if Eng Attribute max length + @else 属性值最大长度,仅用于通知属性【标题】【子标题】【消息】属性,其他属性传0 @endif */ +} ble_ancs_attr_req_t; + +/** + * @if Eng + * @brief Struct of notify attribute request + * @else + * @brief 通知属性请求结构体。 + * @endif + */ +typedef struct { + uint32_t notification_uid; /*!< @if Eng Notify uuid @else 通知ID @endif */ + uint16_t att_num; /*!< @if Eng Attribute num @else 属性个数 @endif */ + ble_ancs_attr_req_t attr[0]; /*!< @if Eng Attribute array @else 属性ID数组 @endif */ +} ble_ancs_notification_attr_req_t; + +/** + * @if Eng + * @brief Struct of attribute response + * @else + * @brief 属性响应结构体。 + * @endif + */ +typedef struct { + 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 */ +} ble_ancs_attr_rsp_t; + +/** + * @if Eng + * @brief Struct of notify attribute response + * @else + * @brief 通知属性响应结构体。 + * @endif + */ +typedef struct { + uint32_t notification_uid; /*!< @if Eng Notify uuid @else 通知ID @endif */ + uint16_t att_num; /*!< @if Eng Attribute num @else 属性个数 @endif */ + struct list_stru attr_rsp_lst; /*!< @if Eng Attribute list {@ref ble_ancs_attr_rsp_t} + @else 属性列表 {@ref ble_ancs_attr_rsp_t} @endif */ +} ble_ancs_notification_attr_rsp_t; + +/** + * @if Eng + * @brief Struct of APP id + * @else + * @brief 应用ID + * @endif + */ +typedef struct { + uint16_t len; /*!< @if Eng Length @else 长度 @endif */ + uint8_t *id; /*!< @if Eng Id @else ID @endif */ +} ble_ancs_app_id_t; + +/** + * @if Eng + * @brief Struct of app attribute request + * @else + * @brief 应用属性请求结构体。 + * @endif + */ +typedef struct { + ble_ancs_app_id_t app_id; /*!< @if Eng App id @else 应用ID @endif */ + uint16_t att_num; /*!< @if Eng Attribute num @else 属性个数 @endif */ + uint8_t attr_id[0]; /*!< @if Eng Attribute Array {@ref ancs_app_att_id_t} + @else 属性ID数组 {@ref ancs_app_att_id_t} @endif */ +} ble_ancs_app_attr_req_t; + +/** + * @if Eng + * @brief Struct of app attribute response + * @else + * @brief 应用属性响应结构体。 + * @endif + */ +typedef struct { + ble_ancs_app_id_t app_id; /*!< @if Eng App id @else 应用ID @endif */ + uint16_t att_num; /*!< @if Eng Attribute num @else 属性个数 @endif */ + struct list_stru attr_rsp_lst; /*!< @if Eng Attribute list {@ref ble_ancs_attr_rsp_t} + @else 属性列表 {@ref ble_ancs_attr_rsp_t} @endif */ +} ble_ancs_app_attr_rsp_t; + + +/** + * @if Eng + * @brief Struct of perform action request + * @else + * @brief 通知处理请求结构体。 + * @endif + */ +typedef struct { + uint32_t notification_uid; /*!< @if Eng Notify uuid @else 通知ID @endif */ + uint8_t action_id; /*!< @if Eng Action id {@ref ancs_action_id_t} + @else 行为ID {@ref ancs_action_id_t} @endif */ +} ble_ancs_notification_action_req_t; + +/** + * @if Eng + * @brief Callback invoked when client setup service complete. + * @par Callback invoked when client setup service complete. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] status error code{ @ref errcode_bt_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @else + * @brief ANCS客户端服务建立完成回调函数。 + * @par ANCS客户端服务建立完成回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] status 执行结果错误码{ @ref errcode_bt_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @endif + */ +typedef void (*ancs_client_setup_result_cbk)(uint8_t client_id, uint16_t conn_id, errcode_t status); + +/** + * @if Eng + * @brief Callback invoked when client subscribe character notify complete. + * @par Callback invoked when client subscribe character notify complete. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] type subscribe type{ @ref ancs_client_subscribe_type_t }. + * @param [in] status gatt error code{ @ref gatt_status_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @see ble_ancs_client_callbacks_t + * @else + * @brief ANCS客户端订阅特征通知结果回调函数。 + * @par ANCS客户端订阅特征通知结果回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] type 订阅类型{ @ref ancs_client_subscribe_type_t }. + * @param [in] status gatt操作错误码{ @ref gatt_status_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @see ble_ancs_client_callbacks_t + * @endif + */ +typedef void (*ancs_client_subscribe_result_cbk)(uint8_t client_id, uint16_t conn_id, + ancs_client_subscribe_type_t type, gatt_status_t status); + +/** + * @if Eng + * @brief Callback invoked when remote service push notify message. + * @par Callback invoked when remote service push notify message. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] notify_src notify message { @ref ble_ancs_notification_src_t }. + * @param [in] status error code{ @ref errcode_bt_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @else + * @brief ANCS远端服务推送通知消息回调函数。 + * @par ANCS远端服务推送通知消息回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] notify_src 通知消息 { @ref ble_ancs_notification_src_t }. + * @param [in] status 操作错误码{ @ref errcode_bt_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @endif + */ +typedef void (*ancs_client_notify_source_cbk)(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_src_t *notify_src, errcode_t status); + +/** + * @if Eng + * @brief Callback invoked when remote service push notify attribute info. + * @par Callback invoked when remote service push notify attribute info. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] notify_attr_rsp notify attribute info { @ref ble_ancs_notification_attr_rsp_t }. + * @param [in] status error code{ @ref errcode_bt_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @else + * @brief ANCS远端服务推送通知属性信息回调函数。 + * @par ANCS远端服务推送通知属性信息回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] notify_attr_rsp 通知属性信息 { @ref ble_ancs_notification_attr_rsp_t }. + * @param [in] status 操作错误码{ @ref errcode_bt_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @endif + */ +typedef void (*ancs_client_notification_attr_rsp_cbk)(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_attr_rsp_t *notify_attr_rsp, errcode_t status); + +/** + * @if Eng + * @brief Callback invoked when remote service push app attribute info. + * @par Callback invoked when remote service push app attribute info. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] app_attr_rsp app attribute info { @ref ble_ancs_app_attr_rsp_t }. + * @param [in] status error code{ @ref errcode_bt_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @else + * @brief ANCS远端服务推送应用属性信息回调函数。 + * @par ANCS远端服务推送应用属性信息回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] app_attr_rsp 应用属性信息 { @ref ble_ancs_app_attr_rsp_t }. + * @param [in] status 操作错误码{ @ref errcode_bt_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_def.h + * @see ble_ancs_client_callbacks_t + * @endif + */ +typedef void (*ancs_client_app_attr_rsp_cbk)(uint8_t client_id, uint16_t conn_id, + ble_ancs_app_attr_rsp_t *app_attr_rsp, errcode_t status); + +/** + * @if Eng + * @brief Callback invoked when client write contro point complete. + * @par Callback invoked when client write contro point complete. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] status gatt error code{ @ref gatt_status_t }. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @see ble_ancs_client_callbacks_t + * @else + * @brief AMS客户端写控制点特征响应回调函数。 + * @par AMS客户端写控制点特征响应回调函数。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] status gatt操作错误码{ @ref gatt_status_t }。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @see ble_ancs_client_callbacks_t + * @endif + */ +typedef void (*ancs_client_write_result_cbk)(uint8_t client_id, uint16_t conn_id, gatt_status_t status); + +/** + * @if Eng + * @brief Struct of GATT client callback function. + * @else + * @brief GATT client回调函数接口定义。 + * @endif + */ +typedef struct { + ancs_client_setup_result_cbk setup_cb; /*!< @if Eng setup callback @else 客户端服务建立完成回调 @endif */ + ancs_client_subscribe_result_cbk subscribe_cb; /*!< @if Eng subscribe callback @else 订阅特征通知结果回调 @endif */ + ancs_client_notify_source_cbk notify_source_cb; /*!< @if Eng notify source callback + @else 远端服务推送通知消息回调 @endif */ + ancs_client_notification_attr_rsp_cbk notify_attr_cb; /*!< @if Eng notify attribute callback + @else 远端服务推送通知属性信息回调 @endif */ + ancs_client_app_attr_rsp_cbk app_attr_cb; /*!< @if Eng app attribute callback + @else 远端服务推送应用属性信息回调 @endif */ + ancs_client_write_result_cbk write_result_cb; /*!< @if Eng write result callback + @else 客户端写控制点特征请求响应回调 @endif */ +} ble_ancs_client_callbacks_t; + +/** + * @if Eng + * @brief The interface of ANCS client setup service. + * @par The interface of ANCS client setup service. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief ANCS客户端发起服务建立。 + * @par ANCS客户端发起服务建立。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ancs_client_setup_service(uint8_t client_id, uint16_t conn_id); + +/** + * @if Eng + * @brief The interface of ANCS client discovery service result callback. + * @par The interface of ANCS client discovery service result callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] service service info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief ANCS客户端发现服务结果处理接口。 + * @par ANCS客户端发现服务结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] service ANCS 服务信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ancs_client_discovery_service_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_service_result_t *service); + +/** + * @if Eng + * @brief The interface of ANCS client discovery character result callback. + * @par The interface of ANCS client discovery character result callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] character character info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief ANCS客户端发现特征结果处理接口。 + * @par ANCS客户端发现特征结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] character ANCS 服务特征信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ancs_client_discovery_character_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_character_result_t *character); + +/** + * @if Eng + * @brief The interface of ANCS client discovery descriptor result callback. + * @par The interface of ANCS client discovery descriptor result callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] descriptor descriptor info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief ANCS客户端发现描述符结果处理接口。 + * @par ANCS客户端发现描述符结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] descriptor ANCS服务特征描述符信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ancs_client_discovery_descriptor_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_descriptor_result_t *descriptor); + +/** + * @if Eng + * @brief The interface of ANCS client receive notify info callback. + * @par The interface of ANCS client receive notify info callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] data notify info. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_client.h + * @see + * @else + * @brief ANCS客户端接收对端通知信息处理接口。 + * @par ANCS客户端接收对端通知信息处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] data 对端通知信息。 + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_client.h + * @see + * @endif + */ +void ble_ancs_client_notify_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data); + +/** + * @if Eng + * @brief The interface of ANCS client write response callback. + * @par The interface of ANCS client write response callback. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] status gatt status {@ref gatt_status_t}. + * @retval #void no return value. + * @par Dependency: + * @li bts_gatt_stru.h + * @see + * @else + * @brief ANCS客户端写请求响应结果处理接口。 + * @par ANCS客户端写请求响应结果处理接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] status gatt 操作结果码 {@ref gatt_status_t}. + * @retval 无返回值。 + * @par 依赖: + * @li bts_gatt_stru.h + * @see + * @endif + */ +void ble_ancs_client_write_cbk(uint8_t client_id, uint16_t conn_id, uint16_t handle, gatt_status_t status); + +/** + * @if Eng + * @brief The interface of ANCS client subscribe notify source character notify. + * @par The interface of ANCS client subscribe notify source character notify. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] enable_flag enable/disable flag {@ref ancs_client_notify_enable_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief ANCS客户端订阅通知源特征通知接口。 + * @par ANCS客户端订阅通知源特征通知接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] enable_flag 开启/关闭标记。 {@ref ancs_client_notify_enable_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ancs_client_subscribe_notification_source(uint8_t client_id, uint16_t conn_id, + ancs_client_notify_enable_t enable_flag); + +/** + * @if Eng + * @brief The interface of ANCS client subscribe data source character notify. + * @par The interface of ANCS client subscribe data source character notify. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] enable_flag enable/disable flag {@ref ancs_client_notify_enable_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief ANCS客户端订阅数据源特征通知接口。 + * @par ANCS客户端订阅数据源特征通知接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] enable_flag 开启/关闭标记。 {@ref ancs_client_notify_enable_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ancs_client_subscribe_data_source(uint8_t client_id, uint16_t conn_id, + ancs_client_notify_enable_t enable_flag); + +/** + * @if Eng + * @brief The interface of ANCS client send get notify attribute command. + * @par The interface of ANCS client send get notify attribute command. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] notify_att_req notify attribute request {@ref ble_ancs_notification_attr_req_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief ANCS客户端发送获取通知属性命令接口。 + * @par ANCS客户端发送获取通知属性命令接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] notify_att_req 通知属性请求。 {@ref ble_ancs_notification_attr_req_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ancs_client_send_get_notify_att_cmd(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_attr_req_t *notify_att_req); + +/** + * @if Eng + * @brief The interface of ANCS client send get app attribute command. + * @par The interface of ANCS client send get app attribute command. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] app_att_req app attribute request {@ref ble_ancs_app_attr_req_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief ANCS客户端发送获取应用属性命令接口。 + * @par ANCS客户端发送获取应用属性命令接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] app_att_req 应用属性请求。 {@ref ble_ancs_app_attr_req_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ancs_client_send_get_app_att_cmd(uint8_t client_id, uint16_t conn_id, + ble_ancs_app_attr_req_t *app_att_req); + +/** + * @if Eng + * @brief The interface of ANCS client send perform notify action command. + * @par The interface of ANCS client send perform notify action command. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @param [in] action_req perform action request {@ref ble_ancs_notification_action_req_t}. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief ANCS客户端发送执行通知行为命令接口。 + * @par ANCS客户端发送执行通知行为命令接口。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @param [in] action_req 执行行为请求。 {@ref ble_ancs_notification_action_req_t}. + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ancs_client_send_perform_notify_action_cmd(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_action_req_t *action_req); + +/** + * @if Eng + * @brief The interface of ANCS client register callback. + * @par The interface of ANCS client register callback. + * @attention + * @param [in] func the pointer of callback struct. + * @retval errcode_t {@ref errcode_bt_t}. + * @par Dependency: + * @li bts_def.h + * @see + * @else + * @brief ANCS客户端注册回调接口。 + * @par ANCS客户端注册回调接口。 + * @attention + * @param [in] func 回调函数结构体指针。 + * @retval 操作错误码 {@ref errcode_bt_t}. + * @par 依赖: + * @li bts_def.h + * @see + * @endif + */ +errcode_t ble_ancs_client_register_callbacks(ble_ancs_client_callbacks_t *func); + +/** + * @if Eng + * @brief The interface of check service uuid whether or not ANCS service. + * @par The interface of check service uuid whether or not ANCS service. + * @attention + * @param [in] uuid service uuid. + * @retval true or false true:Yes, false:No. + * @par Dependency: + * @li + * @see + * @else + * @brief ANCS客户端注册回调接口。 + * @par ANCS客户端注册回调接口。 + * @attention + * @param [in] uuid 服务uuid。 + * @retval 是或否 是:是ANCS服务,否:不是ANCS服务. + * @par 依赖: + * @li + * @see + * @endif + */ +bool is_ble_ancs_service(bt_uuid_t *uuid); + +/** + * @if Eng + * @brief The interface of ANCS client clear stored remote ANCS service info by connect id. + * @par The interface of ANCS client clear stored remote ANCS service info by connect id. + * @attention + * @param [in] client_id client ID. + * @param [in] conn_id connect id. + * @retval #void no return value. + * @par Dependency: + * @li + * @see + * @else + * @brief ANCS客户端根据连接ID清理存储的对端ANCS服务信息。 + * @par ANCS客户端根据连接ID清理存储的对端ANCS服务信息。 + * @attention + * @param [in] client_id 客户端ID。 + * @param [in] conn_id 连接ID。 + * @retval 无返回值。 + * @par 依赖: + * @li + * @see + * @endif + */ +void ble_ancs_client_clear_remote_by_conn(uint8_t client_id, uint16_t conn_id); + +/** + * @if Eng + * @brief The interface of ANCS client clear all stored remote ANCS service info. + * @par The interface of ANCS client clear all stored remote ANCS service info. + * @attention + * @retval #void no return value. + * @par Dependency: + * @li + * @see + * @else + * @brief ANCS客户端清理所有存储的对端ANCS服务信息。 + * @par ANCS客户端清理所有存储的对端ANCS服务信息。 + * @attention + * @retval 无返回值。 + * @par 依赖: + * @li + * @see + * @endif + */ +void ble_ancs_client_clear_remote_all(void); + +/** + * @} + */ +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_gatts_callbacks.h b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_gatts_callbacks.h index 2963b3a15..3dd3092fa 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_gatts_callbacks.h +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/include/ble_gatts_callbacks.h @@ -14,6 +14,7 @@ extern "C" { errcode_t ble_server_register_gatt_callbacks(void); errcode_t ble_client_register_gatt_callbacks(void); +uint32_t ble_gatt_mtu_exchange_result_get(void); /** * @} diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/CMakeLists.txt b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/CMakeLists.txt index 1473bfd4d..b626a1df0 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/CMakeLists.txt +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/CMakeLists.txt @@ -8,5 +8,7 @@ set( ${CMAKE_CURRENT_SOURCE_DIR}/ble_fmp_target.c ${CMAKE_CURRENT_SOURCE_DIR}/ble_fmp_locator.c ${CMAKE_CURRENT_SOURCE_DIR}/ble_gatts_callbacks.c + ${CMAKE_CURRENT_SOURCE_DIR}/ble_ancs_client.c + ${CMAKE_CURRENT_SOURCE_DIR}/ble_ams_client.c ) set(BTH_SAMPLE_LIST "${BTH_SAMPLE_LIST}" "${bt_comm_src_list}" CACHE INTERNAL "bt ram obj list" FORCE) diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_ams_client.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_ams_client.c new file mode 100644 index 000000000..56f352e4e --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_ams_client.c @@ -0,0 +1,593 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2024. All rights reserved. + * Description: BLE Apple Media Service Client module. + */ + +#include +#include "sdk_list.h" +#include "errcode.h" +#include "btsrv_log.h" +#include "bts_le_gap.h" +#include "sdk_general.h" +#include "bts_uuid.h" +#include "ble_ams_client.h" + +#define BLE_CLIENT_CHARACTERISTIC_CONFIGURATION_UUID 0x2902 +#define AMS_ENTITY_UPDATE_NOTIFY_VALUE_OFFSET 3 +#define AMS_ENTITY_UPDATE_NOTIFY_FLAGS_OFFSET 2 +#define AMS_STRING_SUFFIX_ZERO_BYTE 1 + +#define u16_low_byte(uuid) ((uint8_t)((uuid) & 0x00FF)) +#define u16_high_byte(uuid) ((uint8_t)(((uuid) & 0xFF00) >> 8)) + +/* AMS服务UUID,小端序 */ +uint8_t ams_uuid[BT_UUID_MAX_LEN] = { + 0xDC, 0xF8, 0x55, 0xAD, 0x02, 0xC5, 0xF4, 0x8E, 0x3A, 0x43, 0x36, 0x0F, 0x2B, 0x50, 0xD3, 0x89}; + +/* AMS服务特征UUID-Remote Command,小端序 */ +uint8_t rmt_cmd_uuid[BT_UUID_MAX_LEN] = { + 0xC2, 0x51, 0xCA, 0xF7, 0x56, 0x0E, 0xDF, 0xB8, 0x8A, 0x4A, 0xB1, 0x57, 0xD8, 0x81, 0x3C, 0x9B}; + +/* AMS服务特征UUID-Entity Update,小端序 */ +uint8_t entity_update_uuid[BT_UUID_MAX_LEN] = { + 0x02, 0xC1, 0x96, 0xBA, 0x92, 0xBB, 0x0C, 0x9A, 0x1F, 0x41, 0x8D, 0x80, 0xCE, 0xAB, 0x7C, 0x2F}; + +/* AMS服务特征UUID-Entity Attribute,小端序 */ +uint8_t entity_att_uuid[BT_UUID_MAX_LEN] = { + 0xD7, 0xD5, 0xBB, 0x70, 0xA8, 0xA3, 0xAB, 0xA6, 0xD8, 0x46, 0xAB, 0x23, 0x8C, 0xF3, 0xB2, 0xC6}; + +/* AMS客户端回调函数结构体 */ +ble_ams_client_callbacks_t g_ams_callbacks_t = {0}; + +/* 对端AMS服务信息 */ +struct list_stru g_ble_ams_service_list = {NULL, NULL}; + +/* 根据连接ID查询存储的对端AMS服务信息 */ +static ble_ams_service_t* ams_service_remote_by_conn(uint8_t client_id, uint16_t conn_id) +{ + ble_ams_service_t *node = (ble_ams_service_t *)g_ble_ams_service_list.head; + while (node != NULL) { + if ((node->client_id == client_id) && (node->conn_id == conn_id)) { + return node; + } + node = lnext(node); + } + + return NULL; +} + +/* AMS客户端发起服务建立 */ +errcode_t ble_ams_client_setup_service(uint8_t client_id, uint16_t conn_id) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote != NULL) { + bts_error("ams client remote service is already exist,client_id:%u, conn_id:%u.\r\n", + client_id, conn_id); + return ERRCODE_BT_DONE; + } + + bt_uuid_t service_uuid = {0}; + service_uuid.uuid_len = BT_UUID_MAX_LEN; + if (memcpy_s(service_uuid.uuid, BT_UUID_MAX_LEN, ams_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] uuid memcpy fail!\r\n"); + return ERRCODE_BT_FAIL; + } + return gattc_discovery_service(client_id, conn_id, &service_uuid); +} + +/* 发现服务回调函数 */ +void ble_ams_client_discovery_service_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_service_result_t *service) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote != NULL) { + bts_error("ams client remote service is already exist,client_id:%u, conn_id:%u.\r\n", + client_id, conn_id); + return; + } + remote = bt_sdk_list_node_create(sizeof(ble_ams_service_t)); + if (remote == NULL) { + bts_info("ams client remote node create fail.\r\n"); + return; + } + remote->client_id = client_id; + remote->conn_id = conn_id; + remote->start_handle = service->start_hdl; + remote->end_handle = service->end_hdl; + bt_sdk_list_add_tail(&g_ble_ams_service_list, remote); + + /* 发现特征 */ + gattc_discovery_character_param_t param = {0}; + param.service_handle = remote->start_handle; + errcode_t ret = gattc_discovery_character(client_id, conn_id, ¶m); + bts_info("ams client discovery character ret:%u.\r\n", ret); +} + +/* AMS服务特征匹配 */ +static ams_character_t ams_char_match(bt_uuid_t *uuid) +{ + if (uuid->uuid_len != BT_UUID_MAX_LEN) { + return AMS_CHAR_INVALID; + } + bt_uuid_t char_uuid = {0}; + char_uuid.uuid_len = BT_UUID_MAX_LEN; + if (memcpy_s(char_uuid.uuid, BT_UUID_MAX_LEN, rmt_cmd_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] remote cmd uuid memcpy fail!\r\n"); + return AMS_CHAR_INVALID; + } + if (memcmp(&char_uuid, uuid, sizeof(bt_uuid_t)) == 0) { + return AMS_CHAR_REMOTE_CMD; + } + if (memcpy_s(char_uuid.uuid, BT_UUID_MAX_LEN, entity_update_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] entity update uuid memcpy fail!\r\n"); + return AMS_CHAR_INVALID; + } + if (memcmp(&char_uuid, uuid, sizeof(bt_uuid_t)) == 0) { + return AMS_CHAR_ENTITY_UPDATE; + } + if (memcpy_s(char_uuid.uuid, BT_UUID_MAX_LEN, entity_att_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] entity att uuid memcpy fail!\r\n"); + return AMS_CHAR_INVALID; + } + if (memcmp(&char_uuid, uuid, sizeof(bt_uuid_t)) == 0) { + return AMS_CHAR_ENTITY_ATTR; + } + return AMS_CHAR_INVALID; +} + +/* 发现特征回调函数 */ +void ble_ams_client_discovery_character_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_character_result_t *character) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + if ((character->declare_handle < remote->start_handle) || + (character->declare_handle > remote->end_handle)) { + bts_error("ams client remote service did not have this character_handle:%u conn_id:%u\n", + character->declare_handle, conn_id); + return; + } + + switch (ams_char_match(&(character->uuid))) { + case AMS_CHAR_REMOTE_CMD: { + remote->remote_cmd.declare_handle = character->declare_handle; + remote->remote_cmd.value_handle = character->value_handle; + remote->remote_cmd.properties = character->properties; + + /* 发现描述符 */ + gattc_discovery_descriptor(client_id, conn_id, character->declare_handle); + break; + } + + case AMS_CHAR_ENTITY_UPDATE: { + remote->entity_update.declare_handle = character->declare_handle; + remote->entity_update.value_handle = character->value_handle; + remote->entity_update.properties = character->properties; + + /* 发现描述符 */ + gattc_discovery_descriptor(client_id, conn_id, character->declare_handle); + break; + } + + case AMS_CHAR_ENTITY_ATTR: { + remote->entity_attr.declare_handle = character->declare_handle; + remote->entity_attr.value_handle = character->value_handle; + remote->entity_attr.properties = character->properties; + break; + } + + default: + bts_error("[btsrv][INFO] invalid character!\r\n"); + break; + } +} + +/* 发现描述符回调函数 */ +void ble_ams_client_discovery_descriptor_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_descriptor_result_t *descriptor) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + if (descriptor->descriptor_hdl < remote->start_handle || + descriptor->descriptor_hdl > remote->end_handle) { + bts_error("ams client remote service did not have this descriptor_handle:%u conn_id:%u\n", + descriptor->descriptor_hdl, conn_id); + return; + } + + /* 客户端特征配置描述符 */ + bt_uuid_t ccc_uuid = {0}; + bts_data_to_uuid_len2(BLE_CLIENT_CHARACTERISTIC_CONFIGURATION_UUID, &ccc_uuid); + if (!bts_uuid_is_equal(&ccc_uuid, &(descriptor->uuid))) { + return; + } + + uint16_t cmd_ccc_max_handle = remote->end_handle; + uint16_t entity_ccc_max_handle = remote->end_handle; + + if ((remote->entity_update.value_handle != 0) && + (remote->remote_cmd.value_handle != 0) && + (remote->remote_cmd.value_handle < remote->entity_update.value_handle)) { + cmd_ccc_max_handle = remote->entity_update.value_handle - 1; + } else if ((remote->remote_cmd.value_handle != 0) && + (remote->entity_update.value_handle != 0) && + (remote->remote_cmd.value_handle > remote->entity_update.value_handle)) { + entity_ccc_max_handle = remote->remote_cmd.value_handle - 1; + } + + if ((remote->remote_cmd.value_handle != 0) && + (descriptor->descriptor_hdl > remote->remote_cmd.value_handle) && + (descriptor->descriptor_hdl <= cmd_ccc_max_handle)) { + remote->remote_cmd_ccc_handle = descriptor->descriptor_hdl; + } else if ((remote->entity_update.value_handle != 0) && + (descriptor->descriptor_hdl > remote->entity_update.value_handle) && + (descriptor->descriptor_hdl <= entity_ccc_max_handle)) { + remote->entity_update_ccc_handle = descriptor->descriptor_hdl; + } + + if ((remote->remote_cmd_ccc_handle != 0) && + (remote->entity_update_ccc_handle != 0)) { + if (g_ams_callbacks_t.setup_cb != NULL) { + g_ams_callbacks_t.setup_cb(client_id, conn_id, ERRCODE_BT_SUCCESS); + } + } +} + +/* 处理远端命令上报信息 */ +static void remote_cmd_rpt_handle(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data) +{ + errcode_t status = ERRCODE_BT_SUCCESS; + ble_ams_remote_cmd_rpt_t *rpt_data = bt_os_new(sizeof(ble_ams_remote_cmd_rpt_t) + data->data_len); + rpt_data->cmd_num = data->data_len; + if (memcpy_s(rpt_data->remote_cmd, rpt_data->cmd_num, data->data, rpt_data->cmd_num) != EOK) { + bts_error("[btsrv][ERROR] remote cmd rpt memcpy fail!\r\n"); + status = ERRCODE_BT_MEMCPY_FAIL; + } + + if (g_ams_callbacks_t.remote_cmd_cb != NULL) { + g_ams_callbacks_t.remote_cmd_cb(client_id, conn_id, rpt_data, status); + } + bt_os_free(rpt_data); +} + +/* 处理实体更新上报信息 */ +static void entity_update_rpt_handle(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data) +{ + errcode_t status = ERRCODE_BT_SUCCESS; + uint16_t value_len = data->data_len - AMS_ENTITY_UPDATE_NOTIFY_VALUE_OFFSET; + ble_ams_entity_update_rpt_t *rpt_data = bt_os_new( + sizeof(ble_ams_entity_update_rpt_t) + value_len + AMS_STRING_SUFFIX_ZERO_BYTE); + rpt_data->entity_id = *(data->data); + rpt_data->att_id = *(data->data + sizeof(uint8_t)); + rpt_data->entity_update_flags = *(data->data + AMS_ENTITY_UPDATE_NOTIFY_FLAGS_OFFSET); + rpt_data->value_length = value_len + AMS_STRING_SUFFIX_ZERO_BYTE; + if (memcpy_s(rpt_data->value, rpt_data->value_length, + (data->data + AMS_ENTITY_UPDATE_NOTIFY_VALUE_OFFSET), value_len) != EOK) { + bts_error("[btsrv][ERROR] entity update rpt memcpy fail!\r\n"); + status = ERRCODE_BT_MEMCPY_FAIL; + } + rpt_data->value[rpt_data->value_length - 1] = 0; /* 字符串拼接末尾0 */ + + if (g_ams_callbacks_t.entity_update_cb != NULL) { + g_ams_callbacks_t.entity_update_cb(client_id, conn_id, rpt_data, status); + } + bt_os_free(rpt_data); +} + +/* 特征通知回调函数 */ +void ble_ams_client_notify_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + /* Remote Command */ + /* 数据格式:RemoteCommandID 1(1B)|RemoteCommandID 2(1B)|... */ + if (data->handle == remote->remote_cmd.value_handle) { + remote_cmd_rpt_handle(client_id, conn_id, data); + + /* Entity Update */ + /* 数据格式:EntityID(1B)|AttributeID(1B)|EntityUpdateFlags(1B)|Value(动态) */ + } else if (data->handle == remote->entity_update.value_handle) { + entity_update_rpt_handle(client_id, conn_id, data); + } +} + +/* AMS客户端订阅结果处理函数 */ +static void ble_ams_client_subscribe_result(uint8_t client_id, uint16_t conn_id, + ams_client_subscribe_type_t type, gatt_status_t status) +{ + if (g_ams_callbacks_t.subscribe_cb != NULL) { + g_ams_callbacks_t.subscribe_cb(client_id, conn_id, type, status); + } +} + +/* 注册感兴趣实体属性响应结果处理 */ +static void ble_ams_client_write_character_rsp(uint8_t client_id, uint16_t conn_id, + ams_client_write_character_type_t type, + gatt_status_t status) +{ + if (g_ams_callbacks_t.write_rsp_cb != NULL) { + g_ams_callbacks_t.write_rsp_cb(client_id, conn_id, type, status); + } +} + +/* 写请求响应回调函数 */ +void ble_ams_client_write_cbk(uint8_t client_id, uint16_t conn_id, uint16_t handle, gatt_status_t status) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + if (handle == (remote->remote_cmd_ccc_handle)) { + ble_ams_client_subscribe_result(client_id, conn_id, AMS_CLIENT_SUBSCRIBE_REMOTE_CMD, status); + } else if (handle == (remote->entity_update_ccc_handle)) { + ble_ams_client_subscribe_result(client_id, conn_id, AMS_CLIENT_SUBSCRIBE_ENTITY_UPDATE, status); + } else if (handle == (remote->entity_update.value_handle)) { + ble_ams_client_write_character_rsp(client_id, conn_id, AMS_CLIENT_WRITE_ENTITY_UPDATE, status); + } else if (handle == (remote->remote_cmd.value_handle)) { + ble_ams_client_write_character_rsp(client_id, conn_id, AMS_CLIENT_WRITE_REMOTE_CMD, status); + } else if (handle == (remote->entity_attr.value_handle)) { + ble_ams_client_write_character_rsp(client_id, conn_id, AMS_CLIENT_WRITE_ENTITY_ATTRIBUTE, status); + } +} + +/* 读请求响应回调函数 */ +void ble_ams_client_read_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *read_result, + gatt_status_t status) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + if (read_result->handle != remote->entity_attr.value_handle) { + return; + } + + ble_ams_full_attr_value_t *full_value = bt_os_new(sizeof(ble_ams_full_attr_value_t) + read_result->data_len + 1); + full_value->value_len = read_result->data_len + 1; + if (read_result->data_len != 0) { + if (memcpy_s(full_value->value, full_value->value_len, read_result->data, read_result->data_len) != EOK) { + bts_error("[btsrv][ERROR] read result memcpy fail!\r\n"); + bt_os_free(full_value); + return; + } + } + *(full_value->value + full_value->value_len - 1) = 0; /* 字符串末尾拼接0 */ + + if (g_ams_callbacks_t.read_full_attr_result_cb != NULL) { + g_ams_callbacks_t.read_full_attr_result_cb(client_id, conn_id, full_value, status); + } + bt_os_free(full_value); +} + +/* 订阅远端命令特征通知 */ +errcode_t ble_ams_client_subscribe_remote_cmd(uint8_t client_id, uint16_t conn_id, + ams_client_notify_enable_t enable_flag) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ams client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->remote_cmd_ccc_handle == 0) { + bts_error("ams client remote service did not discovery notify ccc, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + uint16_t ccc_value = BLE_AMS_CLIENT_CHARACTERISTIC_CONFIGURATION_DEFAULT; + if (enable_flag == AMS_CLIENT_NOTIFY_ENABLE) { + ccc_value = BLE_AMS_CLIENT_CHARACTERISTIC_CONFIGURATION_NOTIFICATION; + } + uint8_t notify_ccc_val[] = { + u16_low_byte(ccc_value), + u16_high_byte(ccc_value) + }; + gattc_handle_value_t value = {0}; + value.data_len = (uint16_t)sizeof(notify_ccc_val); + value.data = notify_ccc_val; + value.handle = remote->remote_cmd_ccc_handle; + return gattc_write_req(client_id, conn_id, &value); +} + +/* 订阅实体更新特征通知 */ +errcode_t ble_ams_client_subscribe_entity_update(uint8_t client_id, uint16_t conn_id, + ams_client_notify_enable_t enable_flag) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ams client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->entity_update_ccc_handle == 0) { + bts_error("ams client remote service did not discovery notify ccc, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + uint16_t ccc_value = BLE_AMS_CLIENT_CHARACTERISTIC_CONFIGURATION_DEFAULT; + if (enable_flag == AMS_CLIENT_NOTIFY_ENABLE) { + ccc_value = BLE_AMS_CLIENT_CHARACTERISTIC_CONFIGURATION_NOTIFICATION; + } + uint8_t notify_ccc_val[] = { + u16_low_byte(ccc_value), + u16_high_byte(ccc_value) + }; + gattc_handle_value_t value = {0}; + value.data_len = (uint16_t)sizeof(notify_ccc_val); + value.data = notify_ccc_val; + value.handle = remote->entity_update_ccc_handle; + return gattc_write_req(client_id, conn_id, &value); +} + +/* 发送远端命令 */ +errcode_t ble_ams_client_send_remote_cmd(uint8_t client_id, uint16_t conn_id, + ams_remote_cmd_id_t cmd_id) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ams client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->remote_cmd.value_handle == 0) { + bts_error("ams client did not discovery character, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + uint8_t data = (uint8_t)cmd_id; + gattc_handle_value_t value = {0}; + value.data_len = (uint16_t)sizeof(uint8_t); + value.data = &data; + value.handle = remote->remote_cmd.value_handle; + return gattc_write_req(client_id, conn_id, &value); +} + +/* 注册感兴趣的实体属性 */ +errcode_t ble_ams_client_register_interested_entity_attribute(uint8_t client_id, uint16_t conn_id, + ble_ams_interested_entity_attr_req_t *entity_attr_req) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ams client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->entity_update.value_handle == 0) { + bts_error("ams client did not discovery character, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (entity_attr_req->att_num == 0) { + bts_error("ams client attr req param error, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_PARAM_ERR; + } + + uint16_t data_length = sizeof(uint8_t) + (entity_attr_req->att_num) * sizeof(uint8_t); + uint8_t *data = bt_os_new(data_length); + uint8_t *pt_data = data; + *pt_data = entity_attr_req->entity_id; + pt_data = pt_data + 1; + for (int i = 0; i < entity_attr_req->att_num; i++) { + *(pt_data + i) = entity_attr_req->att_id[i]; + } + + gattc_handle_value_t value = {0}; + value.data_len = data_length; + value.data = data; + value.handle = remote->entity_update.value_handle; + errcode_t result = gattc_write_req(client_id, conn_id, &value); + bt_os_free(data); + return result; +} + +/* 获取完整的实体属性 */ +errcode_t ble_ams_client_retrieve_full_entity_attribute(uint8_t client_id, uint16_t conn_id, + ble_ams_full_entity_attr_cmd_t *full_attr_req) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ams client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->entity_attr.value_handle == 0) { + bts_error("ams client did not discovery character, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + gattc_handle_value_t value = {0}; + value.data_len = (uint16_t)sizeof(ble_ams_full_entity_attr_cmd_t); + value.data = full_attr_req; + value.handle = remote->entity_attr.value_handle; + return gattc_write_req(client_id, conn_id, &value); +} + +/* 读取完整的实体属性 */ +errcode_t ble_ams_client_read_full_entity_attribute(uint8_t client_id, uint16_t conn_id) +{ + ble_ams_service_t *remote = ams_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ams client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->entity_attr.value_handle == 0) { + bts_error("ams client did not discovery character, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + return gattc_read_req_by_handle(client_id, conn_id, remote->entity_attr.value_handle); +} + +/* 注册AMS客户端回调函数 */ +errcode_t ble_ams_client_register_callbacks(ble_ams_client_callbacks_t *func) +{ + if (memcpy_s(&g_ams_callbacks_t, sizeof(g_ams_callbacks_t), func, sizeof(ble_ams_client_callbacks_t)) != EOK) { + return ERRCODE_BT_MEMCPY_FAIL; + } + return ERRCODE_BT_SUCCESS; +} + +/* AMS服务判断 */ +bool is_ble_ams_service(bt_uuid_t *uuid) +{ + bt_uuid_t ams_service_uuid = {0}; + ams_service_uuid.uuid_len = BT_UUID_MAX_LEN; + if (memcpy_s(ams_service_uuid.uuid, BT_UUID_MAX_LEN, ams_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[BLE]service uuid memcpy error! \n"); + return false; + } + if (ams_service_uuid.uuid_len != uuid->uuid_len) { + return false; + } + + return (memcmp(uuid, &ams_service_uuid, sizeof(bt_uuid_t)) == 0 ? true : false); +} + +/* 根据连接ID清理存储的对端AMS服务信息 */ +void ble_ams_client_clear_remote_by_conn(uint8_t client_id, uint16_t conn_id) +{ + ble_ams_service_t *node = NULL; + node = ams_service_remote_by_conn(client_id, conn_id); + if (node != NULL) { + bt_sdk_list_remove(&g_ble_ams_service_list, node); + sdk_list_node_free(node); + } +} + +/* 清理所有存储的对端AMS服务信息 */ +void ble_ams_client_clear_remote_all(void) +{ + ble_ams_service_t *node = (ble_ams_service_t *)g_ble_ams_service_list.head; + ble_ams_service_t *cur_node = NULL; + while (node != NULL) { + cur_node = node; + node = lnext(node); + bt_sdk_list_remove(&g_ble_ams_service_list, cur_node); + sdk_list_node_free(cur_node); + cur_node = NULL; + } +} diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_ancs_client.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_ancs_client.c new file mode 100644 index 000000000..244b8ad62 --- /dev/null +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_ancs_client.c @@ -0,0 +1,896 @@ +/* + * Copyright (c) @CompanyNameMagicTag 2024. All rights reserved. + * Description: BLE Apple Notification Center Service Client module. + */ + +#include +#include "sdk_list.h" +#include "datatype.h" +#include "errcode.h" +#include "btsrv_log.h" +#include "bts_le_gap.h" +#include "sdk_general.h" +#include "bts_uuid.h" +#include "ble_gatts_callbacks.h" +#include "ble_ancs_client.h" + +#define BLE_CLIENT_CHARACTERISTIC_CONFIGURATION_UUID 0x2902 +#define ANCS_NOTIFY_ATT_ID_OFFSET 5 +#define ANCS_NOTIFY_ATT_MAX_LENGTH_BYTE 2 +#define ANCS_NOTIFY_ACTION_ID_OFFSET 5 +#define ANCS_NOTIFY_ATT_VALUE_OFFSET 3 +#define BLE_ATT_HEADER_LEN 3 +#define BLE_ANCS_DATA_MAX_LEN 512 +#define ANCS_NOTIFY_UUID_BYTE_LENGTH 4 +#define ANCS_NOTIFY_SOURCE_LENGTH 8 +#define ANCS_NOTIFY_ATT_DATA_HEADER_LENGTH 8 + +#define u16_low_byte(data) ((uint8_t)((data) & 0x00FF)) +#define u16_high_byte(data) ((uint8_t)(((data) & 0xFF00) >> 8)) +#define little_u8_2_u16(p) ((((uint16_t)(*((p) + 1))) << 8) | ((uint16_t)(*(p)))) +#define u32_2_little_first_byte(uuid) ((uint8_t)((uuid) & 0x000000FF)) +#define u32_2_little_second_byte(uuid) ((uint8_t)(((uuid) & 0x0000FF00) >> 8)) +#define u32_2_little_three_byte(uuid) ((uint8_t)(((uuid) & 0x00FF0000) >> 16)) +#define u32_2_little_four_byte(uuid) ((uint8_t)(((uuid) & 0xFF000000) >> 24)) +#define little_byte_2_u32(data) (((uint32_t)(*(data))) | \ + ((uint32_t)(((uint32_t)*((data) + BT_INDEX_1)) << 8)) | \ + ((uint32_t)(((uint32_t)*((data) + BT_INDEX_2)) << 16)) | \ + ((uint32_t)(((uint32_t)*((data) + BT_INDEX_3)) << 24))) + +/* ANCS服务UUID,小端序 */ +uint8_t ancs_uuid[BT_UUID_MAX_LEN] = { + 0xD0, 0x00, 0x2D, 0x12, 0x1E, 0x4B, 0x0F, 0xA4, 0x99, 0x4E, 0xCE, 0xB5, 0x31, 0xF4, 0x05, 0x79}; + +/* ANCS服务特征UUID-Notification Source,小端序 */ +uint8_t notify_src_uuid[BT_UUID_MAX_LEN] = { + 0xBD, 0x1D, 0xA2, 0x99, 0xE6, 0x25, 0x58, 0x8C, 0xD9, 0x42, 0x01, 0x63, 0x0D, 0x12, 0xBF, 0x9F}; + +/* ANCS服务特征UUID-Control Point,小端序 */ +uint8_t ctl_point_uuid[BT_UUID_MAX_LEN] = { + 0xD9, 0xD9, 0xAA, 0xFD, 0xBD, 0x9B, 0x21, 0x98, 0xA8, 0x49, 0xE1, 0x45, 0xF3, 0xD8, 0xD1, 0x69}; + +/* ANCS服务特征UUID-Data Source,小端序 */ +uint8_t data_src_uuid[BT_UUID_MAX_LEN] = { + 0xFB, 0x7B, 0x7C, 0xCE, 0x6A, 0xB3, 0x44, 0xBE, 0xB5, 0x4B, 0xD6, 0x24, 0xE9, 0xC6, 0xEA, 0x22}; + +ble_ancs_client_callbacks_t g_ancs_callbacks_t = {0}; +struct list_stru g_ble_ancs_service_list = {NULL, NULL}; /* ble_ancs_service_t */ + +/* 根据连接ID查询ANCS服务信息 */ +static ble_ancs_service_t* ancs_service_remote_by_conn(uint8_t client_id, uint16_t conn_id) +{ + ble_ancs_service_t *node = (ble_ancs_service_t *)g_ble_ancs_service_list.head; + while (node != NULL) { + if ((node->client_id == client_id) && (node->conn_id == conn_id)) { + return node; + } + node = lnext(node); + } + + return NULL; +} + +/* ANCS服务特征匹配 */ +static ancs_character_t ancs_char_match(bt_uuid_t *uuid) +{ + if (uuid->uuid_len != BT_UUID_MAX_LEN) { + return ANCS_CHAR_INVALID; + } + bt_uuid_t char_uuid = {0}; + char_uuid.uuid_len = BT_UUID_MAX_LEN; + if (memcpy_s(char_uuid.uuid, BT_UUID_MAX_LEN, notify_src_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] notify src uuid memcpy fail!\r\n"); + return ANCS_CHAR_INVALID; + } + if (memcmp(&char_uuid, uuid, sizeof(bt_uuid_t)) == 0) { + return ANCS_CHAR_NOTIFY_SRC; + } + if (memcpy_s(char_uuid.uuid, BT_UUID_MAX_LEN, ctl_point_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] ctl point uuid memcpy fail!\r\n"); + return ANCS_CHAR_INVALID; + } + if (memcmp(&char_uuid, uuid, sizeof(bt_uuid_t)) == 0) { + return ANCS_CHAR_CTRL_POINT; + } + if (memcpy_s(char_uuid.uuid, BT_UUID_MAX_LEN, data_src_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] data src uuid memcpy fail!\r\n"); + return ANCS_CHAR_INVALID; + } + if (memcmp(&char_uuid, uuid, sizeof(bt_uuid_t)) == 0) { + return ANCS_CHAR_DATA_SRC; + } + return ANCS_CHAR_INVALID; +} + +/* ANCS客户端发起服务建立 */ +errcode_t ble_ancs_client_setup_service(uint8_t client_id, uint16_t conn_id) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote != NULL) { + bts_error("ancs client remote service is already exist,client_id:%u, conn_id:%u.\r\n", + client_id, conn_id); + return ERRCODE_BT_DONE; + } + bt_uuid_t service_uuid = {0}; + service_uuid.uuid_len = BT_UUID_MAX_LEN; + if (memcpy_s(service_uuid.uuid, BT_UUID_MAX_LEN, ancs_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[btsrv][ERROR] uuid memcpy fail!\r\n"); + return ERRCODE_BT_FAIL; + } + return gattc_discovery_service(client_id, conn_id, &service_uuid); +} + +/* ANCS客户端发现服务回调处理函数 */ +void ble_ancs_client_discovery_service_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_service_result_t *service) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote != NULL) { + bts_error("ancs client remote service is already exist,client_id:%u, conn_id:%u.\r\n", + client_id, conn_id); + return; + } + remote = bt_sdk_list_node_create(sizeof(ble_ancs_service_t)); + if (remote == NULL) { + bts_info("ancs client remote node create fail.\r\n"); + return; + } + remote->client_id = client_id; + remote->conn_id = conn_id; + remote->start_handle = service->start_hdl; + remote->end_handle = service->end_hdl; + bt_sdk_list_add_tail(&g_ble_ancs_service_list, remote); + + /* 发现特征 */ + gattc_discovery_character_param_t param = {0}; + param.service_handle = remote->start_handle; + errcode_t ret = gattc_discovery_character(client_id, conn_id, ¶m); + bts_info("ancs client discovery character ret:%u.\r\n", ret); +} + +/* ANCS客户端发现特征回调处理函数 */ +void ble_ancs_client_discovery_character_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_character_result_t *character) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + if ((character->declare_handle < remote->start_handle) || + (character->declare_handle > remote->end_handle)) { + bts_error("ancs client remote service did not have this character_handle:%u conn_id:%u\n", + character->declare_handle, conn_id); + return; + } + + switch (ancs_char_match(&(character->uuid))) { + case ANCS_CHAR_NOTIFY_SRC: { + remote->notify_src.declare_handle = character->declare_handle; + remote->notify_src.value_handle = character->value_handle; + remote->notify_src.properties = character->properties; + + /* 发现描述符 */ + gattc_discovery_descriptor(client_id, conn_id, character->declare_handle); + break; + } + + case ANCS_CHAR_DATA_SRC: { + remote->data_src.declare_handle = character->declare_handle; + remote->data_src.value_handle = character->value_handle; + remote->data_src.properties = character->properties; + + /* 发现描述符 */ + gattc_discovery_descriptor(client_id, conn_id, character->declare_handle); + break; + } + + case ANCS_CHAR_CTRL_POINT: { + remote->ctl_point.declare_handle = character->declare_handle; + remote->ctl_point.value_handle = character->value_handle; + remote->ctl_point.properties = character->properties; + break; + } + + default: + bts_error("[btsrv][INFO] invalid character!\r\n"); + break; + } +} + +/* ANCS客户端发现描述符回调处理函数 */ +void ble_ancs_client_discovery_descriptor_cbk(uint8_t client_id, uint16_t conn_id, + gattc_discovery_descriptor_result_t *descriptor) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + if (descriptor->descriptor_hdl < remote->start_handle || + descriptor->descriptor_hdl > remote->end_handle) { + bts_error("ancs client remote service did not have this descriptor_handle:%u conn_id:%u\n", + descriptor->descriptor_hdl, conn_id); + return; + } + + /* 客户端特征配置描述符 */ + bt_uuid_t ccc_uuid = {0}; + bts_data_to_uuid_len2(BLE_CLIENT_CHARACTERISTIC_CONFIGURATION_UUID, &ccc_uuid); + if (!bts_uuid_is_equal(&ccc_uuid, &(descriptor->uuid))) { + return; + } + + uint16_t notify_ccc_max_handle = remote->end_handle; + uint16_t data_ccc_max_handle = remote->end_handle; + if ((remote->data_src.value_handle != 0) && + (remote->notify_src.value_handle != 0) && + (remote->notify_src.value_handle < remote->data_src.value_handle)) { + notify_ccc_max_handle = remote->data_src.value_handle - 1; + } else if ((remote->notify_src.value_handle != 0) && + (remote->data_src.value_handle != 0) && + (remote->notify_src.value_handle > remote->data_src.value_handle)) { + data_ccc_max_handle = remote->notify_src.value_handle - 1; + } + + if ((remote->notify_src.value_handle != 0) && + (descriptor->descriptor_hdl > remote->notify_src.value_handle) && + (descriptor->descriptor_hdl <= notify_ccc_max_handle)) { + remote->notify_src_ccc_handle = descriptor->descriptor_hdl; + } else if ((remote->data_src.value_handle != 0) && + (descriptor->descriptor_hdl > remote->data_src.value_handle) && + (descriptor->descriptor_hdl <= data_ccc_max_handle)) { + remote->data_src_ccc_handle = descriptor->descriptor_hdl; + } + + if ((remote->notify_src_ccc_handle != 0) && + (remote->data_src_ccc_handle != 0)) { + if (g_ancs_callbacks_t.setup_cb != NULL) { + g_ancs_callbacks_t.setup_cb(client_id, conn_id, ERRCODE_BT_SUCCESS); + } + } +} + +/* ANCS客户端订阅通知源特征通知 */ +errcode_t ble_ancs_client_subscribe_notification_source(uint8_t client_id, uint16_t conn_id, + ancs_client_notify_enable_t enable_flag) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ancs client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->notify_src_ccc_handle == 0) { + bts_error("ancs client remote service did not discovery notify ccc, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + uint16_t ccc_value = BLE_ANCS_CLIENT_CHARACTERISTIC_CONFIGURATION_DEFAULT; + if (enable_flag == ANCS_CLIENT_NOTIFY_ENABLE) { + ccc_value = BLE_ANCS_CLIENT_CHARACTERISTIC_CONFIGURATION_NOTIFICATION; + } + uint8_t notify_ccc_val[] = { + u16_low_byte(ccc_value), + u16_high_byte(ccc_value) + }; + gattc_handle_value_t value = {0}; + value.data_len = (uint16_t)sizeof(notify_ccc_val); + value.data = notify_ccc_val; + value.handle = remote->notify_src_ccc_handle; + return gattc_write_req(client_id, conn_id, &value); +} + +/* ANCS客户端订阅数据源特征通知 */ +errcode_t ble_ancs_client_subscribe_data_source(uint8_t client_id, uint16_t conn_id, + ancs_client_notify_enable_t enable_flag) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ancs client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->data_src_ccc_handle == 0) { + bts_error("ancs client remote service did not discovery data ccc, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + uint16_t ccc_value = BLE_ANCS_CLIENT_CHARACTERISTIC_CONFIGURATION_DEFAULT; + if (enable_flag == ANCS_CLIENT_NOTIFY_ENABLE) { + ccc_value = BLE_ANCS_CLIENT_CHARACTERISTIC_CONFIGURATION_NOTIFICATION; + } + uint8_t notify_ccc_val[] = { + u16_low_byte(ccc_value), + u16_high_byte(ccc_value) + }; + gattc_handle_value_t value = {0}; + value.data_len = (uint16_t)sizeof(notify_ccc_val); + value.data = notify_ccc_val; + value.handle = remote->data_src_ccc_handle; + return gattc_write_req(client_id, conn_id, &value); +} + +/* u32转小端序字节流 */ +static uint32_t convert_little_2_u32(uint8_t *data) +{ + return little_byte_2_u32(data); +} + +/* 释放【通知属性响应数据】申请的内存 */ +static void notify_att_rsp_free(ble_ancs_notification_attr_rsp_t *notify_att_rsp) +{ + ble_ancs_attr_rsp_t *node = notify_att_rsp->attr_rsp_lst.head; + ble_ancs_attr_rsp_t *cur_node = NULL; + /* 校验失败,清空队列 */ + while (node != NULL) { + cur_node = node; + node = lnext(node); + bt_sdk_list_remove(¬ify_att_rsp->attr_rsp_lst, cur_node); /* 出队 */ + bt_os_free(cur_node->att); + sdk_list_node_free(cur_node); + cur_node = NULL; + } + bt_os_free(notify_att_rsp); + return; +} + +/* 组装属性响应数据,兼容分包场景,只解析第一包 */ +static uint16_t ancs_att_rsp_package(ble_ancs_attr_rsp_t *attr_rsp, + uint8_t *data, uint16_t total_length, uint16_t offset_byte) +{ + if ((total_length - offset_byte) <= ANCS_NOTIFY_ATT_VALUE_OFFSET) { /* 最后一个属性只包含属性id或者属性长度 */ + attr_rsp->att_id = *data; + attr_rsp->att_length = 0; + attr_rsp->att = 0; + return 0; + } + attr_rsp->att_id = *data; + uint16_t data_length = little_u8_2_u16(data + 1); + attr_rsp->att_length = data_length + 1; /* 字符串以0结尾 */ + if (data_length != 0) { + uint8_t *att_data = bt_os_new(attr_rsp->att_length); + if (memset_s(att_data, attr_rsp->att_length, 0, attr_rsp->att_length) != EOK) { + bt_os_free(att_data); + attr_rsp->att_length = 0; + attr_rsp->att = 0; + return data_length; + } + uint16_t copy_length = data_length; + if ((total_length - offset_byte) < (data_length + ANCS_NOTIFY_ATT_VALUE_OFFSET)) { /* 最后一个属性 */ + copy_length = total_length - offset_byte - ANCS_NOTIFY_ATT_VALUE_OFFSET; + } + if (memcpy_s(att_data, attr_rsp->att_length, data + ANCS_NOTIFY_ATT_VALUE_OFFSET, copy_length) != EOK) { + bts_error("[btsrv][ERROR] addr memcpy fail!\r\n"); + bt_os_free(att_data); + attr_rsp->att_length = 0; + attr_rsp->att = 0; + return data_length; + } + att_data[attr_rsp->att_length - 1] = 0; /* 字符串以0结尾 */ + attr_rsp->att = att_data; + } else { + attr_rsp->att_length = 0; + attr_rsp->att = 0; + } + return data_length; +} + +/* 解析属性响应数据 */ +static uint16_t parse_att_rsp(uint8_t *data, uint16_t data_length, struct list_stru *attr_rsp_lst) +{ + uint16_t offset_byte = 0; + uint16_t att_num = 0; + uint16_t att_data_len = 0; + while (offset_byte < data_length) { + ble_ancs_attr_rsp_t *attr_rsp = (ble_ancs_attr_rsp_t *)bt_sdk_list_node_create(sizeof(ble_ancs_attr_rsp_t)); + if (attr_rsp != NULL) { + att_data_len = ancs_att_rsp_package(attr_rsp, data, data_length, offset_byte); + att_num += 1; + bt_sdk_list_add_tail(attr_rsp_lst, attr_rsp); + offset_byte = offset_byte + 1 + sizeof(uint16_t) + att_data_len; + data = data + 1 + sizeof(uint16_t) + att_data_len; + } + } + return att_num; +} + +/* 解析通知属性响应数据,响应数据格式:cmd_id(1B)|notify_uid(4B)|att_id1(1B)|att_id1_length(2B)|att_id1_data(动态)|... */ +static void notify_att_data_parse(uint8_t client_id, uint16_t conn_id, uint8_t *data, uint16_t data_length) +{ + ble_ancs_notification_attr_rsp_t *notify_att_rsp = NULL; + errcode_t result = ERRCODE_BT_SUCCESS; + if (data_length <= (ANCS_NOTIFY_ATT_DATA_HEADER_LENGTH - 1)) { + result = ERRCODE_BT_PARAM_ERR; + } else { + notify_att_rsp = bt_os_new(sizeof(ble_ancs_notification_attr_rsp_t)); + notify_att_rsp->notification_uid = convert_little_2_u32(data); + notify_att_rsp->att_num = 0; + notify_att_rsp->attr_rsp_lst.head = NULL; + notify_att_rsp->attr_rsp_lst.tail = NULL; + data = data + ANCS_NOTIFY_UUID_BYTE_LENGTH; + notify_att_rsp->att_num = parse_att_rsp(data, + data_length - ANCS_NOTIFY_UUID_BYTE_LENGTH, ¬ify_att_rsp->attr_rsp_lst); + } + + if (g_ancs_callbacks_t.notify_attr_cb != NULL) { + g_ancs_callbacks_t.notify_attr_cb(client_id, conn_id, notify_att_rsp, result); + } + + if (notify_att_rsp != NULL) { + notify_att_rsp_free(notify_att_rsp); + } +} + +/* 释放【应用属性响应结果】申请的内存 */ +static void app_att_rsp_free(ble_ancs_app_attr_rsp_t *app_att_rsp) +{ + ble_ancs_attr_rsp_t *node = app_att_rsp->attr_rsp_lst.head; + ble_ancs_attr_rsp_t *cur_node = NULL; + while (node != NULL) { + cur_node = node; + node = lnext(node); + bt_sdk_list_remove(&app_att_rsp->attr_rsp_lst, cur_node); /* 出队 */ + bt_os_free(cur_node->att); + sdk_list_node_free(cur_node); + cur_node = NULL; + } + if (app_att_rsp->app_id.id != NULL) { + bt_os_free(app_att_rsp->app_id.id); + } + bt_os_free(app_att_rsp); + return; +} + +/* 解析应用编号 */ +static void app_id_parse(ble_ancs_app_attr_rsp_t *app_att_rsp, uint8_t *data, uint16_t data_length) +{ + uint16_t app_id_len = 0; + for (int i = 0; i < data_length - 1; i++) { + app_id_len = app_id_len + 1; + if (*(data + i) == 0) { + break; + } + } + if (app_id_len != 0) { + app_att_rsp->app_id.len = app_id_len; + uint8_t *id = bt_os_new(app_id_len); + if (id != NULL) { + if (memcpy_s(id, app_id_len, data, app_id_len) != EOK) { + bt_os_free(id); + app_att_rsp->app_id.id = NULL; + return; + } + app_att_rsp->app_id.id = id; + return; + } + } + app_att_rsp->app_id.len = 0; + app_att_rsp->app_id.id = NULL; +} + +/* 解析应用属性响应结果,响应格式:cmd_id(1B)|app_id(动态长度,字符串字节流,以NULL结尾)|att_id1(1B)|att_id1_length(2B)|att_id1_data(动态)|... */ +static void app_att_data_parse(uint8_t client_id, uint16_t conn_id, uint8_t *data, uint16_t data_length) +{ + ble_ancs_app_attr_rsp_t *app_att_rsp = NULL; + errcode_t result = ERRCODE_BT_SUCCESS; + if (data_length <= 0) { + result = ERRCODE_BT_PARAM_ERR; + } else { + app_att_rsp = bt_os_new(sizeof(ble_ancs_app_attr_rsp_t)); + app_id_parse(app_att_rsp, data, data_length); + if ((app_att_rsp->app_id.len == 0) || (app_att_rsp->app_id.id == NULL)) { + result = ERRCODE_BT_PARAM_ERR; + } else { + app_att_rsp->att_num = 0; + app_att_rsp->attr_rsp_lst.head = NULL; + app_att_rsp->attr_rsp_lst.tail = NULL; + uint16_t app_id_len = app_att_rsp->app_id.len; + data = data + app_id_len; + app_att_rsp->att_num = parse_att_rsp(data, data_length - app_id_len, &app_att_rsp->attr_rsp_lst); + } + } + + if (g_ancs_callbacks_t.app_attr_cb != NULL) { + g_ancs_callbacks_t.app_attr_cb(client_id, conn_id, app_att_rsp, result); + } + + if (app_att_rsp != NULL) { + app_att_rsp_free(app_att_rsp); + } +} + +/* ANCS客户端通知消息处理函数,消息格式:event_id(1B)|event_flags(1B)|category_id(1B)|category_count(1B)|notify_uuid(4B) */ +static void notify_src_handle(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data) +{ + errcode_t result = ERRCODE_BT_SUCCESS; + ble_ancs_notification_src_t *notify_src_data = NULL; + if (data->data_len != ANCS_NOTIFY_SOURCE_LENGTH) { + result = ERRCODE_BT_PARAM_ERR; + } else { + uint8_t *pt_data = data->data; + notify_src_data = bt_os_new(sizeof(ble_ancs_notification_src_t)); + notify_src_data->event_id = *pt_data; + notify_src_data->event_flags = *(pt_data + BT_INDEX_1); + notify_src_data->category_id = *(pt_data + BT_INDEX_2); + notify_src_data->category_count = *(pt_data + BT_INDEX_3); + pt_data = pt_data + BT_INDEX_4; + notify_src_data->notification_uid = convert_little_2_u32(pt_data); + } + + if (g_ancs_callbacks_t.notify_source_cb != NULL) { + g_ancs_callbacks_t.notify_source_cb(client_id, conn_id, notify_src_data, result); + } + if (notify_src_data != NULL) { + bt_os_free(notify_src_data); + } +} + +/* ANCS客户端数据消息处理函数 */ +static void data_src_handle(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data) +{ + uint8_t *pt_data = data->data; + uint16_t data_length = data->data_len; + if ((data_length == (ble_gatt_mtu_exchange_result_get() - BLE_ATT_HEADER_LEN)) || + (data_length == BLE_ANCS_DATA_MAX_LEN)) { + bts_error("response is larger than MTU, please limit attribute length, client_id:%u conn_id:%u\n", + client_id, conn_id); + } + uint8_t cmd_id = *pt_data; + pt_data = pt_data + 1; + switch (cmd_id) { + /* 数据格式:cmd_id(1B)|notify_uid(4B)|att_id1(1B)|att_id1_length(2B)|att_id1_data(动态)|... */ + case ANCS_CMD_GET_NOTIFY_ATT:{ + notify_att_data_parse(client_id, conn_id, pt_data, data->data_len - 1); + break; + } + /* 数据格式:cmd_id(1B)|app_id(动态长度,字符串字节流,以NULL结尾)|att_id1(1B)|att_id1_length(2B)|att_id1_data(动态)|... */ + case ANCS_CMD_GET_APP_ATT:{ + app_att_data_parse(client_id, conn_id, pt_data, data->data_len - 1); + break; + } + default: + break; + } +} + +/* ANCS客户端接收对端通知处理函数 */ +void ble_ancs_client_notify_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + /* notification source */ + /* 数据格式:event_id(1B)|event_flags(1B)|category_id(1B)|category_count(1B)|notification_uid(4B) */ + if (data->handle == remote->notify_src.value_handle) { + notify_src_handle(client_id, conn_id, data); + /* data source */ + } else if (data->handle == remote->data_src.value_handle) { + data_src_handle(client_id, conn_id, data); + } +} + +/* ANCS客户端订阅结果处理函数 */ +static void ble_ancs_client_subscribe_result(uint8_t client_id, uint16_t conn_id, + ancs_client_subscribe_type_t type, gatt_status_t status) +{ + if (g_ancs_callbacks_t.subscribe_cb != NULL) { + g_ancs_callbacks_t.subscribe_cb(client_id, conn_id, type, status); + } +} + +/* ANCS客户端写请求响应结果处理函数 */ +static void ble_ancs_client_write_result(uint8_t client_id, uint16_t conn_id, gatt_status_t status) +{ + if (g_ancs_callbacks_t.write_result_cb != NULL) { + g_ancs_callbacks_t.write_result_cb(client_id, conn_id, status); + } +} + +/* ANCS客户端写请求响应处理函数 */ +void ble_ancs_client_write_cbk(uint8_t client_id, uint16_t conn_id, uint16_t handle, gatt_status_t status) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + return; + } + + if (handle == (remote->notify_src_ccc_handle)) { + ble_ancs_client_subscribe_result(client_id, conn_id, ANCS_CLIENT_SUBSCRIBE_NOTIFY, status); + } else if (handle == (remote->data_src_ccc_handle)) { + ble_ancs_client_subscribe_result(client_id, conn_id, ANCS_CLIENT_SUBSCRIBE_DATA, status); + } else if (handle == (remote->ctl_point.value_handle)) { + ble_ancs_client_write_result(client_id, conn_id, status); + } +} + +/* 校验通知属性是否需要拼接【最大长度】参数 */ +static bool is_followed_by_max_length_param(uint8_t att_id) +{ + bool is_followed = false; + switch (att_id) { + case ANCS_NOTIFY_ATT_TITLE: + case ANCS_NOTIFY_ATT_SUBTITLE: + case ANCS_NOTIFY_ATT_MESSAGE: + is_followed = true; + break; + default: + break; + } + return is_followed; +} + +/* u32转小端序 */ +static void u32_2_little(uint32_t notify_uid, uint8_t *pt_data) +{ + *(pt_data + BT_INDEX_1) = u32_2_little_first_byte(notify_uid); + *(pt_data + BT_INDEX_2) = u32_2_little_second_byte(notify_uid); + *(pt_data + BT_INDEX_3) = u32_2_little_three_byte(notify_uid); + *(pt_data + BT_INDEX_4) = u32_2_little_four_byte(notify_uid); +} + +/* 组装通知属性请求参数 */ +static errcode_t package_notify_att_req_param(ble_ancs_notification_attr_req_t *notify_att_req, uint8_t *pt_data) +{ + /* command id */ + *pt_data = ANCS_CMD_GET_NOTIFY_ATT; + + /* notification uuid 小端 */ + u32_2_little(notify_att_req->notification_uid, pt_data); + + /* 拼接ATT ID */ + pt_data = pt_data + ANCS_NOTIFY_ATT_ID_OFFSET; + for (int i = 0; i < notify_att_req->att_num; i++) { + /* 校验ATT ID */ + if (notify_att_req->attr[i].att_id > ANCS_NOTIFY_ATT_NEGATIVE_LABEL) { + return ERRCODE_BT_PARAM_ERR; + } + *(pt_data) = notify_att_req->attr[i].att_id; + pt_data = pt_data + 1; + + /* 属性带有最大长度参数,小端传输 */ + if (is_followed_by_max_length_param(notify_att_req->attr[i].att_id)) { + *(pt_data) = u16_low_byte(notify_att_req->attr[i].att_max_length); + *(pt_data + 1) = u16_high_byte(notify_att_req->attr[i].att_max_length); + pt_data = pt_data + ANCS_NOTIFY_ATT_MAX_LENGTH_BYTE; + } + } + return ERRCODE_BT_SUCCESS; +} + +/* 计算申请内存大小 */ +static uint16_t calc_notify_att_req_param_length(ble_ancs_notification_attr_req_t *notify_att_req) +{ + uint16_t data_len = sizeof(uint8_t) + sizeof(uint32_t) + + (notify_att_req->att_num) * sizeof(uint8_t); + for (int i = 0; i < notify_att_req->att_num; i++) { + /* 属性带有最大长度参数 */ + if (is_followed_by_max_length_param(notify_att_req->attr[i].att_id)) { + data_len += sizeof(uint16_t); + } + } + return data_len; +} + +/* 发送获取通知属性命令 */ +errcode_t ble_ancs_client_send_get_notify_att_cmd(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_attr_req_t *notify_att_req) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ancs client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->ctl_point.value_handle == 0) { + bts_error("ancs client remote service did not discovery character, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (notify_att_req->att_num == 0) { + bts_error("ancs client att num is invalid, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_PARAM_ERR; + } + + /* 计算请求数据长度 */ + uint16_t data_len = calc_notify_att_req_param_length(notify_att_req); + + /* 请求数据格式:cmd_id(1B)|notify_uid(4B)|att_id1(1B)|att_id2(1B)|att_id2_max_length(2B)|... */ + uint8_t *data = (uint8_t *)bt_os_new(data_len); + + /* 指向参数数据的指针,用于拼接参数移动指针 */ + uint8_t *pt_data = data; + errcode_t ret = package_notify_att_req_param(notify_att_req, pt_data); + if (ret != ERRCODE_BT_SUCCESS) { + bt_os_free(data); + return ret; + } + gattc_handle_value_t value = {0}; + value.handle = remote->ctl_point.value_handle; + value.data_len = data_len; + value.data = data; + errcode_t result = gattc_write_req(client_id, conn_id, &value); + bt_os_free(data); + return result; +} + +static errcode_t package_app_att_req_param(ble_ancs_app_attr_req_t *app_att_req, uint8_t *pt_data) +{ + /* command id */ + *pt_data = ANCS_CMD_GET_APP_ATT; + + /* app id ,字符串 */ + pt_data = pt_data + 1; + if (memcpy_s(pt_data, app_att_req->app_id.len, app_att_req->app_id.id, app_att_req->app_id.len) != EOK) { + bts_error("[btsrv][ERROR] app id memcpy fail!\r\n"); + return ERRCODE_BT_MALLOC_FAIL; + } + + /* 校验 att id */ + pt_data = pt_data + app_att_req->app_id.len; + for (int i = 0; i < app_att_req->att_num; i++) { + if (app_att_req->attr_id[i] > ANCS_APP_ATT_DISPLAY_NAME) { + return ERRCODE_BT_PARAM_ERR; + } + *(pt_data) = app_att_req->attr_id[i]; + pt_data = pt_data + 1; + } + + return ERRCODE_BT_SUCCESS; +} + +/* 发送获取应用属性命令 */ +errcode_t ble_ancs_client_send_get_app_att_cmd(uint8_t client_id, uint16_t conn_id, + ble_ancs_app_attr_req_t *app_att_req) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ancs client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->ctl_point.value_handle == 0) { + bts_error("ancs client remote service did not discovery character, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (app_att_req->att_num == 0) { + bts_error("ancs client att num is invalid, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_PARAM_ERR; + } + + if (app_att_req->app_id.len != strlen((char *)app_att_req->app_id.id) + 1) { + bts_error("[ANCSClient][AppIdentifier]string must be NULL-terminated!\r\n"); + return ERRCODE_BT_PARAM_ERR; + } + + /* 计算数据长度 */ + uint16_t data_len = sizeof(uint8_t) + app_att_req->app_id.len + + (app_att_req->att_num) * sizeof(uint8_t); + + /* 数据格式:cmd_id(1B)|app_id(动态)|att_id1(1B)|att_id2(1B)|... */ + uint8_t *data = (uint8_t *)bt_os_new(data_len); + /* 指向参数数据的指针,用于拼接参数移动指针 */ + uint8_t *pt_data = data; + errcode_t ret = package_app_att_req_param(app_att_req, pt_data); + if (ret != ERRCODE_BT_SUCCESS) { + bt_os_free(data); + return ret; + } + + gattc_handle_value_t value = {0}; + value.handle = remote->ctl_point.value_handle; + value.data_len = data_len; + value.data = data; + errcode_t result = gattc_write_req(client_id, conn_id, &value); + bt_os_free(data); + return result; +} + +/* 发送执行通知行为命令 */ +errcode_t ble_ancs_client_send_perform_notify_action_cmd(uint8_t client_id, uint16_t conn_id, + ble_ancs_notification_action_req_t *action_req) +{ + ble_ancs_service_t *remote = ancs_service_remote_by_conn(client_id, conn_id); + if (remote == NULL) { + bts_error("ancs client remote service is not exist, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + + if (remote->ctl_point.value_handle == 0) { + bts_error("ancs client remote service did not discovery character, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_NOT_READY; + } + if (action_req->action_id >= ANCS_ACTION_RESERVED) { + bts_error("ancs client action id is invalid, client_id:%u conn_id:%u\n", + client_id, conn_id); + return ERRCODE_BT_PARAM_ERR; + } + + /* 计算数据长度 */ + uint16_t data_len = sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t); + + /* 数据格式:cmd_id(1B)|notify_uid(4B)|action_id(1B) */ + uint8_t *data = (uint8_t *)bt_os_new(data_len); + /* 指向参数数据的指针,用于拼接参数移动指针 */ + uint8_t *pt_data = data; + + /* command id */ + *pt_data = ANCS_CMD_PERFORM_NOTIFY_ACTION; + + /* notification uuid 小端 */ + u32_2_little(action_req->notification_uid, pt_data); + *(pt_data + ANCS_NOTIFY_ACTION_ID_OFFSET) = action_req->action_id; + + gattc_handle_value_t value = {0}; + value.handle = remote->ctl_point.value_handle; + value.data_len = data_len; + value.data = data; + errcode_t result = gattc_write_req(client_id, conn_id, &value); + bt_os_free(data); + return result; +} + +/* 注册ANCS客户端回调函数 */ +errcode_t ble_ancs_client_register_callbacks(ble_ancs_client_callbacks_t *func) +{ + if (memcpy_s(&g_ancs_callbacks_t, sizeof(g_ancs_callbacks_t), func, sizeof(ble_ancs_client_callbacks_t)) != EOK) { + return ERRCODE_BT_MEMCPY_FAIL; + } + return ERRCODE_BT_SUCCESS; +} + +/* ANCS服务判断 */ +bool is_ble_ancs_service(bt_uuid_t *uuid) +{ + bt_uuid_t ancs_service_uuid = {0}; + ancs_service_uuid.uuid_len = BT_UUID_MAX_LEN; + if (memcpy_s(ancs_service_uuid.uuid, BT_UUID_MAX_LEN, ancs_uuid, BT_UUID_MAX_LEN) != EOK) { + bts_error("[BLE]client discovery ancs memcpy error! \n"); + return false; + } + if (ancs_service_uuid.uuid_len != uuid->uuid_len) { + return false; + } + + return (memcmp(uuid, &ancs_service_uuid, sizeof(bt_uuid_t)) == 0 ? true : false); +} + +/* 根据连接ID清理本地存储的对端ANCS服务信息 */ +void ble_ancs_client_clear_remote_by_conn(uint8_t client_id, uint16_t conn_id) +{ + ble_ancs_service_t *node = NULL; + node = ancs_service_remote_by_conn(client_id, conn_id); + if (node != NULL) { + bt_sdk_list_remove(&g_ble_ancs_service_list, node); + sdk_list_node_free(node); + } +} + +/* 清理本地存储的所有对端ANCS服务信息 */ +void ble_ancs_client_clear_remote_all(void) +{ + ble_ancs_service_t *node = (ble_ancs_service_t *)g_ble_ancs_service_list.head; + ble_ancs_service_t *cur_node = NULL; + while (node != NULL) { + cur_node = node; + node = lnext(node); + bt_sdk_list_remove(&g_ble_ancs_service_list, cur_node); + sdk_list_node_free(cur_node); + cur_node = NULL; + } +} diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_bas_client.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_bas_client.c index 666608273..4c649f65b 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_bas_client.c +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_bas_client.c @@ -304,8 +304,6 @@ void ble_bas_client_read_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_v bts_unused(status); ble_bas_client_t *dev = bas_client_get_dev_by_conn(client_id, conn_id); if (dev == NULL) { - bts_error("bas client remote service is not exist, client_id:%u conn_id:%hu\n", - client_id, conn_id); return; } @@ -324,8 +322,6 @@ void ble_bas_client_notify_characteristic_cbk(uint8_t client_id, uint16_t conn_i { ble_bas_client_t *dev = bas_client_get_dev_by_conn(client_id, conn_id); if (dev == NULL) { - bts_error("bas client remote service is not exist, client_id:%u conn_id:%hu\n", - client_id, conn_id); return; } diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_gatts_callbacks.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_gatts_callbacks.c index 839b34d73..7ae553614 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_gatts_callbacks.c +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/ble_profile/profiles/src/ble_gatts_callbacks.c @@ -12,9 +12,13 @@ #include "ble_bas_client.h" #include "ble_pro_dis_client.h" #include "ble_fmp_locator.h" +#include "ble_ancs_client.h" +#include "ble_ams_client.h" #include "bts_uuid.h" #include "ble_gatts_callbacks.h" +uint32_t g_ble_gatt_mtu_size = 23; + static bool bt_gatts_cmp_uuid(const bt_uuid_t *tgt_uuid, const bt_uuid_t *src_uuid) { uint8_t *tgt = (uint8_t *)bts_init_128bit_uuid(tgt_uuid); @@ -182,13 +186,16 @@ static void ble_client_discovery_service_cbk(uint8_t client_id, uint16_t conn_id bt_uuid_t fmp_service_uuid = {0}; bts_data_to_uuid_len2(FMP_IMMEDIATE_ALERT_SERVICE_UUID, &fmp_service_uuid); - if (bt_gatts_cmp_uuid(&service->uuid, &bas_service_uuid) == true) { ble_bas_client_discovery_service_cbk(client_id, conn_id, service); } else if (bt_gatts_cmp_uuid(&service->uuid, &dis_service_uuid) == true) { ble_dis_client_discovery_service_cbk(client_id, conn_id, service); } else if (bt_gatts_cmp_uuid(&service->uuid, &fmp_service_uuid) == true) { fmp_locator_discovery_service_cbk(client_id, conn_id, service); + } else if (is_ble_ancs_service(&service->uuid)) { + ble_ancs_client_discovery_service_cbk(client_id, conn_id, service); + } else if (is_ble_ams_service(&service->uuid)) { + ble_ams_client_discovery_service_cbk(client_id, conn_id, service); } } @@ -213,6 +220,8 @@ static void ble_client_discovery_character_cbk(uint8_t client_id, uint16_t conn_ fmp_locator_discovery_characteristic_cbk(client_id, conn_id, character); } else { ble_dis_client_discovery_character_cbk(client_id, conn_id, character); + ble_ancs_client_discovery_character_cbk(client_id, conn_id, character); + ble_ams_client_discovery_character_cbk(client_id, conn_id, character); } } @@ -225,6 +234,8 @@ static void ble_client_discovery_descriptor_cbk(uint8_t client_id, uint16_t conn return; } ble_bas_client_discovery_descriptor_cbk(client_id, conn_id, descriptor); + ble_ancs_client_discovery_descriptor_cbk(client_id, conn_id, descriptor); + ble_ams_client_discovery_descriptor_cbk(client_id, conn_id, descriptor); } static void ble_client_read_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *read_result, @@ -232,17 +243,18 @@ static void ble_client_read_cbk(uint8_t client_id, uint16_t conn_id, gattc_handl { bts_info("[BLE]client read cbk client_id: %u conn_id: %hu status: %d handle: %hu \n", client_id, conn_id, status, read_result->handle); - if (status != ERRCODE_BT_SUCCESS) { - return; - } ble_bas_client_read_cbk(client_id, conn_id, read_result, status); ble_dis_client_read_cbk(client_id, conn_id, read_result, status); + ble_ams_client_read_cbk(client_id, conn_id, read_result, status); } static void ble_client_write_cbk(uint8_t client_id, uint16_t conn_id, uint16_t handle, gatt_status_t status) { bts_info("[BLE]client write cbk client_id: %u conn_id: %hu status: %d handle: %hu \n", client_id, conn_id, status, handle); + + ble_ancs_client_write_cbk(client_id, conn_id, handle, status); + ble_ams_client_write_cbk(client_id, conn_id, handle, status); } static void ble_client_notification_cbk(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data, @@ -254,8 +266,16 @@ static void ble_client_notification_cbk(uint8_t client_id, uint16_t conn_id, gat return; } ble_bas_client_notify_characteristic_cbk(client_id, conn_id, data); + ble_ancs_client_notify_cbk(client_id, conn_id, data); + ble_ams_client_notify_cbk(client_id, conn_id, data); } +static void ble_client_mtu_exchange_result_cbk(uint8_t client_id, uint16_t conn_id, uint32_t mtu_size, errcode_t status) +{ + bts_info("[BLE]client MTU changed cbk: status: %u client_id: %u conn_id: %u mtu:%u.\r\n", + status, client_id, conn_id, mtu_size); + g_ble_gatt_mtu_size = mtu_size; +} errcode_t ble_client_register_gatt_callbacks(void) { @@ -267,6 +287,12 @@ errcode_t ble_client_register_gatt_callbacks(void) cb.read_cb = ble_client_read_cbk; cb.write_cb = ble_client_write_cbk; cb.notification_cb = ble_client_notification_cbk; + cb.mtu_changed_cb = ble_client_mtu_exchange_result_cbk; ret = gattc_register_callbacks(&cb); return ret; +} + +uint32_t ble_gatt_mtu_exchange_result_get(void) +{ + return g_ble_gatt_mtu_size; } \ No newline at end of file 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 b3fd574d3..f4196fdb2 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 @@ -11,6 +11,7 @@ #include "soc_errno.h" #include "bts_br_gap.h" #include "bts_le_gap.h" +#include "bts_feature.h" #include "bts_a2dp_source.h" #include "bts_br_gap.h" #include "bts_avrcp_controller.h" @@ -58,6 +59,11 @@ typedef enum { BTSRV_SAMPLE_GAP_SHOW_FOUND_LIST, /* 30 展示发现设备列表 */ BTSRV_SAMPLE_GAP_SET_CONN_REQ_ANSWER, /* 31 设置连接请求应答 */ + BTSRV_SAMPLE_GAP_SET_FEATURE_CONFIG, /* 32 蓝牙特性配置 */ + BTSRV_SAMPLE_GAP_GET_FEATURE_CONFIG, /* 33 蓝牙特性获取 */ + BTSRV_SAMPLE_GAP_RECONNECT_PHONE, /* 34 重连手机 */ + + BTSRV_SAMPLE_GAP_SET_INQUIRY_PARAM, /* 35 设置搜到参数 */ } btsrv_gap_sample_cmd_id; typedef enum { @@ -1104,6 +1110,21 @@ static void btsrv_sample_cmd_get_device_class(const char **params, int32_t param bts_sample_log("gap_get_device_class device_class: %d\n", ret); } +static void btsrv_sample_cmd_set_filter_device_class(const char **params, int32_t params_cnt) +{ + if (params_cnt != 2) { /* 2:参数个数 */ + bts_sample_log("gap_br_set_inquiry_paramters params_cnt error! need: device_class max_number\n"); + return; + } + + uint32_t dev_class = (uint32_t)atoi(params[0]); + uint8_t max_num = (uint8_t)atoi(params[1]); + bts_sample_log_with_func("dev_class:%u max_num:%u\n", dev_class, max_num); + int ret = gap_br_set_inquiry_paramters(dev_class, max_num); + + bts_sample_log("gap_br_set_inquiry_paramters ret: %d\n", ret); +} + static void btsrv_sample_cmd_update_found_list(const char **params, int32_t params_cnt) { bts_unused(params); @@ -1130,6 +1151,44 @@ static void btsrv_sample_cmd_set_connect_req_answer(const char **params, int32_t g_sample_gap_accept_conn = (bool)atoi(params[0]); } +static void btsrv_sample_cmd_set_feature_config(const char **params, int32_t params_cnt) +{ + bts_feature_t feature; + if (params_cnt != 1) { /* 1:参数个数 */ + bts_sample_log("btsrv_sample_cmd_set_feature_config params_cnt error! need: feature_config\n"); + return; + } + *(int *)&feature = atoi(params[0]); + bts_sample_log("feature:%d bt_auto_reconnect_closed:%d\n", *(int *)&feature, feature.bt_auto_reconnect_closed); + errcode_t ret = bts_set_features(&feature); + bts_sample_log("bts set features ret:%d\n", ret); +} + +static void btsrv_sample_cmd_get_feature_config(const char **params, int32_t params_cnt) +{ + bts_unused(params); + bts_unused(params_cnt); + bts_feature_t feature = bts_get_features(); + bts_sample_log("bts get features feature: bt_auto_reconnect_closed:%d.\n", feature.bt_auto_reconnect_closed); +} + +static void btsrv_sample_cmd_reconnect_phone(const char **params, int32_t params_cnt) +{ + errcode_t ret; + if (params_cnt != 1) { /* 1:参数个数 */ + bts_sample_log("reconnect phone param error! need: bd_addr.\n"); + return; + } + + bd_addr_t bd_addr; + if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) { + bts_sample_log("reconnect phone decode addr error!\n"); + return; + } + ret = gap_reconnect_media_device(&bd_addr); + bts_sample_log("reconnect phone ret:%d.\n", ret); +} + btsrv_sample_cmd_hdl_info g_btsrv_gap_sample_hdls[] = { /* 0 */ { BTSRV_SAMPLE_GAP_ENABLE_BLE, btsrv_sample_cmd_enable_ble }, @@ -1166,12 +1225,23 @@ btsrv_sample_cmd_hdl_info g_btsrv_gap_sample_hdls[] = { { BTSRV_SAMPLE_GAP_GET_DEVICE_NAME, btsrv_sample_cmd_get_device_name }, { BTSRV_SAMPLE_GAP_GET_DEVICE_CLASS, btsrv_sample_cmd_get_device_class }, + /* 25 */ + { BTSRV_SAMPLE_GAP_PAIR_REQUEST_RELY, NULL }, + { BTSRV_SAMPLE_GAP_SET_DEVICE_PIN, NULL }, + { BTSRV_SAMPLE_GAP_SET_DEVICE_PAIRING_CONFIRMATION, NULL }, + { BTSRV_SAMPLE_GAP_SET_DEVICE_PASSKEY, NULL }, /* 29 */ { BTSRV_SAMPLE_GAP_UPDATE_FOUND_LIST, btsrv_sample_cmd_update_found_list }, /* 30 */ { BTSRV_SAMPLE_GAP_SHOW_FOUND_LIST, btsrv_sample_cmd_show_found_list }, - { BTSRV_SAMPLE_GAP_SET_CONN_REQ_ANSWER, btsrv_sample_cmd_set_connect_req_answer } + { BTSRV_SAMPLE_GAP_SET_CONN_REQ_ANSWER, btsrv_sample_cmd_set_connect_req_answer }, + { BTSRV_SAMPLE_GAP_SET_FEATURE_CONFIG, btsrv_sample_cmd_set_feature_config }, + { BTSRV_SAMPLE_GAP_GET_FEATURE_CONFIG, btsrv_sample_cmd_get_feature_config }, + { BTSRV_SAMPLE_GAP_RECONNECT_PHONE, btsrv_sample_cmd_reconnect_phone }, + + /* 35 */ + { BTSRV_SAMPLE_GAP_SET_INQUIRY_PARAM, btsrv_sample_cmd_set_filter_device_class }, }; void btsrv_gap_sample_cmd(uint32_t cmd_id, const char **params, int32_t params_cnt) diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gatt.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gatt.c index f1c4921da..99ff62fb5 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gatt.c +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_core/sample_bts_gatt.c @@ -24,6 +24,8 @@ #include "ble_pro_dis_client.h" #include "ble_bas_client.h" #include "ble_fmp_locator.h" +#include "ble_ancs_client.h" +#include "ble_ams_client.h" #include "osal_task.h" #define BTSRV_LOG_DEBUG @@ -1499,8 +1501,8 @@ static void sample_gap_ble_scan_result_cbk(const gap_scan_result_data_t *scan_re scan_result_data->addr.addr[BT_INDEX_5]); } -static void sample_gap_ble_conn_state_change_cbk(uint16_t conn_id, bd_addr_t *addr, gap_acl_state_t conn_state, - gap_pair_state_t pair_state, gap_ble_disc_reason_t disc_reason) +static void sample_gap_ble_conn_state_change_cbk(uint16_t conn_id, bd_addr_t *addr, gap_ble_conn_state_t conn_state, + gap_ble_pair_state_t pair_state, gap_ble_disc_reason_t disc_reason) { bts_sample_log("ConnectStateChanged conn_id:%u addr:0x%02x:**:**:**:%02x:%02x addr_type:%u" "conn_state:%d pair_state:%d\r\n", conn_id, addr->addr[BT_INDEX_0], addr->addr[BT_INDEX_4], @@ -1510,6 +1512,8 @@ static void sample_gap_ble_conn_state_change_cbk(uint16_t conn_id, bd_addr_t *ad ble_dis_client_clear_remote_by_conn(1, conn_id); ble_bas_client_clear_remote_by_conn(1, conn_id); ble_fmp_locator_clear_remote_by_conn(1, conn_id); + ble_ancs_client_clear_remote_by_conn(1, conn_id); + ble_ams_client_clear_remote_by_conn(1, conn_id); } } @@ -1549,6 +1553,15 @@ static void sample_gap_ble_read_remote_rssi_cbk(uint16_t conn_id, int8_t rssi, e bts_sample_log("read remote rssi conn_id:%u rssi:%d status:%u\r\n", conn_id, rssi, status); } +static void sample_gap_ble_connect_param_update_cbk(uint16_t conn_id, errcode_t status, + const gap_ble_conn_param_update_t *param) +{ + bts_sample_log("connect param changed conn_id:%u status:%u", conn_id, status); + if (param != NULL) { + bts_sample_log(" interval:%u latency:%u timeout:%u\r\n", param->interval, param->latency, param->timeout); + } +} + /* 注册GATT回调 params: sample_mode fill_callbacks */ static void sample_gatt_cmd_ble_gatt_reg_cbk(char **params, int32_t params_cnt) { @@ -1578,7 +1591,7 @@ static void sample_gatt_cmd_ble_gatt_reg_cbk(char **params, int32_t params_cnt) sample_gap_ble_read_remote_rssi_cbk, sample_gap_ble_terminate_adv_cbk, sample_gap_ble_auth_complete_cbk, - NULL, + sample_gap_ble_connect_param_update_cbk, }; ret = gap_ble_register_callbacks(&cb); bts_sample_log("gap_ble_register_callbacks with funcs ret(errcode_t): %x\n", ret); diff --git a/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_srv_shell.c b/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_srv_shell.c index 5304e5b80..745461c3f 100644 --- a/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_srv_shell.c +++ b/code/sdk/protocol/bt/host/bt/bts/bt_sample/bt_srv_shell.c @@ -22,6 +22,8 @@ #include "sample_bt_audio_hal.h" #include "sample_ble_fmp.h" #include "sample_pan_service.h" +#include "sample_ble_ancs.h" +#include "sample_ble_ams.h" #define BT_SRV_SAMPLE_CMD_ARGC_MIN 2 @@ -57,6 +59,9 @@ typedef enum { BTSRV_SAMPLE_CMD_GROUP_PAN = 22, /* 22 PAN 测试命令 */ BTSRV_SAMPLE_CMD_GROUP_HFP_AG = 23, /* 23 HFP-AG 测试命令 */ #endif + + BTSRV_SAMPLE_CMD_GROUP_ANCS_CLIENT = 24, /* 24 ANCS CLIENT 测试命令 */ + BTSRV_SAMPLE_CMD_GROUP_AMS_CLIENT = 25, /* 25 AMS CLIENT 测试命令 */ } btsrv_sample_cmd_group; #if (BTH_LE_ONLY == YES) || (BTH_BREDR_LE_DOUBLE == YES) static void ble_service_sample_cmd(int32_t module_id, int32_t cmd_id, char **params, int32_t params_num) @@ -101,6 +106,12 @@ static void ble_service_sample_cmd(int32_t module_id, int32_t cmd_id, char **par case BTSRV_SAMPLE_CMD_GROUP_FMP: ble_at_fmp_srv_cmd(cmd_id, params, params_num); break; + case BTSRV_SAMPLE_CMD_GROUP_ANCS_CLIENT: + ble_ancs_client_at_cmd(cmd_id, params, params_num); + break; + case BTSRV_SAMPLE_CMD_GROUP_AMS_CLIENT: + ble_ams_client_at_cmd(cmd_id, params, params_num); + break; default: bts_sample_log_with_func("invalid cmd group id\n"); break; 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 9d60c127c..bfef91a10 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 @@ -482,7 +482,7 @@ int32_t btsdk_un_pair_device(uintptr_t dev_hdl); uintptr_t btsdk_add_remote_device(uint8_t *bd_addr, uint8_t addr_len); int32_t btsdk_update_remote_device_name(uintptr_t dev_hdl, uint8_t *name, uint16_t *plen); int32_t btsdk_update_remote_device_name_async(uintptr_t dev_hdl, gap_execute_command_cfm_cbk *cfm_cbk); -int32_t btsdk_start_device_discovery(uint32_t dev_class); +int32_t btsdk_start_device_discovery(uint32_t dev_class, uint8_t max_num, uint8_t max_seconds); int32_t btsdk_get_remote_device_address(uintptr_t dev_hdl, uint8_t *bd_addr, uint8_t addr_len); int32_t btsdk_create_acl_link(uintptr_t dev_hdl, uint8_t link_type); int32_t btsdk_create_acl_link_async(uintptr_t dev_hdl, uint8_t link_type, gap_create_connection_cfm_cbk *cfm_cbk); diff --git a/code/sdk/tools/bin/ohos_tools/ace-loader/jerry-snapshot.exe b/code/sdk/tools/bin/ohos_tools/ace-loader/jerry-snapshot.exe new file mode 100644 index 000000000..895c74cb5 Binary files /dev/null and b/code/sdk/tools/bin/ohos_tools/ace-loader/jerry-snapshot.exe differ diff --git a/code/sdk/tools/bin/ohos_tools/ace-loader/jerry.exe b/code/sdk/tools/bin/ohos_tools/ace-loader/jerry.exe new file mode 100644 index 000000000..3bdadfba0 Binary files /dev/null and b/code/sdk/tools/bin/ohos_tools/ace-loader/jerry.exe differ diff --git a/code/sdk/tools/pkg/bin/brandy/bt.bin b/code/sdk/tools/pkg/bin/brandy/bt.bin index 780c42fa8..557347026 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 0fa89884a..9a9b9751c 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 c1a7f2f33..64759267a 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 c66cf33b2..7785263fa 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 b335c6a68..ee819d6dc 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/normal/dsp_main.bin b/code/sdk/tools/pkg/bin/brandy/dsp/normal/dsp_main.bin index 7c4ebc4f7..4e0a8a0d6 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/normal/dsp_main.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/normal/dsp_main.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/dsp/normal/dsp_overlay.bin b/code/sdk/tools/pkg/bin/brandy/dsp/normal/dsp_overlay.bin index cea3f9de9..46c5134c6 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/dsp/normal/dsp_overlay.bin and b/code/sdk/tools/pkg/bin/brandy/dsp/normal/dsp_overlay.bin differ diff --git a/code/sdk/tools/pkg/bin/brandy/ssb.bin b/code/sdk/tools/pkg/bin/brandy/ssb.bin index c6a9dec43..4d35eed24 100644 Binary files a/code/sdk/tools/pkg/bin/brandy/ssb.bin and b/code/sdk/tools/pkg/bin/brandy/ssb.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 9a74cf5cb..a7ce8a108 100644 --- a/code/sdk/tools/pkg/chip_packet/brandy/packet.py +++ b/code/sdk/tools/pkg/chip_packet/brandy/packet.py @@ -24,14 +24,18 @@ from param_packet import gen_flash_part_bin from nv_binary import nv_begin # brandy packet -def build_brandy_other_bin(): +def build_brandy_other_bin(pack_style_str): ''' 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", "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", "mk_nv_bin_cfg.json") + nv_config_json = os.path.join(chip_dir, "nv_bin_cfg") + if pack_style_str.endswith("-user"): + nv_config_json = os.path.join(nv_config_json, "mk_nv_bin_cfg_user.json") + else: + nv_config_json = os.path.join(nv_config_json, "mk_nv_bin_cfg_eng.json") targets = ["acore"] # 输出路径 nv_output_path = os.path.join(SDK_DIR, "output", "brandy", "nv_bin") @@ -45,7 +49,7 @@ def build_brandy_other_bin(): def make_all_in_one_packet(pack_style_str): # make all in one packet - build_brandy_other_bin() + build_brandy_other_bin(pack_style_str) bin_dir = os.path.join(PKG_DIR, "bin", "brandy") application_dir = os.path.join(SDK_DIR, @@ -54,6 +58,7 @@ def make_all_in_one_packet(pack_style_str): "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", diff --git a/jsapp/music/.gitignore b/jsapp/music/.gitignore new file mode 100644 index 000000000..50948c893 --- /dev/null +++ b/jsapp/music/.gitignore @@ -0,0 +1,11 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +/entry/.preview +/entry/build +.cxx diff --git a/jsapp/music/README.md b/jsapp/music/README.md new file mode 100644 index 000000000..9b7ab9855 --- /dev/null +++ b/jsapp/music/README.md @@ -0,0 +1,3 @@ +# Lite_Himalayas + +3321 喜马拉雅demo \ No newline at end of file diff --git a/jsapp/music/build.gradle b/jsapp/music/build.gradle new file mode 100644 index 000000000..5e5275d7b --- /dev/null +++ b/jsapp/music/build.gradle @@ -0,0 +1,38 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 +ohos { + compileSdkVersion 5 + defaultConfig { + compatibleSdkVersion 5 + } +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } + dependencies { + classpath 'com.huawei.ohos:hap:2.4.4.2' + classpath 'com.huawei.ohos:decctest:1.2.4.0' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } +} diff --git a/jsapp/music/entry/.gitignore b/jsapp/music/entry/.gitignore new file mode 100644 index 000000000..3543521e9 --- /dev/null +++ b/jsapp/music/entry/.gitignore @@ -0,0 +1 @@ +/build diff --git a/jsapp/music/entry/build.gradle b/jsapp/music/entry/build.gradle new file mode 100644 index 000000000..88bfe60e0 --- /dev/null +++ b/jsapp/music/entry/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 +ohos { + compileSdkVersion 5 + defaultConfig { + compatibleSdkVersion 5 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + +} + +dependencies { + testImplementation 'junit:junit:4.13' +} +decc { + supportType = ['html','xml'] +} + +project.afterEvaluate { + project.getTasks().getByName("convertImage").dependsOn(project.getTasks().getByName("generateDebugBinSource")) + project.getTasks().getByName("assembleDebug").dependsOn(project.getTasks().getByName("convertImage")) +} + +task convertImage(type: Exec) { + workingDir System.getenv("ImageTool") + buildDir = getBuildDir() + commandLine "python3","images_tool.py","-p","file","-c","config.xml","-i","${buildDir}/intermediates/","-o","${buildDir}/intermediates/" +} \ No newline at end of file diff --git a/jsapp/music/entry/proguard-rules.pro b/jsapp/music/entry/proguard-rules.pro new file mode 100644 index 000000000..f7666e475 --- /dev/null +++ b/jsapp/music/entry/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/jsapp/music/entry/src/main/config.json b/jsapp/music/entry/src/main/config.json new file mode 100644 index 000000000..d915f84d8 --- /dev/null +++ b/jsapp/music/entry/src/main/config.json @@ -0,0 +1,39 @@ +{ + "app": { + "bundleName": "cn.tingshu", + "vendor": "vendor", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "deviceType": [ + "liteWearable" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "name": "default", + "icon": "$media:icon", + "label": "$string:entry_MainAbility", + "type": "page" + } + ], + "js": [ + { + "name": "default", + "pages": [ + "pages/index/index", + "pages/play/play", + "pages/playlist/playlist" + ] + } + ] + } +} \ No newline at end of file diff --git a/jsapp/music/entry/src/main/js/default/app.js b/jsapp/music/entry/src/main/js/default/app.js new file mode 100644 index 000000000..6d060ffe5 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/app.js @@ -0,0 +1,8 @@ +export default { + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } +}; diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_001.png b/jsapp/music/entry/src/main/js/default/common/images/A055_001.png new file mode 100644 index 000000000..0068ef8bd Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_001.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_006.png b/jsapp/music/entry/src/main/js/default/common/images/A055_006.png new file mode 100644 index 000000000..44239136a Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_006.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_007.png b/jsapp/music/entry/src/main/js/default/common/images/A055_007.png new file mode 100644 index 000000000..9c8579ddf Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_007.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_008.png b/jsapp/music/entry/src/main/js/default/common/images/A055_008.png new file mode 100644 index 000000000..3ae91b5e6 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_008.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_009.png b/jsapp/music/entry/src/main/js/default/common/images/A055_009.png new file mode 100644 index 000000000..66afc510b Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_009.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_010.png b/jsapp/music/entry/src/main/js/default/common/images/A055_010.png new file mode 100644 index 000000000..8973d8fff Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_010.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_013.png b/jsapp/music/entry/src/main/js/default/common/images/A055_013.png new file mode 100644 index 000000000..02e90d57d Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_013.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_014.png b/jsapp/music/entry/src/main/js/default/common/images/A055_014.png new file mode 100644 index 000000000..fb15a72ac Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_014.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_015.png b/jsapp/music/entry/src/main/js/default/common/images/A055_015.png new file mode 100644 index 000000000..c5ff8cbc4 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_015.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_016.png b/jsapp/music/entry/src/main/js/default/common/images/A055_016.png new file mode 100644 index 000000000..ab9b6350a Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_016.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_017.png b/jsapp/music/entry/src/main/js/default/common/images/A055_017.png new file mode 100644 index 000000000..d97e4c395 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_017.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_024.png b/jsapp/music/entry/src/main/js/default/common/images/A055_024.png new file mode 100644 index 000000000..e1d8e5ad7 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_024.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_047.png b/jsapp/music/entry/src/main/js/default/common/images/A055_047.png new file mode 100644 index 000000000..87566a5ea Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_047.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_050.png b/jsapp/music/entry/src/main/js/default/common/images/A055_050.png new file mode 100644 index 000000000..1fbb91e5d Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_050.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_051.png b/jsapp/music/entry/src/main/js/default/common/images/A055_051.png new file mode 100644 index 000000000..284ed8d67 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_051.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_060.png b/jsapp/music/entry/src/main/js/default/common/images/A055_060.png new file mode 100644 index 000000000..8667248fe Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_060.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_061.png b/jsapp/music/entry/src/main/js/default/common/images/A055_061.png new file mode 100644 index 000000000..87e0ac3aa Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_061.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_063.png b/jsapp/music/entry/src/main/js/default/common/images/A055_063.png new file mode 100644 index 000000000..15e68f0a7 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_063.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_064.png b/jsapp/music/entry/src/main/js/default/common/images/A055_064.png new file mode 100644 index 000000000..d0129ef7b Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_064.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_065.png b/jsapp/music/entry/src/main/js/default/common/images/A055_065.png new file mode 100644 index 000000000..22189f8a2 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_065.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_066.png b/jsapp/music/entry/src/main/js/default/common/images/A055_066.png new file mode 100644 index 000000000..c1bb02dc6 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_066.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/A055_067.png b/jsapp/music/entry/src/main/js/default/common/images/A055_067.png new file mode 100644 index 000000000..7f8a9f42a Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/A055_067.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/quit.png b/jsapp/music/entry/src/main/js/default/common/images/quit.png new file mode 100644 index 000000000..5190588d2 Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/quit.png differ diff --git a/jsapp/music/entry/src/main/js/default/common/images/xima_logo.png b/jsapp/music/entry/src/main/js/default/common/images/xima_logo.png new file mode 100644 index 000000000..00a1cc67a Binary files /dev/null and b/jsapp/music/entry/src/main/js/default/common/images/xima_logo.png differ diff --git a/jsapp/music/entry/src/main/js/default/i18n/en-US.json b/jsapp/music/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 000000000..e63c70d97 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/jsapp/music/entry/src/main/js/default/i18n/zh-CN.json b/jsapp/music/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 000000000..de6ee5748 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/jsapp/music/entry/src/main/js/default/pages/index/index.css b/jsapp/music/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 000000000..8e1829436 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,34 @@ +.stack { + width: 100%; + height: 100%; +} + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.logo_img { + width: 180px; + height: 180px; + border-radius: 90px; +} + +.logo_text { + margin-top: 15px; + width: 180px; + font-size: 40px; + text-align: center; +} + +.logo_mini { + margin-top: 5px; + letter-spacing: 4px; + width: 180px; + font-size: 16px; + text-align: center; +} diff --git a/jsapp/music/entry/src/main/js/default/pages/index/index.hml b/jsapp/music/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 000000000..efed5d665 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,7 @@ + +
+ + JS听书 + 每一天的精神食粮 +
+
diff --git a/jsapp/music/entry/src/main/js/default/pages/index/index.js b/jsapp/music/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 000000000..261f094a7 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,22 @@ +import app from '@system.app'; +import router from '@system.router'; + +export default { + data: {}, + onInit() { + }, + onShow() { + setTimeout(this.toNav, 2000) + }, + toNav() { + router.replace({ + uri: "pages/playlist/playlist" + }) + }, + swipeEvent(e) { + if (e.direction == "right") { + app.terminate() + console.log("Xima exit"); + } + }, +} \ No newline at end of file diff --git a/jsapp/music/entry/src/main/js/default/pages/play/play.css b/jsapp/music/entry/src/main/js/default/pages/play/play.css new file mode 100644 index 000000000..9e72a64af --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/play/play.css @@ -0,0 +1,149 @@ +.stack { + width: 100%; + height: 100%; +} + +.top_record { + left: 198px; + width: 256px; + height: 256px; +} + +.bottom_record { + top: 198px; + width: 256px; + height: 256px; +} + +.album_div { + width: 100%; + height: 120px; + align-items: center; + padding-top: 40px; + flex-direction: column; + background-color: transparent; +} + +.song_div { + width: 70%; + height: 37px; + background-color: transparent; +} + +.device_img { + width: 26px; + height: 37px; + background-color: transparent; +} + +.song_text { + font-size: 30px; + width: 100%; + text-align: center; + background-color: transparent; +} + +.singer_name { + font-size: 24px; + margin-top: 5px; + width: 60%; + height: 32px; + background-color: transparent; +} + +.play_stack { + width: 118px; + height: 118px; + left: 168px; + top: 168px; +} + +.play_img { + width: 118px; + height: 118px; +} + +.left_btn { + width: 78px; + height: 78px; + left: 40px; + top: 188px; +} + +.right_btn { + width: 78px; + height: 78px; + left: 336px; + top: 188px; +} + +.order_stack { + width: 48px; + height: 48px; + left: 100px; + top: 346px; + background-color: transparent; +} + +.order_img { + width: 48px; + height: 48px; + background-color: transparent; +} + +.volume_img { + width: 48px; + height: 48px; + left: 140px; + top: 346px; +} + +.settings_img { + width: 26px; + height: 37px; + left: 277px; + top: 351px; +} + +.progress { + center-x: 227px; + center-y: 227px; + width: 100%; + height: 100%; + start-angle: 120; + total-angle: -60; + stroke-width: 8px; + radius: 220px; + color: steelblue; + background-color: #333333; +} + +.volume_div { + width: 100%; + height: 100%; + align-items: center; + justify-content: center; + flex-direction: column; + background-color: black; +} + +.volume_div_2 { + width: 80%; + height: 60px; + border-radius: 30px; + align-items: center; + justify-content: center; + background-color: #2CFFFFFF; +} + +.hide_div { + width: 100%; + height: 197px; +} + +.volume_slider { + height: 20px; + width: 70%; + selected-color: steelblue; + color: aliceblue; +} \ No newline at end of file diff --git a/jsapp/music/entry/src/main/js/default/pages/play/play.hml b/jsapp/music/entry/src/main/js/default/pages/play/play.hml new file mode 100644 index 000000000..5d6fae9d8 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/play/play.hml @@ -0,0 +1,38 @@ + + + + + +
+
+ {{ curMusic.curMusicName }} +
+ {{ curMusic.singer }} +
+ + + + + + + + + + + + + + + + +
+
+
+
+ +
+
+
+
diff --git a/jsapp/music/entry/src/main/js/default/pages/play/play.js b/jsapp/music/entry/src/main/js/default/pages/play/play.js new file mode 100644 index 000000000..f4ef0dae9 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/play/play.js @@ -0,0 +1,161 @@ +import player from '@system.audio' +import router from '@system.router'; + +var timestamp = 0 +var lastVolume = 0 + +export default { + data: { + playStatus: 2, //0:play,1:pause,2:stop + duration: 0, + currentTime: 0, + curIndex: 0, + progress: 0, + showVolume: false, + canExit: true, + volume: 0, + musicList: [ + { + src: "/user/music/chun_feng_chu.mp3", + name: "运动听单", + singer: "今日畅听歌曲,春风吹 欢迎收听", + pathType: 0 // 0: system path, 1: inner path + }, + { + src: "resources/base/media/alarm.mp3", + name: "运动听单", + singer: "日本最神秘歌曲,Lemon 欢迎收听", + pathType: 1 + }, + { + src: "/user/music/lan_jing.mp3", + name: "运动听单", + singer: "今日畅听歌曲,化身孤岛的鲸 欢迎收听", + pathType: 0 + } + ], + curMusic: { //current music info + curMusicName: "", + singer: "", + }, + }, + onInit() { + this.curMusic.curMusicName = this.musicList[this.curIndex].name; + this.curMusic.singer = this.musicList[this.curIndex].singer; + //get music duration + player.onplay = () => { + console.log("MusicDemo onplay start"); + this.playStatus = 0; + }; + player.onended = () => { + console.log("MusicDemo onended start"); + this.playStatus = 2; + + // reset player + player.reset(); + + this.changeSong() + console.log("MusicDemo onended start"); + } + player.ontimeupdate = () => { + this.duration = player.duration; + this.currentTime = player.currentTime + console.info("MusicDemo dur:" + this.duration + ", cur:" + this.currentTime) + if (this.duration != 0) { + this.progress = this.currentTime * 100.0 / this.duration; + } else { + this.progress = 0; + } + } + }, + playMusic() { + console.info("MusicDemo getPlayState: " + this.playStatus) + if (this.playStatus == 1) { + player.play(); + this.playStatus = 0; + console.log("MusicDemo playMusic:play"); + return; + } else if (this.playStatus == 0) { + this.playImage = "common/ic_music_play.png"; + player.pause(); + this.playStatus = 1; + console.log("MusicDemo playMusic:pause"); + return; + } + + this.curMusic.curMusicName = this.musicList[this.curIndex].name; + this.curMusic.singer = this.musicList[this.curIndex].singer; + if (this.musicList[this.curIndex].pathType == 0) { + player.src = this.musicList[this.curIndex].src; + } else { + player.srcInner = this.musicList[this.curIndex].src; + } + player.play(); + this.playStatus = 0; + console.log("MusicDemo playMusic:play"); + }, + changeSong() { + console.log("MusicDemo ChangeSong:start"); + if (this.playStatus == 0 || this.playStatus == 1) { + this.playStatus = 2; + } + this.curIndex = (this.curIndex + 1) % 3; + + this.playMusic(); + console.log("MusicDemo ChangeSong:end"); + }, + stopPlay() { + console.log("stopPlay"); + player.onplay = null; + player.onended = null; + player.ontimeupdate = null; + }, + changeVolume(e) { + console.log("MusicDemo ChangeVolume: " + e.progress) + let temp_timestamp = new Date().getTime() + if (temp_timestamp - timestamp > 250) { + timestamp = temp_timestamp + player.volume = e.progress / 100.0 + } else { + lastVolume = e.progress / 100.0 + } + }, + swipeSliderVolume(e){ + player.volume = lastVolume + }, + showVolume() { + this.showVolume = true + this.canExit = false + this.volume = player.volume * 100 + }, + hideVolume() { + this.showVolume = false + setTimeout(this.setCanExit, 500) + }, + clickVolumeDiv() { + }, + setCanExit() { + this.canExit = true + }, + swipeQuitVolume(e) { + if (e.direction == "right") { + if (this.showVolume) { + this.hideVolume() + } + } + }, + swipeExit(e) { + if (e.direction == "right" && this.canExit) { + this.exitApp() + } + }, + exitApp() { + console.log("MusicDemo start back"); + player.reset(); + this.stopPlay(); + router.replace({ + uri: "pages/playlist/playlist" + }) + console.log("MusicDemo end back"); + }, +} diff --git a/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.css b/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.css new file mode 100644 index 000000000..3a7f1afb0 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.css @@ -0,0 +1,53 @@ +/* index.css */ +.container { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; + flex-direction: column; +} + +.todo-wrapper { + margin-top: 40px; + width: 100%; + height: 300px; +} + +.todo-item { + width: 100%; + height: 80px; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.item_divider { + height: 1px; + width: 70%; + background-color: #333333; +} + +.item_div_wrapper { + flex-direction: row; + align-items: center; + justify-content: center; + width: 70%; + height: 60px; +} + +.index-title { + margin-top: 20px; + width: 15%; + height: 40px; + font-size: 30px; + color: #666666; +} + +.todo-title { + margin-top: 20px; + width: 85%; + height: 40px; + text-overflow: ellipsis; + font-size: 30px; +} \ No newline at end of file diff --git a/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.hml b/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.hml new file mode 100644 index 000000000..f84e68edf --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.hml @@ -0,0 +1,15 @@ + +
+ + 运动听单 + + + +
+
+ {{ $item.index }} + {{ $item.singer }} +
+
+
+
diff --git a/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.js b/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.js new file mode 100644 index 000000000..137fce2b6 --- /dev/null +++ b/jsapp/music/entry/src/main/js/default/pages/playlist/playlist.js @@ -0,0 +1,46 @@ +import app from '@system.app'; +import router from '@system.router'; + +// index.js +export default { + data: { + musicList: [ + { + index: 1, + src: "/user/music/chun_feng_chu.mp3", + name: "运动听单", + singer: "今日畅听歌曲,春风吹 欢迎收听" + }, + { + index: 2, + src: "/user/music/alarm.mp3", + name: "运动听单", + singer: "日本最神秘歌曲,Lemon 欢迎收听" + }, + { + index: 3, + src: "/user/music/lan_jing.mp3", + name: "运动听单", + singer: "今日畅听歌曲,化身孤岛的鲸 欢迎收听" + } + ], + }, + goPlay(index) { + router.replace({ + uri: "pages/play/play", + params: { + curIndex: index - 1 + } + }) + }, + swipeExit(e) { + if (e.direction == "right") { + this.exitApp() + } + }, + exitApp() { + console.log("MusicDemo start exit"); + app.terminate(); + console.log("MusicDemo end exit"); + }, +} \ No newline at end of file diff --git a/jsapp/music/entry/src/main/resources/base/element/string.json b/jsapp/music/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..ddc776b12 --- /dev/null +++ b/jsapp/music/entry/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "JS听书" + } + ] +} diff --git a/jsapp/music/entry/src/main/resources/base/media/alarm.mp3 b/jsapp/music/entry/src/main/resources/base/media/alarm.mp3 new file mode 100644 index 000000000..06e0caaa1 Binary files /dev/null and b/jsapp/music/entry/src/main/resources/base/media/alarm.mp3 differ diff --git a/jsapp/music/entry/src/main/resources/base/media/icon.png b/jsapp/music/entry/src/main/resources/base/media/icon.png new file mode 100644 index 000000000..bfe7d71ff Binary files /dev/null and b/jsapp/music/entry/src/main/resources/base/media/icon.png differ diff --git a/jsapp/music/entry/src/main/resources/base/media/icon_small.png b/jsapp/music/entry/src/main/resources/base/media/icon_small.png new file mode 100644 index 000000000..e5cc3f378 Binary files /dev/null and b/jsapp/music/entry/src/main/resources/base/media/icon_small.png differ diff --git a/jsapp/music/gradle.properties b/jsapp/music/gradle.properties new file mode 100644 index 000000000..3966a047e --- /dev/null +++ b/jsapp/music/gradle.properties @@ -0,0 +1,13 @@ +# Project-wide Gradle settings. +# IDE (e.g. DevEco Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# If the Chinese output is garbled, please configure the following parameter. +# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false. +# more information see https://docs.gradle.org/current/userguide/performance.html +# org.gradle.parallel=false +# org.gradle.jvmargs=-Dfile.encoding=GBK \ No newline at end of file diff --git a/jsapp/music/gradle/wrapper/gradle-wrapper.jar b/jsapp/music/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..490fda857 Binary files /dev/null and b/jsapp/music/gradle/wrapper/gradle-wrapper.jar differ diff --git a/jsapp/music/gradle/wrapper/gradle-wrapper.properties b/jsapp/music/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..f59159e86 --- /dev/null +++ b/jsapp/music/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/jsapp/music/gradlew b/jsapp/music/gradlew new file mode 100644 index 000000000..536f0272d --- /dev/null +++ b/jsapp/music/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ]; do + ls=$(ls -ld "$PRG") + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '/.*' >/dev/null; then + PRG="$link" + else + PRG=$(dirname "$PRG")"/$link" + fi +done +SAVED="$(pwd)" +cd "$(dirname \"$PRG\")/" >/dev/null +APP_HOME="$(pwd -P)" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=$(basename "$0") + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn() { + echo "$*" +} + +die() { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$(uname)" in +CYGWIN*) + cygwin=true + ;; +Darwin*) + darwin=true + ;; +MINGW*) + msys=true + ;; +NONSTOP*) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ]; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then + MAX_FD_LIMIT=$(ulimit -H -n) + if [ $? -eq 0 ]; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ]; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ]; then + APP_HOME=$(cygpath --path --mixed "$APP_HOME") + CLASSPATH=$(cygpath --path --mixed "$CLASSPATH") + JAVACMD=$(cygpath --unix "$JAVACMD") + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null) + SEP="" + for dir in $ROOTDIRSRAW; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ]; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@"; do + CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -) + CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition + eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg") + else + eval $(echo args$i)="\"$arg\"" + fi + i=$(expr $i + 1) + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save() { + for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/jsapp/music/gradlew.bat b/jsapp/music/gradlew.bat new file mode 100644 index 000000000..62bd9b9cc --- /dev/null +++ b/jsapp/music/gradlew.bat @@ -0,0 +1,103 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jsapp/music/settings.gradle b/jsapp/music/settings.gradle new file mode 100644 index 000000000..28d595f2f --- /dev/null +++ b/jsapp/music/settings.gradle @@ -0,0 +1 @@ +include ':entry' diff --git a/patch_602_base_to_0521.txt b/patch_602_base_to_0521.txt new file mode 100644 index 000000000..28667eabe --- /dev/null +++ b/patch_602_base_to_0521.txt @@ -0,0 +1,87 @@ +【补丁名称】patch_602_base_to_0521 +【基础版本】b602 +【修复问题】 +BT合入内容 + 1、解决调用a2dp snk接口断开失败问题。 + 2、解决手表与android手机通过WRTM连接后取消配对后能搜到手表BT但是连接不上的问题。 + 3、客户需求:BT自动回连开关、BT回连接口。 + 4、解决BLE数传触发流控丢包后A核无感知的问题。 + 5、优化B核BLE GAP事件上报流程,解决断连事件上报慢的问题。 + 6、解决BLE GATT断连处理中内存泄漏问题。 + 7、解决BR回连失败问题。 + 8、优化GATT服务发现、写请求等阻塞流程,从死等优化成60s超时。 + 9、配置MTU默认值为23,解决ios mut更新失败兼容性问题。 + 10、客户需求合入:inquiry参数配置接口,可配置参数:设备类型、最大设备数量。 + 11、新增维测日志。 + 12、配合btc解决BLE数传和通话共存场景下通话卡顿问题,具体方案是:BT通话和BLE共存时,BT通话结束,连接参数恢复成原先的值。 + 13、解决ble地址变化时BLE write响应上报不成功问题。 + 14、增加默认广播数据名字长度限制。 + 15、解决BT回连过程中,BLE数传ipc error问题。 + 16、解决MMI扫描内存不足问题 + 17、解决BLE配置广播数据后未清理内存导致系统内存资源不足问题 + 18、新增BLE ANCS/AMS Client功能 +PLT合入内容 + 1、dfx维测增强,增加bt panic场景bt ram,bt trace,preserve信息。 + 2、A核到B核IPC消息判断B核深睡flag。 + 3、复位前保护,复位等待B核响应。 + 4、QSPI指针越界 + 5、解决屏幕概率显示黑线,增加gpu memretention配置 + 6、解决efuse写bit问题 + 7、SEC sha hash运算错误 + 8、适配2G NANDflash + 9、RTC定时问题 + 10、解决log dump重新配置狗超时 + 11、增加user target,默认开启离线日志 + 12、离线日志增加流控功能 + 13、优化windows编译路径长问题 + 14、nv配置区分user和eng版本,解决nv升级未生效问题 +GUI合入内容 + 1、支持蜂窝进入退出仿苹果动效 + 2、支持CoverFlow的松手惯性动效 + 3、支持Dump图片资源使用信息 + 4、优化视频页面截图以及跳转进入动效方案 + 5、解决图片资源加卸载过程中的内存异常问题 + 6、解决SVG解析失败问题 + 7、解决页面跳转崩溃问题 + 8、解决跑马灯因精度导致的抖动问题 + 9、解决触摸事件因不同页面控件地址相同导致的异常处理问题 + 10、关闭MapBuffer节省图形占用内存 + 11、解决弧形列表内存泄漏问题 + 12、解决UICrossView 已对齐时松手不上报ScrollEnd回调 + 13、预防通过UIView清除了其他焦点控件 + 14、修复内存分配时内存没对齐问题 + 15、修复问题:Text绘制应取交集,否则可能传超大区域导致VAU绘制报错 + 16、修复corssview UIMenuItem截图失败 +AUDIO&MEDIA合入内容 + 1、解决3A算法无法调参的问题 + 2、解决HSO命令行无法dump数据的问题,删去多余的realpath操作 + 3、支持使用seek的方式进行音视频的循环播放,提升性能 + 4、解决从本地音乐切换到蓝牙音乐频率不改变的问题 + 5、支持设置视频退出的同步和异步模式 +OHOS合入内容 + 1、支持音频资源文件打包到JS应用的需求 + 2、支持百度矢量地图,合入百度JSI接口的修改 + 3、解决自定义地图控件场景ref count反转导致挂死问题 +GPU合入内容: + 1、解决视频播放花屏问题以及低功耗时访问GPU寄存器问题 + 2、解决多线程场景下低功耗时GPU寄存器访问挂死问题 +NATIVE-JS sample合入内容 + 1、增加表盘管理 + 2、增加卡片管理 + 3、增加列表蜂窝切换 + 4、解决概率通话无声、耳机回连失败问题 +【修改影响】NA +【使用方法】 + 1、手动删除sdk_602版本以下文件: + code\sdk\application\wearable\nativeapp\nativeui\main\src\dial\parser\DialBinTypes.h + code\sdk\application\wearable\nativeapp\nativeui\main\src\dial\parser\DialBinParser.h + code\sdk\open_source\openharmony\third_party\jerryscript + 2、合入补丁内容到sdk_602版本目录 + 3、离线表盘工具、js开发配套工具存放在tools,视频表盘制作变更具体参考tools\dial_converter_tool\视频表盘制作变更.txt + 4、nativeapp新增资源存放在res目录 +【自测情况】 + 自验证范围: + 全功能冒烟 + 自验证target: + Native-js、target3 rc版本 +【是否合入版本】根据测试结果确定 \ No newline at end of file