ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.41k stars 2.19k forks source link

[BUG] Storage permission is asked in Android 13 and can't be granted #14423

Closed WhtUsrWrks closed 6 months ago

WhtUsrWrks commented 1 year ago

Hi.. I hadn't used ankidroid so my Samsung Galaxy A21 removed its permissions, and I wanted to use it again today but when I open it it says "Grant storage permission", but I've granted all permissions and it still asks. I've tried u installing and reinstalling and it says the same thing. I don't seem to have a dedicated Storage Permission option in permission manager but it has permission for files and that's on... I don't know what else to change? Thank you

welcome[bot] commented 1 year ago

Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing

thedroiddiv commented 1 year ago

@WhtUsrWrks can you share screenshot of the permission screen and the popup where it is asking permissions? Or better maybe attach a screen recording.

ByteCodeRoad commented 1 year ago

I have the same issue on my Xiaomi Redmi Note 10 Pro. I have attached a screen recording and written some device info below.

https://github.com/ankidroid/Anki-Android/assets/144927977/302d0ccc-5776-42a2-b909-928f7536cc6b

thedroiddiv commented 1 year ago

Thanks for sharing!

BrayanDSO commented 1 year ago

I'm pinning this so we don't forget it

Ezkielnet commented 1 year ago

Hello. I have the same problem with One Plus Nord 2, Android 13.

lukstbit commented 12 months ago

Nobody mentioned which version of the app are they running. Is the app installed from the app store, downloaded from here etc?

feleck commented 12 months ago

Version 2.6.15 from the app store. Android 13, pixel 6a

WhtUsrWrks commented 12 months ago

Mine says 2.16.5 and I downloaded it from Google play

On Tue 19 Sept 2023, 18:32 Marcin, < @.***> wrote:

Version 2.6.15 from the app store. Android 13, pixel 6a —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID:

DuckDuckGo removed one tracker. More https://duckduckgo.com/-QgeEDl9Nx4fz_303RIzy756cy2ouygPrWxiLMNkhxFGBgwb_pdVCbY4m2csn7ZeKEr8Bm8wsxsHbNluvb6j7RdIKr8m7SGzdwrhvYgEFEOrAIdml-udKXwcLWnCDq5vfb3SXENBz0nar-bVUiX6n55PDstjW-awIpy2Y-pGjPqFDbJ7_lt4X2efyItk7Nv5iUQhQ5t0T87uJK-Vkl2F_Niv3PSE6A_icV3FFwljMlh_vh-Uh23xXSAi10EeDdeEm0qxrQ4bahr7LGlCplV85C6b8f6EXlRnE9jffUxSaAeXkiMU9vBxigkwkMGwl_MrfHns3kySeWKxuZ6O9xqCLrQJPvTvTcMe_nbTF31b3tSnozPX-7-vW6JvV5Y8n2e75Ea_2yQPR8fHN0AOO0RA8hkEZ3_wqp54ONKd9y6Kji8Q7hUygCw20BmgbU7WP-VuaXmunlfZIBawi1Pw Report Spam https://duckduckgo.com/-QgeEDl9Nx4fz_303RIzy756cy2ouygPrWxiLMNkhxFGBgwb_pdVCbY4m2csn7ZeKEr8Bm8wsxsHbNluvb6j7RdIKr8m7SGzdwrhvYgEFEOrAIdml-udKXwcLWnCDq5vfb3SXENBz0nar-bVUiX6n55PDstjW-awIpy2Y-pGjPqFDbJ7_lt4X2efyItk7Nv5iUQhQ5t0T87uJK-Vkl2F_Niv3PSE6A_icV3FFwljMlh_vh-Uh23xXSAi10EeDdeEm0qxrQ4bahr7LGlCplV85C6b8f6EXlRnE9jffUxSaAeXkiMU9vBxigkwkMGwl_MrfHns3kySeWKxuZ6O9xqCLrQJPvTvTcMe_nbTF31b3tSnozPX-7-vW6JvV5Y8n2e75Ea_2yQPR8fHN0AOO0RA8hkEZ3_wqp54ONKd9y6Kji8Q7hUygCw20BmgbU7WP-VuaXmunlfZIBawi1Pw

Version 2.6.15 from the app store. Android 13, pixel 6a

— Reply to this email directly, view it on GitHub https://github.com/ankidroid/Anki-Android/issues/14423#issuecomment-1725899183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZXMA7QBWT6EH6ZMQBUZS2TX3G3HJANCNFSM6AAAAAA4S7GPFM . You are receiving this because you were mentioned.Message ID: @.***>

