Android Window 3: Create an application Window, androidwindow
Create application window 1. Create Activity1. the application window must correspond to the Activity. AMS notifies the client ActivityThread to start the Activity. Create Activity object through reflection
2. Create the Window2. activity. attach () method to set internal variables. 3. The activity. attach () method creates a Window object. PolicyManager. makeNewWindow () is created through com. android. internal. policy. impl. policy configuration) Create PhoneWondow and assign it to Activity. in mWindow, set setCallback () [The calback of Window is the current Activity, which is why the user message can be transmitted to the Activity] 4. window. mWindowManager assignment. WindowManager is an interface with two implementation classes Window. LocalWindowManager (a shell, which is implemented in its internal WindowManagerImpl) and WindowManagerImpl
3. Create ViewRoot5. Add a View. Call callActivityOnCreate within the launch mlaunchactivity and call setContentView in onCreate. SetContentView source code getWidnow. setContentView () installDecor () create a title bar, etc. 6. setContentView source code, analysis of Theme related settings 7. after the Activity is ready, notify AMS. AMS calls the Activity. makeVisible () 8. activity. makeVisible () source code. The window type is TYPE_APPLICATION. In ViewGroup. addView, the "level" determines the WindowManager level 9. LocalWindowManager. addView (WindowManagerImpl. addView has only one object for one application), which contains three arrays. Use ViewRoot. setView to complete key addition.
4. Add 10. Save views, ViewRoot, and WindowManager. layoutparams11in the array mViews, mRoots, and mParams. Run ViewRoot. setView to add the last window. MAttachInfo value assignment, requestLayout sends a page layout request for sWindowSession. add to notify WMS to add a window
References:
Android Kernel Analysis Chapter 1 8th create an application window
Graphic Android-Android GUI system (2)-Window Management (View, Canvas, Window Manager)
Android Window mechanism analysis ------ UI Management System (Window level)