blob: 59e4b0e6f73027c1c01502ca711199b52ecd6795 [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
Craig Mautnerb47bbc32012-08-22 17:41:48 -070019import android.view.Display;
Craig Mautner59c00972012-07-30 12:10:24 -070020import android.view.DisplayInfo;
21
22import java.io.PrintWriter;
23import java.util.ArrayList;
24
25class DisplayContentList extends ArrayList<DisplayContent> {
26}
27
28/**
29 * Utility class for keeping track of the WindowStates and other pertinent contents of a
30 * particular Display.
31 *
32 * IMPORTANT: No method from this class should ever be used without holding
33 * WindowManagerService.mWindowMap.
34 */
35class DisplayContent {
36
37 /** Unique identifier of this stack. */
38 private final int mDisplayId;
39
40 /** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element
41 * from mDisplayWindows; */
42 private WindowList mWindows = new WindowList();
43
Craig Mautner59c00972012-07-30 12:10:24 -070044 // This protects the following display size properties, so that
45 // getDisplaySize() doesn't need to acquire the global lock. This is
46 // needed because the window manager sometimes needs to use ActivityThread
47 // while it has its global state locked (for example to load animation
48 // resources), but the ActivityThread also needs get the current display
49 // size sometimes when it has its package lock held.
50 //
51 // These will only be modified with both mWindowMap and mDisplaySizeLock
52 // held (in that order) so the window manager doesn't need to acquire this
53 // lock when needing these values in its normal operation.
54 final Object mDisplaySizeLock = new Object();
55 int mInitialDisplayWidth = 0;
56 int mInitialDisplayHeight = 0;
Dianne Hackborndde331c2012-08-03 14:01:57 -070057 int mInitialDisplayDensity = 0;
Craig Mautner59c00972012-07-30 12:10:24 -070058 int mBaseDisplayWidth = 0;
59 int mBaseDisplayHeight = 0;
Dianne Hackborndde331c2012-08-03 14:01:57 -070060 int mBaseDisplayDensity = 0;
Craig Mautner2d5618c2012-10-18 13:55:47 -070061 private final DisplayInfo mDisplayInfo = new DisplayInfo();
62 private final Display mDisplay;
Craig Mautner59c00972012-07-30 12:10:24 -070063
Craig Mautner39834192012-09-02 07:47:24 -070064 // Accessed directly by all users.
65 boolean layoutNeeded;
Craig Mautner76a71652012-09-03 23:23:58 -070066 int pendingLayoutChanges;
Craig Mautner69b08182012-09-05 13:07:13 -070067 final boolean isDefaultDisplay;
Craig Mautner39834192012-09-02 07:47:24 -070068
Craig Mautner2d5618c2012-10-18 13:55:47 -070069 /**
70 * @param display May not be null.
71 */
Craig Mautnerb47bbc32012-08-22 17:41:48 -070072 DisplayContent(Display display) {
73 mDisplay = display;
74 mDisplayId = display.getDisplayId();
75 display.getDisplayInfo(mDisplayInfo);
Craig Mautner69b08182012-09-05 13:07:13 -070076 isDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY;
Craig Mautner59c00972012-07-30 12:10:24 -070077 }
78
79 int getDisplayId() {
80 return mDisplayId;
81 }
82
83 WindowList getWindowList() {
84 return mWindows;
85 }
86
Craig Mautnerb47bbc32012-08-22 17:41:48 -070087 Display getDisplay() {
88 return mDisplay;
89 }
90
Craig Mautner59c00972012-07-30 12:10:24 -070091 DisplayInfo getDisplayInfo() {
92 return mDisplayInfo;
93 }
94
Craig Mautner722285e2012-09-07 13:55:58 -070095 public void updateDisplayInfo() {
96 mDisplay.getDisplayInfo(mDisplayInfo);
97 }
98
Craig Mautnera91f9e22012-09-14 16:22:08 -070099 public void dump(String prefix, PrintWriter pw) {
100 pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId);
101 final String subPrefix = " " + prefix;
102 pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x");
103 pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity);
104 pw.print("dpi");
105 if (mInitialDisplayWidth != mBaseDisplayWidth
106 || mInitialDisplayHeight != mBaseDisplayHeight
107 || mInitialDisplayDensity != mBaseDisplayDensity) {
108 pw.print(" base=");
109 pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight);
110 pw.print(" "); pw.print(mBaseDisplayDensity); pw.print("dpi");
111 }
112 pw.print(" cur=");
113 pw.print(mDisplayInfo.logicalWidth);
114 pw.print("x"); pw.print(mDisplayInfo.logicalHeight);
115 pw.print(" app=");
116 pw.print(mDisplayInfo.appWidth);
117 pw.print("x"); pw.print(mDisplayInfo.appHeight);
118 pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth);
119 pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
120 pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
121 pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
Craig Mautner2ad92072013-02-25 16:19:24 -0800122 pw.print(subPrefix); pw.print("layoutNeeded="); pw.print(layoutNeeded);
Craig Mautner59c00972012-07-30 12:10:24 -0700123 pw.println();
124 }
125}