This directory: src/com/android/car/scalableui
Contains the model and event handling logic for the Car Scalable UI library, enabling event-driven UI state management and rendering for automotive displays.
Variants) and Transitions for a logical UI panel.Events and updates Panel properties.Panel instances.loader/: Handles loading of panel and state definitions from resources or configurations.manager/: Contains the StateManager.metrics/: Utilities for performance monitoring (e.g., jank).model/: Data classes like Event, PanelState, Variant, Transition, PanelTransaction.panel/: Contains the Panel interface and the PanelPool.PanelState objects with Variants and Transitions) are loaded, often by the loader/ components.Panel instances are created as needed via the PanelPool, using a PanelCreatorDelegate provided by the host environment (e.g., SystemUI).Event occurs (e.g., user interaction, system status change).StateManager.handleEvents() method is called with the Event.StateManager determines which PanelStates are affected, calculates the target Variants, and builds a PanelTransaction containing necessary Animators and callbacks.PanelTransaction, triggering animations and updating Panel properties.Panel implementations render the changes on the screen.manager/StateManager.java)Singleton responsible for the core state transition logic.
Responsibilities:
PanelState objects.Events to determine state changes.PanelTransactions to encapsulate UI updates.PanelPool to get Panel instances to apply state to.handleEvents(List<Event> events, boolean force) Method:
This method is the heart of the event-driven state changes.
PanelState.getTransitionForEvents to find the single resulting Transition after sequentially simulating the effects of each Event in the input list. The events are evaluated in order, and the state resulting from one event becomes the starting point for the next.Variant is the same as the current one and force is not true, no action is taken for this panel (with an exception for KeyFrameVariant).Transition has an Animator, it's added to the PanelTransaction.Builder. The PanelState's current variant is updated, and animation listeners are set to call applyState on completion.Animator, the state is applied immediately via applyState() if the panel is not already animating.PanelTransaction.model/PanelTransaction.java)Represents a set of operations to be applied to one or more panels, usually as a single logical unit.
Key Components:
mTransactionMap: Map<String, Transition> - Panel ID to the Transition to be applied.mAnimatorMap: Map<String, Animator> - Panel ID to the Animator for the transition.mLockededPanelIdSet: Set<String> - Panels to exclude from changes in this transaction.mHasWindowChanges: boolean - Hints if Window Manager operations might be needed.mAnimationStartCallbackRunnable: Runnable - Executed before animations start.mAnimationEndCallbackRunnable: Runnable - Executed after animations end.Execution Flow:
Animators.Panel properties.panel/PanelPool.java)Singleton managing the creation and retrieval of Panel instances.
Key Features:
Panel instance per ID.Panel creation to a PanelCreatorDelegate (provided externally).getOrCreatePanel().PanelState (model/PanelState.java): The Definition
Variants) a panel can be in, the transitions between them, and its current logical state (e.g., which Variant is active).StateManager.Panel (panel/Panel.java): The Instance
PanelPool and their concrete type depends on the rendering layer (e.g., View-based, SurfaceControl-based).Interaction: StateManager reads the PanelState to know what the UI should look like. Then, it gets the corresponding Panel instance from the PanelPool and calls methods on the Panel to make the on-screen representation match the desired state in PanelState.