From 345fa98c97ba280c47854a4f755646e5506e9a85 Mon Sep 17 00:00:00 2001
From: Camille Simon <43054281+camsim99@users.noreply.github.com>
Date: Wed, 9 Oct 2024 18:24:22 +0100
Subject: [PATCH] [camerax] Revert "Explicitly remove READ_EXTERNAL_STORAGE
permission" (#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 https://github.com/flutter/packages/pull/4716 and adds documentation so that users know how to manually remove `READ_EXTERNAL_STORAGE` from the merged manifest if they wish.
Fixes https://github.com/flutter/flutter/issues/156198 and adds documentation to address https://github.com/flutter/flutter/issues/131116.
---
.../camera/camera_android_camerax/CHANGELOG.md | 6 ++++++
.../camera/camera_android_camerax/README.md | 18 ++++++++++++++++--
.../android/src/main/AndroidManifest.xml | 3 ---
.../camera/camera_android_camerax/pubspec.yaml | 2 +-
4 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md
index b1ecba94bf0e..18218256feea 100644
--- a/packages/camera/camera_android_camerax/CHANGELOG.md
+++ b/packages/camera/camera_android_camerax/CHANGELOG.md
@@ -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.
diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md
index bc929109cadb..c409f1a902eb 100644
--- a/packages/camera/camera_android_camerax/README.md
+++ b/packages/camera/camera_android_camerax/README.md
@@ -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
+
+```
### Allowing image streaming in the background
@@ -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
diff --git a/packages/camera/camera_android_camerax/android/src/main/AndroidManifest.xml b/packages/camera/camera_android_camerax/android/src/main/AndroidManifest.xml
index e1629a607c3a..52012aaa6915 100644
--- a/packages/camera/camera_android_camerax/android/src/main/AndroidManifest.xml
+++ b/packages/camera/camera_android_camerax/android/src/main/AndroidManifest.xml
@@ -1,11 +1,8 @@
-
diff --git a/packages/camera/camera_android_camerax/pubspec.yaml b/packages/camera/camera_android_camerax/pubspec.yaml
index 60a0a82bb4aa..51d18c6aaa07 100644
--- a/packages/camera/camera_android_camerax/pubspec.yaml
+++ b/packages/camera/camera_android_camerax/pubspec.yaml
@@ -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