!5678 merge feat/ndk-getlocaldevicename-c-abi into master

feat: add C ABI OH_DeviceManager_GetLocalDeviceNameC

Created-by: dyylll
Commit-by: daiyunlong
Merged-by: openharmony_ci
Description: ### 相关的Issue
https://gitcode.com/openharmony/interface_sdk_c/issues/4440

### 原因(目的、解决的问题等)


### 描述(做了什么,变更了什么)


### 自检结果(结果截图添加到下面)
- [x] 是否通过C语法扫描
- [x] 是否通过注释规则扫描
- [x] 是否更新json文件
- [x] 实现代码是否已经合入
- [x] 目标是否已经添加到interface/sdk_c仓ndk依赖目标(ndk_targets.gni)里
- [x] 头文件library声明与SDK so库名称一致

### 兼容性影响评估,如有影响请写明(Y/N)
- [ ] 不兼容
  - [ ] 是否经过评审

### L0新增用例自检结果
- [ ] 是,有新增L0用例,且完成自检
- [x] 否

### API参考文档影响评估(提供docs仓pr链接)
- [ ] 是,已刷新API参考文档
- [x] 否,不涉及刷新API参考文档

See merge request: openharmony/interface_sdk_c!5678
This commit is contained in:
openharmony_ci
2026-07-27 19:09:40 +08:00
2 changed files with 36 additions and 6 deletions
@@ -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
};
@@ -2,5 +2,9 @@
{
"first_introduced": "20",
"name": "OH_DeviceManager_GetLocalDeviceName"
},
{
"first_introduced": "26.0.0",
"name": "OH_DeviceManager_GetLocalDeviceNameC"
}
]
]