From 4a8b00893579be094d4f14e8d062e757a25de5c4 Mon Sep 17 00:00:00 2001 From: yangxuguang-huawei Date: Tue, 1 Apr 2025 10:37:06 +0800 Subject: [PATCH] feat: add API to get launch params Signed-off-by: yangxuguang-huawei Change-Id: I6301e32042000d3f2e14745476a0c007d284fd67 --- .../ability_runtime/application_context.h | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/AbilityKit/ability_runtime/application_context.h b/AbilityKit/ability_runtime/application_context.h index bb39d5978..a19f5e28b 100644 --- a/AbilityKit/ability_runtime/application_context.h +++ b/AbilityKit/ability_runtime/application_context.h @@ -276,6 +276,40 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_StartSelfUIAbility(AbilityBase_Want * AbilityRuntime_ErrorCode OH_AbilityRuntime_StartSelfUIAbilityWithStartOptions(AbilityBase_Want *want, AbilityRuntime_StartOptions *options); +/** + * @brief Obtain the launch parameter of starting UIAbility. + * + * @param buffer A pointer to a buffer that receives the launch parameter of starting UIAbility. + * @param bufferSize The length of the buffer. + * @param writeLength The string length actually written to the buffer, + * when returning {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR}. + * @return The error code. + * {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful. + * {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the buffer or writeLength is null, + * or the buffer size is less than the minimum buffer size. + * {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist. + * @since 20 + */ +AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetLaunchParameter( + char* buffer, const int32_t bufferSize, int32_t* writeLength); + +/** + * @brief Obtain the latest parameter of starting UIAbility. + * + * @param buffer A pointer to a buffer that receives the latest parameter of starting UIAbility. + * @param bufferSize The length of the buffer. + * @param writeLength The string length actually written to the buffer, + * when returning {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR}. + * @return The error code. + * {@link ABILITY_RUNTIME_ERROR_CODE_NO_ERROR} if the operation is successful. + * {@link ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID} if the buffer or writeLength is null, + * or the buffer size is less than the minimum buffer size. + * {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist. + * @since 20 + */ +AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetLatestParameter( + char* buffer, const int32_t bufferSize, int32_t* writeLength); + #ifdef __cplusplus } // extern "C" #endif -- Gitee