element-android icon indicating copy to clipboard operation
element-android copied to clipboard

Crash when accessing a local file and permission is revoked

Open bmarty opened this issue 4 years ago • 5 comments

In airplane mode (so no network)

  • Open a room
  • Send an attachment (image from the gallery for instance) to the room. It won't be sent of course
  • Kill the app
  • Open the same room
  • Long click of the pending event with the attachment
  • Observe the crash:
Caused by: java.lang.SecurityException: UID 10568 does not have permission to content://com.android.providers.media.documents/document/video%3A13374 [user 0]; you could obtain access using ACTION_OPEN_DOCUMENT or related APIs
        at android.os.Parcel.createException(Parcel.java:2088)
        at android.os.Parcel.readException(Parcel.java:2056)
        at android.os.Parcel.readException(Parcel.java:2004)
        at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:4454)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1716)
        at android.app.Activity.startActivityForResult(Activity.java:5258)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:574)
        at android.app.Activity.startActivityForResult(Activity.java:5203)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:560)
        at android.app.Activity.startActivity(Activity.java:5587)
        at android.app.Activity.startActivity(Activity.java:5555)
        at im.vector.app.features.home.room.detail.RoomDetailFragment.openFile(RoomDetailFragment.kt:630)
        at im.vector.app.features.home.room.detail.RoomDetailFragment.startOpenFileIntent(RoomDetailFragment.kt:619)
        at im.vector.app.features.home.room.detail.RoomDetailFragment.access$startOpenFileIntent(RoomDetailFragment.kt:214)
        at im.vector.app.features.home.room.detail.RoomDetailFragment$onViewCreated$14.invoke(RoomDetailFragment.kt:393)
        at im.vector.app.features.home.room.detail.RoomDetailFragment$onViewCreated$14.invoke(RoomDetailFragment.kt:377)
  • We should only use the local file to render in the bottom sheet and not the original file location.

bmarty avatar Jul 01 '21 16:07 bmarty

(I cannot repro on an emulator today, will try on a real device)

bmarty avatar Sep 01 '22 09:09 bmarty

@bmarty did you reproduce this issue on a real device?

giomfo avatar Nov 16 '22 11:11 giomfo

We have a similar issue on Tchap

yostyle avatar Feb 16 '23 17:02 yostyle

Maybe linked to : https://github.com/vector-im/element-android/issues/6377

jdauphant avatar Mar 07 '23 10:03 jdauphant

reproduced in Element

https://github.com/element-hq/element-android/assets/1191674/99d62f86-4bc4-4292-9526-3bc49a391262

  1. Switch to Airplane Mode
  2. Open a room
  3. Add a PDF file in the timeline
  4. You can open the local file (you have the permission)
  5. Go back to home
  6. Re-Open the same room
  7. Click on the PDF file (you loose the permission)

yostyle avatar Apr 04 '24 16:04 yostyle