Skip to content

Conversation

@avazirna
Copy link
Contributor

@avazirna avazirna commented Dec 20, 2024

Summary

Android 14 brought new restrictions around implicit intents and CC app callouts are based on implicit intents, this PR reviews the exported attribute of activities targeted by predefined app callout options.
Ticket: https://dimagi.atlassian.net/browse/QA-7356

PR Checklist

  • If I think the PR is high risk, "High Risk" label is set
  • I have confidence that this PR will not introduce a regression for the reasons below
  • Do we need to enhance manual QA test coverage ? If yes, "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, "Release Note" label is set and a "Release Note" is specified in PR description.

@avazirna avazirna changed the base branch from master to commcare_2.55 December 20, 2024 21:46
@avazirna avazirna marked this pull request as ready for review December 20, 2024 21:46
@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2024

📝 Walkthrough

Walkthrough

The pull request introduces significant modifications to the Android application's manifest and string resources, focusing on enhancing permission management and activity/receiver configurations. The changes involve creating a new permission group called commcare.permission-group.INTERNAL_ACTION and adding several specific permissions related to NFC data handling, boundary drawing, printing, and app updates.

Multiple activities and receivers, including DrawingBoundaryActivity, NfcWriteActivity, NfcReadActivity, RefreshToLatestBuildReceiver, CommCareLogoutReceiver, and TemplatePrinterActivity, have been updated to change their exported status to true and associate them with specific, signature-level or dangerous-level permissions. Corresponding string resources have been added to provide labels and descriptions for these new permissions, improving the application's permission management and interaction capabilities.

Sequence Diagram

sequenceDiagram
    participant App
    participant AndroidSystem
    participant Activity
    participant Receiver

    App->>AndroidSystem: Request Permission
    AndroidSystem-->>App: Permission Check
    
    alt Permission Granted
        App->>Activity: Launch DrawingBoundaryActivity
        Activity-->>App: Perform Boundary Drawing
        
        App->>Activity: Launch NfcWriteActivity
        Activity-->>App: Write NFC Data
        
        App->>Activity: Launch NfcReadActivity
        Activity-->>App: Read NFC Data
        
        App->>Receiver: Trigger RefreshToLatestBuildReceiver
        Receiver-->>App: Update Application
    else Permission Denied
        AndroidSystem-->>App: Access Restricted
    end
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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

@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: 1

🔭 Outside diff range comments (3)
app/AndroidManifest.xml (3)

Input Validation Present but Documentation Needed for Template Format

Based on the verification results:

  1. Input validation exists in TemplatePrinterTask.java through the validateString() method which checks for well-formed {{ }} and < > pairs.
  2. Security measures are implemented with encryption for file operations in TemplatePrinterUtils.java.
  3. However, there's no user-facing documentation about the expected template format and intent structure.

Required actions:

  • Add documentation in the codebase (e.g., README.md) describing:
    • The expected intent format for org.commcare.dalvik.action.PRINT
    • Template format requirements (e.g., {{ }} for variables, < > for sections)
    • Supported template styles (TEMPLATE_HTML, TEMPLATE_ZPL)

The existing validation and security measures appear sufficient, so rate limiting isn't necessary for this use case.

🔗 Analysis chain

Line range hint 506-512: Document Printer Integration Requirements

Since TemplatePrinterActivity is now exposed, please:

  1. Document the expected intent format
  2. Add input validation for template data
  3. Consider rate limiting if necessary
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for existing documentation
fd README.md | xargs rg -l "TemplatePrinter|Print.*Activity"

# Check for input validation
ast-grep --pattern 'validateTemplate($_)' -l java

Length of output: 114


Script:

#!/bin/bash
# Search for the TemplatePrinterActivity class implementation
ast-grep --pattern 'class TemplatePrinterActivity' -l

# Look for any input handling in printer-related activities
rg -l "getIntent|getExtra.*" --type java | xargs rg "class.*Print.*Activity" -A 5

