summaryrefslogtreecommitdiff
path: root/libs/gui/WindowInfo.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2022-08-16 11:49:27 -0700
committer Xin Li <delphij@google.com> 2022-08-16 11:49:27 -0700
commit91192c8103e78895c57d9da1fc04c8695898580f (patch)
tree9a4deff758bed03ccc5ff838dc55f467c303d762 /libs/gui/WindowInfo.cpp
parent896cdca96956b6f14e262380b34a0b04e1214b50 (diff)
parenta7459772bbc558b8b13df09de8b0cea156d81870 (diff)
DO NOT MERGE - Merge Android 13
Bug: 242648940 Merged-In: Ia3eae81cc26b28b0d25dc5f5c6cd04ec8c1bafdf Change-Id: Icd8e5ea85bfed76d58c81368d94dd1f6101fc087
Diffstat (limited to 'libs/gui/WindowInfo.cpp')
-rw-r--r--libs/gui/WindowInfo.cpp123
1 files changed, 60 insertions, 63 deletions
diff --git a/libs/gui/WindowInfo.cpp b/libs/gui/WindowInfo.cpp
index b2ef7aabc9..4e966d1393 100644
--- a/libs/gui/WindowInfo.cpp
+++ b/libs/gui/WindowInfo.cpp
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-#include <type_traits>
#define LOG_TAG "WindowInfo"
#define LOG_NDEBUG 0
-#include <android-base/stringprintf.h>
+#include <type_traits>
+
#include <binder/Parcel.h>
#include <gui/WindowInfo.h>
@@ -26,7 +26,14 @@
namespace android::gui {
-// --- WindowInfo ---
+void WindowInfo::setInputConfig(ftl::Flags<InputConfig> config, bool value) {
+ if (value) {
+ inputConfig |= config;
+ return;
+ }
+ inputConfig &= ~config;
+}
+
void WindowInfo::addTouchableRegion(const Rect& region) {
touchableRegion.orSelf(region);
}
@@ -40,30 +47,36 @@ bool WindowInfo::frameContainsPoint(int32_t x, int32_t y) const {
}
bool WindowInfo::supportsSplitTouch() const {
- return flags.test(Flag::SPLIT_TOUCH);
+ return !inputConfig.test(InputConfig::PREVENT_SPLITTING);
+}
+
+bool WindowInfo::isSpy() const {
+ return inputConfig.test(InputConfig::SPY);
+}
+
+bool WindowInfo::interceptsStylus() const {
+ return inputConfig.test(InputConfig::INTERCEPTS_STYLUS);
}
bool WindowInfo::overlaps(const WindowInfo* other) const {
- return frameLeft < other->frameRight && frameRight > other->frameLeft &&
+ const bool nonEmpty = (frameRight - frameLeft > 0) || (frameBottom - frameTop > 0);
+ return nonEmpty && frameLeft < other->frameRight && frameRight > other->frameLeft &&
frameTop < other->frameBottom && frameBottom > other->frameTop;
}
bool WindowInfo::operator==(const WindowInfo& info) const {
- return info.token == token && info.id == id && info.name == name && info.flags == flags &&
- info.type == type && info.dispatchingTimeout == dispatchingTimeout &&
- info.frameLeft == frameLeft && info.frameTop == frameTop &&
- info.frameRight == frameRight && info.frameBottom == frameBottom &&
- info.surfaceInset == surfaceInset && info.globalScaleFactor == globalScaleFactor &&
- info.transform == transform && info.displayOrientation == displayOrientation &&
- info.displayWidth == displayWidth && info.displayHeight == displayHeight &&
- info.touchableRegion.hasSameRects(touchableRegion) && info.visible == visible &&
- info.trustedOverlay == trustedOverlay && info.focusable == focusable &&
- info.touchOcclusionMode == touchOcclusionMode && info.hasWallpaper == hasWallpaper &&
- info.paused == paused && info.ownerPid == ownerPid && info.ownerUid == ownerUid &&
- info.packageName == packageName && info.inputFeatures == inputFeatures &&
- info.displayId == displayId && info.portalToDisplayId == portalToDisplayId &&
+ return info.token == token && info.id == id && info.name == name &&
+ info.dispatchingTimeout == dispatchingTimeout && info.frameLeft == frameLeft &&
+ info.frameTop == frameTop && info.frameRight == frameRight &&
+ info.frameBottom == frameBottom && info.surfaceInset == surfaceInset &&
+ info.globalScaleFactor == globalScaleFactor && info.transform == transform &&
+ info.touchableRegion.hasSameRects(touchableRegion) &&
+ info.touchOcclusionMode == touchOcclusionMode && info.ownerPid == ownerPid &&
+ info.ownerUid == ownerUid && info.packageName == packageName &&
+ info.inputConfig == inputConfig && info.displayId == displayId &&
info.replaceTouchableRegionWithCrop == replaceTouchableRegionWithCrop &&
- info.applicationInfo == applicationInfo;
+ info.applicationInfo == applicationInfo && info.layoutParamsType == layoutParamsType &&
+ info.layoutParamsFlags == layoutParamsFlags && info.isClone == isClone;
}
status_t WindowInfo::writeToParcel(android::Parcel* parcel) const {
@@ -77,13 +90,17 @@ status_t WindowInfo::writeToParcel(android::Parcel* parcel) const {
}
parcel->writeInt32(1);
+ // Ensure that the size of the flags that we use is 32 bits for writing into the parcel.
+ static_assert(sizeof(inputConfig) == 4u);
+
// clang-format off
status_t status = parcel->writeStrongBinder(token) ?:
parcel->writeInt64(dispatchingTimeout.count()) ?:
parcel->writeInt32(id) ?:
parcel->writeUtf8AsUtf16(name) ?:
- parcel->writeInt32(flags.get()) ?:
- parcel->writeInt32(static_cast<std::underlying_type_t<WindowInfo::Type>>(type)) ?:
+ parcel->writeInt32(layoutParamsFlags.get()) ?:
+ parcel->writeInt32(
+ static_cast<std::underlying_type_t<WindowInfo::Type>>(layoutParamsType)) ?:
parcel->writeInt32(frameLeft) ?:
parcel->writeInt32(frameTop) ?:
parcel->writeInt32(frameRight) ?:
@@ -97,26 +114,18 @@ status_t WindowInfo::writeToParcel(android::Parcel* parcel) const {
parcel->writeFloat(transform.dtdy()) ?:
parcel->writeFloat(transform.dsdy()) ?:
parcel->writeFloat(transform.ty()) ?:
- parcel->writeUint32(displayOrientation) ?:
- parcel->writeInt32(displayWidth) ?:
- parcel->writeInt32(displayHeight) ?:
- parcel->writeBool(visible) ?:
- parcel->writeBool(focusable) ?:
- parcel->writeBool(hasWallpaper) ?:
- parcel->writeBool(paused) ?:
- parcel->writeBool(trustedOverlay) ?:
parcel->writeInt32(static_cast<int32_t>(touchOcclusionMode)) ?:
parcel->writeInt32(ownerPid) ?:
parcel->writeInt32(ownerUid) ?:
parcel->writeUtf8AsUtf16(packageName) ?:
- parcel->writeInt32(inputFeatures.get()) ?:
+ parcel->writeInt32(inputConfig.get()) ?:
parcel->writeInt32(displayId) ?:
- parcel->writeInt32(portalToDisplayId) ?:
applicationInfo.writeToParcel(parcel) ?:
parcel->write(touchableRegion) ?:
parcel->writeBool(replaceTouchableRegionWithCrop) ?:
parcel->writeStrongBinder(touchableRegionCropHandle.promote()) ?:
- parcel->writeStrongBinder(windowToken);
+ parcel->writeStrongBinder(windowToken) ?:
+ parcel->writeBool(isClone);
// clang-format on
return status;
}
@@ -137,12 +146,14 @@ status_t WindowInfo::readFromParcel(const android::Parcel* parcel) {
return status;
}
- flags = Flags<Flag>(parcel->readInt32());
- type = static_cast<Type>(parcel->readInt32());
float dsdx, dtdx, tx, dtdy, dsdy, ty;
- int32_t touchOcclusionModeInt;
+ int32_t lpFlags, lpType, touchOcclusionModeInt, inputConfigInt;
+ sp<IBinder> touchableRegionCropHandleSp;
+
// clang-format off
- status = parcel->readInt32(&frameLeft) ?:
+ status = parcel->readInt32(&lpFlags) ?:
+ parcel->readInt32(&lpType) ?:
+ parcel->readInt32(&frameLeft) ?:
parcel->readInt32(&frameTop) ?:
parcel->readInt32(&frameRight) ?:
parcel->readInt32(&frameBottom) ?:
@@ -155,48 +166,34 @@ status_t WindowInfo::readFromParcel(const android::Parcel* parcel) {
parcel->readFloat(&dtdy) ?:
parcel->readFloat(&dsdy) ?:
parcel->readFloat(&ty) ?:
- parcel->readUint32(&displayOrientation) ?:
- parcel->readInt32(&displayWidth) ?:
- parcel->readInt32(&displayHeight) ?:
- parcel->readBool(&visible) ?:
- parcel->readBool(&focusable) ?:
- parcel->readBool(&hasWallpaper) ?:
- parcel->readBool(&paused) ?:
- parcel->readBool(&trustedOverlay) ?:
parcel->readInt32(&touchOcclusionModeInt) ?:
parcel->readInt32(&ownerPid) ?:
parcel->readInt32(&ownerUid) ?:
- parcel->readUtf8FromUtf16(&packageName);
- // clang-format on
-
- if (status != OK) {
- return status;
- }
-
- touchOcclusionMode = static_cast<TouchOcclusionMode>(touchOcclusionModeInt);
-
- inputFeatures = Flags<Feature>(parcel->readInt32());
- // clang-format off
- status = parcel->readInt32(&displayId) ?:
- parcel->readInt32(&portalToDisplayId) ?:
+ parcel->readUtf8FromUtf16(&packageName) ?:
+ parcel->readInt32(&inputConfigInt) ?:
+ parcel->readInt32(&displayId) ?:
applicationInfo.readFromParcel(parcel) ?:
parcel->read(touchableRegion) ?:
- parcel->readBool(&replaceTouchableRegionWithCrop);
+ parcel->readBool(&replaceTouchableRegionWithCrop) ?:
+ parcel->readNullableStrongBinder(&touchableRegionCropHandleSp) ?:
+ parcel->readNullableStrongBinder(&windowToken) ?:
+ parcel->readBool(&isClone);
// clang-format on
if (status != OK) {
return status;
}
- touchableRegionCropHandle = parcel->readStrongBinder();
+ layoutParamsFlags = ftl::Flags<Flag>(lpFlags);
+ layoutParamsType = static_cast<Type>(lpType);
transform.set({dsdx, dtdx, tx, dtdy, dsdy, ty, 0, 0, 1});
+ touchOcclusionMode = static_cast<TouchOcclusionMode>(touchOcclusionModeInt);
+ inputConfig = ftl::Flags<InputConfig>(inputConfigInt);
+ touchableRegionCropHandle = touchableRegionCropHandleSp;
- status = parcel->readNullableStrongBinder(&windowToken);
- return status;
+ return OK;
}
-// --- WindowInfoHandle ---
-
WindowInfoHandle::WindowInfoHandle() {}
WindowInfoHandle::~WindowInfoHandle() {}