use of android.view.IWindow in project platform_frameworks_base by android.
the class WindowManagerService method addAppWindowToListLocked.
private int addAppWindowToListLocked(final WindowState win) {
final DisplayContent displayContent = win.getDisplayContent();
if (displayContent == null) {
// It doesn't matter this display is going away.
return 0;
}
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
final WindowList windows = displayContent.getWindowList();
WindowList tokenWindowList = getTokenWindowsOnDisplay(token, displayContent);
int tokenWindowsPos = 0;
if (!tokenWindowList.isEmpty()) {
return addAppWindowToTokenListLocked(win, token, windows, tokenWindowList);
}
// No windows from this token on this display
if (localLOGV)
Slog.v(TAG_WM, "Figuring out where to add app window " + client.asBinder() + " (token=" + token + ")");
// Figure out where the window should go, based on the
// order of applications.
WindowState pos = null;
final ArrayList<Task> tasks = displayContent.getTasks();
int taskNdx;
int tokenNdx = -1;
for (taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
for (tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
final AppWindowToken t = tokens.get(tokenNdx);
if (t == token) {
--tokenNdx;
if (tokenNdx < 0) {
--taskNdx;
if (taskNdx >= 0) {
tokenNdx = tasks.get(taskNdx).mAppTokens.size() - 1;
}
}
break;
}
// We haven't reached the token yet; if this token
// is not going to the bottom and has windows on this display, we can
// use it as an anchor for when we do reach the token.
tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
if (!t.sendingToBottom && tokenWindowList.size() > 0) {
pos = tokenWindowList.get(0);
}
}
if (tokenNdx >= 0) {
// early exit
break;
}
}
// we need to look some more.
if (pos != null) {
// Move behind any windows attached to this one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
tokenWindowList = getTokenWindowsOnDisplay(atoken, displayContent);
final int NC = tokenWindowList.size();
if (NC > 0) {
WindowState bottom = tokenWindowList.get(0);
if (bottom.mSubLayer < 0) {
pos = bottom;
}
}
}
placeWindowBefore(pos, win);
return tokenWindowsPos;
}
// token that has windows on this display.
for (; taskNdx >= 0; --taskNdx) {
AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
for (; tokenNdx >= 0; --tokenNdx) {
final AppWindowToken t = tokens.get(tokenNdx);
tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
final int NW = tokenWindowList.size();
if (NW > 0) {
pos = tokenWindowList.get(NW - 1);
break;
}
}
if (tokenNdx >= 0) {
// found
break;
}
}
if (pos != null) {
// Move in front of any windows attached to this
// one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
WindowState top = atoken.windows.get(NC - 1);
if (top.mSubLayer >= 0) {
pos = top;
}
}
}
placeWindowAfter(pos, win);
return tokenWindowsPos;
}
// Just search for the start of this layer.
final int myLayer = win.mBaseLayer;
int i;
for (i = windows.size() - 1; i >= 0; --i) {
WindowState w = windows.get(i);
// of the animation.
if (w.mBaseLayer <= myLayer && w.mAttrs.type != TYPE_DOCK_DIVIDER) {
break;
}
}
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE)
Slog.v(TAG_WM, "Based on layer: Adding window " + win + " at " + (i + 1) + " of " + windows.size());
windows.add(i + 1, win);
mWindowsChanged = true;
return tokenWindowsPos;
}
use of android.view.IWindow in project android_frameworks_base by DirtyUnicorns.
the class WindowManagerService method addAppWindowToListLocked.
private int addAppWindowToListLocked(final WindowState win) {
final DisplayContent displayContent = win.getDisplayContent();
if (displayContent == null) {
// It doesn't matter this display is going away.
return 0;
}
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
final WindowList windows = displayContent.getWindowList();
WindowList tokenWindowList = getTokenWindowsOnDisplay(token, displayContent);
int tokenWindowsPos = 0;
if (!tokenWindowList.isEmpty()) {
return addAppWindowToTokenListLocked(win, token, windows, tokenWindowList);
}
// No windows from this token on this display
if (localLOGV)
Slog.v(TAG_WM, "Figuring out where to add app window " + client.asBinder() + " (token=" + token + ")");
// Figure out where the window should go, based on the
// order of applications.
WindowState pos = null;
final ArrayList<Task> tasks = displayContent.getTasks();
int taskNdx;
int tokenNdx = -1;
for (taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
for (tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
final AppWindowToken t = tokens.get(tokenNdx);
if (t == token) {
--tokenNdx;
if (tokenNdx < 0) {
--taskNdx;
if (taskNdx >= 0) {
tokenNdx = tasks.get(taskNdx).mAppTokens.size() - 1;
}
}
break;
}
// We haven't reached the token yet; if this token
// is not going to the bottom and has windows on this display, we can
// use it as an anchor for when we do reach the token.
tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
if (!t.sendingToBottom && tokenWindowList.size() > 0) {
pos = tokenWindowList.get(0);
}
}
if (tokenNdx >= 0) {
// early exit
break;
}
}
// we need to look some more.
if (pos != null) {
// Move behind any windows attached to this one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
tokenWindowList = getTokenWindowsOnDisplay(atoken, displayContent);
final int NC = tokenWindowList.size();
if (NC > 0) {
WindowState bottom = tokenWindowList.get(0);
if (bottom.mSubLayer < 0) {
pos = bottom;
}
}
}
placeWindowBefore(pos, win);
return tokenWindowsPos;
}
// token that has windows on this display.
for (; taskNdx >= 0; --taskNdx) {
AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
for (; tokenNdx >= 0; --tokenNdx) {
final AppWindowToken t = tokens.get(tokenNdx);
tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
final int NW = tokenWindowList.size();
if (NW > 0) {
pos = tokenWindowList.get(NW - 1);
break;
}
}
if (tokenNdx >= 0) {
// found
break;
}
}
if (pos != null) {
// Move in front of any windows attached to this
// one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
WindowState top = atoken.windows.get(NC - 1);
if (top.mSubLayer >= 0) {
pos = top;
}
}
}
placeWindowAfter(pos, win);
return tokenWindowsPos;
}
// Just search for the start of this layer.
final int myLayer = win.mBaseLayer;
int i;
for (i = windows.size() - 1; i >= 0; --i) {
WindowState w = windows.get(i);
// of the animation.
if (w.mBaseLayer <= myLayer && w.mAttrs.type != TYPE_DOCK_DIVIDER) {
break;
}
}
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE)
Slog.v(TAG_WM, "Based on layer: Adding window " + win + " at " + (i + 1) + " of " + windows.size());
windows.add(i + 1, win);
mWindowsChanged = true;
return tokenWindowsPos;
}
use of android.view.IWindow in project android_frameworks_base by ParanoidAndroid.
the class WindowManagerService method performLayoutAndPlaceSurfacesLockedInner.
// "Something has changed! Let's make it correct now."
private final void performLayoutAndPlaceSurfacesLockedInner(boolean recoveringMemory) {
if (DEBUG_WINDOW_TRACE) {
Slog.v(TAG, "performLayoutAndPlaceSurfacesLockedInner: entry. Called by " + Debug.getCallers(3));
}
final long currentTime = SystemClock.uptimeMillis();
int i;
if (mFocusMayChange) {
mFocusMayChange = false;
updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, false);
}
// Initialize state of exiting tokens.
for (i = mExitingTokens.size() - 1; i >= 0; i--) {
mExitingTokens.get(i).hasVisible = false;
}
// Initialize state of exiting applications.
for (i = mExitingAppTokens.size() - 1; i >= 0; i--) {
mExitingAppTokens.get(i).hasVisible = false;
}
mInnerFields.mHoldScreen = null;
mInnerFields.mScreenBrightness = -1;
mInnerFields.mButtonBrightness = -1;
mInnerFields.mUserActivityTimeout = -1;
mInnerFields.mDisplayHasContent = LayoutFields.DISPLAY_CONTENT_UNKNOWN;
mTransactionSequence++;
final DisplayContent defaultDisplay = getDefaultDisplayContentLocked();
final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo();
final int defaultDw = defaultInfo.logicalWidth;
final int defaultDh = defaultInfo.logicalHeight;
if (SHOW_LIGHT_TRANSACTIONS)
Slog.i(TAG, ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces");
SurfaceControl.openTransaction();
try {
if (mWatermark != null) {
mWatermark.positionSurface(defaultDw, defaultDh);
}
if (mStrictModeFlash != null) {
mStrictModeFlash.positionSurface(defaultDw, defaultDh);
}
boolean focusDisplayed = false;
boolean updateAllDrawn = false;
final int numDisplays = mDisplayContents.size();
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
WindowList windows = displayContent.getWindowList();
DisplayInfo displayInfo = displayContent.getDisplayInfo();
final int displayId = displayContent.getDisplayId();
final int dw = displayInfo.logicalWidth;
final int dh = displayInfo.logicalHeight;
final int innerDw = displayInfo.appWidth;
final int innerDh = displayInfo.appHeight;
final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
// Reset for each display unless we are forcing mirroring.
if (mInnerFields.mDisplayHasContent != LayoutFields.DISPLAY_CONTENT_MIRROR) {
mInnerFields.mDisplayHasContent = LayoutFields.DISPLAY_CONTENT_UNKNOWN;
}
int repeats = 0;
do {
repeats++;
if (repeats > 6) {
Slog.w(TAG, "Animation repeat aborted after too many iterations");
displayContent.layoutNeeded = false;
break;
}
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("On entry to LockedInner", displayContent.pendingLayoutChanges);
if ((displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0 && (adjustWallpaperWindowsLocked() & ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
assignLayersLocked(windows);
displayContent.layoutNeeded = true;
}
if (isDefaultDisplay && (displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
if (DEBUG_LAYOUT)
Slog.v(TAG, "Computing new config from layout");
if (updateOrientationFromAppTokensLocked(true)) {
displayContent.layoutNeeded = true;
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
}
}
if ((displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
displayContent.layoutNeeded = true;
}
// FIRST LOOP: Perform a layout, if needed.
if (repeats < 4) {
performLayoutLockedInner(displayContent, repeats == 1, false);
} else {
Slog.w(TAG, "Layout repeat skipped after too many iterations");
}
// FIRST AND ONE HALF LOOP: Make WindowManagerPolicy think
// it is animating.
displayContent.pendingLayoutChanges = 0;
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("loop number " + mLayoutRepeatCount, displayContent.pendingLayoutChanges);
if (isDefaultDisplay) {
mPolicy.beginPostLayoutPolicyLw(dw, dh);
for (i = windows.size() - 1; i >= 0; i--) {
WindowState w = windows.get(i);
if (w.mHasSurface) {
mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs);
}
}
displayContent.pendingLayoutChanges |= mPolicy.finishPostLayoutPolicyLw();
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("after finishPostLayoutPolicyLw", displayContent.pendingLayoutChanges);
}
} while (displayContent.pendingLayoutChanges != 0);
mInnerFields.mObscured = false;
mInnerFields.mDimming = false;
mInnerFields.mSyswin = false;
// Only used if default window
final boolean someoneLosingFocus = !mLosingFocus.isEmpty();
final int N = windows.size();
for (i = N - 1; i >= 0; i--) {
WindowState w = windows.get(i);
final boolean obscuredChanged = w.mObscured != mInnerFields.mObscured;
// Update effect.
w.mObscured = mInnerFields.mObscured;
if (!mInnerFields.mObscured) {
handleNotObscuredLocked(w, currentTime, innerDw, innerDh);
}
if (!mInnerFields.mDimming) {
handleFlagDimBehind(w, innerDw, innerDh);
}
if (isDefaultDisplay && obscuredChanged && (mWallpaperTarget == w) && w.isVisibleLw()) {
// This is the wallpaper target and its obscured state
// changed... make sure the current wallaper's visibility
// has been updated accordingly.
updateWallpaperVisibilityLocked();
}
final WindowStateAnimator winAnimator = w.mWinAnimator;
// it.
if (w.mHasSurface && w.shouldAnimateMove()) {
// Frame has moved, containing content frame
// has also moved, and we're not currently animating...
// let's do something.
Animation a = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.window_move_from_decor);
winAnimator.setAnimation(a);
winAnimator.mAnimDw = w.mLastFrame.left - w.mFrame.left;
winAnimator.mAnimDh = w.mLastFrame.top - w.mFrame.top;
try {
w.mClient.moved(w.mFrame.left, w.mFrame.top);
} catch (RemoteException e) {
}
}
//Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
w.mContentChanged = false;
// Moved from updateWindowsAndWallpaperLocked().
if (w.mHasSurface) {
// Take care of the window being ready to display.
final boolean committed = winAnimator.commitFinishDrawingLocked(currentTime);
if (isDefaultDisplay && committed) {
if (w.mAttrs.type == TYPE_DREAM) {
// HACK: When a dream is shown, it may at that
// point hide the lock screen. So we need to
// redo the layout to let the phone window manager
// make this happen.
displayContent.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
debugLayoutRepeats("dream and commitFinishDrawingLocked true", displayContent.pendingLayoutChanges);
}
}
if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
if (DEBUG_WALLPAPER_LIGHT)
Slog.v(TAG, "First draw done in potential wallpaper target " + w);
mInnerFields.mWallpaperMayChange = true;
displayContent.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
debugLayoutRepeats("wallpaper and commitFinishDrawingLocked true", displayContent.pendingLayoutChanges);
}
}
}
winAnimator.setSurfaceBoundariesLocked(recoveringMemory);
final AppWindowToken atoken = w.mAppToken;
if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) {
Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen=" + w.isOnScreen() + " allDrawn=" + atoken.allDrawn + " freezingScreen=" + atoken.mAppAnimator.freezingScreen);
}
if (atoken != null && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) {
if (atoken.lastTransactionSequence != mTransactionSequence) {
atoken.lastTransactionSequence = mTransactionSequence;
atoken.numInterestingWindows = atoken.numDrawnWindows = 0;
atoken.startingDisplayed = false;
}
if ((w.isOnScreen() || winAnimator.mAttrType == TYPE_BASE_APPLICATION) && !w.mExiting && !w.mDestroying) {
if (WindowManagerService.DEBUG_VISIBILITY || WindowManagerService.DEBUG_ORIENTATION) {
Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw() + ", isAnimating=" + winAnimator.isAnimating());
if (!w.isDrawnLw()) {
Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceControl + " pv=" + w.mPolicyVisibility + " mDrawState=" + winAnimator.mDrawState + " ah=" + w.mAttachedHidden + " th=" + atoken.hiddenRequested + " a=" + winAnimator.mAnimating);
}
}
if (w != atoken.startingWindow) {
if (!atoken.mAppAnimator.freezingScreen || !w.mAppFreezing) {
atoken.numInterestingWindows++;
if (w.isDrawnLw()) {
atoken.numDrawnWindows++;
if (WindowManagerService.DEBUG_VISIBILITY || WindowManagerService.DEBUG_ORIENTATION)
Slog.v(TAG, "tokenMayBeDrawn: " + atoken + " freezingScreen=" + atoken.mAppAnimator.freezingScreen + " mAppFreezing=" + w.mAppFreezing);
updateAllDrawn = true;
}
}
} else if (w.isDrawnLw()) {
atoken.startingDisplayed = true;
}
}
}
}
if (isDefaultDisplay && someoneLosingFocus && (w == mCurrentFocus) && w.isDisplayedLw()) {
focusDisplayed = true;
}
updateResizingWindows(w);
}
final boolean hasUniqueContent;
switch(mInnerFields.mDisplayHasContent) {
case LayoutFields.DISPLAY_CONTENT_MIRROR:
hasUniqueContent = isDefaultDisplay;
break;
case LayoutFields.DISPLAY_CONTENT_UNIQUE:
hasUniqueContent = true;
break;
case LayoutFields.DISPLAY_CONTENT_UNKNOWN:
default:
hasUniqueContent = false;
break;
}
mDisplayManagerService.setDisplayHasContent(displayId, hasUniqueContent, true);
if (!mInnerFields.mDimming && mAnimator.isDimmingLocked(displayId)) {
stopDimmingLocked(displayId);
}
}
if (updateAllDrawn) {
updateAllDrawnLocked();
}
if (focusDisplayed) {
mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
}
// Give the display manager a chance to adjust properties
// like display rotation if it needs to.
mDisplayManagerService.performTraversalInTransactionFromWindowManager();
} catch (RuntimeException e) {
Log.wtf(TAG, "Unhandled exception in Window Manager", e);
} finally {
SurfaceControl.closeTransaction();
if (SHOW_LIGHT_TRANSACTIONS)
Slog.i(TAG, "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces");
}
final WindowList defaultWindows = defaultDisplay.getWindowList();
// to go.
if (mAppTransition.isReady()) {
defaultDisplay.pendingLayoutChanges |= handleAppTransitionReadyLocked(defaultWindows);
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("after handleAppTransitionReadyLocked", defaultDisplay.pendingLayoutChanges);
}
if (!mAnimator.mAnimating && mAppTransition.isRunning()) {
// We have finished the animation of an app transition. To do
// this, we have delayed a lot of operations like showing and
// hiding apps, moving apps in Z-order, etc. The app token list
// reflects the correct Z-order, but the window list may now
// be out of sync with it. So here we will just rebuild the
// entire app window list. Fun!
defaultDisplay.pendingLayoutChanges |= handleAnimatingStoppedAndTransitionLocked();
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("after handleAnimStopAndXitionLock", defaultDisplay.pendingLayoutChanges);
}
if (mInnerFields.mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0 && !mAppTransition.isReady()) {
// At this point, there was a window with a wallpaper that
// was force hiding other windows behind it, but now it
// is going away. This may be simple -- just animate
// away the wallpaper and its window -- or it may be
// hard -- the wallpaper now needs to be shown behind
// something that was hidden.
defaultDisplay.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("after animateAwayWallpaperLocked", defaultDisplay.pendingLayoutChanges);
}
mInnerFields.mWallpaperForceHidingChanged = false;
if (mInnerFields.mWallpaperMayChange) {
if (WindowManagerService.DEBUG_WALLPAPER_LIGHT)
Slog.v(TAG, "Wallpaper may change! Adjusting");
defaultDisplay.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("WallpaperMayChange", defaultDisplay.pendingLayoutChanges);
}
if (mFocusMayChange) {
mFocusMayChange = false;
if (updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, false)) {
defaultDisplay.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
}
}
if (needsLayout()) {
defaultDisplay.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
if (DEBUG_LAYOUT_REPEATS)
debugLayoutRepeats("mLayoutNeeded", defaultDisplay.pendingLayoutChanges);
}
for (i = mResizingWindows.size() - 1; i >= 0; i--) {
WindowState win = mResizingWindows.get(i);
if (win.mAppFreezing) {
// Don't remove this window until rotation has completed.
continue;
}
final WindowStateAnimator winAnimator = win.mWinAnimator;
try {
if (DEBUG_RESIZE || DEBUG_ORIENTATION)
Slog.v(TAG, "Reporting new frame to " + win + ": " + win.mCompatFrame);
int diff = 0;
boolean configChanged = win.isConfigChanged();
if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION) && configChanged) {
Slog.i(TAG, "Sending new config to window " + win + ": " + winAnimator.mSurfaceW + "x" + winAnimator.mSurfaceH + " / " + mCurConfiguration + " / 0x" + Integer.toHexString(diff));
}
win.setConfiguration(mCurConfiguration);
if (DEBUG_ORIENTATION && winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING)
Slog.i(TAG, "Resizing " + win + " WITH DRAW PENDING");
final IWindow client = win.mClient;
final Rect frame = win.mFrame;
final Rect overscanInsets = win.mLastOverscanInsets;
final Rect contentInsets = win.mLastContentInsets;
final Rect visibleInsets = win.mLastVisibleInsets;
final boolean reportDraw = winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING;
final Configuration newConfig = configChanged ? win.mConfiguration : null;
if (win.mClient instanceof IWindow.Stub) {
// To prevent deadlock simulate one-way call if win.mClient is a local object.
mH.post(new Runnable() {
@Override
public void run() {
try {
client.resized(frame, overscanInsets, contentInsets, visibleInsets, reportDraw, newConfig);
} catch (RemoteException e) {
// Not a remote call, RemoteException won't be raised.
}
}
});
} else {
client.resized(frame, overscanInsets, contentInsets, visibleInsets, reportDraw, newConfig);
}
win.mOverscanInsetsChanged = false;
win.mContentInsetsChanged = false;
win.mVisibleInsetsChanged = false;
winAnimator.mSurfaceResized = false;
} catch (RemoteException e) {
win.mOrientationChanging = false;
win.mLastFreezeDuration = (int) (SystemClock.elapsedRealtime() - mDisplayFreezeTime);
}
mResizingWindows.remove(i);
}
if (DEBUG_ORIENTATION && mDisplayFrozen)
Slog.v(TAG, "With display frozen, orientationChangeComplete=" + mInnerFields.mOrientationChangeComplete);
if (mInnerFields.mOrientationChangeComplete) {
if (mWindowsFreezingScreen) {
mWindowsFreezingScreen = false;
mLastFinishedFreezeSource = mInnerFields.mLastWindowFreezeSource;
mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
}
stopFreezingDisplayLocked();
}
// Destroy the surface of any windows that are no longer visible.
boolean wallpaperDestroyed = false;
i = mDestroySurface.size();
if (i > 0) {
do {
i--;
WindowState win = mDestroySurface.get(i);
win.mDestroying = false;
if (mInputMethodWindow == win) {
mInputMethodWindow = null;
}
if (win == mWallpaperTarget) {
wallpaperDestroyed = true;
}
win.mWinAnimator.destroySurfaceLocked();
} while (i > 0);
mDestroySurface.clear();
}
// Time to remove any exiting tokens?
for (i = mExitingTokens.size() - 1; i >= 0; i--) {
WindowToken token = mExitingTokens.get(i);
if (!token.hasVisible) {
mExitingTokens.remove(i);
if (token.windowType == TYPE_WALLPAPER) {
mWallpaperTokens.remove(token);
}
}
}
// Time to remove any exiting applications?
for (i = mExitingAppTokens.size() - 1; i >= 0; i--) {
AppWindowToken token = mExitingAppTokens.get(i);
if (!token.hasVisible && !mClosingApps.contains(token)) {
// Make sure there is no animation running on this token,
// so any windows associated with it will be removed as
// soon as their animations are complete
token.mAppAnimator.clearAnimation();
token.mAppAnimator.animating = false;
if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT)
Slog.v(TAG, "performLayout: App token exiting now removed" + token);
mAppTokens.remove(token);
mAnimatingAppTokens.remove(token);
mExitingAppTokens.remove(i);
}
}
if (!mAnimator.mAnimating && mRelayoutWhileAnimating.size() > 0) {
for (int j = mRelayoutWhileAnimating.size() - 1; j >= 0; j--) {
try {
mRelayoutWhileAnimating.get(j).mClient.doneAnimating();
} catch (RemoteException e) {
}
}
mRelayoutWhileAnimating.clear();
}
if (wallpaperDestroyed) {
defaultDisplay.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
defaultDisplay.layoutNeeded = true;
}
final int numDisplays = mDisplayContents.size();
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
if (displayContent.pendingLayoutChanges != 0) {
displayContent.layoutNeeded = true;
}
}
// Finally update all input windows now that the window changes have stabilized.
mInputMonitor.updateInputWindowsLw(true);
setHoldScreenLocked(mInnerFields.mHoldScreen);
if (!mDisplayFrozen) {
if (mInnerFields.mScreenBrightness < 0 || mInnerFields.mScreenBrightness > 1.0f) {
mPowerManager.setScreenBrightnessOverrideFromWindowManager(-1);
} else {
mPowerManager.setScreenBrightnessOverrideFromWindowManager(toBrightnessOverride(mInnerFields.mScreenBrightness));
}
if (mInnerFields.mButtonBrightness < 0 || mInnerFields.mButtonBrightness > 1.0f) {
mPowerManager.setButtonBrightnessOverrideFromWindowManager(-1);
} else {
mPowerManager.setButtonBrightnessOverrideFromWindowManager(toBrightnessOverride(mInnerFields.mButtonBrightness));
}
mPowerManager.setUserActivityTimeoutOverrideFromWindowManager(mInnerFields.mUserActivityTimeout);
}
if (mTurnOnScreen) {
if (DEBUG_VISIBILITY)
Slog.v(TAG, "Turning screen on after layout!");
mPowerManager.wakeUp(SystemClock.uptimeMillis());
mTurnOnScreen = false;
}
if (mInnerFields.mUpdateRotation) {
if (DEBUG_ORIENTATION)
Slog.d(TAG, "Performing post-rotate rotation");
if (updateRotationUncheckedLocked(false)) {
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
} else {
mInnerFields.mUpdateRotation = false;
}
}
if (mInnerFields.mOrientationChangeComplete && !defaultDisplay.layoutNeeded && !mInnerFields.mUpdateRotation) {
checkDrawnWindowsLocked();
}
final int N = mPendingRemove.size();
if (N > 0) {
if (mPendingRemoveTmp.length < N) {
mPendingRemoveTmp = new WindowState[N + 10];
}
mPendingRemove.toArray(mPendingRemoveTmp);
mPendingRemove.clear();
DisplayContentList displayList = new DisplayContentList();
for (i = 0; i < N; i++) {
WindowState w = mPendingRemoveTmp[i];
removeWindowInnerLocked(w.mSession, w);
if (!displayList.contains(w.mDisplayContent)) {
displayList.add(w.mDisplayContent);
}
}
for (DisplayContent displayContent : displayList) {
assignLayersLocked(displayContent.getWindowList());
displayContent.layoutNeeded = true;
}
}
// Check to see if we are now in a state where the screen should
// be enabled, because the window obscured flags have changed.
enableScreenIfNeededLocked();
scheduleAnimationLocked();
if (DEBUG_WINDOW_TRACE) {
Slog.e(TAG, "performLayoutAndPlaceSurfacesLockedInner exit: animating=" + mAnimator.mAnimating);
}
}
use of android.view.IWindow in project android_frameworks_base by ParanoidAndroid.
the class WindowManagerService method addWindowToListInOrderLocked.
private void addWindowToListInOrderLocked(WindowState win, boolean addToToken) {
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
final DisplayContent displayContent = win.mDisplayContent;
final WindowList windows = win.getWindowList();
final int N = windows.size();
final WindowState attached = win.mAttachedWindow;
int i;
WindowList tokenWindowList = getTokenWindowsOnDisplay(token, displayContent);
if (attached == null) {
int tokenWindowsPos = 0;
int windowListPos = tokenWindowList.size();
if (token.appWindowToken != null) {
int index = windowListPos - 1;
if (index >= 0) {
// keep the starting window on top.
if (win.mAttrs.type == TYPE_BASE_APPLICATION) {
// Base windows go behind everything else.
WindowState lowestWindow = tokenWindowList.get(0);
placeWindowBefore(lowestWindow, win);
tokenWindowsPos = indexOfWinInWindowList(lowestWindow, token.windows);
} else {
AppWindowToken atoken = win.mAppToken;
WindowState lastWindow = tokenWindowList.get(index);
if (atoken != null && lastWindow == atoken.startingWindow) {
placeWindowBefore(lastWindow, win);
tokenWindowsPos = indexOfWinInWindowList(lastWindow, token.windows);
} else {
int newIdx = findIdxBasedOnAppTokens(win);
//windows associated with this token.
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Slog.v(TAG, "Adding window " + win + " at " + (newIdx + 1) + " of " + N);
}
windows.add(newIdx + 1, win);
if (newIdx < 0) {
// No window from token found on win's display.
tokenWindowsPos = 0;
} else {
tokenWindowsPos = indexOfWinInWindowList(windows.get(newIdx), token.windows) + 1;
}
mWindowsChanged = true;
}
}
} else {
// No windows from this token on this display
if (localLOGV)
Slog.v(TAG, "Figuring out where to add app window " + client.asBinder() + " (token=" + token + ")");
// Figure out where the window should go, based on the
// order of applications.
final int NA = mAnimatingAppTokens.size();
WindowState pos = null;
for (i = NA - 1; i >= 0; i--) {
AppWindowToken t = mAnimatingAppTokens.get(i);
if (t == token) {
i--;
break;
}
// We haven't reached the token yet; if this token
// is not going to the bottom and has windows on this display, we can
// use it as an anchor for when we do reach the token.
tokenWindowList = getTokenWindowsOnDisplay(t, win.mDisplayContent);
if (!t.sendingToBottom && tokenWindowList.size() > 0) {
pos = tokenWindowList.get(0);
}
}
// we need to look some more.
if (pos != null) {
// Move behind any windows attached to this one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
tokenWindowList = getTokenWindowsOnDisplay(atoken, win.mDisplayContent);
final int NC = tokenWindowList.size();
if (NC > 0) {
WindowState bottom = tokenWindowList.get(0);
if (bottom.mSubLayer < 0) {
pos = bottom;
}
}
}
placeWindowBefore(pos, win);
} else {
// token that has windows on this display.
while (i >= 0) {
AppWindowToken t = mAnimatingAppTokens.get(i);
tokenWindowList = getTokenWindowsOnDisplay(t, win.mDisplayContent);
final int NW = tokenWindowList.size();
if (NW > 0) {
pos = tokenWindowList.get(NW - 1);
break;
}
i--;
}
if (pos != null) {
// Move in front of any windows attached to this
// one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
WindowState top = atoken.windows.get(NC - 1);
if (top.mSubLayer >= 0) {
pos = top;
}
}
}
placeWindowAfter(pos, win);
} else {
// Just search for the start of this layer.
final int myLayer = win.mBaseLayer;
for (i = 0; i < N; i++) {
WindowState w = windows.get(i);
if (w.mBaseLayer > myLayer) {
break;
}
}
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Slog.v(TAG, "Adding window " + win + " at " + i + " of " + N);
}
windows.add(i, win);
mWindowsChanged = true;
}
}
}
} else {
// Figure out where window should go, based on layer.
final int myLayer = win.mBaseLayer;
for (i = N - 1; i >= 0; i--) {
if (windows.get(i).mBaseLayer <= myLayer) {
break;
}
}
i++;
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE)
Slog.v(TAG, "Adding window " + win + " at " + i + " of " + N);
windows.add(i, win);
mWindowsChanged = true;
}
if (addToToken) {
if (DEBUG_ADD_REMOVE)
Slog.v(TAG, "Adding " + win + " to " + token);
token.windows.add(tokenWindowsPos, win);
}
} else {
// Figure out this window's ordering relative to the window
// it is attached to.
final int NA = tokenWindowList.size();
final int sublayer = win.mSubLayer;
int largestSublayer = Integer.MIN_VALUE;
WindowState windowWithLargestSublayer = null;
for (i = 0; i < NA; i++) {
WindowState w = tokenWindowList.get(i);
final int wSublayer = w.mSubLayer;
if (wSublayer >= largestSublayer) {
largestSublayer = wSublayer;
windowWithLargestSublayer = w;
}
if (sublayer < 0) {
// in the same sublayer.
if (wSublayer >= sublayer) {
if (addToToken) {
if (DEBUG_ADD_REMOVE)
Slog.v(TAG, "Adding " + win + " to " + token);
token.windows.add(i, win);
}
placeWindowBefore(wSublayer >= 0 ? attached : w, win);
break;
}
} else {
// in the same sublayer.
if (wSublayer > sublayer) {
if (addToToken) {
if (DEBUG_ADD_REMOVE)
Slog.v(TAG, "Adding " + win + " to " + token);
token.windows.add(i, win);
}
placeWindowBefore(w, win);
break;
}
}
}
if (i >= NA) {
if (addToToken) {
if (DEBUG_ADD_REMOVE)
Slog.v(TAG, "Adding " + win + " to " + token);
token.windows.add(win);
}
if (sublayer < 0) {
placeWindowBefore(attached, win);
} else {
placeWindowAfter(largestSublayer >= 0 ? windowWithLargestSublayer : attached, win);
}
}
}
if (win.mAppToken != null && addToToken) {
win.mAppToken.allAppWindows.add(win);
}
}
use of android.view.IWindow in project android_frameworks_base by ResurrectionRemix.
the class WindowManagerService method addAppWindowToListLocked.
private int addAppWindowToListLocked(final WindowState win) {
final DisplayContent displayContent = win.getDisplayContent();
if (displayContent == null) {
// It doesn't matter this display is going away.
return 0;
}
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
final WindowList windows = displayContent.getWindowList();
WindowList tokenWindowList = getTokenWindowsOnDisplay(token, displayContent);
int tokenWindowsPos = 0;
if (!tokenWindowList.isEmpty()) {
return addAppWindowToTokenListLocked(win, token, windows, tokenWindowList);
}
// No windows from this token on this display
if (localLOGV)
Slog.v(TAG_WM, "Figuring out where to add app window " + client.asBinder() + " (token=" + token + ")");
// Figure out where the window should go, based on the
// order of applications.
WindowState pos = null;
final ArrayList<Task> tasks = displayContent.getTasks();
int taskNdx;
int tokenNdx = -1;
for (taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
for (tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
final AppWindowToken t = tokens.get(tokenNdx);
if (t == token) {
--tokenNdx;
if (tokenNdx < 0) {
--taskNdx;
if (taskNdx >= 0) {
tokenNdx = tasks.get(taskNdx).mAppTokens.size() - 1;
}
}
break;
}
// We haven't reached the token yet; if this token
// is not going to the bottom and has windows on this display, we can
// use it as an anchor for when we do reach the token.
tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
if (!t.sendingToBottom && tokenWindowList.size() > 0) {
pos = tokenWindowList.get(0);
}
}
if (tokenNdx >= 0) {
// early exit
break;
}
}
// we need to look some more.
if (pos != null) {
// Move behind any windows attached to this one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
tokenWindowList = getTokenWindowsOnDisplay(atoken, displayContent);
final int NC = tokenWindowList.size();
if (NC > 0) {
WindowState bottom = tokenWindowList.get(0);
if (bottom.mSubLayer < 0) {
pos = bottom;
}
}
}
placeWindowBefore(pos, win);
return tokenWindowsPos;
}
// token that has windows on this display.
for (; taskNdx >= 0; --taskNdx) {
AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
for (; tokenNdx >= 0; --tokenNdx) {
final AppWindowToken t = tokens.get(tokenNdx);
tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
final int NW = tokenWindowList.size();
if (NW > 0) {
pos = tokenWindowList.get(NW - 1);
break;
}
}
if (tokenNdx >= 0) {
// found
break;
}
}
if (pos != null) {
// Move in front of any windows attached to this
// one.
WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
if (atoken != null) {
final int NC = atoken.windows.size();
if (NC > 0) {
WindowState top = atoken.windows.get(NC - 1);
if (top.mSubLayer >= 0) {
pos = top;
}
}
}
placeWindowAfter(pos, win);
return tokenWindowsPos;
}
// Just search for the start of this layer.
final int myLayer = win.mBaseLayer;
int i;
for (i = windows.size() - 1; i >= 0; --i) {
WindowState w = windows.get(i);
// of the animation.
if (w.mBaseLayer <= myLayer && w.mAttrs.type != TYPE_DOCK_DIVIDER) {
break;
}
}
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE)
Slog.v(TAG_WM, "Based on layer: Adding window " + win + " at " + (i + 1) + " of " + windows.size());
windows.add(i + 1, win);
mWindowsChanged = true;
return tokenWindowsPos;
}
Aggregations