open_file icon indicating copy to clipboard operation
open_file copied to clipboard

Extra permission

Open sm2017 opened this issue 3 years ago • 5 comments

Here we have some default permissions https://github.com/crazecoder/open_file/blob/master/android/src/main/AndroidManifest.xml#L5-L6

  1. How can I remove them?
  2. Why we have REQUEST_INSTALL_PACKAGES?
  3. I am always using getApplicationDocumentsDirectory so I think READ_EXTERNAL_STORAGE is redundant , right?

sm2017 avatar Jan 06 '21 13:01 sm2017

For ease of use, the required permissions are written in the plugin. If you don't need them, you can remove them like this

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="xxxxx">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"
        tools:node="remove"/> 
</manifest>

crazecoder avatar Apr 19 '21 08:04 crazecoder

These permissions should not be included by default and should be moved to the readme page. "Don't unnecessarily request storage-related permissions for devices that run Android 10 or higher" https://developer.android.com/training/data-storage/shared/media

micsanbr avatar Apr 26 '21 07:04 micsanbr

Same goes for "requestLegacyExternalStorage"

Starting May 5th, you must let us know why your app requires broad storage access with content We've detected that your app contains the requestLegacyExternalStorage flag in the manifest file of 1 or more of your app bundles or APKs.

micsanbr avatar Apr 26 '21 07:04 micsanbr

@micsan13br It has been removed in 3.2.0

crazecoder avatar Apr 26 '21 12:04 crazecoder

@crazecoder I'm using 3.2.1 and I still get this warning in Play Console now:

image

I think because it is still referenced in code in OpenFilePlugin.java:

@RequiresApi(api = Build.VERSION_CODES.M)
    private void openApkFile() {
        if (!canInstallApk()) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                startInstallPermissionSettingActivity();
            } else {
                ActivityCompat.requestPermissions(activity,
                        new String[]{Manifest.permission.REQUEST_INSTALL_PACKAGES}, REQUEST_CODE);
            }
        } else {
            startActivity();
        }
    }

jamesncl avatar Sep 15 '22 15:09 jamesncl

For ease of use, the required permissions are written in the plugin. If you don't need them, you can remove them like this

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="xxxxx">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"
        tools:node="remove"/> 
</manifest>

This doesn't work for me - I have this in my manifest, and now I'm blocked from updating my app because the permission is still there:

image

jamesncl avatar Oct 30 '22 10:10 jamesncl