Skip to content

Commit fa25bf5

Browse files
author
Jeff Brown
committed
Add display manager skeleton.
The purpose of this change is to remove direct reliance on SurfaceFlinger for describing the size and characteristics of displays. This patch also starts to make a distinction between logical displays and physical display devices. Currently, the window manager owns the concept of a logical display whereas the new display manager owns the concept of a physical display device. Change-Id: I7e0761f83f033be6c06fd1041280c21500bcabc0
1 parent bbcb123 commit fa25bf5

33 files changed

+1129
-655
lines changed

Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ LOCAL_SRC_FILES += \
114114
core/java/android/content/pm/IPackageStatsObserver.aidl \
115115
core/java/android/database/IContentObserver.aidl \
116116
core/java/android/hardware/ISerialManager.aidl \
117+
core/java/android/hardware/display/IDisplayManager.aidl \
117118
core/java/android/hardware/input/IInputManager.aidl \
118119
core/java/android/hardware/input/IInputDevicesChangedListener.aidl \
119120
core/java/android/hardware/usb/IUsbManager.aidl \

api/16.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22892,7 +22892,7 @@ package android.view {
2289222892
method protected void onApplyThemeResource(android.content.res.Resources.Theme, int, boolean);
2289322893
}
2289422894

22895-
public class Display {
22895+
public final class Display {
2289622896
method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
2289722897
method public int getDisplayId();
2289822898
method public deprecated int getHeight();

api/current.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5355,6 +5355,7 @@ package android.content {
53555355
field public static final int CONTEXT_INCLUDE_CODE = 1; // 0x1
53565356
field public static final int CONTEXT_RESTRICTED = 4; // 0x4
53575357
field public static final java.lang.String DEVICE_POLICY_SERVICE = "device_policy";
5358+
field public static final java.lang.String DISPLAY_SERVICE = "display";
53585359
field public static final java.lang.String DOWNLOAD_SERVICE = "download";
53595360
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
53605361
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
@@ -9952,6 +9953,13 @@ package android.hardware {
99529953

99539954
}
99549955

9956+
package android.hardware.display {
9957+
9958+
public final class DisplayManager {
9959+
}
9960+
9961+
}
9962+
99559963
package android.hardware.input {
99569964

99579965
public final class InputManager {
@@ -23120,13 +23128,15 @@ package android.view {
2312023128
method protected void onApplyThemeResource(android.content.res.Resources.Theme, int, boolean);
2312123129
}
2312223130

23123-
public class Display {
23131+
public final class Display {
2312423132
method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
2312523133
method public int getDisplayId();
2312623134
method public deprecated int getHeight();
2312723135
method public void getMetrics(android.util.DisplayMetrics);
2312823136
method public deprecated int getOrientation();
23129-
method public int getPixelFormat();
23137+
method public deprecated int getPixelFormat();
23138+
method public void getRealMetrics(android.util.DisplayMetrics);
23139+
method public void getRealSize(android.graphics.Point);
2313023140
method public void getRectSize(android.graphics.Rect);
2313123141
method public float getRefreshRate();
2313223142
method public int getRotation();

core/java/android/app/ContextImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import android.hardware.SensorManager;
4848
import android.hardware.SerialManager;
4949
import android.hardware.SystemSensorManager;
50+
import android.hardware.display.DisplayManager;
5051
import android.hardware.input.IInputManager;
5152
import android.hardware.input.InputManager;
5253
import android.hardware.usb.IUsbManager;
@@ -343,6 +344,11 @@ public Object createStaticService() {
343344
return InputManager.getInstance();
344345
}});
345346

347+
registerService(DISPLAY_SERVICE, new StaticServiceFetcher() {
348+
public Object createStaticService() {
349+
return DisplayManager.getInstance();
350+
}});
351+
346352
registerService(INPUT_METHOD_SERVICE, new ServiceFetcher() {
347353
public Object createService(ContextImpl ctx) {
348354
return InputMethodManager.getInstance(ctx);

core/java/android/content/Context.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,15 @@ public abstract boolean startInstrumentation(ComponentName className,
19531953
*/
19541954
public static final String INPUT_SERVICE = "input";
19551955

1956+
/**
1957+
* Use with {@link #getSystemService} to retrieve a
1958+
* {@link android.hardware.display.DisplayManager} for interacting with display devices.
1959+
*
1960+
* @see #getSystemService
1961+
* @see android.hardware.display.DisplayManager
1962+
*/
1963+
public static final String DISPLAY_SERVICE = "display";
1964+
19561965
/**
19571966
* Use with {@link #getSystemService} to retrieve a
19581967
* {@link android.os.SchedulingPolicyService} for managing scheduling policy.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.display;
18+
19+
import android.content.Context;
20+
import android.os.IBinder;
21+
import android.os.RemoteException;
22+
import android.os.ServiceManager;
23+
import android.util.Log;
24+
import android.view.DisplayInfo;
25+
26+
/**
27+
* Manages the properties, media routing and power state of attached displays.
28+
* <p>
29+
* Get an instance of this class by calling
30+
* {@link android.content.Context#getSystemService(java.lang.String)
31+
* Context.getSystemService()} with the argument
32+
* {@link android.content.Context#DISPLAY_SERVICE}.
33+
* </p>
34+
*/
35+
public final class DisplayManager {
36+
private static final String TAG = "DisplayManager";
37+
38+
private static DisplayManager sInstance;
39+
40+
private final IDisplayManager mDm;
41+
42+
private DisplayManager(IDisplayManager dm) {
43+
mDm = dm;
44+
}
45+
46+
/**
47+
* Gets an instance of the display manager.
48+
* @return The display manager instance.
49+
* @hide
50+
*/
51+
public static DisplayManager getInstance() {
52+
synchronized (DisplayManager.class) {
53+
if (sInstance == null) {
54+
IBinder b = ServiceManager.getService(Context.DISPLAY_SERVICE);
55+
sInstance = new DisplayManager(IDisplayManager.Stub.asInterface(b));
56+
}
57+
return sInstance;
58+
}
59+
}
60+
61+
/**
62+
* Get information about a particular logical display.
63+
*
64+
* @param displayId The logical display id.
65+
* @param outInfo A structure to populate with the display info.
66+
* @return True if the logical display exists, false otherwise.
67+
*/
68+
public boolean getDisplayInfo(int displayId, DisplayInfo outInfo) {
69+
try {
70+
return mDm.getDisplayInfo(displayId, outInfo);
71+
} catch (RemoteException ex) {
72+
Log.e(TAG, "Could not get display information from display manager.", ex);
73+
return false;
74+
}
75+
}
76+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.display;
18+
19+
import android.view.DisplayInfo;
20+
21+
/** @hide */
22+
interface IDisplayManager {
23+
boolean getDisplayInfo(int displayId, out DisplayInfo outInfo);
24+
}

0 commit comments

Comments
 (0)