From 13bf76a87d9113d60f39e645c5453bf18d0a158d Mon Sep 17 00:00:00 2001 From: Linnan Li Date: Sun, 5 May 2024 19:18:02 +0800 Subject: Use a strongly typed LogicalDisplayId for displayId(2/n) Currently, we use int32_t for displayId, which is not a safe type, and it may also lead to misdefinition of types. Here, we introduce LogicalDisplayId as a strong type for displayId and move all contents of constants.h into LogicalDisplayId.h. Bug: 339106983 Test: atest inputflinger_tests Test: atest InputTests Test: m checkinput Test: m libsurfaceflinger_unittest Test: presubmit Change-Id: If44e56f69553d095af5adb59b595e4a852ab32ce Signed-off-by: Linnan Li --- libs/gui/WindowInfo.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libs/gui/WindowInfo.cpp') diff --git a/libs/gui/WindowInfo.cpp b/libs/gui/WindowInfo.cpp index ad0d99d11e..82d2554340 100644 --- a/libs/gui/WindowInfo.cpp +++ b/libs/gui/WindowInfo.cpp @@ -146,7 +146,7 @@ status_t WindowInfo::writeToParcel(android::Parcel* parcel) const { parcel->writeInt32(ownerUid.val()) ?: parcel->writeUtf8AsUtf16(packageName) ?: parcel->writeInt32(inputConfig.get()) ?: - parcel->writeInt32(displayId) ?: + parcel->writeInt32(displayId.val()) ?: applicationInfo.writeToParcel(parcel) ?: parcel->write(touchableRegion) ?: parcel->writeBool(replaceTouchableRegionWithCrop) ?: @@ -175,7 +175,8 @@ status_t WindowInfo::readFromParcel(const android::Parcel* parcel) { } float dsdx, dtdx, tx, dtdy, dsdy, ty; - int32_t lpFlags, lpType, touchOcclusionModeInt, inputConfigInt, ownerPidInt, ownerUidInt; + int32_t lpFlags, lpType, touchOcclusionModeInt, inputConfigInt, ownerPidInt, ownerUidInt, + displayIdInt; sp touchableRegionCropHandleSp; // clang-format off @@ -198,7 +199,7 @@ status_t WindowInfo::readFromParcel(const android::Parcel* parcel) { parcel->readInt32(&ownerUidInt) ?: parcel->readUtf8FromUtf16(&packageName) ?: parcel->readInt32(&inputConfigInt) ?: - parcel->readInt32(&displayId) ?: + parcel->readInt32(&displayIdInt) ?: applicationInfo.readFromParcel(parcel) ?: parcel->read(touchableRegion) ?: parcel->readBool(&replaceTouchableRegionWithCrop) ?: @@ -221,6 +222,7 @@ status_t WindowInfo::readFromParcel(const android::Parcel* parcel) { ownerPid = Pid{ownerPidInt}; ownerUid = Uid{static_cast(ownerUidInt)}; touchableRegionCropHandle = touchableRegionCropHandleSp; + displayId = ui::LogicalDisplayId{displayIdInt}; return OK; } -- cgit v1.2.3-59-g8ed1b