summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2013-09-23 17:37:09 -0700
committerCraig Mautner <cmautner@google.com>2013-09-24 09:01:48 -0700
commitac56514ea7ff5e30f4d3010da2b8ebbdb36406de (patch)
treee4a8414ae8021176c5e0f10c7c12eadea5327d96 /services
parentdbfceb7ea0f2925fa2e9cce4a5eece0b72d9c093 (diff)
downloadframeworks_base-ac56514ea7ff5e30f4d3010da2b8ebbdb36406de.zip
frameworks_base-ac56514ea7ff5e30f4d3010da2b8ebbdb36406de.tar.gz
frameworks_base-ac56514ea7ff5e30f4d3010da2b8ebbdb36406de.tar.bz2
Fix method for determining focused window.
Method had been rewritten to be task-based and there were errors when a task had no apptokens. New version is much easier to maintain. Maybe fixes bug 10689184. Change-Id: I5e4c8447a33a4f5686296c20b9f9fe302c9ae49f
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java83
1 files changed, 30 insertions, 53 deletions
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index d063db5..a0bd0ee 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -158,7 +158,7 @@ public class WindowManagerService extends IWindowManager.Stub
DisplayManagerService.WindowManagerFuncs, DisplayManager.DisplayListener {
static final String TAG = "WindowManager";
static final boolean DEBUG = false;
- static final boolean DEBUG_ADD_REMOVE = true;
+ static final boolean DEBUG_ADD_REMOVE = false;
static final boolean DEBUG_FOCUS = false;
static final boolean DEBUG_FOCUS_LIGHT = DEBUG_FOCUS || false;
static final boolean DEBUG_ANIM = false;
@@ -9770,21 +9770,6 @@ public class WindowManagerService extends IWindowManager.Stub
}
private WindowState findFocusedWindowLocked(DisplayContent displayContent) {
- // Set nextApp to the first app and set taskNdx and tokenNdx to point to the app following.
- final ArrayList<Task> tasks = displayContent.getTasks();
- int taskNdx = tasks.size() - 1;
- AppTokenList tokens = taskNdx >= 0 ? tasks.get(taskNdx).mAppTokens : null;
- int tokenNdx = tokens != null ? tokens.size() - 1 : -1;
- WindowToken nextApp = tokenNdx >= 0 ? tokens.get(tokenNdx) : null;
- --tokenNdx;
- if (tokenNdx < 0) {
- --taskNdx;
- if (taskNdx >= 0) {
- tokens = tasks.get(taskNdx).mAppTokens;
- tokenNdx = tokens.size() - 1;
- }
- }
-
final WindowList windows = displayContent.getWindowList();
for (int i = windows.size() - 1; i >= 0; i--) {
final WindowState win = windows.get(i);
@@ -9795,59 +9780,51 @@ public class WindowManagerService extends IWindowManager.Stub
+ ", flags=" + win.mAttrs.flags
+ ", canReceive=" + win.canReceiveKeys());
- AppWindowToken thisApp = win.mAppToken;
+ AppWindowToken wtoken = win.mAppToken;
// If this window's application has been removed, just skip it.
- if (thisApp != null && (thisApp.removed || thisApp.sendingToBottom)) {
- if (DEBUG_FOCUS) Slog.v(TAG, "Skipping " + thisApp + " because "
- + (thisApp.removed ? "removed" : "sendingToBottom"));
+ if (wtoken != null && (wtoken.removed || wtoken.sendingToBottom)) {
+ if (DEBUG_FOCUS) Slog.v(TAG, "Skipping " + wtoken + " because "
+ + (wtoken.removed ? "removed" : "sendingToBottom"));
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.
- if (thisApp != null && nextApp != null && thisApp != nextApp
- && win.mAttrs.type != TYPE_APPLICATION_STARTING) {
- final WindowToken origAppToken = nextApp;
- final int origTaskNdx = taskNdx;
- final int origTokenNdx = tokenNdx;
- for ( ; taskNdx >= 0; --taskNdx) {
- tokens = tasks.get(taskNdx).mAppTokens;
+ if (!win.canReceiveKeys()) {
+ continue;
+ }
+
+ // Descend through all of the app tokens and find the first that either matches
+ // win.mAppToken (return win) or mFocusedApp (return null).
+ if (wtoken != null && win.mAttrs.type != TYPE_APPLICATION_STARTING &&
+ mFocusedApp != null) {
+ ArrayList<Task> tasks = displayContent.getTasks();
+ for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
+ AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
+ int tokenNdx = tokens.size() - 1;
for ( ; tokenNdx >= 0; --tokenNdx) {
- if (nextApp == mFocusedApp) {
+ final AppWindowToken token = tokens.get(tokenNdx);
+ if (wtoken == token) {
+ break;
+ }
+ if (mFocusedApp == token) {
// Whoops, we are below the focused app... no focus for you!
- if (localLOGV || DEBUG_FOCUS) Slog.v(
- TAG, "findFocusedWindow: Reached focused app=" + mFocusedApp);
+ if (localLOGV || DEBUG_FOCUS_LIGHT) Slog.v(TAG,
+ "findFocusedWindow: Reached focused app=" + mFocusedApp);
return null;
}
- nextApp = tokens.get(tokenNdx);
- if (nextApp == thisApp) {
- break;
- }
}
- if (thisApp == nextApp) {
+ if (tokenNdx >= 0) {
+ // Early exit from loop, must have found the matching token.
break;
}
}
- if (thisApp != nextApp) {
- // Uh oh, the app token doesn't exist! This shouldn't
- // happen, but if it does we can get totally hosed...
- // so restart at the original app.
- nextApp = origAppToken;
- // return indices to same place.
- taskNdx = origTaskNdx;
- tokenNdx = origTokenNdx;
- }
}
- // Dispatch to this window if it is wants key events.
- if (win.canReceiveKeys()) {
- if (DEBUG_FOCUS_LIGHT) Slog.v(
- TAG, "findFocusedWindow: Found new focus @ " + i + " = " + win);
- return win;
- }
+ if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "findFocusedWindow: Found new focus @ " + i +
+ " = " + win);
+ return win;
}
+
if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "findFocusedWindow: No focusable windows.");
return null;
}