设备控制
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本指南中的功能介绍了您可以在设备政策控制器 (DPC) 应用中实现的设备管理功能。您还可以使用 TestDPC 应用作为 Android 企业功能的示例代码来源。
DPC 应用可以在个人设备上以资料所有者模式运行,或在全托管式设备上以设备所有者模式运行。下表显示了 DPC 在资料所有者模式或设备所有者模式下运行时可用的功能:
创建自定义锁屏消息
在设备所有者模式下运行时,DPC 可以使用 setDeviceOwnerLockScreenInfo
方法在用户设备上创建自定义锁屏消息。此消息会在设备处于锁定状态时显示在设备屏幕上,对于丢失或被盗的设备非常有用。常见消息是“此手机归 <company name>
所有,如有发现,请致电 <phone number>
”。
停用数据漫游
数据漫游可能会导致移动运营商账单产生高额费用。为简化这些费用,在设备所有者模式下运行的 DPC 可以通过设置 DISALLOW_DATA ROAMING
限制来停用数据漫游。DPC 设置用户限制后,用户将无法在设备上使用设置更改数据漫游设置。
在用户的某项设置被屏蔽时向其显示自定义消息
当用户点击其 IT 部门屏蔽的设置或功能时,支持消息会简要说明他们无法访问该功能的原因。
这些消息比“不允许执行此操作”更具描述性。运行在设备所有者或资料所有者模式下的 DPC 可以使用 DevicePolicyManager
setShortSupportMessage()
和 setLongSupportMessage()
方法自定义这些消息。
创建支持消息
如需说明某项设置受到限制的原因,您可以使用简短或长篇消息:
如果这两种消息中的任一消息需要翻译,DeviceAdminReceiver
需要监听 ACTION_LOCALE_CHANGED
广播并相应地设置此字符串的新版本。
锁定壁纸
将 Android 设备用作共用设备的组织(例如学校或公司)可以阻止用户更改设备主屏幕上的壁纸。
如需锁定壁纸,运行在设备所有者或资料所有者模式下的 DPC 可以将 DISALLOW_SET_WALLPAPER
设置为 true
。此设置的默认值为 false
。
锁定客户用户图标
在设备所有者或资料所有者模式下运行的 DPC 可以添加用户,并为每位用户指定图标。此用户图标仅在设备上显示,与其他 Google 产品和服务(例如 Gmail 邮件或 Google+ 个人资料)中显示的个人资料图标不同。
DPC 可以将 DISALLOW_SET_USER_ICON
配置为 true
,以限制用户更改其图标。此设置的默认值为 false
。
远程监控设备运行状况和状态
在设备所有者或资料所有者模式下运行的 DPC 可以监控在远程位置运行的无人值守设备,例如通过 Android 设备运行的数字标牌显示屏或自助服务终端。为此,DPC 使用 HardwarePropertiesManager
接口获取有关设备运行状况的信息,例如 GPU 温度和 CPU 使用率。这对于诊断因过热或其他问题而自动关闭的设备问题非常有用。
如需访问设备的硬件属性管理器服务,请将 Context.getSystemService()
与字符串 Context.HARDWARE_PROPERTIES_SERVICE
搭配使用。
远程重启 Android 设备
只有在设备政策控制器 (DPC) 以设备所有者模式运行时,才能远程重新启动 Android 设备。在某些情况下,部署在公共场所的封装内设备或作为数字标牌显示屏的设备可能会阻止轻松访问电源按钮。如果设备需要重新启动,DPC 可以使用 DevicePolicyManager.reboot()
方法来进行此操作。
如果有通话正在进行,设备不会重启。设备需要处于空闲状态才能重启。这是为了防止管理员通过重新启动请求中断用户的通话。如果设备处于活动状态,则会一直抛出 IllegalStateException
,直到 CALL_STATE_IDLE
。
阻止用户通过蓝牙发送文件
设备所有者和个人资料所有者可以使用 DISALLOW_BLUETOOTH_SHARING
阻止用户通过蓝牙发送文件。接收文件不会受到影响。由设备所有者设置后,DISALLOW_BLUETOOTH_SHARING
会应用于设备上的所有用户。
借助此选项,IT 管理员可以控制快速分享的行为。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Device control\n\nThe features in this guide describe device management capabilities you can\nimplement in your [device policy controller](/work/dpc/build-dpc) (DPC)\napp. You can also use the\n[TestDPC](https://github.com/googlesamples/android-testdpc/) app as\na source of sample code for Android's enterprise features.\n\nA DPC app can run in profile owner mode on personal devices or in device owner\nmode on fully managed devices. This table indicates which features are\navailable when the DPC runs in [profile owner mode or device owner\nmode](https://developers.google.com/android/work/play/emm-api/prov-devices#modes_of_operation):\n\n| **Feature** | **Profile owner** | **Device owner** |\n|---------------------------------------------------------------------------------------------------------------------|-------------------|------------------|\n| [Create a custom lock screen message](#create_a_custom_lock_screen_message) | | ✓ |\n| [Disable data roaming](#disable_data_roaming) | | ✓ |\n| [Give users a customized message if a setting is blocked](#give_users_a_customized_message_if_a_setting_is_blocked) | ✓ | ✓ |\n| [Lock down the wallpaper](#lock_down_the_wallpaper) | ✓ | ✓ |\n| [Lock down a customer user icon](#lock_down_a_customer_user_icon) | ✓ | ✓ |\n| [Remotely monitor device health and status](#remotely_monitor_device_health_and_status) | ✓ | ✓ |\n| [Remotely reboot an Android device](#remotely_reboot_an_android_device) | | ✓ |\n| [Prevent users sending files over Bluetooth](#prevent_users_sending_files_over_bluetooth) | ✓ | ✓ |\n\nCreate a custom lock screen message\n-----------------------------------\n\nRunning in device owner mode, a DPC can create a custom lock screen message on\ntheir users' devices using the [`setDeviceOwnerLockScreenInfo`](/reference/android/app/admin/DevicePolicyManager#setDeviceOwnerLockScreenInfo(android.content.ComponentName,%20java.lang.CharSequence))\nmethod. This message displays on the device screen when locked, and is useful\nfor a lost or stolen device. A common message is \"This phone belongs to\n*`\u003ccompany name\u003e`* , call *`\u003cphone number\u003e`* if found.\"\n\nDisable data roaming\n--------------------\n\nData roaming can cause significant charges on Mobile carrier bills. To help\nstreamline those costs, a DPC running in device owner mode can disable\ndata roaming by setting the [`DISALLOW_DATA ROAMING`](/reference/android/os/UserManager#DISALLOW_DATA_ROAMING) restriction. Once the\nuser restriction is set by the DPC, a user can't change data roaming using\n**Settings** on their device.\n\nGive users a customized message if a setting is blocked\n-------------------------------------------------------\n\nWhen a user clicks a setting or feature blocked by their IT department, the\nsupport message gives a brief explanation of why they can't access the feature.\n\nThese messages can be more descriptive than \"Action not allowed\". A DPC running\nin device owner or profile owner mode can customize these messages\nusing the\n[`DevicePolicyManager`](/reference/android/app/admin/DevicePolicyManager) [`setShortSupportMessage()`](/reference/android/app/admin/DevicePolicyManager#setShortSupportMessage(android.content.ComponentName,%20java.lang.CharSequence))\nand [`setLongSupportMessage()`](/reference/android/app/admin/DevicePolicyManager#setLongSupportMessage(android.content.ComponentName,%20java.lang.CharSequence)) methods.\n\n### Create support messages\n\nTo explain why a setting is restricted, you can use short or long messages:\n\n- **To create a short message** , use the [`setShortSupportMessage()`](/reference/android/app/admin/DevicePolicyManager#setShortSupportMessage(android.content.ComponentName,%20java.lang.CharSequence))\n method.\n\n - The short message is restricted to 200 characters.\n - A common message is \"This setting is disabled by your admin. Contact *'[yourITdepartment@example.com](mailto:yourITdepartment@example.com)'* for support.\"\n- **To create a long message** , use the [`setLongSupportMessage()`](/reference/android/app/admin/DevicePolicyManager#setLongSupportMessage(android.content.ComponentName,%20java.lang.CharSequence)) method.\n The user can view this message on their device under **Settings** \\\u003e\n **Security** \\\u003e **Device admins**, and then select a specific admin.\n\nIf either of these messages needs to be translated, the\n[`DeviceAdminReceiver`](/reference/android/app/admin/DeviceAdminReceiver) needs to listen to the [`ACTION_LOCALE_CHANGED`](/reference/android/content/Intent#ACTION_LOCALE_CHANGED)\nbroadcast and set a new version of this string accordingly.\n\nLock down the wallpaper\n-----------------------\n\nOrganizations such as schools or companies that run Android devices as shared\ndevices can block their users from changing the wallpaper on their device home\nscreen.\n\nTo lock down the wallpaper, a DPC running in device owner or profile owner\nmode can set [`DISALLOW_SET_WALLPAPER`](/reference/android/os/UserManager#DISALLOW_SET_WALLPAPER) to `true`. The default for this\nsetting is `false`.\n\nLock down a customer user icon\n------------------------------\n\nA DPC running in either device owner or profile owner mode can add users and\nspecify an icon for each user. This user icon is only on the device and is\nseparate from the profile icon that appears in other Google properties, such as\na Gmail message or Google Plus profile.\n\nA DPC can configure the [`DISALLOW_SET_USER_ICON`](/reference/android/os/UserManager#DISALLOW_SET_USER_ICON) to `true` to restrict a\nuser from changing their icon. The default for this setting is `false`.\n\nRemotely monitor device health and status\n-----------------------------------------\n\nA DPC running in device owner or profile owner mode can monitor unattended\ndevices running in a remote location, such as digital signage displays or kiosks\nrun off of Android devices. To do this, a DPC uses the\n[`HardwarePropertiesManager`](/reference/android/os/HardwarePropertiesManager) interface to get information about device\nhealth, such as GPU temperatures and CPU usage. This is useful to diagnose\nissues with devices that automatically turn off because of overheating or other\nissues.\n\nTo access the device's Hardware Property Manager service, use\n[`Context.getSystemService()`](/reference/android/content/Context#getSystemService(java.lang.String)) with string\n[`Context.HARDWARE_PROPERTIES_SERVICE`](/reference/android/content/Context#HARDWARE_PROPERTIES_SERVICE).\n| **Note:** Not all properties monitored by [`HardwarePropertiesManager`](/reference/android/os/HardwarePropertiesManager) are available to all Android devices.\n\nRemotely reboot an Android device\n---------------------------------\n\nA DPC can remotely reboot Android devices only when it runs in device owner\nmode. In some cases, devices deployed in public places inside enclosures or as\ndigital signage displays can prevent easy access to the power button. If a\ndevice needs to be rebooted, a DPC can do so using the\n[`DevicePolicyManager.reboot()`](/reference/android/app/admin/DevicePolicyManager#reboot(android.content.ComponentName)) method.\n\nA device doesn't reboot if there's an ongoing call. The device needs to be\nin an idle state to reboot. This is to prevent an admin interrupting a user's\nphone call with a reboot request. If the device is active, it throws an\n`IllegalStateException` until [`CALL_STATE_IDLE`](/reference/android/telephony/TelephonyManager#CALL_STATE_IDLE).\n\nPrevent users sending files over Bluetooth\n------------------------------------------\n\nDevice owners and profile owners can prevent users from sending files over\nBluetooth using [`DISALLOW_BLUETOOTH_SHARING`](/reference/android/os/UserManager#DISALLOW_BLUETOOTH_SHARING). Receiving files isn't\naffected. When set by a device owner, `DISALLOW_BLUETOOTH_SHARING` applies to\nall users on the device.\n\nThis option allows the IT admins to control the behavior of [Quick Share](https://support.google.com/android/answer/9286773)."]]