Ezkielnet commented 12 months ago

I could enter, unintentionally. I wanted to show you the gray error message at the bottom and when I hit Delete app data, the app opened.

https://github.com/ankidroid/Anki-Android/assets/23616105/bd24a159-dedd-4376-a636-93bcefe7d7cc

Sc3l3t0n commented 12 months ago

Could this be the problem? This would at least explain why the system does not ask for memory access in the first place.

Three new permission is introduced with Android 13: READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, and READ_MEDIA_AUDIO. If you were using READ_EXTERNAL_STORAGE for accessing files, then you need to use one of these new permissions. If a user with Android 13 has previously granted this permission, then all is good. If not, then the permission request for READ_EXTERNAL_STORAGE will be ignored.

Source: https://medium.com/@muhammadbilal4074/storage-permission-in-android-13-89372e543864#:~:text=Three%20new%20permission%20is%20introduced,permission%2C%20then%20all%20is%20good.

queue-tip commented 12 months ago

I experience the same running version 2.16.5 on Pixel 7 Pro with Android 13 (September 2023 update)

hmenke commented 12 months ago

Launching AnkiDroid this logcat is produced.

09-23 21:21:47.398 18391 19178 I Role    : com.ichi2.anki not qualified for android.app.role.HOME due to missing RequiredComponent{mIntentFilterData=IntentFilterData{mAction='android.intent.action.MAIN', mCategories='[android.intent.category.HOME]', mDataScheme='null', mDataType='null'}, mMinTargetSdkVersion=1, mPermission='null', mQueryFlags=0, mMetaData=[]}
09-23 21:21:47.401 18391 19178 I Role    : com.ichi2.anki not qualified for android.app.role.DIALER due to missing RequiredComponent{mIntentFilterData=IntentFilterData{mAction='android.intent.action.DIAL', mCategories='[]', mDataScheme='null', mDataType='null'}, mMinTargetSdkVersion=1, mPermission='null', mQueryFlags=0, mMetaData=[]}
09-23 21:21:47.404 18391 18642 I Role    : com.ichi2.anki not qualified for android.app.role.SMS due to missing RequiredComponent{mIntentFilterData=IntentFilterData{mAction='android.provider.Telephony.SMS_DELIVER', mCategories='[]', mDataScheme='null', mDataType='null'}, mMinTargetSdkVersion=1, mPermission='android.permission.BROADCAST_SMS', mQueryFlags=0, mMetaData=[]}
09-23 21:21:47.406 20072 20072 E AppInfoDashboard: Package: com.ichi2.anki not found for user: 10
09-23 21:21:47.406 20072 20072 E AppInfoDashboard: Package: com.ichi2.anki not found for user: 11
09-23 21:21:47.407  1494  5310 E AppOps  : Bad call made by uid 1000. Package "com.ichi2.anki" does not belong to uid -1.
09-23 21:21:47.407  1494  5310 E AppOps  : noteOperation
09-23 21:21:47.407  1494  5310 E AppOps  : java.lang.SecurityException: Specified package "com.ichi2.anki" under uid -1 but it is not
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService.verifyAndGetBypass(AppOpsService.java:4703)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService.noteOperationUnchecked(AppOpsService.java:3466)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService.noteOperationImpl(AppOpsService.java:3454)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService.-$$Nest$mnoteOperationImpl(Unknown Source:0)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.lambda$noteOperation$4(AppOpsService.java:7662)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.$r8$lambda$oOwUoG55BBmJ6yiwhp3OAq3tQ30(Unknown Source:0)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher$$ExternalSyntheticLambda3.apply(Unknown Source:32)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.policy.AppOpsPolicy.noteOperation(AppOpsPolicy.java:225)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.noteOperation(AppOpsService.java:7660)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.server.appop.AppOpsService.noteOperation(AppOpsService.java:3438)
09-23 21:21:47.407  1494  5310 E AppOps  :  at com.android.internal.app.IAppOpsService$Stub.onTransact(IAppOpsService.java:479)
09-23 21:21:47.407  1494  5310 E AppOps  :  at android.os.Binder.execTransactInternal(Binder.java:1309)
09-23 21:21:47.407  1494  5310 E AppOps  :  at android.os.Binder.execTransact(Binder.java:1268)
dae commented 11 months ago

Maybe related? https://www.reddit.com/r/androiddev/comments/146cd1y/comment/jnt3jmn/

gragramel commented 11 months ago

Dear AnkiDroid Team/Users,

