Remove media permissions to make complaint with Android 14 requirements (#889)

Co-authored-by: Ravi Yakasiri <ravi.yakasiri@planonsoftware.com>
This commit is contained in:
ravi-yk 2024-10-24 22:08:18 +05:30 committed by GitHub
parent 0a4bfe1a74
commit faa4615ee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 20 deletions

View File

@ -55,9 +55,7 @@
</feature> </feature>
</config-file> </config-file>
<config-file target="AndroidManifest.xml" parent="/*"> <config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
</config-file> </config-file>
<config-file target="AndroidManifest.xml" parent="application"> <config-file target="AndroidManifest.xml" parent="application">
<provider <provider

View File

@ -225,26 +225,11 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
private String[] getPermissions(boolean storageOnly, int mediaType) { private String[] getPermissions(boolean storageOnly, int mediaType) {
ArrayList<String> permissions = new ArrayList<>(); ArrayList<String> permissions = new ArrayList<>();
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
// Android API 33 and higher // Android API 30 or lower
switch (mediaType) {
case PICTURE:
permissions.add(Manifest.permission.READ_MEDIA_IMAGES);
break;
case VIDEO:
permissions.add(Manifest.permission.READ_MEDIA_VIDEO);
break;
default:
permissions.add(Manifest.permission.READ_MEDIA_IMAGES);
permissions.add(Manifest.permission.READ_MEDIA_VIDEO);
break;
}
} else {
// Android API 32 or lower
permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE); permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
} }
if (!storageOnly) { if (!storageOnly) {
// Add camera permission when not storage. // Add camera permission when not storage.
permissions.add(Manifest.permission.CAMERA); permissions.add(Manifest.permission.CAMERA);