# Search for any existing validation or security checks in printer activities
rg -l "Print.*Activity" --type java | xargs rg "validate|check|security" -A 3

# Look for any documentation in comments
rg -l "Print.*Activity" --type java | xargs rg "/\*\*|//.*print" -B 1 -A 3

Length of output: 20133


Based on the evidence gathered from the codebase, I can now generate the final response:

Security concerns confirmed for RefreshToLatestBuildReceiver

The exposed broadcast receiver lacks proper security controls:

  • No custom permission requirement in the manifest unlike other receivers (e.g., CommCareLogoutReceiver uses org.commcare.dalvik.permission.COMMCARE_LOGOUT)
  • No source validation or build verification in the implementation
  • Only basic checks for app existence and developer preferences
  • Directly launches update activity with FLAG_ACTIVITY_NEW_TASK without user confirmation

Recommendations:

  • Add a custom permission requirement in AndroidManifest.xml
  • Implement source package validation in onReceive()
  • Add build signature verification before proceeding with the update
  • Consider requiring user confirmation before initiating the update process
🔗 Analysis chain

Line range hint 441-447: Verify Build Refresh Security

The RefreshToLatestBuildReceiver being exposed could potentially be used to force app updates. Ensure:

  1. Proper verification of the source application
  2. Validation of the build being installed
  3. User consent mechanisms

Let's search for the receiver implementation and related security measures to verify how the build refresh functionality is secured.


From the initial results, we can see the receiver implementation, but we need to understand the security controls around it, particularly through developer preferences and permissions.


From the previous results, we see the receiver launches RefreshToLatestBuildActivity and uses developer preferences. Let's check the activity implementation and any security validations in the update process.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for build verification
rg -A 10 "verifyBuild|validateBuild"

# Check for user consent implementation
rg -A 5 "showUpdatePrompt|confirmUpdate"

Length of output: 81


Script:

#!/bin/bash
# Search for the RefreshToLatestBuildReceiver implementation
rg -A 20 "class.*RefreshToLatestBuildReceiver"

# Search for build-related security checks
rg -A 10 "checkPermission|validateSource|validateIntent"

# Look for update-related code
rg -A 10 "updateTo|installBuild|processBuild"

# Search for the action constant usage
rg "org.commcare.dalvik.api.action.RefreshToLatestBuildAction"

Length of output: 10222


Script:

#!/bin/bash
# Let's check for any security-related code in the RefreshToLatestBuildReceiver
rg -A 30 "DeveloperPreferences|MainConfigurablePreferences" app/src/org/commcare/provider/RefreshToLatestBuildReceiver.java

# Check for any permission declarations related to this receiver
rg -B 5 -A 5 "org.commcare.dalvik.permission" app/AndroidManifest.xml

# Look for any security-related preferences
rg -A 5 "DeveloperPreferences.*enable|UPDATE_TARGET" app/src/org/commcare/

Length of output: 13832


Script:

#!/bin/bash
# Check for the RefreshToLatestBuildActivity implementation
rg -A 20 "class.*RefreshToLatestBuildActivity"

# Look for any update validation or security checks in the update process
rg -A 10 "validateUpdate|verifyUpdate|checkUpdate" app/src/org/commcare/

# Check for any developer mode or privilege checks
rg -A 5 "isDeveloperModeEnabled|requiresDeveloperPrivilege" app/src/org/commcare/

Length of output: 12142


Based on the gathered information, I can now provide a final response:

Additional NFC Security Controls Required

The NFC implementation shows basic structure but lacks comprehensive security controls:

  • The base NfcActivity class has encryption key support (NFC_ENCRYPTION_KEY_ARG) but implementation details are not visible
  • Error handling exists but appears minimal (finishWithErrorToast)
  • No clear data validation mechanisms are present in the NFC read/write activities

Required security improvements:

  • Implement robust input validation in NfcWriteActivity before writing NDEF messages
  • Add data sanitization in NfcReadActivity.onNewIntent for incoming NFC data
  • Enhance error handling beyond basic toast messages
  • Document the encryption implementation if present, or add if missing
