GSI updates for frameworks/native
Change-Id: I37d241a88c7bbe3c4a1a237ffe83a6d5f57129b8
diff --git a/patches/frameworks/native/0001-Ignore-usage-bits-verification.patch b/patches/frameworks/native/0001-Ignore-usage-bits-verification.patch
new file mode 100644
index 0000000..582ef1d
--- /dev/null
+++ b/patches/frameworks/native/0001-Ignore-usage-bits-verification.patch
@@ -0,0 +1,31 @@
+From 2ef0a95324974587a6b3d73217d34ca0f1e57063 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Sun, 19 Aug 2018 23:07:24 +0200
+Subject: [PATCH 1/4] Ignore usage bits verification
+
+This didn't ignore as of 8.1, so we're ""safe""
+
+Conflicts:
+ libs/ui/Gralloc2.cpp
+
+Change-Id: I5d7643416e24249b30347369eec2510259fa1c53
+---
+ libs/ui/Gralloc2.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp
+index 105d2cbfa..8d859afb3 100644
+--- a/libs/ui/Gralloc2.cpp
++++ b/libs/ui/Gralloc2.cpp
+@@ -92,7 +92,7 @@ Gralloc2::Error Mapper::validateBufferDescriptorInfo(
+ if (descriptorInfo.usage & ~validUsageBits) {
+ ALOGE("buffer descriptor contains invalid usage bits 0x%" PRIx64,
+ descriptorInfo.usage & ~validUsageBits);
+- return Error::NONE;
++ //return Error::BAD_VALUE;
+ }
+ return Error::NONE;
+ }
+--
+2.17.1
+
diff --git a/patches/frameworks/native/0001-Enable-fallback-to-old-ro.sf.hwrotation-property.patch b/patches/frameworks/native/0002-Enable-fallback-to-old-ro.sf.hwrotation-property.patch
similarity index 89%
rename from patches/frameworks/native/0001-Enable-fallback-to-old-ro.sf.hwrotation-property.patch
rename to patches/frameworks/native/0002-Enable-fallback-to-old-ro.sf.hwrotation-property.patch
index 8a00c8e..05c6be7 100644
--- a/patches/frameworks/native/0001-Enable-fallback-to-old-ro.sf.hwrotation-property.patch
+++ b/patches/frameworks/native/0002-Enable-fallback-to-old-ro.sf.hwrotation-property.patch
@@ -1,14 +1,14 @@
-From ab72887deb1b7b297efc3bb26a62e23069a42081 Mon Sep 17 00:00:00 2001
+From 520e662326d5932d74c9e4fb0a3dc57fcb858b23 Mon Sep 17 00:00:00 2001
From: phh <phh@phh.me>
Date: Wed, 22 Aug 2018 08:57:52 +0000
-Subject: [PATCH] Enable fallback to old ro.sf.hwrotation property
+Subject: [PATCH 2/4] Enable fallback to old ro.sf.hwrotation property
---
services/surfaceflinger/SurfaceFlinger.cpp | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
-index b2d4637f1..22b13a578 100644
+index d1a6ca781..cb3fa9ec1 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -292,6 +292,24 @@ SurfaceFlinger::SurfaceFlinger() : SurfaceFlinger(SkipInitialization) {
diff --git a/patches/frameworks/native/0003-Revert-sf-Fix-damage-for-Huawei-compositor.patch b/patches/frameworks/native/0003-Revert-sf-Fix-damage-for-Huawei-compositor.patch
new file mode 100644
index 0000000..7b44a7e
--- /dev/null
+++ b/patches/frameworks/native/0003-Revert-sf-Fix-damage-for-Huawei-compositor.patch
@@ -0,0 +1,93 @@
+From 090a7ac43a4ee42a092580a4339d51e66e0cab7a Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Sat, 25 Aug 2018 02:13:29 -0400
+Subject: [PATCH 3/4] Revert "sf: Fix damage for Huawei compositor"
+
+This reverts commit 508eeaea266bc018bf1265f789ed858b73dd7079.
+---
+ services/surfaceflinger/BufferLayer.cpp | 35 +---------------------
+ services/surfaceflinger/SurfaceFlinger.cpp | 8 -----
+ services/surfaceflinger/SurfaceFlinger.h | 2 --
+ 3 files changed, 1 insertion(+), 44 deletions(-)
+
+diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
+index 264d35aed..7ac143219 100644
+--- a/services/surfaceflinger/BufferLayer.cpp
++++ b/services/surfaceflinger/BufferLayer.cpp
+@@ -631,40 +631,7 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice)
+ visible.dump(LOG_TAG);
+ }
+
+- if(mFlinger->mDamageUsesScreenReference) {
+- const Rect& frame = hwcInfo.displayFrame;
+- int32_t left = frame.left;
+- int32_t top = frame.top;
+- int32_t right = frame.right;
+- int32_t bottom = frame.bottom;
+- if(surfaceDamageRegion.getBounds() == Rect::INVALID_RECT) {
+- auto fullSource = Region(Rect(left, top, right, bottom));
+- error = hwcLayer->setSurfaceDamage(fullSource);
+- } else {
+- //There is no easy way to scale, so just scale the bounds
+- const Rect& preDamageRect = surfaceDamageRegion.bounds();
+- const FloatRect& crop = hwcInfo.sourceCrop;
+-
+- float frameWidth = right - left;
+- float frameHeight = bottom - top;
+-
+- float cropWidth = crop.right - crop.left;
+- float cropHeight = crop.bottom - crop.top;
+-
+- float wFactor = frameWidth / cropWidth;
+- float hFactor = frameHeight / cropHeight;
+-
+- Rect scaledDamageRect = Rect(
+- (int)(preDamageRect.left * wFactor),
+- (int)(preDamageRect.top * hFactor),
+- (int)(preDamageRect.right * wFactor),
+- (int)(preDamageRect.bottom * hFactor));
+- Region realDamage = Region(scaledDamageRect).translate(frame.left, frame.top);
+- error = hwcLayer->setSurfaceDamage(realDamage);
+- }
+- } else {
+- error = hwcLayer->setSurfaceDamage(surfaceDamageRegion);
+- }
++ error = hwcLayer->setSurfaceDamage(surfaceDamageRegion);
+ if (error != HWC2::Error::None) {
+ ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(),
+ to_string(error).c_str(), static_cast<int32_t>(error));
+diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
+index cb3fa9ec1..0580b4bfc 100644
+--- a/services/surfaceflinger/SurfaceFlinger.cpp
++++ b/services/surfaceflinger/SurfaceFlinger.cpp
+@@ -384,14 +384,6 @@ SurfaceFlinger::SurfaceFlinger() : SurfaceFlinger(SkipInitialization) {
+ // for production purposes later on.
+ setenv("TREBLE_TESTING_OVERRIDE", "true", true);
+ }
+-
+- property_get("ro.hardware", value, "");
+- if (!strcmp(value, "hi3660") ||
+- !strcmp(value, "hi6250") ||
+- !strcmp(value, "hi3670") ||
+- !strcmp(value, "kirin970")) {
+- mDamageUsesScreenReference = true;
+- }
+ }
+
+ void SurfaceFlinger::onFirstRef()
+diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
+index 7a8762b83..0148ab675 100644
+--- a/services/surfaceflinger/SurfaceFlinger.h
++++ b/services/surfaceflinger/SurfaceFlinger.h
+@@ -852,8 +852,6 @@ private:
+ // Restrict layers to use two buffers in their bufferqueues.
+ bool mLayerTripleBufferingDisabled = false;
+
+- bool mDamageUsesScreenReference;
+-
+ // these are thread safe
+ mutable std::unique_ptr<MessageQueue> mEventQueue{std::make_unique<impl::MessageQueue>()};
+ FrameTracker mAnimFrameTracker;
+--
+2.17.1
+
diff --git a/patches/frameworks/native/0004-device-Huawei-HWC-doesn-t-understand-0-0-0-0-fullscr.patch b/patches/frameworks/native/0004-device-Huawei-HWC-doesn-t-understand-0-0-0-0-fullscr.patch
new file mode 100644
index 0000000..0002bec
--- /dev/null
+++ b/patches/frameworks/native/0004-device-Huawei-HWC-doesn-t-understand-0-0-0-0-fullscr.patch
@@ -0,0 +1,74 @@
+From 8ee3c4eba65c42f02c13d5bb65dcce33e9c0260a Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Fri, 5 Jan 2018 00:26:38 +0100
+Subject: [PATCH 4/4] [device] ::Huawei:: HWC doesn't understand 0,0,0,0 ==
+ fullscreen damage. Set it to the whole visible surface
+
+::Huawei:: Fix damage for Huawei compositor
+
+For Huawei compositor, the damage area is a region on the screen.
+But for SurfaceFlinger, this is a region on the source surface.
+On Huawei devices, do the plane conversion.
+
+This fixes several UI glitches, most notably GBoard.
+---
+ services/surfaceflinger/BufferLayer.cpp | 8 +++++++-
+ services/surfaceflinger/SurfaceFlinger.cpp | 8 ++++++++
+ services/surfaceflinger/SurfaceFlinger.h | 3 +++
+ 3 files changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
+index 7ac143219..2646af0c9 100644
+--- a/services/surfaceflinger/BufferLayer.cpp
++++ b/services/surfaceflinger/BufferLayer.cpp
+@@ -631,7 +631,13 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice)
+ visible.dump(LOG_TAG);
+ }
+
+- error = hwcLayer->setSurfaceDamage(surfaceDamageRegion);
++ if(mFlinger->mDamageUsesScreenReference) {
++ const auto& frame = hwcInfo.displayFrame;
++ auto fullSource = Region(Rect(frame.left, frame.top, frame.right, frame.bottom));
++ error = hwcLayer->setSurfaceDamage(fullSource);
++ } else {
++ error = hwcLayer->setSurfaceDamage(surfaceDamageRegion);
++ }
+ if (error != HWC2::Error::None) {
+ ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(),
+ to_string(error).c_str(), static_cast<int32_t>(error));
+diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
+index 0580b4bfc..49e3b269a 100644
+--- a/services/surfaceflinger/SurfaceFlinger.cpp
++++ b/services/surfaceflinger/SurfaceFlinger.cpp
+@@ -384,6 +384,14 @@ SurfaceFlinger::SurfaceFlinger() : SurfaceFlinger(SkipInitialization) {
+ // for production purposes later on.
+ setenv("TREBLE_TESTING_OVERRIDE", "true", true);
+ }
++
++ property_get("ro.hardware", value, "");
++ if(strstr(value, "hi3660")||
++ strstr(value, "hi6250") ||
++ strstr(value, "hi3670") ||
++ strstr(value, "kirin970")) {
++ mDamageUsesScreenReference = true;
++ }
+ }
+
+ void SurfaceFlinger::onFirstRef()
+diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
+index 0148ab675..367ea555a 100644
+--- a/services/surfaceflinger/SurfaceFlinger.h
++++ b/services/surfaceflinger/SurfaceFlinger.h
+@@ -852,6 +852,9 @@ private:
+ // Restrict layers to use two buffers in their bufferqueues.
+ bool mLayerTripleBufferingDisabled = false;
+
++ bool mDamageUsesScreenReference;
++
++
+ // these are thread safe
+ mutable std::unique_ptr<MessageQueue> mEventQueue{std::make_unique<impl::MessageQueue>()};
+ FrameTracker mAnimFrameTracker;
+--
+2.17.1
+