diff --git a/.gitee/ISSUE_TEMPLATE.en.md b/.gitee/ISSUE_TEMPLATE.en.md new file mode 100644 index 0000000000000000000000000000000000000000..f1a77b33d5a833e94bca343717f13a6070c57bcd --- /dev/null +++ b/.gitee/ISSUE_TEMPLATE.en.md @@ -0,0 +1,11 @@ +### Description? + + + +### Steps to reproduce + + + +### Error results + + diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..84543046a428301c095c347a218dacb334ad488a --- /dev/null +++ b/.gitee/ISSUE_TEMPLATE.zh-CN.md @@ -0,0 +1,11 @@ +### 该问题是怎么引起的? + + + +### 重现步骤 + + + +### 报错信息 + + diff --git a/.gitee/PULL_REQUEST_TEMPLATE.en.md b/.gitee/PULL_REQUEST_TEMPLATE.en.md new file mode 100644 index 0000000000000000000000000000000000000000..073fa0eacdf447178b995856bc7166d1a6ef8859 --- /dev/null +++ b/.gitee/PULL_REQUEST_TEMPLATE.en.md @@ -0,0 +1,19 @@ +### Issue + + +### Reason + + +### how to fix + + +### Test (libc-test is mandatory, but not limited to) +- [ ] pass c syntax checker +- [ ] pass interface checker +- [ ] add symbol to json +- [ ] merge the implementation +- [ ] add target to ndk.targets in build + +### Compatibility impact assessment, please indicate (Y/N) +- [ ] not compatible + - [ ] evaluated by committee diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..5af541eea79402a473f050e961d30a763395586b --- /dev/null +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -0,0 +1,19 @@ +### 相关的Issue + + +### 原因(目的、解决的问题等) + + +### 描述(做了什么,变更了什么) + + +### 自检结果(结果截图添加到下面) +- [ ] 是否通过C语法扫描 +- [ ] 是否通过注释规则扫描 +- [ ] 是否更新json文件 +- [ ] 实现代码是否已经合入 +- [ ] 目标是否已经添加到build仓ndk依赖目标里 + +### 兼容性影响评估,如有影响请写明(Y/N) +- [ ] 不兼容 + - [ ] 是否经过评审 diff --git a/AbilityKit/ability_runtime/BUILD.gn b/AbilityKit/ability_runtime/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e96e8afc2f01082308d3f5d85f308c27f011bbe5 --- /dev/null +++ b/AbilityKit/ability_runtime/BUILD.gn @@ -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", + ] +} diff --git a/AbilityKit/ability_runtime/ability_runtime_common.h b/AbilityKit/ability_runtime/ability_runtime_common.h new file mode 100644 index 0000000000000000000000000000000000000000..e4cf556e420be527795b10ebbf0e6ec30bad72da --- /dev/null +++ b/AbilityKit/ability_runtime/ability_runtime_common.h @@ -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 diff --git a/AbilityKit/ability_runtime/application_context.h b/AbilityKit/ability_runtime/application_context.h new file mode 100644 index 0000000000000000000000000000000000000000..1ba53503d9f1b6ace7fece3f3d6e004221835186 --- /dev/null +++ b/AbilityKit/ability_runtime/application_context.h @@ -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 +#include +#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 diff --git a/AbilityKit/ability_runtime/context_constant.h b/AbilityKit/ability_runtime/context_constant.h new file mode 100644 index 0000000000000000000000000000000000000000..921f407c1aaf3c9201eb79fe7749f9cb4e48ca40 --- /dev/null +++ b/AbilityKit/ability_runtime/context_constant.h @@ -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 diff --git a/AbilityKit/ability_runtime/libability_runtime.ndk.json b/AbilityKit/ability_runtime/libability_runtime.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..239f84f6151aab58f4d1fd3177870b80af428f59 --- /dev/null +++ b/AbilityKit/ability_runtime/libability_runtime.ndk.json @@ -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" + } +] \ No newline at end of file diff --git a/BasicServicesKit/BUILD.gn b/BasicServicesKit/BUILD.gn index f28da4fa87770e830375a5c8ff5922fbd1e425a2..11168e05767c470e71a1fd29061968685116a083 100644 --- a/BasicServicesKit/BUILD.gn +++ b/BasicServicesKit/BUILD.gn @@ -57,3 +57,51 @@ ohos_ndk_library("libohscan_ndk") { system_capability = "SystemCapability.Print.PrintFramework" system_capability_headers = [ "BasicServicesKit/ohscan.h" ] } + +ohos_ndk_headers("time_service_ndk_header") { + dest_dir = "$ndk_headers_out_dir/BasicServicesKit/" + sources = [ "./time_service.h" ] +} + +ohos_ndk_library("libtime_service_ndk") { + output_name = "time_service_ndk" + output_extension = "so" + ndk_description_file = "./libtime_service.ndk.json" + min_compact_version = "12" + system_capability = "SystemCapability.MiscServices.Time" + system_capability_headers = [ "BasicServicesKit/time_service.h" ] +} + +ohos_ndk_headers("ohcommonevent_header") { + dest_dir = "$ndk_headers_out_dir/BasicServicesKit/" + sources = [ + "./commonevent/oh_commonevent.h", + "./commonevent/oh_commonevent_support.h", + ] +} + +ohos_ndk_library("libcommonevent_ndk") { + output_name = "ohcommonevent" + output_extension = "so" + ndk_description_file = "./commonevent/libcommonevent.ndk.json" + min_compact_version = "12" + system_capability = "SystemCapability.Notification.CommonEvent" + system_capability_headers = [ + "BasicServicesKit/commonevent/oh_commonevent.h", + "BasicServicesKit/commonevent/oh_commonevent_support.h", + ] +} + +ohos_ndk_headers("ohbattery_info_header") { + dest_dir = "$ndk_headers_out_dir/BasicServicesKit/" + sources = [ "./ohbattery_info.h" ] +} + +ohos_ndk_library("libohbattery_info_ndk") { + output_name = "ohbattery_info" + output_extension = "so" + ndk_description_file = "./ohbattery_info.ndk.json" + min_compact_version = "13" + system_capability = "SystemCapability.PowerManager.BatteryManager.Core" + system_capability_headers = [ "BasicServicesKit/ohbattery_info.h" ] +} diff --git a/BasicServicesKit/commonevent/libcommonevent.ndk.json b/BasicServicesKit/commonevent/libcommonevent.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..40ddccdfe88e4c25f5c538caef903e240f963f44 --- /dev/null +++ b/BasicServicesKit/commonevent/libcommonevent.ndk.json @@ -0,0 +1,98 @@ +[ + { + "first_introduced": "12", + "name":"OH_CommonEvent_CreateSubscribeInfo" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_SetPublisherPermission" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_SetPublisherBundleName" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_DestroySubscribeInfo" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_CreateSubscriber" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_DestroySubscriber" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_Subscribe" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_UnSubscribe" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetEventFromRcvData" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetCodeFromRcvData" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetDataStrFromRcvData" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetBundleNameFromRcvData" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetParametersFromRcvData" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_HasKeyInParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetIntFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetIntArrayFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetLongFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetLongArrayFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetBoolFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetBoolArrayFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetCharFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetCharArrayFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetDoubleFromParameters" + }, + { + "first_introduced": "12", + "name":"OH_CommonEvent_GetDoubleArrayFromParameters" + } +] diff --git a/BasicServicesKit/commonevent/oh_commonevent.h b/BasicServicesKit/commonevent/oh_commonevent.h new file mode 100644 index 0000000000000000000000000000000000000000..44c6799268b25e0eeb9291a274f824275051d47d --- /dev/null +++ b/BasicServicesKit/commonevent/oh_commonevent.h @@ -0,0 +1,370 @@ +/* + * 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 OH_CommonEvent + * @{ + * + * @brief Provides the APIs of common event service. + * + * @since 12 + */ +/** + * @file oh_commonevent.h + * + * @brief Declares the APIs to subscribe and unsubscribe common event, and so on. + * + * @library libohcommonevent.so + * @kit BasicServicesKit + * @syscap SystemCapability.Notification.CommonEvent + * @since 12 + * @version 1.0 + */ + +#ifndef OH_COMMONEVENT_H +#define OH_COMMONEVENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines error codes. + * + * @since 12 + * @version 1.0 + */ +typedef enum CommonEvent_ErrCode { + /** @error Execution successful. */ + COMMONEVENT_ERR_OK = 0, + + /** @error permission verification failed. */ + COMMONEVENT_ERR_PERMISSION_ERROR = 201, + + /** @error invalid input parameter. */ + COMMONEVENT_ERR_INVALID_PARAMETER = 401, + + /** @error IPC request failed to send. */ + COMMONEVENT_ERR_SENDING_REQUEST_FAILED = 1500007, + + /** @error Common event service not init. */ + COMMONEVENT_ERR_INIT_UNDONE = 1500008, + + /** @error The subscriber number exceed system specification */ + COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED = 1500010, + + /** @error A memory allocation error occurs. */ + COMMONEVENT_ERR_ALLOC_MEMORY_FAILED = 1500011, +} CommonEvent_ErrCode; + +/** + * @brief the information of the subscriber + * + * @since 12 + */ +typedef struct CommonEvent_SubscribeInfo CommonEvent_SubscribeInfo; + +/** + * @brief the subscriber of common event + * + * @since 12 + */ +typedef void CommonEvent_Subscriber; + +/** + * @brief the data of the commonEvent callback + * + * @since 12 + */ +typedef struct CommonEvent_RcvData CommonEvent_RcvData; + +/** + * @brief The description of the parameters in a common event callback data. + * + * @since 12 + */ +typedef void CommonEvent_Parameters; + +/** + * @brief Common event callback. + * + * @param data common event callback data. + * @since 12 + */ +typedef void (*CommonEvent_ReceiveCallback)(const CommonEvent_RcvData *data); + +/** + * @brief Create subscribe information. + * + * @param events Indicates the subscribed events. + * @param eventsNum Indicates the subscribed events of number. + * @return Returns the CommonEvent_SubscribeInfo, if allocate memory failed, returns null. + * @since 12 + */ +CommonEvent_SubscribeInfo* OH_CommonEvent_CreateSubscribeInfo(const char* events[], int32_t eventsNum); + +/** + * @brief Set the subscribe information of permission. + * + * @param info Indicates the subscribed events. + * @param permission Indicates the subscribed events of permission. + * @return Returns the error code. + * Returns {@link COMMONEVENT_ERR_OK} if the operation is successful. + * Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs. + * @since 12 + */ +CommonEvent_ErrCode OH_CommonEvent_SetPublisherPermission(CommonEvent_SubscribeInfo* info, const char* permission); + +/** + * @brief Set the subscribe information of bundleName. + * + * @param info Indicates the subscribed events. + * @param bundleName Indicates the subscribed events of bundleName. + * @return Returns the error code. + * Returns {@link COMMONEVENT_ERR_OK} if the operation is successful. + * Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER} if a parameter error occurs. + * @since 12 + */ +CommonEvent_ErrCode OH_CommonEvent_SetPublisherBundleName(CommonEvent_SubscribeInfo* info, const char* bundleName); + +/** + * @brief Destroy the subscribe information. + * + * @param info Indicates the subscribe info. + * @since 12 + */ +void OH_CommonEvent_DestroySubscribeInfo(CommonEvent_SubscribeInfo* info); + +/** + * @brief Create a subscriber. + * + * @param info Indicates the created subscribe Info. + * @param callback Indicates the received common event callback. + * @return Returns the CommonEvent_Subscriber, if allocate memory failed, returns null. + * @since 12 + */ +CommonEvent_Subscriber* OH_CommonEvent_CreateSubscriber(const CommonEvent_SubscribeInfo* info, + CommonEvent_ReceiveCallback callback); + +/** + * @brief Destory the subscriber. + * + * @param subscriber Indicates the created subscriber. + * @since 12 + */ +void OH_CommonEvent_DestroySubscriber(CommonEvent_Subscriber* subscriber); + +/** + * @brief Subscribe event by a subscriber. + * + * @param subscriber Indicates the subscriber. + * @return Returns the error code. + * Returns {@link COMMONEVENT_ERR_OK} if the operation is successful. + * Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER } if the input parameter is invalid. + * Returns {@link COMMONEVENT_ERR_SENDING_REQUEST_FAILED } if IPC request failed to send. + * Returns {@link COMMONEVENT_ERR_INIT_UNDONE } if ces not init done. + * Returns {@link COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED } if the subscriber number is exceeded. + * Returns {@link COMMONEVENT_ERR_ALLOC_MEMORY_FAILED } if a memory allocation error occurs. + * @since 12 + */ +CommonEvent_ErrCode OH_CommonEvent_Subscribe(const CommonEvent_Subscriber* subscriber); + +/** + * @brief Unsubscribe event by a subscriber. + * + * @param subscriber Indicates the subscriber. + * @return Returns the error code. + * Returns {@link COMMONEVENT_ERR_OK} if the operation is successful. + * Returns {@link COMMONEVENT_ERR_INVALID_PARAMETER } if the input parameter is invalid. + * Returns {@link COMMONEVENT_ERR_SENDING_REQUEST_FAILED } if IPC request failed to send. + * Returns {@link COMMONEVENT_ERR_INIT_UNDONE } if ces not init done. + * @since 12 + */ +CommonEvent_ErrCode OH_CommonEvent_UnSubscribe(const CommonEvent_Subscriber* subscriber); + +/** + * @brief Get event name from callback data. + * + * @param rcvData Indicates the event of callback data. + * @return Returns the event name. + * @since 12 + */ +const char* OH_CommonEvent_GetEventFromRcvData(const CommonEvent_RcvData* rcvData); + +/** + * @brief Get event result code from callback data. + * + * @param rcvData Indicates the event of callback data. + * @return Returns the event of result code, default is 0. + * @since 12 + */ +int32_t OH_CommonEvent_GetCodeFromRcvData(const CommonEvent_RcvData* rcvData); + +/** + * @brief Get event result data from callback data. + * + * @param rcvData Indicates the event of callback data. + * @return Returns the event of result data, default is null. + * @since 12 + */ +const char* OH_CommonEvent_GetDataStrFromRcvData(const CommonEvent_RcvData* rcvData); + +/** + * @brief Get event bundlename from callback data. + * + * @param rcvData Indicates the event of callback data. + * @return Returns the event of bundlename, default is null. + * @since 12 + */ +const char* OH_CommonEvent_GetBundleNameFromRcvData(const CommonEvent_RcvData* rcvData); + +/** + * @brief Get event parameters data from callback data. + * + * @param rcvData Indicates the event of callback data. + * @return Returns the event of parameters data, default is null. + * @since 12 + */ +const CommonEvent_Parameters* OH_CommonEvent_GetParametersFromRcvData(const CommonEvent_RcvData* rcvData); + +/** + * @brief Check whether the parameters contains a key. + * + * @param rcvData Indicates the event of callback data. + * @param key Indicates the key of parameter. + * @return Returns the result of check, true means it contains. + * @since 12 + */ +bool OH_CommonEvent_HasKeyInParameters(const CommonEvent_Parameters* para, const char* key); + +/** + * @brief Get int data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param defaultValue Indicates default return value. + * @return Returns the int data of the key in the parameters. + * @since 12 + */ +int OH_CommonEvent_GetIntFromParameters(const CommonEvent_Parameters* para, const char* key, const int defaultValue); + +/** + * @brief Get int array data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param array Indicates the int array. + * @return Returns the length of the array. + * @since 12 + */ +int32_t OH_CommonEvent_GetIntArrayFromParameters(const CommonEvent_Parameters* para, const char* key, int** array); + +/** + * @brief Get long data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param defaultValue Indicates default return value. + * @return Returns the long data of the key in the parameters. + * @since 12 + */ +long OH_CommonEvent_GetLongFromParameters(const CommonEvent_Parameters* para, const char* key, const long defaultValue); + +/** + * @brief Get long array data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param array Indicates the long array. + * @return Returns the length of the array. + * @since 12 + */ +int32_t OH_CommonEvent_GetLongArrayFromParameters(const CommonEvent_Parameters* para, const char* key, long** array); + +/** + * @brief Get bool data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param defaultValue Indicates default return value. + * @return Returns the bool data of the key in the parameters. + * @since 12 + */ +bool OH_CommonEvent_GetBoolFromParameters(const CommonEvent_Parameters* para, const char* key, const bool defaultValue); + +/** + * @brief Get bool array data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param array Indicates the bool array. + * @return Returns the length of the array. + * @since 12 + */ +int32_t OH_CommonEvent_GetBoolArrayFromParameters(const CommonEvent_Parameters* para, const char* key, bool** array); + +/** + * @brief Get char data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param defaultValue Indicates default return value. + * @return Returns the char data of the key in the parameters. + * @since 12 + */ +char OH_CommonEvent_GetCharFromParameters(const CommonEvent_Parameters* para, const char* key, const char defaultValue); + +/** + * @brief Get char array data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param array Indicates the char array. + * @return Returns the length of the array. + * @since 12 + */ +int32_t OH_CommonEvent_GetCharArrayFromParameters(const CommonEvent_Parameters* para, const char* key, char** array); + +/** + * @brief Get double data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param defaultValue Indicates default return value. + * @return Returns the double data of the key in the parameters. + * @since 12 + */ +double OH_CommonEvent_GetDoubleFromParameters(const CommonEvent_Parameters* para, const char* key, + const double defaultValue); + +/** + * @brief Get double array data from parameters data by key. + * + * @param rcvData Indicates the event of parameters data. + * @param key Indicates the key of parameters data. + * @param array Indicates the double array. + * @return Returns the length of the array, default is 0. + * @since 12 + */ +int32_t OH_CommonEvent_GetDoubleArrayFromParameters(const CommonEvent_Parameters* para, const char* key, + double** array); + +#ifdef __cplusplus +} +#endif +#endif // OH_COMMONEVENT_H +/** @} */ diff --git a/BasicServicesKit/commonevent/oh_commonevent_support.h b/BasicServicesKit/commonevent/oh_commonevent_support.h new file mode 100644 index 0000000000000000000000000000000000000000..6d1256b95cdc7b06fd104194b0c53a58cbb7ed0d --- /dev/null +++ b/BasicServicesKit/commonevent/oh_commonevent_support.h @@ -0,0 +1,562 @@ +/* + * 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 OH_CommonEvent + * @{ + * + * @brief Provides the APIs of common event service. + * + * @since 12 + */ +/** + * @file oh_commonevent_support.h + * + * @brief Declares the constants of system-defined common event. + * + * @library libohcommonevent.so + * @kit BasicServicesKit + * @syscap SystemCapability.Notification.CommonEvent + * @since 12 + * @version 1.0 + */ + +#ifndef OH_COMMONEVENT_SUPPORT_H +#define OH_COMMONEVENT_SUPPORT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief This commonEvent means when the device is shutting down, note: turn off, not sleeping. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SHUTDOWN = "usual.event.SHUTDOWN"; + +/** + * @brief This commonEvent means when the charging state, level and so on about the battery. + * + * @since 12 + */ +static const char* const COMMON_EVENT_BATTERY_CHANGED = "usual.event.BATTERY_CHANGED"; + +/** + * @brief This commonEvent means when the device in low battery state. + * + * @since 12 + */ +static const char* const COMMON_EVENT_BATTERY_LOW = "usual.event.BATTERY_LOW"; + +/** + * @brief This commonEvent means when the battery level is an ok state. + * + * @since 12 + */ +static const char* const COMMON_EVENT_BATTERY_OKAY = "usual.event.BATTERY_OKAY"; + +/** + * @brief This commonEvent means when the other power is connected to the device. + * + * @since 12 + */ +static const char* const COMMON_EVENT_POWER_CONNECTED = "usual.event.POWER_CONNECTED"; + +/** + * @brief This commonEvent means when the other power is removed from the device. + * + * @since 12 + */ +static const char* const COMMON_EVENT_POWER_DISCONNECTED = "usual.event.POWER_DISCONNECTED"; + +/** + * @brief This commonEvent means when the screen is turned off. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SCREEN_OFF = "usual.event.SCREEN_OFF"; + +/** + * @brief This commonEvent means when the device is awakened and interactive. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SCREEN_ON = "usual.event.SCREEN_ON"; + +/** + * @brief This commonEvent means when the thermal state level change + * + * @since 12 + */ +static const char* const COMMON_EVENT_THERMAL_LEVEL_CHANGED = "usual.event.THERMAL_LEVEL_CHANGED"; + +/** + * @brief This commonEvent means when the current time is changed. + * + * @since 12 + */ +static const char* const COMMON_EVENT_TIME_TICK = "usual.event.TIME_TICK"; + +/** + * @brief This commonEvent means when the time is set. + * + * @since 12 + */ +static const char* const COMMON_EVENT_TIME_CHANGED = "usual.event.TIME_CHANGED"; + +/** + * @brief This commonEvent means when the time zone is changed. + * + * @since 12 + */ +static const char* const COMMON_EVENT_TIMEZONE_CHANGED = "usual.event.TIMEZONE_CHANGED"; + +/** + * @brief This commonEvent means when a new application package is installed on the device. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGE_ADDED = "usual.event.PACKAGE_ADDED"; + +/** + * @brief This commonEvent means when an existing application package is removed from the device. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGE_REMOVED = "usual.event.PACKAGE_REMOVED"; + +/** + * @brief This commonEvent means when an installed application's add-on package is removed from the device. + * + * @since 12 + */ +static const char* const COMMON_EVENT_BUNDLE_REMOVED = "usual.event.BUNDLE_REMOVED"; + +/** + * @brief This commonEvent means when an existing application package is completely removed from the device. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGE_FULLY_REMOVED = "usual.event.PACKAGE_FULLY_REMOVED"; + +/** + * @brief This commonEvent means when an existing application package has been changed. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGE_CHANGED = "usual.event.PACKAGE_CHANGED"; + +/** + * @brief This commonEvent means the user has restarted a package, and all of its processes have been killed. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGE_RESTARTED = "usual.event.PACKAGE_RESTARTED"; + +/** + * @brief This commonEvent means the user has cleared the package data. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGE_DATA_CLEARED = "usual.event.PACKAGE_DATA_CLEARED"; + +/** + * @brief This commonEvent means the user has cleared the package cache. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGE_CACHE_CLEARED = "usual.event.PACKAGE_CACHE_CLEARED"; + +/** + * @brief This commonEvent means the packages have been suspended. + * + * @since 12 + */ +static const char* const COMMON_EVENT_PACKAGES_SUSPENDED = "usual.event.PACKAGES_SUSPENDED"; + +/** + * @brief This commonEvent Sent to a package that has been suspended by the system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_MY_PACKAGE_SUSPENDED = "usual.event.MY_PACKAGE_SUSPENDED"; + +/** + * @brief Sent to a package that has been un-suspended. + * + * @since 12 + */ +static const char* const COMMON_EVENT_MY_PACKAGE_UNSUSPENDED = "usual.event.MY_PACKAGE_UNSUSPENDED"; + +/** + * @brief The current device's locale has changed. + * + * @since 12 + */ +static const char* const COMMON_EVENT_LOCALE_CHANGED = "usual.event.LOCALE_CHANGED"; + +/** + * @brief Indicates low memory condition notification acknowledged by user and package + * management should be started. + * + * @since 12 + */ +static const char* const COMMON_EVENT_MANAGE_PACKAGE_STORAGE = "usual.event.MANAGE_PACKAGE_STORAGE"; + +/** + * @brief Remind new user of that the service has been unlocked. + * + * @since 12 + */ +static const char* const COMMON_EVENT_USER_UNLOCKED = "usual.event.USER_UNLOCKED"; + +/** + * @brief Distributed account logout successfully. + * + * @since 12 + */ +static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT = "common.event.DISTRIBUTED_ACCOUNT_LOGOUT"; + +/** + * @brief Distributed account is invalid. + * + * @since 12 + */ +static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID = + "common.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID"; + +/** + * @brief Distributed account logs off. + * + * @since 12 + */ +static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF = "common.event.DISTRIBUTED_ACCOUNT_LOGOFF"; + +/** + * @brief WIFI state. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_POWER_STATE = "usual.event.wifi.POWER_STATE"; + +/** + * @brief WIFI scan results. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_SCAN_FINISHED = "usual.event.wifi.SCAN_FINISHED"; + +/** + * @brief WIFI RSSI change. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_RSSI_VALUE = "usual.event.wifi.RSSI_VALUE"; + +/** + * @brief WIFI connect state. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_CONN_STATE = "usual.event.wifi.CONN_STATE"; + +/** + * @brief WIFI hotspot state. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_HOTSPOT_STATE = "usual.event.wifi.HOTSPOT_STATE"; + +/** + * @brief WIFI ap sta join. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_AP_STA_JOIN = "usual.event.wifi.WIFI_HS_STA_JOIN"; + +/** + * @brief WIFI ap sta join. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_AP_STA_LEAVE = "usual.event.wifi.WIFI_HS_STA_LEAVE"; + +/** + * @brief Indicates Wi-Fi MpLink state notification acknowledged by binding or unbinding MpLink. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE = "usual.event.wifi.mplink.STATE_CHANGE"; + +/** + * @brief Indicates Wi-Fi P2P connection state notification acknowledged by connecting or disconnected P2P. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_P2P_CONN_STATE = "usual.event.wifi.p2p.CONN_STATE_CHANGE"; + +/** + * @brief Indicates that the Wi-Fi P2P state change. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_P2P_STATE_CHANGED = "usual.event.wifi.p2p.STATE_CHANGE"; + +/** + * @brief Indicates that the Wi-Fi P2P peers state change. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED = "usual.event.wifi.p2p.DEVICES_CHANGE"; + +/** + * @brief Indicates that the Wi-Fi P2P discovery state change. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED = + "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE"; + +/** + * @brief Indicates that the Wi-Fi P2P current device state change. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED = + "usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE"; + +/** + * @brief Indicates that the Wi-Fi P2P group info is changed. + * + * @since 12 + */ +static const char* const COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED = "usual.event.wifi.p2p.GROUP_STATE_CHANGED"; + +/** + * @brief Nfc state change. + * + * @since 12 + */ +static const char* const COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED = "usual.event.nfc.action.ADAPTER_STATE_CHANGED"; + +/** + * @brief Nfc field on detected. + * + * @since 12 + */ +static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED = "usual.event.nfc.action.RF_FIELD_ON_DETECTED"; + +/** + * @brief Nfc field off detected. + * + * @since 12 + */ +static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED = "usual.event.nfc.action.RF_FIELD_OFF_DETECTED"; + +/** + * @brief Sent when stop charging battery. + * + * @since 12 + */ +static const char* const COMMON_EVENT_DISCHARGING = "usual.event.DISCHARGING"; + +/** + * @brief Sent when start charging battery. + * + * @since 12 + */ +static const char* const COMMON_EVENT_CHARGING = "usual.event.CHARGING"; + +/** + * @brief Sent when device's idle mode changed + * + * @since 12 + */ +static const char* const COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED = "usual.event.DEVICE_IDLE_MODE_CHANGED"; + +/** + * @brief Sent when device's charge idle mode changed. + * + * @since 12 + */ +static const char* const COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED = "usual.event.CHARGE_IDLE_MODE_CHANGED"; + +/** + * @brief Sent when device's power save mode changed + * + * @since 12 + */ +static const char* const COMMON_EVENT_POWER_SAVE_MODE_CHANGED = "usual.event.POWER_SAVE_MODE_CHANGED"; + +/** + * @brief The usb state change events. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_USB_STATE = "usual.event.hardware.usb.action.USB_STATE"; + +/** + * @brief The usb port changed. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_USB_PORT_CHANGED = "usual.event.hardware.usb.action.USB_PORT_CHANGED"; + +/** + * @brief The usb device attached. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_USB_DEVICE_ATTACHED = "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED"; + +/** + * @brief The usb device detached. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_USB_DEVICE_DETACHED = "usual.event.hardware.usb.action.USB_DEVICE_DETACHED"; + +/** + * @brief Indicates the common event Action indicating that the airplane mode status of the device changes. + * Users can register this event to listen to the change of the airplane mode status of the device. + * + * @since 12 + */ +static const char* const COMMON_EVENT_AIRPLANE_MODE_CHANGED = "usual.event.AIRPLANE_MODE"; + +/** + * @brief sent by the window manager service when the window mode is split. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SPLIT_SCREEN = "common.event.SPLIT_SCREEN"; + +/** + * @brief Indicate the result of quick fix apply. + * This common event can be triggered only by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_QUICK_FIX_APPLY_RESULT = "usual.event.QUICK_FIX_APPLY_RESULT"; + +/** + * @brief Indicate the result of quick fix revoke. + * This common event can be triggered only by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_QUICK_FIX_REVOKE_RESULT = "usual.event.QUICK_FIX_REVOKE_RESULT"; + +/** + * @brief Indicate the action of a common event that the user information has been updated. + * This common event can be triggered only by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_USER_INFO_UPDATED = "usual.event.USER_INFO_UPDATED"; + +/** + * @brief Indicates the action of a common event that the phone SIM card state has changed. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SIM_STATE_CHANGED = "usual.event.SIM_STATE_CHANGED"; + +/** + * @brief Indicates the action of a common event that the call state has been changed. + * To subscribe to this protected common event, your application must have the ohos.permission.GET_TELEPHONY_STATE + * permission. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_CALL_STATE_CHANGED = "usual.event.CALL_STATE_CHANGED"; + +/** + * @brief Indicates the action of a common event that the network state has been changed. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_NETWORK_STATE_CHANGED = "usual.event.NETWORK_STATE_CHANGED"; + +/** + * @brief Indicates the action of a common event that the signal info has been changed. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SIGNAL_INFO_CHANGED = "usual.event.SIGNAL_INFO_CHANGED"; + +/** + * @brief This commonEvent means when the screen is unlocked. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SCREEN_UNLOCKED = "usual.event.SCREEN_UNLOCKED"; + +/** + * @brief This commonEvent means when the screen is locked. + * + * @since 12 + */ +static const char* const COMMON_EVENT_SCREEN_LOCKED = "usual.event.SCREEN_LOCKED"; + +/** + * @brief This commonEvent means when the http proxy change. + * + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_HTTP_PROXY_CHANGE = "usual.event.HTTP_PROXY_CHANGE"; + +/** + * @brief This commonEvent means when the network connectivityy change. + * + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_CONNECTIVITY_CHANGE = "usual.event.CONNECTIVITY_CHANGE"; + +/** + * @brief This common event means that minors mode is enabled. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_MINORSMODE_ON = "usual.event.MINORSMODE_ON"; + +/** + * @brief This common event means that minors mode is disabled. + * This is a protected common event that can only be sent by system. + * + * @since 12 + */ +static const char* const COMMON_EVENT_MINORSMODE_OFF = "usual.event.MINORSMODE_OFF"; +#ifdef __cplusplus +} +#endif +#endif // OH_COMMONEVENT_SUPPORT_H +/** @} */ diff --git a/BasicServicesKit/libtime_service.ndk.json b/BasicServicesKit/libtime_service.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..2e80130d800d76d0bd1164cdb0179ee07e384c9a --- /dev/null +++ b/BasicServicesKit/libtime_service.ndk.json @@ -0,0 +1,5 @@ +[ + { "first_introduced": "12", + "name":"OH_TimeService_GetTimeZone" + } +] \ No newline at end of file diff --git a/BasicServicesKit/ohbattery_info.h b/BasicServicesKit/ohbattery_info.h new file mode 100644 index 0000000000000000000000000000000000000000..38f289a38f4087ca9fd0166d23146302aa2894bd --- /dev/null +++ b/BasicServicesKit/ohbattery_info.h @@ -0,0 +1,124 @@ +/* + * 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 OH_BatteryInfo + * @{ + * + * @brief Provides the definition of the C interface for the BatteryInfo module. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 13 + * @version 1.0 + */ +/** + * @file ohbattery_info.h + * + * @brief Declares the APIs to get informations about the current battery capacity and the power source type, + * defines strings that identify corresponding common events. + * + * @library libohbattery_info.so + * @kit BasicServicesKit + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 13 + * @version 1.0 + */ +#ifndef OHBATTERY_INFO_HEADER +#define OHBATTERY_INFO_HEADER + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief A string that identifies the common event sent after battery capacity changes. + * @since 13 + * @version 1.0 + */ +static const char* COMMON_EVENT_KEY_CAPACITY = "soc"; +/** + * @brief A string that identifies the common event sent after charge state changes. + * @since 13 + * @version 1.0 + */ +static const char* COMMON_EVENT_KEY_CHARGE_STATE = "chargeState"; +/** + * @brief A string that identifies the common event sent after plugged type changes. + * @since 13 + * @version 1.0 + */ +static const char* COMMON_EVENT_KEY_PLUGGED_TYPE = "pluggedType"; + +/** + * @brief Defines plugged types. + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** + * Power source is unplugged. + */ + PLUGGED_TYPE_NONE, + + /** + * Power source is an AC charger. + */ + PLUGGED_TYPE_AC, + + /** + * Power source is a USB DC charger. + */ + PLUGGED_TYPE_USB, + + /** + * Power source is wireless charger. + */ + PLUGGED_TYPE_WIRELESS, + + /** + * The bottom of the enum. + */ + PLUGGED_TYPE_BUTT +} BatteryInfo_BatteryPluggedType; + +/** + * @brief This API returns the current battery capacity. + * + * @return Returns number between 0 and 100. + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 13 + */ +int32_t OH_BatteryInfo_GetCapacity(); + +/** + * @brief This API returns the current plugged type. + * + * @return {@link BatteryInfo_BatteryPluggedType#PLUGGED_TYPE_NONE} if the power source is unplugged. + * {@link PLUGGED_TYPE_AC} if the power source is an AC charger. + * {@link PLUGGED_TYPE_USB} if the power source is an USB DC charger. + * {@link PLUGGED_TYPE_WIRELESS} if the power source is wireless charger. + * {@link PLUGGED_TYPE_BUTT} if the type is unknown. + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 13 + */ +BatteryInfo_BatteryPluggedType OH_BatteryInfo_GetPluggedType(); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* OHBATTERY_INFO_HEADER */ +/** @} */ diff --git a/BasicServicesKit/ohbattery_info.ndk.json b/BasicServicesKit/ohbattery_info.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..ffe1e95d2e036e2e0b7b1c366812a33ee8e02869 --- /dev/null +++ b/BasicServicesKit/ohbattery_info.ndk.json @@ -0,0 +1,8 @@ +[ + { "first_introduced": "13", + "name":"OH_BatteryInfo_GetCapacity" + }, + { "first_introduced": "13", + "name":"OH_BatteryInfo_GetPluggedType" + } +] diff --git a/BasicServicesKit/ohprint.h b/BasicServicesKit/ohprint.h index 9bb887d6ba8916ee3fbeb6738fe7c1c0a60bdf7c..66b71c05be44c4afe7d027acabb54a31f329225a 100644 --- a/BasicServicesKit/ohprint.h +++ b/BasicServicesKit/ohprint.h @@ -280,6 +280,28 @@ typedef enum { DOCUMENT_FORMAT_TEXT, } Print_DocumentFormat; +/** + * @brief Indicates the print job doc adapter state. + * + * @since 13 + */ +typedef enum { + /** Print job preview ability destroy. */ + PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY = 0, + /** Print job task succeed. */ + PRINT_DOC_ADAPTER_PRINT_TASK_SUCCEED = 1, + /** Print job task failed. */ + PRINT_DOC_ADAPTER_PRINT_TASK_FAIL = 2, + /** Print job task cancel. */ + PRINT_DOC_ADAPTER_PRINT_TASK_CANCEL = 3, + /** Print job task block. */ + PRINT_DOC_ADAPTER_PRINT_TASK_BLOCK = 4, + /** Print job task preview ability destroy for cancel. */ + PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY_FOR_CANCELED = 5, + /** Print job task preview ability destroy for started. */ + PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY_FOR_STARTED = 6, +} Print_JobDocAdapterState; + /** * @brief Indicates printer capabilities. * @@ -422,6 +444,96 @@ typedef struct { char *advancedOptions; } Print_PrintJob; +/** + * @brief Indicates print range structure. + * + * @since 13 + */ +typedef struct { + /** Print start page. */ + uint32_t startPage; + /** Print end page. */ + uint32_t endPage; + /** Print page array length. */ + uint32_t pagesArrayLen; + /** Print page array. */ + uint32_t* pagesArray; +} Print_Range; + +/** + * @brief Indicates print attributes structure. + * + * @since 13 + */ +typedef struct { + /** Print ranges. */ + Print_Range pageRange; + /** Print page size. */ + Print_PageSize pageSize; + /** Print margin. */ + Print_Margin pageMargin; + /** Copy numbers. */ + uint32_t copyNumber; + /** Duplex mode. */ + uint32_t duplexMode; + /** color mode. */ + uint32_t colorMode; + /** Print sequential. */ + bool isSequential; + /** Print orient. */ + bool isLandscape; + /** Print option flag. */ + bool hasOption; + /** Print options. */ + char options[256]; +} Print_PrintAttributes; + +/** + * @brief Write files result callback. + * + * @param jobId The print job id of one print task. + * @param code The result of write files. + * @since 13 + */ +typedef void(*Print_WriteResultCallback)(const char *jobId, uint32_t code); + +/** + * @brief Print start layout callback. + * + * @param jobId The print job id of one print task. + * @param fd The file descriptor to be written. + * @param oldAttrs The attribute of last. + * @param newAttrs The attribute of current. + * @param writeCallback The Write files result callback. + * @since 13 + */ +typedef void(*Print_OnStartLayoutWrite)(const char *jobId, + uint32_t fd, + const Print_PrintAttributes *oldAttrs, + const Print_PrintAttributes *newAttrs, + Print_WriteResultCallback writeCallback); + +/** + * @brief Print job state callback. + * + * @param jobId The print job id of one print task. + * @param state The state of current print job. + * @since 13 + */ +typedef void(*Print_OnJobStateChanged)(const char *jobId, uint32_t state); + +/** + * @brief Indicates print doc state callback structure. + * + * @since 13 + */ +typedef struct { + /** Print start layout callback. */ + Print_OnStartLayoutWrite startLayoutWriteCb; + /** Print job state callback. */ + Print_OnJobStateChanged jobStateChangedCb; +} Print_PrintDocCallback; + /** * @brief Printer discovery callback. * @@ -659,6 +771,23 @@ Print_ErrorCode OH_Print_UpdatePrinterProperties(const char *printerId, const Pr */ Print_ErrorCode OH_Print_RestorePrinterProperties(const char *printerId, const Print_StringList *propertyKeyList); +/** + * @brief This API provide capacity to start print dialog. + * + * @permission {@code ohos.permission.PRINT} + * @param printJobName The name of this print job. + * @param printDocCallback The print doc state callback. + * @param context The context of caller app. + * @return Returns {@link Print_ErrorCode#PRINT_ERROR_NONE} if the execution is successful. + * {@link PRINT_ERROR_NO_PERMISSION} The permission {@code ohos.permission.PRINT} is needed. + * {@link PRINT_ERROR_RPC_FAILURE} Unable to connect to the print service. + * @syscap SystemCapability.Print.PrintFramework + * @since 13 + */ +Print_ErrorCode OH_Print_StartPrintByNative(const char *printJobName, + Print_PrintDocCallback printDocCallback, + void *context); + #ifdef __cplusplus } #endif diff --git a/BasicServicesKit/ohprint.ndk.json b/BasicServicesKit/ohprint.ndk.json index 8d2491d0f96a1a034dc7d02c077a7981660580c1..e4e54c4fd070430c1f53ef1b8a517ba308f0f3dd 100644 --- a/BasicServicesKit/ohprint.ndk.json +++ b/BasicServicesKit/ohprint.ndk.json @@ -66,5 +66,9 @@ { "first_introduced": "12", "name": "OH_Print_RestorePrinterProperties" + }, + { + "first_introduced": "13", + "name": "OH_Print_StartPrintByNative" } ] diff --git a/BasicServicesKit/os_account.h b/BasicServicesKit/os_account.h index a93a32b4b579bef078ab04be747b520d86aef457..2a90d0cfdf64e8cfcc99f4c3d8e3d53cc42237fd 100644 --- a/BasicServicesKit/os_account.h +++ b/BasicServicesKit/os_account.h @@ -13,9 +13,6 @@ * limitations under the License. */ -#ifndef OS_ACCOUNT_H -#define OS_ACCOUNT_H - /** * @addtogroup OsAccount * @{ @@ -23,6 +20,7 @@ * @brief Provide the definition of the C interface for the native OsAccount. * @since 12 */ + /** * @file os_account.h * @@ -33,6 +31,9 @@ * @since 12 */ +#ifndef OS_ACCOUNT_H +#define OS_ACCOUNT_H + #include #include "os_account_common.h" diff --git a/BasicServicesKit/os_account_common.h b/BasicServicesKit/os_account_common.h index 932b398c58b04102846ef7661762fe775d5c0a20..334ad730b2103c8d77fa38be57153b612a516c0c 100644 --- a/BasicServicesKit/os_account_common.h +++ b/BasicServicesKit/os_account_common.h @@ -13,9 +13,6 @@ * limitations under the License. */ -#ifndef OS_ACCOUNT_COMMON_H -#define OS_ACCOUNT_COMMON_H - /** * @addtogroup OsAccount * @{ @@ -23,6 +20,7 @@ * @brief Provide the definition of the C interface for the native OsAccount. * @since 12 */ + /** * @file os_account_common.h * @@ -33,6 +31,9 @@ * @since 12 */ +#ifndef OS_ACCOUNT_COMMON_H +#define OS_ACCOUNT_COMMON_H + #ifdef __cplusplus extern "C" { #endif diff --git a/BasicServicesKit/time_service.h b/BasicServicesKit/time_service.h new file mode 100644 index 0000000000000000000000000000000000000000..b33159e86c0a4f57f8671abf93e086ddf64ce083 --- /dev/null +++ b/BasicServicesKit/time_service.h @@ -0,0 +1,80 @@ +/* + * 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. + */ + +#ifndef TIME_SERVICE_H +#define TIME_SERVICE_H + +/** + * @addtogroup TimeService + * @{ + * + * @brief Declares the time zone capabilities provided by TimeService to an application. + * @since 12 + */ +/** + * @file time_service.h + * + * @brief Declares the APIs for obtaining the time zone information. + * @library libtime_service_ndk.so + * @kit BasicServicesKit + * @syscap SystemCapability.MiscServices.Time + * @since 12 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes. + * + * @since 12 + */ +typedef enum TimeService_ErrCode { + /** @error Success.*/ + TIMESERVICE_ERR_OK = 0, + + /** @error Failed to obtain system parameters.*/ + TIMESERVICE_ERR_INTERNAL_ERROR = 13000001, + + /** @error Invalid parameter.*/ + TIMESERVICE_ERR_INVALID_PARAMETER = 13000002, +} TimeService_ErrCode; + +/** + * @brief Obtains the current system time zone. + * + * @param timeZone Pointer to an array of characters indicating the time zone ID. On success, the string indicates the + * current system time zone ID. On failure, the string is empty. The string is terminated using '\0'. + * @param len Size of the memory allocated for the time zone ID character array. There is no upper limit for the length + * of the time zone ID. It is recommended to allocate sufficient memory, at least not less than 31 bytes. + * @return Returns {@link TIMESERVICE_ERR_OK} if the operation is successful. + * Returns {@link TIMESERVICE_ERR_INTERNAL_ERROR} if obtaining the system parameters fails. + * Returns {@link TIMESERVICE_ERR_INVALID_PARAMETER} if timeZone is a null pointer or the length of the + * time zone ID (excluding the terminating character ('\0')) is greater than or equal to len. + * @syscap SystemCapability.MiscServices.Time + * @since 12 + */ +TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif /* TIME_SERVICE_H */ \ No newline at end of file diff --git a/ConnectivityKit/bluetooth/BUILD.gn b/ConnectivityKit/bluetooth/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..869366f31d196301aa0499d694ef943d419fda77 --- /dev/null +++ b/ConnectivityKit/bluetooth/BUILD.gn @@ -0,0 +1,29 @@ +# 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("bluetooth_ndk_header") { + dest_dir = "$ndk_headers_out_dir/ConnectivityKit/bluetooth" + sources = [ "./oh_bluetooth.h" ] +} + +ohos_ndk_library("libbluetooth_ndk") { + ndk_description_file = "./libbluetooth.ndk.json" + output_name = "bluetooth_ndk" + output_extension = "so" + min_compact_version = "13" + system_capability = "SystemCapability.Communication.Bluetooth.Core" + system_capability_headers = [ "./oh_bluetooth.h" ] +} diff --git a/ConnectivityKit/bluetooth/libbluetooth.ndk.json b/ConnectivityKit/bluetooth/libbluetooth.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..d8b21f30ce75182012fd52c07d3e0f4f7a418d8d --- /dev/null +++ b/ConnectivityKit/bluetooth/libbluetooth.ndk.json @@ -0,0 +1,5 @@ +[ + { + "name": "OH_Bluetooth_GetBluetoothSwitchState" + } +] \ No newline at end of file diff --git a/ConnectivityKit/bluetooth/oh_bluetooth.h b/ConnectivityKit/bluetooth/oh_bluetooth.h new file mode 100644 index 0000000000000000000000000000000000000000..cbe820916a8d670da02e6e9ecf27c35ad0deaeaa --- /dev/null +++ b/ConnectivityKit/bluetooth/oh_bluetooth.h @@ -0,0 +1,95 @@ +/* + * 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 Bluetooth + * @{ + * + * @brief Provide functions for querying the status of bluetooth switch. + * @since 13 + */ +/** + * @file oh_bluetooth.h + * @kit ConnectivityKit + * @brief Define interfaces for querying bluetooth switch status. + * @library libbluetooth.so + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 13 + */ + +#ifndef OH_BLUETOOTH_H +#define OH_BLUETOOTH_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumeration state of bluetooth switch. + * + * @since 13 + */ +typedef enum Bluetooth_SwitchState { + /** Indicates the local bluetooth is off. */ + BLUETOOTH_STATE_OFF = 0, + /** Indicates the local bluetooth is turning on. */ + BLUETOOTH_STATE_TURNING_ON = 1, + /** Indicates the local bluetooth is on, and ready for use. */ + BLUETOOTH_STATE_ON = 2, + /** Indicates the local bluetooth is turning off. */ + BLUETOOTH_STATE_TURNING_OFF = 3, + /** Indicates the local bluetooth is turning LE mode on. */ + BLUETOOTH_STATE_BLE_TURNING_ON = 4, + /** Indicates the local bluetooth is in LE only mode. */ + BLUETOOTH_STATE_BLE_ON = 5, + /** Indicates the local bluetooth is turning off LE only mode. */ + BLUETOOTH_STATE_BLE_TURNING_OFF = 6 +} Bluetooth_SwitchState; + +/** + * @brief Enumeration the bluetooth result codes. + * + * @since 13 + */ +typedef enum Bluetooth_ResultCode { + /** + * @error The operation is successful. + */ + BLUETOOTH_SUCCESS = 0, + /** + * @error Parameter error. Possible reasons: 1. The input parameter is a null pointer; + * 2. Parameter values exceed the defined range. + */ + BLUETOOTH_INVALID_PARAM = 401, +} Bluetooth_ResultCode; + +/** + * @brief Get the bluetooth switch state. + * + * @param state - It is a pointer used to receive bluetooth switch status values. + * The caller needs to pass in a non empty boolean pointer, otherwise an error will be returned. + * For a detailed definition, please refer to {@link Bluetooth_SwitchState}. + * @return Bluetooth functions result code. + * For a detailed definition, please refer to {@link Bluetooth_ResultCode}. + * {@link BLUETOOTH_SUCCESS} Successfully obtained the bluetooth switch status. + * {@link BLUETOOTH_INVALID_PARAM} The input parameter enabled is a null pointer. + * @since 13 + */ +Bluetooth_ResultCode OH_Bluetooth_GetBluetoothSwitchState(Bluetooth_SwitchState *state); +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_BLUETOOTH_H \ No newline at end of file diff --git a/ConnectivityKit/wifi/BUILD.gn b/ConnectivityKit/wifi/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..19812ca5c9565344db3df28a9e3c23397fd714ac --- /dev/null +++ b/ConnectivityKit/wifi/BUILD.gn @@ -0,0 +1,29 @@ +# 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("wifi_ndk_header") { + dest_dir = "$ndk_headers_out_dir/ConnectivityKit/wifi" + sources = [ "./oh_wifi.h" ] +} + +ohos_ndk_library("libwifi_ndk") { + ndk_description_file = "./libwifi.ndk.json" + output_name = "wifi_ndk" + output_extension = "so" + min_compact_version = "13" + system_capability = "SystemCapability.Communication.WiFi.STA" + system_capability_headers = [ "./oh_wifi.h" ] +} diff --git a/ConnectivityKit/wifi/libwifi.ndk.json b/ConnectivityKit/wifi/libwifi.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..178e649260616fe8ca02afd2db7b40c7ac210ef2 --- /dev/null +++ b/ConnectivityKit/wifi/libwifi.ndk.json @@ -0,0 +1,6 @@ +[ + { + "first_introduced": "13", + "name": "OH_Wifi_IsWifiEnabled" + } +] \ No newline at end of file diff --git a/ConnectivityKit/wifi/oh_wifi.h b/ConnectivityKit/wifi/oh_wifi.h new file mode 100644 index 0000000000000000000000000000000000000000..1d8e1d64516cd22c4f20fbacbc4c2a502905bfa0 --- /dev/null +++ b/ConnectivityKit/wifi/oh_wifi.h @@ -0,0 +1,90 @@ +/* + * 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 Wifi + * @{ + * + * @brief Provide functions for querying the status of wifi switch. + * @since 13 + */ +/** + * @file oh_wifi.h + * @kit ConnectivityKit + * @brief Define interfaces for querying wifi switch status. + * @library libwifi.so + * @syscap SystemCapability.Communication.WiFi.STA + * @since 13 + */ + +#ifndef OH_WIFI_H +#define OH_WIFI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the wifi result codes. + * + * @since 13 + */ +typedef enum Wifi_ResultCode { + /** + * @error The operation is successful. + */ + WIFI_SUCCESS = 0, + /** + * @error Permission verification failed. The application does not have the + * permission required to call the API. + */ + WIFI_PERMISSION_DENIED = 201, + /** + * @error Parameter error. Possible reasons: 1. The input parameter is a null pointer;\n + * 2. Parameter values exceed the defined range.\n + */ + WIFI_INVALID_PARAM = 401, + /** + * @error Capability not supported. Failed to call function due to limited device capabilities. + */ + WIFI_NOT_SUPPORTED = 801, + /** + * @error Operation failed. + * Possible reasons: Internal execution failed. + */ + WIFI_OPERATION_FAILED = 2501000 +} Wifi_ResultCode; + +/** + * @brief Check whether the wifi switch is enabled. + * + * @param enabled - It is a boolean pointer used to receive wifi switch status values.\n + * Equal to true indicates that the wifi switch is turned on, false indicates that\n + * the wifi switch is turned off.\n + * The caller needs to pass in a non empty boolean pointer, otherwise an error will be returned.\n + * @return wifi functions result code.\n + * For a detailed definition, please refer to {@link Wifi_ResultCode}.\n + * {@link WIFI_SUCCESS} Successfully obtained the wifi switch status.\n + * {@link WIFI_INVALID_PARAM} The input parameter enabled is a null pointer.\n + * {@link WIFI_OPERATION_FAILED} Internal execution failed.\n + * @since 13 + */ +Wifi_ResultCode OH_Wifi_IsWifiEnabled(bool *enabled); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_WIFI_H \ No newline at end of file diff --git a/DataProtectionKit/BUILD.gn b/DataProtectionKit/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b6f4d3b5e6a2ec2c605d4cfacb54fef7c68d3a01 --- /dev/null +++ b/DataProtectionKit/BUILD.gn @@ -0,0 +1,28 @@ +# 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("dlppermission_capi_header") { + dest_dir = "$ndk_headers_out_dir/DataProtectionKit" + sources = [ "./dlp_permission_api.h" ] +} + +ohos_ndk_library("libohdlp_permission") { + output_name = "ohdlp_permission" + output_extension = "so" + ndk_description_file = "./libdlppermission.ndk.json" + system_capability = "SystemCapability.Security.DataLossPrevention" + system_capability_headers = [ "DataProtectionKit/dlp_permission_api.h" ] +} diff --git a/DataProtectionKit/dlp_permission_api.h b/DataProtectionKit/dlp_permission_api.h new file mode 100644 index 0000000000000000000000000000000000000000..057c0fd32b66b8912288bb61cb207074dc34c49d --- /dev/null +++ b/DataProtectionKit/dlp_permission_api.h @@ -0,0 +1,172 @@ +/* + * 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 DlpPermissionApi + * @{ + * + * @brief Provides the capability to access the data loss prevention (DLP) files. + * + * @since 13 + */ + +/** + * @file dlp_permission_api.h + * + * @brief Declares the APIs for accessing the data loss prevention (DLP) files. + * + * @library libohdlp_permission.so + * @kit DataProtectionKit + * @syscap SystemCapability.Security.DataLossPrevention + * @since 13 + */ + +#ifndef DLP_PERMISSION_API_H +#define DLP_PERMISSION_API_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes. + * + * @since 13 + */ +typedef enum { + /** @error The operation is successful. */ + ERR_OH_SUCCESS = 0, + /** @error Invalid parameter value. */ + ERR_OH_INVALID_PARAMETER = 19100001, + /** @error No permission to call this API, which is available only for DLP sandbox applications. */ + ERR_OH_API_ONLY_FOR_SANDBOX = 19100006, + /** @error No permission to call this API, which is available only for non-DLP sandbox applications. */ + ERR_OH_API_NOT_FOR_SANDBOX = 19100007, + /** @error The system ability works abnormally. */ + ERR_OH_SYSTEM_SERVICE_EXCEPTION = 19100011, + /** @error Indicates the memory error. */ + ERR_OH_OUT_OF_MEMORY = 19100012, + /** @error DisplayName missing in want. */ + ERR_OH_APPLICATION_NOT_AUTHORIZED = 19100018 +} DLP_ErrCode; + +/** + * @brief Enumerates the access permissions for a DLP file. + * + * @since 13 + */ +typedef enum { + /** No permission. */ + NO_PERMISSION = 0, + /** Read-only. */ + READ_ONLY = 1, + /** Edit. */ + CONTENT_EDIT = 2, + /** Full control. */ + FULL_CONTROL = 3 +} DLP_FileAccess; + +/** + * @brief Obtains the permission info of this DLP file. + * + * @param dlpFileAccess - Indicates the access permission for the DLP file. + * @param flags - Indicates the actions allowed for the DLP file. + * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. + * {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid. + * {@link DLP_ErrCode#ERR_OH_API_ONLY_FOR_SANDBOX} 19100006 - If no permission to + * call this API, which is available only for DLP sandbox applications. + * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability + * works abnormally. + * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. + * @since 13 + */ +DLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags); + +/** + * @brief Obtains the original file name from a DLP file name. + * This method removes the DLP file name extension from the DLP file name. + * + * @param fileName - Indicates the DLP file name. + * @param originalFileName - Indicates the original file name obtained. + * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. + * {@link DLP_ErrCode#ERR_OH_INVALID_PARAMS} 19100001 - If the parameter value is invalid. + * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. + * @since 13 + */ +DLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char **originalFileName); + +/** + * @brief Checks whether current application is in the DLP sandbox. + * + * @param isInSandbox - Indicates output parameter, + * {@code true} if current application is in a DLP sandbox, {@code false} otherwise. + * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. + * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability + * works abnormally. + * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. + * @since 13 + */ +DLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox); + +/** + * @brief Sets sandbox application configuration. + * + * @param configInfo - Configuration of the sandbox application. + * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. + * {@link DLP_ErrCode#ERR_OH_INVALID_PARAMETER} 19100001 - If the parameter value is invalid. + * {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to + * call this API, which is available only for non-DLP sandbox applications. + * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability + * works abnormally. + * {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application. + * @since 13 + */ +DLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo); + +/** + * @brief Obtains sandbox application configuration. + * + * @param configInfo - Configuration of the sandbox application. + * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. + * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability + * works abnormally. + * {@link DLP_ErrCode#ERR_OH_OUT_OF_MEMORY} 19100012 - If the memory error. + * {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application. + * @since 13 + */ +DLP_ErrCode OH_DLP_GetSandboxAppConfig(char **configInfo); + +/** + * @brief Cleans sandbox application configuration. + * + * @return {@link DLP_ErrCode#ERR_OH_SUCCESS} 0 - If the operation is successful. + * {@link DLP_ErrCode#ERR_OH_API_NOT_FOR_SANDBOX} 19100007 - If no permission to + * call this API, which is available only for non-DLP sandbox applications. + * {@link DLP_ErrCode#ERR_OH_SYSTEM_SERVICE_EXCEPTION} 19100011 - If the system ability + * works abnormally. + * {@link DLP_ErrCode#ERR_OH_APPLICATION_NOT_AUTHORIZED} 19100018 - If not authorized application. + * @since 13 + */ +DLP_ErrCode OH_DLP_CleanSandboxAppConfig(); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* DLP_PERMISSION_API_H */ \ No newline at end of file diff --git a/DataProtectionKit/libdlppermission.ndk.json b/DataProtectionKit/libdlppermission.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..6de2fcd8759e825e7c5c99d784ad3d4fb296fa73 --- /dev/null +++ b/DataProtectionKit/libdlppermission.ndk.json @@ -0,0 +1,26 @@ +[ + { + "first_introduced": "13", + "name": "OH_DLP_GetDlpPermissionInfo" + }, + { + "first_introduced": "13", + "name": "OH_DLP_GetOriginalFileName" + }, + { + "first_introduced": "13", + "name": "OH_DLP_IsInSandbox" + }, + { + "first_introduced": "13", + "name": "OH_DLP_SetSandboxAppConfig" + }, + { + "first_introduced": "13", + "name": "OH_DLP_GetSandboxAppConfig" + }, + { + "first_introduced": "13", + "name": "OH_DLP_CleanSandboxAppConfig" + } +] \ No newline at end of file diff --git a/LocationKit/BUILD.gn b/LocationKit/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b5718e151b6855764be4a008588249c329f593c7 --- /dev/null +++ b/LocationKit/BUILD.gn @@ -0,0 +1,35 @@ +# 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("location_ndk_header") { + dest_dir = "$ndk_headers_out_dir/LocationKit" + sources = [ + "./oh_location.h", + "./oh_location_type.h", + ] +} + +ohos_ndk_library("liblocation_ndk") { + ndk_description_file = "./liblocation.ndk.json" + output_name = "location_ndk" + output_extension = "so" + min_compact_version = "13" + system_capability = "SystemCapability.Location.Location.Core" + system_capability_headers = [ + "./oh_location.h", + "./oh_location_type.h", + ] +} diff --git a/LocationKit/liblocation.ndk.json b/LocationKit/liblocation.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..181ff9dc119791688005e7d7f08f7f88d00de07a --- /dev/null +++ b/LocationKit/liblocation.ndk.json @@ -0,0 +1,35 @@ +[ + { + "name": "OH_Location_IsLocatingEnabled" + }, + { + "name": "OH_Location_StartLocating" + }, + { + "name": "OH_Location_StopLocating" + }, + { + "name": "OH_LocationInfo_GetBasicInfo" + }, + { + "name": "OH_LocationInfo_GetAdditionalInfo" + }, + { + "name": "OH_Location_CreateRequestConfig" + }, + { + "name": "OH_Location_DestroyRequestConfig" + }, + { + "name": "OH_LocationRequestConfig_SetUseScene" + }, + { + "name": "OH_LocationRequestConfig_SetPowerConsumptionScene" + }, + { + "name": "OH_LocationRequestConfig_SetInterval" + }, + { + "name": "OH_LocationRequestConfig_SetCallback" + } +] \ No newline at end of file diff --git a/LocationKit/oh_location.h b/LocationKit/oh_location.h new file mode 100644 index 0000000000000000000000000000000000000000..62eac6710d5c696f7e92687ae8867ef92cf51b92 --- /dev/null +++ b/LocationKit/oh_location.h @@ -0,0 +1,104 @@ +/* + * 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 Location + * @{ + * + * @brief Provide functions for querying the status of location switch, starting and stopping locating. + * @since 13 + */ +/** + * @file oh_location.h + * @kit LocationKit + * @brief Define interfaces for querying location switch status, starting locating, and stopping locating. + * @library liblocation_ndk.so + * @syscap SystemCapability.Location.Location.Core + * @since 13 + */ + +#ifndef OH_LOCATION_H +#define OH_LOCATION_H + +#include "oh_location_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Check whether the location switch is enabled. + * + * @param enabled - It is a boolean pointer used to receive location switch status values.\n + * Equal to true indicates that the location switch is turned on, false indicates that\n + * the location switch is turned off.\n + * The caller needs to pass in a non empty boolean pointer, otherwise an error will be returned.\n + * @return Location functions result code.\n + * For a detailed definition, please refer to {@link Location_ResultCode}.\n + * {@link LOCAION_SUCCESS} Successfully obtained the location switch status.\n + * {@link LOCATION_INVALID_PARAM} The input parameter enabled is a null pointer.\n + * {@link LOCATION_SERVICE_UNAVAILABLE} Abnormal startup of location services.\n + * @since 13 + */ +Location_ResultCode OH_Location_IsLocatingEnabled(bool* enabled); + +/** + * @brief Start locating and subscribe location changed. + * + * @param requestConfig - Pointer to the locating request parameters.\n + * For details, see {@link Location_RequestConfig}.\n + * You can use {@link OH_Location_CreateRequestConfig} to create an instance.\n + * @return Location functions result code.\n + * For a detailed definition, please refer to {@link Location_ResultCode}.\n + * {@link LOCAION_SUCCESS} Successfully start locating.\n + * {@link LOCATION_INVALID_PARAM} The input parameter requestConfig is a null pointer.\n + * {@link LOCATION_PERMISSION_DENIED} Permission verification failed. The application does not have the\n + * permission required to call the API.\n + * {@link LOCATION_NOT_SUPPORTED} Capability not supported.\n + * Failed to call function due to limited device capabilities.\n + * {@link LOCATION_SERVICE_UNAVAILABLE} Abnormal startup of location services.\n + * {@link LOCATION_SWITCH_OFF} The location switch is off.\n + * @permission ohos.permission.APPROXIMATELY_LOCATION + * @since 13 + */ +Location_ResultCode OH_Location_StartLocating(const Location_RequestConfig* requestConfig); + +/** + * @brief Stop locating and unsubscribe location changed. + * + * @param requestConfig - Pointer to the locating request parameters.\n + * For details, see {@link Location_RequestConfig}.\n + * This parameter needs to be the same as the requestConfig pointer passed in\n + * {@link OH_Location_StartLocating}.\n + * @return Location functions result code.\n + * For a detailed definition, please refer to {@link Location_ResultCode}.\n + * {@link LOCAION_SUCCESS} Successfully stop locationg.\n + * {@link LOCATION_INVALID_PARAM} 1.The input parameter is a null pointer.\n + * 2.Different from the requestConfig pointer passed from {@link OH_Location_StartLocating}.\n + * {@link LOCATION_PERMISSION_DENIED} Permission verification failed. The application does not have the\n + * permission required to call the API.\n + * {@link LOCATION_NOT_SUPPORTED} Capability not supported.\n + * Failed to call function due to limited device capabilities.\n + * {@link LOCATION_SERVICE_UNAVAILABLE} Possible reasons: 1. Abnormal startup of location services.\n + * {@link LOCATION_SWITCH_OFF} The location switch is off.\n + * @permission ohos.permission.APPROXIMATELY_LOCATION + * @since 13 + */ +Location_ResultCode OH_Location_StopLocating(const Location_RequestConfig* requestConfig); +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_LOCATION_H \ No newline at end of file diff --git a/LocationKit/oh_location_type.h b/LocationKit/oh_location_type.h new file mode 100644 index 0000000000000000000000000000000000000000..729a61051d24dc4d89c3e11aecf9eabefeebee2a --- /dev/null +++ b/LocationKit/oh_location_type.h @@ -0,0 +1,372 @@ +/* + * 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 Location + * @{ + * + * @brief Provide functions for querying the status of location switch, starting and stopping locating. + * + * @since 13 + */ + +/** + * @file oh_location_type.h + * @kit LocationKit + * @brief Declares the common location attributes. + * @library liblocation_ndk.so + * @syscap SystemCapability.Location.Location.Core + * @since 13 + */ + +#ifndef OH_LOCATION_TYPE_H +#define OH_LOCATION_TYPE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the location result codes. + * + * @since 13 + */ +typedef enum Location_ResultCode { + /** + * @error The operation is successful. + */ + LOCATION_SUCCESS = 0, + /** + * @error Permission verification failed. The application does not have the + * permission required to call the API. + */ + LOCATION_PERMISSION_DENIED = 201, + /** + * @error Parameter error. Possible reasons: 1. The input parameter is a null pointer;\n + * 2. Parameter values exceed the defined range.\n + */ + LOCATION_INVALID_PARAM = 401, + /** + * @error Capability not supported. Failed to call function due to limited device capabilities. + */ + LOCATION_NOT_SUPPORTED = 801, + /** + * @error The location service is unavailable. + * Possible reasons: Abnormal startup of location services.\n + */ + LOCATION_SERVICE_UNAVAILABLE = 3301000, + /** + * @error The location switch is off. + */ + LOCATION_SWITCH_OFF = 3301100 +} Location_ResultCode; + +/** + * @brief Enumeration values of use scenarios. + * + * @since 13 + */ +typedef enum Location_UseScene { + /** + * Indicates the navigation scenario. + * This feature applies to outdoor scenarios where real-time device locations need + * to be obtained, such as vehicle-mounted and pedestrian navigation. + * The GNSS positioning technology is used to provide positioning services, and the + * power consumption is high. + */ + LOCATION_USE_SCENE_NAVIGATION = 0x0401, + /** + * Indicates the sport scenario. + * This feature applies to scenarios where user location tracks are recorded, + * for example, sports apps. The GNSS positioning technology is used to provide + * positioning services, and the power consumption is high. + */ + LOCATION_USE_SCENE_SPORT = 0x0402, + /** + * Indicates a travel scenario. + * This mode applies to travel scenarios, such as taxi and public transportation. + * The GNSS positioning technology is used to provide positioning services, and + * the power consumption is high. + */ + LOCATION_USE_SCENE_TRANSPORT = 0x0403, + /** + * Indicates the daily service usage scenario. + * This mode applies to scenarios where precise user location is not required, + * such as news, online shopping, and ordering applications. + * In this scenario, only a network positioning technology is used to provide a + * positioning service, and power consumption is relatively low. + */ + LOCATION_USE_SCENE_DAILY_LIFE_SERVICE = 0x0404 +} Location_UseScene; + +/** + * @brief Enumerates the power consumption scenario. + * + * @since 13 + */ +typedef enum Location_PowerConsumptionScene { + /** + * High power consumption. + * GNSS positioning technology is mainly used. We will use network positioning + * technology to provide services before GNSS provides stable location results; + * During continuous positioning, if the GNSS positioning result cannot be obtained + * for more than 30 seconds, the network positioning technology is used to obtain + * the location. Consumes a large number of hardware resources and power. + */ + LOCATION_HIGH_POWER_CONSUMPTION = 0x0601, + /** + * Low power consumption. + * This mode applies to scenarios that do not require high user location precision, + * such as news, online shopping, and meal ordering. + * In this scenario, only a network positioning technology is used to provide a + * positioning service, and power consumption is relatively low. + */ + LOCATION_LOW_POWER_CONSUMPTION = 0x0602, + /** + * No power consumption. + * In this scenario, the location is not proactively triggered. The location is + * returned to the current app only when other apps are located. + */ + LOCATION_NO_POWER_CONSUMPTION = 0x0603 +} Location_PowerConsumptionScene; + +/** + * @brief Enumerates the source type of location. + * + * @since 13 + */ +typedef enum Location_SourceType { + /** + * The positioning result is based on the GNSS positioning technology. + */ + LOCATION_SOURCE_TYPE_GNSS = 1, + /** + * The positioning result comes from the network positioning technology. + */ + LOCATION_SOURCE_TYPE_NETWORK = 2, + /** + * The positioning result comes from the high-precision indoor positioning technology. + */ + LOCATION_SOURCE_TYPE_INDOOR = 3, + /** + * The positioning result comes from the high-precision positioning technology. + */ + LOCATION_SOURCE_TYPE_RTK = 4 +} Location_SourceType; + +/** + * @brief Defines the location information. + * + * @since 13 + */ +typedef struct Location_BasicInfo { + /** + * Indicates latitude information, with positive values indicating north latitude\n + * and negative values indicating south latitude. The value range is -90 to 90.\n + * Only supports WGS84 coordinate system.\n + */ + double latitude; + /** + * Indicates longitude information, positive values indicate east longitude,\n + * and negative values indicate west longitude. The value range is -180 to 180.\n + * Only supports WGS84 coordinate system.\n + */ + double longitude; + /** + * Altitude in meters. + */ + double altitude; + /** + * Horizontal location accuracy in meters. + */ + double accuracy; + /** + * Speed in meters per second. + */ + double speed; + /** + * Heading in degrees. The value range is 0 to 360. + */ + double direction; + /** + * Timestamp for the location fix. Number of milliseconds since January 1, 1970. + */ + int64_t timeForFix; + /** + * Time since the system was booted, and include deep sleep. The unit is nanosecond. + */ + int64_t timeSinceBoot; + /** + * Vertical position accuracy in meters. + */ + double altitudeAccuracy; + /** + * Speed accuracy in meter per seconds. + */ + double speedAccuracy; + /** + * Direction accuracy in degrees. The value range is 0 to 360. + */ + double directionAccuracy; + /** + * Time uncertainty in nanosecond. + */ + int64_t uncertaintyOfTimeSinceBoot; + /** + * Indicates the source of the location result. + */ + Location_SourceType locationSourceType; +} Location_BasicInfo; + +/** + * @brief Define the structure of location information. + * @since 13 + */ +typedef struct Location_Info Location_Info; + +/** + * @brief Obtain basic location information. + * + * @param location - Pointer to the location information structure.\n + * A non-null pointer is required. The pointer can be obtained from {@link Location_InfoCallback}.\n + * @return Return the basic information structure of the location.\n + * For a detailed definition, please refer to {@link Location_BasicInfo}.\n + * @since 13 + */ +Location_BasicInfo OH_LocationInfo_GetBasicInfo(Location_Info* location); + +/** + * @brief Obtain additional information from the location information. + * + * @param location - Pointer to the location information structure.\n + * A non-null pointer is required. The pointer can be obtained from {@link Location_InfoCallback}.\n + * @param additionalInfo - Non null pointers of char type; This variable is used to store additional\n + * information strings. The string is in JSON format.\n + * The pointer and the corresponding memory are created by the caller.\n + * You are advised to apply for a memory of 256 bytes or more.\n + * If a null pointer is passed, an error code is returned.\n + * @param length - Memory size of additionalInfo. + * @return Location functions result code.\n + * For a detailed definition, please refer to {@link Location_ResultCode}.\n + * {@link LOCAION_SUCCESS} Successfully obtained additional information.\n + * {@link LOCATION_INVALID_PARAM} 1.The input parameter location or additionalInfo is a null pointer.\n + * 2.The input parameter length is too small to store additional information.\n + * @since 13 + */ +Location_ResultCode OH_LocationInfo_GetAdditionalInfo(Location_Info* location, + char* additionalInfo, uint32_t length); + +/** + * @brief Defines the callback function used to report location data. + * + * @param location - Pointer to the {@link Location_Info} instance. Carry the latest location information.\n + * The memory of the location instance is recycled at the end of {@link Location_InfoCallback}.\n + * Before that, call {@link OH_LocationInfo_GetBasicInfo} and other interfaces to obtain location information.\n + * @param userData - Pointer to an application data structure, this parameter is passed in\n + * through {@link OH_LocationRequestConfig_SetCallback}.\n + * @since 13 + */ +typedef void (*Location_InfoCallback)(Location_Info* location, void* userData); + +/** + * @brief Define the structure of location request parameters. + * @since 13 + */ +typedef struct Location_RequestConfig Location_RequestConfig; + +/** + * @brief Create a location request parameter structure instance. + * + * @return Return a pointer to the {@ link Location_RequestConfig} instance. \n + * If NULL is returned, it indicates that the creation failed. \n + * The possible reason is that the application address space is full,\n + * resulting in the inability to allocate space. \n + * @since 13 + */ +Location_RequestConfig* OH_Location_CreateRequestConfig(void); + +/** + * @brief Destroy the location request parameter instance and reclaim memory. + * + * @param requestConfig - Pointer to {@link Location_RequestConfig} instance.\n + * The instance was created by {@link OH_Location_CreateRequestConfig}.\n + * @since 13 + */ +void OH_Location_DestroyRequestConfig(Location_RequestConfig* requestConfig); + +/** + * @brief Set the use scenario in the location request parameter.\n + * Prioritize useScene in the location request parameter {@link Location_RequestConfig}.\n + * If useScene is set, powerConsumptionScene becomes invalid.\n + * If useScene is not set and powerConsumptionScene is set, this parameter takes effect.\n + * If both parameters are not set, the default useScene is\n + * {@link LOCATION_USE_SCENE_DAILY_LIFE_SERVICE},\n + * and the powerConsumptionCenario parameter is invalid.\n + * + * @param requestConfig - Pointer to the {@link Location_RequestConfig} instance.\n + * The instance was created by {@link OH_Location_CreateRequestConfig}.\n + * @param useScene - Representing the use scenario during location requests.\n + * The default value is {@link LOCATION_USE_SCENE_DAILY_LIFE_SERVICE}\n. + * For a detailed definition, please refer to {@link Location_UseScene}.\n + * @since 13 + */ +void OH_LocationRequestConfig_SetUseScene(Location_RequestConfig* requestConfig, + Location_UseScene useScene); + +/** + * @brief Set the power consumption scenario in the location request parameters. + * + * @param requestConfig - Pointer to the {@link Location_RequestConfig} instance.\n + * The instance was created by {@link OH_Location_CreateRequestConfig}.\n + * @param powerConsumptionScene - Represents the power consumption scenario for location requests.\n + * The recognition value is {@link LOCATION_LOW_POWER_CONSUMPTION}.\n + * For a detailed definition, please refer to {@link Location_PowerConsumptionScene}.\n + * @since 13 + */ +void OH_LocationRequestConfig_SetPowerConsumptionScene(Location_RequestConfig* requestConfig, + Location_PowerConsumptionScene powerConsumptionScene); + +/** + * @brief Set the location reporting interval in the location request parameter. + * + * @param requestConfig - Pointer to the {@link Location_RequestConfig} instance.\n + * The instance was created by {@link OH_Location_CreateRequestConfig}.\n + * @param interval - Indicates the time interval for location reporting, in seconds.\n + * The value is greater than or equal to 1. The default value is 1.\n + * @since 13 + */ +void OH_LocationRequestConfig_SetInterval(Location_RequestConfig* requestConfig, + int interval); + +/** + * @brief Set up a callback function for receiving location information. + * + * @param requestConfig - Pointer to the {@link Location_RequestConfig} instance.\n + * The instance was created by {@link OH_Location_CreateRequestConfig}.\n + * @param callback - Pointer to the callback function for receiving the location.\n + * For details, see {@link Location_InfoCallback}.\n + * @param userData - Pointer to the application data structure, which will be\n + * carried in the callback function.\n + * @since 13 + */ +void OH_LocationRequestConfig_SetCallback(Location_RequestConfig* requestConfig, + Location_InfoCallback callback, void* userData); +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_LOCATION_TYPE_H \ No newline at end of file diff --git a/NotificationKit/BUILD.gn b/NotificationKit/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..eff7eea6e08463b4c96eb12e3c44da7da587fbff --- /dev/null +++ b/NotificationKit/BUILD.gn @@ -0,0 +1,28 @@ +# 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("ohnotification_header") { + dest_dir = "$ndk_headers_out_dir/NotificationKit/" + sources = [ "./notification.h" ] +} + +ohos_ndk_library("libnotification_ndk") { + output_name = "ohnotification" + output_extension = "so" + ndk_description_file = "./libohnotification.ndk.json" + min_compact_version = "13" + system_capability = "SystemCapability.Notification.Notification" + system_capability_headers = [ "NotificationKit/notification.h" ] +} diff --git a/NotificationKit/libohnotification.ndk.json b/NotificationKit/libohnotification.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..24b56b30a00063e07790c859328c2a8420f99f74 --- /dev/null +++ b/NotificationKit/libohnotification.ndk.json @@ -0,0 +1,6 @@ +[ + { + "first_introduced": "13", + "name": "OH_Notification_IsNotificationEnabled" + } +] diff --git a/NotificationKit/notification.h b/NotificationKit/notification.h new file mode 100644 index 0000000000000000000000000000000000000000..d7a31be18c4125e1a1326dc294847d20ca24cc33 --- /dev/null +++ b/NotificationKit/notification.h @@ -0,0 +1,58 @@ +/* + * 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 NOTIFICATION + * @{ + * + * @brief Provides the definition of the C interface for the notification service. + * + * @since 13 + */ +/** + * @file notification.h + * + * @brief Declares the APIs of notification service. + * + * @library libohnotification.so + * @kit NotificationKit + * @syscap SystemCapability.Notification.Notification + * @since 13 + */ + +#ifndef OH_NOTIFICATION_H +#define OH_NOTIFICATION_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Checks whether this application is allowed to publish notifications. + * + * @return true - This application is allowed to publish notifications. + * false - This application is not allowed to publish notifications. + * @since 13 + */ +bool OH_Notification_IsNotificationEnabled(void); + +#ifdef __cplusplus +} +#endif +#endif // OH_NOTIFICATION_H +/** @} */ diff --git a/README.OpenSource b/README.OpenSource deleted file mode 100644 index 0b04b76a88869e4a5b3be5d926cdbd07b444710d..0000000000000000000000000000000000000000 --- a/README.OpenSource +++ /dev/null @@ -1,83 +0,0 @@ -[ - { - "Name" : "zlib", - "License" : "zlib/libpng License", - "License File" : "LICENSE", - "Version Number" : "v1.2.12", - "Owner" : "gongjunsong@huawei.com", - "Upstream URL" : "https://github.com/madler/zlib/archive/refs/tags/v1.2.12.tar.gz", - "Description" : "zlib 1.2.12 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files" - }, - { - "Name": "libuv", - "License": "MIT License", - "License File": "LICENSE", - "Version Number": "v1.44.1", - "Owner": "sunbingxin@huawei.com", - "Upstream URL": "https://github.com/libuv/libuv", - "Description": "libuv is a multi-platform support library with a focus on asynchronous I/O." - }, - { - "Name": "MindSpore", - "License": "Apache License 2.0", - "License File": "LICENSE.txt", - "Version Number": "1.8.1", - "Owner": "zhuguodong0001@163.com", - "Upstream URL": "https://gitee.com/mindspore/mindspore/repository/archive/v1.8.1", - "Description": "MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios." - }, - { - "Name" : "musl", - "License" : "MIT License", - "License File" : "COPYRIGHT", - "Version Number" : "1.2.5", - "Owner" : "zhaoxinyuan9@huawei.com", - "Upstream URL" : "https://musl.libc.org", - "Description" : "musl is an MIT-licensed implementation of the standard C library" - }, - { - "Name": "node", - "License": "ISC License,Public Domain,MIT License,Free Software Foundation - MIT License,Apache License V2.0,ICU License,zlib/libpng License,BSD 2-Clause License,BSD 3-Clause License", - "License File": "LICENSE", - "Version Number": "14.21.2", - "Owner": "sunbingxin@huawei.com", - "Upstream URL": "http://www.nodejs.org/", - "Description": "Node.js is an open-source, cross-platform, JavaScript runtime environment. It executes JavaScript code outside of a browser." - }, - { - "Name": "Khronos Group - OpenSL ES", - "License": "null", - "License File": "NOTICE", - "Version Number": "1.0.1", - "Owner": "yangshuai67@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/OpenSL-ES-Registry.git", - "Description": "OpenSL ES™ is a royalty-free, cross-platform, hardware-accelerated audio API tuned for embedded systems." - }, - { - "Name": "EGL", - "License": "MIT License", - "License File": "LICENSE", - "Version Number": "1.5", - "Owner": "lizheng2@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/EGL-Registry.git", - "Description": "EGL is an interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system." - }, - { - "Name": "openGLES", - "License": "Apache-2.0", - "License File": "NOTICE", - "Version Number": "a301c9b4600e4074008b93fba17744a859fb763b", - "Owner": "lizheng2@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/OpenGL-Registry.git", - "Description": "The OpenGL ES registry contains specifications of the core API and shading language; specifications of Khronos- and vendor-approved OpenGL ES extensions; header files corresponding to the specificatio" - }, - { - "Name": "Vulkan", - "License": "Apache-2.0", - "License File": "LICENSE", - "Version Number": "v1.3.231", - "Owner": "mengzhaobing@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/Vulkan-Headers.git", - "Description": "Vulkan header files and API registry" - } -] diff --git a/ability/ability_runtime/child_process/libchild_process.ndk.json b/ability/ability_runtime/child_process/libchild_process.ndk.json index 6206b6310b1c6140e4cc5d484139fa908f7da455..b00d0d189533554ddc571ce9c2940cb8c929f08d 100644 --- a/ability/ability_runtime/child_process/libchild_process.ndk.json +++ b/ability/ability_runtime/child_process/libchild_process.ndk.json @@ -1,3 +1,10 @@ [ - { "name": "OH_Ability_CreateNativeChildProcess" } + { + "first_introduced": "12", + "name": "OH_Ability_CreateNativeChildProcess" + }, + { + "first_introduced": "13", + "name": "OH_Ability_StartNativeChildProcess" + } ] \ No newline at end of file diff --git a/ability/ability_runtime/child_process/native_child_process.h b/ability/ability_runtime/child_process/native_child_process.h index 5cce2512ab97db0d845516a9ce8c533a2a719a3e..a60cca63568834946710910b6b94f6fa1afb2f5a 100644 --- a/ability/ability_runtime/child_process/native_child_process.h +++ b/ability/ability_runtime/child_process/native_child_process.h @@ -13,11 +13,6 @@ * limitations under the License. */ -#ifndef OHOS_ABILITY_RUNTIME_C_NATIVE_CHILD_PROCESS_H -#define OHOS_ABILITY_RUNTIME_C_NATIVE_CHILD_PROCESS_H - -#include "IPCKit/ipc_cparcel.h" - /** * @addtogroup ChildProcess * @{ @@ -40,6 +35,11 @@ * @since 12 */ +#ifndef OHOS_ABILITY_RUNTIME_C_NATIVE_CHILD_PROCESS_H +#define OHOS_ABILITY_RUNTIME_C_NATIVE_CHILD_PROCESS_H + +#include "IPCKit/ipc_cparcel.h" + #ifdef __cplusplus extern "C" { #endif @@ -173,6 +173,111 @@ typedef void (*OH_Ability_OnNativeChildProcessStarted)(int errCode, OHIPCRemoteP int OH_Ability_CreateNativeChildProcess(const char* libName, OH_Ability_OnNativeChildProcessStarted onProcessStarted); +/** + * @brief The info of the file descriptors passed to child process. + * @since 13 + */ +typedef struct NativeChildProcess_Fd { + /** the key of the file descriptor. */ + char* fdName; + + /** the value of the file descriptor. */ + int32_t fd; + + /** the next pointer of the linked list. */ + struct NativeChildProcess_Fd* next; +} NativeChildProcess_Fd; + +/** + * @brief The list of the info of the file descriptors passed to child process. + * @since 13 + */ +typedef struct NativeChildProcess_FdList { + /** the head of the list. + * For details, see {@link NativeChildProcess_Fd}. + */ + struct NativeChildProcess_Fd* head; +} NativeChildProcess_FdList; + +/** + * @brief Enumerates the isolation modes used by the native child process module. + * @since 13 + */ +typedef enum NativeChildProcess_IsolationMode { + /** + * Normal isolation mode, parent process shares the same sandbox or internet with the child process. + */ + NCP_ISOLATION_MODE_NORMAL = 0, + + /** + * Isolated mode, parent process does not share the same sandbox or internet with the child process. + */ + NCP_ISOLATION_MODE_ISOLATED = 1, +} NativeChildProcess_IsolationMode; + +/** + * @brief The options used by the child process. + * @since 13 + */ +typedef struct NativeChildProcess_Options { + /** the isolation mode used by the child process. + * For details, see {@link NativeChildProcess_IsolationMode}. + */ + NativeChildProcess_IsolationMode isolationMode; + + /** reserved field for future extension purposes */ + int64_t reserved; +} NativeChildProcess_Options; + +/** + * @brief The arguments passed to the child process. + * @since 13 + */ +typedef struct NativeChildProcess_Args { + /** the entry parameter. */ + char* entryParams; + + /** the list of the info of the file descriptors passed to child process. + * For details, see {@link NativeChildProcess_FdList}. + */ + struct NativeChildProcess_FdList fdList; +} NativeChildProcess_Args; + +/** + * @brief Starts a child process, loads the specified dynamic library file. + * + * The dynamic library specified must implement a function with NativeChildProcess_Args as a + * pamameter(function name can be customized), and export the function, such as:\n + * 1. void Main(NativeChildProcess_Args args); + * + * The processing logic sequence is shown in the following pseudocode: \n + * Main process: \n + * 1. OH_Ability_StartNativeChildProcess(entryPoint, args, options)\n + * Child process: \n + * 2. dlopen(libName)\n + * 3. dlsym("Main")\n + * 4. Main(args)\n + * 5. The child process exits after the Main(args) function is returned \n + * + * @param entry Dynamic library and entry function loaded in child process, such as "libEntry.so:Main". + * The value cannot be nullptr. + * @param args The arguments passed to the child process. + * For details, see {@link NativeChildProcess_Args}. + * @param options The child process options. + * For details, see {@link NativeChildProcess_Options}. + * @param pid The started child process id. + * @return Returns {@link NCP_NO_ERROR} if the call is successful.\n + * Returns {@link NCP_ERR_INVALID_PARAM} if the dynamic library name or callback function pointer is invalid.\n + * Returns {@link NCP_ERR_NOT_SUPPORTED} if the device does not support the creation of native child processes.\n + * Returns {@link NCP_ERR_ALREADY_IN_CHILD} if it is not allowed to create another child process in the child process.\n + * Returns {@link NCP_ERR_MAX_CHILD_PROCESSES_REACHED} if the maximum number of native child processes is reached.\n + * For details, see {@link Ability_NativeChildProcess_ErrCode}. + * @see OH_Ability_OnNativeChildProcessStarted + * @since 13 + */ +Ability_NativeChildProcess_ErrCode OH_Ability_StartNativeChildProcess( + const char* entry, NativeChildProcess_Args args, + NativeChildProcess_Options options, int32_t *pid); #ifdef __cplusplus } // extern "C" diff --git a/ai/neural_network_runtime/neural_network_runtime_type.h b/ai/neural_network_runtime/neural_network_runtime_type.h index 26d4babc2a71b50c406ad687e1ec33daf41fbc43..414fa872c3da1a55247a0ec1591e9d7b74eac97e 100644 --- a/ai/neural_network_runtime/neural_network_runtime_type.h +++ b/ai/neural_network_runtime/neural_network_runtime_type.h @@ -39,8 +39,13 @@ #ifndef NEURAL_NETWORK_RUNTIME_TYPE_H #define NEURAL_NETWORK_RUNTIME_TYPE_H +#ifdef __cplusplus #include #include +#else +#include +#include +#endif #ifdef __cplusplus extern "C" { diff --git a/ark_runtime/jsvm/jsvm.h b/ark_runtime/jsvm/jsvm.h index 190a60defc365c14e1750a8b116d7c0918d39216..3f47366b4e021dcd9f8861a3fb9d136619b31d81 100644 --- a/ark_runtime/jsvm/jsvm.h +++ b/ark_runtime/jsvm/jsvm.h @@ -718,6 +718,57 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateArraybuffer(JSVM_Env env, void** data, JSVM_Value* result); +/** + * @brief This API allocate the memory of array buffer backing store. + * + * @param byteLength: size of backing store memory. + * @param initialized: initialization status of the backing store memory. + * @param data: pointer that recieve the backing store memory pointer. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if allocation succeed.\n + * Returns {@link JSVM_INVALID_ARG } if data is null pointer.\n + * Returns {@link JSVM_GENERIC_FAILURE } if allocation failed.\n + * @since 12 + */ +JSVM_Status JSVM_CDECL OH_JSVM_AllocateArrayBufferBackingStoreData(size_t byteLength, + JSVM_InitializedFlag initialized, + void **data); + +/** + * @brief This API release the memory of an array buffer backing store. + * + * @param data: pointer to the backing store memory. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if run succeed.\n + * Returns {@link JSVM_INVALID_ARG } if data is null pointer.\n + * @since 12 + */ +JSVM_Status JSVM_CDECL OH_JSVM_FreeArrayBufferBackingStoreData(void *data); + +/** + * @brief This API create an array buffer using the backing store data. + * + * @param env: The environment that the API is invoked under. + * @param data: pointer to the backing store memory. + * @param backingStoreSize: size of backing store memory. + * @param offset: start position of the array buffer in the backing store memory. + * @param arrayBufferSize: size of the array buffer. + * @param result: pointer that recieve the array buffer. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if creation succeed.\n + * Returns {@link JSVM_INVALID_ARG } if any of the following condition reached:\n + * 1. offset + arrayBufferSize > backingStoreSize\n + * 2. backingStoreSize or arrayBufferSize equals zero + * 3. data or result is null pointer + * @since 12 + */ +JSVM_Status JSVM_CDECL OH_JSVM_CreateArrayBufferFromBackingStoreData(JSVM_Env env, + void *data, + size_t backingStoreSize, + size_t offset, + size_t arrayBufferSize, + JSVM_Value *result); + /** * @brief This API does not observe leap seconds; they are ignored, as ECMAScript aligns with POSIX time specification. * This API allocates a JavaScript Date object. @@ -2788,7 +2839,9 @@ JSVM_Status JSVM_CDECL OH_JSVM_IsConstructor(JSVM_Env env, * @return Only returns JSVM function's result code. * {@link JSVM_OK } If the API succeeded.\n * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n - * {@link JSVM_PENDING_EXCPTION } If the API throws an exception during runtime.\n + * {@link JSVM_STRING_EXPECTED } If the value of 'value' is not a string.\n + * {@link JSVM_GENERIC_FAILURE } If create RegExp failed.\n + * {@link JSVM_PENDING_EXCEPTION } If the API throws an exception during runtime.\n * @since 12 */ JSVM_Status JSVM_CDECL OH_JSVM_CreateRegExp(JSVM_Env env, @@ -2893,6 +2946,105 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ReleaseScript(JSVM_Env env, JSVM_Script script); JSVM_EXTERN JSVM_Status OH_JSVM_OpenInspectorWithName(JSVM_Env env, int pid, const char* name); + +/** + * @brief Compile WebAssembly bytecode into a WebAssembly module. + * If WebAssembly cache provided, deserialization will be performed. + * + * @param env: The environment that the API is invoked under. + * @param wasmBytecode: WebAssembly bytecode. + * @param wasmBytecodeLength: WebAssembly bytecode length in byte. + * @param cacheData: Optional WebAssembly cache. + * @param cacheDataLength: Optional WebAssembly cache length in byte. + * @param cacheRejected: Output parameter representing whether the provided cacheData is rejected. + * @param wasmModule: Output parameter representing compiled WebAssembly module. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_INVALID_ARG } if any of env, wasmBytecode is NULL, or data length is invalid.\n + * Returns {@link JSVM_GENERIC_FAILURE } if compile failed.\n + * Returns {@link JSVM_PENDING_EXCEPTION } if an exception occurs.\n + * + * @since 12 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_CompileWasmModule(JSVM_Env env, + const uint8_t *wasmBytecode, + size_t wasmBytecodeLength, + const uint8_t *cacheData, + size_t cacheDataLength, + bool *cacheRejected, + JSVM_Value *wasmModule); + +/** + * @brief Compile the function with the specified index in the WebAssembly module + * into the specified optimization level. + * + * @param env: The environment that the API is invoked under. + * @param wasmModule: The WebAssembly module to which the function to compiled belongs. + * @param functionIndex: The index of the function to be compiled, should never be out of range. + * @param optLevel: Optimization level the function will be compiled with. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_INVALID_ARG } if env is NULL, or wasmModule is NULL or is not a WebAssembly module.\n + * Returns {@link JSVM_GENERIC_FAILURE } if functionIndex out of range or compile failed.\n + * Returns {@link JSVM_PENDING_EXCEPTION } if an exception occurs.\n + * + * @since 12 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_CompileWasmFunction(JSVM_Env env, + JSVM_Value wasmModule, + uint32_t functionIndex, + JSVM_WasmOptLevel optLevel); + +/** + * @brief Check whether the given JSVM_Value is a WebAssembly module. + * + * @param env: The environment that the API is invoked under. + * @param value: The JavaScript value to check. + * @param result: Whether the given value is a WebAssembly module. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_INVALID_ARG } if any of the input arguments is NULL.\n + * + * @since 12 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_IsWasmModuleObject(JSVM_Env env, + JSVM_Value value, + bool* result); + +/** + * @brief Create cache for compiled WebAssembly module. + * + * @param env: The environment that the API is invoked under. + * @param wasmModule: The compiled WebAssembly module. + * @param data: Output parameter representing generated WebAssembly module cache. + * @param length: Output parameter representing byte length of generated WebAssembly module cache. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_INVALID_ARG } if any of the input arguments is NULL.\n + * Returns {@link JSVM_GENERIC_FAILURE } if create wasm cache failed.\n + * + * @since 12 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_CreateWasmCache(JSVM_Env env, + JSVM_Value wasmModule, + const uint8_t** data, + size_t* length); + +/** + * @brief Release cache data with specified cache type. + * + * @param env: The environment that the API is invoked under. + * @param cacheData: The cache data to be released, double free is undefined behaviors. + * @param cacheType: The type of cache data. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_INVALID_ARG } if any of the pointer arguments is NULL or cacheType is illegal.\n + * + * @since 12 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_ReleaseCache(JSVM_Env env, + const uint8_t* cacheData, + JSVM_CacheType cacheType); EXTERN_C_END /** @} */ #endif /* ARK_RUNTIME_JSVM_JSVM_H */ diff --git a/ark_runtime/jsvm/jsvm_types.h b/ark_runtime/jsvm/jsvm_types.h index b3fb450d5726e8aea0100d89186472e05eb43051..1141b051f8d71e2590a0ded319cf722d8fef7f0b 100644 --- a/ark_runtime/jsvm/jsvm_types.h +++ b/ark_runtime/jsvm/jsvm_types.h @@ -679,7 +679,7 @@ typedef struct { /** int type. */ int num; /** bool type. */ - _Bool boolean; + bool boolean; } content; } JSVM_CompileOptions; @@ -734,5 +734,41 @@ typedef enum { /** Unicode Sets mode. */ JSVM_REGEXP_UNICODE_SETS = 1 << 8, } JSVM_RegExpFlags; + +/** + * @brief initialization flag + * + * @since 12 + */ +typedef enum { + /** initialize with zero. */ + JSVM_ZERO_INITIALIZED, + /** leave uninitialized. */ + JSVM_UNINITIALIZED, +} JSVM_InitializedFlag; + +/** + * @brief WebAssembly function optimization level + * + * @since 12 + */ +typedef enum { + /** baseline optimization level. */ + JSVM_WASM_OPT_BASELINE = 10, + /** high optimization level. */ + JSVM_WASM_OPT_HIGH = 20, +} JSVM_WasmOptLevel; + +/** + * @brief Cache data type + * + * @since 12 + */ +typedef enum { + /** js code cache, generated by OH_JSVM_CreateCodeCache */ + JSVM_CACHE_TYPE_JS, + /** WebAssembly cache, generated by OH_JSVM_CreateWasmCache */ + JSVM_CACHE_TYPE_WASM, +} JSVM_CacheType; /** @} */ #endif /* ARK_RUNTIME_JSVM_JSVM_TYPE_H */ diff --git a/ark_runtime/jsvm/libjsvm.ndk.json b/ark_runtime/jsvm/libjsvm.ndk.json index f7308460d0162cd4758ad54551668547cf71730e..e0157b7722ff66f925d17ba0a0367d2a0c5e5fe8 100644 --- a/ark_runtime/jsvm/libjsvm.ndk.json +++ b/ark_runtime/jsvm/libjsvm.ndk.json @@ -702,5 +702,37 @@ { "first_introduced": "12", "name": "OH_JSVM_OpenInspectorWithName" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_AllocateArrayBufferBackingStoreData" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_FreeArrayBufferBackingStoreData" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_CreateArrayBufferFromBackingStoreData" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_CompileWasmModule" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_CompileWasmFunction" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_IsWasmModuleObject" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_CreateWasmCache" + }, + { + "first_introduced": "12", + "name": "OH_JSVM_ReleaseCache" } ] diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 92f05cac45979656a9068743b1f2973f9c73c39e..f8f7ff2746bf12bfd81dd20c3727968cda6863f7 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -32,6 +32,8 @@ if (!is_arkui_x) { "native_dialog.h", "native_gesture.h", "native_interface.h", + "native_interface_accessibility.h", + "native_key_event.h", "native_node.h", "native_node_napi.h", "native_type.h", diff --git a/arkui/ace_engine/native/drag_and_drop.h b/arkui/ace_engine/native/drag_and_drop.h index c8dc147263247f5ea57e28e1d466c75494e08361..2f68d95b0f7affd5a6d626e7bd425d6513752183 100644 --- a/arkui/ace_engine/native/drag_and_drop.h +++ b/arkui/ace_engine/native/drag_and_drop.h @@ -80,22 +80,22 @@ typedef enum { */ typedef enum { /** Unknown. */ - ARKUI_PREVIEW_DRAG_STATUS_UNKNOWN = -1, + ARKUI_PRE_DRAG_STATUS_UNKNOWN = -1, /** A drag gesture is being detected. */ - ARKUI_PREVIEW_DRAG_STATUS_ACTION_DETECTING, + ARKUI_PRE_DRAG_STATUS_ACTION_DETECTING, /** The component is ready to be dragged. */ - ARKUI_PREVIEW_DRAG_STATUS_READY_TO_TRIGGER_DRAG, + ARKUI_PRE_DRAG_STATUS_READY_TO_TRIGGER_DRAG, /** A lift animation is started. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_STARTED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_STARTED, /** A lift animation is finished. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_FINISHED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_FINISHED, /** A drop animation is started. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_STARTED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_STARTED, /** A drop animation is finished. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_FINISHED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_FINISHED, /** A drop animation is terminated. */ - ARKUI_PREVIEW_DRAG_STATUS_CANCELED_BEFORE_DRAG, -} ArkUI_PreviewDragStatus; + ARKUI_PRE_DRAG_STATUS_CANCELED_BEFORE_DRAG, +} ArkUI_PreDragStatus; /** * @brief Defines an enum for drag preview scale modes. @@ -192,7 +192,7 @@ ArkUI_DragEvent* OH_ArkUI_NodeEvent_GetDragEvent(ArkUI_NodeEvent* nodeEvent); * @return Returns the interaction state prior to the drop and drop operation. * @since 12 */ -ArkUI_PreviewDragStatus OH_ArkUI_NodeEvent_GetPreviewDragStatus(ArkUI_NodeEvent* nodeEvent); +ArkUI_PreDragStatus OH_ArkUI_NodeEvent_GetPreDragStatus(ArkUI_NodeEvent* nodeEvent); /** * @brief Sets whether to disable the default drop animation. diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 250a1c13d40a618dadb08cfd7cf34f8066cc1f83..96208e941e96abf6410a15e90b35acb6e7e5f810 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -247,6 +247,70 @@ "first_introduced": "12", "name": "OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetResponseRecognizersFromInterruptInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SetGestureRecognizerEnabled" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureRecognizerEnabled" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureRecognizerState" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureEventTargetInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GestureEventTargetInfo_IsScrollBegin" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GestureEventTargetInfo_IsScrollEnd" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetPanGestureDirectionMask" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_IsBuiltInGesture" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureTag" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureBindNodeId" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_IsGestureRecognizerValid" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetUserData" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify" + }, { "first_introduced": "12", "name": "OH_NativeXComponent_SetNeedSoftKeyboard" @@ -1231,6 +1295,14 @@ "first_introduced": "12", "name": "OH_ArkUI_NodeUtils_GetPositionWithTranslateInScreen" }, + { + "first_introduced": "13", + "name": "OH_ArkUI_NodeUtils_AddCustomProperty" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_NodeUtils_RemoveCustomProperty" + }, { "first_introduced": "12", "name": "OH_ArkUI_ListChildrenMainSizeOption_Create" @@ -1765,7 +1837,7 @@ }, { "first_introduced": "12", - "name": "OH_ArkUI_NodeEvent_GetPreviewDragStatus" + "name": "OH_ArkUI_NodeEvent_GetPreDragStatus" }, { "first_introduced": "12", @@ -1982,5 +2054,385 @@ { "first_introduced": "12", "name": "OH_ArkUI_DialogDismissEvent_GetDismissReason" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_GetFontSize" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_SetWidth" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_SetHeight" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetXOffset" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetLineTop" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetLineBottom" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetBaseline" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_RegisterSystemColorModeChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_UnregisterSystemColorModeChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_RegisterSystemFontStyleChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_UnregisterSystemFontStyleChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SystemFontStyleEvent_GetFontSizeScale" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SystemFontStyleEvent_GetFontWeightScale" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityProviderRegisterCallback" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_SendAccessibilityAsyncEvent" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AddAndGetAccessibilityElementInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetParentId" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetComponentType" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetContents" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetHintText" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetAccessibilityText" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetAccessibilityDescription" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetChildNodeIds" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetOperationActions" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetScreenRect" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetCheckable" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetChecked" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetFocusable" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetFocused" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetVisible" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetSelected" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetClickable" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetLongClickable" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetEnabled" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetIsPassword" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetScrollable" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetEditable" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetIsHint" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetRangeInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetGridInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetGridItemInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetSelectedTextStart" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetSelectedTextEnd" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetCurrentItemIndex" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetStartItemIndex" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetEndItemIndex" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetItemCount" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetAccessibilityOffset" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetZIndex" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetAccessibilityOpacity" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetBackgroundColor" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetBackgroundImage" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetBlur" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetHitTestBehavior" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_CreateAccessibilityEventInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_DestoryAccessibilityEventInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityEventSetEventType" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityEventSetRequestFocusId" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityEventSetElementInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_FindAccessibilityActionArgumentByKey" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_CreateAccessibilityElementInfo" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_DestoryAccessibilityElementInfo" + }, + { + "first_introduced": "13", + "name": "OH_NativeXComponent_GetNativeAccessibilityProvider" + }, + { + "first_introduced": "13", + "name": "OH_ArkUI_AccessibilityElementInfoSetElementId" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_StyledString_Descriptor_Create" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_StyledString_Descriptor_Destroy" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_ConvertToHtml" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_MarshallStyledStringDescriptor" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_UnmarshallStyledStringDescriptor" + }, + { + "first_introduced": "14", + "name": "OH_NativeXComponent_RegisterKeyEventCallbackWithResult" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetType" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetKeyCode" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetKeyText" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetKeySource" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetDeviceId" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetMetaKey" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetTimestamp" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_StopPropagation" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetModifierKeyState" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetKeyIntensionCode" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_GetUnicode" + }, + { + "first_introduced": "14", + "name": "OH_ArkUI_KeyEvent_SetConsumed" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_dialog.h b/arkui/ace_engine/native/native_dialog.h index 1338eee7ae19d25f0155a2fb6ce21a4081e61d19..95b1a6cbefda04982a2e908f85bc796178a4954b 100644 --- a/arkui/ace_engine/native/native_dialog.h +++ b/arkui/ace_engine/native/native_dialog.h @@ -37,6 +37,7 @@ #ifndef ARKUI_NATIVE_DIALOG_H #define ARKUI_NATIVE_DIALOG_H +#include #include "native_type.h" #ifdef __cplusplus diff --git a/arkui/ace_engine/native/native_gesture.h b/arkui/ace_engine/native/native_gesture.h index 35dac3924d75d777b705ff8a71685073e42edfd6..42b37aa9c4b2fec751befab632b234d9ff24be14 100644 --- a/arkui/ace_engine/native/native_gesture.h +++ b/arkui/ace_engine/native/native_gesture.h @@ -38,6 +38,7 @@ #include "ui_input_event.h" #include "native_type.h" +#include #ifdef __cplusplus extern "C" { @@ -223,6 +224,65 @@ typedef enum { GESTURE_INTERRUPT_RESULT_REJECT, } ArkUI_GestureInterruptResult; +/** + * @brief Enumerates the gesture recognizer states. + * + * @since 12 + */ +typedef enum { + /** Ready. */ + ARKUI_GESTURE_RECOGNIZER_STATE_READY = 0, + + /** Detecting. */ + ARKUI_GESTURE_RECOGNIZER_STATE_DETECTING = 1, + + /** Pending. */ + ARKUI_GESTURE_RECOGNIZER_STATE_PENDING = 2, + + /** Blocked. */ + ARKUI_GESTURE_RECOGNIZER_STATE_BLOCKED = 3, + + /** Successful. */ + ARKUI_GESTURE_RECOGNIZER_STATE_SUCCESSFUL = 4, + + /** Failed. */ + ARKUI_GESTURE_RECOGNIZER_STATE_FAILED = 5, +} ArkUI_GestureRecognizerState; + +/** + * @brief Defines the gesture recognizer handle. + * + * @since 12 + */ +typedef ArkUI_GestureRecognizer* ArkUI_GestureRecognizerHandle; + +/** + * @brief Defines the gesture recognizer handle array. + * + * @since 12 + */ +typedef ArkUI_GestureRecognizerHandle* ArkUI_GestureRecognizerHandleArray; + +/** + * @brief Defines a GestureEventTargetInfo object that provides information about a gesture event target. + * + * @since 12 + */ +typedef struct ArkUI_GestureEventTargetInfo ArkUI_GestureEventTargetInfo; + +/** + * @brief Defines a parallel internal gesture event. + * + * @since 12 + */ +typedef struct ArkUI_ParallelInnerGestureEvent ArkUI_ParallelInnerGestureEvent; + +/** + * @brief Defines a callback function for notifying gesture recognizer destruction. + * @since 12 + */ +typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData); + /** * @brief Checks whether a gesture is a built-in gesture of the component. * @@ -408,6 +468,191 @@ float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event); * @since 12 */ ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event); + +/** +* @brief Obtains information about a gesture response chain. +* +* @param event Indicates the pointer to the gesture interruption information. +* @param responseChain Indicates the pointer to an array of gesture recognizers on the response chain. +* @param count Indicates the pointer to the number of gesture recognizers on the response chain. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event, + ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count); + +/** +* @brief Sets the enabled state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param enabled Indicates the enabled state. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled); + +/** +* @brief Obtains the enabled state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture recognizer is enabled. +* Returns false if the gesture recognizer is disabled. +* @since 12 +*/ +bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains the state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param state Indicates the pointer to the state of the gesture recognizer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state); + +/** +* @brief Obtains the information about a gesture event target. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param info Indicates the information about a gesture event target. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info); + +/** +* @brief Obtains whether this scroll container is scrolled to the top. +* +* @param info Indicates the information about a gesture event target. +* @param ret Indicates whether the scroll container is scrolled to the top. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. +* @since 12 +*/ +int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret); + +/** +* @brief Obtains whether this scroll container is scrolled to the bottom. +* +* @param info Indicates the information about a gesture event target. +* @param ret Indicates whether the scroll container is scrolled to the bottom. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. +* @since 12 +*/ +int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret); + +/** +* @brief Obtains the direction of a pan gesture. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param directionMask Indicates the pan direction. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer, + ArkUI_GestureDirectionMask* directionMask); + +/** +* @brief Obtains whether a gesture is a built-in gesture. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture is a built-in gesture; returns false otherwise. +* @since 12 +*/ +bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains the tag of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param buffer Indicates the buffer. +* @param bufferSize Indicates the buffer size. +* @param result Indicates the length of the string to be written to the buffer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result); + +/** +* @brief Obtains the ID of the component linked to a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param nodeId Indicates the component ID. +* @param size Indicates the buffer size. +* @param result Indicates the length of the string to be written to the buffer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size, + int32_t* result); + +/** +* @brief Obtains whether a gesture recognizer is valid. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture recognizer is valid. +* Returns false if the gesture recognizer is invalid. +* @since 12 +*/ +bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains custom data in the parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @return Returns the pointer to custom data. +* @since 12 +*/ +void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event); + +/** +* @brief Obtains the current gesture recognizer in a parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @return Returns the pointer to the current gesture recognizer. +* @since 12 +*/ +ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer( + ArkUI_ParallelInnerGestureEvent* event); + +/** +* @brief Obtains the conflicting gesture recognizers in a parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @param array Indicates the pointer to the array of conflicting gesture recognizers. +* @param size Indicates the size of the array of conflicting gesture recognizers. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event, + ArkUI_GestureRecognizerHandleArray* array, int32_t* size); + +/** +* @brief Sets a callback function for notifying gesture recognizer destruction. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param callback Indicates the callback function for notifying gesture recognizer destruction. +* @param userData Indicates the custom data. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +*/ +int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer, + ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData); + /** * @brief Defines the gesture APIs. * @@ -625,6 +870,46 @@ typedef struct { * @return Returns the gesture type. */ ArkUI_GestureRecognizerType (*getGestureType)(ArkUI_GestureRecognizer* recognizer); + + /** + * @brief Sets the callback function for a parallel internal gesture event. + * + * @param node Indicates the ArkUI node for which the callback of a parallel internal gesture event is to be set. + * @param userData Indicates the custom data. + * @param parallelInnerGesture Indicates the parallel internal gesture event. event returns the data of the + * parallel internal gesture event; parallelInnerGesture returns the pointer to the gesture recognizer + * that requires parallel recognition. + * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. + */ + int32_t (*setInnerGestureParallelTo)( + ArkUI_NodeHandle node, void* userData, ArkUI_GestureRecognizer* (*parallelInnerGesture)( + ArkUI_ParallelInnerGestureEvent* event)); + + /** + * @brief Creates a tap gesture that is subject to distance restrictions. + * + * 1. This API is used to trigger a tap gesture with one, two, or more taps. \n + * 2. If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. \n + * 3. If the distance between the last tapped position and the current tapped position exceeds 60 vp, + * gesture recognition fails. \n + * 4. If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers + * touching the screen within 300 ms of the first finger touch is less than the required number, + * or when the number of fingers lifted from the screen within 300 ms of the first finger's being lifted + * is less than the required number. \n + * 5. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized. \n + * 6. If the finger moves beyond the preset distance limit, gesture recognition fails. \n + * + * @param countNum Indicates the number of consecutive taps. If the value is less than 1 or is not set, the default + * value 1 is used. + * @param fingersNum Indicates the number of fingers required to trigger a tap. The value ranges from 1 to 10. + * If the value is less than 1 or is not set, the default value 1 is used. + * @param distanceThreshold Indicates the allowed moving distance of a finger. + * If the value is less than 0 or is not set, it will be converted to the default value of infinity. + * @return Returns the pointer to the created gesture. + */ + ArkUI_GestureRecognizer* (*createTapGestureWithDistanceThreshold)( + int32_t countNum, int32_t fingersNum, double distanceThreshold); } ArkUI_NativeGestureAPI_1; #ifdef __cplusplus diff --git a/arkui/ace_engine/native/native_interface_accessibility.h b/arkui/ace_engine/native/native_interface_accessibility.h new file mode 100644 index 0000000000000000000000000000000000000000..4150edcec64efad87550a5c61c321d0cd07dd7a4 --- /dev/null +++ b/arkui/ace_engine/native/native_interface_accessibility.h @@ -0,0 +1,1029 @@ +/* + * 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 ArkUI_Accessibility + * @{ + * + * @brief Describes the native capabilities supported by ArkUI Accessibility, such as querying accessibility nodes and + * reporting accessibility events. + * + * @since 13 + */ + +/** + * @file native_interface_accessibility.h + * + * @brief Declares the APIs used to access the native Accessibility. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @kit ArkUI + * @since 13 + */ +#ifndef _NATIVE_INTERFACE_ACCESSIBILITY_H +#define _NATIVE_INTERFACE_ACCESSIBILITY_H + +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +/** + * @brief Defines a struct for accessibility element information. + * + * @since 13 + */ +typedef struct ArkUI_AccessibilityElementInfo ArkUI_AccessibilityElementInfo; + +/** + * @brief Defines a struct for accessibility event information. + * + * @since 13 + */ +typedef struct ArkUI_AccessibilityEventInfo ArkUI_AccessibilityEventInfo; + +/** + * @brief Defines a struct for the local provider of accessibility. + * + * @since 13 + */ +typedef struct ArkUI_AccessibilityProvider ArkUI_AccessibilityProvider; + +/** + * @brief Defines a struct for accessibility action arguments. + * + * @since 13 + */ +typedef struct ArkUI_AccessibilityActionArguments ArkUI_AccessibilityActionArguments; + +/** + * @brief Defines an enum for accessibility action types. + * + * @since 13 + */ +typedef enum { + /** Invalid action. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_INVALID = 0, + /** Response to a click. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK = 0x00000010, + /** Response to a long click. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_LONG_CLICK = 0x00000020, + /** Accessibility focus acquisition. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS = 0x00000040, + /** Accessibility focus clearance. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS = 0x00000080, + /** Forward scroll action. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_FORWARD = 0x00000100, + /** Backward scroll action. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_BACKWARD = 0x00000200, + /** Copy action for text content. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY = 0x00000400, + /** Paste action for text content. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE = 0x00000800, + /** Cut action for text content. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CUT = 0x00001000, + /** Text selection action, requiring the setting of selectTextBegin, TextEnd, and TextInForward + * parameters to select a text segment in the text box. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT = 0x00002000, + /** Text content setting action. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_TEXT = 0x00004000, + /** Cursor position setting action. */ + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_CURSOR_POSITION = 0x00100000, +} ArkUI_Accessibility_ActionType; + +/** + * @brief Defines an enum for accessibility event types. + * + * @since 13 + */ +typedef enum { + /** Invalid event. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_INVALID = 0, + /** Click event, sent after the UI component responds. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_CLICKED = 0x00000001, + /** Long click event, sent after the UI component responds. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_LONG_CLICKED = 0x00000002, + /** Selection event, sent after the UI component responds. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SELECTED = 0x00000004, + /** Text update event, sent when text is updated. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_TEXT_UPDATE = 0x00000010, + /** Page state update event, sent when the page transitions, switches, resizes, or moves. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_STATE_UPDATE = 0x00000020, + /** Page content update event, sent when the page content changes. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_CONTENT_UPDATE = 0x00000800, + /** Scrolled event, sent when a scrollable component experiences a scroll event. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SCROLLED = 0x000001000, + /** Accessibility focus event, sent after the UI component responds. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUSED = 0x00008000, + /** Accessibility focus cleared event, sent after the UI component responds. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUS_CLEARED = 0x00010000, + /** FOcus request for a specific node. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_REQUEST_ACCESSIBILITY_FOCUS = 0x02000000, + /** Page open event reported by the UI component. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_OPEN = 0x20000000, + /** Page close event reported by the UI component. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_CLOSE = 0x08000000, + /** Announcement event, indicating a request to proactively announce specified content. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ANNOUNCE_FOR_ACCESSIBILITY = 0x10000000, + /** Focus update event, used for focus update scenarios. */ + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_FOCUS_NODE_UPDATE = 0x10000001, +} ArkUI_AccessibilityEventType; + +/** + * @brief Defines a struct for the accessible action. + * + * @since 13 + */ +typedef struct { + /** Action type. */ + ArkUI_Accessibility_ActionType actionType; + /** Action description. */ + const char* description; +} ArkUI_AccessibleAction; + +/** + * @brief Defines a struct for the accessible rectangle. + * + * @since 13 + */ +typedef struct { + /** X coordinate of the upper left corner. */ + int32_t leftTopX; + /** Y coordinate of the upper left corner. */ + int32_t leftTopY; + /** X coordinate of the lower right corner. */ + int32_t rightBottomX; + /** Y coordinate of the lower right corner. */ + int32_t rightBottomY; +} ArkUI_AccessibleRect; + +/** + * @brief Define a struct for the accessible range information. + * + * @since 13 + */ +typedef struct { + /** Minimum value. */ + double min; + /** Maximum value. */ + double max; + /** Current value. */ + double current; +} ArkUI_AccessibleRangeInfo; + +/** + * @brief Defines a struct for the accessible grid information. + * + * @since 13 + */ +typedef struct { + /** Number of rows. */ + int32_t rowCount; + /** Number of columns. */ + int32_t columnCount; + /** Selection mode. The value 0 indicates that only one row can be selected. */ + int32_t selectionMode; +} ArkUI_AccessibleGridInfo; + +/** + * @brief Defines a struct for the accessible grid item information. + * + * @since 13 + */ +typedef struct { + /** Whether it is a header. */ + bool heading; + /** Whether it is selected. */ + bool selected; + /** Column index. */ + int32_t columnIndex; + /** Row index. */ + int32_t rowIndex; + /** Column span. */ + int32_t columnSpan; + /** Row span. */ + int32_t rowSpan; +} ArkUI_AccessibleGridItemInfo; + +/** + * @brief Enumerates the accessibility error codes. + * + * @since 13 + */ +typedef enum { + /** + * @error Success. + */ + ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL = 0, + /** + * @error Failure. + */ + ARKUI_ACCESSIBILITY_NATIVE_RESULT_FAILED = -1, + /** + * @error Invalid parameter. + */ + ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER = -2, + /** + * @error Out of memory. + */ + ARKUI_ACCESSIBILITY_NATIVE_RESULT_OUT_OF_MEMORY = -3, +} ArkUI_AcessbilityErrorCode; + +/** + * @brief Defines an enum for the accessibility search modes. + * + * @since 13 + */ +typedef enum { + /** Search for current nodes. */ + ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_CURRENT = 0, + /** Search for parent nodes. */ + ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_PREDECESSORS = 1 << 0, + /** Search for sibling nodes. */ + ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_SIBLINGS = 1 << 1, + /** Search for child nodes at the next level. */ + ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_CHILDREN = 1 << 2, + /** Search for all child nodes. */ + ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_RECURSIVE_CHILDREN = 1 << 3, +} ArkUI_AccessibilitySearchMode; + +/** + * @brief Defines an enum for the accessibility focus types. + * + * @since 13 + */ +typedef enum { + /** Invalid type. */ + ARKUI_ACCESSIBILITY_NATIVE_FOCUS_TYPE_INVALID = -1, + /** Input focus type. */ + ARKUI_ACCESSIBILITY_NATIVE_FOCUS_TYPE_INPUT = 1 << 0, + /** Accessibility focus type. */ + ARKUI_ACCESSIBILITY_NATIVE_FOCUS_TYPE_ACCESSIBILITY = 1 << 1, +} ArkUI_AccessibilityFocusType; + +/** + * @brief Enumerates the directions for moving the accessibility focus. + * + * @since 13 + */ +typedef enum { + /** Invalid direction. */ + ARKUI_ACCESSIBILITY_NATIVE_DIRECTION_INVALID = 0, + /** Up. */ + ARKUI_ACCESSIBILITY_NATIVE_DIRECTION_UP = 0x00000001, + /** Down. */ + ARKUI_ACCESSIBILITY_NATIVE_DIRECTION_DOWN = 0x00000002, + /** Left. */ + ARKUI_ACCESSIBILITY_NATIVE_DIRECTION_LEFT = 0x00000004, + /** Right. */ + ARKUI_ACCESSIBILITY_NATIVE_DIRECTION_RIGHT = 0x00000008, + /** Forward. */ + ARKUI_ACCESSIBILITY_NATIVE_DIRECTION_FORWARD = 0x00000010, + /** Backward. */ + ARKUI_ACCESSIBILITY_NATIVE_DIRECTION_BACKWARD = 0x00000020, +} ArkUI_AccessibilityFocusMoveDirection; + +/** + * @brief Defines a struct for the accessibility element information list. + * + * @since 13 + */ +typedef struct ArkUI_AccessibilityElementInfoList ArkUI_AccessibilityElementInfoList; + +/** + * @brief Registers callbacks for the accessibility provider. + * + * @since 13 + */ +typedef struct ArkUI_AccessibilityProviderCallbacks { + /** + * @brief Called to obtain element information based on a specified node. + * + * @param elementId Indicates the element ID. + * @param mode Indicates accessibility search mode. + * @param requestId Indicates the request ID. + * @param elementList Indicates accessibility elementInfo list. + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. + */ + int32_t (*findAccessibilityNodeInfosById)(int64_t elementId, ArkUI_AccessibilitySearchMode mode, + int32_t requestId, ArkUI_AccessibilityElementInfoList* elementList); + /** + * @brief Called to obtain element information based on a specified node and text content. + * + * @param elementId Indicates the element ID. + * @param text Indicates accessibility text. + * @param requestId Indicates the request ID. + * @param elementList Indicates accessibility elementInfo list. + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. + */ + int32_t (*findAccessibilityNodeInfosByText)(int64_t elementId, const char* text, int32_t requestId, + ArkUI_AccessibilityElementInfoList* elementList); + /** + * @brief Called to obtain focused element information based on a specified node. + * + * @param elementId Indicates the element ID. + * @param focusType Indicates focus type. + * @param requestId Indicates the request ID. + * @param elementInfo Indicates accessibility elementInfo. + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. + */ + int32_t (*findFocusedAccessibilityNode)(int64_t elementId, ArkUI_AccessibilityFocusType focusType, + int32_t requestId, ArkUI_AccessibilityElementInfo* elementInfo); + /** + * @brief Called to find the next focusable node based on the reference node. + * + * @param elementId Indicates the element ID. + * @param direction Indicates direction. + * @param requestId Indicates the request ID. + * @param elementInfo Indicates accessibility elementInfo. + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. + */ + int32_t (*findNextFocusAccessibilityNode)( + int64_t elementId, ArkUI_AccessibilityFocusMoveDirection direction, + int32_t requestId, ArkUI_AccessibilityElementInfo* elementInfo); + /** + * @brief Called to execute a specified action on a specified node. + * + * @param elementId Indicates the element ID. + * @param action Indicates action. + * @param actionArguments Indicates action arguments. + * @param requestId Indicates the request ID. + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. + */ + int32_t (*executeAccessibilityAction)(int64_t elementId, ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments *actionArguments, int32_t requestId); + /** + * @brief Called to clear the focus state of the current focused node. + * + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_FAILED} if the operation is failed. + */ + int32_t (*clearFocusedFocusAccessibilityNode)(); + /** + * @brief Called to query the current cursor position of the specified node. + * + * @param elementId Indicates the element ID. + * @param requestId Indicates the request ID. + * @param index Indicates index. + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. + */ + int32_t (*getAccessibilityNodeCursorPosition)(int64_t elementId, int32_t requestId, int32_t* index); +} ArkUI_AccessibilityProviderCallbacks; + +/** + * @brief Registers a callback for this ArkUI_AccessibilityProvider instance. + * + * @param provider Indicates the pointer to the ArkUI_AccessibilityProvider instance. + * @param callbacks Indicates the pointer to the GetAccessibilityNodeCursorPosition callback. + * @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. + * Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. + * @since 13 + */ +int32_t OH_ArkUI_AccessibilityProviderRegisterCallback( + ArkUI_AccessibilityProvider* provider, ArkUI_AccessibilityProviderCallbacks* callbacks); + +/** + * @brief Sends accessibility event information. + * + * @param provider Indicates the pointer to the ArkUI_AccessibilityProvider instance. + * @param eventInfo Indicates the pointer to the accessibility event information. + * @param callback Indicates the pointer to the callback that is called after the event is sent. + * @since 13 + */ +void OH_ArkUI_SendAccessibilityAsyncEvent( + ArkUI_AccessibilityProvider* provider, ArkUI_AccessibilityEventInfo* eventInfo, + void (*callback)(int32_t errorCode)); + +/** + * @brief Adds and obtains the pointer to an ArkUI_AccessibilityElementInfo object. + * + * @param list Indicates the pointer to an ArkUI_AccessibilityElementInfoList object. + * @return Returns the pointer to the ArkUI_AccessibilityElementInfo object. + * @since 13 + */ +ArkUI_AccessibilityElementInfo* OH_ArkUI_AddAndGetAccessibilityElementInfo( + ArkUI_AccessibilityElementInfoList* list); + +/** +* @brief Sets the element ID for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param elementId Indicates the element ID. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetElementId( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t elementId); + +/** +* @brief Sets the parent ID for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param parentId Indicates the parent ID. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetParentId( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t parentId); + +/** +* @brief Sets the component type for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param componentType Indicates the component type. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetComponentType( + ArkUI_AccessibilityElementInfo* elementInfo, const char* componentType); + +/** +* @brief Sets the component content for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param contents Indicates the component content. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetContents( + ArkUI_AccessibilityElementInfo* elementInfo, const char* contents); + +/** +* @brief Sets the hint text for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param hintText Indicates the hint text. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetHintText( + ArkUI_AccessibilityElementInfo* elementInfo, const char* hintText); + +/** +* @brief Sets the accessibility text for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param accessibilityText Indicates the accessibility text. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetAccessibilityText( + ArkUI_AccessibilityElementInfo* elementInfo, const char* accessibilityText); + +/** +* @brief Sets the accessibility description for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param accessibilityDescription Indicates the accessibility description. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetAccessibilityDescription( + ArkUI_AccessibilityElementInfo* elementInfo, const char* accessibilityDescription); + +/** +* @brief Set the number of child nodes and child node IDs for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param childCount Indicates the number of child nodes. +* @param childNodeIds Indicates an array of child node IDs. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetChildNodeIds( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t childCount, int64_t* childNodeIds); + +/** +* @brief Sets the operation actions for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param operationCount Indicates the operation count. +* @param operationActions Indicates the operation actions. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetOperationActions(ArkUI_AccessibilityElementInfo* elementInfo, + int32_t operationCount, ArkUI_AccessibleAction* operationActions); + +/** +* @brief Sets the screen area for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param screenRect Indicates the screen area. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetScreenRect( + ArkUI_AccessibilityElementInfo* elementInfo, ArkUI_AccessibleRect* screenRect); + +/** +* @brief Sets whether the element is checkable for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param checkable Indicates whether the element is checkable. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetCheckable( + ArkUI_AccessibilityElementInfo* elementInfo, bool checkable); + +/** +* @brief Sets whether the element is checked for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param checked Indicates whether the element is checked. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetChecked( + ArkUI_AccessibilityElementInfo* elementInfo, bool checked); + +/** +* @brief Sets whether the element is focusable for an ArkUI_AccessibilityElementInfo object. +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param focusable Indicates whether the element is focusable. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetFocusable( + ArkUI_AccessibilityElementInfo* elementInfo, bool focusable); + +/** +* @brief Sets whether the element is focused for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param isFocused Indicates whether the element is focused. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetFocused( + ArkUI_AccessibilityElementInfo* elementInfo, bool isFocused); + +/** +* @brief Sets whether the element is visible for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param isVisible Indicates whether the element is visible. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetVisible( + ArkUI_AccessibilityElementInfo* elementInfo, bool isVisible); + +/** +* @brief Sets the accessibility focus state for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param accessibilityFocused Indicates whether the element has accessibility focus. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused( + ArkUI_AccessibilityElementInfo* elementInfo, bool accessibilityFocused); + +/** +* @brief Sets whether the element is selected for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param selected Indicates whether the element is selected. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetSelected( + ArkUI_AccessibilityElementInfo* elementInfo, bool selected); + +/** +* @brief Sets whether the element is clickable for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param clickable Indicates whether the element is clickable. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetClickable( + ArkUI_AccessibilityElementInfo* elementInfo, bool clickable); + +/** +* @brief Sets whether the element is long clickable for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param longClickable Indicates whether the element is long clickable. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetLongClickable( + ArkUI_AccessibilityElementInfo* elementInfo, bool longClickable); + +/** +* @brief Sets whether the element is enabled for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param isEnabled Indicates whether the element is enabled. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetEnabled( + ArkUI_AccessibilityElementInfo* elementInfo, bool isEnabled); + +/** +* @brief Sets whether the element is a password for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param isPassword Indicates whether the element is a password. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetIsPassword( + ArkUI_AccessibilityElementInfo* elementInfo, bool isPassword); + +/** +* @brief Sets whether the element is scrollable for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param scrollable Indicates whether the element is scrollable. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetScrollable( + ArkUI_AccessibilityElementInfo* elementInfo, bool scrollable); + +/** +* @brief Sets whether the element is editable for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param editable Indicates whether the element is editable. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetEditable( + ArkUI_AccessibilityElementInfo* elementInfo, bool editable); + +/** +* @brief Sets whether the element is a hint for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param isHint Indicates whether the element is a hint. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetIsHint( + ArkUI_AccessibilityElementInfo* elementInfo, bool isHint); + +/** +* @brief Sets the range information for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param rangeInfo Indicates the range information. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetRangeInfo( + ArkUI_AccessibilityElementInfo* elementInfo, ArkUI_AccessibleRangeInfo* rangeInfo); + +/** +* @brief Sets the grid information for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param gridInfo Indicates the grid information. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetGridInfo( + ArkUI_AccessibilityElementInfo* elementInfo, ArkUI_AccessibleGridInfo* gridInfo); + +/** +* @brief Sets the grid item for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param gridItem Indicates the grid item. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetGridItemInfo( + ArkUI_AccessibilityElementInfo* elementInfo, ArkUI_AccessibleGridItemInfo* gridItem); + +/** +* @brief Sets the starting index of the selected text for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param selectedTextStart Indicates the starting index of the selected text +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetSelectedTextStart( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t selectedTextStart); + +/** +* @brief Sets the end index of the selected text for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param selectedTextEnd Indicates the end index of the selected text +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetSelectedTextEnd( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t selectedTextEnd); + +/** +* @brief Sets the index of the currently selected item for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param currentItemIndex Indicates the index of the currently selected item. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetCurrentItemIndex( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t currentItemIndex); + +/** +* @brief Sets the index of the first item for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param startItemIndex Indicates the index of the first item. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetStartItemIndex( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t startItemIndex); + +/** +* @brief Sets the index of the last item for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param endItemIndex Indicates the index of the last item. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetEndItemIndex( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t endItemIndex); + +/** +* @brief Sets the number of items for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param itemCount Indicates the number of items. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetItemCount( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t itemCount); + +/** +* @brief Sets the offset for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param offset Indicates the scroll pixel offset relative to the top of the element. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetAccessibilityOffset( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t offset); + +/** +* @brief Sets the accessibility group for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param accessibilityGroup Indicates the accessibility group. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup( + ArkUI_AccessibilityElementInfo* elementInfo, bool accessibilityGroup); + +/** +* @brief Sets the accessibility level for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param accessibilityLevel Indicates the accessibility level. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel( + ArkUI_AccessibilityElementInfo* elementInfo, const char* accessibilityLevel); + +/** +* @brief Sets the z-index for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param zIndex Indicates the z-index value. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetZIndex( + ArkUI_AccessibilityElementInfo* elementInfo, int32_t zIndex); + +/** +* @brief Sets the opacity for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param opacity Indicates the opacity. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetAccessibilityOpacity( + ArkUI_AccessibilityElementInfo* elementInfo, float opacity); + +/** +* @brief Sets the background color for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param backgroundColor Indicates the background color. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetBackgroundColor( + ArkUI_AccessibilityElementInfo* elementInfo, const char* backgroundColor); + +/** +* @brief Sets the background image for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param backgroundImage Indicates the backgroundImage. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetBackgroundImage( + ArkUI_AccessibilityElementInfo* elementInfo, const char* backgroundImage); + +/** +* @brief Sets the blur effect for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param blur Indicates the blur effect. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetBlur( + ArkUI_AccessibilityElementInfo* elementInfo, const char* blur); + +/** +* @brief Sets the hit test behavior for an ArkUI_AccessibilityElementInfo object. +* +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @param hitTestBehavior Indicates the hit test behavior. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityElementInfoSetHitTestBehavior( + ArkUI_AccessibilityElementInfo* elementInfo, const char* hitTestBehavior); + +/** + * @brief Creates an ArkUI_AccessibilityElementInfo object. + * + * @return Returns the ArkUI_AccessibilityElementInfo object, or NULL if it fails to create. + * The possible reason for failure is that the memory error occurred during object creation. + * @since 13 + * @version 1.0 + */ +ArkUI_AccessibilityElementInfo* OH_ArkUI_CreateAccessibilityElementInfo(void); + +/** + * @brief Destroys an ArkUI_AccessibilityElementInfo object. + * + * @param elementInfo Indicates the pointer to the ArkUI_AccessibilityElementInfo object to destroy. + * @since 13 + * @version 1.0 + */ +void OH_ArkUI_DestoryAccessibilityElementInfo(ArkUI_AccessibilityElementInfo* elementInfo); + +/** + * @brief Creates an ArkUI_AccessibilityEventInfo object. + * + * @return Returns the ArkUI_AccessibilityEventInfo object, or NULL if it fails to create. + * The possible reason for failure is that the memory error occurred during object creation. + * @since 13 + */ +ArkUI_AccessibilityEventInfo* OH_ArkUI_CreateAccessibilityEventInfo(void); + +/** + * @brief Destroys an ArkUI_AccessibilityEventInfo object. + * + * @param eventInfo Indicates the pointer to the ArkUI_AccessibilityEventInfo object to destroy. + * @since 13 + */ +void OH_ArkUI_DestoryAccessibilityEventInfo(ArkUI_AccessibilityEventInfo* eventInfo); + +/** +* @brief Sets the event type for an ArkUI_AccessibilityEventInfo object. +* +* @param eventInfo Indicates the pointer to an ArkUI_AccessibilityEventInfo object. +* @param eventType Indicates the event type. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityEventSetEventType( + ArkUI_AccessibilityEventInfo* eventInfo, ArkUI_AccessibilityEventType eventType); + +/** +* @brief Sets the text announced for accessibility for an ArkUI_AccessibilityEventInfo object. +* +* @param eventInfo Indicates the pointer to an ArkUI_AccessibilityEventInfo object. +* @param textAnnouncedForAccessibility Indicates the text announced for accessibility. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility( + ArkUI_AccessibilityEventInfo* eventInfo, const char* textAnnouncedForAccessibility); + +/** +* @brief Sets the request focus ID for an ArkUI_AccessibilityEventInfo object. +* +* @param eventInfo Indicates the pointer to an ArkUI_AccessibilityEventInfo object. +* @param requestFocusId Indicates the request focus ID. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityEventSetRequestFocusId( + ArkUI_AccessibilityEventInfo* eventInfo, int32_t requestFocusId); + +/** +* @brief Sets the element information for an ArkUI_AccessibilityEventInfo object. +* +* @param eventInfo Indicates the pointer to an ArkUI_AccessibilityEventInfo object. +* @param elementInfo Indicates the pointer to an ArkUI_AccessibilityElementInfo object. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_AccessibilityEventSetElementInfo( + ArkUI_AccessibilityEventInfo* eventInfo, ArkUI_AccessibilityElementInfo* elementInfo); + +/** +* @brief Obtains the value of a key from an ArkUI_AccessibilityActionArguments object. +* +* @param arguments Indicates the pointer to an ArkUI_AccessibilityActionArguments object. +* @param key Indicates the key. +* @param value Indicates the value. +* @return Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL} if the operation is successful. +* Returns {@link ARKUI_ACCESSIBILITY_NATIVE_RESULT_BAD_PARAMETER} if a parameter is incorrect. +* @since 13 +*/ +int32_t OH_ArkUI_FindAccessibilityActionArgumentByKey( + ArkUI_AccessibilityActionArguments* arguments, const char* key, char** value); +#ifdef __cplusplus +}; +#endif +#endif // _NATIVE_INTERFACE_ACCESSIBILITY_H diff --git a/arkui/ace_engine/native/native_interface_xcomponent.h b/arkui/ace_engine/native/native_interface_xcomponent.h index bbf7201550d802e3b089f777c686a88294078b5d..301d2a6b92b91f388cc4807efd4d18158d84d5eb 100644 --- a/arkui/ace_engine/native/native_interface_xcomponent.h +++ b/arkui/ace_engine/native/native_interface_xcomponent.h @@ -43,6 +43,7 @@ #include #endif +#include "arkui/native_interface_accessibility.h" #include "arkui/native_type.h" #include "arkui/ui_input_event.h" @@ -53,6 +54,7 @@ extern "C" { #endif #define OH_NATIVE_XCOMPONENT_OBJ ("__NATIVE_XCOMPONENT_OBJ__") +#define OH_NATIVE_XCOMPONENT_MAX_TOUCH_POINTS_NUMBER 10 const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128; const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10; @@ -258,7 +260,7 @@ typedef struct { /** Timestamp of the current touch event. */ int64_t timeStamp; /** Array of the current touch points. */ - OH_NativeXComponent_TouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; + OH_NativeXComponent_TouchPoint touchPoints[OH_NATIVE_XCOMPONENT_MAX_TOUCH_POINTS_NUMBER]; /** Number of current touch points. */ uint32_t numPoints; } OH_NativeXComponent_TouchEvent; @@ -815,6 +817,33 @@ int32_t OH_NativeXComponent_GetTouchEventSourceType( */ OH_NativeXComponent* OH_NativeXComponent_GetNativeXComponent(ArkUI_NodeHandle node); +/** + * @brief Obtains the pointer to the ArkUI_AccessibilityProvider + * instance of this OH_NativeXComponent instance. + * + * @param component Indicates the pointer to the OH_NativeXComponent instance. + * @param handle Indicates the pointer to the ArkUI_AccessibilityProvider instance. + * @return Returns {@link OH_NATIVEXCOMPONENT_RESULT_SUCCESS} if the operation is successful. + * Returns {@link OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER} if a parameter error occurs. + * @since 13 + */ +int32_t OH_NativeXComponent_GetNativeAccessibilityProvider( + OH_NativeXComponent* component, ArkUI_AccessibilityProvider** handle); + +/** + * @brief Registers a callback for this OH_NativeXComponent instance. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param callback Indicates the pointer to a key event callback with result. + * @return Returns the status code of the execution. + * {@link OH_NATIVEXCOMPONENT_RESULT_SUCCESS} the callback function is successfully registered.\n + * {@link OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER} component is nullptr or callback is nullptr.\n + * @since 14 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterKeyEventCallbackWithResult( + OH_NativeXComponent* component, bool (*callback)(OH_NativeXComponent* component, void* window)); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_key_event.h b/arkui/ace_engine/native/native_key_event.h new file mode 100644 index 0000000000000000000000000000000000000000..0ab0303a12598873217f2782af77e281d47ea5ae --- /dev/null +++ b/arkui/ace_engine/native/native_key_event.h @@ -0,0 +1,535 @@ +/* + * 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 ArkUI_NativeModule + * @{ + * + * @brief Provides the general key event APIs of ArkUI on the native side. + * + * @since 14 + */ + +/** + * @file native_key_event.h + * + * @brief Declares the APIs related to native key events. + * + * @library libace_ndk.z.so + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @kit ArkUI + * @since 14 + */ + +#ifndef ARKUI_NATIVE_KEY_EVENT_H +#define ARKUI_NATIVE_KEY_EVENT_H + +#include + +#include "native_type.h" +#include "ui_input_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines an enum for the key codes in key events. + * + * @since 14 + */ +typedef enum { + /** Unknown (or unrecognized) key **/ + ARKUI_KEYCODE_UNKNOWN = -1, + /** Function (Fn) key **/ + ARKUI_KEYCODE_FN = 0, + /** Volume Up key **/ + ARKUI_KEYCODE_VOLUME_UP = 16, + /** Volume Down key **/ + ARKUI_KEYCODE_VOLUME_DOWN = 17, + /** Power key **/ + ARKUI_KEYCODE_POWER = 18, + /** Shutter key **/ + ARKUI_KEYCODE_CAMERA = 19, + /** Speaker Mute key **/ + ARKUI_KEYCODE_VOLUME_MUTE = 22, + /** Mute key **/ + ARKUI_KEYCODE_MUTE = 23, + /** Brightness Up key **/ + ARKUI_KEYCODE_BRIGHTNESS_UP = 40, + /** Brightness Down key **/ + ARKUI_KEYCODE_BRIGHTNESS_DOWN = 41, + /** Key 0 **/ + ARKUI_KEYCODE_0 = 2000, + /** Key 1 **/ + ARKUI_KEYCODE_1 = 2001, + /** Key 2 **/ + ARKUI_KEYCODE_2 = 2002, + /** Key 3 **/ + ARKUI_KEYCODE_3 = 2003, + /** Key 4 **/ + ARKUI_KEYCODE_4 = 2004, + /** Key 5 **/ + ARKUI_KEYCODE_5 = 2005, + /** Key 6 **/ + ARKUI_KEYCODE_6 = 2006, + /** Key 7 **/ + ARKUI_KEYCODE_7 = 2007, + /** Key 8 **/ + ARKUI_KEYCODE_8 = 2008, + /** Key 9 **/ + ARKUI_KEYCODE_9 = 2009, + /** Key + **/ + ARKUI_KEYCODE_STAR = 2010, + /** Key # **/ + ARKUI_KEYCODE_POUND = 2011, + /** Up key on D-pad **/ + ARKUI_KEYCODE_DPAD_UP = 2012, + /** Down key on D-pad **/ + ARKUI_KEYCODE_DPAD_DOWN = 2013, + /** Left key on D-pad **/ + ARKUI_KEYCODE_DPAD_LEFT = 2014, + /** Right key on D-pad **/ + ARKUI_KEYCODE_DPAD_RIGHT = 2015, + /** OK key on D-pad **/ + ARKUI_KEYCODE_DPAD_CENTER = 2016, + /** Key A **/ + ARKUI_KEYCODE_A = 2017, + /** Key B **/ + ARKUI_KEYCODE_B = 2018, + /** Key C **/ + ARKUI_KEYCODE_C = 2019, + /** Key D **/ + ARKUI_KEYCODE_D = 2020, + /** Key E **/ + ARKUI_KEYCODE_E = 2021, + /** Key F **/ + ARKUI_KEYCODE_F = 2022, + /** Key G **/ + ARKUI_KEYCODE_G = 2023, + /** Key H **/ + ARKUI_KEYCODE_H = 2024, + /** Key I **/ + ARKUI_KEYCODE_I = 2025, + /** Key J **/ + ARKUI_KEYCODE_J = 2026, + /** Key K **/ + ARKUI_KEYCODE_K = 2027, + /** Key L **/ + ARKUI_KEYCODE_L = 2028, + /** Key M **/ + ARKUI_KEYCODE_M = 2029, + /** Key N **/ + ARKUI_KEYCODE_N = 2030, + /** Key O **/ + ARKUI_KEYCODE_O = 2031, + /** Key P **/ + ARKUI_KEYCODE_P = 2032, + /** Key R **/ + ARKUI_KEYCODE_Q = 2033, + /** Key R **/ + ARKUI_KEYCODE_R = 2034, + /** Key S **/ + ARKUI_KEYCODE_S = 2035, + /** Key T **/ + ARKUI_KEYCODE_T = 2036, + /** Key U **/ + ARKUI_KEYCODE_U = 2037, + /** Key V **/ + ARKUI_KEYCODE_V = 2038, + /** Key W **/ + ARKUI_KEYCODE_W = 2039, + /** Key X **/ + ARKUI_KEYCODE_X = 2040, + /** Key Y **/ + ARKUI_KEYCODE_Y = 2041, + /** Key Z **/ + ARKUI_KEYCODE_Z = 2042, + /** Key # **/ + ARKUI_KEYCODE_COMMA = 2043, + /** Key # **/ + ARKUI_KEYCODE_PERIOD = 2044, + /** Left Alt key **/ + ARKUI_KEYCODE_ALT_LEFT = 2045, + /** Right Alt key **/ + ARKUI_KEYCODE_ALT_RIGHT = 2046, + /** Left Shift key **/ + ARKUI_KEYCODE_SHIFT_LEFT = 2047, + /** Right Shift key **/ + ARKUI_KEYCODE_SHIFT_RIGHT = 2048, + /** Tab key **/ + ARKUI_KEYCODE_TAB = 2049, + /** Space key **/ + ARKUI_KEYCODE_SPACE = 2050, + /** Symbol key **/ + ARKUI_KEYCODE_SYM = 2051, + /** Explorer key, used to start the explorer application **/ + ARKUI_KEYCODE_EXPLORER = 2052, + /** Email key, used to start the email application **/ + ARKUI_KEYCODE_ENVELOPE = 2053, + /** Enter key **/ + ARKUI_KEYCODE_ENTER = 2054, + /** Backspace key **/ + ARKUI_KEYCODE_DEL = 2055, + /** Key ` **/ + ARKUI_KEYCODE_GRAVE = 2056, + /** Key - **/ + ARKUI_KEYCODE_MINUS = 2057, + /** Key = **/ + ARKUI_KEYCODE_EQUALS = 2058, + /** Key [ **/ + ARKUI_KEYCODE_LEFT_BRACKET = 2059, + /** Key ]**/ + ARKUI_KEYCODE_RIGHT_BRACKET = 2060, + /** Key \\ **/ + ARKUI_KEYCODE_BACKSLASH = 2061, + /** Key ; **/ + ARKUI_KEYCODE_SEMICOLON = 2062, + /** Key ' **/ + ARKUI_KEYCODE_APOSTROPHE = 2063, + /** Key / **/ + ARKUI_KEYCODE_SLASH = 2064, + /** Key @ **/ + ARKUI_KEYCODE_AT = 2065, + /** Key + **/ + ARKUI_KEYCODE_PLUS = 2066, + /** Menu key **/ + ARKUI_KEYCODE_MENU = 2067, + /** Page Up key **/ + ARKUI_KEYCODE_PAGE_UP = 2068, + /** Page Down key **/ + ARKUI_KEYCODE_PAGE_DOWN = 2069, + /** ESC key **/ + ARKUI_KEYCODE_ESCAPE = 2070, + /** Delete key **/ + ARKUI_KEYCODE_FORWARD_DEL = 2071, + /** Left Ctrl key **/ + ARKUI_KEYCODE_CTRL_LEFT = 2072, + /** Right Ctrl key **/ + ARKUI_KEYCODE_CTRL_RIGHT = 2073, + /** Caps Lock key **/ + ARKUI_KEYCODE_CAPS_LOCK = 2074, + /** Scroll Lock key **/ + ARKUI_KEYCODE_SCROLL_LOCK = 2075, + /** Left Meta key **/ + ARKUI_KEYCODE_META_LEFT = 2076, + /** Right Meta key **/ + ARKUI_KEYCODE_META_RIGHT = 2077, + /** Function key **/ + ARKUI_KEYCODE_FUNCTION = 2078, + /** System Request/Print Screen key **/ + ARKUI_KEYCODE_SYSRQ = 2079, + /** Break/Pause key **/ + ARKUI_KEYCODE_BREAK = 2080, + /** Move to Home key **/ + ARKUI_KEYCODE_MOVE_HOME = 2081, + /** Move to End key **/ + ARKUI_KEYCODE_MOVE_END = 2082, + /** Insert key **/ + ARKUI_KEYCODE_INSERT = 2083, + /** Forward key **/ + ARKUI_KEYCODE_FORWARD = 2084, + /** Play key **/ + ARKUI_KEYCODE_MEDIA_PLAY = 2085, + /** Pause key **/ + ARKUI_KEYCODE_MEDIA_PAUSE = 2086, + /** Close key **/ + ARKUI_KEYCODE_MEDIA_CLOSE = 2087, + /** Eject key **/ + ARKUI_KEYCODE_MEDIA_EJECT = 2088, + /** Record key **/ + ARKUI_KEYCODE_MEDIA_RECORD = 2089, + /** F1 key **/ + ARKUI_KEYCODE_F1 = 2090, + /** F2 key **/ + ARKUI_KEYCODE_F2 = 2091, + /** F3 key **/ + ARKUI_KEYCODE_F3 = 2092, + /** F4 key **/ + ARKUI_KEYCODE_F4 = 2093, + /** F5 key **/ + ARKUI_KEYCODE_F5 = 2094, + /** F6 key **/ + ARKUI_KEYCODE_F6 = 2095, + /** F7 key **/ + ARKUI_KEYCODE_F7 = 2096, + /** F8 key **/ + ARKUI_KEYCODE_F8 = 2097, + /** F9 key **/ + ARKUI_KEYCODE_F9 = 2098, + /** F10 key **/ + ARKUI_KEYCODE_F10 = 2099, + /** F11 key **/ + ARKUI_KEYCODE_F11 = 2100, + /** F12 key **/ + ARKUI_KEYCODE_F12 = 2101, + /** Number Lock key on numeric keypad **/ + ARKUI_KEYCODE_NUM_LOCK = 2102, + /** Key 0 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_0 = 2103, + /** Key 1 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_1 = 2104, + /** Key 2 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_2 = 2105, + /** Key 3 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_3 = 2106, + /** Key 4 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_4 = 2107, + /** Key 5 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_5 = 2108, + /** Key 6 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_6 = 2109, + /** Key 7 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_7 = 2110, + /** Key 8 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_8 = 2111, + /** Key 9 on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_9 = 2112, + /** Key / on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_DIVIDE = 2113, + /** Key ) on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_MULTIPLY = 2114, + /** Key - on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_SUBTRACT = 2115, + /** Key + on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_ADD = 2116, + /** Key . on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_DOT = 2117, + /** Key , on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_COMMA = 2118, + /** Enter key on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_ENTER = 2119, + /** Key = on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_EQUALS = 2120, + /** Key ( on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_LEFT_PAREN = 2121, + /** Key ) on numeric keypad **/ + ARKUI_KEYCODE_NUMPAD_RIGHT_PAREN = 2122, +} ArkUI_KeyCode; + +/** + * @brief Defines an enum for the key event types. + * + * @since 14 + */ +typedef enum { + /** Unknown type **/ + ARKUI_KEY_EVENT_UNKNOWN = -1, + /** Pressing of a key **/ + ARKUI_KEY_EVENT_DOWN = 0, + /** Release of a key **/ + ARKUI_KEY_EVENT_UP = 1, + /** Long press of a key **/ + ARKUI_KEY_EVENT_LONG_PRESS = 2, + /** Click of a key **/ + ARKUI_KEY_EVENT_CLICK = 3, +} ArkUI_KeyEventType; + +/** + * @brief Defines an enum for the types of devices that trigger a key event. + * + * @since 14 + */ +typedef enum { + /** Unknown type **/ + ARKUI_KEY_SOURCE_UNKNOWN = 0, + /** Mouse **/ + ARKUI_KEY_SOURCE_TYPE_MOUSE = 1, + /** Keyboard **/ + ARKUI_KEY_SOURCE_TYPE_KEYBOARD = 4, +} ArkUI_KeySourceType; + +/** + * @brief Defines an enum for key intentions. + * + * @since 14 + */ +typedef enum { + /** Unknown intention **/ + ARKUI_KEY_INTENSION_UNKNOWN = -1, + /**Upward**/ + ARKUI_KEY_INTENSION_UP = 1, + /** Downward **/ + ARKUI_KEY_INTENSION_DOWN = 2, + /** Leftward **/ + ARKUI_KEY_INTENSION_LEFT = 3, + /** Rightward **/ + ARKUI_KEY_INTENSION_RIGHT = 4, + /** Select **/ + ARKUI_KEY_INTENSION_SELECT = 5, + /** Escape **/ + ARKUI_KEY_INTENSION_ESCAPE = 6, + /** Back**/ + ARKUI_KEY_INTENSION_BACK = 7, + /** Forward **/ + ARKUI_KEY_INTENSION_FORWARD = 8, + /** Menu **/ + ARKUI_KEY_INTENSION_MENU = 9, + /** Home **/ + ARKUI_KEY_INTENSION_HOME = 10, + /** Page up **/ + ARKUI_KEY_INTENSION_PAGE_UP = 11, + /** Page down **/ + ARKUI_KEY_INTENSION_PAGE_DOWN = 12, + /** Zoom out **/ + ARKUI_KEY_INTENSION_ZOOM_OUT = 13, + /** Zoom in **/ + ARKUI_KEY_INTENSION_ZOOM_IN = 14, + + /** Play or pause **/ + ARKUI_KEY_INTENTION_MEDIA_PLAY_PAUSE = 100, + /** Fast-forward **/ + ARKUI_KEY_INTENTION_MEDIA_FAST_FORWARD = 101, + /** Fast playback **/ + ARKUI_KEY_INTENTION_MEDIA_FAST_PLAYBACK = 103, + /** Play next **/ + ARKUI_KEY_INTENTION_MEDIA_NEXT = 104, + /** Play previous **/ + ARKUI_KEY_INTENTION_MEDIA_PREVIOUS = 105, + /** Mute **/ + ARKUI_KEY_INTENTION_MEDIA_MUTE = 106, + /** Volume up **/ + ARKUI_KEY_INTENTION_VOLUME_UP = 107, + /** Volume down **/ + ARKUI_KEY_INTENTION_VOLUME_DOWN = 108, + + /** Answer a call **/ + ARKUI_KEY_INTENTION_CALL = 200, + /** Camera **/ + ARKUI_KEY_INTENTION_CAMERA = 300, +} ArkUI_KeyIntension; + +/** + * @brief Obtains the type of a key event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the key event type. + * @since 14 + */ +ArkUI_KeyEventType OH_ArkUI_KeyEvent_GetType(const ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the key code from a key event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the key code. + * @since 14 + */ +int32_t OH_ArkUI_KeyEvent_GetKeyCode(const ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the key value from a key event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the key value. + * @since 14 + */ +const char *OH_ArkUI_KeyEvent_GetKeyText(const ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the type of device that triggers a key event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the device type. + * @since 14 + */ +ArkUI_KeySourceType OH_ArkUI_KeyEvent_GetKeySource(const ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the ID of device that triggers a key event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the device ID. + * @since 14 + */ +int32_t OH_ArkUI_KeyEvent_GetDeviceId(const ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the state of the meta key (that is, the WIN key on the Windows keyboard or the Command + * key on the Mac keyboard) when a key event occurs. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the state of the meta key. The value 1 means that the key is pressed, and 0 means the + * opposite. + * @since 14 + */ +int32_t OH_ArkUI_KeyEvent_GetMetaKey(const ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the timestamp of a key event. It is the interval between the time when the event is triggered and the + * time when the system starts, in nanoseconds. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the event timestamp, in nanoseconds. + * @since 14 + */ +uint64_t OH_ArkUI_KeyEvent_GetTimestamp(const ArkUI_UIInputEvent* event); + +/** + * @brief Prevents a key event from bubbling up. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param stopPropagation Whether to stop event propagation. + * @since 14 + */ +void OH_ArkUI_KeyEvent_StopPropagation(const ArkUI_UIInputEvent* event, bool stopPropagation); + +/** + * @brief Obtains the pressed status of modifier keys from a key event. + * The following modifier keys are supported: Ctrl, Alt, Shift, Fn. However, the Fn key on external keyboards + * is not supported. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param modifierKeys Modifier keys to check, which must be created using {@link ArkUI_ModifierKeyName}. + * @return Returns whether the pressed status of the modifier keys. + * @since 14 + */ +bool OH_ArkUI_KeyEvent_GetModifierKeyState(const ArkUI_UIInputEvent* event, uint32_t modifierKeys); + +/** + * @brief Obtains the intention code associated with a key event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the intention code associated with the key event. + * @since 14 + */ +ArkUI_KeyIntension OH_ArkUI_KeyEvent_GetKeyIntensionCode(const ArkUI_UIInputEvent* event); + +/** + * @brief Obtains the Unicode value associated with a key event. + * Non-space basic Latin characters in the 0x0021-0x007E range are supported. Characters with a value of 0 are not + * supported. In the case of key combination, this API returns the Unicode value of the key corresponding to the key + * event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the Unicode value. + * @since 14 + */ +uint32_t OH_ArkUI_KeyEvent_GetUnicode(const ArkUI_UIInputEvent* event); + +/** + * @brief Sets whether a key event is consumed in the key event callback. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param isConsumed Whether the event is consumed. + * @since 14 + */ +void OH_ArkUI_KeyEvent_SetConsumed(const ArkUI_UIInputEvent* event, bool isConsumed); +#ifdef __cplusplus +}; +#endif + +#endif // ARKUI_NATIVE_KEY_EVENT_H +/** @} */ \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 1412a47cfb2a2994f5ec96280b8a77d1c811e5d2..a1a28ebc8de52f5a461dd12b233581dafea72c60 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -122,6 +122,8 @@ typedef enum { ARKUI_NODE_GRID, /** Grid item. */ ARKUI_NODE_GRID_ITEM, + /** Custom span. */ + ARKUI_NODE_CUSTOM_SPAN, } ArkUI_NodeType; /** @@ -494,15 +496,16 @@ typedef enum { */ NODE_VISIBILITY, /** - * @brief Defines the clip attribute, which can be set, reset, and obtained as required through APIs. + * @brief Defines the clipping and masking attribute, which can be set, reset, and obtained as required through + * APIs. * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .value[0].i32: whether to clip the component based on the parent container bounds. - * The value 0 means to clip the component, and 1 means the opposite. \n + * The value 1 means to clip the component, and 0 means the opposite. \n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .value[0].i32: whether to clip the component based on the parent container bounds. - * The value 0 means to clip the component, and 1 means the opposite. \n + * The value 1 means to clip the component, and 0 means the opposite. \n * */ NODE_CLIP, @@ -1027,10 +1030,10 @@ typedef enum { * .string: command for drawing the path.\n * 5. Progress:\n * .value[0].i32: mask type. The parameter type is {@link ArkUI_MaskType}. - * The value is ARKUI_MASK_TYPE_PROSGRESS for the progress shape.\n + * The value is ARKUI_MASK_TYPE_PROGRESS for the progress shape.\n * .value[1].f32: current value of the progress indicator.\n * .value[2].f32: maximum value of the progress indicator.\n - * .value[3].u32: color of the progress indicator.\n + * .value[3].u32: color of the progress indicator, in 0xARGB format.\n * \n * Format of the return value {@link ArkUI_AttributeItem}, which supports five types of shapes:\n * 1. Rectangle:\n @@ -1084,13 +1087,13 @@ typedef enum { * .value[0].i32: blend mode. The parameter type is {@link ArkUI_BlendMode}. The default value is * ARKUI_BLEND_MODE_NONE. \n * .value[1].?i32: how the specified blend mode is applied. The parameter type is {@link ArkUI_BlendApplyType}. - * The default value is ARKUI_BLEND_APPLY_TYPE_FAST. \n + * The default value is BLEND_APPLY_TYPE_FAST. \n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .value[0].i32: blend mode. The parameter type is {@link ArkUI_BlendMode}. The default value is * ARKUI_BLEND_MODE_NONE. \n * .value[1].i32: how the specified blend mode is applied. The parameter type is {@link ArkUI_BlendApplyType}. - * The default value is ARKUI_BLEND_APPLY_TYPE_FAST. \n + * The default value is BLEND_APPLY_TYPE_FAST. \n * */ NODE_BLEND_MODE, @@ -1351,7 +1354,9 @@ typedef enum { /** * @brief Defines the focused state. This attribute can be set and obtained as required through APIs. - * + * @note Setting the parameter to 0 shifts focus from the currently focused component on the current level + * of the page to the root container. + * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .value[0].i32: The parameter type is 1 or 0. * \n @@ -1811,6 +1816,16 @@ typedef enum { */ NODE_UNIQUE_ID = 95, + /** + * @brief Defines the moving distance limit for the component-bound tap gesture. + * This attribute can be set as required through APIs. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].f32: allowed moving distance of a finger, in vp. \n + * + */ + NODE_CLICK_DISTANCE = 97, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -2172,6 +2187,18 @@ typedef enum { */ NODE_TEXT_CONTENT_WITH_STYLED_STRING, + /** + * @brief Sets whether to center text vertically in the text component. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].i32: whether to center text vertically. The default value is false. \n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].i32: whether to center text vertically. \n + * + */ + NODE_TEXT_HALF_LEADING = 1029, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -2259,6 +2286,21 @@ typedef enum { * */ NODE_IMAGE_SPAN_ALT, + /** + * @brief Defines the baseline offset attribute of the ImageSpan component. + * This attribute can be set, reset, and obtained as required through APIs. + * A positive value means an upward offset, while a negative value means a downward offset. + * The default value is 0, and the unit is fp. \n + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].f32: baseline offset, in fp.\n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].f32: baseline offset, in fp. \n + * + * @since 13 + */ + NODE_IMAGE_SPAN_BASELINE_OFFSET = 3003, /** * @brief Defines the image source of the component. * This attribute can be set, reset, and obtained as required through APIs. @@ -4424,7 +4466,7 @@ typedef enum { * @brief Scroll to the next or previous page. * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n - * .value[0].i32 Indicates whether to scroll to next page. Value 1 indicates scroll to next page and value 0 + * .value[0].i32 Indicates whether to scroll to next page. Value 0 indicates scroll to next page and value 1 * indicates scroll to previous page. \n * .value[1]?.i32 Indicates whether to enable animation. Value 1 indicates enable and 0 indicates disable. \n * @@ -4441,6 +4483,48 @@ typedef enum { */ NODE_SCROLL_BY, + /** + * @brief Performs inertial scrolling based on the initial velocity passed in. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].f32: Initial velocity of inertial scrolling. Unit: vp/s. If the value specified is 0, it is + * considered as invalid, and the scrolling for this instance will not take effect. If the value is positive, + * the scroll will move downward; if the value is negative, the scroll will move upward. \n + * + * @since 13 + */ + NODE_SCROLL_FLING, + + /** + * @brief Sets the fading effect for the edges of scrollable components. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute: + * .value[0].i32: whether to enable the fading effect on edges. The value 0 means to disable the fading effect, + * and 1 means to enable it. + * .value[1]?.f32: length of the fading effect on edges, in vp. Default value: 32. + * + * Format of the return value {@link ArkUI_AttributeItem}: + * .value[0].i32: whether the fading effect on edges is enabled. The value 0 means that the fading effect is + * disabled, and 1 means that it is enabled. + * .value[1].f32: length of the fading effect on edges, in vp. + * + * @since 14 + */ + NODE_SCROLL_FADING_EDGE, + + /** + * @brief Obtains the total size of all child components when fully expanded in the scrollable component. + * + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].f32: total width of all child components when fully expanded in the scrollable component. + * The default unit is vp. \n + * .value[1].f32: total height of all child components when fully expanded in the scrollable component. + * The default unit is vp. \n + * + * @since 14 + */ + NODE_SCROLL_SIZE, + /** * @brief Defines the direction in which the list items are arranged. This attribute can be set, reset, and * obtained as required through APIs. @@ -5537,7 +5621,7 @@ typedef enum { * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is * {@link ArkUI_NodeComponentEvent}. \n * {@link ArkUI_NodeComponentEvent} contains one parameter:\n - * ArkUI_NodeComponentEvent.data[0].i32: corresponds to {@link ArkUI_PreViewDragStatus}. \n + * ArkUI_NodeComponentEvent.data[0].i32: corresponds to {@link ArkUI_PreDragStatus}. \n */ NODE_ON_PRE_DRAG = 14, /** @@ -5590,6 +5674,31 @@ typedef enum { * {@link ArkUI_NodeEvent} object. \n */ NODE_ON_DRAG_END = 20, + /** + * @brief Defines the event triggered when a key event occurs. + * + * The callback can be triggered during interactions with a focused window using an external keyboard or other input + * device. \n + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is + * {@link ArkUI_NodeComponentEvent}. \n + * + * @since 14 + */ + NODE_ON_KEY_EVENT = 21, + /** + * @brief Defines the event triggered before the input method responds to the key action. + * + * If the return value of this callback is true, it is considered that the key event has been consumed, and + * subsequent event callbacks (keyboardShortcut, input method events, onKeyEvent) will be intercepted + * and no longer triggered. + * The callback can be triggered during interactions with a focused window using an external keyboard or other input + * device. \n + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is + * {@link ArkUI_NodeComponentEvent}. \n + * + * @since 14 + */ + NODE_ON_KEY_PRE_IME = 22, /** * @brief Triggers onDetectResultUpdate callback @@ -7406,6 +7515,48 @@ ArkUI_NodeHandle OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent* e */ ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent* event); +/** +* @brief Obtains the measurement information of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param info Indicates the measurement information to be obtained. +* @return Returns the result code. +* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMeasureInfo* info); + +/** +* @brief Sets the measurement metrics of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param metrics Indicates the measurement metrics to set. +* @return Returns the result code. +* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMetrics* metrics); + +/** +* @brief Obtains the drawing information of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param info Indicates the drawing information to obtain. +* @return Returns the result code. +* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanDrawInfo* info); + /** * @brief Defines the node content event type. * @@ -7431,7 +7582,7 @@ typedef struct ArkUI_NodeContentEvent ArkUI_NodeContentEvent; typedef void (*ArkUI_NodeContentCallback)(ArkUI_NodeContentEvent* event); /** - * @brief register a callback functoin to a node content. + * @brief register a callback function to a node content. * * @param content Indicates the pointer to the node content instance. * @param callback Indicates the callback function. @@ -7498,7 +7649,7 @@ int32_t OH_ArkUI_NodeContent_AddNode(ArkUI_NodeContentHandle content, ArkUI_Node * * @param content Indicates the pointer to the node content instance. * @param node Indicates the pointer to the node - * @return Returns the error code. + * @return Returns the error code. * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. * @since 12 @@ -7596,6 +7747,25 @@ int32_t OH_ArkUI_NodeUtils_GetPositionWithTranslateInWindow(ArkUI_NodeHandle nod */ int32_t OH_ArkUI_NodeUtils_GetPositionWithTranslateInScreen(ArkUI_NodeHandle node, ArkUI_IntOffset* translateOffset); +/** + * @brief Add the custom property of the component. This interface only works on the main thread. + * + * @param node ArkUI_NodeHandle pointer. + * @param name The name of the custom property. Passing null pointers is not allowed. + * @param value The value of the custom property. Passing null pointers is not allowed. + * @since 13 + */ +void OH_ArkUI_NodeUtils_AddCustomProperty(ArkUI_NodeHandle node, const char* name, const char* value); + +/** + * @brief Remove the custom property of the component. + * + * @param node ArkUI_NodeHandle pointer. + * @param name The name of the custom property. + * @since 13 + */ +void OH_ArkUI_NodeUtils_RemoveCustomProperty(ArkUI_NodeHandle node, const char* name); + /** * @brief Collapse the ListItem in its expanded state. * @@ -7620,6 +7790,72 @@ int32_t OH_ArkUI_List_CloseAllSwipeActions(ArkUI_NodeHandle node, void* userData */ ArkUI_ContextHandle OH_ArkUI_GetContextByNode(ArkUI_NodeHandle node); +/** +* @brief The event called when the system color mode changes. +* Only one system color change callback can be registered for the same component. +* +* @param node Indicates the target node. +* @param userData Indicates the custom data to be saved. +* @param onColorModeChange Callback Events. +* @return Error code. +* {@link ARKUI_ERROR_CODE_NO_ERROR} Success. +* {@link ARKUI_ERROR_CODE_PARAM_INVALID} Function parameter exception. +* {@link ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED} The component does not support this event. +* @since 12 +*/ +int32_t OH_ArkUI_RegisterSystemColorModeChangeEvent(ArkUI_NodeHandle node, + void* userData, void (*onColorModeChange)(ArkUI_SystemColorMode colorMode, void* userData)); + +/** +* @brief Unregister the event callback when the system color mode changes. +* +* @param node Indicates the target node. +* @since 12 +*/ +void OH_ArkUI_UnregisterSystemColorModeChangeEvent(ArkUI_NodeHandle node); + +/** +* @brief The event called when the system font style changes. +* Only one system font change callback can be registered for the same component. +* +* @param node Indicates the target node. +* @param userData Indicates the custom data to be saved. +* @param onFontStyleChange Callback Events. +* @return Error code. +* {@link ARKUI_ERROR_CODE_NO_ERROR} Success. +* {@link ARKUI_ERROR_CODE_PARAM_INVALID} Function parameter exception. +* {@link ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED} The component does not support this event. +* @since 12 +*/ +int32_t OH_ArkUI_RegisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node, + void* userData, void (*onFontStyleChange)(ArkUI_SystemFontStyleEvent* event, void* userData)); + +/** +* @brief Unregister the event callback when the system font style changes. +* +* @param node Indicates the target node. +* @since 12 +*/ +void OH_ArkUI_UnregisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node); + +/** + * @brief Retrieve the font size value for system font change events. + * + * @param event Indicates a pointer to the current system font change event. + * @return Updated system font size scaling factor. Default value: 1.0. + * @since 12 + */ +float OH_ArkUI_SystemFontStyleEvent_GetFontSizeScale(const ArkUI_SystemFontStyleEvent* event); + +/** + * @brief Retrieve the font thickness values for system font change events. + * + * @param event Indicates a pointer to the current system font change event. + * @return The updated system font thickness scaling factor. Default value: 1.0. + * @since 12 + */ +float OH_ArkUI_SystemFontStyleEvent_GetFontWeightScale(const ArkUI_SystemFontStyleEvent* event); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index f238b1d6ff91dc6be0bd1c0ec1e84c483909387f..f484a35382dfeb78bf9e1359396865047769170e 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -136,6 +136,13 @@ typedef struct ArkUI_Context* ArkUI_ContextHandle; */ typedef struct ArkUI_SwiperIndicator ArkUI_SwiperIndicator; +/** +* @brief Define the data objects of styled string supported by text components. +* +* @since 14 +*/ +typedef struct ArkUI_StyledString_Descriptor ArkUI_StyledString_Descriptor; + /** * @brief specifies the alignment rules for subcomponents set in relative containers. * @@ -808,7 +815,7 @@ typedef enum { * does not scroll when the component scrolling reaches the boundary. */ ARKUI_SCROLL_NESTED_MODE_SELF_ONLY = 0, /** The component scrolls first, and when it hits the boundary, the parent component scrolls. - /** When the parent component hits the boundary, its edge effect is displayed. If no edge + * When the parent component hits the boundary, its edge effect is displayed. If no edge * effect is specified for the parent component, the edge effect of the child component is displayed instead. */ ARKUI_SCROLL_NESTED_MODE_SELF_FIRST, /** The parent component scrolls first, and when it hits the boundary, the component scrolls. @@ -983,6 +990,18 @@ typedef enum { ARKUI_COLOR_MODE_DARK, } ArkUI_ColorMode; +/** + * @brief Enumerates the system color modes. + * + * @since 12 + */ +typedef enum { + /** Light color mode. */ + ARKUI_SYSTEM_COLOR_MODE_LIGHT = 0, + /** Dark color mode. */ + ARKUI_SYSTEM_COLOR_MODE_DARK, +} ArkUI_SystemColorMode; + /** * @brief Enumerates the blur styles. * @@ -1511,7 +1530,7 @@ typedef enum { /** The content of the view is blended in sequence on the target image. */ BLEND_APPLY_TYPE_FAST = 0, /** The content of the component and its child components are drawn on the offscreen canvas, and then blended with - /* the existing content on the canvas. */ + * the existing content on the canvas. */ BLEND_APPLY_TYPE_OFFSCREEN, } ArkUI_BlendApplyType; @@ -1895,6 +1914,15 @@ typedef enum { ARKUI_ERROR_CODE_GET_INFO_FAILED = 106201, /** The buffer size is not large enough. */ ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR = 106202, + /** The component is not a scroll container. */ + ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER = 180001, + /** The buffer is not large enough. */ + ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH = 180002, + /** + * @error invalid styled string. + * @since 14 + */ + ARKUI_ERROR_CODE_INVALID_STYLED_STRING = 180101, } ArkUI_ErrorCode; /** @@ -2063,6 +2091,27 @@ typedef struct { float perspective; } ArkUI_RotationOptions; +/** + * @brief Defines a struct for the measurement information of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanMeasureInfo ArkUI_CustomSpanMeasureInfo; + +/** + * @brief Defines a struct for the measurement metrics of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanMetrics ArkUI_CustomSpanMetrics; + +/** + * @brief Defines a struct for the drawing information of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanDrawInfo ArkUI_CustomSpanDrawInfo; + /** * @brief Defines the state of the NavDestination component. * @@ -2137,6 +2186,13 @@ typedef enum { ARKUI_SAFE_AREA_EDGE_END = 1 << 3, } ArkUI_SafeAreaEdge; +/** + * @brief Defines parameter used by the system font style callback event. + * + * @since 12 + */ +typedef struct ArkUI_SystemFontStyleEvent ArkUI_SystemFontStyleEvent; + /** * @brief Creates a size constraint. * @@ -2458,16 +2514,6 @@ void OH_ArkUI_WaterFlowSectionOption_SetMargin(ArkUI_WaterFlowSectionOption* opt */ ArkUI_Margin OH_ArkUI_WaterFlowSectionOption_GetMargin(ArkUI_WaterFlowSectionOption* option, int32_t index); -/** -* @brief Obtains the number of items in the water flow section that matches the specified index. -* -* @param option Indicates the pointer to a water flow section configuration. -* @param index Indicates the index of the target water flow section. -* @return Returns the number of items in the water flow section. -* @since 12 -*/ -int32_t OH_ArkUI_WaterFlowSectionOption_GetItemCount(ArkUI_WaterFlowSectionOption* option, int32_t index); - /** * @brief Creates a navigation indicator. * @@ -3410,6 +3456,133 @@ int32_t OH_ArkUI_ListChildrenMainSizeOption_UpdateSize(ArkUI_ListChildrenMainSiz */ float OH_ArkUI_ListChildrenMainSizeOption_GetMainSize(ArkUI_ListChildrenMainSize* option, int32_t index); +/** + * @brief Creates measurement information for this custom span. + * + * @return Returns a CustomSpanMeasureInfo instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanMeasureInfo* OH_ArkUI_CustomSpanMeasureInfo_Create(); + +/** + * @brief Disposes of measurement information of this custom span. + * + * @param info The CustomSpanMeasureInfo instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanMeasureInfo_Dispose(ArkUI_CustomSpanMeasureInfo* info); + +/** + * @brief Obtains the font size of a custom span. + * + * @param info Indicates the pointer to the measurement information of a custom span. + * @return Returns the font size. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(ArkUI_CustomSpanMeasureInfo* info); + +/** + * @brief Creates measurement metrics for this custom span. + * + * @return Returns a CustomSpanMetrics instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanMetrics* OH_ArkUI_CustomSpanMetrics_Create(); + +/** + * @brief Disposes of measurement metrics of this custom span. + * + * @param info The CustomSpanMetrics instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanMetrics_Dispose(ArkUI_CustomSpanMetrics* metrics); + +/** + * @brief Sets the width for a custom span. + * + * @param metrics Indicates the pointer to a CustomSpanMetrics instance. + * @param width Indicates the width, in px. The width should be greater than 0. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +int32_t OH_ArkUI_CustomSpanMetrics_SetWidth(ArkUI_CustomSpanMetrics* metrics, float width); + +/** + * @brief Sets the height for a custom span. + * + * @param metrics Indicates the pointer to a CustomSpanMetrics instance. + * @param width Indicates the height, in px. The width should be greater than 0. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +int32_t OH_ArkUI_CustomSpanMetrics_SetHeight(ArkUI_CustomSpanMetrics* metrics, float height); + +/** + * @brief Creates drawing information for this custom span. + * + * @return Returns a CustomSpanDrawInfo instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanDrawInfo* OH_ArkUI_CustomSpanDrawInfo_Create(); + +/** + * @brief Disposes of drawing information for this custom span. + * + * @param info The CustomSpanDrawInfo instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanDrawInfo_Dispose(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the x-axis offset of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the x-axis offset. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetXOffset(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the top margin of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the top margin. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetLineTop(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the bottom margin of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the bottom margin. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the baseline offset of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the baseline offset. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetBaseline(ArkUI_CustomSpanDrawInfo* info); + /** * @brief Create a image frame from the image path. * @param src Indicates the image path. diff --git a/arkui/ace_engine/native/styled_string.h b/arkui/ace_engine/native/styled_string.h index cb537a6c6000eea2ef226d369cfad59a87d2c64a..b3f2db163fc23d816641f647f8b0f8076193ced8 100644 --- a/arkui/ace_engine/native/styled_string.h +++ b/arkui/ace_engine/native/styled_string.h @@ -39,6 +39,7 @@ #include "native_drawing/drawing_text_declaration.h" #include "native_drawing/drawing_text_typography.h" +#include "native_type.h" #ifdef __cplusplus extern "C" { @@ -118,6 +119,62 @@ OH_Drawing_Typography* OH_ArkUI_StyledString_CreateTypography(ArkUI_StyledString */ void OH_ArkUI_StyledString_AddPlaceholder(ArkUI_StyledString* handle, OH_Drawing_PlaceholderSpan* placeholder); +/** + * @brief Creates an ArkUI_StyledString_Descriptor object. + * + * @return Returns the pointer to the ArkUI_StyledString_Descriptor object created. + * @since 14 + */ +ArkUI_StyledString_Descriptor* OH_ArkUI_StyledString_Descriptor_Create(void); + +/** + * @brief Destroys an ArkUI_StyledString_Descriptor object and reclaims the memory occupied by the object. + * + * @param descriptor Pointer to an ArkUI_StyledString_Descriptor object. + * @since 14 + */ +void OH_ArkUI_StyledString_Descriptor_Destroy(ArkUI_StyledString_Descriptor* descriptor); + +/** + * @brief Converts styled string information into HTML. + * + * @param descriptor Pointer to an ArkUI_StyledString_Descriptor object. + * @return Returns the pointer to the resulting HTML string. This pointer is managed internally and should be destroyed + * by calling OH_ArkUI_StyledString_Descriptor_Destroy() when no longer needed to free the memory. + * @since 14 + */ +const char* OH_ArkUI_ConvertToHtml(ArkUI_StyledString_Descriptor* descriptor); + +/** + * @brief Deserializes a byte array containing styled string information into a styled string. + * + * @param buffer Byte array to be deserialized. + * @param bufferSize Length of the byte array. + * @param descriptor Pointer to an ArkUI_StyledString_Descriptor object. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * @since 14 + */ +int32_t OH_ArkUI_UnmarshallStyledStringDescriptor( + uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor); + +/** + * @brief Serializes the styled string information into a byte array. + * + * @param buffer Byte array where the serialized data will be stored. + * @param bufferSize Length of the byte array. + * @param descriptor Pointer to an ArkUI_StyledString_Descriptor object. + * @param resultSize Actual length of the byte array. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_INVALID_STYLED_STRING} if the styled string is invalid. + * @since 14 + */ +int32_t OH_ArkUI_MarshallStyledStringDescriptor( + uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor, size_t* resultSize); + #ifdef __cplusplus }; #endif diff --git a/arkui/display_manager/BUILD.gn b/arkui/display_manager/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ba052e0a375ab34f32e1e43c3952fcf931ad1bd3 --- /dev/null +++ b/arkui/display_manager/BUILD.gn @@ -0,0 +1,37 @@ +# 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("display_manager_header") { + dest_dir = "$ndk_headers_out_dir/window_manager" + sources = [ + "oh_display_capture.h", + "oh_display_info.h", + "oh_display_manager.h", + ] +} + +ohos_ndk_library("native_display_manager") { + output_name = "native_display_manager" + output_extension = "so" + ndk_description_file = "./libdm.ndk.json" + system_capability = "SystemCapability.Window.SessionManager" + system_capability_headers = [ + "oh_display_capture.h", + "oh_display_info.h", + "oh_display_manager.h", + ] + min_compact_version = "12" +} diff --git a/arkui/display_manager/libdm.ndk.json b/arkui/display_manager/libdm.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..c86ff6a93d8d24d1d5f2f63ebdd5d8da7feca174 --- /dev/null +++ b/arkui/display_manager/libdm.ndk.json @@ -0,0 +1,106 @@ +[ + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayId" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayWidth" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayHeight" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayRotation" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayOrientation" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayRefreshRate" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityDpi" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityPixels" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayScaledDensity" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_IsFoldable" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetFoldDisplayMode" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_RegisterDisplayChangeListener" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_UnregisterDisplayChangeListener" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreatePrimaryDisplay" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateDisplayById" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_DestroyDisplay" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateAllDisplays" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_DestroyAllDisplays" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CaptureScreenPixelmap" + } +] \ No newline at end of file diff --git a/arkui/display_manager/oh_display_capture.h b/arkui/display_manager/oh_display_capture.h new file mode 100644 index 0000000000000000000000000000000000000000..a9fd997b1bc0b8ec5ec2c85f4af2164b0a7f2c5b --- /dev/null +++ b/arkui/display_manager/oh_display_capture.h @@ -0,0 +1,69 @@ +/* + * 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 OH_DisplayCapture + * @{ + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 14 + * @version 1.0 + */ + +/** + * @file oh_display_capture.h + * + * @brief Defines the data structures for the C APIs of the display capture. + * + * @kit ArkUI + * @library libnative_display_manager.so + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 14 + * @version 1.0 + */ + +#ifndef OH_NATIVE_DISPLAY_CAPTURE_H +#define OH_NATIVE_DISPLAY_CAPTURE_H + +#include "multimedia/image_framework/image/pixelmap_native.h" +#include "oh_display_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Capture a screen pixelmap of the specified display. + * + * @param displayId The ID of the display to be captured. + * @param pixelMap The output pixel map of the captured display. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. + * { @link DISPLAY_MANAGER_ERROR_NO_PERMISSION } If no permission. + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } If device not support. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CaptureScreenPixelmap(uint32_t displayId, + OH_PixelmapNative **pixelMap); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_NATIVE_DISPLAY_CAPTURE_H diff --git a/arkui/display_manager/oh_display_info.h b/arkui/display_manager/oh_display_info.h new file mode 100644 index 0000000000000000000000000000000000000000..2a4bda3fb7643a3de473854eb0dc58f5c2674331 --- /dev/null +++ b/arkui/display_manager/oh_display_info.h @@ -0,0 +1,349 @@ +/* + * 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. + */ + +#ifndef OH_NATIVE_DISPLAY_INFO_H +#define OH_NATIVE_DISPLAY_INFO_H + +/** + * @addtogroup OH_DisplayInfo + * @{ + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +/** + * @file oh_display_info.h + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @kit ArkUI + * @library libnative_display_manager.so + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief display name length + * @since 14 + */ +#define OH_DISPLAY_NAME_LENGTH 32 + +/** + * @brief Enumerates rotations. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** device rotation 0 degree */ + DISPLAY_MANAGER_ROTATION_0, + + /** device rotation 90 degrees */ + DISPLAY_MANAGER_ROTATION_90, + + /** device rotation 180 degrees */ + DISPLAY_MANAGER_ROTATION_180, + + /** device rotation 270 degree */ + DISPLAY_MANAGER_ROTATION_270, +} NativeDisplayManager_Rotation; + +/** + * @brief Enumerates orientations. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** device portrait show */ + DISPLAY_MANAGER_PORTRAIT = 0, + + /** device landscape show */ + DISPLAY_MANAGER_LANDSCAPE = 1, + + /** device portrait inverted show */ + DISPLAY_MANAGER_PORTRAIT_INVERTED = 2, + + /** device landscape inverted show */ + DISPLAY_MANAGER_LANDSCAPE_INVERTED = 3, + + /** device unknow show */ + DISPLAY_MANAGER_UNKNOWN, +} NativeDisplayManager_Orientation; + +/** + * @brief Enumerates the result types of the display manager interface. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** @error Operation is successful */ + DISPLAY_MANAGER_OK = 0, + + /** @error Operation no permission */ + DISPLAY_MANAGER_ERROR_NO_PERMISSION = 201, + + /** @error Operation not system app */ + DISPLAY_MANAGER_ERROR_NOT_SYSTEM_APP = 202, + + /** @error Operation invalid param */ + DISPLAY_MANAGER_ERROR_INVALID_PARAM = 401, + + /** @error Operation device not supported */ + DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED = 801, + + /** @error Operation screen invalid */ + DISPLAY_MANAGER_ERROR_INVALID_SCREEN = 1400001, + + /** @error Operation invalid call */ + DISPLAY_MANAGER_ERROR_INVALID_CALL = 1400002, + + /** @error Operation system abnormal */ + DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL = 1400003, +} NativeDisplayManager_ErrorCode; + +/** + * @brief Enumerates the fold display mode. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** display mode unknown */ + DISPLAY_MANAGER_FOLD_DISPLAY_MODE_UNKNOWN = 0, + + /** display mode full */ + DISPLAY_MANAGER_FOLD_DISPLAY_MODE_FULL = 1, + + /** display mode main */ + DISPLAY_MANAGER_FOLD_DISPLAY_MODE_MAIN = 2, + + /** display mode sub */ + DISPLAY_MANAGER_FOLD_DISPLAY_MODE_SUB = 3, + + /** display mode coordination */ + DISPLAY_MANAGER_FOLD_DISPLAY_MODE_COORDINATION = 4, +} NativeDisplayManager_FoldDisplayMode; + +/** + * @brief Defines the display rect data structure. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /* rect left */ + int32_t left; + /* rect top */ + int32_t top; + /* rect width */ + uint32_t width; + /* rect height */ + uint32_t height; +} NativeDisplayManager_Rect; + +/** + * @brief Defines the display waterfallDisplayAreaRects data structure. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /* waterfall left rect */ + NativeDisplayManager_Rect left; + + /* waterfall top rect */ + NativeDisplayManager_Rect top; + + /* waterfall right rect */ + NativeDisplayManager_Rect right; + + /* waterfall bottom rect */ + NativeDisplayManager_Rect bottom; +} NativeDisplayManager_WaterfallDisplayAreaRects; + +/** + * @brief Defines the display cutout info data structure. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /* boundingRects length */ + int32_t boundingRectsLength; + + /* boundingRects info pointer */ + NativeDisplayManager_Rect *boundingRects; + + /* waterfallDisplayAreaRects info */ + NativeDisplayManager_WaterfallDisplayAreaRects waterfallDisplayAreaRects; +} NativeDisplayManager_CutoutInfo; + +/** + * @brief Enumerates of the display state. + * + * @since 14 + * @version 1.0 + */ +typedef enum { + /** display state unknown */ + DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN = 0, + + /** display state off */ + DISPLAY_MANAGER_DISPLAY_STATE_OFF = 1, + + /** display state on */ + DISPLAY_MANAGER_DISPLAY_STATE_ON = 2, + + /** display state doze */ + DISPLAY_MANAGER_DISPLAY_STATE_DOZE = 3, + + /** display state doze suspend */ + DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND = 4, + + /** display state vr */ + DISPLAY_MANAGER_DISPLAY_STATE_VR = 5, + + /** display state on suspend */ + DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND = 6, +} NativeDisplayManager_DisplayState; + +/** + * @brief Defines the display hdr structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /** hdrFormat length */ + uint32_t hdrFormatLength; + + /** hdrFormat pointer */ + uint32_t *hdrFormats; +} NativeDisplayManager_DisplayHdrFormat; + +/** + * @brief Defines the display color space structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /** color space length */ + uint32_t colorSpaceLength; + + /** color space pointer */ + uint32_t *colorSpaces; +} NativeDisplayManager_DisplayColorSpace; + +/** + * @brief Defines the display structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /** display id */ + uint32_t id; + + /** display name */ + char name[OH_DISPLAY_NAME_LENGTH + 1]; + + /** display is alive */ + bool isAlive; + + /** display width */ + int32_t width; + + /** display height */ + int32_t height; + + /** display physical width */ + int32_t physicalWidth; + + /** display physical height */ + int32_t physicalHeight; + + /** display refresh rate */ + uint32_t refreshRate; + + /** display available width */ + uint32_t availableWidth; + + /** display available height */ + uint32_t availableHeight; + + /** display density dpi */ + float densityDPI; + + /** display density pixels */ + float densityPixels; + + /** display scale density */ + float scaledDensity; + + /** display xdpi*/ + float xDPI; + + /** display ydpi */ + float yDPI; + + /** display rotation */ + NativeDisplayManager_Rotation rotation; + + /** display state */ + NativeDisplayManager_DisplayState state; + + /** display orientation */ + NativeDisplayManager_Orientation orientation; + + /** display hdr format */ + NativeDisplayManager_DisplayHdrFormat *hdrFormat; + + /** display color space */ + NativeDisplayManager_DisplayColorSpace *colorSpace; +} NativeDisplayManager_DisplayInfo; + +/** + * @brief Defines the displays structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /** displays length */ + uint32_t displaysLength; + + /** displays pointer */ + NativeDisplayManager_DisplayInfo *displaysInfo; +} NativeDisplayManager_DisplaysInfo; + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_NATIVE_DISPLAY_INFO_H \ No newline at end of file diff --git a/arkui/display_manager/oh_display_manager.h b/arkui/display_manager/oh_display_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..caf6480af564b5617e0639d8de5eeddd93131147 --- /dev/null +++ b/arkui/display_manager/oh_display_manager.h @@ -0,0 +1,376 @@ +/* + * 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. + */ + +#ifndef OH_NATIVE_DISPLAY_MANAGER_H +#define OH_NATIVE_DISPLAY_MANAGER_H + +/** + * @addtogroup OH_DisplayManager + * @{ + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +/** + * @file oh_display_manager.h + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @kit ArkUI + * @library libnative_display_manager.so. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +#include "oh_display_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Obtain the default display Id. + * + * @param { *displayId } Indicates the pointer to an uint64_t object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId(uint64_t *displayId); + +/** + * @brief Obtain the default display width. + * + * @param { *displayWidth } Indicates the pointer to an int32_t object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth(int32_t *displayWidth); + +/** + * @brief Obtain the default display height. + * + * @param { *displayHeight } Indicates the pointer to an int32_t object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight(int32_t *displayHeight); + +/** + * @brief Obtain the default display rotation. + * + * @param { *displayRotation } Indicates the pointer to an NativeDisplayManager_Rotation object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation( + NativeDisplayManager_Rotation *displayRotation); + +/** + * @brief Obtain the default display orientation. + * + * @param { *displayOrientation } Indicates the pointer to an NativeDisplayManager_Orientation object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation( + NativeDisplayManager_Orientation *displayOrientation); + +/** + * @brief Obtain the default display virtualPixels. + * + * @param { *virtualPixels } Indicates the pointer to an float object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio(float *virtualPixels); + +/** + * @brief Obtain the default display refreshRate. + * + * @param { *refreshRate } Indicates the pointer to an uint32_t object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate(uint32_t *refreshRate); + +/** + * @brief Obtain the default display densityDpi. + * + * @param { *densityDpi } Indicates the pointer to an int32_t object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDpi(int32_t *densityDpi); + +/** + * @brief Obtain the default display densityPixels. + * + * @param { *densityPixels } Indicates the pointer to an float object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels(float *densityPixels); + +/** + * @brief Obtain the default display scaledDensity. + * + * @param { *scaledDensity } Indicates the pointer to an float object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity(float *scaledDensity); + +/** + * @brief Obtain the default display xDpi. + * + * @param { *xDpi } Indicates the pointer to an float object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi(float *xDpi); + +/** + * @brief Obtain the default display yDpi. + * + * @param { *yDpi } Indicates the pointer to an float object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi(float *yDpi); + +/** + * @brief Create the cutout info of the device. + * + * @param { **cutoutInfo } Indicates the pointer to an NativeDisplayManager_CutoutInfo object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo( + NativeDisplayManager_CutoutInfo **cutoutInfo); + +/** + * @brief Destroy an NativeDisplayManager_CutoutInfo object and reclaims the memory occupied by the object. + * + * @param { **cutoutInfo } Indicates the pointer to an NativeDisplayManager_CutoutInfo object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo( + NativeDisplayManager_CutoutInfo *cutoutInfo); + +/** + * @brief Check whether the device is foldable. + * + * @return { bool } true means the device is foldable. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +bool OH_NativeDisplayManager_IsFoldable(); + +/** + * @brief Get the display mode of the foldable device. + * + * @param { *displayMode } Indicates the pointer to an NativeDisplayManager_FoldDisplayMode object. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } device not support. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode( + NativeDisplayManager_FoldDisplayMode *displayMode); + +/** + * @brief the callback function type when display change. + * + * @param { *displayId } change display id. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +typedef void (*OH_NativeDisplayManager_DisplayChangeCallback)(uint64_t displayId); + +/** + * @brief Register the callback for display change listener. + * + * @param { displayChangeCallback } display change callback. + * @param { *listenerIndex } Indicates the pointer to an uint32_t object. used in unregister call. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener( + OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex); + +/** + * @brief Unregister the callback for display changes listener. + * + * @param { listenerIndex } display changed listener index. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener(uint32_t listenerIndex); + +/** + * @brief the callback function type when display fold change. + * + * @param { displayMode } current fold display mode. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +typedef void (*OH_NativeDisplayManager_FoldDisplayModeChangeCallback)( + NativeDisplayManager_FoldDisplayMode displayMode); + +/** + * @brief Register the callback for display mode change listener. + * + * @param { displayModeChangeCallback } display mode change callback. + * @param { *listenerIndex } Indicates the pointer to an uint32_t object. used in unregister call. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } device not support. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener( + OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex); + +/** + * @brief Unregister the callback for display mode change listener. + * + * @param { listenerIndex } display mode change listener index. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } device not support. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener(uint32_t listenerIndex); + +/** + * @brief Create all displays. + * + * @param allDisplays Output parameter for all displays information. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( + NativeDisplayManager_DisplaysInfo **allDisplays); + +/** + * @brief Destroy all displays. + * + * @param allDisplays all displays to be free. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays); + +/** + * @brief Create display information by display id. + * + * @param displayId The display id. + * @param displayInfo The pointer to the display information. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById(uint32_t displayId, + NativeDisplayManager_DisplayInfo **displayInfo); + +/** + * @brief Destroy the display information. + * + * @param displayInfo the target display to be free. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +void OH_NativeDisplayManager_DestroyDisplay(NativeDisplayManager_DisplayInfo *displayInfo); + +/** + * @brief Create a primary display. + * + * @param displayInfo The information of the created display. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay( + NativeDisplayManager_DisplayInfo **displayInfo); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_NATIVE_DISPLAY_MANAGER_H diff --git a/arkui/napi/native_api.h b/arkui/napi/native_api.h index 7cbab661df57db9c7805d01493064fdba4627baa..a45ce8476fc01722462abbd8444fdf8bdbcd1433 100644 --- a/arkui/napi/native_api.h +++ b/arkui/napi/native_api.h @@ -72,7 +72,19 @@ NAPI_INNER_EXTERN napi_status napi_adjust_external_memory(napi_env env, extern "C" { #endif +/** + * @brief Native detach callback of napi_coerce_to_native_binding_object that can be used to + * detach the js object and the native object. + * + * @since 11 + */ typedef void* (*napi_native_binding_detach_callback)(napi_env env, void* native_object, void* hint); +/** + * @brief Native attach callback of napi_coerce_to_native_binding_object that can be used to + * bind the js object and the native object. + * + * @since 11 + */ typedef napi_value (*napi_native_binding_attach_callback)(napi_env env, void* native_object, void* hint); NAPI_EXTERN napi_status napi_run_script_path(napi_env env, const char* path, napi_value* result); @@ -130,6 +142,18 @@ NAPI_EXTERN napi_status napi_create_object_with_named_properties(napi_env env, size_t property_count, const char** keys, const napi_value* values); +/** + * @brief This API sets native properties to a object and converts this js object to native binding object. + * + * @param[in] env Current running virtual machine context. + * @param[in] js_object The JavaScript value to coerce. + * @param[in] detach_cb Native callback that can be used to detach the js object and the native object. + * @param[in] attach_cb Native callback that can be used to bind the js object and the native object. + * @param[in] native_object User-provided native instance to pass to thr detach callback and attach callback. + * @param[in] hint Optional hint to pass to the detach callback and attach callback. + * @return Return the function execution status. + * @since 11 + */ NAPI_EXTERN napi_status napi_coerce_to_native_binding_object(napi_env env, napi_value js_object, napi_native_binding_detach_callback detach_cb, diff --git a/arkui/window_manager/oh_window_event_filter.h b/arkui/window_manager/oh_window_event_filter.h index 2e4992809c19a3183bb5fc4f8de1a2789f7b0d00..e4651cd59a57279f1b33cac71f45ef84b13dbf77 100644 --- a/arkui/window_manager/oh_window_event_filter.h +++ b/arkui/window_manager/oh_window_event_filter.h @@ -12,15 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef INCLUDE_OH_WINDOW_EVENT_FILTER_H -#define INCLUDE_OH_WINDOW_EVENT_FILTER_H - /** * @addtogroup WindowManager_NativeModule * @{ * - * * @brief Provides abilities of windowManager on the native side, such as key event * filtration. * @@ -37,6 +33,11 @@ * @kit ArkUI * @since 12 */ + +#ifndef INCLUDE_OH_WINDOW_EVENT_FILTER_H +#define INCLUDE_OH_WINDOW_EVENT_FILTER_H + +#include "stdbool.h" #include "stdint.h" #include "oh_window_comm.h" #include "multimodalinput/oh_input_manager.h" @@ -78,4 +79,5 @@ WindowManager_ErrorCode OH_NativeWindowManager_UnregisterKeyEventFilter(int32_t } #endif -#endif // INCLUDE_OH_WINDOW_EVENT_FILTER_H \ No newline at end of file +#endif // INCLUDE_OH_WINDOW_EVENT_FILTER_H +/** @} */ \ No newline at end of file diff --git a/backgroundtasks/transient/BUILD.gn b/backgroundtasks/transient/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3d449102055682de739dac0e5fda3266c2321594 --- /dev/null +++ b/backgroundtasks/transient/BUILD.gn @@ -0,0 +1,35 @@ +# 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_library("libtransient_task_ndk") { + output_name = "transient_task" + output_extension = "so" + ndk_description_file = "./libtransient_task.ndk.json" + system_capability = + "SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask" + system_capability_headers = [ + "transient_task/transient_task_api.h", + "transient_task/transient_task_type.h", + ] +} + +ohos_ndk_headers("transient_task_header") { + dest_dir = "$ndk_headers_out_dir/transient_task" + sources = [ + "include/transient_task_api.h", + "include/transient_task_type.h", + ] +} diff --git a/backgroundtasks/transient/include/transient_task_api.h b/backgroundtasks/transient/include/transient_task_api.h new file mode 100644 index 0000000000000000000000000000000000000000..74b467dc61fe50f384fecec1d9969bc1f485773e --- /dev/null +++ b/backgroundtasks/transient/include/transient_task_api.h @@ -0,0 +1,107 @@ +/* + * 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. + */ + +#ifndef OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_API_H +#define OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_API_H + +#include + +#include "transient_task_type.h" + +/** + * @addtogroup TransientTask + * @{ + * + * @brief Provide C interface for the Transient task management. + * + * @since 13 + * @version 1.0 + */ + +/** + * @file transient_task_api.h + * + * @brief Declares the APIs for Transient task management. + * + * @library libtransient_task.so + * @kit BackgroundTasksKit + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @since 13 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Requests delayed transition to the suspended state. + * + * @param reason Indicates the reason for delayed transition to the suspended state. + * @param callback Indicates the callback delay time expired. + * @param delaySuspendInfo Indicates the info of delay request. + * @return {@link ERR_TRANSIENT_TASK_OK} 0 - Success. + * {@link ERR_TRANSIENT_TASK_INVALID_PARAM} 401 - Invalid parameter. + * {@link ERR_TRANSIENT_TASK_PARCEL_FAILED} 9800002 - Parcelable failed. + * {@link ERR_TRANSIENT_TASK_TRANSACTION_FAILED} 9800003 - Transact failed. + * {@link ERR_TRANSIENT_TASK_SYS_NOT_READY} 9800004 - System service not ready. + * {@link ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED} 9900001 - uid or pid info verify failed. + * {@link ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED} 9900002 - Transient task verification failed. + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @since 13 + * @version 1.0 + */ +int32_t OH_BackgroundTaskManager_RequestSuspendDelay(const char* reason, + TransientTask_Callback callback, TransientTask_DelaySuspendInfo *info); + +/** + * @brief Obtains the remaining time before an application enters the suspended state. + * + * @param requestId Indicates the identifier of the delay request. + * @param time Indicates the remaining Time. + * @return {@link ERR_TRANSIENT_TASK_OK} 0 - Success. + * {@link ERR_TRANSIENT_TASK_INVALID_PARAM} 401 - Invalid parameter. + * {@link ERR_TRANSIENT_TASK_PARCEL_FAILED} 9800002 - Parcelable failed. + * {@link ERR_TRANSIENT_TASK_TRANSACTION_FAILED} 9800003 - Transact failed. + * {@link ERR_TRANSIENT_TASK_SYS_NOT_READY} 9800004 - System service not ready. + * {@link ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED} 9900001 - uid or pid info verify failed. + * {@link ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED} 9900002 - Transient task verification failed. + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @since 13 + * @version 1.0 + */ +int32_t OH_BackgroundTaskManager_GetRemainingDelayTime(int32_t requestId, int32_t *delayTime); + +/** + * @brief Cancels delayed transition to the suspended state. + * + * @param requestId Indicates the identifier of the delay request. + * @return {@link ERR_TRANSIENT_TASK_OK} 0 - Success. + * {@link ERR_TRANSIENT_TASK_INVALID_PARAM} 401 - Invalid parameter. + * {@link ERR_TRANSIENT_TASK_PARCEL_FAILED} 9800002 - Parcelable failed. + * {@link ERR_TRANSIENT_TASK_TRANSACTION_FAILED} 9800003 - Transact failed. + * {@link ERR_TRANSIENT_TASK_SYS_NOT_READY} 9800004 - System service not ready. + * {@link ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED} 9900001 - uid or pid info verify failed. + * {@link ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED} 9900002 - Transient task verification failed. + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @since 13 + * @version 1.0 + */ +int32_t OH_BackgroundTaskManager_CancelSuspendDelay(int32_t requestId); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/backgroundtasks/transient/include/transient_task_type.h b/backgroundtasks/transient/include/transient_task_type.h new file mode 100644 index 0000000000000000000000000000000000000000..6ddd4dbfa738319da8785a6db3ab25d0822cc4a7 --- /dev/null +++ b/backgroundtasks/transient/include/transient_task_type.h @@ -0,0 +1,104 @@ +/* + * 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. + */ + +#ifndef OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_TYPE_H +#define OHOS_BACKGROUOND_TASK_MANAGER_TRANSIENT_TASK_TYPE_H + +/** + * @addtogroup TransientTask + * @{ + + * @brief Provide C interface for the transient task management. + * @since 13 + * @version 1.0 + */ + +/** + * @file transient_task_type.h + * + * @brief Defines the data structures for the C APIs of transient task. + * + * @library libtransient_task.so + * @kit BackgroundTasksKit + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @since 11 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief Enum for transient task error code. + * @since 13 + */ +typedef enum TransientTask_ErrorCode { + /** + * @error result is ok. + */ + ERR_TRANSIENT_TASK_OK = 0, + /** + * @error Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameters types. + */ + ERR_TRANSIENT_TASK_INVALID_PARAM = 401, + /** + * @error Parcel operation failed. + */ + ERR_TRANSIENT_TASK_PARCEL_FAILED = 9800002, + /** + * @error Internal transaction failed. + */ + ERR_TRANSIENT_TASK_TRANSACTION_FAILED = 9800003, + /** + * @error System service operation failed. + */ + ERR_TRANSIENT_TASK_SYS_NOT_READY = 9800004, + /** + * Caller information verification failed for a transient task. + */ + ERR_TRANSIENT_TASK_CLIENT_INFO_VERIFICATION_FAILED = 9900001, + /** + * Transient task verification failed. + */ + ERR_TRANSIENT_TASK_SERVICE_VERIFICATION_FAILED = 9900002, +} TransientTask_ErrorCode; + +/** + * @brief Define DelaySuspendInfo for TransientTask. + * + * @since 13 + * @version 1.0 + */ +typedef struct TransientTask_DelaySuspendInfo { + /** The unique identifier of the delay request */ + int32_t requestId; + /** The actual delay duration (ms) */ + int32_t actualDelayTime; +} TransientTask_DelaySuspendInfo; + +/** + * @brief Define a callback function when delay time expired. + * @since 13 + */ +typedef void (*TransientTask_Callback)(void); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/backgroundtasks/transient/libtransient_task.ndk.json b/backgroundtasks/transient/libtransient_task.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..df952bfe1d139048cdf28ba8f1a65bbfec7dbb7f --- /dev/null +++ b/backgroundtasks/transient/libtransient_task.ndk.json @@ -0,0 +1,14 @@ +[ + { + "first_introduced": "13", + "name": "OH_BackgroundTaskManager_RequestSuspendDelay" + }, + { + "first_introduced": "13", + "name": "OH_BackgroundTaskManager_GetRemainingDelayTime" + }, + { + "first_introduced": "13", + "name": "OH_BackgroundTaskManager_CancelSuspendDelay" + } +] \ No newline at end of file diff --git a/build-tools/capi_parser/src/bin/config.py b/build-tools/capi_parser/src/bin/config.py index cd015a7454ee76bd1df5f5461825af0a782618f3..0fb2aeaeb1a94b117f282e90d3da7c1e89fc09bc 100644 --- a/build-tools/capi_parser/src/bin/config.py +++ b/build-tools/capi_parser/src/bin/config.py @@ -15,7 +15,7 @@ import enum from coreImpl.parser import parser -from coreImpl.check import check +from coreImpl.check import check, check_syntax from coreImpl.diff import diff @@ -25,6 +25,7 @@ class ToolNameType(enum.Enum): CHECK = 'check' COLLECT_H = 'collect_h' COLLECT_FILE = 'collect_file' + CHECK_SYNTAX = 'check_syntax' tool_name_type_set = [ @@ -54,9 +55,11 @@ def run_tools(options): elif tool_name == ToolNameType["CHECK"].value: check.curr_entry(options.path, options.checker, options.output) elif tool_name == ToolNameType['COLLECT_H'].value: - parser.parser_direct(options.parser_path) + parser.parser_direct(options.parser_path, options.dependent_path) elif tool_name == ToolNameType['COLLECT_FILE'].value: parser.parser_file_level(options.output_path) + elif tool_name == ToolNameType['CHECK_SYNTAX'].value: + check_syntax.check_syntax_entrance(options.parser_path, options.dependent_path, options.output_path) else: print("工具名称错误") @@ -89,6 +92,13 @@ class Config(object): "type": str, "help": "工具输出文件路径" }, + { + "name": "--dependent-path", + "abbr": "-D", + "required": False, + "type": str, + "help": "依赖文件路径" + }, { "name": "--codecheck--path", "abbr": "--path", diff --git a/build-tools/capi_parser/src/coreImpl/check/check.py b/build-tools/capi_parser/src/coreImpl/check/check.py index db91aeb047b79ae6b08cb8bd8d50ea2f6cdf992c..02c062c63cc371cc49423caf6fdefd82aaabcc34 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check.py +++ b/build-tools/capi_parser/src/coreImpl/check/check.py @@ -18,9 +18,11 @@ import os.path import openpyxl as op from pathlib import Path from typedef.check.check import FileDocInfo, check_command_message, CheckErrorMessage +from typedef.check.check_compatibility import check_compatibility_command_message from coreImpl.check.check_doc import process_comment, process_file_doc_info from coreImpl.check.check_name import check_file_name, check_api_name from coreImpl.parser.parser import parser_include_ast +from coreImpl.check.check_compatibility import check_compatibility_entrance def process_api_json(api_info, file_doc_info, api_result_info_list, parent_kind, command_list): @@ -112,7 +114,7 @@ def write_in_txt(check_result, output_path): def result_to_json(check_result): - return json.dumps(check_result, default=lambda obj: obj.__dict__, indent=4) + return json.dumps(check_result, default=lambda obj: obj.__dict__, indent=4, ensure_ascii=False) def get_file_path(txt_file): # 路径装在txt文件用的--获取.h文件路径 @@ -134,8 +136,10 @@ def curr_entry(files_path, command: str, output): return if command == 'all': command_list = check_command_message + command_of_compatibility_list = check_compatibility_command_message else: command_list = command.split(',') + command_of_compatibility_list = command_list check_result_list = [] if len(file_list) > 0: check_result_list = get_check_result_list(file_list, root_path, command_list) @@ -146,6 +150,11 @@ def curr_entry(files_path, command: str, output): result_list.append(result) else: result_list = check_result_list + old_dir = r'' + new_dir = r'' + if old_dir and new_dir: + compatibility_data = check_compatibility_entrance(old_dir, new_dir, command_of_compatibility_list) + result_list.extend(compatibility_data) write_in_txt(result_list, output) diff --git a/build-tools/capi_parser/src/coreImpl/check/check_compatibility.py b/build-tools/capi_parser/src/coreImpl/check/check_compatibility.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9e70f7b2fdd369889a5564725298e979107ca8 --- /dev/null +++ b/build-tools/capi_parser/src/coreImpl/check/check_compatibility.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# 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. + + +from coreImpl.diff.diff_file import check_diff_entrance +from typedef.check.check import CheckOutPut +from typedef.check.check_compatibility import match_diff_and_check_scene_dict, CheckCompatibilityErrorMessage + + +def process_each_diff_data(diff_data: list, compatibility_rule: list): + check_compatibility_result_list = [] + for element in diff_data: + diff_type_message = element.diff_type.name + match_check_rule = match_diff_and_check_scene_dict.get(diff_type_message) + if (not element.is_compatible) and match_check_rule and match_check_rule in compatibility_rule: + old_different_content = str(element.old_differ_content) + new_different_content = str(element.new_differ_content) + match_check_message = (CheckCompatibilityErrorMessage.get_rule_message(match_check_rule) + .replace('$$', old_different_content).replace('&&', new_different_content)) + old_declara = element.old_api_declara + new_declara = element.new_api_declara + content_line = element.api_line + if element.file_doc_line != 0: + content_line = element.file_doc_line + main_buggy_code = 'Old since:{}\nNew since:{}'.format(old_declara, new_declara) + result_obj = CheckOutPut(element.api_file_path, content_line, match_check_rule, match_check_message, + main_buggy_code, content_line) + check_compatibility_result_list.append(result_obj) + + return check_compatibility_result_list + + +def check_compatibility_entrance(old_dir, new_dir, compatibility_rule: list): + diff_data = check_diff_entrance(old_dir, new_dir) + check_compatibility_data_list = process_each_diff_data(diff_data, compatibility_rule) + + return check_compatibility_data_list diff --git a/build-tools/capi_parser/src/coreImpl/check/check_doc.py b/build-tools/capi_parser/src/coreImpl/check/check_doc.py index 4e95d50a799a73f8dc966f18d8d3325210391e49..cf966259f6250147feba43a4b0dbe7eacf3e874e 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_doc.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_doc.py @@ -21,7 +21,7 @@ import subprocess from clang.cindex import CursorKind -from typedef.check.check import DocInfo, FileDocInfo, TAGS, CheckErrorMessage, CheckOutPut +from typedef.check.check import DocInfo, FileDocInfo, TAGS, CheckErrorMessage, CheckOutPut, CommentStartEndValue current_file = os.path.dirname(__file__) # permission数据来源于https://gitee.com/openharmony/utils_system_resources/raw/master/systemres/main/config.json @@ -447,7 +447,7 @@ def process_comment(comment: str, file_doc_info: FileDocInfo, api_info) -> list: comment_start_line = api_info['location']['location_line'] - comment.count('\n') - 1 for index, item in enumerate(result_json): if api_info['kind'] == CursorKind.TRANSLATION_UNIT.name and len(item['tags']) > 0 and\ - item['tags'][0]['tag'] == '}' and index <= len(api_info['line_list']) - 1: + item['tags'][0]['tag'] == '}' and 'line_list' in api_info and index <= len(api_info['line_list']) - 1: comment_start_line = api_info['line_list'][index] api_result_info_list.extend(process_each_comment(item, file_doc_info, api_info, comment_start_line)) if index == len(result_json) - 1: @@ -474,7 +474,7 @@ def process_file_doc_info(file_doc_info: FileDocInfo, file_info, comment_start_l api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_10.name, get_tage_start_and_end(None, comment_start_line, file_doc_info.group_comment_str, file_info)) - api_result_info.mainBuggyLine = -1 + api_result_info.mainBuggyLine = CommentStartEndValue.DEFAULT_END.value api_result_info_list.append(api_result_info) # 处理file说明 if file_doc_info.file_name is None: @@ -502,6 +502,5 @@ def set_value_to_result(api_info, command, comment_value_info): def get_main_buggy_code(api_info): - main_buggy_code = os.path.basename(api_info['name']) if (len(api_info['node_content']) - == 0) else api_info['node_content']['content'] + main_buggy_code = '' if (len(api_info['node_content']) == 0) else api_info['node_content']['content'] return main_buggy_code diff --git a/build-tools/capi_parser/src/coreImpl/check/check_name.py b/build-tools/capi_parser/src/coreImpl/check/check_name.py index b32636d4392e67ec1ff106866a7c8a32ba9e7f08..98690645c81b5a83266266e044e5fe6616a71b37 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_name.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_name.py @@ -55,9 +55,14 @@ def check_function_name(api_info, kind, parent_kind): def set_value_to_result(api_info, command): + content = api_info['node_content']['content'] + node_name = api_info['name'] + if api_info['kind'] == 'MACRO_DEFINITION' and api_info.get('def_func_name'): + node_name = api_info.get('def_func_name') + descriptive_message = CheckErrorMessage.__getitem__(command).value.replace('$$', node_name) return CheckOutPut(os.path.abspath(os.path.join(api_info['gn_path'], api_info['location']['location_path'])), - api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, - api_info['node_content']['content'], api_info['location']['location_line']) + api_info['location']['location_line'], command, descriptive_message, + content, api_info['location']['location_line']) def is_self_developed_function(function_name): @@ -124,10 +129,10 @@ def check_file_name(file_info): file_name = os.path.basename(file_info['name']) result = re.match(CheckName['FILE_NAME'].value, file_name) if result is None: - chck_output = CheckOutPut(os.path.abspath(os.path.join(file_info['gn_path'], file_info['name'])), 0, - CheckErrorMessage.API_NAME_UNIVERSAL_14.name, - CheckErrorMessage.API_NAME_UNIVERSAL_14.value, file_name, 0) - api_result_info_list.append(chck_output) + check_output = CheckOutPut(os.path.abspath(os.path.join(file_info['gn_path'], file_info['name'])), 0, + CheckErrorMessage.API_NAME_UNIVERSAL_14.name, + CheckErrorMessage.API_NAME_UNIVERSAL_14.value.replace('$$', file_name), '', 0) + api_result_info_list.append(check_output) return api_result_info_list diff --git a/build-tools/capi_parser/src/coreImpl/check/check_syntax.py b/build-tools/capi_parser/src/coreImpl/check/check_syntax.py index 70572b31a4b5267bdc0dbd5f14441b8d698a48e5..a54d7ff71a6e13cefcc842f96e19f8ca0e89d49a 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_syntax.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_syntax.py @@ -16,7 +16,8 @@ import re import os import subprocess -from typedef.check.check import ApiResultInfo, ErrorMessage, ErrorType, LogType, ErrorLevel +import openpyxl as op +from typedef.check.check import ApiResultInfo, ErrorType, LogType, ErrorLevel def check_syntax(file_path): @@ -32,26 +33,110 @@ def check_syntax(file_path): return result_list -def processing_data(run_result, result_file): +def get_all_dependent_file_path(dependent_file_path): + link_path = [] + for dir_path, _, _ in os.walk(dependent_file_path): + if 'build-tools' not in dir_path: + link_path.append(dir_path) + + return link_path + + +def process_result_data(result_info_list): + syntax_info_data = [] + for syntax_info in result_info_list: + info_data = [ + syntax_info.api_name, + syntax_info.file_name, + syntax_info.error_info, + syntax_info.location_line, + syntax_info.error_content, + ] + syntax_info_data.append(info_data) + + return syntax_info_data + + +def general_syntax_excel(syntax_data_list, output_path): + data = process_result_data(syntax_data_list) + wb = op.Workbook() + ws = wb['Sheet'] + ws.title = '语法错误信息' + ws.append(['当前文件路径', '错误文件路径', '错误信息', '行号', '代码片段']) + for title in data: + d = title[0], title[1], title[2], title[3], title[4] + ws.append(d) + + wb.save(output_path) + + +def get_dir_file_path(file_path): + file_path_total = [] + for dir_path, _, filenames in os.walk(file_path): + for file_name in filenames: + if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path and file_name.endswith('.h'): + file_path_total.append(os.path.join(dir_path, file_name)) + + return file_path_total + + +def get_all_object_file_path(file_path): + file_path_total = [] + if os.path.isdir(file_path): + file_path_total = get_dir_file_path(file_path) + else: + if file_path.endswith('.h'): + file_path_total.append(file_path) + + return file_path_total + + +def check_syntax_entrance(file_path, dependent_file_path, output_path): + cmd_list = ['clang'] + link_path = get_all_dependent_file_path(dependent_file_path) + args = ['-I{}'.format(path) for path in link_path] + cmd_list.extend(args) + cmd_list.append('-std=c99') + cmd_list.append('--target=aarch64-linux-musl') + result_list = [] + all_files_list = get_all_object_file_path(file_path) + for element_file in all_files_list: + command = cmd_list + [element_file] + run_result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + result_list.extend(processing_data(run_result, element_file)) + general_syntax_excel(result_list, output_path) + return result_list + + +def processing_data(run_result, current_file): api_result_info_list = [] for run_result_child in run_result.stderr.decode().split('^'): + split_error_message = run_result_child.split('\r\n') + error_content = ''.join(split_error_message[-2:-3:-1]) result_child = run_result_child.replace('~', '') ret = re.findall('\\d+:\\d+', result_child) + error_file_message = re.search(r'([^"]+):\d:\d:', result_child) + error_file_name = current_file + if error_file_message: + error_file_list = error_file_message.group(1).split('\r\n') + if len(error_file_list) >= 1: + error_file_name = os.path.normpath(error_file_list[len(error_file_list) - 1]) if len(ret) != 0: error_message = get_specified_string(result_child) if len(error_message) == 1: continue position = ret[0] api_result_info = ApiResultInfo(ErrorType.SYNTAX_ERRORS.value, - error_message[1], result_file) + error_message[1], current_file) line_column = get_line_and_column(position) api_result_info.set_location_line(line_column[0]) api_result_info.set_location_column(line_column[1]) - api_result_info.set_location(result_file) + api_result_info.set_location(current_file) api_result_info.set_type(LogType.LOG_API.value) api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(result_file) + api_result_info.set_file_name(error_file_name) api_result_info_list.append(api_result_info) + api_result_info.set_error_content(error_content) return api_result_info_list diff --git a/build-tools/capi_parser/src/coreImpl/check/rules/perssion_rule.json b/build-tools/capi_parser/src/coreImpl/check/rules/perssion_rule.json index 86ddddeac950a971810d86068338181c2df0608f..1f24bce79502e849c0910c52f3169f0026a8f98e 100644 --- a/build-tools/capi_parser/src/coreImpl/check/rules/perssion_rule.json +++ b/build-tools/capi_parser/src/coreImpl/check/rules/perssion_rule.json @@ -2581,6 +2581,15 @@ "availableLevel": "system_basic", "provisionEnable": true, "distributedSceneEnable": false + }, + { + "name": "ohos.permission.START_NATIVE_CHILD_PROCESS", + "grantMode": "system_grant", + "since": 12, + "deprecated": "", + "availableLevel": "system_basic", + "provisionEnable": true, + "distributedSceneEnable": false } ] } diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff.py b/build-tools/capi_parser/src/coreImpl/diff/diff.py index 43f15d2cacb0b87ad2fe5b1d080b505f6adbd6df..375f7ab94be6ce616070cfe0d276a9b5125dadab 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from coreImpl.parser.parser import parser_include_ast +from coreImpl.parser.parser import diff_parser_include_ast from coreImpl.diff.diff_file import start_diff_file @@ -42,5 +42,5 @@ def process_file_diff(old_file, new_file): def get_parser_data(file_path): root_start = file_path.split('sdk_c')[0] root_path = f'{root_start}sdk_c' - parser_data = parser_include_ast(root_path, [file_path]) + parser_data = diff_parser_include_ast(root_path, [file_path]) return parser_data diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py index 0635db772b2671ede5285629946c7da01df24d34..e8f7d3d9c2bc5f8435ec058e87aba0d49f69ef5f 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -17,16 +17,18 @@ import filecmp import json import os import stat +import re from collections import OrderedDict import openpyxl as op -from coreImpl.parser.parser import parser_include_ast +from coreImpl.parser.parser import diff_parser_include_ast from coreImpl.diff.diff_processor_node import judgment_entrance, change_data_total -from typedef.diff.diff import OutputJson, ApiChangeData +from typedef.diff.diff import OutputJson, ApiChangeData, IgnoreFileDirectory from bin.write_md import write_md_entrance global_old_dir = '' global_new_dir = '' diff_info_list = [] +syntax_file_list = [] def get_modification_type_dict(): @@ -67,13 +69,15 @@ def get_api_change_obj(api_data): change_data_obj.set_kit_name(element.kit_name) change_data_obj.set_sub_system(element.sub_system) change_data_obj.set_is_api_change(element.is_api_change) - change_data_obj.set_class_name(element.class_name) + change_data_obj.set_current_api_type(element.current_api_type) change_data_obj.set_diff_type(element.operation_diff_type) change_data_obj.set_change_type(element.api_modification_type) change_data_obj.set_old_all_text(element.old_api_full_text) change_data_obj.set_new_all_text(element.new_api_full_text) change_data_obj.set_compatible_total(element.is_compatible) change_data_obj.set_is_system_api(element.is_system_api) + change_data_obj.set_open_close_api(element.open_close_api) + change_data_obj.set_is_third_party_api(element.is_third_party_api) key = 1 else: old_all_text = '{}#&#{}'.format(change_data_obj.old_all_text, element.old_api_full_text) @@ -120,7 +124,7 @@ def collect_node_api_change(api_change_info_list): api_change_info.kit_name, api_change_info.sub_system, api_change_info.is_api_change, - api_change_info.class_name, + api_change_info.current_api_type, api_change_info.diff_type, api_change_info.change_type, api_change_info.compatible, @@ -129,18 +133,42 @@ def collect_node_api_change(api_change_info_list): api_change_info.new_all_text, api_change_info.compatible_total, api_change_info.unique_id, - api_change_info.is_system_api + api_change_info.is_system_api, + api_change_info.open_close_api, + api_change_info.is_third_party_api ] change_data.append(info_data) return change_data +def syntax_file_excel(output_path): + data = [] + if syntax_file_list: + for syntax_dict in syntax_file_list: + info_data = [ + syntax_dict.get('current_file'), + syntax_dict.get('error_message') + ] + data.append(info_data) + + wb = op.Workbook() + ws = wb['Sheet'] + ws.title = '语法错误文件信息' + ws.append(['当前文件', '错误信息']) + for element in data: + d = element[0], element[1] + ws.append(d) + output_path_xlsx = os.path.abspath(os.path.join(output_path, r'syntax_file_error.xlsx')) + wb.save(output_path_xlsx) + + def start_diff_file(old_dir, new_dir, output_path): result_info_list = global_assignment(old_dir, new_dir) total = change_data_total collect_api_change_data = collect_api_change(total) generate_excel(result_info_list, collect_api_change_data, output_path) + syntax_file_excel(output_path) write_md_entrance(result_info_list, output_path) result_json = result_to_json(result_info_list) diff_result_path = r'./diff_result.txt' @@ -148,6 +176,12 @@ def start_diff_file(old_dir, new_dir, output_path): write_in_txt(result_json, output_path_txt) +def check_diff_entrance(old_dir, new_dir): + result_info_list = global_assignment(old_dir, new_dir) + + return result_info_list + + def disposal_result_data(result_info_list): data = [] for diff_info in result_info_list: @@ -179,11 +213,11 @@ def generate_excel(result_info_list, api_change_data, output_path): ws_of_change = wb.create_sheet('api变更次数统计') ws_of_change.append(['api名称', 'kit名称', '归属子系统', '是否是api', 'api类型', '操作标记', '变更类型', '兼容性', '变更次数', '差异项-旧版本', '差异项-新版本', '兼容性列表', '接口全路径', - '是否为系统API']) + '是否为系统API', '开源/闭源API', '是否是三方库api']) for element in change_data_list: change_data = element[0], element[1], element[2], element[3], element[4], element[5],\ element[6], element[7], element[8], element[9], element[10], element[11],\ - element[12], element[13] + element[12], element[13], element[14], element[15] ws_of_change.append(change_data) output_path_xlsx = os.path.abspath(os.path.join(output_path, 'diff.xlsx')) wb.save(output_path_xlsx) @@ -224,6 +258,18 @@ def get_file_ext(file_name): return os.path.splitext(file_name)[1] +def filter_ignore_file(file_path): + norm_file_path = os.path.normpath(file_path) + if os.name == 'nt': # Windows + pattern = re.compile(IgnoreFileDirectory.IGNORE_FILE_DIR_wd.value) + else: # Linux / macOS + pattern = re.compile(IgnoreFileDirectory.IGNORE_FILE_DIR_lx.value) + # 检查匹配 + if pattern.search(norm_file_path): + return False + return True + + def diff_list(old_file_list, new_file_list, old_dir, new_dir): all_list = set(old_file_list + new_file_list) if len(all_list) == 0: @@ -247,7 +293,7 @@ def add_new_file(diff_file_path): if os.path.isdir(diff_file_path): add_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1)) + result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [diff_file_path], flag=1)) for new_info in result_map.values(): diff_info_list.extend(judgment_entrance(None, new_info)) @@ -256,7 +302,7 @@ def del_old_file(diff_file_path): if os.path.isdir(diff_file_path): del_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0)) + result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [diff_file_path], flag=0)) for old_info in result_map.values(): diff_info_list.extend(judgment_entrance(old_info, None)) @@ -278,12 +324,13 @@ def get_same_file_diff(target_file, old_file_list, new_file_list, old_dir, new_d def get_file_result_diff(old_target_file, new_target_file): - old_file_result_map = parse_file_result(parser_include_ast(global_old_dir, [old_target_file], flag=0)) - new_file_result_map = parse_file_result(parser_include_ast(global_new_dir, [new_target_file], flag=1)) - merged_dict = OrderedDict(list(old_file_result_map.items()) + list(new_file_result_map.items())) - all_key_list = merged_dict.keys() - for key in all_key_list: - diff_info_list.extend(judgment_entrance(old_file_result_map.get(key), new_file_result_map.get(key))) + old_file_result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [old_target_file], flag=0)) + new_file_result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [new_target_file], flag=1)) + if old_file_result_map and new_file_result_map: + merged_dict = OrderedDict(list(old_file_result_map.items()) + list(new_file_result_map.items())) + all_key_list = merged_dict.keys() + for key in all_key_list: + diff_info_list.extend(judgment_entrance(old_file_result_map.get(key), new_file_result_map.get(key))) def del_file(dir_path): @@ -295,7 +342,7 @@ def del_file(dir_path): if os.path.isdir(file_path): del_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0)) + result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [file_path], flag=0)) for old_info in result_map.values(): diff_info_list.extend(judgment_entrance(old_info, None)) @@ -309,7 +356,7 @@ def add_file(dir_path): if os.path.isdir(file_path): add_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1)) + result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [file_path], flag=1)) for new_info in result_map.values(): diff_info_list.extend(judgment_entrance(None, new_info)) @@ -322,16 +369,36 @@ def parse_file_result(result, data_type=0): """ result_map = {} for root_node in result: + if root_node['syntax_error'] != 'NA': + error_file_path = os.path.abspath(os.path.join(root_node['gn_path'], root_node['name'])) + error_message_dict = { + 'current_file': error_file_path, + 'error_message': root_node['syntax_error'] + } + syntax_file_list.append(error_message_dict) + result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) if data_type != 1: parse_file_result_by_child(result_map, root_node) - result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) return result_map +def process_empty_name(data_info: dict, result_map): + data_current_file = os.path.split(data_info['location']['location_path'])[1] + if data_info['kind'] == 'ENUM_DECL' and 'members' in data_info and data_current_file in data_info['type']: + for element in data_info['members']: + result_map.setdefault(f'{data_current_file}-{element["name"]}', element) + elif data_info['kind'] == 'ENUM_DECL' and 'members' in data_info and (data_current_file not in data_info['type']): + result_map.setdefault(f'{data_current_file}-{data_info["type"]}', data_info) + elif (data_info['kind'] == 'STRUCT_DECL' or data_info['kind'] == 'UNION_DECL') and \ + (data_current_file not in data_info['type']): + result_map.setdefault(f'{data_current_file}-{data_info["type"]}', data_info) + + def parse_file_result_by_child(result_map, root_node): children_list = root_node['children'] for children in children_list: if children["name"] == '': + process_empty_name(children, result_map) continue result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) del root_node['children'] diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py index a0deb5b436a09cf167b02143a8dd66277d237017..14df24b0ffbfa3945a0bab94ee905dcf5be154d3 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py @@ -68,6 +68,8 @@ def wrap_diff_info(old_info, new_info, diff_info: DiffInfo): else: api_declare = old_info['name'] + if old_info['kind'] != 'TRANSLATION_UNIT': + diff_info.set_old_api_declara(api_declare) old_content = '类名:{};\nAPI声明:{};\n差异内容:{}\n'.format(diff_info.class_name, api_declare, diff_info.old_differ_content) diff_info.set_old_api_full_text(old_content) @@ -87,6 +89,8 @@ def wrap_diff_info(old_info, new_info, diff_info: DiffInfo): api_declare = new_info['node_content']['content'] else: api_declare = new_info['name'] + if new_info['kind'] != 'TRANSLATION_UNIT': + diff_info.set_new_api_declara(api_declare) new_content = '类名:{};\nAPI声明:{};\n差异内容:{}\n'.format(diff_info.class_name, api_declare, diff_info.new_differ_content) @@ -423,7 +427,7 @@ def process_union_name(old, new, diff_union_list): if old['name'] != new['name']: old_union_name = old['name'] new_union_name = new['name'] - result_message_obj = get_initial_result_obj(DiffType.STRUCT_MEMBER_NAME_CHANGE, + result_message_obj = get_initial_result_obj(DiffType.UNION_NAME_CHANGE, old_union_name, new_union_name) diff_info = wrap_diff_info(old, new, result_message_obj) diff_union_list.append(diff_info) @@ -437,7 +441,7 @@ def process_union_member(old, new, diff_union_list): if old_member_result.get(key) is None: old_member_content = 'NA' new_member_content = new_member_result.get(key)['node_content']['content'] - result_message_obj = get_initial_result_obj(DiffType.STRUCT_MEMBER_NAME_CHANGE, + result_message_obj = get_initial_result_obj(DiffType.UNION_MEMBER_ADD, old_member_content, new_member_content) diff_info = wrap_diff_info(old_member_result.get(key), new_member_result.get(key), @@ -446,7 +450,7 @@ def process_union_member(old, new, diff_union_list): elif new_member_result.get(key) is None: old_member_content = old_member_result.get(key)['node_content']['content'] new_member_content = 'NA' - result_message_obj = get_initial_result_obj(DiffType.STRUCT_MEMBER_NAME_CHANGE, + result_message_obj = get_initial_result_obj(DiffType.UNION_MEMBER_REDUCE, old_member_content, new_member_content) diff_info = wrap_diff_info(old_member_result.get(key), new_member_result.get(key), @@ -749,6 +753,27 @@ def process_typedef_child(old_child, new_child, diff_typedef_list): diff_typedef_list.extend(special_data) +def process_anonymous_enum_member(old_info, new_info): + result_obj_list = [] + if old_info and new_info: + if old_info['name'] != new_info['name']: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_NAME_CHANGE, old_info['name'], new_info['name']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + if old_info['value'] != new_info['value']: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_VALUE_CHANGE, old_info['value'], new_info['value']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + else: + if old_info: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_REDUCE, old_info['node_content']['content'], 'NA') + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + + elif new_info: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_ADD, 'NA', new_info['node_content']['content']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + + return result_obj_list + + process_data = { Scene.FUNCTION_DECL.value: process_function, Scene.MACRO_DEFINITION.value: process_define, @@ -756,14 +781,39 @@ process_data = { Scene.UNION_DECL.value: process_union, Scene.ENUM_DECL.value: process_enum, Scene.VAR_DECL.value: process_variable_const, - Scene.TYPEDEF_DECL.value: process_typedef + Scene.TYPEDEF_DECL.value: process_typedef, + Scene.ENUM_CONSTANT_DECL.value: process_anonymous_enum_member, } +def get_ch_api_kind(dict_key): + if dict_key == Scene.ENUM_CONSTANT_DECL.value: + key = 'ENUM_DECL' + else: + key = dict_key + api_kind_dict = { + 'FUNCTION_DECL': '函数类型', + 'MACRO_DEFINITION': '宏定义类型', + 'STRUCT_DECL': '结构体类型', + 'UNION_DECL': '联合体类型', + 'ENUM_DECL': '枚举类型', + 'VAR_DECL': '常/变量类型', + 'TYPEDEF_DECL': '重命名类型', + 'TRANSLATION_UNIT': 'NA' + } + return api_kind_dict.get(key) + + def collect_change_data_total(data: dict, diff_info_list): for element in diff_info_list: element.set_api_node_name(data['name']) + if (data['kind'] == Scene.STRUCT_DECL.value or data['kind'] == Scene.UNION_DECL.value + or data['kind'] == Scene.ENUM_DECL.value) and (not data['name']): + element.set_api_node_name(data['type']) element.set_current_api_unique_id(data['unique_id']) + element.set_open_close_api(data['open_close_api']) + element.set_is_third_party_api(data['is_third_party_api']) + element.set_current_api_type(get_ch_api_kind(data['kind'])) change_data_total.append(diff_info_list) @@ -780,17 +830,18 @@ def process_add_node(add_infor, key_extern, struct_union_enum): return diff_info_list if 'is_extern' in add_infor and add_infor['is_extern']: key_extern = True - diff_type = DiffType.ADD_API - old_api_content = 'NA' - if add_infor['kind'] in struct_union_enum: - new_api_content = add_infor['type'] + if add_infor['kind'] == Scene.ENUM_CONSTANT_DECL.value: + result_obj_list = process_anonymous_enum_member(old_infor, add_infor) + diff_info_list.extend(result_obj_list) else: - new_api_content = add_infor['node_content']['content'] - diff_info_list.append(wrap_diff_info(old_infor, add_infor, DiffInfo(diff_type, - old_api_content, new_api_content))) - if diff_type == DiffType.ADD_API: - set_is_api_change_result(diff_info_list, key_extern) - collect_change_data_total(add_infor, diff_info_list) + if add_infor['kind'] in struct_union_enum: + new_api_content = add_infor['type'] + else: + new_api_content = add_infor['node_content']['content'] + diff_info_list.append(wrap_diff_info(old_infor, add_infor, DiffInfo(DiffType.ADD_API, + 'NA', new_api_content))) + set_is_api_change_result(diff_info_list, key_extern) + collect_change_data_total(add_infor, diff_info_list) return diff_info_list @@ -802,14 +853,16 @@ def process_reduce_node(reduce_infor, key_extern, struct_union_enum): return diff_info_list if 'is_extern' in reduce_infor and reduce_infor['is_extern']: key_extern = True - diff_type = DiffType.REDUCE_API - new_api_content = 'NA' - if reduce_infor['kind'] in struct_union_enum: - old_api_content = reduce_infor['type'] + if reduce_infor['kind'] == Scene.ENUM_CONSTANT_DECL.value: + result_obj_list = process_anonymous_enum_member(reduce_infor, new_infor) + diff_info_list.extend(result_obj_list) else: - old_api_content = reduce_infor['node_content']['content'] - diff_info_list.append(wrap_diff_info(reduce_infor, new_infor, DiffInfo(diff_type, - old_api_content, new_api_content))) + if reduce_infor['kind'] in struct_union_enum: + old_api_content = reduce_infor['type'] + else: + old_api_content = reduce_infor['node_content']['content'] + diff_info_list.append(wrap_diff_info(reduce_infor, new_infor, DiffInfo(DiffType.REDUCE_API, + old_api_content, 'NA'))) set_is_api_change_result(diff_info_list, key_extern) collect_change_data_total(reduce_infor, diff_info_list) @@ -930,17 +983,19 @@ def process_tag_file(old_tag, new_tag, old_info, new_info): def process_tag_library(old_tag, new_tag, old_info, new_info): diff_info_list = [] if old_tag is None: - diff_info_list.append( - wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_LIBRARY_NA_TO_HAVE, 'NA', new_tag['name']))) + library_result_obj = DiffInfo(DiffType.DOC_TAG_LIBRARY_NA_TO_HAVE, 'NA', new_tag['name']) + set_file_doc_content_snippet(old_tag, new_tag, library_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, library_result_obj)) return diff_info_list if new_tag is None: - diff_info_list.append( - wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_LIBRARY_HAVE_TO_NA, old_tag['name'], "NA"))) + library_result_obj = DiffInfo(DiffType.DOC_TAG_LIBRARY_HAVE_TO_NA, old_tag['name'], "NA") + set_file_doc_content_snippet(old_tag, new_tag, library_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, library_result_obj)) return diff_info_list if old_tag['name'] != new_tag['name']: - diff_info_list.append(wrap_diff_info(old_info, new_info, - DiffInfo(DiffType.DOC_TAG_LIBRARY_A_TO_B, old_tag['name'], - new_tag['name']))) + library_result_obj = DiffInfo(DiffType.DOC_TAG_LIBRARY_A_TO_B, old_tag['name'], new_tag['name']) + set_file_doc_content_snippet(old_tag, new_tag, library_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, library_result_obj)) return diff_info_list @@ -965,35 +1020,47 @@ def process_tag_param(old_tag, new_tag, old_info, new_info): return diff_info_list +def set_file_doc_content_snippet(old_tag, new_tag, diff_obj): + if old_tag is not None: + if old_tag.get('source'): + diff_obj.set_file_doc_line(old_tag.get('source')[0].get('number')) + diff_obj.set_old_api_declara(old_tag.get('source')[0].get('source')) + if new_tag is not None: + if new_tag.get('source'): + diff_obj.set_file_doc_line(new_tag.get('source')[0].get('number')) + diff_obj.set_new_api_declara(new_tag.get('source')[0].get('source')) + + def process_tag_permission(old_tag, new_tag, old_info, new_info): diff_info_list = [] if old_tag is None: - diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_PERMISSION_NA_TO_HAVE, - 'NA', - f'{new_tag["name"]} ' - f'{new_tag["description"]}'))) + permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_NA_TO_HAVE, 'NA', f'{new_tag["name"]} ' + f'{new_tag["description"]}') + set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj)) return diff_info_list if new_tag is None: - diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_PERMISSION_HAVE_TO_NA, - f'{old_tag["name"]} ' - f'{old_tag["description"]}', - 'NA'))) + permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_HAVE_TO_NA, f'{old_tag["name"]} ' + f'{old_tag["description"]}', 'NA') + set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj)) return diff_info_list old_permission = f'{old_tag["name"]} {old_tag["description"]}' new_permission = f'{new_tag["name"]} {new_tag["description"]}' if old_permission != new_permission: compare_value = compare_permission(old_permission, new_permission) if compare_value.state_range == RangeChange.DOWN.value: - diff_info_list.append(wrap_diff_info(old_info, new_info, - DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_SMALLER, old_permission, - new_permission))) + permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_SMALLER, old_permission, new_permission) + set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj)) elif compare_value.state_range == RangeChange.UP.value: - diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo( - DiffType.DOC_TAG_PERMISSION_RANGE_BIGGER, old_permission, new_permission))) + permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_BIGGER, old_permission, new_permission) + set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj)) elif compare_value.state_range == RangeChange.CHANGE.value: - diff_info_list.append(wrap_diff_info(old_info, new_info, - DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_CHANGE, old_permission, - new_permission))) + permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_CHANGE, old_permission, new_permission) + set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj)) return diff_info_list @@ -1027,22 +1094,23 @@ def process_tag_since(old_tag, new_tag, old_info, new_info): def process_tag_syscap(old_tag, new_tag, old_info, new_info): diff_info_list = [] if old_tag is None: - diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_SYSCAP_NA_TO_HAVE, - 'NA', - f'{new_tag["name"]} ' - f'{new_tag["description"]}'))) + syscap_result_obj = DiffInfo(DiffType.DOC_TAG_SYSCAP_NA_TO_HAVE, 'NA', f'{new_tag["name"]} ' + f'{new_tag["description"]}') + set_file_doc_content_snippet(old_tag, new_tag, syscap_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, syscap_result_obj)) return diff_info_list if new_tag is None: - diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_SYSCAP_HAVE_TO_NA, - f'{old_tag["name"]} ' - f'{old_tag["description"]}', - 'NA'))) + syscap_result_obj = DiffInfo(DiffType.DOC_TAG_SYSCAP_HAVE_TO_NA, f'{old_tag["name"]} ' + f'{old_tag["description"]}', 'NA') + set_file_doc_content_snippet(old_tag, new_tag, syscap_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, syscap_result_obj)) return diff_info_list old_syscap = f'{old_tag["name"]} {old_tag["description"]}' new_syscap = f'{new_tag["name"]} {new_tag["description"]}' if old_syscap != new_syscap: - diff_info_list.append( - wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_SYSCAP_A_TO_B, old_syscap, new_syscap))) + syscap_result_obj = DiffInfo(DiffType.DOC_TAG_SYSCAP_A_TO_B, old_syscap, new_syscap) + set_file_doc_content_snippet(old_tag, new_tag, syscap_result_obj) + diff_info_list.append(wrap_diff_info(old_info, new_info, syscap_result_obj)) return diff_info_list diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_permission.py b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_permission.py index b30825902017a64480f37790e3c48ddea377a30c..8b7c2f852b2d35605d7c5bef2b36e2acd0c2356d 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_permission.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_permission.py @@ -49,7 +49,7 @@ class DiffProcessorPermission: variable_list = [] # 命题集合 @staticmethod - def get_bool_in_list(self, number_list, bin_len): + def get_bool_in_list(number_list, bin_len): state_list = [bin(i) for i in number_list] state_list = [x[2:] for x in state_list] state_list = ['0' * (bin_len - len(x)) + x for x in state_list] @@ -57,7 +57,7 @@ class DiffProcessorPermission: return tuple(state_list) @staticmethod - def process_value(self, state_value): + def process_value(state_value): calculate = CalculateValue() for state in state_value: if state_value[state]: diff --git a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py index 158d76bb828c789afb30e1a8d74fa2a1382b1a69..e109bfe95bdfd5aa02a9b379d9d05a90ca3a5245 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py +++ b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py @@ -85,8 +85,6 @@ def get_result_api(file_data, result_api): if 'children' in file_data: for item1 in file_data["children"]: # 抛开根节点 if (item1["kind"] == 'FUNCTION_DECL' or item1["kind"] == 'VAR_DECL') and item1["is_extern"]: - differ_infor = difference_api(item1) - item1['differ_infor'] = differ_infor item = filter_func(item1) result_api.append(item) @@ -151,7 +149,8 @@ def collated_api_data(api_data: list): api.get('location_path'), api.get('sub_system'), api.get('unique_id'), - api.get('differ_infor') + api.get('open_close_api'), + api.get('is_third_party_api') ] collated_data_total.append(collated_data) return collated_data_total @@ -161,7 +160,7 @@ def generate_excel(array, name, generate_json_unique, original_json_unique): first_line_infor = ['模块名', '类名', '方法名', '函数', '类型', '起始版本', '废弃版本', 'syscap', '错误码', '是否为系统API', '模型限制', '权限', '是否支持跨平台', '是否支持卡片应用', '是否支持高阶API', - '装饰器', 'kit', '文件路径', '子系统', '接口全路径', '开源/闭源/三方库API'] + '装饰器', 'kit', '文件路径', '子系统', '接口全路径', '开源/闭源API', '是否是三方库API'] workbook = openpyxl.Workbook() work_sheet1 = workbook.active work_sheet1.title = '对比结果' @@ -184,7 +183,7 @@ def write_information_to_worksheet(work_sheet, information_data): write_data = data[0], data[1], data[2], data[3], data[4], \ data[5], data[6], data[7], data[8], data[9], \ data[10], data[11], data[12], data[13], data[14], \ - data[15], data[16], data[17], data[18], data[19], data[20] + data[15], data[16], data[17], data[18], data[19], data[20], data[21] work_sheet.append(write_data) diff --git a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json index 668e349dea236349fdb94eb55890b8fc711ec894..2e76360574711680bfcb669fd1bce4a97e388687 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json +++ b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json @@ -16,6 +16,11 @@ "kitName": "ArkUI", "subSystem": "ArkUI开发框架" }, + { + "filePath": "arkui/ace_engine/native/native_interface_accessibility.h", + "kitName": "ArkUI", + "subSystem": "ArkUI开发框架" + }, { "filePath": "arkui/ace_engine/native/native_xcomponent_key_event.h", "kitName": "ArkUI", diff --git a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py index a067d98afeea9306f53ebf43223e9c9579411467..c27ef98f7b6790bb94a24a5a4f0b90f6e8474b9c 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py @@ -25,7 +25,7 @@ from clang.cindex import CursorKind from clang.cindex import TypeKind from utils.constants import StringConstant from utils.constants import RegularExpressions -from typedef.parser.parser import NodeKind +from typedef.parser.parser import NodeKind, DifferApiInfor, DifferApiRegular line_dist = {} @@ -149,13 +149,26 @@ def processing_def(cursor, data): # 处理宏定义 print('mar_define error, its content is none') if text: text = text.strip() # 删除两边的字符(默认是删除左右空格) - data['text'] = text - data["type"] = "def_no_type" + data['text'] = text + data["type"] = "" + + +def difference_api(api_data: dict): + api_name = api_data['name'] + closed_pattern = DifferApiRegular.CLOSED_SOURCE_API_REGULAR.value + open_pattern = DifferApiRegular.OPEN_SOURCE_API_REGULAR.value + if re.search(closed_pattern, api_name, flags=re.IGNORECASE): + api_data['open_close_api'] = DifferApiInfor.CLOSED_SOURCE_API.value + elif re.search(open_pattern, api_name, flags=re.IGNORECASE): + api_data['open_close_api'] = DifferApiInfor.OPEN_SOURCE_API.value + else: + api_data['is_third_party_api'] = True def processing_func(cursor, data): # 处理函数 data["return_type"] = cursor.result_type.spelling # 增加返回类型键值对 judgment_extern(cursor, data) + difference_api(data) def processing_type(cursor, data): # 没有类型的节点处理 @@ -197,6 +210,12 @@ special_node_process = { } +def process_members_class_name(data: dict, parent_cursor): + file_name = os.path.split(data['location']['location_path'])[1] + if (not data['name']) and (file_name not in parent_cursor.type.spelling): + data['class_name'] = '{}-{}'.format(file_name, parent_cursor.type.spelling) + + def get_api_unique_id(cursor, loc, data): unique_id = '' if cursor.kind == CursorKind.MACRO_DEFINITION: @@ -213,7 +232,7 @@ def get_api_unique_id(cursor, loc, data): parent_name_str = '' elif parent_of_cursor.kind.name in struct_union_enum: parent_name_str = parent_of_cursor.type.spelling - data['class_name'] = parent_of_cursor.spelling + process_members_class_name(data, parent_of_cursor) else: parent_name_str = parent_of_cursor.spelling except ValueError: @@ -227,7 +246,21 @@ def get_api_unique_id(cursor, loc, data): return unique_id -def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊处理的节点 +def get_node_class_name(data): + struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value, + NodeKind.ENUM_DECL.value] + current_file_name = os.path.split(data["location"]["location_path"])[1] + if data.get('kind') in struct_union_enum and 'class_name' in data: + class_name = '{}-{}'.format(current_file_name, data["name"]) + if (not data["name"]) and (current_file_name not in data["type"]): + class_name = '{}-{}'.format(current_file_name, data["type"]) + else: + class_name = current_file_name + + return class_name + + +def processing_special_node(cursor, data, key, directory_path): # 处理需要特殊处理的节点 if key == 0: location_path = cursor.spelling kind_name = CursorKind.TRANSLATION_UNIT.name @@ -240,13 +273,16 @@ def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊 "location_line": cursor.location.line, "location_column": cursor.location.column } - if gn_path: - relative_path = os.path.relpath(location_path, gn_path) # 获取头文件相对路 + if directory_path: + relative_path = os.path.relpath(location_path, directory_path) # 获取头文件相对路 loc["location_path"] = relative_path data["location"] = loc + data["class_name"] = get_node_class_name(data) data["unique_id"] = get_api_unique_id(cursor, loc, data) if key == 0: data["unique_id"] = data["name"] + syntax_error_message = diagnostic_callback(cursor.translation_unit.diagnostics, directory_path) + data["syntax_error"] = syntax_error_message if kind_name in special_node_process.keys(): node_process = special_node_process[kind_name] node_process(cursor, data) # 调用对应节点处理函数 @@ -255,14 +291,20 @@ def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊 def node_extent(cursor, current_file): start_offset = cursor.extent.start.offset end_offset = cursor.extent.end.offset + start_line = cursor.extent.start.line + end_line = cursor.extent.end.line with open(current_file, 'r', encoding='utf=8') as f: f.seek(start_offset) content = f.read(end_offset - start_offset) - + f.seek(0) + file_content_all = f.readlines() + line_content = file_content_all[start_line - 1: end_line] + line_content = ''.join(line_content) extent = { "start_offset": start_offset, "end_offset": end_offset, - "content": content + "content": content, + "line_content": line_content } f.close() return extent @@ -279,12 +321,12 @@ def define_comment(cursor, current_file, data): data['comment'] = matches.group() -def get_default_node_data(cursor, gn_path): +def get_default_node_data(cursor, directory_path): data = { "name": cursor.spelling, "kind": '', "type": cursor.type.spelling, - "gn_path": gn_path, + "gn_path": directory_path, "node_content": {}, "comment": '', "syscap": '', @@ -302,20 +344,45 @@ def get_default_node_data(cursor, gn_path): "form": 'NA', "atomic_service": 'NA', "decorator": 'NA', - "unique_id": '' + "unique_id": '', + "syntax_error": 'NA', + "open_close_api": 'NA', + "is_third_party_api": False } return data -def parser_data_assignment(cursor, current_file, gn_path, comment=None, key=0): - data = get_default_node_data(cursor, gn_path) +def diagnostic_callback(diagnostic, dir_path): + # 获取诊断信息的详细内容 + syntax_error_message = 'NA' + key = 0 + for dig in diagnostic: + file_path = f"{dig.location.file}" + try: + file_path = os.path.relpath(os.path.normpath(file_path), dir_path) + except ValueError: + pass + line = dig.location.line + message = dig.spelling + # 输出诊断信息 + error_message = f"{file_path}:{line}\n错误信息:{message}" + if 0 == key: + syntax_error_message = error_message + key = 1 + else: + syntax_error_message = '{}\n{}'.format(syntax_error_message, error_message) + return syntax_error_message + + +def parser_data_assignment(cursor, current_file, directory_path, comment=None, key=0): + data = get_default_node_data(cursor, directory_path) get_comment(cursor, data) if key == 0: data["kind"] = CursorKind.TRANSLATION_UNIT.name if comment: data["comment"] = comment - if gn_path: - relative_path = os.path.relpath(cursor.spelling, gn_path) + if directory_path: + relative_path = os.path.relpath(cursor.spelling, directory_path) data["name"] = relative_path else: content = node_extent(cursor, current_file) @@ -323,25 +390,21 @@ def parser_data_assignment(cursor, current_file, gn_path, comment=None, key=0): data["kind"] = cursor.kind.name if cursor.kind.name == CursorKind.MACRO_DEFINITION.name: define_comment(cursor, current_file, data) - struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value, - NodeKind.ENUM_DECL.value] - if data.get('kind') in struct_union_enum and 'class_name' in data: - data['class_name'] = data.get('name') get_syscap_value(data) get_since_value(data) get_kit_value(data) get_permission_value(data) get_module_name_value(data) get_deprecate_since_value(data) - processing_special_node(cursor, data, key, gn_path) # 节点处理 + processing_special_node(cursor, data, key, directory_path) # 节点处理 get_file_kit_or_system(data) return data -def ast_to_dict(cursor, current_file, last_data, gn_path, comment=None, key=0): # 解析数据的整理 +def ast_to_dict(cursor, current_file, last_data, directory_path, comment=None, key=0): # 解析数据的整理 # 通用赋值 - data = parser_data_assignment(cursor, current_file, gn_path, comment, key) + data = parser_data_assignment(cursor, current_file, directory_path, comment, key) if last_data: data['module_name'] = last_data['module_name'] data['kit_name'] = last_data['kit_name'] @@ -367,7 +430,7 @@ def ast_to_dict(cursor, current_file, last_data, gn_path, comment=None, key=0): and child.kind.name != CursorKind.MACRO_INSTANTIATION.name \ and child.kind.name != CursorKind.INCLUSION_DIRECTIVE.name \ and (child.location.file.name == current_file): - processing_ast_node(child, current_file, data, name, gn_path) + processing_ast_node(child, current_file, data, name, directory_path) else: if cursor.kind == CursorKind.FUNCTION_DECL: # 防止clang默认处理(对于头文件没有的情况)出现没有该键值对 data["parm"] = [] @@ -489,17 +552,17 @@ def get_comment(cursor, data: dict): data["comment"] = 'none_comment' -def processing_ast_node(child, current_file, data, name, gn_path): - child_data = ast_to_dict(child, current_file, data, gn_path, key=1) +def processing_ast_node(child, current_file, data, name, directory_path): + child_data = ast_to_dict(child, current_file, data, directory_path, key=1) if child.kind == CursorKind.TYPE_REF: data["type_ref"] = child_data else: data[name].append(child_data) -def preorder_travers_ast(cursor, comment, current_file, gn_path): # 获取属性 +def preorder_travers_ast(cursor, comment, current_file, directory_path): # 获取属性 previous_data = {} - ast_dict = ast_to_dict(cursor, current_file, previous_data, gn_path, comment) # 获取节点属性 + ast_dict = ast_to_dict(cursor, current_file, previous_data, directory_path, comment) # 获取节点属性 return ast_dict @@ -554,7 +617,7 @@ def get_start_comments(include_path): # 获取每个头文件的最开始注释 return content -def api_entrance(share_lib, include_path, gn_path, link_path): # 统计入口 +def api_entrance(share_lib, include_path, directory_path, link_path): # 统计入口 # clang.cindex需要用到libclang.dll共享库 所以配置共享库 if not Config.loaded: Config.set_library_file(share_lib) @@ -564,6 +627,7 @@ def api_entrance(share_lib, include_path, gn_path, link_path): # 统计入口 # options赋值为如下,代表宏定义解析数据也要 args = ['-I{}'.format(path) for path in link_path] args.append('-std=c99') + args.append('--target=aarch64-linux-musl') options = clang.cindex.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD data_total = [] # 列表对象-用于统计 @@ -572,7 +636,7 @@ def api_entrance(share_lib, include_path, gn_path, link_path): # 统计入口 ast_root_node = tu.cursor # 获取根节点 matches = get_start_comments(item) # 接收文件最开始的注释 # 前序遍历AST - file_result_data = preorder_travers_ast(ast_root_node, matches, item, gn_path) # 调用处理函数 + file_result_data = preorder_travers_ast(ast_root_node, matches, item, directory_path) # 调用处理函数 data_total.append(file_result_data) iter_line_dist = iter(line_dist) first = next(iter_line_dist) @@ -584,12 +648,12 @@ def api_entrance(share_lib, include_path, gn_path, link_path): # 统计入口 return data_total -def get_include_file(include_file_path, link_path, gn_path): # 库路径、.h文件路径、链接头文件路径 +def get_include_file(include_file_path, link_path, directory_path): # 库路径、.h文件路径、链接头文件路径 # libclang.dll库路径 libclang_path = StringConstant.LIB_CLG_PATH.value # c头文件的路径 file_path = include_file_path # 头文件链接路径 link_include_path = link_path # 可以通过列表传入 - data = api_entrance(libclang_path, file_path, gn_path, link_include_path) # 调用接口 + data = api_entrance(libclang_path, file_path, directory_path, link_include_path) # 调用接口 return data diff --git a/build-tools/capi_parser/src/coreImpl/parser/parser.py b/build-tools/capi_parser/src/coreImpl/parser/parser.py index 5ab20372e1dafd9f410fa0fbfd89c0bf1208ffb5..9da03cafe1123bf345e890649c83dac64bb0a5f9 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parser.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parser.py @@ -267,10 +267,8 @@ def find_include(link_include_path): def copy_self_include(link_include_path, self_include_file): for dir_path, dir_name, file_name_list in os.walk(self_include_file): - for element in dir_name: - dir_path_name = os.path.abspath(os.path.join(dir_path, element)) - if 'sysroot_myself' not in dir_path and dir_path_name not in link_include_path: - link_include_path.append(dir_path_name) + if 'sysroot_myself' not in dir_path and 'build-tools' not in dir_path and dir_path not in link_include_path: + link_include_path.append(dir_path) def delete_typedef_child(child): @@ -294,19 +292,10 @@ def parser(directory_path): # 目录路径 return data_total -def parser_include_ast(dire_file_path, include_path: list, flag=-1): # 对于单独的.h解析接口 +def parser_include_ast(dire_file_path, include_path: list): # 对于单独的.h解析接口 correct_include_path = [] link_include_path = [dire_file_path] - # 针对check - if -1 == flag: - copy_std_lib(link_include_path, dire_file_path) - link_include(dire_file_path, StringConstant.FUNK_NAME.value, link_include_path) - # 针对diff - else: - copy_std_lib(link_include_path) - find_include(link_include_path) - if len(link_include_path) <= 2: - copy_self_include(link_include_path, dire_file_path) + copy_self_include(link_include_path, dire_file_path) for item in include_path: split_path = os.path.splitext(item) if split_path[1] == '.h': # 判断.h结尾 @@ -322,16 +311,28 @@ def parser_include_ast(dire_file_path, include_path: list, flag=-1): # return data +def diff_parser_include_ast(dire_file_path, include_path: list, flag=-1): # 对于单独的.h解析接口 + link_include_path = [dire_file_path] + copy_self_include(link_include_path, dire_file_path) + data = parse_include.get_include_file(include_path, link_include_path, dire_file_path) + + for item in data: + if 'children' in item: + for child in item['children']: + delete_typedef_child(child) + + return data + + def get_dir_file_path(dir_path): file_path_list = [] link_include_path = [] # 装链接头文件路径 for dir_path, dir_names, filenames in os.walk(dir_path): - for dir_name in dir_names: - if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path: - link_include_path.append(os.path.join(dir_path, dir_name)) + if 'sysroot_myself' not in dir_path and 'build-tools' not in dir_path and dir_path not in link_include_path: + link_include_path.append(dir_path) for file in filenames: if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path and file.endswith('.h'): - file_path_list.append(os.path.join(dir_path, file)) + file_path_list.append(os.path.normpath(os.path.join(dir_path, file))) return file_path_list, link_include_path @@ -403,21 +404,30 @@ def complete_kit_or_system(api_message: OneFileApiMessage, json_path): api_message.set_sub_system(sub_system_name) -def parser_direct(path): # 目录路径 +def get_dependent_path_all(dependent_path): + all_dependent_path_list = [] + for dir_path, _, _ in os.walk(dependent_path): + if 'sysroot_myself' not in dir_path and 'build-tools' not in dir_path: + all_dependent_path_list.append(dir_path) + + return all_dependent_path_list + + +def parser_direct(path, dependent_path): # 目录路径 file_path_list = [] link_include_path = [] # 装链接头文件路径 - copy_std_lib(link_include_path) + link_include_path.extend(get_dependent_path_all(dependent_path)) dir_path = '' if os.path.isdir(path): - link_include_path.append(path) - file_path_total, link_include_total = get_dir_file_path(path) + if path not in link_include_path: + link_include_path.append(path) + file_path_total, _ = get_dir_file_path(path) file_path_list.extend(file_path_total) - link_include_path.extend(link_include_total) dir_path = path - else: - if path.endswith('.h'): - file_path_list.append(path) - dir_path = os.path.dirname(path) + elif path.endswith('.h'): + file_path_list.append(path) + dir_path = os.path.dirname(path) + if dir_path not in link_include_path: link_include_path.append(dir_path) data_total = parse_include.get_include_file(file_path_list, link_include_path, dir_path) generating_tables.get_api_data(data_total, StringConstant.PARSER_DIRECT_EXCEL_NAME.value) diff --git a/build-tools/capi_parser/src/typedef/check/check.py b/build-tools/capi_parser/src/typedef/check/check.py index 44f8e8248b534798c32f6ea02d5aa6ac9745042d..a77da9802f718ffb5c53b977d1c4ddf402039e3c 100644 --- a/build-tools/capi_parser/src/typedef/check/check.py +++ b/build-tools/capi_parser/src/typedef/check/check.py @@ -158,34 +158,34 @@ be reused please delete the extra tags.' class CheckErrorMessage(enum.Enum): - API_NAME_UNIVERSAL_01 = ('API check error of [naming errors]:The names of self-developed ' + API_NAME_UNIVERSAL_01 = ('API check error of [naming errors]:The [$$] of self-developed ' 'functions in APIs must start with OH_ or OS_ or HMS_ and comply ' 'with the large hump case format.') - API_NAME_UNIVERSAL_02 = ('API check error of [naming errors]:The names of constants in ' + API_NAME_UNIVERSAL_02 = ('API check error of [naming errors]:The [$$] of constants in ' 'APIs must be in uppercase and separated by underscores.') - API_NAME_UNIVERSAL_03 = ('API check error of [naming errors]:The naming of enumeration ' + API_NAME_UNIVERSAL_03 = ('API check error of [naming errors]:The [$$] of enumeration ' 'types should follow the big hump rule.') - API_NAME_UNIVERSAL_04 = ('API check error of [naming errors]:The naming of enumeration ' + API_NAME_UNIVERSAL_04 = ('API check error of [naming errors]:The [$$] of enumeration ' 'values should follow the all uppercase rule and separated by underscores.') - API_NAME_UNIVERSAL_05 = ('API check error of [naming errors]:The naming of struct should ' + API_NAME_UNIVERSAL_05 = ('API check error of [naming errors]:The [$$] of struct should ' 'follow the rules of the Great Hump.') - API_NAME_UNIVERSAL_06 = ('API check error of [naming errors]:The naming of members in the ' + API_NAME_UNIVERSAL_06 = ('API check error of [naming errors]:The [$$] of members in the ' 'structure should follow the small hump format.') - API_NAME_UNIVERSAL_07 = ('API check error of [naming errors]:The naming of the consortium ' - 'should follow the format of the large camel hump.') - API_NAME_UNIVERSAL_08 = ('API check error of [naming errors]:The naming of members in the ' + API_NAME_UNIVERSAL_07 = ('API check error of [naming errors]:The [$$] of the consortium ' + 'should follow the format of the Great hump.') + API_NAME_UNIVERSAL_08 = ('API check error of [naming errors]:The [$$] of members in the ' 'consortium should follow the small hump format.') - API_NAME_UNIVERSAL_09 = ('API check error of [naming errors]:The names of a global variable ' + API_NAME_UNIVERSAL_09 = ('API check error of [naming errors]:The [$$] of a global variable ' 'must be prefixed with g_ in the small camel case format.') - API_NAME_UNIVERSAL_10 = ('API check error of [naming errors]:The naming of general functions ' + API_NAME_UNIVERSAL_10 = ('API check error of [naming errors]:The [$$] of general functions ' 'should follow the big hump format.') - API_NAME_UNIVERSAL_11 = ('API check error of [naming errors]:Function parameter names should ' + API_NAME_UNIVERSAL_11 = ('API check error of [naming errors]:Function parameter [$$] should ' 'follow the small hump format.') - API_NAME_UNIVERSAL_12 = ('API check error of [naming errors]:Macro naming should follow all ' + API_NAME_UNIVERSAL_12 = ('API check error of [naming errors]:Macro [$$] should follow all ' 'uppercase format and separated by underscores.') - API_NAME_UNIVERSAL_13 = ('API check error of [naming errors]:Functional macro naming should ' + API_NAME_UNIVERSAL_13 = ('API check error of [naming errors]:Functional macro [$$] should ' 'follow all uppercase format and separated by underscores.') - API_NAME_UNIVERSAL_14 = ('API check error of [naming errors]:The file name should be all ' + API_NAME_UNIVERSAL_14 = ('API check error of [naming errors]:The [$$] file name should be all ' 'lowercase and separated by underscores.') API_DOC_GLOBAL_01 = ('API check error of [api doc errors]:The [file] tag is repeat. Please ' 'check the tag in file.') @@ -263,12 +263,16 @@ class CheckOutPut: main_buggy_code, main_buggy_line): self.analyzerName = 'apiengine' self.buggyFilePath = buggy_file_path + if code_context_start_line == -1: + code_context_start_line = 0 self.codeContextStartLine = code_context_start_line self.defectLevel = 2 self.defectType = defect_type self.description = description - self.language = 'c' + self.language = 'c++' self.mainBuggyCode = main_buggy_code + if main_buggy_line == -1: + main_buggy_line = 0 self.mainBuggyLine = main_buggy_line @@ -328,6 +332,7 @@ class OutputTxt: class ApiResultInfo: error_type: ErrorType = ErrorType.DEFAULT.value error_info = '' + error_content = '' level: ErrorLevel = -1 api_name = '' api_since = '' @@ -425,6 +430,12 @@ class ApiResultInfo: def set_location(self, location_param): self.location = location_param + def get_error_content(self): + return self.error_content + + def set_error_content(self, error_content): + self.error_content = error_content + class DocInfo: group = '' @@ -455,3 +466,9 @@ class FileDocInfo: file_since = False file_comment_str = '' curr_doc_info = DocInfo() + + +class CommentStartEndValue(enum.Enum): + DEFAULT_START = 0, + DEFAULT_END = 0 + diff --git a/build-tools/capi_parser/src/typedef/check/check_compatibility.py b/build-tools/capi_parser/src/typedef/check/check_compatibility.py new file mode 100644 index 0000000000000000000000000000000000000000..9b06a9a12e4781b8aafee1318ad32171f1b60675 --- /dev/null +++ b/build-tools/capi_parser/src/typedef/check/check_compatibility.py @@ -0,0 +1,177 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# 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 enum +from typedef.diff.diff import DiffType + + +class CheckCompatibilityErrorMessage(enum.Enum): + API_CHANGE_INCOMPATIBLE_01 = ('API check error of [api compatibility errors]:Deleting [$$] API is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_02 = ('API check error of [api compatibility errors]:Changing API name [$$] to API name ' + '[&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_03 = ('API check error of [api compatibility errors]:Deleting [$$] file is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_04 = ('API check error of [api compatibility errors]:Changing [$$] file path is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_05 = ('API check error of [api compatibility errors]:Changing function name [$$] to ' + 'function name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_06 = ('API check error of [api compatibility errors]:Changing function return type [$$] ' + 'to function return type [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_07 = ('API check error of [api compatibility errors]:Changing function param location [$$] ' + 'to function param location [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_08 = ('API check error of [api compatibility errors]:Adding new function param [&&] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_09 = ('API check error of [api compatibility errors]:Deleting function param [$$] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_10 = ('API check error of [api compatibility errors]:Changing function param type [$$] ' + 'to function param type [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_11 = ('API check error of [api compatibility errors]:Changing variable name [$$] to ' + 'variable name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_12 = ('API check error of [api compatibility errors]:Changing const name [$$] to const ' + 'name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_13 = ('API check error of [api compatibility errors]:Changing variable type [$$] to ' + 'variable type [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_14 = ('API check error of [api compatibility errors]:Changing const type [$$] to const ' + 'type [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_15 = ('API check error of [api compatibility errors]:Changing variable [$$] to const [&&] ' + 'is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_16 = ('API check error of [api compatibility errors]:Changing const [$$] to variable [&&] ' + 'is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_17 = ('API check error of [api compatibility errors]:Changing variable value [$$] to ' + 'variable value [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_18 = ('API check error of [api compatibility errors]:Changing const value [$$] to const ' + 'value [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_19 = ('API check error of [api compatibility errors]:Deleting variable [$$] is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_20 = ('API check error of [api compatibility errors]:Deleting const [$$] is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_21 = ('API check error of [api compatibility errors]:Changing macro name [$$] to macro ' + 'name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_22 = ('API check error of [api compatibility errors]:Changing macro value [$$] to macro ' + 'value [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_23 = ('API check error of [api compatibility errors]:Deleting macro define [$$] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_24 = ('API check error of [api compatibility errors]:Changing enum name [$$] to enum name ' + '[&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_25 = ('API check error of [api compatibility errors]:Changing enum member name [$$] to ' + 'enum member name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_26 = ('API check error of [api compatibility errors]:Changing enum member value [$$] to ' + 'enum member name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_27 = ('API check error of [api compatibility errors]:Deleting enum [$$] is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_28 = ('API check error of [api compatibility errors]:Deleting enum member [$$] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_29 = ('API check error of [api compatibility errors]:Changing struct name [$$] to struct ' + 'name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_30 = ('API check error of [api compatibility errors]:Adding struct member [&&] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_31 = ('API check error of [api compatibility errors]:Deleting struct member [$$] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_32 = ('API check error of [api compatibility errors]:Changing struct member type [$$] to ' + 'struct member type [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_33 = ('API check error of [api compatibility errors]:Changing struct member name [$$] to ' + 'struct member name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_34 = ('API check error of [api compatibility errors]:Deleting struct [$$] is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_35 = ('API check error of [api compatibility errors]:Changing struct since [$$] to ' + 'struct since [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_36 = ('API check error of [api compatibility errors]:Changing union name [$$] to ' + 'union name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_37 = ('API check error of [api compatibility errors]:Adding union member [&&] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_38 = ('API check error of [api compatibility errors]:Deleting union member [$$] is ' + 'prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_39 = ('API check error of [api compatibility errors]:Changing union member type [$$] to ' + 'union member type [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_40 = ('API check error of [api compatibility errors]:Changing union member name [$$] to ' + 'union member name [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_41 = ('API check error of [api compatibility errors]:Deleting union [$$] is prohibited.' + 'Please resolve it.') + API_CHANGE_INCOMPATIBLE_42 = ('API check error of [api compatibility errors]:Changing union since [$$] to union ' + 'since [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_43 = ('API check error of [api compatibility errors]:Changing the @library in comments ' + 'from no to [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_44 = ('API check error of [api compatibility errors]:Changing the @library in comments ' + 'from [$$] to no is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_45 = ('API check error of [api compatibility errors]:Changing the @library in comments ' + 'from [$$] to [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_46 = ('API check error of [api compatibility errors]:Changing the @permission in comments ' + 'is prohibited.Add and relation permission.Please resolve it.') + API_CHANGE_INCOMPATIBLE_47 = ('API check error of [api compatibility errors]:Changing the @permission in comments ' + 'is prohibited.Reduce or relation permission.Please resolve it.') + API_CHANGE_INCOMPATIBLE_48 = ('API check error of [api compatibility errors]:Changing the @permission in comments ' + 'is prohibited.Permission value change.Please resolve it.') + API_CHANGE_INCOMPATIBLE_49 = ('API check error of [api compatibility errors]:Changing the @syscap in comments ' + 'from no to [&&] is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_50 = ('API check error of [api compatibility errors]:Changing the @syscap in comments ' + 'from [$$] to no is prohibited.Please resolve it.') + API_CHANGE_INCOMPATIBLE_51 = ('API check error of [api compatibility errors]:Changing the @syscap in comments ' + 'from [$$] to [&&] is prohibited.Please resolve it.') + + @classmethod + def get_rule_message(cls, rule): + return cls[rule].value if rule in cls.__members__ else 'None' + + +check_compatibility_command_message = [ + member.name for name_compatibility_tool, + member in CheckCompatibilityErrorMessage.__members__.items() +] + + +match_diff_and_check_scene_dict = { + DiffType.REDUCE_API.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_01.name, + DiffType.REDUCE_FILE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_03.name, + DiffType.FUNCTION_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_05.name, + DiffType.FUNCTION_RETURN_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_06.name, + DiffType.FUNCTION_PARAM_POS_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_07.name, + DiffType.FUNCTION_PARAM_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_08.name, + DiffType.FUNCTION_PARAM_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_09.name, + DiffType.FUNCTION_PARAM_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_10.name, + DiffType.VARIABLE_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_11.name, + DiffType.CONSTANT_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_12.name, + DiffType.VARIABLE_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_13.name, + DiffType.CONSTANT_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_14.name, + DiffType.VARIABLE_CHANGE_TO_CONSTANT.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_15.name, + DiffType.CONSTANT_CHANGE_TO_VARIABLE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_16.name, + DiffType.VARIABLE_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_17.name, + DiffType.CONSTANT_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_18.name, + DiffType.DEFINE_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_21.name, + DiffType.DEFINE_TEXT_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_22.name, + DiffType.ENUM_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_24.name, + DiffType.ENUM_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_25.name, + DiffType.ENUM_MEMBER_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_26.name, + DiffType.ENUM_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_28.name, + DiffType.STRUCT_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_29.name, + DiffType.STRUCT_MEMBER_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_30.name, + DiffType.STRUCT_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_31.name, + DiffType.STRUCT_MEMBER_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_32.name, + DiffType.STRUCT_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_33.name, + DiffType.UNION_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_36.name, + DiffType.UNION_MEMBER_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_37.name, + DiffType.UNION_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_38.name, + DiffType.UNION_MEMBER_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_39.name, + DiffType.UNION_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_40.name, + DiffType.DOC_TAG_LIBRARY_NA_TO_HAVE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_43.name, + DiffType.DOC_TAG_LIBRARY_HAVE_TO_NA.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_44.name, + DiffType.DOC_TAG_LIBRARY_A_TO_B.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_45.name, + DiffType.DOC_TAG_PERMISSION_RANGE_SMALLER: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_47.name, + DiffType.DOC_TAG_PERMISSION_RANGE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_48.name, + DiffType.DOC_TAG_SYSCAP_NA_TO_HAVE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_49.name, + DiffType.DOC_TAG_SYSCAP_HAVE_TO_NA.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_50.name, + DiffType.DOC_TAG_SYSCAP_A_TO_B.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_51.name, +} diff --git a/build-tools/capi_parser/src/typedef/diff/diff.py b/build-tools/capi_parser/src/typedef/diff/diff.py index 897c320ba71011f093e2668d18c51f3106accf7e..adb97275ca12d44d96c355d0c486f2ded8db5e78 100644 --- a/build-tools/capi_parser/src/typedef/diff/diff.py +++ b/build-tools/capi_parser/src/typedef/diff/diff.py @@ -116,6 +116,7 @@ class Scene(enum.Enum): VAR_DECL = 'VAR_DECL' TYPEDEF_DECL = 'TYPEDEF_DECL' TRANSLATION_UNIT = 'TRANSLATION_UNIT' + ENUM_CONSTANT_DECL = 'ENUM_CONSTANT_DECL' class TAGS(enum.Enum): @@ -229,6 +230,7 @@ compatible_list = [ DiffType.ADD_API, DiffType.ADD_DOC, DiffType.ADD_DOC_TAG, + DiffType.ENUM_MEMBER_ADD, DiffType.FUNCTION_PARAM_NAME_CHANGE, DiffType.DOC_TAG_ADDTOGROUP_NA_TO_HAVE, DiffType.DOC_TAG_ADDTOGROUP_HAVE_TO_NA, @@ -386,6 +388,12 @@ class DiffInfo: operation_diff_type: str = '' old_differ_content: str = '' new_differ_content: str = '' + open_close_api: str = '' + is_third_party_api = False + current_api_type: str = '' + old_api_declara: str = '' + new_api_declara: str = '' + file_doc_line: int = 0 def __init__(self, diff_type: DiffType, old_differ_content, new_differ_content): self.diff_type = diff_type @@ -540,6 +548,42 @@ class DiffInfo: def get_new_differ_content(self): return self.new_differ_content + def set_open_close_api(self, open_close_api): + self.open_close_api = open_close_api + + def get_open_close_api(self): + return self.open_close_api + + def set_is_third_party_api(self, is_third_party_api): + self.is_third_party_api = is_third_party_api + + def get_is_third_party_api(self): + return self.is_third_party_api + + def set_current_api_type(self, current_api_type): + self.current_api_type = current_api_type + + def get_current_api_type(self): + return self.current_api_type + + def set_old_api_declara(self, old_api_declara): + self.old_api_declara = old_api_declara + + def get_old_api_declara(self): + return self.old_api_declara + + def set_new_api_declara(self, new_api_declara): + self.new_api_declara = new_api_declara + + def get_new_api_declara(self): + return self.new_api_declara + + def set_file_doc_line(self, file_doc_line): + self.file_doc_line = file_doc_line + + def get_file_doc_line(self): + return self.file_doc_line + class OutputJson: api_name: str = '' @@ -595,6 +639,10 @@ class ApiChangeData: compatible_total = False unique_id: str = '' is_system_api = False + open_close_api: str = '' + is_third_party_api = False + api_type: str = '' + current_api_type: str = '' def set_api_name(self, api_name): self.api_name = api_name @@ -679,3 +727,32 @@ class ApiChangeData: def get_is_system_api(self): return self.is_system_api + + def set_open_close_api(self, open_close_api): + self.open_close_api = open_close_api + + def get_open_close_api(self): + return self.open_close_api + + def set_is_third_party_api(self, is_third_party_api): + self.is_third_party_api = is_third_party_api + + def get_is_third_party_api(self): + return self.is_third_party_api + + def set_api_type(self, api_type): + self.api_type = api_type + + def get_api_type(self): + return self.api_type + + def set_current_api_type(self, current_api_type): + self.current_api_type = current_api_type + + def get_current_api_type(self): + return self.current_api_type + + +class IgnoreFileDirectory(enum.Enum): + IGNORE_FILE_DIR_lx = r'/(arm-linux-ohos|aarch64-linux-ohos|x86_64-linux-ohos|i686-linux-ohos|linux|tee|)(/|$)' + IGNORE_FILE_DIR_wd = r'\\(arm-linux-ohos|aarch64-linux-ohos|x86_64-linux-ohos|i686-linux-ohos|linux|tee|)(\\|$)' diff --git a/build-tools/capi_parser/src/utils/constants.py b/build-tools/capi_parser/src/utils/constants.py index 9c67d962b8669b9dda3a6868012349fb0d908c90..579737ce9a20acb19c77009a8558a2cc7aff7e5b 100644 --- a/build-tools/capi_parser/src/utils/constants.py +++ b/build-tools/capi_parser/src/utils/constants.py @@ -24,15 +24,15 @@ class StringConstant(enum.Enum): REPLACE_WAREHOUSE = '\\interface_sdk_c\\interface_sdk_c' # 拉到本地仓路径(去掉磁盘) # 拉到本地仓的三方库绝对路径 INCLUDE_LIB = r'.\third_party\musl\ndk_musl_include' - STD_INCLUDE = r'.\sysroot_myself\std_include_files' - CREATE_LIB_PATH = r'.\sysroot_myself\$is_headers_out_dir' - SELF_INCLUDE = r'.\sysroot_myself\self_include_files' - SELF_INCLUDE_OLD = r'.\sysroot_myself\self_include_files_old' - SELF_INCLUDE_NEW = r'.\sysroot_myself\self_include_files_new' - SYSROOT = r'.\sysroot_myself' + STD_INCLUDE = r'./sysroot_myself/std_include_files' + CREATE_LIB_PATH = r'./sysroot_myself/$is_headers_out_dir' + SELF_INCLUDE = r'./sysroot_myself/self_include_files' + SELF_INCLUDE_OLD = r'./sysroot_myself/self_include_files_old' + SELF_INCLUDE_NEW = r'./sysroot_myself/self_include_files_new' + SYSROOT = r'./sysroot_myself' RESULT_HEAD_NAME = "result_total.xlsx" PARSER_DIRECT_EXCEL_NAME = 'parser_direct_data.xlsx' - FILE_LEVEL_API_DATA = r'.\api_kit_c.json' + FILE_LEVEL_API_DATA = r'./api_kit_c.json' class RegularExpressions(enum.Enum): diff --git a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h index 67fcee95add3784728a2d1bde59e09215829fb64..04bb5d3311b50786aa49d24727f99e080f525837 100644 --- a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h +++ b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h @@ -62,6 +62,20 @@ struct OH_NativeBundle_ApplicationInfo { char* fingerprint; }; +/** + * @brief Indicates information of elementName. + * + * @since 13 + */ +struct OH_NativeBundle_ElementName { + /** Indicates the name of application. */ + char* bundleName; + /** Indicates the name of module. */ + char* moduleName; + /** Indicates the name of ability. */ + char* abilityName; +}; + /** * @brief Indicates information of application * @@ -70,6 +84,14 @@ struct OH_NativeBundle_ApplicationInfo { */ typedef struct OH_NativeBundle_ApplicationInfo OH_NativeBundle_ApplicationInfo; +/** + * @brief Indicates information of elementName + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_NativeBundle_ElementName OH_NativeBundle_ElementName; + /** * @brief Obtains the application info based on the The current bundle. * @@ -110,6 +132,33 @@ char* OH_NativeBundle_GetAppId(); * @version 1.0 */ char* OH_NativeBundle_GetAppIdentifier(); + +/** +* @brief Obtains information of the entry mainElement based on the current application, including bundle name, + * module name, and ability name. + * After utilizing this interface, to prevent memory leaks, + * it is necessary to manually release the pointer returned by the interface. + * + * @return Returns the newly created OH_NativeBundle_ElementName object, if the returned object is NULL, + * it indicates creation failure. The possible cause of failure could be that the application address space is full, + * leading to space allocation failure. + * @since 13 + */ +OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName(); + +/** + * @brief Obtains the compatible device type of the current application. + * After utilizing this interface, to prevent memory leaks, + * it is necessary to manually release the pointer returned by the interface. + * + * @return Returns the newly created string that indicates the compatible device type, + * if the returned object is NULL, it indicates creation failure. + * The possible cause of failure could be that the application address space is full, + * leading to space allocation failure. + * @since 14 + * @version 1.0 + */ +char* OH_NativeBundle_GetCompatibleDeviceType(); #ifdef __cplusplus }; #endif diff --git a/bundlemanager/bundle_framework/bundle/libbundle.ndk.json b/bundlemanager/bundle_framework/bundle/libbundle.ndk.json index f27f556889a6ed45be8813d4364241f33e5ad44a..f61863508c87306870bff6432339dbc5376b451a 100644 --- a/bundlemanager/bundle_framework/bundle/libbundle.ndk.json +++ b/bundlemanager/bundle_framework/bundle/libbundle.ndk.json @@ -10,5 +10,13 @@ { "first_introduced": "11", "name": "OH_NativeBundle_GetAppIdentifier" + }, + { + "first_introduced": "13", + "name": "OH_NativeBundle_GetMainElementName" + }, + { + "first_introduced": "14", + "name": "OH_NativeBundle_GetCompatibleDeviceType" } ] diff --git a/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h b/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h index a228044348e33e324aa8c5df8dbb9378534face3..f8510ba94437ee9d225cd9b7d90e8488a1ac0bb6 100644 --- a/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h +++ b/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h @@ -32,6 +32,9 @@ * provides features include create, begin read ,end read, begin write, end write, rebuild, and so on. * when using, it is necessary to link libpurgeable_memory_ndk.z.so * + * @library libpurgeablemem.so + * @syscap SystemCapability.Kernel.Memory + * @kit KernelEnhanceKit * @since 10 * @version 1.0 */ diff --git a/distributeddatamgr/pasteboard/BUILD.gn b/distributeddatamgr/pasteboard/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4cdf98a135446a6bb757e47ccdbcc90ec7f4fff7 --- /dev/null +++ b/distributeddatamgr/pasteboard/BUILD.gn @@ -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") +import("//foundation/distributeddatamgr/pasteboard/pasteboard.gni") + +ohos_ndk_headers("pasteboard_ndk_header") { + dest_dir = "$ndk_headers_out_dir/database/pasteboard/" + sources = [ + "./include/oh_pasteboard.h", + "./include/oh_pasteboard_err_code.h", + ] +} + +ohos_ndk_library("libpasteboard") { + output_name = "pasteboard" + output_extension = "so" + system_capability = "SystemCapability.MiscServices.Pasteboard" + ndk_description_file = "./libpasteboard.ndk.json" + min_compact_version = "13" + system_capability_headers = [ + "$ndk_headers_out_dir/database/pasteboard/oh_pasteboard.h", + "$ndk_headers_out_dir/database/pasteboard/oh_pasteboard_err_code.h", + ] +} diff --git a/distributeddatamgr/pasteboard/include/oh_pasteboard.h b/distributeddatamgr/pasteboard/include/oh_pasteboard.h new file mode 100644 index 0000000000000000000000000000000000000000..15d489623ca853e65e60500a7c9996c279468d2f --- /dev/null +++ b/distributeddatamgr/pasteboard/include/oh_pasteboard.h @@ -0,0 +1,287 @@ +/* + * 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 Pasteboard + * @{ + * + * @brief Provides the copy and paste support for the system Pasteboard. + * You can use the APIs of this module to operate the Pasteboard content of the plain text, HTML, + * URI, Want, pixel map, and other types. + * + * @since 13 + */ + +/** + * @file OH_Pasteboard.h + * + * @brief Provides APIs and enums of the Pasteboard module. + * + * @kit BasicServicesKit + * @library libpasteboard.so + * @syscap SystemCapability.MiscServices.Pasteboard + * + * @since 13 + */ + +#ifndef OH_PASTEBOARD_H +#define OH_PASTEBOARD_H + +#include +#include +#include "database/udmf/udmf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the types of data changes that can be observed. + * + * @since 13 + */ +typedef enum Pasteboard_NotifyType { + /** + * @brief Change of the Pasteboard data in the local device. + */ + NOTIFY_LOCAL_DATA_CHANGE = 1, + /** + * @brief Change of the Pasteboard data in the remote devices. + */ + NOTIFY_REMOTE_DATA_CHANGE = 2 +} Pasteboard_NotifyType; + +/** + * @brief Defines the callback function used to return the Pasteboard data changed. + * + * @param context The context set by {@link OH_PasteboardObserver_SetData} function. + * @param type The types of data changes. For details, see {@link Pasteboard_NotifyType}. + * @since 13 + */ +typedef void (*Pasteboard_Notify)(void* context, Pasteboard_NotifyType type); + +/** + * @brief Defines the callback function used free the context. + * @param context Pointer to the context which is to be free. + * @since 13 + */ +typedef void (*Pasteboard_Finalize)(void* context); + +/** + * @brief Defines the Pasteboard subscriber information + * + * @since 13 + */ +typedef struct OH_PasteboardObserver OH_PasteboardObserver; + +/** + * @brief Creates a {@link OH_PasteboardObserver} instance. + * + * @return Returns the pointer to the {@link OH_PasteboardObserver} instance created if the operation is successful. + * Returns nullptr if the operation is failed. + * @see OH_PasteboardObserver. + * @since 13 + */ +OH_PasteboardObserver* OH_PasteboardObserver_Create(); + +/** + * @brief Destroy a {@link OH_PasteboardObserver} instance. + * + * @param observer Pointer to the {@link OH_PasteboardObserver} instance to destroy. + * @return Returns the status code of the execution. For details, see {@link PASTEBOARD_ErrCode}. + * Returns {@link ERR_OK} if the operation is successful. + * Returns {@link ERR_INVALID_PARAMETER} if invalid args are detected. + * @see OH_PasteboardObserver PASTEBOARD_ErrCode. + * @since 13 + */ +int OH_PasteboardObserver_Destroy(OH_PasteboardObserver* observer); + +/** + * @brief Sets a callback function to return the Pasteboard data changed. + * + * @param observer Pointer to the {@link OH_PasteboardObserver} instance. + * @param context Pointer to the context set, which is the first parameter in Pasteboard_Notify. + * @param callback Callback to set. For details, see {@link Pasteboard_Notify}. + * @param finalize Optional callback that can free context when destroy observer. + * For details, see {@link Pasteboard_Finalize}. + * @return Returns the status code of the execution. For details, see {@link PASTEBOARD_ErrCode}. + * Returns {@link ERR_OK} if the operation is successful. + * Returns {@link ERR_INVALID_PARAMETER} if invalid args are detected. + * @see OH_PasteboardObserver Pasteboard_Notify PASTEBOARD_ErrCode. + * @since 13 + */ +int OH_PasteboardObserver_SetData(OH_PasteboardObserver* observer, void* context, + const Pasteboard_Notify callback, const Pasteboard_Finalize finalize); + +/** + * @brief Represents the Pasteboard information. + * + * @since 13 + */ +typedef struct OH_Pasteboard OH_Pasteboard; + +/** + * @brief Creates a {@link OH_Pasteboard} instance. + * + * @return Returns the pointer to the {@link OH_Pasteboard} instance created if the operation is successful. + * Returns nullptr if the memory is not enough. + * @see OH_Pasteboard. + * @since 13 + */ +OH_Pasteboard* OH_Pasteboard_Create(); + +/** + * @brief Destroy a {@link OH_Pasteboard} instance. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance to destroy. + * @see OH_Pasteboard. + * @since 13 + */ +void OH_Pasteboard_Destroy(OH_Pasteboard* pasteboard); + +/** + * @brief Subscribes to the Pasteboard data change. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param type Event type to subscribe to. + * @param observer - Pointer to the observer information, which specifies the callback used to + * reporting the pasteboard data change. For details, see {@link OH_PasteboardObserver}. + * @return Returns the status code of the execution. For details, {@link PASTEBOARD_ErrCode}. + * Returns {@link ERR_OK} if the operation is successful. + * Returns {@link ERR_INVALID_PARAMETER} if invalid args are detected. + * @see OH_Pasteboard OH_PasteboardObserver PASTEBOARD_ErrCode. + * @since 13 + */ +int OH_Pasteboard_Subscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer); + +/** + * @brief Unsubscribes from the Pasteboard data change. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param type Event type to subscribe to. + * @param observer - Pointer to the observer information, which specifies the callback used to + * reporting the pasteboard data change. For details, see {@link OH_PasteboardObserver}. + * @return Returns the status code of the execution. For details, {@link PASTEBOARD_ErrCode}. + * Returns {@link ERR_OK} if the operation is successful. + * Returns {@link ERR_INVALID_PARAMETER} if invalid args are detected. + * @see OH_Pasteboard OH_PasteboardObserver PASTEBOARD_ErrCode. + * @since 13 + */ +int OH_Pasteboard_Unsubscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer); + +/** + * @brief Checks whether the Pasteboard data is from a remote device. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @return Returns a boolean value, which indicates whether the the data is from a remote device. + * The value {@code false} means Pasteboard data is not from a remote device. + * The value {@code true} means the opposite. + * @see OH_Pasteboard. + * @since 13 + */ +bool OH_Pasteboard_IsRemoteData(OH_Pasteboard* pasteboard); + +/** + * @brief Obtains the source of Pasteboard data. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param source Pointer to the source data. + * @param len Length of the source data. + * @return Returns the status code of the execution. For details, see {@link PASTEBOARD_ErrCode}. + * Returns {@link ERR_OK} if the operation is successful. + * Returns {@link ERR_INVALID_PARAMETER} if invalid args are detected. + * @see OH_Pasteboard PASTEBOARD_ErrCode. + * @since 13 + */ +int OH_Pasteboard_GetDataSource(OH_Pasteboard* pasteboard, char* source, unsigned int len); + +/** + * @brief Checks whether the Pasteboard has the specified type of data. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param type Poniter to the type of data to check. + * @return Returns a boolean value, which indicates whether the Pasteboard has the specified type of data. + * The value {@code true} means the Pasteboard has the specified type of data. + * The value {@code false} means the opposite. + * @see OH_Pasteboard. + * @since 13 + */ +bool OH_Pasteboard_HasType(OH_Pasteboard* pasteboard, const char* type); + +/** + * @brief Checks whether there is data in the Pasteboard. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @return Returns a boolean value, which indicates whether there is data in the Pasteboard. + * The value {@code true} means there is data in Pasteboard. + * The value {@code false} means the opposite. + * @see OH_Pasteboard. + * @since 13 + */ +bool OH_Pasteboard_HasData(OH_Pasteboard* pasteboard); + +/** + * @brief Obtains data from the Pasteboard. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param status The status code of the execution. For details, see {@link PASTEBOARD_ErrCode}. + * @return Returns the pointer to the {@link OH_UdmfData} instance. + * @see OH_Pasteboard OH_UdmfData PASTEBOARD_ErrCode. + * @since 13 + */ +OH_UdmfData* OH_Pasteboard_GetData(OH_Pasteboard* pasteboard, int* status); + +/** + * @brief Writes data to the Pasteboard. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param data Pointer to the {@link OH_UdmfData} instance. + * @return Returns the status code of the execution. For details, see {@link PASTEBOARD_ErrCode}. + * Returns {@link ERR_OK} if the operation is successful. + * Returns {@link ERR_INVALID_PARAMETER} if invalid args are detected. + * @see OH_Pasteboard OH_UdmfData PASTEBOARD_ErrCode. + * @since 13 + */ +int OH_Pasteboard_SetData(OH_Pasteboard* pasteboard, OH_UdmfData* data); + +/** + * @brief Clears the data in the Pastedboard. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @return Returns the status code of the execution. For details, see {@link PASTEBOARD_ErrCode}. + * Returns {@link ERR_OK} if the operation is successful. + * Returns {@link ERR_INVALID_PARAMETER} if invalid args are detected. + * @see OH_Pasteboard PASTEBOARD_ErrCode. + * @since 13 + */ +int OH_Pasteboard_ClearData(OH_Pasteboard* pasteboard); + +/** + * @brief Obtains all MIME types of Pasteboard data. + * + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param count Poniter to the count of MIME types. + * @return Returns char array of MIME types in the Pasteboard. + * Returns nullptr if the operation is failed. + * @see OH_Pasteboard. + * @since 14 + */ +char **OH_Pasteboard_GetMimeTypes(OH_Pasteboard *pasteboard, unsigned int *count); +#ifdef __cplusplus +}; +#endif + +/** @} */ +#endif \ No newline at end of file diff --git a/distributeddatamgr/pasteboard/include/oh_pasteboard_err_code.h b/distributeddatamgr/pasteboard/include/oh_pasteboard_err_code.h new file mode 100644 index 0000000000000000000000000000000000000000..36f30f1a99c8eaf96f8ab3c255a9a473548e226e --- /dev/null +++ b/distributeddatamgr/pasteboard/include/oh_pasteboard_err_code.h @@ -0,0 +1,83 @@ +/* + * 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 Pasteboard + * @{ + * + * @brief Provides the copy and paste support for the system Pasteboard. + * You can use the APIs of this module to operate the Pasteboard content of the plain text, HTML, + * URI, Want, pixel map, and other types. + * + * @since 13 + */ + +/** + * @file oh_pasteboard_err_code.h + * + * @brief Declaration error code information. + * + * @kit BasicServicesKit + * @library libpasteboard.so + * @syscap SystemCapability.MiscServices.Pasteboard + * + * @since 13 + */ + + +#ifndef OH_PASTEBOARD_ERR_CODE_H +#define OH_PASTEBOARD_ERR_CODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes. + * + * @since 13 + */ +typedef enum PASTEBOARD_ErrCode { + /** + * @error The operation is successful. + */ + ERR_OK = 0, + /** + * @error Permission verification failed. + */ + ERR_PERMISSION_ERROR = 201, + /** + * @error Invalid parameter is detected. + */ + ERR_INVALID_PARAMETER = 401, + /** + * @error The capability is not supported. + */ + ERR_DEVICE_NOT_SUPPORTED = 801, + /** + * @error Inner error. + */ + ERR_INNER_ERROR = 12900000, + /** + * @error Another copy is in progress. + */ + ERR_BUSY = 12900003, +} PASTEBOARD_ErrCode; +#ifdef __cplusplus +}; +#endif + +/** @} */ +#endif diff --git a/distributeddatamgr/pasteboard/libpasteboard.ndk.json b/distributeddatamgr/pasteboard/libpasteboard.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..829a3ba45fac1adec83078b3db8e7538fdbd5a4e --- /dev/null +++ b/distributeddatamgr/pasteboard/libpasteboard.ndk.json @@ -0,0 +1,58 @@ +[ + { + "first_introduced": "13", + "name": "OH_PasteboardObserver_Create" + }, + { + "first_introduced": "13", + "name": "OH_PasteboardObserver_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_PasteboardObserver_SetData" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_Create" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_Subscribe" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_Unsubscribe" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_IsRemoteData" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_GetDataSource" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_HasType" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_HasData" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_GetData" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_SetData" + }, + { + "first_introduced": "13", + "name": "OH_Pasteboard_ClearData" + } +] \ No newline at end of file diff --git a/distributeddatamgr/preferences/BUILD.gn b/distributeddatamgr/preferences/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..77c03331c6a4d6c259edececb9b44af3e89556a3 --- /dev/null +++ b/distributeddatamgr/preferences/BUILD.gn @@ -0,0 +1,40 @@ +# 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") +import("//foundation/distributeddatamgr/preferences/preferences.gni") + +ohos_ndk_headers("preferences_ndk_header") { + dest_dir = "$ndk_headers_out_dir/database/preferences/" + sources = [ + "./include/oh_preferences.h", + "./include/oh_preferences_err_code.h", + "./include/oh_preferences_option.h", + "./include/oh_preferences_value.h", + ] +} + +ohos_ndk_library("libohpreferences") { + output_name = "ohpreferences" + output_extension = "so" + system_capability = "SystemCapability.DistributedDataManager.Preferences.Core" + ndk_description_file = "./libpreferences.ndk.json" + min_compact_version = "13" + system_capability_headers = [ + "database/preferences/oh_preferences.h", + "database/preferences/oh_preferences_err_code.h", + "database/preferences/oh_preferences_value.h", + "database/preferences/oh_preferences_option.h", + ] +} diff --git a/distributeddatamgr/preferences/include/oh_preferences.h b/distributeddatamgr/preferences/include/oh_preferences.h new file mode 100644 index 0000000000000000000000000000000000000000..944fa9dffcdcd8024127548ed3994bf5f8de406d --- /dev/null +++ b/distributeddatamgr/preferences/include/oh_preferences.h @@ -0,0 +1,271 @@ +/* + * 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 PREFERENCES + * @{ + * + * @brief Provides APIs for processing data in the form of key-value (KV) pairs. + * You can use the APIs provided by the Preferences module to query, modify, and persist KV pairs. + * The key is of the string type, and the value can be a number, a string, a boolean value. + * + * @since 13 + */ + +/** + * @file oh_preferences.h + * + * @brief Defines the APIS and enums of Preference. + * + * @kit ArkData + * @library libohpreferences.so + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + * @since 13 + */ + +#ifndef OH_PREFERENCES_H +#define OH_PREFERENCES_H + +#include +#include + +#include "oh_preferences_value.h" +#include "oh_preferences_option.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Represents a Preferences instance. + * + * @since 13 + */ +typedef struct OH_Preferences OH_Preferences; + +/** + * @brief Call to return the change in KV pairs. + * + * @param context Pointer to the context of data observer. + * @param pairs Pointer to the KV pairs to be observed. + * @param count Number of KV pairs to be observed. + * @see OH_PreferencesPair. + * @since 13 + */ +typedef void (*OH_PreferencesDataObserver)(void *context, const OH_PreferencesPair *pairs, uint32_t count); + +/** + * @brief Opens a Preferences object. + * + * @param option Pointer to an {@Link OH_PreferencesOption} instance. + * @param errCode Pointer to the status code of the execution. For details, See {@link OH_Preferences_ErrCode}. + * @return Returns an pointer to the Preferences object in {@Link OH_Preferences} if the operation is successful, + * returns nullptr otherwise. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_NOT_SUPPORTED} indicates the capability is not supported. + * {@link PREFERENCES_ERROR_DELETE_FILE} indicates delete file failed. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_Preferences OH_PreferencesOption. + * @since 13 + */ +OH_Preferences *OH_Preferences_Open(OH_PreferencesOption *option, int *errCode); + +/** + * @brief Closes a Preferences object. + * + * @param preference Pointer to the {@Link OH_Preferences} instance to close. + * @return Returns the status code of the execution. For details, see {@Link OH_Preferences_ErrCode}. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_Close(OH_Preferences *preference); + +/** + * @brief Obtains the integer value in a Preferences object based on the given key. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param key Pointer to the key of the value to obtain. + * @param value Pointer to the value obtained. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * {@link PREFERENCES_ERROR_KEY_NOT_FOUND} indicates the key does not exist. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_GetInt(OH_Preferences *preference, const char *key, int *value); + +/** + * @brief Obtains the Boolean value in a Preferences object based on the given key. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param key Pointer to the key of the value to obtain. + * @param value Pointer to the Boolean value obtained. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * {@link PREFERENCES_ERROR_KEY_NOT_FOUND} indicates the key does not exist. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_GetBool(OH_Preferences *preference, const char *key, bool *value); + +/** + * @brief Obtains the string value in a Preferences object based on the given key. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param key Pointer to the key of the value to obtain. + * @param value Double pointer to the value obtained in an char * array. Release {@Link OH_Preferences_FreeString} the + * memory by user when this parameter is no longer required. + * @param valueLen Pointer to the length of the string obtained. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * {@link PREFERENCES_ERROR_KEY_NOT_FOUND} indicates the key does not exist. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_GetString(OH_Preferences *preference, const char *key, char **value, uint32_t *valueLen); + +/** + * @brief Free a string got by Preferences object. + * + * @param string Point to string need to free. + * @see OH_Preferences. + * @since 13 + */ +void OH_Preferences_FreeString(char *string); + +/** + * @brief Sets an integer in a Preferences object. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param key Pointer to the key to set. + * @param value Value to set. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_SetInt(OH_Preferences *preference, const char *key, int value); + +/** + * @brief Sets a Boolean value in a Preferences object. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param key Pointer to the key to set. + * @param value Boolean value to set. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_SetBool(OH_Preferences *preference, const char *key, bool value); + +/** + * @brief Sets a string in a Preferences object. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param key Pointer to the key to set. + * @param value Point to string to set. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_SetString(OH_Preferences *preference, const char *key, const char *value); + +/** + * @brief Deletes a KV pair from a Preferences object. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param key Pointer to the key of the data to delete. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_Preferences. + * @since 13 + */ +int OH_Preferences_Delete(OH_Preferences *preference, const char *key); + +/** + * @brief Registers a data observer for a Preferences object. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param context Pointer to the context of the data observer. + * @param observer the {@Link OH_PreferencesDataObserver} to register. + * @param keys Pointer to the keys to observe. + * @param keyCount Number of keys to observe. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * {@link PREFERENCES_ERROR_GET_DATAOBSMGRCLIENT} indicates get dataObsMgrClient error. + * @see OH_Preferences OH_PreferencesDataObserver. + * @since 13 + */ +int OH_Preferences_RegisterDataObserver(OH_Preferences *preference, void *context, + OH_PreferencesDataObserver observer, const char *keys[], uint32_t keyCount); + +/** + * @brief Unregisters a data observer for a Preferences object. + * + * @param preference Pointer to the target {@Link OH_Preferences} instance. + * @param context Pointer to the context of the data observer. + * @param observer the {@Link OH_PreferencesDataObserver} to unregister. + * @param keys Pointer to the keys observed. If this parameter is null, this API unregisters the listening for all keys. + * @param keyCount Number of the keys. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_Preferences OH_PreferencesDataObserver. + * @since 13 + */ +int OH_Preferences_UnregisterDataObserver(OH_Preferences *preference, void *context, + OH_PreferencesDataObserver observer, const char *keys[], uint32_t keyCount); + +#ifdef __cplusplus +}; +#endif + +/** @} */ +#endif // OH_PREFERENCES_H \ No newline at end of file diff --git a/distributeddatamgr/preferences/include/oh_preferences_err_code.h b/distributeddatamgr/preferences/include/oh_preferences_err_code.h new file mode 100644 index 0000000000000000000000000000000000000000..5b77219b9d9647f416e18126d8014747b23ddf24 --- /dev/null +++ b/distributeddatamgr/preferences/include/oh_preferences_err_code.h @@ -0,0 +1,77 @@ +/* + * 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 PREFERENCES + * @{ + * + * @brief Provides APIs for processing data in the form of key-value (KV) pairs. + * You can use the APIs provided by the Preferences module to query, modify, and persist KV pairs. + * The key is of the string type, and the value can be a number, a string, a boolean value. + * + * @since 13 + */ + +/** + * @file preferences_err_code.h + * + * @brief Defines the status codes used in the Preferences module. + * + * @kit ArkData + * @library libohpreferences.so + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + * @since 13 + */ + + +#ifndef OH_PREFERENCES_ERR_CODE_H +#define OH_PREFERENCES_ERR_CODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the status codes. + * + * @since 13 + */ +typedef enum OH_Preferences_ErrCode { + /** @error Operation successful. */ + PREFERENCES_OK = 0, + /* @error Invalid args. */ + PREFERENCES_ERROR_INVALID_PARAM = 401, + /* @error Capability not supported. */ + PREFERENCES_ERROR_NOT_SUPPORTED = 801, + /* @error Base error code. */ + PREFERENCES_ERROR_BASE = 15500000, + /* @error Failed to delete a file. */ + PREFERENCES_ERROR_DELETE_FILE = 15500010, + /* @error Storage error. */ + PREFERENCES_ERROR_STORAGE = 15500011, + /* @error Failed to malloc memory. */ + PREFERENCES_ERROR_MALLOC = 15500012, + /* @error Key not found error. */ + PREFERENCES_ERROR_KEY_NOT_FOUND = 15500013, + /* @error Failed to get DataObsMgrClient. */ + PREFERENCES_ERROR_GET_DATAOBSMGRCLIENT = 15500019, +} OH_Preferences_ErrCode; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_PREFERENCES_ERR_CODE_H diff --git a/distributeddatamgr/preferences/include/oh_preferences_option.h b/distributeddatamgr/preferences/include/oh_preferences_option.h new file mode 100644 index 0000000000000000000000000000000000000000..a8a25af9f55287456e3595803981a3c727390acf --- /dev/null +++ b/distributeddatamgr/preferences/include/oh_preferences_option.h @@ -0,0 +1,118 @@ +/* + * 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 PREFERENCES + * @{ + * + * @brief Provides APIs for processing data in the form of key-value (KV) pairs. + * You can use the APIs provided by the Preferences module to query, modify, and persist KV pairs. + * The key is of the string type, and the value can be a number, a string, a boolean value. + * + * @since 13 + */ + +/** + * @file oh_preferences_option.h + * + * @brief Defines the APIs and enums related to preferences option. + * + * @kit ArkData + * @library libohpreferences.so + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + * @since 13 + */ + +#ifndef OH_PREFERENCES_OPTION_H +#define OH_PREFERENCES_OPTION_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Represents an OH_PreferencesOption instance. + * + * @since 13 + */ +typedef struct OH_PreferencesOption OH_PreferencesOption; + +/** + * @brief Creates an {@Link OH_PreferencesOption} instance. + * + * @return Returns a pointer to the {@Link OH_PreferencesOption} instance created if the operation is successful; + * returns nullptr otherwise while malloc memory failed. + * @see OH_PreferencesOption. + * @since 13 + */ +OH_PreferencesOption *OH_PreferencesOption_Create(void); + +/** + * @brief Sets the file path in an {@Link OH_PreferencesOption} instance. + * + * @param option Pointer to the target {@Link OH_PreferencesOption} instance. + * @param fileName Pointer to the file name to set. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} success. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * @see OH_PreferencesOption. + * @since 13 + */ +int OH_PreferencesOption_SetFileName(OH_PreferencesOption *option, const char *fileName); + +/** + * @brief Sets the bundle name in an {@Link OH_PreferencesOption} instance. + * + * @param option Pointer to the target {@Link OH_PreferencesOption} instance. + * @param bundleName Pointer to the bundle name to set. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} success. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * @see OH_PreferencesOption. + * @since 13 + */ +int OH_PreferencesOption_SetBundleName(OH_PreferencesOption *option, const char *bundleName); + +/** + * @brief Sets the data group ID in an {@Link OH_PreferencesOption} instance. + * + * @param option Represents a pointer to an {@link OH_PreferencesOption} instance. + * @param dataGroupId Represents preferences data group id param. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} success. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * @see OH_PreferencesOption. + * @since 13 + */ +int OH_PreferencesOption_SetDataGroupId(OH_PreferencesOption *option, const char *dataGroupId); + +/** + * @brief Destroys an {@Link OH_PreferencesOption} instance. + * + * @param option Pointer to the {@Link OH_PreferencesOption} instance to destroy. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * @see OH_PreferencesOption. + * @since 13 + */ +int OH_PreferencesOption_Destroy(OH_PreferencesOption *option); +#ifdef __cplusplus +}; +#endif +#endif // OH_PREFERENCES_OPTION_H \ No newline at end of file diff --git a/distributeddatamgr/preferences/include/oh_preferences_value.h b/distributeddatamgr/preferences/include/oh_preferences_value.h new file mode 100644 index 0000000000000000000000000000000000000000..945e28fc62980fe1de55cd342a2f1eb33e3d2bb7 --- /dev/null +++ b/distributeddatamgr/preferences/include/oh_preferences_value.h @@ -0,0 +1,175 @@ +/* + * 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 PREFERENCES + * @{ + * + * @brief Provides APIs for processing data in the form of key-value (KV) pairs. + * You can use the APIs provided by the Preferences module to query, modify, and persist KV pairs. + * The key is of the string type, and the value can be a number, a string, a boolean value. + * + * @since 13 + */ + +/** + * @file oh_preferences_value.h + * + * @brief Defines the APIs and enums related to preferences values. + * + * @kit ArkData + * @library libohpreferences.so + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + * @since 13 + */ + +#ifndef OH_PREFERENCES_VALUE_H +#define OH_PREFERENCES_VALUE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the Preference value types. + * + * @since 13 + */ +typedef enum Preference_ValueType { + /** + * @brief Null. + */ + PREFERENCE_TYPE_NULL = 0, + /** + * @brief Int. + */ + PREFERENCE_TYPE_INT, + /** + * @brief boolean. + */ + PREFERENCE_TYPE_BOOL, + /** + * @brief String. + */ + PREFERENCE_TYPE_STRING, + /** + * @brief end butt. + */ + PREFERENCE_TYPE_BUTT +} Preference_ValueType; + +/** + * @brief Represents a KV pair in a Preferences instance. + * + * @since 13 + */ +typedef struct OH_PreferencesPair OH_PreferencesPair; + +/** + * @brief Represents the value in a KV pair of a Preferences instance. + * + * @since 13 + */ +typedef struct OH_PreferencesValue OH_PreferencesValue; + +/** + * @brief Obtains a key from an {@Link OH_PreferencesPair} instance. + * + * @param pairs Pointer to the target {@Link OH_PreferencesPair} instance. + * @param index Represents a target index of the pairs + * @return Returns preferences pointer to the key that when input parameters valid, + * return nullptr otherwise while invalid args are passed in. + * @see OH_PreferencesPair. + * @since 13 + */ +const char *OH_PreferencesPair_GetKey(const OH_PreferencesPair *pairs, uint32_t index); + +/** + * @brief Obtains a value from an {@Link OH_PreferencesPair} instance. + * + * @param pairs Pointer to the target {@Link OH_PreferencesPair} instance. + * @param index Index of the value to obtain. + * @return Returns a pointer to the {@Link OH_PreferencesValue} obtained if the operation is successful, + * returns nullptr otherwise while invalid args are passed in. + * @see OH_PreferencesValue. + * @since 13 + */ +const OH_PreferencesValue *OH_PreferencesPair_GetPreferencesValue(const OH_PreferencesPair *pairs, uint32_t index); + +/** + * @brief Obtains the type of a preferences value. + * + * @param object Pointer to the target {@Link OH_PreferencesValue} instance. + * @return Returns the value type obtained. + * {@link PREFERENCE_TYPE_NULL} indicates invalid args are passed in. + * @see OH_PreferencesValue. + * @since 13 + */ +Preference_ValueType OH_PreferencesValue_GetValueType(const OH_PreferencesValue *object); + +/** + * @brief Obtains the int value of an {@Link OH_PreferencesValue} instance. + * + * @param object Pointer to the target {@Link OH_PreferencesValue} instance. + * @param value Pointer to the value obtained. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_PreferencesValue. + * @since 13 + */ +int OH_PreferencesValue_GetInt(const OH_PreferencesValue *object, int *value); + +/** + * @brief Obtains the Boolean value of an {@Link OH_PreferencesValue} instance. + * + * @param object Pointer to the target {@Link OH_PreferencesValue} instance. + * @param value Pointer to the Boolean value obtained. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_PreferencesValue. + * @since 13 + */ +int OH_PreferencesValue_GetBool(const OH_PreferencesValue *object, bool *value); + +/** + * @brief Obtains the string value of an {@Link OH_PreferencesValue} instance. + * + * @param object Pointer to target {@Link OH_PreferencesValue} instance. + * @param value Double pointer to the value obtained in an char * array. Release {@Link OH_Preferences_FreeString} the + * memory by user when this parameter is no longer required. + * @param valueLen Pointer to the string length. + * @return Returns the status code of the execution. + * {@link PREFERENCES_OK} indicates the operation is successful. + * {@link PREFERENCES_ERROR_INVALID_PARAM} indicates invalid args are passed in. + * {@link PREFERENCES_ERROR_STORAGE} indicates an storage error. + * {@link PREFERENCES_ERROR_MALLOC} indicates an malloc memory error. + * @see OH_PreferencesValue. + * @since 13 + */ +int OH_PreferencesValue_GetString(const OH_PreferencesValue *object, char **value, uint32_t *valueLen); +#ifdef __cplusplus +}; +#endif +#endif // OH_PREFERENCES_VALUE_H \ No newline at end of file diff --git a/distributeddatamgr/preferences/libpreferences.ndk.json b/distributeddatamgr/preferences/libpreferences.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..9c41566f528e86b05404777fa5528a6c277090af --- /dev/null +++ b/distributeddatamgr/preferences/libpreferences.ndk.json @@ -0,0 +1,94 @@ +[ + { + "first_introduced": "13", + "name": "OH_Preferences_Open" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_Close" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_GetInt" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_GetBool" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_GetString" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_FreeString" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_SetInt" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_SetBool" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_SetString" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_Delete" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_RegisterDataObserver" + }, + { + "first_introduced": "13", + "name": "OH_Preferences_UnregisterDataObserver" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesOption_Create" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesOption_SetFileName" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesOption_SetBundleName" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesOption_SetDataGroupId" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesOption_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesPair_GetKey" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesPair_GetPreferencesValue" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesValue_GetValueType" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesValue_GetInt" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesValue_GetBool" + }, + { + "first_introduced": "13", + "name": "OH_PreferencesValue_GetString" + } +] \ No newline at end of file diff --git a/distributeddatamgr/relational_store/include/data_asset.h b/distributeddatamgr/relational_store/include/data_asset.h index a8bc9e16a83b3eb8ae17e0e73785b7ec72ede2f3..a784b51deea833fe86e85045ea4f988a9e05b02b 100644 --- a/distributeddatamgr/relational_store/include/data_asset.h +++ b/distributeddatamgr/relational_store/include/data_asset.h @@ -36,7 +36,7 @@ * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 11 */ -#include +#include #include #ifdef __cplusplus extern "C" { diff --git a/distributeddatamgr/relational_store/include/oh_cursor.h b/distributeddatamgr/relational_store/include/oh_cursor.h index 30d208ab446635eee502b76bc7b4b04ac8e1fe70..232e521a7f1c75b78136db6db8f2ef626f03183f 100644 --- a/distributeddatamgr/relational_store/include/oh_cursor.h +++ b/distributeddatamgr/relational_store/include/oh_cursor.h @@ -38,7 +38,7 @@ * @since 10 */ -#include +#include #include #include #include "database/data/data_asset.h" @@ -86,6 +86,15 @@ typedef enum OH_ColumnType { TYPE_ASSETS } OH_ColumnType; +/** + * @brief Define the OH_Cursor structure type. + * + * Provides methods for accessing a database result set generated by query the database. + * + * @since 10 + */ +typedef struct OH_Cursor OH_Cursor; + /** * @brief Define the OH_Cursor structure type. * diff --git a/distributeddatamgr/relational_store/include/oh_predicates.h b/distributeddatamgr/relational_store/include/oh_predicates.h index 71f4964591e50d5751ab93e25c15abbecca018d9..a73410b475f6024d2d4685b33841d6327f98cb2e 100644 --- a/distributeddatamgr/relational_store/include/oh_predicates.h +++ b/distributeddatamgr/relational_store/include/oh_predicates.h @@ -38,7 +38,7 @@ * @since 10 */ -#include +#include #include #include "database/rdb/oh_value_object.h" @@ -62,6 +62,13 @@ typedef enum OH_OrderType { DESC = 1, } OH_OrderType; +/** + * @brief Define the OH_Predicates structure type. + * + * @since 10 + */ +typedef struct OH_Predicates OH_Predicates; + /** * @brief Define the OH_Predicates structure type. * diff --git a/distributeddatamgr/relational_store/include/oh_value_object.h b/distributeddatamgr/relational_store/include/oh_value_object.h index dbe5d0d18a9598c7cf4cd15f12822f2a58141cb5..7fedc36500f35c91db3ea9aa58ef61d8fefa5762 100644 --- a/distributeddatamgr/relational_store/include/oh_value_object.h +++ b/distributeddatamgr/relational_store/include/oh_value_object.h @@ -38,11 +38,18 @@ * @since 10 */ -#include +#include #ifdef __cplusplus extern "C" { #endif +/** + * @brief Define the OH_VObject structure type. + * + * @since 10 + */ +typedef struct OH_VObject OH_VObject; + /** * @brief Define the OH_VObject structure type. * diff --git a/distributeddatamgr/relational_store/include/oh_values_bucket.h b/distributeddatamgr/relational_store/include/oh_values_bucket.h index db822d1de1db6a2a20fa86bdc1b60896d4098374..7c0457e9c4c6dbb965aeedabfd1ad2c6f70b7fae 100644 --- a/distributeddatamgr/relational_store/include/oh_values_bucket.h +++ b/distributeddatamgr/relational_store/include/oh_values_bucket.h @@ -38,12 +38,19 @@ * @since 10 */ -#include +#include #include "database/data/data_asset.h" #ifdef __cplusplus extern "C" { #endif +/** + * @brief Define the OH_VBucket structure type. + * + * @since 10 + */ +typedef struct OH_VBucket OH_VBucket; + /** * @brief Define the OH_VBucket structure type. * diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 471e486498c2e19254dc14808b7a3727b72dd0fb..b8be9a6aa7948d0c7391250047554e9349400754 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -93,11 +93,17 @@ typedef enum Rdb_SecurityArea { * @brief Security Area 4. */ RDB_SECURITY_AREA_EL4, + + /** + * @brief Security Area 5. + * + * @since 12 + */ + RDB_SECURITY_AREA_EL5, } Rdb_SecurityArea; /** * @brief Manages relational database configurations. - * * @since 10 */ #pragma pack(1) @@ -151,6 +157,167 @@ typedef struct { int64_t id; } OH_Rdb_Store; +/** + * @brief Define OH_Rdb_ConfigV2 type. + * + * @since 14 + */ +typedef struct OH_Rdb_ConfigV2 OH_Rdb_ConfigV2; + +/** + * @brief Define Rdb_DBType type. + * + * @since 14 + */ +typedef enum Rdb_DBType { + /** + * @brief Means using SQLITE as the db kernal + */ + RDB_SQLITE = 1, + /** + * @brief Means using CARLEY_DB as the db kernal + */ + RDB_CAYLEY = 2, + /** + * @brief Means largest value for Rdb_DBType + */ + DBTYPE_BUTT = 64, +} Rdb_DBType; + +/** + * @brief Create OH_Rdb_ConfigV2 which is used to open store + * + * @return Returns the newly created OH_Rdb_ConfigV2 object. If NULL is returned, the creation fails. + * The possible cause is that the address space of the application is full, As a result, the space + * cannot be allocated. + * @see OH_Rdb_ConfigV2 + * @since 14 + */ +OH_Rdb_ConfigV2 *OH_Rdb_CreateConfig(); + +/** + * @brief Destroy OH_Rdb_ConfigV2 which is created by OH_Rdb_CreateConfig + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_DestroyConfig(OH_Rdb_ConfigV2 *config); + +/** + * @brief Set property databaseDir into config + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @param dataBaseDir Indicates the directory of the database. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_SetDatabaseDir(OH_Rdb_ConfigV2 *config, const char *databaseDir); + +/** + * @brief Set property storeName into config + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @param storeName Indicates the name of the database. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_SetStoreName(OH_Rdb_ConfigV2 *config, const char *storeName); + +/** + * @brief Set property bundleName into config + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @param bundleName Indicates the bundle name of the application + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_SetBundleName(OH_Rdb_ConfigV2 *config, const char *bundleName); + +/** + * @brief Set property moduleName into config + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @param moduleName Indicates the module name of the application. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_SetModuleName(OH_Rdb_ConfigV2 *config, const char *moduleName); + +/** + * @brief Set property isEncrypted into config + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @param isEncrypted Indicates whether the database is encrypted. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_SetEncrypted(OH_Rdb_ConfigV2 *config, bool isEncrypted); + +/** + * @brief Set property securityLevel into config + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @param securityLevel Indicates the security level {@link OH_Rdb_SecurityLevel} of the database. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_SetSecurityLevel(OH_Rdb_ConfigV2 *config, int securityLevel); + +/** + * @brief Set property area into config + * + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store + * @param area Represents the security area of the database. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * @since 14 + */ +int OH_Rdb_SetArea(OH_Rdb_ConfigV2 *config, int area); + +/** + * @brief Set property dbType into config + * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. + * @param dbType Indicates the dbType {@link Rdb_DBType} of the database + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * {@link RDB_E_NOT_SUPPORTED} - The error code for not support db types. + * @since 14 + */ +int OH_Rdb_SetDbType(OH_Rdb_ConfigV2 *config, int dbType); + +/** + * @brief Get support db type list + * @param typeCount The output parameter, which is used to recieve the length of the support db type array. + * @return Return Rdb_DBType array contains supported db type, array length is number of support type + * @since 14 + */ +const int *OH_Rdb_GetSupportedDbType(int *typeCount); + /** * @brief Creates an {@link OH_VObject} instance. * @@ -200,6 +367,24 @@ OH_Predicates *OH_Rdb_CreatePredicates(const char *table); */ OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode); +/** + * @brief Obtains an RDB store with OH_Rdb_ConfigV2. + * + * You can set parameters of the RDB store as required. In general, + * this method is recommended to obtain a rdb store. + * + * @param config Represents a pointer to an {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @param errCode This parameter is the output parameter, + * and the execution status of a function is written to this variable. + * @return If the creation is successful, a pointer to the instance of the @link OH_Rdb_Store} structure is returned. + * If the Config is empty, config.size does not match, or errCode is empty. + * Get database path failed.Get RDB Store fail. Nullptr is returned. + * @see OH_Rdb_ConfigV2, OH_Rdb_Store. + * @since 14 + */ +OH_Rdb_Store *OH_Rdb_CreateOrOpen(const OH_Rdb_ConfigV2 *config, int *errCode); + /** * @brief Close the {@link OH_Rdb_Store} object and reclaim the memory occupied by the object. * @@ -227,6 +412,20 @@ int OH_Rdb_CloseStore(OH_Rdb_Store *store); */ int OH_Rdb_DeleteStore(const OH_Rdb_Config *config); +/** + * @brief Deletes the database with a specified path. + * + * @param config Represents a pointer to an {@link OH_Rdb_ConfigV2} instance. + * Indicates the configuration of the database related to this RDB store. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * while failure returns a specific error code. Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_ErrCode. + * @since 14 + */ +int OH_Rdb_DeleteStoreV2(const OH_Rdb_ConfigV2 *config); + /** * @brief Inserts a row of data into the target table. * @@ -301,6 +500,21 @@ OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const ch */ int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql); +/** + * @brief Write operations are performed using the specified transaction represented by the transaction ID + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param trxId The transaction ID of the specified transaction, must be greater than 0 + * @param sql Indicates the SQL statement to execute. + * @return Returns the status code of the execution. + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * {@link RDB_E_NOT_SUPPORTED} - The error code for not supprt. + * @see OH_Rdb_Store. + * @since 14 + */ +int OH_Rdb_ExecuteByTrxId(OH_Rdb_Store *store, int64_t trxId, const char *sql); + /** * @brief Queries data in the database based on an SQL statement. * @@ -349,6 +563,48 @@ int OH_Rdb_RollBack(OH_Rdb_Store *store); */ int OH_Rdb_Commit(OH_Rdb_Store *store); +/** + * @brief Begin a transaction and the transaction ID corresponding to the transaction. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param trxId The output parameter, which is used to receive the transaction ID corresponding to the transaction + * @return Returns the status code of the execution. + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * {@link RDB_E_NOT_SUPPORTED} - The error code for not supprt. + * @see OH_Rdb_Store. + * @since 14 + */ +int OH_Rdb_BeginTransWithTrxId(OH_Rdb_Store *store, int64_t *trxId); + +/** + * @brief Roll back a transaction that is represented by a specified transaction ID + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param trxId The transaction ID of the specified transaction, must be greater than 0 + * @return Returns the status code of the execution. + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * {@link RDB_E_NOT_SUPPORTED} - The error code for not supprt. + * @see OH_Rdb_Store. + * @since 14 + */ +int OH_Rdb_RollBackByTrxId(OH_Rdb_Store *store, int64_t trxId); + +/** + * @brief Commit a transaction that is represented by a specified transaction ID + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param trxId The transaction ID of the specified transaction, must be greater than 0 + * @return Returns the status code of the execution. + * {@link RDB_OK} - success. + * {@link RDB_E_INVALID_ARGS} - The error code for common invalid args. + * {@link RDB_E_NOT_SUPPORTED} - The error code for not supprt. + * @see OH_Rdb_Store. + * @since 14 + */ +int OH_Rdb_CommitByTrxId(OH_Rdb_Store *store, int64_t trxId); + /** * @brief Backs up a database on specified path. * @@ -856,7 +1112,7 @@ typedef struct Rdb_ProgressDetails { * @param progress Represents a pointer to an {@link Rdb_ProgressDetails} instance. * @param version Indicates the version of current {@link Rdb_ProgressDetails}. * @return If the operation is successful, a pointer to the instance of the {@link Rdb_TableDetails} - * structure is returned.If get details is failed,nullptr is returned. + * structure is returned.If get details is failed, nullptr is returned. * @see Rdb_ProgressDetails * @see Rdb_TableDetails * @since 11 diff --git a/distributeddatamgr/relational_store/libnative_rdb.ndk.json b/distributeddatamgr/relational_store/libnative_rdb.ndk.json index 68882bc8a4cce6cbbbe52a5a8d4e8b2aea318418..5e068186572195d21f1a7863fa18a8ec89d38577 100644 --- a/distributeddatamgr/relational_store/libnative_rdb.ndk.json +++ b/distributeddatamgr/relational_store/libnative_rdb.ndk.json @@ -2,18 +2,86 @@ {"name":"OH_Rdb_CreatePredicates" }, {"name":"OH_Rdb_CreateValueObject" }, {"name":"OH_Rdb_CreateValuesBucket" }, + { + "first_introduced":"14", + "name":"OH_Rdb_CreateConfig" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetDatabaseDir" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetStoreName" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetBundleName" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetModuleName" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetEncrypted" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetSecurityLevel" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetArea" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_SetDbType" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_GetSupportedDbType" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_DestroyConfig" + }, {"name":"OH_Rdb_GetOrOpen" }, + { + "first_introduced": "14", + "name":"OH_Rdb_CreateOrOpen" + }, {"name":"OH_Rdb_CloseStore" }, {"name":"OH_Rdb_DeleteStore" }, + { + "first_introduced": "14", + "name":"OH_Rdb_DeleteStoreV2" + }, {"name":"OH_Rdb_Insert" }, {"name":"OH_Rdb_Update" }, {"name":"OH_Rdb_Delete" }, {"name":"OH_Rdb_Query" }, {"name":"OH_Rdb_Execute" }, + { + "first_introduced": "14", + "name":"OH_Rdb_ExecuteByTrxId" + }, {"name":"OH_Rdb_ExecuteQuery" }, {"name":"OH_Rdb_BeginTransaction" }, {"name":"OH_Rdb_RollBack" }, {"name":"OH_Rdb_Commit" }, + { + "first_introduced": "14", + "name":"OH_Rdb_BeginTransWithTrxId" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_RollBackByTrxId" + }, + { + "first_introduced": "14", + "name":"OH_Rdb_CommitByTrxId" + }, {"name":"OH_Rdb_Backup" }, {"name":"OH_Rdb_Restore"}, {"name":"OH_Rdb_GetVersion"}, diff --git a/distributeddatamgr/udmf/include/udmf.h b/distributeddatamgr/udmf/include/udmf.h index 6304de3e70739ac658b42c6ae41506bc017d2f1d..d8d7149e52ec66c7abbaeffcb6014f84114a669e 100644 --- a/distributeddatamgr/udmf/include/udmf.h +++ b/distributeddatamgr/udmf/include/udmf.h @@ -104,6 +104,13 @@ typedef struct OH_UdmfData OH_UdmfData; */ typedef struct OH_UdmfRecord OH_UdmfRecord; +/** + * @brief Defines the data provider. + * + * @since 13 + */ +typedef struct OH_UdmfRecordProvider OH_UdmfRecordProvider; + /** * @brief Describes some property parameters of unified data. * @@ -179,6 +186,62 @@ char** OH_UdmfData_GetTypes(OH_UdmfData* pThis, unsigned int* count); */ OH_UdmfRecord** OH_UdmfData_GetRecords(OH_UdmfData* pThis, unsigned int* count); +/** + * @brief Defines the callback function used free the context. + * @param context Pointer to the context which is to be free. + * @since 13 + */ +typedef void (*UdmfData_Finalize)(void* context); + +/** + * @brief Creates an {@link OH_UdmfRecordProvider} instance. + * + * @return Returns the pointer to the {@link OH_UdmfRecordProvider} instance created if the operation is successful. + * Returns nullptr if the memory is not enough. + * @see OH_UdmfRecordProvider. + * @since 13 + */ +OH_UdmfRecordProvider* OH_UdmfRecordProvider_Create(); + +/** + * @brief Destroy an {@link OH_UdmfRecordProvider} instance. + * + * @param subscriber Pointer to the {@link OH_UdmfRecordProvider} instance to destroy. + * @return Returns the status code of the execution. For details, see {@link Udmf_ErrCode}. + * Returns {@link UDMF_E_OK} if the operation is successful. + * Returns {@link UDMF_E_INVALID_PARAM} if invalid args are detected. + * @see OH_UdmfRecordProvider Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecordProvider_Destroy(OH_UdmfRecordProvider* provider); + +/** + * @brief Defines a callback function used to obtain data by type. + * + * @param context Pointer to the context set by {@link OH_UdmfRecordProvider_SetData}. + * @param type Pointer to the type of data to obtain. For details, see {@link udmf_meta.h}. + * @return Returns the data content. + * @since 13 + */ +typedef void* (*OH_UdmfRecordProvider_GetData)(void* context, const char* type); + +/** + * @brief Sets a callback function to obtain data. + * + * @param provider Pointer to the {@link OH_UdmfRecordProvider} instance. + * @param context Pointer to the context set, which is the first parameter in OH_UdmfRecordProvider_GetData. + * @param callback Callback to set. For details, see {@link OH_UdmfRecordProvider_GetData}. + * @param finalize Optional callback that can free context when destroy provider. + * For details, see {@link UdmfData_Finalize}. + * @return Returns the status code of the execution. For details, see {@link Udmf_ErrCode}. + * Returns {@link UDMF_E_OK} if the operation is successful. + * Returns {@link UDMF_E_INVALID_PARAM} if invalid args are detected. + * @see OH_UdmfRecordProvider OH_UdmfRecordProvider_GetData UdmfData_Finalize Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecordProvider_SetData(OH_UdmfRecordProvider* provider, void* context, + const OH_UdmfRecordProvider_GetData callback, const UdmfData_Finalize finalize); + /** * @brief Creation a pointer to the instance of the {@link OH_UdmfRecord}, it's relate with UDS data. * @@ -255,7 +318,7 @@ int OH_UdmfRecord_AddHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html); /** * @brief Add one {OH_UdsAppItem} data to the {@link OH_UdmfRecord} record. * - * @param repThisord Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. * @param appItem Represents a pointer to an instance of {@link OH_UdsAppItem}. * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. * {@link UDMF_E_OK} success. @@ -265,6 +328,59 @@ int OH_UdmfRecord_AddHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html); */ int OH_UdmfRecord_AddAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem); +/** + * @brief Add one {OH_UdsFileUri} data to the {@link OH_UdmfRecord} record. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecord_AddFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri); + +/** + * @brief Add one {OH_UdsPixelMap} data to the {@link OH_UdmfRecord} record. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecord_AddPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap); + +/** + * @brief Add one {@link OH_UdsArrayBuffer} data to the {@link OH_UdmfRecord} record. + * + * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param type Represents record type, reference udmf_meta.h. + * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecord_AddArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer); + +/** + * @brief Add one {@link OH_UdsContentForm} data to the {@link OH_UdmfRecord} record. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param contentForm Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsContentForm Udmf_ErrCode. + * @since 14 + */ +int OH_UdmfRecord_AddContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm); + /** * @brief Get all types in the {@link OH_UdmfRecord} record. * @@ -350,6 +466,134 @@ int OH_UdmfRecord_GetHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html); */ int OH_UdmfRecord_GetAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem); +/** + * @brief Set the data provider of the types. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param types Represents a pointer to a group of data types; + * @param count Represents the number of data types; + * @param provider Represents a pointer an instance of {@link OH_UdmfRecordProvider}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdmfRecordProvider Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecord_SetProvider(OH_UdmfRecord* pThis, const char* const* types, unsigned int count, + OH_UdmfRecordProvider* provider); + +/** + * @brief Get one {OH_UdsFileUri} data from the {@link OH_UdmfRecord} record. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecord_GetFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri); + +/** + * @brief Get one {OH_UdsPixelMap} data from the {@link OH_UdmfRecord} record. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecord_GetPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap); + +/** + * @brief Get one {@link OH_UdsArrayBuffer} data from the {@link OH_UdmfRecord} record. + * + * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param type Represents record type, reference udmf_meta.h. + * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfRecord_GetArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer); + +/** + * @brief Get one {@link OH_UdsContentForm} data from the {@link OH_UdmfRecord} record. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. + * @param contentForm Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfRecord OH_UdsContentForm Udmf_ErrCode. + * @since 14 + */ +int OH_UdmfRecord_GetContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm); + +/** + * @brief Get primary {@link OH_UdsPlainText} data from the {@link OH_UdmfData}. + * + * @param data Represents a pointer to an instance of {@link OH_UdmfData}. + * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfData OH_UdsPlainText Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfData_GetPrimaryPlainText(OH_UdmfData* data, OH_UdsPlainText* plainText); + +/** + * @brief Get one {@link OH_UdsHtml} data from the {@link OH_UdmfData}. + * + * @param data Represents a pointer to an instance of {@link OH_UdmfData}. + * @param html Represents a pointer to an instance of {@link OH_UdsHtml}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfData OH_UdsHtml Udmf_ErrCode. + * @since 13 + */ +int OH_UdmfData_GetPrimaryHtml(OH_UdmfData* data, OH_UdsHtml* html); + +/** + * @brief Get the count of {@link OH_UdmfRecord} in the {@link OH_UdmfData}. + * + * @param data Represents a pointer to an instance of {@link OH_UdmfData}. + * @return Returns the count of {@link OH_UdmfRecord} + * @see OH_UdmfData. + * @since 13 + */ +int OH_UdmfData_GetRecordCount(OH_UdmfData* data); + +/** + * @brief Get the record of the specified index from the {@link OH_UdmfData}. + * + * @param data Represents a pointer to an instance of {@link OH_UdmfData}. + * @param index Represents the index of {@link OH_UdmfRecord} in the {@link OH_UdmfData}. + * @return Returns {@link OH_UdmfRecord} pointer when input parameters valid, otherwise return nullptr. + * @see OH_UdmfData. + * @since 13 + */ +OH_UdmfRecord* OH_UdmfData_GetRecord(OH_UdmfData* data, unsigned int index); + +/** + * @brief Checks whether the UDMF data is from a local device. + * + * @param data Represents a pointer to an instance of {@link OH_UdmfData}. + * @return Returns a boolean value, which indicates whether the UDMF data is from a local device. + * The value {@code true} means the data is from a local device. + * The value {@code false} means the opposite. + * @see OH_UdmfData. + * @since 13 + */ +bool OH_UdmfData_IsLocal(OH_UdmfData* data); + /** * @brief Creation a pointer to the instance of the {@link OH_UdmfProperty} * from a {@link OH_UdmfData} data. diff --git a/distributeddatamgr/udmf/include/udmf_meta.h b/distributeddatamgr/udmf/include/udmf_meta.h index 17990eebc4e7184cd16704dafc1f7b2e586f2663..cfe651a89e0d3fc20011f09f7d617abaa6b69929 100644 --- a/distributeddatamgr/udmf/include/udmf_meta.h +++ b/distributeddatamgr/udmf/include/udmf_meta.h @@ -990,6 +990,20 @@ extern "C" { */ #define UDMF_META_OPENHARMONY_WANT "openharmony.want" +/** + * @brief A specific type of uniform data type. + * + * @since 13 + */ +#define UDMF_META_GENERAL_FILE_URI "general.file-uri" + +/** + * @brief A specific type of uniform data type. + * + * @since 14 + */ +#define UDMF_METE_GENERAL_CONTENT_FORM "general.content-form" + #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/udmf/include/uds.h b/distributeddatamgr/udmf/include/uds.h index 54c122b22f69ad83fdebb49646dd520a55a724bf..e7450a53a8ccad49019dd22ccd9f6913b16f14aa 100644 --- a/distributeddatamgr/udmf/include/uds.h +++ b/distributeddatamgr/udmf/include/uds.h @@ -40,7 +40,10 @@ #ifndef UDS_H #define UDS_H +#include "multimedia/image_framework/image/pixelmap_native.h" + #ifdef __cplusplus + extern "C" { #endif @@ -72,6 +75,34 @@ typedef struct OH_UdsHtml OH_UdsHtml; */ typedef struct OH_UdsAppItem OH_UdsAppItem; +/** + * @brief Describes the unified data struct of file uri. + * + * @since 13 + */ +typedef struct OH_UdsFileUri OH_UdsFileUri; + +/** + * @brief Describes the unified data struct of open harmony pixel map. + * + * @since 13 + */ +typedef struct OH_UdsPixelMap OH_UdsPixelMap; + +/** + * @brief Describes the unified data struct of content form. + * + * @since 14 + */ +typedef struct OH_UdsContentForm OH_UdsContentForm; + +/** + * @brief Describes the unified data struct of array buffer. + * + * @since 13 + */ +typedef struct OH_UdsArrayBuffer OH_UdsArrayBuffer; + /** * @brief Creation a pointer to the instance of the {@link OH_UdsPlainText}. * @@ -464,6 +495,362 @@ int OH_UdsAppItem_SetBundleName(OH_UdsAppItem* pThis, const char* bundleName); */ int OH_UdsAppItem_SetAbilityName(OH_UdsAppItem* pThis, const char* abilityName); +/** + * @brief Creation a pointer to the instance of the {@link OH_UdsFileUri}. + * + * @return If the operation is successful, a pointer to the instance of the {@link OH_UdsFileUri} + * structure is returned. If the memory is not enough, nullptr is returned. + * @see OH_UdsFileUri + * @since 13 + */ +OH_UdsFileUri* OH_UdsFileUri_Create(); + +/** + * @brief Destroy a pointer that points to the {@link OH_UdsFileUri} instance. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @see OH_UdsFileUri + * @since 13 + */ +void OH_UdsFileUri_Destroy(OH_UdsFileUri* pThis); + +/** + * @brief Get type id from the {@link OH_UdsFileUri}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsFileUri + * @since 13 + */ +const char* OH_UdsFileUri_GetType(OH_UdsFileUri* pThis); + +/** + * @brief Get file uri from the {@link OH_UdsFileUri}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsFileUri + * @since 13 + */ +const char* OH_UdsFileUri_GetFileUri(OH_UdsFileUri* pThis); + +/** + * @brief Get file type from the {@link OH_UdsFileUri}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsFileUri + * @since 13 + */ +const char* OH_UdsFileUri_GetFileType(OH_UdsFileUri* pThis); + +/** + * @brief Set file uri to the {@link OH_UdsFileUri}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @param fileUri Represents a new file uri string. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsFileUri Udmf_ErrCode + * @since 13 + */ +int OH_UdsFileUri_SetFileUri(OH_UdsFileUri* pThis, const char* fileUri); + +/** + * @brief Set file type to the {@link OH_UdsFileUri}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsFileUri}. + * @param fileType Represents a new file type string. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsFileUri Udmf_ErrCode + * @since 13 + */ +int OH_UdsFileUri_SetFileType(OH_UdsFileUri* pThis, const char* fileType); + +/** + * @brief Creation a pointer to the instance of the {@link OH_UdsPixelMap}. + * + * @return If the operation is successful, a pointer to the instance of the {@link OH_UdsPixelMap} + * structure is returned. If the memory is not enough, nullptr is returned. + * @see OH_UdsPixelMap + * @since 13 + */ +OH_UdsPixelMap* OH_UdsPixelMap_Create(); + +/** + * @brief Destroy a pointer that points to the {@link OH_UdsPixelMap} instance. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsPixelMap}. + * @see OH_UdsPixelMap + * @since 13 + */ +void OH_UdsPixelMap_Destroy(OH_UdsPixelMap* pThis); + +/** + * @brief Get type id from the {@link OH_UdsPixelMap}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsPixelMap}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsPixelMap + * @since 13 + */ +const char* OH_UdsPixelMap_GetType(OH_UdsPixelMap* pThis); + +/** + * @brief Get pixel map from the {@link OH_UdsPixelMap}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsPixelMap}. + * @param pixelmapNative Represents output params of {@link OH_PixelmapNative}. + * @see OH_UdsPixelMap + * @since 13 + */ +void OH_UdsPixelMap_GetPixelMap(OH_UdsPixelMap* pThis, OH_PixelmapNative* pixelmapNative); + +/** + * @brief Set pixel map to the {@link OH_UdsPixelMap}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsPixelMap}. + * @param pixelmapNative Represents a new {@link OH_PixelmapNative}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsPixelMap Udmf_ErrCode + * @since 13 + */ +int OH_UdsPixelMap_SetPixelMap(OH_UdsPixelMap* pThis, OH_PixelmapNative* pixelmapNative); + +/** + * @brief Creation a pointer to the instance of the {@link OH_UdsArrayBuffer}. + * + * @return If the operation is successful, a pointer to the instance of the {@link OH_UdsArrayBuffer} + * structure is returned. If the memory is not enough, nullptr is returned. + * @see OH_UdsArrayBuffer + * @since 13 + */ +OH_UdsArrayBuffer* OH_UdsArrayBuffer_Create(); + +/** + * @brief Destroy a pointer that points to the {@link OH_UdsArrayBuffer} instance. + * + * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsArrayBuffer Udmf_ErrCode + * @since 13 + */ +int OH_UdsArrayBuffer_Destroy(OH_UdsArrayBuffer* buffer); + +/** + * @brief Set array buffer data to the {@link OH_UdsArrayBuffer}. + * + * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. + * @param data Represents the array buffer data. + * @param len Represents the length of data param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsArrayBuffer Udmf_ErrCode + * @since 13 + */ +int OH_UdsArrayBuffer_SetData(OH_UdsArrayBuffer* buffer, unsigned char* data, unsigned int len); + +/** + * @brief Get array buffer data from the {@link OH_UdsArrayBuffer}. + * + * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. + * @param data Represents a pointer to array buffer data that is a output param. + * @param len Represents the array buffer data length that is a output param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsArrayBuffer Udmf_ErrCode + * @since 13 + */ +int OH_UdsArrayBuffer_GetData(OH_UdsArrayBuffer* buffer, unsigned char** data, unsigned int* len); + +/** + * @brief Creation a pointer to the instance of the {@link OH_UdsContentForm}. + * + * @return If the operation is successful, a pointer to the instance of the {@link OH_UdsContentForm} + * structure is returned. If the operation is failed, nullptr is returned. + * @see OH_UdsContentForm + * @since 14 + */ +OH_UdsContentForm* OH_UdsContentForm_Create(); + +/** + * @brief Destroy a pointer that points to the {@link OH_UdsContentForm} instance. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @see OH_UdsContentForm + * @since 14 + */ +void OH_UdsContentForm_Destroy(OH_UdsContentForm* pThis); + +/** + * @brief Get type id from the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsContentForm + * @since 14 + */ +const char* OH_UdsContentForm_GetType(OH_UdsContentForm* pThis); + +/** + * @brief Get thumb data from the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param thumbData Represents a pointer to thumb data that is a output param. + * @param len Represents the thumb data length that is a output param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * {@link UDMF_ERR} Internal data error. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_GetThumbData(OH_UdsContentForm* pThis, unsigned char** thumbData, unsigned int* len); + +/** + * @brief Get description from the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsContentForm + * @since 14 + */ +const char* OH_UdsContentForm_GetDescription(OH_UdsContentForm* pThis); + +/** + * @brief Get title from the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsContentForm + * @since 14 + */ +const char* OH_UdsContentForm_GetTitle(OH_UdsContentForm* pThis); + +/** + * @brief Get thumb data from the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param appIcon Represents a pointer to app icon that is a output param. + * @param len Represents the app icon length that is a output param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * {@link UDMF_ERR} Internal data error. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_GetAppIcon(OH_UdsContentForm* pThis, unsigned char** appIcon, unsigned int* len); + +/** + * @brief Get app name from the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsContentForm + * @since 14 + */ +const char* OH_UdsContentForm_GetAppName(OH_UdsContentForm* pThis); + +/** + * @brief Get link url from the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdsContentForm + * @since 14 + */ +const char* OH_UdsContentForm_GetLinkUri(OH_UdsContentForm* pThis); + +/** + * @brief Set thumb data to the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param thumbData Represents the thumb data. + * @param len Represents the length of thumb data param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_SetThumbData(OH_UdsContentForm* pThis, const unsigned char* thumbData, unsigned int len); + +/** + * @brief Set description to the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param description Represents a description string. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_SetDescription(OH_UdsContentForm* pThis, const char* description); + +/** + * @brief Set title to the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param title Represents a title string. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_SetTitle(OH_UdsContentForm* pThis, const char* title); + +/** + * @brief Set thumb data to the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param appIcon Represents the app icon. + * @param len Represents the length of app icon param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_SetAppIcon(OH_UdsContentForm* pThis, const unsigned char* appIcon, unsigned int len); + +/** + * @brief Set app name to the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param appName Represents a app name string. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_SetAppName(OH_UdsContentForm* pThis, const char* appName); + +/** + * @brief Set link uri to the {@link OH_UdsContentForm}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdsContentForm}. + * @param linkUri Represents a link uri string. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdsContentForm Udmf_ErrCode + * @since 14 + */ +int OH_UdsContentForm_SetLinkUri(OH_UdsContentForm* pThis, const char* linkUri); + #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/udmf/libudmf.ndk.json b/distributeddatamgr/udmf/libudmf.ndk.json index 6011e71c0e23c5b8eede9c16492b47bea98872fe..0cef8921c368b3926479b0bc64347539a4bcd7a3 100644 --- a/distributeddatamgr/udmf/libudmf.ndk.json +++ b/distributeddatamgr/udmf/libudmf.ndk.json @@ -334,5 +334,197 @@ { "first_introduced": "12", "name": "OH_Udmf_SetUnifiedData" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecordProvider_Create" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecordProvider_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecordProvider_SetData" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecord_AddFileUri" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecord_AddPixelMap" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecord_AddArrayBuffer" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecord_SetProvider" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecord_GetFileUri" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecord_GetPixelMap" + }, + { + "first_introduced": "13", + "name": "OH_UdmfRecord_GetArrayBuffer" + }, + { + "first_introduced": "13", + "name": "OH_UdmfData_GetPrimaryPlainText" + }, + { + "first_introduced": "13", + "name": "OH_UdmfData_GetPrimaryHtml" + }, + { + "first_introduced": "13", + "name": "OH_UdmfData_GetRecordCount" + }, + { + "first_introduced": "13", + "name": "OH_UdmfData_GetRecord" + }, + { + "first_introduced": "13", + "name": "OH_UdmfData_IsLocal" + }, + { + "first_introduced": "13", + "name": "OH_UdsFileUri_Create" + }, + { + "first_introduced": "13", + "name": "OH_UdsFileUri_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_UdsFileUri_GetType" + }, + { + "first_introduced": "13", + "name": "OH_UdsFileUri_GetFileUri" + }, + { + "first_introduced": "13", + "name": "OH_UdsFileUri_GetFileType" + }, + { + "first_introduced": "13", + "name": "OH_UdsFileUri_SetFileUri" + }, + { + "first_introduced": "13", + "name": "OH_UdsFileUri_SetFileType" + }, + { + "first_introduced": "13", + "name": "OH_UdsPixelMap_Create" + }, + { + "first_introduced": "13", + "name": "OH_UdsPixelMap_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_UdsPixelMap_GetType" + }, + { + "first_introduced": "13", + "name": "OH_UdsPixelMap_GetPixelMap" + }, + { + "first_introduced": "13", + "name": "OH_UdsPixelMap_SetPixelMap" + }, + { + "first_introduced": "13", + "name": "OH_UdsArrayBuffer_Create" + }, + { + "first_introduced": "13", + "name": "OH_UdsArrayBuffer_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_UdsArrayBuffer_SetData" + }, + { + "first_introduced": "13", + "name": "OH_UdsArrayBuffer_GetData" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_Create" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_Destroy" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_GetType" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_GetThumbData" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_GetDescription" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_GetTitle" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_GetAppIcon" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_GetAppName" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_GetLinkUri" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_SetThumbData" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_SetDescription" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_SetTitle" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_SetAppIcon" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_SetAppName" + }, + { + "first_introduced": "14", + "name": "OH_UdsContentForm_SetLinkUri" + }, + { + "first_introduced": "14", + "name": "OH_UdmfRecord_AddContentForm" + }, + { + "first_introduced": "14", + "name": "OH_UdmfRecord_GetContentForm" } ] \ No newline at end of file diff --git a/docs/howto_add.md b/docs/howto_add.md index aeb70e52f19aa2f6dbc805da4043d39b1939ef6f..9ff64faba0bd5a711add61ccfc5c753d92813b78 100644 --- a/docs/howto_add.md +++ b/docs/howto_add.md @@ -17,7 +17,7 @@ GN语法,https://zhuanlan.zhihu.com/p/136954435 ``` ./build.sh --product-name ohos-sdk ``` -更加详细的SDK编译指导,请参考[如何编译full-SDK](http://https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-compile-guide.md)。 +更加详细的SDK编译指导,请参考[如何编译full-SDK](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-compile-guide.md)。 ## 编译结果 @@ -113,6 +113,22 @@ sources = [ 这个模板只针对mac/win/linux平台的几个工具链,一般开发同学使用不到。 输入参数含义同ohos_ndk_headers。ohos_ndk_toolchains目标的默认dest_dir为$root_out_dir/sdk-native/sysroot/usr/lib +## 添加到build系统 + +上面添加的目标需要加到build的[ndk依赖目标](https://gitee.com/openharmony/build/blob/master/ohos/ndk/ndk_targets.gni)文件的_ndk_library_targets变量里面,这样在编译 +SDK的时候,才会被依赖到。 + +新增如下 +``` +_ndk_library_targets = [ + "//interface/sdk_c/sensors/miscdevice/vibrator:lib_vibrator_ndk", + "//interface/sdk_c/sensors/miscdevice/vibrator:ndk_vibrator_header", + ... + "//interface/sdk_c/sensors/sensor:libsensor_ndk", + "//interface/sdk_c/sensors/sensor:sensor_ndk_header", +] +``` + ## 文档 C API的文档生成在docs目录,需要安装doxygen工具,在ubuntu上使用`sudo apt-get install doxygen`即可安装。如果编译机上没有安装doxygen,文档将无法生成。 diff --git a/drivers/external_device_manager/base/ddk_api.h b/drivers/external_device_manager/base/ddk_api.h index 41d69c7b66d838f6c8c0ce6ef0d7d65b04da25a4..b5eb3005bd9191a208db204f7f813eb06de551bb 100644 --- a/drivers/external_device_manager/base/ddk_api.h +++ b/drivers/external_device_manager/base/ddk_api.h @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef DDK_API_H -#define DDK_API_H /** * @addtogroup Ddk @@ -36,6 +34,9 @@ * @since 12 */ +#ifndef DDK_API_H +#define DDK_API_H + #include #include "ddk_types.h" diff --git a/drivers/external_device_manager/base/ddk_types.h b/drivers/external_device_manager/base/ddk_types.h index e9e352c873b67aa0e4d70dc5ec86796fde82cbb1..b136513677027efe9fceb7d6ac3be863394f382e 100644 --- a/drivers/external_device_manager/base/ddk_types.h +++ b/drivers/external_device_manager/base/ddk_types.h @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef DDK_TYPES_H -#define DDK_TYPES_H /** * @addtogroup Ddk @@ -36,6 +34,9 @@ * @since 12 */ +#ifndef DDK_TYPES_H +#define DDK_TYPES_H + #include #include diff --git a/drivers/external_device_manager/hid/hid_ddk_api.h b/drivers/external_device_manager/hid/hid_ddk_api.h index b5d535a107598c9e7f6f793d9d0ce2b8a2c0c326..ac9336efd4a1098c94eb41a9469c6449aa412cfb 100644 --- a/drivers/external_device_manager/hid/hid_ddk_api.h +++ b/drivers/external_device_manager/hid/hid_ddk_api.h @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef HID_DDK_API_H -#define HID_DDK_API_H /** * @addtogroup HidDdk @@ -32,11 +30,16 @@ * @brief Declares the HID DDK interfaces for the host to access an input device. * * @kit DriverDevelopmentKit + * @library libhid.z.so + * @syscap SystemCapability.Driver.HID.Extension * File to include: * @since 11 * @version 1.0 */ +#ifndef HID_DDK_API_H +#define HID_DDK_API_H + #include #include "hid_ddk_types.h" @@ -100,7 +103,7 @@ int32_t OH_Hid_EmitEvent(int32_t deviceId, const Hid_EmitItem items[], uint16_t * @version 1.0 */ int32_t OH_Hid_DestroyDevice(int32_t deviceId); - +/** @} */ #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/drivers/external_device_manager/hid/hid_ddk_types.h b/drivers/external_device_manager/hid/hid_ddk_types.h index 4feaf5f5593e9ab44aa9bd5012f376b83c19a519..1029fbb12cf907ed78fc74dc36a1cfe6ced0ddcf 100644 --- a/drivers/external_device_manager/hid/hid_ddk_types.h +++ b/drivers/external_device_manager/hid/hid_ddk_types.h @@ -13,8 +13,6 @@ * limitations under the License. */ -#ifndef HID_DDK_TYPES_H -#define HID_DDK_TYPES_H /** * @addtogroup HidDdk * @{ @@ -33,10 +31,15 @@ * @brief Provides definitions of enum variables and structs in the HID DDK. * * File to include: + * @library libhid.z.so + * @syscap SystemCapability.Driver.HID.Extension * @since 11 * @version 1.0 */ +#ifndef HID_DDK_TYPES_H +#define HID_DDK_TYPES_H + #include #ifdef __cplusplus diff --git a/drivers/external_device_manager/usb/usb_ddk_api.h b/drivers/external_device_manager/usb/usb_ddk_api.h index d43aa52d75f273710cf91db472fa402d5e0cf064..90ff08e69e6bd68e6d07879c76a876eb6fc8fbf3 100644 --- a/drivers/external_device_manager/usb/usb_ddk_api.h +++ b/drivers/external_device_manager/usb/usb_ddk_api.h @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef USB_DDK_API_H -#define USB_DDK_API_H /** * @addtogroup UsbDdk @@ -33,10 +31,16 @@ * * @brief Declares the USB DDK APIs used by the USB host to access USB devices. * + * @kit DriverDevelopmentKit + * @library libusb_ndk.z.so + * @syscap SystemCapability.Driver.USB.Extension * @since 10 * @version 1.0 */ +#ifndef USB_DDK_API_H +#define USB_DDK_API_H + #include #include "ddk_types.h" diff --git a/drivers/external_device_manager/usb/usb_ddk_types.h b/drivers/external_device_manager/usb/usb_ddk_types.h index 6385308af0def4120aabfeecb32fd3e7a26088e7..602baba11bddfd9ccfd23a44fb34e028cb07cfb3 100644 --- a/drivers/external_device_manager/usb/usb_ddk_types.h +++ b/drivers/external_device_manager/usb/usb_ddk_types.h @@ -13,8 +13,6 @@ * limitations under the License. */ -#ifndef USB_DDK_TYPES_H -#define USB_DDK_TYPES_H /** * @addtogroup UsbDdk * @{ @@ -33,10 +31,16 @@ * * @brief Provides the enumerated variables, structures, and macros used in USB DDK APIs. * + * @kit DriverDevelopmentKit + * @library libusb_ndk.z.so + * @syscap SystemCapability.Driver.USB.Extension * @since 10 * @version 1.0 */ +#ifndef USB_DDK_TYPES_H +#define USB_DDK_TYPES_H + #include #include diff --git a/filemanagement/file_uri/include/oh_file_uri.h b/filemanagement/file_uri/include/oh_file_uri.h index 799cb6eea738c762ca95fe4a50cd50f4fc92ce16..dde24336d1afa1b68ff5d630c6daa2dac80ff1f2 100644 --- a/filemanagement/file_uri/include/oh_file_uri.h +++ b/filemanagement/file_uri/include/oh_file_uri.h @@ -13,21 +13,35 @@ * limitations under the License. */ -#ifndef FILE_MANAGEMENT_OH_FILE_URI_H -#define FILE_MANAGEMENT_OH_FILE_URI_H +/** + * @addtogroup fileUri + * @{ + * + * @brief This module provides URI format validation and URI conversion processing, + * as well as obtaining URI-related information + * + * @since 12 + */ /** * @file oh_file_uri.h * @kit CoreFileKit * * @brief uri verification and conversion + * This class is mainly for URI format verification and URI conversion processing; + * The conversion and operation of the media library type URI is not supported, + * and the class only converts according to the existing specifications, + * and there is no guarantee that the conversion result will actually exist. * @library libohfileuri.so * @syscap SystemCapability.FileManagement.AppFileService * @since 12 */ +#ifndef FILE_MANAGEMENT_OH_FILE_URI_H +#define FILE_MANAGEMENT_OH_FILE_URI_H + #include "error_code.h" -#include "stdbool.h" +#include #include #include #ifdef __cplusplus @@ -93,7 +107,24 @@ FileManagement_ErrCode OH_FileUri_GetFullDirectoryUri(const char *uri, unsigned * @since 12 */ bool OH_FileUri_IsValidUri(const char *uri, unsigned int length); + +/** +* @brief Gets the fileName From uri. +* This function obtains that the last segment of the URI string is the return value of the function, +* and the URI of the media type is not supported +* @param uri Input a pointer to the uri string. +* @param length The length of the input uri. +* @param result Output a pointer to a FileName string. Please use free() to clear the resource. +* @return Returns the status code of the execution. +* {@link ERR_PARAMS} 401 - Invalid input parameter. +* {@link ERR_ENOMEM} 13900011 - Failed to apply for memory or failed to copy memory. +* {@link ERR_OK} 0 - This operation was successfully executed. +* @syscap SystemCapability.FileManagement.AppFileService +* @since 13 + */ +FileManagement_ErrCode OH_FileUri_GetFileName(const char *uri, unsigned int length, char **result); #ifdef __cplusplus }; #endif +/** @} */ #endif // FILE_MANAGEMENT_OH_FILE_URI_H diff --git a/filemanagement/file_uri/liboh_file_uri.ndk.json b/filemanagement/file_uri/liboh_file_uri.ndk.json index 776c160a844e043392cb6a6d33d84b72bccfcac1..d17efcd7a88cd6634ea7d1386c839c25529a977c 100644 --- a/filemanagement/file_uri/liboh_file_uri.ndk.json +++ b/filemanagement/file_uri/liboh_file_uri.ndk.json @@ -13,5 +13,9 @@ { "first_introduced": "12", "name":"OH_FileUri_IsValidUri" + }, + { + "first_introduced": "13", + "name":"OH_FileUri_GetFileName" } ] \ No newline at end of file diff --git a/filemanagement/fileshare/include/oh_file_share.h b/filemanagement/fileshare/include/oh_file_share.h index d37dbb98d967eeb7b85554868c9e986532a88fbe..fc89f08edd9afabcc857ff04d60957f4fbb25a3a 100644 --- a/filemanagement/fileshare/include/oh_file_share.h +++ b/filemanagement/fileshare/include/oh_file_share.h @@ -13,11 +13,6 @@ * limitations under the License. */ -#ifndef FILE_MANAGEMENT_OH_FILE_SHARE_H -#define FILE_MANAGEMENT_OH_FILE_SHARE_H - -#include "error_code.h" - /** * @addtogroup fileShare * @{ @@ -37,6 +32,13 @@ * @syscap SystemCapability.FileManagement.AppFileService.FolderAuthorization * @since 12 */ + +#ifndef FILE_MANAGEMENT_OH_FILE_SHARE_H +#define FILE_MANAGEMENT_OH_FILE_SHARE_H + +#include "error_code.h" +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/global/resource_management/libnative_resmgr.ndk.json b/global/resource_management/libnative_resmgr.ndk.json index 039fbcaa74a600a7425f3ef96dc81bbe1d054323..dcb320f422601685fedcaf4d6563333549dda9dc 100644 --- a/global/resource_management/libnative_resmgr.ndk.json +++ b/global/resource_management/libnative_resmgr.ndk.json @@ -50,5 +50,93 @@ { "first_introduced": "12", "name": "OH_ResourceManager_GetLocalesData" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetSymbol" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetSymbolByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetLocales" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetConfiguration" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_ReleaseConfiguration" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetString" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetStringByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetStringArray" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetStringArrayByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_ReleaseStringArray" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetPluralString" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetPluralStringByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetColor" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetColorByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetInt" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetIntByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetFloat" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetFloatByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetBool" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_GetBoolByName" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_AddResource" + }, + { + "first_introduced": "12", + "name": "OH_ResourceManager_RemoveResource" } ] \ No newline at end of file diff --git a/global/resource_management/librawfile.ndk.json b/global/resource_management/librawfile.ndk.json index 31739dc49ae893359e74e97343b5febec5163069..d81c3da5c6ca49cc1010a28f7297111614f92d1c 100644 --- a/global/resource_management/librawfile.ndk.json +++ b/global/resource_management/librawfile.ndk.json @@ -75,94 +75,6 @@ "first_introduced": "12", "name": "OH_ResourceManager_IsRawDir" }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetSymbol" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetSymbolByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetLocales" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetConfiguration" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_ReleaseConfiguration" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetString" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetStringByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetStringArray" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetStringArrayByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_ReleaseStringArray" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetPluralString" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetPluralStringByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetColor" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetColorByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetInt" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetIntByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetFloat" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetFloatByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetBool" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_GetBoolByName" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_AddResource" - }, - { - "first_introduced": "12", - "name": "OH_ResourceManager_RemoveResource" - }, { "first_introduced": "12", "name": "OH_ResourceManager_GetRawFileDescriptorData" diff --git a/graphic/graphic_2d/native_buffer/buffer_common.h b/graphic/graphic_2d/native_buffer/buffer_common.h index fd1bfa4a5a61e90172f1e55c41b395c3e9770030..d67646240969ae66153afc1dcc5a2dcb1eaec1fe 100644 --- a/graphic/graphic_2d/native_buffer/buffer_common.h +++ b/graphic/graphic_2d/native_buffer/buffer_common.h @@ -138,7 +138,12 @@ typedef enum OH_NativeBuffer_MetadataType { /** HDR10 */ OH_VIDEO_HDR_HDR10, /** HDR VIVID */ - OH_VIDEO_HDR_VIVID + OH_VIDEO_HDR_VIVID, + /** + * NONE Metadata + * @since 13 + */ + OH_VIDEO_NONE = -1 } OH_NativeBuffer_MetadataType; /** diff --git a/graphic/graphic_2d/native_buffer/native_buffer.h b/graphic/graphic_2d/native_buffer/native_buffer.h index fca0fc9a296f8a3c8f61b59b601cbf09992affa7..154df76d3ea589a746fdd175691561d2b24969e2 100644 --- a/graphic/graphic_2d/native_buffer/native_buffer.h +++ b/graphic/graphic_2d/native_buffer/native_buffer.h @@ -287,7 +287,10 @@ typedef struct { /** * @brief Alloc a OH_NativeBuffer that matches the passed BufferRequestConfig. \n - * A new OH_NativeBuffer instance is created each time this function is called. + * A new OH_NativeBuffer instance is created each time this function is called.\n + * This interface needs to be used in conjunction with OH_NativeBuffer_Unreference<\b>, + * otherwise memory leaks will occur.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param config Indicates the pointer to a BufferRequestConfig instance. @@ -299,7 +302,10 @@ typedef struct { OH_NativeBuffer* OH_NativeBuffer_Alloc(const OH_NativeBuffer_Config* config); /** - * @brief Adds the reference count of a OH_NativeBuffer. + * @brief Adds the reference count of a OH_NativeBuffer.\n + * This interface needs to be used in conjunction with OH_NativeBuffer_Unreference<\b>, + * otherwise memory leaks will occur.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -310,8 +316,9 @@ OH_NativeBuffer* OH_NativeBuffer_Alloc(const OH_NativeBuffer_Config* config); int32_t OH_NativeBuffer_Reference(OH_NativeBuffer *buffer); /** - * @brief Decreases the reference count of a OH_NativeBuffer and, when the reference count reaches 0, \n - * destroys this OH_NativeBuffer. + * @brief Decreases the reference count of a OH_NativeBuffer and, when the reference count reaches 0, + * destroys this OH_NativeBuffer.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -322,7 +329,8 @@ int32_t OH_NativeBuffer_Reference(OH_NativeBuffer *buffer); int32_t OH_NativeBuffer_Unreference(OH_NativeBuffer *buffer); /** - * @brief Return a config of the OH_NativeBuffer in the passed OHNativeBufferConfig struct. + * @brief Return a config of the OH_NativeBuffer in the passed OHNativeBufferConfig struct.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -334,7 +342,9 @@ int32_t OH_NativeBuffer_Unreference(OH_NativeBuffer *buffer); void OH_NativeBuffer_GetConfig(OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config); /** - * @brief Provide direct cpu access to the OH_NativeBuffer in the process's address space. + * @brief Provide direct cpu access to the OH_NativeBuffer in the process's address space.\n + * This interface needs to be used in conjunction with OH_NativeBuffer_Unmap<\b>.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -347,7 +357,8 @@ void OH_NativeBuffer_GetConfig(OH_NativeBuffer *buffer, OH_NativeBuffer_Config* int32_t OH_NativeBuffer_Map(OH_NativeBuffer *buffer, void **virAddr); /** - * @brief Remove direct cpu access ability of the OH_NativeBuffer in the process's address space. + * @brief Remove direct cpu access ability of the OH_NativeBuffer in the process's address space.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -358,7 +369,8 @@ int32_t OH_NativeBuffer_Map(OH_NativeBuffer *buffer, void **virAddr); int32_t OH_NativeBuffer_Unmap(OH_NativeBuffer *buffer); /** - * @brief Get the systen wide unique sequence number of the OH_NativeBuffer. + * @brief Get the systen wide unique sequence number of the OH_NativeBuffer.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -369,7 +381,8 @@ int32_t OH_NativeBuffer_Unmap(OH_NativeBuffer *buffer); uint32_t OH_NativeBuffer_GetSeqNum(OH_NativeBuffer *buffer); /** - * @brief Provide direct cpu access to the potentially multi-plannar OH_NativeBuffer in the process's address space. + * @brief Provide direct cpu access to the potentially multi-plannar OH_NativeBuffer in the process's address space.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -382,7 +395,8 @@ uint32_t OH_NativeBuffer_GetSeqNum(OH_NativeBuffer *buffer); int32_t OH_NativeBuffer_MapPlanes(OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes); /** - * @brief Converts an OHNativeWindowBuffer instance to an OH_NativeBuffer. + * @brief Converts an OHNativeWindowBuffer instance to an OH_NativeBuffer.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param nativeWindowBuffer Indicates the pointer to a OHNativeWindowBuffer instance. @@ -394,7 +408,8 @@ int32_t OH_NativeBuffer_MapPlanes(OH_NativeBuffer *buffer, void **virAddr, OH_Na int32_t OH_NativeBuffer_FromNativeWindowBuffer(OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer); /** - * @brief Set the color space of the OH_NativeBuffer. + * @brief Set the color space of the OH_NativeBuffer.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -406,7 +421,8 @@ int32_t OH_NativeBuffer_FromNativeWindowBuffer(OHNativeWindowBuffer *nativeWindo int32_t OH_NativeBuffer_SetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace); /** - * @brief Get the color space of the OH_NativeBuffer. + * @brief Get the color space of the OH_NativeBuffer.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -420,7 +436,8 @@ int32_t OH_NativeBuffer_SetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_C int32_t OH_NativeBuffer_GetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace); /** - * @brief Set the metadata type of the OH_NativeBuffer. + * @brief Set the metadata type of the OH_NativeBuffer.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. @@ -438,7 +455,8 @@ int32_t OH_NativeBuffer_SetMetadataValue(OH_NativeBuffer *buffer, OH_NativeBuffe int32_t size, uint8_t *metadata); /** - * @brief Set the metadata type of the OH_NativeBuffer. + * @brief Set the metadata type of the OH_NativeBuffer.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer * @param buffer Indicates the pointer to a OH_NativeBuffer instance. diff --git a/graphic/graphic_2d/native_color_space_manager/BUILD.gn b/graphic/graphic_2d/native_color_space_manager/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9c88300e6e162ee74db15676d08809d1816afb29 --- /dev/null +++ b/graphic/graphic_2d/native_color_space_manager/BUILD.gn @@ -0,0 +1,29 @@ +# 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("native_color_space_manager_header") { + dest_dir = "$ndk_headers_out_dir/native_color_space_manager" + sources = [ "./native_color_space_manager.h" ] +} + +ohos_ndk_library("libnative_color_space_manager_ndk") { + output_name = "native_color_space_manager" + output_extension = "so" + ndk_description_file = "./libnative_color_space_manager.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.ColorManager.Core" + system_capability_headers = + [ "native_color_space_manager/native_color_space_manager.h" ] +} diff --git a/graphic/graphic_2d/native_color_space_manager/libnative_color_space_manager.ndk.json b/graphic/graphic_2d/native_color_space_manager/libnative_color_space_manager.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..2dc8c437213bb8553869eaab7ab10ec354de2753 --- /dev/null +++ b/graphic/graphic_2d/native_color_space_manager/libnative_color_space_manager.ndk.json @@ -0,0 +1,26 @@ +[ + { + "first_introduced": "13", + "name": "OH_NativeColorSpaceManager_CreateFromName" + }, + { + "first_introduced": "13", + "name": "OH_NativeColorSpaceManager_CreateFromPrimariesAndGamma" + }, + { + "first_introduced": "13", + "name": "OH_NativeColorSpaceManager_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_NativeColorSpaceManager_GetColorSpaceName" + }, + { + "first_introduced": "13", + "name": "OH_NativeColorSpaceManager_GetWhitePoint" + }, + { + "first_introduced": "13", + "name": "OH_NativeColorSpaceManager_GetGamma" + } +] \ No newline at end of file diff --git a/graphic/graphic_2d/native_color_space_manager/native_color_space_manager.h b/graphic/graphic_2d/native_color_space_manager/native_color_space_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..a2528fcb9d824f3b7d7cd1075225abfdd926903b --- /dev/null +++ b/graphic/graphic_2d/native_color_space_manager/native_color_space_manager.h @@ -0,0 +1,231 @@ +/* + * 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 NativeColorSpaceManager + * @{ + * + * @brief Provides the native colorSpaceManager capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @since 13 + * @version 1.0 + */ + +/** + * @file native_color_space_manager.h + * + * @brief Defines the functions for obtaining and using a native colorSpaceManager. + * + * @kit ArkGraphics2D + * @library libnative_color_space_manager.so + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @since 13 + * @version 1.0 + */ +#ifndef C_INCLUDE_NATIVE_COLOR_SPACE_MANAGER_H_ +#define C_INCLUDE_NATIVE_COLOR_SPACE_MANAGER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines a colorspace manager. + * @since 13 + */ +typedef struct OH_NativeColorSpaceManager OH_NativeColorSpaceManager; + +/** + * @brief Enumerates color space types. + * @since 13 + */ +typedef enum { + /** Indicates an unknown color space. */ + NONE = 0, + /** Indicates the color space based on Adobe RGB. */ + ADOBE_RGB = 1, + /** Indicates the color space based on SMPTE RP 431-2-2007 and IEC 61966-2.1:1999. */ + DCI_P3 = 2, + /** Indicates the color space based on SMPTE RP 431-2-2007 and IEC 61966-2.1:1999. */ + DISPLAY_P3 = 3, + /** Indicates the standard red green blue (SRGB) color space based on IEC 61966-2.1:1999. */ + SRGB = 4, + /** Indicates the color space based on ITU-R BT.709. */ + BT709 = 6, + /** Indicates the color space based on ITU-R BT.601. */ + BT601_EBU = 7, + /** Indicates the color space based on ITU-R BT.601. */ + BT601_SMPTE_C = 8, + /** Indicates the color space based on ITU-R BT.2020. */ + BT2020_HLG = 9, + /** Indicates the color space based on ITU-R BT.2020. */ + BT2020_PQ = 10, + /** PRIMARIES_P3_D65 | TRANSFUNC_HLG | RANGE_FULL */ + P3_HLG = 11, + /** PRIMARIES_P3_D65 | TRANSFUNC_PQ | RANGE_FULL */ + P3_PQ = 12, + /** PRIMARIES_ADOBE_RGB | TRANSFUNC_ADOBE_RGB | RANGE_LIMIT */ + ADOBE_RGB_LIMIT = 13, + /** PRIMARIES_P3_D65 | TRANSFUNC_SRGB | RANGE_LIMIT */ + DISPLAY_P3_LIMIT = 14, + /** PRIMARIES_SRGB | TRANSFUNC_SRGB | RANGE_LIMIT */ + SRGB_LIMIT = 15, + /** PRIMARIES_BT709 | TRANSFUNC_BT709 | RANGE_LIMIT */ + BT709_LIMIT = 16, + /** PRIMARIES_BT601_P | TRANSFUNC_BT709 | RANGE_LIMIT */ + BT601_EBU_LIMIT = 17, + /** PRIMARIES_BT601_N | TRANSFUNC_BT709 | RANGE_LIMIT */ + BT601_SMPTE_C_LIMIT = 18, + /** PRIMARIES_BT2020 | TRANSFUNC_HLG | RANGE_LIMIT */ + BT2020_HLG_LIMIT = 19, + /** PRIMARIES_BT2020 | TRANSFUNC_PQ | RANGE_LIMIT */ + BT2020_PQ_LIMIT = 20, + /** PRIMARIES_P3_D65 | TRANSFUNC_HLG | RANGE_LIMIT */ + P3_HLG_LIMIT = 21, + /** PRIMARIES_P3_D65 | TRANSFUNC_PQ | RANGE_LIMIT */ + P3_PQ_LIMIT = 22, + /** PRIMARIES_P3_D65 | TRANSFUNC_LINEAR */ + LINEAR_P3 = 23, + /** PRIMARIES_SRGB | TRANSFUNC_LINEAR */ + LINEAR_SRGB = 24, + /** PRIMARIES_BT709 | TRANSFUNC_LINEAR */ + LINEAR_BT709 = LINEAR_SRGB, + /** PRIMARIES_BT2020 | TRANSFUNC_LINEAR */ + LINEAR_BT2020 = 25, + /** PRIMARIES_SRGB | TRANSFUNC_SRGB | RANGE_FULL */ + DISPLAY_SRGB = SRGB, + /** PRIMARIES_P3_D65 | TRANSFUNC_SRGB | RANGE_FULL */ + DISPLAY_P3_SRGB = DISPLAY_P3, + /** PRIMARIES_P3_D65 | TRANSFUNC_HLG | RANGE_FULL */ + DISPLAY_P3_HLG = P3_HLG, + /** PRIMARIES_DISPLAY_P3 | TRANSFUNC_PQ | RANGE_FULL */ + DISPLAY_P3_PQ = P3_PQ, + /** Indicates a customized color space. */ + CUSTOM = 5, +} ColorSpaceName; + +/** + * @brief Describes the primary colors red, green, blue and white point coordinated as (x, y) + * in color space, in terms of real world chromaticities. + * @since 13 + */ +typedef struct { + /** Coordinate value x of red color */ + float rX; + /** Coordinate value y of red color */ + float rY; + /** Coordinate value x of green color */ + float gX; + /** Coordinate value y of green color */ + float gY; + /** Coordinate value x of blue color */ + float bX; + /** Coordinate value y of blue color */ + float bY; + /** Coordinate value x of white point */ + float wX; + /** Coordinate value y of white point */ + float wY; +} ColorSpacePrimaries; + +/** + * @brief Indicates white point coordinated as (x, y) return array. + * @since 13 + */ +typedef struct { + /** Indicates white point return array */ + float arr[2]; +} WhitePointArray; + +/** + * @brief Creates a NativeColorSpaceManager instance by colorSpaceName. + * A new NativeColorSpaceManager instance is created each time this function is called. + * + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @param colorSpaceName Indicates the NativeColorSpace connection name. + * @return Returns the pointer to the NativeColorSpaceManager instance created. + * Creation failed, cause memory shortage. + * @since 13 + * @version 1.0 + */ +OH_NativeColorSpaceManager* OH_NativeColorSpaceManager_CreateFromName(ColorSpaceName colorSpaceName); + +/** + * @brief Creates a NativeColorSpaceManager instance by primaries and gamma. + * A new NativeColorSpaceManager instance is created each time this function is called. + * + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @param primaries Indicates the NativeColorSpace connection primaries. + * @param gamma Indicates the NativeColorSpace connection gamma. + * @return Returns the pointer to the NativeColorSpaceManager instance created. + * Creation failed, cause memory shortage. + * @since 13 + * @version 1.0 + */ +OH_NativeColorSpaceManager* OH_NativeColorSpaceManager_CreateFromPrimariesAndGamma( + ColorSpacePrimaries primaries, float gamma); + +/** + * @brief Delete the NativeColorSpaceManager instance. + * + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @param nativeColorSpaceManager Indicates the pointer to a NativeColorSpaceManager instance. + * @since 13 + * @version 1.0 + */ +void OH_NativeColorSpaceManager_Destroy(OH_NativeColorSpaceManager* nativeColorSpaceManager); + +/** + * @brief Get colorSpace name. + * + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @param nativeColorSpaceManager Indicates the pointer to a NativeColorSpaceManager instance. + * @return Returns value, return value > 0 && value <= 25, success, return value == 0 , failed. + * @since 13 + * @version 1.0 + */ +int OH_NativeColorSpaceManager_GetColorSpaceName( + OH_NativeColorSpaceManager* nativeColorSpaceManager); + +/** + * @brief Get white point. + * + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @param nativeColorSpaceManager Indicates the pointer to a NativeColorSpaceManager instance. + * @return Returns float array, return array = <0.f, 0.f>, failed, otherwise, true. + * @since 13 + * @version 1.0 + */ +WhitePointArray OH_NativeColorSpaceManager_GetWhitePoint( + OH_NativeColorSpaceManager* nativeColorSpaceManager); + +/** + * @brief Get gamma. + * + * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core + * @param nativeColorSpaceManager Indicates the pointer to a NativeColorSpaceManager instance. + * @return Returns float, return value == 0.f, failed, otherwise, true. + * @since 13 + * @version 1.0 + */ +float OH_NativeColorSpaceManager_GetGamma(OH_NativeColorSpaceManager* nativeColorSpaceManager); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif \ No newline at end of file diff --git a/graphic/graphic_2d/native_display_soloist/native_display_soloist.h b/graphic/graphic_2d/native_display_soloist/native_display_soloist.h index 3f1311f3e25fc6a27262b0bcd49304859e6b310e..abbda4fdefc2d61ab483d52a51a5d854c87d217f 100644 --- a/graphic/graphic_2d/native_display_soloist/native_display_soloist.h +++ b/graphic/graphic_2d/native_display_soloist/native_display_soloist.h @@ -39,6 +39,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { #endif diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index fa8656ce602ccb00e10ab6b31e2f470ad1b93fa6..88c0459bc9fd316e2be057729c6e97d9081011e3 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -39,6 +39,7 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pixel_map.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_point.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_record_cmd.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_rect.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_region.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_register_font.h", @@ -49,6 +50,10 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_surface.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_blob.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_declaration.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_line.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_run.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_typography.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_typeface.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_types.h", @@ -81,6 +86,7 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_pen.h", "native_drawing/drawing_pixel_map.h", "native_drawing/drawing_point.h", + "native_drawing/drawing_record_cmd.h", "native_drawing/drawing_rect.h", "native_drawing/drawing_region.h", "native_drawing/drawing_register_font.h", @@ -93,6 +99,10 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_surface.h", "native_drawing/drawing_text_blob.h", "native_drawing/drawing_text_declaration.h", + "native_drawing/drawing_text_font_descriptor.h", + "native_drawing/drawing_text_line.h", + "native_drawing/drawing_text_lineTypography.h", + "native_drawing/drawing_text_run.h", "native_drawing/drawing_text_typography.h", "native_drawing/drawing_typeface.h", "native_drawing/drawing_types.h", diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 4d1e8a0faf85206dfd434b47cfa6207628b4f5fd..f78e6127f9297b09d0a66a932d3fd2165787339b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -828,6 +828,19 @@ OH_Drawing_ErrorCode OH_Drawing_CanvasIsClipEmpty(OH_Drawing_Canvas* canvas, boo */ OH_Drawing_ErrorCode OH_Drawing_CanvasGetImageInfo(OH_Drawing_Canvas* canvas, OH_Drawing_Image_Info* imageInfo); +/** + * @brief Replay drawing command. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param recordCmd Indicates the pointer to an OH_Drawing_RecordCmd object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if canvas or recordCmd is nullptr. + * @since 13 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_CanvasDrawRecordCmd(OH_Drawing_Canvas* canvas, OH_Drawing_RecordCmd* recordCmd); #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_error_code.h b/graphic/graphic_2d/native_drawing/drawing_error_code.h index b9d52fc51f10fa9ebca557208ad331b06df80eb2..817c8c61467d0798907427364e08d674741e1637 100644 --- a/graphic/graphic_2d/native_drawing/drawing_error_code.h +++ b/graphic/graphic_2d/native_drawing/drawing_error_code.h @@ -65,6 +65,11 @@ typedef enum { * @error The parameter is not in the valid range. */ OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE = 26200001, + /** + * @error mem allocate failed. + * @since 13 + */ + OH_DRAWING_ERROR_ALLOCATION_FAILED = 26200002, } OH_Drawing_ErrorCode; /** diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 38ea644f359e53892c949eb6f499df748d079975..ca4eac99045eeaae76190ab8e1ab254facc87605 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -497,6 +497,60 @@ typedef struct OH_Drawing_Font_Metrics { */ float OH_Drawing_FontGetMetrics(OH_Drawing_Font*, OH_Drawing_Font_Metrics*); +/** + * @brief Retrieves the bound rect for each glyph in glyph array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param font Indicates the pointer to an OH_Drawing_Font object. + * @param glyphs Indicates the array of glyph indices to be measured. + * @param count Indicates the number of glyphs. + * @param bounds The bound rect array for each glyph, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, glyphs + * and bounds is nullptr or count is 0. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_FontGetBounds(const OH_Drawing_Font* font, const uint16_t* glyphs, uint32_t count, + OH_Drawing_Array* bounds); + +/** + * @brief Retrieves the path for specified Glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param font Indicates the pointer to an OH_Drawing_Font object. + * @param glyph glyph index to be obtained. + * @param path The path object, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, path + * is nullptr or glyph not exist. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_FontGetPathForGlyph(const OH_Drawing_Font* font, uint16_t glyph, + OH_Drawing_Path* path); + +/** + * @brief Get the text outline path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param font Indicates the pointer to an OH_Drawing_Font object. + * @param text Indicates the character storage encoded with text encoding. + * @param byteLength Indicates the text length in bytes. + * @param encoding OH_Drawing_TextEncoding Indicates the text encoding. + * @param x Indicates x coordinates of the text. + * @param y Indicates y coordinates of the text. + * @param path OH_Drawing_Path The path object, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, text or path is nullptr. + * @since 14 + */ +OH_Drawing_ErrorCode OH_Drawing_FontGetTextPath(const OH_Drawing_Font* font, const void* text, size_t byteLength, + OH_Drawing_TextEncoding encoding, float x, float y, OH_Drawing_Path* path); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_pixel_map.h b/graphic/graphic_2d/native_drawing/drawing_pixel_map.h index 668a915a0c05b6163eb14e34783082775d9cc2ee..ef29ce5b42a542cb6ab169201284adfba58fd86b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_pixel_map.h +++ b/graphic/graphic_2d/native_drawing/drawing_pixel_map.h @@ -51,14 +51,14 @@ extern "C" { * @since 12 * @version 1.0 */ -struct NativePixelMap_; +typedef struct NativePixelMap_ NativePixelMap_; /** * @brief Introduces the native pixel map information defined by image framework. * @since 12 * @version 1.0 */ -struct OH_PixelmapNative; +typedef struct OH_PixelmapNative OH_PixelmapNative; /** * @brief Gets an OH_Drawing_PixelMap object. diff --git a/graphic/graphic_2d/native_drawing/drawing_record_cmd.h b/graphic/graphic_2d/native_drawing/drawing_record_cmd.h new file mode 100644 index 0000000000000000000000000000000000000000..63c03f03b1d348ef47eb9d7af70e3385a27ebc39 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_record_cmd.h @@ -0,0 +1,123 @@ +/* + * 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. + */ + +#ifndef C_INCLUDE_DRAWING_RECORD_CMD_H +#define C_INCLUDE_DRAWING_RECORD_CMD_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 13 + * @version 1.0 + */ + +/** + * @file drawing_record_cmd.h + * + * @brief Declares functions related to the RecordCmd object in the drawing module. + * + * @library libnative_drawing.so + * @since 13 + * @version 1.0 + */ + +#include "drawing_types.h" +#include "drawing_error_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_RecordCmdUtils object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_RecordCmdUtils object created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_RecordCmdUtils* OH_Drawing_RecordCmdUtilsCreate(void); + +/** + * @brief Destroys an OH_Drawing_RecordCmdUtils object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param recordCmdUtils Indicates the pointer to an OH_Drawing_RecordCmdUtils object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if recordCmdUtils is nullptr. + * @since 13 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RecordCmdUtilsDestroy(OH_Drawing_RecordCmdUtils* recordCmdUtils); + +/** + * @brief Get the canvas that records the drawing command. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param recordCmdUtils Indicates the pointer to an OH_Drawing_RecordCmdUtils object. + * @param width Width of canvas object. + * @param height Height of canvas object. + * @param canvas Indicates a secondary pointer to an OH_Drawing_Canvasobject. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if recordCmdUtils or canvas is nullptr, + * width less than or equal to 0 or height less than or equal to 0. + * Returns {@link OH_DRAWING_ERROR_ALLOCATION_FAILED} if no memory. + * @since 13 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RecordCmdUtilsBeginRecording(OH_Drawing_RecordCmdUtils* recordCmdUtils, + int32_t width, int32_t height, OH_Drawing_Canvas** canvas); + +/** + * @brief Finish the recording and get the recording command object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param recordCmdUtils Indicates the pointer to an OH_Drawing_RecordCmdUtils object. + * @param recordCmd Indicates a secondary pointer to an OH_Drawing_RecordCmd object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if recordCmdUtils or recordCmd is nullptr. + * Returns {@link OH_DRAWING_ERROR_ALLOCATION_FAILED} if no memory. + * @since 13 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RecordCmdUtilsFinishRecording(OH_Drawing_RecordCmdUtils* recordCmdUtils, + OH_Drawing_RecordCmd** recordCmd); + +/** + * @brief Destroys an OH_Drawing_RecordCmd object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param recordCmd Indicates the pointer to an OH_Drawing_RecordCmd object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if recordCmd is nullptr. + * @since 13 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RecordCmdDestroy(OH_Drawing_RecordCmd* recordCmd); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/graphic/graphic_2d/native_drawing/drawing_rect.h b/graphic/graphic_2d/native_drawing/drawing_rect.h index e07abff68df1f0ac2cd19ec03a9dacac6565144f..d247e88f71502ebdfb0d2d2b03a4106768212004 100644 --- a/graphic/graphic_2d/native_drawing/drawing_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_rect.h @@ -214,6 +214,64 @@ void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst); */ void OH_Drawing_RectDestroy(OH_Drawing_Rect*); +/** + * @brief Creates an OH_Drawing_Array object, which is used to store multiple OH_Drawing_Rect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param size Indicates the size of the array object. + * @return Returns the pointer to the OH_Drawing_Array object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty, + * or size is invalid. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size); + +/** + * @brief Gets the size of an OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArray Indicates the array object. + * @param pSize Indicates the size pointer. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or pSize is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize); + +/** + * @brief Gets the specified OH_Drawing_Rect object from OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArray Indicates the array object. + * @param index Indicates the index of array, caller must make sure the index is valid. + * @param rect Pointers to Pointer of OH_Drawing_Rect object, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or rect is nullptr, + * or index is valid. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index, + OH_Drawing_Rect** rect); + +/** + * @brief Destroys an array OH_Drawing_Rect object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArray Indicates the pointer to an OH_Drawing_Array object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index 9a324c807a683863d649a9e7bc6ec5139a59f919..24ec0b3655896e0708d5961628d9a7210a560071 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h @@ -60,6 +60,14 @@ typedef struct OH_Drawing_FontCollection OH_Drawing_FontCollection; */ typedef struct OH_Drawing_Typography OH_Drawing_Typography; +/** + * @brief Defines an OH_Drawing_LineTypography, which is used to perform line layout. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_LineTypography OH_Drawing_LineTypography; + /** * @brief Defines an OH_Drawing_TextStyle, which is used to manage text colors and decorations. * @@ -125,6 +133,30 @@ typedef struct OH_Drawing_FontParser OH_Drawing_FontParser; */ typedef struct OH_Drawing_TextShadow OH_Drawing_TextShadow; +/** + * @brief Defines an OH_Drawing_TextTab, which is used to to store the tab alignment type and position. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_TextTab OH_Drawing_TextTab; + +/** + * @brief Defines an OH_Drawing_TextLine, which is used to manage text line. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_TextLine OH_Drawing_TextLine; + +/** + * @brief Defines an OH_Drawing_Run, which is used to manage run. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_Run OH_Drawing_Run; + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h new file mode 100644 index 0000000000000000000000000000000000000000..e6c2621077463ececd7aa61b03b9814f969456df --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2021-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 Drawing + * @{ + * + * @brief Provides the font descriptor capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 14 + * @version 1.0 + */ + +/** + * @file drawing_text_font_descriptor.h + * + * @brief Provide the ability to provide OH_Drawing_FontDescriptor. + * + * @kit ArkGraphics2D + * @library libnative_drawing.so + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @since 14 + * @version 1.0 + */ + +#ifndef DRAWING_TEXT_FONT_DESCRIPTOR_H +#define DRAWING_TEXT_FONT_DESCRIPTOR_H + +#include "drawing_text_typography.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief An enumeration of system font types. + * + * @since 14 + */ +typedef enum { + /** All font types */ + ALL = 1 << 0, + /** System generic font type */ + GENERIC = 1 << 1, + /** Stylish font type */ + STYLISH = 1 << 2, + /** Installed font types */ + INSTALLED = 1 << 3, +} OH_Drawing_SystemFontType; + +/** + * @brief Obtain all system font descriptive symbols that match the specified font descriptor. Where the 'path' + * fields are not considered as valid matching values, It takes effect when the remaining fields are not + * default values, If all the fields of the parameters OH_Drawing_FontDescriptor are default, obtain all system + * font descriptors. If the match fails, return nullptr. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontDescriptor The pointer to the OH_Drawing_FontDescriptor object. It is recommended to + * use OH_Drawing_CreateFontDescriptor to obtain a valid OH_Drawing_FontDescriptor instance. + * If you create your own OH_Drawing_FontDescriptor object, ensure that fields not intended for matching are + * set to their default values. + * @param size_t Indicates the count of obtained OH_Drawing_FontDescriptor. + * @return Returns an array of OH_Drawing_FontDescriptor. Released through the + * OH_Drawing_DestroyFontDescriptors interface after use. + * @since 14 + */ +OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescriptor*, size_t*); + +/** + * @brief Releases the OH_Drawing_FontDescriptor array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontDescriptor OH_Drawing_FontDescriptor object array. + * @param size_t Represents the number of members of the OH_Drawing_FontDescriptor array. + * @since 14 + */ +void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor*, size_t); + +/** + * @brief Get the OH_Drawing_FontDescriptor object by the font full name and the font type, supporting generic + * fonts, stylish fonts, and installed fonts. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_String Indicates the full name object OH_Drawing_String. + * @param OH_Drawing_SystemFontType Indicates enumerates of system font type object OH_Drawing_SystemFontType. + * @return Returns the pointer to a font descriptor object OH_Drawing_FontDescriptor. + * @since 14 + */ +OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String*, OH_Drawing_SystemFontType); + +/** + * @brief Obtain the corresponding font full name array by the font type. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_SystemFontType Indicates enumerates of system font type object OH_Drawing_SystemFontType. + * @return Returns the pointer to full name array object OH_Drawing_Array. + * @since 14 + */ +OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontType); + +/** + * @brief Get the specified full name object OH_Drawing_String by index from the + * OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates an array of full name object OH_Drawing_Array. + * @param size_t The index of full name. + * @return Returns a full name object OH_Drawing_String. + * @since 14 + */ +const OH_Drawing_String* OH_Drawing_GetSystemFontFullNameByIndex(OH_Drawing_Array*, size_t); + +/** + * @brief Releases the memory occupied by an array of font full names. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates an array of full name object OH_Drawing_Array. + * @since 14 + */ +void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/graphic/graphic_2d/native_drawing/drawing_text_line.h b/graphic/graphic_2d/native_drawing/drawing_text_line.h new file mode 100644 index 0000000000000000000000000000000000000000..760769b4b5fcaf8d84b01c358fa4480a7b4e50ac --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_line.h @@ -0,0 +1,276 @@ +/* + * 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 Drawing + * @{ + * + * @brief Provides the 2D drawing capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 14 + * @version 1.0 + */ + +/** + * @file drawing_text_line.h + * + * @brief Declares functions related to textLine in the drawing module. + * + * @since 14 + * @version 1.0 + */ + +#ifndef C_INCLUDE_DRAWING_TEXT_LINE_H +#define C_INCLUDE_DRAWING_TEXT_LINE_H + +#include "drawing_text_declaration.h" +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get text line information. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param typography Indicates the pointer to a typography object OH_Drawing_Typography. + * @return Indicates the pointer to a text line array object OH_Drawing_Array. + * @since 14 + */ +OH_Drawing_Array* OH_Drawing_TypographyGetTextLines(OH_Drawing_Typography* typography); + +/** + * @brief Releases the memory occupied by the text line array object OH_Drawing_Array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param lines Indicates the pointer to the text line array object OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyTextLines(OH_Drawing_Array* lines); + +/** + * @brief Releases the memory occupied by the text line object OH_Drawing_TextLine. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to the text line object OH_Drawing_TextLine. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyTextLine(OH_Drawing_TextLine* line); + +/** + * @brief Get the text line object by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param lines Indicates the pointer to the text line array object OH_Drawing_Array. + * @param index The text line object index. + * @return Indicates the pointer to a text line object OH_Drawing_TextLine. + * @since 14 + */ +OH_Drawing_TextLine* OH_Drawing_GetTextLineByIndex(OH_Drawing_Array* lines, size_t index); + +/** + * @brief Get the count of glyphs. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the count of glyphs. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetGlyphCount(OH_Drawing_TextLine* line); + +/** + * @brief Get the range of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param start Indicates the pointer to text line start position. + * @param end Indicates the pointer to text line end position. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_TextLineGetTextRange(OH_Drawing_TextLine* line, size_t* start, size_t* end); + +/** + * @brief Get the glyph runs array of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Indicates the pointer to a glyph runs array object of text line OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_TextLineGetGlyphRuns(OH_Drawing_TextLine* line); + +/** + * @brief Releases the memory occupied by the run array object OH_Drawing_Array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param runs Indicates the pointer to the run array object OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyRuns(OH_Drawing_Array* runs); + +/** + * @brief Get the run object by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param runs Indicates the pointer to the run array object OH_Drawing_Array. + * @param index The run object index. + * @return Indicates the pointer to a run object OH_Drawing_Run. + * @since 14 + */ +OH_Drawing_Run* OH_Drawing_GetRunByIndex(OH_Drawing_Array* runs, size_t index); + +/** + * @brief Paint the range of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param x Represents the X-axis position on the canvas. + * @param y Represents the Y-axis position on the canvas. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_TextLinePaint(OH_Drawing_TextLine* line, OH_Drawing_Canvas* canvas, double x, double y); + +/** + * @brief Creates a truncated text line object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param width Indicates the text line width to set. + * @param mode Indicates the ellipsis model to set, EllipsisMode:MIDDLE is not supported. + * For details, see the enum OH_Drawing_EllipsisModal. + * @param ellipsis Indicates the ellipsis string to set. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_TextLine* OH_Drawing_TextLineCreateTruncatedLine(OH_Drawing_TextLine* line, double width, int mode, + const char* ellipsis); + +/** + * @brief Gets the text line typographic bounds. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param ascent Indicates the distance that the pointer points to remain above the baseline. + * @param descent Indicates the pointer to the distance that remains below the baseline. + * @param leading Indicates the pointer to the line Spacing. + * @return Returns The total width of the typesetting border. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetTypographicBounds(OH_Drawing_TextLine* line, double* ascent, double* descent, + double* leading); + +/** + * @brief Gets the text line image bounds. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the pointer to the OH_Drawing_Rect struct created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_TextLineGetImageBounds(OH_Drawing_TextLine* line); + +/** + * @brief Gets the tail space width. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the tail space width. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetTrailingSpaceWidth(OH_Drawing_TextLine* line); + +/** + * @brief Gets the string index of the given position. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param point Indicates the pointer to an OH_Drawing_Point object. + * @return Returns the string index for a given position. + * @since 14 + */ +int32_t OH_Drawing_TextLineGetStringIndexForPosition(OH_Drawing_TextLine* line, OH_Drawing_Point* point); + +/** + * @brief Gets the offset of the given string index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param index The given string index. + * @return Returns the offset for a given string index. + * @since 14 + */ +double OH_Drawing_TextLineGetOffsetForStringIndex(OH_Drawing_TextLine* line, int32_t index); + +/** + * @brief User-defined callback functions for using offsets and indexes. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param offset Character offset is traversed as an argument to the callback function. + * @param index Character index is traversed as an argument to the callback function. + * @param leadingEdge Whether the current offset is at the character front, as an argument to the callback function. + * @return The return value of the user-defined callback function. + * If false is returned, the traversal continues. + * If true is returned, the traversal stops. + * @since 14 + * @version 1.0 + */ +typedef bool (*Drawing_CaretOffsetsCallback)(double offset, int32_t index, bool leadingEdge); + +/** + * @brief Enumerate caret offset and index in text lines. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param callback User-defined callback functions, see Drawing_CaretOffsetsCallback. + * @since 14 + */ +void OH_Drawing_TextLineEnumerateCaretOffsets(OH_Drawing_TextLine* line, Drawing_CaretOffsetsCallback callback); + +/** + * @brief Gets the text offset based on the given alignment factor and alignment width. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param alignmentFactor The coefficients that text needs to be aligned. + * Less than or equal to 0 is left justified, 0.5 is center justified, + * and greater than or equal to 1 is right justified. + * @param alignmentWidth The width of the text to be aligned. + * Returns 0 if it is less than the actual width of the text. + * @return Returns the offset of the aligned text. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetAlignmentOffset(OH_Drawing_TextLine* line, double alignmentFactor, double alignmentWidth); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // C_INCLUDE_DRAWING_TEXT_LINE_H \ No newline at end of file diff --git a/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h b/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h new file mode 100644 index 0000000000000000000000000000000000000000..6d20d529b1a95b3abe9724a5de249b75e8775f29 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved. + * 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 Drawing + * @{ + * + * @brief Provides the 2D drawing capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 14 + * @version 1.0 + */ + +/** + * @file drawing_text_linetypography.h + * + * @brief Declares functions related to lineTypography in the drawing module. + * + * @kit ArkGraphics2D + * @library libnative_drawing.so + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @since 14 + * @version 1.0 + */ + +#ifndef DRAWING_TEXT_LINETYPOGRAPHY_H +#define DRAWING_TEXT_LINETYPOGRAPHY_H + +#include "drawing_text_declaration.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_LineTypography object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyCreate Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @return Returns the pointer to the OH_Drawing_LineTypography object created. + * @since 14 + */ +OH_Drawing_LineTypography* OH_Drawing_CreateLineTypography(OH_Drawing_TypographyCreate* handler); + +/** + * @brief Releases the memory occupied by an OH_Drawing_LineTypography object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_LineTypography Indicates the pointer to an OH_Drawing_LineTypography object. + * @since 14 + */ +void OH_Drawing_DestroyLineTypography(OH_Drawing_LineTypography* lineTypography); + +/** + * @brief Calculate the line breakpoint based on the width provided. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyCreate Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @param startIndex Indicates the starting point for the line-break calculations. + * @param width Indicates the requested line-break width. + * @return Returns the count of the characters from startIndex that would cause the line break. + * @since 14 + */ +size_t OH_Drawing_LineTypographyGetLineBreak(OH_Drawing_LineTypography* lineTypography, + size_t startIndex, double width); + +/** + * @brief Creates a text line object based on the text range provided. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_LineTypography Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @param startIndex Indicates the starting index of the text range. + * @param count Indicates the characters count of the text range. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 14 + */ +OH_Drawing_TextLine* OH_Drawing_LineTypographyCreateLine(OH_Drawing_LineTypography* lineTypography, + size_t startIndex, size_t count); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_run.h b/graphic/graphic_2d/native_drawing/drawing_text_run.h new file mode 100644 index 0000000000000000000000000000000000000000..b71a197ddff579899f1b009c233e7a025a67f96a --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_run.h @@ -0,0 +1,212 @@ +/* + * 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 Drawing + * @{ + * + * @brief Provides the text run capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 14 + * @version 1.0 + */ + +/** + * @file drawing_text_run.h + * + * @brief Declares functions related to run in the drawing module. + * + * @since 14 + * @version 1.0 + */ + +#ifndef C_INCLUDE_DRAWING_TEXT_RUN_H +#define C_INCLUDE_DRAWING_TEXT_RUN_H + +#include "drawing_text_declaration.h" +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief Gets the run glyph indices ,the offset of the index relative to the entire paragraph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @param start The run of start index. + * @param length The run of length, if start and length are set to 0, then get all of the current run. + * @return Run of glyph indices array object OH_Drawing_Array. + * @since 14 + */ +OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, int64_t start, int64_t length); + +/** + * @brief Gets the run glyph indices by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param stringIndices the run glyph indices array object OH_Drawing_Array. + * @param index The run of glyph index. + * @return Run of glyph indices element. + * @since 14 + */ +uint64_t OH_Drawing_GetRunStringIndicesByIndex(OH_Drawing_Array* stringIndices, size_t index); + +/** + * @brief Releases the memory run glyph indices array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param stringIndices glyph indices array object OH_Drawing_Array. + * @since 14 + */ +void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* stringIndices); + +/** + * @brief Gets the range run glyph location and length. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @param location The run of glyph location. + * @param length The run of glyph length. + * @since 14 + */ +void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint64_t* location, uint64_t* length); + +/** + * @brief Gets the run typographic bound. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @param ascent The run of ascent. + * @param descent The run of descent. + * @param leading The run of leading. + * @return run typographic width. + * @since 14 + */ +float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, float* descent, float* leading); + +/** + * @brief Paints text on the canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @param x Indicates the x coordinate. + * @param y Indicates the y coordinate. + * @since 14 + */ +void OH_Drawing_RunPaint(OH_Drawing_Canvas* canvas, OH_Drawing_Run* run, double x, double y); + +/** + * @brief Gets the run image bound. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @return The run image bounds to an OH_Drawing_Rect object. + * @since 14 + */ +OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run); + + /** + * @brief Releases the memory run image bounds pointer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rect Run image bounds to an OH_Drawing_Rect object. + * @since 14 + */ +void OH_Drawing_DestroyRunImageBounds(OH_Drawing_Rect* rect); + +/** + * @brief Gets the range glyph identifier for each character. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @param start The run of start index. + * @param length The run of length, if start and length are set to 0, then get all of the current run. + * @return Run of glyph array object OH_Drawing_ArrayOH_Drawing_Array. + * @param index The run of glyph index. + * @return Run of glyph element. + * @since 14 + * @version 1.0 + */ +uint16_t OH_Drawing_GetRunGlyphsByIndex(OH_Drawing_Array* glyphs, size_t index); + +/** + * @brief Releases the memory run glyph array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param glyphs The run of glyph array object OH_Drawing_Array. + * @since 14 + */ +void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs); + +/** + * @brief Gets the range glyph position array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @param start The run of start index. + * @param length The run of length, if start and length are set to 0, then get all of the current run. + * @return Run of position array object OH_Drawing_Array. + * @since 14 + */ +OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, int64_t start, int64_t length); + +/** + * @brief Gets the glyph position by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param positions The run of position array object OH_Drawing_Array. + * @param index The run of glyph index. + * @return Run of glyph position pointer to an OH_Drawing_Point object. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Point* OH_Drawing_GetRunPositionsByIndex(OH_Drawing_Array* positions, size_t index); + +/** + * @brief Releases the memory run of position array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param positions The run of position array object OH_Drawing_Array. + * @since 14 + */ +void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions); + +/** + * @brief Gets the number of glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @return The number of glyph. + * @since 14 + */ +uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run); +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // C_INCLUDE_DRAWING_TEXT_RUN_H diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index d821c385580bc0c2fe13343d5bb52928b2a6adc0..da9f9a974c6361dac299cec58f539061dc90b675 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -734,6 +734,29 @@ void OH_Drawing_SetTextStyleBaseLine(OH_Drawing_TextStyle*, int /* OH_Drawing_Te */ void OH_Drawing_SetTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */); +/** + * @brief Add the text decoration. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param int Indicates the text decoration to add. For details, see the enum OH_Drawing_TextDecoration. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_AddTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */); + +/** + * @brief Remove the text decoration. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param int Indicates the text decoration to remove, shoud be match existing text decorations. + * For details, see the enum OH_Drawing_TextDecoration. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_RemoveTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */); + /** * @brief Sets the color for the text decoration. * @@ -1031,6 +1054,20 @@ double OH_Drawing_TypographyGetHeight(OH_Drawing_Typography*); */ double OH_Drawing_TypographyGetLongestLine(OH_Drawing_Typography*); +/** + * @brief Obtains the width of the longest line with indent. You are advised to + * round up the return value in actual use. When the text content is empty, the + * minimum float value, that is, 0.0, is returned. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by + * {@link OH_Drawing_CreateTypography}. + * @return Returns the width of the longest line with indent. + * @since 13 + * @version 1.1 + */ +double OH_Drawing_TypographyGetLongestLineWithIndent(OH_Drawing_Typography*); + /** * @brief Gets the min intrinsic width. * @@ -2753,6 +2790,78 @@ void OH_Drawing_TypographyDestroyTextBox(OH_Drawing_TextBox*); void OH_Drawing_SetTextShadow(OH_Drawing_TextShadow* shadow, uint32_t color, OH_Drawing_Point* offset, double blurRadius); +/** + * @brief Creates an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextAlign Indicates enumerates text tab alignment modes. TAB alignment, Support left alignment + * right alignment center alignment, other enumeration values are left alignment effect. + * @param float Indicates location of text tab. + * @return Returns the pointer to the OH_Drawing_TextTab object created. If the object returns NULL, + * the creation failed. The possible cause of the failure is that the application address space is used up. + * As a result, space cannot be allocated. + * @since 14 + * @version 1.0 + */ +OH_Drawing_TextTab* OH_Drawing_CreateTextTab(OH_Drawing_TextAlign alignment, float location); + +/** + * @brief Releases the memory occupied by an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyTextTab(OH_Drawing_TextTab*); + +/** + * @brief Get alignment of an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @return Returns align of an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +OH_Drawing_TextAlign OH_Drawing_GetTextTabAlignment(OH_Drawing_TextTab*); + +/** + * @brief Get location of an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @return Returns location of an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +float OH_Drawing_GetTextTabLocation(OH_Drawing_TextTab*); + +/** + * @brief Sets the text tab of OH_Drawing_TypographyStyle object. + * Tab alignment does not take effect when text alignment is also set, Or when the ellipsis style is configured. + * When the tab is not set or the tab's location property is less than or equal to 0, it is the default space effect. + * And all tabs in the paragraph after the setting are aligned according to this tab effect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_SetTypographyTextTab(OH_Drawing_TypographyStyle*, OH_Drawing_TextTab* TextTab); + +/** + * @brief Get DrawingArray size. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param drawingArray Indicates the pointer to the array object OH_Drawing_Array. + * @return Size of array. + * @since 14 + * @version 1.0 + */ +size_t OH_Drawing_GetDrawingArraySize(OH_Drawing_Array* drawingArray); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_typeface.h b/graphic/graphic_2d/native_drawing/drawing_typeface.h index 0208f5ff9e598d6b2ad5974ba001442e01caca72..fa3d016e98bf069bb4f1725181c220b38283bbb4 100644 --- a/graphic/graphic_2d/native_drawing/drawing_typeface.h +++ b/graphic/graphic_2d/native_drawing/drawing_typeface.h @@ -40,6 +40,7 @@ * @version 1.0 */ +#include "drawing_error_code.h" #include "drawing_types.h" #ifdef __cplusplus @@ -57,7 +58,7 @@ extern "C" { OH_Drawing_Typeface* OH_Drawing_TypefaceCreateDefault(void); /** - * @brief Creates a OH_Drawing_Typeface object by file. + * @brief Creates an OH_Drawing_Typeface object by file. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param path file path. @@ -69,7 +70,44 @@ OH_Drawing_Typeface* OH_Drawing_TypefaceCreateDefault(void); OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromFile(const char* path, int index); /** - * @brief Creates a OH_Drawing_Typeface object by given a stream. If the stream is not a valid + * @brief Creates an OH_Drawing_Typeface object with the specified font arguments from a file. + * If the OH_Drawing_Typeface object does not support the variations described in fontArguments, + * this function creates an OH_Drawing_Typeface object without font arguments. + * In this case, this function provides the same capability as {@link OH_Drawing_TypefaceCreateFromFile}. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path Indicates the file path. + * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object. + * @return Returns the pointer to the OH_Drawing_Typeface object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty, + * or either path or fontArguments is nullptr, or the path is invalid. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromFileWithArguments(const char* path, + const OH_Drawing_FontArguments* fontArguments); + +/** + * @brief Creates an OH_Drawing_Typeface object with the specified font arguments from + * an existing OH_Drawing_Typeface object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param current Indicates the existing OH_Drawing_Typeface object. + * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object. + * @return Returns the pointer to the OH_Drawing_Typeface object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty, + * or either current or fontArguments is nullptr, + * or current does not support the variations described in fontArguments. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromCurrent(const OH_Drawing_Typeface* current, + const OH_Drawing_FontArguments* fontArguments); + +/** + * @brief Creates an OH_Drawing_Typeface object by given a stream. If the stream is not a valid * font file, returns nullptr. Ownership of the stream is transferred, so the caller must not reference * it or free it again. * @@ -92,6 +130,48 @@ OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromStream(OH_Drawing_MemoryStream */ void OH_Drawing_TypefaceDestroy(OH_Drawing_Typeface*); +/** + * @brief Creates an OH_Drawing_FontArguments object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_FontArguments object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty. + * @since 13 + * @version 1.0 + */ +OH_Drawing_FontArguments* OH_Drawing_FontArgumentsCreate(void); + +/** + * @brief Adds a font variation axis for an OH_Drawing_FontArguments object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object. + * @param axis Indicates the axis tag, which must contain four ASCII characters. + * @param value Indicates the value of the axis field. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if either fontArguments or axis is nullptr, + * or the length of axis is not 4. + * @since 13 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_FontArgumentsAddVariation(OH_Drawing_FontArguments* fontArguments, + const char* axis, float value); + +/** + * @brief Destroys an OH_Drawing_FontArguments object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if fontArguments is nullptr. + * @since 13 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_FontArgumentsDestroy(OH_Drawing_FontArguments* fontArguments); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index edcc71cb8345836bc9647825ebc47b6d0ff63173..1a4d8499cd73f9d4b66ce11e42cb1665abbd88f0 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -40,8 +40,9 @@ * @version 1.0 */ -#include +#include #include +#include #ifdef __cplusplus extern "C" { @@ -239,6 +240,14 @@ typedef struct OH_Drawing_Font OH_Drawing_Font; */ typedef struct OH_Drawing_MemoryStream OH_Drawing_MemoryStream; +/** + * @brief Defines fontArguments, which is used to describe the arguments for a font. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_FontArguments OH_Drawing_FontArguments; + /** * @brief Defines a typeface, which is used to describe the typeface. * @@ -470,6 +479,19 @@ typedef struct { double leftBottomRadius; } OH_Drawing_RectStyle_Info; +/** + * @brief Defines the string information struct. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /** A pointer to a byte string containing UTF-16BE(Big Endian) encoded entities */ + uint8_t* strData; + /** The length of `strData` in bytes */ + uint32_t strLen; +} OH_Drawing_String; + /** * @brief Enumerates text encoding types. * @since 12 @@ -502,6 +524,29 @@ typedef struct OH_Drawing_FontMgr OH_Drawing_FontMgr; */ typedef struct OH_Drawing_FontStyleSet OH_Drawing_FontStyleSet; +/** + * @brief Define OH_Drawing_RecordCmdUtils, which is used to generate drawing commands tool. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_RecordCmdUtils OH_Drawing_RecordCmdUtils; + +/** + * @brief Define OH_Drawing_RecordCmd, which is used to replay drawing commands. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_RecordCmd OH_Drawing_RecordCmd; + +/** + * @brief Defines an array object, which is used to store multiple NDK object. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_Array OH_Drawing_Array; #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index f0d6835c1e41a25d9e5b1d28eff675a8e46fb7f0..353ce3f539771d30cdac90947de31c81c38d3c4d 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -176,6 +176,18 @@ }, { "name": "OH_Drawing_FilterSetMaskFilter" }, { "name": "OH_Drawing_FilterDestroy" }, + { + "first_introduced": "13", + "name": "OH_Drawing_FontArgumentsAddVariation" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_FontArgumentsCreate" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_FontArgumentsDestroy" + }, { "name": "OH_Drawing_FontCreate" }, { "name": "OH_Drawing_FontDestroy" }, { @@ -615,6 +627,14 @@ { "name": "OH_Drawing_SetTextStyleFontWeight" }, { "name": "OH_Drawing_SetTextStyleBaseLine" }, { "name": "OH_Drawing_SetTextStyleDecoration" }, + { + "first_introduced": "14", + "name": "OH_Drawing_AddTextStyleDecoration" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RemoveTextStyleDecoration" + }, { "name": "OH_Drawing_SetTextStyleDecorationColor" }, { "name": "OH_Drawing_SetTextStyleFontHeight" }, { "name": "OH_Drawing_SetTextStyleFontFamilies" }, @@ -680,7 +700,15 @@ { "name": "OH_Drawing_MemoryStreamCreate" }, { "name": "OH_Drawing_MemoryStreamDestroy" }, { "name": "OH_Drawing_TypefaceCreateDefault" }, + { + "first_introduced": "13", + "name": "OH_Drawing_TypefaceCreateFromCurrent" + }, { "name": "OH_Drawing_TypefaceCreateFromFile" }, + { + "first_introduced": "13", + "name": "OH_Drawing_TypefaceCreateFromFileWithArguments" + }, { "name": "OH_Drawing_TypefaceCreateFromStream" }, { "name": "OH_Drawing_TypefaceDestroy" }, { "name": "OH_Drawing_CreateTypographyHandler" }, @@ -699,6 +727,10 @@ { "name": "OH_Drawing_TypographyGetMaxWidth" }, { "name": "OH_Drawing_TypographyGetHeight" }, { "name": "OH_Drawing_TypographyGetLongestLine" }, + { + "first_introduced": "13", + "name": "OH_Drawing_TypographyGetLongestLineWithIndent" + }, { "name": "OH_Drawing_TypographyGetMinIntrinsicWidth" }, { "name": "OH_Drawing_TypographyGetMaxIntrinsicWidth" }, { "name": "OH_Drawing_TypographyGetAlphabeticBaseline" }, @@ -902,6 +934,14 @@ "first_introduced": "12", "name": "OH_Drawing_DestroyFontDescriptor" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatchFontDescriptors" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_DestroyFontDescriptors" + }, { "first_introduced": "12", "name": "OH_Drawing_CreateFontParser" @@ -910,6 +950,22 @@ "first_introduced": "12", "name": "OH_Drawing_DestroyFontParser" }, + { + "first_introduced": "14", + "name": "OH_Drawing_GetFontDescriptorByFullName" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_GetSystemFontFullNamesByType" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_GetSystemFontFullNameByIndex" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_DestroySystemFontFullNames" + }, { "first_introduced": "12", "name": "OH_Drawing_FontParserGetSystemFontList" @@ -1441,5 +1497,229 @@ { "first_introduced": "12", "name":"OH_Drawing_SetTextShadow" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_CanvasDrawRecordCmd" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RecordCmdUtilsCreate" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RecordCmdUtilsDestroy" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RecordCmdUtilsBeginRecording" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RecordCmdUtilsFinishRecording" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RecordCmdDestroy" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_CreateLineTypography" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_DestroyLineTypography" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_LineTypographyGetLineBreak" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_LineTypographyCreateLine" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_FontGetBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_FontGetPathForGlyph" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectCreateArray" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectGetArraySize" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectGetArrayElement" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectDestroyArray" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_CreateTextTab" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyTextTab" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetTextTabAlignment" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetTextTabLocation" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_SetTypographyTextTab" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_FontGetTextPath" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetDrawingArraySize" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TypographyGetTextLines" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyTextLines" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyTextLine" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetTextLineByIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetGlyphCount" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetTextRange" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetGlyphRuns" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRuns" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunByIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLinePaint" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineCreateTruncatedLine" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetTypographicBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetImageBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetTrailingSpaceWidth" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetStringIndexForPosition" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetOffsetForStringIndex" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_TextLineEnumerateCaretOffsets" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetAlignmentOffset" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunStringIndices" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunStringIndicesByIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunStringIndices" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunStringRange" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunTypographicBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RunPaint" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunImageBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunImageBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunGlyphs" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunGlyphsByIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunGlyphs" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunPositions" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunPositionsByIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunPositions" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunGlyphCount" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_image/libnative_image.ndk.json b/graphic/graphic_2d/native_image/libnative_image.ndk.json index c591bf0fd4313549f7db25d9257c799d48002116..1a8c6688deed4d6b3103e20d66bb88dafaee707b 100644 --- a/graphic/graphic_2d/native_image/libnative_image.ndk.json +++ b/graphic/graphic_2d/native_image/libnative_image.ndk.json @@ -18,5 +18,17 @@ { "first_introduced": "12", "name": "OH_NativeImage_ReleaseNativeWindowBuffer" + }, + { + "first_introduced": "12", + "name": "OH_ConsumerSurface_Create" + }, + { + "first_introduced": "13", + "name": "OH_ConsumerSurface_SetDefaultUsage" + }, + { + "first_introduced": "13", + "name": "OH_ConsumerSurface_SetDefaultSize" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_image/native_image.h b/graphic/graphic_2d/native_image/native_image.h index a1bbf51227e965dad3a2726a423590dbed7cfa12..25d33544165961542b1fcd4a92800be77c1ddc7a 100644 --- a/graphic/graphic_2d/native_image/native_image.h +++ b/graphic/graphic_2d/native_image/native_image.h @@ -79,6 +79,9 @@ typedef struct OH_OnFrameAvailableListener { /** * @brief Create a OH_NativeImage related to an Opengl ES texture and target. \n + * This interface needs to be used in conjunction with OH_NativeImage_Destroy<\b>, + * otherwise memory leaks will occur.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param textureId Indicates the id of the Opengl ES texture which the native image attached to. @@ -91,7 +94,8 @@ typedef struct OH_OnFrameAvailableListener { OH_NativeImage* OH_NativeImage_Create(uint32_t textureId, uint32_t textureTarget); /** - * @brief Acquire the OHNativeWindow for the OH_NativeImage. + * @brief Acquire the OHNativeWindow for the OH_NativeImage.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -103,7 +107,8 @@ OHNativeWindow* OH_NativeImage_AcquireNativeWindow(OH_NativeImage* image); /** * @brief Attach the OH_NativeImage to Opengl ES context, and the Opengl ES texture is bound to the \n - * GL_TEXTURE_EXTERNAL_OES, which will update by the OH_NativeImage. + * GL_TEXTURE_EXTERNAL_OES, which will update by the OH_NativeImage.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -115,7 +120,8 @@ OHNativeWindow* OH_NativeImage_AcquireNativeWindow(OH_NativeImage* image); int32_t OH_NativeImage_AttachContext(OH_NativeImage* image, uint32_t textureId); /** - * @brief Detach the OH_NativeImage from the Opengl ES context. + * @brief Detach the OH_NativeImage from the Opengl ES context.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -127,7 +133,10 @@ int32_t OH_NativeImage_AttachContext(OH_NativeImage* image, uint32_t textureId); int32_t OH_NativeImage_DetachContext(OH_NativeImage* image); /** - * @brief Update the related Opengl ES texture with the OH_NativeImage acquired buffer. + * @brief Update the related Opengl ES texture with the OH_NativeImage acquired buffer.\n + * This interface needs to be called in the Opengl ES context thread.\n + * This interface needs to be called after receiving the OH_OnFrameAvailableListener<\b> callback.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -138,7 +147,8 @@ int32_t OH_NativeImage_DetachContext(OH_NativeImage* image); int32_t OH_NativeImage_UpdateSurfaceImage(OH_NativeImage* image); /** - * @brief Get the timestamp of the texture image set by the most recent call to OH_NativeImage_UpdateSurfaceImage. + * @brief Get the timestamp of the texture image set by the most recent call to OH_NativeImage_UpdateSurfaceImage.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -164,7 +174,8 @@ int64_t OH_NativeImage_GetTimestamp(OH_NativeImage* image); int32_t OH_NativeImage_GetTransformMatrix(OH_NativeImage* image, float matrix[16]); /** - * @brief Return the native image's surface id. + * @brief Return the native image's surface id.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -176,7 +187,9 @@ int32_t OH_NativeImage_GetTransformMatrix(OH_NativeImage* image, float matrix[16 int32_t OH_NativeImage_GetSurfaceId(OH_NativeImage* image, uint64_t* surfaceId); /** - * @brief Set the frame available callback. + * @brief Set the frame available callback.\n + * Not allow calling other interfaces in the callback function.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -188,7 +201,8 @@ int32_t OH_NativeImage_GetSurfaceId(OH_NativeImage* image, uint64_t* surfaceId); int32_t OH_NativeImage_SetOnFrameAvailableListener(OH_NativeImage* image, OH_OnFrameAvailableListener listener); /** - * @brief Unset the frame available callback. + * @brief Unset the frame available callback.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -199,8 +213,9 @@ int32_t OH_NativeImage_SetOnFrameAvailableListener(OH_NativeImage* image, OH_OnF int32_t OH_NativeImage_UnsetOnFrameAvailableListener(OH_NativeImage* image); /** - * @brief Destroy the OH_NativeImage created by OH_NativeImage_Create, and the pointer to \n - * OH_NativeImage will be null after this operation. + * @brief Destroy the OH_NativeImage created by OH_NativeImage_Create, and the pointer to + * OH_NativeImage will be null after this operation.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage pointer. @@ -211,6 +226,8 @@ void OH_NativeImage_Destroy(OH_NativeImage** image); /** * @brief Obtains the transform matrix of the texture image by producer transform type.\n + * The matrix will not be update until OH_NativeImage_UpdateSurfaceImage<\b> is called.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -233,6 +250,7 @@ int32_t OH_NativeImage_GetTransformMatrixV2(OH_NativeImage* image, float matrix[ * This interface needs to be used in conjunction with OH_NativeImage_ReleaseNativeWindowBuffer<\b>, * otherwise memory leaks will occur.\n * When the fenceFd is used up, you need to close it.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -251,6 +269,7 @@ int32_t OH_NativeImage_AcquireNativeWindowBuffer(OH_NativeImage* image, * @brief Release the OHNativeWindowBuffer to the buffer queue through an * OH_NativeImage instance for reuse.\n * The fenceFd will be close by system.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeImage * @param image Indicates the pointer to a OH_NativeImage instance. @@ -266,6 +285,53 @@ int32_t OH_NativeImage_AcquireNativeWindowBuffer(OH_NativeImage* image, int32_t OH_NativeImage_ReleaseNativeWindowBuffer(OH_NativeImage* image, OHNativeWindowBuffer* nativeWindowBuffer, int fenceFd); +/** + * @brief Create a OH_NativeImage as a consumerSurface. \n + * This interface is only used for memory rotation on the surface consumer, + * the OH_NativeImage will not actively perform memory rendering processing.\n + * This method can not be used at the same time with OH_NativeImage_UpdateSurfaceImage.\n + * This interface is used in conjunction with OH_NativeImage_AcquireNativeWindowBuffer<\b> and + * OH_NativeImage_ReleaseNativeWindowBuffer<\b>.\n + * This interface needs to be used in conjunction with OH_NativeImage_Destroy<\b>, + * otherwise memory leaks will occur.\n + * This interface is a non-thread-safe type interface.\n + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeImage + * @return Returns the pointer to the OH_NativeImage instance created if the operation is successful, \n + * returns NULL otherwise. + * @since 12 + * @version 1.0 + */ +OH_NativeImage* OH_ConsumerSurface_Create(void); + +/** + * @brief Set the default usage of the OH_NativeImage.\n + * This interface is a non-thread-safe type interface.\n + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeImage + * @param image Indicates the pointer to a OH_NativeImage instance. + * @param usage Indicates the usage of the OH_NativeImage.Refer to the enum OH_NativeBuffer_Usage. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - image is NULL. + * @since 13 + * @version 1.0 + */ +int32_t OH_ConsumerSurface_SetDefaultUsage(OH_NativeImage* image, uint64_t usage); + +/** + * @brief Set the default size of the OH_NativeImage.\n + * This interface is a non-thread-safe type interface.\n + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeImage + * @param image Indicates the pointer to a OH_NativeImage instance. + * @param width Indicates the width of the OH_NativeImage, and it should be greater than 0. + * @param height Indicates the height of the OH_NativeImage, and it should be greater than 0. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - image is NULL or width, height less than or equal to 0. + * @since 13 + * @version 1.0 + */ +int32_t OH_ConsumerSurface_SetDefaultSize(OH_NativeImage* image, int32_t width, int32_t height); #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json index b702a1d7a12bbc2fa3df403e0d1a21ee278e874d..28ff64c271c393e75c728466f161345fde544bae 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -2,5 +2,10 @@ { "name": "OH_NativeVSync_Create" }, { "name": "OH_NativeVSync_Destroy" }, { "name": "OH_NativeVSync_RequestFrame" }, - { "name": "OH_NativeVSync_GetPeriod" } + { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, + { "name": "OH_NativeVSync_GetPeriod" }, + { + "first_introduced": "14", + "name": "OH_NativeVSync_DVSyncSwitch" + } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 069d17689616c2a336e82da0ae3bb8c27af778c0..791fbfd36040affd8f282f874c4e61eb2469de0e 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -65,7 +65,6 @@ OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length); * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param window Indicates the pointer to a NativeVsync instance. - * @return Returns int32_t, return value == 0, success, otherwise, failed. * @since 9 * @version 1.0 */ @@ -73,17 +72,37 @@ void OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync); /** * @brief Request next vsync with callback. + * If you call this interface multiple times in one frame, it will only call the last callback. * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param nativeVsync Indicates the pointer to a NativeVsync. * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. - * @param data Indicates data whick will be used in callback. - * @return Returns int32_t, return value == 0, success, otherwise, failed. + * @param data Indicates data which will be used in callback. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. * @since 9 * @version 1.0 */ int OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); +/** + * @brief Request next vsync with callback. + * If this function is called multiple times in one vsync period, all these callbacks and dataset will be called. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync. + * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. + * @param data Indicates data which will be used in callback. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. + * @since 12 + * @version 1.0 + */ +int OH_NativeVSync_RequestFrameWithMultiCallback( + OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); + /** * @brief Get vsync period. * @@ -95,6 +114,32 @@ int OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_Fram * @version 1.0 */ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); + +/** + * @brief Enables DVSync to improve the smoothness of self-drawing animations. + * DVSync, short for Decoupled VSync, is a frame timing management policy that is decoupled from the hardware's VSync. + * DVSync drives the early rendering of upcoming animation frames by sending VSync signals with future timestamps. + * These frames are stored in a frame buffer queue. This helps DVSync reduce potential frame drop and therefore + * enhances the smoothness of animations. + * DVSync requires free self-drawing frame buffers to store these pre-rendered animation frames. + * Therefore, you must ensure that at least one free frame buffer is available. Otherwise, do not enable DVSync. + * After DVSync is enabled, you must correctly respond to the early VSync signals and request the subsequent VSync + * after the animation frame associated with the previous VSync is complete. In addition, the self-drawing frames must + * carry timestamps that align with VSync. + * After the animation ends, disable DVSync. + * On a platform that does not support DVSync or if another application has enabled DVSync, the attempt to enable it + * will not take effect, and the application still receives normal VSync signals. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync. + * @param enable Whether to enable DVSync.The value true means to enable DVSync, and false means the opposite. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. + * @since 14 + * @version 1.0 + */ +int OH_NativeVSync_DVSyncSwitch(OH_NativeVSync* nativeVsync, bool enable); #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_window/external_window.h b/graphic/graphic_2d/native_window/external_window.h index 767e8c8ace97c94607de3d2b0a933d71bf8ef0c9..47a407ff05225dd1fc88e4b1e65926874ee83347 100644 --- a/graphic/graphic_2d/native_window/external_window.h +++ b/graphic/graphic_2d/native_window/external_window.h @@ -117,25 +117,25 @@ typedef enum NativeWindowOperation { /** * get native window buffer format, * variable parameter in function is - * [out] int32_t *format + * [out] int32_t *format, the enumeration value refers to {@link OH_NativeBuffer_Format}. */ GET_FORMAT, /** * set native window buffer format, * variable parameter in function is - * [in] int32_t format + * [in] int32_t format, the enumeration value refers to {@link OH_NativeBuffer_Format}. */ SET_FORMAT, /** * get native window buffer usage, * variable parameter in function is - * [out] uint64_t *usage. + * [out] uint64_t *usage, the enumeration value refers to {@link OH_NativeBuffer_Usage}. */ GET_USAGE, /** * set native window buffer usage, * variable parameter in function is - * [in] uint64_t usage. + * [in] uint64_t usage, the enumeration value refers to {@link OH_NativeBuffer_Usage}. */ SET_USAGE, /** @@ -163,39 +163,41 @@ typedef enum NativeWindowOperation { */ GET_SWAP_INTERVAL, /** - * set native window buffer timeout, + * set the timeout in milliseconds when the native window requests a buffer, + * the default value is 3000 milliseconds when not set, * variable parameter in function is - * [in] int32_t timeout. + * [in] int32_t timeout, in milliseconds. */ SET_TIMEOUT, /** - * get native window buffer timeout, + * get the timeout in milliseconds when the native window requests a buffer, + * the default value is 3000 milliseconds when not set, * variable parameter in function is - * [out] int32_t *timeout. + * [out] int32_t *timeout, in milliseconds. */ GET_TIMEOUT, /** * set native window buffer colorGamut, * variable parameter in function is - * [in] int32_t colorGamut. + * [in] int32_t colorGamut, the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}. */ SET_COLOR_GAMUT, /** * get native window buffer colorGamut, * variable parameter in function is - * [out int32_t *colorGamut]. + * [out int32_t *colorGamut], the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}. */ GET_COLOR_GAMUT, /** * set native window buffer transform, * variable parameter in function is - * [in] int32_t transform. + * [in] int32_t transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}. */ SET_TRANSFORM, /** * get native window buffer transform, * variable parameter in function is - * [out] int32_t *transform. + * [out] int32_t *transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}. */ GET_TRANSFORM, /** @@ -214,14 +216,14 @@ typedef enum NativeWindowOperation { /** * set surface source type, * variable parameter in function is - * [in] int32_t sourceType. + * [in] int32_t sourceType, the enumeration value refers to {@link OHSurfaceSource}. * @since 12 */ SET_SOURCE_TYPE, /** * get surface source type, * variable parameter in function is - * [out] int32_t *sourceType. + * [out] int32_t *sourceType, the enumeration value refers to {@link OHSurfaceSource}. * @since 12 */ GET_SOURCE_TYPE, @@ -253,6 +255,20 @@ typedef enum NativeWindowOperation { * @since 12 */ SET_SDR_WHITE_POINT_BRIGHTNESS, + /** + * Set native window buffer desiredPresentTimestamp, indicates the desired time to present the buffer.\n + * Which should be generated by std::chrono::steady_clock in nanoseconds.\n + * It is only effective when RenderService is the consumer.\n + * The buffer will wait until desiredPresentTimestamp is reached before being consumed and displayed.\n + * If multiple buffers reach desiredPresentTimestamp, the earlier buffer will be dropped.\n + * This Operation should be called before calling OH_NativeWindow_NativeWindowFlushBuffer.\n + * If desiredPresentTimestamp is greater than 1 second of the consumer-provided timestamp, + * the desiredPresentTimestamp will be ignored.\n + * Variable parameter in function is + * [in] int64_t desiredPresentTimestamp. + * @since 13 + */ + SET_DESIRED_PRESENT_TIMESTAMP = 24, } NativeWindowOperation; /** @@ -399,7 +415,9 @@ typedef enum { OHNativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface); /** - * @brief Decreases the reference count of a OHNativeWindow instance by 1, and when the reference count reaches 0, destroys the instance. + * @brief Decreases the reference count of a OHNativeWindow instance by 1, + * and when the reference count reaches 0, destroys the instance.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -422,8 +440,11 @@ void OH_NativeWindow_DestroyNativeWindow(OHNativeWindow* window); OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer); /** - * @brief Creates a OHNativeWindowBuffer instance. - A new OHNativeWindowBuffer instance is created each time this function is called. + * @brief Creates a OHNativeWindowBuffer instance.\n + * A new OHNativeWindowBuffer instance is created each time this function is called.\n + * This interface needs to be used in conjunction with OH_NativeWindow_DestroyNativeWindowBuffer<\b>, + * otherwise memory leaks will occur.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param nativeBuffer Indicates the pointer to a native buffer. The type is OH_NativeBuffer*. @@ -434,7 +455,9 @@ OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer( OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(OH_NativeBuffer* nativeBuffer); /** - * @brief Decreases the reference count of a OHNativeWindowBuffer instance by 1 and, when the reference count reaches 0, destroys the instance. + * @brief Decreases the reference count of a OHNativeWindowBuffer instance by 1 and, + * when the reference count reaches 0, destroys the instance.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param buffer Indicates the pointer to a OHNativeWindowBuffer instance. @@ -444,7 +467,13 @@ OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(O void OH_NativeWindow_DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer); /** - * @brief Requests a OHNativeWindowBuffer through a OHNativeWindow instance for content production. + * @brief Requests a OHNativeWindowBuffer through a OHNativeWindow instance for content production.\n + * Before calling this interface, you need to set the width and height of + * OHNativeWindow through SET_BUFFER_GEOMETRY.\n + * This interface needs to be used in conjunction with OH_NativeWindow_NativeWindowFlushBuffer<\b>, + * otherwise buffer will be exhausted.\n + * When the fenceFd is used up, you need to close it.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -458,7 +487,10 @@ int32_t OH_NativeWindow_NativeWindowRequestBuffer(OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd); /** - * @brief Flushes the OHNativeWindowBuffer filled with the content to the buffer queue through a OHNativeWindow instance for content consumption. + * @brief Flushes the OHNativeWindowBuffer filled with the content to the buffer queue + * through a OHNativeWindow instance for content consumption.\n + * The fenceFd will be close by system.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -490,7 +522,9 @@ int32_t OH_NativeWindow_GetLastFlushedBuffer(OHNativeWindow *window, OHNativeWin int *fenceFd, float matrix[16]); /** - * @brief Returns the OHNativeWindowBuffer to the buffer queue through a OHNativeWindow instance, without filling in any content. The OHNativeWindowBuffer can be used for another request. + * @brief Returns the OHNativeWindowBuffer to the buffer queue through a OHNativeWindow instance, + * without filling in any content. The OHNativeWindowBuffer can be used for another request.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -502,7 +536,8 @@ int32_t OH_NativeWindow_GetLastFlushedBuffer(OHNativeWindow *window, OHNativeWin int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer); /** - * @brief Sets or obtains the attributes of a native window, including the width, height, and content format. + * @brief Sets or obtains the attributes of a native window, including the width, height, and content format.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -515,7 +550,8 @@ int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNative int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, ...); /** - * @brief Obtains the pointer to a BufferHandle of a OHNativeWindowBuffer instance. + * @brief Obtains the pointer to a BufferHandle of a OHNativeWindowBuffer instance.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param buffer Indicates the pointer to a OHNativeWindowBuffer instance. @@ -526,7 +562,10 @@ int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *buffer); /** - * @brief Adds the reference count of a native object. + * @brief Adds the reference count of a native object.\n + * This interface needs to be used in conjunction with OH_NativeWindow_NativeObjectUnreference<\b>, + * otherwise memory leaks will occur.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param obj Indicates the pointer to a OHNativeWindow or OHNativeWindowBuffer instance. @@ -537,7 +576,9 @@ BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *bu int32_t OH_NativeWindow_NativeObjectReference(void *obj); /** - * @brief Decreases the reference count of a native object and, when the reference count reaches 0, destroys this object. + * @brief Decreases the reference count of a native object and, + * when the reference count reaches 0, destroys this object.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param obj Indicates the pointer to a OHNativeWindow or OHNativeWindowBuffer instance. @@ -548,7 +589,8 @@ int32_t OH_NativeWindow_NativeObjectReference(void *obj); int32_t OH_NativeWindow_NativeObjectUnreference(void *obj); /** - * @brief Obtains the magic ID of a native object. + * @brief Obtains the magic ID of a native object.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param obj Indicates the pointer to a OHNativeWindow or OHNativeWindowBuffer instance. @@ -620,7 +662,10 @@ int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint3 int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle); /** - * @brief Attach a buffer to an OHNativeWindow instance. + * @brief Attach a buffer to an OHNativeWindow instance.\n + * This interface needs to be used in conjunction with OH_NativeWindow_NativeWindowDetachBuffer<\b>, + * otherwise buffer management will be chaotic.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to an OHNativeWindow instance. @@ -632,7 +677,8 @@ int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, cons int32_t OH_NativeWindow_NativeWindowAttachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer); /** - * @brief Detach a buffer from an OHNativeWindow instance. + * @brief Detach a buffer from an OHNativeWindow instance.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to an OHNativeWindow instance. @@ -644,7 +690,8 @@ int32_t OH_NativeWindow_NativeWindowAttachBuffer(OHNativeWindow *window, OHNativ int32_t OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer); /** - * @brief Get surfaceId from native window. + * @brief Get surfaceId from native window.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to an OHNativeWindow instance. @@ -657,6 +704,14 @@ int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId /** * @brief Creates an OHNativeWindow instance.\n + * This interface needs to be used in conjunction with OH_NativeWindow_DestroyNativeWindow<\b>, + * otherwise memory leaks will occur.\n + * If there is a concurrent destroy OHNativeWindow, you need to add once and decrement once to the + * OHNativeWindow reference count through OH_NativeWindow_NativeObjectReference<\b> and + * OH_NativeWindow_NativeObjectUnreference<\b>.\n + * If the surface obtained through surfaceId is created in this process, the surface cannot be obtained + * across processes.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param surfaceId Indicates the surfaceId to a surface. @@ -668,7 +723,8 @@ int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId int32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window); /** - * @brief Sets scalingMode of a native window. + * @brief Sets scalingMode of a native window.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window indicates the pointer to an OHNativeWindow instance. @@ -680,7 +736,8 @@ int32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNa int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHScalingModeV2 scalingMode); /** - * @brief Set native window buffer hold. + * @brief Set native window buffer hold.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to an OHNativeWindow instance. @@ -690,42 +747,48 @@ int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHS void OH_NativeWindow_SetBufferHold(OHNativeWindow *window); /** - * @brief Write an OHNativeWindow to an OHIPCParcel. + * @brief Write an OHNativeWindow to an OHIPCParcel.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to an OHNativeWindow instance. * @param parcel Indicates the pointer to an OHIPCParcel instance. - * @return 0 - Success. - * 40001000 - parcel is NULL or window is NULL. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or window is NULL. * @since 12 * @version 1.0 */ int32_t OH_NativeWindow_WriteToParcel(OHNativeWindow *window, OHIPCParcel *parcel); /** - * @brief Read an OHNativeWindow from an OHIPCParcel. + * @brief Read an OHNativeWindow from an OHIPCParcel.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param parcel Indicates the pointer to an OHIPCParcel instance. * @param window Indicates the pointer to an OHNativeWindow instance. - * @return 0 - Success. - * 40001000 - parcel is NULL or parcel does not contain the window. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or parcel does not contain the window. * @since 12 * @version 1.0 */ int32_t OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **window); /** - * @brief Get the last flushed OHNativeWindowBuffer from an OHNativeWindow instance. + * @brief Get the last flushed OHNativeWindowBuffer from an OHNativeWindow instance.\n + * When the fenceFd is used up, you need to close it.\n + * This interface needs to be used in conjunction with OH_NativeWindow_NativeObjectUnreference<\b>, + * otherwise memory leaks will occur.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to an OHNativeWindow instance. * @param buffer Indicates the pointer to an OHNativeWindowBuffer pointer. * @param fenceFd Indicates the pointer to a file descriptor handle. * @param matrix Indicates the retrieved 4*4 transform matrix. - * @return 0 - Success. - * 40001000 - window is NULL or buffer is NULL or fenceFd is NULL. - * 41207000 - buffer state is wrong. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL or buffer is NULL or fenceFd is NULL. + * {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - buffer state is wrong. * @since 12 * @version 1.0 */ @@ -733,7 +796,8 @@ int32_t OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **win int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd, float matrix[16]); /** - * @brief Set the color space of the native window. + * @brief Set the color space of the native window.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -747,7 +811,8 @@ int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeW int32_t OH_NativeWindow_SetColorSpace(OHNativeWindow *window, OH_NativeBuffer_ColorSpace colorSpace); /** - * @brief Get the color space of the native window. + * @brief Get the color space of the native window.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -761,7 +826,8 @@ int32_t OH_NativeWindow_SetColorSpace(OHNativeWindow *window, OH_NativeBuffer_Co int32_t OH_NativeWindow_GetColorSpace(OHNativeWindow *window, OH_NativeBuffer_ColorSpace *colorSpace); /** - * @brief Set the metadata type of the native window. + * @brief Set the metadata type of the native window.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. @@ -779,7 +845,8 @@ int32_t OH_NativeWindow_SetMetadataValue(OHNativeWindow *window, OH_NativeBuffer int32_t size, uint8_t *metadata); /** - * @brief Set the metadata type of the native window. + * @brief Set the metadata type of the native window.\n + * This interface is a non-thread-safe type interface.\n * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window Indicates the pointer to a OHNativeWindow instance. diff --git a/graphic/graphic_2d/native_window/graphic_error_code.h b/graphic/graphic_2d/native_window/graphic_error_code.h index cba61e5e8dbac4efa1b5f7f21a279592ed4be15c..1b5e9deb0166e9817bf5cf1f8a600f73ef53c5dd 100644 --- a/graphic/graphic_2d/native_window/graphic_error_code.h +++ b/graphic/graphic_2d/native_window/graphic_error_code.h @@ -80,6 +80,10 @@ typedef enum OHNativeErrorCode { NATIVE_ERROR_UNSUPPORTED = 50102000, /** @error unknown error, please check log */ NATIVE_ERROR_UNKNOWN = 50002000, + /** @error hdi interface error */ + NATIVE_ERROR_HDI_ERROR = 50007000, + /** @error ipc send failed */ + NATIVE_ERROR_BINDER_ERROR = 50401000, /** @error the egl environment is abnormal */ NATIVE_ERROR_EGL_STATE_UNKNOWN = 60001000, /** @error egl interface invocation failed */ diff --git a/hiviewdfx/hidebug/include/hidebug/hidebug.h b/hiviewdfx/hidebug/include/hidebug/hidebug.h index a5bfec7b6330a51340cf48f4ae1c6e7ef7617b08..7f234b3598a4b3063ca0fbc9835afbc096adba75 100644 --- a/hiviewdfx/hidebug/include/hidebug/hidebug.h +++ b/hiviewdfx/hidebug/include/hidebug/hidebug.h @@ -138,6 +138,18 @@ HiDebug_ErrorCode OH_HiDebug_StartAppTraceCapture(HiDebug_TraceFlag flag, */ HiDebug_ErrorCode OH_HiDebug_StopAppTraceCapture(); +/** + * @brief Get the graphics memory of application. + * + * @param value Indicates value of graphics memory, in kibibytes. + * @return Result code + * {@link HIDEBUG_SUCCESS} Get graphics memory success. + * {@link HIDEBUG_INVALID_ARGUMENT} Invalid argument,value is null. + * {@link HIDEBUG_TRACE_ABNORMAL} Failed to get the application memory due to a remote exception. + * @since 14 + */ +HiDebug_ErrorCode OH_HiDebug_GetGraphicsMemory(uint32_t *value); + #ifdef __cplusplus } #endif // __cplusplus diff --git a/hiviewdfx/hidebug/libhidebug.ndk.json b/hiviewdfx/hidebug/libhidebug.ndk.json index 5569c806de0e24f4160fd854df041f0f9e1d6670..45be9500bc49dbe861892b3f955f4513901afac9 100644 --- a/hiviewdfx/hidebug/libhidebug.ndk.json +++ b/hiviewdfx/hidebug/libhidebug.ndk.json @@ -34,5 +34,9 @@ { "first_introduced": "12", "name": "OH_HiDebug_StopAppTraceCapture" + }, + { + "first_introduced": "13", + "name": "OH_HiDebug_GetGraphicsMemory" } ] \ No newline at end of file diff --git a/hiviewdfx/hitrace/include/hitrace/trace.h b/hiviewdfx/hitrace/include/hitrace/trace.h index 9142b26376133fecfc0b1a3823269a43fab6d8cc..e771136da9160fc003c6c681e181a3b0631ed8f1 100644 --- a/hiviewdfx/hitrace/include/hitrace/trace.h +++ b/hiviewdfx/hitrace/include/hitrace/trace.h @@ -65,6 +65,7 @@ * @since 10 */ #include +#include #ifdef __cplusplus extern "C" { diff --git a/inputmethod/BUILD.gn b/inputmethod/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cc1480cdb87beca13fa1874a4530dd6e8ab67a50 --- /dev/null +++ b/inputmethod/BUILD.gn @@ -0,0 +1,48 @@ +# 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") + +ohos_ndk_library("libohinputmethod") { + output_name = "ohinputmethod" + output_extension = "so" + ndk_description_file = "./libohinputmethodndk.json" + min_compact_version = "12" + system_capability = "SystemCapability.MiscServices.InputMethodFramework" + system_capability_headers = [ + "./inputmethod/inputmethod_controller_capi.h", + "./inputmethod/inputmethod_attach_options_capi.h", + "./inputmethod/inputmethod_cursor_info_capi.h", + "./inputmethod/inputmethod_inputmethod_proxy_capi.h", + "./inputmethod/inputmethod_private_command_capi.h", + "./inputmethod/inputmethod_text_avoid_info_capi.h", + "./inputmethod/inputmethod_text_config_capi.h", + "./inputmethod/inputmethod_text_editor_proxy_capi.h", + "./inputmethod/inputmethod_types_capi.h", + ] +} + +ohos_ndk_headers("libohinputmethod_header") { + dest_dir = "$ndk_headers_out_dir/inputmethod" + sources = [ + "./include/inputmethod_attach_options_capi.h", + "./include/inputmethod_controller_capi.h", + "./include/inputmethod_cursor_info_capi.h", + "./include/inputmethod_inputmethod_proxy_capi.h", + "./include/inputmethod_private_command_capi.h", + "./include/inputmethod_text_avoid_info_capi.h", + "./include/inputmethod_text_config_capi.h", + "./include/inputmethod_text_editor_proxy_capi.h", + "./include/inputmethod_types_capi.h", + ] +} diff --git a/inputmethod/include/inputmethod_attach_options_capi.h b/inputmethod/include/inputmethod_attach_options_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..3a12eaba6db8ce50052d6275fe91703e200b4e2d --- /dev/null +++ b/inputmethod/include/inputmethod_attach_options_capi.h @@ -0,0 +1,84 @@ +/* + * 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_attach_options_capi.h + * + * @brief Provides the input method attach options. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_ATTACH_OPTIONS_CAPI_H +#define OHOS_INPUTMETHOD_ATTACH_OPTIONS_CAPI_H +#include "inputmethod_types_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/** + * @brief Define the InputMethod_AttachOptions structure type. + * + * The options when attaching input method. + * + * @since 12 + */ +typedef struct InputMethod_AttachOptions InputMethod_AttachOptions; + +/** + * @brief Create a new {@link InputMethod_AttachOptions} instance. + * + * @param showKeyboard Represents whether to show the keyboard. + * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_AttachOptions} + * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + * @since 12 + */ +InputMethod_AttachOptions *OH_AttachOptions_Create(bool showKeyboard); +/** + * @brief Delete a {@link InputMethod_AttachOptions} instance. + * + * @param options Represents a pointer to an {@link InputMethod_AttachOptions} instance which will be destroyed. + * @since 12 + */ +void OH_AttachOptions_Destroy(InputMethod_AttachOptions *options); +/** + * @brief Get showKeyboard value from {@link InputMethod_AttachOptions}. + * + * @param options Represents a pointer to an {@link InputMethod_AttachOptions} instance which will be get value from. + * @param showKeyboard Represents showKeyboard value. + * true - need to show keyboard. + * false - no need to show keyboard. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_AttachOptions_IsShowKeyboard(InputMethod_AttachOptions *options, bool *showKeyboard); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_ATTACH_OPTIONS_CAPI_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_controller_capi.h b/inputmethod/include/inputmethod_controller_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..abfc5cbdc0631b2d1ae4e65be70d1afe76430d48 --- /dev/null +++ b/inputmethod/include/inputmethod_controller_capi.h @@ -0,0 +1,86 @@ +/* + * 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_controller_capi.h + * + * @brief Provides the functions for using input method. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_CONTROLLER_CAPI_H +#define OHOS_INPUTMETHOD_CONTROLLER_CAPI_H +#include +#include + +#include "inputmethod_text_editor_proxy_capi.h" +#include "inputmethod_inputmethod_proxy_capi.h" +#include "inputmethod_attach_options_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/** + * @brief Attach application to the input method service. + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance. + * The caller needs to manage the lifecycle of textEditorProxy. + * If the call succeeds, caller cannot release textEditorProxy until the next attach or detach call. + * @param options Represents a pointer to an {@link InputMethod_AttachOptions} instance. + * The options when attaching input method. + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * Lifecycle is mantianed until the next attach or detach call. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_PARAMCHECK} - parameter check failed. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodController_Attach(InputMethod_TextEditorProxy *textEditorProxy, + InputMethod_AttachOptions *options, InputMethod_InputMethodProxy **inputMethodProxy); + +/** + * @brief Detach application from the input method service. + * + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodController_Detach(InputMethod_InputMethodProxy *inputMethodProxy); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_CONTROLLER_CAPI_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_cursor_info_capi.h b/inputmethod/include/inputmethod_cursor_info_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..5810219f76753ab05f71fd3818ad9451e19bb4ff --- /dev/null +++ b/inputmethod/include/inputmethod_cursor_info_capi.h @@ -0,0 +1,108 @@ +/* +* 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_cursor_info_capi.h + * + * @brief Provides interfaces to manage the cursor information. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_CURSOR_INFO_CAPI_H +#define OHOS_INPUTMETHOD_CURSOR_INFO_CAPI_H +#include "inputmethod_types_capi.h" +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +/** + * @brief Define the InputMethod_CursorInfo structure type. + * + * The coordinates and width and height information of the cursor. + * + * @since 12 + */ +typedef struct InputMethod_CursorInfo InputMethod_CursorInfo; + +/** + * @brief Create a new {@link InputMethod_CursorInfo} instance. + * + * @param left The left point of the cursor and must be absolute coordinate of the physical screen. + * @param top The top point of the cursor and must be absolute coordinate of the physical screen. + * @param width The width of the cursor. + * @param height The height of the cursor. + * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_CursorInfo} + * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + * @since 12 + */ +InputMethod_CursorInfo *OH_CursorInfo_Create(double left, double top, double width, double height); + +/** + * @brief Destroy a {@link InputMethod_CursorInfo} instance. + * + * @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance which will be destroyed. + * @since 12 + */ +void OH_CursorInfo_Destroy(InputMethod_CursorInfo *cursorInfo); + +/** + * @brief Set cursor info. + * + * @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + * @param left The left point of the cursor and must be absolute coordinate of the physical screen. + * @param top The top point of the cursor and must be absolute coordinate of the physical screen. + * @param width The width of the cursor. + * @param height The height of the cursor. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_CursorInfo_SetRect( + InputMethod_CursorInfo *cursorInfo, double left, double top, double width, double height); + +/** + * @brief Get cursor info. + * + * @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + * @param left The left point of the cursor and must be absolute coordinate of the physical screen. + * @param top The top point of the cursor and must be absolute coordinate of the physical screen. + * @param width The width of the cursor. + * @param height The height of the cursor. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_CursorInfo_GetRect( + InputMethod_CursorInfo *cursorInfo, double *left, double *top, double *width, double *height); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_CURSOR_INFO_CAPI_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_inputmethod_proxy_capi.h b/inputmethod/include/inputmethod_inputmethod_proxy_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..f8257c2b6307f7237a2f11f46b4fbf05e44057b9 --- /dev/null +++ b/inputmethod/include/inputmethod_inputmethod_proxy_capi.h @@ -0,0 +1,173 @@ +/* +* 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_inputmethod_proxy_capi.h + * + * @brief Provides functions to use input methods. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_INPUTMETHOD_PROXY_CAPI_H +#define OHOS_INPUTMETHOD_INPUTMETHOD_PROXY_CAPI_H +#include + +#include "inputmethod_types_capi.h" +#include "inputmethod_cursor_info_capi.h" +#include "inputmethod_private_command_capi.h" +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +/** + * @brief Define the InputMethod_InputMethodProxy structure type. + * + * Provides methods for controlling input method. + * + * @since 12 + */ +typedef struct InputMethod_InputMethodProxy InputMethod_InputMethodProxy; + +/** + * @brief Show keyboard. + * + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_DETACHED} - input method client detached. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodProxy_ShowKeyboard(InputMethod_InputMethodProxy *inputMethodProxy); + +/** + * @brief Hide keyboard. + * + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_DETACHED} - input method client detached. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodProxy_HideKeyboard(InputMethod_InputMethodProxy *inputMethodProxy); + +/** + * @brief Notify selection change. + * + * Notify selection change when text or cursor position or selected text changed. + * + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + * @param text The whole input text. + * @param length The length of text. Max length is 8K. + * @param start The start position of selected text. + * @param end The end position of selected text. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_PARAMCHECK} - parameter check failed. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_DETACHED} - input method client detached. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodProxy_NotifySelectionChange( + InputMethod_InputMethodProxy *inputMethodProxy, char16_t text[], size_t length, int start, int end); + +/** + * @brief Notify text editor configuration change. + * + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + * @param enterKey The enter key type. + * @param textType The text input type. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_PARAMCHECK} - parameter check failed. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_DETACHED} - input method client detached. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodProxy_NotifyConfigurationChange(InputMethod_InputMethodProxy *inputMethodProxy, + InputMethod_EnterKeyType enterKey, InputMethod_TextInputType textType); + +/** + * @brief Notify cursor update. + * + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + * @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + * The cursor information. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_PARAMCHECK} - parameter check failed. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_DETACHED} - input method client detached. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodProxy_NotifyCursorUpdate( + InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_CursorInfo *cursorInfo); + +/** + * @brief Send private command. + * + * @param inputMethodProxy Represents a pointer to an {@link InputMethod_InputMethodProxy} instance. + * The inputMethodProxy is obtained from {@link OH_InputMethodController_Attach}. + * @param privateCommand The private commands, which is defined in {@link InputMethod_PrivateCommand}. Max size 32KB. + * @param size The size of privateCommand. Max is 5. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_PARAMCHECK} - parameter check failed. + * {@link IME_ERR_IMCLIENT} - input method client error. + * {@link IME_ERR_IMMS} - input method manager service error. + * {@link IME_ERR_DETACHED} - input method client detached. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_InputMethodProxy_SendPrivateCommand( + InputMethod_InputMethodProxy *inputMethodProxy, InputMethod_PrivateCommand *privateCommand[], size_t size); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // INPUTMETHOD_INPUTMETHOD_PROXY_CAP_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_private_command_capi.h b/inputmethod/include/inputmethod_private_command_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..2821b2e75ee7c4f0ae1a8ee7e16ca20e0e429d32 --- /dev/null +++ b/inputmethod/include/inputmethod_private_command_capi.h @@ -0,0 +1,195 @@ +/* + * 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_private_command_capi.h + * + * @brief Provides functions to manage private commands. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_PRIVATE_COMMAND_CAPI_H +#define OHOS_INPUTMETHOD_PRIVATE_COMMAND_CAPI_H +#include +#include + +#include "inputmethod_types_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/** + * @brief Define the InputMethod_PrivateCommand structure type. + * + * The private command between text editor and input method. + * + * @since 12 + */ +typedef struct InputMethod_PrivateCommand InputMethod_PrivateCommand; + +/** + * @brief Create a new {@link InputMethod_PrivateCommand} instance. + * + * @param key The key of the private command. + * @param keyLength The length of the key. + * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_PrivateCommand} + * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + * @since 12 + */ +InputMethod_PrivateCommand *OH_PrivateCommand_Create(char key[], size_t keyLength); +/** + * @brief Destroy a {@link InputMethod_PrivateCommand} instance. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be destroyed. + * @since 12 + */ +void OH_PrivateCommand_Destroy(InputMethod_PrivateCommand *command); +/** + * @brief Set key value into {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + * @param key Represents key value. + * @param keyLength Represents key length. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_SetKey(InputMethod_PrivateCommand *command, char key[], size_t keyLength); +/** + * @brief Set bool data value into {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + * @param value Represents bool data value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_SetBoolValue(InputMethod_PrivateCommand *command, bool value); +/** + * @brief Set integer data value into {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + * @param value Represents integer data value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_SetIntValue(InputMethod_PrivateCommand *command, int32_t value); +/** + * @brief Set string data value into {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. + * @param value Represents string data value. + * @param valueLength Represents the length of string data value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_SetStrValue( + InputMethod_PrivateCommand *command, char value[], size_t valueLength); + +/** + * @brief Get key value from {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + * @param key Represents key value. + * @param keyLength Represents key length. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_GetKey( + InputMethod_PrivateCommand *command, const char **key, size_t *keyLength); +/** + * @brief Get value type from {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + * @param type Represents a pointer to a {@link InputMethod_CommandValueType} instance. Indicates the data type of the + * value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_GetValueType( + InputMethod_PrivateCommand *command, InputMethod_CommandValueType *type); +/** + * @brief Get bool data value from {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + * @param value Represents bool data value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * {@link IME_ERR_QUERY_FAILED} - query failed, no bool value in command. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_GetBoolValue(InputMethod_PrivateCommand *command, bool *value); +/** + * @brief Get integer data value from {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + * @param value Represents integer data value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * {@link IME_ERR_QUERY_FAILED} - query failed, no integer value in command. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_GetIntValue(InputMethod_PrivateCommand *command, int32_t *value); +/** + * @brief Get string data value from {@link InputMethod_PrivateCommand}. + * + * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. + * @param value Represents string data value. + * @param valueLength Represents the length of string data value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * {@link IME_ERR_QUERY_FAILED} - query failed, no string value in command. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_PrivateCommand_GetStrValue( + InputMethod_PrivateCommand *command, const char **value, size_t *valueLength); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_PRIVATE_COMMAND_CAPI_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_text_avoid_info_capi.h b/inputmethod/include/inputmethod_text_avoid_info_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..a22590f6a9dcf2b52d29c2b9aa8102e5f1ce99c2 --- /dev/null +++ b/inputmethod/include/inputmethod_text_avoid_info_capi.h @@ -0,0 +1,120 @@ +/* + * 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_text_avoid_info_capi.h + * + * @brief Provides functions to manage text editor to avoid the keyboard. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_TEXT_AVOID_INFO_CAPI_H +#define OHOS_INPUTMETHOD_TEXT_AVOID_INFO_CAPI_H +#include "inputmethod_types_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Define the InputMethod_TextAvoidInfo structure type. + * + * Information for text editor to avoid the keyboard. + * + * @since 12 + */ +typedef struct InputMethod_TextAvoidInfo InputMethod_TextAvoidInfo; + +/** + * @brief Create a new {@link InputMethod_TextAvoidInfo} instance. + * + * @param positionY The y-coordinate of the avoid area. + * @param height The height of the avoid area. + * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_TextAvoidInfo} + * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + * @since 12 + */ +InputMethod_TextAvoidInfo *OH_TextAvoidInfo_Create(double positionY, double height); +/** + * @brief Destroy a {@link InputMethod_TextAvoidInfo} instance. + * + * @param options Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be destroyed. + * @since 12 + */ +void OH_TextAvoidInfo_Destroy(InputMethod_TextAvoidInfo *info); +/** + * @brief Set positionY value into {@link InputMethod_TextAvoidInfo}. + * + * @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be set value. + * @param positionY Represents positionY value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextAvoidInfo_SetPositionY(InputMethod_TextAvoidInfo *info, double positionY); +/** + * @brief Set height value into {@link InputMethod_TextAvoidInfo}. + * + * @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be set value. + * @param height Represents height value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextAvoidInfo_SetHeight(InputMethod_TextAvoidInfo *info, double height); +/** + * @brief Get positionY value from {@link InputMethod_TextAvoidInfo}. + * + * @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be get value from. + * @param positionY Represents positionY value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextAvoidInfo_GetPositionY(InputMethod_TextAvoidInfo *info, double *positionY); +/** + * @brief Get height value into {@link InputMethod_TextAvoidInfo}. + * + * @param info Represents a pointer to an {@link InputMethod_TextAvoidInfo} instance which will be get value from. + * @param height Represents height value. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextAvoidInfo_GetHeight(InputMethod_TextAvoidInfo *info, double *height); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_TEXT_AVOID_INFO_CAP_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_text_config_capi.h b/inputmethod/include/inputmethod_text_config_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..ad639af2da400488b1ed116889b0f8e089f427c3 --- /dev/null +++ b/inputmethod/include/inputmethod_text_config_capi.h @@ -0,0 +1,229 @@ +/* + * 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_text_config_capi.h + * + * @brief Provides functions to manage the text configuration. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_TEXT_CONFIG_CAPI_H +#define OHOS_INPUTMETHOD_TEXT_CONFIG_CAPI_H +#include + +#include "inputmethod_cursor_info_capi.h" +#include "inputmethod_text_avoid_info_capi.h" +#include "inputmethod_types_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/** + * @brief Define the InputMethod_TextConfig structure type. + * + * The configuration of the text editor. + * + * @since 12 + */ +typedef struct InputMethod_TextConfig InputMethod_TextConfig; + +/** + * @brief Create a new {@link InputMethod_TextConfig} instance. + * + * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_TextConfig} + * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + * @since 12 + */ +InputMethod_TextConfig *OH_TextConfig_Create(void); +/** + * @brief Destroy a {@link InputMethod_TextConfig} instance. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be destroyed. + * @since 12 + */ +void OH_TextConfig_Destroy(InputMethod_TextConfig *config); + +/** + * @brief Set input type into TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + * @param inputType The text input type of text Editor, which is defined in {@link InputMethod_TextInputType}. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_SetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType inputType); +/** + * @brief Set enter key type into TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + * @param enterKeyType The enter key type of text Editor, which is defined in {@link InputMethod_EnterKeyType}. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_SetEnterKeyType( + InputMethod_TextConfig *config, InputMethod_EnterKeyType enterKeyType); +/** + * @brief Set preview text support into TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + * @param supported Indicates whether the preview text is supported. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_SetPreviewTextSupport(InputMethod_TextConfig *config, bool supported); +/** + * @brief Set selection into TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + * @param start The start position of selection. + * @param end The end position of selection. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_SetSelection(InputMethod_TextConfig *config, int32_t start, int32_t end); +/** + * @brief Set window id into TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be set. + * @param windowId The window ID of the application currently bound to the input method. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_SetWindowId(InputMethod_TextConfig *config, int32_t windowId); + +/** + * @brief Get input type from TextConfig + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + * @param inputType Represents a pointer to an {@link InputMethod_TextInputType} instance. + * The text input type of text Editor + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_GetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType *inputType); +/** + * @brief Get enter key type from TextConfig + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + * @param enterKeyType Represents a pointer to an {@link InputMethod_EnterKeyType} instance. + * Indicates the enter key type of text Editor + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_GetEnterKeyType( + InputMethod_TextConfig *config, InputMethod_EnterKeyType *enterKeyType); +/** + * @brief Get is preview text supported from TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + * @param supported Indicates whether the preview text is supported. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_IsPreviewTextSupported(InputMethod_TextConfig *config, bool *supported); +/** + * @brief Get cursor info from TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + * @param cursorInfo Represents a pointer to an {@link InputMethod_CursorInfo} instance. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_GetCursorInfo(InputMethod_TextConfig *config, InputMethod_CursorInfo **cursorInfo); + +/** + * @brief Get text avoid information from text configuration. + * + * @param config Indicates the text configuration. + * @param avoidInfo Indicates the text avoid information. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + *@since 12 + */ +InputMethod_ErrorCode OH_TextConfig_GetTextAvoidInfo( + InputMethod_TextConfig *config, InputMethod_TextAvoidInfo **avoidInfo); + +/** + * @brief Get selection from TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + * @param start Represents selection start position. + * @param end Represents selection end position. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_GetSelection(InputMethod_TextConfig *config, int32_t *start, int32_t *end); +/** + * @brief Get window id from TextConfig. + * + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance which will be get from. + * @param windowId The window ID of the application currently bound to the input method. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextConfig_GetWindowId(InputMethod_TextConfig *config, int32_t *windowId); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_TEXT_CONFIG_CAPI_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_text_editor_proxy_capi.h b/inputmethod/include/inputmethod_text_editor_proxy_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..2a6b9f08a4598079629fb88ae2ea5edfb5ae61f6 --- /dev/null +++ b/inputmethod/include/inputmethod_text_editor_proxy_capi.h @@ -0,0 +1,702 @@ +/* + * 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_text_editor_proxy_capi.h + * + * @brief Provides functions for getting requests and notifications from input method. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_TEXT_EDITOR_PROXY_CAPI_H +#define OHOS_INPUTMETHOD_TEXT_EDITOR_PROXY_CAPI_H +#include + +#include "inputmethod_private_command_capi.h" +#include "inputmethod_text_config_capi.h" +#include "inputmethod_types_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/** + * @brief Define the InputMethod_TextEditorProxy structure type. + * + * Provides methods for getting requests and notifications from input method.\n + * When input method sends request or notification to editor, the methods will be called.\n + * + * @since 12 + */ +typedef struct InputMethod_TextEditorProxy InputMethod_TextEditorProxy; + +/** + * @brief Defines the function called when input method getting text config. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetGetTextConfigFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance. + * @param config Represents a pointer to an {@link InputMethod_TextConfig} instance. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_GetTextConfigFunc)( + InputMethod_TextEditorProxy *textEditorProxy, InputMethod_TextConfig *config); +/** + * @brief Defines the function called when input method inserting text. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetInsertTextFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to the {@link InputMethod_TextEditorProxy} instance which will be set + * in. + * @param text Represents a pointer to the text to be inserted. + * @param length Represents the length of the text to be inserted. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_InsertTextFunc)( + InputMethod_TextEditorProxy *textEditorProxy, const char16_t *text, size_t length); +/** + * @brief Defines the function called when input method deleting text forward. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetDeleteForwardFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to the {@link InputMethod_TextEditorProxy} instance which will be set + * in. + * @param length Represents the length of the text to be deleted. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_DeleteForwardFunc)(InputMethod_TextEditorProxy *textEditorProxy, int32_t length); +/** + * @brief Defines the function called when input method deleting text backward. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetDeleteForwardFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to the {@link InputMethod_TextEditorProxy} instance which will be set + * in. + * @param length Represents the length of the text to be deleted. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_DeleteBackwardFunc)(InputMethod_TextEditorProxy *textEditorProxy, int32_t length); +/** + * @brief Called when input method notifying keyboard status. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetSendKeyboardStatusFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param keyboardStatus Keyboard status, which is defined in {@link InputMethod_KeyboardStatus}. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_SendKeyboardStatusFunc)( + InputMethod_TextEditorProxy *textEditorProxy, InputMethod_KeyboardStatus keyboardStatus); +/** + * @brief Called when input method sending enter key. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetSendEnterKeyFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param enterKeyType Enter key type, which is defined in {@link InputMethod_EnterKeyType}. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_SendEnterKeyFunc)( + InputMethod_TextEditorProxy *textEditorProxy, InputMethod_EnterKeyType enterKeyType); +/** + * @brief Called when input method requesting to move cursor. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetMoveCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param direction Represents the direction of the cursor movement, which is defined in {@link InputMethod_Direction}. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_MoveCursorFunc)( + InputMethod_TextEditorProxy *textEditorProxy, InputMethod_Direction direction); +/** + * @brief Called when input method requesting to set selection. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetHandleSetSelectionFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param start Represents the start position of the selection. + * @param end Represents the end position of the selection. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_HandleSetSelectionFunc)( + InputMethod_TextEditorProxy *textEditorProxy, int32_t start, int32_t end); +/** + * @brief Called when input method sending extend action. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetHandleExtendActionFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param action Represents the extend action, which is defined in {@link InputMethod_ExtendAction}. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_HandleExtendActionFunc)( + InputMethod_TextEditorProxy *textEditorProxy, InputMethod_ExtendAction action); +/** + * @brief Called when input method requesting to get left text of cursor. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetGetLeftTextOfCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param number Represents the number of characters to be get. + * @param text Represents the left text of cursor, you need to assing this parameter. + * @param length Represents the length of the left text of cursor, you need to assing this parameter. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_GetLeftTextOfCursorFunc)( + InputMethod_TextEditorProxy *textEditorProxy, int32_t number, char16_t text[], size_t *length); +/** + * @brief Called when input method requesting to get right text of cursor. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetGetRightTextOfCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param number Represents the number of characters to be get. + * @param text Represents the right text of cursor, you need to assing this parameter. + * @param length Represents the length of the right text of cursor. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_GetRightTextOfCursorFunc)( + InputMethod_TextEditorProxy *textEditorProxy, int32_t number, char16_t text[], size_t *length); +/** + * @brief Called when input method requesting to get text index at cursor. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetGetTextIndexAtCursorFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @return Returns the index of text at cursor. + * @since 12 + */ +typedef int32_t (*OH_TextEditorProxy_GetTextIndexAtCursorFunc)(InputMethod_TextEditorProxy *textEditorProxy); +/** + * @brief Called when input method sending private command. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetReceivePrivateCommandFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param privateCommand Private command from input method. + * @param size Size of private command. + * @return Returns the result of handling private command. + * @since 12 + */ +typedef int32_t (*OH_TextEditorProxy_ReceivePrivateCommandFunc)( + InputMethod_TextEditorProxy *textEditorProxy, InputMethod_PrivateCommand *privateCommand[], size_t size); +/** + * @brief Called when input method setting preview text. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetReceivePrivateCommandFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @param text Represents text to be previewd. + * @param length Length of preview text. + * @param start Start position of preview text. + * @param end End position of preview text. + * @return Returns the result of setting preview text. + * @since 12 + */ +typedef int32_t (*OH_TextEditorProxy_SetPreviewTextFunc)( + InputMethod_TextEditorProxy *textEditorProxy, const char16_t text[], size_t length, int32_t start, int32_t end); +/** + * @brief Called when input method finishing preview text. + * + * You need to implement this function, set it to {@link InputMethod_TextEditorProxy} through {@link + * OH_TextEditorProxy_SetReceivePrivateCommandFunc}, and use {@link OH_InputMethodController_Attach} to complete the + * registration.\n + * + * @param textEditorProxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set in. + * @since 12 + */ +typedef void (*OH_TextEditorProxy_FinishTextPreviewFunc)(InputMethod_TextEditorProxy *textEditorProxy); + +/** + * @brief Create a new {@link InputMethod_TextEditorProxy} instance. + * + * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_TextEditorProxy} + * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. + * @since 12 + */ +InputMethod_TextEditorProxy *OH_TextEditorProxy_Create(void); +/** + * @brief Destroy a {@link InputMethod_TextEditorProxy} instance. + * + * @param proxy The {@link InputMethod_TextEditorProxy} instance to be destroyed. + * @since 12 + */ +void OH_TextEditorProxy_Destroy(InputMethod_TextEditorProxy *proxy); +/** + * @brief Set function {@link OH_TextEditorProxy_GetTextConfigFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param getTextConfigFunc Represents function {@link OH_TextEditorProxy_GetTextConfigFunc} which will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetGetTextConfigFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextConfigFunc getTextConfigFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_InsertTextFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param insertTextFunc Represents function {@link OH_TextEditorProxy_InsertTextFunc} which will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetInsertTextFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_InsertTextFunc insertTextFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_SetDeleteForwardFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param deleteForwardFunc Represents function {@link OH_TextEditorProxy_DeleteForwardFunc} which will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetDeleteForwardFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteForwardFunc deleteForwardFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_DeleteBackwardFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param deleteBackwardFunc Represents function {@link OH_TextEditorProxy_DeleteBackwardFunc} which will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetDeleteBackwardFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteBackwardFunc deleteBackwardFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param sendKeyboardStatusFunc Represents function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} which will be + * set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetSendKeyboardStatusFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendKeyboardStatusFunc sendKeyboardStatusFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_SendEnterKeyFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param sendEnterKeyFunc Represents function {@link OH_TextEditorProxy_SendEnterKeyFunc} which will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetSendEnterKeyFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendEnterKeyFunc sendEnterKeyFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_MoveCursorFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param moveCursorFunc Represents function {@link OH_TextEditorProxy_MoveCursorFunc} which will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetMoveCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_MoveCursorFunc moveCursorFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_HandleSetSelectionFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param handleSetSelectionFunc Represents function {@link OH_TextEditorProxy_HandleSetSelectionFunc} which will be + * set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetHandleSetSelectionFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleSetSelectionFunc handleSetSelectionFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_HandleExtendActionFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param handleExtendActionFunc Represents function {@link OH_TextEditorProxy_HandleExtendActionFunc} which will be + * set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetHandleExtendActionFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleExtendActionFunc handleExtendActionFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param getLeftTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} which will + * be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetGetLeftTextOfCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetLeftTextOfCursorFunc getLeftTextOfCursorFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param getRightTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} which + * will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetGetRightTextOfCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetRightTextOfCursorFunc getRightTextOfCursorFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param getTextIndexAtCursorFunc Represents function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} which + * will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetGetTextIndexAtCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextIndexAtCursorFunc getTextIndexAtCursorFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param receivePrivateCommandFunc Represents function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} which + * will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetReceivePrivateCommandFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_ReceivePrivateCommandFunc receivePrivateCommandFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_SetPreviewTextFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param setPreviewTextFunc Represents function {@link OH_TextEditorProxy_SetPreviewTextFunc} which will be set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetSetPreviewTextFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SetPreviewTextFunc setPreviewTextFunc); +/** + * @brief Set function {@link OH_TextEditorProxy_FinishTextPreviewFunc} into {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be set function in. + * @param finishTextPreviewFunc Represents function {@link OH_TextEditorProxy_FinishTextPreviewFunc} which will be + * set. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_SetFinishTextPreviewFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_FinishTextPreviewFunc finishTextPreviewFunc); + +/** + * @brief Get function {@link OH_TextEditorProxy_GetTextConfigFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param getTextConfigFunc Represents function {@link OH_TextEditorProxy_GetTextConfigFunc} which will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetGetTextConfigFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextConfigFunc *getTextConfigFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_InsertTextFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param insertTextFunc Represents function {@link OH_TextEditorProxy_InsertTextFunc} which will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetInsertTextFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_InsertTextFunc *insertTextFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_DeleteForwardFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param deleteForwardFunc Represents function {@link OH_TextEditorProxy_DeleteForwardFunc} which will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetDeleteForwardFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteForwardFunc *deleteForwardFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_DeleteBackwardFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param deleteBackwardFunc Represents function {@link OH_TextEditorProxy_DeleteBackwardFunc} which will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetDeleteBackwardFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_DeleteBackwardFunc *deleteBackwardFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param sendKeyboardStatusFunc Represents function {@link OH_TextEditorProxy_SendKeyboardStatusFunc} which will be + * get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetSendKeyboardStatusFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendKeyboardStatusFunc *sendKeyboardStatusFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_SendEnterKeyFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param sendEnterKeyFunc Represents function {@link OH_TextEditorProxy_SendEnterKeyFunc} which will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetSendEnterKeyFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SendEnterKeyFunc *sendEnterKeyFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_MoveCursorFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param moveCursorFunc Represents function {@link OH_TextEditorProxy_MoveCursorFunc} which will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetMoveCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_MoveCursorFunc *moveCursorFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_HandleSetSelectionFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param handleSetSelectionFunc Represents function {@link OH_TextEditorProxy_HandleSetSelectionFunc} which will be + * get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetHandleSetSelectionFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleSetSelectionFunc *handleSetSelectionFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_HandleExtendActionFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param handleExtendActionFunc Represents function {@link OH_TextEditorProxy_HandleExtendActionFunc} which will be + * get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetHandleExtendActionFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_HandleExtendActionFunc *handleExtendActionFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param getLeftTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetLeftTextOfCursorFunc} which will + * be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetGetLeftTextOfCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetLeftTextOfCursorFunc *getLeftTextOfCursorFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param getRightTextOfCursorFunc Represents function {@link OH_TextEditorProxy_GetRightTextOfCursorFunc} which + * will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetGetRightTextOfCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetRightTextOfCursorFunc *getRightTextOfCursorFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param getTextIndexAtCursorFunc Represents function {@link OH_TextEditorProxy_GetTextIndexAtCursorFunc} which + * will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetGetTextIndexAtCursorFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_GetTextIndexAtCursorFunc *getTextIndexAtCursorFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param receivePrivateCommandFunc Represents function {@link OH_TextEditorProxy_ReceivePrivateCommandFunc} which + * will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetReceivePrivateCommandFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_ReceivePrivateCommandFunc *receivePrivateCommandFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_SetPreviewTextFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param setPreviewTextFunc Represents function {@link OH_TextEditorProxy_SetPreviewTextFunc} which will be get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetSetPreviewTextFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_SetPreviewTextFunc *setPreviewTextFunc); +/** + * @brief Get function {@link OH_TextEditorProxy_FinishTextPreviewFunc} from {@link InputMethod_TextEditorProxy}. + * + * @param proxy Represents a pointer to an {@link InputMethod_TextEditorProxy} instance which will be get function + * from. + * @param finishTextPreviewFunc Represents function {@link OH_TextEditorProxy_FinishTextPreviewFunc} which will be + * get. + * @return Returns a specific error code. + * {@link IME_ERR_OK} - success. + * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. + * Specific error codes can be referenced {@link InputMethod_ErrorCode}. + * @since 12 + */ +InputMethod_ErrorCode OH_TextEditorProxy_GetFinishTextPreviewFunc( + InputMethod_TextEditorProxy *proxy, OH_TextEditorProxy_FinishTextPreviewFunc *finishTextPreviewFunc); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_TEXT_EDITOR_PROXY_CAP_H \ No newline at end of file diff --git a/inputmethod/include/inputmethod_types_capi.h b/inputmethod/include/inputmethod_types_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..0fc88c45514054cb20d41bcc77506692d228bc60 --- /dev/null +++ b/inputmethod/include/inputmethod_types_capi.h @@ -0,0 +1,308 @@ +/* +* 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 InputMethod + * @{ + * + * @brief InputMethod provides functions to use input methods and develop input methods. + * + * @since 12 + */ + +/** + * @file inputmethod_types_capi.h + * + * @brief Provides the input method types. + * + * @library libohinputmethod.so + * @kit IMEKit + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 12 + * @version 1.0 + */ +#ifndef OHOS_INPUTMETHOD_TYPES_CAPI_H +#define OHOS_INPUTMETHOD_TYPES_CAPI_H +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +/** + * @brief Keyboard status. + * + * @since 12 + */ +typedef enum InputMethod_KeyboardStatus { + /** + * The keyboard status is none. + */ + IME_KEYBOARD_STATUS_NONE = 0, + /** + * The keyboard status is hide. + */ + IME_KEYBOARD_STATUS_HIDE = 1, + /** + * The keyboard status is show. + */ + IME_KEYBOARD_STATUS_SHOW = 2, +} InputMethod_KeyboardStatus; + +/** + * @brief Enter key type. + * + * @since 12 + */ +typedef enum InputMethod_EnterKeyType { + /** + * The enter key type is UNSPECIFIED. + */ + IME_ENTER_KEY_UNSPECIFIED = 0, + /** + * The enter key type is NONE. + */ + IME_ENTER_KEY_NONE = 1, + /** + * The enter key type is GO. + */ + IME_ENTER_KEY_GO = 2, + /** + * The enter key type is SEARCH. + */ + IME_ENTER_KEY_SEARCH = 3, + /** + * The enter key type is SEND. + */ + IME_ENTER_KEY_SEND = 4, + /** + * The enter key type is NEXT. + */ + IME_ENTER_KEY_NEXT = 5, + /** + * The enter key type is DONE. + */ + IME_ENTER_KEY_DONE = 6, + /** + * The enter key type is PREVIOUS. + */ + IME_ENTER_KEY_PREVIOUS = 7, + /** + * The enter key type is NEWLINE. + */ + IME_ENTER_KEY_NEWLINE = 8, +} InputMethod_EnterKeyType; + +/** + * @brief Direction. + * + * @since 12 + */ +typedef enum InputMethod_Direction { + /** + * The direction is NONE. + */ + IME_DIRECTION_NONE = 0, + /** + * The direction is UP. + */ + IME_DIRECTION_UP = 1, + /** + * The direction is DOWN. + */ + IME_DIRECTION_DOWN = 2, + /** + * The direction is LEFT. + */ + IME_DIRECTION_LEFT = 3, + /** + * The direction is RIGHT. + */ + IME_DIRECTION_RIGHT = 4, +} InputMethod_Direction; + +/** + * @brief The extend action. + * + * @since 12 + */ +typedef enum InputMethod_ExtendAction { + /** + * Select all text. + */ + IME_EXTEND_ACTION_SELECT_ALL = 0, + /** + * Cut selected text. + */ + IME_EXTEND_ACTION_CUT = 3, + /** + * Copy selected text. + */ + IME_EXTEND_ACTION_COPY = 4, + /** + * Paste from paste board. + */ + IME_EXTEND_ACTION_PASTE = 5, +} InputMethod_ExtendAction; + +/** + * @brief The text input type. + * + * @since 12 + */ +typedef enum InputMethod_TextInputType { + /** + * The text input type is NONE. + */ + IME_TEXT_INPUT_TYPE_NONE = -1, + /** + * The text input type is TEXT. + */ + IME_TEXT_INPUT_TYPE_TEXT = 0, + /** + * The text input type is MULTILINE. + */ + IME_TEXT_INPUT_TYPE_MULTILINE = 1, + /** + * The text input type is NUMBER. + */ + IME_TEXT_INPUT_TYPE_NUMBER = 2, + /** + * The text input type is PHONE. + */ + IME_TEXT_INPUT_TYPE_PHONE = 3, + /** + * The text input type is DATETIME. + */ + IME_TEXT_INPUT_TYPE_DATETIME = 4, + /** + * The text input type is EMAIL ADDRESS. + */ + IME_TEXT_INPUT_TYPE_EMAIL_ADDRESS = 5, + /** + * The text input type is URL. + */ + IME_TEXT_INPUT_TYPE_URL = 6, + /** + * The text input type is VISIBLE PASSWORD. + */ + IME_TEXT_INPUT_TYPE_VISIBLE_PASSWORD = 7, + /** + * The text input type is NUMBER PASSWORD. + */ + IME_TEXT_INPUT_TYPE_NUMBER_PASSWORD = 8, + /** + * The text input type is SCREEN LOCK PASSWORD. + */ + IME_TEXT_INPUT_TYPE_SCREEN_LOCK_PASSWORD = 9, + /** + * The text input type is USER NAME. + */ + IME_TEXT_INPUT_TYPE_USER_NAME = 10, + /** + * The text input type is NEW PASSWORD. + */ + IME_TEXT_INPUT_TYPE_NEW_PASSWORD = 11, + /** + * The text input type is NUMBER DECIMAL. + */ + IME_TEXT_INPUT_TYPE_NUMBER_DECIMAL = 12, +} InputMethod_TextInputType; + +/** + * @brief The value type of command data. + * + * @since 12 + */ +typedef enum InputMethod_CommandValueType { + /** + * Value type is NONE. + */ + IME_COMMAND_VALUE_TYPE_NONE = 0, + /** + * Value type is STRING. + */ + IME_COMMAND_VALUE_TYPE_STRING = 1, + /** + * Value type is BOOL. + */ + IME_COMMAND_VALUE_TYPE_BOOL = 2, + /** + * Value type is INT32. + */ + IME_COMMAND_VALUE_TYPE_INT32 = 3, +} InputMethod_CommandValueType; + +/** + * @brief The value type of command data. + * + * @since 12 + */ +typedef enum InputMethod_ErrorCode { + /** + * @error The error code in the correct case. + */ + IME_ERR_OK = 0, + + /** + * @error The error code when error is undefined. + */ + IME_ERR_UNDEFINED = 1, + /** + * @error The error code when parameter check failed. + */ + IME_ERR_PARAMCHECK = 401, + /** + * @error The error code when the bundle manager error. + */ + IME_ERR_PACKAGEMANAGER = 12800001, + /** + * @error The error code when input method engine error. + */ + IME_ERR_IMENGINE = 12800002, + /** + * @error The error code when input method client error. + */ + IME_ERR_IMCLIENT = 12800003, + /** + * @error The error code when configuration persistence error. + */ + IME_ERR_CONFIG_PERSIST = 12800005, + /** + * @error The error code when input method controller error. + */ + IME_ERR_CONTROLLER = 12800006, + /** + * @error The error code when input method setting error. + */ + IME_ERR_SETTINGS = 12800007, + /** + * @error The error code when input method manager service error. + */ + IME_ERR_IMMS = 12800008, + /** + * @error The error code when input method client detached. + */ + IME_ERR_DETACHED = 12800009, + /** + * @error The error code when unexpected null pointer. + */ + IME_ERR_NULL_POINTER = 12802000, + /** + * @error The error code when query failed. + */ + IME_ERR_QUERY_FAILED = 12802001, +} InputMethod_ErrorCode; +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} */ +#endif // OHOS_INPUTMETHOD_TYPES_CAPI_H \ No newline at end of file diff --git a/inputmethod/libohinputmethodndk.json b/inputmethod/libohinputmethodndk.json new file mode 100644 index 0000000000000000000000000000000000000000..0c026b2e6bc2707f68cfce8f01e07e2598cf5c3a --- /dev/null +++ b/inputmethod/libohinputmethodndk.json @@ -0,0 +1,314 @@ +[ + { + "first_introduced": "12", + "name": "OH_InputMethodController_Attach" + }, + { + "first_introduced": "12", + "name": "OH_InputMethodController_Detach" + }, + { + "first_introduced": "12", + "name": "OH_InputMethodProxy_ShowKeyboard" + }, + { + "first_introduced": "12", + "name": "OH_InputMethodProxy_HideKeyboard" + }, + { + "first_introduced": "12", + "name": "OH_InputMethodProxy_NotifySelectionChange" + }, + { + "first_introduced": "12", + "name": "OH_InputMethodProxy_NotifyConfigurationChange" + }, + { + "first_introduced": "12", + "name": "OH_InputMethodProxy_NotifyCursorUpdate" + }, + { + "first_introduced": "12", + "name": "OH_InputMethodProxy_SendPrivateCommand" + }, + { + "first_introduced": "12", + "name": "OH_CursorInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_CursorInfo_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_CursorInfo_SetRect" + }, + { + "first_introduced": "12", + "name": "OH_CursorInfo_GetRect" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_Create" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_SetInputType" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_SetEnterKeyType" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_SetPreviewTextSupport" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_SetSelection" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_SetWindowId" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_GetInputType" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_GetEnterKeyType" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_IsPreviewTextSupported" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_GetCursorInfo" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_GetTextAvoidInfo" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_GetSelection" + }, + { + "first_introduced": "12", + "name": "OH_TextConfig_GetWindowId" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_Create" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetGetTextConfigFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetInsertTextFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetDeleteForwardFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetDeleteBackwardFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetSendKeyboardStatusFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetSendEnterKeyFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetMoveCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetHandleSetSelectionFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetHandleExtendActionFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetGetLeftTextOfCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetGetRightTextOfCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetGetTextIndexAtCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetReceivePrivateCommandFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetSetPreviewTextFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_SetFinishTextPreviewFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetGetTextConfigFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetInsertTextFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetDeleteForwardFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetDeleteBackwardFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetSendKeyboardStatusFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetSendEnterKeyFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetMoveCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetHandleSetSelectionFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetHandleExtendActionFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetGetLeftTextOfCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetGetRightTextOfCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetGetTextIndexAtCursorFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetReceivePrivateCommandFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetSetPreviewTextFunc" + }, + { + "first_introduced": "12", + "name": "OH_TextEditorProxy_GetFinishTextPreviewFunc" + }, + { + "first_introduced": "12", + "name": "OH_AttachOptions_Create" + }, + { + "first_introduced": "12", + "name": "OH_AttachOptions_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_AttachOptions_IsShowKeyboard" + }, + { + "first_introduced": "12", + "name": "OH_TextAvoidInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_TextAvoidInfo_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_TextAvoidInfo_SetPositionY" + }, + { + "first_introduced": "12", + "name": "OH_TextAvoidInfo_SetHeight" + }, + { + "first_introduced": "12", + "name": "OH_TextAvoidInfo_GetPositionY" + }, + { + "first_introduced": "12", + "name": "OH_TextAvoidInfo_GetHeight" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_Create" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_SetKey" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_SetBoolValue" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_SetIntValue" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_SetStrValue" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_GetKey" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_GetValueType" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_GetBoolValue" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_GetIntValue" + }, + { + "first_introduced": "12", + "name": "OH_PrivateCommand_GetStrValue" + } +] \ No newline at end of file diff --git a/multimedia/audio_framework/BUILD.gn b/multimedia/audio_framework/BUILD.gn index 3445ac0be4c355fcf0121ff84df60005c348be2b..e3a53b3cf93cd734a46e6c067705fe3cc7687753 100644 --- a/multimedia/audio_framework/BUILD.gn +++ b/multimedia/audio_framework/BUILD.gn @@ -18,7 +18,9 @@ ohos_ndk_headers("ohaudio_header") { dest_dir = "$ndk_headers_out_dir/ohaudio" sources = [ "audio_capturer/native_audiocapturer.h", + "audio_manager/native_audio_manager.h", "audio_manager/native_audio_routing_manager.h", + "audio_manager/native_audio_session_manager.h", "audio_renderer/native_audiorenderer.h", "common/native_audio_common.h", "common/native_audio_device_base.h", @@ -37,8 +39,10 @@ ohos_ndk_library("libohaudio_ndk") { "ohaudio/native_audiostreambuilder.h", "ohaudio/native_audiorenderer.h", "ohaudio/native_audiocapturer.h", + "ohaudio/native_audio_manager.h", "ohaudio/native_audio_routing_manager.h", "ohaudio/native_audio_common.h", "ohaudio/native_audio_device_base.h", + "ohaudio/native_audio_session_manager.h", ] } diff --git a/multimedia/audio_framework/audio_manager/native_audio_manager.h b/multimedia/audio_framework/audio_manager/native_audio_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..24c37f94b8bf26a89666d3749e06d192c7272a86 --- /dev/null +++ b/multimedia/audio_framework/audio_manager/native_audio_manager.h @@ -0,0 +1,84 @@ +/* + * 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 OHAudio + * @{ + * + * @brief Provide the definition of the C interface for the audio module. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 12 + * @version 1.0 + */ + +/** + * @file native_audio_manager.h + * + * @brief Declare audio manager related interfaces. + * + * @library libohaudio.so + * @syscap SystemCapability.Multimedia.Audio.Core + * @kit AudioKit + * @since 12 + * @version 1.0 + */ +#ifndef NATIVE_AUDIO_MANAGER_H +#define NATIVE_AUDIO_MANAGER_H + +#include "native_audio_common.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Declare the audio manager. + * The handle of audio manager is used for audio management related functions. + * + * @since 12 + */ +typedef struct OH_AudioManager OH_AudioManager; + +/** + * @brief Get audio manager handle. + * + * @param audioManager the {@link OH_AudioManager} handle received from this function. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioManager is nullptr; + * @since 12 + */ +OH_AudioCommon_Result OH_GetAudioManager(OH_AudioManager **audioManager); + +/** + * @brief Get audio scene. + * @param audioManager the {@link OH_AudioManager} handle received from {@link OH_GetAudioManager}. + * @param scene the {@link OH_AudioScene} pointer to receive the result. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioManager is nullptr; + * 2.The param of scene is nullptr. + * @since 12 + */ +OH_AudioCommon_Result OH_GetAudioScene(OH_AudioManager* manager, OH_AudioScene *scene); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // NATIVE_AUDIO_ROUTING_MANAGER_H \ No newline at end of file diff --git a/multimedia/audio_framework/audio_manager/native_audio_routing_manager.h b/multimedia/audio_framework/audio_manager/native_audio_routing_manager.h index a34a8fbc00546d111bb36151698b5b071c3eb0c6..b5f363ac7dd3bfe72451f9315f76fb324cc82d82 100644 --- a/multimedia/audio_framework/audio_manager/native_audio_routing_manager.h +++ b/multimedia/audio_framework/audio_manager/native_audio_routing_manager.h @@ -113,6 +113,75 @@ OH_AudioCommon_Result OH_AudioRoutingManager_GetDevices( OH_AudioDevice_Flag deviceFlag, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray); +/** + * @brief Get available devices by device usage. + * + * @param audioRoutingManager the {@link OH_AudioRoutingManager} handle returned + * by {@link OH_AudioManager_GetAudioRoutingManager}. + * @param deviceUsage the {@link OH_AudioDevice_Usage}. + * @param audioDeviceDescriptorArray the {@link OH_AudioDeviceDescriptorArray} + * pointer variable which will be set the audio device descriptors value + * Do not release the audioDeviceDescriptorArray pointer separately + * instead call {@link OH_AudioRoutingManager_ReleaseDevices} to release the DeviceDescriptor array + * when it is no use anymore. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioRoutingManager is nullptr; + * 2.The param of deviceUsage is invalid; + * 3.The param of audioDeviceDescriptorArray is nullptr. + * {@link AUDIOCOMMON_RESULT_ERROR_NO_MEMORY} No memory error. + * @since 12 + */ +OH_AudioCommon_Result OH_AudioRoutingManager_GetAvailableDevices( + OH_AudioRoutingManager *audioRoutingManager, + OH_AudioDevice_Usage deviceUsage, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray); + +/** + * @brief Get preferred ouput devices by audio usage. + * + * @param audioRoutingManager the {@link OH_AudioRoutingManager} handle returned + * by {@link OH_AudioManager_GetAudioRoutingManager}. + * @param streamUsage the {@link OH_AudioStream_Usage}. + * @param audioDeviceDescriptorArray the {@link OH_AudioDeviceDescriptorArray} + * pointer variable which will be set the audio device descriptors value + * Do not release the audioDeviceDescriptorArray pointer separately + * instead call {@link OH_AudioRoutingManager_ReleaseDevices} to release the DeviceDescriptor array + * when it is no use anymore. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioRoutingManager is nullptr; + * 2.The param of streamUsage is invalid; + * 3.The param of audioDeviceDescriptorArray is nullptr. + * {@link AUDIOCOMMON_RESULT_ERROR_NO_MEMORY} No memory error. + * @since 12 + */ +OH_AudioCommon_Result OH_AudioRoutingManager_GetPreferredOutputDevice( + OH_AudioRoutingManager *audioRoutingManager, + OH_AudioStream_Usage streamUsage, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray); + +/** + * @brief Get preferred input devices by audio source type. + * @param audioRoutingManager the {@link OH_AudioRoutingManager} handle returned + * by {@link OH_AudioManager_GetAudioRoutingManager}. + * @param sourceType the {@link OH_AudioStream_SourceType}. + * @param audioDeviceDescriptorArray the {@link OH_AudioDeviceDescriptorArray} + * pointer variable which will be set the audio device descriptors value + * Do not release the audioDeviceDescriptorArray pointer separately + * instead call {@link OH_AudioRoutingManager_ReleaseDevices} to release the DeviceDescriptor array + * when it is no use anymore. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioRoutingManager is nullptr; + * 2.The param of sourceType is invalid; + * 3.The param of audioDeviceDescriptorArray is nullptr. + * {@link AUDIOCOMMON_RESULT_ERROR_NO_MEMORY} No memory error. + * @since 12 + */ +OH_AudioCommon_Result OH_AudioRoutingManager_GetPreferredInputDevice(OH_AudioRoutingManager *audioRoutingManager, + OH_AudioStream_SourceType sourceType, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray); /** * @brief Register the device change callback of the audio routing manager. * @@ -168,6 +237,61 @@ OH_AudioCommon_Result OH_AudioRoutingManager_UnregisterDeviceChangeCallback( OH_AudioCommon_Result OH_AudioRoutingManager_ReleaseDevices( OH_AudioRoutingManager *audioRoutingManager, OH_AudioDeviceDescriptorArray *audioDeviceDescriptorArray); + +/** + * @brief This type defines the callback function that is used to receive the audio devices' block status. + * + * @param audioDeviceDescriptorArray The {@link OH_AudioDeviceDescriptorArray} + * pointer variable which will be set the audio device descriptors value. + * Do not release the audioDeviceDescriptorArray pointer separately instead of calling + * {@link OH_AudioRoutingManager_ReleaseDevices} to release the DeviceDescriptor array when it is no use anymore. + * @param status The {@link OH_AudioDevice_BlockStatus} is the block status. + * @param userData User data which is passed by user. + * @since 13 + */ +typedef void (*OH_AudioRoutingManager_OnDeviceBlockStatusCallback)( + OH_AudioDeviceDescriptorArray *audioDeviceDescriptorArray, + OH_AudioDevice_BlockStatus status, + void *userData); + +/** + * @brief Query whether microphone block detection is supported on current device. + * + * @param audioRoutingManager the {@link OH_AudioRoutingManager} handle returned by + * {@link OH_AudioManager_GetAudioRoutingManager}. + * @param supported query result. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioRoutingManager is nullptr; + * 2.The param of supported is nullptr. + * @since 13 + */ +OH_AudioCommon_Result OH_AudioRoutingManager_IsMicBlockDetectionSupported( + OH_AudioRoutingManager *audioRoutingManager, + bool *supported); + +/** + * @brief Set the microphone block status callback. Before using this function, users should query whether block + * detection is supported on current device. The caller will receive the callback only when it is recording + * and the used microphones' block status have changed. Currently, block detecting is only support for microphones + * located on the local device. + * + * @param audioRoutingManager The {@link OH_AudioRoutingManager} handle returned by + * {@link OH_AudioManager_GetAudioRoutingManager}. + * @param callback The function pointer will point to the callback function that is used to receive the block status. + * @param userData User data which is passed by user. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioRoutingManager is nullptr; + * 2.The param of callback is nullptr. + * @since 13 + */ +OH_AudioCommon_Result OH_AudioRoutingManager_SetMicBlockStatusCallback( + OH_AudioRoutingManager *audioRoutingManager, + OH_AudioRoutingManager_OnDeviceBlockStatusCallback callback, + void *userData); #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/audio_manager/native_audio_session_manager.h b/multimedia/audio_framework/audio_manager/native_audio_session_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..08ae357486363ddf5aa59e5e06b3ce6048a93056 --- /dev/null +++ b/multimedia/audio_framework/audio_manager/native_audio_session_manager.h @@ -0,0 +1,222 @@ +/* + * 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 OHAudio + * @{ + * + * @brief Provide the definition of the C interface for the audio module. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 12 + * @version 1.0 + */ + +/** + * @file native_audio_session_manager.h + * + * @brief Declare audio session manager related interfaces. + * + * This file interfaces are used for the creation of audioSessionManager + * as well as activating/deactivating the audio session + * as well as checking and listening the audio session decativated events. + * + * @library libohaudio.so + * @syscap SystemCapability.Multimedia.Audio.Core + * @kit AudioKit + * @since 12 + * @version 1.0 + */ + +#ifndef NATIVE_AUDIO_SESSION_MANAGER_H +#define NATIVE_AUDIO_SESSION_MANAGER_H + +#include "native_audio_common.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Declare the audio session manager. + * The handle of audio session manager is used for audio session related functions. + * + * @since 12 + */ +typedef struct OH_AudioSessionManager OH_AudioSessionManager; + +/** + * @brief Declare the audio concurrency modes. + * + * @since 12 + */ +typedef enum { + /** + * @brief default mode + */ + CONCURRENCY_DEFAULT = 0, + + /** + * @brief mix with others mode + */ + CONCURRENCY_MIX_WITH_OTHERS = 1, + + /** + * @brief duck others mode + */ + CONCURRENCY_DUCK_OTHERS = 2, + + /** + * @brief pause others mode + */ + CONCURRENCY_PAUSE_OTHERS = 3, +} OH_AudioSession_ConcurrencyMode; + +/** + * @brief Declare the audio deactivated reasons. + * + * @since 12 + */ +typedef enum { + /** + * @brief deactivated because of lower priority + */ + DEACTIVATED_LOWER_PRIORITY = 0, + + /** + * @brief deactivated because of timing out + */ + DEACTIVATED_TIMEOUT = 1, +} OH_AudioSession_DeactivatedReason; + +/** + * @brief declare the audio session strategy + * + * @since 12 + */ +typedef struct OH_AudioSession_Strategy { + /** + * @brief audio session concurrency mode + */ + OH_AudioSession_ConcurrencyMode concurrencyMode; +} OH_AudioSession_Strategy; + +/** + * @brief declare the audio session deactivated event + * + * @since 12 + */ +typedef struct OH_AudioSession_DeactivatedEvent { + /** + * @brief audio session deactivated reason + */ + OH_AudioSession_DeactivatedReason reason; +} OH_AudioSession_DeactivatedEvent; + +/** + * @brief This function pointer will point to the callback function that + * is used to return the audio session deactivated event. + * + * @param event the {@link #OH_AudioSession_DeactivatedEvent} deactivated triggering event. + * @since 12 + */ +typedef int32_t (*OH_AudioSession_DeactivatedCallback) ( + OH_AudioSession_DeactivatedEvent event); + +/** + * @brief Fetch the audio session manager handle. + * The audio session manager handle should be the first parameter in audio session related functions + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * which will be returned as the output parameter + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error + * @since 12 + */ +OH_AudioCommon_Result OH_AudioManager_GetAudioSessionManager( + OH_AudioSessionManager **audioSessionManager); + +/** + * @brief Activate the audio session for the current pid application. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param strategy pointer of {@link #OH_AudioSession_Strategy} + * which is used for setting audio session strategy + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_REULT_INVALID_PARAM} if parameter validation fails + * or {@link #AUDIOCOMMON_RESULT_ERROR_ILLEGAL_STATE} if system illegal state + * @since 12 + */ +OH_AudioCommon_Result OH_AudioSessionManager_ActivateAudioSession( + OH_AudioSessionManager *audioSessionManager, const OH_AudioSession_Strategy *strategy); + +/** + * @brief Deactivate the audio session for the current pid application. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_REULT_INVALID_PARAM} if parameter validation fails + * or {@link #AUDIOCOMMON_RESULT_ERROR_ILLEGAL_STATE} if system illegal state + * @since 12 + */ +OH_AudioCommon_Result OH_AudioSessionManager_DeactivateAudioSession( + OH_AudioSessionManager *audioSessionManager); + +/** + * @brief Querying whether the current pid application has an activated audio session. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @return True when the current pid application has an activated audio session + * False when it does not + * @since 12 + */ +bool OH_AudioSessionManager_IsAudioSessionActivated( + OH_AudioSessionManager *audioSessionManager); + +/** + * @brief Register the audio session deactivated event callback. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param callback the {@link #OH_AudioSession_DeactivatedCallback} which is used + * to receive the deactivated event + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * @since 12 + */ +OH_AudioCommon_Result OH_AudioSessionManager_RegisterSessionDeactivatedCallback( + OH_AudioSessionManager *audioSessionManager, OH_AudioSession_DeactivatedCallback callback); + +/** + * @brief Unregister the audio session deactivated event callback. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param callback the {@link #OH_AudioSession_DeactivatedCallback} which is used + * to receive the deactivated event + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * @since 12 + */ +OH_AudioCommon_Result OH_AudioSessionManager_UnregisterSessionDeactivatedCallback( + OH_AudioSessionManager *audioSessionManager, OH_AudioSession_DeactivatedCallback callback); +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // NATIVE_AUDIO_ROUTING_MANAGER_H \ No newline at end of file diff --git a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index 226b9c9805bda7e64019c609926a41df8fa7936f..90255a7fd0c3a559765a1a4dc7d90c0f9b0657c0 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -40,8 +40,10 @@ #ifndef NATIVE_AUDIORENDERER_H #define NATIVE_AUDIORENDERER_H +#include #include #include "native_audiostream_base.h" +#include "native_audio_device_base.h" #include "multimedia/native_audio_channel_layout.h" #ifdef __cplusplus extern "C" { @@ -479,6 +481,29 @@ OH_AudioStream_Result OH_AudioRenderer_SetSilentModeAndMixWithOthers( OH_AudioStream_Result OH_AudioRenderer_GetSilentModeAndMixWithOthers( OH_AudioRenderer* renderer, bool* on); +/** + * @brief Temporarily changes the current audio device + * This function applys on audiorenderers whose StreamUsage are + * STREAM_USAGE_VOICE_COMMUNICATIN/STREAM_USAGE_VIDEO_COMMUNICATION/STREAM_USAGE_VOICE_MESSAGE. + * Setting the device will only takes effect if no other accessory such as headphones are in use. + * + * @param renderer Renderer generated by OH_AudioStreamBuilder_GenerateRenderer() + * @param deviceType The target device. The available deviceTypes are: + * EARPIECE: Built-in earpiece + * SPEAKER: Built-in speaker + * DEFAULT: System default output device + * @return result code for this function. + * {@link #AUDIOSTREAM_SUCCESS} succeed in setting the default output device + * {@link #AUDIOSTREAM_ERROR_INVALID_PARAM}: + * 1.The param of renderer is nullptr; + * 2.The param of deviceType is not valid + * {@link #AUDIOSTREAM_ERROR_ILLEGAL_STATE} This audiorenderer can not reset the output device + * {@link #AUDIOSTREAM_ERROR_SYSTEM} system error when calling this function. + * @since 12 + */ +OH_AudioStream_Result OH_AudioRenderer_SetDefaultOutputDevice( + OH_AudioRenderer* renderer, OH_AudioDevice_Type deviceType); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/common/native_audio_common.h b/multimedia/audio_framework/common/native_audio_common.h index c0051b877023fa71b57735978ef9cb312420e71a..6a50df302af275066de91d06c0a60ab0f4c2a50e 100644 --- a/multimedia/audio_framework/common/native_audio_common.h +++ b/multimedia/audio_framework/common/native_audio_common.h @@ -95,6 +95,41 @@ typedef enum { AUDIOCOMMON_RESULT_ERROR_SYSTEM = 6800301, } OH_AudioCommon_Result; +/** + * @brief Defines the audio scene. + * + * @since 12 + */ +typedef enum { + /** + * Default audio scene. + * + * @since 12 + */ + AUDIO_SCENE_DEFAULT = 0, + + /** + * Ringing scene. + * + * @since 12 + */ + AUDIO_SCENE_RINGING = 1, + + /** + * Phone call scene. + * + * @since 12 + */ + AUDIO_SCENE_PHONE_CALL = 2, + + /** + * Voice chat scene. + * + * @since 12 + */ + AUDIO_SCENE_VOICE_CHAT = 3, +} OH_AudioScene; + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/common/native_audio_device_base.h b/multimedia/audio_framework/common/native_audio_device_base.h index 6d7a6cef5dc6f525025e664c893bf81261c3f1d0..573e07fedc48fbce42989a418a165f9dbfa2d141 100644 --- a/multimedia/audio_framework/common/native_audio_device_base.h +++ b/multimedia/audio_framework/common/native_audio_device_base.h @@ -176,6 +176,55 @@ typedef enum { AUDIO_DEVICE_FLAG_ALL = 3, } OH_AudioDevice_Flag; +/** + * @brief Defines the audio device usage. + * + * @since 12 + */ +typedef enum { + /** + * @brief Device used for media ouput. + * + * @since 12 + */ + AUDIO_DEVICE_USAGE_MEDIA_OUTPUT = 1, + + /** + * @brief Device used for media input. + * + * @since 12 + */ + AUDIO_DEVICE_USAGE_MEDIA_INPUT = 2, + + /** + * @brief Device used for media, including input and output. + * + * @since 12 + */ + AUDIO_DEVICE_USAGE_MEDIA_ALL = 3, + + /** + * @brief Device used for call output. + * + * @since 12 + */ + AUDIO_DEVICE_USAGE_CALL_OUTPUT = 4, + + /** + * @brief Device used for call input. + * + * @since 12 + */ + AUDIO_DEVICE_USAGE_CALL_INPUT = 8, + + /** + * @brief Device used for call, including input and output. + * + * @since 12 + */ + AUDIO_DEVICE_USAGE_CALL_ALL = 12, +} OH_AudioDevice_Usage; + /** * @brief Declaring the audio device descriptor. * The instance is used to get more audio device detail attributes. @@ -201,6 +250,28 @@ typedef struct OH_AudioDeviceDescriptorArray { OH_AudioDeviceDescriptor **descriptors; } OH_AudioDeviceDescriptorArray; +/** + * @brief Declaring the audio device blocked status. By default, the audio device is considered as unbloked. + * + * @since 13 + */ +typedef enum { + /** + * @brief Audio device is unblocked. + * + * @since 13 + */ + AUDIO_DEVICE_UNBLOCKED = 0, + + /** + * @brief Audio Device is blocked. + * + * @since 13 + */ + AUDIO_DEVICE_BLOCKED = 1, +} OH_AudioDevice_BlockStatus; + + /** * @brief Query the device role of the target audio device descriptor. * diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index 6c1b362a49bfe01ac5a3f164c4decacccd4eab18..44dacf0d03d9a17fbb4e8b15afc81c4c23abaca4 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -439,11 +439,17 @@ typedef enum { * * @since 12 */ - AUDIOSTREAM_SOURCE_TYPE_VOICE_MESSAGE = 10 + AUDIOSTREAM_SOURCE_TYPE_VOICE_MESSAGE = 10, + /** + * Camcorder source type. + * + * @since 13 + */ + AUDIOSTREAM_SOURCE_TYPE_CAMCORDER = 13 } OH_AudioStream_SourceType; /** - * Defines the audio interrupt mode. + * @brief Defines the audio interrupt mode. * * @since 12 */ diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 165dc86317acefed2e5c60665b99e4be66e2ebe8..961c75daeeaa798a67c49fcf5724e2fdb7241a9f 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -317,10 +317,66 @@ }, { "first_introduced": "12", - "name":"OH_AudioRenderer_SetSilentModeAndMixWithOthers" + "name":"OH_AudioRenderer_SetSilentModeAndMixWithOthers" }, { "first_introduced": "12", "name":"OH_AudioRenderer_GetSilentModeAndMixWithOthers" + }, + { + "first_introduced": "12", + "name":"OH_AudioManager_GetAudioSessionManager" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_ActivateAudioSession" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_DeactivateAudioSession" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_IsAudioSessionActivated" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_RegisterSessionDeactivatedCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_UnregisterSessionDeactivatedCallback" + }, + { + "first_introduced": "12", + "name": "OH_GetAudioManager" + }, + { + "first_introduced": "12", + "name": "OH_GetAudioScene" + }, + { + "first_introduced": "12", + "name": "OH_AudioRoutingManager_GetAvailableDevices" + }, + { + "first_introduced": "12", + "name": "OH_AudioRoutingManager_GetPreferredOutputDevice" + }, + { + "first_introduced": "12", + "name": "OH_AudioRoutingManager_GetPreferredInputDevice" + }, + { + "first_introduced": "12", + "name":"OH_AudioRenderer_SetDefaultOutputDevice" + }, + { + "first_introduced": "13", + "name": "OH_AudioRoutingManager_IsMicBlockDetectionSupported" + }, + { + "first_introduced": "13", + "name": "OH_AudioRoutingManager_SetMicBlockStatusCallback" } ] diff --git a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json index 74292f25c062fd9bf13a5a538eaf70aded15c384..715c18d86205d7b2a1e446b9017e06140ca92971 100644 --- a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json +++ b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json @@ -59,10 +59,6 @@ "first_introduced": "11", "name": "OH_AVCODEC_MIMETYPE_AUDIO_G711MU" }, - { - "first_introduced": "12", - "name": "OH_AVCODEC_MIMETYPE_AUDIO_LBVC" - }, { "first_introduced": "12", "name": "OH_AVCODEC_MIMETYPE_AUDIO_APE" @@ -387,6 +383,18 @@ "first_introduced": "12", "name": "OH_MD_KEY_START_TIME" }, + { + "first_introduced": "12", + "name": "OH_MD_KEY_TRACK_START_TIME" + }, + { + "first_introduced": "12", + "name": "OH_MD_KEY_VIDEO_DECODER_OUTPUT_COLOR_SPACE" + }, + { + "first_introduced": "14", + "name": "OH_MD_KEY_VIDEO_DECODER_OUTPUT_ENABLE_VRR" + }, { "first_introduced": "10", "name": "OH_AVCodec_GetCapability" diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index 4c683158024c649dc21404fbbd054aacf9a7ccd7..8ae03c4bb792d71f2707e9a3615c86b4a6dd3691 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -279,6 +279,7 @@ OH_AVErrCode OH_AudioCodec_IsValid(OH_AVCodec *codec, bool *isValid); * {@link AV_ERR_INVALID_VAL} 3 - If the codec instance is nullptr or invalid, * the mediaKeySession is nullptr or invalid. * {@link AV_ERR_INVALID_STATE} 8 - If the codec service is invalid. + * {@link AV_ERR_NO_MEMORY}, failed to request memory. * @since 12 * @version 1.0 */ diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index c5e35031cfa4005ba8484a54ad2014aec1e8fb86..147a7268eae44b15243a603f1ae8358541e87648 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -312,14 +312,6 @@ extern const char *OH_AVCODEC_MIMETYPE_AUDIO_OPUS; */ extern const char *OH_AVCODEC_MIMETYPE_AUDIO_G711MU; -/** - * @brief Enumerates the mime type of audio low bitrate voice codec. - * - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 12 - */ -extern const char *OH_AVCODEC_MIMETYPE_AUDIO_LBVC; - /** * @brief Enumerates the mime type of audio ape codec. * @@ -940,6 +932,35 @@ extern const char *OH_MD_KEY_VIDEO_SAR; * @since 12 */ extern const char *OH_MD_KEY_START_TIME; +/** + * @brief Key for start time of track, value type is int64_t. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 12 + */ +extern const char *OH_MD_KEY_TRACK_START_TIME; +/** + * @brief Key for setting the output color space of video decoder. The value type is int32_t. + * The supported value is {@link OH_COLORSPACE_BT709_LIMIT}, see {@link OH_NativeBuffer_ColorSpace}. It is used in + * {@link OH_VideoDecoder_Configure}. If the color space conversion capability is supported and this key is configured, + * the video decoder will automatically transcode an HDR Vivid video to an SDR video with color space BT709. + * If color space conversion capability is not supported, {@link OH_VideoDecoder_Configure} returns + * {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION}. + * If the input video is not an HDR vivid video, an error {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION} will + * be reported by callback function {@link OH_AVCodecOnError}. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 12 + */ +extern const char *OH_MD_KEY_VIDEO_DECODER_OUTPUT_COLOR_SPACE; +/** + * @brief Key for describing if enable VRR or not, value type is int32_t (0 or 1): 1 is enabled, 0 otherwise. + * This is an optional key that applies only to video decoder. It is used in configure. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 14 + */ +extern const char *OH_MD_KEY_VIDEO_DECODER_OUTPUT_ENABLE_VRR; /** * @brief Media type. @@ -1198,6 +1219,9 @@ typedef enum OH_TemporalGopReferenceMode { ADJACENT_REFERENCE = 0, /** Refer to latest long-term reference frame. */ JUMP_REFERENCE = 1, + /** Uniformly scaled reference structure, which has even distribution of video frames after drop the highest + * enhance layer. The temporal group of pictures must be power of 2. */ + UNIFORMLY_SCALED_REFERENCE = 2, } OH_TemporalGopReferenceMode; #ifdef __cplusplus diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index c52df2c28f136c9543db3e4985336834473d8eb6..f4b58bcbc5882710d509f145af7035fa011254b6 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -146,6 +146,8 @@ OH_AVErrCode OH_VideoDecoder_SetSurface(OH_AVCodec *codec, OHNativeWindow *windo * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. + * {@link AV_ERR_UNSUPPORT}, unsupported features. + * {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION}, video unsupported color space conversion. * @since 9 */ OH_AVErrCode OH_VideoDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); @@ -162,6 +164,7 @@ OH_AVErrCode OH_VideoDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, decoder is in buffer mode and color space conversion is configured. * @since 9 */ OH_AVErrCode OH_VideoDecoder_Prepare(OH_AVCodec *codec); @@ -178,6 +181,7 @@ OH_AVErrCode OH_VideoDecoder_Prepare(OH_AVCodec *codec); * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, video color space conversion is configured but decoder is not prepared. * @since 9 */ OH_AVErrCode OH_VideoDecoder_Start(OH_AVCodec *codec); @@ -343,6 +347,8 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_DRM_DECRYPT_FAILED}, the drm-protected video buffer is decrypted failed, + * it is recommended to check the logs. * @since 11 */ OH_AVErrCode OH_VideoDecoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index); @@ -442,6 +448,7 @@ OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid); * @return {@link AV_ERR_OK} 0 - Success * {@link AV_ERR_OPERATE_NOT_PERMIT} 2 - If the codec service or the media key session * service is in wrong status. + * {@link AV_ERR_NO_MEMORY}, instance has already released or no memory. * {@link AV_ERR_INVALID_VAL} 3 - If the codec instance is nullptr or invalid, * the mediaKeySession is nullptr or invalid. * @since 11 diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index 7b2117ebceeeb3cf9ebab50c1a54fb4db73d18d3..4913528156683067fd92bbbbfa0a0bd1d6574b73 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -47,6 +47,12 @@ typedef struct OH_AVDemuxer OH_AVDemuxer; * @since 11 */ typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; + +/** +* @brief Callback for getting media key system information from media source. +* @since 11 +* @version 1.0 +*/ typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); /** @@ -210,6 +216,7 @@ OH_AVErrCode OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback(OH_AVDemuxer *dem * @param mediaKeySystemInfo Indicates the media key system info which ram space allocated by callee and * released by caller. * @return {@link AV_ERR_OK} 0 - Success + * {@link AV_ERR_OPERATE_NOT_PERMIT} 2 - If the demuxer engine is not inited or init failed. * {@link AV_ERR_INVALID_VAL} 3 - If the demuxer instance is nullptr or invalid * or the mediaKeySystemInfo is nullptr. * @since 11 diff --git a/multimedia/av_session/BUILD.gn b/multimedia/av_session/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bf7c9da268aa632de69a79bb688af52f19bd4de8 --- /dev/null +++ b/multimedia/av_session/BUILD.gn @@ -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("ohavsession_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/av_session" + sources = [ + "native_avmetadata.h", + "native_avsession.h", + "native_avsession_errors.h", + ] +} + +ohos_ndk_library("libohavsession_ndk") { + output_name = "ohavsession" + output_extension = "so" + ndk_description_file = "./libohavsession.ndk.json" + system_capability = "SystemCapability.Multimedia.AVSession.Core" + system_capability_headers = [ + "multimedia/av_session/native_avmetadata.h", + "multimedia/av_session/native_avsession.h", + "multimedia/av_session/native_avsession_errors.h", + ] +} diff --git a/multimedia/av_session/libohavsession.ndk.json b/multimedia/av_session/libohavsession.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..27c878d84b42fada9678470000067bc21d5dd5d5 --- /dev/null +++ b/multimedia/av_session/libohavsession.ndk.json @@ -0,0 +1,166 @@ +[ + { + "first_introduced": "13", + "name": "OH_AVSession_Create" + }, + { + "first_introduced": "13", + "name": "OH_AVSession_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_AVSession_Activate" + }, + { + "first_introduced": "13", + "name": "OH_AVSession_Deactivate" + }, + { + "first_introduced": "13", + "name": "OH_AVSession_GetSessionType" + }, + { + "first_introduced": "13", + "name": "OH_AVSession_GetSessionId" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_SetAVMetadata" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_SetPlaybackState" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_SetPlaybackPosition" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_SetFavorite" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_SetLoopMode" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_RegisterCommandCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_UnregisterCommandCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_RegisterForwardCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_UnregisterForwardCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_RegisterRewindCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_UnregisterRewindCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_RegisterSeekCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_UnregisterSeekCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_RegisterSetLoopModeCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_UnregisterSetLoopModeCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_RegisterToggleFavoriteCallback" + }, + { + "first_introduced": "13", + "name":"OH_AVSession_UnregisterToggleFavoriteCallback" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_Create" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetAssetId" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetTitle" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetArtist" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetAuthor" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetAlbum" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetWriter" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetComposer" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetDuration" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetMediaImageUri" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetSubtitle" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetDescription" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetLyric" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetSkipIntervals" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_SetDisplayTags" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadataBuilder_GenerateAVMetadata" + }, + { + "first_introduced": "13", + "name": "OH_AVMetadata_Destroy" + } +] \ No newline at end of file diff --git a/multimedia/av_session/native_avmetadata.h b/multimedia/av_session/native_avmetadata.h new file mode 100644 index 0000000000000000000000000000000000000000..a37816c927d9b620c431129821bac5f2a07d5a78 --- /dev/null +++ b/multimedia/av_session/native_avmetadata.h @@ -0,0 +1,374 @@ +/* + * 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 OHAVSession + * @{ + * + * @brief Provide the definition of the C interface for the avsession module. + * + * @syscap SystemCapability.Multimedia.AVSession.Core + * + * @since 13 + * @version 1.0 + */ + +/** + * @file native_avmetadata.h + * + * @brief Declare avmetadata builder related interfaces. + * + * @library libohavsession.so + * @syscap SystemCapability.Multimedia.AVSession.Core + * @kit AVSessionKit + * @since 13 + * @version 1.0 + */ + +#ifndef NATIVE_AVMETADATA_H +#define NATIVE_AVMETADATA_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief AVMetadata error code + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** + * @error The call was successful. + */ + AVMETADATA_SUCCESS = 0, + + /** + * @error This means that the function was executed with an invalid input parameter. + */ + AVMETADATA_ERROR_INVALID_PARAM = 1, + + /** + * @error This means there is no memory left. + */ + AVMETADATA_ERROR_NO_MEMORY = 2, +} AVMetadata_Result; + +/** + * @brief Defines the skip interval when fastforward or rewind. + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** + * @brief 10 seconds + */ + SECONDS_10 = 10, + + /** + * @brief 15 seconds + */ + SECONDS_15 = 15, + + /** + * @brief 30 seconds + */ + SECONDS_30 = 30, +} AVMetadata_SkipIntervals; + +/** + * @brief Display tag + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** + * @brief Indicate the audio vivid property. + */ + AVSESSION_DISPLAYTAG_AUDIO_VIVID = 1, +} AVMetadata_DisplayTag; + +/** + * @brief Declaring the avmetadata builder. + * The instance of builder is used for creating avmetadata. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_AVMetadataBuilderStruct OH_AVMetadataBuilder; + +/** + * @brief Declaring the avmetadata. + * The instance of avmetadata set by application for current resource. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_AVMetadataStruct OH_AVMetadata; + +/** + * @brief Creates an AVMetadataBuilder instance. + * + * @param builder The builder reference to the created result. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM} The param of builder is nullptr. + * {@link AVMETADATA_ERROR_NO_MEMORY} No memory to allocate a new instance. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_Create(OH_AVMetadataBuilder** builder); + +/** + * @brief Destroy a bulder. + * + * @param builder The metadata builder instance pointer + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM} The param of builder is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_Destroy(OH_AVMetadataBuilder* builder); + +/** + * @brief Set current asset id of the resource + * + * @param builder The metadata builder instance pointer + * @param assetId The current assetId of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of assetId is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetAssetId(OH_AVMetadataBuilder* builder, const char* assetId); + +/** + * @brief Set the title of the resource + * + * @param builder The metadata builder instance pointer + * @param title The title of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of title is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetTitle(OH_AVMetadataBuilder* builder, const char* title); + +/** + * @brief Set the artist of the resource + * + * @param builder The metadata builder instance pointer + * @param artist The artist of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of artist is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetArtist(OH_AVMetadataBuilder* builder, const char* artist); + +/** + * @brief Set the author of the resource + * + * @param builder The metadata builder instance pointer + * @param author The author of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of author is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetAuthor(OH_AVMetadataBuilder* builder, const char* author); + +/** + * @brief Set the album information + * + * @param builder The metadata builder instance pointer + * @param album The album name + * @return Return code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1. The param of builder is nullptr. + * 2. The param of album is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetAlbum(OH_AVMetadataBuilder* builder, const char* album); + +/** + * @brief Set the writer of the resource + * + * @param builder The metadata builder instance pointer + * @param writer The writer of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1. The param of builder is nullptr. + * 2. The param of writer is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetWriter(OH_AVMetadataBuilder* builder, const char* writer); + +/** + * @brief Set the composer of the resource + * + * @param builder The metadata builder instance pointer + * @param composer The composer of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1. The param of builder is nullptr. + * 2. The param of composer is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetComposer(OH_AVMetadataBuilder* builder, const char* composer); + +/** + * @brief Set the duration of the resource + * + * @param builder The metadata builder instance pointer + * @param duration The duration of resource, in miliseconds + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM} The param of builder is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetDuration(OH_AVMetadataBuilder* builder, int64_t duration); + +/** + * @brief Set the media image uri of the resource + * + * @param builder The metadata builder instance pointer + * @param mediaImageUri The mediaImageUri of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of mediaImageUri nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetMediaImageUri(OH_AVMetadataBuilder* builder, const char* mediaImageUri); + +/** + * @brief Set the subtitle of the resource + * + * @param builder The metadata builder instance pointer + * @param subtitle The subtitle of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of subtitle nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetSubtitle(OH_AVMetadataBuilder* builder, const char* subtitle); + +/** + * @brief Set the media description of the resource + * + * @param builder The metadata builder instance pointer + * @param description The description of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of description nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetDescription(OH_AVMetadataBuilder* builder, const char* description); + +/** + * @brief Set the media lyric content of the resource + * + * @param builder The metadata builder instance pointer + * @param lyric The lyric of resource. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of lyric nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetLyric(OH_AVMetadataBuilder* builder, const char* lyric); + +/** + * @brief Set the skip intervals of the resource + * + * @param builder The metadata builder instance pointer + * @param intervals The intervals of resource, only can be set : 10, 15, 30 + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of intervals is invalid. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetSkipIntervals(OH_AVMetadataBuilder* builder, + AVMetadata_SkipIntervals intervals); + +/** + * @brief Set the display tags of the resource + * + * @param builder The metadata builder instance pointer + * @param tags The display tags of resource which are supported by this app to be displayed on the media center + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM} The param of builder is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_SetDisplayTags(OH_AVMetadataBuilder* builder, int32_t tags); + +/** + * @brief Create the avmetadta. + * + * @param builder The metadata builder instance pointer + * @param avMetadata Pointer to a viriable to receive the avMetadata object. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_NO_MEMORY} No memory to allocate a new instance. + * {@link AVMETADATA_ERROR_INVALID_PARAM}: + * 1.The param of builder is nullptr; + * 2.The param of avMetadata is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadataBuilder_GenerateAVMetadata(OH_AVMetadataBuilder* builder, + OH_AVMetadata** avMetadata); + +/** + * @brief Request to release the avmetadta. + * + * @param avMetadata Pointer to a viriable to receive the avMetadata object. + * @return Function result code: + * {@link AVMETADATA_SUCCESS} If the execution is successful. + * {@link AVMETADATA_ERROR_INVALID_PARAM} The param of avMetadata is nullptr. + * @since 13 + */ +AVMetadata_Result OH_AVMetadata_Destroy(OH_AVMetadata* avMetadata); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVMETADATA_H +/** @} */ \ No newline at end of file diff --git a/multimedia/av_session/native_avsession.h b/multimedia/av_session/native_avsession.h new file mode 100644 index 0000000000000000000000000000000000000000..50b7e64592b3db56afd3b3ec3048e38300203da7 --- /dev/null +++ b/multimedia/av_session/native_avsession.h @@ -0,0 +1,687 @@ +/* + * 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 OHAVSession + * @{ + * + * @brief Provide the definition of the C interface for the avsession module. + * + * @syscap SystemCapability.Multimedia.AVSession.Core + * + * @since 13 + * @version 1.0 + */ + +/** + * @file native_avsession.h + * + * @brief Declare avsession interface. + * + * @library libohavsession.so + * @syscap SystemCapability.Multimedia.AVSession.Core + * @kit AVSessionKit + * @since 13 + * @version 1.0 + */ + +#ifndef NATIVE_AVSESSION_H +#define NATIVE_AVSESSION_H + +#include +#include "native_avsession_errors.h" +#include "native_avmetadata.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enum for avsession type. + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** + * @brief audio session type. + */ + SESSION_TYPE_AUDIO = 0, + + /** + * @brief video session type. + */ + SESSION_TYPE_VIDEO = 1, + + /** + * @brief voice call session type. + */ + SESSION_TYPE_VOICE_CALL = 2, + + /** + * @brief video call session type. + */ + SESSION_TYPE_VIDEO_CALL = 3 +} AVSession_Type; + +/** + * @brief Enum for playback state. + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** + * @brief Initial state. + */ + PLAYBACK_STATE_INITIAL = 0, + + /** + * @brief Preparing state. Indicates that the media file is not ready to play. + */ + PLAYBACK_STATE_PREPARING = 1, + + /** + * @brief Playing state. + */ + PLAYBACK_STATE_PLAYING = 2, + + /** + * @brief Pause state. + */ + PLAYBACK_STATE_PAUSED = 3, + + /** + * @brief Fast forward state. + */ + PLAYBACK_STATE_FAST_FORWARDING = 4, + + /** + * @brief Rewind state. + */ + PLAYBACK_STATE_REWINDED = 5, + + /** + * @brief Stopped state. + */ + PLAYBACK_STATE_STOPPED = 6, + + /** + * @brief Complete state. + */ + PLAYBACK_STATE_COMPLETED = 7, + + /** + * @brief Release state. + */ + PLAYBACK_STATE_RELEASED = 8, + + /** + * @brief Error state. + */ + PLAYBACK_STATE_ERROR = 9, + + /** + * @brief Idle state. + */ + PLAYBACK_STATE_IDLE = 10, + + /** + * @brief Buffering state. + */ + PLAYBACK_STATE_BUFFERING = 11, + + /** + * @brief Max state. + */ + PLAYBACK_STATE_MAX = 12, +} AVSession_PlaybackState; + +/** + * @brief Defines the playback position. + * + * @since 13 + */ +typedef struct AVSession_PlaybackPosition { + /** + * @brief Elapsed time(position) of this media set by the app. + */ + int64_t elapsedTime; + + /** + * @brief Record the system time when elapsedTime is set. + */ + int64_t updateTime; +} AVSession_PlaybackPosition; + +/** + * @brief Defines the playback mode. + * + * @since 13 + */ +typedef enum { + /** + * @brief sequential playback mode + */ + LOOP_MODE_SEQUENCE = 0, + + /** + * @brief single playback mode + */ + LOOP_MODE_SINGLE = 1, + + /** + * @brief list playback mode + */ + LOOP_MODE_LIST = 2, + + /** + * @brief shuffle playback mode + */ + LOOP_MODE_SHUFFLE = 3, + + /** + * @brief custom playback mode + */ + LOOP_MODE_CUSTOM = 4, +} AVSession_LoopMode; + +/** + * @brief Enum for different control command. + * + * @since 13 + * @version 1.0 + */ +typedef enum AVSession_ControlCommand { + /** + * @brief invalid control command + */ + CONTROL_CMD_INVALID = -1, + + /** + * @brief play command + */ + CONTROL_CMD_PLAY = 0, + + /** + * @brief pause command + */ + CONTROL_CMD_PAUSE = 1, + + /** + * @brief stop command + */ + CONTROL_CMD_STOP = 2, + + /** + * @brief playnext command + */ + CONTROL_CMD_PLAY_NEXT = 3, + + /** + * @brief playprevious command + */ + CONTROL_CMD_PLAY_PREVIOUS = 4, +} AVSession_ControlCommand; + +/** + * @brief Defines enumeration of avsession callback result. + * + * @since 13 + */ +typedef enum { + /** + * @brief Result of avsession callabck is success. + */ + AVSESSION_CALLBACK_RESULT_SUCCESS = 0, + + /** + * @brief Result of avsession callabck failed. + */ + AVSESSION_CALLBACK_RESULT_FAILURE = -1, +} AVSessionCallback_Result; + +/** + * @brief AVSession object + * + * A pointer can be created using {@link OH_AVSession_Create} method. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_AVSession OH_AVSession; + +/** + * @brief Declaring the callback struct for playback command + * + * @since 13 + * @version 1.0 + */ +typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnCommand)(OH_AVSession* session, + AVSession_ControlCommand command, void* userData); + +/** + * @brief Declaring the callback struct for forward command + * + * @since 13 + * @version 1.0 + */ +typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnFastForward)(OH_AVSession* session, + uint32_t seekTime, void* userData); + +/** + * @brief Declaring the callback struct for rewind command + * + * @since 13 + * @version 1.0 + */ +typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnRewind)(OH_AVSession* session, + uint32_t seekTime, void* userData); + +/** + * @brief Declaring the callback struct for seek command + * + * @since 13 + * @version 1.0 + */ +typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnSeek)(OH_AVSession* session, + uint64_t seekTime, void* userData); + +/** + * @brief Declaring the callback struct for set loop mode command + * + * @since 13 + * @version 1.0 + */ +typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnSetLoopMode)(OH_AVSession* session, + AVSession_LoopMode curLoopMode, void* userData); + +/** + * @brief Declaring the callback struct for toggle favorite command + * + * @since 13 + * @version 1.0 + */ +typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnToggleFavorite)(OH_AVSession* session, + const char* assetId, void* userData); + +/** + * @brief Request to create the avsession. + * + * @param sessionType The session type to set + * @param sessionTag The session tag set by the application + * @param bundleName The bundle name to set + * @param abilityName The abilityName name to set + * @param avsession Pointer to a viriable to receive the OH_AVSession + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_INVALID_PARAMETER}: + * 1. The param of sessionType is invalid. + * 2. The param of sessionTag is nullptr. + * 3. The param of bundleName is nullptr. + * 4. The param of abilityName is nullptr. + * 5. The param of avsession is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_Create(AVSession_Type sessionType, const char* sessionTag, + const char* bundleName, const char* abilityName, OH_AVSession** avsession); + +/** + * @brief Request to destory the avsession. + * + * @param avsession The avsession instance pointer + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} The param of avsession is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_Destroy(OH_AVSession* avsession); + +/** + * @brief Activate the avsession. + * + * @param avsession The avsession instance pointer + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} The param of avsession is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_Activate(OH_AVSession* avsession); + +/** + * @brief Deactivate the avsession. + * + * @param avsession The avsession instance pointer + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} The param of avsession is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_Deactivate(OH_AVSession* avsession); + +/** + * @brief Get session type. + * + * @param avsession The avsession instance pointer + * @param sessionType The returned session type + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is invalid. + * 2. The param of sessionType is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_GetSessionType(OH_AVSession* avsession, AVSession_Type* sessionType); + +/** + * @brief Get session id. + * + * @param avsession The avsession instance pointer + * @param sessionId The returned session id + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of sessionId is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_GetSessionId(OH_AVSession* avsession, const char** sessionId); + +/** + * @brief Request to set av metadata. + * + * @param avsession The avsession instance pointer + * @param avmetadata The metadata to set + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of avmetadata is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_SetAVMetadata(OH_AVSession* avsession, OH_AVMetadata* avmetadata); + +/** + * @brief Request to set av playbackstate. + * + * @param avsession The avsession instance pointer + * @param playbackState The playbackState to set + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of playbackState is invalid. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_SetPlaybackState(OH_AVSession* avsession, + AVSession_PlaybackState playbackState); + +/** + * @brief Request to set playback position. + * + * @param avsession The avsession instance pointer + * @param playbackPosition The playbackPosition to set + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of playbackPosition is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_SetPlaybackPosition(OH_AVSession* avsession, + AVSession_PlaybackPosition* playbackPosition); + +/** + * @brief Request to set favorite state. + * + * @param avsession The avsession instance pointer + * @param favorite true means making the resource to be liked, false means dislike. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} The param of avsession is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_SetFavorite(OH_AVSession* avsession, bool favorite); + +/** + * @brief Request to set loop mode. + * + * @param avsession The avsession instance pointer + * @param loopMode The loopmode to be set for playback. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of loopMode is invalid. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_SetLoopMode(OH_AVSession* avsession, AVSession_LoopMode loopMode); + +/** + * @brief Request to register command callback. + * + * @param avsession The avsession instance pointer + * @param command The control command type to be registered. + * @param callback the {@link OH_AVSessionCallback_OnCommand} to be registered. + * @param userData User data which is passed by user. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_CODE_COMMAND_INVALID} The command is invalid. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_RegisterCommandCallback(OH_AVSession* avsession, + AVSession_ControlCommand command, OH_AVSessionCallback_OnCommand callback, void* userData); + +/** + * @brief Request to unregister command callback. + * + * @param avsession The avsession instance pointer + * @param command The control command type to be unregistered. + * @param callback the {@link OH_AVSessionCallback_OnCommand} to be unregistered. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_CODE_COMMAND_INVALID} The command is invalid. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_UnregisterCommandCallback(OH_AVSession* avsession, + AVSession_ControlCommand command, OH_AVSessionCallback_OnCommand callback); + +/** + * @brief Request to register fastforward callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnFastForward} to be registered. + * @param userData User data which is passed by user. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_RegisterForwardCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnFastForward callback, void* userData); + +/** + * @brief Request to unregister fastforward callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnFastForward} to be unregistered. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_UnregisterForwardCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnFastForward callback); + +/** + * @brief Request to register rewind callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnRewind} to be registered. + * @param userData User data which is passed by user. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_RegisterRewindCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnRewind callback, void* userData); + +/** + * @brief Request to unregister rewind callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnRewind} to be unregistered. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_UnregisterRewindCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnRewind callback); + +/** + * @brief Request to register seek callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnSeek} to be registered. + * @param userData User data which is passed by user. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_RegisterSeekCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnSeek callback, void* userData); + +/** + * @brief Request to unregister seek callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnSeek} to be unregistered. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_UnregisterSeekCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnSeek callback); + +/** + * @brief Request to register set loopmode callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnSetLoopMode} to be registered. + * @param userData User data which is passed by user. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_RegisterSetLoopModeCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnSetLoopMode callback, void* userData); + +/** + * @brief Request to unregister set loopmode callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnSetLoopMode} to be unregistered. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_UnregisterSetLoopModeCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnSetLoopMode callback); + +/** + * @brief Request to register toggle favorite callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnToggleFavorite} to be registered. + * @param userData User data which is passed by user. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_RegisterToggleFavoriteCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnToggleFavorite callback, void* userData); + +/** + * @brief Request to unregister toggle favorite callback. + * + * @param avsession The avsession instance pointer + * @param callback the {@link OH_AVSessionCallback_OnToggleFavorite} to be unregistered. + * @return Function result code: + * {@link AV_SESSION_ERR_SUCCESS} If the execution is successful. + * {@link AV_SESSION_ERR_SERVICE_EXCEPTION} Internal server error. + * {@link AV_SESSION_ERR_INVALID_PARAMETER} + * 1. The param of avsession is nullptr. + * 2. The param of callback is nullptr. + * @since 13 + */ +AVSession_ErrCode OH_AVSession_UnregisterToggleFavoriteCallback(OH_AVSession* avsession, + OH_AVSessionCallback_OnToggleFavorite callback); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVSESSION_H +/** @} */ \ No newline at end of file diff --git a/multimedia/av_session/native_avsession_errors.h b/multimedia/av_session/native_avsession_errors.h new file mode 100644 index 0000000000000000000000000000000000000000..e19406013ee5027e066f692699a96be197b1cd1e --- /dev/null +++ b/multimedia/av_session/native_avsession_errors.h @@ -0,0 +1,90 @@ +/* + * 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 OHAVSession + * @{ + * + * @brief Provide the definition of the C interface for the avsession module. + * @since 13 + */ + +/** + * @file native_avsession_errors.h + * + * @brief Declare avsession related error. + * + * @library libohavsession.so + * @syscap SystemCapability.Multimedia.AVSession.Core + * @kit AVSessionKit + * @since 13 + */ + +#ifndef NATIVE_AVSESSION_ERRORS_H +#define NATIVE_AVSESSION_ERRORS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief AVSession error code + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** + * @error The operation completed successfully. + */ + AV_SESSION_ERR_SUCCESS = 0, + + /** + * @error Invalid parameter。 + */ + AV_SESSION_ERR_INVALID_PARAMETER = 401, + + /** + * @error Service exception. + */ + AV_SESSION_ERR_SERVICE_EXCEPTION = 6600101, + + /** + * @error The session does not exist. + */ + AV_SESSION_ERR_CODE_SESSION_NOT_EXIST = 6600102, + + /** + * @error Invalid session command. + */ + AV_SESSION_ERR_CODE_COMMAND_INVALID = 6600105, + + /** + * @error The session is not activated. + */ + AV_SESSION_ERR_CODE_SESSION_INACTIVE = 6600106, + + /** + * @error Too many commands or events. + */ + AV_SESSION_ERR_CODE_MESSAGE_OVERLOAD = 6600107, +} AVSession_ErrCode; + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVSESSION_ERRORS_H +/** @} */ \ No newline at end of file diff --git a/multimedia/camera_framework/BUILD.gn b/multimedia/camera_framework/BUILD.gn index 5193d84e080d5a418fdeeb2b85ed7668ce47e195..2773cb88b913c78a75810c6816b4c20ba429c49b 100644 --- a/multimedia/camera_framework/BUILD.gn +++ b/multimedia/camera_framework/BUILD.gn @@ -23,6 +23,7 @@ ohos_ndk_headers("camera_ndk_header") { "./camera_manager.h", "./capture_session.h", "./metadata_output.h", + "./photo_native.h", "./photo_output.h", "./preview_output.h", "./video_output.h", @@ -44,5 +45,6 @@ ohos_ndk_library("libohcamera") { "ohcamera/photo_output.h", "ohcamera/preview_output.h", "ohcamera/video_output.h", + "ohcamera/photo_native.h", ] } diff --git a/multimedia/camera_framework/camera.h b/multimedia/camera_framework/camera.h index 8f806c3bd022c8fe85e7809499b969b558ed0cad..1a907e0f7410434a7953d8bef537ee50d75c8ebe 100644 --- a/multimedia/camera_framework/camera.h +++ b/multimedia/camera_framework/camera.h @@ -42,6 +42,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -925,7 +926,7 @@ typedef struct Camera_TorchStatusInfo { /** * the current torch brightness level. */ - int32_t torchLevel; + float torchLevel; } Camera_TorchStatusInfo; /** @@ -972,6 +973,70 @@ typedef struct Camera_FrameShutterEndInfo { int32_t captureId; } Camera_FrameShutterEndInfo; +/** +* @brief Enum for fold status. +* +* @since 13 +* @version 1.0 +*/ +typedef enum Camera_FoldStatus { + /** + * Non_foldable status. + */ + NON_FOLDABLE = 0, + + /** + * Expanded status. + */ + EXPANDED = 1, + + /** + * Folded status. + */ + FOLDED = 2 +} Camera_FoldStatus; + +/** + * @brief Fold status info. + * + * @since 13 + * @version 1.0 + */ +typedef struct Camera_FoldStatusInfo { + /** + * Camera instance list. + */ + Camera_Device** supportedCameras; + + /** + * Size of camera list. + */ + uint32_t cameraSize; + + /** + * Current fold status. + */ + Camera_FoldStatus foldStatus; +} Camera_FoldStatusInfo; + +/** + * @brief Auto device switch status info. + * + * @since 13 + * @version 1.0 + */ +typedef struct Camera_AutoDeviceSwitchStatusInfo { + /** + * is device switched. + */ + bool isDeviceSwitched; + + /** + * is device capability changed. + */ + bool isDeviceCapabilityChanged; +} Camera_AutoDeviceSwitchStatusInfo; + /** * @brief Creates a CameraManager instance. * diff --git a/multimedia/camera_framework/camera.ndk.json b/multimedia/camera_framework/camera.ndk.json index 52bbf5fc002f20bf0a3fd815230b66e945d75893..dd8d98bbccbda9332843e7ecd6285a864735a9cf 100644 --- a/multimedia/camera_framework/camera.ndk.json +++ b/multimedia/camera_framework/camera.ndk.json @@ -31,6 +31,14 @@ "first_introduced": "11", "name": "OH_CameraManager_UnregisterCallback" }, + { + "first_introduced": "12", + "name": "OH_CameraManager_RegisterTorchStatusCallback" + }, + { + "first_introduced": "12", + "name": "OH_CameraManager_UnregisterTorchStatusCallback" + }, { "first_introduced": "11", "name": "OH_CameraManager_GetSupportedCameras" @@ -83,6 +91,10 @@ "first_introduced": "12", "name": "OH_CameraManager_CreatePhotoOutputUsedInPreconfig" }, + { + "first_introduced": "12", + "name": "OH_CameraManager_CreatePhotoOutputWithoutSurface" + }, { "first_introduced": "11", "name": "OH_CameraManager_CreateVideoOutput" @@ -103,6 +115,18 @@ "first_introduced": "12", "name": "OH_CameraManager_DeleteSceneModes" }, + { + "first_introduced": "12", + "name": "OH_CameraManager_IsTorchSupported" + }, + { + "first_introduced": "12", + "name": "OH_CameraManager_IsTorchSupportedByTorchMode" + }, + { + "first_introduced": "12", + "name": "OH_CameraManager_SetTorchMode" + }, { "first_introduced": "11", "name": "OH_Camera_GetCameraManager" @@ -119,6 +143,14 @@ "first_introduced": "11", "name": "OH_CaptureSession_UnregisterCallback" }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_RegisterSmoothZoomInfoCallback" + }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_UnregisterSmoothZoomInfoCallback" + }, { "first_introduced": "12", "name": "OH_CaptureSession_SetSessionMode" @@ -311,6 +343,34 @@ "first_introduced": "12", "name": "OH_CaptureSession_PreconfigWithRatio" }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_GetExposureValue" + }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_GetFocalLength" + }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_SetSmoothZoom" + }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_GetSupportedColorSpaces" + }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_DeleteColorSpaces" + }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_GetActiveColorSpace" + }, + { + "first_introduced": "12", + "name": "OH_CaptureSession_SetActiveColorSpace" + }, { "first_introduced": "11", "name": "OH_MetadataOutput_RegisterCallback" @@ -339,10 +399,66 @@ "first_introduced": "11", "name": "OH_PhotoOutput_UnregisterCallback" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterCaptureStartWithInfoCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterCaptureStartWithInfoCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterCaptureEndCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterCaptureEndCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterFrameShutterEndCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterFrameShutterEndCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterCaptureReadyCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterCaptureReadyCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterEstimatedCaptureDurationCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterEstimatedCaptureDurationCallback" + }, { "first_introduced": "11", "name": "OH_PhotoOutput_Capture" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterPhotoAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterPhotoAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterPhotoAssetAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterPhotoAssetAvailableCallback" + }, { "first_introduced": "11", "name": "OH_PhotoOutput_Capture_WithCaptureSetting" @@ -355,6 +471,10 @@ "first_introduced": "11", "name": "OH_PhotoOutput_IsMirrorSupported" }, + { + "first_introduced": "13", + "name": "OH_PhotoOutput_EnableMirror" + }, { "first_introduced": "12", "name": "OH_PhotoOutput_GetActiveProfile" @@ -363,6 +483,18 @@ "first_introduced": "12", "name": "OH_PhotoOutput_DeleteProfile" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_IsMovingPhotoSupported" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_EnableMovingPhoto" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_GetPhotoRotation" + }, { "first_introduced": "11", "name": "OH_PreviewOutput_RegisterCallback" @@ -391,6 +523,30 @@ "first_introduced": "12", "name": "OH_PreviewOutput_DeleteProfile" }, + { + "first_introduced": "12", + "name": "OH_PreviewOutput_GetSupportedFrameRates" + }, + { + "first_introduced": "12", + "name": "OH_PreviewOutput_DeleteFrameRates" + }, + { + "first_introduced": "12", + "name": "OH_PreviewOutput_SetFrameRate" + }, + { + "first_introduced": "12", + "name": "OH_PreviewOutput_GetActiveFrameRate" + }, + { + "first_introduced": "12", + "name": "OH_PreviewOutput_GetPreviewRotation" + }, + { + "first_introduced": "12", + "name": "OH_PreviewOutput_SetPreviewRotation" + }, { "first_introduced": "11", "name": "OH_VideoOutput_RegisterCallback" @@ -419,8 +575,60 @@ "first_introduced": "12", "name": "OH_VideoOutput_DeleteProfile" }, + { + "first_introduced": "12", + "name": "OH_VideoOutput_GetSupportedFrameRates" + }, + { + "first_introduced": "12", + "name": "OH_VideoOutput_DeleteFrameRates" + }, + { + "first_introduced": "12", + "name": "OH_VideoOutput_SetFrameRate" + }, + { + "first_introduced": "12", + "name": "OH_VideoOutput_GetActiveFrameRate" + }, + { + "first_introduced": "12", + "name": "OH_VideoOutput_GetVideoRotation" + }, { "first_introduced": "12", "name": "OH_CameraDevice_GetCameraOrientation" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_GetMainImage" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_Release" + }, + { + "first_introduced": "13", + "name": "OH_CameraManager_RegisterFoldStatusInfoCallback" + }, + { + "first_introduced": "13", + "name": "OH_CameraManager_UnregisterFoldStatusInfoCallback" + }, + { + "first_introduced": "13", + "name": "OH_CaptureSession_RegisterAutoDeviceSwitchStatusCallback" + }, + { + "first_introduced": "13", + "name": "OH_CaptureSession_UnregisterAutoDeviceSwitchStatusCallback" + }, + { + "first_introduced": "13", + "name": "OH_CaptureSession_IsAutoDeviceSwitchSupported" + }, + { + "first_introduced": "13", + "name": "OH_CaptureSession_EnableAutoDeviceSwitch" } ] diff --git a/multimedia/camera_framework/camera_manager.h b/multimedia/camera_framework/camera_manager.h index 9524a13f40bcbad5688fa0423d10524cdee8b54b..3c7f2fee0b095fb645fc1e3ab3d6a40d8312e5c8 100644 --- a/multimedia/camera_framework/camera_manager.h +++ b/multimedia/camera_framework/camera_manager.h @@ -63,6 +63,25 @@ extern "C" { */ typedef void (*OH_CameraManager_StatusCallback)(Camera_Manager* cameraManager, Camera_StatusInfo* status); +/** + * @brief Camera manager torch status callback. + * + * @param cameraManager the {@link Camera_Manager} which deliver the callback. + * @param status the {@link Camera_TorchStatusInfo} of the torch. + * @since 12 + */ +typedef void (*OH_CameraManager_TorchStatusCallback)(Camera_Manager* cameraManager, Camera_TorchStatusInfo* status); + +/** + * @brief Camera manager fold status info callback. + * + * @param cameraManager the {@link Camera_Manager} which deliver the callback. + * @param foldStatusInfo the {@link Camera_FoldStatusInfo} of the device. + * @since 13 + */ +typedef void (*OH_CameraManager_OnFoldStatusInfoChange)(Camera_Manager* cameraManager, + Camera_FoldStatusInfo* foldStatusInfo); + /** * @brief A listener for camera devices status. * @@ -99,6 +118,54 @@ Camera_ErrorCode OH_CameraManager_RegisterCallback(Camera_Manager* cameraManager */ Camera_ErrorCode OH_CameraManager_UnregisterCallback(Camera_Manager* cameraManager, CameraManager_Callbacks* callback); +/** + * @brief Register torch status change event callback. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param torchStatusCallback the {@link OH_CameraManager_TorchStatusCallback} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_RegisterTorchStatusCallback(Camera_Manager* cameraManager, + OH_CameraManager_TorchStatusCallback torchStatusCallback); + +/** + * @brief Unregister torch status change event callback. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param torchStatusCallback the {@link OH_CameraManager_TorchStatusCallback} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_UnregisterTorchStatusCallback(Camera_Manager* cameraManager, + OH_CameraManager_TorchStatusCallback torchStatusCallback); + +/** + * @brief Register fold status info change event callback. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param foldStatusInfoCallback the {@link OH_CameraManager_OnFoldStatusInfoChange} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 13 + */ +Camera_ErrorCode OH_CameraManager_RegisterFoldStatusInfoCallback(Camera_Manager* cameraManager, + OH_CameraManager_OnFoldStatusInfoChange foldStatusInfoCallback); + +/** + * @brief Unregister fold status info change event callback. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param foldStatusInfoCallback the {@link OH_CameraManager_OnFoldStatusInfoChange} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 13 + */ +Camera_ErrorCode OH_CameraManager_UnregisterFoldStatusInfoCallback(Camera_Manager* cameraManager, + OH_CameraManager_OnFoldStatusInfoChange foldStatusInfoCallback); + /** * @brief Gets supported camera descriptions. * @@ -282,6 +349,20 @@ Camera_ErrorCode OH_CameraManager_CreatePhotoOutput(Camera_Manager* cameraManage Camera_ErrorCode OH_CameraManager_CreatePhotoOutputUsedInPreconfig(Camera_Manager* cameraManager, const char* surfaceId, Camera_PhotoOutput** photoOutput); +/** + * @brief Create a photo output instance without surfaceId. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param profile the {@link Camera_Profile} to create {@link Camera_PhotoOutput}. + * @param photoOutput the {@link Camera_PhotoOutput} will be created if the method call succeeds. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_CreatePhotoOutputWithoutSurface(Camera_Manager *cameraManager, + const Camera_Profile *profile, Camera_PhotoOutput **photoOutput); + /** * @brief Create a video output instance. * @@ -350,6 +431,45 @@ Camera_ErrorCode OH_CameraManager_GetSupportedSceneModes(Camera_Device* camera, */ Camera_ErrorCode OH_CameraManager_DeleteSceneModes(Camera_Manager* cameraManager, Camera_SceneMode* sceneModes); +/** + * @brief Check if the device supports torch. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param isTorchSupported whether the device supports torch. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_IsTorchSupported(Camera_Manager* cameraManager, + bool* isTorchSupported); + +/** + * @brief Check whether the device supports the torch with the specified torch mode. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param torchMode the {@link Camera_TorchMode} to be checked. + * @param isTorchSupported whether device supports the torch mode. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_IsTorchSupportedByTorchMode(Camera_Manager* cameraManager, + Camera_TorchMode torchMode, bool* isTorchSupported); + +/** + * @brief Set camera torch mode. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param torchMode the {@link Camera_TorchMode} to be set. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_SetTorchMode(Camera_Manager* cameraManager, + Camera_TorchMode torchMode); + #ifdef __cplusplus } #endif diff --git a/multimedia/camera_framework/capture_session.h b/multimedia/camera_framework/capture_session.h index 8bf5f648f86a5df6c929c1f31071bdacfd303914..54786c5d9abf0c37c5f502105e2486b510a242e2 100644 --- a/multimedia/camera_framework/capture_session.h +++ b/multimedia/camera_framework/capture_session.h @@ -48,6 +48,7 @@ #include "photo_output.h" #include "video_output.h" #include "metadata_output.h" +#include "native_buffer/native_buffer.h" #ifdef __cplusplus extern "C" { @@ -83,6 +84,26 @@ typedef void (*OH_CaptureSession_OnFocusStateChange)(Camera_CaptureSession* sess */ typedef void (*OH_CaptureSession_OnError)(Camera_CaptureSession* session, Camera_ErrorCode errorCode); +/** + * @brief Capture session smooth zoom info callback. + * + * @param session the {@link Camera_CaptureSession} which deliver the callback. + * @param smoothZoomInfo the {@link Camera_SmoothZoomInfo} which delivered by the callback. + * @since 12 + */ +typedef void (*OH_CaptureSession_OnSmoothZoomInfo)(Camera_CaptureSession* session, + Camera_SmoothZoomInfo* smoothZoomInfo); + +/** + * @brief Capture session device switch status callback. + * + * @param session the {@link Camera_CaptureSession} which deliver the callback. + * @param autoDeviceSwitchStatusInfo the {@link Camera_AutoDeviceSwitchStatusInfo} which delivered by the callback. + * @since 13 + */ +typedef void (*OH_CaptureSession_OnAutoDeviceSwitchStatusChange)(Camera_CaptureSession* session, + Camera_AutoDeviceSwitchStatusInfo* autoDeviceSwitchStatusInfo); + /** * @brief A listener for capture session. * @@ -126,6 +147,30 @@ Camera_ErrorCode OH_CaptureSession_RegisterCallback(Camera_CaptureSession* sessi Camera_ErrorCode OH_CaptureSession_UnregisterCallback(Camera_CaptureSession* session, CaptureSession_Callbacks* callback); +/** + * @brief Register smooth zoom information event callback. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param smoothZoomInfoCallback the {@link OH_CaptureSession_OnSmoothZoomInfo} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_RegisterSmoothZoomInfoCallback(Camera_CaptureSession* session, + OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback); + +/** + * @brief Unregister smooth zoom information event callback. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param smoothZoomInfoCallback the {@link OH_CaptureSession_OnSmoothZoomInfo} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_UnregisterSmoothZoomInfoCallback(Camera_CaptureSession* session, + OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback); + /** * @brief Specifies the specific mode. * @@ -682,8 +727,8 @@ Camera_ErrorCode OH_CaptureSession_CanAddVideoOutput(Camera_CaptureSession* sess * @brief Check the preconfig type is supported or not. * * @param session the {@link Camera_CaptureSession} instance. - * @param preconfigType the target {@link Camera_PreconfigType} to set. - * @param canPreconfig the result of whether the preconfig type is supported. + * @param preconfigType The type {@link Camera_PreconfigType} to check support for. + * @param canPreconfig The result of whether preconfiguration supported. * @return {@link #CAMERA_OK} if the method call succeeds. * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. * @since 12 @@ -695,25 +740,24 @@ Camera_ErrorCode OH_CaptureSession_CanPreconfig(Camera_CaptureSession* session, * @brief Check the preconfig type with ratio is supported or not. * * @param session the {@link Camera_CaptureSession} instance. - * @param preconfigType the target {@link Camera_PreconfigType} to set. - * @param preconfigRatio the target {@link Camera_PreconfigRatio} to set. - * @param canPreconfig the result of whether the preconfig type with ratio is supported. + * @param preconfigType The type {@link Camera_PreconfigType} to check support for. + * @param preconfigRatio The ratio {@link Camera_PreconfigRatio} to check support for. + * @param canPreconfig The result of whether preconfiguration supported. * @return {@link #CAMERA_OK} if the method call succeeds. * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. * @since 12 */ Camera_ErrorCode OH_CaptureSession_CanPreconfigWithRatio(Camera_CaptureSession* session, - Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio, - bool* canPreconfig); + Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio, bool* canPreconfig); /** * @brief Set the preconfig type. * * @param session the {@link Camera_CaptureSession} instance. - * @param preconfigType the target {@link Camera_PreconfigType} to set. + * @param preconfigType The type {@link Camera_PreconfigType} to check support for. * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if the internal preconfiguration fails. * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. - * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. * @since 12 */ Camera_ErrorCode OH_CaptureSession_Preconfig(Camera_CaptureSession* session, @@ -723,16 +767,155 @@ Camera_ErrorCode OH_CaptureSession_Preconfig(Camera_CaptureSession* session, * @brief Set the preconfig type with ratio. * * @param session the {@link Camera_CaptureSession} instance. - * @param preconfigType the target {@link Camera_PreconfigType} to set. - * @param preconfigRatio the target {@link Camera_PreconfigRatio} to set. + * @param preconfigType The type {@link Camera_PreconfigType} to check support for. + * @param preconfigRatio The ratio {@link Camera_PreconfigRatio} to check support for. * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if the internal preconfiguration fails. * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. - * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. * @since 12 */ Camera_ErrorCode OH_CaptureSession_PreconfigWithRatio(Camera_CaptureSession* session, Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio); +/** + * @brief Query the exposure value. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param exposureValue the current exposure value. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_GetExposureValue(Camera_CaptureSession* session, float* exposureValue); + +/** + * @brief Get current focal length. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param focalLength the current focal length. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_GetFocalLength(Camera_CaptureSession* session, float* focalLength); + +/** + * @brief Set target zoom ratio by smooth method. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param targetZoom the target zoom ratio to set. + * @param smoothZoomMode the {@link Camera_SmoothZoomMode} instance. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_SetSmoothZoom(Camera_CaptureSession* session, + float targetZoom, Camera_SmoothZoomMode smoothZoomMode); + +/** + * @brief Get the supported color spaces. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param colorSpace the supported {@link OH_NativeBuffer_ColorSpace} list to be filled if the method call succeeds. + * @param size the size of supported color Spaces queried. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_GetSupportedColorSpaces(Camera_CaptureSession* session, + OH_NativeBuffer_ColorSpace** colorSpace, uint32_t* size); + +/** + * @brief Delete the color spaces. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param colorSpace the target {@link OH_NativeBuffer_ColorSpace} list to be deleted if the method call succeeds. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_DeleteColorSpaces(Camera_CaptureSession* session, + OH_NativeBuffer_ColorSpace* colorSpace); + +/** + * @brief Get current color space. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param colorSpace the current {@link OH_NativeBuffer_ColorSpace} . + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_GetActiveColorSpace(Camera_CaptureSession* session, + OH_NativeBuffer_ColorSpace* colorSpace); + +/** + * @brief Set current color space. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param colorSpace the target {@link OH_NativeBuffer_ColorSpace} to set. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * @since 12 + */ +Camera_ErrorCode OH_CaptureSession_SetActiveColorSpace(Camera_CaptureSession* session, + OH_NativeBuffer_ColorSpace colorSpace); + +/** + * @brief Register device switch event callback. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param autoDeviceSwitchStatusChange the {@link OH_CaptureSession_OnAutoDeviceSwitchStatusChange} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 13 + */ +Camera_ErrorCode OH_CaptureSession_RegisterAutoDeviceSwitchStatusCallback(Camera_CaptureSession* session, + OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange); + +/** + * @brief Unregister device switch event callback. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param autoDeviceSwitchStatusChange the {@link OH_CaptureSession_OnAutoDeviceSwitchStatusChange} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 13 + */ +Camera_ErrorCode OH_CaptureSession_UnregisterAutoDeviceSwitchStatusCallback(Camera_CaptureSession* session, + OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange); + +/** + * @brief Check whether auto device switch is supported. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param isSupported the result of whether auto device switch supported. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * @since 13 + */ +Camera_ErrorCode OH_CaptureSession_IsAutoDeviceSwitchSupported(Camera_CaptureSession* session, bool* isSupported); + +/** + * @brief Enable auto switch or not for the camera device. + * + * @param session the {@link Camera_CaptureSession} instance. + * @param enabled the flag of enable auto switch or not. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 13 + */ +Camera_ErrorCode OH_CaptureSession_EnableAutoDeviceSwitch(Camera_CaptureSession* session, bool enabled); + #ifdef __cplusplus } #endif diff --git a/multimedia/camera_framework/photo_native.h b/multimedia/camera_framework/photo_native.h new file mode 100644 index 0000000000000000000000000000000000000000..f12a68498c43371a779ead43f34af23921d663fd --- /dev/null +++ b/multimedia/camera_framework/photo_native.h @@ -0,0 +1,90 @@ +/* + * 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 OH_Camera + * @{ + * + * @brief Provide the definition of the C interface for the camera module. + * + * @syscap SystemCapability.Multimedia.Camera.Core + * + * @since 12 + * @version 1.0 + */ + +/** + * @file photo_native.h + * + * @brief Declare the camera photo concepts. + * + * @library libohcamera.so + * @kit CameraKit + * @syscap SystemCapability.Multimedia.Camera.Core + * @since 12 + * @version 1.0 + */ + +#ifndef NATIVE_INCLUDE_PHOTO_NATIVE_H +#define NATIVE_INCLUDE_PHOTO_NATIVE_H + +#include +#include +#include "camera.h" +#include "multimedia/image_framework/image/image_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Camera photo object + * + * A pointer can be created using {@link OH_PhotoNative} method. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_PhotoNative OH_PhotoNative; + +/** + * @brief Get main image. + * + * @param photo the {@link OH_PhotoNative} instance. + * @param mainImage the {@link OH_ImageNative} which use to get main image. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + * @version 1.0 + */ +Camera_ErrorCode OH_PhotoNative_GetMainImage(OH_PhotoNative* photo, OH_ImageNative** mainImage); + +/** + * @brief Release camera photo. + * + * @param photo the {@link OH_PhotoNative} instance to released. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + * @version 1.0 + */ +Camera_ErrorCode OH_PhotoNative_Release(OH_PhotoNative* photo); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_INCLUDE_PHOTO_NATIVE_H +/** @} */ \ No newline at end of file diff --git a/multimedia/camera_framework/photo_output.h b/multimedia/camera_framework/photo_output.h index 7c30f55695ca616555a392317e05098cb225d1ac..27e502b695a667c5e6ad112c8035bb6081bf4919 100644 --- a/multimedia/camera_framework/photo_output.h +++ b/multimedia/camera_framework/photo_output.h @@ -43,6 +43,8 @@ #include #include #include "camera.h" +#include "photo_native.h" +#include "multimedia/media_library/media_asset_base_capi.h" #ifdef __cplusplus extern "C" { @@ -95,6 +97,68 @@ typedef void (*OH_PhotoOutput_OnFrameEnd)(Camera_PhotoOutput* photoOutput, int32 */ typedef void (*OH_PhotoOutput_OnError)(Camera_PhotoOutput* photoOutput, Camera_ErrorCode errorCode); +/** + * @brief Photo output capture end callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param frameCount the frameCount which is delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_CaptureEnd) (Camera_PhotoOutput* photoOutput, int32_t frameCount); + +/** + * @brief Photo output capture start with infomation callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param Info the {@link Camera_CaptureStartInfo} which is delivered by the callback.. + * @since 12 + */ +typedef void (*OH_PhotoOutput_CaptureStartWithInfo) (Camera_PhotoOutput* photoOutput, Camera_CaptureStartInfo* Info); + +/** + * @brief Photo output eframe shutter end callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param Info the {@link Camera_CaptureStartInfo} which is delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_OnFrameShutterEnd) (Camera_PhotoOutput* photoOutput, Camera_FrameShutterInfo* Info); + +/** + * @brief Photo output capture ready callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_CaptureReady) (Camera_PhotoOutput* photoOutput); + +/** + * @brief Photo output estimated capture duration callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param duration the duration which is delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_EstimatedCaptureDuration) (Camera_PhotoOutput* photoOutput, int64_t duration); + +/** + * @brief Photo output available high-resolution images callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param photo the {@link OH_PhotoNative} which delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_PhotoAvailable)(Camera_PhotoOutput* photoOutput, OH_PhotoNative* photo); + +/** + * @brief Photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param photoAsset the {@link OH_MediaAsset} which delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_PhotoAssetAvailable)(Camera_PhotoOutput* photoOutput, OH_MediaAsset* photoAsset); + /** * @brief A listener for photo output. * @@ -146,6 +210,188 @@ Camera_ErrorCode OH_PhotoOutput_RegisterCallback(Camera_PhotoOutput* photoOutput */ Camera_ErrorCode OH_PhotoOutput_UnregisterCallback(Camera_PhotoOutput* photoOutput, PhotoOutput_Callbacks* callback); +/** + * @brief Register capture start event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_CaptureStartWithInfo} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterCaptureStartWithInfoCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_CaptureStartWithInfo callback); + +/** + * @brief Gets the photo rotation angle. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to get the photo rotation angle. + * @param deviceDegree the current device rotation degree. + * @param imageRotation the {@link Camera_ImageRotation} result of photo rotation angle. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_GetPhotoRotation(Camera_PhotoOutput* photoOutput, int deviceDegree, + Camera_ImageRotation* imageRotation); + +/** + * @brief Unregister capture start event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_CaptureStartWithInfo} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterCaptureStartWithInfoCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_CaptureStartWithInfo callback); + +/** + * @brief Register capture end event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_CaptureEnd} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterCaptureEndCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_CaptureEnd callback); + +/** + * @brief Unregister capture end event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_CaptureEnd} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterCaptureEndCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_CaptureEnd callback); + +/** + * @brief Register frame shutter end event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_OnFrameShutterEnd} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterFrameShutterEndCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_OnFrameShutterEnd callback); + +/** + * @brief Unregister frame shutter end event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_OnFrameShutterEnd} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterFrameShutterEndCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_OnFrameShutterEnd callback); + +/** + * @brief Register capture ready event callback. After receiving the callback, can proceed to the next capture. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_CaptureReady} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterCaptureReadyCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_CaptureReady callback); + +/** + * @brief Unregister capture ready event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_CaptureReady} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterCaptureReadyCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_CaptureReady callback); + +/** + * @brief Register estimated capture duration event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_EstimatedCaptureDuration} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterEstimatedCaptureDurationCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_EstimatedCaptureDuration callback); + +/** + * @brief Unregister estimated capture duration event callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_EstimatedCaptureDuration} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterEstimatedCaptureDurationCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_EstimatedCaptureDuration callback); + +/** + * @brief Register photo output photo available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAvailable} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAvailable callback); + +/** + * @brief Unregister photo output photo available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link PhotoOutput_Callbacks} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAvailable callback); + +/** + * @brief Register photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAssetAvailable callback); + +/** + * @brief Unregister photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAssetAvailable callback); + /** * @brief Capture photo. * @@ -196,12 +442,25 @@ Camera_ErrorCode OH_PhotoOutput_Release(Camera_PhotoOutput* photoOutput); Camera_ErrorCode OH_PhotoOutput_IsMirrorSupported(Camera_PhotoOutput* photoOutput, bool* isSupported); /** - * @brief Get active profiles. + * @brief Enable mirror for photo capture. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to configure mirror. + * @param enabled the flag indicates whether mirror is enabled. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 13 + */ +Camera_ErrorCode OH_PhotoOutput_EnableMirror(Camera_PhotoOutput* photoOutput, bool enabled); + +/** + * @brief Get active photo output profile. * - * @param photoOutput the {@link Camera_PhotoOutput} instance which used to get active profiles. - * @param profile the active {@link Camera_Profile} will be filled if the method call succeeds. + * @param photoOutput the {@link Camera_PhotoOutput} instance to deliver active profile. + * @param profile the active {@link Camera_Profile} to be filled if the method call succeeds. * @return {@link #CAMERA_OK} if the method call succeeds. * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. * @since 12 */ Camera_ErrorCode OH_PhotoOutput_GetActiveProfile(Camera_PhotoOutput* photoOutput, Camera_Profile** profile); @@ -216,6 +475,30 @@ Camera_ErrorCode OH_PhotoOutput_GetActiveProfile(Camera_PhotoOutput* photoOutput */ Camera_ErrorCode OH_PhotoOutput_DeleteProfile(Camera_Profile* profile); +/** + * @brief Check whether to support moving photo. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to check whether moving photo supported. + * @param isSupported the result of whether moving photo supported. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_IsMovingPhotoSupported(Camera_PhotoOutput* photoOutput, bool* isSupported); + +/** + * @brief Enable moving photo or not. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to enable moving photo or not. + * @param enabled the flag of enable moving photo or not. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_EnableMovingPhoto(Camera_PhotoOutput* photoOutput, bool enabled); + #ifdef __cplusplus } #endif diff --git a/multimedia/camera_framework/preview_output.h b/multimedia/camera_framework/preview_output.h index 8328b615aecda7e8b5a94292c47e8d2f252bd8be..15e67085d71455682d209363553cce057bceb560 100644 --- a/multimedia/camera_framework/preview_output.h +++ b/multimedia/camera_framework/preview_output.h @@ -169,12 +169,13 @@ Camera_ErrorCode OH_PreviewOutput_Stop(Camera_PreviewOutput* previewOutput); Camera_ErrorCode OH_PreviewOutput_Release(Camera_PreviewOutput* previewOutput); /** - * @brief Get active profiles. + * @brief Get active preview output profile. * - * @param previewOutput the {@link Camera_PreviewOutput} instance which used to get active profiles. - * @param profile the active {@link Camera_Profile} will be filled if the method call succeeds. + * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver active profile. + * @param profile the active {@link Camera_Profile} to be filled if the method call succeeds. * @return {@link #CAMERA_OK} if the method call succeeds. * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. * @since 12 */ Camera_ErrorCode OH_PreviewOutput_GetActiveProfile(Camera_PreviewOutput* previewOutput, Camera_Profile** profile); @@ -189,6 +190,86 @@ Camera_ErrorCode OH_PreviewOutput_GetActiveProfile(Camera_PreviewOutput* preview */ Camera_ErrorCode OH_PreviewOutput_DeleteProfile(Camera_Profile* profile); +/** + * @brief Gets the preview rotation angle. + * + * @param previewOutput the {@link Camera_PreviewOutput} instance which used to get the preview rotation angle. + * @param displayRotation the current display rotation angle. + * @param imageRotation the {@link Camera_ImageRotation} result of preview rotation angle. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PreviewOutput_GetPreviewRotation(Camera_PreviewOutput* previewOutput, int displayRotation, + Camera_ImageRotation* imageRotation); + +/** + * @brief Sets the preview rotation angle. + * + * @param previewOutput the {@link Camera_PreviewOutput} instance which used to set the preview rotation angle. + * @param previewRotation the {@link Camera_ImageRotation} of preview display rotation angle. + * @param isDisplayLocked TRUE means the display is locked. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PreviewOutput_SetPreviewRotation(Camera_PreviewOutput* previewOutput, + Camera_ImageRotation previewRotation, bool isDisplayLocked); + +/** + * @brief Get supported preview output frame rate list. + * + * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver supported frame rate list. + * @param frameRateRange the supported {@link Camera_FrameRateRange} list to be filled if the method call succeeds. + * @param size the size of supported {@link Camera_FrameRateRange} list will be filled. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PreviewOutput_GetSupportedFrameRates(Camera_PreviewOutput* previewOutput, + Camera_FrameRateRange** frameRateRange, uint32_t* size); + +/** + * @brief Delete frame rate list. + * + * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver supported frame rate list. + * @param frameRateRange the {@link Camera_FrameRateRange} list to be deleted. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PreviewOutput_DeleteFrameRates(Camera_PreviewOutput* previewOutput, + Camera_FrameRateRange* frameRateRange); + +/** + * @brief Set preview output frame rate. + * + * @param previewOutput the {@link Camera_PreviewOutput} instance to be set frame rate. + * @param minFps the minimum to be set. + * @param maxFps the maximum to be set. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PreviewOutput_SetFrameRate(Camera_PreviewOutput* previewOutput, + int32_t minFps, int32_t maxFps); + +/** + * @brief Get active preview output frame rate. + * + * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver the active frame rate. + * @param frameRateRange the active {@link Camera_FrameRateRange} to be filled if the method call succeeds. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PreviewOutput_GetActiveFrameRate(Camera_PreviewOutput* previewOutput, + Camera_FrameRateRange* frameRateRange); + #ifdef __cplusplus } #endif diff --git a/multimedia/camera_framework/video_output.h b/multimedia/camera_framework/video_output.h index 35a76e9446af9f5121d2df5f7c33ebcf39a76e8e..d0228d3e732efec62e2002e25aa1e02249912fe5 100644 --- a/multimedia/camera_framework/video_output.h +++ b/multimedia/camera_framework/video_output.h @@ -167,12 +167,13 @@ Camera_ErrorCode OH_VideoOutput_Stop(Camera_VideoOutput* videoOutput); Camera_ErrorCode OH_VideoOutput_Release(Camera_VideoOutput* videoOutput); /** - * @brief Get active profiles. + * @brief Get active video output profile. * - * @param videoOutput the {@link Camera_VideoOutput} instance which used to get active profiles. - * @param profile the active {@link Camera_VideoProfile} will be filled if the method call succeeds. + * @param videoOutput the {@link Camera_VideoOutput} instance to deliver active video profile. + * @param profile the active {@link Camera_VideoProfile} to be filled if the method call succeeds. * @return {@link #CAMERA_OK} if the method call succeeds. * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. * @since 12 */ Camera_ErrorCode OH_VideoOutput_GetActiveProfile(Camera_VideoOutput* videoOutput, Camera_VideoProfile** profile); @@ -187,6 +188,72 @@ Camera_ErrorCode OH_VideoOutput_GetActiveProfile(Camera_VideoOutput* videoOutput */ Camera_ErrorCode OH_VideoOutput_DeleteProfile(Camera_VideoProfile* profile); +/** + * @brief Gets the video rotation angle. + * + * @param videoOutput the {@link Camera_VideoOutput} instance which used to get the video rotation angle. + * @param deviceDegree the current device rotation degree. + * @param imageRotation the {@link Camera_ImageRotation} result of video rotation angle. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_VideoOutput_GetVideoRotation(Camera_VideoOutput* videoOutput, int deviceDegree, + Camera_ImageRotation* imageRotation); + +/** + * @brief Get supported video output frame rate list. + * + * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list. + * @param frameRateRange the supported {@link Camera_FrameRateRange} list to be filled if the method call succeeds. + * @param size the size of supported {@link Camera_FrameRateRange} list will be filled. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_VideoOutput_GetSupportedFrameRates(Camera_VideoOutput* videoOutput, + Camera_FrameRateRange** frameRateRange, uint32_t* size); + +/** + * @brief Delete frame rate list. + * + * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list. + * @param frameRateRange the {@link Camera_FrameRateRange} list to be deleted. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_VideoOutput_DeleteFrameRates(Camera_VideoOutput* videoOutput, + Camera_FrameRateRange* frameRateRange); + +/** + * @brief Set video output frame rate. + * + * @param videoOutput the {@link Camera_VideoOutput} instance to be set frame rate. + * @param minFps the minimum to be set. + * @param maxFps the maximum to be set. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_VideoOutput_SetFrameRate(Camera_VideoOutput* videoOutput, + int32_t minFps, int32_t maxFps); + +/** + * @brief Get active video output frame rate. + * + * @param videoOutput the {@link Camera_VideoOutput} instance to deliver the active frame rate. + * @param frameRateRange the active {@link Camera_FrameRateRange} to be filled if the method call succeeds. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_VideoOutput_GetActiveFrameRate(Camera_VideoOutput* videoOutput, + Camera_FrameRateRange* frameRateRange); + #ifdef __cplusplus } #endif diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index 386f3162eb67f5fa563b7a2c4d5bb66eb2366f43..410a27f20e5a94d19d63d75dd861916d50f2b9bc 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -486,6 +486,11 @@ typedef struct DRM_MediaKeySystemInfo { DRM_PsshInfo psshInfo[MAX_PSSH_INFO_COUNT]; } DRM_MediaKeySystemInfo; +/** +* @brief Callback for getting media key system information from media source. +* @since 11 +* @version 1.0 +*/ typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo *mediaKeySystemInfo); /** diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 0e453e4d5b3fbae7c6a4ecacf67c026dfcd97746..7e0949b810692dc6176a491497d44613a723de68 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -115,13 +115,17 @@ "first_introduced": "11", "name": "OH_MediaKeySession_Destroy" }, + { + "first_introduced": "11", + "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + }, { "first_introduced": "12", "name": "OH_MediaKeySystem_GetMediaKeySystems" }, { "first_introduced": "12", - "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + "name": "OH_MediaKeySession_SetCallback" }, { "first_introduced": "12", diff --git a/multimedia/drm_framework/native_mediakeysession.h b/multimedia/drm_framework/native_mediakeysession.h index 8afa6cfbec1bf5e83d176e9dafd07b19fbefca74..1eec1dfc3a0bfc36cc101f626eda94bfef232f00 100644 --- a/multimedia/drm_framework/native_mediakeysession.h +++ b/multimedia/drm_framework/native_mediakeysession.h @@ -38,6 +38,7 @@ #define OHOS_DRM_NATIVE_MEDIA_KEY_SESSION_H #include +#include #include #include "native_drm_err.h" #include "native_drm_common.h" @@ -300,4 +301,4 @@ Drm_ErrCode OH_MediaKeySession_Destroy(MediaKeySession *mediaKeySessoin); } #endif -#endif // OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H \ No newline at end of file +#endif // OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 2a818346bb2e251fbfaabe5afc2ce9385c2906d3..966948a6459bf197d2a47e41e1c4f4a030ea7c75 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -135,8 +135,6 @@ bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, * @brief Creates a media key system instance from the name. * @param name Secifies which drm system will be created by name. * @param mediaKeySystem Media key system instance. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully, - * return DRM_ERR_MAX_SYSTEM_NUM_REACHED when max num media key system reached. * @return {@link DRM_ERR_OK} 0 - Success.  *         {@link DRM_ERR_INVALID_VAL} 24700503 - Probably caused by: * 1. the name is nullptr or the length of name is zero. @@ -155,6 +153,7 @@ Drm_ErrCode OH_MediaKeySystem_Create(const char *name, MediaKeySystem **mediaKey * @param value Configuration vaule string to be set. * @return {@link DRM_ERR_OK} 0 - Success.  *         {@link DRM_ERR_INVALID_VAL} 24700503 - The parameter passed in is a null pointer or invalid. + *         {@link DRM_ERR_UNKNOWN} 24700506 - Internal error occurred, it is recommended to check the logs. * @since 11 * @version 1.0 */ @@ -358,7 +357,6 @@ Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySyste */ Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); - #ifdef __cplusplus } #endif diff --git a/multimedia/image_effect/image_effect.h b/multimedia/image_effect/image_effect.h index 921d8a5b04daf0fe9269f0c0fca3cb201c0bb1f3..db65c16e4f0dd1adefa49191e099835b530cb2cb 100644 --- a/multimedia/image_effect/image_effect.h +++ b/multimedia/image_effect/image_effect.h @@ -40,6 +40,7 @@ #include "image_effect_filter.h" #include "native_buffer/native_buffer.h" #include "native_window/external_window.h" +#include "multimedia/image_framework/image/picture_native.h" #ifdef __cplusplus extern "C" { @@ -315,6 +316,33 @@ ImageEffect_ErrorCode OH_ImageEffect_SetInputUri(OH_ImageEffect *imageEffect, co */ ImageEffect_ErrorCode OH_ImageEffect_SetOutputUri(OH_ImageEffect *imageEffect, const char *uri); +/** + * @brief Set input picture that contains the image information. It should be noted that the input picture will be + * directly rendered and modified if the output is not set + * + * @syscap SystemCapability.Multimedia.ImageEffect.Core + * @param imageEffect Encapsulate OH_ImageEffect structure instance pointer + * @param picture Indicates the OH_PictureNative that contains the image information + * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to + * {@link ImageEffect_ErrorCode} + * {@link EFFECT_ERROR_PARAM_INVALID}, the input parameter is a null pointer. + * @since 13 + */ +ImageEffect_ErrorCode OH_ImageEffect_SetInputPicture(OH_ImageEffect *imageEffect, OH_PictureNative *picture); + +/** + * @brief Set output picture that contains the image information + * + * @syscap SystemCapability.Multimedia.ImageEffect.Core + * @param imageEffect Encapsulate OH_ImageEffect structure instance pointer + * @param picture Indicates the OH_PictureNative that contains the image information + * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to + * {@link ImageEffect_ErrorCode} + * {@link EFFECT_ERROR_PARAM_INVALID}, the input parameter is a null pointer. + * @since 13 + */ +ImageEffect_ErrorCode OH_ImageEffect_SetOutputPicture(OH_ImageEffect *imageEffect, OH_PictureNative *picture); + /** * @brief Render the filter effects that can be a single filter or a chain of filters * diff --git a/multimedia/image_effect/image_effect_filter.h b/multimedia/image_effect/image_effect_filter.h index 8c616e60af91745eac8f12e5ea3e6aedbb99ce75..d42de85d79a133d034657731d24c0339bdd72839 100644 --- a/multimedia/image_effect/image_effect_filter.h +++ b/multimedia/image_effect/image_effect_filter.h @@ -36,6 +36,7 @@ #ifndef NATIVE_IMAGE_EFFECT_FILTER_H #define NATIVE_IMAGE_EFFECT_FILTER_H +#include #include #include "image_effect_errors.h" #include "multimedia/image_framework/image/pixelmap_native.h" @@ -147,6 +148,7 @@ typedef union ImageEffect_DataValue { void *ptrValue; } ImageEffect_DataValue; +#ifdef __cplusplus /** * @brief Data parameter struct information * @@ -159,6 +161,20 @@ typedef struct ImageEffect_Any { /** Effect any data value */ ImageEffect_DataValue dataValue = { 0 }; } ImageEffect_Any; +#else +/** + * @brief Data parameter struct information + * + * @syscap SystemCapability.Multimedia.ImageEffect.Core + * @since 12 + */ +typedef struct ImageEffect_Any { + /** Effect any data type */ + ImageEffect_DataType dataType; + /** Effect any data value */ + ImageEffect_DataValue dataValue; +} ImageEffect_Any; +#endif /** * @brief Enumerates the pixel format type @@ -315,6 +331,7 @@ ImageEffect_ErrorCode OH_EffectFilterInfo_GetSupportedFormats(OH_EffectFilterInf */ ImageEffect_ErrorCode OH_EffectFilterInfo_Release(OH_EffectFilterInfo *info); +#ifdef __cplusplus /** * @brief EffectFilter names information * @@ -327,6 +344,20 @@ typedef struct ImageEffect_FilterNames { /** EffectFilter names memory block */ const char **nameList = nullptr; } ImageEffect_FilterNames; +#else +/** + * @brief EffectFilter names information + * + * @syscap SystemCapability.Multimedia.ImageEffect.Core + * @since 12 + */ +typedef struct ImageEffect_FilterNames { + /** EffectFilter names array size */ + uint32_t size; + /** EffectFilter names memory block */ + const char **nameList; +} ImageEffect_FilterNames; +#endif /** * @brief Define the new type name OH_EffectBufferInfo for struct OH_EffectBufferInfo diff --git a/multimedia/image_effect/libimage_effect.ndk.json b/multimedia/image_effect/libimage_effect.ndk.json index 6b3c6abab74f8bc6e547aa7cd5837886a620affa..16f31e29f19a30b0443d3c5c819da543c176fcbe 100644 --- a/multimedia/image_effect/libimage_effect.ndk.json +++ b/multimedia/image_effect/libimage_effect.ndk.json @@ -203,6 +203,14 @@ "first_introduced": "12", "name": "OH_ImageEffect_SetOutputUri" }, + { + "first_introduced": "13", + "name": "OH_ImageEffect_SetInputPicture" + }, + { + "first_introduced": "13", + "name": "OH_ImageEffect_SetOutputPicture" + }, { "first_introduced": "12", "name": "OH_ImageEffect_Start" diff --git a/multimedia/image_framework/BUILD.gn b/multimedia/image_framework/BUILD.gn index be2610e9773a09e7004b3e20972f49de5bd5f1f1..f28533e28e769816c6eb39a75af6db2577eb1905 100644 --- a/multimedia/image_framework/BUILD.gn +++ b/multimedia/image_framework/BUILD.gn @@ -44,6 +44,38 @@ ohos_ndk_headers("libpixelmap_header") { sources = [ "./include/image/pixelmap_native.h" ] } +ohos_ndk_library("libpicture") { + ndk_description_file = "./libpicture.ndk.json" + output_name = "picture" + output_extension = "so" + min_compact_version = "13" + system_capability = "SystemCapability.Multimedia.Image.Core" + system_capability_headers = [ + "multimedia/image_framework/image/picture_native.h", + "multimedia/image_framework/image/image_common.h", + ] +} + +ohos_ndk_headers("libpicture_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework/image" + sources = [ "./include/image/picture_native.h" ] +} + +ohos_ndk_library("libimage_common") { + ndk_description_file = "./libimage_common.ndk.json" + output_name = "image_common" + output_extension = "so" + min_compact_version = "13" + system_capability = "SystemCapability.Multimedia.Image.Core" + system_capability_headers = + [ "multimedia/image_framework/image/image_common.h" ] +} + +ohos_ndk_headers("libimage_common_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework/image" + sources = [ "./include/image/image_common.h" ] +} + ohos_ndk_library("libimage_ndk") { ndk_description_file = "./libimage_ndk.ndk.json" min_compact_version = "1" @@ -119,10 +151,7 @@ ohos_ndk_library("libohimage") { ohos_ndk_headers("ohimage_header") { dest_dir = "$ndk_headers_out_dir/multimedia/image_framework/image" - sources = [ - "./include/image/image_common.h", - "./include/image/image_native.h", - ] + sources = [ "./include/image/image_native.h" ] } ohos_ndk_library("libimage_receiver") { diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index 6e50d776490653fff25f6c27627d47c82d32b817..b6cf5943d3fdc2dd37eae7bf2cd3d982477c7fb7 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -83,6 +83,7 @@ struct Image_Region { */ typedef struct Image_Region Image_Region; +#ifdef __cplusplus /** * @brief Defines the region of the image source to decode. * @@ -94,6 +95,33 @@ struct Image_String { /** data lenth for string type */ size_t size = 0; }; +#else +/** + * @brief Defines the region of the image source to decode. + * + * @since 12 + */ +struct Image_String { + /** data for string type */ + char *data; + /** data lenth for string type */ + size_t size; +}; +#endif + +/** + * @brief Define a PictureMetadata struct type, used for picture metadata. + * + * @since 13 + */ +struct OH_PictureMetadata; + +/** + * @brief Define a PictureMetadata struct type, used for picture metadata. + * + * @since 13 + */ +typedef struct OH_PictureMetadata OH_PictureMetadata; /** * @brief Defines the property string (in key-value format) of the image source. @@ -125,6 +153,10 @@ typedef enum { IMAGE_UNKNOWN_MIME_TYPE = 7600102, /** too large data or image */ IMAGE_TOO_LARGE = 7600103, + /** @error DMA memory does not exist */ + IMAGE_DMA_NOT_EXIST = 7600173, + /** @error DMA operation failed */ + IMAGE_DMA_OPERATION_FAILED = 7600174, /** unsupported operations */ IMAGE_UNSUPPORTED_OPERATION = 7600201, /** unsupported metadata */ @@ -133,6 +165,10 @@ typedef enum { IMAGE_UNSUPPORTED_CONVERSION = 7600203, /** invalid region */ IMAGE_INVALID_REGION = 7600204, + /** @error unsupported memory format + * @since 13 + */ + IMAGE_UNSUPPORTED_MEMORY_FORMAT = 7600205, /** failed to allocate memory */ IMAGE_ALLOC_FAILED = 7600301, /** memory copy failed */ @@ -147,6 +183,89 @@ typedef enum { IMAGE_ENCODE_FAILED = 7800301, } Image_ErrorCode; +/** + * @brief Define the metadata type. + * + * @since 13 + */ +typedef enum { + /* + * EXIF metadata. + */ + EXIF_METADATA = 1, + /* + * Fragment metadata. + */ + FRAGMENT_METADATA = 2, +} Image_MetadataType; + +/** + * @brief Creates a PictureMetadata object. + * + * @param metadataType The type of metadata. + * @param metadata The PictureMetadata pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PictureMetadata_Create(Image_MetadataType metadataType, OH_PictureMetadata **metadata); + +/** + * @brief Obtains the property of picture metadata. + * + * @param metadata The PictureMetadata pointer will be operated. + * @param key The property's key. + * @param value The property's value. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr, or key is nullptr, or value is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 13 + */ +Image_ErrorCode OH_PictureMetadata_GetProperty(OH_PictureMetadata *metadata, Image_String *key, Image_String *value); + +/** + * @brief Set picture metadata property. + * + * @param metadata The PictureMetadata pointer will be operated. + * @param key The property's key. + * @param value The property's value. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr, or key is nullptr, or value is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 13 + */ +Image_ErrorCode OH_PictureMetadata_SetProperty(OH_PictureMetadata *metadata, Image_String *key, Image_String *value); + +/** + * @brief Releases this PictureMetadata object. + * + * @param metadata The PictureMetadata pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PictureMetadata_Release(OH_PictureMetadata *metadata); + +/** + * @brief Obtains a clone of metadata. + * + * @param oldMetadata The PictureMetadata pointer will be operated. + * @param newMetadata The PictureMetadata pointer will be cloned. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr. + * {@link IMAGE_ALLOC_FAILED} memory alloc failed. + * {@link IMAGE_COPY_FAILED} memory copy failed. + * @since 13 + */ +Image_ErrorCode OH_PictureMetadata_Clone(OH_PictureMetadata *oldMetadata, OH_PictureMetadata **newMetadata); + /** * @brief Defines the bmp mime type. * @@ -1333,6 +1452,42 @@ static const char *OHOS_IMAGE_PROPERTY_WIND_SNAPSHOT_MODE = "HwMnoteWindSnapshot * @since 12 */ static const char *OHOS_IMAGE_PROPERTY_GIF_LOOP_COUNT = "GIFLoopCount"; + +/** + * @brief X in original + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The top left corner of the fragment image is at the X-coordinate of the original image + * + * @since 13 + */ +static const char *OHOS_IMAGE_PROPERTY_X_IN_ORIGINAL = "XInOriginal"; + +/** + * @brief Y in original + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The top left corner of the fragment image is at the Y-coordinate of the original image + * + * @since 13 + */ +static const char *OHOS_IMAGE_PROPERTY_Y_IN_ORIGINAL = "YInOriginal"; + +/** + * @brief Fragment map width + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The width of the fragment image + * + * @since 13 + */ +static const char *OHOS_IMAGE_PROPERTY_FRAGMENT_WIDTH = "FragmentImageWidth"; + +/** + * @brief Fragment map height + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The height of the fragment image + * + * @since 13 + */ +static const char *OHOS_IMAGE_PROPERTY_FRAGMENT_HEIGHT = "FragmentImageHeight"; #ifdef __cplusplus }; #endif diff --git a/multimedia/image_framework/include/image/image_packer_native.h b/multimedia/image_framework/include/image/image_packer_native.h index 6a5a4e9b54b4a05661efc659a3cf847dbc9358cd..b80688711c64b08211dcd44d518e737fd4ec4ac4 100644 --- a/multimedia/image_framework/include/image/image_packer_native.h +++ b/multimedia/image_framework/include/image/image_packer_native.h @@ -59,6 +59,20 @@ typedef struct OH_ImagePackerNative OH_ImagePackerNative; struct OH_PackingOptions; typedef struct OH_PackingOptions OH_PackingOptions; +/** + * @brief Defines the image sequence packing options. + * + * @since 13 + */ +struct OH_PackingOptionsForSequence; + +/** + * @brief Defines the image sequence packing options. + * + * @since 13 + */ +typedef struct OH_PackingOptionsForSequence OH_PackingOptionsForSequence; + /** * @brief Enumerates packing dynamic range. * @@ -182,6 +196,134 @@ Image_ErrorCode OH_PackingOptions_SetDesiredDynamicRange(OH_PackingOptions *opti */ Image_ErrorCode OH_PackingOptions_Release(OH_PackingOptions *options); +/** + * @brief Create a pointer for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_Create(OH_PackingOptionsForSequence **options); + +/** + * @brief Set FrameCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param frameCount The number of image frameCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetFrameCount(OH_PackingOptionsForSequence *options, + uint32_t frameCount); + +/** + * @brief Get FrameCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param frameCount The number of image frameCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or frameCount is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetFrameCount(OH_PackingOptionsForSequence *options, + uint32_t *frameCount); + +/** + * @brief Set DelayTimeList number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param delayTimeList The pointer of image delayTime list. + * @param delayTimeListLength The number of image delayTimeListLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or delayTimeList is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetDelayTimeList(OH_PackingOptionsForSequence *options, + int32_t *delayTimeList, size_t delayTimeListLength); + +/** + * @brief Get DelayTimeList number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param delayTimeList The pointer of image delayTime list. + * @param delayTimeListLength The number of image delayTimeListLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or delayTimeList is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetDelayTimeList(OH_PackingOptionsForSequence *options, + int32_t *delayTimeList, size_t delayTimeListLength); + +/** + * @brief Set DisposalTypes number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param disposalTypes The pointer of image disposalTypes. + * @param disposalTypesLength The number of image disposalTypesLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or disposalTypes is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetDisposalTypes(OH_PackingOptionsForSequence *options, + uint32_t *disposalTypes, size_t disposalTypesLength); + +/** + * @brief Get DisposalTypes number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param disposalTypes The pointer of image disposalTypes. + * @param disposalTypesLength The number of image disposalTypesLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or disposalTypes is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetDisposalTypes(OH_PackingOptionsForSequence *options, + uint32_t *disposalTypes, size_t disposalTypesLength); + +/** + * @brief Set LoopCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param loopCount The number of image loopCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetLoopCount(OH_PackingOptionsForSequence *options, uint32_t loopCount); + +/** + * @brief Get LoopCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param loopCount The number of image loopCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or loopCount is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetLoopCount(OH_PackingOptionsForSequence *options, uint32_t *loopCount); + +/** + * @brief delete OH_PackingOptionsForSequence pointer. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PackingOptionsForSequence_Release(OH_PackingOptionsForSequence *options); + /** * @brief Create a pointer for OH_ImagePackerNative struct. * @@ -219,6 +361,43 @@ Image_ErrorCode OH_ImagePackerNative_PackToDataFromImageSource(OH_ImagePackerNat Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmap(OH_ImagePackerNative *imagePacker, OH_PackingOptions *options, OH_PixelmapNative *pixelmap, uint8_t *outData, size_t *size); +/** + * @brief Encoding a Picture into the data with required format. + * + * @param imagePacker The imagePacker to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptions}. + * @param picture The picture to be packed. + * @param outData The output data buffer to store the packed image. + * @param size A pointer to the size of the output data buffer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} imagePacker is nullptr, or picture is nullptr, or outData is nullptr, + * or size is invalid. + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 13 + */ +Image_ErrorCode OH_ImagePackerNative_PackToDataFromPicture(OH_ImagePackerNative *imagePacker, + OH_PackingOptions *options, OH_PictureNative *picture, uint8_t *outData, size_t *size); + +/** + * @brief Encoding a PixelMap sequence into the data + * + * @param imagePacker The imagePacker to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptionsForSequence}. + * @param pixelmapSequence The pixelmap sequence to be packed. + * @param sequenceLength The pixelmap sequence size to be packed. + * @param outData The output data buffer to store the packed image. + * @param outDataSize A pointer to the size of the output data buffer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} one of the pointer type parameters is nullptr, or size/length is invalid + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 13 + */ +Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmapSequence(OH_ImagePackerNative *imagePacker, + OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence, + size_t sequenceLength, uint8_t *outData, size_t *outDataSize); + /** * @brief Encoding an ImageSource into the a file with fd with required format. * @@ -245,6 +424,39 @@ Image_ErrorCode OH_ImagePackerNative_PackToFileFromImageSource(OH_ImagePackerNat Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmap(OH_ImagePackerNative *imagePacker, OH_PackingOptions *options, OH_PixelmapNative *pixelmap, int32_t fd); +/** + * @brief Encoding a Picture into the a file with fd with required format. + * + * @param imagePacker The imagePacker to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptions}. + * @param picture The picture to be packed. + * @param fd Indicates a writable file descriptor. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} imagePacker is nullptr, or picture is nullptr, or fd is invalid. + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 13 + */ +Image_ErrorCode OH_ImagePackerNative_PackToFileFromPicture(OH_ImagePackerNative *imagePacker, + OH_PackingOptions *options, OH_PictureNative *picture, int32_t fd); + +/** + * @brief Encoding a PixelMap sequence into the a file with fd + * + * @param imagePacker The image packer to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptionsForSequence}. + * @param pixelmapSequence The pixelmap sequence to be packed. + * @param sequenceLength The pixelmap sequence size to be packed. + * @param fd Indicates a writable file descriptor. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} one of the pointer type parameters is nullptr, or length is invalid + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 13 + */ +Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmapSequence(OH_ImagePackerNative *imagePacker, + OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence, size_t sequenceLength, int32_t fd); + /** * @brief Releases an imagePacker object. * diff --git a/multimedia/image_framework/include/image/image_source_native.h b/multimedia/image_framework/include/image/image_source_native.h index 72cf4dae2dbda1887ee062ad4a346024551eb7bf..7e54b94ef5f383016d0166855b7eb20ffd07396e 100644 --- a/multimedia/image_framework/include/image/image_source_native.h +++ b/multimedia/image_framework/include/image/image_source_native.h @@ -38,6 +38,7 @@ #include "image_common.h" #include "pixelmap_native.h" +#include "picture_native.h" #include "rawfile/raw_file.h" #ifdef __cplusplus @@ -61,6 +62,22 @@ typedef struct OH_ImageSourceNative OH_ImageSourceNative; struct OH_ImageSource_Info; typedef struct OH_ImageSource_Info OH_ImageSource_Info; +/** + * @brief Defines decoding options for picture + * {@link OH_DecodingOptionsForPicture_Create}. + * + * @since 13 + */ +struct OH_DecodingOptionsForPicture; + +/** + * @brief Defines decoding options for picture + * {@link OH_DecodingOptionsForPicture_Create}. + * + * @since 13 + */ +typedef struct OH_DecodingOptionsForPicture OH_DecodingOptionsForPicture; + /** * @brief Enumerates decoding dynamic range.. * @@ -360,6 +377,23 @@ Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList(OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative *resVecPixMap[], size_t size); +/** + * @brief Create Picture pointer from ImageSource + * based on the specified {@link OH_DecodingOptionsForPicture} struct. + * + * @param source Indicates a void pointer(from ImageSource pointer convert). + * @param options Indicates a pointer to the options for decoding the image source. + * For details, see {@link OH_DecodingOptionsForPicture}. + * @param picture Indicates a void pointer to the Picture object obtained at the C++ native layer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} source is nullptr, or picture is nullptr. + * {@link IMAGE_DECODE_FAILED} decode failed. + * @since 13 + */ +Image_ErrorCode OH_ImageSourceNative_CreatePicture(OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options, + OH_PictureNative **picture); + /** * @brief Obtains the delay time list from some ImageSource objects (such as GIF image sources). * @@ -429,6 +463,57 @@ Image_ErrorCode OH_ImageSourceNative_GetFrameCount(OH_ImageSourceNative *source, */ Image_ErrorCode OH_ImageSourceNative_Release(OH_ImageSourceNative *source); +/** + * @brief Create a pointer for OH_DecodingOptionsForPicture struct. + * + * @param options The OH_DecodingOptionsForPicture pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 13 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_Create(OH_DecodingOptionsForPicture **options); + +/** + * @brief Obtains the desired auxiliary pictures of decoding options. + * + * @param options The OH_DecodingOptionsForPicture pointer will be operated. + * @param desiredAuxiliaryPictures The desired auxiliary pictures in DecodingOptionsForPicture. + * @param length The length of desired auxiliary pictures. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr, desiredAuxiliaryPictures is nullptr, + * or length is invalid. + * @since 13 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, + Image_AuxiliaryPictureType **desiredAuxiliaryPictures, size_t *length); + +/** + * @brief Set decoding options desired auxiliary pictures. + * + * @param options The OH_DecodingOptionsForPicture pointer will be operated. + * @param desiredAuxiliaryPictures The desired auxiliary pictures will be set. + * @param length The length of desired auxiliary pictures. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr, desiredAuxiliaryPictures is nullptr, + * or length is invalid. + * @since 13 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, + Image_AuxiliaryPictureType *desiredAuxiliaryPictures, size_t length); + +/** + * @brief Releases an DecodingOptionsForPicture object. + * + * @param options Indicates a DecodingOptionsForPicture pointer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 13 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_Release(OH_DecodingOptionsForPicture *options); #ifdef __cplusplus }; #endif diff --git a/multimedia/image_framework/include/image/picture_native.h b/multimedia/image_framework/include/image/picture_native.h new file mode 100644 index 0000000000000000000000000000000000000000..42eed5065322b58ecc4cece094d222f4d51080f0 --- /dev/null +++ b/multimedia/image_framework/include/image/picture_native.h @@ -0,0 +1,491 @@ +/* + * 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 image + * @{ + * + * @brief Provides APIs for obtaining picture data and information. + * + * @Syscap SystemCapability.Multimedia.Image.Core + * @since 13 + */ + +/** + * @file picture_native.h + * + * @brief Declares the APIs that can access a picture. + * + * @library libpicture.so + * @kit ImageKit + * @Syscap SystemCapability.Multimedia.Image.Core + * @since 13 + */ +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PICTURE_NATIVE_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PICTURE_NATIVE_H_ +#include "image_common.h" +#include "pixelmap_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define a Picture struct type, used for picture pointer controls. + * + * @since 13 + */ +struct OH_PictureNative; + +/** + * @brief Define a Picture struct type, used for picture pointer controls. + * + * @since 13 + */ +typedef struct OH_PictureNative OH_PictureNative; + +/** + * @brief Define a AuxiliaryPicture struct type, used for auxiliary + * picture pointer controls. + * + * @since 13 + */ +struct OH_AuxiliaryPictureNative; + +/** + * @brief Define a AuxiliaryPicture struct type, used for auxiliary + * picture pointer controls. + * + * @since 13 + */ +typedef struct OH_AuxiliaryPictureNative OH_AuxiliaryPictureNative; + +/** + * @brief Define a AuxiliaryPictureInfo struct type, used for auxiliary + * picture info controls. + * + * @since 13 + */ +struct OH_AuxiliaryPictureInfo; + +/** + * @brief Define a AuxiliaryPictureInfo struct type, used for auxiliary + * picture info controls. + * + * @since 13 + */ +typedef struct OH_AuxiliaryPictureInfo OH_AuxiliaryPictureInfo; + +/** + * @brief Define a auxiliary picture type. + * + * @since 13 + */ +typedef enum { + /* + * Gainmap + */ + AUXILIARY_PICTURE_TYPE_GAINMAP = 1, + /* + * Depth map + */ + AUXILIARY_PICTURE_TYPE_DEPTH_MAP = 2, + /* + * Unrefocus map + */ + AUXILIARY_PICTURE_TYPE_UNREFOCUS_MAP = 3, + /* + * Linear map + */ + AUXILIARY_PICTURE_TYPE_LINEAR_MAP = 4, + /* + * Fragment map + */ + AUXILIARY_PICTURE_TYPE_FRAGMENT_MAP = 5, +} Image_AuxiliaryPictureType; + +/** + * @brief Create a Picture object. + * + * @param mainPixelmap The pixel map of the main image. + * @param picture Picture pointer for created. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} mainPixelmap is nullptr, or picture is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_CreatePicture(OH_PixelmapNative *mainPixelmap, OH_PictureNative **picture); + +/** + * @brief Obtains the pixel map of the main image. + * + * @param picture The Picture pointer will be operated. + * @param mainPixelmap Main pixel map pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or mainPixelmap is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_GetMainPixelmap(OH_PictureNative *picture, OH_PixelmapNative **mainPixelmap); + +/** + * @brief Obtains the hdr pixel map. + * + * @param picture The Picture pointer will be operated. + * @param hdrPixelmap Hdr pixel map pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or hdrPixelmap is nullptr. + * {@link IMAGE_UNSUPPORTED_OPERATION} Unsupported operation, e.g. the picture does not has a gainmap + * @since 13 + */ +Image_ErrorCode OH_PictureNative_GetHdrComposedPixelmap(OH_PictureNative *picture, OH_PixelmapNative **hdrPixelmap); + +/** + * @brief Obtains the gainmap pixel map. + * + * @param picture The Picture pointer will be operated. + * @param gainmapPixelmap Gainmap pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or gainmapPixelmap is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_GetGainmapPixelmap(OH_PictureNative *picture, OH_PixelmapNative **gainmapPixelmap); + +/** + * @brief Set auxiliary picture. + * + * @param picture The Picture pointer will be operated. + * @param type The type of auxiliary picture. + * @param auxiliaryPicture AuxiliaryPicture object. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or auxiliaryPicture is nullptr, or the type is invalid. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_SetAuxiliaryPicture(OH_PictureNative *picture, Image_AuxiliaryPictureType type, + OH_AuxiliaryPictureNative *auxiliaryPicture); + +/** + * @brief Obtains the auxiliary picture based on type. + * + * @param picture The Picture pointer will be operated. + * @param type The type of auxiliary picture. + * @param auxiliaryPicture AuxiliaryPicture pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or auxiliaryPicture is nullptr, or the type is invalid. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_GetAuxiliaryPicture(OH_PictureNative *picture, Image_AuxiliaryPictureType type, + OH_AuxiliaryPictureNative **auxiliaryPicture); + +/** + * @brief Obtains the metadata of main picture. + * + * @param picture The Picture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata of main picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_GetMetadata(OH_PictureNative *picture, Image_MetadataType metadataType, + OH_PictureMetadata **metadata); + +/** + * @brief Set main picture metadata. + * + * @param picture The Picture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_SetMetadata(OH_PictureNative *picture, Image_MetadataType metadataType, + OH_PictureMetadata *metadata); + +/** + * @brief Releases this Picture object. + * + * @param picture The Picture pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr. + * @since 13 + */ +Image_ErrorCode OH_PictureNative_Release(OH_PictureNative *picture); + +/** + * @brief Create a AuxiliaryPicture object. + * + * @param data The image data buffer. + * @param dataLength The length of data. + * @param size The size of auxiliary picture. + * @param type The type of auxiliary picture. + * @param auxiliaryPicture AuxiliaryPicture pointer for created. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} data is nullptr, or dataLength is invalid, or size is nullptr, or the type + * is invalid, or auxiliaryPicture is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_Create(uint8_t *data, size_t dataLength, Image_Size *size, + Image_AuxiliaryPictureType type, OH_AuxiliaryPictureNative **auxiliaryPicture); + +/** + * @brief Write pixels to auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param source The pixels will be written. + * @param bufferSize The size of pixels. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or source is nullptr, or the bufferSize is invalid. + * {@link IMAGE_ALLOC_FAILED} memory alloc failed. + * {@link IMAGE_COPY_FAILED} memory copy failed. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_WritePixels(OH_AuxiliaryPictureNative *auxiliaryPicture, uint8_t *source, + size_t bufferSize); + +/** + * @brief Read pixels from auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param destination The pixels will be read. + * @param bufferSize The size of pixels for reading. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or destination is nullptr, + * or the bufferSize is invalid. + * {@link IMAGE_ALLOC_FAILED} memory alloc failed. + * {@link IMAGE_COPY_FAILED} memory copy failed. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_ReadPixels(OH_AuxiliaryPictureNative *auxiliaryPicture, uint8_t *destination, + size_t *bufferSize); + +/** + * @brief Obtains the type of auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param type The type of auxiliary picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or type is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_GetType(OH_AuxiliaryPictureNative *auxiliaryPicture, + Image_AuxiliaryPictureType *type); + +/** + * @brief Obtains the info of auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param info The info of auxiliary picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or info is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_GetInfo(OH_AuxiliaryPictureNative *auxiliaryPicture, + OH_AuxiliaryPictureInfo **info); + +/** + * @brief Set auxiliary picture info. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param info The info will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or info is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_SetInfo(OH_AuxiliaryPictureNative *auxiliaryPicture, + OH_AuxiliaryPictureInfo *info); + +/** + * @brief Obtains the metadata of auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata of auxiliary picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_GetMetadata(OH_AuxiliaryPictureNative *auxiliaryPicture, + Image_MetadataType metadataType, OH_PictureMetadata **metadata); + +/** + * @brief Set auxiliary picture metadata. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_SetMetadata(OH_AuxiliaryPictureNative *auxiliaryPicture, + Image_MetadataType metadataType, OH_PictureMetadata *metadata); + +/** + * @brief Releases this AuxiliaryPicture object. + * + * @param picture The Picture pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_Release(OH_AuxiliaryPictureNative *picture); + +/** + * @brief Create a AuxiliaryPictureInfo object. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_Create(OH_AuxiliaryPictureInfo **info); + +/** + * @brief Obtains the type of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param type The type of auxiliary picture info. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or type is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetType(OH_AuxiliaryPictureInfo *info, Image_AuxiliaryPictureType *type); + +/** + * @brief Set auxiliary picture info type. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param type The type will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or type is invalid. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetType(OH_AuxiliaryPictureInfo *info, Image_AuxiliaryPictureType type); + +/** + * @brief Obtains the size of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param size The size of auxiliary picture info. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or size is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetSize(OH_AuxiliaryPictureInfo *info, Image_Size *size); + +/** + * @brief Set auxiliary picture info size. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param size The size will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or size is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetSize(OH_AuxiliaryPictureInfo *info, Image_Size *size); + +/** + * @brief Obtains the rowStride of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param rowStride The rowStride of auxiliary picture info. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or rowStride is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetRowStride(OH_AuxiliaryPictureInfo *info, uint32_t *rowStride); + +/** + * @brief Set auxiliary picture info rowStride. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param rowStride The rowStride will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or rowStride is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetRowStride(OH_AuxiliaryPictureInfo *info, uint32_t rowStride); + +/** + * @brief Obtains the pixelFormat of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param pixelFormat The pixelFormat will be get. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or pixelFormat is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetPixelFormat(OH_AuxiliaryPictureInfo *info, PIXEL_FORMAT *pixelFormat); + +/** + * @brief Set auxiliary picture info pixelFormat. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param pixelFormat The pixelFormat will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetPixelFormat(OH_AuxiliaryPictureInfo *info, PIXEL_FORMAT pixelFormat); + +/** + * @brief Releases this AuxiliaryPictureInfo object. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr. + * @since 13 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_Release(OH_AuxiliaryPictureInfo *info); + +#ifdef __cplusplus +}; +#endif +/** @} */ +#endif //INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PICTURE_NATIVE_H_ \ No newline at end of file diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h index 5f8be7c783e9671e7fd411d5ab276e6d0bd05a63..1599a662170d02f5f8e7ad856a9546bbc5f4bfb5 100644 --- a/multimedia/image_framework/include/image/pixelmap_native.h +++ b/multimedia/image_framework/include/image/pixelmap_native.h @@ -36,6 +36,9 @@ #ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXELMAP_NATIVE_H_ #define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXELMAP_NATIVE_H_ + +#include + #include "image_common.h" #include "napi/native_api.h" @@ -51,6 +54,21 @@ extern "C" { struct OH_PixelmapNative; typedef struct OH_PixelmapNative OH_PixelmapNative; +/** + * @brief Define a native buffer type, used for retrieving a native buffer. + * + * @since 12 + */ +struct OH_NativeBuffer; +typedef struct OH_NativeBuffer OH_NativeBuffer; + +/** + * @brief Define a native ColorSpaceManager type, used for retrieving a native ColorSpaceManager. + * + * @since 13 + */ +typedef struct OH_NativeColorSpaceManager OH_NativeColorSpaceManager; + /** * @brief Define a pixelmap alpha type. * @@ -112,6 +130,18 @@ typedef enum { * NV12 format */ PIXEL_FORMAT_NV12 = 9, + /* + * RGBA_1010102 format + */ + PIXEL_FORMAT_RGBA_1010102 = 10, + /* + * YCBCR_P010 format + */ + PIXEL_FORMAT_YCBCR_P010 = 11, + /* + * YCRCB_P010 format + */ + PIXEL_FORMAT_YCRCB_P010 = 12, } PIXEL_FORMAT; /** @@ -171,19 +201,19 @@ typedef enum { /** * No metadata. */ - NONE = 0, + HDR_METADATA_TYPE_NONE = 0, /** * Indicates that metadata will be used for the base image. */ - BASE = 1, + HDR_METADATA_TYPE_BASE = 1, /** * Indicates that metadata will be used for the gainmap image. */ - GAINMAP = 2, + HDR_METADATA_TYPE_GAINMAP = 2, /** * Indicates that metadata will be used for the alternate image. */ - ALTERNATE = 3, + HDR_METADATA_TYPE_ALTERNATE = 3, } OH_Pixelmap_HdrMetadataType; /** @@ -631,6 +661,23 @@ Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_ */ Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize); +/** + * @brief Get argb pixel buffer from pixelmap. + * + * @param pixelmap The Pixelmap pointer to be operated. + * @param destination Buffer to which the image pixel map data will be written. + * @param bufferSize Buffer size to which the image pixel map data will be written. + * @return Function result code: + * {@link IMAGE_SUCCESS} If the operation is successful. + * {@link IMAGE_BAD_PARAMETER} If invalid parameter, destination and bufferSize are incorrect. + * {@link IMAGE_UNSUPPORTED_CONVERSION} If format does not support conversion to argb or conversion failed. + * {@link IMAGE_ALLOC_FAILED} If device has no memory. + * {@link IMAGE_COPY_FAILED} If memory copy failed. + * @see OH_PixelmapNative + * @since 13 + */ +Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize); + /** * @brief Convert {@link OH_PixelmapNative} to standard dynamic range. * @@ -765,6 +812,95 @@ Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixel Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap( OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap); +/** + * @brief Get metadata. + * + * @param pixelmap The Pixelmap pointer to be operated. + * @param key Type of metadata. + * @param value Value of metadata. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect. + * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory does not exist. + * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed. + * @see OH_PixelmapNative + * @since 12 + */ +Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, + OH_Pixelmap_HdrMetadataValue **value); + +/** + * @brief Set metadata. + * + * @param pixelmap The Pixelmap pointer to be operated. + * @param key Type of metadata. + * @param value Value of metadata. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect. + * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory does not exist. + * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed. + * @see OH_PixelmapNative + * @since 12 + */ +Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, + OH_Pixelmap_HdrMetadataValue *value); + +/** + * @brief Get the native buffer from the PixelMap. + * + * @param pixelmap The PixelMap to get the native buffer from. + * @param nativeBuffer The native buffer to retrieve. + * @return Returns {@link Image_ErrorCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, pixelmap or nativeBuffer is null. + * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory dose not exist. + * returns {@link Image_ErrorCode} IMAGE_DMA_OPERATION_FAILED - if operations related to DMA memory has failed. + * @see OH_PixelmapNative + * @since 12 + */ +Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer); + +/** + * @brief Set pixelmap memory name. + * + * @param pixelmap The Pixelmap pointer to be operated. + * @param name The pointer of name that needs to be set. + * @param size The size of name size that needs to be set. + * @return Function result code: + * {@link IMAGE_SUCCESS} If the operation is successful. + * {@link IMAGE_BAD_PARAMETER} If invalid parameter, name and size are incorrect. + * {@link IMAGE_UNSUPPORTED_MEMORY_FORMAT} If memory format is unsupported. + * @see OH_PixelmapNative + * @since 13 + */ +Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size); + +/** + * @brief Get the native colorspace from the PixelMap. + * + * @param pixelmap The native pixelmap to get the native colorspace from. + * @param colorSpaceNative The native colorspace to retrieve. + * @return Function result code: + * {@link IMAGE_SUCCESS} If the execution is successful. + * {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid. + * @see OH_PixelmapNative + * @since 13 + */ +Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap, + OH_NativeColorSpaceManager **colorSpaceNative); + +/** + * @brief Set the native colorspace for the PixelMap. + * + * @param pixelmap The native pixelmap to set the native colorspace for. + * @param colorSpaceNative The native colorspace to set. + * @return Function result code: + * {@link IMAGE_SUCCESS} If the execution is successful. + * {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid. + * @see OH_PixelmapNative + * @since 13 + */ +Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap, + OH_NativeColorSpaceManager *colorSpaceNative); + #ifdef __cplusplus }; #endif diff --git a/multimedia/image_framework/libimage_common.ndk.json b/multimedia/image_framework/libimage_common.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..63d2820cc1fb4da91e3e0f1b9efea3415c20312b --- /dev/null +++ b/multimedia/image_framework/libimage_common.ndk.json @@ -0,0 +1,22 @@ +[ + { + "first_introduced": "13", + "name": "OH_PictureMetadata_Create" + }, + { + "first_introduced": "13", + "name": "OH_PictureMetadata_GetProperty" + }, + { + "first_introduced": "13", + "name": "OH_PictureMetadata_SetProperty" + }, + { + "first_introduced": "13", + "name": "OH_PictureMetadata_Release" + }, + { + "first_introduced": "13", + "name": "OH_PictureMetadata_Clone" + } +] \ No newline at end of file diff --git a/multimedia/image_framework/libimage_packer.ndk.json b/multimedia/image_framework/libimage_packer.ndk.json index 0b5efcecfdb13f252a99694f011a200e24e884c6..c6f2435047bd9bc116df32a37adeb447808f7d1a 100644 --- a/multimedia/image_framework/libimage_packer.ndk.json +++ b/multimedia/image_framework/libimage_packer.ndk.json @@ -39,6 +39,46 @@ "first_introduced": "12", "name": "OH_PackingOptions_Release" }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_Create" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_SetFrameCount" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_GetFrameCount" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_SetDelayTimeList" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_GetDelayTimeList" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_SetDisposalTypes" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_GetDisposalTypes" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_SetLoopCount" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_GetLoopCount" + }, + { + "first_introduced": "13", + "name": "OH_PackingOptionsForSequence_Release" + }, { "first_introduced": "12", "name": "OH_ImagePackerNative_Create" @@ -51,6 +91,14 @@ "first_introduced": "12", "name": "OH_ImagePackerNative_PackToDataFromPixelmap" }, + { + "first_introduced": "13", + "name": "OH_ImagePackerNative_PackToDataFromPicture" + }, + { + "first_introduced": "13", + "name": "OH_ImagePackerNative_PackToDataFromPixelmapSequence" + }, { "first_introduced": "12", "name": "OH_ImagePackerNative_PackToFileFromImageSource" @@ -59,6 +107,14 @@ "first_introduced": "12", "name": "OH_ImagePackerNative_PackToFileFromPixelmap" }, + { + "first_introduced": "13", + "name": "OH_ImagePackerNative_PackToFileFromPicture" + }, + { + "first_introduced": "13", + "name": "OH_ImagePackerNative_PackToFileFromPixelmapSequence" + }, { "first_introduced": "12", "name": "OH_ImagePackerNative_Release" diff --git a/multimedia/image_framework/libimage_source.ndk.json b/multimedia/image_framework/libimage_source.ndk.json index 562ec53ca3b2468e6f7c9c70d68b944ff53c59a0..37312763efbe5c189c070d93a8d3e90281c6eea7 100644 --- a/multimedia/image_framework/libimage_source.ndk.json +++ b/multimedia/image_framework/libimage_source.ndk.json @@ -99,6 +99,10 @@ "first_introduced": "12", "name": "OH_ImageSourceNative_CreatePixelmapList" }, + { + "first_introduced": "13", + "name": "OH_ImageSourceNative_CreatePicture" + }, { "first_introduced": "12", "name": "OH_ImageSourceNative_GetDelayTimeList" @@ -122,5 +126,21 @@ { "first_introduced": "12", "name": "OH_ImageSourceNative_Release" + }, + { + "first_introduced": "13", + "name": "OH_DecodingOptionsForPicture_Create" + }, + { + "first_introduced": "13", + "name": "OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures" + }, + { + "first_introduced": "13", + "name": "OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures" + }, + { + "first_introduced": "13", + "name": "OH_DecodingOptionsForPicture_Release" } ] \ No newline at end of file diff --git a/multimedia/image_framework/libohimage.ndk.json b/multimedia/image_framework/libohimage.ndk.json index a9eefa5fbf460cbf00e0f714a491f9e2b330cc41..da613fb2ac170e64b6ec444011d7a8133d3da97b 100644 --- a/multimedia/image_framework/libohimage.ndk.json +++ b/multimedia/image_framework/libohimage.ndk.json @@ -23,6 +23,10 @@ "first_introduced": "12", "name": "OH_ImageNative_GetPixelStride" }, + { + "first_introduced": "12", + "name": "OH_ImageNative_GetTimestamp" + }, { "first_introduced": "12", "name": "OH_ImageNative_Release" diff --git a/multimedia/image_framework/libpicture.ndk.json b/multimedia/image_framework/libpicture.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..e236c17a4982c99e536d5094721a514914aa6612 --- /dev/null +++ b/multimedia/image_framework/libpicture.ndk.json @@ -0,0 +1,114 @@ +[ + { + "first_introduced": "13", + "name": "OH_PictureNative_CreatePicture" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_GetMainPixelmap" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_GetHdrComposedPixelmap" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_GetGainmapPixelmap" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_SetAuxiliaryPicture" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_GetAuxiliaryPicture" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_GetMetadata" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_SetMetadata" + }, + { + "first_introduced": "13", + "name": "OH_PictureNative_Release" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_Create" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_WritePixels" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_ReadPixels" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_GetType" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_GetInfo" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_SetInfo" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_GetMetadata" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_SetMetadata" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureNative_Release" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_Create" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_GetType" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_SetType" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_GetSize" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_SetSize" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_GetRowStride" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_SetRowStride" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_GetPixelFormat" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_SetPixelFormat" + }, + { + "first_introduced": "13", + "name": "OH_AuxiliaryPictureInfo_Release" + } + ] \ No newline at end of file diff --git a/multimedia/image_framework/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json index f06f6b1866994fabc7112dc3877870b99a9d044d..4c103c8aea0f003b44d024d9e8c13cbe9506311b 100644 --- a/multimedia/image_framework/libpixelmap.ndk.json +++ b/multimedia/image_framework/libpixelmap.ndk.json @@ -99,6 +99,10 @@ "first_introduced": "12", "name": "OH_PixelmapNative_WritePixels" }, + { + "first_introduced": "13", + "name": "OH_PixelmapNative_GetArgbPixels" + }, { "first_introduced": "12", "name": "OH_PixelmapNative_ToSdr" @@ -149,10 +153,34 @@ }, { "first_introduced": "12", - "name": "OH_PixelmapNative_ConvertPixelmapToNapi" + "name": "OH_PixelmapNative_GetMetadata" + }, + { + "first_introduced": "12", + "name": "OH_PixelmapNative_SetMetadata" }, { "first_introduced": "12", - "name": "OH_PixelmapNative_ConvertPixelmapFromNapi" + "name": "OH_PixelmapNative_GetNativeBuffer" + }, + { + "first_introduced": "13", + "name": "OH_PixelmapNative_GetColorSpaceNative" + }, + { + "first_introduced": "13", + "name": "OH_PixelmapNative_SetColorSpaceNative" + }, + { + "first_introduced": "12", + "name": "OH_PixelmapNative_ConvertPixelmapNativeToNapi" + }, + { + "first_introduced": "12", + "name": "OH_PixelmapNative_ConvertPixelmapNativeFromNapi" + }, + { + "first_introduced": "13", + "name": "OH_PixelmapNative_SetMemoryName" } ] \ No newline at end of file diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index cffaba60e2f486611b86ed432608f60f6879c548..edecfa2a89f3f673d09682def19034e2082bacb9 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -78,6 +78,11 @@ typedef enum OH_AVErrCode { * @error unsupport interface. */ AV_ERR_UNSUPPORT = 9, + /** + * @error input data error. + * @since 12 + */ + AV_ERR_INPUT_DATA_ERROR = 10, /** * @error extend err start. */ @@ -92,6 +97,16 @@ typedef enum OH_AVErrCode { * @since 12 */ AV_ERR_DRM_DECRYPT_FAILED = 201, + /** + * @error video error base. + * @since 12 + */ + AV_ERR_VIDEO_BASE = 300, + /** + * @error video unsupported color space conversion. + * @since 12 + */ + AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION = 301, } OH_AVErrCode; #ifdef __cplusplus diff --git a/multimedia/media_library/media_access_helper_capi.h b/multimedia/media_library/media_access_helper_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..7579ee14876b2001d49b312d805322a82b6cf73d --- /dev/null +++ b/multimedia/media_library/media_access_helper_capi.h @@ -0,0 +1,68 @@ +/* + * 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 MediaAssetManager + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 12 + */ + +/** + * @file media_access_helper_capi.h + * + * @brief Defines APIs related to media assess helper. + * + * Provides the ability to create photo albums, as well as access and modify media data information in the albums. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 12 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ACCESS_HELPER_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ACCESS_HELPER_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Apply the change request of asset or album. + * + * @permission ohos.permission.WRITE_IMAGEVIDEO + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance to be applied. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} Permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAccessHelper_ApplyChanges(OH_MediaAssetChangeRequest* changeRequest); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ACCESS_HELPER_H +/** @} */ \ No newline at end of file diff --git a/multimedia/media_library/media_asset_base_capi.h b/multimedia/media_library/media_asset_base_capi.h index 1648933242f2ffcfef6821638001700d294463b7..53380d6deedf25720000929db83002e18daa86cf 100644 --- a/multimedia/media_library/media_asset_base_capi.h +++ b/multimedia/media_library/media_asset_base_capi.h @@ -26,7 +26,7 @@ */ /** - * @file media_asset_manager.h + * @file media_asset_base_capi.h * * @brief Defines the structure and enumeration for Media Asset Manager. * @@ -38,7 +38,7 @@ * MediaLibrary_RequestOptions structure: This structure provides options for requesting media library resources. \n * * @kit MediaLibraryKit - * @Syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @library libmedia_asset_manager.so * @since 12 */ @@ -48,6 +48,8 @@ #include +#include "multimedia/image_framework/image/image_source_native.h" + #ifdef __cplusplus extern "C" { #endif @@ -71,6 +73,33 @@ static const int32_t UUID_STR_MAX_LENGTH = 37; */ typedef struct OH_MediaAssetManager OH_MediaAssetManager; +/** + * @brief Define Media Asset Change Request + * + * This structure provides the ability to handle a media asset change request. + * + * @since 12 + */ +typedef struct OH_MediaAssetChangeRequest OH_MediaAssetChangeRequest; + +/** + * @brief Define Moving Photo + * + * This structure provides the ability to obtain information about moving photo. + * + * @since 13 + */ +typedef struct OH_MovingPhoto OH_MovingPhoto; + +/** + * @brief Define Media Asset + * + * This structure provides the ability to encapsulate file asset attributes. + * + * @since 12 + */ +typedef struct OH_MediaAsset OH_MediaAsset; + /** * @brief Define MediaLibrary_RequestId * @@ -85,6 +114,64 @@ typedef struct MediaLibrary_RequestId { char requestId[UUID_STR_MAX_LENGTH]; } MediaLibrary_RequestId; +/** + * @brief Enum for media library error code. + * + * @since 12 + */ +typedef enum MediaLibrary_ErrorCode { + /** + * @error Media library result is ok. + */ + MEDIA_LIBRARY_OK = 0, + + /** + * @error Permission is denied. + */ + MEDIA_LIBRARY_PERMISSION_DENIED = 201, + + /** + * @error Mandatory parameters are left unspecified + * or incorrect parameter types or parameter verification failed. + */ + MEDIA_LIBRARY_PARAMETER_ERROR = 401, + + /** + * @error File does not exist. + */ + MEDIA_LIBRARY_NO_SUCH_FILE = 23800101, + + /** + * @error Invalid display name. + */ + MEDIA_LIBRARY_INVALID_DISPLAY_NAME = 23800102, + + /** + * @error Invalid asset uri. + */ + MEDIA_LIBRARY_INVALID_ASSET_URI = 23800103, + + /** + * @error Member is not a valid PhotoKey. + */ + MEDIA_LIBRARY_INVALID_PHOTO_KEY = 23800104, + + /** + * @error Operation is not supported. + */ + MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED = 23800201, + + /** + * @error Internal system error. + * It is recommended to retry and check the logs. + * Possible causes: + * 1. Database corrupted. + * 2. The file system is abnormal. + * 3. The IPC request timed out. + */ + MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR = 23800301, +} MediaLibrary_ErrorCode; + /** * @brief Delivery Mode * @@ -102,6 +189,90 @@ typedef enum MediaLibrary_DeliveryMode { MEDIA_LIBRARY_BALANCED_MODE = 2 } MediaLibrary_DeliveryMode; +/** + * @brief Request Options + * + * This structure provides options for requesting media library resources. + * + * @since 12 + */ +typedef struct MediaLibrary_RequestOptions { + /*delivery mode*/ + MediaLibrary_DeliveryMode deliveryMode; +} MediaLibrary_RequestOptions; + +/** + * @brief Enum for media type. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaType { + /*image asset*/ + MEDIA_LIBRARY_IMAGE = 1, + /*video asset*/ + MEDIA_LIBRARY_VIDEO = 2 +} MediaLibrary_MediaType; + +/** + * @brief Enum for media asset subtype. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaSubType { + /*default Photo Type*/ + MEDIA_LIBRARY_DEFAULT = 0, + /*moving Photo Type*/ + MEDIA_LIBRARY_MOVING_PHOTO = 3, + /*burst Photo Type*/ + MEDIA_LIBRARY_BURST = 4 +} MediaLibrary_MediaSubType; + +/** + * @brief Enum for resource types. + * + * @since 12 + */ +typedef enum MediaLibrary_ResourceType { + /*image resource*/ + MEDIA_LIBRARY_IMAGE_RESOURCE = 1, + /*video resource*/ + MEDIA_LIBRARY_VIDEO_RESOURCE = 2 +} MediaLibrary_ResourceType; + +/** + * @brief Enum for image file Type. + * + * @since 12 + */ +typedef enum MediaLibrary_ImageFileType { + /*JPEG type*/ + MEDIA_LIBRARY_IMAGE_JPEG = 1 +} MediaLibrary_ImageFileType; + +/** + * @brief Enum for media quality. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaQuality { + /*fast quality*/ + MEDIA_LIBRARY_QUALITY_FAST = 1, + /*full quality*/ + MEDIA_LIBRARY_QUALITY_FULL = 2 +} MediaLibrary_MediaQuality; + +/** + * @brief Enum for media content type. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaContentType { + /*compressed media content type*/ + MEDIA_LIBRARY_COMPRESSED = 1, + /*picture object media content type*/ + MEDIA_LIBRARY_PICTURE_OBJECT = 2 +} MediaLibrary_MediaContentType; + /** * @brief Called when a requested source is prepared. * @@ -114,18 +285,40 @@ typedef enum MediaLibrary_DeliveryMode { typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId); /** - * @brief Request Options + * @brief Called when a requested image source is prepared. * - * This structure provides options for requesting media library resources. + * This function is called when the requested image source is prepared. * + * @param result results {@link MediaLibrary_ErrorCode} of the processing of the requested resources. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request. + * @param mediaQuality the {@link MediaLibrary_MediaQuality} of the requested source. + * @param type the {@link MediaLibrary_MediaContentType} of the requested source. + * @param imageSourceNative it used to obtain {@link OH_ImageSourceNative} information when image source is prepared. * @since 12 */ -typedef struct MediaLibrary_RequestOptions { - /*delivery mode*/ - MediaLibrary_DeliveryMode deliveryMode; -} MediaLibrary_RequestOptions; +typedef void (*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result, + MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type, + OH_ImageSourceNative* imageSourceNative); + +/** + * @brief Called when a requested moving photo is prepared. + * + * This function is called when the requested moving photo is prepared. + * + * @param result results {@link MediaLibrary_ErrorCode} of the processing of the requested resources. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request. + * @param mediaQuality the {@link MediaLibrary_MediaQuality} of the requested source. + * @param type the {@link MediaLibrary_MediaContentType} of the requested source. + * @param movingPhoto it used to obtain {@link OH_MovingPhoto} information when the data is prepared. + * @since 13 + */ +typedef void (*OH_MediaLibrary_OnMovingPhotoDataPrepared)(MediaLibrary_ErrorCode result, + MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type, + OH_MovingPhoto* movingPhoto); #ifdef __cplusplus } #endif -#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_BASE_H \ No newline at end of file + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_BASE_H +/** @} */ diff --git a/multimedia/media_library/media_asset_capi.h b/multimedia/media_library/media_asset_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..04fb1b2d6d2fc88c790d7c1809ad401ab7a21850 --- /dev/null +++ b/multimedia/media_library/media_asset_capi.h @@ -0,0 +1,309 @@ +/* + * 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 MediaAssetManager + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 12 + */ + +/** + * @file media_asset_capi.h + * + * @brief Defines APIs related to media asset. + * + * Provides the ability to obtain image or video information. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 12 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the uri of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param uri the uri of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetUri(OH_MediaAsset* mediaAsset, const char** uri); + +/** + * @brief Get the media file type of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param mediaType the media file type of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetMediaType(OH_MediaAsset* mediaAsset, MediaLibrary_MediaType* mediaType); + +/** + * @brief Get the subtype of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param mediaSubType the subtype of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetMediaSubType(OH_MediaAsset* mediaAsset, + MediaLibrary_MediaSubType* mediaSubType); + +/** + * @brief Get the display name of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param displayName the display name of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDisplayName(OH_MediaAsset* mediaAsset, const char** displayName); + +/** + * @brief Get the file size of the media asset + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param size the file size(in bytes) of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetSize(OH_MediaAsset* mediaAsset, uint32_t* size); + +/** + * @brief Get the date of asset creation. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateAdded the creation date of the asset. + * The value is the number of seconds elapsed since the Epoch time (00:00:00 UTC on January 1, 1970). + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateAdded(OH_MediaAsset* mediaAsset, uint32_t* dateAdded); + +/** + * @brief Get the modified date of the asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateModified the modified date of the asset. + * The value is the number of seconds elapsed since the Epoch time. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateModified(OH_MediaAsset* mediaAsset, uint32_t* dateModified); + +/** + * @brief Get the date taken of the asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateTaken the date taken of the asset. + * The value is the number of seconds elapsed since the Epoch time. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateTaken(OH_MediaAsset* mediaAsset, uint32_t* dateTaken); + +/** + * @brief Get the creation time of the asset in milliseconds. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateAddedMs the creation time of the asset in milliseconds. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateAddedMs(OH_MediaAsset* mediaAsset, uint32_t* dateAddedMs); + +/** + * @brief Get the modified time of the asset in milliseconds. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateModifiedMs the modified time of the asset in milliseconds. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateModifiedMs(OH_MediaAsset* mediaAsset, uint32_t* dateModifiedMs); + +/** + * @brief Get the duration of the media asset in milliseconds. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param duration the duration of the media asset in milliseconds. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDuration(OH_MediaAsset* mediaAsset, uint32_t* duration); + +/** + * @brief Get the image width(in pixels) of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param width the image width(in pixels) of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetWidth(OH_MediaAsset* mediaAsset, uint32_t* width); + +/** + * @brief Get the image height(in pixels) of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param height the image height(in pixels) of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetHeight(OH_MediaAsset* mediaAsset, uint32_t* height); + +/** + * @brief Get the orientation of the image. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param orientation the orientation of the image. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetOrientation(OH_MediaAsset* mediaAsset, uint32_t* orientation); + +/** + * @brief Get the favorite state of the asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param favorite the favorite state of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_IsFavorite(OH_MediaAsset* mediaAsset, uint32_t* favorite); + +/** + * @brief Get the title of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param title the title of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetTitle(OH_MediaAsset* mediaAsset, const char** title); + +/** + * @brief Release the media asset + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_Release(OH_MediaAsset* mediaAsset); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_H +/** @} */ \ No newline at end of file diff --git a/multimedia/media_library/media_asset_change_request_capi.h b/multimedia/media_library/media_asset_change_request_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..aedbff48a8db36c1cb558ccc2dc2df6172d13e57 --- /dev/null +++ b/multimedia/media_library/media_asset_change_request_capi.h @@ -0,0 +1,168 @@ +/* + * 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 MediaAssetManager + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 12 + */ + +/** + * @file media_asset_change_request_capi.h + * + * @brief Defines APIs related to media asset change request. + * + * Provides the ability to change assets. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 12 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a {@link OH_MediaAssetChangeRequest} instance. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +OH_MediaAssetChangeRequest* OH_MediaAssetChangeRequest_Create(OH_MediaAsset* mediaAsset); + +/** + * @brief Add resource of the asset using file uri. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the resource to add. + * @param fileUri the file uri. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_NO_SUCH_FILE} if file does not exist. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithUri(OH_MediaAssetChangeRequest* changeRequest, + MediaLibrary_ResourceType resourceType, char* fileUri); + +/** + * @brief Add resource of the asset using ArrayBuffer. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the resource to add. + * @param buffer the data buffer to add. + * @param length the length of the data buffer. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithBuffer(OH_MediaAssetChangeRequest* changeRequest, + MediaLibrary_ResourceType resourceType, uint8_t* buffer, uint32_t length); + +/** + * @brief Get write cache handler. + * + * @permission ohos.permission.WRITE_IMAGEVIDEO + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param fd the write cache handler. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_GetWriteCacheHandler(OH_MediaAssetChangeRequest* changeRequest, + int32_t* fd); + +/** + * @brief Save the photo asset captured by camera. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param imageFileType The {@link MediaLibrary_ImageFileType} of photo to be saved. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_SaveCameraPhoto(OH_MediaAssetChangeRequest* changeRequest, + MediaLibrary_ImageFileType imageFileType); + +/** + * @brief Discard the photo asset captured by camera. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_DiscardCameraPhoto(OH_MediaAssetChangeRequest* changeRequest); + +/** + * @brief Release the {@link OH_MediaAssetChangeRequest} instance. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_Release(OH_MediaAssetChangeRequest* changeRequest); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H +/** @} */ diff --git a/multimedia/media_library/media_asset_manager/BUILD.gn b/multimedia/media_library/media_asset_manager/BUILD.gn index 57c7fb44c62b782a35a442c125e82836cd8a7fd9..9385e2e920edc04433238d19f530106638bfdb3f 100644 --- a/multimedia/media_library/media_asset_manager/BUILD.gn +++ b/multimedia/media_library/media_asset_manager/BUILD.gn @@ -18,8 +18,12 @@ import("//foundation/multimedia/media_library/media_library.gni") ohos_ndk_headers("media_asset_manager_header") { dest_dir = "$ndk_headers_out_dir/multimedia/media_library" sources = [ + "../media_access_helper_capi.h", "../media_asset_base_capi.h", + "../media_asset_capi.h", + "../media_asset_change_request_capi.h", "../media_asset_manager_capi.h", + "../moving_photo_capi.h", ] } @@ -31,5 +35,9 @@ ohos_ndk_library("libmedia_asset_manager") { system_capability_headers = [ "multimedia/media_library/media_asset_manager_capi.h", "multimedia/media_library/media_asset_base_capi.h", + "multimedia/media_library/media_access_helper_capi.h", + "multimedia/media_library/media_asset_capi.h", + "multimedia/media_library/moving_photo_capi.h", + "multimedia/media_library/media_asset_change_request_capi.h", ] } diff --git a/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json b/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json index 7e910b968fd298226c2da9cf3f49aa028b11dec4..077fecaab83fa6ed465a764cc153a5d2288b15ce 100644 --- a/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json +++ b/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json @@ -14,5 +14,137 @@ { "first_introduced": "12", "name": "OH_MediaAssetManager_CancelRequest" + }, + { + "first_introduced": "13", + "name": "OH_MediaAssetManager_RequestMovingPhoto" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetManager_RequestImage" + }, + { + "first_introduced": "13", + "name": "OH_MediaAssetManager_Release" + }, + { + "first_introduced": "12", + "name": "OH_MediaAccessHelper_ApplyChanges" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetUri" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetMediaType" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetMediaSubType" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDisplayName" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetSize" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetDateAdded" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetDateModified" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetDateTaken" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetDateAddedMs" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDateModifiedMs" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetDuration" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetWidth" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetHeight" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetOrientation" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_IsFavorite" + }, + { + "first_introduced": "13", + "name": "OH_MediaAsset_GetTitle" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_Release" + }, + { + "first_introduced": "13", + "name": "OH_MovingPhoto_GetUri" + }, + { + "first_introduced": "13", + "name": "OH_MovingPhoto_RequestContentWithUris" + }, + { + "first_introduced": "13", + "name": "OH_MovingPhoto_RequestContentWithUri" + }, + { + "first_introduced": "13", + "name": "OH_MovingPhoto_RequestContentWithBuffer" + }, + { + "first_introduced": "13", + "name": "OH_MovingPhoto_Release" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_Create" + }, + { + "first_introduced": "13", + "name": "OH_MediaAssetChangeRequest_AddResourceWithUri" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_AddResourceWithBuffer" + }, + { + "first_introduced": "13", + "name": "OH_MediaAssetChangeRequest_GetWriteCacheHandler" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_SaveCameraPhoto" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_DiscardCameraPhoto" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_Release" } ] \ No newline at end of file diff --git a/multimedia/media_library/media_asset_manager_capi.h b/multimedia/media_library/media_asset_manager_capi.h index 4b465e05e85bf54a21645fdd692f831704f395eb..2d480e4289f3c7f31e92be70723dbb70fc031222 100644 --- a/multimedia/media_library/media_asset_manager_capi.h +++ b/multimedia/media_library/media_asset_manager_capi.h @@ -23,7 +23,7 @@ */ /** - * @file media_asset_manager.h + * @file media_asset_manager_capi.h * * @brief Defines the media asset manager APIs. * @@ -31,7 +31,7 @@ * to reqeust media source. * * @kit MediaLibraryKit - * @Syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @library libmedia_asset_manager.so * @since 12 */ @@ -39,6 +39,8 @@ #ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H #define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H +#include + #include "media_asset_base_capi.h" #ifdef __cplusplus @@ -94,7 +96,70 @@ MediaLibrary_RequestId OH_MediaAssetManager_RequestVideoForPath(OH_MediaAssetMan */ bool OH_MediaAssetManager_CancelRequest(OH_MediaAssetManager* manager, const MediaLibrary_RequestId requestId); +/** + * @brief Request moving photo object. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param manager the pointer to {@link OH_MediaAssetManager} instance. + * @param mediaAsset the {@link OH_MediaAsset} instance of media file object to be requested. + * @param requestOptions the {@link MediaLibrary_RequestOptions} for image request strategy mode. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request, which is an output parameter. + * @param callback the {@link OH_MediaLibrary_OnMovingPhotoDataPrepared} that will be called + * when the requested source is prepared. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAssetManager_RequestMovingPhoto(OH_MediaAssetManager* manager, + OH_MediaAsset* mediaAsset, MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId, + OH_MediaLibrary_OnMovingPhotoDataPrepared callback); + +/** + * @brief Request image resources based on different strategy modes. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param manager the pointer to {@link OH_MediaAssetManager} instance. + * @param mediaAsset the {@link OH_MediaAsset} instance of media file object to be requested. + * @param requestOptions the {@link MediaLibrary_RequestOptions} for image request strategy mode. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request, which is an output parameter. + * @param callback the {@link OH_MediaLibrary_OnImageDataPrepared} that will be called + * when the requested source is prepared. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetManager_RequestImage(OH_MediaAssetManager* manager, OH_MediaAsset* mediaAsset, + MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId, + OH_MediaLibrary_OnImageDataPrepared callback); + +/** + * @brief Release the {@link OH_MediaAssetManager} instance. + * + * @param manager the {@link OH_MediaAssetManager} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MediaAssetManager_Release(OH_MediaAssetManager* manager); + #ifdef __cplusplus } #endif -#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H \ No newline at end of file + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H +/** @} */ diff --git a/multimedia/media_library/moving_photo_capi.h b/multimedia/media_library/moving_photo_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..ce079ecd3944da1a7d00c24203735a25faffa3fc --- /dev/null +++ b/multimedia/media_library/moving_photo_capi.h @@ -0,0 +1,138 @@ +/* + * 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 MediaAssetManager + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 13 + */ + +/** + * @file moving_photo_capi.h + * + * @brief Defines APIs related to moving photo. + * + * Provides the ability to obtain moving photo information. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 13 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MOVING_PHOTO_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MOVING_PHOTO_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get uri of the moving photo. + * + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param uri the uri of the moving photo. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_GetUri(OH_MovingPhoto* movingPhoto, const char** uri); + +/** + * @brief Request the image and video content of the moving photo and write to destination uri. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param imageUri the destination file uri to save the image data. + * @param videoUri the destination file uri to save the video data. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithUris(OH_MovingPhoto* movingPhoto, char* imageUri, + char* videoUri); + +/** + * @brief Request the image or video content of the moving photo and write to destination uri. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the moving photo content to request. + * @param uri the destination file uri to save the data. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithUri(OH_MovingPhoto* movingPhoto, + MediaLibrary_ResourceType resourceType, char* uri); + +/** + * @brief Request data of the moving photo. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the moving photo content to request. + * @param buffer the buffer of the content. + * @param size the size of the buffer. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithBuffer(OH_MovingPhoto* movingPhoto, + MediaLibrary_ResourceType resourceType, const uint8_t** buffer, uint32_t* size); + +/** + * @brief Release the {@link OH_MovingPhoto} instance. + * + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 13 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_Release(OH_MovingPhoto* movingPhoto); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MOVING_PHOTO_H +/** @} */ \ No newline at end of file diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index d2d7aa7e8f2229f3c418f3d64ee10f6ca4cb8c02..ce355909a31309cb78b5c0e77cb0e151691f7ede 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -39,6 +39,7 @@ #ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H #define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H +#include #include #include #include "native_averrors.h" @@ -461,6 +462,8 @@ OH_AVErrCode OH_AVPlayer_SetLooping(OH_AVPlayer *player, bool loop); * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, * or player SetPlayerCallback failed. * @since 11 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayer_SetPlayerOnInfoCallback} {@link OH_AVPlayer_SetPlayerOnErrorCallback} * @version 1.0 */ OH_AVErrCode OH_AVPlayer_SetPlayerCallback(OH_AVPlayer *player, AVPlayerCallback callback); @@ -562,6 +565,32 @@ OH_AVErrCode OH_AVPlayer_GetMediaKeySystemInfo(OH_AVPlayer *player, DRM_MediaKey OH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySession *mediaKeySession, bool secureVideoPath); +/** + * @brief Method to set player information notify callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance. + * @param callback Pointer to callback function, nullptr indicates unregister callback. + * @param userData Pointer to user specific data. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnInfoCallback failed. + * @since 12 + */ +OH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInfoCallback callback, void *userData); + +/** + * @brief Method to set player error callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance. + * @param callback Pointer to callback function, nullptr indicates unregister callback. + * @param userData Pointer to user specific data. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnErrorCallback failed. + * @since 12 + */ +OH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnErrorCallback callback, void *userData); + #ifdef __cplusplus } #endif diff --git a/multimedia/player_framework/avplayer/libavplayer.ndk.json b/multimedia/player_framework/avplayer/libavplayer.ndk.json index dbfa420edf150b49c60963d92591da2fcb4bb7b2..d7151471ef8156446a5d99dfe765a02abccdaae0 100644 --- a/multimedia/player_framework/avplayer/libavplayer.ndk.json +++ b/multimedia/player_framework/avplayer/libavplayer.ndk.json @@ -27,6 +27,90 @@ { "name": "OH_AVPlayer_SelectTrack" }, { "name": "OH_AVPlayer_DeselectTrack" }, { "name": "OH_AVPlayer_GetCurrentTrack" }, + { + "first_introduced": "12", + "name": "OH_PLAYER_STATE" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_STATE_CHANGE_REASON" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_VOLUME" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_BITRATE_ARRAY" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_AUDIO_INTERRUPT_TYPE" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_AUDIO_INTERRUPT_FORCE" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_AUDIO_INTERRUPT_HINT" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_AUDIO_DEVICE_CHANGE_REASON" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_BUFFERING_TYPE" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_BUFFERING_VALUE" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_SEEK_POSITION" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_PLAYBACK_SPEED" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_BITRATE" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_CURRENT_POSITION" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_DURATION" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_VIDEO_WIDTH" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_VIDEO_HEIGHT" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_MESSAGE_TYPE" + }, + { + "first_introduced": "12", + "name": "OH_PLAYER_IS_LIVE_STREAM" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetOnInfoCallback" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetOnErrorCallback" + }, { "first_introduced": "12", "name": "OH_AVPlayer_SetMediaKeySystemInfoCallback" diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index 903a52f72ae0a6c957451398b9cb494a871781d2..8a3b311fcd047fbd7ea6b766b12105e1bfee383e 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -40,6 +40,8 @@ #include +#include "native_avformat.h" + #ifdef __cplusplus extern "C" { #endif @@ -113,14 +115,32 @@ typedef enum AVPlaybackSpeed { * @brief Video playback at 0.5x normal speed. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @since 12 - */ + */ AV_SPEED_FORWARD_0_50_X, /** * @brief Video playback at 1.5x normal speed. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @since 12 - */ + */ AV_SPEED_FORWARD_1_50_X, + /** + * @brief Video playback at 3.0x normal speed. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 13 + */ + AV_SPEED_FORWARD_3_00_X, + /** + * @brief Video playback at 0.25x normal speed. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 13 + */ + AV_SPEED_FORWARD_0_25_X, + /** + * @brief Video playback at 0.125x normal speed. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 13 + */ + AV_SPEED_FORWARD_0_125_X, } AVPlaybackSpeed; /** @@ -172,6 +192,169 @@ typedef enum AVPlayerOnInfoType { AV_INFO_TYPE_AUDIO_OUTPUT_DEVICE_CHANGE = 17, } AVPlayerOnInfoType; +/** + * @brief Player Buffering Type + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +typedef enum AVPlayerBufferingType { + /** Indicates the buffer to start buffering. */ + AVPLAYER_BUFFERING_START = 1, + + /** Indicates the buffer to end buffering and start playback. */ + AVPLAYER_BUFFERING_END, + + /** Indicates the current buffering percentage of the buffer. */ + AVPLAYER_BUFFERING_PERCENT, + + /** Indicates how long the buffer cache data can be played. */ + AVPLAYER_BUFFERING_CACHED_DURATION, +} AVPlayerBufferingType; + +/** + * @brief Key to get state, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_STATE; + +/** + * @brief Key to get state change reason, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_STATE_CHANGE_REASON; + +/** + * @brief Key to get volume, value type is float. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_VOLUME; + +/** + * @brief Key to get bitrate count, value type is uint32_t array. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_BITRATE_ARRAY; + +/** + * @brief Key to get audio interrupt type, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_INTERRUPT_TYPE; + +/** + * @brief Key to get audio interrupt force, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_INTERRUPT_FORCE; + +/** + * @brief Key to get audio interrupt hint, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_INTERRUPT_HINT; + +/** + * @brief Key to get audio device change reason, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_DEVICE_CHANGE_REASON; + +/** + * @brief Key to get buffering type, value type is AVPlayerBufferingType. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_BUFFERING_TYPE; + +/** + * @brief Key to get buffering value, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_BUFFERING_VALUE; + +/** + * @brief Key to get seek position, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_SEEK_POSITION; + +/** + * @brief Key to get playback speed, value type is AVPlaybackSpeed. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_PLAYBACK_SPEED; + +/** + * @brief Key to get bitrate, value type is uint32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_BITRATE; + +/** + * @brief Key to get current position, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_CURRENT_POSITION; + +/** + * @brief Key to get duration, value type is int64_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_DURATION; + +/** + * @brief Key to get video width, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_VIDEO_WIDTH; + +/** + * @brief Key to get video height, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_VIDEO_HEIGHT; + +/** + * @brief Key to get message type, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_MESSAGE_TYPE; + +/** + * @brief Key to get is live stream, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_IS_LIVE_STREAM; + /** * @brief Called when a player message or alarm is received. * @syscap SystemCapability.Multimedia.Media.AVPlayer @@ -179,10 +362,24 @@ typedef enum AVPlayerOnInfoType { * @param type Indicates the information type. For details, see {@link AVPlayerOnInfoType}. * @param extra Indicates other information, for example, the start time position of a playing file. * @since 11 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayerOnInfoCallback} * @version 1.0 */ typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, int32_t extra); +/** + * @brief Called when a player info event is received. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player The pointer to an OH_AVPlayer instance. + * @param type Indicates the information type. For details, see {@link AVPlayerOnInfoType}. + * @param infoBody Indicates the information parameters, only valid in callback function. + * @param userData Pointer to user specific data. + * @since 12 + */ +typedef void (*OH_AVPlayerOnInfoCallback)(OH_AVPlayer *player, AVPlayerOnInfoType type, OH_AVFormat* infoBody, + void *userData); + /** * @brief Called when an error occurred for versions above api9 * @syscap SystemCapability.Multimedia.Media.AVPlayer @@ -190,10 +387,24 @@ typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, * @param errorCode Error code. * @param errorMsg Error message. * @since 11 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayerOnInfoCallback} {@link OH_AVPlayerOnError} * @version 1.0 */ typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg); +/** + * @brief Called when an error occurred. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player The pointer to an OH_AVPlayer instance. + * @param errorCode Error code. + * @param errorMsg Error message, only valid in callback function. + * @param userData Pointer to user specific data. + * @since 12 + */ +typedef void (*OH_AVPlayerOnErrorCallback)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg, + void *userData); + /** * @brief A collection of all callback function pointers in OH_AVPlayer. Register an instance of this * structure to the OH_AVPlayer instance, and process the information reported through the callback to ensure the @@ -202,6 +413,8 @@ typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const * @param onInfo Monitor OH_AVPlayer operation information, refer to {@link OH_AVPlayerOnInfo} * @param onError Monitor OH_AVPlayer operation errors, refer to {@link OH_AVPlayerOnError} * @since 11 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayerOnInfoCallback} {@link OH_AVPlayerOnErrorCallback} * @version 1.0 */ typedef struct AVPlayerCallback { @@ -209,7 +422,6 @@ typedef struct AVPlayerCallback { OH_AVPlayerOnError onError; } AVPlayerCallback; - #ifdef __cplusplus } #endif diff --git a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json index 645b3569dbcc1ec2f96b800754cda139bab903c6..8464ce4fdeaa14dcaee96222c8c496c923f6b927 100644 --- a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json +++ b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json @@ -94,5 +94,13 @@ { "first_introduced": "12", "name": "OH_AVScreenCapture_ResizeCanvas" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_SkipPrivacyMode" + }, + { + "first_introduced": "14", + "name": "OH_AVScreenCapture_SetMaxVideoFrameRate" } ] \ No newline at end of file diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index 1264f7882a8286daa7996eb36bc167450e31542c..48af8569db16f56f2a584909eaac238271269c9d 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -35,6 +35,7 @@ #ifndef NATIVE_AVSCREEN_CAPTURE_H #define NATIVE_AVSCREEN_CAPTURE_H +#include #include #include #include "native_avscreen_capture_errors.h" @@ -391,13 +392,45 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent( * @param height Video frame height of avscreeencapture * @return Function result code. * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. - * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input filter is nullptr. + * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr. * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted. * @since 12 * @version 1.0 */ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas(struct OH_AVScreenCapture *capture, int32_t width, int32_t height); + +/** + * @brief skip some windows' privacy mode of current app during the screen recording + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param Pointer of windowID list + * @param length of windowID list + * @return Function result code. + * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. + * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input windowIDs are not belong current + * app. + * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted. + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode(struct OH_AVScreenCapture *capture, + int32_t *windowIDs, int32_t windowCount); + +/** + * @brief set up the max number of video frame per second + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param max frame rate of video + * @return Function result code. + * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. + * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or frameRate is not support. + * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted. + * @since 14 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMaxVideoFrameRate(struct OH_AVScreenCapture *capture, + int32_t frameRate); #ifdef __cplusplus } #endif diff --git a/multimedia/player_framework/native_avscreen_capture_base.h b/multimedia/player_framework/native_avscreen_capture_base.h index 34eb708d4b6a7807fa34bc18656325e2980ce34e..deed04f4c93cd0f0a2719db11cfc641399f65497 100644 --- a/multimedia/player_framework/native_avscreen_capture_base.h +++ b/multimedia/player_framework/native_avscreen_capture_base.h @@ -35,6 +35,7 @@ #ifndef NATIVE_AVSCREEN_CAPTURE_BASE_H #define NATIVE_AVSCREEN_CAPTURE_BASE_H +#include #include #include "native_avbuffer.h" @@ -446,6 +447,8 @@ typedef enum OH_AVScreenCaptureStateCode { OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE = 8, /* Private window disappeared on current captured screen*/ OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE = 9, + /* ScreenCapture stopped by user switches */ + OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER_SWITCHES = 10, } OH_AVScreenCaptureStateCode; /** diff --git a/multimedia/video_processing_engine/image_processing.h b/multimedia/video_processing_engine/image_processing.h new file mode 100644 index 0000000000000000000000000000000000000000..8465d8618c7f201429b6fdcb6da340de3e33d062 --- /dev/null +++ b/multimedia/video_processing_engine/image_processing.h @@ -0,0 +1,314 @@ +/* + * 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 ImageProcessing + * @{ + * + * @brief Provide APIs for image quality processing. + * + * @since 13 + */ + +/** + * @file image_processing.h + * + * @brief Declare image processing functions. + * + * Provides SDR content processing for images, including color space conversion, metadata generation + * and image scaling. + * + * @library libimage_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit ImageKit + * @since 13 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_H +#define VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_H + +#include +#include +#include "image_processing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initialize global environment for image processing. + * + * This function is optional. \n + * Typically, this function is called once when the host process is started to initialize the global environment for + * image processing, which can reduce the time of {@link OH_ImageProcessing_Create}. \n + * To deinitialize global environment, call {@link OH_ImageProcessing_DeinitializeEnvironment}. + * + * @return {@link IMAGE_PROCESSING_SUCCESS} if initialization is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED} if initialization is failed. \n + * You can check if the device GPU is working properly. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_InitializeEnvironment(void); + +/** + * @brief Deinitialize global environment for image processing. + * + * This function is required if {@link OH_ImageProcessing_InitializeEnvironment} is called. Typically, this + * function is called when the host process is about to exit to deinitialize the global environment, which is + * initialized by calling {@link OH_ImageProcessing_InitializeEnvironment}. \n + * If there is some image processing instance existing, this function should not be called. \n + * If the {@link OH_ImageProcessing_InitializeEnvironment} is not called, this function should not be called. + * + * @return {@link IMAGE_PROCESSING_SUCCESS} if deinitialization is successful. \n + * {@link IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if some image processing instance is not destroyed or + * {@link OH_ImageProcessing_InitializeEnvironment} is not called. \n + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_DeinitializeEnvironment(void); + +/** + * @brief Query whether the image color space conversion is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @param destinationImageInfo Output image color space information pointer. + * @return true if the color space conversion is supported. \n + * false if the the color space conversion is unsupported. + * @since 13 + */ +bool OH_ImageProcessing_IsColorSpaceConversionSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo, + const ImageProcessing_ColorSpaceInfo* destinationImageInfo); + +/** + * @brief Query whether the image composition is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @param sourceGainmapInfo Input gainmap color space information pointer. + * @param destinationImageInfo Output image color space information pointer. + * @return true if the image composition is supported. \n + * false if the image composition is unsupported. + * @since 13 + */ +bool OH_ImageProcessing_IsCompositionSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo, + const ImageProcessing_ColorSpaceInfo* sourceGainmapInfo, + const ImageProcessing_ColorSpaceInfo* destinationImageInfo); + +/** + * @brief Query whether the image decomposition is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @param destinationImageInfo Output image color space information pointer. + * @param destinationGainmapInfo Output gainmap information pointer. + * @return true if the image decomposition is supported. \n + * false if the image decomposition is unsupported. + * @since 13 + */ +bool OH_ImageProcessing_IsDecompositionSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo, + const ImageProcessing_ColorSpaceInfo* destinationImageInfo, + const ImageProcessing_ColorSpaceInfo* destinationGainmapInfo); + +/** + * @brief Query whether the image metadata generation is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @return true if the image metadata generation is supported.. \n + * false if the image metadata generation is unsupported. + * @since 13 + */ +bool OH_ImageProcessing_IsMetadataGenerationSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo); + +/** + * @brief Create an image processing instance. + * + * @param imageProcessor Output parameter. The *imageProcessor points to a new image processing object. + * The *imageProcessor must be null before passed in. + * @param type Use IMAGE_PROCESSING_TYPE_XXX to specify the processing type. The processing type of the instance can not + * be changed. + * @return {@link IMAGE_PROCESSING_SUCCESS} if creating an image processing successfully. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the type is not supported. For example, if metadata + * generation is not supported by vendor, it returns unsupported processing. \n + * {@link IMAGE_PROCESSING_ERROR_CREATE_FAILED} if failed to create an image processing. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or *instance is not null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if type is invalid. \n + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Create(OH_ImageProcessing** imageProcessor, int32_t type); + +/** + * @brief Destroy the image processing instance. + * + * @param imageProcessor An image processing instance pointer. It is recommended setting the + * instance pointer to null after the instance is destroyed. + * @return {@link IMAGE_PROCESSING_SUCCESS} if the instance is destroyed successfully. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Destroy(OH_ImageProcessing* imageProcessor); + +/** + * @brief Set parameter for image processing. + * + * Add parameter identified by the specified parameter key. + * + * @param imageProcessor An image processing instance pointer. + * @param parameter The parameter for image processing. + * @return {@link IMAGE_PROCESSING_SUCCESS} if setting parameter is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of the parameter is invalid. For example, the parameter + * contains unsupported parameter key or value. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_SetParameter(OH_ImageProcessing* imageProcessor, + const OH_AVFormat* parameter); + +/** + * @brief Get parameter of image processing. + * + * Get parameter identified by the specified parameter key. + * + * @param imageProcessor An image processing instance pointer. + * @param parameter The parameter used by the image processing instance. + * @return {@link IMAGE_PROCESSING_SUCCESS} if getting parameter is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_GetParameter(OH_ImageProcessing* imageProcessor, + OH_AVFormat* parameter); + +/** + * @brief Conversion between single-layer images. + * + * The function generate the destinationImage from sourceImage. It include the colorspace conversion from + * HDR image to SDR image, SDR image to HDR image, SDR image to SDR image and HDR image to HDR image. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION}. + * @param sourceImage Input image pointer. + * @param destinationImage Output image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_ConvertColorSpace(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage); + +/** + * @brief Composition from dual-layer HDR images to single-layer HDR images. + * + * The function generate the destinationImage from sourceImage and sourceGainmap. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_COMPOSITION}. + * @param sourceImage Input image pointer. + * @param sourceGainmap Input gainmap pointer. + * @param destinationImage Output image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Compose(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* sourceGainmap, OH_PixelmapNative* destinationImage); + +/** + * @brief Decomposition from single-layer HDR images to dual-layer HDR images. + * + * The function generate the destinationImage and destinationGainmap from sourceImage. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_DECOMPOSITION}. + * @param sourceImage Input image pointer. + * @param destinationImage Output image pointer. + * @param destinationGainmap Output gainmap pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Decompose(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage, OH_PixelmapNative* destinationGainmap); + +/** + * @brief Metadata Generation for HDR images. + * + * The function generate metadata for the sourceImage. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_METADATA_GENERATION}. + * @param sourceImage Input image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_GenerateMetadata(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage); + +/** + * @brief Clarity enhancement for images. + * + * The function generate the destinationImage from sourceImage with necessary scaling operation according to the size + * preset in the sourceImage and destinationImage. Different levels of scaling methonds are provided to balance + * performance and image quality. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER}. + * @param sourceImage Input image pointer. + * @param destinationImage Output image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 13 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_EnhanceDetail(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage); +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_H +/** @} */ diff --git a/multimedia/video_processing_engine/image_processing/BUILD.gn b/multimedia/video_processing_engine/image_processing/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ff1239898dce28180a6245c6f34042483a892a21 --- /dev/null +++ b/multimedia/video_processing_engine/image_processing/BUILD.gn @@ -0,0 +1,35 @@ +# 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("image_processing_ndk_headers") { + dest_dir = "$ndk_headers_out_dir/multimedia/video_processing_engine" + sources = [ + "../image_processing.h", + "../image_processing_types.h", + ] +} + +ohos_ndk_library("libimage_processing_ndk") { + ndk_description_file = "./libimage_processing.ndk.json" + output_name = "image_processing" + output_extension = "so" + min_compact_version = "13" + system_capability = "SystemCapability.Multimedia.VideoProcessingEngine" + system_capability_headers = [ + "multimedia/video_processing_engine/image_processing_types.h", + "multimedia/video_processing_engine/image_processing.h", + ] +} diff --git a/multimedia/video_processing_engine/image_processing/libimage_processing.ndk.json b/multimedia/video_processing_engine/image_processing/libimage_processing.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..918e744ee31dd9e7ed26bfb6aa6c125780860029 --- /dev/null +++ b/multimedia/video_processing_engine/image_processing/libimage_processing.ndk.json @@ -0,0 +1,92 @@ +[ + { + "first_introduced": "13", + "name": "OH_ImageProcessing_InitializeEnvironment" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_DeinitializeEnvironment" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_IsColorSpaceConversionSupported" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_IsCompositionSupported" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_IsDecompositionSupported" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_IsMetadataGenerationSupported" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_Create" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_Destroy" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_SetParameter" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_GetParameter" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_ConvertColorSpace" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_Compose" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_Decompose" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_GenerateMetadata" + }, + { + "first_introduced": "13", + "name": "OH_ImageProcessing_EnhanceDetail" + }, + { + "first_introduced": "13", + "name": "IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION", + "type": "variable" + }, + { + "first_introduced": "13", + "name": "IMAGE_PROCESSING_TYPE_COMPOSITION", + "type": "variable" + }, + { + "first_introduced": "13", + "name": "IMAGE_PROCESSING_TYPE_DECOMPOSITION", + "type": "variable" + }, + { + "first_introduced": "13", + "name": "IMAGE_PROCESSING_TYPE_METADATA_GENERATION", + "type": "variable" + }, + { + "first_introduced": "13", + "name": "IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER", + "type": "variable" + }, + { + "first_introduced": "13", + "name": "IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL", + "type": "variable" + } +] diff --git a/multimedia/video_processing_engine/image_processing_types.h b/multimedia/video_processing_engine/image_processing_types.h new file mode 100644 index 0000000000000000000000000000000000000000..d42f565869b5582e6c6773fc4812266799f9033a --- /dev/null +++ b/multimedia/video_processing_engine/image_processing_types.h @@ -0,0 +1,229 @@ +/* + * 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 ImageProcessing + * @{ + * + * @brief Provide image processing including color space conversion and metadata generation. + * + * @since 13 + */ + +/** + * @file image_processing_types.h + * + * @brief Type definitions for image processing. + * + * @library libimage_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit ImageKit + * @since 13 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H +#define VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define the object for image processing. + * + * Define a null pointer of OH_ImageProcessing and call {@link OH_ImageProcessing_Create} to create an image processing + * instance. The pointer should be null before creating instance. + * User can create multiple image processing instances for different processing types. + * + * @since 13 + */ +typedef struct OH_ImageProcessing OH_ImageProcessing; + +/** + * @brief Forward declaration of OH_PixelmapNative. + * + * @since 13 + */ +typedef struct OH_PixelmapNative OH_PixelmapNative; + +/** + * @brief Forward declaration of OH_AVFormat. + * + * @since 13 + */ +typedef struct OH_AVFormat OH_AVFormat; + +/** + * @brief Used to create an image processing instance for color space conversion. + * + * Color space conversion includes the conversion of single-layer HDR images to SDR images, as well as + * the color space conversion of SDR images, and the conversion of SDR images to single-layer HDR images. Some + * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsColorSpaceConversionSupported} to query if + * the conversion is supported between single-layer images. + * + * @see OH_ImageProcessing_Create + * @since 13 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION; + +/** + * @brief Used to create an image processing instance for HDR image composition. + * + * HDR image compose includes the conversion from dual-layer HDR images to single-layer HDR images. Some + * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsCompositionSupported} to + * query if the composition is supported from dual-layer HDR image to single-layer HDR image. + * + * @see OH_ImageProcessing_Create + * @since 13 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_COMPOSITION; + +/** + * @brief Used to create an image processing instance for HDR image decomposition. + * + * HDR image decompose includes the conversion from single-layer HDR images to dual-layer HDR images. Some + * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsDecompositionSupported} to + * query if the decomposition is supported from single-layer image to dual-layer HDR image. + * + * @see OH_ImageProcessing_Create + * @since 13 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_DECOMPOSITION; + +/** + * @brief Used to create an image processing instance for metadata generation. + * + * Generate HDR Vivid metadata for single-layer image. The capability is supported by vendor. If the capability is not + * supported, {@link OH_ImageProcessing_Create} returns {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING}. + * + * @see OH_ImageProcessing_Create + * @since 13 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_METADATA_GENERATION; + +/** + * @brief Used to create an image processing instance for detail enhancement. + * + * Scale or resize images with the specified quality or just enhance details for rendering an image without changing + * its resolution. + * + * @see OH_ImageProcessing_Create + * @since 13 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER; + +/** + * @brief The key is used to specify the quality level for image detail enhancement. + * + * See {@link ImageDetailEnhancer_QualityLevel} for its value. + * Use {@link OH_ImageProcessing_SetParameter} to set the quality level. + * Use {@link OH_ImageProcessing_GetParameter} to get the current quality level. + * + * @see OH_VideoProcessing_SetParameter + * @see OH_VideoProcessing_GetParameter + * @since 13 + */ +extern const char* IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL; + +/** + * @brief The color space information is used for color space conversion capability query. + * + * @see OH_ImageProcessing_IsColorSpaceConversionSupported + * @see OH_ImageProcessing_IsCompositionSupported + * @see OH_ImageProcessing_IsDecompositionSupported + * @since 13 + */ +typedef struct ImageProcessing_ColorSpaceInfo { + /** define metadata type, {@link enum OH_Pixelmap_HdrMetadataKey} */ + int32_t metadataType; + /** define color space, {@link enum ColorSpaceName} */ + int32_t colorSpace; + /** define pixel format, {@link enum PIXEL_FORMAT} */ + int32_t pixelFormat; +} ImageProcessing_ColorSpaceInfo; + +/** + * @brief The quality level is used for detail enhancement. + * + * It is the value of the key parameter {@link IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL}. + * + * @see OH_ImageProcessing_SetParameter + * @see OH_ImageProcessing_GetParameter + * @since 13 + */ +typedef enum ImageDetailEnhancer_QualityLevel { + /** No detail enhancement */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_NONE, + /** A low level of detail enhancement quality but with a fast speed. It's the default level */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_LOW, + /** A medium level of detail enhancement quality. Its speed is between the low setting and high setting */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM, + /** A high level of detail enhancement quality but with a relatively slow speed */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH, +} ImageDetailEnhancer_QualityLevel; + +/** + * @brief Image processing error code. + * + * @since 13 + */ +typedef enum ImageProcessing_ErrorCode { + /** @error Operation is successful. */ + IMAGE_PROCESSING_SUCCESS, + /** @error Input parameter is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output image buffer - The image buffer is null. + * 2 - Invalid parameter - The parameter is null. + * 3 - Invalid type - The type passed in the create function does not exist. + */ + IMAGE_PROCESSING_ERROR_INVALID_PARAMETER = 401, + /** @error Some unknown error occurred, such as GPU calculation failure or memcpy failure. */ + IMAGE_PROCESSING_ERROR_UNKNOWN = 29200001, + /** @error The global environment initialization for image processing failed, such as failure to initialize + * the GPU environment. + */ + IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED, + /** @error Failed to create image processing instance. For example, + * the number of instances exceeds the upper limit. + */ + IMAGE_PROCESSING_ERROR_CREATE_FAILED, + /** @error Failed to process image buffer. For example, the processing times out. */ + IMAGE_PROCESSING_ERROR_PROCESS_FAILED, + /** @error The processing is not supported. You may call OH_ImageProcessing_IsXXXSupported + * to check whether the capability is supported. + */ + IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING, + /** @error The operation is not permitted. This may be caused by incorrect status. */ + IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED, + /** @error Out of memory. */ + IMAGE_PROCESSING_ERROR_NO_MEMORY, + /** @error The image processing instance is invalid. This may be caused by null instance. */ + IMAGE_PROCESSING_ERROR_INVALID_INSTANCE, + /** @error Input value is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output image buffer - The image buffer width(height) + * is too large or colorspace is incorrect. + * 2 - Invalid parameter - The parameter does not contain valid information, + * such as detail enhancer level is incorrect. + */ + IMAGE_PROCESSING_ERROR_INVALID_VALUE +} ImageProcessing_ErrorCode; + +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H +/** @} */ diff --git a/multimedia/video_processing_engine/video_processing.h b/multimedia/video_processing_engine/video_processing.h new file mode 100644 index 0000000000000000000000000000000000000000..7c22782c6d01d5773649fc92243826d753ad495c --- /dev/null +++ b/multimedia/video_processing_engine/video_processing.h @@ -0,0 +1,329 @@ +/* + * 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 VideoProcessing + * @{ + * + * @brief Provide APIs for video quality processing. + * + * @since 12 + */ + +/** + * @file video_processing.h + * + * @brief Declare video processing functions. + * + * Provides SDR content processing for videos, including color space conversion, metadata generation + * and video scaling. + * + * @library libvideo_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit MediaKit + * @since 12 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_H +#define VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_H + +#include +#include +#include "video_processing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initialize global environment for video processing. + * + * This function is optional. \n + * Typically, this function is called once when the host process is started to initialize the global environment for + * video processing, which can reduce the time of {@link OH_VideoProcessing_Create}. \n + * To deinitialize global environment, call {@link OH_VideoProcessing_DeinitializeEnvironment}. + * + * @return {@link VIDEO_PROCESSING_SUCCESS} if initialization is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INITIALIZE_FAILED} if initialization is failed. \n + * You can check if the device GPU is working properly. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_InitializeEnvironment(void); + +/** + * @brief Deinitialize global environment for video processing. + * + * This function is required if {@link OH_VideoProcessing_InitializeEnvironment} is called. Typically, this + * function is called when the host process is about to exit to deinitialize the global environment, which is + * initialized by calling {@link OH_VideoProcessing_InitializeEnvironment}. \n + * If there is some video processing instance existing, this function should not be called. \n + * If the {@link OH_VideoProcessing_InitializeEnvironment} is not called, this function should not be called. + * + * @return {@link VIDEO_PROCESSING_SUCCESS} if deinitialization is successful. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if some video processing instance is not destroyed or + * {@link OH_VideoProcessing_InitializeEnvironment} is not called. \n + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_DeinitializeEnvironment(void); + +/** + * @brief Query if the video color space conversion is supported. + * + * @param sourceVideoInfo Source video color space information. + * @param destinationVideoInfo Destination video color space information. + * @return true if the video color space conversion is supported. \n + * false if the video color space conversion is not supported. + * @since 12 + */ +bool OH_VideoProcessing_IsColorSpaceConversionSupported( + const VideoProcessing_ColorSpaceInfo* sourceVideoInfo, + const VideoProcessing_ColorSpaceInfo* destinationVideoInfo); + +/** + * @brief Query if the video metadata generation is supported. + * + * @param sourceVideoInfo Source video color space information. + * @return true if the video metadata generation is supported. \n + * false if the video metadata generation is not supported. + * @since 12 + */ +bool OH_VideoProcessing_IsMetadataGenerationSupported( + const VideoProcessing_ColorSpaceInfo* sourceVideoInfo); + +/** + * @brief Create a video processing instance. + * + * @param videoProcessor Output parameter. The *videoProcessor points to a new video processing object. + * The *videoProcessor must be null before passed in. + * @param type Use VIDEO_PROCESSING_TYPE_XXX to specify the processing type. The processing type of the instance can not + * be changed. + * @return {@link VIDEO_PROCESSING_SUCCESS} if creating a video processing instance successfully. \n + * {@link VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the type is not supported. For example, if metadata + * generation is not supported by vendor, it returns unsupported processing. \n + * {@link VIDEO_PROCESSING_ERROR_CREATE_FAILED} if failed to create a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or *instance is not null. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if type is invalid. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Create(OH_VideoProcessing** videoProcessor, int type); + +/** + * @brief Destroy the video processing instance. + * + * Stop the instance before destroying it. see {@link OH_VideoProcessing_Stop}. \n + * + * @param videoProcessor The video processing instance pointer to be destroyed. It is recommended setting the + * instance pointer to null after the instance is destroyed. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the instance is destroyed successfully . \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if the instance is still running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Destroy(OH_VideoProcessing* videoProcessor); + +/** + * @brief Register callback object. + * + * Register the callback object before starting video processing. + * + * @param videoProcessor A video processing instance pointer. + * @param callback Callback pointer to be registered. + * @param userData User's custom data pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if callback is registered successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if callback is null. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if video processing instance is running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_RegisterCallback(OH_VideoProcessing* videoProcessor, + const VideoProcessing_Callback* callback, void* userData); + +/** + * @brief Set the output surface for video processing. + * + * Set the output surface before starting video processing. + * + * @param videoProcessor A video processing instance pointer. + * @param window The output surface pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if setting output surface successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if window is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_SetSurface(OH_VideoProcessing* videoProcessor, + const OHNativeWindow* window); + +/** + * @brief Create an input surface. + * + * Create the input surface before starting video processing. + * Call {@link OH_NativeWindow_DestroyNativeWindow} to destroy the input surface. + * + * @param videoProcessor A video processing instance pointer. + * @param window The input surface pointer. For example, it is the output surface of a video decoder. + * @return {@link VIDEO_PROCESSING_SUCCESS} if operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if window is null or *window is not null. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if creating surface failed, input surface is already created + * or video processing instance is running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_GetSurface(OH_VideoProcessing* videoProcessor, OHNativeWindow** window); + +/** + * @brief Set parameter for video processing. + * + * Add parameter identified by the specified parameter key. + * + * @param videoProcessor An video processing instance pointer. + * @param parameter The parameter for video processing. + * @return {@link VIDEO_PROCESSING_SUCCESS} if setting parameter is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_VALUE} if some property of the parameter is invalid. For example, the parameter + * contains unsupported parameter key or value. \n + * {@link VIDEO_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_SetParameter(OH_VideoProcessing* videoProcessor, + const OH_AVFormat* parameter); + +/** + * @brief Get parameter of video processing. + * + * Get parameter identified by the specified parameter key. + * + * @param videoProcessor An video processing instance pointer. + * @param parameter The parameter used by the video processing instance. + * @return {@link VIDEO_PROCESSING_SUCCESS} if getting parameter is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_GetParameter(OH_VideoProcessing* videoProcessor, OH_AVFormat* parameter); + +/** + * @brief Start video processing instance. + * + * After successfully calling this function, the state {@link VIDEO_PROCESSING_STATE_RUNNING} is reported by callback + * function {@link OH_VideoProcessingCallback_OnState}. + * + * @param videoProcessor A video processing instance pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if output surface is not set, input surface is not created or + * instance is already running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Start(OH_VideoProcessing* videoProcessor); + +/** + * @brief To stop video processing instance. + * + * After the video processing instance is stopped successfully, the state {@link VIDEO_PROCESSING_STATE_STOPPED} is + * reported by callback function {@link OH_VideoProcessing_OnState}. + * + * @param videoProcessor A video processing instance pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if instance is already stopped. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Stop(OH_VideoProcessing* videoProcessor); + +/** + * @brief Send the output buffer out. + * + * If the callback function {@link OH_VideoProcessingCallback_OnNewOutputBuffer} is set, the buffer's index is reported + * to user by the callback function when an output buffer is ready. + * + * @param videoProcessor A video processing instance pointer. + * @param index The output buffer's index. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if index is invalid. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if callback {@link OH_VideoProcessing_OnNewOutputBuffer} is + * not set or instance is stopped. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_RenderOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index); + +/** + * @brief Create a video processing callback object. + * + * @param callback Output parameter. The *callback points to a new callback object. The *callback should be null before + * creating the callback object. + * @return {@link VIDEO_PROCESSING_SUCCESS} if callback object is created successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if callback is null or *callback is not null. \n + * {@link VIDEO_PROCESSING_ERROR_NO_MEMORY} if out of memory. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_Create(VideoProcessing_Callback** callback); + +/** + * @brief Destroy the callback object. + * + * The callback object can be destroyed after it is registered to video processing instance. + * + * @param callback The callback object pointer. It is recommended setting the callback pointer to null after the + * callback object is destroyed. + * @return {@link VIDEO_PROCESSING_SUCCESS} if callback is successfully destroyed. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if callback is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_Destroy(VideoProcessing_Callback* callback); + +/** + * @brief Bind the {@link OH_VideoProcessingCallback_OnError} callback function to callback object. + * + * @param callback A callback object pointer. + * @param onError The callback function. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the function is bound to callback object successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the callback is null or onError is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_BindOnError(VideoProcessing_Callback* callback, + OH_VideoProcessingCallback_OnError onError); + +/** + * @brief Bind the {@link OH_VideoProcessingCallback_OnState} callback function to callback object. + * + * @param callback A callback object pointer. + * @param onState The callback function. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the function is bound to callback object successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the callback is null or onState is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_BindOnState(VideoProcessing_Callback* callback, + OH_VideoProcessingCallback_OnState onState); + +/** + * @brief Bind the {@link OH_VideoProcessingCallback_OnNewOutputBuffer} callback function to callback object. + * + * @param callback A callback object pointer. + * @param onNewOutputBuffer The callback function. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the function is bound to callback object successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the callback is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_BindOnNewOutputBuffer(VideoProcessing_Callback* callback, + OH_VideoProcessingCallback_OnNewOutputBuffer onNewOutputBuffer); + +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_H +/** @} */ diff --git a/multimedia/video_processing_engine/video_processing/BUILD.gn b/multimedia/video_processing_engine/video_processing/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0dc56d02583cefe8084b36cea30c3d8ef7455f0a --- /dev/null +++ b/multimedia/video_processing_engine/video_processing/BUILD.gn @@ -0,0 +1,35 @@ +# 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("video_processing_ndk_headers") { + dest_dir = "$ndk_headers_out_dir/multimedia/video_processing_engine" + sources = [ + "../video_processing.h", + "../video_processing_types.h", + ] +} + +ohos_ndk_library("libvideo_processing_ndk") { + ndk_description_file = "./libvideo_processing.ndk.json" + output_name = "video_processing" + output_extension = "so" + min_compact_version = "12" + system_capability = "SystemCapability.Multimedia.VideoProcessingEngine" + system_capability_headers = [ + "multimedia/video_processing_engine/video_processing_types.h", + "multimedia/video_processing_engine/video_processing.h", + ] +} diff --git a/multimedia/video_processing_engine/video_processing/libvideo_processing.ndk.json b/multimedia/video_processing_engine/video_processing/libvideo_processing.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..19fc6e2cc0dfa42b931163299b783ed0a34a8248 --- /dev/null +++ b/multimedia/video_processing_engine/video_processing/libvideo_processing.ndk.json @@ -0,0 +1,98 @@ +[ + { + "first_introduced": "12", + "name": "OH_VideoProcessing_InitializeEnvironment" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_DeinitializeEnvironment" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_IsColorSpaceConversionSupported" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_IsMetadataGenerationSupported" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Create" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_RegisterCallback" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_SetSurface" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_GetSurface" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_SetParameter" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_GetParameter" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Start" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Stop" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_RenderOutputBuffer" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_Create" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_BindOnError" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_BindOnState" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_BindOnNewOutputBuffer" + }, + { + "first_introduced": "12", + "name": "VIDEO_PROCESSING_TYPE_COLOR_SPACE_CONVERSION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "VIDEO_PROCESSING_TYPE_METADATA_GENERATION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "VIDEO_PROCESSING_TYPE_DETAIL_ENHANCER", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "VIDEO_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL", + "type": "variable" + } +] diff --git a/multimedia/video_processing_engine/video_processing_types.h b/multimedia/video_processing_engine/video_processing_types.h new file mode 100644 index 0000000000000000000000000000000000000000..d863e2cf37bcc7c1a1bf3c3dcd78bccf7d1c6d7a --- /dev/null +++ b/multimedia/video_processing_engine/video_processing_types.h @@ -0,0 +1,278 @@ +/* + * 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 VideoProcessing + * @{ + * + * @brief Provide video processing including color space conversion and metadata generation. + * + * @since 12 + */ + +/** + * @file video_processing_types.h + * + * @brief Type definitions for video processing. + * + * @library libvideo_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit MediaKit + * @since 12 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_TYPES_H +#define VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_TYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define the video processing object. + * + * Define a null pointer of OH_VideoProcessing and call {@link OH_VideoProcessing_Create} to create a video processing + * instance. The pointer should be null before creating instance. + * User can create multiple video processing instances for different processing types. + * + * @since 12 + */ +typedef struct OH_VideoProcessing OH_VideoProcessing; + +/** + * @brief Forward declaration of NativeWindow. + * + * @since 12 + */ +typedef struct NativeWindow OHNativeWindow; + +/** + * @brief Forward declaration of OH_AVFormat. + * + * @since 12 + */ +typedef struct OH_AVFormat OH_AVFormat; + +/** + * @brief Used to create a video processing instance for color space conversion. + * + * Some capabilities are supported by vendor. Use {@link OH_VideoProcessing_IsColorSpaceConversionSupported} to query if + * the conversion is supported. + * + * @see OH_VideoProcessing_Create + * @since 12 + */ +extern const int32_t VIDEO_PROCESSING_TYPE_COLOR_SPACE_CONVERSION; + +/** + * @brief Used to create a video processing instance for metadata generation. + * + * Generate HDR vivid metadata for video. The capability is supported by vendor. If the capability is not supported, + * {@link OH_VideoProcessing_Create} returns {@link VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING}. + * + * @see OH_VideoProcessing_Create + * @since 12 + */ +extern const int32_t VIDEO_PROCESSING_TYPE_METADATA_GENERATION; + +/** + * @brief Used to create an video processing instance of detail enhancement. + * + * Scale or resize video with the specified quality or just enhance details for rendering without changing its + * resolution. + * + * @see OH_ImageProcessing_Create + * @since 12 + */ +extern const int32_t VIDEO_PROCESSING_TYPE_DETAIL_ENHANCER; + +/** + * @brief The key is used to specify the quality level for video detail enhancement. + * + * See {@link VideoDetailEnhancer_QualityLevel} for its values. + * Use {@link OH_VideoProcessing_SetParameter} to set the quality level. + * Use {@link OH_VideoProcessing_GetParameter} to get the current quality level. + * + * @see OH_VideoProcessing_SetParameter + * @see OH_VideoProcessing_GetParameter + * @since 12 + */ +extern const char* VIDEO_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL; + +/** + * @brief Video color space information structure of querying if video color space conversion is supported. + * + * @see OH_VideoProcessing_IsColorSpaceConversionSupported + * @since 12 + */ +typedef struct VideoProcessing_ColorSpaceInfo { + /** The metadata type of the video, see {@link enum OH_NativeBuffer_MetadataType} */ + int32_t metadataType; + /** The color space type of the video, see {@link enum OH_NativeBuffer_ColorSpace} */ + int32_t colorSpace; + /** The pixel format of the video, see {@link enum OH_NativeBuffer_Format} */ + int32_t pixelFormat; +} VideoProcessing_ColorSpaceInfo; + +/** + * @brief The quality level is used for detail enhancement. + * + * It is the value of the key parameter {@link VIDEO_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL}. + * + * @see OH_VideoProcessing_SetParameter + * @see OH_VideoProcessing_GetParameter + * @since 12 + */ +typedef enum VideoDetailEnhancer_QualityLevel { + /** No detail enhancement */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_NONE, + /** A low level of detail enhancement quality but with a fast speed. It's the default level */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_LOW, + /** A medium level of detail enhancement quality. Its speed is between the low setting and high setting */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM, + /** A high level of detail enhancement quality but with a relatively slow speed */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH, +} VideoDetailEnhancer_QualityLevel; + +/** + * @brief Video processing error code. + * + * @since 12 + */ +typedef enum VideoProcessing_ErrorCode { + /** @error Operation is successful. */ + VIDEO_PROCESSING_SUCCESS, + /** @error Input parameter is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output video buffer - The video buffer is null. + * 2 - Invalid parameter - The parameter is null. + * 3 - Invalid type - The type passed in the create function does not exist. + */ + VIDEO_PROCESSING_ERROR_INVALID_PARAMETER = 401, + /** @error Some unknown error occurred, such as GPU calculation failure or memcpy failure. */ + VIDEO_PROCESSING_ERROR_UNKNOWN = 29210001, + /** @error The global environment initialization for video processing failed, such as failure to initialize + * the GPU environment. + */ + VIDEO_PROCESSING_ERROR_INITIALIZE_FAILED, + /** @error Failed to create video processing instance. For example, + * the number of instances exceeds the upper limit. + */ + VIDEO_PROCESSING_ERROR_CREATE_FAILED, + /** @error Failed to process video buffer. For example, the processing times out. */ + VIDEO_PROCESSING_ERROR_PROCESS_FAILED, + /** @error The processing is not supported. You may call OH_VideoProcessing_IsXXXSupported + * to check whether the capability is supported. + */ + VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING, + /** @error The operation is not permitted. This may be caused by incorrect status. */ + VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED, + /** @error Out of memory. */ + VIDEO_PROCESSING_ERROR_NO_MEMORY, + /** @error The video processing instance is invalid. This may be caused by null instance. */ + VIDEO_PROCESSING_ERROR_INVALID_INSTANCE, + /** @error Input value is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output video buffer - The video buffer width(height) + * is too large or colorspace is incorrect. + * 2 - Invalid parameter - The parameter does not contain valid information, + * such as detail enhancer level is incorrect. + */ + VIDEO_PROCESSING_ERROR_INVALID_VALUE +} VideoProcessing_ErrorCode; + +/** + * @brief Video processing states. + * + * The state is reported to user by callback function {@link OH_VideoProcessing_OnState}. + * + * @since 12 + */ +typedef enum VideoProcessing_State { + /** Video processing is running */ + VIDEO_PROCESSING_STATE_RUNNING, + /** Video processing is stopped */ + VIDEO_PROCESSING_STATE_STOPPED +} VideoProcessing_State; + +/** + * @brief Video processing asynchronous callback object type. + * + * Define a null pointer of VideoProcessing_Callback and call {@link OH_VideoProcessingCallback_Create} to create a + * callback object. The pointer should be null before creating the callback object. + * Register the callback to a video processing instance by calling {@link OH_VideoProcessing_RegisterCallback}. + * + * @since 12 + */ +typedef struct VideoProcessing_Callback VideoProcessing_Callback; + +/** + * @brief The callback function pointer definition for reporting error during video processing. + * + * Errors: \n + * {@link VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING}, the processing is not supported. For example, the + * color space conversion according to the source and destination videos' properties is not supported. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_VALUE}, some property of the video is invalid. For example, the color space of + * the video is invalid. \n + * {@link VIDEO_PROCESSING_ERROR_NO_MEMORY}, out of memory. \n + * {@link VIDEO_PROCESSING_ERROR_PROCESS_FAILED}, some processing error occurs. \n + * For more errors, see {@link VideoProcessing_ErrorCode}. + * + * @param videoProcessor The video processing instance. + * @param error Error code reporting to user. + * @param userData User's custom data. + * @since 12 + */ +typedef void (*OH_VideoProcessingCallback_OnError)(OH_VideoProcessing* videoProcessor, + VideoProcessing_ErrorCode error, void* userData); + +/** + * @brief The callback function pointer definition for reporting video processing state. + * + * The state will be {@link VIDEO_PROCESSING_STATE_RUNNING} after {@link OH_VideoProcessing_Start} is called + * successfully. + * The state will be {@link VIDEO_PROCESSING_STATE_STOPPED} after all the buffers cached before + * {@link OH_VideoProcessing_Stop} is called are processed. + * + * @param videoProcessor The video processing instance. + * @param state see {@link VideoProcessing_State}. + * @param userData User's custom data. + * @since 12 + */ +typedef void (*OH_VideoProcessingCallback_OnState)(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, + void* userData); + +/** + * @brief The callback function pointer definition for reporting a new output buffer is filled with processed data. + * + * Every new output buffer's index will report to user once the buffer is filled with processed data. Then call + * {@link OH_VideoProcessing_RenderOutputBuffer} with the buffer's index to send the output buffer out. + * If this function is not registered, the output buffer is sent out as soon as the buffer is filled with processed + * data without reporting. + * + * @param videoProcessor The video processing instance. + * @param index The index of the new output buffer. + * @param userData The user's custom data. + * @since 12 + */ +typedef void (*OH_VideoProcessingCallback_OnNewOutputBuffer)(OH_VideoProcessing* videoProcessor, uint32_t index, + void* userData); + +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_TYPES_H +/** @} */ diff --git a/multimodalinput/kits/c/BUILD.gn b/multimodalinput/kits/c/BUILD.gn index 60f919ab132fe57ba9c3cdaf305e7f899264baff..1d53eb37c3208cc6c0570224f2ca4199d33616fd 100644 --- a/multimodalinput/kits/c/BUILD.gn +++ b/multimodalinput/kits/c/BUILD.gn @@ -18,6 +18,7 @@ import("//foundation/multimodalinput/input/multimodalinput_mini.gni") ohos_ndk_headers("ohinput_header") { dest_dir = "$ndk_headers_out_dir/multimodalinput" sources = [ + "./input/oh_axis_type.h", "./input/oh_input_manager.h", "./input/oh_key_code.h", ] @@ -29,6 +30,7 @@ ohos_ndk_library("libohinput_ndk") { ndk_description_file = "./ohinput.ndk.json" system_capability = "SystemCapability.MultimodalInput.Input.Core" system_capability_headers = [ + "multimodalinput/oh_axis_type.h", "multimodalinput/oh_input_manager.h", "multimodalinput/oh_key_code.h", ] diff --git a/multimodalinput/kits/c/input/oh_axis_type.h b/multimodalinput/kits/c/input/oh_axis_type.h new file mode 100644 index 0000000000000000000000000000000000000000..de141042d511c42e2db39f9958e409759985c5be --- /dev/null +++ b/multimodalinput/kits/c/input/oh_axis_type.h @@ -0,0 +1,144 @@ +/* + * 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 input + * @{ + * + * @brief Provides the C interface in the multi-modal input domain. + * + * @since 12 + */ + +/** + * @file oh_axis_type.h + * + * @brief Defines the axis event-specific structure and enumerations. + * @kit InputKit + * @syscap SystemCapability.MultimodalInput.Input.Core + * @library liboh_input.so + * @since 12 + */ + +#ifndef OH_AXIS_TYPE_H +#define OH_AXIS_TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates axis types. + * + * @since 12 + */ +typedef enum InputEvent_AxisType { + /** + * Indicates an unknown axis type. It is generally used as the initial value. + * + * @since 12 + */ + AXIS_TYPE_UNKNOWN, + + /** + * Indicates the vertical scroll axis. When you scroll the mouse wheel or make certain gestures on the touchpad, + * the status of the vertical scroll axis changes. + * + * @since 12 + */ + AXIS_TYPE_SCROLL_VERTICAL, + + /** + * Indicates the horizontal scroll axis. + * When you scroll the mouse wheel or make certain gestures on the touchpad, + * the status of the horizontal scroll axis changes. + * + * @since 12 + */ + AXIS_TYPE_SCROLL_HORIZONTAL, + + /** + * Indicates the pinch axis, which is used to describe a pinch gesture on the touchscreen or touchpad. + * + * @since 12 + */ + AXIS_TYPE_PINCH, + + /** + * Indicates the rotate axis, which is used to describe a rotate gesture on the touchpad. + * + * @since 12 + */ + AXIS_TYPE_ROTATE +} InputEvent_AxisType; + +/** + * @brief Enumerates axis event types. + * + * @since 12 + */ +typedef enum InputEvent_AxisEventType { + /** + * @brief Enumerates two-finger pinch events. The axis value can be AXIS_TYPE_PINCH or AXIS_TYPE_ROTATE. + * + * @since 12 + */ + AXIS_EVENT_TYPE_PINCH = 1, + /** + * @brief Enumerates scroll axis events. + * The axis value can be AXIS_TYPE_SCROLL_VERTICAL or AXIS_TYPE_SCROLL_HORIZONTAL. + * Wherein, the value of AXIS_TYPE_SCROLL_HORIZONTAL is 0 for a mouse wheel event. + * + * @since 12 + */ + AXIS_EVENT_TYPE_SCROLL = 2 +} InputEvent_AxisEventType; + +/** + * @brief Enumerates axis event actions. + * + * @since 12 + */ +typedef enum InputEvent_AxisAction { + /** + * Cancel action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_CANCEL = 0, + /** + * Start action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_BEGIN, + /** + * Update action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_UPDATE, + /** + * End action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_END, +} InputEvent_AxisAction; +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/multimodalinput/kits/c/input/oh_input_manager.h b/multimodalinput/kits/c/input/oh_input_manager.h index 7506a28f9f85bc13507c452b224163cd1e88a31c..0a2b5b4716bf1c9112b3a18632b7cd3534269bf2 100644 --- a/multimodalinput/kits/c/input/oh_input_manager.h +++ b/multimodalinput/kits/c/input/oh_input_manager.h @@ -37,6 +37,7 @@ #include +#include "oh_axis_type.h" #include "oh_key_code.h" #ifdef __cplusplus @@ -48,7 +49,7 @@ extern "C" { * * @since 12 */ -enum Input_KeyStateAction { +typedef enum Input_KeyStateAction { /** Default */ KEY_DEFAULT = -1, /** Pressing of a key */ @@ -59,14 +60,14 @@ enum Input_KeyStateAction { KEY_SWITCH_ON = 2, /** Key switch disabled */ KEY_SWITCH_OFF = 3 -}; +} Input_KeyStateAction; /** * @brief Enumerates key event types. * * @since 12 */ -typedef enum { +typedef enum Input_KeyEventAction { /** Cancellation of a key action. */ KEY_ACTION_CANCEL = 0, /** Pressing of a key. */ @@ -80,7 +81,7 @@ typedef enum { * * @since 12 */ -typedef enum { +typedef enum Input_MouseEventAction { /** Cancel. */ MOUSE_ACTION_CANCEL = 0, /** Moving of the mouse pointer. */ @@ -102,19 +103,19 @@ typedef enum { * * @since 12 */ -enum InputEvent_MouseAxis { +typedef enum InputEvent_MouseAxis { /** Vertical scroll axis */ MOUSE_AXIS_SCROLL_VERTICAL = 0, /** Horizontal scroll axis */ MOUSE_AXIS_SCROLL_HORIZONTAL = 1, -}; +} InputEvent_MouseAxis; /** * @brief Enumerated values of mouse event button. * * @since 12 */ -typedef enum { +typedef enum Input_MouseEventButton { /** Invalid button */ MOUSE_BUTTON_NONE = -1, /** Left button on the mouse. */ @@ -134,7 +135,7 @@ typedef enum { * * @since 12 */ -typedef enum { +typedef enum Input_TouchEventAction { /** Touch cancelled. */ TOUCH_ACTION_CANCEL = 0, /** Touch pressed. */ @@ -145,56 +146,221 @@ typedef enum { TOUCH_ACTION_UP = 3, } Input_TouchEventAction; +/** + * @brief Enumerates keyboard types. + * + * @since 13 + */ +typedef enum Input_KeyboardType { + /** Keyboard without keys */ + KEYBOARD_TYPE_NONE = 0, + /** Keyboard with unknown keys */ + KEYBOARD_TYPE_UNKNOWN = 1, + /** Full keyboard */ + KEYBOARD_TYPE_ALPHABETIC = 2, + /** Digital keyboard */ + KEYBOARD_TYPE_DIGITAL = 3, + /** Stylus */ + KEYBOARD_TYPE_STYLUS = 4, + /** Remote control */ + KEYBOARD_TYPE_REMOTE_CONTROL = 5, +} Input_KeyboardType; + +/** + * @brief Enumerates event source types. + * + * @since 12 + */ +typedef enum InputEvent_SourceType { + /** + * Indicates that the input source generates events similar to mouse cursor movement, + * button press and release, and wheel scrolling. + * + * @since 12 + */ + SOURCE_TYPE_MOUSE = 1, + /** + * Indicates that the input source generates a touchscreen multi-touch event. + * + * @since 12 + */ + SOURCE_TYPE_TOUCHSCREEN = 2, + /** + * Indicates that the input source generates a touchpad multi-touch event. + * + * @since 12 + */ + SOURCE_TYPE_TOUCHPAD = 3 +} InputEvent_SourceType; + /** * @brief Defines key information, which identifies a key pressing behavior. For example, the Ctrl key information contains the key value and key type. * * @since 12 */ -struct Input_KeyState; +typedef struct Input_KeyState Input_KeyState; /** * @brief The key event to be injected. * * @since 12 */ -struct Input_KeyEvent; +typedef struct Input_KeyEvent Input_KeyEvent; /** * @brief The mouse event to be injected. * * @since 12 */ -struct Input_MouseEvent; +typedef struct Input_MouseEvent Input_MouseEvent; /** * @brief The touch event to be injected. * * @since 12 */ -struct Input_TouchEvent; +typedef struct Input_TouchEvent Input_TouchEvent; + +/** + * @brief Enumerates axis events. + * + * @since 12 + */ +typedef struct Input_AxisEvent Input_AxisEvent; /** - * @brief Enumerates the error codes. + * @brief Defines the hot key structure. + * + * @since 13 + */ +typedef struct Input_Hotkey Input_Hotkey; + +/** + * @brief Enumerates error codes. * * @since 12 */ -typedef enum { - /** @error Success return code on sucess*/ +typedef enum Input_Result { + /** @error Success return code on success*/ INPUT_SUCCESS = 0, /** @error Permission verification failed */ INPUT_PERMISSION_DENIED = 201, /** @error Non-system application */ INPUT_NOT_SYSTEM_APPLICATION = 202, /** @error Parameter check failed */ - INPUT_PARAMETER_ERROR = 401 + INPUT_PARAMETER_ERROR = 401, + /** @error Service error */ + INPUT_SERVICE_EXCEPTION = 3800001, + /** @error Interceptor repeatedly created for an application */ + INPUT_REPEAT_INTERCEPTOR = 4200001, + /** + * @error Already occupied by the system + * @since 13 + */ + INPUT_OCCUPIED_BY_SYSTEM = 4200002, + /** + * @error Already occupied by the other + * @since 13 + */ + INPUT_OCCUPIED_BY_OTHER = 4200003, } Input_Result; +/** + * @brief Callback used to return shortcut key events. + * @since 13 + */ +typedef void (*Input_HotkeyCallback)(Input_Hotkey* hotkey); + +/** + * @brief Represents information about the input device. + * + * @since 13 + */ +typedef struct Input_DeviceInfo Input_DeviceInfo; + +/** + * @brief Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed. + * + * @param keyEvent Key event object. + * @since 12 + */ +typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent); + +/** + * @brief Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed. + * + * @param mouseEvent Mouse event object. + * @since 12 + */ +typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent); + +/** + * @brief Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed. + * + * @param touchEvent Touch event object. + * @since 12 + */ +typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent); + +/** + * @brief Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed. + * + * @param axisEvent Axis event object. + * @since 12 + */ +typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent); + +/** + * @brief Defines the callback for device addition events. + * @param deviceId Device ID. + * @since 13 + */ +typedef void (*Input_DeviceAddedCallback)(int32_t deviceId); + +/** + * @brief Defines the callback for device removal events. + * @param deviceId Device ID. + * @since 13 + */ +typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId); + +/** + * @brief Defines the structure for the interceptor of event callbacks, + * including mouseCallback, touchCallback, and axisCallback. + * @since 12 + */ +typedef struct Input_InterceptorEventCallback { + /** Defines a lifecycle callback for **mouseEvent**. */ + Input_MouseEventCallback mouseCallback; + /** Defines a lifecycle callback for **touchEvent**. */ + Input_TouchEventCallback touchCallback; + /** Defines a lifecycle callback for **axisEvent**. */ + Input_AxisEventCallback axisCallback; +} Input_InterceptorEventCallback; + +/** + * @brief Defines a listener for device insertion and removal events. + * @since 13 + */ +typedef struct Input_DeviceListener { + /** Callback for device addition events */ + Input_DeviceAddedCallback deviceAddedCallback; + /** Callback for device removal events */ + Input_DeviceRemovedCallback deviceRemovedCallback; +} Input_DeviceListener; + +/** + * @brief Defines event interceptor options. + * @since 12 + */ +typedef struct Input_InterceptorOptions Input_InterceptorOptions; + /** * @brief Queries the key state. * * @param keyState Key state. * @return OH_Input_GetKeyState function result code. - * {@link INPUT_SUCCESS} get KeyState sucess.\n + * {@link INPUT_SUCCESS} get KeyState success.\n * {@link INPUT_PARAMETER_ERROR} keyCode is invalid.\n * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 @@ -285,7 +451,7 @@ int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState); * * @param keyEvent - the key event to be injected. * @return OH_Input_InjectKeyEvent function result code. - * {@link INPUT_SUCCESS} inject keyEvent sucess.\n + * {@link INPUT_SUCCESS} inject keyEvent success.\n * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n * {@link INPUT_PARAMETER_ERROR} keyCode is less 0, can not process.\n * @syscap SystemCapability.MultimodalInput.Input.Core @@ -377,7 +543,7 @@ int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent); * * @param mouseEvent - the mouse event to be injected. * @return OH_Input_InjectMouseEvent function result code. - * {@link INPUT_SUCCESS} inject mouseEvent sucess.\n + * {@link INPUT_SUCCESS} inject mouseEvent success.\n * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n * @syscap SystemCapability.MultimodalInput.Input.Core @@ -508,7 +674,8 @@ int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent * @brief Sets the axis value for a mouse axis event. * * @param mouseEvent Mouse event object. - * @param axisType Axis value. A positive value means scrolling forward, and a negative number means scrolling backward. + * @param axisType Axis value. A positive value means scrolling forward, + * and a negative number means scrolling backward. * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ @@ -549,7 +716,7 @@ int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEve * * @param touchEvent - the touch event to be injected. * @return OH_Input_InjectTouchEvent function result code. - * {@link INPUT_SUCCESS} inject touchEvent sucess.\n + * {@link INPUT_SUCCESS} inject touchEvent success.\n * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 @@ -683,6 +850,793 @@ int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEve */ void OH_Input_CancelInjection(); +/** + * @brief Creates an axis event object. + * + * @return If the operation is successful, a {@Link Input_AxisEvent} object is returned. + * If the operation fails, null is returned. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_AxisEvent* OH_Input_CreateAxisEvent(void); + +/** + * @brief Destroys an axis event object. + * + * @param axisEvent Pointer to the axis event object. + * @return OH_Input_DestroyAxisEvent function result code. + * {@link INPUT_SUCCESS} Destroys axisEvent success.\n + * {@link INPUT_PARAMETER_ERROR}The axisEvent is NULL or the *axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent); + +/** + * @brief Sets the axis event action. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. + * @return OH_Input_SetAxisEventAction function result code. + * {@link INPUT_SUCCESS} Sets the axis event action success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action); + +/** + * @brief Obtains the axis event action. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. + * @return OH_Input_GetAxisEventAction function result code. + * {@link INPUT_SUCCESS} Obtains the axis event action success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the action is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action); + +/** + * @brief Sets the X coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayX X coordinate of the axis event. + * @return OH_Input_SetAxisEventDisplayX function result code. + * {@link INPUT_SUCCESS} Sets the X coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX); + +/** + * @brief Obtains the X coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayX X coordinate of the axis event. + * @return OH_Input_GetAxisEventDisplayX function result code. + * {@link INPUT_SUCCESS} Obtains the X coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayX is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX); + +/** + * @brief Sets the Y coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayY Y coordinate of the axis event. + * @return OH_Input_SetAxisEventDisplayY function result code. + * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY); + +/** + * @brief Obtains the Y coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayY Y coordinate of the axis event. + * @return OH_Input_GetAxisEventDisplayY function result code. + * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY); + +/** + * @brief Sets the axis value of the axis type specified by the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. + * @param axisValue Axis value. + * @return OH_Input_SetAxisEventAxisValue function result code. + * {@link INPUT_SUCCESS} Sets the axis value of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent, + InputEvent_AxisType axisType, double axisValue); + +/** + * @brief Obtains the axis value for the specified axis type of the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. + * @param axisValue Axis value. + * @return OH_Input_GetAxisEventAxisValue function result code. + * {@link INPUT_SUCCESS} Obtains the axis value of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisValue is NULL, + * or the axisType not found in the axisEvent.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent, + InputEvent_AxisType axisType, double* axisValue); + +/** + * @brief Sets the time when an axis event occurs. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param actionTime Time when an axis event occurs. + * @return OH_Input_SetAxisEventActionTime function result code. + * {@link INPUT_SUCCESS} Sets the time when an axis event occurs success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime); + +/** + * @brief Obtains the time when an axis event occurs. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param actionTime Time when an axis event occurs. + * @return OH_Input_GetAxisEventActionTime function result code. + * {@link INPUT_SUCCESS} Obtains the time when an axis event occurs success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the actionTime is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime); + +/** + * @brief Sets the axis event type. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. + * @return OH_Input_SetAxisEventType function result code. + * {@link INPUT_SUCCESS} Sets the axis event type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType); + +/** + * @brief Obtains the axis event type. + * + * @param axisEvent Axis event object. + * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. + * @return OH_Input_GetAxisEventType function result code. + * {@link INPUT_SUCCESS} Obtains the axis event type success.\n + * {@Link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisEventType is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType); + +/** + * @brief Sets the axis event source type. + * + * @param axisEvent Axis event object. + * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. + * @return OH_Input_SetAxisEventSourceType function result code. + * {@link INPUT_SUCCESS} Sets the axis event source type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType); + +/** + * @brief Obtains the axis event source type. + * + * @param axisEvent Axis event object. + * @param axisEventType Axis event source type. The values are defined in {@link InputEvent_SourceType}. + * @return OH_Input_GetAxisEventSourceType function result code. + * {@link INPUT_SUCCESS} Obtains the axis event source type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the sourceType is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType); + +/** + * @brief Adds a listener of key events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive key events. + * @return OH_Input_AddKeyEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of key events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback); + +/** + * @brief Adds a listener for mouse events, including mouse click and movement events, + * but not scroll wheel events. Scroll wheel events are axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive mouse events. + * @return OH_Input_AddMouseEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of mouse events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback); + +/** + * @brief Add a listener for touch events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive touch events. + * @return OH_Input_AddTouchEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of touch events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback); + +/** + * @brief Adds a listener for all types of axis events. + * The axis event types are defined in {@Link InputEvent_AxisEventType}. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive axis events. + * @return OH_Input_AddAxisEventMonitorForAll function result code. + * {@link INPUT_SUCCESS} Adds a listener for all types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback); + +/** + * @brief Adds a listener for the specified type of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param axisEventType - Axis event type. The values are defined in {@Link InputEvent_AxisEventType}. + * @param callback - Callback used to receive the specified type of axis events. + * @return OH_Input_AddAxisEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener for the specified types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); + +/** + * @brief Removes a key event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the key event listener. + * @return OH_Input_RemoveKeyEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a key event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback); + +/** + * @brief Removes a mouse event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the mouse event listener. + * @return OH_Input_RemoveMouseEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a mouse event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback); + +/** + * @brief Removes a touch event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the touch event listener. + * @return OH_Input_RemoveTouchEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a touch event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback); + +/** + * @brief Removes the listener for all types of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the listener used to listen for all types of axis events. + * @return OH_Input_RemoveAxisEventMonitorForAll function result code. + * {@link INPUT_SUCCESS} Removes the listener for all types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback); + +/** + * @brief Removes the listener for the specified type of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param axisEventType - Axis event type. The axis event type is defined in {@Link InputEvent_AxisEventType}. + * @param callback - Callback for the listener used to listen for the specified type of axis events. + * @return OH_Input_RemoveAxisEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes the listener for the specified type of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); + +/** + * @brief Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @param callback - Callback used to receive key events. + * @param option - Options for event interception. If **null** is passed, the default value is used. + * @return OH_Input_AddKeyEventInterceptor function result code. + * {@link INPUT_SUCCESS} Adds a key event interceptor success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option); + +/** + * @brief Adds an interceptor for input events, including mouse, touch, and axis events. + * If multiple interceptors are added, only the first one takes effect. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @param callback - Pointer to the structure of the callback for the input event interceptor. + * For details, see {@Link Input_InterceptorEventCallback}. + * @param option - Options for event interception. If **null** is passed, the default value is used. + * @return OH_Input_AddInputEventInterceptor function result code. + * {@link INPUT_SUCCESS} Adds an interceptor for input events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback, + Input_InterceptorOptions *option); + +/** + * @brief Removes a key event interceptor. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @return OH_Input_RemoveKeyEventInterceptor function result code. + * {@link INPUT_SUCCESS}Removes a key event interceptor success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveKeyEventInterceptor(void); + +/** + * @brief Removes an interceptor for input events, including mouse, touch, and axis events. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @return OH_Input_RemoveInputEventInterceptor function result code. + * {@link INPUT_SUCCESS} Removes an interceptor for input events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveInputEventInterceptor(void); + +/** + * @brief Obtains the interval since the last system input event. + * + * @param timeInterval Interval, in microseconds. + * @return OH_Input_GetIntervalSinceLastInput status code, specifically. + * {@Link INPUT_SUCCESS} if the Operation is successful.\n + * {@Link INPUT_SERVICE_EXCEPTION} Failed to get the interval because the service is exception.\n + * {@Link INPUT_PARAMETER_ERROR} The timeInterval is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetIntervalSinceLastInput(int64_t *timeInterval); + +/** + * @brief Creates a hot key object. + * + * @return Returns an {@Link Input_Hotkey} pointer object if the operation is successful. Otherwise, a null pointer is + * returned. The possible cause is memory allocation failure. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Hotkey *OH_Input_CreateHotkey(void); + +/** + * @brief Destroys a hot key object. + * + * @param hotkey Hot key object. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +void OH_Input_DestroyHotkey(Input_Hotkey **hotkey); + +/** + * @brief Sets a modifier key. + * + * @param hotkey Hotkey key object. + * @param preKeys List of modifier keys. + * @param size Number of modifier keys. One or two modifier keys are supported. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +void OH_Input_SetPreKeys(Input_Hotkey *hotkey, int32_t *preKeys, int32_t size); + +/** + * @brief Obtains a modifier key. + * + * @param hotkey Hotkey key object. + * @param preKeys List of modifier keys. + * @param preKeyCount Number of modifier keys. + * @return OH_Input_GetPreKeys status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the pressedKeys is NULL or the pressedKeyCount + * is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetPreKeys(const Input_Hotkey *hotkey, int32_t **preKeys, int32_t *preKeyCount); + +/** + * @brief Sets a modified key. + * + * @param hotkey Hotkey key object. + * @param finalKey Modified key. Only one modified key is supported. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +void OH_Input_SetFinalKey(Input_Hotkey *hotkey, int32_t finalKey); + +/** + * @brief Obtains a modified key. + * + * @param hotkey Hotkey key object. + * @param finalKeyCode Returns the key value of the decorated key. + * @return OH_Input_GetfinalKey status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the finalKeyCode is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetFinalKey(const Input_Hotkey *hotkey, int32_t *finalKeyCode); + +/** + * @brief Creates an array of {@Link Input_Hotkey} instances. + * + * @param count Number of {@Link Input_Hotkey} instances to be created. The count must be the same as the number of + * system shortcut keys. + * @return Returns a pointer to an array of {@Link Input_Hotkey} instances if the operation is successful. If the + * operation fails, a null pointer is returned. The possible cause is memory allocation failure or count is not equal + * to the number of system hotkeys. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Hotkey **OH_Input_CreateAllSystemHotkeys(int32_t count); + +/** + * @brief Destroys an array of {@link Input_Hotkey} instances and reclaims memory. + * + * @param hotkeys Pointer to an array of {@Link Input_Hotkey } instances created by the + * {@Link OH_Input_CreateAllSystemHotkeys} method. + * @param count Count of the array to be destroyed, which must be the same as the number of system shortcut keys. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +void OH_Input_DestroyAllSystemHotkeys(Input_Hotkey **hotkeys, int32_t count); + +/** + * @brief Obtains all hot keys supported by the system. + * + * @param hotkey Array of {@Link Input_Hotkey} instances. + * When calling this API for the first time, you can pass NULL to obtain the array length. + * @param count Number of hot keys supported by the system. + * @return OH_Input_GetAllSystemHotkeys status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} The hotkey or count is NULL, or the value of count does not match the number + * of system shortcut keys supported by the system. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetAllSystemHotkeys(Input_Hotkey **hotkey, int32_t *count); + +/** + * @brief Specifies whether to report repeated key events. + * + * @param hotkey Shortcut key object. + * @param isRepeat Whether to report repeated key events. + * The value true means to report repeated key events, and the value false means the opposite. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +void OH_Input_SetRepeat(Input_Hotkey* hotkey, bool isRepeat); + +/** + * @brief Checks whether to report repeated key events. + * + * @param hotkey Shortcut key object. + * @param isRepeat Whether a key event is repeated. + * @return OH_Input_GetIsRepeat status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} otherwise.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetRepeat(const Input_Hotkey* hotkey, bool *isRepeat); + +/** + * @brief Subscribes to shortcut key events. + * + * @param hotkey Shortcut key object. + * @param callback Callback used to return shortcut key events. + * @return OH_Input_AddHotkeyMonitor status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n + * {@Link INPUT_OCCUPIED_BY_SYSTEM} The hotkey has been used by the system. You can call the {@Link + * GetAllSystemHotkeys} interface to query all system shortcut keys.\n + * {@Link INPUT_OCCUPIED_BY_OTHER} The hotkey has been subscribed to by another.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_AddHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); + +/** + * @brief Unsubscribes from shortcut key events. + * + * @param hotkey Shortcut key object. + * @param callback Callback used to return shortcut key events. + * @return OH_Input_RemoveHotkeyMonitor status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_RemoveHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); + +/** + * @brief Registers a listener for device hot swap events. + * + * @param listener Pointer to an {@Link Input_DeviceListener} object. + * + * @return OH_Input_RegisterDeviceListener status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} if listener is NULL; + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_RegisterDeviceListener(Input_DeviceListener* listener); + +/** + * @brief Unregisters the listener for device hot swap events. + * + * @param listener Pointer to the listener for device hot swap events. For details, see {@Link Input_DeviceListener}. + * + * @return OH_Input_UnregisterDeviceListener status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} if listener is NULL or no listener is registered; + * {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_UnregisterDeviceListener(Input_DeviceListener* listener); + +/** + * @brief Unregisters the listener for all device hot swap events. + * + * @return OH_Input_UnregisterDeviceListener status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_UnregisterDeviceListeners(); + +/** + * @brief Obtains the IDs of all input devices. + * + * @param deviceIds Array of input device IDs. + * @param inSize Size of the array of input device IDs. + * @param outSize Length of the list of input device IDs. The value cannot be greater than the value of inSize. + * @return OH_Input_GetDeviceIds result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceIds or outSize is a null pointer or inSize is less than 0. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDeviceIds(int32_t *deviceIds, int32_t inSize, int32_t *outSize); + +/** + * @brief Obtains the information about an input device. + * + * @param deviceId Device ID. + * @param deviceInfo Pointer to an {@Link Input_DeviceInfo} object. + * @return OH_Input_GetDevice result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if the deviceInfo is a null pointer or the deviceId is invalid. + * You can use the {@Link OH_Input_GetDeviceIds} interface to query the device IDs supported by the system. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDevice(int32_t deviceId, Input_DeviceInfo **deviceInfo); + +/** + * @brief Creates a deviceInfo object. + * + * @return Pointer to an {@Link Input_DeviceInfo} object if the operation is successful; + * a null pointer otherwise (possibly because of a memory allocation failure). + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_DeviceInfo* OH_Input_CreateDeviceInfo(void); + +/** + * @brief Destroys a deviceInfo object. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +void OH_Input_DestroyDeviceInfo(Input_DeviceInfo **deviceInfo); + +/** + * @brief Obtains the keyboard type of an input device. + * + * @param deviceId Device ID. + * @param keyboardType Pointer to the keyboard type of the input device. + * @return OH_Input_GetKeyboardType result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if the device ID is invalid or keyboardType is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetKeyboardType(int32_t deviceId, int32_t *keyboardType); + +/** + * @brief Obtains the ID of an input device. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @param id Pointer to the ID of the input device. + * @return OH_Input_GetDeviceId result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceInfo or id is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDeviceId(Input_DeviceInfo *deviceInfo, int32_t *id); + +/** + * @brief Obtains the name of an input device. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @param name Pointer to the name of the input device. + * @return OH_Input_GetDeviceName result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceInfo or name is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDeviceName(Input_DeviceInfo *deviceInfo, char **name); + +/** + * @brief Obtains the capabilities of an input device, for example, a touchscreen, touchpad, or keyboard. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @param capabilities Pointer to the capabilities of the input device. + * @return OH_Input_GetCapabilities result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceInfo or capabilities is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetCapabilities(Input_DeviceInfo *deviceInfo, int32_t *capabilities); + +/** + * @brief Obtains the version information of an input device. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @param version Pointer to the version information of the input device. + * @return OH_Input_GetDeviceVersion result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceInfo or version is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDeviceVersion(Input_DeviceInfo *deviceInfo, int32_t *version); + +/** + * @brief Obtains the product information of an input device. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @param product Pointer to the product information of the input device. + * @return OH_Input_GetDeviceProduct result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceInfo or product is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDeviceProduct(Input_DeviceInfo *deviceInfo, int32_t *product); + +/** + * @brief Obtains the vendor information of an input device. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @param vendor Pointer to the vendor information of the input device. + * @return OH_Input_GetDeviceVendor result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceInfo or vendor is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDeviceVendor(Input_DeviceInfo *deviceInfo, int32_t *vendor); + +/** + * @brief Obtains the physical address of an input device. + * + * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. + * @param address Pointer to the physical address of the input device. + * @return OH_Input_GetDeviceAddress result code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if deviceInfo or address is a null pointer. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 13 + */ +Input_Result OH_Input_GetDeviceAddress(Input_DeviceInfo *deviceInfo, char **address); #ifdef __cplusplus } #endif diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index cc28eac475c5554d3edf45fa448698accea8275e..0a906be7133067bf80f1d5789d8ace2272d313cd 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -194,5 +194,241 @@ { "first_introduced": "12", "name": "OH_Input_CancelInjection" + }, + { + "first_introduced": "12", + "name": "OH_Input_CreateAxisEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_DestroyAxisEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventType" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventType" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventSourceType" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventSourceType" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddKeyEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddMouseEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddTouchEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddAxisEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddAxisEventMonitorForAll" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveKeyEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveMouseEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveTouchEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveAxisEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveAxisEventMonitorForAll" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddKeyEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddInputEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveKeyEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveInputEventInterceptor" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetIntervalSinceLastInput" + }, + { + "first_introduced": "13", + "name": "OH_Input_CreateAllSystemHotkeys" + }, + { + "first_introduced": "13", + "name": "OH_Input_DestroyAllSystemHotkeys" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetAllSystemHotkeys" + }, + { + "first_introduced": "13", + "name": "OH_Input_CreateHotkey" + }, + { + "first_introduced": "13", + "name": "OH_Input_DestroyHotkey" + }, + { + "first_introduced": "13", + "name": "OH_Input_SetPreKeys" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetPreKeys" + }, + { + "first_introduced": "13", + "name": "OH_Input_SetFinalKey" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetFinalKey" + }, + { + "first_introduced": "13", + "name": "OH_Input_AddHotkeyMonitor" + }, + { + "first_introduced": "13", + "name": "OH_Input_RemoveHotkeyMonitor" + }, + { + "first_introduced": "13", + "name": "OH_Input_SetRepeat" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetRepeat" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDeviceIds" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDevice" + }, + { + "first_introduced": "13", + "name": "OH_Input_CreateDeviceInfo" + }, + { + "first_introduced": "13", + "name": "OH_Input_DestroyDeviceInfo" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetKeyboardType" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDeviceId" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDeviceName" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetCapabilities" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDeviceVersion" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDeviceProduct" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDeviceVendor" + }, + { + "first_introduced": "13", + "name": "OH_Input_GetDeviceAddress" + }, + { + "first_introduced": "13", + "name": "OH_Input_RegisterDeviceListener" + }, + { + "first_introduced": "13", + "name": "OH_Input_UnregisterDeviceListener" + }, + { + "first_introduced": "13", + "name": "OH_Input_UnregisterDeviceListeners" } ] \ No newline at end of file diff --git a/ndk_targets.gni b/ndk_targets.gni new file mode 100644 index 0000000000000000000000000000000000000000..a97312222ece249e3c91d5a1b38a53145dc3d2fb --- /dev/null +++ b/ndk_targets.gni @@ -0,0 +1,330 @@ +# Copyright (c) 2021 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_var.gni") + +# ndk library, ndk header configuration +_ndk_library_targets = [ + "//interface/sdk_c/sensors/miscdevice/vibrator:lib_vibrator_ndk", + "//interface/sdk_c/sensors/miscdevice/vibrator:ndk_vibrator_header", + "//interface/sdk_c/third_party/zlib:libz_ndk", + "//interface/sdk_c/third_party/zlib:zlib_header", + "//interface/sdk_c/global/resource_management:librawfile_ndk", + "//interface/sdk_c/global/resource_management:rawfile_header", + "//interface/sdk_c/global/resource_management:native_resmgr_ndk", + "//interface/sdk_c/global/resource_management:native_resmgr_header", + "//interface/sdk_c/hiviewdfx/hiappevent:libhiappevent_header", + "//interface/sdk_c/hiviewdfx/hiappevent:libhiappevent_ndk", + "//interface/sdk_c/hiviewdfx/hidebug:libohhidebug", + "//interface/sdk_c/hiviewdfx/hidebug:oh_hidebug_header", + "//interface/sdk_c/hiviewdfx/hicollie:libohhicollie", + "//interface/sdk_c/hiviewdfx/hicollie:oh_hicollie_header", + "//interface/sdk_c/hiviewdfx/hilog:hilog_header", + "//interface/sdk_c/hiviewdfx/hilog:libhilog_ndk", + "//interface/sdk_c/hiviewdfx/hitrace:hitrace_header", + "//interface/sdk_c/hiviewdfx/hitrace:libhitrace_ndk", + "//interface/sdk_c/network/netstack/net_websocket:libnet_websocket", + "//interface/sdk_c/network/netstack/net_websocket:websocket_header", + "//interface/sdk_c/network/netssl:libnet_ssl_ndk", + "//interface/sdk_c/network/netssl:net_ssl_header", + "//interface/sdk_c/security/access_token:libability_access_control", + "//interface/sdk_c/security/access_token:accesstoken_header", + "//interface/sdk_c/security/huks:libhuks_ndk", + "//interface/sdk_c/security/huks:huks_header", + "//interface/sdk_c/security/asset:libasset_ndk", + "//interface/sdk_c/security/asset:asset_header", + "//interface/sdk_c/startup/init/syscap:libdeviceinfo_ndk", + "//interface/sdk_c/startup/init/syscap:deviceinfo_header", + "//interface/sdk_c/third_party/mindspore/kits:mindspore_header", + "//interface/sdk_c/third_party/mindspore/kits:mindspore_lib", + "//interface/sdk_c/web/webview/interfaces/native:web_header", + "//interface/sdk_c/web/webview/interfaces/native:libohweb", + "//interface/sdk_c/BasicServicesKit:libos_account_ndk", + "//interface/sdk_c/BasicServicesKit:os_account_ndk_header", + "//interface/sdk_c/ability/ability_runtime/child_process:child_process_header", + "//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/arkui/ace_engine/native:ace_header", + "//interface/sdk_c/arkui/ace_engine/native:arkui_header", + "//interface/sdk_c/arkui/ace_engine/native:libace_ndk", + "//interface/sdk_c/arkui/napi:libnapi_ndk", + "//interface/sdk_c/arkui/napi:napi_header", + "//interface/sdk_c/arkui/window_manager:window_manager_header", + "//interface/sdk_c/arkui/window_manager:native_window_manager", + "//interface/sdk_c/arkui/display_manager:display_manager_header", + "//interface/sdk_c/arkui/display_manager:native_display_manager", + "//interface/sdk_c/ark_runtime/jsvm:libjsvm_ndk", + "//interface/sdk_c/ark_runtime/jsvm:jsvm_header", + "//interface/sdk_c/bundlemanager/bundle_framework/bundle:bundle_header", + "//interface/sdk_c/bundlemanager/bundle_framework/bundle:libbundle_ndk", + "//interface/sdk_c/third_party/node:node_header", + "//interface/sdk_c/graphic/graphic_2d/EGL:libEGL_ndk", + "//interface/sdk_c/graphic/graphic_2d/EGL:EGL_header", + "//interface/sdk_c/graphic/graphic_2d/GLES2:libGLESv2_ndk", + "//interface/sdk_c/graphic/graphic_2d/GLES2:GLES2_header", + "//interface/sdk_c/graphic/graphic_2d/GLES3:libGLESv3_ndk", + "//interface/sdk_c/graphic/graphic_2d/GLES3:GLES3_header", + "//interface/sdk_c/graphic/graphic_2d/KHR:KHR_header", + "//interface/sdk_c/graphic/graphic_2d/native_window:libnative_window_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_window:native_window_header", + "//interface/sdk_c/graphic/graphic_2d/native_buffer:libnative_buffer_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_buffer:native_buffer_header", + "//interface/sdk_c/graphic/graphic_2d/native_image:libnative_image_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_image:native_image_header", + "//interface/sdk_c/graphic/graphic_2d/native_vsync:libnative_vsync_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_vsync:native_vsync_header", + "//interface/sdk_c/graphic/graphic_2d/native_color_space_manager:libnative_color_space_manager_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_color_space_manager:native_color_space_manager_header", + "//interface/sdk_c/graphic/graphic_2d/native_drawing:libnative_drawing_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_drawing:native_drawing_header", + "//interface/sdk_c/graphic/graphic_2d/native_effect:libnative_effect_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_effect:native_effect_header", + "//interface/sdk_c/IPCKit:libipc_capi", + "//interface/sdk_c/IPCKit:ipc_capi_header", + "//interface/sdk_c/LocationKit:liblocation_ndk", + "//interface/sdk_c/LocationKit:location_ndk_header", + "//interface/sdk_c/NotificationKit:libnotification_ndk", + "//interface/sdk_c/NotificationKit:ohnotification_header", + "//interface/sdk_c/ConnectivityKit/bluetooth:libbluetooth_ndk", + "//interface/sdk_c/ConnectivityKit/bluetooth:bluetooth_ndk_header", + "//interface/sdk_c/third_party/libuv:libuv_ndk", + "//interface/sdk_c/third_party/libuv:libuv_header", + "//interface/sdk_c/third_party/libuv:libuv_uv_header", + "//interface/sdk_c/third_party/icu4c:libicu_ndk", + "//interface/sdk_c/third_party/icu4c:icu_unicode_header", + "//interface/sdk_c/multimedia/av_codec/audio_decoder:libnative_media_adec", + "//interface/sdk_c/multimedia/av_codec/audio_decoder:native_media_adec_header", + "//interface/sdk_c/multimedia/av_codec/audio_encoder:libnative_media_aenc", + "//interface/sdk_c/multimedia/av_codec/audio_encoder:native_media_aenc_header", + "//interface/sdk_c/multimedia/av_codec/audio_codec:libnative_media_acodec", + "//interface/sdk_c/multimedia/av_codec/audio_codec:native_media_acodec_header", + "//interface/sdk_c/multimedia/av_codec/video_decoder:libnative_media_vdec", + "//interface/sdk_c/multimedia/av_codec/video_decoder:native_media_vdec_header", + "//interface/sdk_c/multimedia/av_codec/video_encoder:libnative_media_venc", + "//interface/sdk_c/multimedia/av_codec/video_encoder:native_media_venc_header", + "//interface/sdk_c/multimedia/av_codec/codec_base:libnative_media_codecbase", + "//interface/sdk_c/multimedia/av_codec/codec_base:native_media_codecbase_header", + "//interface/sdk_c/multimedia/av_codec/avmuxer:libnative_media_avmuxer", + "//interface/sdk_c/multimedia/av_codec/avmuxer:native_media_avmuxer_header", + "//interface/sdk_c/multimedia/av_codec/avdemuxer:libnative_media_avdemuxer", + "//interface/sdk_c/multimedia/av_codec/avdemuxer:native_media_avdemuxer_header", + "//interface/sdk_c/multimedia/av_codec/avsource:libnative_media_avsource", + "//interface/sdk_c/multimedia/av_codec/avsource:native_media_avsource_header", + "//interface/sdk_c/multimedia/av_codec/avcencinfo:libnative_media_avcencinfo", + "//interface/sdk_c/multimedia/av_codec/avcencinfo:native_media_avcencinfo_header", + "//interface/sdk_c/multimedia/drm_framework:libnative_drm", + "//interface/sdk_c/multimedia/drm_framework:native_drm_header", + "//interface/sdk_c/multimedia/media_foundation/core:native_media_core_header", + "//interface/sdk_c/multimedia/media_foundation/core:native_media_core_common_header", + "//interface/sdk_c/multimedia/media_foundation/core:libnative_media_core", + "//interface/sdk_c/multimedia/media_library/media_asset_manager:libmedia_asset_manager", + "//interface/sdk_c/multimedia/media_library/media_asset_manager:media_asset_manager_header", + "//interface/sdk_c/multimedia/player_framework/avscreen_capture:libnative_avscreen_capture", + "//interface/sdk_c/multimedia/player_framework/avscreen_capture:native_avscreen_capture_header", + "//interface/sdk_c/multimedia/player_framework/avplayer:libavplayer", + "//interface/sdk_c/multimedia/player_framework/avplayer:avplayer_header", + "//interface/sdk_c/multimedia/audio_framework:libohaudio_ndk", + "//interface/sdk_c/multimedia/audio_framework:ohaudio_header", + "//interface/sdk_c/multimedia/av_session:libohavsession_ndk", + "//interface/sdk_c/multimedia/av_session:ohavsession_header", + "//interface/sdk_c/multimedia/camera_framework:libohcamera", + "//interface/sdk_c/multimedia/camera_framework:camera_ndk_header", + "//interface/sdk_c/multimedia/image_framework:libpixelmap_ndk", + "//interface/sdk_c/multimedia/image_framework:libpixelmap", + "//interface/sdk_c/multimedia/image_framework:libpixelmap_header", + "//interface/sdk_c/multimedia/image_framework:image_header", + "//interface/sdk_c/multimedia/image_framework:libimage_ndk", + "//interface/sdk_c/multimedia/image_framework:image_ndk_header", + "//interface/sdk_c/multimedia/image_framework:libimage_receiver_ndk", + "//interface/sdk_c/multimedia/image_framework:image_receiver_ndk_header", + "//interface/sdk_c/multimedia/image_framework:libimage_source_ndk", + "//interface/sdk_c/multimedia/image_framework:image_source_ndk_header", + "//interface/sdk_c/multimedia/image_framework:libimage_source", + "//interface/sdk_c/multimedia/image_framework:libimage_source_header", + "//interface/sdk_c/multimedia/image_framework:libimage_packer_ndk", + "//interface/sdk_c/multimedia/image_framework:image_packer_ndk_header", + "//interface/sdk_c/multimedia/image_framework:libimage_packer", + "//interface/sdk_c/multimedia/image_framework:libimage_packer_header", + "//interface/sdk_c/multimedia/image_framework:libpicture", + "//interface/sdk_c/multimedia/image_framework:libpicture_header", + "//interface/sdk_c/multimedia/image_framework:libimage_common", + "//interface/sdk_c/multimedia/image_framework:libimage_common_header", + "//interface/sdk_c/multimedia/image_effect:libimage_effect", + "//interface/sdk_c/multimedia/image_effect:libimage_effect_header", + "//interface/sdk_c/multimedia/video_processing_engine/video_processing:libvideo_processing_ndk", + "//interface/sdk_c/multimedia/video_processing_engine/video_processing:video_processing_ndk_headers", + "//interface/sdk_c/multimedia/video_processing_engine/image_processing:libimage_processing_ndk", + "//interface/sdk_c/multimedia/video_processing_engine/image_processing:image_processing_ndk_headers", + "//interface/sdk_c/third_party/openSLES:sles_header", + "//interface/sdk_c/third_party/openSLES:libOpenSLES_ndk", + "//interface/sdk_c/ai/neural_network_runtime:libneural_network_core_ndk", + "//interface/sdk_c/ai/neural_network_runtime:libneural_network_runtime_ndk", + "//interface/sdk_c/ai/neural_network_runtime:libneural_network_runtime_header", + "//interface/sdk_c/commonlibrary/memory_utils/libpurgeablemem:libpurgeable_memory_ndk", + "//interface/sdk_c/commonlibrary/memory_utils/libpurgeablemem:purgeable_memory_header", + "//interface/sdk_c/distributeddatamgr/relational_store:data_ndk_header", + "//interface/sdk_c/distributeddatamgr/relational_store:native_rdb_ndk_header", + "//interface/sdk_c/distributeddatamgr/relational_store:libnative_rdb_ndk", + "//interface/sdk_c/distributeddatamgr/udmf:libudmf", + "//interface/sdk_c/distributeddatamgr/udmf:udmf_ndk_header", + "//interface/sdk_c/distributeddatamgr/pasteboard:libpasteboard", + "//interface/sdk_c/distributeddatamgr/pasteboard:pasteboard_ndk_header", + "//interface/sdk_c/distributeddatamgr/preferences:preferences_ndk_header", + "//interface/sdk_c/distributeddatamgr/preferences:libohpreferences", + "//interface/sdk_c/drivers/external_device_manager/usb:libusb_ndk", + "//interface/sdk_c/drivers/external_device_manager/usb:usb_header", + "//interface/sdk_c/drivers/external_device_manager/hid:libhid", + "//interface/sdk_c/drivers/external_device_manager/hid:hid_header", + "//interface/sdk_c/drivers/external_device_manager/base:libddk_base", + "//interface/sdk_c/drivers/external_device_manager/base:ddk_header", + "//interface/sdk_c/graphic/graphic_2d/vulkan:libvulkan_ndk", + "//interface/sdk_c/graphic/graphic_2d/vulkan:vulkan_header", + "//interface/sdk_c/graphic/graphic_2d/vulkan:vulkan_header_vk_video", + "//interface/sdk_c/resourceschedule/ffrt:libffrt_ndk", + "//interface/sdk_c/resourceschedule/ffrt:ffrt_header", + "//interface/sdk_c/network/netmanager:libnet_connection", + "//interface/sdk_c/network/netmanager:netconn_header", + "//interface/sdk_c/sensors/sensor:libsensor_ndk", + "//interface/sdk_c/sensors/sensor:sensor_ndk_header", + "//interface/sdk_c/resourceschedule/qos_manager:libqos_ndk", + "//interface/sdk_c/resourceschedule/qos_manager:qos_header", + "//interface/sdk_c/filemanagement/fileio:libohfileio", + "//interface/sdk_c/filemanagement/fileio:oh_fileio_header", + "//interface/sdk_c/filemanagement/environment:libohenvironment", + "//interface/sdk_c/filemanagement/environment:oh_environment_header", + "//interface/sdk_c/filemanagement/file_uri:libohfileuri", + "//interface/sdk_c/filemanagement/file_uri:oh_file_uri_header", + "//interface/sdk_c/filemanagement/fileshare:libohfileshare", + "//interface/sdk_c/filemanagement/fileshare:oh_file_share_header", + "//interface/sdk_c/multimodalinput/kits/c:libohinput_ndk", + "//interface/sdk_c/multimodalinput/kits/c:ohinput_header", + "//interface/sdk_c/BasicServicesKit:libohprint_ndk", + "//interface/sdk_c/BasicServicesKit:ohprint_header", + "//interface/sdk_c/multimedia/image_framework:libohimage", + "//interface/sdk_c/multimedia/image_framework:ohimage_header", + "//interface/sdk_c/multimedia/image_framework:libimage_receiver", + "//interface/sdk_c/multimedia/image_framework:image_receiver_header", + "//interface/sdk_c/graphic/graphic_2d/native_display_soloist:libnative_display_soloist_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_display_soloist:native_display_soloist_header", + "//interface/sdk_c/third_party/musl/ndk_script:copy_compatible_config", + "//interface/sdk_c/CryptoArchitectureKit:libohcrypto", + "//interface/sdk_c/CryptoArchitectureKit:crypto_capi_header", + "//interface/sdk_c/BasicServicesKit:libohscan_ndk", + "//interface/sdk_c/BasicServicesKit:ohscan_header", + "//interface/sdk_c/BasicServicesKit:libtime_service_ndk", + "//interface/sdk_c/BasicServicesKit:time_service_ndk_header", + "//interface/sdk_c/BasicServicesKit:libcommonevent_ndk", + "//interface/sdk_c/BasicServicesKit:ohcommonevent_header", + "//interface/sdk_c/DataProtectionKit:libohdlp_permission", + "//interface/sdk_c/DataProtectionKit:dlppermission_capi_header", + "//interface/sdk_c/inputmethod:libohinputmethod", + "//interface/sdk_c/inputmethod:libohinputmethod_header", + "//interface/sdk_c/backgroundtasks/transient:libtransient_task_ndk", + "//interface/sdk_c/backgroundtasks/transient:transient_task_header", + "//interface/sdk_c/BasicServicesKit:ohbattery_info_header", + "//interface/sdk_c/BasicServicesKit:libohbattery_info_ndk", + "//interface/sdk_c/telephony/cellular_data:libtelephony_data", + "//interface/sdk_c/telephony/cellular_data:telephony_data_header", + "//interface/sdk_c/telephony/core_service:libtelephony_radio", + "//interface/sdk_c/telephony/core_service:telephony_radio_header", + "//interface/sdk_c/ConnectivityKit/wifi:libwifi_ndk", + "//interface/sdk_c/ConnectivityKit/wifi:wifi_ndk_header", +] + +_ndk_base_libs = [ + "//interface/sdk_c/third_party/musl/ndk_script/adapter:libc_ndk", + "//interface/sdk_c/third_party/musl/ndk_script:musl_ndk_libs_arm32", + "//interface/sdk_c/third_party/musl/ndk_script:musl_ndk_libs_aarch64", + "//interface/sdk_c/third_party/musl/ndk_script:musl_ndk_libs_x86_64", + "//interface/sdk_c/third_party/musl/ndk_script:ndk_toolchain", +] +_ndk_sysroot_uapi = + [ "//interface/sdk_c/third_party/musl/ndk_script:musl_sysroot" ] + +_ndk_cmake = [ + "//prebuilts/cmake/darwin-universal:darwin_cmake_copy", + "//prebuilts/cmake/linux-x86:linux_cmake_copy", + "//prebuilts/cmake/windows-x86:windows_cmake_copy", + "//prebuilts/cmake/ohos:ohos_cmake_copy", + "//build/ohos/ndk:ndk_cmake_files", +] + +if (host_os == "mac") { + _ndk_cmake += [ "//build/ohos/ndk:copy_darwin_ohos_cmake" ] +} else { + _ndk_cmake += [ + "//build/ohos/ndk:copy_linux_ohos_cmake", + "//build/ohos/ndk:copy_windows_ohos_cmake", + "//build/ohos/ndk:copy_ohos_ohos_cmake", + ] +} + +_ndk_ninja = [] +if (host_os == "mac") { + _ndk_ninja += [ "//prebuilts/build-tools/darwin-x86/bin:darwin_ninja_copy" ] +} else { + _ndk_ninja += [ + "//prebuilts/build-tools/linux-x86/bin:linux_ninja_copy", + "//prebuilts/build-tools/windows-x86/bin:windows_ninja_copy", + "//prebuilts/build-tools/ohos/bin:ohos_ninja_copy", + ] +} + +_ndk_targets_list = _ndk_library_targets + _ndk_base_libs + _ndk_sysroot_uapi + + _ndk_cmake + _ndk_ninja + +_parse_script = "//build/ohos/ndk/parse_ndk_targets.py" +_parse_args = [ + "--source-root-dir", + rebase_path("//", root_build_dir), + "--ndk-lib-target-list", +] +_parse_args += _ndk_targets_list + +all_ndk_targets_list = exec_script(_parse_script, _parse_args, "list lines") + +if (ndk_platform == "win") { + all_ndk_targets_list += + [ "//interface/sdk_c/third_party/musl/ndk_script:windows_x86_64" ] +} else if (ndk_platform == "mac") { + if (host_cpu == "arm64") { + all_ndk_targets_list += + [ "//interface/sdk_c/third_party/musl/ndk_script:darwin_arm64" ] + } else { + all_ndk_targets_list += + [ "//interface/sdk_c/third_party/musl/ndk_script:darwin_x86_64" ] + } +} else if (ndk_platform == "linux") { + all_ndk_targets_list += + [ "//interface/sdk_c/third_party/musl/ndk_script:linux_x86_64" ] +} else if (ndk_platform == "ohos") { + all_ndk_targets_list += + [ "//interface/sdk_c/third_party/musl/ndk_script:ohos_arm64" ] +} else if (ndk_platform == "default") { + if (host_os == "mac") { + if (host_cpu == "arm64") { + all_ndk_targets_list += + [ "//interface/sdk_c/third_party/musl/ndk_script:darwin_arm64" ] + } else { + all_ndk_targets_list += + [ "//interface/sdk_c/third_party/musl/ndk_script:darwin_x86_64" ] + } + } else { + all_ndk_targets_list += [ + "//interface/sdk_c/third_party/musl/ndk_script:windows_x86_64", + "//interface/sdk_c/third_party/musl/ndk_script:linux_x86_64", + "//interface/sdk_c/third_party/musl/ndk_script:ohos_arm64", + ] + } +} diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 9446b979f44c3da41f68a5eb0c59c5b987adbed6..6c5c4c2f2bfa8794d61ce12f8b8cdb56fadfb37d 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -186,6 +186,8 @@ int32_t OH_NetConn_GetAllNets(NetConn_NetHandleList *netHandleList); * 2100003 - Internal error. * @permission ohos.permission.INTERNET * @syscap SystemCapability.Communication.NetManager.Core + * @deprecated since 13 + * @useinstead OH_NetConn_RegisterDnsResolver * @since 11 * @version 1.0 */ @@ -199,11 +201,41 @@ int32_t OHOS_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver); * 2100003 - Internal error. * @permission ohos.permission.INTERNET * @syscap SystemCapability.Communication.NetManager.Core + * @deprecated since 13 + * @useinstead OH_NetConn_UnregisterDnsResolver * @since 11 * @version 1.0 */ int32_t OHOS_NetConn_UnregisterDnsResolver(void); +/** + * @brief Registers a custom DNS resolver. + * + * @param resolver Pointer to the custom DNS resolver. + * @return Returns the result code. + * {@link NETMANAGER_EXT_SUCCESS} if the operation is successful. + * {@link NETMANAGER_ERR_PERMISSION_DENIED} Missing permissions, add permission. + * {@link NETMANAGER_ERR_PARAMETER_ERROR} Parameter error. Please enter a correct parameter. + * @permission ohos.permission.INTERNET + * @syscap SystemCapability.Communication.NetManager.Core + * @since 13 + * @version 1.0 + */ +int32_t OH_NetConn_RegisterDnsResolver(OH_NetConn_CustomDnsResolver resolver); + +/** + * @brief Unregisters a custom DNS resolver. + * + * @return 0 - Success. 201 - Missing permissions. + * 401 - Parameter error. 2100002 - Unable to connect to service. + * 2100003 - Internal error. + * @permission ohos.permission.INTERNET + * @syscap SystemCapability.Communication.NetManager.Core + * @since 13 + * @version 1.0 + */ +int32_t OH_NetConn_UnregisterDnsResolver(void); + /** * @brief Binds a socket to the specific network. * @@ -219,6 +251,99 @@ int32_t OHOS_NetConn_UnregisterDnsResolver(void); */ int32_t OH_NetConn_BindSocket(int32_t socketFd, NetConn_NetHandle *netHandle); +/** + * @brief Sets http proxy information to current application. + * + * @param httpProxy Information about the proxy that needs to be set. + * @return 0 - Success. + * 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 12 + * @version 1.0 + */ +int32_t OH_NetConn_SetAppHttpProxy(NetConn_HttpProxy *httpProxy); + +/** + * @brief Registers callback to listen for changes to the application-level http proxy. + * + * @param appHttpProxyChange Callback that need to be registered to listen for changes to the http proxy. + * @param callbackId Callback id returned after registration, associated with a registered callback. + * @return 0 - Success. + * 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 12 + * @version 1.0 + */ +int32_t OH_NetConn_RegisterAppHttpProxyCallback(OH_NetConn_AppHttpProxyChange appHttpProxyChange, uint32_t *callbackId); + +/** + * @brief Unregisters a callback function that listens for application-level proxy changes. + * + * @param callbackId Id of the callback function that needs to be deregistered. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 12 + * @version 1.0 + */ +void OH_NetConn_UnregisterAppHttpProxyCallback(uint32_t callbackId); + +/** + * @brief Registers callback, used to monitor specific network status. + * + * @param netSpecifier specifier information. + * @param callback The callback needed to be registered. + * @param timeout The timeout period in milliseconds. + * @param callbackId out param, corresponding to a registered callback. + * @return 0 - Success. + * 201 - Permission denied. + * 401 - Parameter error. + * 2100002 - Failed to connect to the service. + * 2100003 - System internal error. + * 2101008 - The callback already exists. + * 2101022 - The number of requests exceeded the maximum allowed. + * @permission ohos.permission.GET_NETWORK_INFO + * @syscap SystemCapability.Communication.NetManager.Core + * @since 12 + * @version 1.0 + */ +int32_t OH_NetConn_RegisterNetConnCallback(NetConn_NetSpecifier *specifier, NetConn_NetConnCallback *netConnCallback, + uint32_t timeout, uint32_t *callbackId); + +/** + * @brief Registers a callback to listen default network's status changed. + * + * @param callback The callback needed to be registered. + * @param callbackId out param, corresponding to a registered callback. + * @return 0 - Success. + * 201 - Permission denied. + * 401 - Parameter error. + * 2100002 - Failed to connect to the service. + * 2100003 - System internal error. + * 2101008 - The callback already exists. + * 2101022 - The number of requests exceeded the maximum allowed. + * @permission ohos.permission.GET_NETWORK_INFO + * @syscap SystemCapability.Communication.NetManager.Core + * @since 12 + * @version 1.0 + */ +int32_t OH_NetConn_RegisterDefaultNetConnCallback(NetConn_NetConnCallback *netConnCallback, uint32_t *callbackId); + +/** + * @brief Unregisters network status callback. + * + * @param callBackId the id corresponding to a registered callback. + * @return 0 - Success. + * 201 - Permission denied. + * 401 - Parameter error. + * 2100002 - Failed to connect to the service. + * 2100003 - System internal error. + * 2101007 - The callback does not exists. + * @permission ohos.permission.GET_NETWORK_INFO + * @syscap SystemCapability.Communication.NetManager.Core + * @since 12 + * @version 1.0 + */ +int32_t OH_NetConn_UnregisterNetConnCallback(uint32_t callBackId); + #ifdef __cplusplus } #endif diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index 1698a65934337983703a44216501d0af4ea5ed42..40e80760b13c8cc854164fda6c5eb77d5bc986bb 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -38,7 +38,9 @@ * */ +#include #include +#include #ifdef __cplusplus extern "C" { @@ -69,6 +71,16 @@ typedef enum NetConn_NetCap { NETCONN_NET_CAPABILITY_NOT_VPN = 15, /** Validated */ NETCONN_NET_CAPABILITY_VALIDATED = 16, + /** + * Portal + * @since 12 + */ + NETCONN_NET_CAPABILITY_PORTAL = 17, + /** + * In checking network connectivity. + * @since 12 + */ + NETCONN_NET_CAPABILITY_CHECKING_CONNECTIVITY = 31 } NetConn_NetCap; /** @@ -82,6 +94,11 @@ typedef enum NetConn_NetBearerType { NETCONN_BEARER_CELLULAR = 0, /** WIFI */ NETCONN_BEARER_WIFI = 1, + /** + * Bluetooth + * @since 12 + */ + NETCONN_BEARER_BLUETOOTH = 2, /** Ethernet */ NETCONN_BEARER_ETHERNET = 3, /** @@ -233,6 +250,114 @@ typedef struct NetConn_NetHandleList { */ typedef int (*OH_NetConn_CustomDnsResolver)(const char *host, const char *serv, const struct addrinfo *hint, struct addrinfo **res); + +/** + * @brief Callback for application’s http proxy information changed. + * + * @param proxy The changed proxy information, may be a null pointer. + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NetConn_AppHttpProxyChange)(NetConn_HttpProxy *proxy); + +/** + * @brief Definition of network specifier. + * + * @since 12 + * @version 1.0 + */ +typedef struct NetConn_NetSpecifier { + /** Network capabilities. */ + NetConn_NetCapabilities caps; + /** Network identifier */ + char *bearerPrivateIdentifier; +} NetConn_NetSpecifier; + +/** + * @brief Callback for network available. + * + * @param netHandle The network handle. + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NetConn_NetworkAvailable)(NetConn_NetHandle *netHandle); + +/** + * @brief Callback for network capabilities changed. + * + * @param netHandle The network handle. + * @param netCapabilities The network capabilities. + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NetConn_NetCapabilitiesChange)(NetConn_NetHandle *netHandle, + NetConn_NetCapabilities *netCapabilities); + +/** + * @brief Callback for network connection properties changed. + * + * @param netHandle The network handle. + * @param connConnetionProperties The network connection properties. + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NetConn_NetConnectionPropertiesChange)(NetConn_NetHandle *netHandle, + NetConn_ConnectionProperties *connConnetionProperties); + +/** + * @brief Callback for network lost. + * + * @param netHandle The network handle. + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NetConn_NetLost)(NetConn_NetHandle *netHandle); + +/** + * @brief Callback for network unavailable, this function invoked while network can not be available in given timeout. + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NetConn_NetUnavailable)(void); + +/** + * @brief Callback for network blocked status changed. + * + * @param netHandle The network handle. + * @param blocked The flag used to indicate whether the network will be blocked. + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NetConn_NetBlockStatusChange)(NetConn_NetHandle *netHandle, bool blocked); + +/** + * @brief Defines the network connection callbacks. + * + * @since 12 + * @version 1.0 + */ +typedef struct NetConn_NetConnCallback { + /** Callback for network available */ + OH_NetConn_NetworkAvailable onNetworkAvailable; + /** Callback for network capabilities changed */ + OH_NetConn_NetCapabilitiesChange onNetCapabilitiesChange; + /** Callback for network connection properties changed */ + OH_NetConn_NetConnectionPropertiesChange onConnetionProperties; + /** Callback for network lost */ + OH_NetConn_NetLost onNetLost; + /** Callback for network unavailable, this function invoked while network can not be available in given timeout */ + OH_NetConn_NetUnavailable onNetUnavailable; + /** Callback for network blocked status changed */ + OH_NetConn_NetBlockStatusChange onNetBlockStatusChange; +} NetConn_NetConnCallback; + #ifdef __cplusplus } #endif diff --git a/network/netmanager/libnet_connection.ndk.json b/network/netmanager/libnet_connection.ndk.json index 67993dd381e6caddb618dfaad2cde7b7ba825eab..41b98af11fb5730577e33c5e9bc82573a221fe26 100644 --- a/network/netmanager/libnet_connection.ndk.json +++ b/network/netmanager/libnet_connection.ndk.json @@ -46,5 +46,37 @@ { "first_introduced": "12", "name": "OH_NetConn_BindSocket" + }, + { + "first_introduced": "12", + "name": "OH_NetConn_SetAppHttpProxy" + }, + { + "first_introduced": "12", + "name": "OH_NetConn_RegisterAppHttpProxyCallback" + }, + { + "first_introduced": "12", + "name": "OH_NetConn_UnregisterAppHttpProxyCallback" + }, + { + "first_introduced": "12", + "name": "OH_NetConn_RegisterNetConnCallback" + }, + { + "first_introduced": "12", + "name": "OH_NetConn_RegisterDefaultNetConnCallback" + }, + { + "first_introduced": "12", + "name": "OH_NetConn_UnregisterNetConnCallback" + }, + { + "first_introduced": "13", + "name": "OH_NetConn_RegisterDnsResolver" + }, + { + "first_introduced": "13", + "name": "OH_NetConn_UnregisterDnsResolver" } -] +] \ No newline at end of file diff --git a/network/netssl/include/net_ssl_c.h b/network/netssl/include/net_ssl_c.h index 43c46ca6caf87fcd9239c2b19a7120f3c64894e5..779ccab79a6402acf5377a9a29ce5ec2715b6b5e 100644 --- a/network/netssl/include/net_ssl_c.h +++ b/network/netssl/include/net_ssl_c.h @@ -70,6 +70,45 @@ extern "C" { * @version 1.0 */ uint32_t OH_NetStack_CertVerification(const struct NetStack_CertBlob *cert, const struct NetStack_CertBlob *caCert); + +/** + * @brief Gets pin set for hostname. + * + * @param hostname Hostname. + * @param pin Certificate lock information. + * @return 0 - Success. + * 401 - Parameter error. + * 2305999 - Out of memory. + * @syscap SystemCapability.Communication.NetStack + * @since 12 + * @version 1.0 + */ +int32_t OH_NetStack_GetPinSetForHostName(const char *hostname, NetStack_CertificatePinning *pin); + +/** + * @brief Gets certificates for hostname. + * + * @param hostname Hostname. + * @param certs Certificate Information. + * @return 0 - Success. + * 401 - Parameter error. + * 2305999 - Out of memory. + * @syscap SystemCapability.Communication.NetStack + * @since 12 + * @version 1.0 + */ +int32_t OH_NetStack_GetCertificatesForHostName(const char *hostname, NetStack_Certificates *certs); + +/** + * @brief Frees content of the certificates. + * + * @param certs Certificate. + * @syscap SystemCapability.Communication.NetStack + * @since 12 + * @version 1.0 + */ +void OH_Netstack_DestroyCertificatesContent(NetStack_Certificates *certs); + #ifdef __cplusplus } #endif diff --git a/network/netssl/include/net_ssl_c_type.h b/network/netssl/include/net_ssl_c_type.h index 2241bb54a6d0346be62fbc2d96f17d2990674d3c..c7096a558ae3f101144d730b530a7975b4cf89d6 100644 --- a/network/netssl/include/net_ssl_c_type.h +++ b/network/netssl/include/net_ssl_c_type.h @@ -38,6 +38,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -73,6 +74,58 @@ struct NetStack_CertBlob { uint8_t *data; }; +/** + * @brief Defines the certificate lock type. + * + * @since 12 + * @version 1.0 + */ +typedef enum NetStack_CertificatePinningKind { + /** Public key pinning */ + PUBLIC_KEY, +} NetStack_CertificatePinningKind; + +/** + * @brief Defines the hash algorithm. + * + * @since 12 + * @version 1.0 + */ +typedef enum NetStack_HashAlgorithm { + /** Sha256 */ + SHA_256, +} NetStack_HashAlgorithm; + +/** + * @brief Defines the certificate lock information. + * + * @since 12 + * @version 1.0 + */ +typedef struct NetStack_CertificatePinning { + /** Certificate lock type */ + NetStack_CertificatePinningKind kind; + /** Hash algorithm */ + NetStack_HashAlgorithm hashAlgorithm; + /** Hash value */ + union { + char *publicKeyHash; + }; +} NetStack_CertificatePinning; + +/** + * @brief Defines the certificate information. + * + * @since 12 + * @version 1.0 + */ +typedef struct NetStack_Certificates { + /** PEM content of the certificates */ + char **content; + /** Number of certificates */ + size_t length; +} NetStack_Certificates; + #ifdef __cplusplus } #endif diff --git a/network/netssl/libnet_ssl_c.json b/network/netssl/libnet_ssl_c.json index bd17ed3fb5ac03b7ce75322b8f4aed5f3c1b2118..af49f5a35b1957fe244000d6d3ff788a4befdeff 100644 --- a/network/netssl/libnet_ssl_c.json +++ b/network/netssl/libnet_ssl_c.json @@ -2,5 +2,17 @@ { "first_introduced":"11", "name": "OH_NetStack_CertVerification" + }, + { + "first_introduced":"12", + "name": "OH_NetStack_GetPinSetForHostName" + }, + { + "first_introduced":"12", + "name": "OH_NetStack_GetCertificatesForHostName" + }, + { + "first_introduced":"12", + "name": "OH_Netstack_DestroyCertificatesContent" } ] diff --git a/resourceschedule/ffrt/c/loop.h b/resourceschedule/ffrt/c/loop.h index 2d4e72c78fc5a8224ac9956c5ec1b7b89fdf12e5..95d6a8befa494d9a1cb37659a0e85c5c282c03bc 100644 --- a/resourceschedule/ffrt/c/loop.h +++ b/resourceschedule/ffrt/c/loop.h @@ -41,6 +41,11 @@ #include "queue.h" #include "type_def.h" +/** + * @brief Defines the ffrt loop type. + * + * @since 12 + */ typedef void* ffrt_loop_t; /** diff --git a/resourceschedule/ffrt/c/mutex.h b/resourceschedule/ffrt/c/mutex.h index eb76379baf101d681adbf4602e586e3d0da49b52..1c397cdd31c02da8d4e853301faf87d4fac61a83 100644 --- a/resourceschedule/ffrt/c/mutex.h +++ b/resourceschedule/ffrt/c/mutex.h @@ -39,6 +39,53 @@ #define FFRT_API_C_MUTEX_H #include "type_def.h" +/** + * @brief Initializes mutex attr. + * + * @param mutex Indicates a pointer to the mutex. + * @param attr Indicates a pointer to the mutex attribute. + * @return {@link ffrt_success} 0 - success + * {@link ffrt_error_inval} 22 - if attr is null. + * @since 12 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutexattr_init(ffrt_mutexattr_t* attr); + +/** + * @brief set mutex type. + * + * @param attr Indicates a pointer to the mutex attribute. + * @param type Indicates a int to the mutex type. + * @return {@link ffrt_success} 0 - success. + * {@link ffrt_error_inval} 22 - if attr is null or type is not 0 or 2. + * @since 12 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutexattr_settype(ffrt_mutexattr_t* attr, int type); + +/** + * @brief get mutex type. + * + * @param attr Indicates a pointer to the mutex attribute. + * @param type Indicates a pointer to the mutex type. + * @return {@link ffrt_success} 0 - success. + * {@link ffrt_error_inval} 22 - if attr is null or type is null. + * @since 12 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutexattr_gettype(ffrt_mutexattr_t* attr, int* type); + +/** + * @brief destroy mutex attr, the user needs to invoke this interface. + * + * @param attr Indicates a pointer to the mutex attribute. + * @return {@link ffrt_success} 0 - success. + * {@link ffrt_error_inval} 22 - if attr is null. + * @since 12 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutexattr_destroy(ffrt_mutexattr_t* attr); + /** * @brief Initializes a mutex. * diff --git a/resourceschedule/ffrt/c/task.h b/resourceschedule/ffrt/c/task.h index 066493f9e5037cbdcd107bcac908814e290def55..b789fdc74ddf5d5bbea7b4770eb6aa022f49e939 100644 --- a/resourceschedule/ffrt/c/task.h +++ b/resourceschedule/ffrt/c/task.h @@ -141,6 +141,26 @@ FFRT_C_API void ffrt_task_attr_set_queue_priority(ffrt_task_attr_t* attr, ffrt_q */ FFRT_C_API ffrt_queue_priority_t ffrt_task_attr_get_queue_priority(const ffrt_task_attr_t* attr); +/** + * @brief Sets the task stack size. + * + * @param attr Indicates a pointer to the task attribute. + * @param size Indicates the task stack size, unit is byte. + * @since 12 + * @version 1.0 + */ +FFRT_C_API void ffrt_task_attr_set_stack_size(ffrt_task_attr_t* attr, uint64_t size); + +/** + * @brief Obtains the task stack size. + * + * @param attr Indicates a pointer to the task attribute. + * @return Returns the task stack size, unit is byte. + * @since 12 + * @version 1.0 + */ +FFRT_C_API uint64_t ffrt_task_attr_get_stack_size(const ffrt_task_attr_t* attr); + /** * @brief Updates the QoS of this task. * @@ -209,6 +229,26 @@ FFRT_C_API void ffrt_submit_base(ffrt_function_header_t* f, const ffrt_deps_t* i FFRT_C_API ffrt_task_handle_t ffrt_submit_h_base(ffrt_function_header_t* f, const ffrt_deps_t* in_deps, const ffrt_deps_t* out_deps, const ffrt_task_attr_t* attr); +/** + * @brief increase reference count of task handle. + * + * @param handle Indicates a task handle. + * @return return the task handle original reference count. + * @since 12 + * @version 1.0 + */ +FFRT_C_API uint32_t ffrt_task_handle_inc_ref(ffrt_task_handle_t handle); + +/** + * @brief decrease reference count of task handle. + * + * @param handle Indicates a task handle. + * @return return the task handle original reference count. + * @since 12 + * @version 1.0 + */ +FFRT_C_API uint32_t ffrt_task_handle_dec_ref(ffrt_task_handle_t handle); + /** * @brief Destroys a task handle. * diff --git a/resourceschedule/ffrt/c/type_def.h b/resourceschedule/ffrt/c/type_def.h index c929b5ff9456222e0c550c90e7b5c518cdc9f41b..8d9f7c1abd02874a24720f933c86e47d4306251d 100644 --- a/resourceschedule/ffrt/c/type_def.h +++ b/resourceschedule/ffrt/c/type_def.h @@ -183,6 +183,23 @@ typedef struct { long storage; } ffrt_mutexattr_t; +/** + * @brief ffrt mutex type enum + * + * Describes the mutex type, ffrt_mutex_normal is normal mutex; + * ffrt_mutex_recursive is recursive mutex, ffrt_mutex_default is normal mutex. + * + * @since 12 + */ +typedef enum { + /** ffrt normal mutex type */ + ffrt_mutex_normal = 0, + /** ffrt recursive mutex type */ + ffrt_mutex_recursive = 2, + /** ffrt default mutex type */ + ffrt_mutex_default = ffrt_mutex_normal +} ffrt_mutex_type; + typedef struct { uint32_t storage[(ffrt_mutex_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; } ffrt_mutex_t; diff --git a/resourceschedule/ffrt/ffrt.ndk.json b/resourceschedule/ffrt/ffrt.ndk.json index 0c83414e04d1376626c3c10e964ed79abad22e73..e0e760ce774511ebb8f48602912019c3672e5e9b 100644 --- a/resourceschedule/ffrt/ffrt.ndk.json +++ b/resourceschedule/ffrt/ffrt.ndk.json @@ -5,6 +5,22 @@ { "name": "ffrt_cond_wait" }, { "name": "ffrt_cond_timedwait" }, { "name": "ffrt_cond_destroy" }, + { + "first_introduced": "12", + "name": "ffrt_mutexattr_init" + }, + { + "first_introduced": "12", + "name": "ffrt_mutexattr_settype" + }, + { + "first_introduced": "12", + "name": "ffrt_mutexattr_gettype" + }, + { + "first_introduced": "12", + "name": "ffrt_mutexattr_destroy" + }, { "name": "ffrt_mutex_init" }, { "name": "ffrt_mutex_lock" }, { "name": "ffrt_mutex_unlock" }, @@ -34,11 +50,27 @@ { "name": "ffrt_task_attr_get_qos" }, { "name": "ffrt_task_attr_set_delay" }, { "name": "ffrt_task_attr_get_delay" }, + { + "first_introduced": "12", + "name": "ffrt_task_attr_set_stack_size" + }, + { + "first_introduced": "12", + "name": "ffrt_task_attr_get_stack_size" + }, { "name": "ffrt_this_task_update_qos" }, { "name": "ffrt_this_task_get_id" }, { "name": "ffrt_alloc_auto_managed_function_storage_base" }, { "name": "ffrt_submit_base" }, { "name": "ffrt_submit_h_base" }, + { + "first_introduced": "12", + "name": "ffrt_task_handle_inc_ref" + }, + { + "first_introduced": "12", + "name": "ffrt_task_handle_dec_ref" + }, { "name": "ffrt_task_handle_destroy" }, { "name": "ffrt_wait_deps" }, { "name": "ffrt_wait" }, @@ -50,7 +82,7 @@ { "name": "ffrt_loop_timer_start" }, { "name": "ffrt_loop_timer_stop" }, { "name": "ffrt_queue_attr_set_max_concurrency" }, - { "name": "ffrt_queue_atte_get_max_concurrency" }, + { "name": "ffrt_queue_attr_get_max_concurrency" }, { "name": "ffrt_get_main_queue" }, { "name": "ffrt_get_current_queue" }, { "name": "ffrt_task_attr_set_queue_priority" }, diff --git a/resourceschedule/qos_manager/c/qos.h b/resourceschedule/qos_manager/c/qos.h index 6a04eb6f39e7ea59ebc4f5eefd052060facef8ef..e7bd4183a365f296a553759c9d9fee946792a45c 100644 --- a/resourceschedule/qos_manager/c/qos.h +++ b/resourceschedule/qos_manager/c/qos.h @@ -35,6 +35,7 @@ * schedule the time and running order of tasks according to the QoS set by the tasks. * * @library libqos.so + * @kit KernelEnhanceKit * @syscap SystemCapability.Resourceschedule.QoS.Core * @since 12 */ @@ -84,7 +85,7 @@ typedef enum QoS_Level { * * @param level Indicates the level to set. Specific level can be referenced {@link QoS_Level}. * @return Returns 0 if the operation is successful; returns -1 if level is out of range or - internal error failed. + * internal error failed. * @see QoS_Level * @since 12 */ @@ -94,7 +95,7 @@ int OH_QoS_SetThreadQoS(QoS_Level level); * @brief Cancel the QoS level of the current thread. * * @return Returns 0 if the operation is successful; returns -1 if not set QoS for current thread - * or internal error failed. + * or internal error failed. * @see QoS_Level * @since 12 */ diff --git a/security/access_token/BUILD.gn b/security/access_token/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4b211ad2be92191c74d35250c91a478ad8034cf4 --- /dev/null +++ b/security/access_token/BUILD.gn @@ -0,0 +1,29 @@ +# 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") + +ohos_ndk_headers("accesstoken_header") { + dest_dir = "$ndk_headers_out_dir/accesstoken" + sources = [ "ability_access_control.h" ] +} + +ohos_ndk_library("libability_access_control") { + ndk_description_file = "./libaccesstoken.ndk.json" + min_compact_version = "12" + output_name = "ability_access_control" + output_extension = "so" + + system_capability = "SystemCapability.Security.AccessToken" + system_capability_headers = [ "accesstoken/ability_access_control.h" ] +} diff --git a/security/access_token/ability_access_control.h b/security/access_token/ability_access_control.h new file mode 100644 index 0000000000000000000000000000000000000000..121e5b9836d58e0c0d4163d900614acfd5668894 --- /dev/null +++ b/security/access_token/ability_access_control.h @@ -0,0 +1,61 @@ +/* + * 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 AbilityAccessControl + * @{ + * + * @brief Provides the capability to manage access token. + * + * @since 12 + */ + +/** + * @file ability_access_control.h + * + * @brief Declares the APIs for managing access token. + * + * @library ability_access_control.so + * @kit AbilityKit + * @syscap SystemCapability.Security.AccessToken + * @since 12 + */ + +#ifndef ABILITY_ACCESS_CONTROL_H +#define ABILITY_ACCESS_CONTROL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Checks whether this application has been granted the given permission. + * + * @param permission - Name of the permission to be granted. + * @return true - The permission has been granted to this application. + * false - The permission has not been granted to this application. + * @since 12 + */ +bool OH_AT_CheckSelfPermission(const char *permission); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* ABILITY_ACCESS_CONTROL_H */ diff --git a/security/access_token/libaccesstoken.ndk.json b/security/access_token/libaccesstoken.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..3f1d12c5ea8c0a71d8a677aa54381be887406e89 --- /dev/null +++ b/security/access_token/libaccesstoken.ndk.json @@ -0,0 +1,5 @@ +[ + { + "name": "OH_AT_CheckSelfPermission" + } +] \ No newline at end of file diff --git a/security/asset/inc/asset_api.h b/security/asset/inc/asset_api.h index 794a04e02009198abb8219d1a6ce72d30c63c457..cda927aac42a5993ee6f13785d945feb0adb171e 100755 --- a/security/asset/inc/asset_api.h +++ b/security/asset/inc/asset_api.h @@ -13,14 +13,6 @@ * limitations under the License. */ -#ifndef ASSET_API_H -#define ASSET_API_H - -#include -#include - -#include "asset_type.h" - /** * @addtogroup AssetApi * @{ @@ -44,6 +36,14 @@ * @since 11 */ +#ifndef ASSET_API_H +#define ASSET_API_H + +#include +#include + +#include "asset_type.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/security/asset/inc/asset_type.h b/security/asset/inc/asset_type.h index b977afbef3effc471ad0468a1c649e256d9502eb..4eea24c7cb3038f7de629bc9e8eb72837a66f8fd 100755 --- a/security/asset/inc/asset_type.h +++ b/security/asset/inc/asset_type.h @@ -13,9 +13,6 @@ * limitations under the License. */ -#ifndef ASSET_TYPE_H -#define ASSET_TYPE_H - /** * @addtogroup AssetType * @{ @@ -36,6 +33,9 @@ * @since 11 */ +#ifndef ASSET_TYPE_H +#define ASSET_TYPE_H + #include #include @@ -205,6 +205,12 @@ typedef enum { * @since 12 */ ASSET_TAG_OPERATION_TYPE = ASSET_TYPE_NUMBER | 0x46, + /** + * A tag whose value is a bool indicating whether the attributes of an asset are required to be encrypted. + * + * @since 13 + */ + ASSET_TAG_REQUIRE_ATTR_ENCRYPTED = ASSET_TYPE_BOOL | 0x47, } Asset_Tag; /** diff --git a/sensors/sensor/oh_sensor_type.h b/sensors/sensor/oh_sensor_type.h index 6f2cc925a3eb6d70d4ec034a1a009117f3f9452b..0641a9c0cf414e456dcedd7e972d3df5bb2d8f50 100644 --- a/sensors/sensor/oh_sensor_type.h +++ b/sensors/sensor/oh_sensor_type.h @@ -91,11 +91,21 @@ typedef enum Sensor_Type { * @since 11 */ SENSOR_TYPE_GRAVITY = 257, + /** + * Linear acceleration sensor. + * @since 13 + */ + SENSOR_TYPE_LINEAR_ACCELERATION = 258, /** * Rotation vector sensor. * @since 11 */ SENSOR_TYPE_ROTATION_VECTOR = 259, + /** + * Game rotation vector sensor. + * @since 13 + */ + SENSOR_TYPE_GAME_ROTATION_VECTOR = 262, /** * Pedometer detection sensor. * @since 11 @@ -334,6 +344,11 @@ int32_t OH_SensorEvent_GetAccuracy(Sensor_Event* sensorEvent, Sensor_Accuracy *a * The value 1 means that the number of detected steps changes. * SENSOR_TYPE_PEDOMETER: data[0], indicating the number of steps a user has walked. * SENSOR_TYPE_HEART_RATE: data[0], indicating the heart rate value. + * SENSOR_TYPE_LINEAR_ACCELERATION: Supported from api version 13. data[0], data[1], and data[2], indicating the + * linear acceleration around the x, y, and z axes of the device, respectively, in m/s2. + * SENSOR_TYPE_GAME_ROTATION_VECTOR: Supported from api version 13. data[0], data[1] and data[2], indicating the + * rotation angles of a device around the x, y, and z axes, respectively, in degree. data[3] indicates the rotation + * vector. * * @param sensorEvent - Pointer to the sensor data information. * @param data - Double pointer to the sensor data. diff --git a/startup/init/syscap/include/deviceinfo.h b/startup/init/syscap/include/deviceinfo.h index 955759bfb9c18dcf80d22dd9a77fb093a0ccd587..0725cd54081236132e155373edadce14b5d152e2 100644 --- a/startup/init/syscap/include/deviceinfo.h +++ b/startup/init/syscap/include/deviceinfo.h @@ -16,6 +16,24 @@ #ifndef DEVICEINFO_CSDK_H #define DEVICEINFO_CSDK_H +/** + * @addtogroup DeviceInfo + * @{ + * + * @brief Provides APIs for querying terminal device information. + * + * @since 10 + */ + +/** + * @file deviceinfo.h + * @kit BasicServicesKit + * @brief Declares APIs for querying terminal device information. + * @library libdeviceinfo_ndk.z.so + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -227,4 +245,5 @@ const char *OH_GetDistributionOSReleaseType(void); } #endif #endif +/** @} */ #endif diff --git a/startup/init/syscap/include/syscap_ndk.h b/startup/init/syscap/include/syscap_ndk.h index 070a6cb1e66afea5347295bf62258ac4b7fb7458..d821c3a3528b06478e26abfe6a5e87a48268d029 100644 --- a/startup/init/syscap/include/syscap_ndk.h +++ b/startup/init/syscap/include/syscap_ndk.h @@ -16,6 +16,24 @@ #ifndef SYSCAP_NDK_H #define SYSCAP_NDK_H +/** + * @addtogroup SyscapNdk + * @{ + * + * @brief Provides APIs for querying system capabilities. + * + * @since 10 + */ + +/** + * @file deviceinfo.h + * @kit BasicServicesKit + * @brief Declares APIs for acquiring the set of system capabilities . + * @library na + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ + #include #ifdef __cplusplus @@ -31,4 +49,5 @@ bool canIUse(const char *cap); } #endif #endif +/** @} */ #endif \ No newline at end of file diff --git a/startup/init/syscap/init_sync.h b/startup/init/syscap/init_sync.h index ceeefbce390a32bf12cb49334c52fc475fced04c..ca4836b27465de52e609b71e30128484e5939c01 100644 --- a/startup/init/syscap/init_sync.h +++ b/startup/init/syscap/init_sync.h @@ -16,6 +16,24 @@ #ifndef BASE_STARTUP_INITLITE_NOTIFY_H #define BASE_STARTUP_INITLITE_NOTIFY_H +/** + * @addtogroup InitSync + * @{ + * + * @brief Provides APIs for notifying the Init process of events. + * + * @since 10 + */ + +/** + * @file init_sync.h + * @kit BasicServicesKit + * @brief Declares APIs for notifying events to the Init process. + * @library na + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -45,5 +63,5 @@ extern int NotifyInit(unsigned long event); } #endif #endif - +/** @} */ #endif // BASE_STARTUP_INITLITE_NOTIFY_H diff --git a/telephony/cellular_data/BUILD.gn b/telephony/cellular_data/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..de7e9f09528fce5f848aecc9cdb341bed1d54197 --- /dev/null +++ b/telephony/cellular_data/BUILD.gn @@ -0,0 +1,29 @@ +# 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") + +ohos_ndk_library("libtelephony_data") { + output_name = "telephony_data" + output_extension = "so" + ndk_description_file = "./libtelephony_data.json" + min_compact_version = "1" + system_capability = "SystemCapability.Telephony.CellularData" + + system_capability_headers = [ "telephony/cellular_data/telephony_data.h" ] +} + +ohos_ndk_headers("telephony_data_header") { + dest_dir = "$ndk_headers_out_dir/telephony/cellular_data" + sources = [ "include/telephony_data.h" ] +} diff --git a/telephony/cellular_data/include/telephony_data.h b/telephony/cellular_data/include/telephony_data.h new file mode 100755 index 0000000000000000000000000000000000000000..801f8e81946f4590482fe230386823dec2436170 --- /dev/null +++ b/telephony/cellular_data/include/telephony_data.h @@ -0,0 +1,49 @@ +/* + * 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. + */ + +#ifndef NATIVE_TELEPHONY_DATA_API_H +#define NATIVE_TELEPHONY_DATA_API_H + +/** + * @file telephony_data.h + * + * @brief Provides C interface for the telephony cellular data. + * + * @kit TelephonyKit + * @syscap SystemCapability.Telephony.CellularData + * @library libtelephony_data.so + * @since 13 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Obtains the default cellular data slot id. + * + * @return the default cellular data slot id (0 for slot 1, 1 for slot 2). + * @syscap SystemCapability.Telephony.CellularData + * @since 13 + */ +int32_t OH_Telephony_GetDefaultCellularDataSlotId(void); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_TELEPHONY_DATA_API_H diff --git a/telephony/cellular_data/libtelephony_data.json b/telephony/cellular_data/libtelephony_data.json new file mode 100755 index 0000000000000000000000000000000000000000..03c3f92a877447dbfb3ae5bbae64e55d4bf52ab6 --- /dev/null +++ b/telephony/cellular_data/libtelephony_data.json @@ -0,0 +1,6 @@ +[ + { + "first_introduced":"13", + "name": "OH_Telephony_GetDefaultCellularDataSlotId" + } +] diff --git a/telephony/core_service/BUILD.gn b/telephony/core_service/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..9e4fe53075247c194909a94af92946d622141b78 --- /dev/null +++ b/telephony/core_service/BUILD.gn @@ -0,0 +1,35 @@ +# 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") + +ohos_ndk_library("libtelephony_radio") { + output_name = "telephony_radio" + output_extension = "so" + ndk_description_file = "./libtelephony_radio.json" + min_compact_version = "1" + system_capability = "SystemCapability.Telephony.CoreService" + + system_capability_headers = [ + "telephony/core_service/telephony_radio.h", + "telephony/core_service/telephony_radio_type.h", + ] +} + +ohos_ndk_headers("telephony_radio_header") { + dest_dir = "$ndk_headers_out_dir/telephony/core_service" + sources = [ + "include/telephony_radio.h", + "include/telephony_radio_type.h", + ] +} diff --git a/telephony/core_service/include/telephony_radio.h b/telephony/core_service/include/telephony_radio.h new file mode 100755 index 0000000000000000000000000000000000000000..26746d4bed6bd0f6371cd6260811b16fcca3a448 --- /dev/null +++ b/telephony/core_service/include/telephony_radio.h @@ -0,0 +1,74 @@ +/* + * 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. + */ + +#ifndef NATIVE_TELEPHONY_RADIO_API_H +#define NATIVE_TELEPHONY_RADIO_API_H + +/** + * @file telephony_radio.h + * + * @brief Provides C interface for the telephony radio. + * + * @kit TelephonyKit + * @syscap SystemCapability.Telephony.CoreService + * @library libtelephony_radio.so + * @since 13 + */ + +#include "telephony_radio_type.h" +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief Obtains the radio network state. + * + * @param state Pointer to the network state. + * @return the result defines in {@link Telephony_RadioResult}. + * {@link TEL_RADIO_SUCCESS} Success. + * {@link TEL_RADIO_PERMISSION_DENIED} Permission denied. + * {@link TEL_RADIO_ERR_MARSHALLING_FAILED} Low probability Marshalling failed, try again later. + * {@link TEL_RADIO_ERR_SERVICE_CONNECTION_FAILED} Unable to connect to telephony service, try again later. + * {@link TEL_RADIO_ERR_OPERATION_FAILED} Operation failed in telephony service, try again later. + * {@link TEL_RADIO_ERR_INVALID_PARAM} Invalid parameter. + * @permission ohos.permission.GET_NETWORK_INFO + * @syscap SystemCapability.Telephony.CoreService + * @since 13 + */ +Telephony_RadioResult OH_Telephony_GetNetworkState(Telephony_NetworkState *state); + +/** + * @brief Obtains the radio network state for given slot id. + * + * @param slotId the number of slot, 0 for card slot 1, 1 for card slot 2. + * @param state Pointer to the network state. + * @return the result defines in {@link Telephony_RadioResult}. + * {@link TEL_RADIO_SUCCESS} Success. + * {@link TEL_RADIO_PERMISSION_DENIED} Permission denied. + * {@link TEL_RADIO_ERR_MARSHALLING_FAILED} Low probability Marshalling failed, try again later. + * {@link TEL_RADIO_ERR_SERVICE_CONNECTION_FAILED} Unable to connect to telephony service, try again later. + * {@link TEL_RADIO_ERR_OPERATION_FAILED} Operation failed in telephony service, try again later. + * {@link TEL_RADIO_ERR_INVALID_PARAM} Invalid parameter. + * @permission ohos.permission.GET_NETWORK_INFO + * @syscap SystemCapability.Telephony.CoreService + * @since 13 + */ +Telephony_RadioResult OH_Telephony_GetNetworkStateForSlot(int32_t slotId, Telephony_NetworkState *state); +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_TELEPHONY_RADIO_API_H diff --git a/telephony/core_service/include/telephony_radio_type.h b/telephony/core_service/include/telephony_radio_type.h new file mode 100755 index 0000000000000000000000000000000000000000..15877c912ec5a8e66126b051ee48c0ea61334019 --- /dev/null +++ b/telephony/core_service/include/telephony_radio_type.h @@ -0,0 +1,157 @@ +/* + * 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. + */ + +#ifndef NATIVE_TELEPHONY_RADIO_TYPE_H +#define NATIVE_TELEPHONY_RADIO_TYPE_H + +/** + * @file telephony_radio_type.h + * + * @brief Provides the data structures for the C APIs of the the telephony radio. + * + * @kit TelephonyKit + * @syscap SystemCapability.Telephony.CoreService + * @library libtelephony_radio.so + * @since 13 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define TELEPHONY_MAX_OPERATOR_LEN 64 +#define TELEPHONY_MAX_PLMN_NUMERIC_LEN 6 + +/** + * @brief Result code. + * + * @since 13 + */ +typedef enum { + /* @error success */ + TEL_RADIO_SUCCESS = 0, + /* @error permission denied */ + TEL_RADIO_PERMISSION_DENIED = 201, + /* @error invalid parameter */ + TEL_RADIO_ERR_INVALID_PARAM = 401, + /* @error marshalling failed, this is a low probability error, try again later when get this error */ + TEL_RADIO_ERR_MARSHALLING_FAILED = 8300001, + /* @error unable to connect to telephony service, try again later when get this error */ + TEL_RADIO_ERR_SERVICE_CONNECTION_FAILED = 8300002, + /* @error operation failed in telephony service, try again later when get this error */ + TEL_RADIO_ERR_OPERATION_FAILED = 8300003, +} Telephony_RadioResult; + +/** + * @brief network registration status. + * + * @since 13 + */ +typedef enum { + /* can not use any services */ + TEL_REG_STATE_NO_SERVICE = 0, + /* can use services properly */ + TEL_REG_STATE_IN_SERVICE = 1, + /* can use emergency call only */ + TEL_REG_STATE_EMERGENCY_CALL_ONLY = 2, + /* radio power off */ + TEL_REG_STATE_POWER_OFF = 3, +} Telephony_RegState; + +/** + * @brief radio access technologies. + * + * @since 13 + */ +typedef enum { + /* Unknown radio technology */ + TEL_RADIO_TECHNOLOGY_UNKNOWN = 0, + /* Global System for Mobile Communication (GSM) */ + TEL_RADIO_TECHNOLOGY_GSM = 1, + /* Single-Carrier Radio Transmission Technology (1XRTT) */ + TEL_RADIO_TECHNOLOGY_1XRTT = 2, + /* Wideband Code Division Multiple Access (WCDMA) */ + TEL_RADIO_TECHNOLOGY_WCDMA = 3, + /* High Speed Packet Access (HSPA) */ + TEL_RADIO_TECHNOLOGY_HSPA = 4, + /* Evolved High Speed Packet Access (HSPA+) */ + TEL_RADIO_TECHNOLOGY_HSPAP = 5, + /* Time Division-Synchronous Code Division Multiple Access(TD-SCDMA) */ + TEL_RADIO_TECHNOLOGY_TD_SCDMA = 6, + /* Evolution-Data Optimized (EVDO) */ + TEL_RADIO_TECHNOLOGY_EVDO = 7, + /* Evolved High Rate Package Data (EHRPD) */ + TEL_RADIO_TECHNOLOGY_EHRPD = 8, + /* Long Term Evolution (LTE) */ + TEL_RADIO_TECHNOLOGY_LTE = 9, + /* Long Term Evolution_Carrier Aggregation (LTE_CA) */ + TEL_RADIO_TECHNOLOGY_LTE_CA = 10, + /* Industrial Wireless LAN (IWLAN) */ + TEL_RADIO_TECHNOLOGY_IWLAN = 11, + /* New Radio (NR) */ + TEL_RADIO_TECHNOLOGY_NR = 12, +} Telephony_RadioTechnology; + +/** + * @brief NSA network state. + * + * @since 13 + */ +typedef enum { + /* The device is in idle or connected state in an LTE cell that does not support NSA */ + TEL_NSA_STATE_NOT_SUPPORTED = 1, + /* The device is in the idle state in an LTE cell that supports NSA but not NR coverage detection */ + TEL_NSA_STATE_NO_DETECTED = 2, + /* The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection */ + TEL_NSA_STATE_CONNECTED_DETECTED = 3, + /* The device is in the idle state in an LTE cell that supports NSA and NR coverage detection */ + TEL_NSA_STATE_IDLE_DETECTED = 4, + /* The device is connected to the LTE/NR network in an LTE cell that supports NSA */ + TEL_NSA_STATE_DUAL_CONNECTED = 5, + /* The device is idle or connected to the NG-RAN cell when being attached to the 5G Core */ + TEL_NSA_STATE_SA_ATTACHED = 6, +} Telephony_NsaState; + +/** + * @brief Network status. + * + * @since 13 + */ +typedef struct { + /* Long carrier name of the registered network */ + char longOperatorName_[TELEPHONY_MAX_OPERATOR_LEN]; + /* Short carrier name of the registered network */ + char shortOperatorName_[TELEPHONY_MAX_OPERATOR_LEN]; + /* PLMN code of the registered network */ + char plmnNumeric_[TELEPHONY_MAX_PLMN_NUMERIC_LEN]; + /* Whether in roaming */ + bool isRoaming_; + /* Network registration status */ + Telephony_RegState regState_; + /* Radio technology. */ + Telephony_RadioTechnology cfgTech_; + /* NSA state */ + Telephony_NsaState nsaState_; + /* Whether Carrier Aggregation(CA) is active */ + bool isCaActive_; + /* Whether in emergency call only */ + bool isEmergency_; +} Telephony_NetworkState; + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_TELEPHONY_RADIO_TYPE_H diff --git a/telephony/core_service/libtelephony_radio.json b/telephony/core_service/libtelephony_radio.json new file mode 100755 index 0000000000000000000000000000000000000000..b080408158db8709326688e380480b849c4bad21 --- /dev/null +++ b/telephony/core_service/libtelephony_radio.json @@ -0,0 +1,10 @@ +[ + { + "first_introduced":"13", + "name": "OH_Telephony_GetNetworkState" + }, + { + "first_introduced":"13", + "name": "OH_Telephony_GetNetworkStateForSlot" + } +] diff --git a/third_party/egl/README.OpenSource b/third_party/egl/README.OpenSource deleted file mode 100644 index 4693a658190a41241be69c9a6e6864b0a4acc6b4..0000000000000000000000000000000000000000 --- a/third_party/egl/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name": "EGL", - "License": "MIT License", - "License File": "LICENSE", - "Version Number": "1.5", - "Owner": "lizheng2@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/EGL-Registry.git", - "Description": "EGL is an interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system." - } -] diff --git a/third_party/icu4c/README.OpenSource b/third_party/icu4c/README.OpenSource deleted file mode 100644 index ec3f8592fce5370ee7e0509600e7088760b64f80..0000000000000000000000000000000000000000 --- a/third_party/icu4c/README.OpenSource +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "Name": "International Components for Unicode", - "License": "ICU License, BSD 3-Clause License", - "License File": "LICENSE", - "Version Number": "72.1", - "Upstream URL": "https://github.com/unicode-org/icu/archive/release-72-1.tar.gz", - "Description": "ICU is a mature, widely used set of portable C/C++ and Java libraries for Unicode support, software internationalization and globalization (i18n/g11n). The packages are mirrors of the main website." - } -] diff --git a/third_party/icu4c/ndk_headers/unicode/ubrk.h b/third_party/icu4c/ndk_headers/unicode/ubrk.h index f8454beb97d850540cbb01c0ec632a50799be4d2..9724bcf56944e66b2a0093d4e2fde6c576494540 100644 --- a/third_party/icu4c/ndk_headers/unicode/ubrk.h +++ b/third_party/icu4c/ndk_headers/unicode/ubrk.h @@ -30,6 +30,8 @@ typedef struct UBreakIterator UBreakIterator; #endif +#include "unicode/parseerr.h" + #if !UCONFIG_NO_BREAK_ITERATION /** * \file diff --git a/third_party/libuv/README.OpenSource b/third_party/libuv/README.OpenSource deleted file mode 100644 index 5b25fcf7ccca5edb1c7775521a1b17ab52d02330..0000000000000000000000000000000000000000 --- a/third_party/libuv/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name": "libuv", - "License": "MIT License", - "License File": "LICENSE", - "Version Number": "v1.48.0", - "Owner": "sunbingxin@huawei.com", - "Upstream URL": "https://github.com/libuv/libuv", - "Description": "libuv is a multi-platform support library with a focus on asynchronous I/O." - } -] diff --git a/third_party/mindspore/README.OpenSource b/third_party/mindspore/README.OpenSource deleted file mode 100644 index bd6c7775a37b7798f96d0f4a70fc7b263f241c9a..0000000000000000000000000000000000000000 --- a/third_party/mindspore/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name": "MindSpore", - "License": "Apache License 2.0", - "License File": "LICENSE.txt", - "Version Number": "2.1.0", - "Owner": "chengfeng27@huawei.com", - "Upstream URL": "https://gitee.com/mindspore/mindspore/repository/archive/v2.1.0", - "Description": "MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios." - } -] diff --git a/third_party/musl/README.OpenSource b/third_party/musl/README.OpenSource deleted file mode 100644 index ed40042f94204a5c81bd51ed50667f860c54d321..0000000000000000000000000000000000000000 --- a/third_party/musl/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name" : "musl", - "License" : "MIT License", - "License File" : "COPYRIGHT", - "Version Number" : "1.2.5", - "Owner" : "zhaoxinyuan9@huawei.com", - "Upstream URL" : "https://musl.libc.org", - "Description" : "musl is an MIT-licensed implementation of the standard C library" - } -] diff --git a/third_party/musl/ndk_script/BUILD.gn b/third_party/musl/ndk_script/BUILD.gn index 683b2e30d6224b58904d935640e356d7d8f01ff9..a71e33565ab354dd49bfb34bdfa2de31e336bbe8 100644 --- a/third_party/musl/ndk_script/BUILD.gn +++ b/third_party/musl/ndk_script/BUILD.gn @@ -208,7 +208,7 @@ group("musl_sysroot") { action("copy_ndk_uapi") { outputs = [ "${musl_target_out_dir}/${ndk_musl_include}/linux" ] script = "${musl_dir}/scripts/copy_uapi.sh" - args = [ "-i" ] + [ rebase_path("${uapi_dir}") ] + args = [ "-i" ] + [ rebase_path("${musl_uapi_dir}") ] args += [ "-o" ] + [ rebase_path("${musl_target_out_dir}/${ndk_musl_include}") ] args += [ "-t" ] + [ "${musl_arch}" ] diff --git a/third_party/node/README.OpenSource b/third_party/node/README.OpenSource deleted file mode 100644 index 28991b992ddac0f9064195e839a956823a9f417d..0000000000000000000000000000000000000000 --- a/third_party/node/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name": "node", - "License": "ISC License,Public Domain,MIT License,Free Software Foundation - MIT License,Apache License V2.0,ICU License,zlib/libpng License,BSD 2-Clause License,BSD 3-Clause License", - "License File": "LICENSE", - "Version Number": "v18.20.1", - "Owner": "sunbingxin@huawei.com", - "Upstream URL": "http://www.nodejs.org/", - "Description": "Node.js is an open-source, cross-platform, JavaScript runtime environment. It executes JavaScript code outside of a browser." - } -] diff --git a/third_party/openGLES/README.OpenSource b/third_party/openGLES/README.OpenSource deleted file mode 100644 index 82565035b4e93797b8a7b3a93c62e1692f11eb5a..0000000000000000000000000000000000000000 --- a/third_party/openGLES/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name": "openGLES", - "License": "Apache-2.0", - "License File": "NOTICE", - "Version Number": "63161d674db04a96635c6ab300db793e83f6762c", - "Owner": "lizheng2@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/OpenGL-Registry.git", - "Description": "The OpenGL ES registry contains specifications of the core API and shading language; specifications of Khronos- and vendor-approved OpenGL ES extensions; header files corresponding to the specificatio" - } -] diff --git a/third_party/openSLES/README.OpenSource b/third_party/openSLES/README.OpenSource deleted file mode 100644 index 2eda1e4fdac76f25a768837cd831a5bb01ea1cb9..0000000000000000000000000000000000000000 --- a/third_party/openSLES/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name": "Khronos Group - OpenSL ES", - "License": "null", - "License File": "NOTICE", - "Version Number": "1.0.1", - "Owner": "yangshuai67@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/OpenSL-ES-Registry.git", - "Description": "OpenSL ES™ is a royalty-free, cross-platform, hardware-accelerated audio API tuned for embedded systems." - } -] \ No newline at end of file diff --git a/third_party/vulkan-headers/README.OpenSource b/third_party/vulkan-headers/README.OpenSource deleted file mode 100644 index 97fefa261c1dd7c1ae2b76a35e97e2ee8a5ae61e..0000000000000000000000000000000000000000 --- a/third_party/vulkan-headers/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name": "Vulkan", - "License": "Apache-2.0", - "License File": "LICENSE", - "Version Number": "v1.3.275", - "Owner": "mengzhaobing@huawei.com", - "Upstream URL": "https://github.com/KhronosGroup/Vulkan-Headers.git", - "Description": "Vulkan header files and API registry" - } -] diff --git a/third_party/zlib/README.OpenSource b/third_party/zlib/README.OpenSource deleted file mode 100644 index e3a0accc9f3c2b0bb46cc67944abe7b34c25ee78..0000000000000000000000000000000000000000 --- a/third_party/zlib/README.OpenSource +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Name" : "zlib", - "License" : "zlib/libpng License", - "License File" : "LICENSE", - "Version Number" : "v1.3.1", - "Owner" : "gongjunsong@huawei.com", - "Upstream URL" : "https://github.com/madler/zlib/archive/refs/tags/v1.3.1.tar.gz", - "Description" : "zlib 1.3.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files" - } -] diff --git a/web/webview/interfaces/native/arkweb_error_code.h b/web/webview/interfaces/native/arkweb_error_code.h index 2162e368c31c62481d7f18c1564b135855f68f50..a445de2c717c0e35ae1df73fd6cf6f26a6be6514 100644 --- a/web/webview/interfaces/native/arkweb_error_code.h +++ b/web/webview/interfaces/native/arkweb_error_code.h @@ -33,6 +33,12 @@ #define ARKWEB_ERROR_CODE_H typedef enum ArkWeb_ErrorCode { +/** @error Success. */ +ARKWEB_SUCCESS = 0, + +/** @error Init error. */ +ARKWEB_INIT_ERROR = 17100001, + /** @error Unknown error. */ ARKWEB_ERROR_UNKNOWN = 17100100, @@ -41,6 +47,12 @@ ARKWEB_INVALID_PARAM = 17100101, /** @error Register custom schemes should be called before create any ArkWeb. */ ARKWEB_SCHEME_REGISTER_FAILED = 17100102, + +/** @error Invalid url. */ +ARKWEB_INVALID_URL = 17100103, + +/** @error Invalid cookie value. */ +ARKWEB_INVALID_COOKIE_VALUE = 17100104, } ArkWeb_ErrorCode; #endif // ARKWEB_ERROR_CODE_H diff --git a/web/webview/interfaces/native/arkweb_interface.h b/web/webview/interfaces/native/arkweb_interface.h index d0b1fa45a2e2235f1540b04a1d22a68dc4c92ee1..f204dab326bb68f2e8af432fdebb8bd681ac61e2 100644 --- a/web/webview/interfaces/native/arkweb_interface.h +++ b/web/webview/interfaces/native/arkweb_interface.h @@ -59,6 +59,18 @@ typedef enum { ARKWEB_NATIVE_COMPONENT, /** API type related to ArkWeb controller. */ ARKWEB_NATIVE_CONTROLLER, + /** API type related to ArkWeb WebMessagePort. */ + ARKWEB_NATIVE_WEB_MESSAGE_PORT, + /** API type related to ArkWeb WebMessage. */ + ARKWEB_NATIVE_WEB_MESSAGE, + /** API type related to ArkWeb cookie manager. */ + ARKWEB_NATIVE_COOKIE_MANAGER, + /** + * @brief API type related to ArkWeb JavaScript value. + * + * @since 14 + */ + ARKWEB_NATIVE_JAVASCRIPT_VALUE, } ArkWeb_NativeAPIVariantKind; /* diff --git a/web/webview/interfaces/native/arkweb_scheme_handler.h b/web/webview/interfaces/native/arkweb_scheme_handler.h index 1b3dd4beac871633ff322516b9e5fb77e977ec01..4ab4b8b94be74d5abb1edaabca4c68a04d24e834 100644 --- a/web/webview/interfaces/native/arkweb_scheme_handler.h +++ b/web/webview/interfaces/native/arkweb_scheme_handler.h @@ -32,6 +32,7 @@ #ifndef ARKWEB_SCHEME_HANDLER_H #define ARKWEB_SCHEME_HANDLER_H +#include #include "stdint.h" #include "arkweb_error_code.h" diff --git a/web/webview/interfaces/native/arkweb_type.h b/web/webview/interfaces/native/arkweb_type.h index c63cfc26fceb0393796199b8ca5dd84ee86e7501..e6738810a9dcfbc50cd310e370104a9826b9b9fe 100644 --- a/web/webview/interfaces/native/arkweb_type.h +++ b/web/webview/interfaces/native/arkweb_type.h @@ -36,6 +36,8 @@ #include #include +#include "arkweb_error_code.h" + #ifdef __cplusplus extern "C" { #endif @@ -52,6 +54,48 @@ typedef struct { size_t size; } ArkWeb_JavaScriptBridgeData; +/** + * @brief Defines the data type carried in a ArkWeb_WebMessage. + * + * @since 12 + */ +typedef enum ArkWeb_WebMessageType { + /** Represent error data */ + ARKWEB_NONE = 0, + /** The data carried in the ArkWeb_WebMessage is string. */ + ARKWEB_STRING, + /** The data carried in the ArkWeb_WebMessage is buffer(uint8_t). */ + ARKWEB_BUFFER +} ArkWeb_WebMessageType; + +/** + * @brief Defines the data type carried in a ArkWeb_JavaScriptValue. + * + * @since 14 + */ +typedef enum ArkWeb_JavaScriptValueType { + /** Represent error data */ + ARKWEB_JAVASCRIPT_NONE = 0, + /** The data carried in the ArkWeb_JavaScriptValue is string. */ + ARKWEB_JAVASCRIPT_STRING, + /** The data carried in the ArkWeb_JavaScriptValue is bool. */ + ARKWEB_JAVASCRIPT_BOOL +} ArkWeb_JavaScriptValueType; + +/** + * @brief Defines the ArkWeb_WebMessage. + * + * @since 12 + */ +typedef struct ArkWeb_WebMessage* ArkWeb_WebMessagePtr; + +/** + * @brief Defines the ArkWeb_JavaScriptValuePtr. + * + * @since 14 + */ +typedef struct ArkWeb_JavaScriptValue* ArkWeb_JavaScriptValuePtr; + /** * @brief Defines the javascript callback of the native ArkWeb. * @@ -68,6 +112,19 @@ typedef void (*ArkWeb_OnJavaScriptCallback)( typedef void (*ArkWeb_OnJavaScriptProxyCallback)( const char* webTag, const ArkWeb_JavaScriptBridgeData* dataArray, size_t arraySize, void* userData); +/** + * @brief Defines the JavaScript proxy callback of the native ArkWeb. + * + * @param webTag The name of the web component. + * @param dataArray The JavaScript bridge data array from HTML. + * @param arraySize The number of elements in the array. + * @param userData The data set by user. + * + * @since 14 + */ +typedef ArkWeb_JavaScriptValuePtr (*ArkWeb_OnJavaScriptProxyCallbackWithResult)( + const char* webTag, const ArkWeb_JavaScriptBridgeData* dataArray, size_t arraySize, void* userData); + /** * @brief Defines the component callback of the native ArkWeb. * @@ -75,6 +132,26 @@ typedef void (*ArkWeb_OnJavaScriptProxyCallback)( */ typedef void (*ArkWeb_OnComponentCallback)(const char* webTag, void* userData); +/** + * @brief Defines the ArkWeb_WebMessagePort that represent a HTML5 message port. + * + * @since 12 + */ +typedef struct ArkWeb_WebMessagePort* ArkWeb_WebMessagePortPtr; + +/** + * @brief Defines the callback to receive message from HTML. + * + * @param webTag The name of the web component. + * @param port The ArkWeb_WebMessagePort for registering the ArkWeb_OnMessageEventHandler. + * @param message The received ArkWeb_WebMessage. + * @param userData The data set by user. + * + * @since 12 + */ +typedef void (*ArkWeb_OnMessageEventHandler)( + const char* webTag, const ArkWeb_WebMessagePortPtr port, const ArkWeb_WebMessagePtr message, void* userData); + /** * @brief Defines the javascript object. * @@ -105,6 +182,20 @@ typedef struct { void* userData; } ArkWeb_ProxyMethod; +/** + * @brief Defines the JavaScript proxy method with a return value. + * + * @since 14 + */ +typedef struct { + /** The method of the application side JavaScript object participating in the registration. */ + const char* methodName; + /** The callback function with a return value registered by developer is called back when HTML side uses. */ + ArkWeb_OnJavaScriptProxyCallbackWithResult callback; + /** The user data to set. */ + void* userData; +} ArkWeb_ProxyMethodWithResult; + /** * @brief Defines the javascript proxy registered object. * @@ -119,8 +210,25 @@ typedef struct { size_t size; } ArkWeb_ProxyObject; +/** + * @brief Defines the JavaScript proxy registered object with methodList that has a return value. + * + * @since 14 + */ +typedef struct { + /** The name of the registered object. */ + const char* objName; + /** The JavaScript proxy registered method object list with a callback function that has a return value */ + const ArkWeb_ProxyMethodWithResult* methodList; + /** The size of the methodList. */ + size_t size; +} ArkWeb_ProxyObjectWithResult; + /** * @brief Defines the controller API for native ArkWeb. + * Before invoking an API, you are advised to use ARKWEB_MEMBER_MISSING to check + * whether the function structure has a corresponding function pointer to avoid crash + * caused by mismatch between the SDK and the device ROM. * * @since 12 */ @@ -137,6 +245,72 @@ typedef struct { void (*refresh)(const char* webTag); /** Register the JavaScript object and async method list. */ void (*registerAsyncJavaScriptProxy)(const char* webTag, const ArkWeb_ProxyObject* proxyObject); + /** + * @brief Creates a message channel to communicate with HTML and returns + * the message ports representing the message channel endpoints. + * + * @param webTag The name of the web component. + * @param size The quantity of message ports. + */ + ArkWeb_WebMessagePortPtr* (*createWebMessagePorts)(const char* webTag, size_t* size); + + /** + * @brief Destroy message ports. + * + * @param ports Address of the message ports array pointer. + * @param size The quantity of message ports. + */ + void (*destroyWebMessagePorts)(ArkWeb_WebMessagePortPtr** ports, size_t size); + + /** + * @brief Post message ports to main frame. + * + * @param webTag The name of the web component. + * @param name Name of the message to be sent. + * @param size The quantity of message ports. + * @param url Indicates the URI for receiving the message. + * @return Post web message result code. + * {@link ARKWEB_SUCCESS} post web message success. + * {@link ARKWEB_INVALID_PARAM} the parameter verification fails. + * {@link ARKWEB_INIT_ERROR} no web associated with this webTag. + */ + ArkWeb_ErrorCode (*postWebMessage)( + const char* webTag, const char* name, ArkWeb_WebMessagePortPtr* webMessagePorts, size_t size, const char* url); + + /** + * @brief Get the url of the last frame that calls the JavaScriptProxy. + * This should be call on the thread which JavaScriptProxy called. + * + * @return The url of the last frame that calls the JavaScriptProxy. + * @since 14 + */ + const char* (*getLastJavascriptProxyCallingFrameUrl)(); + + /** + * @brief Register the JavaScript object and method list, the method is callback function that has a return value. + * + * @param webTag The name of the web component. + * @param proxyObject The JavaScript object to register, the object has callback functions with return value. + * @param permission The JSON string, which defaults to null, is used to configure the permission control for + * JSBridge, allowing for the definition of URL whitelists at the object and method levels. + * + * @since 14 + */ + void (*registerJavaScriptProxyEx)(const char* webTag, const ArkWeb_ProxyObjectWithResult* proxyObject, + const char* permission); + + /** + * @brief Register the JavaScript object and async method list. + * + * @param webTag The name of the web component. + * @param proxyObject The JavaScript object to register. + * @param permission The JSON string, which defaults to null, is used to configure the permission control + * for JSBridge, allowing for the definition of URL whitelists at the object and method levels. + * + * @since 14 + */ + void (*registerAsyncJavaScriptProxyEx)(const char* webTag, const ArkWeb_ProxyObject* proxyObject, + const char* permission); } ArkWeb_ControllerAPI; /** @@ -157,6 +331,195 @@ typedef struct { void (*onDestroy)(const char* webTag, ArkWeb_OnComponentCallback callback, void* userData); } ArkWeb_ComponentAPI; +/** + * @brief Defines the web message API for native ArkWeb. + * Before invoking an API, you are advised to use ARKWEB_MEMBER_MISSING to check + * whether the function structure has a corresponding function pointer to avoid crash + * caused by mismatch between the SDK and the device ROM. + * + * @since 12 + */ +typedef struct { + /** The ArkWeb_WebMessagePortAPI struct size. */ + size_t size; + /** + * @brief Post message to HTML. + * + * @param webMessagePort The ArkWeb_WebMessagePort. + * @param webTag The name of the web component. + * @param webMessage The ArkWeb_WebMessage to send. + * @return Post message result code. + * {@link ARKWEB_SUCCESS} post message success. + * {@link ARKWEB_INVALID_PARAM} the parameter verification fails. + * {@link ARKWEB_INIT_ERROR} no web associated with this webTag. + */ + ArkWeb_ErrorCode (*postMessage)( + const ArkWeb_WebMessagePortPtr webMessagePort, const char* webTag, const ArkWeb_WebMessagePtr webMessage); + /** + * @brief Close the message port. + * + * @param webMessagePort The ArkWeb_WebMessagePort. + * @param webTag The name of the web component. + */ + void (*close)(const ArkWeb_WebMessagePortPtr webMessagePort, const char* webTag); + /** + * @brief Set a callback to receive message from HTML. + * + * @param webMessagePort The ArkWeb_WebMessagePort. + * @param webTag The name of the web component. + * @param messageEventHandler The handler to receive message from HTML. + * @param userData The data set by user. + */ + void (*setMessageEventHandler)(const ArkWeb_WebMessagePortPtr webMessagePort, const char* webTag, + ArkWeb_OnMessageEventHandler messageEventHandler, void* userData); +} ArkWeb_WebMessagePortAPI; + +/** + * @brief Defines the web message data API for native ArkWeb. + * Before invoking an API, you are advised to use ARKWEB_MEMBER_MISSING to check + * whether the function structure has a corresponding function pointer to avoid crash + * caused by mismatch between the SDK and the device ROM. + * + * @since 12 + */ +typedef struct { + /** The ArkWeb_WebMessageAPI struct size. */ + size_t size; + /** + * @brief Used to create a ArkWeb_WebMessage. + * + * @return The created ArkWeb_WebMessage, destroy it through + * destroyWebMessage after it is no longer used. + */ + ArkWeb_WebMessagePtr (*createWebMessage)(); + /** + * @brief Used to destroy a ArkWeb_WebMessage. + * + * @param webMessage The ArkWeb_WebMessage to destroy. + */ + void (*destroyWebMessage)(ArkWeb_WebMessagePtr* webMessage); + /** + * @brief Set the type of ArkWeb_WebMessage. + * + * @param webMessage The ArkWeb_WebMessage. + * @param type The type of ArkWeb_WebMessage. + */ + void (*setType)(ArkWeb_WebMessagePtr webMessage, ArkWeb_WebMessageType type); + /** + * @brief Get the type of ArkWeb_WebMessage. + * + * @param webMessage The ArkWeb_WebMessage. + * @return The type of ArkWeb_WebMessage. + */ + ArkWeb_WebMessageType (*getType)(ArkWeb_WebMessagePtr webMessage); + /** + * @brief Set the data of ArkWeb_WebMessage. + * + * @param webMessage The ArkWeb_WebMessage. + * @param data The data of ArkWeb_WebMessage. + * @param dataLength The length of data. + */ + void (*setData)(ArkWeb_WebMessagePtr webMessage, void* data, size_t dataLength); + /** + * @brief Get the data of ArkWeb_WebMessage. + * + * @param webMessage The ArkWeb_WebMessage. + * @param dataLength The length of data. + * @return The data of ArkWeb_WebMessage. + */ + void* (*getData)(ArkWeb_WebMessagePtr webMessage, size_t* dataLength); +} ArkWeb_WebMessageAPI; + +/** + * @brief Defines the native CookieManager API for ArkWeb. + * Before invoking an API, you are advised to use ARKWEB_MEMBER_MISSING to check + * whether the function structure has a corresponding function pointer to avoid crash + * caused by mismatch between the SDK and the device ROM. + * + * @since 12 + */ +typedef struct { + /** The ArkWeb_CookieManagerAPI struct size. */ + size_t size; + + /** + * @brief Obtains the cookie value corresponding to a specified URL. + * + * @param url URL to which the cookie to be obtained belongs. A complete URL is recommended. + * @param incognito True indicates that the memory cookies of the webview in privacy mode are obtained, + * and false indicates that cookies in non-privacy mode are obtained. + * @param includeHttpOnly If true HTTP-only cookies will also be included in the cookieValue. + * @param cookieValue Get the cookie value corresponding to the URL. + * @return Fetch cookie result code. + * {@link ARKWEB_SUCCESS} fetch cookie success. + * {@link ARKWEB_INVALID_URL} invalid url. + * {@link ARKWEB_INVALID_PARAM} cookieValue is nullptr. + */ + ArkWeb_ErrorCode (*fetchCookieSync)(const char* url, bool incognito, bool includeHttpOnly, char** cookieValue); + + /** + * @brief Sets the cookie value for a specified URL. + * + * @param url Specifies the URL to which the cookie belongs. A complete URL is recommended. + * @param cookieValue The value of the cookie to be set. + * @param incognito True indicates that cookies of the corresponding URL are set in privacy mode, + * and false indicates that cookies of the corresponding URL are set in non-privacy mode. + * @param includeHttpOnly If true, HTTP-only cookies can also be overwritten. + * @return Config cookie result code. + * {@link ARKWEB_SUCCESS} config cookie success. + * {@link ARKWEB_INVALID_URL} invalid url. + * {@link ARKWEB_INVALID_COOKIE_VALUE} invalid cookie value. + */ + ArkWeb_ErrorCode (*configCookieSync)(const char* url, + const char* cookieValue, bool incognito, bool includeHttpOnly); + + /** + * @brief Check whether cookies exist. + * + * @param incognito True indicates whether cookies exist in privacy mode, + * and false indicates whether cookies exist in non-privacy mode. + * @return True indicates that the cookie exists, and false indicates that the cookie does not exist. + */ + bool (*existCookies)(bool incognito); + + /** + * @brief Clear all cookies. + * + * @param incognito True indicates that all memory cookies of the webview are cleared in privacy mode, + * and false indicates that persistent cookies in non-privacy mode are cleared. + */ + void (*clearAllCookiesSync)(bool incognito); + + /** + * @brief Clear all session cookies. + */ + void (*clearSessionCookiesSync)(); +} ArkWeb_CookieManagerAPI; + +/** + * @brief Defines the native JavaScriptValue API for ArkWeb. + * Before invoking an API, you are advised to use ARKWEB_MEMBER_MISSING to check + * whether the function structure has a corresponding function pointer to avoid crash + * caused by mismatch between the SDK and the device ROM. + * + * @since 14 + */ +typedef struct { + /** The ArkWeb_JavaScriptValueAPI struct size. */ + size_t size; + + /** + * @brief Create the JavaScript value responding to HTML. + * + * @param type The type of ArkWeb_JavaScriptValue. + * @param data The data buffer of ArkWeb_JavaScriptValue. + * @param dataLength The length of data buffer. + * @return ArkWeb_JavaScriptValuePtr created by ArkWeb, the memory of ArkWeb_JavaScriptValue + * is managed by ArkWeb itself. + */ + ArkWeb_JavaScriptValuePtr (*createJavaScriptValue)(ArkWeb_JavaScriptValueType type, void* data, size_t dataLength); +} ArkWeb_JavaScriptValueAPI; + /** * @brief Check whether the member variables of the current struct exist. * @@ -173,6 +536,6 @@ typedef struct { #define ARKWEB_MEMBER_MISSING(s, f) (!ARKWEB_MEMBER_EXISTS(s, f) || !((s)->f)) #ifdef __cplusplus -}; +} #endif #endif // ARKWEB_TYPE_H \ No newline at end of file diff --git a/web/webview/interfaces/native/native_interface_arkweb.h b/web/webview/interfaces/native/native_interface_arkweb.h index 42a95a67eaee5fc9af7f9f19a2f9d0573665b4f1..48c114fce6b90828b892c8484f0bd84cc1d23b91 100644 --- a/web/webview/interfaces/native/native_interface_arkweb.h +++ b/web/webview/interfaces/native/native_interface_arkweb.h @@ -32,6 +32,7 @@ #ifndef NATIVE_INTERFACE_ARKWEB_H #define NATIVE_INTERFACE_ARKWEB_H +#include #include #ifdef __cplusplus