Hi!
I've a little lost with rooted devices.
I've rooted mi Sony RS T1 ebook reader, and I'm trying to make my lipapa app in a way it can run in this device. I'm having a lot of problems with its android, but worst is I can copy a simple file in a folder.
In this device folders in external sd have root permissions to read, write and execute, and group permissions are the same, but other permissions can't write. I can't change these, nor by the Root Explorer app, nor by Terminal Emulator, nor by B4A and this shell example, making a "chmod 777 /mnt/extsd/folder" in the same way I can launch other commands.
This device has other hell problem: if you try to put in it larger collections of books, it explores every book and, over about 2,000 books, it crashes or makes inestable. So, in order to put all my books (about 14,000), I have to hide them (in a folder with a dot before the name, i.e. ".BOOKS"). But when I try to call my app reader (cool reader), it can't find the book because it's in a hidden folder :BangHead:, so I've to move the selected book to other "visible" folder... But I can't :BangHead::BangHead::BangHead:
The code you have written works with some commands. For example, I can create a new folder (as root; if I try to create it with normal B4A commands it fails, because SD is a rooted device and I can't change it, or I don't know how to change it :signOops
, but it fails with a simple copy command.
I'll show my code:
My "Execute as root" routine. It should execute a single line command passed in the "comando" parameter:
Sub EjecutarRoot (comando As String)
Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Dim Ph As Phone
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", comando & CRLF & "exit") 'Any commands via crlf, and exit at end
StdOut.Initialize
StdErr.Initialize
Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
Msgbox(StdOut.tostring, "")
End Sub
Now, my calling routine:
Sub Test
' First command runs perfectly
EjecutarRoot("mkdir /mnt/extsd/MISLIBROS")
' Second command is ignored
EjecutarRoot("cp /mnt/extsd/kkk.fb2 /mnt/extsd/MISLIBROS/kkk.fb2")
End Sub
File kkk.fb2 exists in /mnt/extsd, and has got read and execution permissions for all users, and write permissions for root and group. Case is correct, file is correct... but Second command doesn't work.
I'm desesperated. Almost every thing I try is wrong with this device, and I don't know too much of linux world nor android world.
Well, I would like to put here my question: Is there a way to execute all the app as root, in order every File.Copy (for example) executes as root as well? If there is, could you be so kind to tell me how could I program it? If it's not possible, could anyone tell me if I'm making any stupid mistake I can't see?
Thank you in advance.
Edit: I forgot mentioning it: If I try a File.MkDir, it doesn't work. The only way I've found to create a folder from B4A in this device is using the EjecutarRoot routine