Share a file whose mime type is not one of the supported ones - #7435
Share a file whose mime type is not one of the supported ones#7435hayaksi1 wants to merge 2 commits into
Conversation
handleIncomingShareIntent only accepted an intent whose resolved mime type started with image/, video/, audio/, application/, file/, text/ or */. An ACTION_SEND carrying EXTRA_STREAM with any other top level type, such as the message/rfc822 that some apps use when attaching a file, fell through to null and the share was dropped before the room picker ever appeared, even though the manifest filter accepts */*. The uris are extracted before that check, so their presence is enough to know the intent carries something to send. Accept the intent when it has uris and keep the mime type list for the case where it does not.
|
Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7435 +/- ##
===========================================
+ Coverage 80.65% 80.69% +0.04%
===========================================
Files 2772 2772
Lines 80803 80804 +1
Branches 11053 11054 +1
===========================================
+ Hits 65168 65203 +35
+ Misses 11370 11336 -34
Partials 4265 4265 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
An intent carrying uris is now accepted before the mime type list is reached, so the image check that every uri share used to exercise is only covered by an intent which has nothing to send. Add one case per listed mime type without a uri. Cover the rest of the handler while it is under test: an intent with no resolvable type, a send multiple without a stream, an action which is neither send nor send multiple, an empty caption, a plain text intent without text, the mime type reported by the content resolver for the uri, and the explicit intent built for the application which will read it, both when the read permission can be granted and when it cannot.
|
Done! Codecov flagged the patch at 50%: accepting the intent as soon as it carries uris short-circuits the mime type list, so While the handler was under test I covered the paths that had none: an intent with no resolvable type, an
|
Content
DefaultShareIntentHandler.handleIncomingShareIntentonly accepted an intent whose resolved mimetype started with
image/,video/,audio/,application/,file/,text/or*/. AnACTION_SENDcarryingEXTRA_STREAMwith any other top level type fell through tonull, andIntentResolverdrops the intent, so nothing happened when sharing into the app.The uris are already extracted before that check, so their presence is enough to know the intent
carries something to send. The mime type list is kept for the case where there are no uris, so no
currently accepted intent is affected.
Motivation and context
Fixes #5623. The reporter shares a
.zipfrom Tasks, which sends it asmessage/rfc822. Themanifest filter for the share target is
*/*, so the app advertises that it accepts this and thensilently discards it.
Tests
./gradlew :features:share:impl:testDebugUnitTestDefaultShareIntentHandlerTestcovers an unlisted mime type with one uri, with several uris,with an
EXTRA_TEXTcaption, plus the image, plain text and nothing-to-share cases. The threeunlisted-mime-type tests fail without the change.
Tested devices