Skip to content

Commit 437a0fb

Browse files
Craig MautnerAndroid (Google) Code Review
authored andcommitted
Merge "Introduce multiple displays with DisplayContent." into jb-mr1-dev
2 parents a7ce155 + 59c0097 commit 437a0fb

File tree

15 files changed

+822
-479
lines changed

15 files changed

+822
-479
lines changed

cmds/am/src/com/android/commands/am/Am.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import android.os.ServiceManager;
3939
import android.os.SystemProperties;
4040
import android.util.AndroidException;
41+
import android.view.Display;
4142
import android.view.IWindowManager;
4243

4344
import java.io.BufferedReader;
@@ -1117,9 +1118,10 @@ private void runDisplaySize() throws Exception {
11171118

11181119
try {
11191120
if (m >= 0 && n >= 0) {
1120-
wm.setForcedDisplaySize(m, n);
1121+
// TODO(multidisplay): For now Configuration only applies to main screen.
1122+
wm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, m, n);
11211123
} else {
1122-
wm.clearForcedDisplaySize();
1124+
wm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
11231125
}
11241126
} catch (RemoteException e) {
11251127
}

core/java/android/view/IWindowManager.aidl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ interface IWindowManager
5757
in IInputContext inputContext);
5858
boolean inputMethodClientHasFocus(IInputMethodClient client);
5959

60-
void setForcedDisplaySize(int longDimen, int shortDimen);
61-
void clearForcedDisplaySize();
60+
void setForcedDisplaySize(int displayId, int longDimen, int shortDimen);
61+
void clearForcedDisplaySize(int displayId);
6262

6363
// Is the device configured to have a full system bar for larger screens?
6464
boolean hasSystemNavBar();
@@ -184,7 +184,7 @@ interface IWindowManager
184184
/**
185185
* Create a screenshot of the applications currently displayed.
186186
*/
187-
Bitmap screenshotApplications(IBinder appToken, int maxWidth, int maxHeight);
187+
Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight);
188188

