Split the DisplayManager into two parts. One part is bound to a Context and takes care of Display compatibility and caching Display objects on behalf of the Context. The other part is global and takes care of communicating with the DisplayManagerService, handling callbacks, and caching DisplayInfo objects on behalf of the process. Implemented support for enumerating Displays and getting callbacks when displays are added, removed or changed. Elaborated the roles of DisplayManagerService, DisplayAdapter, and DisplayDevice. We now support having multiple display adapters registered, each of which can register multiple display devices and configure them dynamically. Added an OverlayDisplayAdapter which is used to simulate secondary displays by means of overlay windows. Different configurations of overlays can be selected using a new setting in the Developer Settings panel. The overlays can be repositioned and resized by the user for convenience. At the moment, all displays are mirrors of display 0 and no display transformations are applied. This will be improved in future patches. Refactored the way that the window manager creates its threads. The OverlayDisplayAdapter needs to be able to use hardware acceleration so it must share the same UI thread as the Keyguard and window manager policy. We now handle this explicitly as part of starting up the system server. This puts us in a better position to consider how we might want to share (or not share) Loopers among components. Overlay displays are disabled when in safe mode or in only-core mode to reduce the number of dependencies started in these modes. Change-Id: Ic2a661d5448dde01b095ab150697cb6791d69bb5
61 lines
2.0 KiB
Java
61 lines
2.0 KiB
Java
/*
|
|
* Copyright (C) 2012 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.server.display;
|
|
|
|
import android.content.Context;
|
|
import android.util.DisplayMetrics;
|
|
|
|
/**
|
|
* Provides a fake default display for headless systems.
|
|
* <p>
|
|
* Display adapters are not thread-safe and must only be accessed
|
|
* on the display manager service's handler thread.
|
|
* </p>
|
|
*/
|
|
public final class HeadlessDisplayAdapter extends DisplayAdapter {
|
|
private static final String TAG = "HeadlessDisplayAdapter";
|
|
|
|
public HeadlessDisplayAdapter(Context context) {
|
|
super(context, TAG);
|
|
}
|
|
|
|
@Override
|
|
protected void onRegister() {
|
|
sendDisplayDeviceEvent(new HeadlessDisplayDevice(), DISPLAY_DEVICE_EVENT_ADDED);
|
|
}
|
|
|
|
private final class HeadlessDisplayDevice extends DisplayDevice {
|
|
public HeadlessDisplayDevice() {
|
|
super(HeadlessDisplayAdapter.this, null);
|
|
}
|
|
|
|
@Override
|
|
public void getInfo(DisplayDeviceInfo outInfo) {
|
|
outInfo.name = getContext().getResources().getString(
|
|
com.android.internal.R.string.display_manager_built_in_display_name);
|
|
outInfo.width = 640;
|
|
outInfo.height = 480;
|
|
outInfo.refreshRate = 60;
|
|
outInfo.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
|
|
outInfo.xDpi = 160;
|
|
outInfo.yDpi = 160;
|
|
outInfo.flags = DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY
|
|
| DisplayDeviceInfo.FLAG_SECURE;
|
|
}
|
|
}
|
|
}
|