🔗 Analysis chain

Line range hint 402-408: Verify NFC Security Implementation

The NFC activities being exposed need additional security considerations:

  1. Ensure proper validation of NFC data
  2. Consider encryption for sensitive data
  3. Implement proper error handling for malformed inputs

Also applies to: 411-417


Let me gather more specific information about the NFC implementation.


Let me check one more aspect of the NFC implementation to see how the data is handled.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for NFC security implementations
echo "Checking for NFC data validation..."
rg -A 5 "getNfcAdapter|createNdefMessage"

# Look for encryption usage
rg -l "encrypt.*NFC|decrypt.*NFC"

Length of output: 276


Script:

#!/bin/bash
# Check NFC activity implementations
echo "Checking NFC activity implementations..."
rg -A 10 "class.*NfcWriteActivity|class.*NfcReadActivity"

# Check for data validation and error handling in NFC related files
echo "Checking NFC data validation and error handling..."
fd -e java -e kt --exec rg -l "try.*catch.*NFC|validate.*NFC|isValid|checkNfc" {} \;

# Look for specific NFC security measures
echo "Checking NFC security implementations..."
ast-grep --pattern 'try {
  $$$
  getNfcAdapter()
  $$$
} catch ($$$) {
  $$$
}'

Length of output: 2873


Script:

#!/bin/bash
# Check NFC base class and data handling
echo "Checking NFC base class implementation..."
rg -A 15 "class NfcActivity" 

# Check for NDEF message handling and validation
echo "Checking NDEF message handling..."
rg -A 10 "handleNdefMessage|onNewIntent|createNdefMessage"

# Look for error handling in NFC activities
echo "Checking error handling..."
rg -A 5 "catch.*Exception.*NFC|onNfcError|handleError" app/src/org/commcare/android/nfc/

Length of output: 3907

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4238469 and 76b6695.

📒 Files selected for processing (2)
  • app/AndroidManifest.xml (5 hunks)
  • app/res/layout/progress_dialog_cancel_button.xml (1 hunks)
🔇 Additional comments (2)
app/res/layout/progress_dialog_cancel_button.xml (1)

17-17: Verify the UX impact of hiding the cancel button

Changing the button's visibility to "gone" removes the ability for users to cancel operations. Please ensure this won't negatively impact user experience, especially in scenarios where operations might take longer than expected.

app/AndroidManifest.xml (1)

Line range hint 349-355: Verify Drawing Boundary Integration

For DrawingBoundaryActivity:

  1. Ensure proper validation of boundary data
  2. Implement size limits for boundary data
  3. Add proper error handling for invalid inputs
✅ Verification successful

Let's search for the actual implementation and boundary-related code to better understand the validation mechanisms in place.


Let's examine the actual implementation of DrawingBoundaryActivity to understand the current validation and error handling mechanisms.


Boundary validation and limits are partially implemented

The code review reveals that DrawingBoundaryActivity already implements several validation mechanisms:

  1. Location accuracy validation:

    • Enforces minimum accuracy between 10-50 meters (LOCATION_MIN_MIN_ACCURACY and LOCATION_MIN_MAX_ACCURACY)
    • Validates location accuracy against locationMinAccuracy threshold
  2. Boundary data validation:

    • Validates coordinates parsing with error handling
    • Implements distance and time interval checks for tracking points
    • Includes error handling for invalid boundary coordinates
  3. Size/Area handling:

    • Calculates and validates area using AreaCalculator
    • Provides perimeter calculations
    • Includes proper error handling for geometry calculations

However, there's no explicit maximum size limit for the boundary area, which could be a potential improvement.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for boundary validation
rg -A 5 "validateBoundary|checkBounds"

# Look for size limit implementations
ast-grep --pattern 'getMaxSize|getLimitSize' -l java

Length of output: 95


Script:

#!/bin/bash
# Search for DrawingBoundaryActivity implementation
rg -A 10 "class DrawingBoundaryActivity"

