Search code examples
androidandroid-sourcebootandroid-statusbar

When SystemUI loads in Android Boot


How to know when the system UI loads in Android boot process? Where exactly the status bar and navigation bar view draws? As SystemUI is a privileged app so is it loading before the start of a launcher app (Home screen)? I am not sure. Any suggestion is welcome.


Solution

  • Below is a chain of briefly explained steps that hopefully shed some light on the sequence of "loading" the system UI components at boot time. I'll demonstrate it on Android 4.2, although the sequence is quite similar for the other versions.

    • When SystemServer is "done" with the core system services, including StatusBarManagerService *, it informs the 3rd party code that the system is ready and starts the system UI (line 870), or more precise, SystemUIService in the com.android.systemui package **.
    • SystemUIService is just an Android application component whose onCreate() method starts/initializes UI components and stores references to the components in the mServices[] array of SystemUI type. The 1st element (mServices[0]) is either the status bar or system bar (status + nav bar).
    • BaseStatusBar, the implementation of the abstract SystemUI class, does some UI stuff (like adding views to WindowManager etc.). Additionally it declares a range of abstract UI-related methods (e.g. createAndAddWindows()) to be implemented by subclasses, e.g. PhoneStatusBar.
    • The status bar and navigation bar aren't composed of a single view. Such subclasses of BaseStatusBar as PhoneStatusBar, TabletStatusBar etc. *** deal with multiple classes basically subclassed from View whose drawing (so does status bar's drawing) takes place in the onDraw() method.
    • Important note: on system boot the status bar (and software navigation bar) won't be visible until the launcher Activity's (the one with android.intent.category.HOME) onResume() method returns (and bootanimation exits) despite the fact all the views the status bar is composed of have already been laid out.

    AOSP:
    * frameworks/base/services/java/com/android/server/
    ** frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIService.java
    *** frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/