am eec69d29: Merge "Fix bug with phantom input windows." into gingerbread

Merge commit 'eec69d2923636b2aaa51df93bacc2b3bbb742736' into gingerbread-plus-aosp

* commit 'eec69d2923636b2aaa51df93bacc2b3bbb742736':
  Fix bug with phantom input windows.
This commit is contained in:
Jeff Brown
2010-07-16 00:16:09 -07:00
committed by Android Git Automerger
9 changed files with 539 additions and 147 deletions

View File

@ -173117,6 +173117,19 @@
visibility="public" visibility="public"
> >
</constructor> </constructor>
<method name="getDevice"
return="android.view.InputDevice"
abstract="false"
native="false"
synchronized="false"
static="true"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="id" type="int">
</parameter>
</method>
<method name="getKeyCharacterMap" <method name="getKeyCharacterMap"
return="android.view.KeyCharacterMap" return="android.view.KeyCharacterMap"
abstract="false" abstract="false"
@ -173128,6 +173141,19 @@
visibility="public" visibility="public"
> >
</method> </method>
<method name="getMotionRange"
return="android.view.InputDevice.MotionRange"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="range" type="int">
</parameter>
</method>
<method name="getName" <method name="getName"
return="java.lang.String" return="java.lang.String"
abstract="false" abstract="false"
@ -173150,6 +173176,118 @@
visibility="public" visibility="public"
> >
</method> </method>
<method name="hasKey"
return="boolean"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="keyCode" type="int">
</parameter>
</method>
<field name="MOTION_RANGE_ORIENTATION"
type="int"
transient="false"
volatile="false"
value="8"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_PRESSURE"
type="int"
transient="false"
volatile="false"
value="2"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_SIZE"
type="int"
transient="false"
volatile="false"
value="3"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_TOOL_MAJOR"
type="int"
transient="false"
volatile="false"
value="6"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_TOOL_MINOR"
type="int"
transient="false"
volatile="false"
value="7"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_TOUCH_MAJOR"
type="int"
transient="false"
volatile="false"
value="4"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_TOUCH_MINOR"
type="int"
transient="false"
volatile="false"
value="5"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_X"
type="int"
transient="false"
volatile="false"
value="0"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="MOTION_RANGE_Y"
type="int"
transient="false"
volatile="false"
value="1"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="SOURCE_CLASS_BUTTON" <field name="SOURCE_CLASS_BUTTON"
type="int" type="int"
transient="false" transient="false"
@ -173327,6 +173465,78 @@
> >
</field> </field>
</class> </class>
<class name="InputDevice.MotionRange"
extends="java.lang.Object"
abstract="false"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
<constructor name="InputDevice.MotionRange"
type="android.view.InputDevice.MotionRange"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</constructor>
<method name="getFlat"
return="float"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getFuzz"
return="float"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getMax"
return="float"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getMin"
return="float"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getRange"
return="float"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
</class>
<class name="InputEvent" <class name="InputEvent"
extends="java.lang.Object" extends="java.lang.Object"
abstract="true" abstract="true"
@ -173337,6 +173547,17 @@
> >
<implements name="android.os.Parcelable"> <implements name="android.os.Parcelable">
</implements> </implements>
<method name="getDevice"
return="android.view.InputDevice"
abstract="false"
native="false"
synchronized="false"
static="false"
final="true"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getDeviceId" <method name="getDeviceId"
return="int" return="int"
abstract="false" abstract="false"

View File

