summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2019-09-23 23:55:30 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-09-23 23:55:30 +0000
commit196200dec24cdbcba8f3e2ffef758c18561161d5 (patch)
treec8e23496383bcfbdea58a6b3edf0b379db149ee7
parent77825a154431e133fbda0cc047b9086032521dfe (diff)
parent539334aa8acd0ad40d84fe4f59d5dd23a00dfbee (diff)
Merge "Don't hold wm lock when intercepting keys"
-rw-r--r--core/java/com/android/internal/policy/KeyInterceptionInfo.java35
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java44
-rw-r--r--services/core/java/com/android/server/policy/WindowManagerPolicy.java10
-rw-r--r--services/core/java/com/android/server/wm/InputManagerCallback.java10
-rw-r--r--services/core/java/com/android/server/wm/InputMonitor.java4
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerInternal.java7
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java16
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java14
-rw-r--r--services/tests/servicestests/src/com/android/server/accessibility/KeyboardInterceptorTest.java30
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java5
10 files changed, 129 insertions, 46 deletions
diff --git a/core/java/com/android/internal/policy/KeyInterceptionInfo.java b/core/java/com/android/internal/policy/KeyInterceptionInfo.java
new file mode 100644
index 000000000000..964be01952ea
--- /dev/null
+++ b/core/java/com/android/internal/policy/KeyInterceptionInfo.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.policy;
+
+
+/**
+ * Stores a snapshot of window information used to decide whether to intercept a key event.
+ */
+public class KeyInterceptionInfo {
+ // Window layout params attributes.
+ public final int layoutParamsType;
+ public final int layoutParamsPrivateFlags;
+ // Debug friendly name to help identify the window
+ public final String windowTitle;
+
+ public KeyInterceptionInfo(int type, int flags, String title) {
+ layoutParamsType = type;
+ layoutParamsPrivateFlags = flags;
+ windowTitle = title;
+ }
+}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index ab531899b496..11c6ec95602f 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -204,6 +204,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.os.RoSystemProperties;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IShortcutService;
+import com.android.internal.policy.KeyInterceptionInfo;
import com.android.internal.policy.PhoneWindow;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.ArrayUtils;
@@ -1603,7 +1604,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mDisplayId = displayId;
}
- int handleHomeButton(WindowState win, KeyEvent event) {
+ int handleHomeButton(IBinder focusedToken, KeyEvent event) {
final boolean keyguardOn = keyguardOn();
final int repeatCount = event.getRepeatCount();
final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
@@ -1646,18 +1647,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return -1;
}
- // If a system window has focus, then it doesn't make sense
- // right now to interact with applications.
- WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null;
- if (attrs != null) {
- final int type = attrs.type;
- if (type == TYPE_KEYGUARD_DIALOG
- || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
+ final KeyInterceptionInfo info =
+ mWindowManagerInternal.getKeyInterceptionInfoFromToken(focusedToken);
+ if (info != null) {
+ // If a system window has focus, then it doesn't make sense
+ // right now to interact with applications.
+ if (info.layoutParamsType == TYPE_KEYGUARD_DIALOG
+ || (info.layoutParamsPrivateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
// the "app" is keyguard, so give it the key
return 0;
}
for (int t : WINDOW_TYPES_WHERE_HOME_DOESNT_WORK) {
- if (type == t) {
+ if (info.layoutParamsType == t) {
// don't do anything, but also don't pass it to the app
return -1;
}
@@ -2598,8 +2599,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// TODO(b/117479243): handle it in InputPolicy
/** {@inheritDoc} */
@Override
- public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {
- final long result = interceptKeyBeforeDispatchingInner(win, event, policyFlags);
+ public long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event,
+ int policyFlags) {
+ final long result = interceptKeyBeforeDispatchingInner(focusedToken, event, policyFlags);
final int eventDisplayId = event.getDisplayId();
if (result == 0 && !mPerDisplayFocusEnabled
&& eventDisplayId != INVALID_DISPLAY && eventDisplayId != mTopFocusedDisplayId) {
@@ -2627,7 +2629,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return result;
}
- private long interceptKeyBeforeDispatchingInner(WindowState win, KeyEvent event,
+ private long interceptKeyBeforeDispatchingInner(IBinder focusedToken, KeyEvent event,
int policyFlags) {
final boolean keyguardOn = keyguardOn();
final int keyCode = event.getKeyCode();
@@ -2730,7 +2732,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
handler = new DisplayHomeButtonHandler(displayId);
mDisplayHomeButtonHandlers.put(displayId, handler);
}
- return handler.handleHomeButton(win, event);
+ return handler.handleHomeButton(focusedToken, event);
} else if (keyCode == KeyEvent.KEYCODE_MENU) {
// Hijack modified menu keys for debugging features
final int chordBug = KeyEvent.META_SHIFT_ON;
@@ -3131,10 +3133,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// TODO(b/117479243): handle it in InputPolicy
/** {@inheritDoc} */
@Override
- public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) {
+ public KeyEvent dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags) {
// Note: This method is only called if the initial down was unhandled.
if (DEBUG_INPUT) {
- Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction()
+ final KeyInterceptionInfo info =
+ mWindowManagerInternal.getKeyInterceptionInfoFromToken(focusedToken);
+ final String title = info == null ? "<unknown>" : info.windowTitle;
+ Slog.d(TAG, "Unhandled key: inputToken=" + focusedToken
+ + ", title=" + title
+ + ", action=" + event.getAction()
+ ", flags=" + event.getFlags()
+ ", keyCode=" + event.getKeyCode()
+ ", scanCode=" + event.getScanCode()
@@ -3173,7 +3180,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
event.getDeviceId(), event.getScanCode(),
flags, event.getSource(), event.getDisplayId(), null);
- if (!interceptFallback(win, fallbackEvent, policyFlags)) {
+ if (!interceptFallback(focusedToken, fallbackEvent, policyFlags)) {
fallbackEvent.recycle();
fallbackEvent = null;
}
@@ -3197,11 +3204,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return fallbackEvent;
}
- private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) {
+ private boolean interceptFallback(IBinder focusedToken, KeyEvent fallbackEvent,
+ int policyFlags) {
int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags);
if ((actions & ACTION_PASS_TO_USER) != 0) {
long delayMillis = interceptKeyBeforeDispatching(
- win, fallbackEvent, policyFlags);
+ focusedToken, fallbackEvent, policyFlags);
if (delayMillis == 0) {
return true;
}
diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
index 6d9c71096cb0..01250db9c5c6 100644
--- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java
+++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
@@ -173,7 +173,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
/**
* Interface to the Window Manager state associated with a particular
- * window. You can hold on to an instance of this interface from the call
+ * window. You can hold on to an instance of this interface from the call
* to prepareAddWindow() until removeWindow().
*/
public interface WindowState {
@@ -1025,7 +1025,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
* behavior for keys that can not be overridden by applications.
* This method is called from the input thread, with no locks held.
*
- * @param win The window that currently has focus. This is where the key
+ * @param focusedToken Client window token that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
* @param policyFlags The policy flags associated with the key.
@@ -1034,7 +1034,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
* milliseconds by which the key dispatch should be delayed before trying
* again.
*/
- public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
+ long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event, int policyFlags);
/**
* Called from the input dispatcher thread when an application did not handle
@@ -1043,14 +1043,14 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
* <p>Allows you to define default global behavior for keys that were not handled
* by applications. This method is called from the input thread, with no locks held.
*
- * @param win The window that currently has focus. This is where the key
+ * @param focusedToken Client window token that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
* @param policyFlags The policy flags associated with the key.
* @return Returns an alternate key event to redispatch as a fallback, or null to give up.
* The caller is responsible for recycling the key event.
*/
- public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
+ KeyEvent dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags);
/**
* Called when the top focused display is changed.
diff --git a/services/core/java/com/android/server/wm/InputManagerCallback.java b/services/core/java/com/android/server/wm/InputManagerCallback.java
index 6830adebad22..ec36a820f5fe 100644
--- a/services/core/java/com/android/server/wm/InputManagerCallback.java
+++ b/services/core/java/com/android/server/wm/InputManagerCallback.java
@@ -181,9 +181,8 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal
*/
@Override
public long interceptKeyBeforeDispatching(
- IBinder focus, KeyEvent event, int policyFlags) {
- WindowState windowState = mService.windowForClientLocked(null, focus, false);
- return mService.mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags);
+ IBinder focusedToken, KeyEvent event, int policyFlags) {
+ return mService.mPolicy.interceptKeyBeforeDispatching(focusedToken, event, policyFlags);
}
/**
@@ -192,9 +191,8 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal
*/
@Override
public KeyEvent dispatchUnhandledKey(
- IBinder focus, KeyEvent event, int policyFlags) {
- WindowState windowState = mService.windowForClientLocked(null, focus, false);
- return mService.mPolicy.dispatchUnhandledKey(windowState, event, policyFlags);
+ IBinder focusedToken, KeyEvent event, int policyFlags) {
+ return mService.mPolicy.dispatchUnhandledKey(focusedToken, event, policyFlags);
}
/** Callback to get pointer layer. */
diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java
index dd9000e06356..8e0531ce3652 100644
--- a/services/core/java/com/android/server/wm/InputMonitor.java
+++ b/services/core/java/com/android/server/wm/InputMonitor.java
@@ -528,6 +528,10 @@ final class InputMonitor {
populateInputWindowHandle(
inputWindowHandle, w, flags, type, isVisible, hasFocus, hasWallpaper);
+ // register key interception info
+ mService.mKeyInterceptionInfoForToken.put(inputWindowHandle.token,
+ w.getKeyInterceptionInfo());
+
if (w.mWinAnimator.hasSurface()) {
mInputTransaction.setInputWindowInfo(
w.mWinAnimator.mSurfaceController.mSurfaceControl, inputWindowHandle);
diff --git a/services/core/java/com/android/server/wm/WindowManagerInternal.java b/services/core/java/com/android/server/wm/WindowManagerInternal.java
index 750926f11180..aa2a96497b99 100644
--- a/services/core/java/com/android/server/wm/WindowManagerInternal.java
+++ b/services/core/java/com/android/server/wm/WindowManagerInternal.java
@@ -30,6 +30,7 @@ import android.view.InputChannel;
import android.view.MagnificationSpec;
import android.view.WindowInfo;
+import com.android.internal.policy.KeyInterceptionInfo;
import com.android.server.input.InputManagerService;
import com.android.server.policy.WindowManagerPolicy;
@@ -519,4 +520,10 @@ public abstract class WindowManagerInternal {
*/
public abstract boolean isTouchableDisplay(int displayId);
+ /**
+ * Returns the info associated with the input token used to determine if a key should be
+ * intercepted. This info can be accessed without holding the global wm lock.
+ */
+ public abstract @Nullable KeyInterceptionInfo
+ getKeyInterceptionInfoFromToken(IBinder inputToken);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 14214b4be7d1..d2d69026bdc0 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -248,6 +248,7 @@ import com.android.internal.os.BackgroundThread;
import com.android.internal.os.IResultReceiver;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IShortcutService;
+import com.android.internal.policy.KeyInterceptionInfo;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.LatencyTracker;
@@ -284,8 +285,10 @@ import java.net.Socket;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -407,6 +410,14 @@ public class WindowManagerService extends IWindowManager.Stub
int mVr2dDisplayId = INVALID_DISPLAY;
boolean mVrModeEnabled = false;
+ /**
+ * Tracks a map of input tokens to info that is used to decide whether to intercept
+ * a key event.
+ */
+ final Map<IBinder, KeyInterceptionInfo> mKeyInterceptionInfoForToken =
+ Collections.synchronizedMap(new ArrayMap<>());
+
+
private final IVrStateCallbacks mVrStateCallbacks = new IVrStateCallbacks.Stub() {
@Override
public void onVrStateChanged(boolean enabled) {
@@ -7360,6 +7371,11 @@ public class WindowManagerService extends IWindowManager.Stub
&& configuration.touchscreen == Configuration.TOUCHSCREEN_FINGER;
}
}
+
+ @Override
+ public @Nullable KeyInterceptionInfo getKeyInterceptionInfoFromToken(IBinder inputToken) {
+ return mKeyInterceptionInfoForToken.get(inputToken);
+ }
}
void registerAppFreezeListener(AppFreezeListener listener) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 501a93ef6645..0a65e3240885 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -203,6 +203,7 @@ import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.policy.KeyInterceptionInfo;
import com.android.internal.util.ToBooleanFunction;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.wm.LocalAnimationAdapter.AnimationSpec;
@@ -633,6 +634,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
private @Nullable InsetsSourceProvider mInsetProvider;
private static final float DEFAULT_DIM_AMOUNT_DEAD_WINDOW = 0.5f;
+ private KeyInterceptionInfo mKeyInterceptionInfo;
void seamlesslyRotateIfAllowed(Transaction transaction, @Rotation int oldRotation,
@Rotation int rotation, boolean requested) {
@@ -2218,6 +2220,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mClientChannel.dispose();
mClientChannel = null;
}
+ mWmService.mKeyInterceptionInfoForToken.remove(mInputWindowHandle.token);
mInputWindowHandle.token = null;
}
@@ -5327,4 +5330,15 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
proto.end(token);
}
}
+
+ KeyInterceptionInfo getKeyInterceptionInfo() {
+ if (mKeyInterceptionInfo == null
+ || mKeyInterceptionInfo.layoutParamsPrivateFlags != getAttrs().privateFlags
+ || mKeyInterceptionInfo.layoutParamsType != getAttrs().type
+ || mKeyInterceptionInfo.windowTitle != getWindowTag()) {
+ mKeyInterceptionInfo = new KeyInterceptionInfo(getAttrs().type, getAttrs().privateFlags,
+ getWindowTag().toString());
+ }
+ return mKeyInterceptionInfo;
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/KeyboardInterceptorTest.java b/services/tests/servicestests/src/com/android/server/accessibility/KeyboardInterceptorTest.java
index 9926a09dd105..322653b4115c 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/KeyboardInterceptorTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/KeyboardInterceptorTest.java
@@ -28,12 +28,12 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+import android.os.IBinder;
import android.view.KeyEvent;
import androidx.test.runner.AndroidJUnit4;
import com.android.server.policy.WindowManagerPolicy;
-import com.android.server.policy.WindowManagerPolicy.WindowState;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
@@ -79,7 +79,7 @@ public class KeyboardInterceptorTest {
@Test
public void whenVolumeKeyArrives_andPolicySaysUseIt_eventGoesToAms() {
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_DOWN);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(event)), eq(0))).thenReturn(0L);
mInterceptor.onKeyEvent(event, 0);
verify(mMockAms).notifyKeyEvent(argThat(matchesKeyEvent(event)), eq(0));
@@ -88,7 +88,7 @@ public class KeyboardInterceptorTest {
@Test
public void whenVolumeKeyArrives_andPolicySaysDropIt_eventDropped() {
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_UP);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(event)), eq(0))).thenReturn(-1L);
mInterceptor.onKeyEvent(event, 0);
verify(mMockAms, times(0)).notifyKeyEvent(anyObject(), anyInt());
@@ -98,14 +98,14 @@ public class KeyboardInterceptorTest {
@Test
public void whenVolumeKeyArrives_andPolicySaysDelayThenUse_eventQueuedThenSentToAms() {
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_UP);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(event)), eq(0))).thenReturn(150L);
mInterceptor.onKeyEvent(event, 0);
assertTrue(mHandler.hasMessages());
verify(mMockAms, times(0)).notifyKeyEvent(anyObject(), anyInt());
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(event)), eq(0))).thenReturn(0L);
mHandler.sendAllMessages();
@@ -115,14 +115,14 @@ public class KeyboardInterceptorTest {
@Test
public void whenVolumeKeyArrives_andPolicySaysDelayThenDrop_eventQueuedThenDropped() {
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_DOWN);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(event)), eq(0))).thenReturn(150L);
mInterceptor.onKeyEvent(event, 0);
assertTrue(mHandler.hasMessages());
verify(mMockAms, times(0)).notifyKeyEvent(anyObject(), anyInt());
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(event)), eq(0))).thenReturn(-1L);
mHandler.sendAllMessages();
@@ -137,18 +137,18 @@ public class KeyboardInterceptorTest {
new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_VOLUME_UP),
new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_0)};
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[1])), eq(0))).thenReturn(150L);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[3])), eq(0))).thenReturn(75L);
for (KeyEvent event : events) {
mInterceptor.onKeyEvent(event, 0);
}
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[1])), eq(0))).thenReturn(0L);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[3])), eq(0))).thenReturn(0L);
mHandler.sendAllMessages();
@@ -167,18 +167,18 @@ public class KeyboardInterceptorTest {
new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_VOLUME_UP),
new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_0)};
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[1])), eq(0))).thenReturn(150L);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[3])), eq(0))).thenReturn(75L);
for (KeyEvent event : events) {
mInterceptor.onKeyEvent(event, 0);
}
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[1])), eq(0))).thenReturn(-1L);
- when(mMockPolicy.interceptKeyBeforeDispatching((WindowState) argThat(nullValue()),
+ when(mMockPolicy.interceptKeyBeforeDispatching((IBinder) argThat(nullValue()),
argThat(matchesKeyEvent(events[3])), eq(0))).thenReturn(-1L);
mHandler.sendAllMessages();
diff --git a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java
index bb89446dd6e6..761f73ea7896 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java
@@ -167,12 +167,13 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
}
@Override
- public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {
+ public long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event,
+ int policyFlags) {
return 0;
}
@Override
- public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) {
+ public KeyEvent dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags) {
return null;
}