Skip to content

fix: improve core:provider module security and correctness#1487

Open
lihenggui wants to merge 4 commits intomainfrom
fix/core-provider-improvements
Open

fix: improve core:provider module security and correctness#1487
lihenggui wants to merge 4 commits intomainfrom
fix/core-provider-improvements

Conversation

@lihenggui
Copy link
Owner

Summary

  • Fix type/packageName bug: getBlockedComponents() was passing packageName to the type field of ShareCmpInfo.Component — now correctly passes it.type.name
  • Add signature permission: ContentProvider was exported without any permission protection, allowing any app to control component states. Added signature-level permission CONTROL_COMPONENTS
  • Extract constants: Magic strings ("getComponents", "blocks", "cmp_list") extracted to companion object constants for reusability
  • Improve return value: controlComponent() now returns success_count and total_count instead of echoing back the input bundle
  • Parse actual ComponentType: Instead of hardcoding ACTIVITY, now parses the real ComponentType from ShareCmpInfo with graceful fallback
  • Add unit tests: ShareCmpInfoTest (serialization round-trip) and AnalyticsExtensionTest (event logging verification)

Test plan

  • ./gradlew :core:provider:test — all tests pass
  • ./gradlew :core:provider:spotlessCheck — formatting clean
  • Verify ContentProvider behavior on device with apps that call through the provider API

- Fix bug where packageName was passed as component type in ShareCmpInfo
- Add signature-level permission to protect exported ContentProvider
- Extract magic strings to companion object constants
- Return success/failure counts from controlComponent instead of raw input
- Parse actual ComponentType from ShareCmpInfo instead of hardcoding ACTIVITY
- Add unit tests for ShareCmpInfo serialization and AnalyticsExtension
- Revert signature permission since provider needs to be open to external apps
- Use runBlocking(Dispatchers.IO) to avoid blocking the caller's thread
- Replace hardcoded Dispatchers.IO with @dispatcher(IO) from EntryPoint
- Inject Json instance from Hilt graph instead of creating locally
- Extract entryPoint() helper to reduce duplication
- Move null checks before runBlocking to avoid unnecessary coroutine creation
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.

1 participant