!1452 【挑单5.0.1release】applicationContext新增ndk接口

Merge pull request !1452 from yangzk/OpenHarmony-5.0.1-Release
This commit is contained in:
openharmony_ci 2024-09-20 08:44:55 +00:00 committed by Gitee
commit 3263b8f011
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 295 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# 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_ndk_header") {
dest_dir = "$ndk_headers_out_dir/AbilityKit/ability_runtime"
sources = [
"./ability_runtime_common.h",
"./application_context.h",
"./context_constant.h",
]
}
ohos_ndk_library("libability_runtime") {
output_name = "ability_runtime"
output_extension = "so"
system_capability = "SystemCapability.Ability.AbilityRuntime.Core"
ndk_description_file = "./libability_runtime.ndk.json"
min_compact_version = "13"
system_capability_headers = [
"AbilityKit/ability_runtime/ability_runtime_common.h",
"AbilityKit/ability_runtime/application_context.h",
"AbilityKit/ability_runtime/context_constant.h",
]
}

View File

@ -0,0 +1,63 @@
/*
* 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 Provide the definition of the C interface for the native AbilityRuntime
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 13
*/
/**
* @file ability_runtime_common.h
*
* @brief Declare the common types for the native AbilityRuntime.
*
* @library libability_runtime.so
* @kit AbilityKit
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 13
*/
#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. */
ABILITY_RUNTIME_ERROR_CODE_NO_ERROR = 0,
/** @error Invalid parameters. */
ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID = 401,
/** @error The context does not exist. */
ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST = 16000011,
} AbilityRuntime_ErrorCode;
#ifdef __cplusplus
}
#endif
/** @} */
#endif // ABILITY_RUNTIME_COMMON_H

View File

@ -0,0 +1,100 @@
/*
* 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 Describe the functions provided by the application context.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 13
*/
/**
* @file application_context.h
*
* @brief Defines the application context APIs.
*
* @library libability_runtime.so
* @kit AbilityKit
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 13
*/
#ifndef ABILITY_RUNTIME_APPLICATION_CONTEXT_H
#define ABILITY_RUNTIME_APPLICATION_CONTEXT_H
#include <stdint.h>
#include <stddef.h>
#include "ability_runtime_common.h"
#include "context_constant.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Obtain the cache directory of the application.
*
* @param buffer A pointer to a buffer that receives the cache directory of the application.
* @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 13
*/
AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetCacheDir(
char* buffer, int32_t bufferSize, int32_t* writeLength);
/**
* @brief Obtain the area mode of the application.
*
* @param areaMode A pointer to the area mode.
* @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 areaMode is null.
* {@link ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST} if the application context does not exist.
* @since 13
*/
AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetAreaMode(AbilityRuntime_AreaMode* areaMode);
/**
* @brief Obtain the bundle name.
*
* @param buffer A pointer to a buffer that receives the bundle name.
* @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 13
*/
AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetBundleName(
char* buffer, int32_t bufferSize, int32_t* writeLength);
#ifdef __cplusplus
} // extern "C"
#endif
/** @} */
#endif // ABILITY_RUNTIME_APPLICATION_CONTEXT_H

View File

@ -0,0 +1,82 @@
/*
* 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 Describe the constant of context.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 13
*/
/**
* @file context_constant.h
*
* @brief Defines the constant of context.
*
* @library libability_runtime.so
* @kit AbilityKit
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 13
*/
#ifndef ABILITY_RUNTIME_CONTEXT_CONSTANT_H
#define ABILITY_RUNTIME_CONTEXT_CONSTANT_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief File area mode.
*
* @since 13
*/
typedef enum {
/**
* System level device encryption area.
*/
ABILITY_RUNTIME_AREA_MODE_EL1 = 0,
/**
* User credential encryption area.
*/
ABILITY_RUNTIME_AREA_MODE_EL2 = 1,
/**
* User credential encryption area.
* when screen locked, can read/write, and create file.
*/
ABILITY_RUNTIME_AREA_MODE_EL3 = 2,
/**
* User credential encryption area.
* when screen locked, FEB2.0 can read/write, FEB3.0 can't
* read/write, and all can't create file.
*/
ABILITY_RUNTIME_AREA_MODE_EL4 = 3,
/**
* User privacy-sensitive encryption area.
* when the screen locked, a closed file cannot be opened, read, or written,
* a file can be created and then opened, read, or written.
*/
ABILITY_RUNTIME_AREA_MODE_EL5 = 4,
} AbilityRuntime_AreaMode;
#ifdef __cplusplus
} // extern "C"
#endif
/** @} */
#endif // ABILITY_RUNTIME_CONTEXT_CONSTANT_H

View File

@ -0,0 +1,14 @@
[
{
"first_introduced": "13",
"name": "OH_AbilityRuntime_ApplicationContextGetCacheDir"
},
{
"first_introduced": "13",
"name": "OH_AbilityRuntime_ApplicationContextGetAreaMode"
},
{
"first_introduced": "13",
"name": "OH_AbilityRuntime_ApplicationContextGetBundleName"
}
]