From eb36fbe764d1b7427183834b9d53965832cda860 Mon Sep 17 00:00:00 2001 From: liyang Date: Fri, 26 Apr 2024 14:50:24 +0800 Subject: [PATCH 01/43] =?UTF-8?q?avscreencapture=E6=94=AF=E6=8C=81pc?= =?UTF-8?q?=E7=AB=AF=E6=8E=92=E9=99=A4=E6=8C=87=E5=AE=9AwindowID=E7=AA=97?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liyang --- .../player_framework/native_avscreen_capture.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index 178866899..8cc18eaf2 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -302,6 +302,19 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent( OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreenCapture *capture, struct OH_AVScreenCapture_ContentFilter *filter); +/** + * @brief Add Window content to the screen capture content filter + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance + * @param Pointer to windowIDs to be added + * @param windowCount to be added + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent( + struct OH_AVScreenCapture_ContentFilter *filter, int32_t *windowIDs, int32_t windowCount); #ifdef __cplusplus } #endif -- Gitee From b685ce8d9199fae2772ce2131b77352dbb78b703 Mon Sep 17 00:00:00 2001 From: liyang Date: Fri, 3 May 2024 19:47:17 +0800 Subject: [PATCH 02/43] Screen capture ContentFilter API Changes in SDK Signed-off-by: liyang --- .../libnative_avscreen_capture.ndk.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 f3fa01d66..f0a7081da 100644 --- a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json +++ b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json @@ -70,5 +70,21 @@ { "first_introduced": "12", "name": "OH_AVScreenCapture_SetErrorCallback" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_CreateContentFilter" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_ReleaseContentFilter" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_ContentFilter_AddAudioContent" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_ExcludeContent" } ] \ No newline at end of file -- Gitee From 6ea3c5bc6b18b423b53b9390a57a02f1af96f234 Mon Sep 17 00:00:00 2001 From: liyang Date: Fri, 3 May 2024 19:49:54 +0800 Subject: [PATCH 03/43] Screen capture ContentFilter API Changes in SDK Signed-off-by: liyang --- .../avscreen_capture/libnative_avscreen_capture.ndk.json | 4 ++++ 1 file changed, 4 insertions(+) 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 f0a7081da..35becaca0 100644 --- a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json +++ b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json @@ -86,5 +86,9 @@ { "first_introduced": "12", "name": "OH_AVScreenCapture_ExcludeContent" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_ContentFilter_AddWindowContent" } ] \ No newline at end of file -- Gitee From 8d0b81bcc7c1b318474463142cbf705e924f3fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=80=80=E5=BE=B7?= Date: Wed, 8 May 2024 15:24:22 +0800 Subject: [PATCH 04/43] asset huks error msg chagne MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 尹耀德 --- security/huks/include/native_huks_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/huks/include/native_huks_type.h b/security/huks/include/native_huks_type.h index 9ed7ec5a8..8b07c7525 100644 --- a/security/huks/include/native_huks_type.h +++ b/security/huks/include/native_huks_type.h @@ -409,7 +409,7 @@ enum OH_Huks_ErrCode { /** Failed to call service. */ OH_HUKS_ERR_CODE_CALL_SERVICE_FAILED = 12000015, /** - * Device password is required but not set. + * A device password is required but not set. * * @since 11 */ -- Gitee From cae3cbb94a2122e309f0b579aad2e0d1a9866176 Mon Sep 17 00:00:00 2001 From: bao92 Date: Wed, 8 May 2024 20:24:55 +0800 Subject: [PATCH 05/43] =?UTF-8?q?drm=20API12=E6=8E=A5=E5=8F=A3=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: bao92 --- .../libnative_media_adec.ndk.json | 4 + multimedia/av_codec/avcencinfo/BUILD.gn | 30 +++ .../libnative_media_avcencinfo.ndk.json | 30 +++ .../libnative_media_avdemuxer.ndk.json | 4 + .../av_codec/native_avcodec_audiodecoder.h | 21 ++ multimedia/av_codec/native_avdemuxer.h | 23 ++ multimedia/av_codec/native_cencinfo.h | 210 ++++++++++++++++++ .../drm_framework/libnative_drm.ndk.json | 12 +- .../drm_framework/native_mediakeysession.h | 53 +++++ .../drm_framework/native_mediakeysystem.h | 43 +++- 10 files changed, 417 insertions(+), 13 deletions(-) create mode 100644 multimedia/av_codec/avcencinfo/BUILD.gn create mode 100644 multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json create mode 100644 multimedia/av_codec/native_cencinfo.h diff --git a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json index 2f11d9276..89b3bac2f 100644 --- a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json +++ b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json @@ -58,5 +58,9 @@ { "first_introduced": "10", "name": "OH_AudioDecoder_IsValid" + }, + { + "first_introduced": "12", + "name": "OH_AudioDecoder_SetDecryptionConfig" } ] diff --git a/multimedia/av_codec/avcencinfo/BUILD.gn b/multimedia/av_codec/avcencinfo/BUILD.gn new file mode 100644 index 000000000..a1f43c09a --- /dev/null +++ b/multimedia/av_codec/avcencinfo/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_avcencinfo_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ "../native_cencinfo.h" ] +} + +ohos_ndk_library("libnative_media_avcencinfo") { + ndk_description_file = "./libnative_media_avcencinfo.ndk.json" + min_compact_version = "12" + output_name = "native_media_avcencinfo" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Spliter" + system_capability_headers = + [ "multimedia/player_framework/native_cencinfo.h" ] +} diff --git a/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json b/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json new file mode 100644 index 000000000..be84ad9ae --- /dev/null +++ b/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json @@ -0,0 +1,30 @@ +[ + { + "first_introduced": "12", + "name": "OH_AVCencInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetAlgo" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetKeyIdAndIv" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetSubsampleInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetMode" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetAVBuffer" + } +] diff --git a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json index 2a3cb212f..dcddf3df4 100644 --- a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json +++ b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json @@ -34,5 +34,9 @@ { "first_introduced": "11", "name": "OH_AVDemuxer_GetMediaKeySystemInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback" } ] diff --git a/multimedia/av_codec/native_avcodec_audiodecoder.h b/multimedia/av_codec/native_avcodec_audiodecoder.h index e834aa233..6e4d65984 100644 --- a/multimedia/av_codec/native_avcodec_audiodecoder.h +++ b/multimedia/av_codec/native_avcodec_audiodecoder.h @@ -24,6 +24,13 @@ extern "C" { #endif +/** + * @brief MediaKeySession field. + * @since 12 + * @version 1.0 + */ +typedef struct MediaKeySession MediaKeySession; + /** * @brief Creates an audio decoder instance from the mime type, which is recommended in most cases. * @syscap SystemCapability.Multimedia.Media.AudioDecoder @@ -245,6 +252,20 @@ OH_AVErrCode OH_AudioDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); */ OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec *codec, bool *isValid); +/** + * @brief Set decryption info. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param mediaKeySession A media key session instance with decryption function. + * @param secureAudio Require secure decoder or not. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 12 + * @version 1.0 +*/ +OH_AVErrCode OH_AudioDecoder_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession, + bool secureAudio); + #ifdef __cplusplus } #endif diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index 84634687e..96717cf96 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -28,6 +28,16 @@ typedef struct OH_AVDemuxer OH_AVDemuxer; typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); +/** + * @brief Call back will be invoked when updating DRM information. + * @param demuxer Player OH_AVDemuxer. + * @param mediaKeySystemInfo DRM information. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef void (*Demuxer_MediaKeySystemInfoCallback)(OH_AVDemuxer *demuxer, DRM_MediaKeySystemInfo *mediaKeySystemInfo); + /** * @brief Creates an OH_AVDemuxer instance for getting samples from source. * Free the resources of the instance by calling OH_AVDemuxer_Destroy. @@ -140,6 +150,19 @@ OH_AVErrCode OH_AVDemuxer_SeekToTime(OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVErrCode OH_AVDemuxer_SetMediaKeySystemInfoCallback(OH_AVDemuxer *demuxer, DRM_MediaKeySystemInfoCallback callback); +/** + * @brief Method to set player media key system info callback. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance + * @param callback object pointer. + * @return Returns {@link AV_ERR_OK} if the drm info callback is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback(OH_AVDemuxer *demuxer, + Demuxer_MediaKeySystemInfoCallback callback); + /** * @brief Obtains media key system info to create media key session. * @syscap SystemCapability.Multimedia.Media.Spliter diff --git a/multimedia/av_codec/native_cencinfo.h b/multimedia/av_codec/native_cencinfo.h new file mode 100644 index 000000000..b7dbf5fba --- /dev/null +++ b/multimedia/av_codec/native_cencinfo.h @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_AVCENCINFO_H +#define NATIVE_AVCENCINFO_H + +#include +#include "native_averrors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief AVBuffer Structure. + * @since 12 + * @version 1.0 + */ +typedef struct OH_AVBuffer OH_AVBuffer; +/** + * @brief AVCencInfo Structure. + * @since 12 + * @version 1.0 + */ +typedef struct OH_AVCencInfo OH_AVCencInfo; +/** + * @brief Key id size. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_ID_SIZE 16 +/** + * @brief Iv size. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_IV_SIZE 16 +/** + * @brief Max subsample num. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_MAX_SUB_SAMPLE_NUM 64 + +/** + * @brief Drm cenc algorithm type. + * @since 12 + * @version 1.0 + */ +typedef enum DrmCencAlgorithm { + /** + * Unencrypted. + */ + DRM_ALG_CENC_UNENCRYPTED = 0x0, + /** + * Aes ctr. + */ + DRM_ALG_CENC_AES_CTR = 0x1, + /** + * Aes wv. + */ + DRM_ALG_CENC_AES_WV = 0x2, + /** + * Aes cbc. + */ + DRM_ALG_CENC_AES_CBC = 0x3, + /** + * Sm4 cbc. + */ + DRM_ALG_CENC_SM4_CBC = 0x4, + /** + * Sm4 ctr. + */ + DRM_ALG_CENC_SM4_CTR = 0x5 +} DrmCencAlgorithm; + +/** + * @brief Mode of cend info like set or not. + * @since 12 + * @version 1.0 + */ +typedef enum DrmCencInfoMode { + /* key/iv/subsample set. */ + DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET = 0x0, + /* key/iv/subsample not set. */ + DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET = 0x1 +} DrmCencInfoMode; + +/** + * @brief Subsample info of media. + * @since 12 + * @version 1.0 + */ +typedef struct DrmSubsample { + /* Clear header len. */ + uint32_t clearHeaderLen; + /* Payload Len. */ + uint32_t payLoadLen; +} DrmSubsample; + +/** + * @brief Creates an OH_AVCencInfo instance for setting cencinfo. + * Free the resources of the instance by calling OH_AVCencInfo_Destory. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @return Returns a pointer to an OH_AVCencInfo instance + * @since 12 + * @version 1.0 + */ +OH_AVCencInfo *OH_AVCencInfo_Create(); + +/** + * @brief Destroy the OH_AVCencInfo instance and free the internal resources. + * The same instance can only be destroyed once. The destroyed instance + * should not be used before it is created again. It is recommended setting + * the instance pointer to NULL right after the instance is destroyed successfully. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 12 + * @version 1.0 +*/ +OH_AVErrCode OH_AVCencInfo_Destroy(OH_AVCencInfo *cencInfo); + +/** + * @brief Method to set algo of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param algo Cenc algo. + * @return Returns {@link AV_ERR_OK} if the algo is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetAlgorithm(OH_AVCencInfo *cencInfo, enum DrmCencAlgorithm algo); + +/** + * @brief Method to set key id and iv of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param keyId Key id. + * @param keyIdLen Key id len. + * @param iv Iv. + * @param ivLen Iv len. + * @return Returns {@link AV_ERR_OK} if the key id and iv is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetKeyIdAndIv(OH_AVCencInfo *cencInfo, uint8_t *keyId, + uint32_t keyIdLen, uint8_t *iv, uint32_t ivLen); + +/** + * @brief Method to set subsample info of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param encryptedBlockCount Number of encrypted blocks. + * @param skippedBlockCount Number of skip(clear) blocks. + * @param firstEncryptedOffset Offset of first encrypted payload. + * @param subsampleCount Subsample num. + * @param subsamples Subsample info + * @return Returns {@link AV_ERR_OK} if the subsample info is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t encryptedBlockCount, + uint32_t skippedBlockCount, uint32_t firstEncryptedOffset, uint32_t subsampleCount, DrmSubsample *subsamples); + +/** + * @brief Method to set mode of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param mode Cenc mode, indicate whether key/iv/subsample set or not. + * @return Returns {@link AV_ERR_OK} if the mode is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetMode(OH_AVCencInfo *cencInfo, enum DrmCencInfoMode mode); + +/** + * @brief Method to attach cencinfo to AVBuffer. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param buffer AVBuffer to attach cencinfo. + * @return Returns {@link AV_ERR_OK} if the cencinfo is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetAVBuffer(OH_AVCencInfo *cencInfo, OH_AVBuffer *buffer); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVCENCINFO_H diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 41e94c3ab..0e453e4d5 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -111,10 +111,6 @@ "first_introduced": "11", "name": "OH_MediaKeySession_RequireSecureDecoderModule" }, - { - "first_introduced": "11", - "name": "OH_MediaKeySession_SetMediaKeySessionCallback" - }, { "first_introduced": "11", "name": "OH_MediaKeySession_Destroy" @@ -122,5 +118,13 @@ { "first_introduced": "12", "name": "OH_MediaKeySystem_GetMediaKeySystems" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySystem_SetCallback" } ] \ No newline at end of file diff --git a/multimedia/drm_framework/native_mediakeysession.h b/multimedia/drm_framework/native_mediakeysession.h index 999aa04e1..8394da5da 100644 --- a/multimedia/drm_framework/native_mediakeysession.h +++ b/multimedia/drm_framework/native_mediakeysession.h @@ -86,6 +86,48 @@ typedef struct MediaKeySession_Callback { MediaKeySession_KeyChangeCallback keyChangeCallback; } MediaKeySession_Callback; +/** + * @brief Call back will be invoked when event triggers. + * @param mediaKeySessoin MediaKeySession instance. + * @param eventType Event type. + * @param info Event info gotten from media key session. + * @param infoLen Event info len. + * @param extra Extra info gotten from media key session. + * @return Drm_ErrCode. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySession_EventCallback)(MediaKeySession *mediaKeySessoin, DRM_EventType eventType, + uint8_t *info, int32_t infoLen, char *extra); + +/** + * @brief Call back will be invoked when key changes. + * @param mediaKeySessoin MediaKeySession instance. + * @param keysInfo Key info gotten from media key system. + * @param newKeysAvailable Whether new keys available. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySession_KeyChangeCallback)(MediaKeySession *mediaKeySessoin, DRM_KeysInfo *keysInfo, + bool newKeysAvailable); + +/** + * @brief MediaKeySession_Callback struct, used to listen event like key expired and key change etc.. + * @since 12 + * @version 1.0 + */ +typedef struct OH_MediaKeySession_Callback { + /** + * Normal event callback like key expired etc.. + */ + OH_MediaKeySession_EventCallback eventCallback; + /** + * Key change callback for keys change event. + */ + OH_MediaKeySession_KeyChangeCallback keyChangeCallback; +} OH_MediaKeySession_Callback; + /** * @brief Generate media key request. * @param mediaKeySession Media key session instance. @@ -208,6 +250,17 @@ Drm_ErrCode OH_MediaKeySession_RequireSecureDecoderModule(MediaKeySession *media Drm_ErrCode OH_MediaKeySession_SetMediaKeySessionCallback(MediaKeySession *mediaKeySessoin, MediaKeySession_Callback *callback); +/** + * @brief Set media key session event callback. + * @param mediaKeySession Media key session instance. + * @param callback Callback to be set to the media key session. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySession_SetCallback(MediaKeySession *mediaKeySessoin, + OH_MediaKeySession_Callback *callback); + /** * @brief Release the resource before the session gonna be unused. * @param mediaKeySession Media key session instance. diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 88f27fdf9..9f84618f0 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -62,6 +62,40 @@ extern "C" { typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra); +/** + * @brief Call back will be invoked when event triggers. + * @param mediaKeySystem MediaKeySystem instance. + * @param eventType Event type. + * @param info Event info gotten from media key system. + * @param infoLen Event info len. + * @param extra Extra info gotten from media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySystem_Callback)(MediaKeySystem *mediaKeySystem, DRM_EventType eventType, + uint8_t *info, int32_t infoLen, char *extra); + +/** + * @brief Set media key system event callback. + * @param mediaKeySystem Media key system instance. + * @param callback Callback to be set to the media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySystem_SetCallback(MediaKeySystem *mediaKeySystem, OH_MediaKeySystem_Callback callback); + +/** + * @brief Acquire supported media key systems' name and uuid. + * @param descs Array used to save media key systems' name and uuid. + * @param count Used to indicate count of struct DRM_MediaKeySystemDescription. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count); + /** * @brief Query if media key system is supported. * @param name Used to point a Digital Right Management solution. @@ -273,15 +307,6 @@ Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySyste */ Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); -/** - * @brief Acquire supported media key systems' name and uuid. - * @param descs Array used to save media key systems' name and uuid. - * @param count Used to indicate count of struct DRM_MediaKeySystemDescription. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. - * @since 12 - * @version 1.0 - */ -Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count); #ifdef __cplusplus } -- Gitee From 472a74aa0329d89a168a02818a1e1c72661e5c24 Mon Sep 17 00:00:00 2001 From: baoxy92 Date: Thu, 9 May 2024 06:27:01 +0000 Subject: [PATCH 06/43] update multimedia/av_codec/native_cencinfo.h. Signed-off-by: baoxy92 --- multimedia/av_codec/native_cencinfo.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/multimedia/av_codec/native_cencinfo.h b/multimedia/av_codec/native_cencinfo.h index b7dbf5fba..29d774649 100644 --- a/multimedia/av_codec/native_cencinfo.h +++ b/multimedia/av_codec/native_cencinfo.h @@ -112,6 +112,7 @@ typedef struct DrmSubsample { /** * @brief Creates an OH_AVCencInfo instance for setting cencinfo. + * * Free the resources of the instance by calling OH_AVCencInfo_Destory. * @syscap SystemCapability.Multimedia.Media.Spliter * @return Returns a pointer to an OH_AVCencInfo instance @@ -122,6 +123,7 @@ OH_AVCencInfo *OH_AVCencInfo_Create(); /** * @brief Destroy the OH_AVCencInfo instance and free the internal resources. + * * The same instance can only be destroyed once. The destroyed instance * should not be used before it is created again. It is recommended setting * the instance pointer to NULL right after the instance is destroyed successfully. @@ -136,6 +138,7 @@ OH_AVErrCode OH_AVCencInfo_Destroy(OH_AVCencInfo *cencInfo); /** * @brief Method to set algo of cencinfo. + * * @syscap SystemCapability.Multimedia.Media.Spliter * @param cencInfo Pointer to an OH_AVCencInfo instance. * @param algo Cenc algo. @@ -148,6 +151,7 @@ OH_AVErrCode OH_AVCencInfo_SetAlgorithm(OH_AVCencInfo *cencInfo, enum DrmCencAlg /** * @brief Method to set key id and iv of cencinfo. + * * @syscap SystemCapability.Multimedia.Media.Spliter * @param cencInfo Pointer to an OH_AVCencInfo instance. * @param keyId Key id. @@ -164,6 +168,7 @@ OH_AVErrCode OH_AVCencInfo_SetKeyIdAndIv(OH_AVCencInfo *cencInfo, uint8_t *keyId /** * @brief Method to set subsample info of cencinfo. + * * @syscap SystemCapability.Multimedia.Media.Spliter * @param cencInfo Pointer to an OH_AVCencInfo instance. * @param encryptedBlockCount Number of encrypted blocks. @@ -181,6 +186,7 @@ OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t en /** * @brief Method to set mode of cencinfo. + * * @syscap SystemCapability.Multimedia.Media.Spliter * @param cencInfo Pointer to an OH_AVCencInfo instance. * @param mode Cenc mode, indicate whether key/iv/subsample set or not. @@ -193,6 +199,7 @@ OH_AVErrCode OH_AVCencInfo_SetMode(OH_AVCencInfo *cencInfo, enum DrmCencInfoMode /** * @brief Method to attach cencinfo to AVBuffer. + * * @syscap SystemCapability.Multimedia.Media.Spliter * @param cencInfo Pointer to an OH_AVCencInfo instance. * @param buffer AVBuffer to attach cencinfo. -- Gitee From d65a3389e72b018a6e4db191cf07e73d4f1233be Mon Sep 17 00:00:00 2001 From: baoxy92 Date: Thu, 9 May 2024 11:36:51 +0000 Subject: [PATCH 07/43] update multimedia/av_codec/native_cencinfo.h. Signed-off-by: baoxy92 --- multimedia/av_codec/native_cencinfo.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/multimedia/av_codec/native_cencinfo.h b/multimedia/av_codec/native_cencinfo.h index 29d774649..0c16be2f4 100644 --- a/multimedia/av_codec/native_cencinfo.h +++ b/multimedia/av_codec/native_cencinfo.h @@ -13,6 +13,25 @@ * limitations under the License. */ +/** + * @addtogroup Multimedia_Drm + * @{ + * + * @brief This feature enables third-party applications to implement the media decapsulation and demultiplexing functions by themselves instead of using the functions provided by the system. After the DRM instance and session are created, the decryption interface provided by the DRM can be invoked for decryption. The decryption parameter structure defines the transmission format of decryption parameters. + * + * @since 12 + */ + +/** + * @file native_cencinfo.h + * + * @brief Provides a unified entry for the native module APIs. + * + * @library libnative_media_avcencinfo.so + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 12 + */ + #ifndef NATIVE_AVCENCINFO_H #define NATIVE_AVCENCINFO_H -- Gitee From b3f77b3d908baa5103357d1e0dde7da86bda7804 Mon Sep 17 00:00:00 2001 From: baoxy92 Date: Thu, 9 May 2024 14:01:25 +0000 Subject: [PATCH 08/43] update multimedia/av_codec/native_cencinfo.h. Signed-off-by: baoxy92 --- multimedia/av_codec/native_cencinfo.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_cencinfo.h b/multimedia/av_codec/native_cencinfo.h index 0c16be2f4..2b17c1d10 100644 --- a/multimedia/av_codec/native_cencinfo.h +++ b/multimedia/av_codec/native_cencinfo.h @@ -17,7 +17,13 @@ * @addtogroup Multimedia_Drm * @{ * - * @brief This feature enables third-party applications to implement the media decapsulation and demultiplexing functions by themselves instead of using the functions provided by the system. After the DRM instance and session are created, the decryption interface provided by the DRM can be invoked for decryption. The decryption parameter structure defines the transmission format of decryption parameters. + * @brief This feature enables third-party applications to implement the + * media decapsulation and demultiplexing functions by themselves instead + * of using the functions provided by the system. + * + * After the DRM instance and session are created, the decryption interface + * provided by the DRM can be invoked for decryption. The decryption parameter + * structure defines the transmission format of decryption parameters. * * @since 12 */ -- Gitee From 8cfef5f3ef2deec5139c525eaa3b783913692d4d Mon Sep 17 00:00:00 2001 From: baoxy92 Date: Fri, 10 May 2024 01:43:48 +0000 Subject: [PATCH 09/43] update multimedia/av_codec/native_cencinfo.h. Signed-off-by: baoxy92 --- multimedia/av_codec/native_cencinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_cencinfo.h b/multimedia/av_codec/native_cencinfo.h index 2b17c1d10..5accda339 100644 --- a/multimedia/av_codec/native_cencinfo.h +++ b/multimedia/av_codec/native_cencinfo.h @@ -19,7 +19,7 @@ * * @brief This feature enables third-party applications to implement the * media decapsulation and demultiplexing functions by themselves instead - * of using the functions provided by the system. + * of using the functions provided by the system. * * After the DRM instance and session are created, the decryption interface * provided by the DRM can be invoked for decryption. The decryption parameter -- Gitee From 214d6d263cce32b37d918bd263e6b387ebdd8f7c Mon Sep 17 00:00:00 2001 From: Reily Date: Fri, 10 May 2024 12:03:44 +0800 Subject: [PATCH 10/43] =?UTF-8?q?sdk=E6=96=B0=E5=A2=9E=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=80=9A=E8=AF=9Dusage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reily --- multimedia/audio_framework/common/native_audiostream_base.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index f4b77d3cf..c47def15b 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -238,6 +238,12 @@ typedef enum { * @since 10 */ AUDIOSTREAM_USAGE_NAVIGATION = 13, + /** + * Video call usage. + * + * @since 12 + */ + AUDIOSTREAM_USAGE_VIDEO_COMMUNICATION = 17, } OH_AudioStream_Usage; /** -- Gitee From 8c9db40b0c9cb329bfe6e1b7489f68f421802a79 Mon Sep 17 00:00:00 2001 From: liyang Date: Sat, 11 May 2024 09:21:09 +0800 Subject: [PATCH 11/43] =?UTF-8?q?=E6=8C=89=E5=B1=8F=E5=B9=95=E5=BD=95?= =?UTF-8?q?=E5=88=B6=E6=8E=92=E9=99=A4=E6=8C=87=E5=AE=9Awindowid=E7=9A=84?= =?UTF-8?q?=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liyang --- multimedia/player_framework/native_avscreen_capture.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index 8cc18eaf2..2d07068fd 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -308,8 +308,9 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreen * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance * @param Pointer to windowIDs to be added * @param windowCount to be added - * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @return Function result code. + * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. + * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input filter is nullptr or input windowIDs invalid. * @since 12 * @version 1.0 */ -- Gitee From 74f638dc4c2322760d3eb19d04cbb4f8d98b96ba Mon Sep 17 00:00:00 2001 From: xiyupeng Date: Wed, 8 May 2024 17:49:18 +0800 Subject: [PATCH 12/43] =?UTF-8?q?scheme=20handler=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E6=96=B0=E5=A2=9EgetRequestResourceType?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiyupeng --- .../interfaces/native/arkweb_scheme_handler.h | 179 ++++++++++++++++++ .../interfaces/native/libohweb.ndk.json | 4 + 2 files changed, 183 insertions(+) diff --git a/web/webview/interfaces/native/arkweb_scheme_handler.h b/web/webview/interfaces/native/arkweb_scheme_handler.h index 9de9b94b4..b746fcff1 100644 --- a/web/webview/interfaces/native/arkweb_scheme_handler.h +++ b/web/webview/interfaces/native/arkweb_scheme_handler.h @@ -121,6 +121,175 @@ typedef enum ArkWeb_CustomSchemeOption { ARKWEB_SCHEME_OPTION_CODE_CACHE_ENABLED = 1 << 7, } ArkWeb_CustomSchemeOption; +/* + * @brief Resource type for a request. These constants match their equivalents in + * Chromium's ResourceType and should not be renumbered. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +typedef enum ArkWeb_ResourceType { + /* + * @brief Top level page. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + MAIN_FRAME = 0, + + /* + * @brief Frame or Iframe. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SUB_FRAME = 1, + + /* + * @brief CSS stylesheet. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + STYLE_SHEET = 2, + + /* + * @brief External script. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SCRIPT = 3, + + /* + * @brief Image (jpg/gif/png/etc). + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + IMAGE = 4, + + /* + * @brief Font. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + FONT_RESOURCE = 5, + + /* + * @brief Some other subresource. This is the default type if the actual type is unknown. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SUB_RESOURCE = 6, + + /* + * @brief Object (or embed) tag for a plugin, or a resource that a plugin requested. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + OBJECT = 7, + + /* + * @brief Media resource. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + MEDIA = 8, + + /* + * @brief Main resource of a dedicated worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + WORKER = 9, + + /* + * @brief Main resource of a shared worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SHARED_WORKER = 10, + + /* + * @brief Explicitly requested prefetch. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PREFETCH = 11, + + /* + * @brief Favicon. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + FAVICON = 12, + + /* + * @brief XMLHttpRequest. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + XHR = 13, + + /* + * @brief Ping request for /sendBeacon. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PING = 14, + + /* + * @brief The main resource of a service worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SERVICE_WORKER = 15, + + /* + * @brief Report of Content Security Policy violations. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + CSP_REPORT = 16, + + /* + * @brief Resource that a plugin requested. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PLUGIN_RESOURCE = 17, + + /* + * @brief A main-frame service worker navigation preload request. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + NAVIGATION_PRELOAD_MAIN_FRAME = 19, + + /* + * @brief A sub-frame service worker navigation preload request. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + NAVIGATION_PRELOAD_SUB_FRAME = 20, +} ArkWeb_ResourceType; + /* * @brief This class is used to intercept requests for a specified scheme. * @@ -324,6 +493,16 @@ void OH_ArkWebResourceRequest_GetHttpBodyStream(const ArkWeb_ResourceRequest* re */ void OH_ArkWebResourceRequest_DestroyHttpBodyStream(ArkWeb_HttpBodyStream* httpBodyStream); +/* + * @brief Get the resource type of request. + * @param resourceRequest The ArkWeb_ResourceRequest. + * @return The resource type of request. -1 if resourceRequest is invalid. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +int32_t OH_ArkWebResourceRequest_GetResourceType(const ArkWeb_ResourceRequest* resourceRequest); + /* * @brief Set a user data to ArkWeb_HttpBodyStream. * @param httpBodyStream The ArkWeb_HttpBodyStream. diff --git a/web/webview/interfaces/native/libohweb.ndk.json b/web/webview/interfaces/native/libohweb.ndk.json index 4e226f72c..4451e5d5a 100644 --- a/web/webview/interfaces/native/libohweb.ndk.json +++ b/web/webview/interfaces/native/libohweb.ndk.json @@ -91,6 +91,10 @@ "first_introduced": "12", "name": "OH_ArkWebResourceRequest_DestroyHttpBodyStream" }, + { + "first_introduced": "12", + "name": "OH_ArkWebResourceRequest_GetResourceType" + }, { "first_introduced": "12", "name": "OH_ArkWebHttpBodyStream_SetReadCallback" -- Gitee From 32022fc19a029e28f561a92f56087d569cde72dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=87=E7=8E=89=E5=8A=A0?= Date: Thu, 25 Apr 2024 17:58:30 +0800 Subject: [PATCH 13/43] =?UTF-8?q?=E6=B7=BB=E5=8A=A0fopencookie=E5=92=8Cren?= =?UTF-8?q?ameat2=E5=87=BD=E6=95=B0=E6=8E=A5=E5=8F=A3=E6=9A=B4=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 仇玉加 --- third_party/musl/ndk_musl_include/stdio.h | 3 ++- third_party/musl/ndk_script/adapter/libc.ndk.json | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/third_party/musl/ndk_musl_include/stdio.h b/third_party/musl/ndk_musl_include/stdio.h index e71ae4f8f..31e9ca11b 100644 --- a/third_party/musl/ndk_musl_include/stdio.h +++ b/third_party/musl/ndk_musl_include/stdio.h @@ -153,6 +153,7 @@ int putchar_unlocked(int); ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict); ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict); int renameat(int, const char *, int, const char *); +int renameat2(int, const char *, int, const char *, unsigned int); char *ctermid(char *); #define L_ctermid 20 #endif @@ -198,7 +199,7 @@ typedef struct _IO_cookie_io_functions_t { cookie_seek_function_t *seek; cookie_close_function_t *close; } cookie_io_functions_t; - +FILE *fopencookie(void *, const char *, cookie_io_functions_t); #endif #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) diff --git a/third_party/musl/ndk_script/adapter/libc.ndk.json b/third_party/musl/ndk_script/adapter/libc.ndk.json index 41070eecd..048a13499 100644 --- a/third_party/musl/ndk_script/adapter/libc.ndk.json +++ b/third_party/musl/ndk_script/adapter/libc.ndk.json @@ -430,6 +430,7 @@ { "name": "fnmatch" }, { "name": "fopen" }, { "name": "fopen64" }, + { "name": "fopencookie" }, { "name": "fork" }, { "name": "forkpty" }, { "name": "fpathconf" }, @@ -1061,6 +1062,7 @@ { "name": "remquol" }, { "name": "rename" }, { "name": "renameat" }, + { "name": "renameat2" }, { "name": "res_init" }, { "name": "res_mkquery" }, { "name": "res_query" }, -- Gitee From ef8a0d13e4f10b230d6dce03854e8480cde87ea4 Mon Sep 17 00:00:00 2001 From: liyang Date: Sat, 11 May 2024 14:31:46 +0800 Subject: [PATCH 14/43] =?UTF-8?q?=E6=8C=89=E5=B1=8F=E5=B9=95=E5=BD=95?= =?UTF-8?q?=E5=88=B6=E6=8E=92=E9=99=A4=E6=8C=87=E5=AE=9Awindowid=E7=9A=84?= =?UTF-8?q?=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liyang --- multimedia/player_framework/native_avscreen_capture.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index 2d07068fd..8cc18eaf2 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -308,9 +308,8 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreen * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance * @param Pointer to windowIDs to be added * @param windowCount to be added - * @return Function result code. - * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. - * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input filter is nullptr or input windowIDs invalid. + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} * @since 12 * @version 1.0 */ -- Gitee From d818dacc754907336a9050f53680c9b3c6517aca Mon Sep 17 00:00:00 2001 From: cyberbox <468042667@qq.com> Date: Sat, 11 May 2024 18:03:18 +0800 Subject: [PATCH 15/43] update capi return descriptions Signed-off-by: cyberbox <468042667@qq.com> Change-Id: I6558383d3dac999918fb50047f00e1f64342a9e4 --- multimedia/media_foundation/native_avbuffer.h | 40 +++-- multimedia/media_foundation/native_averrors.h | 28 ++-- multimedia/media_foundation/native_avformat.h | 30 +++- multimedia/media_foundation/native_avmemory.h | 11 +- multimedia/player_framework/avplayer.h | 152 +++++++++++------- 5 files changed, 170 insertions(+), 91 deletions(-) diff --git a/multimedia/media_foundation/native_avbuffer.h b/multimedia/media_foundation/native_avbuffer.h index 19ec2be46..088750f05 100644 --- a/multimedia/media_foundation/native_avbuffer.h +++ b/multimedia/media_foundation/native_avbuffer.h @@ -33,7 +33,9 @@ typedef struct OH_NativeBuffer OH_NativeBuffer; * to by the return value * needs to be manually released by {@link OH_AVBuffer_Destroy}. * @syscap SystemCapability.Multimedia.Media.Core * @param capacity the buffer's capacity, bytes - * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr + * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr. + * Possible failure causes: 1. capacity <= 0. 2. create allocator failed. 3. create OH_AVBuffer failed. + * 4. created buffer memory is nullptr. 5. created buffer memory's addr is nullptr. 6. failed to new OH_AVBuffer. * @since 11 */ OH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); @@ -42,8 +44,10 @@ OH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); * @brief Clear the internal resources of the buffer and destroy the buffer instance. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr or buffer's magic error. + * {@link AV_ERR_OPERATE_NOT_PERMIT} if input buffer is not user created. * @since 11 */ OH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); @@ -54,8 +58,10 @@ OH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to * {@link OH_AVCodecBufferAttr} - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @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 or attr is nullptr. * @since 11 */ OH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr); @@ -66,8 +72,10 @@ OH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to * {@link OH_AVCodecBufferAttr} - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @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, attr is nullptr, the size or offset of input buffer's memory is invalid. * @since 11 */ OH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr); @@ -78,7 +86,8 @@ OH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBuff * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return Returns Encapsulate OH_AVFormat structure instance pointer if the execution is successful, - * otherwise returns nullptr + * otherwise returns nullptr. Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's meta is nullptr. * @since 11 */ OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); @@ -88,8 +97,10 @@ OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param format Encapsulate OH_AVFormat structure instance pointer - * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to - * {@link OH_AVErrCode} + * @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. * @since 11 */ OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *format); @@ -99,6 +110,8 @@ OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *fo * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return the buffer's virtual address if the buffer is valid, otherwise nullptr + * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. * @since 11 */ uint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); @@ -108,6 +121,8 @@ uint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return the buffer's capacity if the buffer is valid, otherwise -1 + * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. * @since 11 */ int32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); @@ -117,8 +132,9 @@ int32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); * instance pointed to by the return value * needs to be manually released by {@link OH_NativeBuffer_Unreference}. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer - * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, - * otherwise returns nullptr + * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, otherwise returns nullptr + * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. + * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. 5. surfaceBuffer is nullptr. * @since 11 */ OH_NativeBuffer *OH_AVBuffer_GetNativeBuffer(OH_AVBuffer *buffer); diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index eb2ad2039..19d2ca436 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -27,54 +27,56 @@ extern "C" { */ typedef enum OH_AVErrCode { /** - * the operation completed successfully. + * @error the operation completed successfully. */ AV_ERR_OK = 0, /** - * no memory. + * @error no memory. */ AV_ERR_NO_MEMORY = 1, /** - * opertation not be permitted. + * @error opertation not be permitted. */ AV_ERR_OPERATE_NOT_PERMIT = 2, /** - * invalid argument. + * @error invalid argument. */ AV_ERR_INVALID_VAL = 3, /** - * IO error. + * @error IO error. */ AV_ERR_IO = 4, /** - * network timeout. + * @error network timeout. */ AV_ERR_TIMEOUT = 5, /** - * unknown error. + * @error unknown error. */ AV_ERR_UNKNOWN = 6, /** - * media service died. + * @error media service died. */ AV_ERR_SERVICE_DIED = 7, /** - * the state is not support this operation. + * @error the state is not support this operation. */ AV_ERR_INVALID_STATE = 8, /** - * unsupport interface. + * @error unsupport interface. */ AV_ERR_UNSUPPORT = 9, /** - * extend err start. + * @error extend err start. */ AV_ERR_EXTEND_START = 100, - /** drm error base. + /** + * @error drm error base. * @since 12 */ AV_ERR_DRM_BASE = 200, - /** drm decypt failed. + /** + * @error drm decypt failed. * @since 12 */ AV_ERR_DRM_DECRYPT_FAILED = 201, diff --git a/multimedia/media_foundation/native_avformat.h b/multimedia/media_foundation/native_avformat.h index 4335cee33..12aa1a1d4 100644 --- a/multimedia/media_foundation/native_avformat.h +++ b/multimedia/media_foundation/native_avformat.h @@ -70,7 +70,8 @@ struct OH_AVFormat *OH_AVFormat_Create(void); * @param mimeType mime type * @param sampleRate sample rate * @param channelCount channel count - * @return Returns a pointer to an OH_AVFormat instance + * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise nullptr + * Possible failure causes: 1. mimeType is nullptr. 2. new format is nullptr. * @since 10 * @version 1.0 */ @@ -84,7 +85,8 @@ struct OH_AVFormat *OH_AVFormat_CreateAudioFormat(const char *mimeType, * @param mimeType mime type * @param width width * @param height height - * @return Returns a pointer to an OH_AVFormat instance + * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise nullptr + * Possible failure causes: 1. mimeType is nullptr. 2. new format is nullptr. * @since 10 * @version 1.0 */ @@ -108,6 +110,7 @@ void OH_AVFormat_Destroy(struct OH_AVFormat *format); * @param to OH_AVFormat handle pointer to receive data * @param from pointer to the OH_AVFormat handle of the copied data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. * @since 9 * @version 1.0 */ @@ -120,6 +123,7 @@ bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from); * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -132,6 +136,7 @@ bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_ * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -144,6 +149,7 @@ bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64 * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -156,6 +162,7 @@ bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, floa * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. * @since 9 * @version 1.0 */ @@ -168,6 +175,8 @@ bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, dou * @param key key to write data * @param value written data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. value is nullptr. * @since 9 * @version 1.0 */ @@ -181,6 +190,8 @@ bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, con * @param addr written data addr * @param size written data length * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. addr is nullptr. 5. size is zero. * @since 9 * @version 1.0 */ @@ -193,6 +204,8 @@ bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const ui * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -205,6 +218,8 @@ bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_ * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -217,6 +232,8 @@ bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64 * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -229,6 +246,8 @@ bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, floa * @param key read key value * @param out read data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. * @since 9 * @version 1.0 */ @@ -242,6 +261,8 @@ bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, dou * @param out The read string pointer, the data life cycle pointed to is updated with GetString, * and Format is destroyed. If the caller needs to hold it for a long time, it must copy the memory * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. out is nullptr. 5. malloc out string nullptr. * @since 9 * @version 1.0 */ @@ -256,6 +277,8 @@ bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, con * if the caller needs to hold it for a long time, it must copy the memory * @param size Length of read and write data * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * 4. addr is nullptr. 5. size is nullptr. * @since 9 * @version 1.0 */ @@ -265,7 +288,8 @@ bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t * @brief Output the information contained in OH_AVFormat as a string. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance - * @return Returns a string consisting of key and data + * @return Returns a string consisting of key and data for success, nullptr for failure + * Possible failure causes: 1. input format is nullptr. 2. malloc dump info nullptr. * @since 9 * @version 1.0 */ diff --git a/multimedia/media_foundation/native_avmemory.h b/multimedia/media_foundation/native_avmemory.h index 489a4ff49..e4457d835 100644 --- a/multimedia/media_foundation/native_avmemory.h +++ b/multimedia/media_foundation/native_avmemory.h @@ -29,7 +29,9 @@ typedef struct OH_AVMemory OH_AVMemory; * @brief Create an OH_AVMemory instance * @syscap SystemCapability.Multimedia.Media.Core * @param size the memory's size, bytes. - * @return Returns a pointer to an OH_AVMemory instance, needs to be freed by OH_AVMemory_Destroy. + * @return Returns a pointer to an OH_AVMemory instance for success, needs to be freed by OH_AVMemory_Destroy, + * otherwise returns nullptr. Possible failure causes: 1. size <= 0. 2. create OH_AVMemory failed. + * 3.failed to new OH_AVMemory. * @deprecated since 11 * @useinstead OH_AVBuffer_Create * @since 10 @@ -41,6 +43,7 @@ OH_AVMemory *OH_AVMemory_Create(int32_t size); * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return the memory's virtual address if the memory is valid, otherwise nullptr. + * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. * @deprecated since 11 * @useinstead OH_AVBuffer_GetAddr * @since 9 @@ -53,6 +56,7 @@ uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return the memory's size if the memory is valid, otherwise -1. + * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. * @deprecated since 11 * @useinstead OH_AVBuffer_GetCapacity * @since 9 @@ -65,8 +69,9 @@ int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); * instance * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input mem is nullptr, mem's magic error or input mem is not user created. * @deprecated since 11 * @useinstead OH_AVBuffer_Destroy * @since 10 diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index 0939a6516..22725740d 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -65,7 +65,7 @@ typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; * @brief Call back will be invoked when updating DRM information. * @param player Player instance. * @param mediaKeySystemInfo DRM information. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @return void * @since 12 * @version 1.0 */ @@ -74,7 +74,8 @@ typedef void (*Player_MediaKeySystemInfoCallback)(OH_AVPlayer *player, DRM_Media /** * @brief Create a player * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @return Returns a pointer to an OH_AVPlayer instance + * @return Returns a pointer to an OH_AVPlayer instance for success, nullptr for failure + * Possible failure causes: 1. failed to PlayerFactory::CreatePlayer. 2. failed to new PlayerObject. * @since 11 * @version 1.0 */ @@ -85,8 +86,9 @@ OH_AVPlayer *OH_AVPlayer_Create(void); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param url Indicates the playback source. - * @return Returns {@link AV_ERR_OK} if the url is set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, url is null or player setUrlSource failed. * @since 11 * @version 1.0 */ @@ -99,8 +101,9 @@ OH_AVErrCode OH_AVPlayer_SetURLSource(OH_AVPlayer *player, const char *url); * @param fd Indicates the file descriptor of media source. * @param offset Indicates the offset of media source in file descriptor. * @param size Indicates the size of media source. - * @return Returns {@link AV_ERR_OK} if the fd source is set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player setFdSource failed. * @since 11 * @version 1.0 */ @@ -113,8 +116,9 @@ OH_AVErrCode OH_AVPlayer_SetFDSource(OH_AVPlayer *player, int32_t fd, int64_t of * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Prepare} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Prepare failed. * @since 11 * @version 1.0 */ @@ -128,8 +132,9 @@ OH_AVErrCode OH_AVPlayer_Prepare(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if the playback is started; otherwise returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Play failed. * @since 11 * @version 1.0 */ @@ -139,8 +144,9 @@ OH_AVErrCode OH_AVPlayer_Play(OH_AVPlayer *player); * @brief Pauses playback. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Pause} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Pause failed. * @since 11 * @version 1.0 */ @@ -150,8 +156,9 @@ OH_AVErrCode OH_AVPlayer_Pause(OH_AVPlayer *player); * @brief Stop playback. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Stop} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Stop failed. * @since 11 * @version 1.0 */ @@ -165,8 +172,9 @@ OH_AVErrCode OH_AVPlayer_Stop(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Reset} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Reset failed. * @since 11 * @version 1.0 */ @@ -181,8 +189,9 @@ OH_AVErrCode OH_AVPlayer_Reset(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if {@link Release} is successfully added to the task queue; - * returns an error code defined in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Release failed. * @since 11 * @version 1.0 */ @@ -197,8 +206,9 @@ OH_AVErrCode OH_AVPlayer_Release(OH_AVPlayer *player); * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns {@link AV_ERR_OK} if the playback is released; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player ReleaseSync failed. * @since 11 * @version 1.0 */ @@ -217,8 +227,9 @@ OH_AVErrCode OH_AVPlayer_ReleaseSync(OH_AVPlayer *player); * ranging from 0 to 1. each step is 0.01. * @param rightVolume Indicates the target volume of the right audio channel to set, * ranging from 0 to 1. each step is 0.01. - * @return Returns {@link AV_ERR_OK} if the volume is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetVolume failed. * @since 11 * @version 1.0 */ @@ -233,8 +244,9 @@ OH_AVErrCode OH_AVPlayer_SetVolume(OH_AVPlayer *player, float leftVolume, float * @param player Pointer to an OH_AVPlayer instance * @param mSeconds Indicates the target playback position, accurate to milliseconds. * @param mode Indicates the player seek mode. For details, see {@link AVPlayerSeekMode}. - * @return Returns {@link AV_ERR_OK} if the seek is done; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Seek failed. * @since 11 * @version 1.0 */ @@ -245,8 +257,9 @@ OH_AVErrCode OH_AVPlayer_Seek(OH_AVPlayer *player, int32_t mSeconds, AVPlayerSee * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param currentTime Indicates the playback position. - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetCurrentTime failed. * @since 11 * @version 1.0 */ @@ -257,8 +270,9 @@ OH_AVErrCode OH_AVPlayer_GetCurrentTime(OH_AVPlayer *player, int32_t *currentTim * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param videoWidth The video width - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr. * @since 11 * @version 1.0 */ @@ -269,8 +283,9 @@ OH_AVErrCode OH_AVPlayer_GetVideoWidth(OH_AVPlayer *player, int32_t *videoWidth) * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param videoHeight The video height - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr. * @since 11 * @version 1.0 */ @@ -281,8 +296,9 @@ OH_AVErrCode OH_AVPlayer_GetVideoHeight(OH_AVPlayer *player, int32_t *videoHeigh * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param speed the rate mode {@link AVPlaybackSpeed} which can set. - * @return Returns {@link AV_ERR_OK} if the playback rate is set successful; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetPlaybackSpeed failed. * @since 11 * @version 1.0 */ @@ -293,8 +309,9 @@ OH_AVErrCode OH_AVPlayer_SetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed s * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param speed the rate mode {@link AVPlaybackSpeed} which can get. - * @return Returns {@link AV_ERR_OK} if the current player playback rate is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetPlaybackSpeed failed. * @since 11 * @version 1.0 */ @@ -313,8 +330,9 @@ OH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed * * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param bitRate the bit rate, The unit is bps. - * @return Returns {@link AV_ERR_OK} if the bit rate is set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SelectBitRate failed. * @since 11 * @version 1.0 */ @@ -325,8 +343,10 @@ OH_AVErrCode OH_AVPlayer_SelectBitRate(OH_AVPlayer *player, uint32_t bitRate); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} - * @return Returns {@link AV_ERR_OK} if the surface is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, input window is nullptr, + * or player SetVideoSurface failed. * @since 11 * @version 1.0 */ @@ -337,8 +357,9 @@ OH_AVErrCode OH_AVPlayer_SetVideoSurface(OH_AVPlayer *player, OHNativeWindow *w * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param duration Indicates the total duration of media files. - * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetDuration failed. * @since 11 * @version 1.0 */ @@ -349,8 +370,9 @@ OH_AVErrCode OH_AVPlayer_GetDuration(OH_AVPlayer *player, int32_t *duration); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param state the current playback state - * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr. * @since 11 * @version 1.0 */ @@ -360,7 +382,7 @@ OH_AVErrCode OH_AVPlayer_GetState(OH_AVPlayer *player, AVPlayerState *state); * @brief Checks whether the player is playing. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns true if the playback is playing; false otherwise. + * @return Returns true if the playback is playing; Return false if not or input player is nullptr. * @since 11 * @version 1.0 */ @@ -370,7 +392,7 @@ bool OH_AVPlayer_IsPlaying(OH_AVPlayer *player); * @brief Returns the value whether single looping is enabled or not . * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance - * @return Returns true if the playback is single looping; false otherwise. + * @return Returns true if the playback is single looping; Return false if not or input player is nullptr. * @since 11 * @version 1.0 */ @@ -381,8 +403,9 @@ bool OH_AVPlayer_IsLooping(OH_AVPlayer *player); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param loop The switch to set loop - * @return Returns {@link AV_ERR_OK} if the single looping is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetLooping failed. * @since 11 * @version 1.0 */ @@ -393,8 +416,10 @@ OH_AVErrCode OH_AVPlayer_SetLooping(OH_AVPlayer *player, bool loop); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param callback object pointer. - * @return Returns {@link AV_ERR_OK} if the playercallback is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, + * or player SetPlayerCallback failed. * @since 11 * @version 1.0 */ @@ -410,8 +435,9 @@ OH_AVErrCode OH_AVPlayer_SetPlayerCallback(OH_AVPlayer *player, AVPlayerCallback * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param index Track index - * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SelectTrack failed. * @since 11 * @version 1.0 */ @@ -427,8 +453,9 @@ OH_AVErrCode OH_AVPlayer_SelectTrack(OH_AVPlayer *player, int32_t index); * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param index Track index - * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player DeselectTrack failed. * @since 11 * @version 1.0 */ @@ -443,8 +470,9 @@ OH_AVErrCode OH_AVPlayer_DeselectTrack(OH_AVPlayer *player, int32_t index); * @param player Pointer to an OH_AVPlayer instance * @param trackType Media type. * @param index Track index - * @return Returns {@link AV_ERR_OK} if the track index is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetCurrentTrack failed. * @since 11 * @version 1.0 */ @@ -455,8 +483,10 @@ OH_AVErrCode OH_AVPlayer_GetCurrentTrack(OH_AVPlayer *player, int32_t trackType, * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param callback object pointer. - * @return Returns {@link AV_ERR_OK} if the drm info callback is set; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, MediaKeySystemInfoCallback is null + * player SetDrmSystemInfoCallback failed, SetDrmSystemInfoCallback failed or SetDrmSystemInfoCallback failed. * @since 12 * @version 1.0 */ @@ -468,8 +498,9 @@ OH_AVErrCode OH_AVPlayer_SetMediaKeySystemInfoCallback(OH_AVPlayer *player, * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance * @param mediaKeySystemInfo Media key system info. - * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or no memory. * @since 12 * @version 1.0 */ @@ -482,8 +513,9 @@ OH_AVErrCode OH_AVPlayer_GetMediaKeySystemInfo(OH_AVPlayer *player, DRM_MediaKey * @param player Pointer to an OH_AVPlayer instance * @param mediaKeySession A media key session instance with decryption function. * @param secureVideoPath Require secure decoder or not. - * @return Returns {@link AV_ERR_OK} if set successfully; returns an error code defined - * in {@link native_averrors.h} otherwise. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetDecryptConfig failed. * @since 12 * @version 1.0 */ -- Gitee From b8b2d50ccf338bc81105633ed506d51f2ee9b56c Mon Sep 17 00:00:00 2001 From: m00472246 Date: Sun, 12 May 2024 09:10:20 +0800 Subject: [PATCH 16/43] =?UTF-8?q?matrix=E6=8C=89=E7=85=A7=E6=96=B0?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=8F=90=E4=BE=9B=20Signed-off-by:=20m004722?= =?UTF-8?q?46=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: m00472246 --- .../native_image/libnative_image.ndk.json | 3 ++- graphic/graphic_2d/native_image/native_image.h | 13 +++++++++++++ .../graphic_2d/native_window/external_window.h | 18 ++++++++++++++++++ .../native_window/libnative_window.ndk.json | 3 ++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/graphic/graphic_2d/native_image/libnative_image.ndk.json b/graphic/graphic_2d/native_image/libnative_image.ndk.json index 45bb3093e..fbc8a27c0 100644 --- a/graphic/graphic_2d/native_image/libnative_image.ndk.json +++ b/graphic/graphic_2d/native_image/libnative_image.ndk.json @@ -9,5 +9,6 @@ { "name": "OH_NativeImage_GetSurfaceId" }, { "name": "OH_NativeImage_SetOnFrameAvailableListener" }, { "name": "OH_NativeImage_UnsetOnFrameAvailableListener" }, - { "name": "OH_NativeImage_Destroy" } + { "name": "OH_NativeImage_Destroy" }, + { "name": "OH_NativeImage_GetTransformMatrixV2" } ] \ 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 b344a332c..77577ff3f 100644 --- a/graphic/graphic_2d/native_image/native_image.h +++ b/graphic/graphic_2d/native_image/native_image.h @@ -201,6 +201,19 @@ int32_t OH_NativeImage_UnsetOnFrameAvailableListener(OH_NativeImage* image); */ void OH_NativeImage_Destroy(OH_NativeImage** image); +/** + * @brief Obtains the transform matrix of the texture image by producer transform type.\n + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeImage + * @param image Indicates the pointer to a OH_NativeImage instance. + * @param matrix Indicates the retrieved 4*4 transform matrix . + * @return 0 - Success. + * 40001000 - image is NULL. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeImage_GetTransformMatrixV2(OH_NativeImage* image, float matrix[16]); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_window/external_window.h b/graphic/graphic_2d/native_window/external_window.h index db6607b5f..f851a3fee 100644 --- a/graphic/graphic_2d/native_window/external_window.h +++ b/graphic/graphic_2d/native_window/external_window.h @@ -658,6 +658,24 @@ int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHS * @version 1.0 */ void OH_NativeWindow_SetBufferHold(OHNativeWindow *window); + +/** + * @brief Get the last flushed OHNativeWindowBuffer from an OHNativeWindow instance. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param window Indicates the pointer to an OHNativeWindow instance. + * @param buffer Indicates the pointer to an OHNativeWindowBuffer pointer. + * @param fenceFd Indicates the pointer to a file descriptor handle. + * @param matrix Indicates the retrieved 4*4 transform matrix. + * @return 0 - Success. + * 40001000 - window is NULL or buffer is NULL or fenceFd is NULL. + * 41207000 - buffer state is wrong. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer, + int *fenceFd, float matrix[16]); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_window/libnative_window.ndk.json b/graphic/graphic_2d/native_window/libnative_window.ndk.json index 668400ec6..5707571da 100644 --- a/graphic/graphic_2d/native_window/libnative_window.ndk.json +++ b/graphic/graphic_2d/native_window/libnative_window.ndk.json @@ -25,5 +25,6 @@ { "name": "OH_NativeWindow_CreateNativeWindowFromSurfaceId"}, { "name": "OH_NativeWindow_NativeWindowAttachBuffer" }, { "name": "OH_NativeWindow_NativeWindowDetachBuffer" }, - { "name": "OH_NativeWindow_SetBufferHold" } + { "name": "OH_NativeWindow_SetBufferHold" }, + { "name": "OH_NativeWindow_GetLastFlushedBufferV2" } ] \ No newline at end of file -- Gitee From 950977f4afb38d5ac24e8e0dc7391aeb0d9f5c22 Mon Sep 17 00:00:00 2001 From: ustc-tianyu Date: Sun, 12 May 2024 17:03:44 +0800 Subject: [PATCH 17/43] add shader ndk interface Signed-off-by: ustc-tianyu --- .../native_drawing/drawing_shader_effect.h | 25 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 4 +++ 2 files changed, 29 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h index 8cf8e8802..1af5ad345 100644 --- a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h @@ -196,6 +196,31 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Dra OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Image*, OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY, const OH_Drawing_SamplingOptions*, const OH_Drawing_Matrix*); +/** + * @brief Creates an OH_Drawing_ShaderEffect that generates a conical gradient given two circles. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param startPt Indicates the center of the start circle for the gradient. + * @param startRadius Indicates the radius of the start circle for this gradient. + * @param endPt Indicates the center of the start circle for the gradient. + * @param endRadius Indicates the radius of the start circle for this gradient. + * @param colors Indicates the colors to be distributed between the two points. + * @param pos Indicates the relative position of each corresponding color in the colors array. + * @param size Indicates the number of colors and pos. + * @param OH_Drawing_TileMode Indicates the tile mode. + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object, + which represents the local matrix of the created OH_Drawing_ShaderEffect object. + If matrix is nullptr, defaults to the identity matrix. + * @return Returns the pointer to the OH_Drawing_ShaderEffect object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is any of startPt, endPt, colors and pos is nullptr. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(const OH_Drawing_Point2D* startPt, + float startRadius, const OH_Drawing_Point2D* endPt, float endRadius, const uint32_t* colors, const float* pos, + uint32_t size, OH_Drawing_TileMode, const OH_Drawing_Matrix*); + /** * @brief Destroys an OH_Drawing_ShaderEffect object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index def9cec8c..7a4f51b44 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -583,6 +583,10 @@ "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateImageShader" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ShaderEffectCreateTwoPointConicalGradient" + }, { "name": "OH_Drawing_ShaderEffectDestroy" }, { "first_introduced": "12", -- Gitee From 8e74603f5975a8b021f78eecb88a0722cfaf3f5f Mon Sep 17 00:00:00 2001 From: xuerunlong Date: Mon, 13 May 2024 15:31:31 +0800 Subject: [PATCH 18/43] =?UTF-8?q?ndk=E8=B5=84=E6=96=99=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuerunlong --- filemanagement/environment/include/oh_environment.h | 12 ++++++++++++ filemanagement/fileio/include/oh_fileio.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/filemanagement/environment/include/oh_environment.h b/filemanagement/environment/include/oh_environment.h index 5621fd7a5..7acc28d6d 100644 --- a/filemanagement/environment/include/oh_environment.h +++ b/filemanagement/environment/include/oh_environment.h @@ -43,6 +43,10 @@ extern "C" { * @permission ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. + * {@link PERMISSION_ERROR} 201 - Non System Application. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_Environment_GetUserDownloadDir(char **result); @@ -53,6 +57,10 @@ FileManagement_ErrCode OH_Environment_GetUserDownloadDir(char **result); * @permission ohos.permission.READ_WRITE_DESKTOP_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. + * {@link PERMISSION_ERROR} 201 - Non System Application. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_Environment_GetUserDesktopDir(char **result); @@ -63,6 +71,10 @@ FileManagement_ErrCode OH_Environment_GetUserDesktopDir(char **result); * @permission ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. + * {@link PERMISSION_ERROR} 201 - Non System Application. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_Environment_GetUserDocumentDir(char **result); diff --git a/filemanagement/fileio/include/oh_fileio.h b/filemanagement/fileio/include/oh_fileio.h index 65970bdca..1b57f82f0 100644 --- a/filemanagement/fileio/include/oh_fileio.h +++ b/filemanagement/fileio/include/oh_fileio.h @@ -63,6 +63,9 @@ typedef enum FileIO_FileLocation { * @param uriLength Input the length of the uri. * @param location Output the result of file location. * @return Return the status code of the execution. + * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. + * {@link E_NONET} 13900002 - No such file or directory. + * {@link E_NOMEM} 13900011 - Failed to apply for memory. * @since 12 */ FileManagement_ErrCode OH_FileIO_GetFileLocation(char *uri, int uriLength, -- Gitee From 760d48b7dfddba9fabc7d85b915c5479aca5f3cb Mon Sep 17 00:00:00 2001 From: jwx1102601 Date: Mon, 13 May 2024 14:53:38 +0800 Subject: [PATCH 19/43] =?UTF-8?q?CAPI=E5=91=BD=E5=90=8D=E3=80=81Doc?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=B7=A5=E5=85=B7=E9=80=82=E9=85=8Dcodecheck?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jwx1102601 --- build-tools/capi_parser/src/bin/config.py | 44 +++-- .../capi_parser/src/coreImpl/check/check.py | 112 +++++------ .../src/coreImpl/check/check_doc.py | 178 ++++++++---------- .../src/coreImpl/check/check_name.py | 171 ++++++++++------- .../capi_parser/src/typedef/check/check.py | 120 ++++++++++++ .../capi_parser/src/utils/constants.py | 4 +- 6 files changed, 375 insertions(+), 254 deletions(-) diff --git a/build-tools/capi_parser/src/bin/config.py b/build-tools/capi_parser/src/bin/config.py index b988bef76..5751fd7c8 100644 --- a/build-tools/capi_parser/src/bin/config.py +++ b/build-tools/capi_parser/src/bin/config.py @@ -24,7 +24,6 @@ class ToolNameType(enum.Enum): DIFF = 'diff' CHECK = 'check' COLLECT_H = 'collect_h' - COLLECT_FILE = 'collect_file' tool_name_type_set = [ @@ -46,16 +45,15 @@ format_set = [ def run_tools(options): tool_name = options.tool_name + print(tool_name) if tool_name == ToolNameType["COLLECT"].value: parser.parser(options.parser_path) elif tool_name == ToolNameType["DIFF"].value: diff.process_dir(options.diff_path_old, options.diff_path_new) - elif tool_name == ToolNameType['CHECK'].value: - check.curr_entry(options.parser_path) + elif tool_name == ToolNameType["CHECK"].value: + check.curr_entry(options.path, options.checker, options.output) elif tool_name == ToolNameType['COLLECT_H'].value: parser.parser_direct(options.parser_path) - elif tool_name == ToolNameType['COLLECT_FILE'].value: - parser.parser_file_level(options.output_path) else: print("工具名称错误") @@ -68,19 +66,40 @@ class Config(object): { "name": "--tool-name", "abbr": "-N", - "required": True, + "required": False, "choices": tool_name_type_set, "type": str, - "default": ToolNameType["COLLECT"], - "help": "工具名称" + "default": ToolNameType["CHECK"].value, + "help": "工具名称,命令中不写-N的话,默认为check工具" }, { "name": "--parser-path", "abbr": "-P", - "required": True, + "required": False, "type": str, "help": "解析路径" }, + { + "name": "--codecheck--path", + "abbr": "--path", + "required": False, + "type": str, + "help": "codecheck解析文件路径" + }, + { + "name": "--check-command", + "abbr": "--checker", + "required": False, + "type": str, + "help": "校验命令" + }, + { + "name": "--check-output", + "abbr": "--output", + "required": False, + "type": str, + "help": "输出路径" + }, { "name": "--diff-path-old", "abbr": "-old", @@ -94,13 +113,6 @@ class Config(object): "required": False, "type": str, "help": "新文件路径" - }, - { - "name": "--output-path", - "abbr": "-O", - "required": False, - "type": str, - "help": "collect_file工具输出文件路径" } ] diff --git a/build-tools/capi_parser/src/coreImpl/check/check.py b/build-tools/capi_parser/src/coreImpl/check/check.py index 6c25fc305..d1298f989 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check.py +++ b/build-tools/capi_parser/src/coreImpl/check/check.py @@ -14,24 +14,28 @@ # limitations under the License. import json -import openpyxl as op +import os.path from pathlib import Path -from typedef.check.check import FileDocInfo, OutputTxt +from typedef.check.check import FileDocInfo, check_command_message, CheckErrorMessage from coreImpl.check.check_doc import process_comment, process_file_doc_info -from coreImpl.check.check_name import check_file_name, check_ndk_name +from coreImpl.check.check_name import check_file_name, check_api_name from coreImpl.parser.parser import parser_include_ast -from coreImpl.check.check_syntax import check_syntax -def process_api_json(api_info, file_doc_info, api_result_info_list): - api_result_info_list.extend(check_ndk_name(api_info)) +def process_api_json(api_info, file_doc_info, api_result_info_list, parent_kind, command_list): + for command in command_list: + # 对非文件名校验 + if 'NAME' in command and CheckErrorMessage.API_NAME_UNIVERSAL_14.name != command: + api_result_info_list.extend(check_api_name(api_info, parent_kind)) + break if 'comment' in api_info.keys(): comment = api_info['comment'] api_result_info_list.extend( - process_comment(comment, file_doc_info, api_info)) + process_comment(comment, file_doc_info, api_info)) + kind = api_info['kind'] child_node_list = get_api_info_child(api_info) for child_node in child_node_list: - process_api_json(child_node, file_doc_info, api_result_info_list) + process_api_json(child_node, file_doc_info, api_result_info_list, kind, command_list) def get_api_info_child(api_info): @@ -44,20 +48,24 @@ def get_api_info_child(api_info): return [] -def process_file_json(file_info, api_result_info_list): - api_result_info_list.extend(check_file_name(file_info['name'])) +def process_file_json(file_info, api_result_info_list, command_list): + # 校验文件名 + if CheckErrorMessage.API_NAME_UNIVERSAL_14.name in command_list: + api_result_info_list.extend(check_file_name(file_info)) apis = file_info['children'] + kind = file_info['kind'] file_doc_info = FileDocInfo() + # 校验Doc信息 api_result_info_list.extend(process_comment(file_info["comment"], file_doc_info, file_info)) for api in apis: - process_api_json(api, file_doc_info, api_result_info_list) + process_api_json(api, file_doc_info, api_result_info_list, kind, command_list) api_result_info_list.extend(process_file_doc_info(file_doc_info, file_info)) -def process_all_json(python_obj): +def process_all_json(python_obj, command_list): api_result_info_list = [] for file_info in python_obj: - process_file_json(file_info, api_result_info_list) + process_file_json(file_info, api_result_info_list, command_list) return api_result_info_list @@ -69,66 +77,38 @@ def write_in_txt(check_result, output_path): def result_to_json(check_result): - txt_resul = [] - for result in check_result: - location = f'{result.location}(line:{result.location_line}, col:{result.location_column})' - message = 'API check error of [{}]:{}'.format(result.error_type['description'], result.error_info) - txt_resul.append(OutputTxt(result.error_type['id'], result.level, result.api_since, - location, result.file_name, message)) - generate_excel(txt_resul) - return json.dumps(txt_resul, default=lambda obj: obj.__dict__, indent=4) - - -def generate_excel(result_info_list): - data = [] - for diff_info in result_info_list: - info_data = [ - diff_info.id, - diff_info.level, - diff_info.location, - diff_info.file_path, - diff_info.message - ] - data.append(info_data) - wb = op.Workbook() - ws = wb['Sheet'] - ws.append(['类型', '等级', '所在文件位置', '所在文件', '信息']) - for i in range(len(data)): - d = data[i][0], data[i][1], data[i][2], data[i][3], data[i][4] - ws.append(d) - wb.save('error.xlsx') - - -def curr_entry(md_files_path): - file_list = get_md_files(md_files_path) - check_result_list = [] - if len(file_list) > 0: - check_result_list = get_check_result_list(file_list) - write_in_txt(check_result_list, r'./Error.txt') + return json.dumps(check_result, default=lambda obj: obj.__dict__, indent=4) -def get_check_result_list(file_list): +def curr_entry(files_path, command: str, output): + file_list = get_files(files_path) + if command == 'all': + command_list = check_command_message + else: + command_list = command.split(',') + check_result_list = [] + if len(file_list) > 0: + check_result_list = get_check_result_list(file_list, command_list) + result_list = [] + if command != 'all': + for result in check_result_list: + if result.defectType in command_list: + result_list.append(result) + else: + result_list = check_result_list + write_in_txt(result_list, output) + + +def get_check_result_list(file_list, command_list): check_result_list = [] for file in file_list: - root_start = file.split('sdk_c')[0] - root_path = f'{root_start}sdk_c' - python_obj = parser_include_ast(root_path, [file]) - check_result_list.extend(process_all_json(python_obj)) - check_result_list.extend(check_syntax(file)) + python_obj = parser_include_ast(os.path.dirname(file), [file]) + check_result_list.extend(process_all_json(python_obj, command_list)) return check_result_list -def get_md_files(md_files_path): - with open(md_files_path, 'r') as file: - file_list = [] - line = file.readline() - while line: - file_path = line.splitlines()[0] - if file_path.find("sdk_c") != -1 and get_file_type(file_path) == '.h': - file_list.append(line.splitlines()[0]) - line = file.readline() - file.close() - return file_list +def get_files(files_path: str): + return files_path.split(',') def get_file_type(file_path): diff --git a/build-tools/capi_parser/src/coreImpl/check/check_doc.py b/build-tools/capi_parser/src/coreImpl/check/check_doc.py index 89a53eead..550392f5e 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_doc.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_doc.py @@ -14,12 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################## + import json +import os import re import subprocess -import os + from clang.cindex import CursorKind -from typedef.check.check import ApiResultInfo, DocInfo, ErrorType, ErrorMessage, FileDocInfo, LogType, TAGS, ErrorLevel + +from typedef.check.check import DocInfo, FileDocInfo, TAGS, CheckErrorMessage, CheckOutPut current_file = os.path.dirname(__file__) # permission数据来源于https://gitee.com/openharmony/utils_system_resources/raw/master/systemres/main/config.json @@ -32,31 +35,11 @@ with open(os.path.abspath(os.path.join(current_file, "rules/syscap_rule.json"))) syscap_tag_rules = json.load(json_file) -def create_api_result_info_by_doc(error_type: ErrorType, error: ErrorMessage, params: list, api_info: object): - error_info = str(error.value) - for param in params: - error_info = error_info.replace('$$', str(param), 1) - api_result_info = ApiResultInfo(error_type.value, error_info, api_info['name']) - api_result_info.set_api_since(api_info['since']) - api_result_info.set_type(LogType.LOG_JSDOC.value) - api_result_info.set_level(ErrorLevel.LOW.value) - if 'location' in api_info.keys(): - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_file_name(api_info['location']['location_path']) - else: - api_result_info.set_file_name(api_info['name']) - api_result_info.set_location(api_info['name']) - return api_result_info - - def process_tag_addtogroup(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] group_name = tag_info['name'] if group_name == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_11.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -75,8 +58,7 @@ def process_tag_deprecated(tag_info, file_doc_info: FileDocInfo, api_info) -> li name = tag_info['name'] version: str = tag_info['description'] if name != "since" or not version.isdigit(): - api_result_info = create_api_result_info_by_doc( - ErrorType.UNKNOW_DEPRECATED, ErrorMessage.ERROR_INFO_VALUE_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_01.name) api_result_info_list.append(api_result_info) doc_info.deprecated = version return api_result_info_list @@ -87,8 +69,7 @@ def process_tag_file(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] file_name = tag_info['name'] if file_name == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_12.name) api_result_info_list.append(api_result_info) doc_info.file = file_name return api_result_info_list @@ -98,8 +79,10 @@ def process_tag_library(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] library: str = tag_info['name'] + tag_info['description'] if not library.endswith(('.so', '.a')) and library != "NA": - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_LIBRARY, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_13.name) + api_result_info_list.append(api_result_info) + if not library == library.lower(): + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_16.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -111,43 +94,26 @@ def process_tag_param(tag_info, file_doc_info: FileDocInfo, api_info) -> list: return api_result_info_list if 'parm' not in api_info.keys(): - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_COUNT_PARAM, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_FUNCTION_01.name) api_result_info_list.append(api_result_info) return api_result_info_list index = file_doc_info.curr_doc_info.param_index params = api_info['parm'] - if (len(params) < index + 1): + if len(params) < index + 1: return api_result_info_list param = api_info['parm'][index] if tag_info['name'] != param['name']: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_PARAM, [index + 1, index + 1], api_info) + main_buggy_code = get_main_buggy_code(api_info) + api_result_info = CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + api_info['location']['location_line'], CheckErrorMessage.API_DOC_FUNCTION_02.name, + CheckErrorMessage.__getitem__(CheckErrorMessage.API_DOC_FUNCTION_02.name).value + .replace('$$', tag_info['name']).replace('&&', param['name']), + main_buggy_code, api_info['location']['location_line']) api_result_info_list.append(api_result_info) return api_result_info_list -def process_tag_permission(tag_info, file_doc_info: FileDocInfo, api_info) -> list: - doc_info = file_doc_info.curr_doc_info - api_result_info_list = [] - permission: str = "" - if tag_info['description'] == "": - permission: str = tag_info['name'] - else: - permission: str = tag_info['name'] + ' ' + tag_info['description'] - permission_blank = re.sub(re.compile(r'\(|\)'), '', permission) - permission_join = re.sub(re.compile(r'( or | and )'), '$', permission_blank) - permission_list = permission_join.split('$') - error_permission_list = list(filter(lambda item: item not in permission_tag_rules, permission_list)) - if error_permission_list: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_PERMISSION, [], api_info) - api_result_info_list.append(api_result_info) - doc_info.permission = permission - return api_result_info_list - - def process_tag_return(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] return api_result_info_list @@ -158,12 +124,10 @@ def process_tag_since(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] value: str = tag_info['name'] + tag_info['description'] if value == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_03.name) api_result_info_list.append(api_result_info) elif not value.isdigit(): - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_SINCE, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_04.name) api_result_info_list.append(api_result_info) doc_info.since = tag_info['name'] return api_result_info_list @@ -174,12 +138,7 @@ def process_tag_syscap(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] syscap = tag_info['name'] + tag_info['description'] if syscap == "": - api_result_info = create_api_result_info_by_doc( - ErrorType.EMPTY_TAG, ErrorMessage.EMPTY_TAG, [tag_info['tag']], api_info) - api_result_info_list.append(api_result_info) - if syscap not in syscap_tag_rules: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_VALUE, ErrorMessage.ERROR_INFO_VALUE_SYSCAP, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_UNIVERSAL_05.name) api_result_info_list.append(api_result_info) doc_info.syscap = syscap return api_result_info_list @@ -188,8 +147,7 @@ def process_tag_syscap(tag_info, file_doc_info: FileDocInfo, api_info) -> list: def process_tag_left_brace(tag_info, file_doc_info: FileDocInfo, api_info) -> list: api_result_info_list = [] if not file_doc_info.is_in_group_tag: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_USE_LEFT_BRACE, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_14.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -199,8 +157,7 @@ def process_tag_right_brace(tag_info, file_doc_info: FileDocInfo, api_info) -> l if not file_doc_info.has_group_end: file_doc_info.has_group_end = True return api_result_info_list - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_USE_RIGHT_BRACE, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_21.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -212,7 +169,6 @@ process_tag_function = { TAGS['FILE'].value: process_tag_file, TAGS['LIBRARY'].value: process_tag_library, TAGS['PARAM'].value: process_tag_param, - TAGS['PERMISSION'].value: process_tag_permission, TAGS['RETURN'].value: process_tag_return, TAGS['SINCE'].value: process_tag_since, TAGS['SYSCAP'].value: process_tag_syscap, @@ -230,8 +186,7 @@ def process_each_tags(tag_info, file_doc_info: FileDocInfo, api_info) -> list: tag: str = tag_info['tag'] if tag.lower() != tag: tag = tag.lower() - api_result_info = create_api_result_info_by_doc( - ErrorType.ERROR_TAG, ErrorMessage.USE_UPPER_TAG, [tag_info['tag'], tag], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_15.name) api_result_info_list.append(api_result_info) if tag not in process_tag_function.keys(): return [] @@ -250,17 +205,20 @@ def process_file_doc_group(file_doc_info: FileDocInfo, item, api_info) -> list: file_doc_info.group_name = item['name'] file_doc_info.is_in_group_tag = True else: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.REPEAT_FILE_TAG, [item['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_04.name) api_result_info_list.append(api_result_info) if item['tag'] == '{': if not file_doc_info.has_group_start: file_doc_info.has_group_start = True else: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_REPEAT_LEFT_BRACE, [item['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_06.name) api_result_info_list.append(api_result_info) - + elif item['tag'] == 'brief': + file_doc_info.group_brief = item['name'] + item['description'] + elif item['tag'] == 'library': + file_doc_info.group_library = item['name'] + item['description'] + elif item['tag'] == 'syscap': + file_doc_info.group_syscap = item['name'] + item['description'] return api_result_info_list @@ -274,8 +232,7 @@ def process_file_doc_file(file_doc_info: FileDocInfo, item, api_info) -> list: file_doc_info.file_name = item['name'] file_doc_info.is_in_file_tag = True else: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.REPEAT_FILE_TAG, [item['tag']], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_01.name) api_result_info_list.append(api_result_info) elif item['tag'] == 'brief': file_doc_info.file_brief = item['name'] + item['description'] @@ -286,6 +243,7 @@ def process_file_doc_file(file_doc_info: FileDocInfo, item, api_info) -> list: return api_result_info_list +# 第二步 def process_each_comment(comment_object, file_doc_info: FileDocInfo, api_info) -> list: ''' 检查单个comment对应的报错信息,不处理文件级别的校验 @@ -303,32 +261,36 @@ def process_each_comment(comment_object, file_doc_info: FileDocInfo, api_info) - api_result_info_list.extend(process_each_tags(item, file_doc_info, api_info)) # 判断param标签的数量和方法参数的数量是否对应 param_tag_count = file_doc_info.curr_doc_info.param_index + 1 + a = CursorKind.FUNCTION_DECL.name if api_info['kind'] == CursorKind.FUNCTION_DECL.name and \ 'parm' in api_info.keys() and len(api_info['parm']) != param_tag_count: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_INFO_COUNT_PARAM, [], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_FUNCTION_01.name) api_result_info_list.append(api_result_info) # 判断group标签的开头 - if file_doc_info.is_in_group_tag and not file_doc_info.has_group_start: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, ['group tag', 'start tag {'], api_info) - api_result_info_list.append(api_result_info) + if file_doc_info.is_in_group_tag: + if not file_doc_info.has_group_start: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_05.name) + api_result_info_list.append(api_result_info) + if file_doc_info.group_brief is None: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_02.name) + api_result_info_list.append(api_result_info) + if file_doc_info.group_library is None: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_07.name) + api_result_info_list.append(api_result_info) + if file_doc_info.group_syscap is None: + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_08.name) + api_result_info_list.append(api_result_info) # 处理file标签的值 if file_doc_info.is_in_file_tag: if file_doc_info.file_brief is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, ['file tag', 'brief tag'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_17.name) api_result_info_list.append(api_result_info) if file_doc_info.file_library is None: - api_result_info = create_api_result_info_by_doc(ErrorType.WRONG_SCENE, - ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, - ['file tag', 'library tag'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_18.name) api_result_info_list.append(api_result_info) if file_doc_info.file_syscap is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, ['file tag', 'syscap tag'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_19.name) api_result_info_list.append(api_result_info) - return api_result_info_list @@ -342,8 +304,7 @@ def process_tag_missing(comment_object, file_doc_info: FileDocInfo, api_info): if item['tag'] == 'since': has_since_tag = True if not has_since_tag: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_LOST_LABEL, ['since'], api_info) + api_result_info = set_value_to_result(api_info, CheckErrorMessage.API_DOC_GLOBAL_20.name) api_result_info_list.append(api_result_info) return api_result_info_list @@ -360,6 +321,7 @@ process_tag_missing_function = { } +# 第一步 def process_comment(comment: str, file_doc_info: FileDocInfo, api_info) -> list: ''' 处理comment数据,通过node调用comment-parser解析doc注释 @@ -368,14 +330,14 @@ def process_comment(comment: str, file_doc_info: FileDocInfo, api_info) -> list: if comment == "none_comment": return api_result_info_list result = subprocess.check_output( - ['node', os.path.abspath(os.path.join(current_file, "comment_parser.js")), comment]) # 解析comment + ['node', os.path.abspath(os.path.join(current_file, "comment_parser.js")), comment]) # 解析comment result_json = json.loads(result.decode('utf-8')) for index, item in enumerate(result_json): api_result_info_list.extend(process_each_comment(item, file_doc_info, api_info)) if index == len(result_json) - 1: api_result_info_list.extend(process_tag_missing(item, file_doc_info, api_info)) - file_doc_info.is_in_group_tag = False # 初始化group标签判断 - file_doc_info.is_in_file_tag = False # 初始化file标签判断 + file_doc_info.is_in_group_tag = False # 初始化group标签判断 + file_doc_info.is_in_file_tag = False # 初始化file标签判断 return api_result_info_list @@ -386,20 +348,28 @@ def process_file_doc_info(file_doc_info: FileDocInfo, file_info) -> list: api_result_info_list = [] # 处理group说明 if file_doc_info.group_name is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_LOSE_ONE, ['group doc'], file_info) + api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_09.name) api_result_info_list.append(api_result_info) else: # 判断group标签的结尾 if not file_doc_info.has_group_end: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_HAS_ONE_LOSE_OTHER, - ['group tag', 'end tag }'], file_info) + api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_10.name) api_result_info_list.append(api_result_info) # 处理file说明 if file_doc_info.file_name is None: - api_result_info = create_api_result_info_by_doc( - ErrorType.WRONG_SCENE, ErrorMessage.ERROR_FILE_LOSE_ONE, ['file doc'], file_info) + api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_03.name) api_result_info_list.append(api_result_info) return api_result_info_list + + +def set_value_to_result(api_info, command): + main_buggy_code = get_main_buggy_code(api_info) + return CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, + main_buggy_code, api_info['location']['location_line']) + + +def get_main_buggy_code(api_info): + main_buggy_code = '' if len(api_info['node_content']) == 0 else api_info['node_content']['content'] + return main_buggy_code diff --git a/build-tools/capi_parser/src/coreImpl/check/check_name.py b/build-tools/capi_parser/src/coreImpl/check/check_name.py index ca9a6a75a..78e919417 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_name.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_name.py @@ -16,101 +16,132 @@ import enum import os.path import re -from typedef.check.check import ApiResultInfo, ErrorMessage, ErrorType, LogType, ErrorLevel +from typedef.check.check import (CheckOutPut, CheckErrorMessage) -def check_large_hump(api_info): - return processing_check_data('LARGE_HUMP', api_info) +typedefs = [CheckErrorMessage.API_NAME_UNIVERSAL_05.name, CheckErrorMessage.API_NAME_UNIVERSAL_03.name, + CheckErrorMessage.API_NAME_UNIVERSAL_07.name] -def check_function_name(api_info): +def check_large_hump(api_info, kind, parent_kind): api_result_info_list = [] - name = api_info['name'] - self_developed_function_result = re.match(r'^[OH|OS]+([\_]([A-Z]+[a-z0-9]*)+)*$', name) - ordinary_function_result = re.match(r'^([A-Z][a-z0-9]*)*$', name) - if self_developed_function_result or ordinary_function_result is not None: - return api_result_info_list - else: - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, - ErrorMessage[api_info['kind']].value.replace('$$', name), name) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_type(LogType.LOG_API.value) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(api_info['location']['location_path']) - api_result_info_list.append(api_result_info) - return api_result_info_list + # 结构体 + if kind == 'STRUCT_DECL': + api_result_info_list = processing_check_data('LARGE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_05.name) + # 枚举 + if kind == 'ENUM_DECL': + api_result_info_list = processing_check_data('LARGE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_03.name) + # 联合体 + if kind == 'UNION_DECL': + api_result_info_list = processing_check_data('LARGE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_07.name) + return api_result_info_list + + +def check_function_name(api_info, kind, parent_kind): + api_result_info_list = [] + function_name = api_info['name'] + # 自研函数 + if is_self_developed_function(function_name): + self_developed_function_result = re.match(r'^[OH|OS]+([\_]([A-Z]+[a-z0-9]*)+)*$', function_name) + if self_developed_function_result is None: + chck_output = set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_01.name) + api_result_info_list.append(chck_output) + # 一般函数 + if not is_self_developed_function(function_name): + ordinary_function_result = re.match(r'^([A-Z][a-z0-9]*)*$', function_name) + if ordinary_function_result is None: + chck_output = set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_10.name) + api_result_info_list.append(chck_output) + return api_result_info_list + + +def set_value_to_result(api_info, command): + return CheckOutPut(os.path.join(api_info['gn_path'], api_info['location']['location_path']), + api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, + api_info['node_content']['content'], api_info['location']['location_line']) -def check_variable_name(api_info): +def is_self_developed_function(function_name): + return function_name.startswith('OH_') or function_name.startswith('OS_') or function_name.startswith('HMS_') + + +def check_variable_name(api_info, kind, parent_kind): + api_result_info_list = [] is_const = api_info['is_const'] + # 常量 if is_const: - return processing_check_data('ALL_UPPERCASE_HUMP', api_info) - else: - return processing_check_data('SMALL_HUMP', api_info) + api_result_info_list = processing_check_data('ALL_UPPERCASE_HUMP', + api_info, CheckErrorMessage.API_NAME_UNIVERSAL_02.name) + # 全局变量 + if not is_const: + api_result_info_list = processing_check_data('GLOBAL_VARIABLE', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_09.name) + return api_result_info_list -def check_small_hump(api_info): - return processing_check_data('SMALL_HUMP', api_info) +def check_small_hump(api_info, kind, parent_kind): + api_result_info_list = [] + # 函数参数 + if parent_kind == 'FUNCTION_DECL': + api_result_info_list = processing_check_data('SMALL_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_11.name) + # 结构体成员 + if parent_kind == 'STRUCT_DECL': + api_result_info_list = processing_check_data('SMALL_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_06.name) + # 联合体成员 + if parent_kind == 'UNION_DECL': + api_result_info_list = processing_check_data('SMALL_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_08.name) + return api_result_info_list -def check_macro_definition(api_info): +def check_macro_definition(api_info, kind, parent_kind): api_result_info_list = [] name = api_info['name'] + # 宏定义 + if not api_info['is_def_func']: + result = re.match(CheckName['MACRO_DEFINITION'].value, name) + if result is None: + api_result_info_list.append(set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_12.name)) + # 函数式宏 if api_info['is_def_func']: name = api_info['def_func_name'] - result = re.match(CheckName['ALL_UPPERCASE_HUMP'].value, name) - if result is None: - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, - ErrorMessage[api_info['kind']].value.replace('$$', name), name) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_type(LogType.LOG_API.value) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(api_info['location']['location_path']) - api_result_info_list.append(api_result_info) + result = re.match(CheckName['MACRO_DEFINITION'].value, name) + if result is None: + api_result_info_list.append(set_value_to_result(api_info, CheckErrorMessage.API_NAME_UNIVERSAL_13.name)) return api_result_info_list -def check_all_uppercase_hump(api_info): - return processing_check_data('ALL_UPPERCASE_HUMP', api_info) - - -def check_global_variable(api_info): - return processing_check_data('GLOBAL_VARIABLE', api_info) +def check_all_uppercase_hump(api_info, kind, parent_kind): + # 枚举值 + api_result_info_list = processing_check_data('ALL_UPPERCASE_HUMP', api_info, + CheckErrorMessage.API_NAME_UNIVERSAL_04.name) + return api_result_info_list -def check_file_name(file_path): +def check_file_name(file_info): api_result_info_list = [] - file_name = os.path.basename(file_path) + file_name = file_info['name'] result = re.match(CheckName['FILE_NAME'].value, file_name) if result is None: - error_info = ErrorMessage.TRANSLATION_UNIT.value.replace('$$', file_name) - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, error_info, '') - api_result_info.set_type(LogType.LOG_FILE.value) - api_result_info.set_file_name(file_path) - api_result_info.set_location(file_path) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info_list.append(api_result_info) + chck_output = CheckOutPut(os.path.join(file_info['gn_path'], file_info['name']), 0, + CheckErrorMessage.API_NAME_UNIVERSAL_14.name, + CheckErrorMessage.API_NAME_UNIVERSAL_14.value, file_name, 0) + api_result_info_list.append(chck_output) return api_result_info_list -def processing_check_data(function_type, api_info): +def processing_check_data(function_type, api_info, command): api_result_info_list = [] name = api_info['name'] result = re.match(CheckName[function_type].value, name) if result is None: - api_result_info = ApiResultInfo(ErrorType.NAMING_ERRORS.value, - ErrorMessage[api_info['kind']].value.replace('$$', name), name) - api_result_info.set_location_line(api_info['location']['location_line']) - api_result_info.set_location_column(api_info['location']['location_column']) - api_result_info.set_location(api_info['location']['location_path']) - api_result_info.set_type(LogType.LOG_API.value) - api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(api_info['location']['location_path']) - api_result_info_list.append(api_result_info) + chck_output = set_value_to_result(api_info, command) + api_result_info_list.append(chck_output) return api_result_info_list @@ -120,25 +151,35 @@ class CheckName(enum.Enum): ALL_UPPERCASE_HUMP = r'^[A-Z]+[0-9]*([\_][A-Z0-9]*)*$' GLOBAL_VARIABLE = r'^g_([a-z][A-Z0-9]*)*$' FILE_NAME = r'^[a-z]+[a-z0-9]+([\_][a-z0-9]+)*\.h$' + MACRO_DEFINITION = r'^[\_]*[A-Z]+[0-9]*([\_][A-Z0-9]*)*$' process_tag_function = { + # 函数 'FUNCTION_DECL': check_function_name, + # 结构体 'STRUCT_DECL': check_large_hump, + # 枚举 'ENUM_DECL': check_large_hump, + # 联合体 'UNION_DECL': check_large_hump, + # 变量 'VAR_DECL': check_variable_name, + # 参数 'PARM_DECL': check_small_hump, + # 结构体、联合体成员 'FIELD_DECL': check_small_hump, + # 宏定义 'MACRO_DEFINITION': check_macro_definition, + # 枚举值 'ENUM_CONSTANT_DECL': check_all_uppercase_hump, } -def check_ndk_name(api_info): +def check_api_name(api_info, parent_kind): api_result_info_list = [] kind = api_info['kind'] if kind not in process_tag_function.keys(): return api_result_info_list name_process = process_tag_function[kind] - return name_process(api_info) + return name_process(api_info, kind, parent_kind) diff --git a/build-tools/capi_parser/src/typedef/check/check.py b/build-tools/capi_parser/src/typedef/check/check.py index cca3ac40c..65eb13968 100644 --- a/build-tools/capi_parser/src/typedef/check/check.py +++ b/build-tools/capi_parser/src/typedef/check/check.py @@ -138,6 +138,7 @@ be reused please delete the extra tags.' ERROR_FILE_HAS_ONE_LOSE_OTHER = 'the file has the $$, but do not has the $$.' ERROR_FILE_LOSE_ONE = 'the file missing $$' ERROR_LOST_LABEL = 'JSDoc tag validity verification failed. Please confirm if the [$$] tag is missing' + FUNCTION_DECL = 'This name [$$] should use the big hump naming style or beginning with OH/OS,and \ using "_" segmentation.' STRUCT_DECL = 'This name [$$] should use the big hump naming style.' @@ -156,6 +157,122 @@ be reused please delete the extra tags.' TRANSLATION_UNIT = 'This name [$$] should be all lowercase, separated by underscores.' +class CheckErrorMessage(enum.Enum): + API_NAME_UNIVERSAL_01 = ('API check error of [naming errors]:The names of self-developed ' + 'functions in APIs must start with OH_ or OS_ or HMS_ and comply ' + 'with the large hump case format.') + API_NAME_UNIVERSAL_02 = ('API check error of [naming errors]:The names of constants in ' + 'APIs must be in uppercase and separated by underscores.') + API_NAME_UNIVERSAL_03 = ('API check error of [naming errors]:The naming of enumeration ' + 'types should follow the big hump rule.') + API_NAME_UNIVERSAL_04 = ('API check error of [naming errors]:The naming of enumeration ' + 'values should follow the all uppercase rule and separated by underscores.') + API_NAME_UNIVERSAL_05 = ('API check error of [naming errors]:The naming of struct should ' + 'follow the rules of the Great Hump.') + API_NAME_UNIVERSAL_06 = ('API check error of [naming errors]:The naming of members in the ' + 'structure should follow the small hump format.') + API_NAME_UNIVERSAL_07 = ('API check error of [naming errors]:The naming of the consortium ' + 'should follow the format of the large camel hump.') + API_NAME_UNIVERSAL_08 = ('API check error of [naming errors]:The naming of members in the ' + 'consortium should follow the small hump format.') + API_NAME_UNIVERSAL_09 = ('API check error of [naming errors]:The names of a global variable ' + 'must be prefixed with g_ in the small camel case format.') + API_NAME_UNIVERSAL_10 = ('API check error of [naming errors]:The naming of general functions ' + 'should follow the big hump format.') + API_NAME_UNIVERSAL_11 = ('API check error of [naming errors]:Function parameter names should ' + 'follow the small hump format.') + API_NAME_UNIVERSAL_12 = ('API check error of [naming errors]:Macro naming should follow all ' + 'uppercase format and separated by underscores.') + API_NAME_UNIVERSAL_13 = ('API check error of [naming errors]:Functional macro naming should ' + 'follow all uppercase format and separated by underscores.') + API_NAME_UNIVERSAL_14 = ('API check error of [naming errors]:The file name should be all ' + 'lowercase and separated by underscores.') + API_DOC_GLOBAL_01 = ('API check error of [api doc errors]:The [file] tag is repeat. Please ' + 'check the tag in file.') + API_DOC_GLOBAL_02 = ('API check error of [api doc errors]:The file has the [addtogroup] tag, ' + 'but do not has the [brief] tag.') + API_DOC_GLOBAL_03 = 'API check error of [api doc errors]:The file miss [file] tag.' + API_DOC_GLOBAL_04 = ('API check error of [api doc errors]:The [addtogroup] tag is repeat. ' + 'Please check the tag in file.') + API_DOC_GLOBAL_05 = ('API check error of [api doc errors]:The file has the [addtogroup] tag,' + 'but do not has the start tag [{].') + API_DOC_GLOBAL_06 = ('API check error of [api doc errors]:The [{] tag is not allowed to reuse ' + 'in Doc which has [addtogroup] tag.') + API_DOC_GLOBAL_07 = ('API check error of [api doc errors]:The file has the [addtogroup] tag, ' + 'but do not has the [library] tag.') + API_DOC_GLOBAL_08 = ('API check error of [api doc errors]:The file has the [addtogroup] tag, ' + 'but do not has the [syscap] tag.') + API_DOC_GLOBAL_09 = 'API check error of [api doc errors]:The file missing [addtogroup] tag.' + API_DOC_GLOBAL_10 = ('API check error of [api doc errors]:The file has the [addtogroup] tag,' + 'but do not has the end tag [}].') + API_DOC_GLOBAL_11 = ('API check error of [api doc errors]:The [addtogroup] tag value is empty,' + 'please supplement the default value.') + API_DOC_GLOBAL_12 = ('API check error of [api doc errors]:The [file] tag value is empty,please ' + 'supplement the default value.') + API_DOC_GLOBAL_13 = ('API check error of [api doc errors]:The [library] tag value must be end ' + 'with .so or .a, please check the usage method.') + API_DOC_GLOBAL_14 = ('API check error of [api doc errors]:The [{] tag is not allowed to used ' + 'in Doc which not the [addtogroup] tag,or used in the wrong place.'), + API_DOC_GLOBAL_15 = 'API check error of [api doc errors]:Non lowercase labels used in API Doc information.' + API_DOC_GLOBAL_16 = 'API check error of [api doc errors]:The name after the [library] tag should be in lowercase.' + API_DOC_GLOBAL_17 = ('API check error of [api doc errors]:The file has the [file] tag, but do ' + 'not has the [brief] tag.') + API_DOC_GLOBAL_18 = ('API check error of [api doc errors]:The file has the [file] tag, but do not ' + 'has the [library] tag.') + API_DOC_GLOBAL_19 = ('API check error of [api doc errors]:The file has the [file] tag, but do not ' + 'has the [syscap] tag.') + API_DOC_GLOBAL_20 = ('API check error of [api doc errors]:APIDoc tag validity verification failed. ' + 'Please confirm if the [since] tag is missing.') + API_DOC_GLOBAL_21 = ('API check error of [api doc errors]:The validity verification of the APIDoc tag ' + 'failed. The [}] tag is not allowed to be reused please delete the extra tags') + API_DOC_FUNCTION_01 = ('API check error of [api doc errors]:The count of the [param] tag is wrong.' + 'Please check the parameters and Doc.') + API_DOC_FUNCTION_02 = ('API check error of [api doc errors]:The value of the [$$] [param] tag is ' + 'incorrect. Please check if it matches the [&&] parameter name.') + API_DOC_UNIVERSAL_01 = ('API check error of [api doc errors]:The [deprecated] tag value is incorrect.' + 'Please check the usage method.') + API_DOC_UNIVERSAL_02 = ('API check error of [api doc errors]:The [permission] tag value is incorrect. ' + 'Please check if the permission field has been configured or update the ' + 'configuration file.') + API_DOC_UNIVERSAL_03 = ('API check error of [api doc errors]:The [since] tag value is empty.Please ' + 'supplement the default value.') + API_DOC_UNIVERSAL_04 = ('API check error of [api doc errors]:The [since] tag value is incorrect.' + 'Please check if the tag value is a numerical value or version number(number).') + API_DOC_UNIVERSAL_05 = ('API check error of [api doc errors]:The [syscap] tag value is empty.' + 'Please supplement the default value.') + API_DOC_UNIVERSAL_06 = ('API check error of [api doc errors]:The [syscap] tag value is incorrect.' + 'Please check if the syscap field is configured.') + + +check_command_message = [ + member.name for name_tool, + member in CheckErrorMessage.__members__.items() +] + + +class CheckOutPut: + analyzerName = 'apiengine' + buggyFilePath = '' + codeContextStartLine = -1 + defectLevel = 0 + defectType = '' + description = '' + language = 'c' + mainBuggyCode = '' + mainBuggyLine = -1 + + def __init__(self, buggy_file_path, code_context_start_line, defect_type, description, + main_buggy_code, main_buggy_line): + self.buggyFilePath = buggy_file_path + self.codeContextStartLine = code_context_start_line + self.defectLevel = 0 + self.defectType = defect_type + self.description = description + self.language = 'c' + self.mainBuggyCode = main_buggy_code + self.mainBuggyLine = main_buggy_line + + class OutputTxt: id = -1 level = -1 @@ -325,6 +442,9 @@ class DocInfo: class FileDocInfo: is_in_group_tag = False group_name = None + group_brief = None + group_library = None + group_syscap = None has_group_start = False has_group_end = False is_in_file_tag = False diff --git a/build-tools/capi_parser/src/utils/constants.py b/build-tools/capi_parser/src/utils/constants.py index aed1044ee..080f11331 100644 --- a/build-tools/capi_parser/src/utils/constants.py +++ b/build-tools/capi_parser/src/utils/constants.py @@ -19,7 +19,7 @@ import enum class StringConstant(enum.Enum): - LIB_CLG_PATH = r'/home/tools/llvm/lib/libclang.so' # 共享库 + LIB_CLG_PATH = r'C:\Program Files\LLVM\bin\libclang.dll' # 共享库 FUNK_NAME = "ohos_ndk_headers" REPLACE_WAREHOUSE = '\\interface_sdk_c\\interface_sdk_c' # 拉到本地仓路径(去掉磁盘) # 拉到本地仓的三方库绝对路径 @@ -31,8 +31,6 @@ class StringConstant(enum.Enum): SELF_INCLUDE_NEW = r'.\sysroot\self_include_files_new' SYSROOT = r'.\sysroot' RESULT_HEAD_NAME = "result_total.xlsx" - PARSER_DIRECT_EXCEL_NAME = 'parser_direct_data.xlsx' - FILE_LEVEL_API_DATA = r'.\file_api_json.json' class RegularExpressions(enum.Enum): -- Gitee From 3bed19ec5c3025bf6d3e11e9357458bb44c38250 Mon Sep 17 00:00:00 2001 From: wangyan Date: Mon, 13 May 2024 20:13:26 +0800 Subject: [PATCH 20/43] =?UTF-8?q?=E6=95=B4=E6=94=B9CAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyan --- multimedia/av_codec/native_avsource.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_avsource.h b/multimedia/av_codec/native_avsource.h index a211d6950..1b0504fa1 100644 --- a/multimedia/av_codec/native_avsource.h +++ b/multimedia/av_codec/native_avsource.h @@ -31,7 +31,8 @@ typedef struct OH_AVSource OH_AVSource; * @brief Creates an OH_AVSource instance that models the media with dataSource. * @syscap SystemCapability.Multimedia.Media.Spliter * @param dataSource An Struct for a remote media resource. - * @return Returns a pointer to an OH_AVSource instance + * @return Returns a pointer to an OH_AVSource instance if the execution is successful, otherwise returns nullptr. + * Possible failure causes: 1. dataSource is nullptr. 2. dataSource->size == 0. 3. create AVSource failed. * @since 12 */ OH_AVSource *OH_AVSource_CreateWithDataSource(OH_AVDataSource *dataSource); -- Gitee From 2ef72eab4534e6ca0f025b23218f71e707f8dc26 Mon Sep 17 00:00:00 2001 From: openharmony_ci/wusongbai Date: Tue, 14 May 2024 15:01:44 +0800 Subject: [PATCH 21/43] =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E6=96=87=E4=BB=B6=E5=A2=9E=E5=88=A0?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E6=AF=94=E5=AF=B9=E6=96=87=E4=BB=B6=E6=9C=AC?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF=EF=BC=9B=E6=B7=BB=E5=8A=A0=E8=A7=84?= =?UTF-8?q?=E5=88=99=EF=BC=9A=E5=B8=B8=E9=87=8F=E4=B8=8E=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E4=BA=92=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sam_wusb --- .../src/coreImpl/diff/diff_file.py | 36 +++++++++++-------- .../src/coreImpl/diff/diff_processor_node.py | 24 +++++++++++-- .../capi_parser/src/typedef/diff/diff.py | 4 +++ 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py index ad8ff4400..61479547b 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -128,18 +128,18 @@ def add_new_file(diff_file_path): if os.path.isdir(diff_file_path): add_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1)) + result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1), 1) for new_info in result_map.values(): - diff_info_list.extend(judgment_entrance(None, new_info)) + diff_info_list.extend(judgment_entrance(None, new_info, 1)) def del_old_file(diff_file_path): if os.path.isdir(diff_file_path): del_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0)) + result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0), 1) for old_info in result_map.values(): - diff_info_list.extend(judgment_entrance(old_info, None)) + diff_info_list.extend(judgment_entrance(old_info, None, 1)) def get_same_file_diff(target_file, old_file_list, new_file_list, old_dir, new_dir): @@ -176,9 +176,9 @@ def del_file(dir_path): if os.path.isdir(file_path): del_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0)) + result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0), 1) for old_info in result_map.values(): - diff_info_list.extend(judgment_entrance(old_info, None)) + diff_info_list.extend(judgment_entrance(old_info, None, 1)) def add_file(dir_path): @@ -190,19 +190,25 @@ def add_file(dir_path): if os.path.isdir(file_path): add_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1)) + result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1), 1) for new_info in result_map.values(): - diff_info_list.extend(judgment_entrance(None, new_info)) + diff_info_list.extend(judgment_entrance(None, new_info, 1)) -def parse_file_result(result): +def parse_file_result(result, data_type=0): + """ + Args: + result: *** + data_type(int): 数据处理类型。1-文件新增或删除;0-其他 + """ result_map = {} for root_node in result: - children_list = root_node['children'] - for children in children_list: - if children["name"] == '': - continue - result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) - del root_node['children'] + if data_type != 1: + children_list = root_node['children'] + for children in children_list: + if children["name"] == '': + continue + result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) + del root_node['children'] result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) return result_map diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py index f9a94a7ce..dd5a1bab5 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py @@ -388,17 +388,23 @@ def process_variable_const(old, new): diff_var_or_con = [] if 'is_const' in old: if old['is_const']: # 处理常量 + process_constant_to_variable(old, new, diff_var_or_con) # 常量改变量 process_constant_name(old, new, diff_var_or_con) # 处理常量名 process_constant_type(old, new, diff_var_or_con) # 处理常量类型 process_constant_value(old, new, diff_var_or_con) # 处理常量值 else: # 处理变量 + process_variable_to_constant(old, new, diff_var_or_con) # 变量改常量 process_variable_name(old, new, diff_var_or_con) # 处理变量名 process_variable_type(old, new, diff_var_or_con) # 处理变量类型 process_variable_value(old, new, diff_var_or_con) # 处理变量值 return diff_var_or_con +def process_variable_to_constant(old, new, diff_variable_list): + if new['is_const']: + diff_info = wrap_diff_info(old, new, DiffInfo(DiffType.VARIABLE_CHANGE_TO_CONSTANT)) + diff_variable_list.append(diff_info) def process_variable_name(old, new, diff_variable_list): if old['name'] != new['name']: @@ -430,6 +436,10 @@ def process_variable_value(old, new, diff_variable_list): DiffInfo(DiffType.VARIABLE_VALUE_CHANGE)) diff_variable_list.append(diff_info) +def process_constant_to_variable(old, new, diff_constant_list): + if not new['is_const']: + diff_info = wrap_diff_info(old, new, DiffInfo(DiffType.CONSTANT_CHANGE_TO_VARIABLE)) + diff_constant_list.append(diff_info) def process_constant_name(old, new, diff_constant_list): if old['name'] != new['name']: @@ -510,15 +520,23 @@ process_data = { } -def judgment_entrance(old, new): +def judgment_entrance(old, new, data_type=0): + """ + Args: + old: *** + new: *** + data_type(int): 数据处理类型。1-文件新增或删除;0-其他 + """ diff_info_list = [] if old is None and new is None: return diff_info_list if old is None: - diff_info_list.append(wrap_diff_info(old, new, DiffInfo(DiffType.ADD_API))) + diff_type = DiffType.ADD_FILE if data_type == 1 else DiffType.ADD_API + diff_info_list.append(wrap_diff_info(old, new, DiffInfo(diff_type))) return diff_info_list if new is None: - diff_info_list.append(wrap_diff_info(old, new, DiffInfo(DiffType.REDUCE_API))) + diff_type = DiffType.REDUCE_FILE if data_type == 1 else DiffType.REDUCE_API + diff_info_list.append(wrap_diff_info(old, new, DiffInfo(diff_type))) return diff_info_list kind = new['kind'] diff_info_list.extend(process_comment_str(old, new)) diff --git a/build-tools/capi_parser/src/typedef/diff/diff.py b/build-tools/capi_parser/src/typedef/diff/diff.py index 1cbd015fc..82133f4fd 100644 --- a/build-tools/capi_parser/src/typedef/diff/diff.py +++ b/build-tools/capi_parser/src/typedef/diff/diff.py @@ -43,6 +43,8 @@ class TAGS(enum.Enum): class DiffType(enum.Enum): DEFAULT = '' + ADD_FILE = 'add file' + REDUCE_FILE = 'delete file' ADD_API = 'add api' REDUCE_API = 'delete api' ADD_DOC = 'add doc' @@ -83,11 +85,13 @@ class DiffType(enum.Enum): VARIABLE_TYPE_CHANGE = 'change variable type' VARIABLE_VALUE_CHANGE = 'change variable value' VARIABLE_CHANGE_CONST = 'Change variable to constant' + VARIABLE_CHANGE_TO_CONSTANT = 'change variable to constant' CONSTANT_NAME_CHANGE = 'change constant name' CONSTANT_TYPE_CHANGE = 'change constant type' CONSTANT_VALUE_CHANGE = 'change constant value' CONST_CHANGE_VARIABLE = 'Change constant to variable' + CONSTANT_CHANGE_TO_VARIABLE = 'change constant to variable' TYPEDEF_NAME_TYPE_CHANGE = 'change typedef name type' -- Gitee From 523cbaef5c728775bfbe7371c6b318cafbf9e9da Mon Sep 17 00:00:00 2001 From: yeyinglong_admin Date: Tue, 14 May 2024 17:12:39 +0800 Subject: [PATCH 22/43] =?UTF-8?q?Layout=20Rect=E6=8E=A5=E5=8F=A3=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yeyinglong_admin --- arkui/ace_engine/native/native_node.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index e8b1f0f25..8b2ea3ed7 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -1586,19 +1586,20 @@ typedef enum { NODE_FOREGROUND_BLUR_STYLE, /** - * @brief Defines layout rect attribute, which can be set, reset, and obtained as required through APIs. + * @brief Defines the component size and position for layout. + * This attribute 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 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. + * .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 * \n * Format of the return value {@link ArkUI_AttributeItem}:\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. + * .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 * */ NODE_LAYOUT_RECT, -- Gitee From 05746a43b7f6530428ea03276076303e46920ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=80=80=E5=BE=B7?= Date: Tue, 14 May 2024 17:18:23 +0800 Subject: [PATCH 23/43] modify asset ndk return code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 尹耀德 --- security/asset/inc/asset_api.h | 88 +++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 6 deletions(-) diff --git a/security/asset/inc/asset_api.h b/security/asset/inc/asset_api.h index 87b2652dc..6e060d18c 100755 --- a/security/asset/inc/asset_api.h +++ b/security/asset/inc/asset_api.h @@ -52,7 +52,23 @@ extern "C" { * * @param attributes Pointer to the attributes of the asset to add. * @param attributes Number of the attributes of the asset to add. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return Returns ASSET_SUCCESS if the operation is successful; + * Returns ASSET_PERMISSION_DENIED if the caller doesn't have the permission; + * Returns ASSET_INVALID_ARGUMENT if mandatory parameters are left unspecified or + * if incorrect parameter types, or if parameter verification failed; + * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; + * Returns ASSET_DUPLICATED if the asset already exists; + * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; + * Returns ASSET_OUT_OF_MEMORY if insufficient memory; + * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; + * Returns ASSET_DATABASE_ERROR if the database operation failed; + * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; + * Returns ASSET_IPC_ERROR if IPC failed; + * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; + * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; + * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; + * Returns ASSET_FILE_OPERATION_ERROR if the file operation failed; + * Returns ASSET_GET_SYSTEM_TIME_ERROR if getting the system time failed. * @since 11 */ int32_t OH_Asset_Add(const Asset_Attr *attributes, uint32_t attrCnt); @@ -62,7 +78,17 @@ int32_t OH_Asset_Add(const Asset_Attr *attributes, uint32_t attrCnt); * * @param query Pointer to the conditions for removing the assets. * @param queryCnt Number of conditions for removing the assets. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return Returns ASSET_SUCCESS if the operation is successful; + * Returns ASSET_INVALID_ARGUMENT if incorrect parameter types, or if parameter verification failed; + * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; + * Returns ASSET_NOT_FOUND if the asset is not found; + * Returns ASSET_OUT_OF_MEMORY if insufficient memory; + * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; + * Returns ASSET_DATABASE_ERROR if the database operation failed; + * Returns ASSET_IPC_ERROR if IPC failed; + * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; + * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; + * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed. * @since 11 */ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); @@ -74,7 +100,21 @@ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); * @param queryCnt Number of conditions for updating the asset. * @param attributes Pointer to the attributes of the asset to update. * @param attributes Number of the attributes of the asset to update. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return Returns ASSET_SUCCESS if the operation is successful; + * Returns ASSET_INVALID_ARGUMENT if mandatory parameters are left unspecified or + * if incorrect parameter types, or if parameter verification failed; + * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; + * Returns ASSET_NOT_FOUND if the asset is not found; + * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; + * Returns ASSET_OUT_OF_MEMORY if insufficient memory; + * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; + * Returns ASSET_DATABASE_ERROR if the database operation failed; + * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; + * Returns ASSET_IPC_ERROR if IPC failed; + * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; + * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; + * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; + * Returns ASSET_GET_SYSTEM_TIME_ERROR if getting the system time failed. * @since 11 */ int32_t OH_Asset_Update(const Asset_Attr *query, uint32_t queryCnt, @@ -86,7 +126,21 @@ int32_t OH_Asset_Update(const Asset_Attr *query, uint32_t queryCnt, * @param query Pointer to the search criteria of the asset. * @param queryCnt Number of the search criteria. * @param challenge Pointer to the challenge value to be used when OH_Asset_Query is called. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return Returns ASSET_SUCCESS if the operation is successful; + * Returns ASSET_INVALID_ARGUMENT if incorrect parameter types, or if parameter verification failed; + * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; + * Returns ASSET_NOT_FOUND if the asset is not found; + * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; + * Returns ASSET_OUT_OF_MEMORY if insufficient memory; + * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; + * Returns ASSET_DATABASE_ERROR if the database operation failed; + * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; + * Returns ASSET_IPC_ERROR if IPC failed; + * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; + * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; + * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; + * Returns ASSET_LIMIT_EXCEEDED if the cache exceeds the limit; + * Returns ASSET_UNSUPPORTED if the capability is not supported. * @since 11 */ int32_t OH_Asset_PreQuery(const Asset_Attr *query, uint32_t queryCnt, Asset_Blob *challenge); @@ -97,7 +151,21 @@ int32_t OH_Asset_PreQuery(const Asset_Attr *query, uint32_t queryCnt, Asset_Blob * @param query Pointer to the search criteria. * @param queryCnt Number of the search criteria. * @param resultSet Pointer to the query result obtained. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return Returns ASSET_SUCCESS if the operation is successful; + * Returns ASSET_INVALID_ARGUMENT if incorrect parameter types, or if parameter verification failed; + * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; + * Returns ASSET_NOT_FOUND if the asset is not found; + * Returns ASSET_ACCESS_DENIED if access to the asset is denied; + * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; + * Returns ASSET_OUT_OF_MEMORY if insufficient memory; + * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; + * Returns ASSET_DATABASE_ERROR if the database operation failed; + * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; + * Returns ASSET_IPC_ERROR if IPC failed; + * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; + * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; + * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; + * Returns ASSET_UNSUPPORTED if the capability is not supported. * @since 11 */ int32_t OH_Asset_Query(const Asset_Attr *query, uint32_t queryCnt, Asset_ResultSet *resultSet); @@ -108,7 +176,15 @@ int32_t OH_Asset_Query(const Asset_Attr *query, uint32_t queryCnt, Asset_ResultS * @param handle Pointer to the handle of the data to process, which includes the challenge value returned by * OH_Asset_PreQuery. * @param handleCnt Number of the elements in the handle attribute set. - * @return Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise. + * @return Returns ASSET_SUCCESS if the operation is successful; + * Returns ASSET_INVALID_ARGUMENT if mandatory parameters are left unspecified or + * if incorrect parameter types, or if parameter verification failed; + * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; + * Returns ASSET_OUT_OF_MEMORY if insufficient memory; + * Returns ASSET_IPC_ERROR if IPC failed; + * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; + * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; + * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed. * @since 11 */ int32_t OH_Asset_PostQuery(const Asset_Attr *handle, uint32_t handleCnt); -- Gitee From 774ed57674f0235480a5e00662a7db336d9308fd Mon Sep 17 00:00:00 2001 From: sam_wusb Date: Tue, 14 May 2024 19:34:02 +0800 Subject: [PATCH 24/43] =?UTF-8?q?=E9=97=A8=E7=A6=81=E5=9C=88=E5=A4=8D?= =?UTF-8?q?=E6=9D=82=E5=BA=A6=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sam_wusb --- .../capi_parser/src/coreImpl/diff/diff_file.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py index 61479547b..1ca5cbcb4 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -204,11 +204,15 @@ def parse_file_result(result, data_type=0): result_map = {} for root_node in result: if data_type != 1: - children_list = root_node['children'] - for children in children_list: - if children["name"] == '': - continue - result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) - del root_node['children'] + parse_file_result_by_child(result_map, root_node) result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) return result_map + + +def parse_file_result_by_child(result_map, root_node): + children_list = root_node['children'] + for children in children_list: + if children["name"] == '': + continue + result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) + del root_node['children'] -- Gitee From da939befae7b421b567c1636260039f6547a05de Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Tue, 14 May 2024 22:23:18 +0800 Subject: [PATCH 25/43] fix ffrt ffrt_get_main_queue Signed-off-by: zhuguoyang --- resourceschedule/ffrt/ffrt.ndk.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resourceschedule/ffrt/ffrt.ndk.json b/resourceschedule/ffrt/ffrt.ndk.json index ac87d49f8..0c83414e0 100644 --- a/resourceschedule/ffrt/ffrt.ndk.json +++ b/resourceschedule/ffrt/ffrt.ndk.json @@ -51,7 +51,7 @@ { "name": "ffrt_loop_timer_stop" }, { "name": "ffrt_queue_attr_set_max_concurrency" }, { "name": "ffrt_queue_atte_get_max_concurrency" }, - { "name": "ffrt_qet_main_queue" }, + { "name": "ffrt_get_main_queue" }, { "name": "ffrt_get_current_queue" }, { "name": "ffrt_task_attr_set_queue_priority" }, { "name": "ffrt_task_attr_get_queue_priority" }, -- Gitee From 4aa4e23d131437768ede0eccc7a57d889032fedd Mon Sep 17 00:00:00 2001 From: xuerunlong Date: Wed, 15 May 2024 01:25:17 +0000 Subject: [PATCH 26/43] update filemanagement/environment/include/oh_environment.h. Signed-off-by: xuerunlong --- filemanagement/environment/include/oh_environment.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filemanagement/environment/include/oh_environment.h b/filemanagement/environment/include/oh_environment.h index 7acc28d6d..d6f230ce8 100644 --- a/filemanagement/environment/include/oh_environment.h +++ b/filemanagement/environment/include/oh_environment.h @@ -43,7 +43,7 @@ extern "C" { * @permission ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. - * {@link PERMISSION_ERROR} 201 - Non System Application. + * {@link PERMISSION_ERROR} 201 - Permission verification failed. * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. * {@link E_NOMEM} 13900011 - Failed to apply for memory. @@ -57,7 +57,7 @@ FileManagement_ErrCode OH_Environment_GetUserDownloadDir(char **result); * @permission ohos.permission.READ_WRITE_DESKTOP_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. - * {@link PERMISSION_ERROR} 201 - Non System Application. + * {@link PERMISSION_ERROR} 201 - Permission verification failed. * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. * {@link E_NOMEM} 13900011 - Failed to apply for memory. @@ -71,7 +71,7 @@ FileManagement_ErrCode OH_Environment_GetUserDesktopDir(char **result); * @permission ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY * @param result Output a pointer to a string. Please use free() to clear the resource. * @return Return the status code of the execution. - * {@link PERMISSION_ERROR} 201 - Non System Application. + * {@link PERMISSION_ERROR} 201 - Permission verification failed. * {@link PARAMETER_ERROR} 401 - Invalid input parameter, pointer is null. * {@link DEVICE_NOT_SUPPORTED} 801 - Device not supported. * {@link E_NOMEM} 13900011 - Failed to apply for memory. -- Gitee From d4d726671162a1f5a4794aae0a3d4e4e7bb588cd Mon Sep 17 00:00:00 2001 From: xiyupeng Date: Wed, 15 May 2024 10:38:48 +0800 Subject: [PATCH 27/43] =?UTF-8?q?scheme=20handler=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E6=96=B0=E5=A2=9EOH=5FArkWebResourceRequest?= =?UTF-8?q?=5FGetFrameUrl=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiyupeng --- web/webview/interfaces/native/arkweb_scheme_handler.h | 11 +++++++++++ web/webview/interfaces/native/libohweb.ndk.json | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/web/webview/interfaces/native/arkweb_scheme_handler.h b/web/webview/interfaces/native/arkweb_scheme_handler.h index b746fcff1..a95caeb87 100644 --- a/web/webview/interfaces/native/arkweb_scheme_handler.h +++ b/web/webview/interfaces/native/arkweb_scheme_handler.h @@ -503,6 +503,17 @@ void OH_ArkWebResourceRequest_DestroyHttpBodyStream(ArkWeb_HttpBodyStream* httpB */ int32_t OH_ArkWebResourceRequest_GetResourceType(const ArkWeb_ResourceRequest* resourceRequest); +/* + * @brief Get the url of frame which trigger this request. + * @param resourceRequest The ArkWeb_ResourceRequest. + * @param frameUrl The url of frame which trigger this request. This function will allocate memory for the url string + * and caller must release the string by OH_ArkWeb_ReleaseString. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +void OH_ArkWebResourceRequest_GetFrameUrl(const ArkWeb_ResourceRequest* resourceRequest, char** frameUrl); + /* * @brief Set a user data to ArkWeb_HttpBodyStream. * @param httpBodyStream The ArkWeb_HttpBodyStream. diff --git a/web/webview/interfaces/native/libohweb.ndk.json b/web/webview/interfaces/native/libohweb.ndk.json index 4451e5d5a..a92438ec8 100644 --- a/web/webview/interfaces/native/libohweb.ndk.json +++ b/web/webview/interfaces/native/libohweb.ndk.json @@ -95,6 +95,10 @@ "first_introduced": "12", "name": "OH_ArkWebResourceRequest_GetResourceType" }, + { + "first_introduced": "12", + "name": "OH_ArkWebResourceRequest_GetFrameUrl" + }, { "first_introduced": "12", "name": "OH_ArkWebHttpBodyStream_SetReadCallback" -- Gitee From 5bb3c6f7826159982547cd756dc92ccbea440a57 Mon Sep 17 00:00:00 2001 From: peng Date: Wed, 15 May 2024 02:59:13 +0000 Subject: [PATCH 28/43] add audio ndk interface Signed-off-by: peng --- .../libnative_media_codecbase.ndk.json | 4 ++++ multimedia/av_codec/native_avcodec_base.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) 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 5763f34a7..1ccda0136 100644 --- a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json +++ b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json @@ -59,6 +59,10 @@ "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" diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 164e593d9..f341792ba 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -218,6 +218,14 @@ extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_WB; 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. * @@ -242,6 +250,7 @@ extern const char *OH_AVCODEC_MIMETYPE_VIDEO_VVC; */ extern const char *OH_AVCODEC_MIMETYPE_SUBTITLE_SRT; + /** * @brief The extra data's key of surface Buffer * @syscap SystemCapability.Multimedia.Media.CodecBase @@ -594,6 +603,14 @@ typedef enum OH_AVOutputFormat { AV_OUTPUT_FORMAT_DEFAULT = 0, AV_OUTPUT_FORMAT_MPEG_4 = 2, AV_OUTPUT_FORMAT_M4A = 6, + /** The muxer output amr file format. + * @since 12 + */ + AV_OUTPUT_FORMAT_AMR = 8, + /** The muxer output mp3 file format. + * @since 12 + */ + AV_OUTPUT_FORMAT_MP3 = 9, } OH_AVOutputFormat; /** -- Gitee From 0ac4429d39cafcf4446318c135d80973b24397fd Mon Sep 17 00:00:00 2001 From: caochuan Date: Mon, 29 Apr 2024 15:48:45 +0800 Subject: [PATCH 29/43] =?UTF-8?q?fixed=202dda5c6=20from=20https://gitee.co?= =?UTF-8?q?m/can-xia/interface=5Fsdk=5Fc/pulls/608=20=E8=8E=B7=E5=8F=96gif?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=9A=84=E6=92=AD=E6=94=BE=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: caochuan --- multimedia/image_framework/include/image/image_common.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index a567e4615..0b3efd1a7 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -1258,6 +1258,15 @@ static const char *OHOS_IMAGE_PROPERTY_SCENE_POINTER = "HwMnoteScenePointer"; * @since 12 */ static const char *OHOS_IMAGE_PROPERTY_SCENE_VERSION = "HwMnoteSceneVersion"; + +/** + * @brief Gif Loop Count + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * If infinite loop returns 0, other values represent the number of loops + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GIF_LOOP_COUNT = "GIFLoopCount"; #ifdef __cplusplus }; #endif -- Gitee From 9450fad64167a44b56dec3709f96cb2703dcb2a4 Mon Sep 17 00:00:00 2001 From: Can Xia Date: Wed, 15 May 2024 03:19:02 +0000 Subject: [PATCH 30/43] update multimedia/image_framework/include/image/image_common.h. Signed-off-by: Can Xia --- multimedia/image_framework/include/image/image_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index 0b3efd1a7..17524d046 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -1261,7 +1261,7 @@ static const char *OHOS_IMAGE_PROPERTY_SCENE_VERSION = "HwMnoteSceneVersion"; /** * @brief Gif Loop Count - * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * It is used in {@link OH_ImageSource_GetImageProperty} * If infinite loop returns 0, other values represent the number of loops * * @since 12 -- Gitee From 0c9c5f03e21208341122252310ca4ee10a274f51 Mon Sep 17 00:00:00 2001 From: hubin Date: Wed, 8 May 2024 11:27:32 +0800 Subject: [PATCH 31/43] add ipc capi interface Signed-off-by: hubin --- IPCKit/BUILD.gn | 40 +++ IPCKit/ipc_cparcel.h | 531 ++++++++++++++++++++++++++++++++++++ IPCKit/ipc_cremote_object.h | 286 +++++++++++++++++++ IPCKit/ipc_cskeleton.h | 180 ++++++++++++ IPCKit/ipc_error_code.h | 74 +++++ IPCKit/ipc_kit.h | 45 +++ IPCKit/libipc_capi.json | 226 +++++++++++++++ 7 files changed, 1382 insertions(+) create mode 100644 IPCKit/BUILD.gn create mode 100644 IPCKit/ipc_cparcel.h create mode 100644 IPCKit/ipc_cremote_object.h create mode 100644 IPCKit/ipc_cskeleton.h create mode 100644 IPCKit/ipc_error_code.h create mode 100644 IPCKit/ipc_kit.h create mode 100644 IPCKit/libipc_capi.json diff --git a/IPCKit/BUILD.gn b/IPCKit/BUILD.gn new file mode 100644 index 000000000..203f09a8f --- /dev/null +++ b/IPCKit/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (C) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("ipc_capi_header") { + dest_dir = "$ndk_headers_out_dir/IPCKit" + sources = [ + "./ipc_cparcel.h", + "./ipc_cremote_object.h", + "./ipc_cskeleton.h", + "./ipc_error_code.h", + "./ipc_kit.h", + ] +} + +ohos_ndk_library("libipc_capi") { + output_name = "ipc_capi" + output_extension = "so" + ndk_description_file = "./libipc_capi.json" + system_capability = "SystemCapability.Communication.IPC.Core" + system_capability_headers = [ + "IPCKit/ipc_cparcel.h", + "IPCKit/ipc_cremote_object.h", + "IPCKit/ipc_cskeleton.h", + "IPCKit/ipc_error_code.h", + "IPCKit/ipc_kit.h", + ] +} diff --git a/IPCKit/ipc_cparcel.h b/IPCKit/ipc_cparcel.h new file mode 100644 index 000000000..3e89733c6 --- /dev/null +++ b/IPCKit/ipc_cparcel.h @@ -0,0 +1,531 @@ +/* + * 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 CAPI_INCLUDE_IPC_CPARCEL_H +#define CAPI_INCLUDE_IPC_CPARCEL_H + +/** + * @addtogroup OHIPCParcel + * @{ + * + * @brief Defines C interfaces for IPC serialization and deserialization. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cparcel.h + * + * @brief Defines C interfaces for IPC serialization and deserialization. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @brief Defines an IPC serialized object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCParcel; + +/** +* @brief Typedef an IPC serialized object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCParcel OHIPCParcel; + +/** +* @brief Defines an IPC remote proxy object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCRemoteProxy; + +/** +* @brief Typedef an IPC remote proxy object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCRemoteProxy OHIPCRemoteProxy; + +/** +* @brief Defines an IPC remote service object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCRemoteStub; + +/** +* @brief Typedef an IPC remote service object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCRemoteStub OHIPCRemoteStub; + +/** + * @brief Allocates memory. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param len Length of the memory to allocate. + * @return Returns the address of the memory allocated if the operation is successful; returns NULL otherwise. + * @since 12 + */ +typedef void* (*OH_IPC_MemAllocator)(int32_t len); + +/** + * @brief Creates an OHIPCParcel object, which cannot exceed 204,800 bytes. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the pointer to the OHIPCParcel object created if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCParcel* OH_IPCParcel_Create(void); + +/** + * @brief Destroys an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the OHIPCParcel object to destroy. + * @since 12 + */ +void OH_IPCParcel_Destroy(OHIPCParcel *parcel); + +/** + * @brief Obtains the size of the data contained in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the data size obtained if the operation is successful.\n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetDataSize(const OHIPCParcel *parcel); + +/** + * @brief Obtains the number of bytes that can be written to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the number of bytes that can be written to the OHIPCParcel object. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetWritableBytes(const OHIPCParcel *parcel); + +/** + * @brief Obtains the number of bytes that can be read from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the number of bytes that can be read from the OHIPCParcel object. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetReadableBytes(const OHIPCParcel *parcel); + +/** + * @brief Obtains the position where data is read in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the position obtained if the operation is successful. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetReadPosition(const OHIPCParcel *parcel); + +/** + * @brief Obtains the position where data is written in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the position obtained if the operation is successful. \n + * Returns -1 if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_GetWritePosition(const OHIPCParcel *parcel); + +/** + * @brief Resets the position to read data in an IPC parcel. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param newReadPos New position to read data. The value ranges from 0 to the current data size. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_RewindReadPosition(OHIPCParcel *parcel, uint32_t newReadPos); + +/** + * @brief Resets the position to write data in an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param newWritePos New position to write data. The value ranges from 0 to the current data size. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. + * @since 12 + */ +int OH_IPCParcel_RewindWritePosition(OHIPCParcel *parcel, uint32_t newWritePos); + +/** + * @brief Writes an int8_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt8(OHIPCParcel *parcel, int8_t value); + +/** + * @brief Reads an int8_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt8(const OHIPCParcel *parcel, int8_t *value); + +/** + * @brief Writes an int16_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt16(OHIPCParcel *parcel, int16_t value); + +/** + * @brief Reads an int16_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt16(const OHIPCParcel *parcel, int16_t *value); + +/** + * @brief Writes an int32_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt32(OHIPCParcel *parcel, int32_t value); + +/** + * @brief Reads an int32_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt32(const OHIPCParcel *parcel, int32_t *value); + +/** + * @brief Writes an int64_t value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInt64(OHIPCParcel *parcel, int64_t value); + +/** + * @brief Reads an int64_t value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInt64(const OHIPCParcel *parcel, int64_t *value); + +/** + * @brief Writes a float value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteFloat(OHIPCParcel *parcel, float value); + +/** + * @brief Reads a float value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadFloat(const OHIPCParcel *parcel, float *value); + +/** + * @brief Writes a double value to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Value to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteDouble(OHIPCParcel *parcel, double value); + +/** + * @brief Reads a double value from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param value Pointer to the data to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadDouble(const OHIPCParcel *parcel, double *value); + +/** + * @brief Writes a string including a string terminator to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param str String to write, which cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteString(OHIPCParcel *parcel, const char *str); + +/** + * @brief Reads a string from an OHIPCParcel object. You can obtain the length of the string from strlen. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the address of the string read if the operation is successful; + * returns NULL if the operation fails or invalid parameters are found. + * @since 12 + */ +const char* OH_IPCParcel_ReadString(const OHIPCParcel *parcel); + +/** + * @brief Writes data of the specified length from the memory to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param buffer Pointer to the address of the memory information to write. + * @param len Length of the data to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteBuffer(OHIPCParcel *parcel, const uint8_t *buffer, int32_t len); + +/** + * @brief Reads memory information of the specified length from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param len Length of the memory to be read. + * @return Returns the memory address read if the operation is successful; + * returns NULL if invalid parameters are found or len exceeds the readable length of parcel. + * @since 12 + */ +const uint8_t* OH_IPCParcel_ReadBuffer(const OHIPCParcel *parcel, int32_t len); + +/** + * @brief Writes an OHIPCRemoteStub object to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param stub Pointer to the OHIPCRemoteStub object to write. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteRemoteStub(OHIPCParcel *parcel, const OHIPCRemoteStub *stub); + +/** + * @brief Reads the OHIPCRemoteStub object from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the pointer to the OHIPCRemoteStub object read if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCRemoteStub* OH_IPCParcel_ReadRemoteStub(const OHIPCParcel *parcel); + +/** + * @brief Writes an OHIPCRemoteProxy object to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param proxy Pointer to the OHIPCRemoteProxy object to write. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteRemoteProxy(OHIPCParcel *parcel, const OHIPCRemoteProxy *proxy); + +/** + * @brief Reads the OHIPCRemoteProxy object from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @return Returns the pointer to the OHIPCRemoteProxy object read if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCRemoteProxy* OH_IPCParcel_ReadRemoteProxy(const OHIPCParcel *parcel); + +/** + * @brief Writes a file descriptor to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param fd File descriptor to write. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteFileDescriptor(OHIPCParcel *parcel, int32_t fd); + +/** + * @brief Reads a file descriptor from an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param fd Pointer to the file descriptor to read. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadFileDescriptor(const OHIPCParcel *parcel, int32_t *fd); + +/** + * @brief Appends data to an OHIPCParcel object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param data Pointer to the data to append. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the operation fails. + * @since 12 + */ +int OH_IPCParcel_Append(OHIPCParcel *parcel, const OHIPCParcel *data); + +/** + * @brief Writes an interface token to an OHIPCParcel object for interface identity verification. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param token Pointer to the interface token to write. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR} if the data write operation fails. + * @since 12 + */ +int OH_IPCParcel_WriteInterfaceToken(OHIPCParcel *parcel, const char *token); + +/** + * @brief Reads an interface token from an OHIPCParcel object for interface identity verification. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param parcel Pointer to the target OHIPCParcel object. It cannot be NULL. + * @param token Pointer to the address of the memory for storing the interface token. + * The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL. + * If an error code is returned, you still need to check whether the memory is empty and release the memory. + * Otherwise, memory leaks may occur. + * @param len Pointer to the length of the interface token read, including the terminator. It cannot be NULL. + * @param allocator Memory allocator specified by the user for allocating memory for token. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the read operation fails. + * @since 12 + */ +int OH_IPCParcel_ReadInterfaceToken(const OHIPCParcel *parcel, char **token, int32_t *len, + OH_IPC_MemAllocator allocator); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/IPCKit/ipc_cremote_object.h b/IPCKit/ipc_cremote_object.h new file mode 100644 index 000000000..8155b7258 --- /dev/null +++ b/IPCKit/ipc_cremote_object.h @@ -0,0 +1,286 @@ +/* + * 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 CAPI_INCLUDE_IPC_CREMOTE_OBJECT_H +#define CAPI_INCLUDE_IPC_CREMOTE_OBJECT_H + +/** + * @addtogroup OHIPCRemoteObject + * @{ + * + * @brief Provides C interfaces for creating and destroying a remote object, transferring data, + * and observing the dead status of a remote object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cremote_object.h + * + * @brief Defines C interfaces for creating and destroying a remote object, transferring data, + * and observing the dead status of a remote object. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include + +#include "ipc_cparcel.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @brief Defines an OHIPCDeathRecipient object, which is used to receive a notification +* when the OHIPCRemoteStub object dies unexpectedly. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +struct OHIPCDeathRecipient; + +/** +* @brief Typedef an OHIPCDeathRecipient object. +* +* @syscap SystemCapability.Communication.IPC.Core +* @since 12 +*/ +typedef struct OHIPCDeathRecipient OHIPCDeathRecipient; + +/** + * @brief Called to process the remote data request at the stub. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param code Custom command word for communication, in the range [0x01, 0x00ffffff]. + * @param data Pointer to the request data object. It cannot be NULL or released in the function. + * @param reply Pointer to the response data object. It cannot be NULL or released in the function. + * If this function returns an error, data cannot be written to this parameter. + * @param userData Pointer to the user data. It can be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns a custom error code in the range [1909001, 1909999] or a system error code otherwise. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INVALID_USER_ERROR_CODE} if the custom error code is out of the value range. + * @since 12 + */ +typedef int (*OH_OnRemoteRequestCallback)(uint32_t code, const OHIPCParcel *data, + OHIPCParcel *reply, void *userData); + +/** + * @brief Called when an observed object is destroyed. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param userData Pointer to the user data. It can be NULL. + * @since 12 + */ +typedef void (*OH_OnRemoteDestroyCallback)(void *userData); + +/** + * @brief Creates an OHIPCRemoteStub object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param descriptor Pointer to the descriptor of the OHIPCRemoteStub object to create. It cannot be NULL. + * @param requestCallback Callback used to process the data request. It cannot be NULL. + * @param destroyCallback Callback to be invoked when the object is destroyed. It can be NULL. + * @param userData Pointer to the user data. It can be NULL. + * @return Returns the pointer to the OHIPCRemoteStub object created if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCRemoteStub* OH_IPCRemoteStub_Create(const char *descriptor, OH_OnRemoteRequestCallback requestCallback, + OH_OnRemoteDestroyCallback destroyCallback, void *userData); + +/** + * @brief Destroys an OHIPCRemoteStub object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param stub Pointer to the OHIPCRemoteStub object to destroy. + * @since 12 + */ +void OH_IPCRemoteStub_Destroy(OHIPCRemoteStub *stub); + +/** + * @brief Destroys an OHIPCRemoteProxy object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object to destroy. + * @since 12 + */ +void OH_IPCRemoteProxy_Destroy(OHIPCRemoteProxy *proxy); + +/** + * @brief Enumerates the IPC request modes. + * + * @since 12 + */ +typedef enum { + /** Synchronous request. */ + OH_IPC_REQUEST_MODE_SYNC = 0, + /** Asynchronous request. */ + OH_IPC_REQUEST_MODE_ASYNC = 1, +} OH_IPC_RequestMode; + +/** + * @brief Defines the IPC message options. + * + * @since 12 + */ +#pragma pack(4) +typedef struct { + /** Message request mode. */ + OH_IPC_RequestMode mode; + /** Parameter reserved for RPC, which is invalid for IPC. */ + uint32_t timeout; + /** Reserved parameter, which must be NULL. */ + void* reserved; +} OH_IPC_MessageOption; +#pragma pack() + +/** + * @brief Sends an IPC message. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object. It cannot be NULL. + * @param code Custom IPC command word, in the range [0x01, 0x00ffffff]. + * @param data Pointer to the request data object. It cannot be NULL. + * @param reply Pointer to the response data object. It cannot be NULL in the case of a synchronous request, + * and can be NULL in the case of an asynchronous request. + * @param option Pointer to the message options. It can be NULL, which indicates a synchronous request. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if invalid parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_DEAD_REMOTE_OBJECT} if the OHIPCRemoteStub object is dead. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CODE_OUT_OF_RANGE} if the error code is out of the value range. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} or a custom error code in other cases. + * @since 12 + */ +int OH_IPCRemoteProxy_SendRequest(const OHIPCRemoteProxy *proxy, uint32_t code, const OHIPCParcel *data, + OHIPCParcel *reply, const OH_IPC_MessageOption *option); + +/** + * @brief Obtains the interface descriptor from the stub. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object. It cannot be NULL. + * @param descriptor Double pointer to the address of the memory for holding the interface descriptor. + * The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL. + * If an error code is returned, you still need to check whether the memory is empty and release the memory. + * Otherwise, memory leaks may occur. + * @param len Pointer to the length of the data to be written to the descriptor, including the terminator. + * This parameter cannot be NULL. + * @param allocator Memory allocator specified by the user for allocating memory for descriptor. + * It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_DEAD_REMOTE_OBJECT} if the OHIPCRemoteStub object is dead. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_MEM_ALLOCATOR_ERROR} if memory allocation fails. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR} if the data in the serialized object failed to be read. + * @since 12 + */ +int OH_IPCRemoteProxy_GetInterfaceDescriptor(OHIPCRemoteProxy *proxy, char **descriptor, int32_t *len, + OH_IPC_MemAllocator allocator); + +/** + * @brief Called when the OHIPCRemoteStub object dies unexpectedly. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param userData Pointer to the user data. It can be NULL. + * @since 12 + */ +typedef void (*OH_OnDeathRecipientCallback)(void *userData); + +/** + * @brief Called when the OHIPCDeathRecipient object is destroyed. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param userData Pointer to the user data. It can be NULL. + * @since 12 + */ +typedef void (*OH_OnDeathRecipientDestroyCallback)(void *userData); + +/** + * @brief Creates an OHIPCDeathRecipient object, which allows a notification to be received + * when the OHIPCRemoteStub object dies unexpectedly. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param deathRecipientCallback Callback to be invoked when the OHIPCRemoteStub object is dead. + * It cannot be NULL. + * @param destroyCallback Callback to be invoked when the object is destroyed. It can be NULL. + * @param userData Pointer to the user data. It can be NULL. + * @return Returns the pointer to the OHIPCDeathRecipient object created if the operation is successful; + * returns NULL otherwise. + * @since 12 + */ +OHIPCDeathRecipient* OH_IPCDeathRecipient_Create(OH_OnDeathRecipientCallback deathRecipientCallback, + OH_OnDeathRecipientDestroyCallback destroyCallback, void *userData); + +/** + * @brief Destroys an OHIPCDeathRecipient object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param recipient Pointer to the OHIPCDeathRecipient object to destroy. + * @since 12 + */ +void OH_IPCDeathRecipient_Destroy(OHIPCDeathRecipient *recipient); + +/** + * @brief Subscribes to the death of an OHIPCRemoteStub object for an OHIPCRemoteProxy object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object that subscribes to the death notification. + * It cannot be NULL. + * @param recipient Pointer to the object that receives the death notification of the OHIPCRemoteStub object. + * It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCRemoteProxy_AddDeathRecipient(OHIPCRemoteProxy *proxy, OHIPCDeathRecipient *recipient); + +/** + * @brief Unsubscribes from the death of the OHIPCRemoteStub object for an OHIPCRemoteProxy object. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object that unsubscribes from the death notification. + * It cannot be NULL. + * @param recipient Pointer to the object that receives the death notification of the OHIPCRemoteStub object. + * It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCRemoteProxy_RemoveDeathRecipient(OHIPCRemoteProxy *proxy, OHIPCDeathRecipient *recipient); + +/** + * @brief Checks whether the OHIPCRemoteStub object corresponding to the OHIPCRemoteProxy object is dead. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param proxy Pointer to the OHIPCRemoteProxy object to check. It cannot be NULL. + * @return Returns 1 if the OHIPCRemoteStub object is dead; returns 0 otherwise. + * If an invalid parameter is found, the OHIPCRemoteStub object does not exist. + * In this case, 1 is returned. + * @since 12 + */ +int OH_IPCRemoteProxy_IsRemoteDead(const OHIPCRemoteProxy *proxy); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/IPCKit/ipc_cskeleton.h b/IPCKit/ipc_cskeleton.h new file mode 100644 index 000000000..bc70d2bb3 --- /dev/null +++ b/IPCKit/ipc_cskeleton.h @@ -0,0 +1,180 @@ +/* + * 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 CAPI_INCLUDE_IPC_CSKELETON_H +#define CAPI_INCLUDE_IPC_CSKELETON_H + +/** + * @addtogroup OHIPCSkeleton + * @{ + * + * @brief Provides C interfaces for managing the token IDs, credentials, process IDs (PIDs), + * user IDs (UIDs), and thread pool in the IPC framework. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cskeleton.h + * + * @brief Defines C interfaces for managing the token IDs, credentials, PIDs, UIDs, and thread + * pool in the IPC framework. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include + +#include "ipc_cparcel.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Joints this thread to the IPC worker thread pool. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ +void OH_IPCSkeleton_JoinWorkThread(void); + +/** + * @brief Stops this thread. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ +void OH_IPCSkeleton_StopWorkThread(void); + +/** + * @brief Obtains the token ID of the caller. This function must be called in the IPC context. + * Otherwise, the local token ID is returned. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the token ID of the caller. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetCallingTokenId(void); + +/** + * @brief Obtains the token ID of the first caller. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the token ID obtained. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetFirstTokenId(void); + +/** + * @brief Obtains the local token ID. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the token ID obtained. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetSelfTokenId(void); + +/** + * @brief Obtains the process ID of the caller. This function must be called in the IPC context. + * Otherwise, the current process ID is returned. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the process ID of the caller. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetCallingPid(void); + +/** + * @brief Obtains the UID of the caller. This function must be called in the IPC context. + * Otherwise, the current UID is returned. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns the UID of the caller. + * @since 12 + */ +uint64_t OH_IPCSkeleton_GetCallingUid(void); + +/** + * @brief Checks whether a local calling is being made. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns 1 if a local calling is in progress; returns 0 otherwise. + * @since 12 + */ +int OH_IPCSkeleton_IsLocalCalling(void); + +/** + * @brief Sets the maximum number of worker threads. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param maxThreadNum Maximum number of worker threads to set. The default value is 16. + * The value range is [1, 32]. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCSkeleton_SetMaxWorkThreadNum(const int maxThreadNum); + +/** + * @brief Resets the caller identity credential (including the token ID, UID, and PID) to that of this process and + * returns the caller credential information. + * The identity information is used in OH_IPCSkeleton_SetCallingIdentity. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param identity Pointer to the address of the memory for holding the caller identity information. + * The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL. + * @param len Pointer to the length of the identity information. It cannot be NULL. + * @param allocator Memory allocator specified by the user for allocating memory for identity. It cannot be NULL. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_MEM_ALLOCATOR_ERROR} if memory allocation fails. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCSkeleton_ResetCallingIdentity(char **identity, int32_t *len, OH_IPC_MemAllocator allocator); + +/** + * @brief Sets the caller credential information to the IPC context. + * + * @syscap SystemCapability.Communication.IPC.Core + * @param identity Pointer to the caller identity, which cannot be NULL. + * The value is returned by OH_IPCSkeleton_ResetCallingIdentity. + * @return Returns {@link OH_IPC_ErrorCode#OH_IPC_SUCCESS} if the operation is successful. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR} if incorrect parameters are found. \n + * Returns {@link OH_IPC_ErrorCode#OH_IPC_INNER_ERROR} in other cases. + * @since 12 + */ +int OH_IPCSkeleton_SetCallingIdentity(const char *identity); + +/** + * @brief Checks whether an IPC request is being handled. + * + * @syscap SystemCapability.Communication.IPC.Core + * @return Returns 1 if an IPC request is being handled; returns 0 otherwise. + * @since 12 + */ +int OH_IPCSkeleton_IsHandlingTransaction(void); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/IPCKit/ipc_error_code.h b/IPCKit/ipc_error_code.h new file mode 100644 index 000000000..2a2134ca7 --- /dev/null +++ b/IPCKit/ipc_error_code.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_INCLUDE_IPC_ERROR_CODE_H +#define CAPI_INCLUDE_IPC_ERROR_CODE_H + +/** + * @addtogroup OHIPCErrorCode + * @{ + * + * @brief Provides IPC error codes. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_error_code.h + * + * @brief Defines IPC error codes. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** +* @brief Enumerates IPC error codes. +* +* @since 12 +*/ +typedef enum { + /** @error Execution successful. */ + OH_IPC_SUCCESS = 0, + /** @error Start error code. */ + OH_IPC_ERROR_CODE_BASE = 1901000, + /** @error Invalid parameters. */ + OH_IPC_CHECK_PARAM_ERROR = OH_IPC_ERROR_CODE_BASE, + /** @error Failed to write data to the serialized object. */ + OH_IPC_PARCEL_WRITE_ERROR = OH_IPC_ERROR_CODE_BASE + 1, + /** @error Failed to read data from the serialized object. */ + OH_IPC_PARCEL_READ_ERROR = OH_IPC_ERROR_CODE_BASE + 2, + /** @error Failed to allocate memory. */ + OH_IPC_MEM_ALLOCATOR_ERROR = OH_IPC_ERROR_CODE_BASE + 3, + /** @error The command word is out of the value range [0x01,0x00ffffff]. */ + OH_IPC_CODE_OUT_OF_RANGE = OH_IPC_ERROR_CODE_BASE + 4, + /** @error The remote object is dead. */ + OH_IPC_DEAD_REMOTE_OBJECT = OH_IPC_ERROR_CODE_BASE + 5, + /** @error The custom error code is out of range [1900001, 1999999]. */ + OH_IPC_INVALID_USER_ERROR_CODE = OH_IPC_ERROR_CODE_BASE + 6, + /** @error IPC internal error. */ + OH_IPC_INNER_ERROR = OH_IPC_ERROR_CODE_BASE + 7, + /** @error Maximum error code. */ + OH_IPC_ERROR_CODE_MAX = OH_IPC_ERROR_CODE_BASE + 1000, + /** @error Minimum value for a custom error code. */ + OH_IPC_USER_ERROR_CODE_MIN = 1909000, + /** @error Maximum value for a custom error code. */ + OH_IPC_USER_ERROR_CODE_MAX = 1909999, +} OH_IPC_ErrorCode; + +/** @} */ +#endif diff --git a/IPCKit/ipc_kit.h b/IPCKit/ipc_kit.h new file mode 100644 index 000000000..e30d81aac --- /dev/null +++ b/IPCKit/ipc_kit.h @@ -0,0 +1,45 @@ +/* + * 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 CAPI_INCLUDE_IPC_KIT_H +#define CAPI_INCLUDE_IPC_KIT_H + +/** + * @addtogroup IPCKit + * @{ + * + * @brief Provides an entry to the IPC header files for you to reference. + * + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +/** + * @file ipc_cparcel.h + * + * @brief Provides an entry to the IPC header files for you to reference. + * + * @library libipc_capi.so + * @syscap SystemCapability.Communication.IPC.Core + * @since 12 + */ + +#include "ipc_error_code.h" +#include "ipc_cparcel.h" +#include "ipc_cremote_object.h" +#include "ipc_cskeleton.h" + +/** @} */ +#endif diff --git a/IPCKit/libipc_capi.json b/IPCKit/libipc_capi.json new file mode 100644 index 000000000..5c1976b92 --- /dev/null +++ b/IPCKit/libipc_capi.json @@ -0,0 +1,226 @@ +[ + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_JoinWorkThread" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_StopWorkThread" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetCallingTokenId" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetFirstTokenId" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetSelfTokenId" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetCallingPid" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_GetCallingUid" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_IsLocalCalling" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_SetMaxWorkThreadNum" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_ResetCallingIdentity" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_SetCallingIdentity" + }, + { + "first_introduced": "12", + "name": "OH_IPCSkeleton_IsHandlingTransaction" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteStub_Create" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteStub_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_SendRequest" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_GetInterfaceDescriptor" + }, + { + "first_introduced": "12", + "name": "OH_IPCDeathRecipient_Create" + }, + { + "first_introduced": "12", + "name": "OH_IPCDeathRecipient_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_AddDeathRecipient" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_RemoveDeathRecipient" + }, + { + "first_introduced": "12", + "name": "OH_IPCRemoteProxy_IsRemoteDead" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_Create" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetDataSize" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetWritableBytes" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetReadableBytes" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetReadPosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_GetWritePosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_RewindReadPosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_RewindWritePosition" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt8" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt8" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt16" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt16" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt32" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt32" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInt64" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInt64" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteFloat" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadFloat" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteDouble" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadDouble" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteString" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadString" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteBuffer" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadBuffer" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteRemoteStub" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadRemoteStub" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteRemoteProxy" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadRemoteProxy" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteFileDescriptor" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadFileDescriptor" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_Append" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_WriteInterfaceToken" + }, + { + "first_introduced": "12", + "name": "OH_IPCParcel_ReadInterfaceToken" + } +] -- Gitee From 907f1901a9988cea909df6bcefd202e8de4c83eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=80=80=E5=BE=B7?= Date: Wed, 15 May 2024 16:44:57 +0800 Subject: [PATCH 32/43] modify error msg for asset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 尹耀德 --- security/asset/inc/asset_api.h | 164 ++++++++++++++++---------------- security/asset/inc/asset_type.h | 80 ++++------------ 2 files changed, 102 insertions(+), 142 deletions(-) diff --git a/security/asset/inc/asset_api.h b/security/asset/inc/asset_api.h index 6e060d18c..f7753ff03 100755 --- a/security/asset/inc/asset_api.h +++ b/security/asset/inc/asset_api.h @@ -52,23 +52,23 @@ extern "C" { * * @param attributes Pointer to the attributes of the asset to add. * @param attributes Number of the attributes of the asset to add. - * @return Returns ASSET_SUCCESS if the operation is successful; - * Returns ASSET_PERMISSION_DENIED if the caller doesn't have the permission; - * Returns ASSET_INVALID_ARGUMENT if mandatory parameters are left unspecified or - * if incorrect parameter types, or if parameter verification failed; - * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; - * Returns ASSET_DUPLICATED if the asset already exists; - * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; - * Returns ASSET_OUT_OF_MEMORY if insufficient memory; - * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; - * Returns ASSET_DATABASE_ERROR if the database operation failed; - * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; - * Returns ASSET_IPC_ERROR if IPC failed; - * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; - * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; - * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; - * Returns ASSET_FILE_OPERATION_ERROR if the file operation failed; - * Returns ASSET_GET_SYSTEM_TIME_ERROR if getting the system time failed. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful; + * {@link ASSET_PERMISSION_DENIED} 201 - The caller doesn't have the permission; + * {@link ASSET_INVALID_ARGUMENT} 401 - Mandatory parameters are left unspecified or + * incorrect parameter types, or parameter verification failed; + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; + * {@link ASSET_DUPLICATED} 24000003 - The asset already exists; + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; + * {@link ASSET_FILE_OPERATION_ERROR} 24000014 - The file operation failed; + * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ int32_t OH_Asset_Add(const Asset_Attr *attributes, uint32_t attrCnt); @@ -78,17 +78,17 @@ int32_t OH_Asset_Add(const Asset_Attr *attributes, uint32_t attrCnt); * * @param query Pointer to the conditions for removing the assets. * @param queryCnt Number of conditions for removing the assets. - * @return Returns ASSET_SUCCESS if the operation is successful; - * Returns ASSET_INVALID_ARGUMENT if incorrect parameter types, or if parameter verification failed; - * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; - * Returns ASSET_NOT_FOUND if the asset is not found; - * Returns ASSET_OUT_OF_MEMORY if insufficient memory; - * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; - * Returns ASSET_DATABASE_ERROR if the database operation failed; - * Returns ASSET_IPC_ERROR if IPC failed; - * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; - * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; - * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful; + * {@link ASSET_INVALID_ARGUMENT} 401 - Incorrect parameter types, or parameter verification failed; + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. * @since 11 */ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); @@ -100,21 +100,21 @@ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); * @param queryCnt Number of conditions for updating the asset. * @param attributes Pointer to the attributes of the asset to update. * @param attributes Number of the attributes of the asset to update. - * @return Returns ASSET_SUCCESS if the operation is successful; - * Returns ASSET_INVALID_ARGUMENT if mandatory parameters are left unspecified or - * if incorrect parameter types, or if parameter verification failed; - * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; - * Returns ASSET_NOT_FOUND if the asset is not found; - * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; - * Returns ASSET_OUT_OF_MEMORY if insufficient memory; - * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; - * Returns ASSET_DATABASE_ERROR if the database operation failed; - * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; - * Returns ASSET_IPC_ERROR if IPC failed; - * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; - * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; - * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; - * Returns ASSET_GET_SYSTEM_TIME_ERROR if getting the system time failed. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful; + * {@link ASSET_INVALID_ARGUMENT} 401 - Mandatory parameters are left unspecified or + * incorrect parameter types, or parameter verification failed; + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; + * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ int32_t OH_Asset_Update(const Asset_Attr *query, uint32_t queryCnt, @@ -126,21 +126,21 @@ int32_t OH_Asset_Update(const Asset_Attr *query, uint32_t queryCnt, * @param query Pointer to the search criteria of the asset. * @param queryCnt Number of the search criteria. * @param challenge Pointer to the challenge value to be used when OH_Asset_Query is called. - * @return Returns ASSET_SUCCESS if the operation is successful; - * Returns ASSET_INVALID_ARGUMENT if incorrect parameter types, or if parameter verification failed; - * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; - * Returns ASSET_NOT_FOUND if the asset is not found; - * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; - * Returns ASSET_OUT_OF_MEMORY if insufficient memory; - * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; - * Returns ASSET_DATABASE_ERROR if the database operation failed; - * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; - * Returns ASSET_IPC_ERROR if IPC failed; - * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; - * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; - * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; - * Returns ASSET_LIMIT_EXCEEDED if the cache exceeds the limit; - * Returns ASSET_UNSUPPORTED if the capability is not supported. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful; + * {@link ASSET_INVALID_ARGUMENT} 401 -Incorrect parameter types, or parameter verification failed; + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; + * {@link ASSET_LIMIT_EXCEEDED} 24000016 - The cache exceeds the limit; + * {@link ASSET_UNSUPPORTED} 24000017 - The capability is not supported. * @since 11 */ int32_t OH_Asset_PreQuery(const Asset_Attr *query, uint32_t queryCnt, Asset_Blob *challenge); @@ -151,21 +151,21 @@ int32_t OH_Asset_PreQuery(const Asset_Attr *query, uint32_t queryCnt, Asset_Blob * @param query Pointer to the search criteria. * @param queryCnt Number of the search criteria. * @param resultSet Pointer to the query result obtained. - * @return Returns ASSET_SUCCESS if the operation is successful; - * Returns ASSET_INVALID_ARGUMENT if incorrect parameter types, or if parameter verification failed; - * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; - * Returns ASSET_NOT_FOUND if the asset is not found; - * Returns ASSET_ACCESS_DENIED if access to the asset is denied; - * Returns ASSET_STATUS_MISMATCH if the screen lock status does not match; - * Returns ASSET_OUT_OF_MEMORY if insufficient memory; - * Returns ASSET_DATA_CORRUPTED if the asset is corrupted; - * Returns ASSET_DATABASE_ERROR if the database operation failed; - * Returns ASSET_CRYPTO_ERROR if the cryptography operation failed; - * Returns ASSET_IPC_ERROR if IPC failed; - * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; - * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; - * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed; - * Returns ASSET_UNSUPPORTED if the capability is not supported. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful; + * {@link ASSET_INVALID_ARGUMENT} 401 - Incorrect parameter types, or parameter verification failed; + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; + * {@link ASSET_ACCESS_DENIED} 24000004 - Access to the asset is denied; + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; + * {@link ASSET_UNSUPPORTED} 24000017 - The capability is not supported. * @since 11 */ int32_t OH_Asset_Query(const Asset_Attr *query, uint32_t queryCnt, Asset_ResultSet *resultSet); @@ -176,15 +176,15 @@ int32_t OH_Asset_Query(const Asset_Attr *query, uint32_t queryCnt, Asset_ResultS * @param handle Pointer to the handle of the data to process, which includes the challenge value returned by * OH_Asset_PreQuery. * @param handleCnt Number of the elements in the handle attribute set. - * @return Returns ASSET_SUCCESS if the operation is successful; - * Returns ASSET_INVALID_ARGUMENT if mandatory parameters are left unspecified or - * if incorrect parameter types, or if parameter verification failed; - * Returns ASSET_SERVICE_UNAVAILABLE if the ASSET service is unavailable; - * Returns ASSET_OUT_OF_MEMORY if insufficient memory; - * Returns ASSET_IPC_ERROR if IPC failed; - * Returns ASSET_BMS_ERROR if calling the Bundle Manager service failed; - * Returns ASSET_ACCOUNT_ERROR if calling the OS Account service failed; - * Returns ASSET_ACCESS_TOKEN_ERROR if calling the Access Token service failed. + * @return {@link ASSET_SUCCESS} 0 - The operation is successful; + * {@link ASSET_INVALID_ARGUMENT} 401 - Mandatory parameters are left unspecified or + * incorrect parameter types, or parameter verification failed; + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; * @since 11 */ int32_t OH_Asset_PostQuery(const Asset_Attr *handle, uint32_t handleCnt); diff --git a/security/asset/inc/asset_type.h b/security/asset/inc/asset_type.h index cc2bd861d..150d76021 100755 --- a/security/asset/inc/asset_type.h +++ b/security/asset/inc/asset_type.h @@ -216,85 +216,45 @@ typedef enum { * @since 11 */ typedef enum { - /** - * The operation is successful. - */ + /** @error The operation is successful. */ ASSET_SUCCESS = 0, - /** - * The caller does not have the required permission. - */ + /** @error The caller doesn't have the permission. */ ASSET_PERMISSION_DENIED = 201, - /** - * The parameter is invalid. - */ + /** @error The parameter is invalid. */ ASSET_INVALID_ARGUMENT = 401, - /** - * The asset service is unavailable. - */ + /** @error The ASSET service is unavailable. */ ASSET_SERVICE_UNAVAILABLE = 24000001, - /** - * The asset is not found. - */ + /** @error The asset is not found. */ ASSET_NOT_FOUND = 24000002, - /** - * The asset already exists. - */ + /** @error The asset already exists. */ ASSET_DUPLICATED = 24000003, - /** - * The access to the asset is denied. - */ + /** @error Access to the asset is denied. */ ASSET_ACCESS_DENIED = 24000004, - /** - * The lock screen status does not match the access control type specified. - */ + /** @error The screen lock status does not match. */ ASSET_STATUS_MISMATCH = 24000005, - /** - * The system memory is insufficient. - */ + /** @error Insufficient memory. */ ASSET_OUT_OF_MEMORY = 24000006, - /** - * The asset is corrupted. - */ + /** @error The asset is corrupted. */ ASSET_DATA_CORRUPTED = 24000007, - /** - * The database operation failed. - */ + /** @error The database operation failed. */ ASSET_DATABASE_ERROR = 24000008, - /** - * The cryptography operation failed. - */ + /** @error The cryptography operation failed. */ ASSET_CRYPTO_ERROR = 24000009, - /** - * The inter-process communication (IPC) failed. - */ + /** @error IPC failed. */ ASSET_IPC_ERROR = 24000010, - /** - * The Bundle Manager service is abnormal. - */ + /** @error Calling the Bundle Manager service failed. */ ASSET_BMS_ERROR = 24000011, - /** - * The Account service is abnormal. - */ + /** @error Calling the OS Account service failed. */ ASSET_ACCOUNT_ERROR = 24000012, - /** - * The Access Token service is abnormal. - */ + /** @error Calling the Access Token service failed. */ ASSET_ACCESS_TOKEN_ERROR = 24000013, - /** - * The file operation failed. - */ + /** @error The file operation failed. */ ASSET_FILE_OPERATION_ERROR = 24000014, - /** - * The operation for obtaining the system time failed. - */ + /** @error Getting the system time failed. */ ASSET_GET_SYSTEM_TIME_ERROR = 24000015, - /** - * The number of cached assets exceeds the limit. - */ + /** @error The cache exceeds the limit. */ ASSET_LIMIT_EXCEEDED = 24000016, - /** - * The function is not supported. - */ + /** @error The capability is not supported. */ ASSET_UNSUPPORTED = 24000017, } Asset_ResultCode; -- Gitee From ff4fb80ff1c00901e342738079e755379646392f Mon Sep 17 00:00:00 2001 From: Can Xia Date: Wed, 15 May 2024 08:52:13 +0000 Subject: [PATCH 33/43] update multimedia/image_framework/include/image/image_common.h. Signed-off-by: Can Xia --- multimedia/image_framework/include/image/image_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index 17524d046..c60eac8b3 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -1261,7 +1261,7 @@ static const char *OHOS_IMAGE_PROPERTY_SCENE_VERSION = "HwMnoteSceneVersion"; /** * @brief Gif Loop Count - * It is used in {@link OH_ImageSource_GetImageProperty} + * It is used in {@link OH_ImageSource_GetImageProperty}. * If infinite loop returns 0, other values represent the number of loops * * @since 12 -- Gitee From 09517327174650edbeabab28798e4518ffdcdf92 Mon Sep 17 00:00:00 2001 From: peng Date: Wed, 15 May 2024 12:28:49 +0000 Subject: [PATCH 34/43] Adjust comment format Signed-off-by: peng --- multimedia/av_codec/native_avcodec_base.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index f341792ba..9e54da292 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -603,11 +603,13 @@ typedef enum OH_AVOutputFormat { AV_OUTPUT_FORMAT_DEFAULT = 0, AV_OUTPUT_FORMAT_MPEG_4 = 2, AV_OUTPUT_FORMAT_M4A = 6, - /** The muxer output amr file format. + /** + * The muxer output amr file format. * @since 12 */ AV_OUTPUT_FORMAT_AMR = 8, - /** The muxer output mp3 file format. + /** + * The muxer output mp3 file format. * @since 12 */ AV_OUTPUT_FORMAT_MP3 = 9, -- Gitee From 941bfec468648ac99eb73b22de22e9138cd2b02e Mon Sep 17 00:00:00 2001 From: peng Date: Wed, 15 May 2024 12:30:31 +0000 Subject: [PATCH 35/43] Adjust comment format Signed-off-by: peng --- multimedia/av_codec/native_avcodec_base.h | 1 - 1 file changed, 1 deletion(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 9e54da292..ff17fd551 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -250,7 +250,6 @@ extern const char *OH_AVCODEC_MIMETYPE_VIDEO_VVC; */ extern const char *OH_AVCODEC_MIMETYPE_SUBTITLE_SRT; - /** * @brief The extra data's key of surface Buffer * @syscap SystemCapability.Multimedia.Media.CodecBase -- Gitee From 11d8de15f1e556160ebfa5e607dfe3c41bdad7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=80=80=E5=BE=B7?= Date: Thu, 16 May 2024 12:02:37 +0800 Subject: [PATCH 36/43] modify error msg for asset2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 尹耀德 --- security/asset/inc/asset_api.h | 167 ++++++++++++++++++--------------- 1 file changed, 90 insertions(+), 77 deletions(-) diff --git a/security/asset/inc/asset_api.h b/security/asset/inc/asset_api.h index f7753ff03..fc14226cb 100755 --- a/security/asset/inc/asset_api.h +++ b/security/asset/inc/asset_api.h @@ -52,22 +52,24 @@ extern "C" { * * @param attributes Pointer to the attributes of the asset to add. * @param attributes Number of the attributes of the asset to add. - * @return {@link ASSET_SUCCESS} 0 - The operation is successful; - * {@link ASSET_PERMISSION_DENIED} 201 - The caller doesn't have the permission; - * {@link ASSET_INVALID_ARGUMENT} 401 - Mandatory parameters are left unspecified or - * incorrect parameter types, or parameter verification failed; - * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; - * {@link ASSET_DUPLICATED} 24000003 - The asset already exists; - * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; - * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; - * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; - * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; - * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; - * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; - * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; - * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; - * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; - * {@link ASSET_FILE_OPERATION_ERROR} 24000014 - The file operation failed; + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_PERMISSION_DENIED} 201 - The caller doesn't have the permission. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_DUPLICATED} 24000003 - The asset already exists. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_FILE_OPERATION_ERROR} 24000014 - The file operation failed. * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ @@ -78,17 +80,20 @@ int32_t OH_Asset_Add(const Asset_Attr *attributes, uint32_t attrCnt); * * @param query Pointer to the conditions for removing the assets. * @param queryCnt Number of conditions for removing the assets. - * @return {@link ASSET_SUCCESS} 0 - The operation is successful; - * {@link ASSET_INVALID_ARGUMENT} 401 - Incorrect parameter types, or parameter verification failed; - * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; - * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; - * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; - * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; - * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; - * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; - * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; - * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Incorrect parameter types. + * 2. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); @@ -100,20 +105,22 @@ int32_t OH_Asset_Remove(const Asset_Attr *query, uint32_t queryCnt); * @param queryCnt Number of conditions for updating the asset. * @param attributes Pointer to the attributes of the asset to update. * @param attributes Number of the attributes of the asset to update. - * @return {@link ASSET_SUCCESS} 0 - The operation is successful; - * {@link ASSET_INVALID_ARGUMENT} 401 - Mandatory parameters are left unspecified or - * incorrect parameter types, or parameter verification failed; - * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; - * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; - * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; - * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; - * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; - * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; - * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; - * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; - * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; - * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; - * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. * {@link ASSET_GET_SYSTEM_TIME_ERROR} 24000015 - Getting the system time failed. * @since 11 */ @@ -126,20 +133,22 @@ int32_t OH_Asset_Update(const Asset_Attr *query, uint32_t queryCnt, * @param query Pointer to the search criteria of the asset. * @param queryCnt Number of the search criteria. * @param challenge Pointer to the challenge value to be used when OH_Asset_Query is called. - * @return {@link ASSET_SUCCESS} 0 - The operation is successful; - * {@link ASSET_INVALID_ARGUMENT} 401 -Incorrect parameter types, or parameter verification failed; - * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; - * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; - * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; - * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; - * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; - * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; - * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; - * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; - * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; - * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; - * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; - * {@link ASSET_LIMIT_EXCEEDED} 24000016 - The cache exceeds the limit; + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Incorrect parameter types. + * 2. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. + * {@link ASSET_LIMIT_EXCEEDED} 24000016 - The cache exceeds the limit. * {@link ASSET_UNSUPPORTED} 24000017 - The capability is not supported. * @since 11 */ @@ -151,20 +160,22 @@ int32_t OH_Asset_PreQuery(const Asset_Attr *query, uint32_t queryCnt, Asset_Blob * @param query Pointer to the search criteria. * @param queryCnt Number of the search criteria. * @param resultSet Pointer to the query result obtained. - * @return {@link ASSET_SUCCESS} 0 - The operation is successful; - * {@link ASSET_INVALID_ARGUMENT} 401 - Incorrect parameter types, or parameter verification failed; - * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; - * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found; - * {@link ASSET_ACCESS_DENIED} 24000004 - Access to the asset is denied; - * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match; - * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; - * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted; - * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed; - * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed; - * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; - * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; - * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; - * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Incorrect parameter types. + * 2. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_NOT_FOUND} 24000002 - The asset is not found. + * {@link ASSET_ACCESS_DENIED} 24000004 - Access to the asset is denied. + * {@link ASSET_STATUS_MISMATCH} 24000005 - The screen lock status does not match. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_DATA_CORRUPTED} 24000007 - The asset is corrupted. + * {@link ASSET_DATABASE_ERROR} 24000008 - The database operation failed. + * {@link ASSET_CRYPTO_ERROR} 24000009 - The cryptography operation failed. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. * {@link ASSET_UNSUPPORTED} 24000017 - The capability is not supported. * @since 11 */ @@ -176,15 +187,17 @@ int32_t OH_Asset_Query(const Asset_Attr *query, uint32_t queryCnt, Asset_ResultS * @param handle Pointer to the handle of the data to process, which includes the challenge value returned by * OH_Asset_PreQuery. * @param handleCnt Number of the elements in the handle attribute set. - * @return {@link ASSET_SUCCESS} 0 - The operation is successful; - * {@link ASSET_INVALID_ARGUMENT} 401 - Mandatory parameters are left unspecified or - * incorrect parameter types, or parameter verification failed; - * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable; - * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory; - * {@link ASSET_IPC_ERROR} 24000010 - IPC failed; - * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed; - * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed; - * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed; + * @return {@link ASSET_SUCCESS} 0 - The operation is successful. + * {@link ASSET_INVALID_ARGUMENT} 401 - Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link ASSET_SERVICE_UNAVAILABLE} 24000001 - The ASSET service is unavailable. + * {@link ASSET_OUT_OF_MEMORY} 24000006 - Insufficient memory. + * {@link ASSET_IPC_ERROR} 24000010 - IPC failed. + * {@link ASSET_BMS_ERROR} 24000011 - Calling the Bundle Manager service failed. + * {@link ASSET_ACCOUNT_ERROR} 24000012 - Calling the OS Account service failed. + * {@link ASSET_ACCESS_TOKEN_ERROR} 24000013 - Calling the Access Token service failed. * @since 11 */ int32_t OH_Asset_PostQuery(const Asset_Attr *handle, uint32_t handleCnt); -- Gitee From 38b426550f9592cd0c378fba85ee2af3027a6c30 Mon Sep 17 00:00:00 2001 From: huqingyun Date: Tue, 14 May 2024 09:53:15 +0000 Subject: [PATCH 37/43] =?UTF-8?q?=E6=96=B0=E5=A2=9EC-API=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huqingyun Change-Id: I36aaeacea9c680cb3d003e891fc19f28c44dcce4 --- arkui/ace_engine/native/libace.ndk.json | 100 +++++++++++ arkui/ace_engine/native/native_node.h | 102 +++++++++++ arkui/ace_engine/native/native_type.h | 220 ++++++++++++++++++++++++ arkui/ace_engine/native/styled_string.h | 125 ++++++++++++++ 4 files changed, 547 insertions(+) create mode 100644 arkui/ace_engine/native/styled_string.h diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index e880238e0..b5f15e435 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -615,6 +615,10 @@ "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_SetMargin" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_WaterFlowSectionOption_GetSize" + }, { "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_GetItemCount" @@ -635,6 +639,10 @@ "first_introduced": "12", "name": "OH_ArkUI_WaterFlowSectionOption_GetMargin" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_WaterFlowSectionOption_RegisterGetItemMainSizeCallbackByIndex" + }, { "first_introduced": "12", "name": "OH_ArkUI_AnimateOption_Create" @@ -1058,5 +1066,97 @@ { "first_introduced": "12", "name": "OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_PushTextStyle" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_AddText" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_PopTextStyle" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_CreateTypography" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_StyledString_AddPlaceholder" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetContent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetActionAreaDistance" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_GetActionAreaDistance" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnEnterActionArea" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnAction" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnExitActionArea" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionItem_SetOnStateChange" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetStart" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetEnd" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetEdgeEffect" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_GetEdgeEffect" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ListItemSwipeActionOption_SetOnOffsetChange" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 2e089f3e4..d7f2bdf1d 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -1603,6 +1603,19 @@ typedef enum { */ NODE_LAYOUT_RECT, + /** + * @brief Whether the current component supports click-to-focus capability, + * 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: The parameter type is 1 or 0. + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].i32: The parameter type is 1 or 0. + * + */ + NODE_FOCUS_ON_TOUCH, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -1952,6 +1965,18 @@ typedef enum { */ NODE_TEXT_SELECTED_BACKGROUND_COLOR, + /** + * @brief The text component uses a formatted string object to set text content properties, + * and supports property setting, property reset, and property acquisition interfaces. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .object indicates ArkUI_StyledString formatted string data. The parameter type is {@link ArkUI_StyledString}. \n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .object indicates ArkUI_StyledString formatted string data. The parameter type is {@link ArkUI_StyledString}. \n + */ + NODE_TEXT_CONTENT_WITH_STYLED_STRING, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -1985,6 +2010,18 @@ typedef enum { * */ NODE_SPAN_TEXT_BACKGROUND_STYLE, + /** + * @brief Defines the text baseline offset attribute + * This attribute 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: baseline offset, in fp.\n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].f32: baseline offset, in fp. \n + * + */ + NODE_SPAN_BASELINE_OFFSET, /** * @brief Defines the image source of the image span. * This attribute can be set, reset, and obtained as required through APIs. @@ -2013,6 +2050,20 @@ typedef enum { * */ NODE_IMAGE_SPAN_VERTICAL_ALIGNMENT, + /** + * @brief Defines the placeholder image source. + * This attribute can be set, reset, and obtained as required through APIs. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}.\n + * + */ + NODE_IMAGE_SPAN_ALT, /** * @brief Defines the image source of the component. * This attribute can be set, reset, and obtained as required through APIs. @@ -2094,9 +2145,11 @@ typedef enum { * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}. Either .string or .object must be set.\n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .string: placeholder image source. \n + * .object: The parameter type is {@link ArkUI_DrawableDescriptor}.\n * */ NODE_IMAGE_ALT, @@ -4444,6 +4497,19 @@ typedef enum { */ NODE_SWIPER_SWIPE_TO_INDEX, + /** + * @brief: Set the delineation component of the ListItem, supporting property settings, property resets, and + * property acquisition interfaces. + * + * Attribute setting method parameter {@link ArkUI_AttributeItem} format: \n + * .object: Construct using the {@link ArkUI_ListitemSwipeActionOption} object. \n + * \n + * The return value of the attribute acquisition method {@link ArkUI_AttributeItem} format: \n + * .object: Construct using the {@link ArkUI_ListitemSwipeActionOption} object. \n + * + */ + NODE_LIST_ITEM_SWIPE_ACTION = MAX_NODE_SCOPE_NUM * ARKUI_NODE_LIST_ITEM, + /** * @brief Defines the header of the list item group. * This attribute can be set, reset, and obtained as required through APIs. @@ -5438,6 +5504,32 @@ typedef enum { */ NODE_SWIPER_EVENT_ON_GESTURE_SWIPE, + /** + * @brief Define the ARKUI_NODE_SWIPER to listen for Swiper page slide events. + * Instruction: \n + * 1. If the {@link ArkUI_SwiperDisplayModeType} attribute is set to \n + * ARKUI_SWIPER_DISPLAY_MODE_AUTO_LINEAR, the interface does not take effect. \n + * 2, circular scenario, set prevMargin and nextMargin attributes, \n + * so that Swiper front and back end display the same page, the interface does not take effect. \n + * 3. During page sliding, the ContentDidScrollCallback callback is \n + * triggered frame-by-frame for all pages in the window. \n + * For example, when there are two pages in the window with subscripts 0 and 1, \n + * callbacks with index values 0 and 1 are triggered twice per frame. \n + * 4, set the swipeByGroup parameter of the displayCount property to \n + * true if at least one page in the same group is in the window, \n + * A callback is triggered for all pages in the group. \n + * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is + * {@link ArkUI_NodeComponentEvent}. \n + * {@link ArkUI_NodeComponentEvent} contains four parameters:\n + * ArkUI_NodeComponentEvent.data[0].i32 : indicates the index of the Swiper component, \n + * which is consistent with the index change in the onChange event. \n + * ArkUI_NodeComponentEvent.data[1].i32 : The index of a page in the window. \n + * ArkUI_NodeComponentEvent.data[2].f32 : The proportion of page movement relative to \n + * the start position of the Swiper spindle (selectedIndex corresponds to the start position of the page). \n + * ArkUI_NodeComponentEvent.data[3].f32 : The length of the page in the axis direction. \n + */ + NODE_SWIPER_EVENT_ON_CONTENT_DID_SCROLL, + /** * @brief Defines the event triggered when the ARKUI_NODE_SCROLL component scrolls. * @@ -5637,6 +5729,16 @@ typedef enum { */ NODE_REFRESH_ON_REFRESH, + /** + * @brief Defines the event that is triggered when the ARKUI_NODE_REFRESH drop-down distance changes. + * + * 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].f32: Pull-down distance. \n + */ + NODE_REFRESH_ON_OFFSET_CHANGE, + /** * @brief Defines the event triggered when the ARKUI_NODE_SCROLL component is about to scroll. * diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index 71a268f5e..381ea6d42 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -98,6 +98,20 @@ typedef struct ArkUI_NativeDialog* ArkUI_NativeDialogHandle; */ typedef struct ArkUI_WaterFlowSectionOption ArkUI_WaterFlowSectionOption; +/** + * @brief Define the configuration information of the Item within the ListitemSwipeActionOption method. + * + * @since 12 + */ +typedef struct ArkUI_ListItemSwipeActionItem ArkUI_ListItemSwipeActionItem; + +/** + * @brief Define the configuration information for the ListitemSwipeActionOption method. + * + * @since 12 + */ +typedef struct ArkUI_ListItemSwipeActionOption ArkUI_ListItemSwipeActionOption; + /** * @brief Defines the ArkUI native context object. * @@ -862,6 +876,8 @@ typedef enum { ARKUI_SLIDER_STYLE_OUT_SET = 0, /** The slider is in the slider track. */ ARKUI_SLIDER_STYLE_IN_SET, + /** No slider. */ + ARKUI_SLIDER_STYLE_NONE, } ArkUI_SliderStyle; /** @@ -1770,6 +1786,34 @@ typedef enum { ARKUI_SWIPER_INDICATOR_TYPE_DIGIT, } ArkUI_SwiperIndicatorType; +/** + * @brief Define the pattern of element arrangement in the main axis direction of the Swiper component. + * + * @since 12 + */ +typedef enum { + /** In the folded state, when the ListItem slides in the opposite direction to the main axis, + * the operation item is hidden.*/ + ARKUI_LIST_ITEM_SWIPE_ACTION_STATE_COLLAPSED = 0, + /** In the folded state, when the ListItem slides in the opposite direction to the spindle, + * the operation item is displayed.*/ + ARKUI_LIST_ITEM_SWIPE_ACTION_STATE_EXPANDED, + /** Long distance state, the state of deleting a ListItem after it enters the long distance deletion area.*/ + ARKUI_LIST_ITEM_SWIPE_ACTION_STATE_ACTIONING, +} ArkUI_ListItemSwipeActionState; + +/** + * @brief Define the explicit and implicit mode of the SwipeAction method for the Listitem component. + * + * @since 12 + */ +typedef enum { + /** The ListItem can continue to be scratched after the distance exceeds the size of the scratched component.*/ + ARKUI_LIST_ITEM_SWIPE_EDGE_EFFECT_SPRING = 0, + /** The sliding distance of the ListItem cannot exceed the size of the scratched component.*/ + ARKUI_LIST_ITEM_SWIPE_EDGE_EFFECT_NONE, +} ArkUI_ListItemSwipeEdgeEffect; + /** * @brief Creates a size constraint. * @@ -1946,6 +1990,16 @@ void OH_ArkUI_WaterFlowSectionOption_Dispose(ArkUI_WaterFlowSectionOption* optio */ void OH_ArkUI_WaterFlowSectionOption_SetSize(ArkUI_WaterFlowSectionOption* option, int32_t size); +/** +* @brief Gets the FlowItem grouping configuration information array length. +* +* @param option FlowItem Indicates the packet configuration. +* @return Array size. If -1 is returned, the return fails. +* The possible cause of the failure is that the option parameter is abnormal, such as a null pointer. +* @since 12 +*/ +int32_t OH_ArkUI_WaterFlowSectionOption_GetSize(ArkUI_WaterFlowSectionOption* option); + /** * @brief Sets the number of items in a water flow section. * @@ -1967,6 +2021,18 @@ void OH_ArkUI_WaterFlowSectionOption_SetItemCount(ArkUI_WaterFlowSectionOption* */ int32_t OH_ArkUI_WaterFlowSectionOption_GetItemCount(ArkUI_WaterFlowSectionOption* option, int32_t index); +/** +* @brief The FlowItem grouping configuration information getsthe spindle size of +* the specified Item based on flowItemIndex. +* +* @param option Indicates the pointer to a water flow section configuration. +* @param index Indicates the index of the target water flow section. +* @param callback Gets the spindle size of the specified Item based on index. +* @since 12 +*/ +void OH_ArkUI_WaterFlowSectionOption_RegisterGetItemMainSizeCallbackByIndex(ArkUI_WaterFlowSectionOption* option, + int32_t index, float(*callback)(int32_t itemIndex)); + /** * @brief Sets the number of columns (in a vertical layout) or rows (in a horizontal layout) of a water flow. * @@ -2692,6 +2758,160 @@ float OH_ArkUI_AlignmentRuleOption_GetBiasHorizontal(ArkUI_AlignmentRuleOption* * @since 12 */ float OH_ArkUI_AlignmentRuleOption_GetBiasVertical(ArkUI_AlignmentRuleOption* option); + +/** + * @brief Create a configuration item for the ListitemSwipeActionItem interface settings. + * + * @return List Item SwipeActionItem configuration item instance. If the object returns a null pointer, + * it indicates creation failure, and the reason for the failure may be that the address space is full. + * @since 12 +*/ +ArkUI_ListItemSwipeActionItem* OH_ArkUI_ListItemSwipeActionItem_Create(); + +/** +* @brief Destroy the ListitemSwipeActionItem instance. +* +* @param option List Item SwipeActionItem instance to be destroyed. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_Dispose(ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the layout content of ListItem SwipeActionItem. +* +* @param option List Item SwipeActionItem instance. +* @param builder Layout information. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetContent(ArkUI_ListItemSwipeActionItem* item, ArkUI_NodeHandle node); + +/** +* @brief Set the threshold for long-distance sliding deletion distance of components. +* +* @param option List Item SwipeActionItem instance. +* @param distance Component long-distance sliding deletion distance threshold. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetActionAreaDistance(ArkUI_ListItemSwipeActionItem* item, float distance); + +/** +* @brief Obtain the threshold for long-distance sliding deletion distance of components. +* +* @param option List Item SwipeActionItem instance. +* @return Component long-distance sliding deletion distance threshold. If -1.0f is returned, the return fails. +* The possible cause of the failure is that the item parameter is abnormal, such as a null pointer. +* @since 12 +*/ +float OH_ArkUI_ListItemSwipeActionItem_GetActionAreaDistance(ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the event to be called when a sliding entry enters the deletion area. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnEnterActionArea(ArkUI_ListItemSwipeActionItem* item, void (*callback)()); + +/** +* @brief Set the event to be called when a component enters the long-range deletion area and deletes a ListItem. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnAction(ArkUI_ListItemSwipeActionItem* item, void (*callback)()); + +/** +* @brief Set the event to be called when a sliding entry exits the deletion area. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnExitActionArea(ArkUI_ListItemSwipeActionItem* item, void (*callback)()); + +/** +* @brief Set the event triggered when the sliding state of a list item changes. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* swipeActionState The changed state. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionItem_SetOnStateChange(ArkUI_ListItemSwipeActionItem* item, + void (*callback)(ArkUI_ListItemSwipeActionState swipeActionState)); + +/** + * @brief Create a configuration item for the ListitemSwipeActionOption interface settings. + * + * @return List Item SwipeActionOption configuration item instance.If the object returns a null pointer, + * it indicates a creation failure, and the reason for the failure may be that the address space is full. + * @since 12 +*/ +ArkUI_ListItemSwipeActionOption* OH_ArkUI_ListItemSwipeActionOption_Create(); + +/** +* @brief Destroy the ListitemSwipeActionOption instance. +* +* @param option List Item SwipeActionOption instance to be destroyed. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_Dispose(ArkUI_ListItemSwipeActionOption* option); + +/** +* @brief Set the layout content on the left (vertical layout) or top (horizontal layout) +* of the ListItem SwipeActionItem. +* +* @param option List Item SwipeActionItem instance. +* @param builder Layout information. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetStart(ArkUI_ListItemSwipeActionOption* option, + ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the layout content on the right (vertical layout) or bottom (horizontal layout) +* of the ListItem SwipeActionItem. +* +* @param option List Item SwipeActionItem instance. +* @param builder Layout information. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetEnd(ArkUI_ListItemSwipeActionOption* option, + ArkUI_ListItemSwipeActionItem* item); + +/** +* @brief Set the sliding effect. +* +* @param option List Item SwipeActionItem instance. +* @param edgeEffect Sliding effect. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetEdgeEffect(ArkUI_ListItemSwipeActionOption* option, + ArkUI_ListItemSwipeEdgeEffect edgeEffect); + +/** +* @brief Get the sliding effect. +* +* @param option List Item SwipeActionItem instance. +* @return Sliding effect. The default return value is 0. If -1 is returned, the return fails. +* The possible cause of the failure is that the option parameter is abnormal, such as a null pointer. +* @since 12 +*/ +int32_t OH_ArkUI_ListItemSwipeActionOption_GetEdgeEffect(ArkUI_ListItemSwipeActionOption* option); + +/** +* @brief The event called when the sliding operation offset changes. +* +* @param option List Item SwipeActionItem instance. +* @param callback Callback Events. +* offset Slide offset. +* @since 12 +*/ +void OH_ArkUI_ListItemSwipeActionOption_SetOnOffsetChange(ArkUI_ListItemSwipeActionOption* option, + void (*callback)(float offset)); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/styled_string.h b/arkui/ace_engine/native/styled_string.h new file mode 100644 index 000000000..f67994505 --- /dev/null +++ b/arkui/ace_engine/native/styled_string.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup ArkUI_NativeModule + * @{ + * + * @brief Provides ArkUI UI capabilities on the Native side, such as UI component creation and destruction, + * tree node operation, property setting, event monitoring, and so on. + * + * @since 12 + */ + +/** + * @file styled_string.h + * + * @brief Provides ArkUI with property string capabilities on the Native side. + * + * @library libace_ndk.z.so + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + +#ifndef ARKUI_NATIVE_STYLED_STRING_H +#define ARKUI_NATIVE_STYLED_STRING_H + +#include "native_drawing/drawing_text_declaration.h" +#include "native_drawing/drawing_text_typography.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines formatted string data objects supported by the text component. + * + * @since 12 + */ +typedef struct ArkUI_StyledString ArkUI_StyledString; + +/** + * @brief Creates a pointer to the ArkUI_StyledString object. + * + * @param style A pointer to OH_Drawing_TypographyStyle, obtained by {@link OH_Drawing_CreateTypographyStyle}. + * @param collection A pointer to OH_Drawing_FontCollection, obtained by {@link OH_Drawing_CreateFontCollection}. + * @return Creates a pointer to the ArkUI_StyledString object. If the object returns a null pointer, + * the creation failed, either because the address space was full, + * or because the style, collection parameter was an exception such as a null pointer. + * @since 12 + */ +ArkUI_StyledString* OH_ArkUI_StyledString_Create( + OH_Drawing_TypographyStyle* style, OH_Drawing_FontCollection* collection); + +/** + * @brief Free the memory occupied by the ArkUI_StyledString object. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @since 12 + */ +void OH_ArkUI_StyledString_Destroy(ArkUI_StyledString* handle); + +/** + * @brief Sets the new layout style to the top of the current format string style stack. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @param style A pointer to the OH_Drawing_TextStyle object. + * @since 12 + */ +void OH_ArkUI_StyledString_PushTextStyle(ArkUI_StyledString* handle, OH_Drawing_TextStyle* style); + +/** + * @brief Sets the corresponding text content based on the current format string style. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @param content A pointer to the text content. + * @since 12 + */ +void OH_ArkUI_StyledString_AddText(ArkUI_StyledString* handle, const char* content); + +/** + * @brief Removes the top style from the stack in the current format string object. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @since 12 + */ +void OH_ArkUI_StyledString_PopTextStyle(ArkUI_StyledString* handle); + +/** + * @brief Creates a pointer to an OH_Drawing_Typography object based on a format string object + * for advanced text estimation and typography. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @return A pointer to the OH_Drawing_Typography object. If the object returns a null pointer, + * the creation fails because the handle parameter is abnormal, such as a null pointer. + * @since 12 + */ +OH_Drawing_Typography* OH_ArkUI_StyledString_CreateTypography(ArkUI_StyledString* handle); + +/** + * @brief Set the placeholder. + * + * @param handle A pointer to the ArkUI_StyledString object. + * @param placeholder A pointer to the OH_Drawing_PlaceholderSpan object. + * @since 12 + */ +void OH_ArkUI_StyledString_AddPlaceholder(ArkUI_StyledString* handle, OH_Drawing_PlaceholderSpan* placeholder); + +#ifdef __cplusplus +}; +#endif + +#endif // ARKUI_NATIVE_STYLED_STRING_H +/** @} */ -- Gitee From e63efa0a7f938549d76c048a777973349ca17953 Mon Sep 17 00:00:00 2001 From: zhangwenting Date: Thu, 25 Apr 2024 22:50:10 +0800 Subject: [PATCH 38/43] OH_Drawing_TypographyPaintOnPath Signed-off-by: zhangwenting --- .../native_drawing/drawing_text_typography.h | 15 +++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 3690793f2..3c83c56b6 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -977,6 +977,21 @@ void OH_Drawing_TypographyLayout(OH_Drawing_Typography*, double /* maxWidth */); void OH_Drawing_TypographyPaint(OH_Drawing_Typography*, OH_Drawing_Canvas*, double /* potisionX */, double /* potisionY */); +/** + * @brief Paints path text on the canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Typography Indicates the pointer to an OH_Drawing_Typography object. + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Path Indicates path information. + * @param double Indicates the distance along the path to add to the text's starting position. + * @param double Indicates the distance above(-) or below(+) the path to position the text. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TypographyPaintOnPath(OH_Drawing_Typography*, OH_Drawing_Canvas*, OH_Drawing_Path*, + double /* hOffset */, double /* vOffset */); + /** * @brief Gets the max width. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index b2a73b331..1b5569415 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -464,6 +464,10 @@ { "name": "OH_Drawing_DestroyTypography" }, { "name": "OH_Drawing_TypographyLayout" }, { "name": "OH_Drawing_TypographyPaint" }, + { + "first_introduced": "12", + "name": "OH_Drawing_TypographyPaintOnPath" + }, { "name": "OH_Drawing_TypographyGetMaxWidth" }, { "name": "OH_Drawing_TypographyGetHeight" }, { "name": "OH_Drawing_TypographyGetLongestLine" }, -- Gitee From 42a4c987f1ad6c277ae739c07997a8fd6ab8544d Mon Sep 17 00:00:00 2001 From: kangchongtao Date: Thu, 16 May 2024 19:55:04 +0800 Subject: [PATCH 39/43] node.js update to 18.20.1 Signed-off-by: kangchongtao Change-Id: I6e02d1ce68db2aa633899c06ca40364544c11399 Signed-off-by: kangchongtao --- third_party/node/README.OpenSource | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/node/README.OpenSource b/third_party/node/README.OpenSource index 19eb392ef..28991b992 100644 --- a/third_party/node/README.OpenSource +++ b/third_party/node/README.OpenSource @@ -3,7 +3,7 @@ "Name": "node", "License": "ISC License,Public Domain,MIT License,Free Software Foundation - MIT License,Apache License V2.0,ICU License,zlib/libpng License,BSD 2-Clause License,BSD 3-Clause License", "License File": "LICENSE", - "Version Number": "18.18.2", + "Version Number": "v18.20.1", "Owner": "sunbingxin@huawei.com", "Upstream URL": "http://www.nodejs.org/", "Description": "Node.js is an open-source, cross-platform, JavaScript runtime environment. It executes JavaScript code outside of a browser." -- Gitee From 284d26e9f7ba2d2db7c80a797cabf08c34b9739b Mon Sep 17 00:00:00 2001 From: huqingyun Date: Fri, 17 May 2024 02:25:01 +0000 Subject: [PATCH 40/43] =?UTF-8?q?BUILD.gn=20=E6=96=B0=E5=A2=9Esource=20sty?= =?UTF-8?q?led=5Fstring.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huqingyun Change-Id: Iedc05f521501f3c6739c15c33808b3d9d842d641 --- arkui/ace_engine/native/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 024c38820..46ff70046 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -34,6 +34,7 @@ if (!is_arkui_x) { "native_node.h", "native_node_napi.h", "native_type.h", + "styled_string.h", "ui_input_event.h", ] } -- Gitee From 75d3fefec6bc686993bff0af2a3ce92a799087f5 Mon Sep 17 00:00:00 2001 From: wangyan Date: Fri, 17 May 2024 14:12:38 +0800 Subject: [PATCH 41/43] =?UTF-8?q?=E6=95=B4=E6=94=B9CAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyan --- multimedia/av_codec/native_avsource.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_avsource.h b/multimedia/av_codec/native_avsource.h index 1b0504fa1..2aa0d8d24 100644 --- a/multimedia/av_codec/native_avsource.h +++ b/multimedia/av_codec/native_avsource.h @@ -32,7 +32,8 @@ typedef struct OH_AVSource OH_AVSource; * @syscap SystemCapability.Multimedia.Media.Spliter * @param dataSource An Struct for a remote media resource. * @return Returns a pointer to an OH_AVSource instance if the execution is successful, otherwise returns nullptr. - * Possible failure causes: 1. dataSource is nullptr. 2. dataSource->size == 0. 3. create AVSource failed. + * Possible failure causes: 1. dataSource is nullptr. 2. dataSource->size == 0. 3. set data source failed. + * 4. out of memory. 5. demuxer engine is nullptr. * @since 12 */ OH_AVSource *OH_AVSource_CreateWithDataSource(OH_AVDataSource *dataSource); -- Gitee From 99f2a41c6d006115017c5e0e00970f0c18b5c467 Mon Sep 17 00:00:00 2001 From: fanpingan Date: Tue, 4 Jun 2024 09:49:06 +0000 Subject: [PATCH 42/43] update multimedia/player_framework/avplayer.h. Signed-off-by: fanpingan --- multimedia/player_framework/avplayer.h | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index 22725740d..fa63c5ae3 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -43,6 +43,7 @@ #include "native_averrors.h" #include "avplayer_base.h" #include "native_window/external_window.h" +#include "ohaudio/native_audiostream_base.h" #ifdef __cplusplus extern "C" { @@ -317,6 +318,44 @@ OH_AVErrCode OH_AVPlayer_SetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed s */ OH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed *speed); +/** + * @brief Set the renderer information of the player's audio renderer + * @param player Pointer to an OH_AVPlayer instance + * @param streamUsage The value {@link OH_AudioStream_Usage} used for the stream usage of the player audio render. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or streamUsage value is invalid. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetAudioRendererInfo(OH_AVPlayer *player, OH_AudioStream_Usage streamUsage); + +/** + * @brief Set the interruption mode of the player's audio stream + * @param player Pointer to an OH_AVPlayer instance + * @param interruptMode The value {@link OH_AudioInterrupt_Mode} used for the interruption mode of + * the player audio stream. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or interruptMode value is invalid. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetAudioInterruptMode(OH_AVPlayer *player, OH_AudioInterrupt_Mode interruptMode); + +/** + * @brief Set the effect mode of the player's audio stream + * @param player Pointer to an OH_AVPlayer instance + * @param effectMode The value {@link OH_AudioStream_AudioEffectMode} used for the effect mode of + * the player audio stream. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or effectMode value is invalid. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetAudioEffectMode(OH_AVPlayer *player, OH_AudioStream_AudioEffectMode effectMode); + /** * @brief set the bit rate use for hls player * -- Gitee From c79da849e0d01bf2a63bc88c7878ea6c915b0679 Mon Sep 17 00:00:00 2001 From: fanpingan Date: Tue, 4 Jun 2024 09:50:44 +0000 Subject: [PATCH 43/43] update multimedia/player_framework/avplayer/libavplayer.ndk.json. Signed-off-by: fanpingan --- .../player_framework/avplayer/libavplayer.ndk.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/multimedia/player_framework/avplayer/libavplayer.ndk.json b/multimedia/player_framework/avplayer/libavplayer.ndk.json index 5c260ec08..dbfa420ed 100644 --- a/multimedia/player_framework/avplayer/libavplayer.ndk.json +++ b/multimedia/player_framework/avplayer/libavplayer.ndk.json @@ -38,5 +38,17 @@ { "first_introduced": "12", "name": "OH_AVPlayer_SetDecryptionConfig" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetAudioRendererInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetAudioInterruptMode" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetAudioEffectMode" } ] \ No newline at end of file -- Gitee