From 7bf6dc611a752cdac72cbb84bd57e69621ef36a0 Mon Sep 17 00:00:00 2001 From: Tiger Date: Wed, 31 May 2023 16:54:26 +0800 Subject: [PATCH] Use the copy constructor to create simulated sources In this way, we don't need to modify the code in createSimulatedSource when there is a new field of InsetsSource. This fixes a regression since 244e9600633a2ebe77de4585cfa518d2dedf358a Fix: 285080829 Test: Open Settings from portrait while holding device in landscape, and see if the nav bar area is transparent in gesture nav mode. Change-Id: I8288f9d9bf6f2f28a71448cc35727c1c3955bad7 --- .../com/android/server/wm/InsetsSourceProvider.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index b7eaf259ea7ab..1a322ff0196f4 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -272,15 +272,17 @@ class InsetsSourceProvider { /** @return A new source computed by the specified window frame in the given display frames. */ InsetsSource createSimulatedSource(DisplayFrames displayFrames, Rect frame) { - // Don't copy visible frame because it might not be calculated in the provided display - // frames and it is not significant for this usage. - final InsetsSource source = new InsetsSource(mSource.getId(), mSource.getType()); - source.setVisible(mSource.isVisible()); + final InsetsSource source = new InsetsSource(mSource); mTmpRect.set(frame); if (mFrameProvider != null) { mFrameProvider.apply(displayFrames, mWindowContainer, mTmpRect); } source.setFrame(mTmpRect); + + // Don't copy visible frame because it might not be calculated in the provided display + // frames and it is not significant for this usage. + source.setVisibleFrame(null); + return source; }