Replace InputWindowInfo#inputChannel with an IBinder token.
The IBinder token is now being used as the UUID for InputWindows.
We can pass it around without the channel to avoid unnecessary FD
parcelling, duping, and other juggling.
Test: Existing tests pass.
Bug: 80101428
Bug: 113136004
Bug: 111440400
Change-Id: I8eba3fa05f249b7dfcb5c3d9817241cbfe9ab76c
diff --git a/libs/input/InputWindow.cpp b/libs/input/InputWindow.cpp
index f82437e..96646dc 100644
--- a/libs/input/InputWindow.cpp
+++ b/libs/input/InputWindow.cpp
@@ -65,12 +65,12 @@
}
status_t InputWindowInfo::write(Parcel& output) const {
- if (inputChannel == nullptr) {
+ if (token == nullptr) {
output.writeInt32(0);
return OK;
}
output.writeInt32(1);
- status_t s = inputChannel->write(output);
+ status_t s = output.writeStrongBinder(token);
if (s != OK) return s;
output.writeString8(String8(name.c_str()));
@@ -102,15 +102,14 @@
if (from.readInt32() == 0) {
return ret;
-
}
- sp<InputChannel> inputChannel = new InputChannel();
- status_t s = inputChannel->read(from);
- if (s != OK) {
+
+ sp<IBinder> token = from.readStrongBinder();
+ if (token == nullptr) {
return ret;
}
- ret.inputChannel = inputChannel;
+ ret.token = token;
ret.name = from.readString8().c_str();
ret.layoutParamsFlags = from.readInt32();
ret.layoutParamsType = from.readInt32();
@@ -149,11 +148,11 @@
}
void InputWindowHandle::releaseChannel() {
- mInfo.inputChannel.clear();
+ mInfo.token.clear();
}
-sp<InputChannel> InputWindowHandle::getInputChannel() const {
- return mInfo.inputChannel;
+sp<IBinder> InputWindowHandle::getToken() const {
+ return mInfo.token;
}
} // namespace android