From e4b58fdb818c904cf70998d3d74934e857aca4fc Mon Sep 17 00:00:00 2001 From: zhuhan <2281542033@qq.com> Date: Thu, 22 Aug 2024 21:59:54 +0800 Subject: [PATCH] resouce ndk Signed-off-by: zhuhan <2281542033@qq.com> Change-Id: I4408e08fb399c64aa7bdfa68978f51602970caee --- ability/ability_runtime/context/BUILD.gn | 27 ++++++ .../context/libcontext.ndk.json | 10 +++ .../ability_runtime/context/native_context.h | 88 +++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 ability/ability_runtime/context/BUILD.gn create mode 100644 ability/ability_runtime/context/libcontext.ndk.json create mode 100644 ability/ability_runtime/context/native_context.h diff --git a/ability/ability_runtime/context/BUILD.gn b/ability/ability_runtime/context/BUILD.gn new file mode 100644 index 000000000..09affcac3 --- /dev/null +++ b/ability/ability_runtime/context/BUILD.gn @@ -0,0 +1,27 @@ +# 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("context_header") { + dest_dir = "$ndk_headers_out_dir/AbilityKit" + sources = [ "./native_context.h" ] +} + +ohos_ndk_library("libnative_context_ndk") { + ndk_description_file = "./libcontext.ndk.json" + min_compact_version = "13" + output_name = "native_context_ndk" + output_extension = "so" +} diff --git a/ability/ability_runtime/context/libcontext.ndk.json b/ability/ability_runtime/context/libcontext.ndk.json new file mode 100644 index 000000000..7ee58a589 --- /dev/null +++ b/ability/ability_runtime/context/libcontext.ndk.json @@ -0,0 +1,10 @@ +[ + { + "first_introduced": "13", + "name": "OH_NativeAbility_Create_NapiEnv" + }, + { + "first_introduced": "13", + "name": "OH_NativeAbility_Destroy_NapiEnv" + } +] \ No newline at end of file diff --git a/ability/ability_runtime/context/native_context.h b/ability/ability_runtime/context/native_context.h new file mode 100644 index 000000000..ad466dfbd --- /dev/null +++ b/ability/ability_runtime/context/native_context.h @@ -0,0 +1,88 @@ +/* + * 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 Ability_Runtime + * @{ + * + * @brief Provides get resourcemanager interface. + + * + * @since 13 + * @version 1.0 + */ + +/** + * @file native_context.h + * + * @brief Declare interfaces for creating and destroying native resourceManager. + * + * @library libnative_context.z.so + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @since 13 + * @version 1.0 + */ +#ifndef ABILITY_ABILITY_RUNTIME_CONTEXT_NATIVE_CONTEXT_H +#define ABILITY_ABILITY_RUNTIME_CONTEXT_NATIVE_CONTEXT_H + +#include +#include "raw_file_manager.h" +#ifdef __cplusplus +extern "C" { +#endif + +struct NativeResourceManager; +/** + * @brief Bind native rresourceManager with system. + * + * @return Returns the pointer to {@link NativeResourceManager}. If failed returns nullptr. + * @since 12 + * @version 1.0 + */ +NativeResourceManager *OH_ApplicationContext_BindNativeResourceManager(); + +/** + * @brief Release native rresourceManager with system. + * + * @since 12 + * @version 1.0 + */ +void OH_ApplicationContext_ReleaseNativeResourceManager(NativeResourceManager *resMgr); + +/** + * @brief Create native rresourceManager with modulename. + * + * @param moduleName Indicates the moduleName. + * @return Returns the pointer to {@link NativeResourceManager}. If failed returns nullptr. + * @since 12 + * @version 1.0 + */ +NativeResourceManager *OH_ApplicationContext_CreateNativeResourceManager(char *moduleName); + +/** + * @brief Delete native rresourceManager. + * + * @param resMgr Indicates the pointer to {@link RawDir}. + * @return Returns the pointer to {@link NativeResourceManager}. If failed returns nullptr. + * @since 12 + * @version 1.0 + */ +void OH_ApplicationContext_DeleteNativeResourceManager(NativeResourceManager *resMgr); + +#ifdef __cplusplus +}; +#endif +/** @} */ +#endif // ABILITY_ABILITY_RUNTIME_RUNTIME_H \ No newline at end of file -- Gitee