Skip to content

Conversation

@OrangeAndGreen
Copy link
Contributor

https://dimagi.atlassian.net/browse/CCCT-840

cross-request: dimagi/commcare-core#1455

Technical Summary

This PR fixes a crash experienced on some Android versions when the user attempts to deactivate their account. The issue is described more here, and the fix is to simply check the Android version when registering a receiver and pass in the RECEIVER_NOT_EXPORTED flag if necessary.

Feature Flag

ConnectID

Safety Assurance

Safety story

I found other places in existing code that perform the check on Tiramisu and call the registerReceiver function differently depending.

Automated test coverage

No automated tests for ConnectID yet.

QA Plan

Attempt to deactivate a ConnectID account (already covered in the test plan), using a device running Android Tiramisu or newer.

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

… is >= Tiramisu.

Removed auto SMS code retrieval from deactivation OTP page (user must type it manually).
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2025

📝 Walkthrough

Walkthrough

This pull request introduces two sets of changes within the CommCare app. In the ConnectIdPhoneVerificationFragment, the condition for registering the SMS broadcast receiver has been updated. Instead of checking for Android O and above, the fragment now applies the RECEIVER_NOT_EXPORTED flag only when the device runs Android Tiramisu (API level 33) or later. In contrast, devices with earlier Android versions have the receiver registered without this flag. In the ConnectIdUserDeactivateOTPVerificationFragment, the SMS handling functionality has been entirely removed. This includes the removal of related imports, broadcast receiver registration, SMS user consent initiation, OTP extraction logic, and corresponding lifecycle method calls. There are no changes to the declarations of exported or public entities.

Sequence Diagram(s)

sequenceDiagram
    participant F as ConnectIdPhoneVerificationFragment
    participant A as Android System
    F->>A: Check Android API version during registerBrodcastReciever()
    alt API >= TIRAMISU (33)
        F->>A: Register smsBroadcastReceiver with RECEIVER_NOT_EXPORTED flag
    else API < TIRAMISU
        F->>A: Register smsBroadcastReceiver without additional flag
    end
Loading

Possibly related PRs

  • Android 14 update #2894: Adjusted broadcast receiver registration in other components based on Android version, sharing similar code-level modifications.

Suggested labels

Release Note, QA Note, High Risk

Suggested reviewers

  • shubham1g5
  • pm-dimagi

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 12a6338 and 563b676.

📒 Files selected for processing (2)
  • app/src/org/commcare/fragments/connectId/ConnectIdPhoneVerificationFragmnet.java (1 hunks)
  • app/src/org/commcare/fragments/connectId/ConnectIdUserDeactivateOTPVerificationFragment.java (0 hunks)
💤 Files with no reviewable changes (1)
  • app/src/org/commcare/fragments/connectId/ConnectIdUserDeactivateOTPVerificationFragment.java
🔇 Additional comments (1)
app/src/org/commcare/fragments/connectId/ConnectIdPhoneVerificationFragmnet.java (1)

244-248: Good change to ensure compatibility with Android Tiramisu security requirements

The conditional check for Android Tiramisu (API level 33) properly addresses the crash issue by applying the RECEIVER_NOT_EXPORTED flag only on newer Android versions. This aligns with Android's security model changes in Tiramisu, which requires explicit declaration of whether broadcast receivers should be available to other applications.

For reference, this is part of Android's privacy and security improvements that prevent unintended exposure of components to other applications.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.

@OrangeAndGreen OrangeAndGreen merged commit 489b81a into connect_qa Mar 13, 2025
2 checks passed
@OrangeAndGreen OrangeAndGreen deleted the dv/deactivation_crash branch March 13, 2025 18:21
@coderabbitai coderabbitai bot mentioned this pull request Apr 18, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants