Android Question Folder - change permissions

stevieg

Member
Licensed User
Longtime User
I am developing apps for industrial tablets that we get from Asia.
Most of them are 7 and 5 inch with android 4.02.

They usually have RFID and Barcode readers built in.

The problem I have is that the manufacturers usually mess up the Android build in one way or another.
A lot of times (almost always) they don't have the Play Store installed on it.

That means that I need to put the GoogleServicesFramework and the com.android.vending apks' in the /system/app folder.

Most of the time I can usually run a root tool and get them in there, but sometimes the root tool doesn't work and when I run adb devices nothing shows up.

Is there some B4A code I can run to change the permissions of the /system/app folder to rw so I can copy the necessary apks' to this folder?

I have run the following code and it does return a listing of the system/app directory.

Dim p As Phone
Dim sb,se As StringBuilder
sb.Initialize
se.Initialize
p.Shell("ls /system/app",Null,sb,se)
Msgbox(sb,"sb")
Msgbox(se,"se")

Unfortunately I am not that familiar with Linux commands so I don't really know what command to issue if it is even possible.

Any help would be greatly appreciated.

Thanks.
 

stevieg

Member
Licensed User
Longtime User
B4X:
chmod 777 /system/app
is the linux command to change the permissions.
I dont think it will work without root though.

Thanks, I tried that, but it didn't work.

I think I will just have to call back China tonite and try and explain to them what they are doing wrong.

They always try and tell me "Just download Snappea, it is the same...."
 
Upvote 0

stevieg

Member
Licensed User
Longtime User
If the devices are rooted then you can run a script as root: Running shell commands as SuperUser

Thank you Erel,

I actually have tried that code as well, but I think my problem is that I am out of my element when it comes to Linux and command line calls.

Here is the code I was trying:

Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int

StdOut.Initialize
StdErr.Initialize

Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")

File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", "chmod 777 /system/app" & CRLF & "mount -o remount" & CRLF & "exit") 'Any commands via crlf, and exit at end

Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr)

Msgbox(StdOut.tostring, "")

The problem that I am faced with is that the /system/app folder is write protected and I am trying to copy the following files from the external sd card to the /system/app folder.

GoogleServicesFramework.apk
com.google.android.gms.apk
com.android.vending.apk

I read the thread for the above code but there wasn't much explanation about it so I am guessing at most of it.

Thanks.
 
Upvote 0

stevieg

Member
Licensed User
Longtime User
Please use [ code ] [ /code ] tags (without spaces) when posting code.

You should also check the result of StdErr. Are there any error messages?

Sorry, I did not know that about the quotes.

There is no message from StdErr.
 
Upvote 0

stevieg

Member
Licensed User
Longtime User
You can try to copy the files from the script with 'cp' command.

I tried using cp and I get the same results, no files and no errors.
I would think that I should have gotten some kind of error?

Here is the code I have in a button click event:
Did I do the
B4X:
correctly?

B4X:
Sub btnCopy_Click

Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Dim file1 As String = "/mnt/sdcardEx/com.android.vending apk.apk"
Dim file2 As String = "/system/app/com.android.vending apk.apk"
   
Dim p As Phone
Dim sb,se As StringBuilder
sb.Initialize
se.Initialize
p.Shell("ls /mnt/sdcardEx",Null,sb,se)

Msgbox(sb,"Files on external sdcard...")
   
StdOut.Initialize
StdErr.Initialize

Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")

File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", "chmod 777 /system/app" & CRLF & "mount -o remount" & "cp " & file1 &" > " &file2 & CRLF & "exit") 'Any commands via crlf, and exit at end 

Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr)

'Msgbox(StdOut.tostring, "")

sb.Initialize
se.Initialize

p.Shell("ls /system/app",Null,sb,se)
Msgbox(sb,"Files in /system/app")

End Sub

Thanks.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…