Skip to content

Commit

Permalink
[camerax] Revert "Explicitly remove READ_EXTERNAL_STORAGE permission" (
Browse files Browse the repository at this point in the history
…#7826)

Reverts logic to remove `READ_EXTERNAL_STORAGE` permission from merged Android manifest (between plugins and Flutter app) by default. Turns out that this logic conflicts with Flutter plugins/apps that actually require the `READ_EXTERNAL_STORAGE` permission.

Specifically, reverts #4716 and adds documentation so that users know how to manually remove `READ_EXTERNAL_STORAGE`  from the merged manifest if they wish. 

Fixes flutter/flutter#156198 and adds documentation to address flutter/flutter#131116.
  • Loading branch information
camsim99 authored Oct 9, 2024
1 parent 9d00fb1 commit 345fa98
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.6.10

* Removes logic that explicitly removes `READ_EXTERNAL_STORAGE` permission that may be implied
from `WRITE_EXTERNAL_STORAGE` and updates the README to tell users how to manually
remove it from their app's merged manifest if they wish.

## 0.6.9+2

* Updates Java compatibility version to 11.
Expand Down
18 changes: 16 additions & 2 deletions packages/camera/camera_android_camerax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,21 @@ and thus that parameter will silently be ignored.

In order to save captured images and videos to files on Android 10 and below, CameraX
requires specifying the `WRITE_EXTERNAL_STORAGE` permission (see [the CameraX documentation][10]).
This is already done in the plugin, so no further action is required on your end. To understand
the implications of specificying this permission, see [the `WRITE_EXTERNAL_STORAGE` documentation][11].
This is already done in the plugin, so no further action is required on your end.

To understand the privacy impact of specifying the `WRITE_EXTERNAL_STORAGE` permission, see the
[`WRITE_EXTERNAL_STORAGE` documentation][11]. We have seen apps also have the [`READ_EXTERNAL_STORAGE`][13]
permission automatically added to the merged Android manifest; it appears to be implied from
`WRITE_EXTERNAL_STORAGE`. If you do not want the `READ_EXTERNAL_STORAGE` permission to be included
in the merged Android manifest of your app, then take the following steps to remove it:

1. Ensure that your app nor any of the plugins that it depends on require the `READ_EXTERNAL_STORAGE` permission.
2. Add the following to your app's `your_app/android/app/src/main/AndroidManifest.xml`:

```xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
tools:node="remove" />
```

### Allowing image streaming in the background

Expand Down Expand Up @@ -91,4 +104,5 @@ For more information on contributing to this plugin, see [`CONTRIBUTING.md`](CON
[10]: https://developer.android.com/media/camera/camerax/architecture#permissions
[11]: https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE
[12]: https://developer.android.com/reference/android/Manifest.permission#FOREGROUND_SERVICE_CAMERA
[13]: https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE
[148013]: https://github.com/flutter/flutter/issues/148013
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.flutter.plugins.camerax">
<uses-feature android:name="android.hardware.camera.any" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
tools:node="remove" />
</manifest>
2 changes: 1 addition & 1 deletion packages/camera/camera_android_camerax/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android_camerax
description: Android implementation of the camera plugin using the CameraX library.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.6.9+2
version: 0.6.10

environment:
sdk: ^3.5.0
Expand Down

0 comments on commit 345fa98

Please sign in to comment.