Skip to content

Adjust Pure version info display && Adjust Pure version menu functions.#135

Merged
lihuanhuan merged 2 commits intoOneKeyHQ:masterfrom
lihuanhuan:classic1s
Mar 18, 2025
Merged

Adjust Pure version info display && Adjust Pure version menu functions.#135
lihuanhuan merged 2 commits intoOneKeyHQ:masterfrom
lihuanhuan:classic1s

Conversation

@lihuanhuan
Copy link
Contributor

@lihuanhuan lihuanhuan commented Mar 18, 2025

Summary by CodeRabbit

  • New Features
    • Updated device identification: Device model names are now consistently derived from defined constants.
    • Enhanced settings menu: The menu dynamically adapts based on hardware version, displaying a refined set of options for specific devices.

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2025

Walkthrough

The pull request replaces hardcoded device model strings with two new constants and updates menu initialization based on hardware version. In the configuration file, the function now returns either a "pure" or "classic" constant based on a hardware check. In the menu file, a new pure settings menu array is introduced alongside a function that switches menu items depending on the hardware. Additionally, a needed header is included for Bluetooth verification.

Changes

File(s) Change Summary
legacy/firmware/config.c Introduced DEVICE_MODEL_PURE and DEVICE_MODEL_CLASSIC constants. Updated config_get_device_model to return constants based on ble_hw_ver_is_pure(). Modified config_getLabel to use DEVICE_MODEL_CLASSIC directly when needed.
legacy/firmware/menu_list.c Added a static array settings_menu_items_pure with a subset of menu items. Introduced menu_init_settings_menu to select the appropriate menu based on hardware version, and updated menu_default to call this function. Also added #include "ble.h" for hardware version checks.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant config_get_device_model
  participant ble_hw_ver_is_pure
  
  Caller->>config_get_device_model: Request device model
  config_get_device_model->>ble_hw_ver_is_pure: Check hardware version
  ble_hw_ver_is_pure-->>config_get_device_model: Return true/false
  config_get_device_model-->>Caller: Return DEVICE_MODEL_PURE or DEVICE_MODEL_CLASSIC
Loading
sequenceDiagram
  participant Caller
  participant menu_init_settings_menu
  participant ble_hw_ver_is_pure
  
  Caller->>menu_init_settings_menu: Initialize settings menu
  menu_init_settings_menu->>ble_hw_ver_is_pure: Check hardware version
  ble_hw_ver_is_pure-->>menu_init_settings_menu: Return true/false
  menu_init_settings_menu-->>Caller: Set menu items to pure or default array
Loading

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e45984b and d796f0b.

📒 Files selected for processing (2)
  • legacy/firmware/config.c (1 hunks)
  • legacy/firmware/menu_list.c (4 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
legacy/firmware/menu_list.c (6)
legacy/firmware/menu_para.c (8) (8)
  • menu_para_ble_state (38:40)
  • menu_para_ble_index (68:68)
  • menu_para_language (42:42)
  • menu_para_language_index (70:70)
  • menu_para_autolock (48:48)
  • menu_para_autolock_index (89:106)
  • menu_para_input_direction (160:164)
  • menu_para_input_direction_index (166:170)
legacy/firmware/menu_para.h (8) (8)
  • menu_para_ble_state (6:6)
  • menu_para_ble_index (16:16)
  • menu_para_language (7:7)
  • menu_para_language_index (17:17)
  • menu_para_autolock (9:9)
  • menu_para_autolock_index (19:19)
  • menu_para_input_direction (14:14)
  • menu_para_input_direction_index (24:24)
legacy/ble.c (1) (1)
  • ble_hw_ver_is_pure (199:199)
legacy/ble.h (1) (1)
  • ble_hw_ver_is_pure (58:58)
legacy/firmware/menu_core.c (1) (1)
  • menu_init (14:18)
legacy/firmware/menu_core.h (1) (1)
  • menu_init (37:37)
🪛 Cppcheck (2.10-2)
legacy/firmware/config.c

[style] 378-378: The function 'config_get_device_model' is never used.

(unusedFunction)


[style] 383-383: The function 'config_getLabel' is never used.

(unusedFunction)

legacy/firmware/menu_list.c

[style] 699-699: The function 'menu_default' is never used.

(unusedFunction)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Gen check
  • GitHub Check: Style check
  • GitHub Check: Defs check
🔇 Additional comments (7)
legacy/firmware/config.c (3)

375-376: Good addition of clear device model constants.

Using named constants instead of hardcoded strings improves maintainability and consistency.


383-391: Good replacement of hardcoded strings with constants.

Using the DEVICE_MODEL_CLASSIC constant instead of hardcoded strings ensures consistency throughout the codebase.

🧰 Tools
🪛 Cppcheck (2.10-2)

[style] 383-383: The function 'config_getLabel' is never used.

(unusedFunction)


378-380:

Details

✅ Verification successful

Model selection based on hardware detection looks good.

The function now dynamically returns the appropriate device model string based on hardware detection.


🏁 Script executed:

#!/bin/bash
# Verify where this function is called in the codebase
rg -A 1 "config_get_device_model" --type c

Length of output: 652


Device Model Selection Verified

The dynamic device model selection works as intended. The function is called in legacy/firmware/layout2.c and declared in legacy/firmware/config.h, confirming its proper usage.

🧰 Tools
🪛 Cppcheck (2.10-2)

[style] 378-378: The function 'config_get_device_model' is never used.

(unusedFunction)

legacy/firmware/menu_list.c (4)

5-5: Good addition of required header.

Adding ble.h provides access to the Bluetooth hardware verification function.


295-303: Clean implementation of Pure model menu items.

This creates a streamlined menu for Pure models by omitting "Shutdown" and "USB Lock" menu items.


315-323: Good implementation of hardware-dependent menu initialization.

The function correctly sets different menu items based on hardware version detection.


699-702:

Details

✅ Verification successful

Good menu initialization flow.

Added call to menu_init_settings_menu() ensures the right menu items load based on hardware version.


🏁 Script executed:

#!/bin/bash
# Check if menu_default is actually used anywhere
rg -A 1 "menu_default\(" --type c

Length of output: 318


Code changes verified – no further updates needed.

The added call to menu_init_settings_menu() is confirmed to correctly initialize menu items based on hardware version. Our search shows that menu_default() is used in legacy/firmware/trezor.c, and its declaration and definition in menu_list.h and menu_list.c match the intended design.

🧰 Tools
🪛 Cppcheck (2.10-2)

[style] 699-699: The function 'menu_default' is never used.

(unusedFunction)

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Lu1zz Lu1zz self-requested a review March 18, 2025 09:42
@lihuanhuan lihuanhuan merged commit 4b3cbd7 into OneKeyHQ:master Mar 18, 2025
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants