Search code examples
androidgoogle-chromeapkandroid-permissions

Android - check from web site if Chrome app has storage permission


Currently users download an APK from my site. However, some users didn't give access to Chrome to Storage so they get this error:

chrome permission needed

So users need to give Storage permission to Chrome.

My question is whether I can check before the user click to download the APK (for example, with JavaScript), if Chrome has that permission, and if not instruct the user what he should do.


Solution

  • I would say that you cannot do that.

    First, let's look at how the Chrome android application check if the storage is granted.

    You can use some tools such as jadx-gui to see the code of the chrome application, inside it, search for permission checking. Here we are interested in "WRITE_EXTERNAL_STORAGE", you can see that this permission is checked inside the DownloadController class, reading a bit how this class work allow us to understand that when something want to download any file, and want to save it, first they check if the permission is granted, if it is not, they display an alert dialog (the one you showed in your question).

    The problem with this, is that with JavaScript you cannot interact with methods inside the chrome application if they are not any interface setup.

    Solution?

    The best thing you can do is to put a message on your website before the user download the application. Trying to figure out a solution for the Chrome android application is not a good idea because that would be very difficult and pointless for any other web browser, because they all manage permission (such as storage) in different way.