Skip to content

Optimize feature-specific device menu handlers by wrapping in compile-time flags #6939

@coderabbitai

Description

@coderabbitai

Summary

In core/src/apps/homescreen/device_menu.py, feature-specific handler functions such as handle_ToggleTapToWake and handle_ToggleHaptics are always compiled into the firmware regardless of whether the corresponding hardware capability is present. These functions could be wrapped in their respective compile-time flags (e.g. if utils.USE_TOUCH_WAKEUP, if utils.USE_HAPTIC) so they are optimized out on devices that do not support those features.

This would also require corresponding changes in the Rust UI layer so that the respective menu buttons are not listed when the feature is unavailable.

Affected code

  • core/src/apps/homescreen/device_menu.py — handler functions e.g.:
    • handle_ToggleTapToWake (guarded by utils.USE_TOUCH_WAKEUP)
    • handle_ToggleHaptics (guarded by utils.USE_HAPTIC)
    • potentially others with similar patterns
  • Rust UI code for the device menu (button registration) — should not list buttons for unavailable features

Context

Raised during review of PR #6900 (T3W1 wake by touch) at #6900 (comment).

This optimization is out of scope for PR #6900 and should be addressed in a follow-up.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions