summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware/display/DisplayManager.java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-07-23 19:26:30 -0700
committerJeff Brown <jeffbrown@google.com>2012-07-25 18:56:16 -0700
commitfa25bf5382467b1018bd9af7f1cb30a23d7d59f7 (patch)
tree2b65e9c19319112d1873db55a02303a43d68547a /core/java/android/hardware/display/DisplayManager.java
parentbbcb123d4923b0c2f36af7b2ade82f5d7832357d (diff)
downloadframeworks_base-fa25bf5382467b1018bd9af7f1cb30a23d7d59f7.zip
frameworks_base-fa25bf5382467b1018bd9af7f1cb30a23d7d59f7.tar.gz
frameworks_base-fa25bf5382467b1018bd9af7f1cb30a23d7d59f7.tar.bz2
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
Diffstat (limited to 'core/java/android/hardware/display/DisplayManager.java')
-rw-r--r--core/java/android/hardware/display/DisplayManager.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java
new file mode 100644
index 0000000..13a2db4
--- /dev/null
+++ b/core/java/android/hardware/display/DisplayManager.java
@@ -0,0 +1,76 @@
+/*
+ * 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 android.hardware.display;
+
+import android.content.Context;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+import android.view.DisplayInfo;
+
+/**
+ * Manages the properties, media routing and power state of attached displays.
+ * <p>
+ * Get an instance of this class by calling
+ * {@link android.content.Context#getSystemService(java.lang.String)
+ * Context.getSystemService()} with the argument
+ * {@link android.content.Context#DISPLAY_SERVICE}.
+ * </p>
+ */
+public final class DisplayManager {
+ private static final String TAG = "DisplayManager";
+
+ private static DisplayManager sInstance;
+
+ private final IDisplayManager mDm;
+
+ private DisplayManager(IDisplayManager dm) {
+ mDm = dm;
+ }
+
+ /**
+ * Gets an instance of the display manager.
+ * @return The display manager instance.
+ * @hide
+ */
+ public static DisplayManager getInstance() {
+ synchronized (DisplayManager.class) {
+ if (sInstance == null) {
+ IBinder b = ServiceManager.getService(Context.DISPLAY_SERVICE);
+ sInstance = new DisplayManager(IDisplayManager.Stub.asInterface(b));
+ }
+ return sInstance;
+ }
+ }
+
+ /**
+ * Get information about a particular logical display.
+ *
+ * @param displayId The logical display id.
+ * @param outInfo A structure to populate with the display info.
+ * @return True if the logical display exists, false otherwise.
+ */
+ public boolean getDisplayInfo(int displayId, DisplayInfo outInfo) {
+ try {
+ return mDm.getDisplayInfo(displayId, outInfo);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Could not get display information from display manager.", ex);
+ return false;
+ }
+ }
+}