Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2957] Android: Expose MODE_WORLD_READABLE

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2013-01-14T10:35:31.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterDawson Toth
AssigneeIngo Muschenetz
Created2011-04-15T03:33:43.000+0000
Updated2017-03-22T17:22:38.000+0000

Description

Problem

On the incredible there is no external data storage so when I wrote a file I need the ability to set the privilege on it so it can be accessed by another activity not belonging to my app (Context.MODE_WORLD_READABLE).

Solution

Expose MODE_WORLD_READABLE through the Ti.Filesystem module on Android. I will ask the enterprise client to post more information on their preference for this exposure.

Associated Helpdesk Ticket

http://appc.me/c/NCI-43191-678">http://appc.me/c/NCI-43191-678

Comments

  1. Andreas sandberg 2011-04-15

    Adding some kind of permission property on to the object Titanium.Filesystem.File would work for me. Thanks!

  2. Andreas sandberg 2011-04-15

    Any chance we can get this moved into 1.7?

  3. Don Thorp 2011-04-15

    Opie, this needs to be considered for our spec as appropriate. I'm assigning it to S12 so that it can scoped wrt the spec. We will do the work once the spec has been approved. Please move it back into the new state once you update the spec and this ticket with any pertinent information.

  4. Opie Cyrus 2011-04-15

    This item was taken into consideration for the stream spec and should be moved to another milestone I think where it can be grouped with the stream implementation. Assigning back to Don for placement.

  5. Jon Alter 2011-09-13

    Need use and repro case for this to move forward.
  6. Jon Alter 2011-09-13

    Updated example from helpdesk ticket. It is possible to successfully run the updated example without this fix on a device that does not have an sd card. Must have a pdf reader installed, Adobe Reader for example.
       var win = Ti.UI.createWindow({
       	navBarHidden: true,
       	backgroundColor: 'blue'
       });
       win.open();
       
       var button = Ti.UI.createButton({
       	title: 'Get PDF',
       	height: 50,
       	width: 200,
       	top: 20
       });
       win.add(button);
       button.addEventListener('click', function(e) {
       	var xhr = Ti.Network.createHTTPClient();
       	xhr.onload = function() {
       		var f = Ti.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory,"test.pdf");
       		f.write(this.responseData);
       		var intent = Ti.Android.createIntent({
       			action : Ti.Android.ACTION_VIEW,
       			type : 'application/pdf',
       			data : f.getNativePath()
       		});
       		Ti.Android.currentActivity.startActivity(intent);
       	};
       
       	xhr.open("GET", "http://www.appcelerator.com/assets/The_iPad_App_Wave.pdf");
       	xhr.send();
       });
       

    Tested with

    TiSDK 1.7.3.v20110826161351 Nexus S, 2.3.4
  7. Dawson Toth 2011-11-04

    When developers explicitly create files (via the documented Ti.Filesystem.createFile), let them pass in an argument for mode world readable. That would address this issue. If they want to make a file world readable that already exists, their JavaScript can copy it in to a new file that has been created properly.
       var xhr = Ti.Network.createHTTPClient({
           onload: function() {
               var f = Ti.Filesystem.getFile('test.pdf');
               f.createFile({
                   mode: Ti.Android.MODE_WORLD_READABLE
               });
               f.write(this.responseData);
               var intent = Ti.Android.createIntent({
                   action: Ti.Android.ACTION_VIEW,
                   type: 'application/pdf',
                   data: f.getNativePath()
               });
               Ti.Android.currentActivity.startActivity(intent);
           }
       });
       xhr.open('GET', 'http://www.appcelerator.com/assets/The_iPad_App_Wave.pdf');
       xhr.send();
       
  8. Tom A 2012-02-11

    TypeError: Object File has no method 'createFile' (tested with Nexus S Android 4.0.3, Ti SDK 1.8.1) Would be useful to have this feature. Am I doing it wrong or is this just not resolved yet? Any update on the status would be much appreciated.
  9. Varun Joshi 2013-01-14

    Found this link: http://developer.android.com/reference/android/content/Context.html#MODE_WORLD_READABLE Google has deprecated this constant since API Level 17 and the use of this constant is strongly discouraged due to certain security issues as mentioned in above link.
  10. Dawson Toth 2013-01-14

    Shak, please look at my accepted answer on that Q&A. The code you've pasted won't help you, and it's already fixed in platform.
  11. Ingo Muschenetz 2013-01-14

    Marking as won't fix based on Varun's link.
  12. Dawson Toth 2013-01-14

    "Won't fix" doesn't help the customers very much. This is a legit issue for them, and "mode_world_readable" was only one solution. Based on the link and my very limited understanding, the customer would need to be able to create their own ContentProviders. Right? Or, someone could write a module (ie the module team) that exposes a static file ContentProvider. The app inits the module with a directory, and we're off.
  13. Dawson Toth 2013-01-15

    It doesn't matter to me. If it matters to Shak, he can do so.
  14. Lee Morris 2017-03-22

    Closing ticket as the issue will not fix and with reference to the above comments.

JSON Source