@ -50,7 +50,7 @@ public final class InputDevice {
* *
* A {@link KeyEvent} should be interpreted as a button or key press. * A {@link KeyEvent} should be interpreted as a button or key press.
* *
* Use {@link #hasKeyCode} to query whether the device supports a particular button or key. * Use {@link #hasKey} to query whether the device supports a particular button or key.
*/ */
public static final int SOURCE_CLASS_BUTTON = 0x00000001; public static final int SOURCE_CLASS_BUTTON = 0x00000001;
@ -154,7 +154,7 @@ public final class InputDevice {
/** /**
* The input source is a touch pad or digitizer tablet that is not * The input source is a touch pad or digitizer tablet that is not
* associated with a display (unlike {@link SOURCE_TOUCHSCREEN}). * associated with a display (unlike {@link #SOURCE_TOUCHSCREEN}).
* *
* @see #SOURCE_CLASS_POSITION * @see #SOURCE_CLASS_POSITION
*/ */
@ -174,20 +174,79 @@ public final class InputDevice {
*/ */
public static final int SOURCE_JOYSTICK_RIGHT = 0x02000000 | SOURCE_CLASS_JOYSTICK; public static final int SOURCE_JOYSTICK_RIGHT = 0x02000000 | SOURCE_CLASS_JOYSTICK;
/* /**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#x}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_X = 0; public static final int MOTION_RANGE_X = 0;
/**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#y}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_Y = 1; public static final int MOTION_RANGE_Y = 1;
/**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#pressure}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_PRESSURE = 2; public static final int MOTION_RANGE_PRESSURE = 2;
/**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#size}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_SIZE = 3; public static final int MOTION_RANGE_SIZE = 3;
/**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#touchMajor}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_TOUCH_MAJOR = 4; public static final int MOTION_RANGE_TOUCH_MAJOR = 4;
/**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#touchMinor}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_TOUCH_MINOR = 5; public static final int MOTION_RANGE_TOUCH_MINOR = 5;
/**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#toolMajor}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_TOOL_MAJOR = 6; public static final int MOTION_RANGE_TOOL_MAJOR = 6;
/**
* Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#toolMinor}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_TOOL_MINOR = 7; public static final int MOTION_RANGE_TOOL_MINOR = 7;
/**
* Constant for retrieving the range of values for
* {@link MotionEvent.PointerCoords#orientation}.
*
* @see #getMotionRange
*/
public static final int MOTION_RANGE_ORIENTATION = 8; public static final int MOTION_RANGE_ORIENTATION = 8;
public static InputDevice getDevice(int id) { /**
} * Gets information about the input device with the specified id.
* @param id The device id.
* @return The input device or null if not found.
*/ */
public static InputDevice getDevice(int id) {
// TODO
return null;
}
/** /**
* Gets the name of this input device. * Gets the name of this input device.
@ -213,19 +272,80 @@ public final class InputDevice {
return KeyCharacterMap.load(mId); return KeyCharacterMap.load(mId);
} }
/* /**
* Gets information about the range of values for a particular {@link MotionEvent}
* coordinate.
* @param range The motion range constant.
* @return The range of values, or null if the requested coordinate is not
* supported by the device.
*/
public MotionRange getMotionRange(int range) { public MotionRange getMotionRange(int range) {
// TODO
return null;
} }
public boolean hasKeyCode(int keyCode) { /**
* Returns true if the device supports a particular button or key.
* @param keyCode The key code.
* @return True if the device supports the key.
*/
public boolean hasKey(int keyCode) {
// TODO
return false;
} }
/**
* Provides information about the range of values for a particular {@link MotionEvent}
* coordinate.
*/
public static final class MotionRange { public static final class MotionRange {
public float min; /**
public float max; * Gets the minimum value for the coordinate.
public float range; * @return The minimum value.
public float flat; */
public float fuzz; public float getMin() {
}*/ // TODO
return 0;
}
/**
* Gets the maximum value for the coordinate.
* @return The minimum value.
*/
public float getMax() {
// TODO
return 0;
}
/**
* Gets the range of the coordinate (difference between maximum and minimum).
* @return The range of values.
*/
public float getRange() {
// TODO
return 0;
}
/**
* Gets the extent of the center flat position with respect to this coordinate.
* For example, a flat value of 8 means that the center position is between -8 and +8.
* This value is mainly useful for calibrating joysticks.
* @return The extent of the center flat position.
*/
public float getFlat() {
// TODO
return 0;
}
/**
* Gets the error tolerance for input device measurements with respect to this coordinate.
* For example, a value of 2 indicates that the measured value may be up to +/- 2 units
* away from the actual value due to noise and device sensitivity limitations.
* @return The error tolerance.
*/
public float getFuzz() {
// TODO
return 0;
}
}
} }

View File

@ -41,10 +41,19 @@ public abstract class InputEvent implements Parcelable {
return mDeviceId; return mDeviceId;
} }
/**
* Gets the device that this event came from.
*
* @return The device, or null if unknown.
*/
public final InputDevice getDevice() {
return InputDevice.getDevice(mDeviceId);
}
/** /**
* Gets the source of the event. * Gets the source of the event.
* *
* @return The event source or {@link InputDevice.SOURCE_UNKNOWN} if unknown. * @return The event source or {@link InputDevice#SOURCE_UNKNOWN} if unknown.
* @see InputDevice#getSourceInfo * @see InputDevice#getSourceInfo
*/ */
public final int getSource() { public final int getSource() {

View File

@ -1403,7 +1403,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* current location, position and size is updated to the new values. * current location, position and size is updated to the new values.
* The current values in the event are added to a list of historical values. * The current values in the event are added to a list of historical values.
* *
* Only applies to {@link ACTION_MOVE} events. * Only applies to {@link #ACTION_MOVE} events.
* *
* @param eventTime The time stamp (in ms) for this data. * @param eventTime The time stamp (in ms) for this data.
* @param x The new X position. * @param x The new X position.
@ -1427,7 +1427,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* current location, position and size is updated to the new values. * current location, position and size is updated to the new values.
* The current values in the event are added to a list of historical values. * The current values in the event are added to a list of historical values.
* *
* Only applies to {@link ACTION_MOVE} events. * Only applies to {@link #ACTION_MOVE} events.
* *
* @param eventTime The time stamp (in ms) for this data. * @param eventTime The time stamp (in ms) for this data.
* @param pointerCoords The new pointer coordinates. * @param pointerCoords The new pointer coordinates.

View File

@ -171,6 +171,8 @@ public:
status_t append(const char* other); status_t append(const char* other);
status_t append(const char* other, size_t numChars); status_t append(const char* other, size_t numChars);
status_t appendFormat(const char* fmt, ...);
// Note that this function takes O(N) time to calculate the value. // Note that this function takes O(N) time to calculate the value.
// No cache value is stored. // No cache value is stored.
size_t getUtf32Length() const; size_t getUtf32Length() const;

View File

@ -372,6 +372,27 @@ status_t String8::append(const char* other, size_t otherLen)
return real_append(other, otherLen); return real_append(other, otherLen);
} }
status_t String8::appendFormat(const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
int result = NO_ERROR;
int n = vsnprintf(NULL, 0, fmt, ap);
if (n != 0) {
size_t oldLength = length();
char* buf = lockBuffer(oldLength + n);
if (buf) {
vsnprintf(buf + oldLength, n + 1, fmt, ap);
} else {
result = NO_MEMORY;
}
}
va_end(ap);
return result;
}
status_t String8::real_append(const char* other, size_t otherLen) status_t String8::real_append(const char* other, size_t otherLen)
{ {
const size_t myLen = bytes(); const size_t myLen = bytes();
@ -411,15 +432,16 @@ status_t String8::unlockBuffer(size_t size)
if (size != this->size()) { if (size != this->size()) {
SharedBuffer* buf = SharedBuffer::bufferFromData(mString) SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
->editResize(size+1); ->editResize(size+1);
if (buf) { if (! buf) {
return NO_MEMORY;
}
char* str = (char*)buf->data(); char* str = (char*)buf->data();
str[size] = 0; str[size] = 0;
mString = str; mString = str;
return NO_ERROR;
}
} }
return NO_MEMORY; return NO_ERROR;
} }
ssize_t String8::find(const char* other, size_t start) const ssize_t String8::find(const char* other, size_t start) const

View File

@ -56,8 +56,6 @@ public class InputManager {
private final Callbacks mCallbacks; private final Callbacks mCallbacks;
private final Context mContext; private final Context mContext;
private final WindowManagerService mWindowManagerService; private final WindowManagerService mWindowManagerService;
private final PowerManager mPowerManager;
private final PowerManagerService mPowerManagerService;
private int mTouchScreenConfig; private int mTouchScreenConfig;
private int mKeyboardConfig; private int mKeyboardConfig;
@ -85,6 +83,7 @@ public class InputManager {
private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen); private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen);
private static native void nativeSetFocusedApplication(InputApplication application); private static native void nativeSetFocusedApplication(InputApplication application);
private static native void nativePreemptInputDispatch(); private static native void nativePreemptInputDispatch();
private static native String nativeDump();
// Device class as defined by EventHub. // Device class as defined by EventHub.
private static final int CLASS_KEYBOARD = 0x00000001; private static final int CLASS_KEYBOARD = 0x00000001;
@ -100,14 +99,9 @@ public class InputManager {
static final int INPUT_EVENT_INJECTION_FAILED = 2; static final int INPUT_EVENT_INJECTION_FAILED = 2;
static final int INPUT_EVENT_INJECTION_TIMED_OUT = 3; static final int INPUT_EVENT_INJECTION_TIMED_OUT = 3;
public InputManager(Context context, public InputManager(Context context, WindowManagerService windowManagerService) {
WindowManagerService windowManagerService,
PowerManager powerManager,
PowerManagerService powerManagerService) {
this.mContext = context; this.mContext = context;
this.mWindowManagerService = windowManagerService; this.mWindowManagerService = windowManagerService;
this.mPowerManager = powerManager;
this.mPowerManagerService = powerManagerService;
this.mCallbacks = new Callbacks(); this.mCallbacks = new Callbacks();
@ -297,7 +291,10 @@ public class InputManager {
} }
public void dump(PrintWriter pw) { public void dump(PrintWriter pw) {
// TODO String dumpStr = nativeDump();
if (dumpStr != null) {
pw.println(dumpStr);
}
} }
private static final class VirtualKeyDefinition { private static final class VirtualKeyDefinition {

View File

@ -332,7 +332,7 @@ public class WindowManagerService extends IWindowManager.Stub
/** /**
* Z-ordered (bottom-most first) list of all Window objects. * Z-ordered (bottom-most first) list of all Window objects.
*/ */
final ArrayList mWindows = new ArrayList(); final ArrayList<WindowState> mWindows = new ArrayList<WindowState>();
/** /**
* Windows that are being resized. Used so we can tell the client about * Windows that are being resized. Used so we can tell the client about
@ -630,7 +630,7 @@ public class WindowManagerService extends IWindowManager.Stub
"KEEP_SCREEN_ON_FLAG"); "KEEP_SCREEN_ON_FLAG");
mHoldingScreenWakeLock.setReferenceCounted(false); mHoldingScreenWakeLock.setReferenceCounted(false);
mInputManager = new InputManager(context, this, pmc, mPowerManager); mInputManager = new InputManager(context, this);
PolicyThread thr = new PolicyThread(mPolicy, this, context, pm); PolicyThread thr = new PolicyThread(mPolicy, this, context, pm);
thr.start(); thr.start();
@ -665,7 +665,7 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
private void placeWindowAfter(Object pos, WindowState window) { private void placeWindowAfter(WindowState pos, WindowState window) {
final int i = mWindows.indexOf(pos); final int i = mWindows.indexOf(pos);
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v(
TAG, "Adding window " + window + " at " TAG, "Adding window " + window + " at "
@ -674,7 +674,7 @@ public class WindowManagerService extends IWindowManager.Stub
mWindowsChanged = true; mWindowsChanged = true;
} }
private void placeWindowBefore(Object pos, WindowState window) { private void placeWindowBefore(WindowState pos, WindowState window) {
final int i = mWindows.indexOf(pos); final int i = mWindows.indexOf(pos);
if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v(
TAG, "Adding window " + window + " at " TAG, "Adding window " + window + " at "
@ -687,13 +687,13 @@ public class WindowManagerService extends IWindowManager.Stub
//win. used for z ordering the windows in mWindows //win. used for z ordering the windows in mWindows
private int findIdxBasedOnAppTokens(WindowState win) { private int findIdxBasedOnAppTokens(WindowState win) {
//use a local variable to cache mWindows //use a local variable to cache mWindows
ArrayList localmWindows = mWindows; ArrayList<WindowState> localmWindows = mWindows;
int jmax = localmWindows.size(); int jmax = localmWindows.size();
if(jmax == 0) { if(jmax == 0) {
return -1; return -1;
} }
for(int j = (jmax-1); j >= 0; j--) { for(int j = (jmax-1); j >= 0; j--) {
WindowState wentry = (WindowState)localmWindows.get(j); WindowState wentry = localmWindows.get(j);
if(wentry.mAppToken == win.mAppToken) { if(wentry.mAppToken == win.mAppToken) {
return j; return j;
} }
@ -704,7 +704,7 @@ public class WindowManagerService extends IWindowManager.Stub
private void addWindowToListInOrderLocked(WindowState win, boolean addToToken) { private void addWindowToListInOrderLocked(WindowState win, boolean addToToken) {
final IWindow client = win.mClient; final IWindow client = win.mClient;
final WindowToken token = win.mToken; final WindowToken token = win.mToken;
final ArrayList localmWindows = mWindows; final ArrayList<WindowState> localmWindows = mWindows;
final int N = localmWindows.size(); final int N = localmWindows.size();
final WindowState attached = win.mAttachedWindow; final WindowState attached = win.mAttachedWindow;
@ -749,7 +749,7 @@ public class WindowManagerService extends IWindowManager.Stub
// Figure out where the window should go, based on the // Figure out where the window should go, based on the
// order of applications. // order of applications.
final int NA = mAppTokens.size(); final int NA = mAppTokens.size();
Object pos = null; WindowState pos = null;
for (i=NA-1; i>=0; i--) { for (i=NA-1; i>=0; i--) {
AppWindowToken t = mAppTokens.get(i); AppWindowToken t = mAppTokens.get(i);
if (t == token) { if (t == token) {
@ -769,8 +769,7 @@ public class WindowManagerService extends IWindowManager.Stub
// we need to look some more. // we need to look some more.
if (pos != null) { if (pos != null) {
// Move behind any windows attached to this one. // Move behind any windows attached to this one.
WindowToken atoken = WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
mTokenMap.get(((WindowState)pos).mClient.asBinder());
if (atoken != null) { if (atoken != null) {
final int NC = atoken.windows.size(); final int NC = atoken.windows.size();
if (NC > 0) { if (NC > 0) {
@ -796,8 +795,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (pos != null) { if (pos != null) {
// Move in front of any windows attached to this // Move in front of any windows attached to this
// one. // one.
WindowToken atoken = WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
mTokenMap.get(((WindowState)pos).mClient.asBinder());
if (atoken != null) { if (atoken != null) {
final int NC = atoken.windows.size(); final int NC = atoken.windows.size();
if (NC > 0) { if (NC > 0) {
@ -812,7 +810,7 @@ public class WindowManagerService extends IWindowManager.Stub
// Just search for the start of this layer. // Just search for the start of this layer.
final int myLayer = win.mBaseLayer; final int myLayer = win.mBaseLayer;
for (i=0; i<N; i++) { for (i=0; i<N; i++) {
WindowState w = (WindowState)localmWindows.get(i); WindowState w = localmWindows.get(i);
if (w.mBaseLayer > myLayer) { if (w.mBaseLayer > myLayer) {
break; break;
} }
@ -829,7 +827,7 @@ public class WindowManagerService extends IWindowManager.Stub
// Figure out where window should go, based on layer. // Figure out where window should go, based on layer.
final int myLayer = win.mBaseLayer; final int myLayer = win.mBaseLayer;
for (i=N-1; i>=0; i--) { for (i=N-1; i>=0; i--) {
if (((WindowState)localmWindows.get(i)).mBaseLayer <= myLayer) { if (localmWindows.get(i).mBaseLayer <= myLayer) {
i++; i++;
break; break;
} }
@ -912,13 +910,13 @@ public class WindowManagerService extends IWindowManager.Stub
} }
int findDesiredInputMethodWindowIndexLocked(boolean willMove) { int findDesiredInputMethodWindowIndexLocked(boolean willMove) {
final ArrayList localmWindows = mWindows; final ArrayList<WindowState> localmWindows = mWindows;
final int N = localmWindows.size(); final int N = localmWindows.size();
WindowState w = null; WindowState w = null;
int i = N; int i = N;
while (i > 0) { while (i > 0) {
i--; i--;
w = (WindowState)localmWindows.get(i); w = localmWindows.get(i);
//Slog.i(TAG, "Checking window @" + i + " " + w + " fl=0x" //Slog.i(TAG, "Checking window @" + i + " " + w + " fl=0x"
// + Integer.toHexString(w.mAttrs.flags)); // + Integer.toHexString(w.mAttrs.flags));
@ -933,7 +931,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (!willMove if (!willMove
&& w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING && w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
&& i > 0) { && i > 0) {
WindowState wb = (WindowState)localmWindows.get(i-1); WindowState wb = localmWindows.get(i-1);
if (wb.mAppToken == w.mAppToken && canBeImeTarget(wb)) { if (wb.mAppToken == w.mAppToken && canBeImeTarget(wb)) {
i--; i--;
w = wb; w = wb;
@ -963,7 +961,7 @@ public class WindowManagerService extends IWindowManager.Stub
int pos = 0; int pos = 0;
pos = localmWindows.indexOf(curTarget); pos = localmWindows.indexOf(curTarget);
while (pos >= 0) { while (pos >= 0) {
WindowState win = (WindowState)localmWindows.get(pos); WindowState win = localmWindows.get(pos);
if (win.mAppToken != token) { if (win.mAppToken != token) {
break; break;
} }
@ -1068,7 +1066,7 @@ public class WindowManagerService extends IWindowManager.Stub
int wi = imw.mChildWindows.size(); int wi = imw.mChildWindows.size();
while (wi > 0) { while (wi > 0) {
wi--; wi--;
WindowState cw = (WindowState)imw.mChildWindows.get(wi); WindowState cw = imw.mChildWindows.get(wi);
cw.mAnimLayer = cw.mLayer + adj; cw.mAnimLayer = cw.mLayer + adj;
if (DEBUG_LAYERS) Slog.v(TAG, "IM win " + cw if (DEBUG_LAYERS) Slog.v(TAG, "IM win " + cw
+ " anim layer: " + cw.mAnimLayer); + " anim layer: " + cw.mAnimLayer);
@ -1094,7 +1092,7 @@ public class WindowManagerService extends IWindowManager.Stub
int NC = win.mChildWindows.size(); int NC = win.mChildWindows.size();
while (NC > 0) { while (NC > 0) {
NC--; NC--;
WindowState cw = (WindowState)win.mChildWindows.get(NC); WindowState cw = win.mChildWindows.get(NC);
int cpos = mWindows.indexOf(cw); int cpos = mWindows.indexOf(cw);
if (cpos >= 0) { if (cpos >= 0) {
if (cpos < interestingPos) interestingPos--; if (cpos < interestingPos) interestingPos--;
@ -1146,7 +1144,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (pos >= 0) { if (pos >= 0) {
final AppWindowToken targetAppToken = mInputMethodTarget.mAppToken; final AppWindowToken targetAppToken = mInputMethodTarget.mAppToken;
if (pos < mWindows.size()) { if (pos < mWindows.size()) {
WindowState wp = (WindowState)mWindows.get(pos); WindowState wp = mWindows.get(pos);
if (wp == mInputMethodWindow) { if (wp == mInputMethodWindow) {
pos++; pos++;
} }
@ -1190,14 +1188,14 @@ public class WindowManagerService extends IWindowManager.Stub
// located here, and contiguous. // located here, and contiguous.
final int N = mWindows.size(); final int N = mWindows.size();
WindowState firstImWin = imPos < N WindowState firstImWin = imPos < N
? (WindowState)mWindows.get(imPos) : null; ? mWindows.get(imPos) : null;
// Figure out the actual input method window that should be // Figure out the actual input method window that should be
// at the bottom of their stack. // at the bottom of their stack.
WindowState baseImWin = imWin != null WindowState baseImWin = imWin != null
? imWin : mInputMethodDialogs.get(0); ? imWin : mInputMethodDialogs.get(0);
if (baseImWin.mChildWindows.size() > 0) { if (baseImWin.mChildWindows.size() > 0) {
WindowState cw = (WindowState)baseImWin.mChildWindows.get(0); WindowState cw = baseImWin.mChildWindows.get(0);
if (cw.mSubLayer < 0) baseImWin = cw; if (cw.mSubLayer < 0) baseImWin = cw;
} }
@ -1206,7 +1204,7 @@ public class WindowManagerService extends IWindowManager.Stub
// First find the top IM window. // First find the top IM window.
int pos = imPos+1; int pos = imPos+1;
while (pos < N) { while (pos < N) {
if (!((WindowState)mWindows.get(pos)).mIsImWindow) { if (!(mWindows.get(pos)).mIsImWindow) {
break; break;
} }
pos++; pos++;
@ -1214,7 +1212,7 @@ public class WindowManagerService extends IWindowManager.Stub
pos++; pos++;
// Now there should be no more input method windows above. // Now there should be no more input method windows above.
while (pos < N) { while (pos < N) {
if (((WindowState)mWindows.get(pos)).mIsImWindow) { if ((mWindows.get(pos)).mIsImWindow) {
break; break;
} }
pos++; pos++;
@ -1302,7 +1300,7 @@ public class WindowManagerService extends IWindowManager.Stub
// First find top-most window that has asked to be on top of the // First find top-most window that has asked to be on top of the
// wallpaper; all wallpapers go behind it. // wallpaper; all wallpapers go behind it.
final ArrayList localmWindows = mWindows; final ArrayList<WindowState> localmWindows = mWindows;
int N = localmWindows.size(); int N = localmWindows.size();
WindowState w = null; WindowState w = null;
WindowState foundW = null; WindowState foundW = null;
@ -1312,7 +1310,7 @@ public class WindowManagerService extends IWindowManager.Stub
int i = N; int i = N;
while (i > 0) { while (i > 0) {
i--; i--;
w = (WindowState)localmWindows.get(i); w = localmWindows.get(i);
if ((w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER)) { if ((w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER)) {
if (topCurW == null) { if (topCurW == null) {
topCurW = w; topCurW = w;
@ -1483,7 +1481,7 @@ public class WindowManagerService extends IWindowManager.Stub
// AND any starting window associated with it, AND below the // AND any starting window associated with it, AND below the
// maximum layer the policy allows for wallpapers. // maximum layer the policy allows for wallpapers.
while (foundI > 0) { while (foundI > 0) {
WindowState wb = (WindowState)localmWindows.get(foundI-1); WindowState wb = localmWindows.get(foundI-1);
if (wb.mBaseLayer < maxLayer && if (wb.mBaseLayer < maxLayer &&
wb.mAttachedWindow != foundW && wb.mAttachedWindow != foundW &&
(wb.mAttrs.type != TYPE_APPLICATION_STARTING || (wb.mAttrs.type != TYPE_APPLICATION_STARTING ||
@ -1507,7 +1505,7 @@ public class WindowManagerService extends IWindowManager.Stub
} else { } else {
// Okay i is the position immediately above the wallpaper. Look at // Okay i is the position immediately above the wallpaper. Look at
// what is below it for later. // what is below it for later.
foundW = foundI > 0 ? (WindowState)localmWindows.get(foundI-1) : null; foundW = foundI > 0 ? localmWindows.get(foundI-1) : null;
} }
if (visible) { if (visible) {
@ -1566,7 +1564,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (wallpaper == foundW) { if (wallpaper == foundW) {
foundI--; foundI--;
foundW = foundI > 0 foundW = foundI > 0
? (WindowState)localmWindows.get(foundI-1) : null; ? localmWindows.get(foundI-1) : null;
continue; continue;
} }
@ -2403,6 +2401,8 @@ public class WindowManagerService extends IWindowManager.Stub
outSurface.release(); outSurface.release();
} }
} catch (Exception e) { } catch (Exception e) {
mInputMonitor.updateInputWindowsLw();
Slog.w(TAG, "Exception thrown when creating surface for client " Slog.w(TAG, "Exception thrown when creating surface for client "
+ client + " (" + win.mAttrs.getTitle() + ")", + client + " (" + win.mAttrs.getTitle() + ")",
e); e);
@ -2449,7 +2449,6 @@ public class WindowManagerService extends IWindowManager.Stub
applyAnimationLocked(win, transit, false)) { applyAnimationLocked(win, transit, false)) {
focusMayChange = true; focusMayChange = true;
win.mExiting = true; win.mExiting = true;
mInputMonitor.windowIsBecomingInvisibleLw(win);
} else if (win.isAnimating()) { } else if (win.isAnimating()) {
// Currently in a hide animation... turn this into // Currently in a hide animation... turn this into
// an exit. // an exit.
@ -2544,6 +2543,8 @@ public class WindowManagerService extends IWindowManager.Stub
TAG, "Relayout of " + win + ": focusMayChange=" + focusMayChange); TAG, "Relayout of " + win + ": focusMayChange=" + focusMayChange);
inTouchMode = mInTouchMode; inTouchMode = mInTouchMode;
mInputMonitor.updateInputWindowsLw();
} }
if (configChanged) { if (configChanged) {
@ -2999,7 +3000,7 @@ public class WindowManagerService extends IWindowManager.Stub
public int getOrientationFromWindowsLocked() { public int getOrientationFromWindowsLocked() {
int pos = mWindows.size() - 1; int pos = mWindows.size() - 1;
while (pos >= 0) { while (pos >= 0) {
WindowState wtoken = (WindowState) mWindows.get(pos); WindowState wtoken = mWindows.get(pos);
pos--; pos--;
if (wtoken.mAppToken != null) { if (wtoken.mAppToken != null) {
// We hit an application window. so the orientation will be determined by the // We hit an application window. so the orientation will be determined by the
@ -3553,7 +3554,6 @@ public class WindowManagerService extends IWindowManager.Stub
applyAnimationLocked(win, applyAnimationLocked(win,
WindowManagerPolicy.TRANSIT_EXIT, false); WindowManagerPolicy.TRANSIT_EXIT, false);
} }
mInputMonitor.windowIsBecomingInvisibleLw(win);
changed = true; changed = true;
} }
} }
@ -3581,6 +3581,8 @@ public class WindowManagerService extends IWindowManager.Stub
if (performLayout) { if (performLayout) {
updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES); updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES);
performLayoutAndPlaceSurfacesLocked(); performLayoutAndPlaceSurfacesLocked();
} else {
mInputMonitor.updateInputWindowsLw();
} }
} }
} }
@ -3868,7 +3870,7 @@ public class WindowManagerService extends IWindowManager.Stub
int j = win.mChildWindows.size(); int j = win.mChildWindows.size();
while (j > 0) { while (j > 0) {
j--; j--;
WindowState cwin = (WindowState)win.mChildWindows.get(j); WindowState cwin = win.mChildWindows.get(j);
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG,
"Tmp removing child window " + cwin); "Tmp removing child window " + cwin);
mWindows.remove(cwin); mWindows.remove(cwin);
@ -3896,7 +3898,7 @@ public class WindowManagerService extends IWindowManager.Stub
int i = NW; int i = NW;
while (i > 0) { while (i > 0) {
i--; i--;
WindowState win = (WindowState)mWindows.get(i); WindowState win = mWindows.get(i);
if (win.getAppToken() != null) { if (win.getAppToken() != null) {
return i+1; return i+1;
} }
@ -3922,7 +3924,7 @@ public class WindowManagerService extends IWindowManager.Stub
int j = win.mChildWindows.size(); int j = win.mChildWindows.size();
while (j > 0) { while (j > 0) {
j--; j--;
WindowState cwin = (WindowState)win.mChildWindows.get(j); WindowState cwin = win.mChildWindows.get(j);
if (cwin.mSubLayer >= 0) { if (cwin.mSubLayer >= 0) {
for (int pos=NW-1; pos>=0; pos--) { for (int pos=NW-1; pos>=0; pos--) {
if (mWindows.get(pos) == cwin) { if (mWindows.get(pos) == cwin) {
@ -3950,7 +3952,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int NCW = win.mChildWindows.size(); final int NCW = win.mChildWindows.size();
boolean added = false; boolean added = false;
for (int j=0; j<NCW; j++) { for (int j=0; j<NCW; j++) {
WindowState cwin = (WindowState)win.mChildWindows.get(j); WindowState cwin = win.mChildWindows.get(j);
if (!added && cwin.mSubLayer >= 0) { if (!added && cwin.mSubLayer >= 0) {
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding child window at " if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding child window at "
+ index + ": " + cwin); + index + ": " + cwin);
@ -4234,7 +4236,7 @@ public class WindowManagerService extends IWindowManager.Stub
public void closeSystemDialogs(String reason) { public void closeSystemDialogs(String reason) {
synchronized(mWindowMap) { synchronized(mWindowMap) {
for (int i=mWindows.size()-1; i>=0; i--) { for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
if (w.mSurface != null) { if (w.mSurface != null) {
try { try {
w.mClient.closeSystemDialogs(reason); w.mClient.closeSystemDialogs(reason);
@ -4418,7 +4420,7 @@ public class WindowManagerService extends IWindowManager.Stub
// have been drawn. // have been drawn.
final int N = mWindows.size(); final int N = mWindows.size();
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
if (w.isVisibleLw() && !w.mObscured if (w.isVisibleLw() && !w.mObscured
&& (w.mOrientationChanging || !w.isDrawnLw())) { && (w.mOrientationChanging || !w.isDrawnLw())) {
return; return;
@ -4531,7 +4533,7 @@ public class WindowManagerService extends IWindowManager.Stub
Surface.setOrientation(0, rotation, animFlags); Surface.setOrientation(0, rotation, animFlags);
} }
for (int i=mWindows.size()-1; i>=0; i--) { for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
if (w.mSurface != null) { if (w.mSurface != null) {
w.mOrientationChanging = true; w.mOrientationChanging = true;
} }
@ -4687,11 +4689,10 @@ public class WindowManagerService extends IWindowManager.Stub
boolean result = true; boolean result = true;
Object[] windows; WindowState[] windows;
synchronized (mWindowMap) { synchronized (mWindowMap) {
windows = new Object[mWindows.size()];
//noinspection unchecked //noinspection unchecked
windows = mWindows.toArray(windows); windows = mWindows.toArray(new WindowState[mWindows.size()]);
} }
BufferedWriter out = null; BufferedWriter out = null;
@ -4703,7 +4704,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int count = windows.length; final int count = windows.length;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
final WindowState w = (WindowState) windows[i]; final WindowState w = windows[i];
out.write(Integer.toHexString(System.identityHashCode(w))); out.write(Integer.toHexString(System.identityHashCode(w)));
out.write(' '); out.write(' ');
out.append(w.mAttrs.getTitle()); out.append(w.mAttrs.getTitle());
@ -4856,11 +4857,11 @@ public class WindowManagerService extends IWindowManager.Stub
} }
synchronized (mWindowMap) { synchronized (mWindowMap) {
final ArrayList windows = mWindows; final ArrayList<WindowState> windows = mWindows;
final int count = windows.size(); final int count = windows.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
WindowState w = (WindowState) windows.get(i); WindowState w = windows.get(i);
if (System.identityHashCode(w) == hashCode) { if (System.identityHashCode(w) == hashCode) {
return w; return w;
} }
@ -5094,7 +5095,7 @@ public class WindowManagerService extends IWindowManager.Stub
private WindowState getWindowStateForInputChannelLocked(InputChannel inputChannel) { private WindowState getWindowStateForInputChannelLocked(InputChannel inputChannel) {
int windowCount = mWindows.size(); int windowCount = mWindows.size();
for (int i = 0; i < windowCount; i++) { for (int i = 0; i < windowCount; i++) {
WindowState windowState = (WindowState) mWindows.get(i); WindowState windowState = mWindows.get(i);
if (windowState.mInputChannel == inputChannel) { if (windowState.mInputChannel == inputChannel) {
return windowState; return windowState;
} }
@ -5110,10 +5111,10 @@ public class WindowManagerService extends IWindowManager.Stub
// As an optimization, we could try to prune the list of windows but this turns // As an optimization, we could try to prune the list of windows but this turns
// out to be difficult because only the native code knows for sure which window // out to be difficult because only the native code knows for sure which window
// currently has touch focus. // currently has touch focus.
final ArrayList windows = mWindows; final ArrayList<WindowState> windows = mWindows;
final int N = windows.size(); final int N = windows.size();
for (int i = N - 1; i >= 0; i--) { for (int i = N - 1; i >= 0; i--) {
final WindowState child = (WindowState) windows.get(i); final WindowState child = windows.get(i);
if (child.mInputChannel == null || child.mRemoved) { if (child.mInputChannel == null || child.mRemoved) {
// Skip this window because it cannot possibly receive input. // Skip this window because it cannot possibly receive input.
continue; continue;
@ -5258,17 +5259,6 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
public void windowIsBecomingInvisibleLw(WindowState window) {
// The window is becoming invisible. Preempt input dispatch in progress
// so that the next window below can receive focus.
if (window == mInputFocus) {
mInputFocus = null;
preemptInputDispatchLw();
}
updateInputWindowsLw();
}
/* Tells the dispatcher to stop waiting for its current synchronous event targets. /* Tells the dispatcher to stop waiting for its current synchronous event targets.
* Essentially, just makes those dispatches asynchronous so a new dispatch cycle * Essentially, just makes those dispatches asynchronous so a new dispatch cycle
* can begin. * can begin.
@ -5779,7 +5769,7 @@ public class WindowManagerService extends IWindowManager.Stub
final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams(); final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
final DeathRecipient mDeathRecipient; final DeathRecipient mDeathRecipient;
final WindowState mAttachedWindow; final WindowState mAttachedWindow;
final ArrayList mChildWindows = new ArrayList(); final ArrayList<WindowState> mChildWindows = new ArrayList<WindowState>();
final int mBaseLayer; final int mBaseLayer;
final int mSubLayer; final int mSubLayer;
final boolean mLayoutAttached; final boolean mLayoutAttached;
@ -6335,10 +6325,8 @@ public class WindowManagerService extends IWindowManager.Stub
int i = mChildWindows.size(); int i = mChildWindows.size();
while (i > 0) { while (i > 0) {
i--; i--;
WindowState c = (WindowState)mChildWindows.get(i); WindowState c = mChildWindows.get(i);
c.mAttachedHidden = true; c.mAttachedHidden = true;
mInputMonitor.windowIsBecomingInvisibleLw(c);
} }
if (mReportDestroySurface) { if (mReportDestroySurface) {
@ -6448,7 +6436,7 @@ public class WindowManagerService extends IWindowManager.Stub
int i = mChildWindows.size(); int i = mChildWindows.size();
while (i > 0) { while (i > 0) {
i--; i--;
WindowState c = (WindowState)mChildWindows.get(i); WindowState c = mChildWindows.get(i);
if (c.mAttachedHidden) { if (c.mAttachedHidden) {
c.mAttachedHidden = false; c.mAttachedHidden = false;
if (c.mSurface != null) { if (c.mSurface != null) {
@ -6621,7 +6609,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int N = mChildWindows.size(); final int N = mChildWindows.size();
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
((WindowState)mChildWindows.get(i)).finishExit(); mChildWindows.get(i).finishExit();
} }
if (!mExiting) { if (!mExiting) {
@ -6646,10 +6634,6 @@ public class WindowManagerService extends IWindowManager.Stub
Slog.w(TAG, "Error hiding surface in " + this, e); Slog.w(TAG, "Error hiding surface in " + this, e);
} }
mLastHidden = true; mLastHidden = true;
for (int i=0; i<N; i++) {
mInputMonitor.windowIsBecomingInvisibleLw((WindowState)mChildWindows.get(i));
}
} }
mExiting = false; mExiting = false;
if (mRemoveOnExit) { if (mRemoveOnExit) {
@ -7554,7 +7538,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int N = windows.size(); final int N = windows.size();
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
((WindowState)windows.get(i)).finishExit(); windows.get(i).finishExit();
} }
updateReportedVisibilityLocked(); updateReportedVisibilityLocked();
@ -7980,7 +7964,7 @@ public class WindowManagerService extends IWindowManager.Stub
int i = mWindows.size(); int i = mWindows.size();
while (i > 0) { while (i > 0) {
i--; i--;
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
if (w.mOrientationChanging) { if (w.mOrientationChanging) {
w.mOrientationChanging = false; w.mOrientationChanging = false;
Slog.w(TAG, "Force clearing orientation change: " + w); Slog.w(TAG, "Force clearing orientation change: " + w);
@ -8119,7 +8103,7 @@ public class WindowManagerService extends IWindowManager.Stub
int idx = findDesiredInputMethodWindowIndexLocked(false); int idx = findDesiredInputMethodWindowIndexLocked(false);
WindowState imFocus; WindowState imFocus;
if (idx > 0) { if (idx > 0) {
imFocus = (WindowState)mWindows.get(idx-1); imFocus = mWindows.get(idx-1);
if (imFocus != null) { if (imFocus != null) {
if (imFocus.mSession.mClient != null && if (imFocus.mSession.mClient != null &&
imFocus.mSession.mClient.asBinder() == client.asBinder()) { imFocus.mSession.mClient.asBinder() == client.asBinder()) {
@ -8177,9 +8161,9 @@ public class WindowManagerService extends IWindowManager.Stub
// First remove all existing app windows. // First remove all existing app windows.
i=0; i=0;
while (i < NW) { while (i < NW) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
if (w.mAppToken != null) { if (w.mAppToken != null) {
WindowState win = (WindowState)mWindows.remove(i); WindowState win = mWindows.remove(i);
mWindowsChanged = true; mWindowsChanged = true;
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG,
"Rebuild removing window: " + win); "Rebuild removing window: " + win);
@ -8227,7 +8211,7 @@ public class WindowManagerService extends IWindowManager.Stub
int i; int i;
for (i=0; i<N; i++) { for (i=0; i<N; i++) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
if (w.mBaseLayer == curBaseLayer || w.mIsImWindow if (w.mBaseLayer == curBaseLayer || w.mIsImWindow
|| (i > 0 && w.mIsWallpaper)) { || (i > 0 && w.mIsWallpaper)) {
curLayer += WINDOW_LAYER_MULTIPLIER; curLayer += WINDOW_LAYER_MULTIPLIER;
@ -8352,7 +8336,7 @@ public class WindowManagerService extends IWindowManager.Stub
// to another window). // to another window).
int topAttached = -1; int topAttached = -1;
for (i = N-1; i >= 0; i--) { for (i = N-1; i >= 0; i--) {
WindowState win = (WindowState) mWindows.get(i); WindowState win = mWindows.get(i);
// Don't do layout of a window if it is not visible, or // Don't do layout of a window if it is not visible, or
// soon won't be visible, to avoid wasting time and funky // soon won't be visible, to avoid wasting time and funky
@ -8401,7 +8385,7 @@ public class WindowManagerService extends IWindowManager.Stub
// XXX does not deal with windows that are attached to windows // XXX does not deal with windows that are attached to windows
// that are themselves attached. // that are themselves attached.
for (i = topAttached; i >= 0; i--) { for (i = topAttached; i >= 0; i--) {
WindowState win = (WindowState) mWindows.get(i); WindowState win = mWindows.get(i);
// If this view is GONE, then skip it -- keep the current // If this view is GONE, then skip it -- keep the current
// frame, and let the caller know so they can ignore it // frame, and let the caller know so they can ignore it
@ -8548,7 +8532,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int N = mWindows.size(); final int N = mWindows.size();
for (i=N-1; i>=0; i--) { for (i=N-1; i>=0; i--) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
final WindowManager.LayoutParams attrs = w.mAttrs; final WindowManager.LayoutParams attrs = w.mAttrs;
@ -8981,7 +8965,7 @@ public class WindowManagerService extends IWindowManager.Stub
// Clear them out. // Clear them out.
forceHiding = false; forceHiding = false;
for (i=N-1; i>=0; i--) { for (i=N-1; i>=0; i--) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
if (w.mSurface != null) { if (w.mSurface != null) {
final WindowManager.LayoutParams attrs = w.mAttrs; final WindowManager.LayoutParams attrs = w.mAttrs;
if (mPolicy.doesForceHide(w, attrs) && w.isVisibleLw()) { if (mPolicy.doesForceHide(w, attrs) && w.isVisibleLw()) {
@ -9031,6 +9015,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** ANIM STEP: changes=0x" if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** ANIM STEP: changes=0x"
+ Integer.toHexString(changes)); + Integer.toHexString(changes));
mInputMonitor.updateInputWindowsLw();
} while (changes != 0); } while (changes != 0);
// THIRD LOOP: Update the surfaces of all windows. // THIRD LOOP: Update the surfaces of all windows.
@ -9047,7 +9032,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int N = mWindows.size(); final int N = mWindows.size();
for (i=N-1; i>=0; i--) { for (i=N-1; i>=0; i--) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
boolean displayed = false; boolean displayed = false;
final WindowManager.LayoutParams attrs = w.mAttrs; final WindowManager.LayoutParams attrs = w.mAttrs;
@ -9227,7 +9212,6 @@ public class WindowManagerService extends IWindowManager.Stub
Slog.w(TAG, "Exception hiding surface in " + w); Slog.w(TAG, "Exception hiding surface in " + w);
} }
} }
mInputMonitor.windowIsBecomingInvisibleLw(w);
} }
// If we are waiting for this window to handle an // If we are waiting for this window to handle an
// orientation change, well, it is hidden, so // orientation change, well, it is hidden, so
@ -9487,6 +9471,8 @@ public class WindowManagerService extends IWindowManager.Stub
Slog.e(TAG, "Unhandled exception in Window Manager", e); Slog.e(TAG, "Unhandled exception in Window Manager", e);
} }
mInputMonitor.updateInputWindowsLw();
Surface.closeTransaction(); Surface.closeTransaction();
if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG, if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG,
@ -9612,6 +9598,8 @@ public class WindowManagerService extends IWindowManager.Stub
requestAnimationLocked(currentTime+(1000/60)-SystemClock.uptimeMillis()); requestAnimationLocked(currentTime+(1000/60)-SystemClock.uptimeMillis());
} }
mInputMonitor.updateInputWindowsLw();
if (DEBUG_FREEZE) Slog.v(TAG, "Layout: mDisplayFrozen=" + mDisplayFrozen if (DEBUG_FREEZE) Slog.v(TAG, "Layout: mDisplayFrozen=" + mDisplayFrozen
+ " holdScreen=" + holdScreen); + " holdScreen=" + holdScreen);
if (!mDisplayFrozen) { if (!mDisplayFrozen) {
@ -9718,7 +9706,7 @@ public class WindowManagerService extends IWindowManager.Stub
boolean leakedSurface = false; boolean leakedSurface = false;
Slog.i(TAG, "Out of memory for surface! Looking for leaks..."); Slog.i(TAG, "Out of memory for surface! Looking for leaks...");
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
WindowState ws = (WindowState)mWindows.get(i); WindowState ws = mWindows.get(i);
if (ws.mSurface != null) { if (ws.mSurface != null) {
if (!mSessions.contains(ws.mSession)) { if (!mSessions.contains(ws.mSession)) {
Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): " Slog.w(TAG, "LEAKED SURFACE (session doesn't exist): "
@ -9750,7 +9738,7 @@ public class WindowManagerService extends IWindowManager.Stub
Slog.w(TAG, "No leaked surfaces; killing applicatons!"); Slog.w(TAG, "No leaked surfaces; killing applicatons!");
SparseIntArray pidCandidates = new SparseIntArray(); SparseIntArray pidCandidates = new SparseIntArray();
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
WindowState ws = (WindowState)mWindows.get(i); WindowState ws = mWindows.get(i);
if (ws.mSurface != null) { if (ws.mSurface != null) {
pidCandidates.append(ws.mSession.mPid, ws.mSession.mPid); pidCandidates.append(ws.mSession.mPid, ws.mSession.mPid);
} }
@ -9842,7 +9830,7 @@ public class WindowManagerService extends IWindowManager.Stub
? mAppTokens.get(nextAppIndex) : null; ? mAppTokens.get(nextAppIndex) : null;
while (i >= 0) { while (i >= 0) {
win = (WindowState)mWindows.get(i); win = mWindows.get(i);
if (localLOGV || DEBUG_FOCUS) Slog.v( if (localLOGV || DEBUG_FOCUS) Slog.v(
TAG, "Looking for focus: " + i TAG, "Looking for focus: " + i
@ -9990,14 +9978,13 @@ public class WindowManagerService extends IWindowManager.Stub
return; return;
} }
pw.println("Input Dispatcher State:");
mInputManager.dump(pw); mInputManager.dump(pw);
pw.println(" "); pw.println(" ");
synchronized(mWindowMap) { synchronized(mWindowMap) {
pw.println("Current Window Manager state:"); pw.println("Current Window Manager state:");
for (int i=mWindows.size()-1; i>=0; i--) { for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = (WindowState)mWindows.get(i); WindowState w = mWindows.get(i);
pw.print(" Window #"); pw.print(i); pw.print(' '); pw.print(" Window #"); pw.print(i); pw.print(' ');
pw.print(w); pw.println(":"); pw.print(w); pw.println(":");
w.dump(pw, " "); w.dump(pw, " ");

View File

@ -199,6 +199,8 @@ public:
inline sp<InputManager> getInputManager() const { return mInputManager; } inline sp<InputManager> getInputManager() const { return mInputManager; }
String8 dump();
void setDisplaySize(int32_t displayId, int32_t width, int32_t height); void setDisplaySize(int32_t displayId, int32_t width, int32_t height);
void setDisplayOrientation(int32_t displayId, int32_t orientation); void setDisplayOrientation(int32_t displayId, int32_t orientation);
@ -341,7 +343,8 @@ private:
InputApplication* mFocusedApplication; InputApplication* mFocusedApplication;
InputApplication mFocusedApplicationStorage; // preallocated storage for mFocusedApplication InputApplication mFocusedApplicationStorage; // preallocated storage for mFocusedApplication
void dumpDispatchStateLd(); void dumpDispatchStateLd(String8& dump);
void logDispatchStateLd();
bool notifyANR(jobject tokenObj, nsecs_t& outNewTimeout); bool notifyANR(jobject tokenObj, nsecs_t& outNewTimeout);
void releaseFocusedApplicationLd(JNIEnv* env); void releaseFocusedApplicationLd(JNIEnv* env);
@ -404,6 +407,13 @@ NativeInputManager::~NativeInputManager() {
releaseFocusedApplicationLd(env); releaseFocusedApplicationLd(env);
} }
String8 NativeInputManager::dump() {
String8 dump;
dump.append("Native Input Dispatcher State:\n");
dumpDispatchStateLd(dump);
return dump;
}
bool NativeInputManager::isAppSwitchKey(int32_t keyCode) { bool NativeInputManager::isAppSwitchKey(int32_t keyCode) {
return keyCode == AKEYCODE_HOME || keyCode == AKEYCODE_ENDCALL; return keyCode == AKEYCODE_HOME || keyCode == AKEYCODE_ENDCALL;
} }
@ -921,6 +931,8 @@ void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowObjArra
mTouchedWallpaperWindows.clear(); mTouchedWallpaperWindows.clear();
} }
bool hadFocusedWindow = mFocusedWindow != NULL;
mWindows.clear(); mWindows.clear();
mFocusedWindow = NULL; mFocusedWindow = NULL;
mWallpaperWindows.clear(); mWallpaperWindows.clear();
@ -972,10 +984,15 @@ void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowObjArra
mTempTouchedWallpaperChannels.clear(); mTempTouchedWallpaperChannels.clear();
if (hadFocusedWindow && ! mFocusedWindow
|| mFocusedWindow && ! mFocusedWindow->visible) {
preemptInputDispatch();
}
mDispatchStateChanged.broadcast(); mDispatchStateChanged.broadcast();
#if DEBUG_FOCUS #if DEBUG_FOCUS
dumpDispatchStateLd(); logDispatchStateLd();
#endif #endif
} // release lock } // release lock
} }
@ -1092,7 +1109,7 @@ void NativeInputManager::setFocusedApplication(JNIEnv* env, jobject applicationO
mDispatchStateChanged.broadcast(); mDispatchStateChanged.broadcast();
#if DEBUG_FOCUS #if DEBUG_FOCUS
dumpDispatchStateLd(); logDispatchStateLd();
#endif #endif
} // release lock } // release lock
} }
@ -1120,7 +1137,7 @@ void NativeInputManager::setInputDispatchMode(bool enabled, bool frozen) {
} }
#if DEBUG_FOCUS #if DEBUG_FOCUS
dumpDispatchStateLd(); logDispatchStateLd();
#endif #endif
} // release lock } // release lock
} }
@ -1217,7 +1234,7 @@ int32_t NativeInputManager::waitForFocusedWindowLd(uint32_t policyFlags,
#if DEBUG_FOCUS #if DEBUG_FOCUS
LOGD("waitForFocusedWindow finished: injectionResult=%d", LOGD("waitForFocusedWindow finished: injectionResult=%d",
injectionResult); injectionResult);
dumpDispatchStateLd(); logDispatchStateLd();
#endif #endif
return injectionResult; return injectionResult;
} }
@ -1490,7 +1507,7 @@ int32_t NativeInputManager::waitForTouchedWindowLd(MotionEvent* motionEvent, uin
#if DEBUG_FOCUS #if DEBUG_FOCUS
LOGD("waitForTouchedWindow finished: injectionResult=%d", LOGD("waitForTouchedWindow finished: injectionResult=%d",
injectionResult); injectionResult);
dumpDispatchStateLd(); logDispatchStateLd();
#endif #endif
return injectionResult; return injectionResult;
} }
@ -1697,31 +1714,38 @@ void NativeInputManager::pokeUserActivity(nsecs_t eventTime, int32_t eventType)
android_server_PowerManagerService_userActivity(eventTime, eventType); android_server_PowerManagerService_userActivity(eventTime, eventType);
} }
void NativeInputManager::dumpDispatchStateLd() { void NativeInputManager::logDispatchStateLd() {
#if DEBUG_FOCUS String8 dump;
LOGD(" dispatcherState: dispatchEnabled=%d, dispatchFrozen=%d, windowsReady=%d", dumpDispatchStateLd(dump);
mDispatchEnabled, mDispatchFrozen, mWindowsReady); LOGD("%s", dump.string());
}
void NativeInputManager::dumpDispatchStateLd(String8& dump) {
dump.appendFormat(" dispatchEnabled: %d\n", mDispatchEnabled);
dump.appendFormat(" dispatchFrozen: %d\n", mDispatchFrozen);
dump.appendFormat(" windowsReady: %d\n", mWindowsReady);
if (mFocusedApplication) { if (mFocusedApplication) {
LOGD(" focusedApplication: name='%s', dispatchingTimeout=%0.3fms", dump.appendFormat(" focusedApplication: name='%s', dispatchingTimeout=%0.3fms\n",
mFocusedApplication->name.string(), mFocusedApplication->name.string(),
mFocusedApplication->dispatchingTimeout / 1000000.0); mFocusedApplication->dispatchingTimeout / 1000000.0);
} else { } else {
LOGD(" focusedApplication: <null>"); dump.append(" focusedApplication: <null>\n");
} }
LOGD(" focusedWindow: '%s'", dump.appendFormat(" focusedWindow: '%s'\n",
mFocusedWindow != NULL ? mFocusedWindow->inputChannel->getName().string() : "<null>"); mFocusedWindow != NULL ? mFocusedWindow->inputChannel->getName().string() : "<null>");
LOGD(" touchedWindow: '%s', touchDown=%d", dump.appendFormat(" touchedWindow: '%s', touchDown=%d\n",
mTouchedWindow != NULL ? mTouchedWindow->inputChannel->getName().string() : "<null>", mTouchedWindow != NULL ? mTouchedWindow->inputChannel->getName().string() : "<null>",
mTouchDown); mTouchDown);
for (size_t i = 0; i < mTouchedWallpaperWindows.size(); i++) { for (size_t i = 0; i < mTouchedWallpaperWindows.size(); i++) {
LOGD(" touchedWallpaperWindows[%d]: '%s'", dump.appendFormat(" touchedWallpaperWindows[%d]: '%s'\n",
i, mTouchedWallpaperWindows[i]->inputChannel->getName().string()); i, mTouchedWallpaperWindows[i]->inputChannel->getName().string());
} }
for (size_t i = 0; i < mWindows.size(); i++) { for (size_t i = 0; i < mWindows.size(); i++) {
LOGD(" windows[%d]: '%s', paused=%d, hasFocus=%d, hasWallpaper=%d, visible=%d, " dump.appendFormat(" windows[%d]: '%s', paused=%d, hasFocus=%d, hasWallpaper=%d, "
"flags=0x%08x, type=0x%08x, " "visible=%d, flags=0x%08x, type=0x%08x, "
"frame=[%d,%d], touchableArea=[%d,%d][%d,%d], " "frame=[%d,%d], touchableArea=[%d,%d][%d,%d], "
"ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms", "ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
i, mWindows[i].inputChannel->getName().string(), i, mWindows[i].inputChannel->getName().string(),
mWindows[i].paused, mWindows[i].hasFocus, mWindows[i].hasWallpaper, mWindows[i].paused, mWindows[i].hasFocus, mWindows[i].hasWallpaper,
mWindows[i].visible, mWindows[i].layoutParamsFlags, mWindows[i].layoutParamsType, mWindows[i].visible, mWindows[i].layoutParamsFlags, mWindows[i].layoutParamsType,
@ -1731,7 +1755,6 @@ void NativeInputManager::dumpDispatchStateLd() {
mWindows[i].ownerPid, mWindows[i].ownerUid, mWindows[i].ownerPid, mWindows[i].ownerUid,
mWindows[i].dispatchingTimeout / 1000000.0); mWindows[i].dispatchingTimeout / 1000000.0);
} }
#endif
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -2048,6 +2071,15 @@ static void android_server_InputManager_nativePreemptInputDispatch(JNIEnv* env,
gNativeInputManager->preemptInputDispatch(); gNativeInputManager->preemptInputDispatch();
} }
static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) {
if (checkInputManagerUnitialized(env)) {
return NULL;
}
String8 dump(gNativeInputManager->dump());
return env->NewStringUTF(dump.string());
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
static JNINativeMethod gInputManagerMethods[] = { static JNINativeMethod gInputManagerMethods[] = {
@ -2083,7 +2115,9 @@ static JNINativeMethod gInputManagerMethods[] = {
{ "nativeSetInputDispatchMode", "(ZZ)V", { "nativeSetInputDispatchMode", "(ZZ)V",
(void*) android_server_InputManager_nativeSetInputDispatchMode }, (void*) android_server_InputManager_nativeSetInputDispatchMode },
{ "nativePreemptInputDispatch", "()V", { "nativePreemptInputDispatch", "()V",
(void*) android_server_InputManager_nativePreemptInputDispatch } (void*) android_server_InputManager_nativePreemptInputDispatch },
{ "nativeDump", "()Ljava/lang/String;",
(void*) android_server_InputManager_nativeDump },
}; };
#define FIND_CLASS(var, className) \ #define FIND_CLASS(var, className) \