ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ทดสอบการจัดการอุปกรณ์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
อุปกรณ์ OEM ต้องมีองค์ประกอบสำคัญต่อไปนี้เพื่อให้รองรับโปรไฟล์ที่มีการจัดการได้อย่างน้อย
โปรดดูรายการข้อกำหนดทั้งหมดที่หัวข้อใช้การจัดการอุปกรณ์ หากต้องการทดสอบฟีเจอร์การจัดการอุปกรณ์ เจ้าของอุปกรณ์สามารถใช้แอปพลิเคชัน TestDPC ที่อธิบายไว้ด้านล่าง
ตั้งค่าเจ้าของอุปกรณ์สำหรับการทดสอบ
ใช้วิธีการต่อไปนี้เพื่อตั้งค่าสภาพแวดล้อมการทดสอบสำหรับเจ้าของอุปกรณ์
- รีเซ็ตอุปกรณ์เป้าหมายเป็นค่าเริ่มต้น
- ตรวจสอบว่าอุปกรณ์ไม่มีบัญชีผู้ใช้ (เช่น บัญชีที่ใช้เข้าสู่ระบบบริการออนไลน์) ตรวจสอบได้โดยไปที่การตั้งค่า > บัญชี
- ตั้งค่าแอปพลิเคชันทดสอบโดยใช้วิธีใดวิธีหนึ่งต่อไปนี้
- ตั้งค่าแอป TestDPC เป็นเจ้าของอุปกรณ์โดยใช้คําสั่งต่อไปนี้
adb shell dpm set-device-owner "com.afwsamples.testdpc/.DeviceAdminReceiver"
- ดำเนินการตั้งค่าเจ้าของอุปกรณ์ในอุปกรณ์ (เข้ารหัส เลือก Wi-Fi)
ยืนยันการตั้งค่าเจ้าของอุปกรณ์
หากต้องการยืนยันว่าเจ้าของอุปกรณ์ได้รับการตั้งค่าอย่างถูกต้อง ให้ไปที่การตั้งค่า >
ความปลอดภัย > ผู้ดูแลระบบอุปกรณ์ และตรวจสอบว่า TestDPC อยู่ในรายการ ยืนยันว่าปิดใช้ไม่ได้ (ซึ่งหมายความว่าอุปกรณ์ดังกล่าวเป็นเจ้าของอุปกรณ์)
รายงานข้อบกพร่องและบันทึก
ตั้งแต่ Android 7.0 เป็นต้นไป ไคลเอ็นต์นโยบายด้านอุปกรณ์ (DPC) ของเจ้าของอุปกรณ์จะดูรายงานข้อบกพร่องและดูบันทึกสำหรับกระบวนการขององค์กรในอุปกรณ์ที่มีการจัดการได้
หากต้องการเรียกให้แสดงรายงานข้อบกพร่อง (นั่นคือข้อมูลที่เทียบเท่าซึ่งรวบรวมโดย adb bugreport
ที่มีข้อมูล dumpsys
, dumpstate และ logcat) ให้ใช้ DevicePolicyController.requestBugReport
หลังจากรวบรวมรายงานข้อบกพร่องแล้ว ระบบจะแจ้งให้ผู้ใช้ให้ความยินยอมในการส่งข้อมูลรายงานข้อบกพร่อง DeviceAdminReceiver.onBugreport[Failed|Shared|SharingDeclined]
ได้รับผลลัพธ์แล้ว ดูรายละเอียดเกี่ยวกับเนื้อหาของรายงานข้อบกพร่องได้ที่การอ่านรายงานข้อบกพร่อง
นอกจากนี้ DPC ของเจ้าของอุปกรณ์ยังรวบรวมบันทึกที่เกี่ยวข้องกับการดำเนินการที่ผู้ใช้ทำในอุปกรณ์ที่มีการจัดการได้ด้วย จำเป็นต้องใช้การบันทึกกระบวนการขององค์กรสำหรับอุปกรณ์ทั้งหมดที่รายงาน device_admin และเปิดใช้โดยบัฟเฟอร์ความปลอดภัยของบันทึกใหม่ซึ่งอ่านได้โดยเซิร์ฟเวอร์ระบบเท่านั้น (นั่นคือ $ adb logcat -b security
อ่านบัฟเฟอร์ไม่ได้) บริการ ActivityManager และคอมโพเนนต์ Keyguard จะบันทึกเหตุการณ์ต่อไปนี้ลงในบัฟเฟอร์ความปลอดภัย
- กระบวนการสมัครกำลังเริ่มต้น
- การดำเนินการของ Keyguard (เช่น ปลดล็อกไม่สำเร็จและสำเร็จ)
adb
คำสั่งที่ส่งไปยังอุปกรณ์
หากต้องการเก็บบันทึกไว้เมื่อรีบูต (ไม่ใช่การบูตจากเครื่องเย็น) และทำให้ DPC ของเจ้าของอุปกรณ์เข้าถึงบันทึกเหล่านี้ได้ อุปกรณ์จะต้องมีเคอร์เนลที่เปิดใช้ pstore
และ pmsg
รวมถึง DRAM ที่เปิดเครื่องและรีเฟรชตลอดทุกระยะของการรีบูตเพื่อหลีกเลี่ยงการทำให้บันทึกที่เก็บไว้ในหน่วยความจำเสียหาย หากต้องการเปิดใช้การสนับสนุน ให้ใช้การตั้งค่า config_supportPreRebootSecurityLogs
ใน frameworks/base/core/res/res/values/config.xml
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Test device management\n\nTo ensure minimal support for managed profiles, OEM devices must contain the\nfollowing essential elements:\n\n- Profile owner (as described in [Ensuring\n Compatibility with Managed Profiles](https://developer.android.com/training/enterprise/app-compatibility.html))\n- Device owner\n\nFor a complete list of requirements, see\n[Implement device\nmanagement](/docs/devices/admin/implement). To test device management features, device owners can\nuse the TestDPC application described below.\n\nSet up device owner for testing\n-------------------------------\n\nUse the following instructions to set up a device owner testing environment.\n\n1. Factory reset the target device.\n2. Ensure the device does not contain any user accounts (for example, those used to log into online services). To verify, check *Settings \\\u003e Accounts*.\n3. Set up the testing application using one of the following methods:\n - [Download\n the TestDPC application](https://play.google.com/store/apps/details?id=com.afwsamples.testdpc&hl=en) (available from Google Play).\n - [Build\n the TestDPC application](https://github.com/googlesamples/android-testdpc/) (available from github.com).\n4. Set the TestDPC app as the device owner using the following command: \n\n ```\n adb shell dpm set-device-owner \"com.afwsamples.testdpc/.DeviceAdminReceiver\"\n ```\n5. Go through device owner setup on the device (encrypt, select Wi-Fi).\n\nVerify device owner setup\n-------------------------\n\nTo verify the device owner was correctly setup, go to *Settings \\\u003e\nSecurity \\\u003e Device Administrators* and confirm TestDPC is in the\nlist. Verify it cannot be disabled (this signifies it is a device owner).\n\nBug reports and logs\n--------------------\n\nAs of Android 7.0, device owner Device Policy Client (DPCs) can get bug\nreports and view logs for enterprise processes on a managed device.\n\nTo trigger a bug report (that is, the equivalent data collected by\n`adb bugreport` containing `dumpsys`, dumpstate, and\nlogcat data), use `DevicePolicyController.requestBugReport`. After\nthe bug report is collected, the user is prompted to give consent to send the\nbug report data. Results are received by\n`DeviceAdminReceiver.onBugreport[Failed|Shared|SharingDeclined]`. For\ndetails on bug report contents, see\n[Reading bug reports](/docs/setup/read-bug-reports).\n\nIn addition, device owner DPCs can also collect logs related to actions a\nuser has taken on a managed device. Enterprise process logging is required for\nall devices that report device_admin and enabled by a new log security buffer\nreadable only by the system server (that is, `$ adb logcat -b security`\ncannot read the buffer). ActivityManager service and Keyguard components log the\nfollowing events to the security buffer:\n\n- Application processes starting\n- Keyguard actions (for example, unlock failure and success)\n- `adb` commands issued to the device\n\nTo optionally retain logs across reboots (not cold boot) and make these logs\navailable to device owner DPCs, a device must have a kernel with\n`pstore` and `pmsg` enabled, and DRAM powered and\nrefreshed through all stages of reboot to avoid corruption to the logs retained\nin memory. To enable support, use the\n`config_supportPreRebootSecurityLogs` setting in\n`frameworks/base/core/res/res/values/config.xml`."]]