Skip to content

Commit

Permalink
Remove media permissions to make complaint with Android 14 requirements
Browse files Browse the repository at this point in the history
This is cherry-pick and backport of a non-final implementation of PR
apache#889

WR-Issue: #17891
  • Loading branch information
Ravi Yakasiri authored and lorenzodallavecchia committed Oct 16, 2024
1 parent 0b6c858 commit 0ffb278
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
</config-file>
<config-file target="AndroidManifest.xml" parent="application">
Expand Down
13 changes: 3 additions & 10 deletions src/android/CameraLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,11 @@ else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) {
//--------------------------------------------------------------------------

private String[] getStoragePermissions(int mediaType) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
switch (mediaType) {
case PICTURE:
return new String[]{ Manifest.permission.READ_MEDIA_IMAGES };
case VIDEO:
return new String[]{ Manifest.permission.READ_MEDIA_VIDEO };
default:
return new String[]{ Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VIDEO };
}
} else {
if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
// Android API 30 or lower
return new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
}
return new String[0];
}

private boolean hasPermissions(String[] permissions) {
Expand Down

0 comments on commit 0ffb278

Please sign in to comment.