diff --git a/BasicServicesKit/BUILD.gn b/BasicServicesKit/BUILD.gn index f28da4fa87770e830375a5c8ff5922fbd1e425a2..285ccff68c80c348ff26014c4837b4e37234dec3 100644 --- a/BasicServicesKit/BUILD.gn +++ b/BasicServicesKit/BUILD.gn @@ -57,3 +57,37 @@ ohos_ndk_library("libohscan_ndk") { system_capability = "SystemCapability.Print.PrintFramework" system_capability_headers = [ "BasicServicesKit/ohscan.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("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" ] +} 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..695328b66caaab89d6d9c6ef1a757f410f15c737 --- /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 number. + * @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 number. + * @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..67f77687be755140a620cb6dd9dd50135f2192de --- /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 existing application 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/time_service.h b/BasicServicesKit/time_service.h new file mode 100644 index 0000000000000000000000000000000000000000..c7194a406b54be95aec2f1185b49512622e1f08b --- /dev/null +++ b/BasicServicesKit/time_service.h @@ -0,0 +1,79 @@ +/* + * 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 + * @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/ark_runtime/jsvm/jsvm.h b/ark_runtime/jsvm/jsvm.h index 190a60defc365c14e1750a8b116d7c0918d39216..0d9fa9ad1d38b6adedc96c612e0140b12d58733b 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. @@ -2893,6 +2944,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..1f41452453dac385d48463ed3947c017a32ac452 100644 --- a/ark_runtime/jsvm/jsvm_types.h +++ b/ark_runtime/jsvm/jsvm_types.h @@ -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/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..7ed0fc4e5ccd27cb5cab0935b61ee0f7ac52d6c4 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -121,112 +121,112 @@ }, { "first_introduced": "12", - "name": "OH_NativeXComponent_RegisterUIInputEventCallback" + "name": "OH_ArkUI_GetNodeHandleFromNapiValue" }, { "first_introduced": "12", - "name": "OH_ArkUI_UIInputEvent_GetType" + "name": "OH_ArkUI_QueryModuleInterface" }, { "first_introduced": "12", - "name": "OH_ArkUI_UIInputEvent_GetEventTime" + "name": "OH_ArkUI_GestureEvent_GetActionType" }, { "first_introduced": "12", - "name": "OH_ArkUI_PointerEvent_GetX" + "name": "OH_ArkUI_GestureEvent_GetRawInputEvent" }, { "first_introduced": "12", - "name": "OH_ArkUI_PointerEvent_GetY" + "name": "OH_ArkUI_LongPress_GetRepeatCount" }, { "first_introduced": "12", - "name": "OH_ArkUI_PointerEvent_GetWindowX" + "name": "OH_ArkUI_PanGesture_GetVelocity" }, { "first_introduced": "12", - "name": "OH_ArkUI_PointerEvent_GetWindowY" + "name": "OH_ArkUI_PanGesture_GetVelocityY" }, { "first_introduced": "12", - "name": "OH_ArkUI_PointerEvent_GetDisplayX" + "name": "OH_ArkUI_PanGesture_GetVelocityX" }, { "first_introduced": "12", - "name": "OH_ArkUI_PointerEvent_GetDisplayY" + "name": "OH_ArkUI_PanGesture_GetOffsetX" }, { "first_introduced": "12", - "name": "OH_ArkUI_AxisEvent_GetVerticalAxisValue" + "name": "OH_ArkUI_PanGesture_GetOffsetY" }, { "first_introduced": "12", - "name": "OH_ArkUI_AxisEvent_GetHorizontalAxisValue" + "name": "OH_ArkUI_SwipeGesture_GetAngle" }, { "first_introduced": "12", - "name": "OH_ArkUI_AxisEvent_GetPinchAxisScaleValue" + "name": "OH_ArkUI_SwipeGesture_GetVelocity" }, { "first_introduced": "12", - "name": "OH_ArkUI_GetNodeHandleFromNapiValue" + "name": "OH_ArkUI_RotationGesture_GetAngle" }, { "first_introduced": "12", - "name": "OH_ArkUI_GestureEvent_GetActionType" + "name": "OH_ArkUI_PinchGesture_GetScale" }, { "first_introduced": "12", - "name": "OH_ArkUI_GestureEvent_GetRawInputEvent" + "name": "OH_ArkUI_PinchGesture_GetCenterX" }, { "first_introduced": "12", - "name": "OH_ArkUI_LongPress_GetRepeatCount" + "name": "OH_ArkUI_PinchGesture_GetCenterY" }, { "first_introduced": "12", - "name": "OH_ArkUI_PanGesture_GetVelocity" + "name": "OH_NativeXComponent_RegisterSurfaceShowCallback" }, { "first_introduced": "12", - "name": "OH_ArkUI_PanGesture_GetVelocityY" + "name": "OH_NativeXComponent_RegisterSurfaceHideCallback" }, { "first_introduced": "12", - "name": "OH_ArkUI_PanGesture_GetVelocityX" + "name": "OH_NativeXComponent_RegisterUIInputEventCallback" }, { "first_introduced": "12", - "name": "OH_ArkUI_PanGesture_GetOffsetX" + "name": "OH_ArkUI_UIInputEvent_GetType" }, { "first_introduced": "12", - "name": "OH_ArkUI_PanGesture_GetOffsetY" + "name": "OH_ArkUI_UIInputEvent_GetEventTime" }, { "first_introduced": "12", - "name": "OH_ArkUI_SwipeGesture_GetAngle" + "name": "OH_ArkUI_PointerEvent_GetX" }, { "first_introduced": "12", - "name": "OH_ArkUI_SwipeGesture_GetVelocity" + "name": "OH_ArkUI_PointerEvent_GetY" }, { "first_introduced": "12", - "name": "OH_ArkUI_RotationGesture_GetAngle" + "name": "OH_ArkUI_PointerEvent_GetWindowX" }, { "first_introduced": "12", - "name": "OH_ArkUI_PinchGesture_GetScale" + "name": "OH_ArkUI_PointerEvent_GetWindowY" }, { "first_introduced": "12", - "name": "OH_ArkUI_PinchGesture_GetCenterX" + "name": "OH_ArkUI_PointerEvent_GetDisplayX" }, { "first_introduced": "12", - "name": "OH_ArkUI_PinchGesture_GetCenterY" - }, + "name": "OH_ArkUI_PointerEvent_GetDisplayY" + }, { "first_introduced": "12", "name": "OH_ArkUI_GestureEvent_GetNode" @@ -249,15 +249,79 @@ }, { "first_introduced": "12", - "name": "OH_NativeXComponent_SetNeedSoftKeyboard" + "name": "OH_ArkUI_GetResponseRecognizersFromInterruptInfo" }, { "first_introduced": "12", - "name": "OH_NativeXComponent_RegisterSurfaceShowCallback" + "name": "OH_ArkUI_SetGestureRecognizerEnabled" }, { "first_introduced": "12", - "name": "OH_NativeXComponent_RegisterSurfaceHideCallback" + "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_ArkUI_AxisEvent_GetVerticalAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AxisEvent_GetHorizontalAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_AxisEvent_GetPinchAxisScaleValue" }, { "first_introduced": "12", @@ -265,7 +329,7 @@ }, { "first_introduced": "12", - "name": "OH_ArkUI_QueryModuleInterface" + "name": "OH_NativeXComponent_SetNeedSoftKeyboard" }, { "first_introduced": "12", @@ -667,8 +731,7 @@ "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_RegisterGetItemMainSizeCallbackByIndexWithUserData" }, - { - "first_introduced": "12", + { "first_introduced": "12", "name": "OH_ArkUI_AnimateOption_Create" }, { @@ -739,6 +802,10 @@ "first_introduced": "12", "name": "OH_ArkUI_PointerEvent_SetInterceptHitTestMode" }, + { + "first_introduced": "12", + "name": "OH_NativeXComponent_GetNativeXComponent" + }, { "first_introduced": "12", "name": "OH_ArkUI_NodeContent_AddNode" @@ -775,10 +842,6 @@ "first_introduced": "12", "name": "OH_ArkUI_GetNodeContentFromNapiValue" }, - { - "first_introduced": "12", - "name": "OH_NativeXComponent_GetNativeXComponent" - }, { "first_introduced": "12", "name": "OH_ArkUI_MouseEvent_GetMouseButton" @@ -1411,6 +1474,18 @@ "first_introduced": "12", "name": "OH_ArkUI_AccessibilityValue_GetText" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeEvent_GetNumberValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeEvent_GetStringValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeEvent_SetReturnNumberValue" + }, { "first_introduced": "12", "name": "OH_ArkUI_AnimateOption_SetICurve" @@ -1655,18 +1730,6 @@ "first_introduced": "12", "name": "OH_ArkUI_Curve_DisposeCurve" }, - { - "first_introduced": "12", - "name": "OH_ArkUI_NodeEvent_GetNumberValue" - }, - { - "first_introduced": "12", - "name": "OH_ArkUI_NodeEvent_GetStringValue" - }, - { - "first_introduced": "12", - "name": "OH_ArkUI_NodeEvent_SetReturnNumberValue" - }, { "first_introduced": "12", "name": "OH_ArkUI_CreateOpacityTransitionEffect" @@ -1765,7 +1828,7 @@ }, { "first_introduced": "12", - "name": "OH_ArkUI_NodeEvent_GetPreviewDragStatus" + "name": "OH_ArkUI_NodeEvent_GetPreDragStatus" }, { "first_introduced": "12", @@ -1982,5 +2045,93 @@ { "first_introduced": "12", "name": "OH_ArkUI_DialogDismissEvent_GetDismissReason" + }, + { + "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": "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" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_gesture.h b/arkui/ace_engine/native/native_gesture.h index 35dac3924d75d777b705ff8a71685073e42edfd6..19e83b1f55850d698ea2805f36db88a28672875f 100644 --- a/arkui/ace_engine/native/native_gesture.h +++ b/arkui/ace_engine/native/native_gesture.h @@ -223,6 +223,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 +467,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 +869,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_xcomponent.h b/arkui/ace_engine/native/native_interface_xcomponent.h index bbf7201550d802e3b089f777c686a88294078b5d..cb662e8f016cd5ebaf104359d022222242c66563 100644 --- a/arkui/ace_engine/native/native_interface_xcomponent.h +++ b/arkui/ace_engine/native/native_interface_xcomponent.h @@ -722,6 +722,30 @@ int32_t OH_NativeXComponent_AttachNativeRootNode(OH_NativeXComponent* component, */ int32_t OH_NativeXComponent_DetachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root); +/** + * @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 surface show event callback. + * @return Returns the status code of the execution. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterSurfaceShowCallback( + OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); + +/** + * @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 surface hide event callback. + * @return Returns the status code of the execution. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterSurfaceHideCallback( + OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); + /** * @brief Registers a UI input event callback for this OH_NativeXComponent instance and enables the callback to * be invoked when a UI input event is received. @@ -751,30 +775,6 @@ int32_t OH_NativeXComponent_RegisterUIInputEventCallback( */ int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard); -/** - * @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 surface show event callback. - * @return Returns the status code of the execution. - * @since 12 - * @version 1.0 - */ -int32_t OH_NativeXComponent_RegisterSurfaceShowCallback( - OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); - -/** - * @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 surface hide event callback. - * @return Returns the status code of the execution. - * @since 12 - * @version 1.0 - */ -int32_t OH_NativeXComponent_RegisterSurfaceHideCallback( - OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); - /** * @brief Registers a custom event intercept callback for this OH_NativeXComponent and enables the callback * during the hit test. diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 1412a47cfb2a2994f5ec96280b8a77d1c811e5d2..5fd6c0a72d42c1695805bc7824b365547cc5c6e7 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; /** @@ -344,10 +346,9 @@ typedef enum { * @brief Sets the gradient 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].f32: start angle of the linear gradient. This attribute takes effect only when - * {@link ArkUI_LinearGradientDirection} is set to ARKUI_LINEAR_GRADIENT_DIRECTION_CUSTOM. - * A positive value indicates a clockwise rotation from the origin, (0, 0). The default value is 180. \n - * .value[1].i32: direction of the linear gradient. When it is set, the angle attribute does not take effect. + * .value[0].f32: start angle of the linear gradient. A positive value indicates a clockwise rotation from the + * origin, (0, 0). The default value is 180. \n + * .value[1].i32: direction of the linear gradient. It does not take effect when angle is set. * The parameter type is {@link ArkUI_LinearGradientDirection}: \n * .value[2].i32: whether the colors are repeated. The default value is false. \n * .object: array of color stops, each of which consists of a color and its stop position. @@ -359,7 +360,7 @@ typedef enum { * Format of the return value {@link ArkUI_AttributeItem}: \n * .value[0].f32: start angle of the linear gradient. \n * .value[1].i32: direction of the linear gradient. It does not take effect when angle is set. \n - * .value[2].i32: whether the colors are repeated. \n + * .value[0].i32: whether the colors are repeated. \n * .object: array of color stops, each of which consists of a color and its stop position. * Invalid colors are automatically skipped. \n * colors: colors of the color stops. \n @@ -494,15 +495,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 +1029,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 @@ -1602,9 +1604,8 @@ typedef enum { * with the {@link ArkUI_ThemeColorMode} enumeration value.\n * .value[2]?.i32 The color extraction mode used to represent the content blur effect takes\n * the {@link ArkUI_AdaptiveColor} enumeration value.\n - * .value[3]?.f32: blur degree. The value range is [0.0, 1.0]. \n - * .value[4]?.f32 It is a gray-level fuzzy parameter. The value range is [0,127].\n - * .value[5]?.f32 It is a gray-level fuzzy parameter. The value range is [0,127].\n + * .value[3]?.i32 It is a gray-level fuzzy parameter. The value range is [0,127].\n + * .value[4]?.i32 It is a gray-level fuzzy parameter. The value range is [0,127].\n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .value[0].i32 Represents the content blurring style, and uses the {@link ArkUI_BlurStyle} enumeration value.\n @@ -1612,28 +1613,26 @@ typedef enum { * with the {@link ArkUI_ThemeColorMode} enumeration value.\n * .value[2].i32 The color extraction mode used to represent the content blur effect takes\n * the {@link ArkUI_AdaptiveColor} enumeration value.\n - * .value[3].f32: blur degree. The value range is [0.0, 1.0]. \n - * .value[4].f32 It is a gray-level fuzzy parameter. The value range is [0,127].\n - * .value[5].f32 It is a gray-level fuzzy parameter. The value range is [0,127].\n + * .value[3].i32 It is a gray-level fuzzy parameter. The value range is [0,127].\n + * .value[4].i32 It is a gray-level fuzzy parameter. The value range is [0,127].\n * */ NODE_FOREGROUND_BLUR_STYLE, /** - * @brief Defines the component size and position for layout. - * This attribute can be set, reset, and obtained as required through APIs. + * @brief Defines layout rect 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: X coordinate of the component, in px. \n - * .value[1].i32: Y coordinate of the component, in px. \n - * .value[2].i32: width of the component, in px. \n - * .value[3].i32: height of the component, in px. \n + * .value[0].i32: x position of the component. + * .value[1].i32: y position of the component. + * .value[2].i32: width of the component. + * .value[3].i32: height of the component. * \n * Format of the return value {@link ArkUI_AttributeItem}:\n - * .value[0].i32: X coordinate of the component, in px. \n - * .value[1].i32: Y coordinate of the component, in px. \n - * .value[2].i32: width of the component, in px. \n - * .value[3].i32: height of the component, in px. \n + * .value[0].i32: x position of the component. + * .value[1].i32: y position of the component. + * .value[2].i32: width of the component. + * .value[3].i32: height of the component. * */ NODE_LAYOUT_RECT, @@ -1773,8 +1772,8 @@ typedef enum { * */ NODE_VISIBLE_AREA_CHANGE_RATIO = 93, - - /** + + /** * @brief Sets the transition effect when the component is inserted or deleted. * This attribute can be set, and obtained as required through APIs. * @@ -1787,6 +1786,16 @@ typedef enum { */ NODE_TRANSITION = 94, + /** + * @brief Defines the component ID. + * This attribute can be obtained through APIs. + * + * Format of the {@link ArkUI_AttributeItem} parameter for obtaining the attribute:\n + * .value[0].i32: component ID. \n + * + */ + NODE_UNIQUE_ID = 95, + /** * @brief Set the current component system focus box style. * @@ -1802,14 +1811,14 @@ typedef enum { NODE_FOCUS_BOX = 96, /** - * @brief Defines the component ID. - * This attribute can be obtained through APIs. + * @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 obtaining the attribute:\n - * .value[0].i32: component ID. \n + * 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_UNIQUE_ID = 95, + NODE_CLICK_DISTANCE = 97, /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. @@ -2172,6 +2181,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. * @@ -2910,6 +2931,7 @@ typedef enum { * */ NODE_TEXT_INPUT_NUMBER_OF_LINES, + /** * @brief Defines the default placeholder text for the multi-line text box. * This attribute can be set, reset, and obtained as required through APIs. @@ -3193,6 +3215,7 @@ typedef enum { * */ NODE_TEXT_AREA_SHOW_KEYBOARD_ON_FOCUS, + /** * @brief When this property is set, the height of the textArea component is calculated using this property. * @@ -5354,7 +5377,8 @@ typedef enum { /** * @brief Defines the gesture event type. * - * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is {@link ArkUI_UIInputEvent}. + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is + * {@link ArkUI_UIInputEvent}. */ NODE_TOUCH_EVENT = 0, @@ -5537,7 +5561,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, /** @@ -7406,6 +7430,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. * @@ -7620,6 +7686,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..6bf306990cf1e0567055392efa5de5741619e1b2 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -983,6 +983,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. * @@ -1895,6 +1907,10 @@ 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, } ArkUI_ErrorCode; /** @@ -2063,6 +2079,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 +2174,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. * @@ -3410,6 +3454,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/display_manager/BUILD.gn b/arkui/display_manager/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bfdc284acda20515b269782ea6ddcaebf769b548 --- /dev/null +++ b/arkui/display_manager/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("display_manager_header") { + dest_dir = "$ndk_headers_out_dir/window_manager" + sources = [ + "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_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..5efd5356188e93a41c7d2873114918b8a8747932 --- /dev/null +++ b/arkui/display_manager/libdm.ndk.json @@ -0,0 +1,82 @@ +[ + { + "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" + } +] \ No newline at end of file diff --git a/arkui/display_manager/oh_display_info.h b/arkui/display_manager/oh_display_info.h new file mode 100644 index 0000000000000000000000000000000000000000..3b61758845a8af4f163934a599c10274284c99c8 --- /dev/null +++ b/arkui/display_manager/oh_display_info.h @@ -0,0 +1,204 @@ +/* + * 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 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; + +#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..a3b9f3444d7d260e3468ad680c15a941ebf3dc60 --- /dev/null +++ b/arkui/display_manager/oh_display_manager.h @@ -0,0 +1,318 @@ +/* + * 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); + +#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/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 471e486498c2e19254dc14808b7a3727b72dd0fb..d336978dd34f2b7ea5e79f5a6e9b7cad5852a867 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -93,6 +93,12 @@ typedef enum Rdb_SecurityArea { * @brief Security Area 4. */ RDB_SECURITY_AREA_EL4, + /** + * @brief Security Area 5. + * + * @since 12 + */ + RDB_SECURITY_AREA_EL5, } Rdb_SecurityArea; /** diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 4d1e8a0faf85206dfd434b47cfa6207628b4f5fd..3706c89ed7f227bf5dc7a0667828becab8f423b7 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -565,6 +565,17 @@ void OH_Drawing_CanvasScale(OH_Drawing_Canvas*, float sx, float sy); */ void OH_Drawing_CanvasSkew(OH_Drawing_Canvas*, float sx, float sy); +/** + * @brief Clears a canvas by using a specified color. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param color Indicates the color, which is a 32-bit (ARGB) variable. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color); + /** * @brief Get the width of a canvas. * @@ -664,17 +675,6 @@ void OH_Drawing_CanvasDrawShadow(OH_Drawing_Canvas*, OH_Drawing_Path*, OH_Drawin OH_Drawing_Point3D devLightPos, float lightRadius, uint32_t ambientColor, uint32_t spotColor, OH_Drawing_CanvasShadowFlags flag); -/** - * @brief Clears a canvas by using a specified color. - * - * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. - * @param color Indicates the color, which is a 32-bit (ARGB) variable. - * @since 8 - * @version 1.0 - */ -void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color); - /** * @brief Sets matrix of canvas. * diff --git a/graphic/graphic_2d/native_drawing/drawing_image.h b/graphic/graphic_2d/native_drawing/drawing_image.h index 07c96aecddf04e575546b66ef1557b7247cbd240..6d2cd07aed778c475c8aad42fdefa97fa6fbf612 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image.h +++ b/graphic/graphic_2d/native_drawing/drawing_image.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 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 diff --git a/graphic/graphic_2d/native_drawing/drawing_memory_stream.h b/graphic/graphic_2d/native_drawing/drawing_memory_stream.h index 37c57810672fb68966915a89ade7a0b4292bdfb3..b3344e385e053342385e9f086baa7a03103b1395 100644 --- a/graphic/graphic_2d/native_drawing/drawing_memory_stream.h +++ b/graphic/graphic_2d/native_drawing/drawing_memory_stream.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 diff --git a/graphic/graphic_2d/native_drawing/drawing_path_effect.h b/graphic/graphic_2d/native_drawing/drawing_path_effect.h index b3260d576e27c033b8091db77e436454def765c9..13bc7855a33b38e24740481ff90e3476e6c72c44 100644 --- a/graphic/graphic_2d/native_drawing/drawing_path_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_path_effect.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 diff --git a/graphic/graphic_2d/native_drawing/drawing_sampling_options.h b/graphic/graphic_2d/native_drawing/drawing_sampling_options.h index b613776cf1a7f4019b1cf681f21c4a1c359b94ff..b435df8bbeb1b24d93756e6ff65822aeaed54025 100644 --- a/graphic/graphic_2d/native_drawing/drawing_sampling_options.h +++ b/graphic/graphic_2d/native_drawing/drawing_sampling_options.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 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 diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index d821c385580bc0c2fe13343d5bb52928b2a6adc0..355635ea1102caaebffbea66a3e8efe32159f742 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -1018,14 +1018,11 @@ double OH_Drawing_TypographyGetMaxWidth(OH_Drawing_Typography*); double OH_Drawing_TypographyGetHeight(OH_Drawing_Typography*); /** - * @brief Obtains the width of the longest line. You are advised to round up the return value in actual use. - * When the text content is empty, the minimum float value, - * that is, -340282346638528859811704183484516925440.000000, is returned. + * @brief Gets the longest line. * * @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. + * @param OH_Drawing_Typography Indicates the pointer to an OH_Drawing_Typography object. + * @return Returns the length of the longest line. * @since 9 * @version 1.1 */ diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index edcc71cb8345836bc9647825ebc47b6d0ff63173..71697e908abfac66b7acd413391b6b4efed54990 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -105,20 +105,20 @@ typedef struct OH_Drawing_Bitmap OH_Drawing_Bitmap; typedef struct OH_Drawing_Point OH_Drawing_Point; /** - * @brief Define color space to determine color information. + * @brief Defines a pixelmap, which is used to wrap real pixelmap supported by image framework. * * @since 12 * @version 1.0 */ -typedef struct OH_Drawing_ColorSpace OH_Drawing_ColorSpace; +typedef struct OH_Drawing_PixelMap OH_Drawing_PixelMap; /** - * @brief Defines a pixelmap, which is used to wrap real pixelmap supported by image framework. + * @brief Define color space to determine color information. * * @since 12 * @version 1.0 */ -typedef struct OH_Drawing_PixelMap OH_Drawing_PixelMap; +typedef struct OH_Drawing_ColorSpace OH_Drawing_ColorSpace; /** * @brief Defines a point of 2d. diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index f0d6835c1e41a25d9e5b1d28eff675a8e46fb7f0..5f0503977701871b7aae307aa923489bc8de0424 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -122,13 +122,10 @@ "first_introduced": "12", "name": "OH_Drawing_CanvasSkew" }, - { "name": "OH_Drawing_CanvasSetMatrix" }, { "first_introduced": "12", "name": "OH_Drawing_CanvasResetMatrix" }, - { "name": "OH_Drawing_CanvasReadPixels" }, - { "name": "OH_Drawing_CanvasReadPixelsToBitmap" }, { "name": "OH_Drawing_CanvasGetWidth" }, { "name": "OH_Drawing_CanvasGetHeight" }, { "name": "OH_Drawing_CanvasGetLocalClipBounds" }, @@ -139,6 +136,9 @@ "name": "OH_Drawing_MatrixGetAll" }, { "name": "OH_Drawing_CanvasDrawShadow" }, + { "name": "OH_Drawing_CanvasSetMatrix" }, + { "name": "OH_Drawing_CanvasReadPixels" }, + { "name": "OH_Drawing_CanvasReadPixelsToBitmap" }, { "first_introduced": "12", "name": "OH_Drawing_CanvasIsClipEmpty" @@ -272,8 +272,8 @@ { "name": "OH_Drawing_FontCountText" }, { "name": "OH_Drawing_FontSetTextSkewX" }, { "name": "OH_Drawing_FontSetTypeface" }, - { "name": "OH_Drawing_FontGetMetrics" }, { "name": "OH_Drawing_FontGetTypeface" }, + { "name": "OH_Drawing_FontGetMetrics" }, { "first_introduced": "12", "name": "OH_Drawing_GpuContextCreateFromGL" @@ -720,6 +720,12 @@ { "name": "OH_Drawing_ImageBuildFromBitmap" }, { "name": "OH_Drawing_ImageGetWidth" }, { "name": "OH_Drawing_ImageGetHeight" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageGetImageInfo" + }, + { "name": "OH_Drawing_SamplingOptionsCreate" }, + { "name": "OH_Drawing_SamplingOptionsDestroy" }, { "first_introduced": "12", "name": "OH_Drawing_TextStyleGetShadowWithIndex" @@ -756,12 +762,6 @@ "first_introduced": "12", "name": "OH_Drawing_TypographySetIndents" }, - { - "first_introduced": "12", - "name": "OH_Drawing_ImageGetImageInfo" - }, - { "name": "OH_Drawing_SamplingOptionsCreate" }, - { "name": "OH_Drawing_SamplingOptionsDestroy" }, { "first_introduced": "11", "name": "OH_Drawing_TypographyHandlerAddPlaceholder" diff --git a/graphic/graphic_2d/native_image/libnative_image.ndk.json b/graphic/graphic_2d/native_image/libnative_image.ndk.json index c591bf0fd4313549f7db25d9257c799d48002116..4d9f20d89e0955cb004901bfd5c42f6e8f0a83d8 100644 --- a/graphic/graphic_2d/native_image/libnative_image.ndk.json +++ b/graphic/graphic_2d/native_image/libnative_image.ndk.json @@ -18,5 +18,9 @@ { "first_introduced": "12", "name": "OH_NativeImage_ReleaseNativeWindowBuffer" + }, + { + "first_introduced": "12", + "name": "OH_ConsumerSurface_Create" } ] \ 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..56e10963d1c69549515c8735b747125109be079f 100644 --- a/graphic/graphic_2d/native_image/native_image.h +++ b/graphic/graphic_2d/native_image/native_image.h @@ -266,6 +266,19 @@ 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 method can not be used at the same time with OH_NativeImage_UpdateSurfaceImage.\n + * This interface needs to be used in conjunction with OH_NativeImage_Destroy<\b>, + * otherwise memory leaks will occur.\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(); + #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..196fab5242b37ac6412a7b28f14a277c3e549da6 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -2,5 +2,6 @@ { "name": "OH_NativeVSync_Create" }, { "name": "OH_NativeVSync_Destroy" }, { "name": "OH_NativeVSync_RequestFrame" }, + { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, { "name": "OH_NativeVSync_GetPeriod" } ] \ 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..85627485c895b2d38cc06214efaf57a8fba60bda 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. + * @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 whick 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. * diff --git a/graphic/graphic_2d/native_window/graphic_error_code.h b/graphic/graphic_2d/native_window/graphic_error_code.h index cba61e5e8dbac4efa1b5f7f21a279592ed4be15c..8a24196811340761fbf7d29b8287b435d0a52f3b 100644 --- a/graphic/graphic_2d/native_window/graphic_error_code.h +++ b/graphic/graphic_2d/native_window/graphic_error_code.h @@ -80,6 +80,8 @@ typedef enum OHNativeErrorCode { NATIVE_ERROR_UNSUPPORTED = 50102000, /** @error unknown error, please check log */ NATIVE_ERROR_UNKNOWN = 50002000, + /** @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/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..c0ae0a12c2d4b3aa86c9147fdd93b641b7b906de --- /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 is 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 is 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 is 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 is 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 is 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 is 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..1a625eb08f41c918f5ef8f1b9760230a258df2d6 --- /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(); +/** + * @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..05d56b643213f51b2922bdb8d4b93b40ceeaa3ce --- /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(); +/** + * @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..2e1481335ef07ac802a3c0ef41b7afca1054f491 --- /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 package 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 persisting 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 is 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..153d37d39980b1017e55409c9de028a85aff5538 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. * 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..9a01199acd459dd4485960b7b87d8b73aa17969a 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -42,6 +42,7 @@ #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 +480,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 ony takes effect if no other accessory such as headphoes 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..436fc6683cb2e98f0b7f916e3484a80cdfa515a2 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. diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index 6c1b362a49bfe01ac5a3f164c4decacccd4eab18..84015d3645544c8e0ea5f817973f25475a659e18 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -443,7 +443,7 @@ typedef enum { } 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..06d09d6f015f7454c5052c9a8de037605f4c0262 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -317,10 +317,58 @@ }, { "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" } ] 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..589823ef39cbe49747cc11bc69b4e20a3751516e 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,14 @@ "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": "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..a3d3fb9a232993e8b19d40ea43ad1c74b4a14a2a 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,27 @@ 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 Media type. @@ -1198,6 +1211,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/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..4d519c723e6ac2839fdf7a6c8e960e149a06a177 100644 --- a/multimedia/camera_framework/camera.h +++ b/multimedia/camera_framework/camera.h @@ -925,7 +925,7 @@ typedef struct Camera_TorchStatusInfo { /** * the current torch brightness level. */ - int32_t torchLevel; + float torchLevel; } Camera_TorchStatusInfo; /** diff --git a/multimedia/camera_framework/camera.ndk.json b/multimedia/camera_framework/camera.ndk.json index 52bbf5fc002f20bf0a3fd815230b66e945d75893..50cc20db4e252cf0ed4fd270291ff047ad76448e 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" @@ -363,6 +479,14 @@ "first_introduced": "12", "name": "OH_PhotoOutput_DeleteProfile" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_IsMovingPhotoSupported" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_EnableMovingPhoto" + }, { "first_introduced": "11", "name": "OH_PreviewOutput_RegisterCallback" @@ -391,6 +515,22 @@ "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": "11", "name": "OH_VideoOutput_RegisterCallback" @@ -419,8 +559,32 @@ "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_CameraDevice_GetCameraOrientation" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_GetMainImage" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_Release" } ] diff --git a/multimedia/camera_framework/camera_manager.h b/multimedia/camera_framework/camera_manager.h index 9524a13f40bcbad5688fa0423d10524cdee8b54b..42bcc1aaaaec9ea5616078ab178ecdc4e2117cd0 100644 --- a/multimedia/camera_framework/camera_manager.h +++ b/multimedia/camera_framework/camera_manager.h @@ -63,6 +63,15 @@ 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 A listener for camera devices status. * @@ -99,6 +108,30 @@ 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 Gets supported camera descriptions. * @@ -282,6 +315,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 +397,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..5f19ac7242812b8d06c30338ccf7aca2a2cc8a28 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,16 @@ 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 A listener for capture session. * @@ -126,6 +137,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 +717,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 +730,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 +757,106 @@ 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); + #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..bb42601a3dbaa15ea3bb105c85447b2a82deb4d5 --- /dev/null +++ b/multimedia/camera_framework/photo_native.h @@ -0,0 +1,89 @@ +/* + * 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 + * @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..2ec0654fe2ada52f20fa7ddefd02e805985d3724 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,174 @@ 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 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 +428,13 @@ Camera_ErrorCode OH_PhotoOutput_Release(Camera_PhotoOutput* photoOutput); Camera_ErrorCode OH_PhotoOutput_IsMirrorSupported(Camera_PhotoOutput* photoOutput, bool* isSupported); /** - * @brief Get active profiles. + * @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 +449,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..e5921470788793c2fc1825c73e48f6424db46917 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,58 @@ Camera_ErrorCode OH_PreviewOutput_GetActiveProfile(Camera_PreviewOutput* preview */ Camera_ErrorCode OH_PreviewOutput_DeleteProfile(Camera_Profile* profile); +/** + * @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..3f993c82ee7056b0766ccba1be17126927e36758 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,58 @@ Camera_ErrorCode OH_VideoOutput_GetActiveProfile(Camera_VideoOutput* videoOutput */ Camera_ErrorCode OH_VideoOutput_DeleteProfile(Camera_VideoProfile* profile); +/** + * @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_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index 6e50d776490653fff25f6c27627d47c82d32b817..ecd7ae93a50a295cd2e170eceb9201668843a83d 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,19 @@ 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 Defines the property string (in key-value format) of the image source. @@ -125,6 +139,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 */ diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h index 5f8be7c783e9671e7fd411d5ab276e6d0bd05a63..0e5956cfe8a69e05c2707040ed33f46e39335bde 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,14 @@ 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 pixelmap alpha type. * @@ -112,6 +123,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 +194,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; /** @@ -765,6 +788,52 @@ 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); + #ifdef __cplusplus }; #endif 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/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json index f06f6b1866994fabc7112dc3877870b99a9d044d..78c1a0235d6d86d169095bfc13425d017930353d 100644 --- a/multimedia/image_framework/libpixelmap.ndk.json +++ b/multimedia/image_framework/libpixelmap.ndk.json @@ -149,10 +149,22 @@ }, { "first_introduced": "12", - "name": "OH_PixelmapNative_ConvertPixelmapToNapi" + "name": "OH_PixelmapNative_GetMetadata" }, { "first_introduced": "12", - "name": "OH_PixelmapNative_ConvertPixelmapFromNapi" + "name": "OH_PixelmapNative_SetMetadata" + }, + { + "first_introduced": "12", + "name": "OH_PixelmapNative_GetNativeBuffer" + }, + { + "first_introduced": "12", + "name": "OH_PixelmapNative_ConvertPixelmapNativeToNapi" + }, + { + "first_introduced": "12", + "name": "OH_PixelmapNative_ConvertPixelmapNativeFromNapi" } ] \ No newline at end of file diff --git a/multimedia/media_foundation/native_avbuffer.h b/multimedia/media_foundation/native_avbuffer.h index 726f06c4f184ddf0094faf60fe575301c7d2fa92..8ba16dac0308b255a6ce618098cb9f722442967b 100644 --- a/multimedia/media_foundation/native_avbuffer.h +++ b/multimedia/media_foundation/native_avbuffer.h @@ -122,7 +122,7 @@ OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr, buffer's magic error, - * input buffer's buffer is nulllptr, input format is nullptr, buffer's magic error, or input meta is nullptr. + * input buffer's buffer is nulllptr, input format is nullptr or input meta is nullptr. * @since 11 */ OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *format); diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index cffaba60e2f486611b86ed432608f60f6879c548..f32e0ef771c7c326220971d7a6ae5def8d47b588 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -78,20 +78,33 @@ 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. */ AV_ERR_EXTEND_START = 100, - /** - * @error drm error base. + /** drm error base. * @since 12 */ AV_ERR_DRM_BASE = 200, - /** - * @error drm decypt failed. + /** drm decypt failed. * @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..776bc9e2c07607a32bb75f16d2bda3a2642f429c --- /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 MediaAccessHelper + * @{ + * + * @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..a0caef2b320efc75b0949d4242753cdd94b446b3 100644 --- a/multimedia/media_library/media_asset_base_capi.h +++ b/multimedia/media_library/media_asset_base_capi.h @@ -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,24 @@ 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 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 +105,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 +180,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 +276,24 @@ 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); #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 +/** @} */ \ No newline at end of file diff --git a/multimedia/media_library/media_asset_capi.h b/multimedia/media_library/media_asset_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..772e4be5dacccf247f0568e3f2306a898b42b959 --- /dev/null +++ b/multimedia/media_library/media_asset_capi.h @@ -0,0 +1,170 @@ +/* + * 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 MediaAsset + * @{ + * + * @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 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 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 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 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..d4bb6a77270ecf0f5a8173130f418af337c841ac --- /dev/null +++ b/multimedia/media_library/media_asset_change_request_capi.h @@ -0,0 +1,130 @@ +/* + * 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 MediaAssetChangeRequest + * @{ + * + * @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 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 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..a563292372f1a196110c61d9cdef62a915c6f830 100644 --- a/multimedia/media_library/media_asset_manager/BUILD.gn +++ b/multimedia/media_library/media_asset_manager/BUILD.gn @@ -18,7 +18,10 @@ 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", ] } @@ -31,5 +34,8 @@ 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/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..6cc799cb752f4cd2950103a135447346e268757c 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,65 @@ { "first_introduced": "12", "name": "OH_MediaAssetManager_CancelRequest" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetManager_RequestImage" + }, + { + "first_introduced": "12", + "name": "OH_MediaAccessHelper_ApplyChanges" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetUri" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDisplayName" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetSize" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDateModifiedMs" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetWidth" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetHeight" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetOrientation" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_Release" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_Create" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_AddResourceWithBuffer" + }, + { + "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..73612f5c8089ca4cbf198baa492fa22b42131e2c 100644 --- a/multimedia/media_library/media_asset_manager_capi.h +++ b/multimedia/media_library/media_asset_manager_capi.h @@ -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 */ @@ -94,7 +94,33 @@ MediaLibrary_RequestId OH_MediaAssetManager_RequestVideoForPath(OH_MediaAssetMan */ bool OH_MediaAssetManager_CancelRequest(OH_MediaAssetManager* manager, const MediaLibrary_RequestId requestId); +/** + * @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); + #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 +/** @} */ \ 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..50a8ffa498e338d8896fefabf51e1e1b3f3296fb 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,13 +115,13 @@ 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, } AVPlaybackSpeed; @@ -172,6 +174,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 +344,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 +369,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 +395,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 +404,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..1e53ae7d709c96066e430869fe0ca9439238991b 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,9 @@ { "first_introduced": "12", "name": "OH_AVScreenCapture_ResizeCanvas" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_SkipPrivacyMode" } ] \ 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..6025a0f44e766205193cfa32dae24d0f3108eca8 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -391,13 +391,30 @@ 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); #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..0d5b353871361e6d4fe8f043df90c82723a0173f 100644 --- a/multimedia/player_framework/native_avscreen_capture_base.h +++ b/multimedia/player_framework/native_avscreen_capture_base.h @@ -446,6 +446,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/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..dd2fe35ab8f4213a5d7bb16038f621ffa9c8f74c --- /dev/null +++ b/multimedia/video_processing_engine/video_processing/libvideo_processing.ndk.json @@ -0,0 +1,93 @@ +[ + { + "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" + } +] 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..1e6c0dd85afc42c31ebb31b98521aa37e26ba92c 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,147 @@ typedef enum { TOUCH_ACTION_UP = 3, } Input_TouchEventAction; +/** + * @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 the error codes. + * @brief Enumerates axis events. * * @since 12 */ -typedef enum { - /** @error Success return code on sucess*/ +typedef struct Input_AxisEvent Input_AxisEvent; + +/** + * @brief Enumerates error codes. + * + * @since 12 + */ +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 } Input_Result; +/** + * @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 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 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 +377,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 +469,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 +600,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 +642,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 +776,431 @@ 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(); + +/** + * @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(); #ifdef __cplusplus } #endif diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index cc28eac475c5554d3edf45fa448698accea8275e..cfbe993aee96320e1a73e14d8367836b29bd1ad1 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -194,5 +194,125 @@ { "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" } ] \ No newline at end of file diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 9446b979f44c3da41f68a5eb0c59c5b987adbed6..76d12d40616de36d6fff164f9651640c5c8b3e10 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -219,6 +219,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..436698c2906cd90c5e0a78f861c0302c32e9d566 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -69,6 +69,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 +92,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 +248,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..792eff18ed13c4be4641d798da6a60e14a7d1e1f 100644 --- a/network/netmanager/libnet_connection.ndk.json +++ b/network/netmanager/libnet_connection.ndk.json @@ -46,5 +46,29 @@ { "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" } -] +] \ 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..fcc9b6fd5e782a6200ac34fc4a02799b02d6b031 100644 --- a/network/netssl/include/net_ssl_c_type.h +++ b/network/netssl/include/net_ssl_c_type.h @@ -73,6 +73,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..b264a23d9114a447c9731c2d3769b9cc1c93095c 100644 --- a/resourceschedule/qos_manager/c/qos.h +++ b/resourceschedule/qos_manager/c/qos.h @@ -84,7 +84,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 +94,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/web/webview/interfaces/native/arkweb_error_code.h b/web/webview/interfaces/native/arkweb_error_code.h index 2162e368c31c62481d7f18c1564b135855f68f50..88fbc1f143d11a93aa57525ccbc91c000687819e 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..b610729ed5c308d1ff263f45f6450d904a34b766 100644 --- a/web/webview/interfaces/native/arkweb_interface.h +++ b/web/webview/interfaces/native/arkweb_interface.h @@ -59,6 +59,12 @@ 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, } 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..d626371eb13fe4cc6ea18cb9e3700e7add4d21c6 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,27 @@ 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 ArkWeb_WebMessage. + * + * @since 12 + */ +typedef struct ArkWeb_WebMessage* ArkWeb_WebMessagePtr; + /** * @brief Defines the javascript callback of the native ArkWeb. * @@ -75,6 +98,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. * @@ -121,6 +164,9 @@ typedef struct { /** * @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 +183,37 @@ 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); } ArkWeb_ControllerAPI; /** @@ -157,6 +234,171 @@ 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 Check whether the member variables of the current struct exist. * @@ -173,6 +415,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