# Search for boundary-related methods in the codebase
rg -A 5 "boundary|Boundary" --type java

# Look for input validation patterns
ast-grep --pattern 'if ($boundary $_) {
  $$$
}'

Length of output: 1759


Script:

#!/bin/bash
# Search for content of DrawingBoundaryActivity.kt
cat app/src/org/commcare/gis/DrawingBoundaryActivity.kt

# Look for any validation or error handling patterns in the GIS module
rg -A 5 "throw|error|exception|validate" app/src/org/commcare/gis/

Length of output: 14625

<activity
android:name="org.commcare.gis.DrawingBoundaryActivity"
android:exported="false">
android:exported="true">
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Based on the gathered information, I can now provide the final response:

Security Review Completed: Additional Protection Required

The exposed components require additional security measures:

  • NFC activities (NfcReadActivity, NfcWriteActivity) handle sensitive data but lack custom permission protection. Add a custom permission requirement similar to CommCareLogoutReceiver.
  • DrawingBoundaryActivity and TemplatePrinterActivity are exposed without permission checks. Implement custom permissions or checkCallingOrSelfPermission().
  • RefreshToLatestBuildReceiver lacks security validation before processing broadcasts. Add signature/system permission protection.

Required changes:

  1. Add custom permission declarations in AndroidManifest.xml for each component
  2. Add android:permission attribute to each component's manifest entry
  3. Implement runtime permission validation in RefreshToLatestBuildReceiver's onReceive()
🔗 Analysis chain

Security Review Required: Components exposed to external applications

Multiple components are being made accessible to external applications. This change requires careful security review:

  1. Ensure each component has proper permission checks
  2. Validate input from external applications
  3. Consider adding custom permissions if needed
  4. Document the security implications for future maintenance

Also applies to: 402-402, 411-411, 441-441, 506-506


Let me gather more information about security checks in these components.


Let me gather one final piece of information about the base NFC activity class since both NFC activities inherit from it.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for permission checks in these components
echo "Checking DrawingBoundaryActivity for permission checks..."
ast-grep --pattern 'checkCallingOrSelfPermission($_)' -l java

echo "Checking for input validation in NFC activities..."
ast-grep --pattern 'getIntent()' -l java

echo "Checking RefreshToLatestBuildReceiver for security checks..."
rg -A 10 "class RefreshToLatestBuildReceiver"

Length of output: 15095


Script:

#!/bin/bash
# Check for permission declarations in manifest
echo "Checking permission declarations in AndroidManifest.xml..."
rg -A 2 "permission" app/AndroidManifest.xml

# Check for security checks in the activities
echo "Checking NfcWriteActivity for security measures..."
rg -A 10 "class NfcWriteActivity" app/src/org/commcare/android/nfc/

echo "Checking NfcReadActivity for security measures..."
rg -A 10 "class NfcReadActivity" app/src/org/commcare/android/nfc/

echo "Checking DrawingBoundaryActivity for security measures..."
rg -A 10 "class DrawingBoundaryActivity"

echo "Checking TemplatePrinterActivity for security measures..."
rg -A 10 "class TemplatePrinterActivity"

# Check for intent filters
echo "Checking intent filters for these components..."
rg -A 5 "<intent-filter" app/AndroidManifest.xml

Length of output: 15036


Script:

#!/bin/bash
# Check NfcActivity base class for security measures
echo "Checking NfcActivity base class security..."
rg -A 20 "class NfcActivity" app/src/org/commcare/android/nfc/

# Check for custom permissions usage
echo "Checking for custom permission usage..."
rg -B 2 -A 2 "android:permission=" app/AndroidManifest.xml

Length of output: 2656

@avazirna avazirna changed the title Update components exported attribute Update component exported attribute Dec 20, 2024
@avazirna avazirna requested a review from shubham1g5 December 24, 2024 07:33
@shubham1g5
Copy link
Contributor

@avazirna can you link the Android docs reg. restriction you are talking about in PR description.

@avazirna
Copy link
Contributor Author

