Skip to content

Commit 848c2dc

Browse files
author
Jeff Brown
committed
Stub out display manager service implementation.
Reverting to the previous stub as the display adapter registration and the logical to physical mapping is not at all what we are going to need moving forward. Fixed up the service initialization order so that the display manager service has a context from the start. Change-Id: I717f2f1099c7a77180ef207c371ec8329258850a
1 parent 82d53ce commit 848c2dc

File tree

9 files changed

+148
-251
lines changed

9 files changed

+148
-251
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,10 +1553,20 @@ DisplayMetrics getDisplayMetricsLocked(CompatibilityInfo ci, boolean forceUpdate
15531553
if (dm != null && !forceUpdate) {
15541554
return dm;
15551555
}
1556+
1557+
DisplayManager displayManager = DisplayManager.getInstance();
1558+
if (displayManager == null) {
1559+
// may be null early in system startup
1560+
dm = new DisplayMetrics();
1561+
dm.setToDefaults();
1562+
return dm;
1563+
}
1564+
15561565
if (dm == null) {
15571566
dm = new DisplayMetrics();
15581567
mDisplayMetrics.put(ci, dm);
15591568
}
1569+
15601570
CompatibilityInfoHolder cih = new CompatibilityInfoHolder();
15611571
cih.set(ci);
15621572
Display d = WindowManagerImpl.getDefault().makeCompatible(cih).getDefaultDisplay();

core/java/android/hardware/display/DisplayManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,19 @@ private DisplayManager(IDisplayManager dm) {
4545

4646
/**
4747
* Gets an instance of the display manager.
48-
* @return The display manager instance.
48+
*
49+
* @return The display manager instance, may be null early in system startup
50+
* before the display manager has been fully initialized.
51+
*
4952
* @hide
5053
*/
5154
public static DisplayManager getInstance() {
5255
synchronized (DisplayManager.class) {
5356
if (sInstance == null) {
5457
IBinder b = ServiceManager.getService(Context.DISPLAY_SERVICE);
55-
sInstance = new DisplayManager(IDisplayManager.Stub.asInterface(b));
58+
if (b != null) {
59+
sInstance = new DisplayManager(IDisplayManager.Stub.asInterface(b));
60+
}
5661
}
5762
return sInstance;
5863
}

services/java/com/android/server/SystemServer.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,12 @@ public void run() {
155155
power = new PowerManagerService();
156156
ServiceManager.addService(Context.POWER_SERVICE, power);
157157

158-
Slog.i(TAG, "Display Manager");
159-
display = new DisplayManagerService();
160-
ServiceManager.addService(Context.DISPLAY_SERVICE, display, true);
161-
162158
Slog.i(TAG, "Activity Manager");
163159
context = ActivityManagerService.main(factoryTest);
164-
display.setContext(context);
160+
161+
Slog.i(TAG, "Display Manager");
162+
display = new DisplayManagerService(context);
163+
ServiceManager.addService(Context.DISPLAY_SERVICE, display, true);
165164

166165
Slog.i(TAG, "Telephony Registry");
167166
ServiceManager.addService("telephony.registry", new TelephonyRegistry(context));

services/java/com/android/server/display/DisplayAdapter.java

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,33 @@
1616

1717
package com.android.server.display;
1818

19-
import android.view.Display;
20-
2119
/**
22-
* A display adapter makes a single display devices available to the system.
20+
* A display adapter makes zero or more display devices available to the system
21+
* and provides facilities for discovering when displays are connected or disconnected.
2322
* <p>
2423
* For now, all display adapters are registered in the system server but
2524
* in principle it could be done from other processes.
2625
* </p>
2726
*/
2827
public abstract class DisplayAdapter {
29-
/** The current logical Display assignment for this adapter. Will change if other logical
30-
* display is assigned to this adapter */
31-
private int mDisplayId = Display.NO_DISPLAY;
32-
33-
/** Assign the displayId
34-
* @hide */
35-
public void setDisplayId(int displayId) {
36-
mDisplayId = displayId;
37-
}
38-
39-
/** Retrieve the displayId
40-
* @hide */
41-
public int getDisplayId() {
42-
return mDisplayId;
43-
}
44-
4528
/**
46-
* Gets the display adapter name.
29+
* Gets the display adapter name for debugging purposes.
30+
*
4731
* @return The display adapter name.
4832
*/
4933
public abstract String getName();
5034

51-
// TODO: dynamically register display devices
52-
public abstract DisplayDevice getDisplayDevice();
35+
/**
36+
* Registers the display adapter with the display manager.
37+
* The display adapter should register any built-in display devices now.
38+
* Other display devices can be registered dynamically later.
39+
*
40+
* @param listener The listener for callbacks.
41+
*/
42+
public abstract void register(Listener listener);
43+
44+
public interface Listener {
45+
public void onDisplayDeviceAdded(DisplayDevice device);
46+
public void onDisplayDeviceRemoved(DisplayDevice device);
47+
}
5348
}

services/java/com/android/server/display/DisplayDevice.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@
1818

1919
/**
2020
* Represents a physical display device such as the built-in display
21-
* or an external monitor.
21+
* an external monitor, or a WiFi display.
2222
*/
2323
public abstract class DisplayDevice {
24+
/**
25+
* Gets the display adapter that makes the display device available.
26+
*
27+
* @return The display adapter.
28+
*/
29+
public abstract DisplayAdapter getAdapter();
30+
31+
/**
32+
* Gets information about the display device.
33+
*
34+
* @param outInfo The object to populate with the information.
35+
*/
2436
public abstract void getInfo(DisplayDeviceInfo outInfo);
2537
}

services/java/com/android/server/display/DisplayDeviceInfo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
* Describes the characteristics of a physical display device.
2121
*/
2222
public final class DisplayDeviceInfo {
23+
/**
24+
* Gets the name of the display device, which may be derived from
25+
* EDID or other sources. The name may be displayed to the user.
26+
*/
27+
public String name;
28+
2329
/**
2430
* The width of the display in its natural orientation, in pixels.
2531
* This value is not affected by display rotation.
@@ -38,6 +44,7 @@ public final class DisplayDeviceInfo {
3844
public float yDpi;
3945

4046
public void copyFrom(DisplayDeviceInfo other) {
47+
name = other.name;
4148
width = other.width;
4249
height = other.height;
4350
refreshRate = other.refreshRate;
@@ -46,9 +53,10 @@ public void copyFrom(DisplayDeviceInfo other) {
4653
yDpi = other.yDpi;
4754
}
4855

56+
// For debugging purposes
4957
@Override
5058
public String toString() {
51-
return width + " x " + height + ", " + refreshRate + " fps, "
59+
return "\"" + name + "\": " + width + " x " + height + ", " + refreshRate + " fps, "
5260
+ "density " + densityDpi + ", " + xDpi + " x " + yDpi + " dpi";
5361
}
5462
}

0 commit comments

Comments
 (0)