From eacd6c061e595a150a8d01dace86ed63922a367d Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Thu, 1 Feb 2024 15:10:02 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9EFileShare.NDK=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20Signed-off-by:=20weishaoxiong=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filemanagement/fileshare/BUILD.gn | 30 +++ filemanagement/fileshare/include/file_share.h | 186 ++++++++++++++++++ .../fileshare/libfileshare.ndk.json | 7 + 3 files changed, 223 insertions(+) create mode 100644 filemanagement/fileshare/BUILD.gn create mode 100644 filemanagement/fileshare/include/file_share.h create mode 100644 filemanagement/fileshare/libfileshare.ndk.json diff --git a/filemanagement/fileshare/BUILD.gn b/filemanagement/fileshare/BUILD.gn new file mode 100644 index 000000000..8aa471797 --- /dev/null +++ b/filemanagement/fileshare/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_library("libfileshare_ndk") { + ndk_description_file = "./libfileshare.ndk.json" + min_compact_version = "12" + output_name = "fileshare" +} + +ohos_ndk_headers("fileshare_header") { + dest_dir = "$ndk_headers_out_dir/fileshare/" + sources = [ "./include/file_share.h" ] + system_capability = "SystemCapability.FileManagement.AppFileService.FolderAuthorization" + system_capability_headers = [ + "fileshare/file_share.h", + ] +} \ No newline at end of file diff --git a/filemanagement/fileshare/include/file_share.h b/filemanagement/fileshare/include/file_share.h new file mode 100644 index 000000000..6c0d59490 --- /dev/null +++ b/filemanagement/fileshare/include/file_share.h @@ -0,0 +1,186 @@ +/* + * 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 FILE_SHARE_H +#define FILE_SHARE_H +/** + * @addtogroup fileShare + * + * @brief This module provides file sharing capabilities and provides an interface for system applications to authorize + * the Uniform Resource Identifier (URI) of public directory files with read and write permissions to other applications. + * @since 12 + */ + +/** + * @file file_share.h + * + * @brief Provides fileshare APIS. + * @library libfile_share_ndk.z.so + * @syscap SystemCapability.FileManagement.AppFileService.FolderAuthorization + * @since 12 + */ +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief Enumerates the uri operate mode types. + * + * @since 12 + */ +typedef enum OH_OperationMode { + /** + * @brief Indicates read permissions. + */ + READ_MODE = 0b1, + + /** + * @brief Indicates write permissions. + */ + WRITE_MODE = 0b10 +} OH_OperationMode; + +/** + * @brief Enumerates the error code of the permission policy for the URI operation. + * + * @since 12 + */ +typedef enum OH_PolicyErrorCode { + /** + * @brief Indicates that the policy is not allowed to be persisted. + */ + PERSISTENCE_FORBIDDEN = 1, + + /** + * @brief Indicates that the mode of this policy is invalid. + */ + INVALID_MODE = 2, + + /** + * @brief Indicates that the path of this policy is invalid. + */ + INVALID_PATH = 3 +} OH_PolicyErrorCode; + +/** + * @brief Define the OH_PolicyErrorResult structure type. + * + * Failed policy result on URI. + * + * @since 12 + */ +typedef struct OH_PolicyErrorResult { + /** + * Indicates the failed uri of the policy information. + */ + char* uri; + + /** + * Indicates the error code of the failure in the policy information. + */ + OH_PolicyErrorCode code; + + /** + * Indicates the reason of the failure in the policy information. + */ + char* message; +} OH_PolicyErrorResult; + +/** + * @brief Define the OH_PolicyInfo structure type. + * + * Policy information to manager permissions on a URI. + * + * @since 12 + */ +typedef struct OH_PolicyInfo { + /** + * Indicates the uri of the policy information. + */ + char* uri; + + /** + * Indicates the mode of operation for the URI. + * example { OH_OperationMode.READ_MODE } or { OH_OperationMode.READ_MODE | OH_OperationMode.WRITE_MODE }. + */ + int operationMode; +} OH_PolicyInfo; + +/** + * @brief Set persistence permissions for the URI. + * + * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @param policyNum Indicates the size of the policies array. + * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param resultNum Indicates the size of the result array. + * @return Returns the status code of the execution. + * @see OH_PolicyInfo, OH_PolicyErrorResult + * @since 12 + */ +int OH_FileShare_PersistPermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); + +/** + * @brief Revoke persistence permissions for the URI. + * + * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @param policyNum Indicates the size of the policies array. + * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param resultNum Indicates the size of the result array. + * @return Returns the status code of the execution. + * @see OH_PolicyInfo, OH_PolicyErrorResult + * @since 12 + */ +int OH_FileShare_RevokePermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); + +/** + * @brief Enable the URI that have been permanently authorized. + * + * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @param policyNum Indicates the size of the policies array. + * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param resultNum Indicates the size of the result array. + * @return Returns the status code of the execution. + * @see OH_PolicyInfo, OH_PolicyErrorResult + * @since 12 + */ +int OH_FileShare_ActivatePermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); + +/** + * @brief Stop the authorized URI that has been enabled. + * + * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @param policyNum Indicates the size of the policies array. + * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param resultNum Indicates the size of the result array. + * @return Returns the status code of the execution. + * @see OH_PolicyInfo, OH_PolicyErrorResult + * @since 12 + */ +int OH_FileShare_DeactivatePermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); + +/** + * @brief Check persistence permissions for the URI.. + * + * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @param policyNum Indicates the size of the policies array. + * @param result Represents a pointer to an bool instance. + * @return Returns the status code of the execution. + * @see OH_PolicyInfo, OH_PolicyErrorResult + * @since 12 + */ +int OH_FileShare_CheckPersistPermission(const OH_PolicyInfo *policies, int policyNum, bool **result); +#ifdef __cplusplus +}; +#endif +#endif //FILE_SHARE_H diff --git a/filemanagement/fileshare/libfileshare.ndk.json b/filemanagement/fileshare/libfileshare.ndk.json new file mode 100644 index 000000000..7f0b7832e --- /dev/null +++ b/filemanagement/fileshare/libfileshare.ndk.json @@ -0,0 +1,7 @@ +[ + {"name":"OH_FileShare_PersistPermission" }, + {"name":"OH_FileShare_RevokePermission" }, + {"name":"OH_FileShare_ActivatePermission" }, + {"name":"OH_FileShare_DeactivatePermission" }, + {"name":"OH_FileShare_CheckPersistPermission" } +] \ No newline at end of file -- Gitee From 5ad2a306576278c3f9f3efbd92553182e1cb870f Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Fri, 2 Feb 2024 16:59:10 +0800 Subject: [PATCH 02/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/include/file_share.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/filemanagement/fileshare/include/file_share.h b/filemanagement/fileshare/include/file_share.h index 6c0d59490..9acfc2d24 100644 --- a/filemanagement/fileshare/include/file_share.h +++ b/filemanagement/fileshare/include/file_share.h @@ -70,7 +70,12 @@ typedef enum OH_PolicyErrorCode { /** * @brief Indicates that the path of this policy is invalid. */ - INVALID_PATH = 3 + INVALID_PATH = 3, + + /** + * @brief Indicates that the policy is no persistence capability. + */ + PERSISTENCE_WITHOUT = 4 } OH_PolicyErrorCode; /** @@ -179,7 +184,7 @@ int OH_FileShare_DeactivatePermission(const OH_PolicyInfo *policies, int policyN * @see OH_PolicyInfo, OH_PolicyErrorResult * @since 12 */ -int OH_FileShare_CheckPersistPermission(const OH_PolicyInfo *policies, int policyNum, bool **result); +int OH_FileShare_CheckPersistentPermission(const OH_PolicyInfo *policies, int policyNum, bool **result); #ifdef __cplusplus }; #endif -- Gitee From 08dce98fed87d5b4dbe98c3117b73bbaa751fcb7 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Sun, 4 Feb 2024 10:20:46 +0800 Subject: [PATCH 03/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/include/file_share.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/filemanagement/fileshare/include/file_share.h b/filemanagement/fileshare/include/file_share.h index 9acfc2d24..067bd743d 100644 --- a/filemanagement/fileshare/include/file_share.h +++ b/filemanagement/fileshare/include/file_share.h @@ -56,7 +56,7 @@ typedef enum OH_OperationMode { * * @since 12 */ -typedef enum OH_PolicyErrorCode { +typedef enum OH_PolicyErrorCode { /** * @brief Indicates that the policy is not allowed to be persisted. */ @@ -133,7 +133,7 @@ typedef struct OH_PolicyInfo { * @see OH_PolicyInfo, OH_PolicyErrorResult * @since 12 */ -int OH_FileShare_PersistPermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); +int OH_FileShare_PersistPermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Revoke persistence permissions for the URI. @@ -146,7 +146,7 @@ int OH_FileShare_PersistPermission(const OH_PolicyInfo *policies, int policyNum, * @see OH_PolicyInfo, OH_PolicyErrorResult * @since 12 */ -int OH_FileShare_RevokePermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); +int OH_FileShare_RevokePermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Enable the URI that have been permanently authorized. @@ -159,7 +159,7 @@ int OH_FileShare_RevokePermission(const OH_PolicyInfo *policies, int policyNum, * @see OH_PolicyInfo, OH_PolicyErrorResult * @since 12 */ -int OH_FileShare_ActivatePermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); +int OH_FileShare_ActivatePermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Stop the authorized URI that has been enabled. @@ -172,7 +172,7 @@ int OH_FileShare_ActivatePermission(const OH_PolicyInfo *policies, int policyNum * @see OH_PolicyInfo, OH_PolicyErrorResult * @since 12 */ -int OH_FileShare_DeactivatePermission(const OH_PolicyInfo *policies, int policyNum, OH_PolicyErrorResult **result, int *resultNum); +int OH_FileShare_DeactivatePermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Check persistence permissions for the URI.. @@ -184,7 +184,7 @@ int OH_FileShare_DeactivatePermission(const OH_PolicyInfo *policies, int policyN * @see OH_PolicyInfo, OH_PolicyErrorResult * @since 12 */ -int OH_FileShare_CheckPersistentPermission(const OH_PolicyInfo *policies, int policyNum, bool **result); +int OH_FileShare_CheckPersistentPermission(const OH_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); #ifdef __cplusplus }; #endif -- Gitee From a1f7b53292c48befa9588b55b994c827f4c2ef11 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Mon, 5 Feb 2024 10:33:47 +0800 Subject: [PATCH 04/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/BUILD.gn | 2 +- filemanagement/fileshare/include/file_share.h | 69 ++++++++++--------- .../fileshare/libfileshare.ndk.json | 25 +++++-- 3 files changed, 58 insertions(+), 38 deletions(-) diff --git a/filemanagement/fileshare/BUILD.gn b/filemanagement/fileshare/BUILD.gn index 8aa471797..a2c6606f0 100644 --- a/filemanagement/fileshare/BUILD.gn +++ b/filemanagement/fileshare/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") -ohos_ndk_library("libfileshare_ndk") { +ohos_ndk_library("libfile_share") { ndk_description_file = "./libfileshare.ndk.json" min_compact_version = "12" output_name = "fileshare" diff --git a/filemanagement/fileshare/include/file_share.h b/filemanagement/fileshare/include/file_share.h index 067bd743d..317244eb1 100644 --- a/filemanagement/fileshare/include/file_share.h +++ b/filemanagement/fileshare/include/file_share.h @@ -27,7 +27,7 @@ * @file file_share.h * * @brief Provides fileshare APIS. - * @library libfile_share_ndk.z.so + * @library libfile_share.so * @syscap SystemCapability.FileManagement.AppFileService.FolderAuthorization * @since 12 */ @@ -39,7 +39,7 @@ extern "C" { * * @since 12 */ -typedef enum OH_OperationMode { +typedef enum FileShare_OperationMode { /** * @brief Indicates read permissions. */ @@ -49,14 +49,14 @@ typedef enum OH_OperationMode { * @brief Indicates write permissions. */ WRITE_MODE = 0b10 -} OH_OperationMode; +} FileShare_OperationMode; /** * @brief Enumerates the error code of the permission policy for the URI operation. * * @since 12 */ -typedef enum OH_PolicyErrorCode { +typedef enum FileShare_PolicyErrorCode { /** * @brief Indicates that the policy is not allowed to be persisted. */ @@ -76,16 +76,16 @@ typedef enum OH_PolicyErrorCode { * @brief Indicates that the policy is no persistence capability. */ PERSISTENCE_WITHOUT = 4 -} OH_PolicyErrorCode; +} FileShare_PolicyErrorCode; /** - * @brief Define the OH_PolicyErrorResult structure type. + * @brief Define the FileShare_PolicyErrorResult structure type. * * Failed policy result on URI. * * @since 12 */ -typedef struct OH_PolicyErrorResult { +typedef struct FileShare_PolicyErrorResult { /** * Indicates the failed uri of the policy information. */ @@ -94,22 +94,22 @@ typedef struct OH_PolicyErrorResult { /** * Indicates the error code of the failure in the policy information. */ - OH_PolicyErrorCode code; + FileShare_PolicyErrorCode code; /** * Indicates the reason of the failure in the policy information. */ char* message; -} OH_PolicyErrorResult; +} FileShare_PolicyErrorResult; /** - * @brief Define the OH_PolicyInfo structure type. + * @brief Define the FileShare_PolicyInfo structure type. * * Policy information to manager permissions on a URI. * * @since 12 */ -typedef struct OH_PolicyInfo { +typedef struct FileShare_PolicyInfo { /** * Indicates the uri of the policy information. */ @@ -117,74 +117,79 @@ typedef struct OH_PolicyInfo { /** * Indicates the mode of operation for the URI. - * example { OH_OperationMode.READ_MODE } or { OH_OperationMode.READ_MODE | OH_OperationMode.WRITE_MODE }. + * example { FileShare_OperationMode.READ_MODE } or { FileShare_OperationMode.READ_MODE | FileShare_OperationMode.WRITE_MODE }. */ int operationMode; -} OH_PolicyInfo; +} FileShare_PolicyInfo; /** * @brief Set persistence permissions for the URI. * - * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @permission ohos.permission.FILE_ACCESS_PERSIST + * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see OH_PolicyInfo, OH_PolicyErrorResult + * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ -int OH_FileShare_PersistPermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); +int OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Revoke persistence permissions for the URI. * - * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @permission ohos.permission.FILE_ACCESS_PERSIST + * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see OH_PolicyInfo, OH_PolicyErrorResult + * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ -int OH_FileShare_RevokePermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); +int OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Enable the URI that have been permanently authorized. * - * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @permission ohos.permission.FILE_ACCESS_PERSIST + * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see OH_PolicyInfo, OH_PolicyErrorResult + * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ -int OH_FileShare_ActivatePermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); +int OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Stop the authorized URI that has been enabled. * - * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @permission ohos.permission.FILE_ACCESS_PERSIST + * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link OH_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see OH_PolicyInfo, OH_PolicyErrorResult + * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ -int OH_FileShare_DeactivatePermission(const OH_PolicyInfo *policies, unsigned int policyNum, OH_PolicyErrorResult **result, unsigned int *resultNum); +int OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Check persistence permissions for the URI.. * - * @param policies Represents a pointer to an {@link OH_PolicyInfo} instance. + * @permission ohos.permission.FILE_ACCESS_PERSIST + * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. * @param result Represents a pointer to an bool instance. * @return Returns the status code of the execution. - * @see OH_PolicyInfo, OH_PolicyErrorResult + * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ -int OH_FileShare_CheckPersistentPermission(const OH_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); +int OH_FileShare_CheckPersistentPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); #ifdef __cplusplus }; #endif diff --git a/filemanagement/fileshare/libfileshare.ndk.json b/filemanagement/fileshare/libfileshare.ndk.json index 7f0b7832e..e1f0d4b39 100644 --- a/filemanagement/fileshare/libfileshare.ndk.json +++ b/filemanagement/fileshare/libfileshare.ndk.json @@ -1,7 +1,22 @@ [ - {"name":"OH_FileShare_PersistPermission" }, - {"name":"OH_FileShare_RevokePermission" }, - {"name":"OH_FileShare_ActivatePermission" }, - {"name":"OH_FileShare_DeactivatePermission" }, - {"name":"OH_FileShare_CheckPersistPermission" } + { + "first_introduced": "12", + "name": "OH_FileShare_PersistPermission" + }, + { + "first_introduced": "12", + "name": "OH_FileShare_RevokePermission" + }, + { + "first_introduced": "12", + "name": "OH_FileShare_ActivatePermission" + }, + { + "first_introduced": "12", + "name": "OH_FileShare_DeactivatePermission" + }, + { + "first_introduced": "12", + "name": "OH_FileShare_CheckPersistPermission" + } ] \ No newline at end of file -- Gitee From ffd7fb2547de4118315d41a7152d9b4b6f1e546e Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Tue, 6 Feb 2024 14:00:10 +0800 Subject: [PATCH 05/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/include/file_share.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/filemanagement/fileshare/include/file_share.h b/filemanagement/fileshare/include/file_share.h index 317244eb1..5c376b595 100644 --- a/filemanagement/fileshare/include/file_share.h +++ b/filemanagement/fileshare/include/file_share.h @@ -17,7 +17,8 @@ #define FILE_SHARE_H /** * @addtogroup fileShare - * + * @{ + * * @brief This module provides file sharing capabilities and provides an interface for system applications to authorize * the Uniform Resource Identifier (URI) of public directory files with read and write permissions to other applications. * @since 12 @@ -131,7 +132,6 @@ typedef struct FileShare_PolicyInfo { * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ int OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); @@ -145,7 +145,6 @@ int OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigne * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ int OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); @@ -159,7 +158,6 @@ int OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ int OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); @@ -173,7 +171,6 @@ int OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsign * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. - * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ int OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); @@ -186,11 +183,11 @@ int OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, unsi * @param policyNum Indicates the size of the policies array. * @param result Represents a pointer to an bool instance. * @return Returns the status code of the execution. - * @see FileShare_PolicyInfo, FileShare_PolicyErrorResult * @since 12 */ int OH_FileShare_CheckPersistentPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); #ifdef __cplusplus }; #endif +/** @} */ #endif //FILE_SHARE_H -- Gitee From 5447c79a2bc7d7adb97e64f1bab0b6fa2ae13658 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Wed, 7 Feb 2024 16:45:17 +0800 Subject: [PATCH 06/13] =?UTF-8?q?fix=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: weishaoxiong --- filemanagement/fileshare/BUILD.gn | 18 ++--- .../include/{file_share.h => oh_file_share.h} | 71 ++++++++++++------- ...eshare.ndk.json => libfiles_hare.ndk.json} | 0 3 files changed, 56 insertions(+), 33 deletions(-) rename filemanagement/fileshare/include/{file_share.h => oh_file_share.h} (66%) rename filemanagement/fileshare/{libfileshare.ndk.json => libfiles_hare.ndk.json} (100%) diff --git a/filemanagement/fileshare/BUILD.gn b/filemanagement/fileshare/BUILD.gn index a2c6606f0..313eb8f50 100644 --- a/filemanagement/fileshare/BUILD.gn +++ b/filemanagement/fileshare/BUILD.gn @@ -14,17 +14,17 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") -ohos_ndk_library("libfile_share") { - ndk_description_file = "./libfileshare.ndk.json" +ohos_ndk_library("liboh_file_share") { + ndk_description_file = "./libfile_share.ndk.json" min_compact_version = "12" - output_name = "fileshare" -} - -ohos_ndk_headers("fileshare_header") { - dest_dir = "$ndk_headers_out_dir/fileshare/" - sources = [ "./include/file_share.h" ] + output_name = "oh_file_share" system_capability = "SystemCapability.FileManagement.AppFileService.FolderAuthorization" system_capability_headers = [ - "fileshare/file_share.h", + "$ndk_headers_out_dir/filemanagement/fileshare/oh_file_share.h", ] +} + +ohos_ndk_headers("oh_file_share_header") { + dest_dir = "$ndk_headers_out_dir/filemanagement/fileshare/" + sources = [ "./include/oh_file_share.h" ] } \ No newline at end of file diff --git a/filemanagement/fileshare/include/file_share.h b/filemanagement/fileshare/include/oh_file_share.h similarity index 66% rename from filemanagement/fileshare/include/file_share.h rename to filemanagement/fileshare/include/oh_file_share.h index 5c376b595..f0288217b 100644 --- a/filemanagement/fileshare/include/file_share.h +++ b/filemanagement/fileshare/include/oh_file_share.h @@ -13,8 +13,11 @@ * limitations under the License. */ -#ifndef FILE_SHARE_H -#define FILE_SHARE_H +#ifndef FILE_MANAGEMENT_APP_FILE_SERVICE_INTERFACE_OH_FILE_SHARE_H +#define FILE_MANAGEMENT_APP_FILE_SERVICE_INTERFACE_OH_FILE_SHARE_H + +#include "../../common/errorcode.h" + /** * @addtogroup fileShare * @{ @@ -25,10 +28,10 @@ */ /** - * @file file_share.h + * @file oh_file_share.h * - * @brief Provides fileshare APIS. - * @library libfile_share.so + * @brief Provides fileShare APIS. + * @library liboh_file_share.so * @syscap SystemCapability.FileManagement.AppFileService.FolderAuthorization * @since 12 */ @@ -44,12 +47,12 @@ typedef enum FileShare_OperationMode { /** * @brief Indicates read permissions. */ - READ_MODE = 0b1, + READ_MODE = 1 << 0, /** * @brief Indicates write permissions. */ - WRITE_MODE = 0b10 + WRITE_MODE = 1 << 1 } FileShare_OperationMode; /** @@ -76,7 +79,7 @@ typedef enum FileShare_PolicyErrorCode { /** * @brief Indicates that the policy is no persistence capability. */ - PERSISTENCE_WITHOUT = 4 + PERMISSION_NOT_PERSISTED = 4 } FileShare_PolicyErrorCode; /** @@ -90,7 +93,7 @@ typedef struct FileShare_PolicyErrorResult { /** * Indicates the failed uri of the policy information. */ - char* uri; + char *uri; /** * Indicates the error code of the failure in the policy information. @@ -100,7 +103,7 @@ typedef struct FileShare_PolicyErrorResult { /** * Indicates the reason of the failure in the policy information. */ - char* message; + char *message; } FileShare_PolicyErrorResult; /** @@ -114,13 +117,18 @@ typedef struct FileShare_PolicyInfo { /** * Indicates the uri of the policy information. */ - char* uri; + char *uri; + + /** + * Indicates The length of the uri. + */ + unsigned int length; /** * Indicates the mode of operation for the URI. * example { FileShare_OperationMode.READ_MODE } or { FileShare_OperationMode.READ_MODE | FileShare_OperationMode.WRITE_MODE }. */ - int operationMode; + unsigned int operationMode; } FileShare_PolicyInfo; /** @@ -129,12 +137,13 @@ typedef struct FileShare_PolicyInfo { * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -int OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); +OH_FileManagement_ErrCode OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, + FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Revoke persistence permissions for the URI. @@ -142,12 +151,13 @@ int OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigne * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -int OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); +OH_FileManagement_ErrCode OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, + FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Enable the URI that have been permanently authorized. @@ -155,12 +165,13 @@ int OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -int OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); +OH_FileManagement_ErrCode OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, + FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Stop the authorized URI that has been enabled. @@ -168,26 +179,38 @@ int OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsign * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. + * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -int OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); +OH_FileManagement_ErrCode OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, + unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** - * @brief Check persistence permissions for the URI.. + * @brief Check persistence permissions for the URI. * * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an bool instance. + * @param result Represents a pointer to an bool instance. Please use free() to clear Resource. + * @param resultNum Indicates the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -int OH_FileShare_CheckPersistentPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); +OH_FileManagement_ErrCode OH_FileShare_CheckPersistentPermission( + const FileShare_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); + +/** + * @brief Free FileShare_PolicyErrorResult pointer points to address memory. + * + * @param errorResult Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. + * @param resultNum Indicates the size of the errorResult array. + * @since 12 + */ +void OH_FileShare_ReleasePolicyErrorResult(FileShare_PolicyErrorResult *errorResult, unsigned int resultNum); #ifdef __cplusplus }; #endif /** @} */ -#endif //FILE_SHARE_H +#endif // FILE_MANAGEMENT_APP_FILE_SERVICE_INTERFACE_OH_FILE_SHARE_H diff --git a/filemanagement/fileshare/libfileshare.ndk.json b/filemanagement/fileshare/libfiles_hare.ndk.json similarity index 100% rename from filemanagement/fileshare/libfileshare.ndk.json rename to filemanagement/fileshare/libfiles_hare.ndk.json -- Gitee From 3d0d2f1f0c1b7d03835a1f3f6b771b75983df57b Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Sat, 17 Feb 2024 09:08:08 +0800 Subject: [PATCH 07/13] fix: Signed-off-by: weishaoxiong --- .../fileshare/{libfiles_hare.ndk.json => libfile_share.ndk.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename filemanagement/fileshare/{libfiles_hare.ndk.json => libfile_share.ndk.json} (100%) diff --git a/filemanagement/fileshare/libfiles_hare.ndk.json b/filemanagement/fileshare/libfile_share.ndk.json similarity index 100% rename from filemanagement/fileshare/libfiles_hare.ndk.json rename to filemanagement/fileshare/libfile_share.ndk.json -- Gitee From 87aa3d33926c023f5d7391d4b38f57cc42d74e01 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Sat, 17 Feb 2024 10:19:07 +0800 Subject: [PATCH 08/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/include/oh_file_share.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/filemanagement/fileshare/include/oh_file_share.h b/filemanagement/fileshare/include/oh_file_share.h index f0288217b..b15a7b7de 100644 --- a/filemanagement/fileshare/include/oh_file_share.h +++ b/filemanagement/fileshare/include/oh_file_share.h @@ -77,7 +77,7 @@ typedef enum FileShare_PolicyErrorCode { INVALID_PATH = 3, /** - * @brief Indicates that the policy is no persistence capability. + * @brief Indicates that the policy is no persistent capability. */ PERMISSION_NOT_PERSISTED = 4 } FileShare_PolicyErrorCode; @@ -132,7 +132,7 @@ typedef struct FileShare_PolicyInfo { } FileShare_PolicyInfo; /** - * @brief Set persistence permissions for the URI. + * @brief Set persistent permissions for the URI. * * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. @@ -146,7 +146,7 @@ OH_FileManagement_ErrCode OH_FileShare_PersistPermission(const FileShare_PolicyI FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** - * @brief Revoke persistence permissions for the URI. + * @brief Revoke persistent permissions for the URI. * * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. @@ -188,7 +188,7 @@ OH_FileManagement_ErrCode OH_FileShare_DeactivatePermission(const FileShare_Poli unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** - * @brief Check persistence permissions for the URI. + * @brief Check persistent permissions for the URI. * * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. -- Gitee From fa7ca176807615eba2cd7af5a1cd55a44823d1b9 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Sat, 17 Feb 2024 11:37:45 +0800 Subject: [PATCH 09/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/include/oh_file_share.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filemanagement/fileshare/include/oh_file_share.h b/filemanagement/fileshare/include/oh_file_share.h index b15a7b7de..eb26ea075 100644 --- a/filemanagement/fileshare/include/oh_file_share.h +++ b/filemanagement/fileshare/include/oh_file_share.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef FILE_MANAGEMENT_APP_FILE_SERVICE_INTERFACE_OH_FILE_SHARE_H -#define FILE_MANAGEMENT_APP_FILE_SERVICE_INTERFACE_OH_FILE_SHARE_H +#ifndef FILE_MANAGEMENT_OH_FILE_SHARE_H +#define FILE_MANAGEMENT_OH_FILE_SHARE_H #include "../../common/errorcode.h" @@ -213,4 +213,4 @@ void OH_FileShare_ReleasePolicyErrorResult(FileShare_PolicyErrorResult *errorRes }; #endif /** @} */ -#endif // FILE_MANAGEMENT_APP_FILE_SERVICE_INTERFACE_OH_FILE_SHARE_H +#endif // FILE_MANAGEMENT_OH_FILE_SHARE_H -- Gitee From d5860d5a17e4671a01003ca6399601d009dcf936 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Mon, 19 Feb 2024 09:44:44 +0800 Subject: [PATCH 10/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/BUILD.gn | 10 ++-- .../fileshare/include/oh_file_share.h | 46 +++++++++---------- .../fileshare/libfile_share.ndk.json | 4 ++ 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/filemanagement/fileshare/BUILD.gn b/filemanagement/fileshare/BUILD.gn index 313eb8f50..95e1fecee 100644 --- a/filemanagement/fileshare/BUILD.gn +++ b/filemanagement/fileshare/BUILD.gn @@ -14,10 +14,11 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") -ohos_ndk_library("liboh_file_share") { +ohos_ndk_library("libohfileshare") { ndk_description_file = "./libfile_share.ndk.json" min_compact_version = "12" - output_name = "oh_file_share" + output_name = "ohfileshare" + output_extension = "so" system_capability = "SystemCapability.FileManagement.AppFileService.FolderAuthorization" system_capability_headers = [ "$ndk_headers_out_dir/filemanagement/fileshare/oh_file_share.h", @@ -26,5 +27,8 @@ ohos_ndk_library("liboh_file_share") { ohos_ndk_headers("oh_file_share_header") { dest_dir = "$ndk_headers_out_dir/filemanagement/fileshare/" - sources = [ "./include/oh_file_share.h" ] + sources = [ + "./include/oh_file_share.h", + "../fileio/include/error_code.h", + ] } \ No newline at end of file diff --git a/filemanagement/fileshare/include/oh_file_share.h b/filemanagement/fileshare/include/oh_file_share.h index eb26ea075..fb5eb9eff 100644 --- a/filemanagement/fileshare/include/oh_file_share.h +++ b/filemanagement/fileshare/include/oh_file_share.h @@ -16,7 +16,7 @@ #ifndef FILE_MANAGEMENT_OH_FILE_SHARE_H #define FILE_MANAGEMENT_OH_FILE_SHARE_H -#include "../../common/errorcode.h" +#include "error_code.h" /** * @addtogroup fileShare @@ -31,7 +31,7 @@ * @file oh_file_share.h * * @brief Provides fileShare APIS. - * @library liboh_file_share.so + * @library libohfileshare.so * @syscap SystemCapability.FileManagement.AppFileService.FolderAuthorization * @since 12 */ @@ -135,76 +135,76 @@ typedef struct FileShare_PolicyInfo { * @brief Set persistent permissions for the URI. * * @permission ohos.permission.FILE_ACCESS_PERSIST - * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. + * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. - * @param resultNum Indicates the size of the result array. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -OH_FileManagement_ErrCode OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, +FileManagement_ErrCode OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Revoke persistent permissions for the URI. * * @permission ohos.permission.FILE_ACCESS_PERSIST - * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. + * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. - * @param resultNum Indicates the size of the result array. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -OH_FileManagement_ErrCode OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, +FileManagement_ErrCode OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Enable the URI that have been permanently authorized. * * @permission ohos.permission.FILE_ACCESS_PERSIST - * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. + * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. - * @param resultNum Indicates the size of the result array. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -OH_FileManagement_ErrCode OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, +FileManagement_ErrCode OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Stop the authorized URI that has been enabled. * * @permission ohos.permission.FILE_ACCESS_PERSIST - * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. + * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. - * @param resultNum Indicates the size of the result array. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -OH_FileManagement_ErrCode OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, +FileManagement_ErrCode OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); /** * @brief Check persistent permissions for the URI. * * @permission ohos.permission.FILE_ACCESS_PERSIST - * @param policies Represents a pointer to an {@link FileShare_PolicyInfo} instance. + * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Represents a pointer to an bool instance. Please use free() to clear Resource. - * @param resultNum Indicates the size of the result array. + * @param result Output a pointer to an bool instance. Please use free() to clear Resource. + * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -OH_FileManagement_ErrCode OH_FileShare_CheckPersistentPermission( +FileManagement_ErrCode OH_FileShare_CheckPersistentPermission( const FileShare_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); /** * @brief Free FileShare_PolicyErrorResult pointer points to address memory. * - * @param errorResult Represents a pointer to an {@link FileShare_PolicyErrorResult} instance. + * @param errorResult Input a pointer to an {@link FileShare_PolicyErrorResult} instance. * @param resultNum Indicates the size of the errorResult array. * @since 12 */ diff --git a/filemanagement/fileshare/libfile_share.ndk.json b/filemanagement/fileshare/libfile_share.ndk.json index e1f0d4b39..fb133d6bd 100644 --- a/filemanagement/fileshare/libfile_share.ndk.json +++ b/filemanagement/fileshare/libfile_share.ndk.json @@ -18,5 +18,9 @@ { "first_introduced": "12", "name": "OH_FileShare_CheckPersistPermission" + }, + { + "first_introduced": "12", + "name": "OH_FileShare_ReleasePolicyErrorResult" } ] \ No newline at end of file -- Gitee From 6948d3ae3dd162686256802178376f843ff151a4 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Tue, 20 Feb 2024 20:16:31 +0800 Subject: [PATCH 11/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/BUILD.gn | 14 +++--- .../fileshare/include/oh_file_share.h | 48 ++++++++++++------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/filemanagement/fileshare/BUILD.gn b/filemanagement/fileshare/BUILD.gn index 95e1fecee..eb0851c77 100644 --- a/filemanagement/fileshare/BUILD.gn +++ b/filemanagement/fileshare/BUILD.gn @@ -19,16 +19,16 @@ ohos_ndk_library("libohfileshare") { min_compact_version = "12" output_name = "ohfileshare" output_extension = "so" - system_capability = "SystemCapability.FileManagement.AppFileService.FolderAuthorization" - system_capability_headers = [ - "$ndk_headers_out_dir/filemanagement/fileshare/oh_file_share.h", - ] + system_capability = + "SystemCapability.FileManagement.AppFileService.FolderAuthorization" + system_capability_headers = + [ "$ndk_headers_out_dir/filemanagement/fileshare/oh_file_share.h" ] } ohos_ndk_headers("oh_file_share_header") { dest_dir = "$ndk_headers_out_dir/filemanagement/fileshare/" - sources = [ - "./include/oh_file_share.h", + sources = [ "../fileio/include/error_code.h", + "./include/oh_file_share.h", ] -} \ No newline at end of file +} diff --git a/filemanagement/fileshare/include/oh_file_share.h b/filemanagement/fileshare/include/oh_file_share.h index fb5eb9eff..8d16ff3e3 100644 --- a/filemanagement/fileshare/include/oh_file_share.h +++ b/filemanagement/fileshare/include/oh_file_share.h @@ -21,9 +21,10 @@ /** * @addtogroup fileShare * @{ - * + * * @brief This module provides file sharing capabilities and provides an interface for system applications to authorize - * the Uniform Resource Identifier (URI) of public directory files with read and write permissions to other applications. + * the Uniform Resource Identifier (URI) of public directory files with read and write permissions to other + * applications. * @since 12 */ @@ -126,7 +127,8 @@ typedef struct FileShare_PolicyInfo { /** * Indicates the mode of operation for the URI. - * example { FileShare_OperationMode.READ_MODE } or { FileShare_OperationMode.READ_MODE | FileShare_OperationMode.WRITE_MODE }. + * example { FileShare_OperationMode.READ_MODE } or { FileShare_OperationMode.READ_MODE | + * FileShare_OperationMode.WRITE_MODE }. */ unsigned int operationMode; } FileShare_PolicyInfo; @@ -137,13 +139,16 @@ typedef struct FileShare_PolicyInfo { * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use + * OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -FileManagement_ErrCode OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, - FileShare_PolicyErrorResult **result, unsigned int *resultNum); +FileManagement_ErrCode OH_FileShare_PersistPermission(const FileShare_PolicyInfo *policies, + unsigned int policyNum, + FileShare_PolicyErrorResult **result, + unsigned int *resultNum); /** * @brief Revoke persistent permissions for the URI. @@ -151,13 +156,16 @@ FileManagement_ErrCode OH_FileShare_PersistPermission(const FileShare_PolicyInfo * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use + * OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -FileManagement_ErrCode OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, - FileShare_PolicyErrorResult **result, unsigned int *resultNum); +FileManagement_ErrCode OH_FileShare_RevokePermission(const FileShare_PolicyInfo *policies, + unsigned int policyNum, + FileShare_PolicyErrorResult **result, + unsigned int *resultNum); /** * @brief Enable the URI that have been permanently authorized. @@ -165,13 +173,16 @@ FileManagement_ErrCode OH_FileShare_RevokePermission(const FileShare_PolicyInfo * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use + * OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ -FileManagement_ErrCode OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, unsigned int policyNum, - FileShare_PolicyErrorResult **result, unsigned int *resultNum); +FileManagement_ErrCode OH_FileShare_ActivatePermission(const FileShare_PolicyInfo *policies, + unsigned int policyNum, + FileShare_PolicyErrorResult **result, + unsigned int *resultNum); /** * @brief Stop the authorized URI that has been enabled. @@ -179,13 +190,16 @@ FileManagement_ErrCode OH_FileShare_ActivatePermission(const FileShare_PolicyInf * @permission ohos.permission.FILE_ACCESS_PERSIST * @param policies Input a pointer to an {@link FileShare_PolicyInfo} instance. * @param policyNum Indicates the size of the policies array. - * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use OH_FileShare_ReleasePolicyErrorResult() to clear Resource. + * @param result Output a pointer to an {@link FileShare_PolicyErrorResult} instance. Please use + * OH_FileShare_ReleasePolicyErrorResult() to clear Resource. * @param resultNum Output the size of the result array. * @return Returns the status code of the execution. * @since 12 */ FileManagement_ErrCode OH_FileShare_DeactivatePermission(const FileShare_PolicyInfo *policies, - unsigned int policyNum, FileShare_PolicyErrorResult **result, unsigned int *resultNum); + unsigned int policyNum, + FileShare_PolicyErrorResult **result, + unsigned int *resultNum); /** * @brief Check persistent permissions for the URI. @@ -198,8 +212,10 @@ FileManagement_ErrCode OH_FileShare_DeactivatePermission(const FileShare_PolicyI * @return Returns the status code of the execution. * @since 12 */ -FileManagement_ErrCode OH_FileShare_CheckPersistentPermission( - const FileShare_PolicyInfo *policies, unsigned int policyNum, bool **result, unsigned int *resultNum); +FileManagement_ErrCode OH_FileShare_CheckPersistentPermission(const FileShare_PolicyInfo *policies, + unsigned int policyNum, + bool **result, + unsigned int *resultNum); /** * @brief Free FileShare_PolicyErrorResult pointer points to address memory. -- Gitee From a69e58b369e0fac914671b6fdf76c3fa859fff27 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Wed, 28 Feb 2024 15:09:43 +0800 Subject: [PATCH 12/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/include/oh_file_share.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/filemanagement/fileshare/include/oh_file_share.h b/filemanagement/fileshare/include/oh_file_share.h index 8d16ff3e3..821336be5 100644 --- a/filemanagement/fileshare/include/oh_file_share.h +++ b/filemanagement/fileshare/include/oh_file_share.h @@ -22,16 +22,16 @@ * @addtogroup fileShare * @{ * - * @brief This module provides file sharing capabilities and provides an interface for system applications to authorize - * the Uniform Resource Identifier (URI) of public directory files with read and write permissions to other - * applications. + * @brief This module provides file sharing capabilities to authorize Uniform Resource Identifiers (URIs) + * for public directory files that have read and write access to other applications. * @since 12 */ /** * @file oh_file_share.h * - * @brief Provides fileShare APIS. + * @brief Provides URI-based file and directory authorization and persistence, permission activation, permission query, + * and other methods. * @library libohfileshare.so * @syscap SystemCapability.FileManagement.AppFileService.FolderAuthorization * @since 12 -- Gitee From 1e2dcf375638d5b39a827dc5c8b336034557f765 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Thu, 29 Feb 2024 16:55:02 +0800 Subject: [PATCH 13/13] fix: Signed-off-by: weishaoxiong --- filemanagement/fileshare/BUILD.gn | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/filemanagement/fileshare/BUILD.gn b/filemanagement/fileshare/BUILD.gn index eb0851c77..3027c40e5 100644 --- a/filemanagement/fileshare/BUILD.gn +++ b/filemanagement/fileshare/BUILD.gn @@ -21,8 +21,7 @@ ohos_ndk_library("libohfileshare") { output_extension = "so" system_capability = "SystemCapability.FileManagement.AppFileService.FolderAuthorization" - system_capability_headers = - [ "$ndk_headers_out_dir/filemanagement/fileshare/oh_file_share.h" ] + system_capability_headers = [ "filemanagement/fileshare/oh_file_share.h" ] } ohos_ndk_headers("oh_file_share_header") { -- Gitee