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

Commit 6f9a9525 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Fix work profile reinflations when shade window moves between displays

The problem happens if both the following conditions are true:
- Shade is on the default display
- App that triggers the notification is in an external display

When the above is true, the notification was inflated with the wrong
display context, resulting in wrong sizing (e.g. notification on the
default display with dimensions for the external one)

Why was this happening though, as with the
enablePerDisplayPackageContextCacheInStatusbarNotif we already used a
per-display context cache in creating the context for each notification?

It turns out the cache is used for both status bar icons and
notification row view inflations.
However, for the default display the statusbar context is the
SystemUIApplication one, so it's not a WindowContext and does not have a
 mToken associated (see ContextImpl.java for more details on mToken, but
  essentially it's needed to create new resources associated to the
  correct display).

The root cause of the issue here is that when a package context was
created from the application context (from StatusBarNotification
.getPackageContext), even if the application context was associated with
 the default display, it caused the resulting context to have resources
 for the display associated with the app (so the external display in
 this case). The result was a context with wrong resources for the
 default display, that was causing inflations with wrong dimensions (as
 the configuration was wrong)

This is now fixed by always using a STATUS_BAR WindowContext for the
statusbar, instead of the application context. This causes all the
package context created to have resources for the correct display.

You might also ask: why are we using the @Main/@StatusBarMain context in
 IconBuilder, instead of a display specific one? It's wrong, and that
 class should be refactored to avoid using the default context at all.
 If it was already using the correct WindowContext there, the creation
 of the new package context cached would have been correct already. This
  should be fixed as part of another refactor.

Bug: 414788860
Flag: com.android.systemui.shade_window_goes_around
Test: DisplayWindowPropertiesRepositoryImplTest
Change-Id: Ie836c13864c8f77dc4d1babafe8d44337a70f218
parent 4d1f3b8e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment