Repository navigation
feat(apktool): share one APK resource decode across selected locale tables (#4777) - #4804
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no new blocking issue remains. SummaryAdds
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Validated locale request] --> B[Snapshot APK and decode once]
B --> C[Count files and discover locales]
C --> D{Include strings?}
D -->|No| E[Return empty strings and tables]
D -->|Yes| F[Normalize requested locale directory]
F --> G{Table cached?}
G -->|No| H{Read and entry budget remain?}
H -->|No| I[Return skipped table]
H -->|Yes| J[Read bounded XML and cache parsed result]
G -->|Yes| K[Build table within output limit]
J --> K
K --> L[Return tables and primary strings]
Reviews (6) · Last reviewed commit: "feat(apktool): share one APK resource de..." · Reviewed by Greptile |
b70acdc to
f6ec9d4
Compare
Return tagged string-document parsing failures instead of fabricating one unparsed entry. Preserve XML failure reasons and publish unknown counts with partial coverage; count only examined unsupported entries in validated documents. Migrate every consumer, remove the superseded throwing XML wrapper, and retain completed failure Evidence through cancellation and failed cleanup. Adapt the document-versus-entry distinction from PR #4804 using the shared Result and XML owner. Multi-table projection and its aggregate bounds remain under review in #4777. Validation before incoming main rebase: 229 focused tests in 15 files, four baseline controls fail, static/docs checks and two source reviews. Twelve tiny actual MCP workflows and four CLI controls; authored launchers only, no real Apktool/JVM/Windows qualification. Fixes #4820 Co-authored-by: Abhay Tiwari <[email protected]>
a8cfce2 to
6be3356
Compare
6be3356 to
e19ec7c
Compare
…ables (morluto#4777) Project default and multiple selected localized string tables from one immutable decode pass. Remove the need for repeated APK snapshotting, digesting, version probing, apktool d invocations, and workspace enumeration. - Contract: add optional locales array to decode_android_resources input schema (bounded to 20 locales) and structured string_tables to output schema with per-table status, strings, total_count, unparsed_count, and coverage. Preserve legacy strings and locale fields for complete backward compatibility. - Bounds: enforce 32 MiB aggregate XML read cap and 10,000 aggregate string entries cap across batched projections. Handle missing, oversized, and malformed tables per-table without failing or losing completed tables. - Lifecycle: maintain strict descriptor cleanup and provider-owned workspace removal in finally, preserving typed cancellation and failure details. - Adapters: add --locales repeatable option to CLI and update MCP contract. Validation: 10 service tests, 3 CLI boundary tests, and MCP boundary schema tests pass. Fast typecheck/lint and turbo docs:check:built pass. Fixes morluto#4777
e19ec7c to
701be5f
Compare
|
I appreciate how this lets one APK decode answer several locale requests, with per-table status and aggregate limits still visible, @abhay-2108. Keeping the old single-locale response intact makes the new workflow easier to adopt. Welcome to REA. |
Summary
Project default and multiple selected localized string tables from one immutable decode pass, eliminating redundant APK snapshotting, SHA-256 digesting, launcher version probing, repeated
apktool d --no-srcinvocations, and workspace filesystem enumerations for multi-locale inspection.Fixes #4777
Problem and expected behavior
Previously, inspecting multiple string tables (such as default strings and one or more translated locales like
deorpt-BR) required separate serial calls todecode_android_resources. Each call created an owned temporary directory, copied and hashed the APK, executed a fullapktool d --no-srcdecode, traversed the decoded workspace to count files and discover available locales, projected a single string table, and removed the workspace. On NewPipe (0.29.1), each decode required ~7.5–11.4s of CPU time and separate workspace lifecycle overhead.Expected behavior: A caller can specify an array of desired locales via
locales(or repeatable--locales <tag>on the CLI) in addition to or instead of the primarylocale. REA runs one single decode pass, projects each requested table into a structuredstring_tablesarray with typed availability status (present,missing,oversized,malformed,skipped), coverage, and entry counts (nullwhen skipped or unmeasured), while continuing to provide top-levelstringsandlocalefor backwards compatibility.Change and scope
localesinput array todecode_android_resourcesschema (bounded to 20 locales).string_tables: z.array(stringTableSchema).optional()containing per-table facts, typed availability status (present,missing,oversized,malformed,skipped), entry counts (nullwhen skipped, oversized, or unmeasured), and coverage.ApktoolProviderto iterate through all requested locales from the single decoded workspace.AGGREGATE_STRINGS_XML_MAX_BYTES) and 10,000 aggregate string entries budget (MAX_AGGREGATE_STRINGS). Each read receivesMath.min(STRINGS_XML_MAX_BYTES, remainingXmlBudget)and tracksbytesReadeven on parse failures.pt-BRandpt-rBRboth resolve tovalues-pt-rBR) so aliases reuse already-projected tables without extra disk I/O or charging the budget twice.include_strings: falsequeries (all string tables are skipped wheninclude_strings: false).malformed) from valid XML containing unsupported/styled markup (presentwithcoverage: "partial").skippedstatus for tables skipped after aggregate budget exhaustion, reporting unknown (null) entry counts rather than invented zeros.finally, with failed cleanup tracked for retry on provider close.Contract and boundary impact
src/domain/apktool/apktoolResourceAnalysis.tsand provider projection insrc/apktool/ApktoolProvider.ts.--localesoption torea decode-android-resources; updated MCP contract description and examples insrc/contracts/apktool/apktoolToolContracts.ts. Output schema adds optionalstring_tableswhile retaining existingstringsandlocalefields.mkdtempand cleaned up infinally. Failed cleanup tracked in#pendingCommandOwnersfor retry onprovider.close().docs/public/product-catalog.json), package, or installation impact: Regenerated and validated withnpx turbo run docs:check:built. No uncommitted build artifacts.Expected effects:
Evidence and regression coverage
src/apktool/ApktoolDecodeOutput.test.ts: Added tests verifyingmalformedboolean distinguishing syntax errors from styled/unsupported markup (24 tests pass).src/application/apktool/ApktoolResourceAnalysisService.test.ts: Added tests for invalid locale arrays, bounding caps (> 20 locales), and batched locale forwarding to provider (10 tests pass).tests/boundary/cli/apktoolLocaleOption.test.ts: Added CLI tests for repeatable--localesflags and--no-strings --locale deoptions forwarding (4 tests pass).tests/boundary/mcp/apktoolMcp.test.ts: Updated MCP boundary tests to verify advertised JSON schemas withstring_tablesand multi-locale execution (1 test passes).src/apktool/ApktoolProvider.test.ts: Added tests verifying: (1) invocation counter asserts exactly 1 decode occurs, (2) alias deduplication reuses table forpt-BRandpt-rBR, (3)include_strings: falsesuppresses all string tables, (4) styled markup producespresenttable with partial coverage and unparsed count.scripts/verify-apktool.mjs: Updated live verifier check to assert exact requested locale identities andstatus: "present".rea decode-android-resources <app.apk> --locales de --locales pt-BR --jsonoutputsstring_tableswith all requested tables populated from one decode pass.For evidence-bearing changes:
Validation performed
npm run check:fast— 2 successful, 2 total (typecheck and lint passed).npx turbo run docs:check:built— 6 successful, 6 total (product catalog, skill metadata, package metadata, completion ledger, and third-party license inventory).npx vitest run src/apktool/ApktoolDecodeOutput.test.ts src/application/apktool/ApktoolResourceAnalysisService.test.ts tests/boundary/cli/apktoolLocaleOption.test.ts tests/boundary/mcp/apktoolMcp.test.ts— 39 passed across 4 test suites.Compatibility, safety, and release
stringsandlocalefields without modification.generate-package-metadata.mjs --check.0o400) before decoding preserved. Workspace is created in system temporary directory with strict cleanup.Author readiness
Human owner: @abhay-2108
Before merge
type(scope): outcome.