Skip to content

Adjust fingerprint sensor sensitivity.#291

Merged
lihuanhuan merged 2 commits intoOneKeyHQ:mainfrom
lihuanhuan:pro_main
Apr 15, 2025
Merged

Adjust fingerprint sensor sensitivity.#291
lihuanhuan merged 2 commits intoOneKeyHQ:mainfrom
lihuanhuan:pro_main

Conversation

@lihuanhuan
Copy link
Copy Markdown
Contributor

@lihuanhuan lihuanhuan commented Apr 15, 2025

Summary by CodeRabbit

  • New Features

    • Added a Fingerprint Test screen for adjusting fingerprint sensor sensitivity and area via sliders. This feature is accessible from the settings menu when not in production mode.
    • Users can now view and modify fingerprint sensor parameters directly from the device interface.
  • Improvements

    • Added a module constant to indicate production mode, enabling conditional display of development features.
  • Bug Fixes

    • Adjusted fingerprint sensor initialization parameter for improved configuration accuracy.

@lihuanhuan lihuanhuan requested a review from a team as a code owner April 15, 2025 05:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2025

Walkthrough

This update introduces new functionality for fingerprint sensor configuration and testing. It adds methods to set and get fingerprint sensitivity and area, exposes these controls in the user interface, and makes them available only in non-production environments. A new constant, PRODUCTION, is defined to control this behavior. Minor adjustments are made to fingerprint sensor initialization and image validation logic. No existing public APIs are changed.

Changes

Files/Paths Change Summary
core/embed/boardloader/main.c Adds a boolean argument (true) to check_image_contents_ADV in try_bootloader_update.
core/embed/extmod/modtrezorio/modtrezorio-fingerprint.h Adds functions to set/get fingerprint sensitivity and area; exposes them in the module dictionary.
core/embed/extmod/modtrezorutils/modtrezorutils.c Adds PRODUCTION boolean constant to the module globals, set by the PRODUCTION macro.
core/embed/fp_sensor_wrapper/fingerprint.c Changes a config parameter value from 10 to 8 in sensor initialization.
core/embed/fp_sensor_wrapper/fpsensor_common.c Adds fpsensor_get_config_param function to read sensor config parameters.
core/embed/fp_sensor_wrapper/fpsensor_driver.h Declares fpsensor_get_config_param function in the header.
core/src/trezor/lvglui/scrs/homescreen.py Adds FingerprintTest screen for sensor testing; adds button in settings if not production.
core/src/trezor/utils.py Imports PRODUCTION from trezorutils.

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ 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 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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
core/src/trezor/lvglui/scrs/homescreen.py (3)

2760-2787: Hardcoded Chinese text for UI labels.

Labels aren't using the internationalization system.

-        self.app_drawer_up.set_text("按压阈值:")
+        self.app_drawer_up.set_text(_(i18n_keys.FINGERPRINT_PRESSURE_THRESHOLD))

2798-2824: Another hardcoded Chinese label.

Similar internationalization issue.

-        self.app_drawer_up_delay.set_text("面积:")
+        self.app_drawer_up_delay.set_text(_(i18n_keys.FINGERPRINT_AREA))

2834-2847: Missing error handling in fingerprint parameter setting.

No try/except blocks to catch potential errors.

     def on_value_changed(self, event_obj):
         from trezorio import fingerprint

         target = event_obj.get_target()
         if target == self.slider:
             value = target.get_value()
             self.sensitivity = value
             self.percent.set_text(f"{value}")
-            fingerprint.set_sensitivity_and_area(value, self.area)
+            try:
+                fingerprint.set_sensitivity_and_area(value, self.area)
+            except Exception as e:
+                print(f"Error setting sensitivity: {e}")
         elif target == self.slider1:
             value = target.get_value()
             self.area = value
             self.percent1.set_text(f"{value}")
-            fingerprint.set_sensitivity_and_area(self.sensitivity, value)
+            try:
+                fingerprint.set_sensitivity_and_area(self.sensitivity, value)
+            except Exception as e:
+                print(f"Error setting area: {e}")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1430826 and 77da615.

