diff --git a/distributedhardware/device_manager/include/oh_device_manager.h b/distributedhardware/device_manager/include/oh_device_manager.h index 51d7a86c4..792c20194 100644 --- a/distributedhardware/device_manager/include/oh_device_manager.h +++ b/distributedhardware/device_manager/include/oh_device_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025 Huawei Device Co., Ltd. + * Copyright (c) 2025-2026 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 @@ -40,6 +40,31 @@ #ifdef __cplusplus extern "C" { +/** + * @brief Obtains the display name of the local device. + * The device display name involves user privacy. + * You need to provide a privacy statement to declare the purpose of the device display name. + * + * @permission ohos.permission.READ_LOCAL_DEVICE_NAME + * @param localDeviceName Pointer to the display name of the local device. + * After using this API, you need to manually release resources to free up space. + * If the application has the ohos.permission.READ_LOCAL_DEVICE_NAME permission, + * the device display name is returned. + * Otherwise, the default device name is returned. + * @param len Character length of the display name of the local device. + * @return Error code. For details about the error code definitions, see {@link DeviceManager_ErrorCode}. + * Returns {@link ERR_OK} is returned if the execution is successful. + * Returns {@link DM_ERR_FAILED} is returned if the function fails to be executed. + * Returns {@link DM_ERR_OBTAIN_SERVICE} is returned if the device management service fails to be obtained. + * Returns {@link DM_ERR_OBTAIN_BUNDLE_NAME} is returned if the bundle name fails to be obtained. + * Returns {@link ERR_INVALID_PARAMETER} is returned if the localDeviceName is nullptr or + * *localDeviceName is not nullptr. + * @since 20 + * @deprecated since 26.0.0 + * @useinstead OH_DeviceManager_GetLocalDeviceNameC + */ +int32_t OH_DeviceManager_GetLocalDeviceName(char **localDeviceName, unsigned int &len); + #endif /** @@ -53,17 +78,18 @@ extern "C" { * If the application has the ohos.permission.READ_LOCAL_DEVICE_NAME permission, * the device display name is returned. * Otherwise, the default device name is returned. - * @param len Length of the display name of the local device. + * @param len Pointer to the length of the display name of the local device. + * After using this API, you need to manually release resources to free up space. * @return Error code. For details about the error code definitions, see {@link DeviceManager_ErrorCode}. * Returns {@link ERR_OK} is returned if the execution is successful. * Returns {@link DM_ERR_FAILED} is returned if the function fails to be executed. * Returns {@link DM_ERR_OBTAIN_SERVICE} is returned if the device management service fails to be obtained. * Returns {@link DM_ERR_OBTAIN_BUNDLE_NAME} is returned if the bundle name fails to be obtained. * Returns {@link ERR_INVALID_PARAMETER} is returned if the localDeviceName is nullptr or - * *localDeviceName is not nullptr. - * @since 20 + * *localDeviceName is not nullptr or len is nullptr. + * @since 26.0.0 */ -int32_t OH_DeviceManager_GetLocalDeviceName(char **localDeviceName, unsigned int &len); +int32_t OH_DeviceManager_GetLocalDeviceNameC(char **localDeviceName, unsigned int *len); #ifdef __cplusplus }; diff --git a/distributedhardware/device_manager/libdevicemanager.ndk.json b/distributedhardware/device_manager/libdevicemanager.ndk.json index b77563c5d..8d30fe5c0 100644 --- a/distributedhardware/device_manager/libdevicemanager.ndk.json +++ b/distributedhardware/device_manager/libdevicemanager.ndk.json @@ -2,5 +2,9 @@ { "first_introduced": "20", "name": "OH_DeviceManager_GetLocalDeviceName" + }, + { + "first_introduced": "26.0.0", + "name": "OH_DeviceManager_GetLocalDeviceNameC" } -] \ No newline at end of file +]