189189
/**
190190
* Called by the status bar to notify Views of changes to System UI visiblity.

services/java/com/android/server/SystemServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import android.util.EventLog;
4343
import android.util.Log;
4444
import android.util.Slog;
45+
import android.view.Display;
4546
import android.view.WindowManager;
4647

4748
import com.android.internal.os.BinderInternal;

services/java/com/android/server/am/ActivityStack.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import android.util.EventLog;
6060
import android.util.Log;
6161
import android.util.Slog;
62+
import android.view.Display;
6263
import android.view.WindowManagerPolicy;
6364

6465
import java.io.IOException;
@@ -902,7 +903,7 @@ void checkReadyForSleepLocked() {
902903
mService.notifyAll();
903904
}
904905
}
905-
906+
906907
public final Bitmap screenshotActivities(ActivityRecord who) {
907908
if (who.noDisplay) {
908909
return null;
@@ -919,7 +920,8 @@ public final Bitmap screenshotActivities(ActivityRecord who) {
919920
}
920921

921922
if (w > 0) {
922-
return mService.mWindowManager.screenshotApplications(who.appToken, w, h);
923+
return mService.mWindowManager.screenshotApplications(who.appToken,
924+
Display.DEFAULT_DISPLAY, w, h);
923925
}
924926
return null;
925927
}

services/java/com/android/server/am/ProcessList.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import android.graphics.Point;
2626
import android.util.Slog;
27+
import android.view.Display;
2728

2829
/**
2930
* Activity manager code dealing with processes.
@@ -146,7 +147,7 @@ class ProcessList {
146147
void applyDisplaySize(WindowManagerService wm) {
147148
if (!mHaveDisplaySize) {
148149
Point p = new Point();
149-
wm.getInitialDisplaySize(p);
150+
wm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, p);
150151
if (p.x != 0 && p.y != 0) {
151152
updateOomLevels(p.x, p.y, true);
152153
mHaveDisplaySize = true;

services/java/com/android/server/input/InputWindowHandle.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,16 @@ public final class InputWindowHandle {
8787
// Window input features.
8888
public int inputFeatures;
8989

90+
// Display this input is on.
91+
public final int displayId;
92+
9093
private native void nativeDispose();
9194

9295
public InputWindowHandle(InputApplicationHandle inputApplicationHandle,
93-
Object windowState) {
96+
Object windowState, int displayId) {
9497
this.inputApplicationHandle = inputApplicationHandle;
9598
this.windowState = windowState;
99+
this.displayId = displayId;
96100
}
97101

98102
@Override
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
21+
import java.io.PrintWriter;
22+
import java.util.ArrayList;
23+
24+
class DisplayContentList extends ArrayList<DisplayContent> {
25+
}
26+
27+
/**
28+
* Utility class for keeping track of the WindowStates and other pertinent contents of a
29+
* particular Display.
30+
*
31+
* IMPORTANT: No method from this class should ever be used without holding
32+
* WindowManagerService.mWindowMap.
33+
*/
34+
class DisplayContent {
35+
36+
/** Unique identifier of this stack. */
37+
private final int mDisplayId;
38+
39+
/** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element
40+
* from mDisplayWindows; */
41+
private WindowList mWindows = new WindowList();
42+
43+
44+
// 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;
57+
int mBaseDisplayWidth = 0;
58+
int mBaseDisplayHeight = 0;
59+
final DisplayInfo mDisplayInfo = new DisplayInfo();
60+
61+
DisplayContent(final int displayId) {
62+
mDisplayId = displayId;
63+
}
64+
65+
int getDisplayId() {
66+
return mDisplayId;
67+
}
68+
69+
WindowList getWindowList() {
70+
return mWindows;
71+
}
72+
73+
DisplayInfo getDisplayInfo() {
74+
return mDisplayInfo;
75+
}
76+
77+
public void dump(PrintWriter pw) {
78+
pw.print(" Display: mDisplayId="); pw.println(mDisplayId);
79+
pw.print(" init="); pw.print(mInitialDisplayWidth); pw.print("x");
80+
pw.print(mInitialDisplayHeight);
81+
if (mInitialDisplayWidth != mBaseDisplayWidth
82+
|| mInitialDisplayHeight != mBaseDisplayHeight) {
83+
pw.print(" base=");
84+
pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight);
85+
}
86+
if (mInitialDisplayWidth != mDisplayInfo.logicalWidth
87+
|| mInitialDisplayHeight != mDisplayInfo.logicalHeight) {
88+
pw.print(" init="); pw.print(mInitialDisplayWidth);
89+
pw.print("x"); pw.print(mInitialDisplayHeight);
90+
}
91+
pw.print(" cur=");
92+
pw.print(mDisplayInfo.logicalWidth);
93+
pw.print("x"); pw.print(mDisplayInfo.logicalHeight);
94+
pw.print(" app=");
95+
pw.print(mDisplayInfo.appWidth);
96+
pw.print("x"); pw.print(mDisplayInfo.appHeight);
97+
pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth);
98+
pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
99+
pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
100+
pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
101+
pw.println();
102+
}
103+
}

