Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit MIME type declaration on querying available packages for opening files #3020

Open
wants to merge 3 commits into
base: release/3.7
Choose a base branch
from

Conversation

TranceLove
Copy link
Collaborator

@TranceLove TranceLove commented Nov 14, 2021

Description

As noted by Android Studio on the use of android.permission.QUERY_ALL_PACKAGES permission, use <queries> with explicitly defined action and MIME type instead. This looks safer (minimal permission principle), and also reduces possibility of unrelated apps from popping up in the list of available apps.

Additionally:

  • as noted in https://stackoverflow.com/a/55071463, change SQLITE MIME type to application/vnd.sqlite3
  • added explicit android:exported attribute to <activity>s in AndroidManifest.xml where the activity is not necessary to export
  • added back rar to FileUtils.COMPRESSED_FILE_EXTENSIONS to fix problem that opening a RAR file using Amaze does not load up the CompressedExplorerFragment

Manual tests

  • Done

Device: Pixel 2 emulator
OS: Android 11
Device: Fairphone 3
OS: LineageOS 16.0 (9.0)
Device: Pixel 2 emulator
OS: Android 6.0

  • Tapping files (expect those MIME type not explicitly declared in the manifest) should never be affected - user should be given a list of available apps on device for the specified file
  • Tapping open a RAR file from Amaze should open CompressedExplorerFragment for viewing contents inside the archive

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

@TranceLove TranceLove added Issue-Feature A feature request or improvement. Issue-Task (low) This isn't a bug, but should be dealt with. Area-Navigation Related to navigation labels Nov 14, 2021
@TranceLove TranceLove marked this pull request as draft November 14, 2021 10:44
@TranceLove TranceLove added the Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. label Nov 14, 2021
@TranceLove
Copy link
Collaborator Author

Pending #3022 before continuing. Will add queries for commonly used document types.

…ning files

As noted by Android Studio on the use of android.permission.QUERY_ALL_PACKAGES permission, use <queries> with explicit action and MIME type instead. This also reduces possibility of unrelated apps from popping up in the list of available apps.

Additionally, as noted in https://stackoverflow.com/a/55071463, change SQLITE MIME type to application/vnd.sqlite3.
@TranceLove TranceLove force-pushed the feature/better-open-file-query-declaration branch from e3e2e39 to c2e9eae Compare November 16, 2021 14:53
- AndroidManifest.xml, add android:exported attribute to <activity> as recommended by Android Studio
- Add back missing rar extension to FileUtils.COMPRESSED_FILE_EXTENSIONS which prevented RAR files be opened by Amaze for viewing
@TranceLove TranceLove force-pushed the feature/better-open-file-query-declaration branch from c2e9eae to 68a23d0 Compare November 16, 2021 14:56
@TranceLove TranceLove marked this pull request as ready for review November 16, 2021 14:57
@VishalNehra
Copy link
Member

I don't prefer this. We have an inbuilt file opener. we need to query any and all mime types.

Use one single wildcard MIME type for querying
@TranceLove
Copy link
Collaborator Author

I don't prefer this. We have an inbuilt file opener. we need to query any and all mime types.

Then use a wildcard. It is still the preferred way to declare MIME type query to open files as noted by Android Studio hints.

@VishalNehra
Copy link
Member

@TranceLove It's preferable in other usecases, for us mime type is basically all, so defining a subset is gonna hurt us only. I think we can ignore this warning by ide.
One usecase that comes to mind is, if a user choose 'other' in 'open with' option while opening file... He should see all possible intent filters in system, but defining a query here will let him see just a subset.

@VishnuSanal VishnuSanal added the Issue-Discussion Deprecated: use discussions tab. label Mar 6, 2022
@VishalNehra
Copy link
Member

From play store:

Important dates for QUERY_ALL_PACKAGES permission declaration
If your app does not require use of the QUERY_ALL_PACKAGES permission, you must remove the permission from your app manifest. For apps that require this permission, you can now submit a declaration form in Play Console.

You'll need to provide:

A description of the core feature in your app that requires this permission
A short video showing the core feature in your app that requires this permission
To prepare for the questions you'll be required to answer, review this [Help Center](https://support.google.com/googleplay/android-developer/answer/9214102) article.

Starting July 12, you will not be able to submit new apps or app updates if the declaration is missing. You have until July 12 to submit the declaration, or remove the permission from your app manifest. Apps that fail to meet the [policy requirements](https://support.google.com/googleplay/android-developer/answer/9888170#package-vis) or do not submit the declaration form may be removed from Google Play starting July 12.

I'll be declaring because as per the policy, file managers should be allowed to query all packages, but just in case it doesn't go through we should have this PR as a backup. Thanks for working on this @TranceLove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-Navigation Related to navigation Issue-Discussion Deprecated: use discussions tab. Issue-Feature A feature request or improvement. Issue-Task (low) This isn't a bug, but should be dealt with.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants