diff --git a/AbilityKit/want/BUILD.gn b/AbilityKit/want/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..73b46b9e571ab26ac138ef8823042de1880404a2 --- /dev/null +++ b/AbilityKit/want/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("ability_runtime_want_ndk_header") { + dest_dir = "$ndk_headers_out_dir/AbilityKit/want" + sources = [ + "./cwant.h", + "./want_err_code.h", + ] +} + +ohos_ndk_library("libability_runtime_want") { + output_name = "ability_runtime_want" + output_extension = "so" + system_capability = "SystemCapability.Ability.AbilityRuntime.Core" + ndk_description_file = "./libability_runtime_want.json" + min_compact_version = "16" + system_capability_headers = [ + "AbilityKit/want/cwant.h", + "AbilityKit/want/want_err_code.h", + ] +} diff --git a/AbilityKit/want/cwant.h b/AbilityKit/want/cwant.h new file mode 100644 index 0000000000000000000000000000000000000000..ee91f707a7f0edaa109bf2dcc809de3260b44bfb --- /dev/null +++ b/AbilityKit/want/cwant.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup AbilityRuntime + * @{ + * + * @brief + * + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since + */ + +/** + * @file cwant.h + * + * @brief + * + * @library + * @kit AbilityKit + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since + */ + +#ifndef ABILITY_RUNTIME_WANT_H +#define ABILITY_RUNTIME_WANT_H + +#include +#include +#include +#include "want_err_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief + * @since + */ +typedef struct AbilityRuntime_Element { + /** Indicates the name of application. */ + char* bundleName; + /** Indicates the name of module. */ + char* moduleName; + /** Indicates the name of ability. */ + char* abilityName; +} AbilityRuntime_Element; + +struct AbilityRuntime_Want; +typedef struct AbilityRuntime_Want AbilityRuntime_Want; + +/** + * + */ +AbilityRuntime_Want* OH_AbilityRuntime_NewWant(AbilityRuntime_Element element); + +/** + * + */ +Want_ErrorCode OH_AbilityRuntime_DeleteWant(AbilityRuntime_Want* want); + +/** + * + */ +Want_ErrorCode OH_AbilityRuntime_SetWantElement(AbilityRuntime_Want* want, AbilityRuntime_Element element); + +/** + * + */ +Want_ErrorCode OH_AbilityRuntime_GetWantElement(AbilityRuntime_Want* want, AbilityRuntime_Element* element); + +/** + * + */ +Want_ErrorCode OH_AbilityRuntime_SetWantCharParam(AbilityRuntime_Want* want, const char* key, const char* value); + +/** + * + */ +Want_ErrorCode OH_AbilityRuntime_GetWantCharParam(AbilityRuntime_Want* want, const char* key, char* value, size_t valueSize); + +/** + * + */ +Want_ErrorCode OH_AbilityRuntime_AddWantFd(AbilityRuntime_Want* want, const char* key, int32_t fd); + +/** + * + */ +Want_ErrorCode OH_AbilityRuntime_GetWantFd(AbilityRuntime_Want* want, const char* key, int32_t* fd); + +#ifdef __cplusplus +} // extern "C" +#endif + +/** @} */ +#endif // ABILITY_RUNTIME_WANT_H diff --git a/AbilityKit/want/libability_runtime_want.json b/AbilityKit/want/libability_runtime_want.json new file mode 100644 index 0000000000000000000000000000000000000000..82a64b7ec4eefac7e5e7225c4ffb7dbada6e7669 --- /dev/null +++ b/AbilityKit/want/libability_runtime_want.json @@ -0,0 +1,34 @@ +[ + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_NewWant" + }, + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_DeleteWant" + }, + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_SetWantElement" + }, + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_GetWantElement" + }, + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_SetWantCharParam" + }, + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_GetWantCharParam" + }, + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_AddWantFd" + }, + { + "first_introduced": "16", + "name": "OH_AbilityRuntime_GetWantFd" + } +] \ No newline at end of file diff --git a/AbilityKit/want/want_err_code.h b/AbilityKit/want/want_err_code.h new file mode 100644 index 0000000000000000000000000000000000000000..f3d21cde6bf15c42bcd3ada3adba919cef61601c --- /dev/null +++ b/AbilityKit/want/want_err_code.h @@ -0,0 +1,65 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup AbilityRuntime + * @{ + * + * @brief + * + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since + */ + +/** + * @file want_err_code.h + * + * @brief + * + * + * @kit AbilityKit + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since + */ + +#ifndef ABILITY_RUNTIME_COMMON_H +#define ABILITY_RUNTIME_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes. + * + * @since 13 + */ +typedef enum { + /** @error No error. */ + WANT_ERROR_CODE_NO_ERROR = 0, + /** @error Invalid parameters. */ + WANT_ERROR_CODE_PARAM_INVALID = 401, + WANT_ERROR_CODE_CLOSE_FD_ERROR = 16000154, //TODO + WANT_ERROR_CODE_KEY_NOT_FOUND = 16000155, + WANT_ERROR_CODE_BUFFER_TOO_SMALL = 16000156, + +} Want_ErrorCode; + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif // ABILITY_RUNTIME_COMMON_H diff --git a/ndk_targets.gni b/ndk_targets.gni index a97312222ece249e3c91d5a1b38a53145dc3d2fb..c6fd1e36db939188e86395b300011444b74b7489 100644 --- a/ndk_targets.gni +++ b/ndk_targets.gni @@ -55,6 +55,8 @@ _ndk_library_targets = [ "//interface/sdk_c/ability/ability_runtime/child_process:libchild_process", "//interface/sdk_c/AbilityKit/ability_runtime:ability_runtime_ndk_header", "//interface/sdk_c/AbilityKit/ability_runtime:libability_runtime", + "//interface/sdk_c/AbilityKit/want:ability_runtime_want_ndk_header", + "//interface/sdk_c/AbilityKit/want:libability_runtime_want", "//interface/sdk_c/arkui/ace_engine/native:ace_header", "//interface/sdk_c/arkui/ace_engine/native:arkui_header", "//interface/sdk_c/arkui/ace_engine/native:libace_ndk",