The WindowManager of the path of the Android master

Source: Internet
Author: User

Wirelessly's picture is not made purely by window. Instead, it was changed to Window+view's organizational model. window is the concept of a top-level window. View is the equivalent of a control within a window. Subwindow is a dialog box attached to the window. When the window is managed by Android, the window is divided into layers, and different layers correspond to different window types. The following diagram illustrates this concept:



Android starts by layering the windows in layers, then each layer has a lot of windows, and each window contains a lot of view and sublayer. These layered concepts are transparent to the client, and the client only knows Windowtype so that the user can pass

The naming of Windowtype from the intuitive concept of what the window might appear to be like. Here is the conversion of Windowtype to

Layer's function:

Java code
  1. public int WINDOWTYPETOLAYERLW (int type) {
  2. if (type >= first_application_window && type <= last_application_window) {
  3. return application_layer;
  4. }
  5. switch (type) {
  6. Case Type_status_bar:
  7. return status_bar_layer; //14
  8. Case Type_status_bar_panel:
  9. return status_bar_panel_layer; //15
  10. Case Type_status_bar_sub_panel:
  11. return status_bar_sub_panel_layer; //13
  12. Case Type_system_dialog:
  13. return system_dialog_layer; //5
  14. Case Type_search_bar:
  15. return search_bar_layer; //4//4
  16. Case Type_phone:
  17. return phone_layer; //3//3
  18. Case Type_keyguard:
  19. return keyguard_layer; //11
  20. Case Type_keyguard_dialog:
  21. return keyguard_dialog_layer; //12
  22. Case Type_system_alert:
  23. return system_alert_layer; //8
  24. Case Type_system_error:
  25. return system_error_layer; //19
  26. Case Type_input_method:
  27. return input_method_layer; //9
  28. Case Type_input_method_dialog:
  29. return input_method_dialog_layer; //10
  30. Case Type_volume_overlay:
  31. return volume_overlay_layer; //16
  32. Case Type_system_overlay:
  33. return system_overlay_layer; //17
  34. Case Type_secure_system_overlay:
  35. return secure_system_overlay_layer; //21
  36. Case Type_priority_phone:
  37. return priority_phone_layer; //7
  38. Case Type_toast:
  39. return toast_layer; //6
  40. Case Type_wallpaper:
  41. return wallpaper_layer; //2
  42. Case Type_drag:
  43. return drag_layer; //20
  44. Case Type_pointer:
  45. return pointer_layer; //23
  46. Case Type_navigation_bar:
  47. return navigation_bar_layer; //18
  48. Case type_boot_progress:
  49. return boot_progress_layer; //22
  50. Case Type_hidden_nav_consumer:
  51. return hidden_nav_consumer_layer; //24
  52. }
  53. LOG.E (TAG, "Unknown window Type:" + type);
  54. return application_layer;
  55. }

Many people see this later do not know how to analyze, suddenly be from 2 to 24 layers of structure frightened. So I'm going to analyze these hierarchical relationships. We just have to find a breakthrough point, that is the lock screen layer, and on the lock screen layer above the temporary do not care:

Case Type_keyguard:
Return KEYGUARD_LAYER;//11

The layers below the lock screen are:

Input Method Dialog box

Case Type_input_method_dialog:
Return INPUT_METHOD_DIALOG_LAYER;//10

Input

Case Type_input_method:
Return INPUT_METHOD_LAYER;//9

System warning [low power, etc.]

Case Type_system_alert:
Return SYSTEM_ALERT_LAYER;//8

Case Type_priority_phone:
Return PRIORITY_PHONE_LAYER;//7

Case Type_toast:
Return TOAST_LAYER;//6

Case Type_system_dialog:
Return SYSTEM_DIALOG_LAYER;//5

Case Type_search_bar:
return SEARCH_BAR_LAYER;//4//4

Case Type_phone:
return PHONE_LAYER;//3//3

if (type >= first_application_window && type <= last_application_window) {
return application_layer;
}

Case Type_wallpaper:
Return wallpaper_layer;//2

As can be seen from the above, most of them are understandable. Only the following two kinds of bad understanding:

Type_phone 3 and Type_priority_phone 7 are obviously related to the telephone.

Type_phone 3 This is basically not used only in the compatmodedialog used a bit, and Type_priority_phone is the lock net use. This will bring more benefits to operators.

What is on top of 2.keyguard_layer? In turn, follow:

Case Type_keyguard_dialog:
Return KEYGUARD_DIALOG_LAYER;//12 used when shutting down the machine

Case Type_status_bar_sub_panel:
Return STATUS_BAR_SUB_PANEL_LAYER;//13

Case Type_status_bar:
Return STATUS_BAR_LAYER;//14

Case Type_status_bar_panel:
Return STATUS_BAR_PANEL_LAYER;//15

Case Type_volume_overlay:
Return VOLUME_OVERLAY_LAYER;//16

Case Type_system_overlay:
Return SYSTEM_OVERLAY_LAYER;//17

These are a kind, all well understood. From System_overlay_layer down, it's basically uncommon.

Case Type_navigation_bar:
Return NAVIGATION_BAR_LAYER;//18

Case TYPE_SYSTEM_ERROR:
Return SYSTEM_ERROR_LAYER;//19

Case Type_drag:
Return DRAG_LAYER;//20

Case Type_secure_system_overlay:
Return SECURE_SYSTEM_OVERLAY_LAYER;//21

Case Type_boot_progress:
return boot_progress_layer; 22

Case Type_pointer:
return pointer_layer; 23

Case Type_hidden_nav_consumer:
return hidden_nav_consumer_layer; 24

You can see that most dialogs cannot be added to the lock screen. Then some dialog boxes want to be able to display when the lock screen, but also can be kept in accordance with the General dialog box when the screen is not locked. What should be done? such as telephone, alarm clock and so on. The first method dynamically changes the type of window. Sets a different layer to handle depending on whether the screen is currently being locked. Second, in the lock screen, if the window is activated, the lock screen is hidden. When this window is removed, the lock screen is displayed again.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.