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

Commit db4ec8ac authored by Steven Ng's avatar Steven Ng
Browse files

Fix preview layout crash upon screen rotation

Preview layouts are rendered via LauncherAppWidgetHostView. These
layouts are not yet added to the launcher. And thus, there is no
LauncherAppWidgetInfo.

Test: When a preview layout is shown in the recommended widget section,
      rotate the screen. No crash is observed.
Bug: 190395009
Change-Id: Ib1d080a106681fbfe3a4293f9f51f9576ef9414b
parent 25788e96
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -481,6 +481,10 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView
            return;
        }
        LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) getTag();
        if (info == null) {
            // This occurs when LauncherAppWidgetHostView is used to render a preview layout.
            return;
        }
        // Remove and rebind the current widget (which was inflated in the wrong
        // orientation), but don't delete it from the database
        mLauncher.removeItem(this, info, false  /* deleteFromDb */);