harmony 鸿蒙oh_device_manager.h

  • 2025-06-12
  • 浏览 (5)

oh_device_manager.h

Overview

Provides APIs to obtain information about trusted devices and local devices.

File to include:

Library: libnative_devicemanager.so

System capability: SystemCapability.DistributedHardware.DeviceManager

Since: 20

Related module: DeviceManager

Summary

Function

|Name|Description| |–|–| |int32_t OH_DeviceManager_GetLocalDeviceName(char **localDeviceName, unsigned int &len)|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.|

Function Description

OH_DeviceManager_GetLocalDeviceName()

int32_t OH_DeviceManager_GetLocalDeviceName(char **localDeviceName, unsigned int &len)

Description

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.

Required permissions: ohos.permission.READ_LOCAL_DEVICE_NAME

Since: 20

Parameters

|Parameter|Description| |–|–| |char **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.| |unsigned int &len|Length of the display name of the local device.|

Return value

|Type|Description | |–|——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————| |int32_t|Error code. For details about the error code definitions, see DeviceManager_ErrorCode.
ERR_OK is returned if the execution is successful.
ERR_INVALID_PARAMETER is returned if the input parameter is invalid.
DM_ERR_FAILED is returned if the function fails to be executed.
DM_ERR_OBTAIN_SERVICE is returned if the device management service fails to be obtained.
DM_ERR_OBTAIN_BUNDLE_NAME is returned if the bundle name fails to be obtained.|

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Distributed Service Kit (Distributed Management Service)

harmony 鸿蒙DeviceManager

harmony 鸿蒙oh_device_manager_err_code.h

harmony 鸿蒙Device Management Error Codes

harmony 鸿蒙Screen Hopping Error Codes

harmony 鸿蒙Link Enhancement Error Codes

harmony 鸿蒙@ohos.distributedHardware.deviceManager (Device Management) (System API)

harmony 鸿蒙@ohos.cooperate (Screen Hopping) (System API)

harmony 鸿蒙@ohos.distributedsched.abilityConnectionManager (Cross-Device Connection Management) (System API)

harmony 鸿蒙@ohos.distributedsched.abilityConnectionManager (Cross-Device Connection Management)

0  赞