از 27 مارس 2025، توصیه می کنیم از android-latest-release
به جای aosp-main
برای ساختن و کمک به AOSP استفاده کنید. برای اطلاعات بیشتر، به تغییرات AOSP مراجعه کنید.
WindowManager
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
تخلیه WindowManager یک عکس فوری از WindowManager در یک زمان خاص ارائه می دهد. ردیابی های WindowManager دارای توالی زمانی از حالت ها هستند که بینش های ارزشمندی را در مورد اینکه چرا یک پنجره روی صفحه نمایش داده می شود، پیکربندی آن، یا فعالیت، وظیفه، نمایش یا هر عنصر دیگری در سلسله مراتب WindowManager ارائه می دهد. این اطلاعات برای عیبیابی مشکلاتی مانند اینکه چرا برنامه من قابل مشاهده نیست یا هنگام تغییر بین برنامهها دچار سوسو زدن شدم، مفید است.
نمایشگر WindowManager Winscope این اطلاعات را هم برای ردیابی و هم برای تخلیه نمایش می دهد.
برای اطلاعات بیشتر در مورد جمع آوری ردیابی به WindowManager مراجعه کنید.

شکل 1. تحلیل ردیابی WindowManager.
سمت چپ صفحه نمایش دارای نمای سه بعدی از پنجره ها است. نمای rects مرزهای پنجره، مرتبه z و کدورت را در نظر می گیرد.
بخش مرکزی برگه سلسله مراتب پنجره را نشان می دهد. علاوه بر روابط والدین و فرزند بین پنجرهها، فعالیتها و وظایف، این دیدگاه شامل اطلاعات زیر نیز میشود:
- V: پنجره های قابل مشاهده را شناسایی می کند.
در سمت راست صفحه نمایش یک نمونه اولیه از تمام ویژگی های موجود است. برای اطلاعات بیشتر در مورد ویژگیهای بخش proto dump به Properties مراجعه کنید.
ترجمه @IntDef
ترجمه @IntDef
یکی از ویژگی های کلیدی پانل ویژگی های WindowManager است. @IntDef
نشان می دهد که عنصر حاشیه نویسی شده از نوع عدد صحیح یک نوع منطقی را نشان می دهد و مقدار آن باید یکی از ثابت های نامگذاری شده صریح باشد. @IntDef
در پایگاه کد اندروید به جای enums برای کاهش تاثیر حافظه و عملکرد استفاده می شود.
مثال زیر نمونه ای از استفاده @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;
پرچمها بهجای استفاده از مقادیر قابل خواندن توسط انسان، بهعنوان اعداد صحیح ذخیره میشوند، که تفسیر آنها میتواند چالش برانگیز باشد. Winscope این پرچم ها را با استفاده از تعاریف @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 را بهروزرسانی کنید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-29 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]