services/java/com/android/server/wm/DragState.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.os.Process;
3030
import android.os.RemoteException;
3131
import android.util.Slog;
32+
import android.view.DisplayInfo;
3233
import android.view.DragEvent;
3334
import android.view.InputChannel;
3435
import android.view.Surface;
@@ -58,6 +59,7 @@ class DragState {
5859
WindowState mTargetWindow;
5960
ArrayList<WindowState> mNotifiedWindows;
6061
boolean mDragInProgress;
62+
DisplayContent mDisplayContent;
6163

6264
private final Region mTmpRegion = new Region();
6365

@@ -69,6 +71,12 @@ class DragState {
6971
mFlags = flags;
7072
mLocalWin = localWin;
7173
mNotifiedWindows = new ArrayList<WindowState>();
74+
WindowState win = service.mWindowMap.get(token);
75+
if (win != null) {
76+
mDisplayContent = win.mDisplayContent;
77+
} else {
78+
Slog.e(WindowManagerService.TAG, "No window associated with token");
79+
}
7280
}
7381

7482
void reset() {
@@ -101,7 +109,8 @@ void register() {
101109
mDragApplicationHandle.dispatchingTimeoutNanos =
102110
WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
103111

104-
mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null);
112+
mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null,
113+
mDisplayContent.getDisplayId());
105114
mDragWindowHandle.name = "drag";
106115
mDragWindowHandle.inputChannel = mServerChannel;
107116
mDragWindowHandle.layer = getDragLayerLw();
@@ -125,8 +134,9 @@ void register() {
125134
// The drag window covers the entire display
126135
mDragWindowHandle.frameLeft = 0;
127136
mDragWindowHandle.frameTop = 0;
128-
mDragWindowHandle.frameRight = mService.mDisplayInfo.logicalWidth;
129-
mDragWindowHandle.frameBottom = mService.mDisplayInfo.logicalHeight;
137+
DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
138+
mDragWindowHandle.frameRight = displayInfo.logicalWidth;
139+
mDragWindowHandle.frameBottom = displayInfo.logicalHeight;
130140

131141
// Pause rotations before a drag.
132142
if (WindowManagerService.DEBUG_ORIENTATION) {
@@ -179,9 +189,10 @@ void broadcastDragStartedLw(final float touchX, final float touchY) {
179189
Slog.d(WindowManagerService.TAG, "broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")");
180190
}
181191

182-
final int N = mService.mWindows.size();
192+
final WindowList windows = mDisplayContent.getWindowList();
193+
final int N = windows.size();
183194
for (int i = 0; i < N; i++) {
184-
sendDragStartedLw(mService.mWindows.get(i), touchX, touchY, mDataDescription);
195+
sendDragStartedLw(windows.get(i), touchX, touchY, mDataDescription);
185196
}
186197
}
187198

@@ -380,7 +391,8 @@ private WindowState getTouchedWinAtPointLw(float xf, float yf) {
380391
WindowState touchedWin = null;
381392
final int x = (int) xf;
382393
final int y = (int) yf;
383-
final ArrayList<WindowState> windows = mService.mWindows;
394+
395+
final WindowList windows = mDisplayContent.getWindowList();
384396
final int N = windows.size();
385397
for (int i = N - 1; i >= 0; i--) {
386398
WindowState child = windows.get(i);

services/java/com/android/server/wm/FakeWindowImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.os.Looper;
2323
import android.os.Process;
2424
import android.util.Slog;
25+
import android.view.Display;
2526
import android.view.InputChannel;
2627
import android.view.InputEventReceiver;
2728
import android.view.InputQueue;
@@ -56,7 +57,7 @@ public FakeWindowImpl(WindowManagerService service,
5657
mApplicationHandle.dispatchingTimeoutNanos =
5758
WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
5859

59-
mWindowHandle = new InputWindowHandle(mApplicationHandle, null);
60+
mWindowHandle = new InputWindowHandle(mApplicationHandle, null, Display.DEFAULT_DISPLAY);
6061
mWindowHandle.name = name;
6162
mWindowHandle.inputChannel = mServerChannel;
6263
mWindowLayer = getLayerLw(windowType);

services/java/com/android/server/wm/InputMonitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ public void updateInputWindowsLw(boolean force) {
201201
// As an optimization, we could try to prune the list of windows but this turns
202202
// out to be difficult because only the native code knows for sure which window
203203
// currently has touch focus.
204-
final ArrayList<WindowState> windows = mService.mWindows;
205204
final WindowStateAnimator universeBackground = mService.mAnimator.mUniverseBackground;
206205
final int aboveUniverseLayer = mService.mAnimator.mAboveUniverseLayer;
207206
boolean addedUniverse = false;
@@ -226,8 +225,9 @@ public void updateInputWindowsLw(boolean force) {
226225
addInputWindowHandleLw(mService.mFakeWindows.get(i).mWindowHandle);
227226
}
228227

229-
final int N = windows.size();
230-
for (int i = N - 1; i >= 0; i--) {
228+
// TODO(multidisplay): Input only occurs on the default display.
229+
final WindowList windows = mService.getDefaultWindowList();
230+
for (int i = windows.size() - 1; i >= 0; i--) {
231231
final WindowState child = windows.get(i);
232232
final InputChannel inputChannel = child.mInputChannel;
233233
final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;

0 commit comments

Comments
 (0)