feat: resolve resource references in component labels#1369
Merged
Conversation
Enhance ManifestParser to resolve @string/xxx and @0x7fxxxxxx resource references to actual localized strings using Android Resources API. Changes: - Create Resources instance from APK's AssetManager - Add resolveLabel() method to parse resource references - Add resolveComponentName() helper to extract simple names - Update all component parsers (Activity, Service, Receiver, Provider) - Fall back to component simple name when resolution fails - Support localization based on device configuration The Resources constructor is deprecated but remains the only viable approach for reading resources from uninstalled APK files. Change-Id: I4920ac4b57898eb17080d756f286c451fa19eea0
Add test cases to verify that component labels are properly resolved: - Ensure resource references are resolved, not raw hex IDs - Verify all component types (Activity/Service/Receiver/Provider) - Check labels are not empty when present - Validate fallback behavior for failed resolution Change-Id: Ib75521ceb98d37396d37eb0a50109b60be25c26f
…-resources Change-Id: Ic60415b85ac908d1b81844556604ccba8c403288
Remove PackageManager-based label resolution and use labels already parsed by ManifestParser from APK resources. This eliminates redundant pm calls and leverages the resource resolution implemented in ManifestParser. Changes: - Remove resolveActivityLabel() method that used pm.getActivityInfo() - Use manifestActivity.label directly for displayName - Remove unused ComponentName import - Fallback to simpleName when label is null Change-Id: I07eebc6a843cb94463d866b00b2190df1c38ef53
Android stores resource IDs in binary XML as decimal numbers (e.g., @2132018028) rather than hexadecimal. Update resolveLabel() to parse decimal resource IDs in addition to hex and symbolic references. Supported formats: - Decimal: @2132018028 - Hexadecimal: @0x7f0c001c - Symbolic: @string/app_name - Plain text: "My Activity" Also update tests to verify all resource reference formats are properly resolved (not left as raw @ references). Change-Id: Ic62c965753c45238af319cdd3e49289b1fdf6dde
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance ManifestParser to resolve @string/xxx and @0x7fxxxxxx resource references to actual localized strings using Android Resources API.
Changes:
The Resources constructor is deprecated but remains the only viable approach for reading resources from uninstalled APK files.