Merge "Unregister input channel by token"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d3928b0506
@@ -222,7 +222,7 @@ public class InputManagerService extends IInputManager.Stub
|
||||
private static native void nativeRegisterInputChannel(long ptr, InputChannel inputChannel);
|
||||
private static native void nativeRegisterInputMonitor(long ptr, InputChannel inputChannel,
|
||||
int displayId, boolean isGestureMonitor);
|
||||
private static native void nativeUnregisterInputChannel(long ptr, InputChannel inputChannel);
|
||||
private static native void nativeUnregisterInputChannel(long ptr, IBinder connectionToken);
|
||||
private static native void nativePilferPointers(long ptr, IBinder token);
|
||||
private static native void nativeSetInputFilterEnabled(long ptr, boolean enable);
|
||||
private static native void nativeSetInTouchMode(long ptr, boolean inTouchMode);
|
||||
@@ -581,17 +581,17 @@ public class InputManagerService extends IInputManager.Stub
|
||||
|
||||
/**
|
||||
* Unregisters an input channel.
|
||||
* @param inputChannel The input channel to unregister.
|
||||
* @param connectionToken The input channel to unregister.
|
||||
*/
|
||||
public void unregisterInputChannel(InputChannel inputChannel) {
|
||||
if (inputChannel == null) {
|
||||
throw new IllegalArgumentException("inputChannel must not be null.");
|
||||
public void unregisterInputChannel(IBinder connectionToken) {
|
||||
if (connectionToken == null) {
|
||||
throw new IllegalArgumentException("connectionToken must not be null.");
|
||||
}
|
||||
synchronized (mGestureMonitorPidsLock) {
|
||||
mGestureMonitorPidsByToken.remove(inputChannel.getToken());
|
||||
mGestureMonitorPidsByToken.remove(connectionToken);
|
||||
}
|
||||
|
||||
nativeUnregisterInputChannel(mPtr, inputChannel);
|
||||
nativeUnregisterInputChannel(mPtr, connectionToken);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2455,7 +2455,7 @@ public class InputManagerService extends IInputManager.Stub
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
nativeUnregisterInputChannel(mPtr, mInputChannel);
|
||||
nativeUnregisterInputChannel(mPtr, mInputChannel.getToken());
|
||||
mInputChannel.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ class DragState {
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
mService.mInputManager.unregisterInputChannel(mServerChannel);
|
||||
mService.mInputManager.unregisterInputChannel(mServerChannel.getToken());
|
||||
mInputEventReceiver.dispose();
|
||||
mInputEventReceiver = null;
|
||||
mClientChannel.dispose();
|
||||
|
||||
@@ -192,7 +192,7 @@ class EmbeddedWindowController {
|
||||
|
||||
void onRemoved() {
|
||||
if (mInputChannel != null) {
|
||||
mWmService.mInputManager.unregisterInputChannel(mInputChannel);
|
||||
mWmService.mInputManager.unregisterInputChannel(mInputChannel.getToken());
|
||||
mInputChannel.dispose();
|
||||
mInputChannel = null;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ class InputConsumerImpl implements IBinder.DeathRecipient {
|
||||
}
|
||||
|
||||
void disposeChannelsLw(SurfaceControl.Transaction t) {
|
||||
mService.mInputManager.unregisterInputChannel(mServerChannel);
|
||||
mService.mInputManager.unregisterInputChannel(mServerChannel.getToken());
|
||||
mClientChannel.dispose();
|
||||
mServerChannel.dispose();
|
||||
t.remove(mInputSurface);
|
||||
|
||||
@@ -239,7 +239,7 @@ public class Letterbox {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
mWmService.mInputManager.unregisterInputChannel(mServerChannel);
|
||||
mWmService.mInputManager.unregisterInputChannel(mServerChannel.getToken());
|
||||
mInputEventReceiver.dispose();
|
||||
mServerChannel.dispose();
|
||||
mClientChannel.dispose();
|
||||
|
||||
@@ -299,7 +299,7 @@ class TaskPositioner implements IBinder.DeathRecipient {
|
||||
}
|
||||
|
||||
mService.mTaskPositioningController.hideInputSurface(mDisplayContent.getDisplayId());
|
||||
mService.mInputManager.unregisterInputChannel(mServerChannel);
|
||||
mService.mInputManager.unregisterInputChannel(mServerChannel.getToken());
|
||||
|
||||
mInputEventReceiver.dispose();
|
||||
mInputEventReceiver = null;
|
||||
|
||||
@@ -2500,7 +2500,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
|
||||
// unregister server channel first otherwise it complains about broken channel
|
||||
if (mInputChannel != null) {
|
||||
mWmService.mInputManager.unregisterInputChannel(mInputChannel);
|
||||
mWmService.mInputManager.unregisterInputChannel(mInputChannel.getToken());
|
||||
|
||||
mInputChannel.dispose();
|
||||
mInputChannel = null;
|
||||
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
status_t registerInputChannel(JNIEnv* env, const std::shared_ptr<InputChannel>& inputChannel);
|
||||
status_t registerInputMonitor(JNIEnv* env, const std::shared_ptr<InputChannel>& inputChannel,
|
||||
int32_t displayId, bool isGestureMonitor);
|
||||
status_t unregisterInputChannel(JNIEnv* env, const InputChannel& inputChannel);
|
||||
status_t unregisterInputChannel(JNIEnv* env, const sp<IBinder>& connectionToken);
|
||||
status_t pilferPointers(const sp<IBinder>& token);
|
||||
|
||||
void displayRemoved(JNIEnv* env, int32_t displayId);
|
||||
@@ -447,9 +447,9 @@ status_t NativeInputManager::registerInputMonitor(JNIEnv* /* env */,
|
||||
}
|
||||
|
||||
status_t NativeInputManager::unregisterInputChannel(JNIEnv* /* env */,
|
||||
const InputChannel& inputChannel) {
|
||||
const sp<IBinder>& connectionToken) {
|
||||
ATRACE_CALL();
|
||||
return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel);
|
||||
return mInputManager->getDispatcher()->unregisterInputChannel(connectionToken);
|
||||
}
|
||||
|
||||
status_t NativeInputManager::pilferPointers(const sp<IBinder>& token) {
|
||||
@@ -1364,7 +1364,7 @@ static void handleInputChannelDisposed(JNIEnv* env, jobject /* inputChannelObj *
|
||||
|
||||
ALOGW("Input channel object '%s' was disposed without first being unregistered with "
|
||||
"the input manager!", inputChannel->getName().c_str());
|
||||
im->unregisterInputChannel(env, *inputChannel);
|
||||
im->unregisterInputChannel(env, inputChannel->getConnectionToken());
|
||||
}
|
||||
|
||||
static void nativeRegisterInputChannel(JNIEnv* env, jclass /* clazz */,
|
||||
@@ -1417,20 +1417,12 @@ static void nativeRegisterInputMonitor(JNIEnv* env, jclass /* clazz */,
|
||||
}
|
||||
}
|
||||
|
||||
static void nativeUnregisterInputChannel(JNIEnv* env, jclass /* clazz */,
|
||||
jlong ptr, jobject inputChannelObj) {
|
||||
static void nativeUnregisterInputChannel(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
||||
jobject tokenObj) {
|
||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
||||
sp<IBinder> token = ibinderForJavaObject(env, tokenObj);
|
||||
|
||||
std::shared_ptr<InputChannel> inputChannel =
|
||||
android_view_InputChannel_getInputChannel(env, inputChannelObj);
|
||||
if (inputChannel == nullptr) {
|
||||
throwInputChannelNotInitialized(env);
|
||||
return;
|
||||
}
|
||||
|
||||
android_view_InputChannel_setDisposeCallback(env, inputChannelObj, nullptr, nullptr);
|
||||
|
||||
status_t status = im->unregisterInputChannel(env, *inputChannel);
|
||||
status_t status = im->unregisterInputChannel(env, token);
|
||||
if (status && status != BAD_VALUE) { // ignore already unregistered channel
|
||||
std::string message;
|
||||
message += StringPrintf("Failed to unregister input channel. status=%d", status);
|
||||
@@ -1792,7 +1784,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
|
||||
(void*)nativeRegisterInputChannel},
|
||||
{"nativeRegisterInputMonitor", "(JLandroid/view/InputChannel;IZ)V",
|
||||
(void*)nativeRegisterInputMonitor},
|
||||
{"nativeUnregisterInputChannel", "(JLandroid/view/InputChannel;)V",
|
||||
{"nativeUnregisterInputChannel", "(JLandroid/os/IBinder;)V",
|
||||
(void*)nativeUnregisterInputChannel},
|
||||
{"nativePilferPointers", "(JLandroid/os/IBinder;)V", (void*)nativePilferPointers},
|
||||
{"nativeSetInputFilterEnabled", "(JZ)V", (void*)nativeSetInputFilterEnabled},
|
||||
|
||||
Reference in New Issue
Block a user