I experienced the same with AnkiDroid 2.16.5 on Android 13 smartphone. Nevertheless, I was able to workaround that blocking issue by doing the following:

  1. Cleaned up AnkiDroid app stored data (perhaps/probably optional)
  2. Uninstalled AnkiDroid 2.16.5 app
  3. Via Neo Store (F-Droid-like app), I managed to install older AnkiDroid 2.16.3 => OK (I was then able to: launch AnkiDroid, connect, sync and use app without any blocker)
  4. Still via Neo Store, I managed to upgrade to AnkiDroid 2.16.4 => OK (I was able to: launch AnkiDroid, then was asked to: "grant access to all files (special access)), then, once access granted, I was able to: connect, sync and use app without any blocker)
  5. Still via Neo Store, I upgraded to AnkiDroid 2.16.5 => OK (I was able to: launch AnkiDroid, connect, sync and use app without any blocker)

If I compare this situation to my initial launch of AnkiDroid (blocked by current issue), here is the main difference: First time, I was launching AnkiDroid (2.16.5) after a long period of inactivity (and multiple intermediate AnkiDroid updates), so last time I launched it, it was a version v2.x<2.16 (at that time, grant special access to all files was not yet required).

So from my own experience, and only based on it, here are my conclusions on that issue:

Hope this help.

Best regards,

gregyski commented 11 months ago

I experienced this as well.

Device: Pixel 7 Pro Android version: 13 Android security update: 2023-08-05 Ankidroid version: 2.16.5

I exhibited the same symptoms as ByteCodeRoad's video, additionally looking under "...->All Permissions" and not finding Storage there either. Deleting app data as per Ezkielnet and then logging back in and syncing solved it.

snowtimeglass commented 11 months ago

when I hit Delete app data, the app opened.

Deleting app data as per Ezkielnet and then logging back in and syncing solved it.

@Ezkielnet @gregyski Thank you for sharing information about the unexpected discovery.

Just to be sure, after tapping the "Get started" in the initial screen, were you actually able to see the deck list screen? (And it was without being asked for any sort of permissions?)

(I don't have an Android 13 device so I can't try this way myself.)

Ezkielnet commented 11 months ago

when I hit Delete app data, the app opened.

Deleting app data as per Ezkielnet and then logging back in and syncing solved it.

@Ezkielnet @gregyski Thank you for sharing information about the unexpected discovery.

Just to be sure, after tapping the "Get started" in the initial screen, were you actually able to see the deck list screen? (And it was without being asked for any sort of permissions?)

(I don't have an Android 13 device so I can't try this way myself.)

Yes, I can use the application perfectly. I can't be sure if it asks for permissions afterwards because I enabled them manually.

snowtimeglass commented 11 months ago

Yes, I can use the application perfectly.

How nice. Thank you.

I can't be sure if it asks for permissions afterwards because I enabled them manually.

Which permission items did you manually enable? (Are those in the ByteCodeRoad's video?)

Ezkielnet commented 11 months ago

Which permission items did you manually enable? (Are those in the ByteCodeRoad's video?)

When I had the error I enabled all of them, but I just saw that none of them are active.

WhatsApp Image 2023-09-30 at 14 53 51_4574cf73

gregyski commented 11 months ago

when I hit Delete app data, the app opened.

Deleting app data as per Ezkielnet and then logging back in and syncing solved it.

@Ezkielnet @gregyski Thank you for sharing information about the unexpected discovery.

Just to be sure, after tapping the "Get started" in the initial screen, were you actually able to see the deck list screen? (And it was without being asked for any sort of permissions?)

(I don't have an Android 13 device so I can't try this way myself.)

If I'm understanding the question properly, before the "fix" I'd launch the app and be taken directly to permissions without ever seeing any of the Ankidroid interface. After the "fix", for all practical purposes I was starting with a fresh installation so I had to log in and sync to get my decks back from Ankiweb. I did not, at that time, get asked for any further permissions. Note that I had, when trying to fix the issue originally, manually enabled the "Read and write to the Ankidroid database" permission so that was set as well, so while that had no impact on the original problem, I don't know if it impacted the "fix". Hope that helps.

Edit: I just checked my permissions and things again match Ezkielnet. I currently show "No permissions allowed" despite my not actually adjusting them since the "fix". The app is working normally.

snowtimeglass commented 11 months ago

So, after the "Delete app data", the prior manual permissions may be no impact or annulled, and the app works properly without requiring permissions... I think I have a better understanding of the situation. Thank you for the feedbacks.

srishti-R commented 11 months ago

Hi, @snowtimeglass will you be working on this? I would like to contribute.

snowtimeglass commented 11 months ago

No, I'm not. I welcome your contribution.

snowtimeglass commented 11 months ago

@srishti-R

If no one is assigned on a issue you can just comment that you are working on it and start working : )

Originally posted by @criticalAY in https://github.com/ankidroid/Anki-Android/issues/14502#issuecomment-1746660974

srishti-R commented 11 months ago

Strange that I am not facing any such issue in master branch.

gregyski commented 11 months ago

I believe it's possible that it might be related to the Android feature that disables permissions when an app hasn't been used in a while. I know I'd been slacking and am pretty sure that feature activated on my Ankidroid install. And it might even related to some recent Android permission changes making it rather an edge case if it's a combination of the two.

I have no evidence of that, but I know when I was researching the problem to try to fix it I encountered mentions of both situations being potential causes, so I thought I'd mention it.

7merlin commented 11 months ago

Please fix or help find a workaround that doesn't involve deleting data. My AnkiWeb account expired so I'm concerned with loosing all the data if I clear it

queue-tip commented 11 months ago

Please fix or help find a workaround that doesn't involve deleting data. My AnkiWeb account expired so I'm concerned with loosing all the data if I clear it

Either of these should work

risshuu commented 11 months ago

I believe it's possible that it might be related to the Android feature that disables permissions when an app hasn't been used in a while. I know I'd been slacking and am pretty sure that feature activated on my Ankidroid install. And it might even related to some recent Android permission changes making it rather an edge case if it's a combination of the two.

I have no evidence of that, but I know when I was researching the problem to try to fix it I encountered mentions of both situations being potential causes, so I thought I'd mention it.

This would line up with what I am seeing. This happened to me just recently. I haven't used it in months. I am in the same boat as 7merlin where I do not have the decks on ankiweb anymore because of the months that I have spent away from the app. I would also like to be able to get this fixed without wiping my data.

queue-tip: I don't know how I am supposed to do your steps since I am getting this error and cannot get into the app.

snowtimeglass commented 11 months ago

Please fix or help find a workaround that doesn't involve deleting data. My AnkiWeb account expired so I'm concerned with loosing all the data if I clear it

I would also like to be able to get this fixed without wiping my data.

@7merlin @risshuu Long press the app icon > "App Info" > "Storage usage" > "Clear cache" doesn't work as another workaround?

7merlin commented 11 months ago

No, it didn't help

7merlin commented 11 months ago

queue-tip, yes, same as risshuu I can't follow the steps since the app is not opening. How can I export the collection if the app is not opening? How can I sync to ankiweb if the app is not opening?

dae commented 11 months ago

You could try clearing the app's cache (not data) to see if that helps.

https://www.avg.com/en/signal/how-to-clear-cache-on-android-phones#:~:text=a%20Samsung%20phone%3A-,Open%20Settings%20and%20select%20Apps.,Clear%20data%20and%20then%20OK.

Before trying that, if you don't have any other copies of your data, you may be able to extract the data by using a file browsing app that lets you read the files stored inside AnkiDroid's folder. I'm not an Android user, so perhaps someone else here can suggest a good one.

jkexbx commented 11 months ago

I'm also experiencing this on a oneplus 8T. It's definitely related to permissions that are removed due to inactivity.

First tried permissions, but there's nothing more I can give.

Then tried uninstalling and installing while keeping and then removing my data.

Finally, I left the google beta tester group, and reinstalled and that fixed it.

Installing 2.16.5 not from Beta fixed it.

Full video of process: https://youtu.be/IQJwKJLohoE

7merlin commented 11 months ago

dae, I've tried clearing cache, it didn't help.

Where does AnkiDroid store files? Is it somewhere on /sdcard that's accessible via ADB?

dae commented 11 months ago

It should be accessible to ADB, but I think it's on the internal storage by default.

david-allison commented 11 months ago

I've been away for a while, may need some more time to process before I dive into this one

Proposed resolution for advanced users:

❓❗️ Could an affected user try the following ADB commands:

adb shell pm grant com.ichi2.anki android.permission.WRITE_EXTERNAL_STORAGE adb shell pm grant com.ichi2.anki android.permission.READ_EXTERNAL_STORAGE

An affected user would have:

If you're affected in another way and the command works, please let me know. If you feel you're affected but don't know how to use adb, please ask


I'm going to summarise my understanding of this issue, so we can work forward to fix/inform users of a path to resolve this.

Please correct me if I'm incorrect

Information for readers

Red Herrings

Issue Prerequisites

Trigger


Outcome of the request at the top of the post

eumel2 commented 10 months ago

Android 13 Installed via playstore and not used in a while though i did grant the permission from the settings to no avail Version 2.16.5

I tried the adb commands and that fixed it for me @david-allison

david-allison commented 10 months ago

@eumel2 Fantastic! This feedback is vital as I can't reproduce the issue

Could you list your AnkiDroid Directory in Settings - Advanced?

WhtUsrWrks commented 10 months ago

Does anyone have a dummies' guide to running ADB? I've enabled usb debugging, connected to computer, installed ADB app from play store, and connected but the pc says a whole long screen of things like adb : The term 'adb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:8 char:1

and the app just shows that I am connected and I can see where I pasted the adb commands but hasn't done anything

david-allison commented 10 months ago

There is no ADB app. ADB is a computer application which allows you to run commands on your Android via the command line/terminal

Get ADB working Once this step is completed, running adb --version on the command line should produce output


https://github.com/ankidroid/Anki-Android/wiki/Development-Guide#connecting-your-device-to-android-studio-via-adb-to-use-for-testing


Once adb devices succeeds, you can run the command

david-allison commented 10 months ago

The next stage in fixing this is determining when the bug takes place:

Screenshots API 32 on 21.6: Screenshot 2023-10-24 at 16 32 29 Permission can be revoked and reapplied **API 33** **2.15:** Screenshot 2023-10-24 at 16 35 00 Screenshot 2023-10-24 at 16 35 32 **2.16:** Screenshot 2023-10-24 at 16 35 59
david-allison commented 10 months ago

Issue

User actions

Advanced User

An advanced user can fix this issue via ADB:

adb shell pm grant com.ichi2.anki android.permission.WRITE_EXTERNAL_STORAGE
adb shell pm grant com.ichi2.anki android.permission.READ_EXTERNAL_STORAGE

Semi-Advanced User

Download and use the full version of AnkiDroid (cannot be distributed by Google Play) which requests MANAGE_EXTERNAL_STORAGE and can access /AnkiDroid

https://github.com/ankidroid/Anki-Android/releases/latest

Any user

Reinstall AnkiDroid from the Play Store

What should we do?

This is up for discussion

eumel2 commented 10 months ago

The folder is: /storage/emulated/0/AnkiDroid Starting it just now i also got a message to migrate the storage somewhere which I postponed for now

snowtimeglass commented 10 months ago

@david-allison Thank you for putting the issue in perspective.

What do you think about the App info - Storage usage - Manage space - Delete app data approach, which @Ezkielnet and @gregyski have reported. If I understand correctly, it won't delete the collection, and it will enable to open the app and access the /AnkiDroid folder again, without uninstalling the Play Store app. image (Screenshot of Android 9, not 13)

david-allison commented 10 months ago

@snowtimeglass I don't /think/ that would work:

https://github.com/ankidroid/Anki-Android/blob/b44dcf49d5a410751ead0d29b7b3c90ccbfed965/AnkiDroid/src/main/java/com/ichi2/anki/InitialActivity.kt#L287-L295

I believe the issue is that Environment.isExternalStorageLegacy() returns true BUT the user can't provide permissions to access the legacy storage. Therefore the new default directory would be unsafe unusable

Currently, a user would need to uninstall to remove legacy storage access,


DIALOG_STORAGE_UNAVAILABLE_AFTER_UNINSTALL offers "Create a new collection" which is a less destructive version of 'Delete app data', and would fix the issue if it sets collectionPath to the app-private directory

Screenshot 2023-03-04 at 03 07 40

snowtimeglass commented 10 months ago

@david-allison

I don't /think/ that would work:

Therefore the new default directory would be unsafe

In this case, what do "not work" and "unsafe" mean specifically? You mean that the approach may make the legacy directory inaccessible?

david-allison commented 10 months ago

I believe that clearing app data would mean that:

What do[es] ... "unsafe" mean specifically?

I misspoke: I edited the comment to replace unsafe with unusable

gregyski commented 10 months ago

@david-allison What do you think about the App info - Storage usage - Manage space - Delete app data approach, which @Ezkielnet and @gregyski have reported. If I understand correctly, it won't delete the collection, and it will enable to open the app and access the /AnkiDroid folder again, without uninstalling the Play Store app.

If I remember correctly, Delete app data did delete my decks. But since I still had them on Ankiweb I was able to download them again.