Skip to content

Commit 3983419

Browse files
author
Craig Mautner
committed
Minor refactors.
- Refactor DragState to take Display instead of DisplayContent. - Rename xxxAnimationLw methods in WindowManagerPolicy to xxxPostLayout to reflect animation refactoring. Change-Id: I502f2aa45a699ad395a249a12abf9843294623f0
1 parent ce20a45 commit 3983419

File tree

6 files changed

+43
-32
lines changed

6 files changed

+43
-32
lines changed

core/java/android/view/WindowManagerPolicy.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -827,32 +827,33 @@ public void layoutWindowLw(WindowState win,
827827
static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
828828

829829
/**
830-
* Called when animation of the windows is about to start.
830+
* Called following layout of all windows before each window has policy applied.
831831
*
832832
* @param displayWidth The current full width of the screen.
833833
* @param displayHeight The current full height of the screen.
834834
*/
835-
public void beginAnimationLw(int displayWidth, int displayHeight);
835+
public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
836836

837837
/**
838-
* Called each time a window is animating.
838+
* Called following layout of all window to apply policy to each window.
839839
*
840840
* @param win The window being positioned.
841841
* @param attrs The LayoutParams of the window.
842842
*/
843-
public void animatingWindowLw(WindowState win,
843+
public void applyPostLayoutPolicyLw(WindowState win,
844844
WindowManager.LayoutParams attrs);
845845

846846
/**
847-
* Called when animation of the windows is finished. If in this function you do
848-
* something that may have modified the animation state of another window,
849-
* be sure to return true in order to perform another animation frame.
847+
* Called following layout of all windows and after policy has been applied
848+
* to each window. If in this function you do
849+
* something that may have modified the animation state of another window,
850+
* be sure to return non-zero in order to perform another pass through layout.
850851
*
851852
* @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
852853
* {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
853854
* or {@link #FINISH_LAYOUT_REDO_ANIM}.
854855
*/
855-
public int finishAnimationLw();
856+
public int finishPostLayoutPolicyLw();
856857

857858
/**
858859
* Return true if it is okay to perform animations for an app transition

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,7 +2809,7 @@ public void finishLayoutLw() {
28092809
}
28102810

28112811
/** {@inheritDoc} */
2812-
public void beginAnimationLw(int displayWidth, int displayHeight) {
2812+
public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) {
28132813
mTopFullscreenOpaqueWindowState = null;
28142814
mForceStatusBar = false;
28152815

@@ -2819,7 +2819,7 @@ public void beginAnimationLw(int displayWidth, int displayHeight) {
28192819
}
28202820

28212821
/** {@inheritDoc} */
2822-
public void animatingWindowLw(WindowState win,
2822+
public void applyPostLayoutPolicyLw(WindowState win,
28232823
WindowManager.LayoutParams attrs) {
28242824
if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw="
28252825
+ win.isVisibleOrBehindKeyguardLw());
@@ -2851,7 +2851,7 @@ public void animatingWindowLw(WindowState win,
28512851
}
28522852

28532853
/** {@inheritDoc} */
2854-
public int finishAnimationLw() {
2854+
public int finishPostLayoutPolicyLw() {
28552855
int changes = 0;
28562856
boolean topIsFullscreen = false;
28572857

@@ -2906,10 +2906,11 @@ public int finishAnimationLw() {
29062906

29072907
mTopIsFullscreen = topIsFullscreen;
29082908

2909-
// Hide the key guard if a visible window explicitly specifies that it wants to be displayed
2910-
// when the screen is locked
2909+
// Hide the key guard if a visible window explicitly specifies that it wants to be
2910+
// displayed when the screen is locked.
29112911
if (mKeyguard != null) {
2912-
if (localLOGV) Log.v(TAG, "finishAnimationLw::mHideKeyguard="+mHideLockScreen);
2912+
if (localLOGV) Log.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard="
2913+
+ mHideLockScreen);
29132914
if (mDismissKeyguard && !mKeyguardMediator.isSecure()) {
29142915
if (mKeyguard.hideLw(true)) {
29152916
changes |= FINISH_LAYOUT_REDO_LAYOUT

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class DisplayContent {
6262
final DisplayInfo mDisplayInfo = new DisplayInfo();
6363
final Display mDisplay;
6464

65+
// Accessed directly by all users.
66+
boolean layoutNeeded;
67+
6568
DisplayContent(Display display) {
6669
mDisplay = display;
6770
mDisplayId = display.getDisplayId();
@@ -106,6 +109,7 @@ public void dump(PrintWriter pw) {
106109
pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
107110
pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
108111
pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
112+
pw.print("layoutNeeded="); pw.println(layoutNeeded);
109113
pw.println();
110114
}
111115
}

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323

2424
import android.content.ClipData;
2525
import android.content.ClipDescription;
26+
import android.graphics.Point;
2627
import android.graphics.Region;
2728
import android.os.IBinder;
2829
import android.os.Message;
2930
import android.os.Process;
3031
import android.os.RemoteException;
3132
import android.util.Slog;
32-
import android.view.DisplayInfo;
33+
import android.view.Display;
3334
import android.view.DragEvent;
3435
import android.view.InputChannel;
3536
import android.view.Surface;
@@ -59,7 +60,7 @@ class DragState {
5960
WindowState mTargetWindow;
6061
ArrayList<WindowState> mNotifiedWindows;
6162
boolean mDragInProgress;
62-
DisplayContent mDisplayContent;
63+
Display mDisplay;
6364

6465
private final Region mTmpRegion = new Region();
6566

@@ -87,10 +88,10 @@ void reset() {
8788
}
8889

8990
/**
90-
* @param displayContent The display parameters associated with the window being dragged.
91+
* @param display The Display that the window being dragged is on.
9192
*/
92-
void register(DisplayContent displayContent) {
93-
mDisplayContent = displayContent;
93+
void register(Display display) {
94+
mDisplay = display;
9495
if (WindowManagerService.DEBUG_DRAG) Slog.d(WindowManagerService.TAG, "registering drag input channel");
9596
if (mClientChannel != null) {
9697
Slog.e(WindowManagerService.TAG, "Duplicate register of drag input channel");
@@ -108,7 +109,7 @@ void register(DisplayContent displayContent) {
108109
WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
109110

110111
mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null,
111-
mDisplayContent.getDisplayId());
112+
mDisplay.getDisplayId());
112113
mDragWindowHandle.name = "drag";
113114
mDragWindowHandle.inputChannel = mServerChannel;
114115
mDragWindowHandle.layer = getDragLayerLw();
@@ -132,9 +133,10 @@ void register(DisplayContent displayContent) {
132133
// The drag window covers the entire display
133134
mDragWindowHandle.frameLeft = 0;
134135
mDragWindowHandle.frameTop = 0;
135-
DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
136-
mDragWindowHandle.frameRight = displayInfo.logicalWidth;
137-
mDragWindowHandle.frameBottom = displayInfo.logicalHeight;
136+
Point p = new Point();
137+
mDisplay.getRealSize(p);
138+
mDragWindowHandle.frameRight = p.x;
139+
mDragWindowHandle.frameBottom = p.y;
138140

139141
// Pause rotations before a drag.
140142
if (WindowManagerService.DEBUG_ORIENTATION) {
@@ -187,7 +189,7 @@ void broadcastDragStartedLw(final float touchX, final float touchY) {
187189
Slog.d(WindowManagerService.TAG, "broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")");
188190
}
189191

190-
final WindowList windows = mDisplayContent.getWindowList();
192+
final WindowList windows = mService.getWindowList(mDisplay);
191193
final int N = windows.size();
192194
for (int i = 0; i < N; i++) {
193195
sendDragStartedLw(windows.get(i), touchX, touchY, mDataDescription);
@@ -390,7 +392,7 @@ private WindowState getTouchedWinAtPointLw(float xf, float yf) {
390392
final int x = (int) xf;
391393
final int y = (int) yf;
392394

393-
final WindowList windows = mDisplayContent.getWindowList();
395+
final WindowList windows = mService.getWindowList(mDisplay);
394396
final int N = windows.size();
395397
for (int i = N - 1; i >= 0; i--) {
396398
WindowState child = windows.get(i);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public boolean performDrag(IWindow window, IBinder dragToken,
280280
// !!! FIXME: put all this heavy stuff onto the mH looper, as well as
281281
// the actual drag event dispatch stuff in the dragstate
282282

283-
mService.mDragState.register(callingWin.mDisplayContent);
283+
mService.mDragState.register(callingWin.mDisplayContent.getDisplay());
284284
mService.mInputMonitor.updateInputWindowsLw(true /*force*/);
285285
if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel,
286286
mService.mDragState.mServerChannel)) {

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8301,7 +8301,7 @@ public int handleAppTransitionReadyLocked(WindowList windows) {
83018301

83028302
// This has changed the visibility of windows, so perform
83038303
// a new layout to get them all up-to-date.
8304-
changes |= PhoneWindowManager.FINISH_LAYOUT_REDO_LAYOUT
8304+
changes |= WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT
83058305
| WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
83068306
mLayoutNeeded = true;
83078307

@@ -8627,15 +8627,15 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
86278627
mPendingLayoutChanges = 0;
86288628
if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("loop number " + mLayoutRepeatCount,
86298629
mPendingLayoutChanges);
8630-
mPolicy.beginAnimationLw(dw, dh);
8630+
mPolicy.beginPostLayoutPolicyLw(dw, dh);
86318631
for (i = windows.size() - 1; i >= 0; i--) {
86328632
WindowState w = windows.get(i);
86338633
if (w.mHasSurface) {
8634-
mPolicy.animatingWindowLw(w, w.mAttrs);
8634+
mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs);
86358635
}
86368636
}
8637-
mPendingLayoutChanges |= mPolicy.finishAnimationLw();
8638-
if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after finishAnimationLw",
8637+
mPendingLayoutChanges |= mPolicy.finishPostLayoutPolicyLw();
8638+
if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after finishPostLayoutPolicyLw",
86398639
mPendingLayoutChanges);
86408640
} while (mPendingLayoutChanges != 0);
86418641

@@ -9348,7 +9348,7 @@ private boolean updateFocusedWindowLocked(int mode, boolean updateInputWindows)
93489348
}
93499349
}
93509350

9351-
if ((focusChanged&WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
9351+
if ((focusChanged & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
93529352
// The change in focus caused us to need to do a layout. Okay.
93539353
mLayoutNeeded = true;
93549354
if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
@@ -10393,4 +10393,7 @@ public DisplayInfo getDefaultDisplayInfo() {
1039310393
return getDefaultDisplayContent().getDisplayInfo();
1039410394
}
1039510395

10396+
public WindowList getWindowList(final Display display) {
10397+
return getDisplayContent(display.getDisplayId()).getWindowList();
10398+
}
1039610399
}

0 commit comments

Comments
 (0)