public final class DisplayManagerService extends SystemService
The DisplayManagerService
manages the global lifecycle of displays,
decides how to configure logical displays based on the physical display devices currently
attached, sends notifications to the system and to applications when the state
changes, and so on.
The display manager service relies on a collection of DisplayAdapter
components,
for discovering and configuring physical display devices attached to the system.
There are separate display adapters for each manner that devices are attached:
one display adapter for built-in local displays, one for simulated non-functional
displays when the system is headless, one for simulated overlay displays used for
development, one for wifi displays, etc.
Display adapters are only weakly coupled to the display manager service.
Display adapters communicate changes in display device state to the display manager
service asynchronously via a DisplayAdapter.Listener
registered
by the display manager service. This separation of concerns is important for
two main reasons. First, it neatly encapsulates the responsibilities of these
two classes: display adapters handle individual display devices whereas
the display manager service handles the global state. Second, it eliminates
the potential for deadlocks resulting from asynchronous display device discovery.
Because the display manager may be accessed by multiple threads, the synchronization story gets a little complicated. In particular, the window manager may call into the display manager while holding a surface transaction with the expectation that it can apply changes immediately. Unfortunately, that means we can't just do everything asynchronously (*grump*).
To make this work, all of the objects that belong to the display manager must
use the same lock. We call this lock the synchronization root and it has a unique
type DisplayManagerService.SyncRoot
. Methods that require this lock are
named with the "Locked" suffix.
Where things get tricky is that the display manager is not allowed to make any potentially reentrant calls, especially into the window manager. We generally avoid this by making all potentially reentrant out-calls asynchronous.
Modifier and Type | Class and Description |
---|---|
static class |
DisplayManagerService.SyncRoot
This is the object that everything in the display manager locks on.
|
Modifier and Type | Field and Description |
---|---|
SparseArray<com.android.server.display.DisplayManagerService.CallbackRecord> |
mCallbacks |
boolean |
mOnlyCore |
boolean |
mSafeMode |
PHASE_ACTIVITY_MANAGER_READY, PHASE_BOOT_COMPLETED, PHASE_LOCK_SETTINGS_READY, PHASE_SYSTEM_SERVICES_READY, PHASE_THIRD_PARTY_APPS_CAN_START, PHASE_WAIT_FOR_DEFAULT_DISPLAY
Constructor and Description |
---|
DisplayManagerService(Context context) |
Modifier and Type | Method and Description |
---|---|
void |
onBootPhase(int phase)
Called on each phase of the boot process.
|
void |
onStart()
Called when the dependencies listed in the @Service class-annotation are available
and after the chosen start phase.
|
void |
systemReady(boolean safeMode,
boolean onlyCore)
Called when the system is ready to go.
|
void |
windowManagerAndInputReady() |
getBinderService, getContext, getLocalService, isSafeMode, onCleanupUser, onStartUser, onStopUser, onSwitchUser, onUnlockUser, publishBinderService, publishBinderService, publishLocalService
public boolean mSafeMode
public boolean mOnlyCore
public final SparseArray<com.android.server.display.DisplayManagerService.CallbackRecord> mCallbacks
public DisplayManagerService(Context context)
public void onStart()
SystemService
onStart
in class SystemService
public void onBootPhase(int phase)
SystemService
onBootPhase
in class SystemService
phase
- The current boot phase.public void windowManagerAndInputReady()
public void systemReady(boolean safeMode, boolean onlyCore)