diff --git a/BasicServicesKit/BUILD.gn b/BasicServicesKit/BUILD.gn index 83284de78ee714b9e5850c774df53505c7819bf5..8cc2251b3ccc4a92be44bfcaf4170ea48f933f68 100644 --- a/BasicServicesKit/BUILD.gn +++ b/BasicServicesKit/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Huawei Device Co., Ltd. +# 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 @@ -13,6 +13,22 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("os_account_ndk_header") { + dest_dir = "$ndk_headers_out_dir/BasicServicesKit/" + sources = [ + "./os_account.h", + "./os_account_common.h", + ] +} + +ohos_ndk_library("libos_account_ndk") { + output_name = "os_account_ndk" + output_extension = "so" + system_capability = "SystemCapability.Account.OsAccount" + ndk_description_file = "./libos_account.ndk.json" + min_compact_version = "12" + system_capability_headers = [ "BasicServicesKit/os_account.h" ] +} ohos_ndk_headers("ohprint_header") { dest_dir = "$ndk_headers_out_dir/BasicServicesKit/" diff --git a/BasicServicesKit/libos_account.ndk.json b/BasicServicesKit/libos_account.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..e77db8847eb77400b89e281ec2b0ad29d924c254 --- /dev/null +++ b/BasicServicesKit/libos_account.ndk.json @@ -0,0 +1,5 @@ +[ + { "first_introduced": "12", + "name":"OH_OsAccount_GetName" + } +] \ No newline at end of file diff --git a/BasicServicesKit/os_account.h b/BasicServicesKit/os_account.h new file mode 100644 index 0000000000000000000000000000000000000000..4f5816aab00468fda7b705fac0957d94eeb6d43e --- /dev/null +++ b/BasicServicesKit/os_account.h @@ -0,0 +1,62 @@ +/* + * 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 OS_ACCOUNT_H +#define OS_ACCOUNT_H + +/** + * @addtogroup OsAccount + * @{ + * + * @brief Provide the definition of the C interface for the native OsAccount. + * @since 12 + */ +/** + * @file os_account.h + * + * @brief Declares the APIs for accessing and managing the OS account information. + * @library libos_account.so + * @syscap SystemCapability.Account.OsAccount + * @since 12 + */ + +#include +#include "os_account_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Gets the name of the OS account to which the caller process belongs. + * + * @param buffer The name character array which should have space for the name and the terminating character ('\0'). + * @param buffer_size The size of the name character array. + * @return OS_ACCOUNT_ERR_OK - Indicates successful;
+ * OS_ACCOUNT_ERR_INTERNAL_ERROR - Indicates the internal error.
+ * OS_ACCOUNT_ERR_INVALID_PARAMETER - Indicates the buf is NULL pointer or the size of the name, + * including the terminating character ('\0'), is larger then buffer_size; + * @syscap SystemCapability.Account.OsAccount + * @since 12 + */ +OsAccount_ErrCode OH_OsAccount_GetName(char *buffer, size_t buffer_size); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // OS_ACCOUNT_H diff --git a/BasicServicesKit/os_account_common.h b/BasicServicesKit/os_account_common.h new file mode 100644 index 0000000000000000000000000000000000000000..cb1859436475a37c5e83202e49bcc592aacda830 --- /dev/null +++ b/BasicServicesKit/os_account_common.h @@ -0,0 +1,67 @@ +/* + * 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 OS_ACCOUNT_COMMON_H +#define OS_ACCOUNT_COMMON_H + +/** + * @addtogroup OsAccount + * @{ + * + * @brief Provide the definition of the C interface for the native OsAccount. + * @since 12 + */ +/** + * @file os_account_common.h + * + * @brief Declare the common types for the native OsAccount. + * @library libos_account.so + * @syscap SystemCapability.Account.OsAccount + * @since 12 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes. + * + * @since 12 + */ +typedef enum OsAccount_ErrCode { + /** + * Operation is successful. + */ + OS_ACCOUNT_ERR_OK = 0, + + /** + * Internal error. + */ + OS_ACCOUNT_ERR_INTERNAL_ERROR = 12300001, + + /** + * Invalid parameter. + */ + OS_ACCOUNT_ERR_INVALID_PARAMETER = 12300002 +} OsAccount_ErrCode; + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif // OS_ACCOUNT_COMMON_H