3/ Fix inverted ShellInit dependency order (no functional changes)

- We were previously initializing components manually because some startup
  is order-dependent, which led to an increasing number of dependencies
  from ShellTaskOrganizer on things that it really doesn't need to know
  about.  The initialization order actually matches the dependency order
  pretty closely, so instead we can have these components add callbacks
  in the order they are created and initalize in sequence.
- Also move some logic out of constructors to the init callback
- The other subtle issue is that the provider for ShellInitImpl was
  implicitly also ensuring that certain shell components were created at
  startup (since they aren't otherwise referenced by any SysUI component
  directly or indirectly).  Instead, separate that out into another
  more explicit provider, with the @ShellCreateTrigger annotation, and
  allow subclasses to provide a @ShellCreateTriggerOverride annotated
  provider for product-specific initialization

Test: atest WMShellUnitTests
Test: atest SystemUITests
Bug: 238217847

Change-Id: I4a2583ceeaf469130ac07fc8c4e267c28843b7b8
Signed-off-by: Winson Chung <winsonc@google.com>
This commit is contained in:
Winson Chung
2022-07-21 05:49:36 +00:00
parent 68de89974b
commit 91a416bae9
49 changed files with 1035 additions and 453 deletions

View File

@@ -79,11 +79,6 @@ public abstract class SystemUIInitializer {
// Stand up WMComponent
setupWmComponent(mContext);
if (initializeComponents) {
// Only initialize when not starting from tests since this currently initializes some
// components that shouldn't be run in the test environment
mWMComponent.init();
}
// And finally, retrieve whatever SysUI needs from WMShell and build SysUI.
SysUIComponent.Builder builder = mRootComponent.getSysUIComponent();
@@ -102,6 +97,10 @@ public abstract class SystemUIInitializer {
.setDisplayAreaHelper(mWMComponent.getDisplayAreaHelper())
.setRecentTasks(mWMComponent.getRecentTasks())
.setBackAnimation(mWMComponent.getBackAnimation());
// Only initialize when not starting from tests since this currently initializes some
// components that shouldn't be run in the test environment
mWMComponent.init();
} else {
// TODO: Call on prepareSysUIComponentBuilder but not with real components. Other option
// is separating this logic into newly creating SystemUITestsFactory.