B4A Library [icefairy333]RootCmd library

this demo is show you how to install an apk in silent method (need root),and you can use it the execute other command:D
demo code
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim rc As RootCmd
   Dim btninstall As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
   btninstall.Initialize("btn")
   btninstall.Text="Install Apk"
   Activity.AddView(btninstall,0,0,-2,-2)
End Sub
Sub btn_Click
   If rc.haveRoot Then
      File.Copy(File.DirAssets,"testapk.apk",File.DirRootExternal,"testapk.apk") 'copy to sdcard because the assets dir is readable only this application
      If rc.InstallApk(File.DirRootExternal&"/testapk.apk") Then
         Msgbox("install ok","success")
      Else
         Msgbox("install error","error")
      End If
   Else
      Msgbox("there is no root!","need Root")
   End If
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
b4aRootCmd
Author: IceFairy333
Version: 1
  • RootCmd
    Methods:
    • InstallApk (apkAbsolutePath As String) As Boolean
      install apk in silent mode(need root)
    • execRootCmd (cmd As String) As String
    • execRootCmdSilent (cmd As String) As Int
    • haveRoot As Boolean
by the way the library is in the zip

If you have benefitted from my work a contribution would be welcome
btn_donateCC_LG.gif
 

Attachments

  • srcdemo.zip
    104.5 KB · Views: 1,126
Last edited:

bluejay

Active Member
Licensed User
Longtime User
Thanks for sharing the library and providing a demo app.

I don't have any rooted phones at the moment since I only develop for non-rooted devices so I have not been able to tested it. The library code looks pretty good.

I think it would be useful for making tools for rooted phones although that means the size of target audience is a bit limited.

Cheers,

bluejay
 

Suntzu

Member
Licensed User
Longtime User
Thanks for the library.

I tried to run a reboot command but it didn't ask a root permission. I'm using Superuser.

Sent from my SAMSUNG-SGH-I717 using Tapatalk 2
 

Suntzu

Member
Licensed User
Longtime User
Yes. I'm on a rooted stock ICS ROM.

Sent from my SAMSUNG-SGH-I717 using Tapatalk 2
 
Last edited:

leongcc

Member
Licensed User
Longtime User
Thanks Fairy,

"InstallApk" works for me.

Could you elaborate the difference between:
◦execRootCmd (cmd As String) As String
◦execRootCmdSilent (cmd As String) As Int

I am guessing one is for command that returns a string and the other for command that returns Int ?
What is the format for the cmd string, could you give an example ?

Thanks again.
 

icefairy333

Active Member
Licensed User
Longtime User
Thanks Fairy,

"InstallApk" works for me.

Could you elaborate the difference between:
◦execRootCmd (cmd As String) As String
◦execRootCmdSilent (cmd As String) As Int

I am guessing one is for command that returns a string and the other for command that returns Int ?
What is the format for the cmd string, could you give an example ?

Thanks again.

something like:cat,cp,mkdir and other shell command
 

FabioG

Active Member
Licensed User
Longtime User
@icefairy333 great job!

it would be nice if it implements the following commands:

FileExist to check if a file exists
DirExist to verify whether a directory exists
cp to copy one or more files
mv to move one or more files
rm to delete one or more files

could you do?

thank you very much
 

philgoodgood

Member
Licensed User
Longtime User
hi

thanks you very much icefairy333
very nice of galaxy note 2 4.1.2 root and SuperUser

i tried the command cp : great! I do not have to make my copy "handmade"

:icon_clap:
 
Top