@avazirna can you link the Android docs reg. restriction you are talking about in PR description.

done @shubham1g5, we might need to consider having an option to allow app callout questions to use explicit intents.

@shubham1g5
Copy link
Contributor

@avazirna I think we need to implement a permission at the very least for these exported components as we don't really want to allow other apps to have access to these.

@avazirna
Copy link
Contributor Author

avazirna commented Jan 8, 2025

@coderabbitai review

Copy link

@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: 0

🔭 Outside diff range comments (1)
app/res/values/strings.xml (1)

Line range hint 390-391: Consider adding runtime permission checks.

While the manifest-level permissions are properly set up, consider adding runtime permission validation in these components for an additional layer of security. This is particularly important for components that handle sensitive operations like NFC data and system updates.

Example for NFC activities:

+ // Add to NfcReadActivity/NfcWriteActivity
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+     super.onCreate(savedInstanceState);
+     if (checkCallingOrSelfPermission(getPackageName() + ".permission.READ_NFC_DATA") 
+         != PackageManager.PERMISSION_GRANTED) {
+         throw new SecurityException("Caller must have permission " 
+             + getPackageName() + ".permission.READ_NFC_DATA");
+     }
+     // ... rest of the onCreate
+ }

Also applies to: 444-446, 454-456, 475-476, 485-486, 551-552

🧹 Nitpick comments (1)
app/AndroidManifest.xml (1)

95-129: Consider using android:protectionLevel="signature|privileged" for internal permissions.

The new permissions are well-structured, but for internal actions that are signature-protected, consider using signature|privileged to also allow system apps with the appropriate permission to access these components.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 76b6695 and 6db9d6f.

📒 Files selected for processing (2)
  • app/AndroidManifest.xml (7 hunks)
  • app/res/values/strings.xml (1 hunks)
🔇 Additional comments (3)
app/AndroidManifest.xml (2)

74-77: LGTM: Permission group for internal actions.

The new permission group commcare.permission-group.INTERNAL_ACTION is well-defined and appropriately labeled.


390-391: Verify intent-filter actions match permission protection.

The exported components are properly protected with custom permissions, which is good. However, let's verify that the intent-filter actions are consistent with the permission protection:

  1. DrawingBoundaryActivity: action="org.commcare.dalvik.action.DrawBoundary"
  2. NfcWriteActivity: action="org.commcare.nfc.WRITE"
  3. NfcReadActivity: action="org.commcare.nfc.READ"
  4. CommCareLogoutReceiver: action="org.commcare.dalvik.api.action.CommCareLogoutAction"
  5. RefreshToLatestBuildReceiver: action="org.commcare.dalvik.api.action.RefreshToLatestBuildAction"
  6. TemplatePrinterActivity: action="org.commcare.dalvik.action.PRINT"

Also applies to: 444-446, 454-456, 475-476, 485-486, 551-552

✅ Verification successful

Intent actions are properly protected and consistently used

The verification confirms that all intent actions are:

  • Properly declared in AndroidManifest.xml with corresponding permission protection
  • Used consistently in expected locations (tests, form definitions, implementation)
  • No unprotected or unexpected usages found in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that these actions aren't used elsewhere in the codebase
echo "Checking for usage of these actions in the codebase..."
rg "org\.commcare\.(dalvik\.action\.(DrawBoundary|PRINT)|nfc\.(WRITE|READ)|dalvik\.api\.action\.(CommCareLogoutAction|RefreshToLatestBuildAction))"

Length of output: 1965

app/res/values/strings.xml (1)

156-164: LGTM: Permission strings are clear and well-defined.

The new permission-related strings are properly defined and provide clear descriptions of their purpose. The strings correspond correctly to the permissions defined in the AndroidManifest.xml.

</permission>

<permission
android:name="${applicationId}.permission.READ_NFC_DATA"
Copy link
Contributor

Choose a reason for hiding this comment

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

