Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 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 com.android.server.wm; |
| 18 | |
| 19 | import android.view.DisplayInfo; |
| 20 | |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 21 | import com.android.server.display.DisplayManagerService; |
| 22 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 23 | import java.io.PrintWriter; |
| 24 | import java.util.ArrayList; |
| 25 | |
| 26 | class DisplayContentList extends ArrayList<DisplayContent> { |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Utility class for keeping track of the WindowStates and other pertinent contents of a |
| 31 | * particular Display. |
| 32 | * |
| 33 | * IMPORTANT: No method from this class should ever be used without holding |
| 34 | * WindowManagerService.mWindowMap. |
| 35 | */ |
| 36 | class DisplayContent { |
| 37 | |
| 38 | /** Unique identifier of this stack. */ |
| 39 | private final int mDisplayId; |
| 40 | |
| 41 | /** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element |
| 42 | * from mDisplayWindows; */ |
| 43 | private WindowList mWindows = new WindowList(); |
| 44 | |
| 45 | |
| 46 | // This protects the following display size properties, so that |
| 47 | // getDisplaySize() doesn't need to acquire the global lock. This is |
| 48 | // needed because the window manager sometimes needs to use ActivityThread |
| 49 | // while it has its global state locked (for example to load animation |
| 50 | // resources), but the ActivityThread also needs get the current display |
| 51 | // size sometimes when it has its package lock held. |
| 52 | // |
| 53 | // These will only be modified with both mWindowMap and mDisplaySizeLock |
| 54 | // held (in that order) so the window manager doesn't need to acquire this |
| 55 | // lock when needing these values in its normal operation. |
| 56 | final Object mDisplaySizeLock = new Object(); |
| 57 | int mInitialDisplayWidth = 0; |
| 58 | int mInitialDisplayHeight = 0; |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame^] | 59 | int mInitialDisplayDensity = 0; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 60 | int mBaseDisplayWidth = 0; |
| 61 | int mBaseDisplayHeight = 0; |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame^] | 62 | int mBaseDisplayDensity = 0; |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 63 | final DisplayManagerService mDisplayManager; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 64 | final DisplayInfo mDisplayInfo = new DisplayInfo(); |
| 65 | |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 66 | DisplayContent(DisplayManagerService displayManager, final int displayId) { |
| 67 | mDisplayManager = displayManager; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 68 | mDisplayId = displayId; |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 69 | displayManager.getDisplayInfo(displayId, mDisplayInfo); |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | int getDisplayId() { |
| 73 | return mDisplayId; |
| 74 | } |
| 75 | |
| 76 | WindowList getWindowList() { |
| 77 | return mWindows; |
| 78 | } |
| 79 | |
| 80 | DisplayInfo getDisplayInfo() { |
| 81 | return mDisplayInfo; |
| 82 | } |
| 83 | |
| 84 | public void dump(PrintWriter pw) { |
| 85 | pw.print(" Display: mDisplayId="); pw.println(mDisplayId); |
| 86 | pw.print(" init="); pw.print(mInitialDisplayWidth); pw.print("x"); |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame^] | 87 | pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity); |
| 88 | pw.print("dpi"); |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 89 | if (mInitialDisplayWidth != mBaseDisplayWidth |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame^] | 90 | || mInitialDisplayHeight != mBaseDisplayHeight |
| 91 | || mInitialDisplayDensity != mBaseDisplayDensity) { |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 92 | pw.print(" base="); |
| 93 | pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight); |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame^] | 94 | pw.print(" "); pw.print(mBaseDisplayDensity); pw.print("dpi"); |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 95 | } |
| 96 | pw.print(" cur="); |
| 97 | pw.print(mDisplayInfo.logicalWidth); |
| 98 | pw.print("x"); pw.print(mDisplayInfo.logicalHeight); |
| 99 | pw.print(" app="); |
| 100 | pw.print(mDisplayInfo.appWidth); |
| 101 | pw.print("x"); pw.print(mDisplayInfo.appHeight); |
| 102 | pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth); |
| 103 | pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight); |
| 104 | pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth); |
| 105 | pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight); |
| 106 | pw.println(); |
| 107 | } |
| 108 | } |