Merge change 3760 into donut
* changes:
Enable HierarchyViewer on debuggable builds, even if they're secure.
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index a04d73a..828b8aa 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -133,16 +133,16 @@
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 @@
* 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 @@
/** 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 @@
// 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 @@
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<Session> mSessions = new HashSet<Session>();
-
+
/**
* 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 @@
* over them.
*/
final ArrayList<WindowToken> mTokenList = new ArrayList<WindowToken>();
-
+
/**
* Window tokens that are in the process of exiting, but still
* on screen for animations.
@@ -314,9 +315,9 @@
* list or contain windows that need to be force removed.
*/
ArrayList<WindowState> mForceRemoves;
-
+
IInputMethodManager mInputMethodManager;
-
+
SurfaceSession mFxSession;
Surface mDimSurface;
boolean mDimShown;
@@ -326,9 +327,9 @@
long mLastDimAnimTime;
Surface mBlurSurface;
boolean mBlurShown;
-
+
int mTransactionSequence = 0;
-
+
final float[] mTmpFloats = new float[9];
boolean mSafeMode;
@@ -340,7 +341,7 @@
int mLastRotationFlags;
ArrayList<IRotationWatcher> mRotationWatchers
= new ArrayList<IRotationWatcher>();
-
+
boolean mLayoutNeeded = true;
boolean mAnimationPending = false;
boolean mDisplayFrozen = false;
@@ -352,7 +353,7 @@
// 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 @@
boolean mSkipAppTransitionAnimation = false;
final ArrayList<AppWindowToken> mOpeningApps = new ArrayList<AppWindowToken>();
final ArrayList<AppWindowToken> mClosingApps = new ArrayList<AppWindowToken>();
-
+
//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<WindowState> mInputMethodDialogs = new ArrayList<WindowState>();
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 @@
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 @@
}
}
}
-
+
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 @@
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 @@
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 @@
mContext = context;
mPM = pm;
}
-
+
public void run() {
Looper.prepare();
//Looper.myLooper().setMessageLogging(new LogPrinter(
@@ -483,12 +484,12 @@
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 @@
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 @@
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 @@
}
}
}
-
+
mInputThread.start();
-
+
// Add ourself to the Watchdog monitors.
Watchdog.getInstance().addMonitor(this);
}
@@ -586,12 +587,12 @@
}
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 @@
} 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 @@
// 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 @@
}
}
}
-
+
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 @@
}
return false;
}
-
+
int findDesiredInputMethodWindowIndexLocked(boolean willMove) {
final ArrayList localmWindows = mWindows;
final int N = localmWindows.size();
@@ -793,12 +794,12 @@
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 @@
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 @@
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 @@
}
}
}
-
+
//Log.i(TAG, "Placing input method @" + (i+1));
if (w != null) {
if (willMove) {
@@ -904,7 +905,7 @@
}
return -1;
}
-
+
void addInputMethodWindowToListLocked(WindowState win) {
int pos = findDesiredInputMethodWindowIndexLocked(true);
if (pos >= 0) {
@@ -917,7 +918,7 @@
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 @@
+ " anim layer: " + imw.mAnimLayer);
}
}
-
+
private int tmpRemoveWindowLocked(int interestingPos, WindowState win) {
int wpos = mWindows.indexOf(win);
if (wpos >= 0) {
@@ -963,7 +964,7 @@
}
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 @@
reAddWindowLocked(wpos, win);
}
}
-
+
void logWindowList(String prefix) {
int N = mWindows.size();
while (N > 0) {
@@ -983,10 +984,10 @@
Log.v(TAG, prefix + "#" + N + ": " + mWindows.get(N));
}
}
-
+
void moveInputMethodDialogsLocked(int pos) {
ArrayList<WindowState> 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<N; i++) {
@@ -996,7 +997,7 @@
Log.v(TAG, "Window list w/pos=" + pos);
logWindowList(" ");
}
-
+
if (pos >= 0) {
final AppWindowToken targetAppToken = mInputMethodTarget.mAppToken;
if (pos < mWindows.size()) {
@@ -1027,25 +1028,25 @@
}
}
}
-
+
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 @@
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 @@
return false;
}
}
-
+
if (imWin != null) {
if (DEBUG_INPUT_METHOD) {
Log.v(TAG, "Moving IM from " + imPos);
@@ -1099,11 +1100,11 @@
} 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 @@
} 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 @@
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 @@
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 @@
}
mPolicy.adjustWindowParamsLw(win.mAttrs);
-
+
res = mPolicy.prepareAddWindowLw(win, attrs);
if (res != WindowManagerImpl.ADD_OKAY) {
return res;
@@ -1236,9 +1237,9 @@
// 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 @@
}
boolean imMayMove = true;
-
+
if (attrs.type == TYPE_INPUT_METHOD) {
mInputMethodWindow = win;
addInputMethodWindowToListLocked(win);
@@ -1265,18 +1266,18 @@
} 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 @@
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 @@
}
}
Binder.restoreCallingIdentity(origId);
-
+
return res;
}
-
+
public void removeWindow(Session session, IWindow client) {
synchronized(mWindowMap) {
WindowState win = windowForClientLocked(session, client);
@@ -1335,7 +1336,7 @@
removeWindowLocked(session, win);
}
}
-
+
public void removeWindowLocked(Session session, WindowState win) {
if (localLOGV || DEBUG_FOCUS) Log.v(
@@ -1345,7 +1346,7 @@
+ ", 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 @@
// 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 @@
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 @@
} 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 @@
mH.sendMessage(m);
}
}
-
+
if (!mInLayout) {
assignLayersLocked();
mLayoutNeeded = true;
@@ -1492,7 +1493,7 @@
}
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 @@
Binder.restoreCallingIdentity(origId);
}
}
-
+
public void getWindowDisplayFrame(Session session, IWindow client,
Rect outDisplayFrame) {
synchronized(mWindowMap) {
@@ -1533,7 +1534,7 @@
boolean inTouchMode;
Configuration newConfig = null;
long origId = Binder.clearCallingIdentity();
-
+
synchronized(mWindowMap) {
WindowState win = windowForClientLocked(session, client);
if (win == null) {
@@ -1545,7 +1546,7 @@
if (attrs != null) {
mPolicy.adjustWindowParamsLw(attrs);
}
-
+
int attrChanges = 0;
int flagChanges = 0;
if (attrs != null) {
@@ -1577,11 +1578,11 @@
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 @@
}
//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 @@
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 @@
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 @@
}
return null;
}
-
+
private void applyEnterAnimationLocked(WindowState win) {
int transit = WindowManagerPolicy.TRANSIT_SHOW;
if (win.mEnterAnimationPending) {
@@ -1767,7 +1768,7 @@
// 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 @@
}
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 @@
if (Binder.getCallingPid() == Process.myPid()) {
return true;
}
-
+
if (mContext.checkCallingPermission(permission)
== PackageManager.PERMISSION_GRANTED) {
return true;
@@ -1943,7 +1944,7 @@
Log.w(TAG, msg);
return false;
}
-
+
AppWindowToken findAppWindowToken(IBinder token) {
WindowToken wtoken = mTokenMap.get(token);
if (wtoken == null) {
@@ -1951,13 +1952,13 @@
}
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 @@
mTokenList.add(wtoken);
}
}
-
+
public void removeWindowToken(IBinder token) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"removeWindowToken()")) {
@@ -1984,17 +1985,17 @@
boolean delayed = false;
if (!wtoken.hidden) {
wtoken.hidden = true;
-
+
final int N = wtoken.windows.size();
boolean changed = false;
-
+
for (int i=0; i<N; i++) {
WindowState win = wtoken.windows.get(i);
if (win.isAnimating()) {
delayed = true;
}
-
+
if (win.isVisibleNow()) {
applyAnimationLocked(win,
WindowManagerPolicy.TRANSIT_EXIT, false);
@@ -2009,12 +2010,12 @@
performLayoutAndPlaceSurfacesLocked();
updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL);
}
-
+
if (delayed) {
mExitingTokens.add(wtoken);
}
}
-
+
} else {
Log.w(TAG, "Attempted to remove non-existing token: " + token);
}
@@ -2028,7 +2029,7 @@
"addAppToken()")) {
return;
}
-
+
synchronized(mWindowMap) {
AppWindowToken wtoken = findAppWindowToken(token.asBinder());
if (wtoken != null) {
@@ -2043,15 +2044,15 @@
if (localLOGV) Log.v(TAG, "Adding new app token: " + wtoken);
mTokenMap.put(token.asBinder(), wtoken);
mTokenList.add(wtoken);
-
+
// Application tokens start out hidden.
wtoken.hidden = true;
wtoken.hiddenRequested = true;
-
+
//dump();
}
}
-
+
public void setAppGroupId(IBinder token, int groupId) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppStartingIcon()")) {
@@ -2067,7 +2068,7 @@
wtoken.groupId = groupId;
}
}
-
+
public int getOrientationFromWindowsLocked() {
int pos = mWindows.size() - 1;
while (pos >= 0) {
@@ -2091,7 +2092,7 @@
}
return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
-
+
public int getOrientationFromAppTokensLocked() {
int pos = mAppTokens.size() - 1;
int curGroup = 0;
@@ -2133,7 +2134,7 @@
// 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 @@
}
return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
-
+
public Configuration updateOrientationFromAppTokens(
Configuration currentConfig, IBinder freezeThisOneIfNeeded) {
Configuration config;
@@ -2165,11 +2166,11 @@
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 @@
long ident = Binder.clearCallingIdentity();
try {
int req = computeForcedAppOrientationLocked();
-
+
if (req != mForcedAppOrientation) {
changed = true;
mForcedAppOrientation = req;
@@ -2187,7 +2188,7 @@
//action like disabling/enabling sensors etc.,
mPolicy.setCurrentOrientationLw(req);
}
-
+
if (changed) {
changed = setRotationUncheckedLocked(
WindowManagerPolicy.USE_LAST_ROTATION,
@@ -2219,10 +2220,10 @@
} finally {
Binder.restoreCallingIdentity(ident);
}
-
+
return null;
}
-
+
int computeForcedAppOrientationLocked() {
int req = getOrientationFromWindowsLocked();
if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
@@ -2230,35 +2231,35 @@
}
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 @@
"prepareAppTransition()")) {
return;
}
-
+
synchronized(mWindowMap) {
if (DEBUG_APP_TRANSITIONS) Log.v(
TAG, "Prepare app transition: transit=" + transit
@@ -2320,13 +2321,13 @@
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 @@
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 @@
if (mDisplayFrozen) {
return;
}
-
+
if (wtoken.startingData != null) {
return;
}
-
+
if (transferFrom != null) {
AppWindowToken ttoken = findAppWindowToken(transferFrom);
if (ttoken != null) {
@@ -2384,7 +2385,7 @@
"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 @@
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 @@
wtoken.updateLayers();
ttoken.updateLayers();
}
-
+
updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES);
mLayoutNeeded = true;
performLayoutAndPlaceSurfacesLocked();
@@ -2462,7 +2463,7 @@
if (!createIfNeeded) {
return;
}
-
+
mStartingIconInTransition = true;
wtoken.startingData = new StartingData(
pkg, theme, nonLocalizedLabel,
@@ -2492,7 +2493,7 @@
wtoken.willBeHidden = true;
}
}
-
+
boolean setTokenVisibilityLocked(AppWindowToken wtoken, WindowManager.LayoutParams lp,
boolean visible, int transit, boolean performLayout) {
boolean delayed = false;
@@ -2501,7 +2502,7 @@
wtoken.clientHidden = !visible;
wtoken.sendAppVisibilityToClients();
}
-
+
wtoken.willBeHidden = false;
if (wtoken.hidden == visible) {
final int N = wtoken.allAppWindows.size();
@@ -2509,9 +2510,9 @@
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 @@
delayed = runningAppAnimation = true;
}
}
-
+
for (int i=0; i<N; i++) {
WindowState win = wtoken.allAppWindows.get(i);
if (win == wtoken.startingWindow) {
@@ -2532,7 +2533,7 @@
if (win.isAnimating()) {
delayed = true;
}
-
+
//Log.i(TAG, "Window " + win + ": vis=" + win.isVisible());
//win.dump(" ");
if (visible) {
@@ -2567,11 +2568,11 @@
swin.mPolicyVisibilityAfterAnim = false;
}
}
-
+
if (DEBUG_APP_TRANSITIONS) Log.v(TAG, "setTokenVisibilityLocked: " + wtoken
+ ": hidden=" + wtoken.hidden + " hiddenRequested="
+ wtoken.hiddenRequested);
-
+
if (changed && performLayout) {
mLayoutNeeded = true;
updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES);
@@ -2582,7 +2583,7 @@
if (wtoken.animation != null) {
delayed = true;
}
-
+
return delayed;
}
@@ -2609,7 +2610,7 @@
+ " hidden=" + wtoken.hidden
+ " hiddenRequested=" + wtoken.hiddenRequested, e);
}
-
+
// If we are preparing an app transition, then delay changing
// the visibility of this token until we execute that transition.
if (!mDisplayFrozen && mNextAppTransition != WindowManagerPolicy.TRANSIT_NONE) {
@@ -2618,7 +2619,7 @@
return;
}
wtoken.hiddenRequested = !visible;
-
+
if (DEBUG_APP_TRANSITIONS) Log.v(
TAG, "Setting dummy animation on: " + wtoken);
wtoken.setDummyAnimation();
@@ -2630,7 +2631,7 @@
wtoken.allDrawn = false;
wtoken.startingDisplayed = false;
wtoken.startingMoved = false;
-
+
if (wtoken.clientHidden) {
// In the case where we are making an app visible
// but holding off for a transition, we still need
@@ -2646,7 +2647,7 @@
}
return;
}
-
+
final long origId = Binder.clearCallingIdentity();
setTokenVisibilityLocked(wtoken, null, visible, WindowManagerPolicy.TRANSIT_NONE, true);
wtoken.updateReportedVisibilityLocked();
@@ -2687,7 +2688,7 @@
}
}
}
-
+
public void startAppFreezingScreenLocked(AppWindowToken wtoken,
int configChanges) {
if (DEBUG_ORIENTATION) {
@@ -2715,7 +2716,7 @@
}
}
}
-
+
public void startAppFreezingScreen(IBinder token, int configChanges) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppFreezingScreen()")) {
@@ -2727,7 +2728,7 @@
if (DEBUG_ORIENTATION) Log.v(TAG, "Skipping set freeze of " + token);
return;
}
-
+
AppWindowToken wtoken = findAppWindowToken(token);
if (wtoken == null || wtoken.appToken == null) {
Log.w(TAG, "Attempted to freeze screen with non-existing app token: " + wtoken);
@@ -2738,7 +2739,7 @@
Binder.restoreCallingIdentity(origId);
}
}
-
+
public void stopAppFreezingScreen(IBinder token, boolean force) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppFreezingScreen()")) {
@@ -2757,7 +2758,7 @@
Binder.restoreCallingIdentity(origId);
}
}
-
+
public void removeAppToken(IBinder token) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"removeAppToken()")) {
@@ -2806,7 +2807,7 @@
} else {
Log.w(TAG, "Attempted to remove non-existing app token: " + token);
}
-
+
if (!delayed && wtoken != null) {
wtoken.updateReportedVisibilityLocked();
}
@@ -2840,13 +2841,13 @@
Log.v(TAG, " #" + i + ": " + mAppTokens.get(i).token);
}
}
-
+
void dumpWindowsLocked() {
for (int i=mWindows.size()-1; i>=0; i--) {
Log.v(TAG, " #" + i + ": " + mWindows.get(i));
}
}
-
+
private int findWindowOffsetLocked(int tokenPos) {
final int NW = mWindows.size();
@@ -2917,7 +2918,7 @@
}
return index;
}
-
+
private final int reAddAppWindowsLocked(int index, WindowToken token) {
final int NW = token.windows.size();
for (int i=0; i<NW; i++) {
@@ -2944,7 +2945,7 @@
mAppTokens.add(index, wtoken);
if (DEBUG_REORDER) Log.v(TAG, "Moved " + token + " to " + index + ":");
if (DEBUG_REORDER) dumpAppTokensLocked();
-
+
final long origId = Binder.clearCallingIdentity();
if (DEBUG_REORDER) Log.v(TAG, "Removing windows in " + token + ":");
if (DEBUG_REORDER) dumpWindowsLocked();
@@ -3055,7 +3056,7 @@
// -------------------------------------------------------------
// Misc IWindowSession methods
// -------------------------------------------------------------
-
+
public void disableKeyguard(IBinder token, String tag) {
if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
!= PackageManager.PERMISSION_GRANTED) {
@@ -3109,13 +3110,13 @@
public boolean inKeyguardRestrictedInputMode() {
return mPolicy.inKeyguardRestrictedKeyInputMode();
}
-
+
static float fixScale(float scale) {
if (scale < 0) scale = 0;
else if (scale > 20) scale = 20;
return Math.abs(scale);
}
-
+
public void setAnimationScale(int which, float scale) {
if (!checkCallingPermission(android.Manifest.permission.SET_ANIMATION_SCALE,
"setAnimationScale()")) {
@@ -3129,11 +3130,11 @@
case 0: mWindowAnimationScale = fixScale(scale); break;
case 1: mTransitionAnimationScale = fixScale(scale); break;
}
-
+
// Persist setting
mH.obtainMessage(H.PERSIST_ANIMATION_SCALE).sendToTarget();
}
-
+
public void setAnimationScales(float[] scales) {
if (!checkCallingPermission(android.Manifest.permission.SET_ANIMATION_SCALE,
"setAnimationScale()")) {
@@ -3148,11 +3149,11 @@
mTransitionAnimationScale = fixScale(scales[1]);
}
}
-
+
// Persist setting
mH.obtainMessage(H.PERSIST_ANIMATION_SCALE).sendToTarget();
}
-
+
public float getAnimationScale(int which) {
switch (which) {
case 0: return mWindowAnimationScale;
@@ -3160,11 +3161,11 @@
}
return 0;
}
-
+
public float[] getAnimationScales() {
return new float[] { mWindowAnimationScale, mTransitionAnimationScale };
}
-
+
public int getSwitchState(int sw) {
if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
"getSwitchState()")) {
@@ -3172,7 +3173,7 @@
}
return KeyInputQueue.getSwitchState(sw);
}
-
+
public int getSwitchStateForDevice(int devid, int sw) {
if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
"getSwitchStateForDevice()")) {
@@ -3180,7 +3181,7 @@
}
return KeyInputQueue.getSwitchState(devid, sw);
}
-
+
public int getScancodeState(int sw) {
if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
"getScancodeState()")) {
@@ -3188,7 +3189,7 @@
}
return KeyInputQueue.getScancodeState(sw);
}
-
+
public int getScancodeStateForDevice(int devid, int sw) {
if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
"getScancodeStateForDevice()")) {
@@ -3196,7 +3197,7 @@
}
return KeyInputQueue.getScancodeState(devid, sw);
}
-
+
public int getKeycodeState(int sw) {
if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
"getKeycodeState()")) {
@@ -3204,7 +3205,7 @@
}
return KeyInputQueue.getKeycodeState(sw);
}
-
+
public int getKeycodeStateForDevice(int devid, int sw) {
if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
"getKeycodeStateForDevice()")) {
@@ -3212,11 +3213,11 @@
}
return KeyInputQueue.getKeycodeState(devid, sw);
}
-
+
public boolean hasKeys(int[] keycodes, boolean[] keyExists) {
return KeyInputQueue.hasKeys(keycodes, keyExists);
}
-
+
public void enableScreenAfterBoot() {
synchronized(mWindowMap) {
if (mSystemBooted) {
@@ -3224,10 +3225,10 @@
}
mSystemBooted = true;
}
-
+
performEnableScreen();
}
-
+
public void enableScreenIfNeededLocked() {
if (mDisplayEnabled) {
return;
@@ -3237,7 +3238,7 @@
}
mH.sendMessage(mH.obtainMessage(H.ENABLE_SCREEN));
}
-
+
public void performEnableScreen() {
synchronized(mWindowMap) {
if (mDisplayEnabled) {
@@ -3246,7 +3247,7 @@
if (!mSystemBooted) {
return;
}
-
+
// Don't enable the screen until all existing windows
// have been drawn.
final int N = mWindows.size();
@@ -3256,7 +3257,7 @@
return;
}
}
-
+
mDisplayEnabled = true;
if (false) {
Log.i(TAG, "ENABLING SCREEN!");
@@ -3279,21 +3280,21 @@
Log.e(TAG, "Boot completed: SurfaceFlinger is dead!");
}
}
-
+
mPolicy.enableScreenAfterBoot();
-
+
// Make sure the last requested orientation has been applied.
setRotationUnchecked(WindowManagerPolicy.USE_LAST_ROTATION, false,
mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
}
-
+
public void setInTouchMode(boolean mode) {
synchronized(mWindowMap) {
mInTouchMode = mode;
}
}
- public void setRotation(int rotation,
+ public void setRotation(int rotation,
boolean alwaysSendConfiguration, int animFlags) {
if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION,
"setRotation()")) {
@@ -3302,18 +3303,18 @@
setRotationUnchecked(rotation, alwaysSendConfiguration, animFlags);
}
-
+
public void setRotationUnchecked(int rotation,
boolean alwaysSendConfiguration, int animFlags) {
if(DEBUG_ORIENTATION) Log.v(TAG,
"alwaysSendConfiguration set to "+alwaysSendConfiguration);
-
+
long origId = Binder.clearCallingIdentity();
boolean changed;
synchronized(mWindowMap) {
changed = setRotationUncheckedLocked(rotation, animFlags);
}
-
+
if (changed) {
sendNewConfiguration();
synchronized(mWindowMap) {
@@ -3324,10 +3325,10 @@
//update configuration ignoring orientation change
sendNewConfiguration();
}
-
+
Binder.restoreCallingIdentity(origId);
}
-
+
public boolean setRotationUncheckedLocked(int rotation, int animFlags) {
boolean changed;
if (rotation == WindowManagerPolicy.USE_LAST_ROTATION) {
@@ -3341,9 +3342,9 @@
mRotation, mDisplayEnabled);
if (DEBUG_ORIENTATION) Log.v(TAG, "new rotation is set to " + rotation);
changed = mDisplayEnabled && mRotation != rotation;
-
+
if (changed) {
- if (DEBUG_ORIENTATION) Log.v(TAG,
+ if (DEBUG_ORIENTATION) Log.v(TAG,
"Rotation changed to " + rotation
+ " from " + mRotation
+ " (forceApp=" + mForcedAppOrientation
@@ -3372,10 +3373,10 @@
}
}
} //end if changed
-
+
return changed;
}
-
+
public int getRotation() {
return mRotation;
}
@@ -3394,7 +3395,7 @@
}
}
};
-
+
synchronized (mWindowMap) {
try {
watcher.asBinder().linkToDeath(dr, 0);
@@ -3402,7 +3403,7 @@
} catch (RemoteException e) {
// Client died, no cleanup needed.
}
-
+
return mRotation;
}
}
@@ -3418,7 +3419,7 @@
* @see com.android.server.ViewServer#VIEW_SERVER_DEFAULT_PORT
*/
public boolean startViewServer(int port) {
- if ("1".equals(SystemProperties.get(SYSTEM_SECURE, "0"))) {
+ if (isSystemSecure()) {
return false;
}
@@ -3435,7 +3436,7 @@
try {
return mViewServer.start();
} catch (IOException e) {
- Log.w(TAG, "View server did not start");
+ Log.w(TAG, "View server did not start");
}
}
return false;
@@ -3450,6 +3451,11 @@
return false;
}
+ private boolean isSystemSecure() {
+ return "1".equals(SystemProperties.get(SYSTEM_SECURE, "1")) &&
+ "0".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0"));
+ }
+
/**
* Stops the view server if it exists.
*
@@ -3459,7 +3465,7 @@
* @see com.android.server.ViewServer
*/
public boolean stopViewServer() {
- if ("1".equals(SystemProperties.get(SYSTEM_SECURE, "0"))) {
+ if (isSystemSecure()) {
return false;
}
@@ -3481,7 +3487,7 @@
* @see com.android.server.ViewServer
*/
public boolean isViewServerRunning() {
- if ("1".equals(SystemProperties.get(SYSTEM_SECURE, "0"))) {
+ if (isSystemSecure()) {
return false;
}
@@ -3502,7 +3508,7 @@
* @return False if an error occured, true otherwise.
*/
boolean viewServerListWindows(Socket client) {
- if ("1".equals(SystemProperties.get(SYSTEM_SECURE, "0"))) {
+ if (isSystemSecure()) {
return false;
}
@@ -3569,7 +3575,7 @@
* not indicate whether the command itself was successful.
*/
boolean viewServerWindowCommand(Socket client, String command, String parameters) {
- if ("1".equals(SystemProperties.get(SYSTEM_SECURE, "0"))) {
+ if (isSystemSecure()) {
return false;
}
@@ -3659,13 +3665,13 @@
} catch (RemoteException e) {
}
}
-
+
public Configuration computeNewConfiguration() {
synchronized (mWindowMap) {
return computeNewConfigurationLocked();
}
}
-
+
Configuration computeNewConfigurationLocked() {
Configuration config = new Configuration();
if (!computeNewConfigurationLocked(config)) {
@@ -3686,7 +3692,7 @@
}
return config;
}
-
+
boolean computeNewConfigurationLocked(Configuration config) {
if (mDisplay == null) {
return false;
@@ -3706,7 +3712,7 @@
mPolicy.adjustConfigurationLw(config);
return true;
}
-
+
// -------------------------------------------------------------
// Input Events and Focus Management
// -------------------------------------------------------------
@@ -3776,9 +3782,9 @@
Object targetObj = mKeyWaiter.waitForNextEventTarget(null, qev,
ev, true, false);
-
+
int action = ev.getAction();
-
+
if (action == MotionEvent.ACTION_UP) {
// let go of our target
mKeyWaiter.mMotionTarget = null;
@@ -3809,11 +3815,11 @@
ev.recycle();
return true;
}
-
+
WindowState target = (WindowState)targetObj;
-
+
final long eventTime = ev.getEventTime();
-
+
//Log.i(TAG, "Sending " + ev + " to " + target);
if (uid != 0 && uid != target.mSession.mUid) {
@@ -3830,8 +3836,8 @@
return false;
}
}
-
- if ((target.mAttrs.flags &
+
+ if ((target.mAttrs.flags &
WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES) != 0) {
//target wants to ignore fat touch events
boolean cheekPress = mPolicy.isCheekPressedAgainstScreen(ev);
@@ -3858,7 +3864,7 @@
if(mFatTouch) {
//two cases here
//an invalid down followed by 0 or moves(valid or invalid)
- //a valid down, invalid move, more moves. want to ignore till up
+ //a valid down, invalid move, more moves. want to ignore till up
returnFlag = true;
} else if(cheekPress) {
//valid down followed by invalid moves
@@ -3943,7 +3949,7 @@
mKeyWaiter.bindTargetWindowLocked(target);
}
}
-
+
// finally offset the event to the target's coordinate system and
// dispatch the event.
try {
@@ -3964,14 +3970,14 @@
}
return false;
}
-
+
/**
* @return Returns true if event was dispatched, false if it was dropped for any reason
*/
private boolean dispatchTrackball(QueuedEvent qev, MotionEvent ev, int pid, int uid) {
if (DEBUG_INPUT) Log.v(
TAG, "dispatchTrackball [" + ev.getAction() +"] <" + ev.getX() + ", " + ev.getY() + ">");
-
+
Object focusObj = mKeyWaiter.waitForNextEventTarget(null, qev,
ev, false, false);
if (focusObj == null) {
@@ -3989,9 +3995,9 @@
ev.recycle();
return true;
}
-
+
WindowState focus = (WindowState)focusObj;
-
+
if (uid != 0 && uid != focus.mSession.mUid) {
if (mContext.checkPermission(
android.Manifest.permission.INJECT_EVENTS, pid, uid)
@@ -4006,9 +4012,9 @@
return false;
}
}
-
+
final long eventTime = ev.getEventTime();
-
+
synchronized(mWindowMap) {
if (qev != null && ev.getAction() == MotionEvent.ACTION_MOVE) {
mKeyWaiter.bindTargetWindowLocked(focus,
@@ -4020,7 +4026,7 @@
mKeyWaiter.bindTargetWindowLocked(focus);
}
}
-
+
try {
focus.mClient.dispatchTrackball(ev, eventTime);
return true;
@@ -4033,10 +4039,10 @@
// removed.
}
}
-
+
return false;
}
-
+
/**
* @return Returns true if event was dispatched, false if it was dropped for any reason
*/
@@ -4052,9 +4058,9 @@
if (focusObj == mKeyWaiter.CONSUMED_EVENT_TOKEN) {
return true;
}
-
+
WindowState focus = (WindowState)focusObj;
-
+
if (DEBUG_INPUT) Log.v(
TAG, "Dispatching to " + focus + ": " + event);
@@ -4068,7 +4074,7 @@
return false;
}
}
-
+
synchronized(mWindowMap) {
mKeyWaiter.bindTargetWindowLocked(focus);
}
@@ -4076,7 +4082,7 @@
// NOSHIP extra state logging
mKeyWaiter.recordDispatchState(event, focus);
// END NOSHIP
-
+
try {
if (DEBUG_INPUT || DEBUG_FOCUS) {
Log.v(TAG, "Delivering key " + event.getKeyCode()
@@ -4093,10 +4099,10 @@
// removed.
}
}
-
+
return false;
}
-
+
public void pauseKeyDispatching(IBinder _token) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"pauseKeyDispatching()")) {
@@ -4135,11 +4141,11 @@
mKeyWaiter.setEventDispatchingLocked(enabled);
}
}
-
+
/**
* Injects a keystroke event into the UI.
- *
- * @param ev A motion event describing the keystroke action. (Be sure to use
+ *
+ * @param ev A motion event describing the keystroke action. (Be sure to use
* {@link SystemClock#uptimeMillis()} as the timebase.)
* @param sync If true, wait for the event to be completed before returning to the caller.
* @return Returns true if event was dispatched, false if it was dropped for any reason
@@ -4170,9 +4176,9 @@
/**
* Inject a pointer (touch) event into the UI.
- *
- * @param ev A motion event describing the pointer (touch) action. (As noted in
- * {@link MotionEvent#obtain(long, long, int, float, float, int)}, be sure to use
+ *
+ * @param ev A motion event describing the pointer (touch) action. (As noted in
+ * {@link MotionEvent#obtain(long, long, int, float, float, int)}, be sure to use
* {@link SystemClock#uptimeMillis()} as the timebase.)
* @param sync If true, wait for the event to be completed before returning to the caller.
* @return Returns true if event was dispatched, false if it was dropped for any reason
@@ -4182,14 +4188,14 @@
if (sync) {
mKeyWaiter.waitForNextEventTarget(null, null, null, false, true);
}
- return result;
+ return result;
}
-
+
/**
* Inject a trackball (navigation device) event into the UI.
- *
- * @param ev A motion event describing the trackball action. (As noted in
- * {@link MotionEvent#obtain(long, long, int, float, float, int)}, be sure to use
+ *
+ * @param ev A motion event describing the trackball action. (As noted in
+ * {@link MotionEvent#obtain(long, long, int, float, float, int)}, be sure to use
* {@link SystemClock#uptimeMillis()} as the timebase.)
* @param sync If true, wait for the event to be completed before returning to the caller.
* @return Returns true if event was dispatched, false if it was dropped for any reason
@@ -4201,7 +4207,7 @@
}
return result;
}
-
+
private WindowState getFocusedWindow() {
synchronized (mWindowMap) {
return getFocusedWindowLocked();
@@ -4211,7 +4217,7 @@
private WindowState getFocusedWindowLocked() {
return mCurrentFocus;
}
-
+
/**
* This class holds the state for dispatching key events. This state
* is protected by the KeyWaiter instance, NOT by the window lock. You
@@ -4233,7 +4239,7 @@
private boolean wasFrozen;
private boolean focusPaused;
private WindowState curFocus;
-
+
DispatchState(KeyEvent theEvent, WindowState theFocus) {
focus = theFocus;
event = theEvent;
@@ -4255,7 +4261,7 @@
focusPaused = theFocus.mToken.paused;
}
}
-
+
public String toString() {
return "{{" + event + " to " + focus + " @ " + time
+ " lw=" + lastWin + " lb=" + lastBinder
@@ -4274,10 +4280,10 @@
public static final int RETURN_NOTHING = 0;
public static final int RETURN_PENDING_POINTER = 1;
public static final int RETURN_PENDING_TRACKBALL = 2;
-
+
final Object SKIP_TARGET_TOKEN = new Object();
final Object CONSUMED_EVENT_TOKEN = new Object();
-
+
private WindowState mLastWin = null;
private IBinder mLastBinder = null;
private boolean mFinished = true;
@@ -4285,10 +4291,10 @@
private boolean mEventDispatching = true;
private long mTimeToSwitch = 0;
/* package */ boolean mWasFrozen = false;
-
+
// Target of Motion events
WindowState mMotionTarget;
-
+
// Windows above the target who would like to receive an "outside"
// touch event for any down events outside of them.
WindowState mOutsideTouchTargets;
@@ -4333,9 +4339,9 @@
}
targetWin = (WindowState)target;
}
-
+
AppWindowToken targetApp = null;
-
+
// Now: is it okay to send the next event to this window?
synchronized (this) {
// First: did we come here based on the last window not
@@ -4344,7 +4350,7 @@
if (!targetIsNew && mLastWin == null) {
continue;
}
-
+
// We never dispatch events if not finished with the
// last one, or the display is frozen.
if (mFinished && !mDisplayFrozen) {
@@ -4363,7 +4369,7 @@
if (targetIsNew && !targetWin.mToken.paused) {
return targetWin;
}
-
+
// If we didn't find a target window, and there is no
// focused app window, then just eat the events.
} else if (mFocusedApp == null) {
@@ -4373,7 +4379,7 @@
return null;
}
}
-
+
if (DEBUG_INPUT) Log.v(
TAG, "Waiting for last key in " + mLastBinder
+ " target=" + targetWin
@@ -4384,10 +4390,10 @@
+ (targetWin != null ? targetWin.mToken.paused : false)
+ " mFocusedApp=" + mFocusedApp
+ " mCurrentFocus=" + mCurrentFocus);
-
+
targetApp = targetWin != null
? targetWin.mAppToken : mFocusedApp;
-
+
long curTimeout = keyDispatchingTimeout;
if (mTimeToSwitch != 0) {
long now = SystemClock.uptimeMillis();
@@ -4403,7 +4409,7 @@
curTimeout = switchTimeout;
}
}
-
+
try {
// after that continue
// processing keys, so we don't get stuck.
@@ -4467,7 +4473,7 @@
synchronized (this) {
if (abort && (mLastWin == targetWin || targetWin == null)) {
mFinished = true;
- if (mLastWin != null) {
+ if (mLastWin != null) {
if (DEBUG_INPUT) Log.v(TAG,
"Window " + mLastWin +
" timed out on key input");
@@ -4492,11 +4498,11 @@
}
}
}
-
+
Object findTargetWindow(KeyEvent nextKey, QueuedEvent qev,
MotionEvent nextMotion, boolean isPointerEvent) {
mOutsideTouchTargets = null;
-
+
if (nextKey != null) {
// Find the target window for a normal key event.
final int keycode = nextKey.getKeyCode();
@@ -4510,23 +4516,23 @@
+ nextKey);
return SKIP_TARGET_TOKEN;
}
-
+
// System.out.println("##### [" + SystemClock.uptimeMillis() + "] WindowManagerService.dispatchKey(" + keycode + ", " + down + ", " + repeatCount + ")");
-
+
WindowState focus = null;
synchronized(mWindowMap) {
focus = getFocusedWindowLocked();
}
-
+
wakeupIfNeeded(focus, LocalPowerManager.BUTTON_EVENT);
-
+
if (mPolicy.interceptKeyTi(focus,
keycode, nextKey.getMetaState(), down, repeatCount)) {
return CONSUMED_EVENT_TOKEN;
}
-
+
return focus;
-
+
} else if (!isPointerEvent) {
boolean dispatch = mKeyWaiter.checkShouldDispatchKey(-1);
if (!dispatch) {
@@ -4534,20 +4540,20 @@
+ nextMotion);
return SKIP_TARGET_TOKEN;
}
-
+
WindowState focus = null;
synchronized(mWindowMap) {
focus = getFocusedWindowLocked();
}
-
+
wakeupIfNeeded(focus, LocalPowerManager.BUTTON_EVENT);
return focus;
}
-
+
if (nextMotion == null) {
return SKIP_TARGET_TOKEN;
}
-
+
boolean dispatch = mKeyWaiter.checkShouldDispatchKey(
KeyEvent.KEYCODE_UNKNOWN);
if (!dispatch) {
@@ -4555,18 +4561,18 @@
+ nextMotion);
return SKIP_TARGET_TOKEN;
}
-
+
// Find the target window for a pointer event.
int action = nextMotion.getAction();
final float xf = nextMotion.getX();
final float yf = nextMotion.getY();
final long eventTime = nextMotion.getEventTime();
-
+
final boolean screenWasOff = qev != null
&& (qev.flags&WindowManagerPolicy.FLAG_BRIGHT_HERE) != 0;
-
+
WindowState target = null;
-
+
synchronized(mWindowMap) {
synchronized (this) {
if (action == MotionEvent.ACTION_DOWN) {
@@ -4579,12 +4585,12 @@
+ mMotionTarget);
mMotionTarget = null;
}
-
+
// ACTION_DOWN is special, because we need to lock next events to
// the window we'll land onto.
final int x = (int)xf;
final int y = (int)yf;
-
+
final ArrayList windows = mWindows;
final int N = windows.size();
WindowState topErrWindow = null;
@@ -4645,7 +4651,7 @@
}
break;
}
-
+
if ((flags & WindowManager.LayoutParams
.FLAG_WATCH_OUTSIDE_TOUCH) != 0) {
child.mNextOutsideTouch = mOutsideTouchTargets;
@@ -4662,18 +4668,18 @@
mMotionTarget = null;
}
}
-
+
target = mMotionTarget;
}
}
-
+
wakeupIfNeeded(target, eventType(nextMotion));
-
+
// Pointer events are a little different -- if there isn't a
// target found for any event, then just drop it.
return target != null ? target : SKIP_TARGET_TOKEN;
}
-
+
boolean checkShouldDispatchKey(int keycode) {
synchronized (this) {
if (mPolicy.isAppSwitchKeyTqTiLwLi(keycode)) {
@@ -4687,14 +4693,14 @@
return true;
}
}
-
+
void bindTargetWindowLocked(WindowState win,
int pendingWhat, QueuedEvent pendingMotion) {
synchronized (this) {
bindTargetWindowLockedLocked(win, pendingWhat, pendingMotion);
}
}
-
+
void bindTargetWindowLocked(WindowState win) {
synchronized (this) {
bindTargetWindowLockedLocked(win, RETURN_NOTHING, null);
@@ -4712,7 +4718,7 @@
releasePendingPointerLocked(s);
s.mPendingPointerMove = pendingMotion;
s.mPendingPointerWindow = win;
- if (DEBUG_INPUT) Log.v(TAG,
+ if (DEBUG_INPUT) Log.v(TAG,
"bindTargetToWindow " + s.mPendingPointerMove);
} else if (pendingWhat == RETURN_PENDING_TRACKBALL) {
releasePendingTrackballLocked(s);
@@ -4721,7 +4727,7 @@
}
}
}
-
+
void releasePendingPointerLocked(Session s) {
if (DEBUG_INPUT) Log.v(TAG,
"releasePendingPointer " + s.mPendingPointerMove);
@@ -4730,14 +4736,14 @@
s.mPendingPointerMove = null;
}
}
-
+
void releasePendingTrackballLocked(Session s) {
if (s.mPendingTrackballMove != null) {
mQueue.recycleEvent(s.mPendingTrackballMove);
s.mPendingTrackballMove = null;
}
}
-
+
MotionEvent finishedKey(Session session, IWindow client, boolean force,
int returnWhat) {
if (DEBUG_INPUT) Log.v(
@@ -4766,7 +4772,7 @@
session.mPendingTrackballMove = null;
session.mPendingTrackballWindow = null;
}
-
+
if (mLastBinder == client.asBinder()) {
if (DEBUG_INPUT) Log.v(
TAG, "finishedKey: last paused="
@@ -4782,7 +4788,7 @@
notifyAll();
}
}
-
+
if (qev != null) {
MotionEvent res = (MotionEvent)qev.event;
if (DEBUG_INPUT) Log.v(TAG,
@@ -4802,7 +4808,7 @@
notifyAll();
}
}
-
+
void handleNewWindowLocked(WindowState newWindow) {
if (!newWindow.canReceiveKeys()) {
return;
@@ -4903,7 +4909,7 @@
notifyAll();
}
}
-
+
void appSwitchComing() {
synchronized (this) {
// Don't wait for more than .5 seconds for app to finish
@@ -4916,13 +4922,13 @@
notifyAll();
}
}
-
+
private final void doFinishedKeyLocked(boolean doRecycle) {
if (mLastWin != null) {
releasePendingPointerLocked(mLastWin.mSession);
releasePendingTrackballLocked(mLastWin.mSession);
}
-
+
if (mLastWin == null || !mLastWin.mToken.paused
|| !mLastWin.isVisibleLw()) {
// If the current window has been paused, we aren't -really-
@@ -4938,7 +4944,7 @@
private class KeyQ extends KeyInputQueue
implements KeyInputQueue.FilterCallback {
PowerManager.WakeLock mHoldingScreen;
-
+
KeyQ() {
super(mContext);
PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
@@ -4952,7 +4958,7 @@
if (mPolicy.preprocessInputEventTq(event)) {
return true;
}
-
+
switch (event.type) {
case RawInputEvent.EV_KEY: {
// XXX begin hack
@@ -4972,11 +4978,11 @@
}
}
// XXX end hack
-
+
boolean screenIsOff = !mPowerManager.screenIsOn();
boolean screenIsDim = !mPowerManager.screenIsBright();
int actions = mPolicy.interceptKeyTq(event, !screenIsOff);
-
+
if ((actions & WindowManagerPolicy.ACTION_GO_TO_SLEEP) != 0) {
mPowerManager.goToSleep(event.when);
}
@@ -4991,7 +4997,7 @@
mPowerManager.userActivity(event.when, false,
LocalPowerManager.BUTTON_EVENT, false);
}
-
+
if ((actions & WindowManagerPolicy.ACTION_PASS_TO_USER) != 0) {
if (event.value != 0 && mPolicy.isAppSwitchKeyTqTiLwLi(event.keycode)) {
filterQueue(this);
@@ -5002,7 +5008,7 @@
return false;
}
}
-
+
case RawInputEvent.EV_REL: {
boolean screenIsOff = !mPowerManager.screenIsOn();
boolean screenIsDim = !mPowerManager.screenIsBright();
@@ -5019,7 +5025,7 @@
}
return true;
}
-
+
case RawInputEvent.EV_ABS: {
boolean screenIsOff = !mPowerManager.screenIsOn();
boolean screenIsDim = !mPowerManager.screenIsBright();
@@ -5036,7 +5042,7 @@
}
return true;
}
-
+
default:
return true;
}
@@ -5056,7 +5062,7 @@
return FILTER_KEEP;
}
}
-
+
/**
* Must be called with the main window manager lock held.
*/
@@ -5077,11 +5083,11 @@
mSafeMode = mPolicy.detectSafeMode();
return mSafeMode;
}
-
+
public void systemReady() {
mPolicy.systemReady();
}
-
+
private final class InputDispatcherThread extends Thread {
// Time to wait when there is nothing to do: 9999 seconds.
static final int LONG_WAIT=9999*1000;
@@ -5089,7 +5095,7 @@
public InputDispatcherThread() {
super("InputDispatcher");
}
-
+
@Override
public void run() {
while (true) {
@@ -5100,11 +5106,11 @@
}
}
}
-
+
private void process() {
android.os.Process.setThreadPriority(
android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);
-
+
// The last key event we saw
KeyEvent lastKey = null;
@@ -5112,12 +5118,12 @@
long lastKeyTime = SystemClock.uptimeMillis();
long nextKeyTime = lastKeyTime+LONG_WAIT;
- // How many successive repeats we generated
+ // How many successive repeats we generated
int keyRepeatCount = 0;
// Need to report that configuration has changed?
boolean configChanged = false;
-
+
while (true) {
long curTime = SystemClock.uptimeMillis();
@@ -5198,14 +5204,14 @@
mQueue.recycleEvent(ev);
break;
}
-
+
} else if (configChanged) {
configChanged = false;
sendNewConfiguration();
-
+
} else if (lastKey != null) {
curTime = SystemClock.uptimeMillis();
-
+
// Timeout occurred while key was down. If it is at or
// past the key repeat time, dispatch the repeat.
if (DEBUG_INPUT) Log.v(
@@ -5214,7 +5220,7 @@
if (curTime < nextKeyTime) {
continue;
}
-
+
lastKeyTime = nextKeyTime;
nextKeyTime = nextKeyTime + KEY_REPEAT_DELAY;
keyRepeatCount++;
@@ -5222,14 +5228,14 @@
TAG, "Key repeat: count=" + keyRepeatCount
+ ", next @ " + nextKeyTime);
dispatchKey(KeyEvent.changeTimeRepeat(lastKey, curTime, keyRepeatCount), 0, 0);
-
+
} else {
curTime = SystemClock.uptimeMillis();
-
+
lastKeyTime = curTime;
nextKeyTime = curTime + LONG_WAIT;
}
-
+
} catch (Exception e) {
Log.e(TAG,
"Input thread received uncaught exception: " + e, e);
@@ -5252,14 +5258,14 @@
SurfaceSession mSurfaceSession;
int mNumWindow = 0;
boolean mClientDead = false;
-
+
/**
* Current pointer move event being dispatched to client window... must
* hold key lock to access.
*/
QueuedEvent mPendingPointerMove;
WindowState mPendingPointerWindow;
-
+
/**
* Current trackball move event being dispatched to client window... must
* hold key lock to access.
@@ -5279,7 +5285,7 @@
sb.append(mUid);
sb.append("}");
mStringName = sb.toString();
-
+
synchronized (mWindowMap) {
if (mInputMethodManager == null && mHaveInputMethods) {
IBinder b = ServiceManager.getService(
@@ -5310,7 +5316,7 @@
Binder.restoreCallingIdentity(ident);
}
}
-
+
@Override
public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
throws RemoteException {
@@ -5344,11 +5350,11 @@
int viewVisibility, Rect outContentInsets) {
return addWindow(this, window, attrs, viewVisibility, outContentInsets);
}
-
+
public void remove(IWindow window) {
removeWindow(this, window);
}
-
+
public int relayout(IWindow window, WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewFlags,
boolean insetsPending, Rect outFrame, Rect outContentInsets,
@@ -5357,21 +5363,21 @@
requestedWidth, requestedHeight, viewFlags, insetsPending,
outFrame, outContentInsets, outVisibleInsets, outSurface);
}
-
+
public void setTransparentRegion(IWindow window, Region region) {
setTransparentRegionWindow(this, window, region);
}
-
+
public void setInsets(IWindow window, int touchableInsets,
Rect contentInsets, Rect visibleInsets) {
setInsetsWindow(this, window, touchableInsets, contentInsets,
visibleInsets);
}
-
+
public void getDisplayFrame(IWindow window, Rect outDisplayFrame) {
getWindowDisplayFrame(this, window, outDisplayFrame);
}
-
+
public void finishDrawing(IWindow window) {
if (localLOGV) Log.v(
TAG, "IWindow finishDrawing called for " + window);
@@ -5391,7 +5397,7 @@
return mKeyWaiter.finishedKey(this, window, false,
KeyWaiter.RETURN_PENDING_POINTER);
}
-
+
public MotionEvent getPendingTrackballMove(IWindow window) {
if (localLOGV) Log.v(
TAG, "IWindow getPendingMotionEvent called for " + window);
@@ -5423,7 +5429,7 @@
}
}
}
-
+
void windowAddedLocked() {
if (mSurfaceSession == null) {
if (localLOGV) Log.v(
@@ -5438,7 +5444,7 @@
mNumWindow--;
killSessionLocked();
}
-
+
void killSessionLocked() {
if (mNumWindow <= 0 && mClientDead) {
mSessions.remove(this);
@@ -5457,7 +5463,7 @@
}
}
}
-
+
void dump(PrintWriter pw, String prefix) {
pw.print(prefix); pw.print("mNumWindow="); pw.print(mNumWindow);
pw.print(" mClientDead="); pw.print(mClientDead);
@@ -5518,11 +5524,11 @@
boolean mHaveFrame;
WindowState mNextOutsideTouch;
-
+
// Actual frame shown on-screen (may be modified by animation)
final Rect mShownFrame = new Rect();
final Rect mLastShownFrame = new Rect();
-
+
/**
* Insets that determine the actually visible area
*/
@@ -5542,19 +5548,19 @@
* given internal insets before laying out other windows based on it.
*/
boolean mGivenInsetsPending;
-
+
/**
* These are the content insets that were given during layout for
* this window, to be applied to windows behind it.
*/
final Rect mGivenContentInsets = new Rect();
-
+
/**
* These are the visible insets that were given during layout for
* this window, to be applied to windows behind it.
*/
final Rect mGivenVisibleInsets = new Rect();
-
+
/**
* Flag indicating whether the touchable region should be adjusted by
* the visible insets; if false the area outside the visible insets is
@@ -5562,7 +5568,7 @@
* tests.
*/
int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
-
+
// Current transformation being applied.
float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1;
float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1;
@@ -5601,7 +5607,7 @@
// where we don't yet have a surface, but should have one soon, so
// we can give the window focus before waiting for the relayout.
boolean mRelayoutCalled;
-
+
// This is set after the Surface has been created but before the
// window has been drawn. During this time the surface is hidden.
boolean mDrawPending;
@@ -5616,7 +5622,7 @@
// to delay showing the surface until all windows in a token are ready
// to be shown.
boolean mReadyToShow;
-
+
// Set when the window has been shown in the screen the first time.
boolean mHasDrawn;
@@ -5625,17 +5631,17 @@
// Currently on the mDestroySurface list?
boolean mDestroying;
-
+
// Completely remove from window manager after exit animation?
boolean mRemoveOnExit;
// Set when the orientation is changing and this window has not yet
// been updated for the new orientation.
boolean mOrientationChanging;
-
+
// Is this window now (or just being) removed?
boolean mRemoved;
-
+
WindowState(Session s, IWindow c, WindowToken token,
WindowState attachedWindow, WindowManager.LayoutParams a,
int viewVisibility) {
@@ -5661,7 +5667,7 @@
return;
}
mDeathRecipient = deathRecipient;
-
+
if ((mAttrs.type >= FIRST_SUB_WINDOW &&
mAttrs.type <= LAST_SUB_WINDOW)) {
// The multiplier here is to reserve space for multiple
@@ -5737,7 +5743,7 @@
w = mAttrs.width == mAttrs.FILL_PARENT ? pw : mRequestedWidth;
h = mAttrs.height== mAttrs.FILL_PARENT ? ph : mRequestedHeight;
}
-
+
final Rect container = mContainingFrame;
container.set(pf);
@@ -5746,12 +5752,12 @@
final Rect content = mContentFrame;
content.set(cf);
-
+
final Rect visible = mVisibleFrame;
visible.set(vf);
-
+
final Rect frame = mFrame;
-
+
//System.out.println("In: w=" + w + " h=" + h + " container=" +
// container + " x=" + mAttrs.x + " y=" + mAttrs.y);
@@ -5763,7 +5769,7 @@
// Now make sure the window fits in the overall display.
Gravity.applyDisplay(mAttrs.gravity, df, frame);
-
+
// Make sure the content and visible frames are inside of the
// final window frame.
if (content.left < frame.left) content.left = frame.left;
@@ -5774,19 +5780,19 @@
if (visible.top < frame.top) visible.top = frame.top;
if (visible.right > frame.right) visible.right = frame.right;
if (visible.bottom > frame.bottom) visible.bottom = frame.bottom;
-
+
final Rect contentInsets = mContentInsets;
contentInsets.left = content.left-frame.left;
contentInsets.top = content.top-frame.top;
contentInsets.right = frame.right-content.right;
contentInsets.bottom = frame.bottom-content.bottom;
-
+
final Rect visibleInsets = mVisibleInsets;
visibleInsets.left = visible.left-frame.left;
visibleInsets.top = visible.top-frame.top;
visibleInsets.right = frame.right-visible.right;
visibleInsets.bottom = frame.bottom-visible.bottom;
-
+
if (localLOGV) {
//if ("com.google.android.youtube".equals(mAttrs.packageName)
// && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
@@ -5799,7 +5805,7 @@
//}
}
}
-
+
public Rect getFrameLw() {
return mFrame;
}
@@ -5827,11 +5833,11 @@
public Rect getGivenContentInsetsLw() {
return mGivenContentInsets;
}
-
+
public Rect getGivenVisibleInsetsLw() {
return mGivenVisibleInsets;
}
-
+
public WindowManager.LayoutParams getAttrs() {
return mAttrs;
}
@@ -5839,7 +5845,7 @@
public int getSurfaceLayer() {
return mLayer;
}
-
+
public IApplicationToken getAppToken() {
return mAppToken != null ? mAppToken.appToken : null;
}
@@ -5873,7 +5879,7 @@
mAnimation = null;
}
}
-
+
Surface createSurfaceLocked() {
if (mSurface == null) {
mDrawPending = true;
@@ -5913,7 +5919,7 @@
try {
mSurface = new Surface(
- mSession.mSurfaceSession, mSession.mPid,
+ mSession.mSurfaceSession, mSession.mPid,
0, w, h, mAttrs.format, flags);
} catch (Surface.OutOfResourcesException e) {
Log.w(TAG, "OutOfResourcesException creating surface");
@@ -5923,7 +5929,7 @@
Log.e(TAG, "Exception creating surface", e);
return null;
}
-
+
if (localLOGV) Log.v(
TAG, "Got surface: " + mSurface
+ ", set left=" + mFrame.left + " top=" + mFrame.top
@@ -5960,7 +5966,7 @@
}
return mSurface;
}
-
+
void destroySurfaceLocked() {
// Window is no longer on-screen, so can no longer receive
// key events... if we were waiting for it to finish
@@ -5973,7 +5979,7 @@
if (mAppToken != null && this == mAppToken.startingWindow) {
mAppToken.startingDisplayed = false;
}
-
+
if (localLOGV) Log.v(
TAG, "Window " + this
+ " destroying surface " + mSurface + ", session " + mSession);
@@ -6063,7 +6069,7 @@
enableScreenIfNeededLocked();
applyEnterAnimationLocked(this);
-
+
int i = mChildWindows.size();
while (i > 0) {
i--;
@@ -6073,7 +6079,7 @@
c.performShowLocked();
}
}
-
+
if (mAttrs.type != TYPE_APPLICATION_STARTING
&& mAppToken != null) {
mAppToken.firstWindowDrawn = true;
@@ -6089,13 +6095,13 @@
}
return true;
}
-
+
// This must be called while inside a transaction. Returns true if
// there is more animation to run.
boolean stepAnimationLocked(long currentTime, int dw, int dh) {
if (!mDisplayFrozen) {
// We will run animations as long as the display isn't frozen.
-
+
if (!mDrawPending && !mCommitDrawPending && mAnimation != null) {
mHasTransformation = true;
mHasLocalTransformation = true;
@@ -6153,7 +6159,7 @@
mLocalAnimating = true;
mAnimation = null;
}
-
+
if (!mAnimating && !mLocalAnimating) {
return false;
}
@@ -6162,7 +6168,7 @@
TAG, "Animation done in " + this + ": exiting=" + mExiting
+ ", reportedVisible="
+ (mAppToken != null ? mAppToken.reportedVisible : false));
-
+
mAnimating = false;
mLocalAnimating = false;
mAnimation = null;
@@ -6186,7 +6192,7 @@
mFinishedStarting.add(mAppToken);
mH.sendEmptyMessage(H.FINISHED_STARTING);
}
-
+
finishExit();
if (mAppToken != null) {
@@ -6202,16 +6208,16 @@
+ ": exiting=" + mExiting
+ " remove=" + mRemoveOnExit
+ " windowAnimating=" + isWindowAnimating());
-
+
final int N = mChildWindows.size();
for (int i=0; i<N; i++) {
((WindowState)mChildWindows.get(i)).finishExit();
}
-
+
if (!mExiting) {
return;
}
-
+
if (isWindowAnimating()) {
return;
}
@@ -6238,7 +6244,7 @@
mRemoveOnExit = false;
}
}
-
+
boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
if (dsdx < .99999f || dsdx > 1.00001f) return false;
if (dtdy < .99999f || dtdy > 1.00001f) return false;
@@ -6246,7 +6252,7 @@
if (dsdy < -.000001f || dsdy > .000001f) return false;
return true;
}
-
+
void computeShownFrameLocked() {
final boolean selfTransformation = mHasLocalTransformation;
Transformation attachedTransformation =
@@ -6257,7 +6263,7 @@
? mAppToken.transformation : null;
if (selfTransformation || attachedTransformation != null
|| appTransformation != null) {
- // cache often used attributes locally
+ // cache often used attributes locally
final Rect frame = mFrame;
final float tmpFloats[] = mTmpFloats;
final Matrix tmpMatrix = mTmpMatrix;
@@ -6279,7 +6285,7 @@
// Here we must not transform the position of the surface
// since it is already included in the transformation.
//Log.i(TAG, "Transform: " + matrix);
-
+
tmpMatrix.getValues(tmpFloats);
mDsDx = tmpFloats[Matrix.MSCALE_X];
mDtDx = tmpFloats[Matrix.MSKEW_X];
@@ -6314,14 +6320,14 @@
} else {
//Log.i(TAG, "Not applying alpha transform");
}
-
+
if (localLOGV) Log.v(
TAG, "Continuing animation in " + this +
": " + mShownFrame +
", alpha=" + mTransformation.getAlpha());
return;
}
-
+
mShownFrame.set(mFrame);
mShownAlpha = mAlpha;
mDsDx = 1;
@@ -6329,7 +6335,7 @@
mDsDy = 0;
mDtDy = 1;
}
-
+
/**
* Is this window visible? It is not visible if there is no
* surface, or we are in the process of running an exit animation
@@ -6392,7 +6398,7 @@
&& (!mAttachedHidden || mAnimating);
}
}
-
+
/**
* Like isOnScreen(), but we don't return true if the window is part
* of a transition that has not yet been started.
@@ -6411,7 +6417,7 @@
final AppWindowToken atoken = mAppToken;
return mAnimation != null
|| (attached != null && attached.mAnimation != null)
- || (atoken != null &&
+ || (atoken != null &&
(atoken.animation != null
|| atoken.inPendingTransaction));
}
@@ -6453,7 +6459,7 @@
}
return false;
}
-
+
boolean isFullscreenOpaque(int screenWidth, int screenHeight) {
if (mAttrs.format != PixelFormat.OPAQUE || mSurface == null
|| mAnimation != null || mDrawPending || mCommitDrawPending) {
@@ -6545,7 +6551,7 @@
void dump(PrintWriter pw, String prefix) {
StringBuilder sb = new StringBuilder(64);
-
+
pw.print(prefix); pw.print("mSession="); pw.print(mSession);
pw.print(" mClient="); pw.println(mClient.asBinder());
pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs);
@@ -6661,7 +6667,7 @@
+ " " + mAttrs.getTitle() + " paused=" + mToken.paused + "}";
}
}
-
+
// -------------------------------------------------------------
// Window Token State
// -------------------------------------------------------------
@@ -6672,17 +6678,17 @@
// The type of window this token is for, as per WindowManager.LayoutParams.
final int windowType;
-
+
// Set if this token was explicitly added by a client, so should
// not be removed when all windows are removed.
final boolean explicit;
-
+
// For printing.
String stringName;
-
+
// If this is an AppWindowToken, this is non-null.
AppWindowToken appWindowToken;
-
+
// All of the windows associated with this token.
final ArrayList<WindowState> windows = new ArrayList<WindowState>();
@@ -6733,7 +6739,7 @@
int groupId = -1;
boolean appFullscreen;
int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
-
+
// These are used for determining when all windows associated with
// an activity have been drawn, so they can be made visible together
// at the same time.
@@ -6742,20 +6748,20 @@
int numDrawnWindows;
boolean inPendingTransaction;
boolean allDrawn;
-
+
// Is this token going to be hidden in a little while? If so, it
// won't be taken into account for setting the screen orientation.
boolean willBeHidden;
-
+
// Is this window's surface needed? This is almost like hidden, except
// it will sometimes be true a little earlier: when the token has
// been shown, but is still waiting for its app transition to execute
// before making its windows shown.
boolean hiddenRequested;
-
+
// Have we told the window clients to hide themselves?
boolean clientHidden;
-
+
// Last visibility state we reported to the app token.
boolean reportedVisible;
@@ -6764,16 +6770,16 @@
// Have we been asked to have this token keep the screen frozen?
boolean freezingScreen;
-
+
boolean animating;
Animation animation;
boolean hasTransformation;
final Transformation transformation = new Transformation();
-
+
// Offset to the window of all layers in the token, for use by
// AppWindowToken animations.
int animLayerAdjustment;
-
+
// Information about an application starting window if displayed.
StartingData startingData;
WindowState startingWindow;
@@ -6788,7 +6794,7 @@
appWindowToken = this;
appToken = _token;
}
-
+
public void setAnimation(Animation anim) {
if (localLOGV) Log.v(
TAG, "Setting animation in " + this + ": " + anim);
@@ -6803,13 +6809,13 @@
} else if (zorder == Animation.ZORDER_BOTTOM) {
adj = -TYPE_LAYER_OFFSET;
}
-
+
if (animLayerAdjustment != adj) {
animLayerAdjustment = adj;
updateLayers();
}
}
-
+
public void setDummyAnimation() {
if (animation == null) {
if (localLOGV) Log.v(
@@ -6824,7 +6830,7 @@
animating = true;
}
}
-
+
void updateLayers() {
final int N = allAppWindows.size();
final int adj = animLayerAdjustment;
@@ -6838,7 +6844,7 @@
}
}
}
-
+
void sendAppVisibilityToClients() {
final int N = allAppWindows.size();
for (int i=0; i<N; i++) {
@@ -6855,7 +6861,7 @@
}
}
}
-
+
void showAllWindowsLocked() {
final int NW = allAppWindows.size();
for (int i=0; i<NW; i++) {
@@ -6865,12 +6871,12 @@
w.performShowLocked();
}
}
-
+
// This must be called while inside a transaction.
boolean stepAnimationLocked(long currentTime, int dw, int dh) {
if (!mDisplayFrozen) {
// We will run animations as long as the display isn't frozen.
-
+
if (animation == sDummyAnimation) {
// This guy is going to animate, but not yet. For now count
// it is not animating for purposes of scheduling transactions;
@@ -6878,7 +6884,7 @@
// a real animation and the next call will execute normally.
return false;
}
-
+
if ((allDrawn || animating || startingDisplayed) && animation != null) {
if (!animating) {
if (DEBUG_ANIM) Log.v(
@@ -6914,7 +6920,7 @@
}
hasTransformation = false;
-
+
if (!animating) {
return false;
}
@@ -6924,7 +6930,7 @@
if (mInputMethodTarget != null && mInputMethodTarget.mAppToken == this) {
moveInputMethodWindowsIfNeededLocked(true);
}
-
+
if (DEBUG_ANIM) Log.v(
TAG, "Animation done in " + this
+ ": reportedVisible=" + reportedVisible);
@@ -6934,13 +6940,13 @@
animLayerAdjustment = 0;
updateLayers();
}
-
+
final int N = windows.size();
for (int i=0; i<N; i++) {
((WindowState)windows.get(i)).finishExit();
}
updateReportedVisibilityLocked();
-
+
return false;
}
@@ -6948,11 +6954,11 @@
if (appToken == null) {
return;
}
-
+
int numInteresting = 0;
int numVisible = 0;
boolean nowGone = true;
-
+
if (DEBUG_VISIBILITY) Log.v(TAG, "Update reported visibility: " + this);
final int N = allAppWindows.size();
for (int i=0; i<N; i++) {
@@ -6986,7 +6992,7 @@
nowGone = false;
}
}
-
+
boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
if (DEBUG_VISIBILITY) Log.v(TAG, "VIS " + this + ": interesting="
+ numInteresting + " visible=" + numVisible);
@@ -7003,7 +7009,7 @@
mH.sendMessage(m);
}
}
-
+
void dump(PrintWriter pw, String prefix) {
super.dump(pw, prefix);
if (appToken != null) {
@@ -7068,7 +7074,7 @@
return stringName;
}
}
-
+
public static WindowManager.LayoutParams findAnimations(
ArrayList<AppWindowToken> order,
ArrayList<AppWindowToken> tokenList1,
@@ -7076,7 +7082,7 @@
// We need to figure out which animation to use...
WindowManager.LayoutParams animParams = null;
int animSrc = 0;
-
+
//Log.i(TAG, "Looking for animations...");
for (int i=order.size()-1; i>=0; i--) {
AppWindowToken wtoken = order.get(i);
@@ -7105,10 +7111,10 @@
}
}
}
-
+
return animParams;
}
-
+
// -------------------------------------------------------------
// DummyAnimation
// -------------------------------------------------------------
@@ -7122,7 +7128,7 @@
}
}
static final Animation sDummyAnimation = new DummyAnimation();
-
+
// -------------------------------------------------------------
// Async Handler
// -------------------------------------------------------------
@@ -7133,7 +7139,7 @@
final CharSequence nonLocalizedLabel;
final int labelRes;
final int icon;
-
+
StartingData(String _pkg, int _theme, CharSequence _nonLocalizedLabel,
int _labelRes, int _icon) {
pkg = _pkg;
@@ -7160,19 +7166,19 @@
public static final int ENABLE_SCREEN = 16;
public static final int APP_FREEZE_TIMEOUT = 17;
public static final int COMPUTE_AND_SEND_NEW_CONFIGURATION = 18;
-
+
private Session mLastReportedHold;
-
+
public H() {
}
-
+
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case REPORT_FOCUS_CHANGE: {
WindowState lastFocus;
WindowState newFocus;
-
+
synchronized(mWindowMap) {
lastFocus = mLastFocus;
newFocus = mCurrentFocus;
@@ -7216,7 +7222,7 @@
case REPORT_LOSING_FOCUS: {
ArrayList<WindowState> losers;
-
+
synchronized(mWindowMap) {
losers = mLosingFocus;
mLosingFocus = new ArrayList<WindowState>();
@@ -7248,10 +7254,10 @@
// Animation has been canceled... do nothing.
return;
}
-
+
if (DEBUG_STARTING_WINDOW) Log.v(TAG, "Add starting "
+ wtoken + ": pkg=" + sd.pkg);
-
+
View view = null;
try {
view = mPolicy.addStartingWindow(
@@ -7378,7 +7384,7 @@
} catch (RemoteException ex) {
}
} break;
-
+
case WINDOW_FREEZE_TIMEOUT: {
synchronized (mWindowMap) {
Log.w(TAG, "Window freeze timeout expired.");
@@ -7395,7 +7401,7 @@
}
break;
}
-
+
case HOLD_SCREEN_CHANGED: {
Session oldHold;
Session newHold;
@@ -7404,7 +7410,7 @@
newHold = (Session)msg.obj;
mLastReportedHold = newHold;
}
-
+
if (oldHold != newHold) {
try {
if (oldHold != null) {
@@ -7422,7 +7428,7 @@
}
break;
}
-
+
case APP_TRANSITION_TIMEOUT: {
synchronized (mWindowMap) {
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_NONE) {
@@ -7435,7 +7441,7 @@
}
break;
}
-
+
case PERSIST_ANIMATION_SCALE: {
Settings.System.putFloat(mContext.getContentResolver(),
Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
@@ -7443,7 +7449,7 @@
Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
break;
}
-
+
case FORCE_GC: {
synchronized(mWindowMap) {
if (mAnimationPending) {
@@ -7463,12 +7469,12 @@
Runtime.getRuntime().gc();
break;
}
-
+
case ENABLE_SCREEN: {
performEnableScreen();
break;
}
-
+
case APP_FREEZE_TIMEOUT: {
synchronized (mWindowMap) {
Log.w(TAG, "App freeze timeout expired.");
@@ -7484,14 +7490,14 @@
}
break;
}
-
+
case COMPUTE_AND_SEND_NEW_CONFIGURATION: {
if (updateOrientationFromAppTokens(null, null) != null) {
sendNewConfiguration();
}
break;
}
-
+
}
}
}
@@ -7525,7 +7531,7 @@
}
return false;
}
-
+
// -------------------------------------------------------------
// Internals
// -------------------------------------------------------------
@@ -7533,7 +7539,7 @@
final WindowState windowForClientLocked(Session session, IWindow client) {
return windowForClientLocked(session, client.asBinder());
}
-
+
final WindowState windowForClientLocked(Session session, IBinder client) {
WindowState win = mWindowMap.get(client);
if (localLOGV) Log.v(
@@ -7558,7 +7564,7 @@
int curBaseLayer = 0;
int curLayer = 0;
int i;
-
+
for (i=0; i<N; i++) {
WindowState w = (WindowState)mWindows.get(i);
if (w.mBaseLayer == curBaseLayer || w.mIsImWindow) {
@@ -7614,11 +7620,11 @@
}
}
}
-
+
mInLayout = true;
try {
performLayoutAndPlaceSurfacesLockedInner(recoveringMemory);
-
+
int i = mPendingRemove.size()-1;
if (i >= 0) {
while (i >= 0) {
@@ -7654,7 +7660,7 @@
int i;
// FIRST LOOP: Perform a layout, if needed.
-
+
while (mLayoutNeeded) {
mPolicy.beginLayoutLw(dw, dh);
@@ -7689,7 +7695,7 @@
}
}
}
-
+
// Now perform layout of attached windows, which usually
// depend on the position of the window they are attached to.
// XXX does not deal with windows that are attached to windows
@@ -7720,7 +7726,7 @@
}
}
}
-
+
private final void performLayoutAndPlaceSurfacesLockedInner(
boolean recoveringMemory) {
final long currentTime = SystemClock.uptimeMillis();
@@ -7732,11 +7738,11 @@
// FIRST LOOP: Perform a layout, if needed.
performLayoutLockedInner();
-
+
if (mFxSession == null) {
mFxSession = new SurfaceSession();
}
-
+
if (SHOW_TRANSACTIONS) Log.i(TAG, ">>> OPEN TRANSACTION");
// Initialize state of exiting tokens.
@@ -8060,7 +8066,7 @@
!w.mLastContentInsets.equals(w.mContentInsets);
w.mVisibleInsetsChanged =
!w.mLastVisibleInsets.equals(w.mVisibleInsets);
- if (!w.mLastFrame.equals(w.mFrame)
+ if (!w.mLastFrame.equals(w.mFrame)
|| w.mContentInsetsChanged
|| w.mVisibleInsetsChanged) {
w.mLastFrame.set(w.mFrame);
@@ -8082,7 +8088,7 @@
w.mAppToken.allDrawn = false;
}
}
- if (DEBUG_ORIENTATION) Log.v(TAG,
+ if (DEBUG_ORIENTATION) Log.v(TAG,
"Resizing window " + w + " to " + w.mFrame);
mResizingWindows.add(w);
} else if (w.mOrientationChanging) {
@@ -8272,7 +8278,7 @@
if (SHOW_TRANSACTIONS) Log.i(TAG, " DIM "
+ mDimSurface + ": CREATE");
try {
- mDimSurface = new Surface(mFxSession, 0,
+ mDimSurface = new Surface(mFxSession, 0,
-1, 16, 16,
PixelFormat.OPAQUE,
Surface.FX_SURFACE_DIM);
@@ -8327,7 +8333,7 @@
if (SHOW_TRANSACTIONS) Log.i(TAG, " BLUR "
+ mBlurSurface + ": CREATE");
try {
- mBlurSurface = new Surface(mFxSession, 0,
+ mBlurSurface = new Surface(mFxSession, 0,
-1, 16, 16,
PixelFormat.OPAQUE,
Surface.FX_SURFACE_BLUR);
@@ -8381,7 +8387,7 @@
} else {
more = false;
}
-
+
// Do we need to continue animating?
if (more) {
if (SHOW_TRANSACTIONS) Log.i(TAG, " DIM "
@@ -8407,7 +8413,7 @@
}
}
}
-
+
if (!blurring && mBlurShown) {
if (SHOW_TRANSACTIONS) Log.i(TAG, " BLUR " + mBlurSurface
+ ": HIDE");
@@ -8425,7 +8431,7 @@
}
Surface.closeTransaction();
-
+
if (DEBUG_ORIENTATION && mDisplayFrozen) Log.v(TAG,
"With display frozen, orientationChangeComplete="
+ orientationChangeComplete);
@@ -8438,7 +8444,7 @@
stopFreezingDisplayLocked();
}
}
-
+
i = mResizingWindows.size();
if (i > 0) {
do {
@@ -8456,7 +8462,7 @@
} while (i > 0);
mResizingWindows.clear();
}
-
+
// Destroy the surface of any windows that are no longer visible.
i = mDestroySurface.size();
if (i > 0) {
@@ -8515,13 +8521,13 @@
mH.sendMessageDelayed(mH.obtainMessage(H.ANIMATE), delay);
}
}
-
+
/**
* Have the surface flinger show a surface, robustly dealing with
* error conditions. In particular, if there is not enough memory
* to show the surface, then we will try to get rid of other surfaces
* in order to succeed.
- *
+ *
* @return Returns true if the surface was successfully shown.
*/
boolean showSurfaceRobustlyLocked(WindowState win) {
@@ -8533,22 +8539,22 @@
} catch (RuntimeException e) {
Log.w(TAG, "Failure showing surface " + win.mSurface + " in " + win);
}
-
+
reclaimSomeSurfaceMemoryLocked(win, "show");
-
+
return false;
}
-
+
void reclaimSomeSurfaceMemoryLocked(WindowState win, String operation) {
final Surface surface = win.mSurface;
-
+
EventLog.writeEvent(LOG_WM_NO_SURFACE_MEMORY, win.toString(),
win.mSession.mPid, operation);
-
+
if (mForceRemoves == null) {
mForceRemoves = new ArrayList<WindowState>();
}
-
+
long callingIdentity = Binder.clearCallingIdentity();
try {
// There was some problem... first, do a sanity check of the
@@ -8582,7 +8588,7 @@
}
}
}
-
+
boolean killedApps = false;
if (!leakedSurface) {
Log.w(TAG, "No leaked surfaces; killing applicatons!");
@@ -8606,7 +8612,7 @@
}
}
}
-
+
if (leakedSurface || killedApps) {
// We managed to reclaim some memory, so get rid of the trouble
// surface and ask the app to request another one.
@@ -8615,7 +8621,7 @@
surface.clear();
win.mSurface = null;
}
-
+
try {
win.mClient.dispatchGetNewSurface();
} catch (RemoteException e) {
@@ -8625,7 +8631,7 @@
Binder.restoreCallingIdentity(callingIdentity);
}
}
-
+
private boolean updateFocusedWindowLocked(int mode) {
WindowState newFocus = computeFocusedWindowLocked();
if (mCurrentFocus != newFocus) {
@@ -8638,7 +8644,7 @@
final WindowState oldFocus = mCurrentFocus;
mCurrentFocus = newFocus;
mLosingFocus.remove(newFocus);
-
+
final WindowState imWindow = mInputMethodWindow;
if (newFocus != imWindow && oldFocus != imWindow) {
if (moveInputMethodWindowsIfNeededLocked(
@@ -8654,7 +8660,7 @@
assignLayersLocked();
}
}
-
+
if (newFocus != null && mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS) {
mKeyWaiter.handleNewWindowLocked(newFocus);
}
@@ -8682,13 +8688,13 @@
+ ", canReceive=" + win.canReceiveKeys());
AppWindowToken thisApp = win.mAppToken;
-
+
// If this window's application has been removed, just skip it.
if (thisApp != null && thisApp.removed) {
i--;
continue;
}
-
+
// If there is a focused app, don't allow focus to go to any
// windows below it. If this is an application window, step
// through the app tokens until we find its app.
@@ -8745,9 +8751,9 @@
}
return;
}
-
+
mScreenFrozenLock.acquire();
-
+
long now = SystemClock.uptimeMillis();
//Log.i(TAG, "Freezing, gc pending: " + mFreezeGcPending + ", now " + now);
if (mFreezeGcPending != 0) {
@@ -8760,32 +8766,32 @@
} else {
mFreezeGcPending = now;
}
-
+
mDisplayFrozen = true;
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_NONE) {
mNextAppTransition = WindowManagerPolicy.TRANSIT_NONE;
mAppTransitionReady = true;
}
-
+
if (PROFILE_ORIENTATION) {
File file = new File("/data/system/frozen");
Debug.startMethodTracing(file.toString(), 8 * 1024 * 1024);
}
Surface.freezeDisplay(0);
}
-
+
private void stopFreezingDisplayLocked() {
if (!mDisplayFrozen) {
return;
}
-
+
mDisplayFrozen = false;
mH.removeMessages(H.APP_FREEZE_TIMEOUT);
if (PROFILE_ORIENTATION) {
Debug.stopMethodTracing();
}
Surface.unfreezeDisplay(0);
-
+
// Reset the key delivery timeout on unfreeze, too. We force a wakeup here
// too because regular key delivery processing should resume immediately.
synchronized (mKeyWaiter) {
@@ -8801,10 +8807,10 @@
mH.removeMessages(H.FORCE_GC);
mH.sendMessageDelayed(mH.obtainMessage(H.FORCE_GC),
2000);
-
+
mScreenFrozenLock.release();
}
-
+
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission("android.permission.DUMP")
@@ -8814,7 +8820,7 @@
+ ", uid=" + Binder.getCallingUid());
return;
}
-
+
synchronized(mWindowMap) {
pw.println("Current Window Manager state:");
for (int i=mWindows.size()-1; i>=0; i--) {