@avazirna Here the permission READ_NFC_DATA doesn't make sense since the purpose of this permission is not to give an external app permission to read nfc data (we don't have that functionality for external apps) but merely to protect the app's exposed components that should not ideally be exposed in the first place. As such we should have one single permission like PROTECT_FALSELY_EXPOSED_COMPONENTS and apply it to all such components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense having an umbrella permission for these, so this will be applied to READ_NFC_DATA, WRITE_NFC_DATA, DRAW_BOUNDARY_AREA and PRINT

@avazirna avazirna requested a review from shubham1g5 January 9, 2025 10:20
@avazirna avazirna force-pushed the review-activities-export-attribute branch from 1673e7a to 6226c5e Compare January 9, 2025 10:48
@avazirna
Copy link
Contributor Author

avazirna commented Jan 9, 2025

Applied the same permission to DataChangeLogsActivity

<receiver
android:name="org.commcare.provider.RefreshToLatestBuildReceiver"
android:exported="false">
android:permission="org.commcare.dalvik.permission.UPDATE_TO_LATEST_BUILD"
Copy link
Contributor

@shubham1g5 shubham1g5 Jan 9, 2025

Choose a reason for hiding this comment

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

RefreshToLatestBuildReceiver is a internal dev only tool and introducing a permission here will break the underlying scripts. Given it was marked as exported=false earlier, is there a good reason to change it to true now ? FWIW I think the underlying scripts would already be broken because it was marked as un-exported and as such I think the best way forward here is to just delete the RefreshToLatestBuildReceiver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might not have enough context here, but my understanding is that this receiver is for external use, its documentation also states that it should respond to requests via adb, in that case it needs to be exported.

Trigger from command line with:

  • adb shell am broadcast -a org.commcare.dalvik.api.action.RefreshToLatestBuildAction

Considering that this is for dev use only, what's the usage? To make sure the feature is working as expected?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a adb command to update the app to latest without interacting with UI and was meant to increase dev efficiency - https://github.com/dimagi/commcare-android/blob/master/scripts/ccc#L63

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleting this receiver then, thanks

android:label="@string/title_data_change_logs_activity"
android:exported="false"
android:name="org.commcare.activities.DataChangeLogsActivity">
android:exported="true"
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to export this activity ? (I don't recall using it in callouts)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not, but it's supposed to respond to ACTION_VIEW actions, so I think it needs to be exported. I didn't test this though, let me do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Btw from the Spec, I don't see the reason for this activity to respond o ACTION_VIEW actions, can you provide some context here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's again because of dev tooling - https://github.com/dimagi/commcare-android/blob/master/scripts/ccc#L217 which I am fine with killing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shubham1g5 I've reverted the exported status of these components, I will kill them or move to a different manifest file in a different PR.

@avazirna avazirna force-pushed the review-activities-export-attribute branch from 6226c5e to d0d1c6b Compare January 10, 2025 00:29
@avazirna avazirna requested a review from shubham1g5 January 10, 2025 00:33
Comment on lines 156 to 159
<string name="permission_protect_falsely_exposed_components_label">Protect falsely exposed components</string>
<string name="permission_protect_falsely_exposed_components_description">Due to implicit intent constrains, certain intent-aware components are now exposed, this permission is to prevent abusive use by external apps</string>

<string name="permission_group_internal_action_label">Permission group for CommCare Internal Actions</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

can we try to simply these strings and make them user-friendly (remove any tech jargain like intents/callouts) as these may be presented to the users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done abe2a90

@avazirna avazirna merged commit 3a6167b into commcare_2.55 Jan 10, 2025
1 of 2 checks passed
@avazirna avazirna deleted the review-activities-export-attribute branch January 10, 2025 08:04
@coderabbitai coderabbitai bot mentioned this pull request Jan 15, 2025
@coderabbitai coderabbitai bot mentioned this pull request Feb 25, 2025
@coderabbitai coderabbitai bot mentioned this pull request Mar 12, 2025
4 tasks
@coderabbitai coderabbitai bot mentioned this pull request May 16, 2025
4 tasks
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