ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
WindowManager
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
WindowManager
dumps ให้ภาพรวมของ WindowManager ณ เวลาหนึ่งๆ ร่องรอยของ WindowManager แสดงลำดับสถานะตามลำดับเวลาซึ่งให้ข้อมูลเชิงลึกที่มีคุณค่าเกี่ยวกับสาเหตุที่หน้าต่างปรากฏบนหน้าจอ การกำหนดค่าของหน้าต่าง หรือการกำหนดค่าของกิจกรรม งาน การแสดงผล หรือองค์ประกอบอื่นๆ ในลําดับชั้น WindowManager ข้อมูลนี้มีประโยชน์ในการแก้ปัญหาต่างๆ เช่น ทำไมแอปของฉันจึงไม่แสดงหรือฉันเห็นหน้าจอกะพริบขณะสลับใช้แอป
เครื่องมือดู WindowManager ของ Winscope จะแสดงข้อมูลนี้สำหรับทั้งร่องรอยและข้อมูลพุล
ดูข้อมูลเพิ่มเติมเกี่ยวกับการรวบรวมร่องรอยได้ที่ WindowManager
รูปที่ 1 การวิเคราะห์การติดตาม WindowManager
ด้านซ้ายของหน้าจอจะมีมุมมอง 3 มิติของหน้าต่าง มุมมอง rects จะพิจารณาขอบเขตของหน้าต่างลําดับชั้น z และความทึบแสง
ส่วนกลางของแท็บจะแสดงลําดับชั้นของหน้าต่าง นอกจากความสัมพันธ์แบบ "หลัก-ย่อย" ระหว่างหน้าต่าง กิจกรรม และงานแล้ว มุมมองนี้ยังมีข้อมูลต่อไปนี้ด้วย
- V: ระบุหน้าต่างที่มองเห็นได้
ด้านขวาของหน้าจอจะมีการดัมพ์โปรโตของพร็อพเพอร์ตี้ทั้งหมดที่ใช้ได้ ดูข้อมูลเพิ่มเติมเกี่ยวกับฟีเจอร์ของส่วนการดัมพ์โปรโตได้ที่พร็อพเพอร์ตี้
@IntDef translation
@IntDef
translation เป็นพร็อพเพอร์ตี้หลักของแผงพร็อพเพอร์ตี้ WindowManager
@IntDef
หมายถึงว่าองค์ประกอบที่มีคำอธิบายประกอบซึ่งมีประเภทจำนวนเต็มแสดงถึงประเภทตรรกะ และค่าขององค์ประกอบต้องเป็นหนึ่งในค่าคงที่ที่มีชื่ออย่างชัดแจ้ง
@IntDef
ใช้ภายในโค้ดฐานของ Android แทน enum เพื่อลดผลกระทบต่อหน่วยความจำและประสิทธิภาพ
ตัวอย่างการใช้ @IntDef มีดังนี้
/**
* The modes to control how root task is moved to the front when calling {@link Task#reparent}.
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({
REPARENT_MOVE_ROOT_TASK_TO_FRONT,
REPARENT_KEEP_ROOT_TASK_AT_FRONT,
REPARENT_LEAVE_ROOT_TASK_IN_PLACE
})
@interface ReparentMoveRootTaskMode {}
// Moves the root task to the front if it was not at the front
static final int REPARENT_MOVE_ROOT_TASK_TO_FRONT = 0;
// Only moves the root task to the front if it was focused or frontmost already
static final int REPARENT_KEEP_ROOT_TASK_AT_FRONT = 1;
// Do not move the root task as a part of reparenting
static final int REPARENT_LEAVE_ROOT_TASK_IN_PLACE = 2;
ระบบจะจัดเก็บ Flag เป็นจำนวนเต็มแทนที่จะใช้ค่าที่มนุษย์อ่านได้ ซึ่งอาจตีความได้ยาก Winscope จะแปล Flag เหล่านี้เป็นค่าที่มนุษย์อ่านได้โดยใช้คำจำกัดความ @IntDef
ในระหว่างการคอมไพล์ Winscope จะรวบรวมพจนานุกรมของค่า @IntDef
และใช้รายการนี้เพื่อถอดรหัสอินสแตนซ์ @IntDef
ให้เป็นรูปแบบที่มนุษย์อ่านออกได้เมื่อรันไทม์ เช่น กิจกรรมที่มี activityType
จาก 2
จะแปลเป็น activityType
จาก ACTIVITY_TYPE_HOME
ในทำนองเดียวกัน หน้าต่างที่มี
flags=2173763840
จะแปลเป็นดังนี้ใน Winscope
flags=FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | FLAG_HARDWARE_ACCELERATED |
FLAG_SPLIT_TOUCH | FLAG_SHOW_WALLPAPER | FLAG_LAYOUT_INSET_DECOR |
FLAG_LAYOUT_IN_SCREEN
หาก Winscope แปลอินสแตนซ์ @IntDef
อย่างไม่ถูกต้อง ให้ทำตามขั้นตอนในอัปเดตการแมป @IntDef เพื่ออัปเดตรายการอินสแตนซ์ @IntDef
ที่ Winscope รู้จัก
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# WindowManager\n\n[WindowManager](/docs/core/graphics/surfaceflinger-windowmanager#windowmanager)\ndumps provide a snapshot of WindowManager at a specific time. WindowManager\ntraces feature a chronological sequence of states that provide valuable insights\ninto why a window appears on screen, its configuration, or that of its activity,\ntask, display or of any other element in the WindowManager hierarchy. This\ninformation is useful for troubleshooting issues like *why isn't my app\nvisible* or *I experienced flickering while changing between apps*.\n\nWinscope's WindowManager viewer displays this information for both traces\nand dumps.\n\nSee\n[WindowManager](/docs/core/graphics/winscope/capture/adb#capture-adb-wm)\nfor more information about trace collection.\n\n**Figure 1.** WindowManager trace analysis.\n\nThe left side of the screen features a 3D view of the windows. The rects view\nconsiders window bounds, z-order, and opacity.\n\nThe tab's central segment shows the window hierarchy. In addition to the\nparent-child relationships between windows, activities, and tasks, this view\nalso includes the following information:\n\n- **V:** Identifies visible windows.\n\nThe right side of the screen features a **proto dump** of all available\nproperties. For more information about the features of the proto dump section\nsee [Properties](/docs/core/graphics/winscope/analyze/overview#analyze-properties).\n\n@IntDef translation\n-------------------\n\n`@IntDef` translation is a key property of the WindowManager properties panel.\n`@IntDef` denotes that the annotated element of integer type represents a\nlogical type and that its value must be one of the explicitly named constants.\n`@IntDef` is used within the Android codebase instead of enums for mitigating\nmemory and performance impact.\n\nThe following is an example of @IntDef usage: \n\n /**\n * The modes to control how root task is moved to the front when calling {@link Task#reparent}.\n */\n @Retention(RetentionPolicy.SOURCE)\n @IntDef({\n REPARENT_MOVE_ROOT_TASK_TO_FRONT,\n REPARENT_KEEP_ROOT_TASK_AT_FRONT,\n REPARENT_LEAVE_ROOT_TASK_IN_PLACE\n })\n @interface ReparentMoveRootTaskMode {}\n\n // Moves the root task to the front if it was not at the front\n static final int REPARENT_MOVE_ROOT_TASK_TO_FRONT = 0;\n // Only moves the root task to the front if it was focused or frontmost already\n static final int REPARENT_KEEP_ROOT_TASK_AT_FRONT = 1;\n // Do not move the root task as a part of reparenting\n static final int REPARENT_LEAVE_ROOT_TASK_IN_PLACE = 2;\n\nFlags are stored as *integers* , instead of using\nhuman-readable values, which can be challenging to interpret. Winscope\ntranslates these flags into human-readable values using `@IntDef` definitions.\nDuring compilations, Winscope collects a dictionary of `@IntDef` values and uses\nthis list to decode `@IntDef` instances into a human-readable format at\nruntime. For example, an activity with `activityType` of `2` is translated into\n`activityType` of `ACTIVITY_TYPE_HOME`. Similarly, a window with\n`flags=2173763840` is translated in Winscope as:\n\n`flags=FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | FLAG_HARDWARE_ACCELERATED |\nFLAG_SPLIT_TOUCH | FLAG_SHOW_WALLPAPER | FLAG_LAYOUT_INSET_DECOR |\nFLAG_LAYOUT_IN_SCREEN`\n\nIf Winscope doesn't translate an `@IntDef` instance correctly,\nfollow the steps in [Update @IntDef mapping](/docs/core/graphics/winscope/run#update-intdef)\nto update the list of `@IntDef` instances known by Winscope."]]