Fix bubble bar state after rotation on foldable

Currently when the views get updated for a mode change, it doesn't
take into account the expanded state. This change ensures that if
bubbles was expanded prior to a mode change, the expanded state
gets applied to the layer view & that the expanded and selected state
is sent over to launcher in the initial bubble bar state.

The real root cause of this is that when a foldable is rotated, we're
getting an unregister and then a register call for our bubble state
listener from launcher, which causes a mode change. It would be good
to check why that's happening because it seems incorrect, however, we
shouldn't rely on launcher's correctness / should ensure the current
state is applied which is what this CL does.

Flag: com.android.wm.shell.bubble_bar
Test: atest BubbleDataTest BubblesTest
Test: manual - enable bubble bar on a foldable
             - expand bubbles, rotate device
             => observe that bubbles are expanded still
             => collapse bubbles and check that swipe to home and
                overview works fine
Bug: 324443226
Change-Id: I12ec9755cc1d5de9d03ca2074eaac16a6bb1efa8
4 files changed