GlassThermalState enum Cost and policy
Thermal pressure, in Apple's four names — the coarser vocabulary of the two, so every Android status maps onto one of them and none of Apple's is invented.
Android's seven statuses fold as NONE → nominal, LIGHT and MODERATE
→ fair, SEVERE → serious, CRITICAL, EMERGENCY and SHUTDOWN →
critical. The line between fair and serious is drawn where both
platforms' own documentation first says the user will notice: Apple's
serious is "system performance is impacted", Android's SEVERE is
"throttling where UX is largely impacted", and MODERATE is "not largely
impacted".
The package does not read the device: the application passes what it read to GlassHost.thermal, and GlassHost.thermalPolicy decides what each state may spend on staleness. Null there is treated as nominal.
GlassThermalState? fromAndroid(int status) => switch (status) {
0 => GlassThermalState.nominal, // THERMAL_STATUS_NONE
1 || 2 => GlassThermalState.fair, // LIGHT, MODERATE
3 => GlassThermalState.serious, // SEVERE
4 || 5 || 6 => GlassThermalState.critical, // CRITICAL, EMERGENCY, SHUTDOWN
_ => null,
};
GlassHost(thermal: fromAndroid(status), child: const MyScreen());
See also:
- GlassThermalPolicy, which turns a state into frames of staleness.
- RetakeReason.throttled, the decision a throttled frame reports.
- g1455.plugfox.dev/foundations/performance.
Values
- nominal → const GlassThermalState
-
No thermal pressure: Apple's
nominal, Android'sNONE. Spends nothing. - fair → const GlassThermalState
-
Pressure the user does not notice: Apple's
fair, Android'sLIGHTandMODERATE. Spends GlassThermalPolicy.fairDeltaE, zero by default. - serious → const GlassThermalState
-
Pressure that impacts the experience: Apple's
serious, Android'sSEVERE. Spends GlassThermalPolicy.seriousDeltaE. - critical → const GlassThermalState
-
Pressure at or past the point the platform starts shutting things down: Apple's
critical, Android'sCRITICAL,EMERGENCYandSHUTDOWN. Spends GlassThermalPolicy.criticalDeltaE.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
GlassThermalState> - A constant List of the values in this enum, in order of their declaration.