From 06882f8effe0f69fb689c46b4fe876329ce60ada Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Wed, 10 Jun 2009 13:36:04 -0700 Subject: [PATCH] Enable HierarchyViewer on debuggable builds, even if they're secure. That will let us (finally) use the tool on userdebug builds. --- .../android/server/WindowManagerService.java | 1038 +++++++++-------- 1 file changed, 522 insertions(+), 516 deletions(-) diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index a04d73a513652..828b8aabf33cb 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -133,16 +133,16 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo static final boolean DEBUG_STARTING_WINDOW = false; static final boolean DEBUG_REORDER = false; static final boolean SHOW_TRANSACTIONS = false; - + static final boolean PROFILE_ORIENTATION = false; static final boolean BLUR = true; static final boolean localLOGV = DEBUG; - + static final int LOG_WM_NO_SURFACE_MEMORY = 31000; - + /** How long to wait for first key repeat, in milliseconds */ static final int KEY_REPEAT_FIRST_DELAY = 750; - + /** How long to wait for subsequent key repeats, in milliseconds */ static final int KEY_REPEAT_DELAY = 50; @@ -150,16 +150,16 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo * for multiple windows of the same type and Z-ordering adjustment * with TYPE_LAYER_OFFSET. */ static final int TYPE_LAYER_MULTIPLIER = 10000; - + /** Offset from TYPE_LAYER_MULTIPLIER for moving a group of windows above * or below others in the same layer. */ static final int TYPE_LAYER_OFFSET = 1000; - + /** How much to increment the layer for each window, to reserve room * for effect surfaces between them. */ static final int WINDOW_LAYER_MULTIPLIER = 5; - + /** The maximum length we will accept for a loaded animation duration: * this is 10 seconds. */ @@ -173,21 +173,21 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo /** Adjustment to time to perform a dim, to make it more dramatic. */ static final int DIM_DURATION_MULTIPLIER = 6; - + static final int UPDATE_FOCUS_NORMAL = 0; static final int UPDATE_FOCUS_WILL_ASSIGN_LAYERS = 1; static final int UPDATE_FOCUS_PLACING_SURFACES = 2; static final int UPDATE_FOCUS_WILL_PLACE_SURFACES = 3; - + /** The minimum time between dispatching touch events. */ int mMinWaitTimeBetweenTouchEvents = 1000 / 35; // Last touch event time long mLastTouchEventTime = 0; - + // Last touch event type int mLastTouchEventType = OTHER_EVENT; - + // Time to wait before calling useractivity again. This saves CPU usage // when we get a flood of touch events. static final int MIN_TIME_BETWEEN_USERACTIVITIES = 1000; @@ -195,10 +195,11 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // Last time we call user activity long mLastUserActivityCallTime = 0; - // Last time we updated battery stats + // Last time we updated battery stats long mLastBatteryStatsCallTime = 0; - + private static final String SYSTEM_SECURE = "ro.secure"; + private static final String SYSTEM_DEBUGGABLE = "ro.debuggable"; /** * Condition waited on by {@link #reenableKeyguard} to know the call to @@ -224,20 +225,20 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo final Context mContext; final boolean mHaveInputMethods; - + final boolean mLimitedAlphaCompositing; - + final WindowManagerPolicy mPolicy = PolicyManager.makeNewWindowManager(); final IActivityManager mActivityManager; - + final IBatteryStats mBatteryStats; - + /** * All currently active sessions with clients. */ final HashSet mSessions = new HashSet(); - + /** * Mapping from an IWindow IBinder to the server's Window object. * This is also used as the lock for all of our state. @@ -255,7 +256,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo * over them. */ final ArrayList mTokenList = new ArrayList(); - + /** * Window tokens that are in the process of exiting, but still * on screen for animations. @@ -314,9 +315,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo * list or contain windows that need to be force removed. */ ArrayList mForceRemoves; - + IInputMethodManager mInputMethodManager; - + SurfaceSession mFxSession; Surface mDimSurface; boolean mDimShown; @@ -326,9 +327,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo long mLastDimAnimTime; Surface mBlurSurface; boolean mBlurShown; - + int mTransactionSequence = 0; - + final float[] mTmpFloats = new float[9]; boolean mSafeMode; @@ -340,7 +341,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo int mLastRotationFlags; ArrayList mRotationWatchers = new ArrayList(); - + boolean mLayoutNeeded = true; boolean mAnimationPending = false; boolean mDisplayFrozen = false; @@ -352,7 +353,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // perform a rotation animation when turning off shows the lock screen which // changes the orientation. PowerManager.WakeLock mScreenFrozenLock; - + // State management of app transitions. When we are preparing for a // transition, mNextAppTransition will be the kind of transition to // perform or TRANSIT_NONE if we are not waiting. If we are waiting, @@ -365,40 +366,40 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo boolean mSkipAppTransitionAnimation = false; final ArrayList mOpeningApps = new ArrayList(); final ArrayList mClosingApps = new ArrayList(); - + //flag to detect fat touch events boolean mFatTouch = false; Display mDisplay; - + H mH = new H(); WindowState mCurrentFocus = null; WindowState mLastFocus = null; - + // This just indicates the window the input method is on top of, not // necessarily the window its input is going to. WindowState mInputMethodTarget = null; WindowState mUpcomingInputMethodTarget = null; boolean mInputMethodTargetWaitingAnim; int mInputMethodAnimLayerAdjustment; - + WindowState mInputMethodWindow = null; final ArrayList mInputMethodDialogs = new ArrayList(); AppWindowToken mFocusedApp = null; PowerManagerService mPowerManager; - + float mWindowAnimationScale = 1.0f; float mTransitionAnimationScale = 1.0f; - + final KeyWaiter mKeyWaiter = new KeyWaiter(); final KeyQ mQueue; final InputDispatcherThread mInputThread; // Who is holding the screen on. Session mHoldingScreenOn; - + /** * Whether the UI is currently running in touch mode (not showing * navigational focus because the user is directly pressing the screen). @@ -408,14 +409,14 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo private ViewServer mViewServer; final Rect mTempRect = new Rect(); - + final Configuration mTempConfiguration = new Configuration(); - + public static WindowManagerService main(Context context, PowerManagerService pm, boolean haveInputMethods) { WMThread thr = new WMThread(context, pm, haveInputMethods); thr.start(); - + synchronized (thr) { while (thr.mService == null) { try { @@ -424,17 +425,17 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } } } - + return thr.mService; } - + static class WMThread extends Thread { WindowManagerService mService; - + private final Context mContext; private final PowerManagerService mPM; private final boolean mHaveInputMethods; - + public WMThread(Context context, PowerManagerService pm, boolean haveInputMethods) { super("WindowManager"); @@ -442,19 +443,19 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mPM = pm; mHaveInputMethods = haveInputMethods; } - + public void run() { Looper.prepare(); WindowManagerService s = new WindowManagerService(mContext, mPM, mHaveInputMethods); android.os.Process.setThreadPriority( android.os.Process.THREAD_PRIORITY_DISPLAY); - + synchronized (this) { mService = s; notifyAll(); } - + Looper.loop(); } } @@ -465,7 +466,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo private final Context mContext; private final PowerManagerService mPM; boolean mRunning = false; - + public PolicyThread(WindowManagerPolicy policy, WindowManagerService service, Context context, PowerManagerService pm) { @@ -475,7 +476,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mContext = context; mPM = pm; } - + public void run() { Looper.prepare(); //Looper.myLooper().setMessageLogging(new LogPrinter( @@ -483,12 +484,12 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo android.os.Process.setThreadPriority( android.os.Process.THREAD_PRIORITY_FOREGROUND); mPolicy.init(mContext, mService, mPM); - + synchronized (this) { mRunning = true; notifyAll(); } - + Looper.loop(); } } @@ -499,7 +500,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mHaveInputMethods = haveInputMethods; mLimitedAlphaCompositing = context.getResources().getBoolean( com.android.internal.R.bool.config_sf_limitedAlpha); - + mPowerManager = pm; mPowerManager.setPolicy(mPolicy); PowerManager pmc = (PowerManager)context.getSystemService(Context.POWER_SERVICE); @@ -515,14 +516,14 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale); mTransitionAnimationScale = Settings.System.getFloat(context.getContentResolver(), Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale); - + mQueue = new KeyQ(); mInputThread = new InputDispatcherThread(); - + PolicyThread thr = new PolicyThread(mPolicy, this, context, pm); thr.start(); - + synchronized (thr) { while (!thr.mRunning) { try { @@ -531,9 +532,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } } } - + mInputThread.start(); - + // Add ourself to the Watchdog monitors. Watchdog.getInstance().addMonitor(this); } @@ -586,12 +587,12 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return -1; } - + private void addWindowToListInOrderLocked(WindowState win, boolean addToToken) { final IWindow client = win.mClient; final WindowToken token = win.mToken; final ArrayList localmWindows = mWindows; - + final int N = localmWindows.size(); final WindowState attached = win.mAttachedWindow; int i; @@ -616,12 +617,12 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } else { int newIdx = findIdxBasedOnAppTokens(win); if(newIdx != -1) { - //there is a window above this one associated with the same - //apptoken note that the window could be a floating window - //that was created later or a window at the top of the list of + //there is a window above this one associated with the same + //apptoken note that the window could be a floating window + //that was created later or a window at the top of the list of //windows associated with this token. localmWindows.add(newIdx+1, win); - } + } } } } else { @@ -647,7 +648,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // we need to look some more. if (pos != null) { // Move behind any windows attached to this one. - WindowToken atoken = + WindowToken atoken = mTokenMap.get(((WindowState)pos).mClient.asBinder()); if (atoken != null) { final int NC = atoken.windows.size(); @@ -770,12 +771,12 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } } } - + if (win.mAppToken != null && addToToken) { win.mAppToken.allAppWindows.add(win); } } - + static boolean canBeImeTarget(WindowState w) { final int fl = w.mAttrs.flags & (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM); @@ -784,7 +785,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return false; } - + int findDesiredInputMethodWindowIndexLocked(boolean willMove) { final ArrayList localmWindows = mWindows; final int N = localmWindows.size(); @@ -793,12 +794,12 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo while (i > 0) { i--; w = (WindowState)localmWindows.get(i); - + //Log.i(TAG, "Checking window @" + i + " " + w + " fl=0x" // + Integer.toHexString(w.mAttrs.flags)); if (canBeImeTarget(w)) { //Log.i(TAG, "Putting input method here!"); - + // Yet more tricksyness! If this window is a "starting" // window, we do actually want to be on top of it, but // it is not -really- where input will go. So if the caller @@ -816,16 +817,16 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo break; } } - + mUpcomingInputMethodTarget = w; - + if (DEBUG_INPUT_METHOD) Log.v(TAG, "Desired input method target=" + w + " willMove=" + willMove); - + if (willMove && w != null) { final WindowState curTarget = mInputMethodTarget; if (curTarget != null && curTarget.mAppToken != null) { - + // Now some fun for dealing with window animations that // modify the Z order. We need to look at all windows below // the current target that are in this app, finding the highest @@ -851,14 +852,14 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pos--; } } - + if (highestTarget != null) { - if (DEBUG_INPUT_METHOD) Log.v(TAG, "mNextAppTransition=" + if (DEBUG_INPUT_METHOD) Log.v(TAG, "mNextAppTransition=" + mNextAppTransition + " " + highestTarget + " animating=" + highestTarget.isAnimating() + " layer=" + highestTarget.mAnimLayer + " new layer=" + w.mAnimLayer); - + if (mNextAppTransition != WindowManagerPolicy.TRANSIT_NONE) { // If we are currently setting up for an animation, // hold everything until we can find out what will happen. @@ -877,7 +878,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } } } - + //Log.i(TAG, "Placing input method @" + (i+1)); if (w != null) { if (willMove) { @@ -904,7 +905,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return -1; } - + void addInputMethodWindowToListLocked(WindowState win) { int pos = findDesiredInputMethodWindowIndexLocked(true); if (pos >= 0) { @@ -917,7 +918,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo addWindowToListInOrderLocked(win, true); moveInputMethodDialogsLocked(pos); } - + void setInputMethodAnimLayerAdjustment(int adj) { if (DEBUG_LAYERS) Log.v(TAG, "Setting im layer adj to " + adj); mInputMethodAnimLayerAdjustment = adj; @@ -944,7 +945,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo + " anim layer: " + imw.mAnimLayer); } } - + private int tmpRemoveWindowLocked(int interestingPos, WindowState win) { int wpos = mWindows.indexOf(win); if (wpos >= 0) { @@ -963,7 +964,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return interestingPos; } - + private void reAddWindowToListInOrderLocked(WindowState win) { addWindowToListInOrderLocked(win, false); // This is a hack to get all of the child windows added as well @@ -975,7 +976,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo reAddWindowLocked(wpos, win); } } - + void logWindowList(String prefix) { int N = mWindows.size(); while (N > 0) { @@ -983,10 +984,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Log.v(TAG, prefix + "#" + N + ": " + mWindows.get(N)); } } - + void moveInputMethodDialogsLocked(int pos) { ArrayList dialogs = mInputMethodDialogs; - + final int N = dialogs.size(); if (DEBUG_INPUT_METHOD) Log.v(TAG, "Removing " + N + " dialogs w/pos=" + pos); for (int i=0; i= 0) { final AppWindowToken targetAppToken = mInputMethodTarget.mAppToken; if (pos < mWindows.size()) { @@ -1027,25 +1028,25 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } } } - + boolean moveInputMethodWindowsIfNeededLocked(boolean needAssignLayers) { final WindowState imWin = mInputMethodWindow; final int DN = mInputMethodDialogs.size(); if (imWin == null && DN == 0) { return false; } - + int imPos = findDesiredInputMethodWindowIndexLocked(true); if (imPos >= 0) { // In this case, the input method windows are to be placed // immediately above the window they are targeting. - + // First check to see if the input method windows are already // located here, and contiguous. final int N = mWindows.size(); WindowState firstImWin = imPos < N ? (WindowState)mWindows.get(imPos) : null; - + // Figure out the actual input method window that should be // at the bottom of their stack. WindowState baseImWin = imWin != null @@ -1054,7 +1055,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo WindowState cw = (WindowState)baseImWin.mChildWindows.get(0); if (cw.mSubLayer < 0) baseImWin = cw; } - + if (firstImWin == baseImWin) { // The windows haven't moved... but are they still contiguous? // First find the top IM window. @@ -1078,7 +1079,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo return false; } } - + if (imWin != null) { if (DEBUG_INPUT_METHOD) { Log.v(TAG, "Moving IM from " + imPos); @@ -1099,11 +1100,11 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } else { moveInputMethodDialogsLocked(imPos); } - + } else { // In this case, the input method windows go in a fixed layer, // because they aren't currently associated with a focus window. - + if (imWin != null) { if (DEBUG_INPUT_METHOD) Log.v(TAG, "Moving IM from " + imPos); tmpRemoveWindowLocked(0, imWin); @@ -1117,20 +1118,20 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } else { moveInputMethodDialogsLocked(-1);; } - + } - + if (needAssignLayers) { assignLayersLocked(); } - + return true; } - + void adjustInputMethodDialogsLocked() { moveInputMethodDialogsLocked(findDesiredInputMethodWindowIndexLocked(true)); } - + public int addWindow(Session session, IWindow client, WindowManager.LayoutParams attrs, int viewVisibility, Rect outContentInsets) { @@ -1138,11 +1139,11 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (res != WindowManagerImpl.ADD_OKAY) { return res; } - + boolean reportNewConfig = false; WindowState attachedWindow = null; WindowState win = null; - + synchronized(mWindowMap) { // Instantiating a Display requires talking with the simulator, // so don't do it until we know the system is mostly up and @@ -1153,14 +1154,14 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mQueue.setDisplay(mDisplay); reportNewConfig = true; } - + if (mWindowMap.containsKey(client.asBinder())) { Log.w(TAG, "Window " + client + " is already added"); return WindowManagerImpl.ADD_DUPLICATE_ADD; } if (attrs.type >= FIRST_SUB_WINDOW && attrs.type <= LAST_SUB_WINDOW) { - attachedWindow = windowForClientLocked(null, attrs.token); + attachedWindow = windowForClientLocked(null, attrs.token); if (attachedWindow == null) { Log.w(TAG, "Attempted to add window with token that is not a window: " + attrs.token + ". Aborting."); @@ -1227,7 +1228,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } mPolicy.adjustWindowParamsLw(win.mAttrs); - + res = mPolicy.prepareAddWindowLw(win, attrs); if (res != WindowManagerImpl.ADD_OKAY) { return res; @@ -1236,9 +1237,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // From now on, no exceptions or errors allowed! res = WindowManagerImpl.ADD_OKAY; - + final long origId = Binder.clearCallingIdentity(); - + if (addToken) { mTokenMap.put(attrs.token, token); mTokenList.add(token); @@ -1252,7 +1253,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } boolean imMayMove = true; - + if (attrs.type == TYPE_INPUT_METHOD) { mInputMethodWindow = win; addInputMethodWindowToListLocked(win); @@ -1265,18 +1266,18 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } else { addWindowToListInOrderLocked(win, true); } - + win.mEnterAnimationPending = true; - + mPolicy.getContentInsetHintLw(attrs, outContentInsets); - + if (mInTouchMode) { res |= WindowManagerImpl.ADD_FLAG_IN_TOUCH_MODE; } if (win == null || win.mAppToken == null || !win.mAppToken.clientHidden) { res |= WindowManagerImpl.ADD_FLAG_APP_VISIBLE; } - + boolean focusChanged = false; if (win.canReceiveKeys()) { if ((focusChanged=updateFocusedWindowLocked(UPDATE_FOCUS_WILL_ASSIGN_LAYERS)) @@ -1284,15 +1285,15 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo imMayMove = false; } } - + if (imMayMove) { - moveInputMethodWindowsIfNeededLocked(false); + moveInputMethodWindowsIfNeededLocked(false); } - + assignLayersLocked(); // Don't do layout here, the window must call // relayout to be displayed, so we'll do it there. - + //dump(); if (focusChanged) { @@ -1322,10 +1323,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } } Binder.restoreCallingIdentity(origId); - + return res; } - + public void removeWindow(Session session, IWindow client) { synchronized(mWindowMap) { WindowState win = windowForClientLocked(session, client); @@ -1335,7 +1336,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo removeWindowLocked(session, win); } } - + public void removeWindowLocked(Session session, WindowState win) { if (localLOGV || DEBUG_FOCUS) Log.v( @@ -1345,7 +1346,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo + ", surface=" + win.mSurface); final long origId = Binder.clearCallingIdentity(); - + if (DEBUG_APP_TRANSITIONS) Log.v( TAG, "Remove " + win + ": mSurface=" + win.mSurface + " mExiting=" + win.mExiting @@ -1365,7 +1366,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // If we are not currently running the exit animation, we // need to see about starting one. if (wasVisible=win.isWinVisibleLw()) { - + int transit = WindowManagerPolicy.TRANSIT_EXIT; if (win.getAttrs().type == TYPE_APPLICATION_STARTING) { transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE; @@ -1402,17 +1403,17 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL); Binder.restoreCallingIdentity(origId); } - + private void removeWindowInnerLocked(Session session, WindowState win) { mKeyWaiter.releasePendingPointerLocked(win.mSession); mKeyWaiter.releasePendingTrackballLocked(win.mSession); - + win.mRemoved = true; - + if (mInputMethodTarget == win) { moveInputMethodWindowsIfNeededLocked(false); } - + mPolicy.removeWindowLw(win); win.removeLocked(); @@ -1424,7 +1425,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } else if (win.mAttrs.type == TYPE_INPUT_METHOD_DIALOG) { mInputMethodDialogs.remove(win); } - + final WindowToken token = win.mToken; final AppWindowToken atoken = win.mAppToken; token.windows.remove(win); @@ -1461,7 +1462,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mH.sendMessage(m); } } - + if (!mInLayout) { assignLayersLocked(); mLayoutNeeded = true; @@ -1492,7 +1493,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } void setInsetsWindow(Session session, IWindow client, - int touchableInsets, Rect contentInsets, + int touchableInsets, Rect contentInsets, Rect visibleInsets) { long origId = Binder.clearCallingIdentity(); try { @@ -1511,7 +1512,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Binder.restoreCallingIdentity(origId); } } - + public void getWindowDisplayFrame(Session session, IWindow client, Rect outDisplayFrame) { synchronized(mWindowMap) { @@ -1533,7 +1534,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo boolean inTouchMode; Configuration newConfig = null; long origId = Binder.clearCallingIdentity(); - + synchronized(mWindowMap) { WindowState win = windowForClientLocked(session, client); if (win == null) { @@ -1545,7 +1546,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (attrs != null) { mPolicy.adjustWindowParamsLw(attrs); } - + int attrChanges = 0; int flagChanges = 0; if (attrs != null) { @@ -1577,11 +1578,11 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo boolean imMayMove = (flagChanges&( WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)) != 0; - + boolean focusMayChange = win.mViewVisibility != viewVisibility || ((flagChanges&WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) != 0) || (!win.mRelayoutCalled); - + win.mRelayoutCalled = true; final int oldVisibility = win.mViewVisibility; win.mViewVisibility = viewVisibility; @@ -1669,17 +1670,17 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } //System.out.println("Relayout " + win + ": focus=" + mCurrentFocus); } - + // updateFocusedWindowLocked() already assigned layers so we only need to // reassign them at this point if the IM window state gets shuffled boolean assignLayers = false; - + if (imMayMove) { if (moveInputMethodWindowsIfNeededLocked(false)) { assignLayers = true; } } - + mLayoutNeeded = true; win.mGivenInsetsPending = insetsPending; if (assignLayers) { @@ -1695,7 +1696,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo outVisibleInsets.set(win.mVisibleInsets); if (localLOGV) Log.v( TAG, "Relayout given client " + client.asBinder() - + ", requestedWidth=" + requestedWidth + + ", requestedWidth=" + requestedWidth + ", requestedHeight=" + requestedHeight + ", viewVisibility=" + viewVisibility + "\nRelayout returning frame=" + outFrame @@ -1710,9 +1711,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (newConfig != null) { sendNewConfiguration(); } - + Binder.restoreCallingIdentity(origId); - + return (inTouchMode ? WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE : 0) | (displayed ? WindowManagerImpl.RELAYOUT_FIRST_TIME : 0); } @@ -1749,7 +1750,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return null; } - + private void applyEnterAnimationLocked(WindowState win) { int transit = WindowManagerPolicy.TRANSIT_SHOW; if (win.mEnterAnimationPending) { @@ -1767,7 +1768,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // an animation of the same type, then just leave that one alone. return true; } - + // Only apply an animation if the display isn't frozen. If it is // frozen, there is no reason to animate and it can cause strange // artifacts when we unfreeze the display if some different animation @@ -1832,7 +1833,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return null; } - + private boolean applyAnimationLocked(AppWindowToken wtoken, WindowManager.LayoutParams lp, int transit, boolean enter) { // Only apply an animation if the display isn't frozen. If it is @@ -1931,7 +1932,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (Binder.getCallingPid() == Process.myPid()) { return true; } - + if (mContext.checkCallingPermission(permission) == PackageManager.PERMISSION_GRANTED) { return true; @@ -1943,7 +1944,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Log.w(TAG, msg); return false; } - + AppWindowToken findAppWindowToken(IBinder token) { WindowToken wtoken = mTokenMap.get(token); if (wtoken == null) { @@ -1951,13 +1952,13 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return wtoken.appWindowToken; } - + public void addWindowToken(IBinder token, int type) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "addWindowToken()")) { return; } - + synchronized(mWindowMap) { WindowToken wtoken = mTokenMap.get(token); if (wtoken != null) { @@ -1969,7 +1970,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mTokenList.add(wtoken); } } - + public void removeWindowToken(IBinder token) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "removeWindowToken()")) { @@ -1984,17 +1985,17 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo boolean delayed = false; if (!wtoken.hidden) { wtoken.hidden = true; - + final int N = wtoken.windows.size(); boolean changed = false; - + for (int i=0; i= 0) { @@ -2091,7 +2092,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } - + public int getOrientationFromAppTokensLocked() { int pos = mAppTokens.size() - 1; int curGroup = 0; @@ -2133,7 +2134,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // to use the orientation behind it, then just take whatever // orientation it has and ignores whatever is under it. lastFullscreen = wtoken.appFullscreen; - if (lastFullscreen + if (lastFullscreen && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) { return or; } @@ -2150,7 +2151,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } - + public Configuration updateOrientationFromAppTokens( Configuration currentConfig, IBinder freezeThisOneIfNeeded) { Configuration config; @@ -2165,11 +2166,11 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Binder.restoreCallingIdentity(ident); return config; } - + /* * The orientation is computed from non-application windows first. If none of * the non-application windows specify orientation, the orientation is computed from - * application tokens. + * application tokens. * @see android.view.IWindowManager#updateOrientationFromAppTokens( * android.os.IBinder) */ @@ -2179,7 +2180,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo long ident = Binder.clearCallingIdentity(); try { int req = computeForcedAppOrientationLocked(); - + if (req != mForcedAppOrientation) { changed = true; mForcedAppOrientation = req; @@ -2187,7 +2188,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo //action like disabling/enabling sensors etc., mPolicy.setCurrentOrientationLw(req); } - + if (changed) { changed = setRotationUncheckedLocked( WindowManagerPolicy.USE_LAST_ROTATION, @@ -2219,10 +2220,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } finally { Binder.restoreCallingIdentity(ident); } - + return null; } - + int computeForcedAppOrientationLocked() { int req = getOrientationFromWindowsLocked(); if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { @@ -2230,35 +2231,35 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } return req; } - + public void setAppOrientation(IApplicationToken token, int requestedOrientation) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "setAppOrientation()")) { return; } - + synchronized(mWindowMap) { AppWindowToken wtoken = findAppWindowToken(token.asBinder()); if (wtoken == null) { Log.w(TAG, "Attempted to set orientation of non-existing app token: " + token); return; } - + wtoken.requestedOrientation = requestedOrientation; } } - + public int getAppOrientation(IApplicationToken token) { synchronized(mWindowMap) { AppWindowToken wtoken = findAppWindowToken(token.asBinder()); if (wtoken == null) { return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } - + return wtoken.requestedOrientation; } } - + public void setFocusedApp(IBinder token, boolean moveFocusNow) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "setFocusedApp()")) { @@ -2297,7 +2298,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo "prepareAppTransition()")) { return; } - + synchronized(mWindowMap) { if (DEBUG_APP_TRANSITIONS) Log.v( TAG, "Prepare app transition: transit=" + transit @@ -2320,13 +2321,13 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo public int getPendingAppTransition() { return mNextAppTransition; } - + public void executeAppTransition() { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "executeAppTransition()")) { return; } - + synchronized(mWindowMap) { if (DEBUG_APP_TRANSITIONS) Log.v( TAG, "Execute app transition: mNextAppTransition=" + mNextAppTransition); @@ -2351,7 +2352,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (DEBUG_STARTING_WINDOW) Log.v( TAG, "setAppStartingIcon: token=" + token + " pkg=" + pkg + " transferFrom=" + transferFrom); - + AppWindowToken wtoken = findAppWindowToken(token); if (wtoken == null) { Log.w(TAG, "Attempted to set icon of non-existing app token: " + token); @@ -2364,11 +2365,11 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (mDisplayFrozen) { return; } - + if (wtoken.startingData != null) { return; } - + if (transferFrom != null) { AppWindowToken ttoken = findAppWindowToken(transferFrom); if (ttoken != null) { @@ -2384,7 +2385,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo "Moving existing starting from " + ttoken + " to " + wtoken); final long origId = Binder.clearCallingIdentity(); - + // Transfer the starting window over to the new // token. wtoken.startingData = ttoken.startingData; @@ -2402,7 +2403,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo ttoken.allAppWindows.remove(startingWindow); addWindowToListInOrderLocked(startingWindow, true); wtoken.allAppWindows.add(startingWindow); - + // Propagate other interesting state between the // tokens. If the old token is displayed, we should // immediately force the new one to be displayed. If @@ -2432,7 +2433,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo wtoken.updateLayers(); ttoken.updateLayers(); } - + updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES); mLayoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); @@ -2462,7 +2463,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (!createIfNeeded) { return; } - + mStartingIconInTransition = true; wtoken.startingData = new StartingData( pkg, theme, nonLocalizedLabel, @@ -2492,7 +2493,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo wtoken.willBeHidden = true; } } - + boolean setTokenVisibilityLocked(AppWindowToken wtoken, WindowManager.LayoutParams lp, boolean visible, int transit, boolean performLayout) { boolean delayed = false; @@ -2501,7 +2502,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo wtoken.clientHidden = !visible; wtoken.sendAppVisibilityToClients(); } - + wtoken.willBeHidden = false; if (wtoken.hidden == visible) { final int N = wtoken.allAppWindows.size(); @@ -2509,9 +2510,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo if (DEBUG_APP_TRANSITIONS) Log.v( TAG, "Changing app " + wtoken + " hidden=" + wtoken.hidden + " performLayout=" + performLayout); - + boolean runningAppAnimation = false; - + if (transit != WindowManagerPolicy.TRANSIT_NONE) { if (wtoken.animation == sDummyAnimation) { wtoken.animation = null; @@ -2522,7 +2523,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo delayed = runningAppAnimation = true; } } - + for (int i=0; i