[BUG] Automatic picture uploads strip GPS location from photos (missing ACCESS_MEDIA_LOCATION) Actual behaviour on Android

オープン 初心者向け
#5,040 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, kotlin
領域
mobile, mobile-dev

調査の方向性

まず owncloudApp/src/main/AndroidManifest.xml を確認し、不足している ACCESS_MEDIA_LOCATION 権限と権限処理の経路を調べてください。報告で挙げられているアップロードのエントリポイントの名前は UploadFileFromContentUriWorker です。権限を許可した後、自動アップロードされた写真を元の写真と比較してください。SHA-256 と GPS メタデータも比較対象に含めます。アップロード後も元の写真データが保持され、権限を拒否したユーザーには位置情報メタデータが削除される可能性があると伝えられれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Camera Uploads Contributions are welcome Technical

Photos uploaded by Automatic uploads → Picture uploads reach the server with their GPS location removed on Android. Nothing warns the user, so a backup quietly differs from the original.

The uploaded file is the same size as the original but not byte-identical. The only difference is a run of 43–48 bytes inside the EXIF GPS block, all set to zero in the uploaded copy. All other EXIF data (camera model, exposure, timestamps) is untouched. That pattern is Android's media-location redaction, not an EXIF edit: on Android 10+ the system blanks location metadata for any app reading media without android.permission.ACCESS_MEDIA_LOCATION. The ownCloud app doesn't declare this permission (it's absent from owncloudApp/src/main/AndroidManifest.xml on master), so every photo it reads arrives already redacted.

Expected behaviour:

Automatic uploads should send a byte-identical copy of the original photo, including its location metadata (as they do already on the iOS client) If the user declines the media-location permission, the app should at least say that uploads will have their location removed instead of quietly altering like this.

Steps to reproduce:

On an Android 10+ device, turn on location tagging in the camera app.
In ownCloud, turn on Settings → Automatic uploads → Picture uploads, with the source folder set to DCIM/Camera.
Take a photo and wait for it to upload.
Download the uploaded file (web UI or WebDAV) and compare it with the original from the device:
    exiftool -gps:all uploaded.jpg shows no position (e.g. GPSLatitudeRef: Unknown ()), while the original has one.
    cmp -l original.jpg uploaded.jpg shows about 45 differing bytes, all 0 in the uploaded file.

Verified fix

I rebuilt the same 4.8.4 APK with a single change, adding this line to the binary manifest (no code changes), re-signed it, and installed it with the permission granted:

After that, new automatic uploads are byte-identical to the originals (matching SHA-256) with GPS intact. The current Storage Access Framework read path (DocumentFile.fromTreeUri → contentResolver.openInputStream in UploadFileFromContentUriWorker) needs no other change. Android just stops redacting once the app holds the permission.

Note on #3056: that issue (missing geotags with "Picture from camera") was closed with "it is not in our plans to add the location permission in the app". ACCESS_MEDIA_LOCATION is not a device-location permission. It doesn't let the app see where the phone is. It only lets the app read location data that is already stored in the user's own photos. Nextcloud's Android client, which started as a fork of this codebase, declares it for the same reason. iOS owncloud client also keeps this location data intact, so it's an os differentiation that's not desirable either.

Video uploads are probably affected the same way, since Android also redacts location in video metadata, but I haven't verified that.

Environment data

Android version: 17 (ColorOS 17)

Device model: OPPO Find N6 (CPH2765)

Stock or customized system: Stock

ownCloud app version: 4.8.4 (Google Play)

ownCloud server version: 10.16.6 Community
Logs
Web server error log

N/A — the upload succeeds without errors; the file content is altered on the device before upload.

ownCloud log (data/owncloud.log)

N/A — no errors are logged.

主要言語
Kotlin
スター
4.2k
フォーク
3.1k
平均マージ
3日 9時間
マージ済み PR(30日)
16

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

owncloud/android のほかの issue

owncloud/android の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。