Extract native incoming-Intent parser from AndroidDocumentsPlugin#92
Merged
Conversation
Moves ACTION_VIEW/ACTION_SEND parsing and classification into an IncomingIntentParser that returns structured results: open-with document URI, shared Markdown stream URI, validated shared text with its raw title, or a rejection with the stable code/message pair. The parser owns the category allow-lists, scheme checks, EXTRA_STREAM/EXTRA_TEXT extraction with their malformed-extra handling, the shared-text MIME gate and byte validation, the SEND_MULTIPLE rejection, and the Markdown MIME/extension candidate rules shared with the document read paths. Parse-stage rejection logs move with the reasoning, preserving the exact log lines. The plugin keeps everything stateful and platform-facing: the duplicate-intent guard, ContentResolver document reads, URI permission persistence, JSObject/event emission (including the shared-text document payload, whose display name is still normalized at emission), and the Capacitor listeners. Event names, payload fields, error codes, and messages are unchanged. Adds IncomingIntentParserTest (5 JUnit tests) for the pure classification rules; Intent-level behavior was smoke-verified on the emulator with real SEND text (accepted, titled from EXTRA_SUBJECT), file-scheme VIEW (rejected with the preserved scheme log), and SEND_MULTIPLE (rejected) intents.
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.
Summary
Seventh PR of the semantic-decomposition series: moves ACTION_VIEW / ACTION_SEND parsing and classification out of
AndroidDocumentsPlugin.javainto a focusedIncomingIntentParserthat returns structured results. Behavior-preserving — event names, payload fields, error codes, messages, and log lines are unchanged.Boundary
IncomingIntentParser.parse(Intent)returns one of six structured results: ignored, open-with document (URI), shared Markdown stream (URI), shared text (validated markdown + normalized MIME + raw title), or an open-with/share rejection carrying the stable code/message pair. The parser owns:SEND_MULTIPLErejection,content://scheme checks,EXTRA_STREAM/EXTRA_TEXTextraction with their malformed-extra handling (incl. the Tiramisu parcelable API split),MarkdownCodec, and theEXTRA_TITLE→EXTRA_SUBJECT→fallback title resolution (returned raw; the plugin still normalizes to a.mdname at emission, keeping naming with TODO 8's territory),isMarkdownCandidate& co.) that the document read paths share,Per the TODO, the parser owns no UI or persistence. The plugin keeps the duplicate-intent guard (instance state),
ContentResolverdocument reads, URI-permission persistence, all JSObject/event building and Capacitor listener notification — its incoming path is now a dispatch switch over the parser result, with the three emitters (emitOpenWithDocument,emitSharedStream,emitSharedText) carrying the previously duplicated read/emit bodies unchanged.Testing
IncomingIntentParserTest(5 JUnit tests) locks the pure classification rules: Markdown extensions case-insensitively, exact Markdown MIME set, the plain-text-by-MIME vs extension-wins candidate rule, the any-text/*-or-empty shared-text gate, and MIME normalization. Native suite now 13/13 viagradlew testDebugUnitTest(CI-gated since Extract native Markdown codec from AndroidDocumentsPlugin #91).SEND text/plainaccepted end-to-end (event emitted, display nameSmokeTitle.mdresolved fromEXTRA_SUBJECT),VIEW file://rejected through the full parser with the preservedunsupported scheme: filelog, andSEND_MULTIPLErejected. (A shell-issuedVIEW content://is blocked by the OS before reaching any app — adb limitation; the open-with happy path is a verbatim move whose preceding checks the rejection smoke exercised.)compileDebugJavaWithJavac+assembleDebuggreen; Java-only diff, TS contract untouched.