Bug 26273 - Xamarin.Android fails to play videos stored in Isolated storage.
Summary: Xamarin.Android fails to play videos stored in Isolated storage.
Status: RESOLVED FEATURE
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.20.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2015-01-22 04:36 UTC by Prashant Cholachagudda
Modified: 2016-09-22 14:36 UTC (History)
2 users (show)

Tags: XATriaged
Is this bug a regression?: ---
Last known good build:


Attachments
Testcase (311.87 KB, application/zip)
2015-01-22 04:36 UTC, Prashant Cholachagudda
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description Prashant Cholachagudda 2015-01-22 04:36:25 UTC
Created attachment 9443 [details]
Testcase

A Video file downloaded to App's Isolated storage is corrupted. While the video file downloaded to the external storage is just file and playback on the Video player.
Comment 1 Abhishek 2015-01-22 09:37:15 UTC
I have tried this issue and able to reproduce the reported behavior at my end.

Step to reproduce:

1.Download the attach Testcase.
2.Run the application on the device.
3.Click on "Download and save to isolated storage" It will download the video file.
4.Click on "Play from Isolate Storage". It will show the error "Unable to play video".
5.Click on "Download and save to(android) file storage" it will download the file in the external drive.
6.Click on "Play from File storage" .It will play the video file.

I observe that when I Click on "Play from Isolate Storage". It will show the error "Unable to play video".

Device Log: https://gist.github.com/Abhishekk360/88b344f10582596aa3f9
Application Output: https://gist.github.com/AkhileshKumar01/c6e1fd6286bc04880adf

Build Info:

=== Xamarin Studio ===

Version 5.7.1 (build 14)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.Mac ===

Version: 1.10.0.18 (Indie Edition)

=== Xamarin.Android ===

Version: 4.20.0.28 (Indie Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin.iOS ===

Version: 8.6.1.19 (Indie Edition)
Hash: 80971a6
Branch: 
Build date: 2015-01-21 17:42:51-0500

=== Build Information ===

Release ID: 507010014
Git revision: a4dd61ad7f8b3695be4b17bcb5c3ae6b81438cf7
Build date: 2015-01-19 15:21:09-05
Xamarin addins: 081208fe3bbf40e24a562867c6c7fba20a9b94b6

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Marek Habersack 2016-08-30 21:52:31 UTC
The sample still crashes with XA master and cycle8 but it's a different problem - some code throws TargetInvocationException
Comment 3 Marek Habersack 2016-09-22 14:36:44 UTC
I've investigated the issue further and I think there's no bug here. The reason is the nature of isolated storage - it should be accessible only by the user/app (in Android every application runs with a separate Unix user permissions) and so when it is created its permissions are set to 0700 octal, which means it is only readable/writable/browsable by the owning user. The way video playback works is that the app creates an intent with the URI pointing to the location of the downloaded file:

  file:///data/user/0/Test01.Droid/files/.config/.isolated-storage/video.mp4

However, the isolated storage directory has the following permissions:

  $ ls -ld /data/user/0/Test01.Droid/files/.config/.isolated-storage                                                                                                                                                                     
drwx------ 2 u0_a170 u0_a170 4096 2016-09-22 16:09 /data/user/0/Test01.Droid/files/.config/.isolated-storage

And therefore any 3rd party application trying to open it will get a permission denied error:

  $ ls -l /data/user/0/Test01.Droid/files/.config/.isolated-storage/video.mp4
     ls: /data/user/0/Test01.Droid/files/.config/.isolated-storage/video.mp4: Permission denied

It would be possible to change the permissions of the .isolated-storage directory to world-readable but that would make the storage area not quite isolated, thus defying its purpose. However, if you download the content to a directory created off off the $HOME/files directory (that would be /data/user/0/Test01.Droid/files/ in this case), 3rd party apps will be able to access the downloaded file.

If you want to keep the content in isolated storage and still allow access to it, you can implement a content provider, keeping in mind that it will incur unnecessary overhead. The better option, unless content is confidential, is to download it to a publicly readable location.