blob: 3898ebcd447b7e33baadfc4dc83b57afffa2d815 [file] [log] [blame]
Craig Mautner59c00972012-07-30 12:10:24 -07001/*
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
17package com.android.server.wm;
18
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -070019import android.os.RemoteCallbackList;
Craig Mautnerb47bbc32012-08-22 17:41:48 -070020import android.view.Display;
Craig Mautner59c00972012-07-30 12:10:24 -070021import android.view.DisplayInfo;
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -070022import android.view.IDisplayContentChangeListener;
Craig Mautner59c00972012-07-30 12:10:24 -070023
24import java.io.PrintWriter;
25import java.util.ArrayList;
26
27class DisplayContentList extends ArrayList<DisplayContent> {
28}
29
30/**
31 * Utility class for keeping track of the WindowStates and other pertinent contents of a
32 * particular Display.
33 *
34 * IMPORTANT: No method from this class should ever be used without holding
35 * WindowManagerService.mWindowMap.
36 */
37class DisplayContent {
38
39 /** Unique identifier of this stack. */
40 private final int mDisplayId;
41
42 /** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element
43 * from mDisplayWindows; */
44 private WindowList mWindows = new WindowList();
45
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -070046 // Specification for magnifying the display content.
47 MagnificationSpec mMagnificationSpec;
48
49 // Callback for observing content changes on a display.
50 RemoteCallbackList<IDisplayContentChangeListener> mDisplayContentChangeListeners;
Craig Mautner59c00972012-07-30 12:10:24 -070051
52 // This protects the following display size properties, so that
53 // getDisplaySize() doesn't need to acquire the global lock. This is
54 // needed because the window manager sometimes needs to use ActivityThread
55 // while it has its global state locked (for example to load animation
56 // resources), but the ActivityThread also needs get the current display
57 // size sometimes when it has its package lock held.
58 //
59 // These will only be modified with both mWindowMap and mDisplaySizeLock
60 // held (in that order) so the window manager doesn't need to acquire this
61 // lock when needing these values in its normal operation.
62 final Object mDisplaySizeLock = new Object();
63 int mInitialDisplayWidth = 0;
64 int mInitialDisplayHeight = 0;
Dianne Hackborndde331c2012-08-03 14:01:57 -070065 int mInitialDisplayDensity = 0;
Craig Mautner59c00972012-07-30 12:10:24 -070066 int mBaseDisplayWidth = 0;
67 int mBaseDisplayHeight = 0;
Dianne Hackborndde331c2012-08-03 14:01:57 -070068 int mBaseDisplayDensity = 0;
Craig Mautner59c00972012-07-30 12:10:24 -070069 final DisplayInfo mDisplayInfo = new DisplayInfo();
Craig Mautnerb47bbc32012-08-22 17:41:48 -070070 final Display mDisplay;
Craig Mautner59c00972012-07-30 12:10:24 -070071
Craig Mautner39834192012-09-02 07:47:24 -070072 // Accessed directly by all users.
73 boolean layoutNeeded;
Craig Mautner76a71652012-09-03 23:23:58 -070074 int pendingLayoutChanges;
Craig Mautner69b08182012-09-05 13:07:13 -070075 final boolean isDefaultDisplay;
Craig Mautner39834192012-09-02 07:47:24 -070076
Craig Mautnerb47bbc32012-08-22 17:41:48 -070077 DisplayContent(Display display) {
78 mDisplay = display;
79 mDisplayId = display.getDisplayId();
80 display.getDisplayInfo(mDisplayInfo);
Craig Mautner69b08182012-09-05 13:07:13 -070081 isDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY;
Craig Mautner59c00972012-07-30 12:10:24 -070082 }
83
84 int getDisplayId() {
85 return mDisplayId;
86 }
87
88 WindowList getWindowList() {
89 return mWindows;
90 }
91
Craig Mautnerb47bbc32012-08-22 17:41:48 -070092 Display getDisplay() {
93 return mDisplay;
94 }
95
Craig Mautner59c00972012-07-30 12:10:24 -070096 DisplayInfo getDisplayInfo() {
97 return mDisplayInfo;
98 }
99
Craig Mautner722285e2012-09-07 13:55:58 -0700100 public void updateDisplayInfo() {
101 mDisplay.getDisplayInfo(mDisplayInfo);
102 }
103
Craig Mautnera91f9e22012-09-14 16:22:08 -0700104 public void dump(String prefix, PrintWriter pw) {
105 pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId);
106 final String subPrefix = " " + prefix;
107 pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x");
108 pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity);
109 pw.print("dpi");
110 if (mInitialDisplayWidth != mBaseDisplayWidth
111 || mInitialDisplayHeight != mBaseDisplayHeight
112 || mInitialDisplayDensity != mBaseDisplayDensity) {
113 pw.print(" base=");
114 pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight);
115 pw.print(" "); pw.print(mBaseDisplayDensity); pw.print("dpi");
116 }
117 pw.print(" cur=");
118 pw.print(mDisplayInfo.logicalWidth);
119 pw.print("x"); pw.print(mDisplayInfo.logicalHeight);
120 pw.print(" app=");
121 pw.print(mDisplayInfo.appWidth);
122 pw.print("x"); pw.print(mDisplayInfo.appHeight);
123 pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth);
124 pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
125 pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
126 pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
127 pw.print(subPrefix); pw.print("layoutNeeded="); pw.print(layoutNeeded);
Dianne Hackborn5b329e82012-09-14 11:54:12 -0700128 if (mMagnificationSpec != null) {
Craig Mautnera91f9e22012-09-14 16:22:08 -0700129 pw.print(" mMagnificationSpec="); pw.print(mMagnificationSpec);
Dianne Hackborn5b329e82012-09-14 11:54:12 -0700130 }
Craig Mautner59c00972012-07-30 12:10:24 -0700131 pw.println();
132 }
133}