Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 17 | #define LOG_TAG "WindowInfo" |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 18 | #define LOG_NDEBUG 0 |
| 19 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 20 | #include <type_traits> |
| 21 | |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 22 | #include <binder/Parcel.h> |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 23 | #include <gui/WindowInfo.h> |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 24 | |
| 25 | #include <log/log.h> |
| 26 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 27 | namespace android::gui { |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 28 | |
Siarhei Vishniakou | 366fb5b | 2023-12-06 11:23:41 -0800 | [diff] [blame] | 29 | namespace { |
| 30 | |
| 31 | std::ostream& operator<<(std::ostream& out, const sp<IBinder>& binder) { |
| 32 | if (binder == nullptr) { |
| 33 | out << "<null>"; |
| 34 | } else { |
| 35 | out << binder.get(); |
| 36 | } |
| 37 | return out; |
| 38 | } |
| 39 | |
| 40 | std::ostream& operator<<(std::ostream& out, const Region& region) { |
| 41 | if (region.isEmpty()) { |
| 42 | out << "<empty>"; |
| 43 | return out; |
| 44 | } |
| 45 | |
| 46 | bool first = true; |
| 47 | Region::const_iterator cur = region.begin(); |
| 48 | Region::const_iterator const tail = region.end(); |
| 49 | while (cur != tail) { |
| 50 | if (first) { |
| 51 | first = false; |
| 52 | } else { |
| 53 | out << "|"; |
| 54 | } |
| 55 | out << "[" << cur->left << "," << cur->top << "][" << cur->right << "," << cur->bottom |
| 56 | << "]"; |
| 57 | cur++; |
| 58 | } |
| 59 | return out; |
| 60 | } |
| 61 | |
| 62 | } // namespace |
| 63 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 64 | void WindowInfo::setInputConfig(ftl::Flags<InputConfig> config, bool value) { |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 65 | if (value) { |
| 66 | inputConfig |= config; |
| 67 | return; |
| 68 | } |
| 69 | inputConfig &= ~config; |
| 70 | } |
| 71 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 72 | void WindowInfo::addTouchableRegion(const Rect& region) { |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 73 | touchableRegion.orSelf(region); |
| 74 | } |
| 75 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 76 | bool WindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const { |
| 77 | return touchableRegion.contains(x, y); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 78 | } |
| 79 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 80 | bool WindowInfo::frameContainsPoint(int32_t x, int32_t y) const { |
Chavi Weingarten | 7f01919 | 2023-08-08 20:39:01 +0000 | [diff] [blame] | 81 | return x >= frame.left && x < frame.right && y >= frame.top && y < frame.bottom; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 82 | } |
| 83 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 84 | bool WindowInfo::supportsSplitTouch() const { |
Prabir Pradhan | 76bdecb | 2022-01-31 11:14:15 -0800 | [diff] [blame] | 85 | return !inputConfig.test(InputConfig::PREVENT_SPLITTING); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Prabir Pradhan | 07e05b6 | 2021-11-19 03:57:24 -0800 | [diff] [blame] | 88 | bool WindowInfo::isSpy() const { |
Prabir Pradhan | 51e7db0 | 2022-02-07 06:02:57 -0800 | [diff] [blame] | 89 | return inputConfig.test(InputConfig::SPY); |
Prabir Pradhan | 07e05b6 | 2021-11-19 03:57:24 -0800 | [diff] [blame] | 90 | } |
| 91 | |
Prabir Pradhan | d65552b | 2021-10-07 11:23:50 -0700 | [diff] [blame] | 92 | bool WindowInfo::interceptsStylus() const { |
Prabir Pradhan | 51e7db0 | 2022-02-07 06:02:57 -0800 | [diff] [blame] | 93 | return inputConfig.test(InputConfig::INTERCEPTS_STYLUS); |
Prabir Pradhan | d65552b | 2021-10-07 11:23:50 -0700 | [diff] [blame] | 94 | } |
| 95 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 96 | bool WindowInfo::overlaps(const WindowInfo* other) const { |
Chavi Weingarten | 7f01919 | 2023-08-08 20:39:01 +0000 | [diff] [blame] | 97 | return !frame.isEmpty() && frame.left < other->frame.right && frame.right > other->frame.left && |
| 98 | frame.top < other->frame.bottom && frame.bottom > other->frame.top; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 99 | } |
| 100 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 101 | bool WindowInfo::operator==(const WindowInfo& info) const { |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 102 | return info.token == token && info.id == id && info.name == name && |
Chavi Weingarten | 7f01919 | 2023-08-08 20:39:01 +0000 | [diff] [blame] | 103 | info.dispatchingTimeout == dispatchingTimeout && info.frame == frame && |
Vishnu Nair | 494a2e4 | 2023-11-10 17:21:19 -0800 | [diff] [blame] | 104 | info.contentSize == contentSize && info.surfaceInset == surfaceInset && |
| 105 | info.globalScaleFactor == globalScaleFactor && info.transform == transform && |
| 106 | info.touchableRegion.hasSameRects(touchableRegion) && |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 107 | info.touchOcclusionMode == touchOcclusionMode && info.ownerPid == ownerPid && |
| 108 | info.ownerUid == ownerUid && info.packageName == packageName && |
Prabir Pradhan | 51e7db0 | 2022-02-07 06:02:57 -0800 | [diff] [blame] | 109 | info.inputConfig == inputConfig && info.displayId == displayId && |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 110 | info.replaceTouchableRegionWithCrop == replaceTouchableRegionWithCrop && |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 111 | info.applicationInfo == applicationInfo && info.layoutParamsType == layoutParamsType && |
Vishnu Nair | 59a6be3 | 2024-01-29 10:26:21 -0800 | [diff] [blame] | 112 | info.layoutParamsFlags == layoutParamsFlags && |
| 113 | info.canOccludePresentation == canOccludePresentation; |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 114 | } |
| 115 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 116 | status_t WindowInfo::writeToParcel(android::Parcel* parcel) const { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 117 | if (parcel == nullptr) { |
| 118 | ALOGE("%s: Null parcel", __func__); |
| 119 | return BAD_VALUE; |
| 120 | } |
Robert Carr | 2984b7a | 2020-04-13 17:06:45 -0700 | [diff] [blame] | 121 | if (name.empty()) { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 122 | parcel->writeInt32(0); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 123 | return OK; |
| 124 | } |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 125 | parcel->writeInt32(1); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 126 | |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 127 | // Ensure that the size of custom types are what we expect for writing into the parcel. |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 128 | static_assert(sizeof(inputConfig) == 4u); |
Prabir Pradhan | aeebeb4 | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 129 | static_assert(sizeof(ownerPid.val()) == 4u); |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 130 | static_assert(sizeof(ownerUid.val()) == 4u); |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 131 | |
Vishnu Nair | 47074b8 | 2020-08-14 11:54:47 -0700 | [diff] [blame] | 132 | // clang-format off |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 133 | status_t status = parcel->writeStrongBinder(token) ?: |
| 134 | parcel->writeInt64(dispatchingTimeout.count()) ?: |
| 135 | parcel->writeInt32(id) ?: |
| 136 | parcel->writeUtf8AsUtf16(name) ?: |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 137 | parcel->writeInt32(layoutParamsFlags.get()) ?: |
| 138 | parcel->writeInt32( |
| 139 | static_cast<std::underlying_type_t<WindowInfo::Type>>(layoutParamsType)) ?: |
Chavi Weingarten | 7f01919 | 2023-08-08 20:39:01 +0000 | [diff] [blame] | 140 | parcel->write(frame) ?: |
Vishnu Nair | 494a2e4 | 2023-11-10 17:21:19 -0800 | [diff] [blame] | 141 | parcel->writeInt32(contentSize.width) ?: |
| 142 | parcel->writeInt32(contentSize.height) ?: |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 143 | parcel->writeInt32(surfaceInset) ?: |
| 144 | parcel->writeFloat(globalScaleFactor) ?: |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 145 | parcel->writeFloat(alpha) ?: |
chaviw | 1ff3d1e | 2020-07-01 15:53:47 -0700 | [diff] [blame] | 146 | parcel->writeFloat(transform.dsdx()) ?: |
| 147 | parcel->writeFloat(transform.dtdx()) ?: |
| 148 | parcel->writeFloat(transform.tx()) ?: |
| 149 | parcel->writeFloat(transform.dtdy()) ?: |
| 150 | parcel->writeFloat(transform.dsdy()) ?: |
| 151 | parcel->writeFloat(transform.ty()) ?: |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 152 | parcel->writeInt32(static_cast<int32_t>(touchOcclusionMode)) ?: |
Prabir Pradhan | aeebeb4 | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 153 | parcel->writeInt32(ownerPid.val()) ?: |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 154 | parcel->writeInt32(ownerUid.val()) ?: |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 155 | parcel->writeUtf8AsUtf16(packageName) ?: |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 156 | parcel->writeInt32(inputConfig.get()) ?: |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 157 | parcel->writeInt32(displayId) ?: |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 158 | applicationInfo.writeToParcel(parcel) ?: |
| 159 | parcel->write(touchableRegion) ?: |
| 160 | parcel->writeBool(replaceTouchableRegionWithCrop) ?: |
chaviw | e0ba4e9 | 2021-08-11 11:38:41 -0500 | [diff] [blame] | 161 | parcel->writeStrongBinder(touchableRegionCropHandle.promote()) ?: |
Vishnu Nair | 59a6be3 | 2024-01-29 10:26:21 -0800 | [diff] [blame] | 162 | parcel->writeStrongBinder(windowToken) ?: |
| 163 | parcel->writeStrongBinder(focusTransferTarget) ?: |
| 164 | parcel->writeBool(canOccludePresentation); |
Vishnu Nair | 47074b8 | 2020-08-14 11:54:47 -0700 | [diff] [blame] | 165 | // clang-format on |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 166 | return status; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 167 | } |
| 168 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 169 | status_t WindowInfo::readFromParcel(const android::Parcel* parcel) { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 170 | if (parcel == nullptr) { |
| 171 | ALOGE("%s: Null parcel", __func__); |
| 172 | return BAD_VALUE; |
| 173 | } |
| 174 | if (parcel->readInt32() == 0) { |
| 175 | return OK; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 176 | } |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 177 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 178 | token = parcel->readStrongBinder(); |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 179 | dispatchingTimeout = static_cast<decltype(dispatchingTimeout)>(parcel->readInt64()); |
| 180 | status_t status = parcel->readInt32(&id) ?: parcel->readUtf8FromUtf16(&name); |
| 181 | if (status != OK) { |
| 182 | return status; |
| 183 | } |
| 184 | |
chaviw | 1ff3d1e | 2020-07-01 15:53:47 -0700 | [diff] [blame] | 185 | float dsdx, dtdx, tx, dtdy, dsdy, ty; |
Prabir Pradhan | aeebeb4 | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 186 | int32_t lpFlags, lpType, touchOcclusionModeInt, inputConfigInt, ownerPidInt, ownerUidInt; |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 187 | sp<IBinder> touchableRegionCropHandleSp; |
| 188 | |
Vishnu Nair | 47074b8 | 2020-08-14 11:54:47 -0700 | [diff] [blame] | 189 | // clang-format off |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 190 | status = parcel->readInt32(&lpFlags) ?: |
| 191 | parcel->readInt32(&lpType) ?: |
Chavi Weingarten | 7f01919 | 2023-08-08 20:39:01 +0000 | [diff] [blame] | 192 | parcel->read(frame) ?: |
Vishnu Nair | 494a2e4 | 2023-11-10 17:21:19 -0800 | [diff] [blame] | 193 | parcel->readInt32(&contentSize.width) ?: |
| 194 | parcel->readInt32(&contentSize.height) ?: |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 195 | parcel->readInt32(&surfaceInset) ?: |
| 196 | parcel->readFloat(&globalScaleFactor) ?: |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 197 | parcel->readFloat(&alpha) ?: |
chaviw | 1ff3d1e | 2020-07-01 15:53:47 -0700 | [diff] [blame] | 198 | parcel->readFloat(&dsdx) ?: |
| 199 | parcel->readFloat(&dtdx) ?: |
| 200 | parcel->readFloat(&tx) ?: |
| 201 | parcel->readFloat(&dtdy) ?: |
| 202 | parcel->readFloat(&dsdy) ?: |
| 203 | parcel->readFloat(&ty) ?: |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 204 | parcel->readInt32(&touchOcclusionModeInt) ?: |
Prabir Pradhan | aeebeb4 | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 205 | parcel->readInt32(&ownerPidInt) ?: |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 206 | parcel->readInt32(&ownerUidInt) ?: |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 207 | parcel->readUtf8FromUtf16(&packageName) ?: |
| 208 | parcel->readInt32(&inputConfigInt) ?: |
| 209 | parcel->readInt32(&displayId) ?: |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 210 | applicationInfo.readFromParcel(parcel) ?: |
| 211 | parcel->read(touchableRegion) ?: |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 212 | parcel->readBool(&replaceTouchableRegionWithCrop) ?: |
| 213 | parcel->readNullableStrongBinder(&touchableRegionCropHandleSp) ?: |
Chavi Weingarten | 847e851 | 2023-03-29 00:26:09 +0000 | [diff] [blame] | 214 | parcel->readNullableStrongBinder(&windowToken) ?: |
Vishnu Nair | 59a6be3 | 2024-01-29 10:26:21 -0800 | [diff] [blame] | 215 | parcel->readNullableStrongBinder(&focusTransferTarget) ?: |
| 216 | parcel->readBool(&canOccludePresentation); |
Chavi Weingarten | 847e851 | 2023-03-29 00:26:09 +0000 | [diff] [blame] | 217 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 218 | // clang-format on |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 219 | |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 220 | if (status != OK) { |
| 221 | return status; |
| 222 | } |
| 223 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 224 | layoutParamsFlags = ftl::Flags<Flag>(lpFlags); |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 225 | layoutParamsType = static_cast<Type>(lpType); |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 226 | transform.set({dsdx, dtdx, tx, dtdy, dsdy, ty, 0, 0, 1}); |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 227 | touchOcclusionMode = static_cast<TouchOcclusionMode>(touchOcclusionModeInt); |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 228 | inputConfig = ftl::Flags<InputConfig>(inputConfigInt); |
Prabir Pradhan | aeebeb4 | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 229 | ownerPid = Pid{ownerPidInt}; |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 230 | ownerUid = Uid{static_cast<uid_t>(ownerUidInt)}; |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 231 | touchableRegionCropHandle = touchableRegionCropHandleSp; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 232 | |
Prabir Pradhan | 032141e | 2022-02-15 05:30:01 -0800 | [diff] [blame] | 233 | return OK; |
Robert Carr | 1cc7867 | 2018-07-31 14:25:57 -0700 | [diff] [blame] | 234 | } |
| 235 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 236 | WindowInfoHandle::WindowInfoHandle() {} |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 237 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 238 | WindowInfoHandle::~WindowInfoHandle() {} |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 239 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 240 | WindowInfoHandle::WindowInfoHandle(const WindowInfoHandle& other) : mInfo(other.mInfo) {} |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 241 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 242 | WindowInfoHandle::WindowInfoHandle(const WindowInfo& other) : mInfo(other) {} |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 243 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 244 | status_t WindowInfoHandle::writeToParcel(android::Parcel* parcel) const { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 245 | return mInfo.writeToParcel(parcel); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 246 | } |
| 247 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 248 | status_t WindowInfoHandle::readFromParcel(const android::Parcel* parcel) { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 249 | return mInfo.readFromParcel(parcel); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 250 | } |
| 251 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 252 | void WindowInfoHandle::releaseChannel() { |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 253 | mInfo.token.clear(); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 254 | } |
| 255 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 256 | sp<IBinder> WindowInfoHandle::getToken() const { |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 257 | return mInfo.token; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 258 | } |
| 259 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 260 | void WindowInfoHandle::updateFrom(sp<WindowInfoHandle> handle) { |
Garfield Tan | bd0fbcd | 2018-11-30 12:45:03 -0800 | [diff] [blame] | 261 | mInfo = handle->mInfo; |
| 262 | } |
Siarhei Vishniakou | 366fb5b | 2023-12-06 11:23:41 -0800 | [diff] [blame] | 263 | |
Siarhei Vishniakou | aeed0da | 2024-01-09 08:57:13 -0800 | [diff] [blame] | 264 | std::ostream& operator<<(std::ostream& out, const WindowInfo& info) { |
Siarhei Vishniakou | 366fb5b | 2023-12-06 11:23:41 -0800 | [diff] [blame] | 265 | out << "name=" << info.name << ", id=" << info.id << ", displayId=" << info.displayId |
| 266 | << ", inputConfig=" << info.inputConfig.string() << ", alpha=" << info.alpha << ", frame=[" |
| 267 | << info.frame.left << "," << info.frame.top << "][" << info.frame.right << "," |
| 268 | << info.frame.bottom << "], globalScale=" << info.globalScaleFactor |
| 269 | << ", applicationInfo.name=" << info.applicationInfo.name |
| 270 | << ", applicationInfo.token=" << info.applicationInfo.token |
| 271 | << ", touchableRegion=" << info.touchableRegion << ", ownerPid=" << info.ownerPid.toString() |
| 272 | << ", ownerUid=" << info.ownerUid.toString() << ", dispatchingTimeout=" |
| 273 | << std::chrono::duration_cast<std::chrono::milliseconds>(info.dispatchingTimeout).count() |
| 274 | << "ms, token=" << info.token.get() |
Vishnu Nair | aa20770 | 2024-02-23 22:22:18 +0000 | [diff] [blame^] | 275 | << ", touchOcclusionMode=" << ftl::enum_string(info.touchOcclusionMode); |
| 276 | if (info.canOccludePresentation) out << ", canOccludePresentation"; |
| 277 | std::string transform; |
| 278 | info.transform.dump(transform, "transform", " "); |
| 279 | out << "\n" << transform; |
Siarhei Vishniakou | 366fb5b | 2023-12-06 11:23:41 -0800 | [diff] [blame] | 280 | return out; |
| 281 | } |
| 282 | |
Siarhei Vishniakou | aeed0da | 2024-01-09 08:57:13 -0800 | [diff] [blame] | 283 | std::ostream& operator<<(std::ostream& out, const WindowInfoHandle& window) { |
| 284 | const WindowInfo& info = *window.getInfo(); |
| 285 | out << info; |
| 286 | return out; |
| 287 | } |
| 288 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 289 | } // namespace android::gui |