裝置控制
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本指南的功能說明瞭可在裝置政策控制器 (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 Plus 個人資料) 中顯示的個人資料圖示不同。
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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間: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)."]]