From: luozheng <1732036298@qq.com> Date: Mon, 20 Apr 2026 08:02:14 +0000 (+0800) Subject: application文件夹下wstp文件夹1201patch合并提交 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=859e1238d06c1771877e2a31c8f4a39a9ffd07b5;p=mirrors%2FFD230.git application文件夹下wstp文件夹1201patch合并提交 --- 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 e1f654eba..5a61aad55 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 @@ -7,6 +7,8 @@ #if defined(__LITEOS__) #include "los_memory.h" #include "los_memory_pri.h" +#include "los_task_pri.h" +#include "los_swtmr_pri.h" #ifdef CFG_DRIVERS_MMC #include "soc/mmc.h" #endif @@ -443,36 +445,9 @@ uint32_t mcu_os_heap_info(uint8_t *para, uint32_t para_len) unused(para); unused(para_len); #if LOSCFG_MEM_TASK_STAT && defined __LITEOS__ - LosMemPoolInfo *heapMan = (LosMemPoolInfo*)OS_EXTEND_MEM_ADDR; - TSK_INFO_S task_info; - uint32_t taskId; - - wstp_print("\r\n"); OsMemInfoPrint(OS_EXTEND_MEM_ADDR); - wstp_print("\n\t\tstack name task id used size peak size\n"); - for (taskId = 0; taskId <= LOSCFG_BASE_CORE_TSK_LIMIT; taskId++) { - if (0 != LOS_TaskInfoGet(taskId, &task_info)) { - // 过滤掉无用的task id - continue; - } - wstp_print("%22s %-5d 0x%-8x 0x%-8x\n", task_info.acName, taskId, - heapMan->stat.taskMemstats[taskId].memUsed, heapMan->stat.taskMemstats[taskId].memPeak); - } - wstp_print("\r\n\r\n"); - - heapMan = (LosMemPoolInfo*)OS_SYS_MEM_ADDR; - OsMemInfoPrint(OS_SYS_MEM_ADDR); - wstp_print("\n\t\tstack name task id used size peak size\n"); - for (taskId = 0; taskId <= LOSCFG_BASE_CORE_TSK_LIMIT; taskId++) { - if (0 != LOS_TaskInfoGet(taskId, &task_info)) { - // 过滤掉无用的task id - continue; - } - wstp_print("%22s %-5d 0x%-8x 0x%-8x\n", task_info.acName, taskId, - heapMan->stat.taskMemstats[taskId].memUsed, heapMan->stat.taskMemstats[taskId].memPeak); - } wstp_print("\r\n"); - + OsMemInfoPrint(OS_SYS_MEM_ADDR); #endif #if defined __FREERTOS__ && defined FREERTOS_DEBUG freertos_heap_print(); @@ -485,27 +460,12 @@ uint32_t mcu_os_stack_info(uint8_t *para, uint32_t para_len) unused(para); unused(para_len); -#if LOSCFG_MEM_TASK_STAT && defined __LITEOS__ - TSK_INFO_S task_info; - uint32_t taskId; - uint32_t total_size = 0; - uint32_t used_size = 0; - uint32_t peak_size = 0; - - wstp_print("\n stack name task id prio status stack addr total size used size peak size percentage\n" - " -------------- ------- --- ------ --------- -------- -------- --------\n"); - for (taskId = 0; taskId <= LOSCFG_BASE_CORE_TSK_LIMIT; taskId++) { - if (0 != LOS_TaskInfoGet(taskId, &task_info)) { - continue; - } - wstp_print("%22s %-5d %-2d %-2d %-10p 0x%-8x 0x%-8x 0x%-8x %.02f\n", task_info.acName, - task_info.uwTaskID, task_info.usTaskPrio, task_info.usTaskStatus, task_info.uwTopOfStack, - task_info.uwStackSize, task_info.uwCurrUsed, task_info.uwPeakUsed, (task_info.uwCurrUsed*1.0f/task_info.uwStackSize)); - total_size += task_info.uwStackSize; - used_size += task_info.uwCurrUsed; - peak_size += task_info.uwPeakUsed; - } - wstp_print("\n total size(%d) used size(%d) peak size(%d)\n",total_size,used_size,peak_size); +#if LOSCFG_DEBUG_TASK && defined __LITEOS__ + (VOID)OsDbgTskInfoGet(OS_ALL_TASK_MASK); +#endif + +#if LOSCFG_DEBUG_SWTMR && defined __LITEOS__ + OsDbgSwtmrInfoGet(OS_ALL_SWTMR_MASK); #endif #if defined __FREERTOS__ && defined FREERTOS_DEBUG diff --git a/code/sdk/application/wstp/at_service/graphic/CMakeLists.txt b/code/sdk/application/wstp/at_service/graphic/CMakeLists.txt index 0e620ba11..59c9744aa 100644 --- a/code/sdk/application/wstp/at_service/graphic/CMakeLists.txt +++ b/code/sdk/application/wstp/at_service/graphic/CMakeLists.txt @@ -29,6 +29,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/lvgl/proprietary/include/dfx ${ROOT_DIR}/middleware/services/gpu/drv/include ${ROOT_DIR}/middleware/services/gpu/drv/dpu/dfx + ${ROOT_DIR}/open_source/mbedtls/mbedtls_v3.6.0/include ) set(PRIVATE_DEFINES diff --git a/code/sdk/application/wstp/at_service/graphic/graphic_at_process.c b/code/sdk/application/wstp/at_service/graphic/graphic_at_process.c index d5a214bb6..403f892b7 100644 --- a/code/sdk/application/wstp/at_service/graphic/graphic_at_process.c +++ b/code/sdk/application/wstp/at_service/graphic/graphic_at_process.c @@ -19,6 +19,7 @@ #include "common_def.h" #ifdef ENABLE_UIKIT #include "sample_ui.h" +#include "sample_util.h" #include "dfx/dfx_cmd.h" #endif #include "lcd_bus.h" @@ -127,8 +128,74 @@ static int32_t UikitSample(commu_inter_info_t* interInfo) g_sampleInitialized = true; return ERRCODE_SUCC; } + +static int32_t UikitSampleRun(commu_inter_info_t* interInfo) +{ + int32_t ret = ERRCODE_SUCC; + char *argv[GRAPHIC_MAX_PARAM_CNT]; + int32_t argc = 0; + ret = ConvertATParamToSampleParam(interInfo->payload, interInfo->payloadLength, &argc, argv); + if (ret != ERRCODE_SUCC) { + goto FREE; + } + if (argc != 1) { + PRINT("{%s():%d} invalid argc: %d(must be : 1).\r\n", __FUNCTION__, __LINE__, argc); + goto FREE; + } else { + if (!g_sampleInitialized) { + SampleUi(); + g_sampleInitialized = true; + } + + char* testcase = argv[0]; + PRINT("{%s():%d} SAMPLE [%s] START RUN. \n", __FUNCTION__, __LINE__, testcase); + StartCaseUi(testcase); + } + +FREE: + for (int32_t i = 0; i < argc; i++) { + if (argv[i] != NULL) { + BSP_MEM_FREE(argv[i]); + argv[i] = NULL; + } + } + return ret; +} + #endif +/******************************************************************************* + 功能描述 : 计算当前画面截图后文件的hash值,并打印出来。 + 参数内容 : 参数包含一个参数(key),打印在时一同输出。用于关联定位。 +*******************************************************************************/ +static int32_t UikitHashScreen(commu_inter_info_t* interInfo) +{ + int32_t ret = ERRCODE_SUCC; + char *argv[GRAPHIC_MAX_PARAM_CNT]; + int32_t argc = 0; + ret = ConvertATParamToSampleParam(interInfo->payload, interInfo->payloadLength, &argc, argv); + if (ret != ERRCODE_SUCC) { + goto FREE; + } + if (argc != 1) { + PRINT("{%s():%d} invalid argc: %d(must be : 1).\r\n", __FUNCTION__, __LINE__, argc); + goto FREE; + } else { + char* key = argv[0]; + CalcSampleUiHash(key); + } + + PRINT("{%s():%d} free args.\r\n", __FUNCTION__, __LINE__); +FREE: + for (int32_t i = 0; i < argc; i++) { + if (argv[i] != NULL) { + BSP_MEM_FREE(argv[i]); + argv[i] = NULL; + } + } + return ret; +} + static int32_t UikitDfx(commu_inter_info_t* interInfo) { int32_t ret = ERRCODE_SUCC; @@ -155,6 +222,8 @@ FREE: static const GraphicProcessType g_UikitFuncs[] = { #ifndef SUPPORT_NATIVE_UI { UIKIT_SAMPLE, UikitSample }, + { UIKIT_SAMPLE_RUN, UikitSampleRun }, + { UIKIT_SAMPLE_HASH, UikitHashScreen }, #endif { UIKIT_DFX, UikitDfx }, }; diff --git a/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h b/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h index e0ba960bd..4e2b60d50 100644 --- a/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h +++ b/code/sdk/application/wstp/at_service/graphic/graphic_at_process.h @@ -67,6 +67,8 @@ typedef enum { UIKIT_SAMPLE, UIKIT_DFX, UIKIT_MAX, + UIKIT_SAMPLE_RUN, + UIKIT_SAMPLE_HASH, } UikitCmd; typedef enum { diff --git a/code/sdk/application/wstp/at_service/graphic/graphic_cmd_manager.c b/code/sdk/application/wstp/at_service/graphic/graphic_cmd_manager.c index 6cbceaf78..5039f7c1a 100644 --- a/code/sdk/application/wstp/at_service/graphic/graphic_cmd_manager.c +++ b/code/sdk/application/wstp/at_service/graphic/graphic_cmd_manager.c @@ -28,6 +28,8 @@ static uint32_t MCGraphicATCmdHandle(uint8_t *para, uint32_t paraLen, char* strC static const at_cmd_table_t g_graphic_cmd[] = { { "AT^UIKIT_SAMPLE", MCGraphicATCmdHandle, "00 00 00 00" }, { "AT^UIKIT_DFX", MCGraphicATCmdHandle, "00 01 00 00" }, + { "AT^UIKIT_SAMPLE_RUN", MCGraphicATCmdHandle, "00 03 00 00" }, + { "AT^UIKIT_SAMPLE_HASH", MCGraphicATCmdHandle, "00 04 00 00" }, { "AT^GUI_SET_FREQ", MCGraphicATCmdHandle, "01 00 00 00" }, { "AT^LVGL_SAMPLE", MCGraphicATCmdHandle, "02 00 00 00" }, { "AT^LVGL_DFX", MCGraphicATCmdHandle, "02 01 00 00" }, diff --git a/code/sdk/application/wstp/at_service/graphic/graphic_rx_process.c b/code/sdk/application/wstp/at_service/graphic/graphic_rx_process.c index 78d29ce72..5b9983132 100644 --- a/code/sdk/application/wstp/at_service/graphic/graphic_rx_process.c +++ b/code/sdk/application/wstp/at_service/graphic/graphic_rx_process.c @@ -20,7 +20,7 @@ void graphic_at_task_init(void) { -#ifdef ENABLE_UIKIT +#if defined(ENABLE_UIKIT) && !defined(SUPPORT_OHOSFWK) InitGraphicService(); #endif diff --git a/code/sdk/application/wstp/at_service/media/media_at_process.c b/code/sdk/application/wstp/at_service/media/media_at_process.c index 1bbe78d8a..a1f33ca8a 100644 --- a/code/sdk/application/wstp/at_service/media/media_at_process.c +++ b/code/sdk/application/wstp/at_service/media/media_at_process.c @@ -22,6 +22,9 @@ #include "camera_preview_sample_wrapper.h" #include "voice_call_volte_sample_wrapper.h" #include "audio_player_test.h" +#ifndef MEMORY_MINI +#include "audio_recorder_sample.h" +#endif #endif #include "app_at_process.h" #include "app_msg_manager.h" @@ -783,7 +786,7 @@ static int32_t MediaVideoPlayMute(const uint8_t *data, uint32_t dataLen) static int32_t MediaCameraPreviewStart(const uint8_t *data, uint32_t dataLen) { wstp_print("{%s():%d} func in.\r\n", __FUNCTION__, __LINE__); - int32_t ret = ERRCODE_SUCC; + int32_t ret = ERRCODE_FAIL; #ifdef ENABLE_UIKIT int32_t argc = 0; uint8_t *argv[MEDIA_MAX_PARAM_CNT]; @@ -833,7 +836,7 @@ static int32_t MediaVoiceCallVolteHandle(const uint8_t *data, uint32_t dataLen) { wstp_print("{%s():%d} func in.\r\n", __FUNCTION__, __LINE__); - int32_t ret; + int32_t ret = ERRCODE_FAIL; int32_t argc = 0; uint8_t *argv[MEDIA_MAX_PARAM_CNT]; @@ -842,7 +845,7 @@ static int32_t MediaVoiceCallVolteHandle(const uint8_t *data, uint32_t dataLen) goto FREE; } - VoiceCallVolteSample(argc, (const char **)&argv); + ret = VoiceCallVolteSample(argc, (const char **)&argv); FREE: for (int32_t i = 0; i < argc; i++) { @@ -853,7 +856,7 @@ FREE: } wstp_print("{%s():%d} func out success.\r\n", __FUNCTION__, __LINE__); - return ERRCODE_SUCC; + return ret; } #endif @@ -861,7 +864,7 @@ static int32_t MediaA2dpSinkAef(const uint8_t *data, uint32_t dataLen) { wstp_print("{%s():%d} func in.\r\n", __FUNCTION__, __LINE__); - int32_t ret; + int32_t ret = ERRCODE_FAIL; int32_t argc = 0; uint8_t *argv[MEDIA_MAX_PARAM_CNT]; @@ -893,6 +896,33 @@ FREE: return ret; } +#ifndef MEMORY_MINI +static int32_t MediaAudioRecorder(const uint8_t *data, uint32_t dataLen) +{ + wstp_print("{%s():%d} func in.\r\n", __FUNCTION__, __LINE__); + + int32_t ret = ERRCODE_FAIL; + int32_t argc = 0; + uint8_t *argv[MEDIA_MAX_PARAM_CNT]; + + ret = ConvertCmdParamToSampleParam(data, dataLen, &argc, argv); + if (ret != ERRCODE_SUCC) { + goto FREE; + } + ret = AudioRecorderSample(argc, (const char **)&argv); +FREE: + for (int32_t i = 0; i < argc; i++) { + if (argv[i] != NULL) { + BSP_MEM_FREE(argv[i]); + argv[i] = NULL; + } + } + + wstp_print("{%s():%d} func out success.\r\n", __FUNCTION__, __LINE__); + return ret; +} +#endif + #ifndef MEMORY_MINI static const MediaProcessType g_mediaAudioRecordFuncs[] = { { MEDIA_AUDIO_RECORD_START, MediaAudioRecordStart }, @@ -929,6 +959,10 @@ static const MediaProcessType g_mediaCameraPreviewFuncs[] = { static const MediaProcessType g_mediaVoiceCallVolteFuncs[] = { { MEDIA_VOICE_CALL_VOLTE_HANDLE, MediaVoiceCallVolteHandle }, }; + +static const MediaProcessType g_mediaAudioRecorderFuncs[] = { + { MEDIA_AUDIO_RECORDER_CMD, MediaAudioRecorder }, +}; #endif static const MediaProcessType g_mediaA2dpSinkFuncs[] = { @@ -1043,6 +1077,25 @@ static int32_t MediaVoiceCallVolteProcess(const uint8_t *data, uint32_t dataLen) wstp_print("{%s():%d} func out %s.\r\n", __FUNCTION__, __LINE__, (ret == ERRCODE_SUCC) ? "success" : "failure"); return ret; } + +static int32_t MediaAudioRecorderProcess(const uint8_t *data, uint32_t dataLen) +{ + wstp_print("{%s():%d} func in.\r\n", __FUNCTION__, __LINE__); + + int32_t ret = ERRCODE_FAIL; + + uint8_t videoCmd = data[MEDIA_SUB_CMD_POS]; + wstp_print("{%s():%d} audio recorder cmd: %d.\r\n", __FUNCTION__, __LINE__, videoCmd); + + for (uint8_t i = 0; i < ARRAY_COUNT(g_mediaAudioRecorderFuncs); i++) { + if (videoCmd == g_mediaAudioRecorderFuncs[i].id) { + ret = g_mediaAudioRecorderFuncs[i].func(data, dataLen); + } + } + + wstp_print("{%s():%d} func out %s.\r\n", __FUNCTION__, __LINE__, (ret == ERRCODE_SUCC) ? "success" : "failure"); + return ret; +} #endif static int32_t MediaA2dpSinkProcess(const uint8_t *data, uint32_t dataLen) @@ -1072,6 +1125,7 @@ static const MediaProcessType g_mediaAudioFuncs[] = { { MEDIA_VIDEO_PLAY, MediaVideoPlayProcess }, { MEDIA_CAMERA_PREVIEW, MediaCameraPreviewProcess }, { MEDIA_VOICE_CALL_VOLTE, MediaVoiceCallVolteProcess }, + { MEDIA_AUDIO_RECORDER, MediaAudioRecorderProcess }, #endif { MEDIA_A2DP_SINK, MediaA2dpSinkProcess }, }; diff --git a/code/sdk/application/wstp/at_service/media/media_at_process.h b/code/sdk/application/wstp/at_service/media/media_at_process.h index 8903d70ea..f13c75ad2 100644 --- a/code/sdk/application/wstp/at_service/media/media_at_process.h +++ b/code/sdk/application/wstp/at_service/media/media_at_process.h @@ -32,6 +32,7 @@ typedef enum { MEDIA_CAMERA_PREVIEW, MEDIA_VOICE_CALL_VOLTE, MEDIA_A2DP_SINK, + MEDIA_AUDIO_RECORDER, MEDIA_AUDIO_CMD_MAX, } MediaAudioCmd; @@ -105,6 +106,10 @@ typedef enum { MEDIA_A2DP_SINK_AEF, // 00 } MediaA2dpSinkCmd; +typedef enum { + MEDIA_AUDIO_RECORDER_CMD, // 00 +} MediaAudioRecorderCmd; + void media_at_process(const uint8_t *data, uint32_t dataLen); uint32_t media_diag_cmd_process(diag_ser_data_t *data); diff --git a/code/sdk/application/wstp/at_service/media/media_cmd_manager.c b/code/sdk/application/wstp/at_service/media/media_cmd_manager.c index f6c727b1d..de4dfe508 100644 --- a/code/sdk/application/wstp/at_service/media/media_cmd_manager.c +++ b/code/sdk/application/wstp/at_service/media/media_cmd_manager.c @@ -142,6 +142,9 @@ static const at_cmd_table_t g_media_cmd[] = { { "AT^MEDIAVOICECALLVOLTE", MCMediaATCmdHandle, "05 00" }, #endif { "AT^MEDIA2DPSINKAEF", MCMediaATCmdHandle, "06 00" }, +#ifndef MEMORY_MINI + { "AT^AUDIORECORDER", MCMediaATCmdHandle, "07 00" }, +#endif }; at_cmd_table_t *get_media_cmd_table(uint32_t *cmd_count) diff --git a/code/sdk/application/wstp/at_service/ohosfwk/CMakeLists.txt b/code/sdk/application/wstp/at_service/ohosfwk/CMakeLists.txt index c18054782..1bb212c36 100644 --- a/code/sdk/application/wstp/at_service/ohosfwk/CMakeLists.txt +++ b/code/sdk/application/wstp/at_service/ohosfwk/CMakeLists.txt @@ -22,6 +22,8 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/services/bundlemgr_lite/include ${ROOT_DIR}/open_source/openharmony/base/sensors/location/sample ${ROOT_DIR}/open_source/openharmony/base/sensors/sample + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/include + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits/animator ) set(PRIVATE_DEFINES diff --git a/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp b/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp index baf1d3862..7ccf44807 100644 --- a/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp +++ b/code/sdk/application/wstp/at_service/ohosfwk/ohosfwk_at_process.cpp @@ -7,6 +7,8 @@ * 2022-11-17, Create file. \n */ #include "stdlib.h" +#include "sys/time.h" +#include "time.h" #include "common_def.h" #include "wearable_log.h" #include "ohosfwk_at_process.h" @@ -30,6 +32,7 @@ #include "applist/ApplistModel.h" #endif #include "bundle_manager.h" +#include "js_ability.h" #include #ifdef SUPPORT_AT_LOCATION #include "location_sample.h" @@ -38,15 +41,35 @@ #ifdef SUPPORT_AT_SENSOR #include "sensor_sample.h" #endif +#include "monkey/MonkeyModel.h" #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0])) -#define OHOSFWK_MAX_ARGC 8 -#define OHOSFWK_MAX_ARGV_LEN 64 +#define OHOSFWK_MAX_ARGC 8 +#define OHOSFWK_MAX_ARGV_LEN 64 -#define OHOSFWK_SUCCESS 0 -#define OHOSFWK_FAILED (-1) +#define OHOSFWK_SUCCESS 0 +#define OHOSFWK_FAILED (-1) #define MAX_PAGE 100 #define ARGC_NUM 2 +#define DEFAULT_TIME_ZONE (8 * 60) +#define MINUTES_PER_HOUR 60 +#define SECONDS_PER_MINUTE 60 +#define USEC_TO_MILLI 1000 +#define TIME_MAX 64 +#define DECIMAL 10 +#define TIME_YEAR_OFFSET 70 +#define MIN_TIMEZONE_OFFSET (-12 * 60) +#define MAX_TIMEZONE_OFFSET (12 * 60) + +enum { + UNDEFINED_STATE = -1, + INIT_STATE, // 0 + READY_STATE, + SHOW_STATE, + BACKGROUND_STATE, + DESTROY_STATE, + END_STATE +}; static void ReceiveCallback(const uint8_t resultCode, const void *resultMessage) { @@ -73,8 +96,8 @@ static void ReceiveCallback(const uint8_t resultCode, const void *resultMessage) AdapterFree(installMsg); } -static int ConvertCmdToParam( - uint8_t *para, uint32_t paraLen, uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN], uint32_t *argc) +static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN], uint32_t* argc) { uint32_t pos = 0; *argc = 0; @@ -115,6 +138,76 @@ static uint32_t OhosfwkATCmdAmExitJsApp(uint8_t *para, uint32_t paraLen, char *s return ERRCODE_SUCC; } +static const char *StateInfoToString(int8_t pageInfo) +{ + switch (pageInfo) { + case UNDEFINED_STATE: + return "-1 - UNDEFINED_STATE"; + case INIT_STATE: + return "0 - INIT_STATE"; + case READY_STATE: + return "1 - READY_STATE"; + case SHOW_STATE: + return "2 - SHOW_STATE"; + case BACKGROUND_STATE: + return "3 - BACKGROUND_STATE"; + case DESTROY_STATE: + return "4 - DESTROY_STATE"; + case END_STATE: + return "5 - END_STATE"; + default: + return "Can not get state!"; + } +} + +static uint32_t OhosfwkATCmdAmDfx(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + unused(strCommonCmd); + + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; + uint32_t argc = 0; + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != OHOSFWK_SUCCESS) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OHOSFWK ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + char *info = reinterpret_cast(argv[0]); + if (info == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "failed to get info!\n"); + return ERRCODE_FAIL; + } + + if (strcmp(info, "dump") == 0) { + ElementName *elementName = OHOS::AbilityMsClient::GetInstance().GetTopAbility(); + if (elementName == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "failed to get elementName!\n"); + return ERRCODE_FAIL; + } + if (elementName->bundleName == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "failed to get bundleName!\n"); + return ERRCODE_FAIL; + } + char *currentBundleName = elementName->bundleName; + + BundleInfo bundleInfo; + ret = OHOS::BundleMsClient::GetInstance().GetBundleInfo(currentBundleName, 0, &bundleInfo); + if (ret != OHOSFWK_SUCCESS) { + PRINTK("Native App: %s\n", currentBundleName); + PRINTK("Can not provide BundleInfo\n"); + return ERRCODE_SUCC; + } + int8_t pageInfo = OHOS::ACELite::GetJsPageStateInfo(); + const char *pageInfoLog = StateInfoToString(pageInfo); + PRINTK("-------------PageState-------------\n"); + PRINTK("label: %s\n", bundleInfo.label); + PRINTK("bundleName: %s\n", bundleInfo.bundleName); + PRINTK("pageState: %s\n", pageInfoLog); + PRINTK("-----------PageState End-----------\n"); + } + return ERRCODE_SUCC; +} + static uint32_t OhosfwkATCmdBmInstall(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); @@ -232,7 +325,7 @@ static uint32_t OhosfwkATCmdAmStartJsApp(uint8_t *para, uint32_t paraLen, char * return ERRCODE_FAIL; } - if (argc != 1) { + if (argc > 2 || argc <= 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OHOSFWK ATCMD Set Parameter Failed\n"); return ERRCODE_FAIL; } @@ -244,7 +337,11 @@ static uint32_t OhosfwkATCmdAmStartJsApp(uint8_t *para, uint32_t paraLen, char * startElement.bundleName = (char *)argv[0]; startElement.deviceId = nullptr; SetWantElement(want, startElement); - StartAbility(want); + if (argc == 2 && strcmp("NoAnimation", (char *)argv[1]) == 0) { + StartAbility(want); + } else { + StartAbilityWithAnimation(want, static_cast(1), true); + } ClearWant(want); delete want; return ERRCODE_SUCC; @@ -517,6 +614,7 @@ static uint32_t OhosfwkATCmdSensor(uint8_t *para, uint32_t paraLen, char *strCom } #endif +#ifdef CONFIG_NATIVEAPP_TEST static uint32_t OhosfwkATSwitchSlicePage(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); @@ -548,6 +646,195 @@ static uint32_t OhosfwkATSwitchSlicePage(uint8_t *para, uint32_t paraLen, char * return ERRCODE_SUCC; } +static uint32_t OhosATMonkeyControl(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + unused(strCommonCmd); + uint8_t argv[OHOSFWK_MAX_ARGC][OHOSFWK_MAX_ARGV_LEN] = {0}; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != OHOSFWK_SUCCESS) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OhosATMonkeyControl ATCMD Convert Command Failed"); + return ERRCODE_FAIL; + } + if (argc != 1) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OhosATMonkeyControl ATCMD Set Parameter Failed"); + return ERRCODE_FAIL; + } + + char *monkeyStr = (char *)argv[0]; + uint32_t monkeyControl = atoi(monkeyStr); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "OhosATMonkeyControl(),monkeyControl = %[d]", monkeyControl); + OHOS::MonkeyModel::GetInstance().SetStart(monkeyControl); + return ERRCODE_SUCC; +} +#endif + +static int32_t GetLocalTimezone(void) +{ + struct tm localTime; + struct tm gmtTime; + struct timeval tv = { 0, 0 }; + + if (gettimeofday(&tv, NULL)) { + return 0; + } + + localtime_r(&tv.tv_sec, &localTime); + gmtime_r(&tv.tv_sec, &gmtTime); + + return (localTime.tm_hour - gmtTime.tm_hour) * MINUTES_PER_HOUR + (localTime.tm_min - gmtTime.tm_min); +} + +static uint32_t GetTimeZone(char *time) +{ + char *ptr = time; + char *tmp; + const char* utcStr = "UTC"; + size_t utcStrLen = strlen(utcStr); + + // 判断是否配置时区 + tmp = strchr(ptr, ' '); + if (tmp == NULL) { + return DEFAULT_TIME_ZONE; // 未配置时区默认为UTC+8:00 + } + *tmp = '\0'; + ptr = tmp + 1; + if (strncmp(ptr, utcStr, utcStrLen) != 0) { + return DEFAULT_TIME_ZONE; + } + ptr += utcStrLen; + + // 时 + tmp = strchr(ptr, ':'); + if (tmp == NULL) { return 0; } + *tmp = '\0'; + int hour = strtol(ptr, NULL, DECIMAL); + ptr = tmp + 1; + + // 分 + int min = strtol(ptr, NULL, DECIMAL); + int offsetMin = hour * MINUTES_PER_HOUR + min; + if (offsetMin < MIN_TIMEZONE_OFFSET || offsetMin > MAX_TIMEZONE_OFFSET) { + return DEFAULT_TIME_ZONE; + } + return offsetMin; +} + +static uint32_t GetSecTime(uint8_t *time, struct timezone *tz) +{ + uint32_t sec; + struct tm tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; + char *ptr = (char *)time; + char *tmp; + + // å¹´ + tmp = strchr(ptr, '-'); + if (tmp == NULL) { return 0; } + *tmp = '\0'; + // 年的计算需要减去1900 + tm.tm_year = strtol(ptr, NULL, DECIMAL) - 1900; + if (tm.tm_year < TIME_YEAR_OFFSET) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OhosfwkATCmdTimezoneSet year num must bigger than 1970!"); + return 0; + } + ptr = tmp + 1; + + // 月 + tmp = strchr(ptr, '-'); + if (tmp == NULL) { return 0; } + *tmp = '\0'; + // 月的计算需要减1 + tm.tm_mon = strtol(ptr, NULL, DECIMAL) - 1; + ptr = tmp + 1; + + // 日 + tmp = strchr(ptr, ' '); + if (tmp == NULL) { return 0; } + *tmp = '\0'; + tm.tm_mday = strtol(ptr, NULL, DECIMAL); + ptr = tmp + 1; + + // 时 + tmp = strchr(ptr, ':'); + if (tmp == NULL) { return 0; } + *tmp = '\0'; + tm.tm_hour = strtol(ptr, NULL, DECIMAL); + ptr = tmp + 1; + + // 分 + tmp = strchr(ptr, ':'); + if (tmp == NULL) { return 0; } + *tmp = '\0'; + tm.tm_min = strtol(ptr, NULL, DECIMAL); + ptr = tmp + 1; + + // 秒 + tm.tm_sec = strtol(ptr, NULL, DECIMAL); + sec = (uint32_t)mktime(&tm); + + // 时区 + tz->tz_minuteswest = GetTimeZone(ptr); + + return sec; +} + +static uint32_t OhosfwkATCmdTimezoneSet(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + unused(strCommonCmd); + unused(paraLen); + + struct timeval tv = { 0, 0 }; + struct timezone tz = { 0, 0 }; + tv.tv_sec = GetSecTime(para, &tz); + int32_t localTimeZone = GetLocalTimezone(); + + tv.tv_sec = tv.tv_sec + localTimeZone * SECONDS_PER_MINUTE - (tz.tz_minuteswest * SECONDS_PER_MINUTE); + if (tv.tv_sec == 0) { + return ERRCODE_FAIL; + } else if (tv.tv_sec <= (tz.tz_minuteswest * SECONDS_PER_MINUTE)) { + tv.tv_sec = 0; + } + + settimeofday(&tv, &tz); + return ERRCODE_SUCC; +} + +static uint32_t OhosfwkATCmdTimezoneGet(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + unused(strCommonCmd); + unused(para); + unused(paraLen); + char timebuf[TIME_MAX] = { 0 }; + struct tm tm; + struct timeval tv = { 0, 0 }; + const char* formatStr = " %F %T"; + + if (gettimeofday(&tv, NULL)) { + return ERRCODE_FAIL; + } + + // 计算本地时间 + localtime_r(&tv.tv_sec, &tm); + uint32_t millisec = tv.tv_usec / USEC_TO_MILLI; + strftime(timebuf, TIME_MAX - 1, formatStr + 1, &tm); + + // 计算时区 + int32_t localTimeZone = GetLocalTimezone(); + int32_t offsetMin = localTimeZone % MINUTES_PER_HOUR; + offsetMin = offsetMin < 0 ? offsetMin + MINUTES_PER_HOUR : offsetMin; + int32_t offsetHour = localTimeZone / MINUTES_PER_HOUR; + offsetHour = localTimeZone < 0 && offsetMin != 0 ? offsetHour - 1 : offsetHour; + + if (localTimeZone >= 0) { + PRINTK("%s:%03d UTC+%d:%02d", timebuf, millisec, offsetHour, offsetMin); + } else { + PRINTK("%s:%03d UTC%d:%02d", timebuf, millisec, offsetHour, offsetMin); + } + + return ERRCODE_SUCC; +} + static const at_cmd_table_t g_ohosfwk_cmd[] = { {(char *)"AT^OHOSFWK_AM_EXIT_JSAPP", OhosfwkATCmdAmExitJsApp, (char *)"00 00 00 00"}, {(char *)"AT^OHOSFWK_BM_INSTALL", OhosfwkATCmdBmInstall, (char *)"00 00 00 01"}, @@ -559,14 +846,20 @@ static const at_cmd_table_t g_ohosfwk_cmd[] = { {(char *)"AT^OHOSFWK_CHANGE_LANGUAGE", OhosfwkATCmdChangeLanguage, (char *)"00 00 00 07"}, {(char *)"AT^OHOSFWK_BM_GET_APPINFO", OhosfwkATCmdBmGetAppInfo, (char *)"00 00 00 10"}, {(char *)"AT^OHOSFWK_BM_GET_APPLIST", OhosfwkATCmdBmGetAppList, (char *)"00 00 00 11"}, - {(char *)"AT^OHOSFWK_MSG_START_NOTIFY", OhosfwkATStartNotify, (char *)"00 00 00 12"}, + {(char *)"AT^OHOSFWK_AM_DFX", OhosfwkATCmdAmDfx, (char *)"00 00 00 12" }, + {(char *)"AT^OHOSFWK_MSG_START_NOTIFY", OhosfwkATStartNotify, (char *)"00 00 00 13"}, #ifdef SUPPORT_AT_LOCATION {(char *)"AT^OHOSFWK_LOCATION", OhosfwkATCmdLocation, (char *)"00 00 00 08"}, #endif #ifdef SUPPORT_AT_SENSOR {(char *)"AT^OHOSFWK_SENSOR", OhosfwkATCmdSensor, (char *)"00 00 00 09"}, #endif +#ifdef CONFIG_NATIVEAPP_TEST {(char *)"AT^SWITCH_SLICE_PAGE", OhosfwkATSwitchSlicePage, (char *)"00 00 00 13"}, // 界面切换AT指令方便测试使用; + {(char *)"AT^_MONKEY_CONTROL", OhosATMonkeyControl, (char *)"00 00 00 14"}, // Monkey 开关 +#endif + {(char *)"AT^OHOSFWK_GLOBAL_TIMEZONE_SET", OhosfwkATCmdTimezoneSet, (char *)"00 00 00 15"}, + {(char *)"AT^OHOSFWK_GLOBAL_TIMEZONE_GET", OhosfwkATCmdTimezoneGet, (char *)"00 00 00 16"}, }; at_cmd_table_t *get_ohosfwk_cmd_table(uint32_t *cmd_count)