⛔ Files ignored due to path filters (1)
  • core/mocks/generated/trezorio/fingerprint.pyi is excluded by !**/generated/**
📒 Files selected for processing (8)
  • core/embed/boardloader/main.c (1 hunks)
  • core/embed/extmod/modtrezorio/modtrezorio-fingerprint.h (4 hunks)
  • core/embed/extmod/modtrezorutils/modtrezorutils.c (1 hunks)
  • core/embed/fp_sensor_wrapper/fingerprint.c (1 hunks)
  • core/embed/fp_sensor_wrapper/fpsensor_common.c (1 hunks)
  • core/embed/fp_sensor_wrapper/fpsensor_driver.h (1 hunks)
  • core/src/trezor/lvglui/scrs/homescreen.py (3 hunks)
  • core/src/trezor/utils.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
core/embed/fp_sensor_wrapper/fingerprint.c (2)
core/embed/fp_sensor_wrapper/fpsensor_common.c (1)
  • fpsensor_set_config_param (197-207)
core/embed/fp_sensor_wrapper/fpsensor_driver.h (1)
  • fpsensor_set_config_param (262-262)
core/embed/fp_sensor_wrapper/fpsensor_common.c (1)
core/embed/fp_sensor_wrapper/fpsensor_driver.h (1)
  • fpsensor_get_config_param (263-263)
core/embed/extmod/modtrezorio/modtrezorio-fingerprint.h (2)
core/embed/fp_sensor_wrapper/fpsensor_common.c (2)
  • fpsensor_set_config_param (197-207)
  • fpsensor_get_config_param (209-213)
core/embed/fp_sensor_wrapper/fpsensor_driver.h (2)
  • fpsensor_set_config_param (262-262)
  • fpsensor_get_config_param (263-263)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Style check
  • GitHub Check: Gen check
🔇 Additional comments (10)
core/embed/fp_sensor_wrapper/fpsensor_driver.h (1)

263-263: New getter function looks good.

The function signature correctly uses pointers for output parameters and matches the parameter naming in the setter function.

core/embed/extmod/modtrezorutils/modtrezorutils.c (1)

635-639: PRODUCTION flag implementation is correct.

This follows the same pattern as other conditional flags (EMULATOR, BITCOIN_ONLY) and properly exposes the build configuration to Python code.

core/src/trezor/utils.py (1)

22-22: Import addition is appropriate.

Adding PRODUCTION to the imports makes the flag accessible throughout the Python codebase.

core/embed/fp_sensor_wrapper/fingerprint.c (1)

76-76:

Details

✅ Verification successful

Default finger area parameter adjustment looks reasonable.

Changing the finger area parameter from 10 to 8 aligns with the new fingerprint sensor configuration capabilities being added.


🏁 Script executed:

#!/bin/bash
# Check if this parameter is used elsewhere in the codebase
rg --type c "fpsensor_set_config_param\([^,]+,[^)]+\)" -A 1 -B 1

Length of output: 1588


Approved: Finger area change verified.
The update from 10 to 8 is consistent across the codebase.

core/embed/boardloader/main.c (1)

267-267:

Details

❓ Verification inconclusive

Verify the added parameter's impact on bootloader validation.

The new boolean parameter true added to check_image_contents_ADV() affects critical bootloader validation code. Ensure this change is thoroughly tested.


🏁 Script executed:

#!/bin/bash
# Check for other usages of check_image_contents_ADV to ensure consistent parameter usage
rg "check_image_contents_ADV" --type c

Length of output: 748


Validate new parameter in bootloader tests.

  • The parameter is consistently used.
  • Confirm bootloader tests fully cover this update.
core/src/trezor/lvglui/scrs/homescreen.py (3)

1555-1559: Conditionally adds Fingerprint Test option to settings menu.

The feature is properly gated behind a production flag.


1597-1598: Properly handles event routing to new test screen.


2731-2748: New class to test fingerprint sensor parameters.

Class structure looks correct and imports the needed fingerprint module.

core/embed/extmod/modtrezorio/modtrezorio-fingerprint.h (2)

21-21: Good include added for driver


335-338: Registration looks good

@lihuanhuan lihuanhuan merged commit 94f2b46 into OneKeyHQ:main Apr 15, 2025
8 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