diff options
Diffstat (limited to 'services/java/com/android/server')
6 files changed, 41 insertions, 13 deletions
diff --git a/services/java/com/android/server/wm/DragState.java b/services/java/com/android/server/wm/DragState.java index b37d1c2..e622503 100644 --- a/services/java/com/android/server/wm/DragState.java +++ b/services/java/com/android/server/wm/DragState.java @@ -139,6 +139,9 @@ class DragState { mServerChannel.dispose(); mClientChannel = null; mServerChannel = null; + + mDragWindowHandle = null; + mDragApplicationHandle = null; } } diff --git a/services/java/com/android/server/wm/InputApplicationHandle.java b/services/java/com/android/server/wm/InputApplicationHandle.java index d78b1d9..1812f11 100644 --- a/services/java/com/android/server/wm/InputApplicationHandle.java +++ b/services/java/com/android/server/wm/InputApplicationHandle.java @@ -46,7 +46,10 @@ public final class InputApplicationHandle { @Override protected void finalize() throws Throwable { - nativeDispose(); - super.finalize(); + try { + nativeDispose(); + } finally { + super.finalize(); + } } } diff --git a/services/java/com/android/server/wm/InputMonitor.java b/services/java/com/android/server/wm/InputMonitor.java index 12ef238..573a7d4 100644 --- a/services/java/com/android/server/wm/InputMonitor.java +++ b/services/java/com/android/server/wm/InputMonitor.java @@ -17,10 +17,10 @@ package com.android.server.wm; import android.graphics.Rect; -import android.os.Process; import android.os.RemoteException; import android.util.Log; import android.util.Slog; +import android.view.InputChannel; import android.view.KeyEvent; import android.view.WindowManager; @@ -160,13 +160,21 @@ final class InputMonitor { if (WindowManagerService.DEBUG_DRAG) { Log.d(WindowManagerService.TAG, "Inserting drag window"); } - addInputWindowHandleLw(mService.mDragState.mDragWindowHandle); + final InputWindowHandle dragWindowHandle = mService.mDragState.mDragWindowHandle; + if (dragWindowHandle != null) { + addInputWindowHandleLw(dragWindowHandle); + } else { + Slog.w(WindowManagerService.TAG, "Drag is in progress but there is no " + + "drag window handle."); + } } final int N = windows.size(); for (int i = N - 1; i >= 0; i--) { final WindowState child = windows.get(i); - if (child.mInputChannel == null || child.mRemoved) { + final InputChannel inputChannel = child.mInputChannel; + final InputWindowHandle inputWindowHandle = child.mInputWindowHandle; + if (inputChannel == null || inputWindowHandle == null || child.mRemoved) { // Skip this window because it cannot possibly receive input. continue; } @@ -186,8 +194,6 @@ final class InputMonitor { } // Add a window to our list of input windows. - final InputWindowHandle inputWindowHandle = child.mInputWindowHandle; - inputWindowHandle.inputChannel = child.mInputChannel; inputWindowHandle.name = child.toString(); inputWindowHandle.layoutParamsFlags = flags; inputWindowHandle.layoutParamsType = type; diff --git a/services/java/com/android/server/wm/InputWindowHandle.java b/services/java/com/android/server/wm/InputWindowHandle.java index abf68d9..264877c 100644 --- a/services/java/com/android/server/wm/InputWindowHandle.java +++ b/services/java/com/android/server/wm/InputWindowHandle.java @@ -98,7 +98,10 @@ public final class InputWindowHandle { @Override protected void finalize() throws Throwable { - nativeDispose(); - super.finalize(); + try { + nativeDispose(); + } finally { + super.finalize(); + } } } diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 1a4caa7..4adf304 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -2051,10 +2051,11 @@ public class WindowManagerService extends IWindowManager.Stub return res; } - if (outInputChannel != null) { + if (outInputChannel != null && (attrs.inputFeatures + & WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0) { String name = win.makeInputChannelName(); InputChannel[] inputChannels = InputChannel.openInputChannelPair(name); - win.mInputChannel = inputChannels[0]; + win.setInputChannel(inputChannels[0]); inputChannels[1].transferTo(outInputChannel); mInputManager.registerInputChannel(win.mInputChannel, win.mInputWindowHandle); diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index cdd0047..a384b03 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -1236,7 +1236,8 @@ final class WindowState implements WindowManagerPolicy.WindowState { * Input Manager uses when discarding windows from input consideration. */ boolean isPotentialDragTarget() { - return isVisibleNow() && (mInputChannel != null) && !mRemoved; + return isVisibleNow() && !mRemoved + && mInputChannel != null && mInputWindowHandle != null; } /** @@ -1372,7 +1373,16 @@ final class WindowState implements WindowManagerPolicy.WindowState { // we are doing this as part of processing a death note.) } } - + + void setInputChannel(InputChannel inputChannel) { + if (mInputChannel != null) { + throw new IllegalStateException("Window already has an input channel."); + } + + mInputChannel = inputChannel; + mInputWindowHandle.inputChannel = inputChannel; + } + void disposeInputChannel() { if (mInputChannel != null) { mService.mInputManager.unregisterInputChannel(mInputChannel); @@ -1380,6 +1390,8 @@ final class WindowState implements WindowManagerPolicy.WindowState { mInputChannel.dispose(); mInputChannel = null; } + + mInputWindowHandle.inputChannel = null; } private class DeathRecipient implements IBinder.DeathRecipient { |