Handle runtime permissions in K-9
See original GitHub issueExpected behaviour
K-9 should:
- Clearly denote why it uses each permission
- Handle loss of permissions without crashing
- Handle loss of non-critical permissions without loss of core functionality
- Properly display information about each of the permissions it exposes.
Actual behavior
- If you remove the Contacts permission the application crashes.
01-21 19:52:43.872 7635-8133/com.fsck.k9.debug E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: com.fsck.k9.debug, PID: 7635
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{9aee797 7635:com.fsck.k9.debug/u0a119} (pid=7635, uid=10119) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.os.Parcel.readException(Parcel.java:1684)
at android.os.Parcel.readException(Parcel.java:1637)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4199)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5476)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2239)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1517)
at android.content.ContentResolver.query(ContentResolver.java:516)
at android.content.ContentResolver.query(ContentResolver.java:474)
at com.fsck.k9.activity.compose.RecipientLoader.fillContactDataFromQuery(RecipientLoader.java:188)
at com.fsck.k9.activity.compose.RecipientLoader.loadInBackground(RecipientLoader.java:110)
If you try and save an attachment with no Storage permission
01-21 20:32:12.880 12365-12600/com.fsck.k9.debug E/k9: Error saving attachment
java.io.FileNotFoundException: /storage/emulated/0/download.jpeg (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
at com.fsck.k9.ui.messageview.AttachmentController.writeAttachmentToStorage(AttachmentController.java:151)
at com.fsck.k9.ui.messageview.AttachmentController.saveAttachmentWithUniqueFileName(AttachmentController.java:141)
at com.fsck.k9.ui.messageview.AttachmentController.access$900(AttachmentController.java:42)
at com.fsck.k9.ui.messageview.AttachmentController$SaveAttachmentAsyncTask.doInBackground(AttachmentController.java:348)
at com.fsck.k9.ui.messageview.AttachmentController$SaveAttachmentAsyncTask.doInBackground(AttachmentController.java:337)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
- If you view the ‘Additional Permissions’ screen:
Steps to reproduce
- (Possibly) Run a version of the app targeting SDK version 23 or higher
- Remove the contacts permission
- Try to type an email.
Environment
K-9 Mail version: e238ee543f489cb39333a88a0882485103bda017
Android version: 7.1.1
Account type (IMAP, POP3, WebDAV/Exchange): N/A
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:18 (10 by maintainers)
Top Results From Across the Web
Handle runtime permissions in K-9 · Issue #2110 - GitHub
Is there a reason we can't have runtime permissions even while targetting api level < 23? Users can revoke permissions, and we can...
Read more >Handle Runtime Permissions in Android | by SHISHIR - Medium
Some permissions are automatically granted to the application. Just we need to declare those permissions in AndroidManifest.xml and it will work fine.
Read more >Android M - check runtime permission - how to determine if the ...
To make life much simpler, I wrote an util class to handle runtime permissions. public class PermissionUtil { /* * Check if version...
Read more >Runtime Permissions With Jetpack Compose - YouTube
In this live stream we looked at the Accompanist permissions library and how we can integrate permission checks into our Jetpack Compose ...
Read more >Runtime Permission Issues in Android Apps - arXiv
Abstract—Android introduces a new permission model that allows apps to request permissions at runtime rather than at the installation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The UX of requesting permissions can certainly be improved. But I think we have the functionality covered now. Closing this issue.
@rugk, yes, see issue #3498 and the original report by @philipwhiuk above, in the section Actual Behavior.