Merge "WM: Clean up InputTarget interface"

This commit is contained in:
Vishnu Nair
2021-10-12 16:47:31 +00:00
committed by Android (Google) Code Review
5 changed files with 18 additions and 26 deletions

View File

@@ -87,16 +87,12 @@ class AnrController {
return;
}
WindowState windowState = target.asWindowState();
WindowState windowState = target.getWindowState();
pid = target.getPid();
if (windowState != null) {
activity = windowState.mActivityRecord;
} else {
// Don't blame the host process, instead blame the embedded pid.
activity = null;
// Use host WindowState for logging and z-order test.
windowState = target.asEmbeddedWindow().mHostWindowState;
}
// Blame the activity if the input token belongs to the window. If the target is
// embedded, then we will blame the pid instead.
activity = (windowState.mInputChannelToken == inputToken)
? windowState.mActivityRecord : null;
Slog.i(TAG_WM, "ANR in " + target + ". Reason:" + reason);
aboveSystem = isWindowAboveSystem(windowState);
dumpAnrStateLocked(activity, windowState, reason);

View File

@@ -198,8 +198,8 @@ class EmbeddedWindowController {
}
@Override
public EmbeddedWindow asEmbeddedWindow() {
return this;
public WindowState getWindowState() {
return mHostWindowState;
}
@Override

View File

@@ -25,13 +25,8 @@ import android.view.IWindow;
* of both targets.
*/
interface InputTarget {
default WindowState asWindowState() {
return null;
}
default EmbeddedWindowController.EmbeddedWindow asEmbeddedWindow() {
return null;
}
/* Get the WindowState associated with the target. */
WindowState getWindowState();
/* Display id of the target. */
int getDisplayId();

View File

@@ -5018,16 +5018,17 @@ public class WindowManagerService extends IWindowManager.Stub
ProtoLog.i(WM_DEBUG_FOCUS_LIGHT, "Focus changing: %s -> %s", lastTarget, newTarget);
}
if (newTarget != null && newTarget.asWindowState() != null) {
WindowState newFocus = newTarget.asWindowState();
mAnrController.onFocusChanged(newFocus);
newFocus.reportFocusChangedSerialized(true);
// Call WindowState focus change observers
WindowState newFocusedWindow = newTarget != null ? newTarget.getWindowState() : null;
if (newFocusedWindow != null && newFocusedWindow.mInputChannelToken == newToken) {
mAnrController.onFocusChanged(newFocusedWindow);
newFocusedWindow.reportFocusChangedSerialized(true);
notifyFocusChanged();
}
if (lastTarget != null && lastTarget.asWindowState() != null) {
WindowState lastFocus = lastTarget.asWindowState();
lastFocus.reportFocusChangedSerialized(false);
WindowState lastFocusedWindow = lastTarget != null ? lastTarget.getWindowState() : null;
if (lastFocusedWindow != null && lastFocusedWindow.mInputChannelToken == oldToken) {
lastFocusedWindow.reportFocusChangedSerialized(false);
}
}

View File

@@ -1727,7 +1727,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
@Override
public WindowState asWindowState() {
public WindowState getWindowState() {
return this;
}