That is the correct way to do it from a security perspective. I
suppose you could get around it by making the app's data directory
world writable - but that's not a good idea for obvious reasons.

On Dec 30, 1:21 pm, cturner <[email protected]> wrote:
> Hi Dave,
> I've been following along here.  I think you're saying  that the only
> way for the native code to create/read/write to files in the private
> directory is by having the Java app pass an open file descriptor to
> the native code.  Is that correct?
>
> Progressive download is one use case, but we have others as well, so I
> want to understand all the possibilities.  Writing files to sdcard is
> not always an acceptable method, since the card can be removed or
> swapped out.
>
> On Dec 30, 10:43 am, Dave Sparks <[email protected]> wrote:
>
> > I think my earlier post was just confusing - sorry about that .I
> > assume we're talking about the text file OpenCore uses for resuming a
> > progressive download.
>
> > If your application wants to allow the media server to write a file in
> > its private directory, it needs to pass in an open file descriptor
> > with write access rights. The media server should then close the fd
> > when it is done, the same way that it works when we pass in an open fd
> > for media playback.
>
> > On Dec 24, 11:05 pm, rktb <[email protected]> wrote:
>
> > > Ok thanks.
>
> > > <waiting for Dave> :-)
>
> > > On Dec 25, 12:01 pm, freepine <[email protected]> wrote:
>
> > > > Hi Ravi,
> > > > I don't have more useful information except the links your are referring
> > > > from android website:( I think Dave might can help to share some 
> > > > resource
> > > > for us.
>
> > > > There was some discussions in the list about granting access permission 
> > > > to
> > > > other applications, which might require delicate solutions and also 
> > > > depends
> > > > on the concrete requirements.
>
> > > > -freepine
>
> > > > On Thu, Dec 25, 2008 at 2:41 PM, rktb <[email protected]> wrote:
>
> > > > > Hi freepine,
>
> > > > > I would like to read more about the permissions and access before
> > > > > posting any educated question. Can you point me to any code or doc? If
> > > > > not, read further for my questions :-)
>
> > > > > Though progressive download is a good example, the files that I am
> > > > > referring to is not media content. The media content, I am almost
> > > > > certain, should be accessed by content providers. What I am talking
> > > > > about is a normal text file that, in this case, stores the state of
> > > > > the download. And, a different app. needs access to this text file.
> > > > > This is the required behavior.
>
> > > > > Thanks,
> > > > > Ravi
>
> > > > > On Dec 25, 10:05 am, freepine <[email protected]> wrote:
> > > > > > I think it depends:).
> > > > > > Are you trying to implement something like progressive download in
> > > > > opencore
> > > > > > player?
> > > > > > If so, I think you might not want to grant the access permission of
> > > > > > downloaded files only to the default music player?
>
> > > > > > Will it be played as ringtone or inserted to MMS? :)
>
> > > > > > -freepine
>
> > > > > > On Thu, Dec 25, 2008 at 12:49 PM, rktb <[email protected]> wrote:
>
> > > > > > > Oh ok.  Thanks freepine !
>
> > > > > > > So, can we summarize that the mediaserver cannot really create a 
> > > > > > > file
> > > > > > > in internal memory. And, the best way to provide a file access is 
> > > > > > > to
> > > > > > > pass it through a file descriptor from the application to the
> > > > > > > mediaserver process.
>
> > > > > > > -Ravi
>
> > > > > > > On Dec 25, 9:11 am, freepine <[email protected]> wrote:
> > > > > > > > I guess it's the java app you are using, i.e. com.android.music
>
> > > > > > > > On Thu, Dec 25, 2008 at 9:57 AM, rktb <[email protected]> wrote:
>
> > > > > > > > > Hi Dave,
>
> > > > > > > > > Sorry...I did not understand completely.
>
> > > > > > > > > What is the native app?
>
> > > > > > > > > -Ravi
>
> > > > > > > > > On Dec 25, 12:34 am, Dave Sparks <[email protected]> 
> > > > > > > > > wrote:
> > > > > > > > > > Hi Ravi,
>
> > > > > > > > > > I think you need to have the native app create the file and 
> > > > > > > > > > pass
> > > > > the
> > > > > > > > > > open file descriptor to the media server. This is how 
> > > > > > > > > > rights are
> > > > > > > > > > conferred from one process to another in the Android 
> > > > > > > > > > security
> > > > > model.
>
> > > > > > > > > > Dave
>
> > > > > > > > > > On Dec 24, 12:58 am, rktb <[email protected]> wrote:
>
> > > > > > > > > > > Hi,
>
> > > > > > > > > > > Need some pointers about file access permissions:
>
> > > > > > > > > > > Here is what I have tried:
>
> > > > > > > > > > > From the Java app., I can create a file in /data/data/
> > > > > > > > > > > <my_package_name>/files/ using the API openFileOutput(). 
> > > > > > > > > > > The
> > > > > > > > > > > permissions of the file is as follows:
> > > > > > > > > > > -rw-rw---- app_10   app_10          0 2008-12-23 09:17
> > > > > > > testFile1.txt
>
> > > > > > > > > > > The files folder itself has the permissions:
> > > > > > > > > > >  drwxrwx--x app_10   app_10            2008-12-23 09:17 
> > > > > > > > > > > files
>
> > > > > > > > > > > When I create a file using native code on /sdcard, the
> > > > > permissions
> > > > > > > are
> > > > > > > > > > > as follows:
> > > > > > > > > > >  ----rw-rw- system   system          0 2008-12-23 09:17
> > > > > > > > > > > fromNativeCode.txt
> > > > > > > > > > > Is it right to say that native code process has "system"
> > > > > rights?
>
> > > > > > > > > > > Now, when I create a file using the Java layer, I can 
> > > > > > > > > > > open the
> > > > > same
> > > > > > > > > > > file for "reading" through native code. But, I cannot 
> > > > > > > > > > > open a
> > > > > file
> > > > > > > in
> > > > > > > > > > > the same place using the native code with "writing" 
> > > > > > > > > > > capability.
> > > > > > >  The
> > > > > > > > > > > permissions of the "files" folder is "app_10", which is 
> > > > > > > > > > > the
> > > > > userID
> > > > > > > of
> > > > > > > > > > > the app. Right? Doesn't "system" trump "app_10" in terms 
> > > > > > > > > > > of
> > > > > > > > > > > permissions?
>
> > > > > > > > > > > In other words, the objective that I am trying to achieve 
> > > > > > > > > > > is to
> > > > > > > create
> > > > > > > > > > > a file inside native code at a place other than sdcard.
> > > > > Preferably,
> > > > > > > > > > > application specific location.
>
> > > > > > > > > > > Any document that anybody could point that would detail 
> > > > > > > > > > > more
> > > > > about
> > > > > > > > > > > security and permissions? I have already readhttp://
> > > > > > > > > code.google.com/android/devel/security.html. But, it does not
> > > > > > > > > > > deal with native code details.
>
> > > > > > > > > > > Thanks,
> > > > > > > > > > > Ravi- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"android-framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/android-framework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to