Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 180d3c8d authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Support relative insets in wallpaper service

The wallpaper service didn't provide host bounds when calculating insets
based on an assumption that there should be no caption bar attached to a
wallpaper. However, this is not true on desktop environment. In
settings, when the user opens a wallpaper preview in a freeform window,
there will be a wallpaper service instance running inside a window with
a caption bar.

Provide the window's visible frame to let the insets calculation running
as expected.

Bug: 424504547
Bug: 277292497
Test: Open wallpaper settings - view all - preview and it will not crash
Flag: com.android.window.flags.relative_insets
Change-Id: Ia1a4fd9b1b88a76739876ec9f6169f79ef3a2a10
parent 76979804
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1388,8 +1388,13 @@ public abstract class WallpaperService extends Service {
                    final DisplayCutout rawCutout = mInsetsState.getDisplayCutout();
                    final Rect visibleFrame = new Rect(mWinFrames.frame);
                    visibleFrame.intersect(mInsetsState.getDisplayFrame());
                    // A wallpaper usually doesn't have a host window bounds, except when it's shown
                    // as a preview in a freeform window, like in a wallpaper picker.
                    // Host bounds needs to be the accurate value when it has one. The value doesn't
                    // matter when there's no actual host window.
                    final Rect hostBounds = config.windowConfiguration.getBounds();
                    WindowInsets windowInsets = mInsetsState.calculateInsets(visibleFrame,
                            null /* hostBounds */, null /* ignoringVisibilityState */,
                            hostBounds, null /* ignoringVisibilityState */,
                            config.isScreenRound(), mLayout.softInputMode, mLayout.flags,
                            SYSTEM_UI_FLAG_VISIBLE, mLayout.type,
                            config.windowConfiguration.getActivityType(), null /* idSideMap */);