public class RootManager
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
boolean |
copyFile(java.lang.String source,
java.lang.String destinationDir)
Copy a file into destination dir.
|
static RootManager |
getInstance() |
boolean |
hasRooted()
Check if the device is rooted
|
boolean |
installBinary(java.lang.String filePath)
Install a binary file into "/system/bin/"
|
Result |
installPackage(java.lang.String apkPath)
Install an app on the device.
|
Result |
installPackage(java.lang.String apkPath,
java.lang.String installLocation)
Install a app on the specific location.
|
boolean |
isProcessRunning(java.lang.String processName)
Check if a process is running.
|
boolean |
killProcessById(java.lang.String processID)
Kill a process by its process id.
|
boolean |
killProcessByName(java.lang.String processName)
Kill a process by its name.
|
boolean |
obtainPermission()
Try to obtain the root access.
|
boolean |
remount(java.lang.String path,
java.lang.String mountType)
Remount file system.
|
boolean |
removeBinary(java.lang.String fileName)
Remove a binary from "/system/bin/"
|
void |
restartDevice()
Restart the device.
|
Result |
runBinary(java.lang.String path)
Run a binary file.
|
Result |
runBinBinary(java.lang.String binaryName)
Run a binary in "/system/bin/"
|
Result |
runCommand(java.lang.String command)
Run raw commands in default shell.
|
boolean |
screenCap(java.lang.String path)
Get screen shot.
|
boolean |
screenRecord(java.lang.String path)
Record screen for 30s.
|
boolean |
screenRecord(java.lang.String path,
long bitRate,
long time)
Record screen.
|
Result |
uninstallPackage(java.lang.String packageName)
Uninstall an app by its package name.
|
Result |
uninstallSystemApp(java.lang.String apkPath)
Uninstall a system app by its path.
|
public static RootManager getInstance()
public boolean hasRooted()
This function check if the system has SU file. Note that though SU file exits, it might not work.
public boolean obtainPermission()
This function might lead to a popup to users, and wait for the input : grant or decline.
public Result installPackage(java.lang.String apkPath)
do NOT call this function on UI thread, IllegalStateException will be thrown
otherwise.
apkPath - the APK file path i.e., "/sdcard/Tech_test.apk" is OK. ASCII is
supported.Result of running the command.public Result installPackage(java.lang.String apkPath, java.lang.String installLocation)
do NOT call this function on UI thread, IllegalStateException will be thrown
otherwise.
apkPath - the APK file path i.e., "/sdcard/Tech_test.apk" is OK. ASCII
is supported.installLocation - the location of this installation.
Result of running the command.public Result uninstallPackage(java.lang.String packageName)
do NOT call this function on UI thread, IllegalStateException will be thrown
otherwise.
packageName - the app's package name.Result of running the command.public Result uninstallSystemApp(java.lang.String apkPath)
do NOT call this function on UI thread, IllegalStateException will be thrown
otherwise.
apkPath - the source apk path of the system app.Result of running the command.public boolean installBinary(java.lang.String filePath)
filePath - The target of the binary file.public boolean removeBinary(java.lang.String fileName)
fileName, - name of target file.public boolean copyFile(java.lang.String source,
java.lang.String destinationDir)
source - the source file path.destinationDir - the destination dir path.public boolean remount(java.lang.String path,
java.lang.String mountType)
path - the path you want to remountmountType - the mount type, including, "ro", read only, "rw" , read and writepublic Result runBinBinary(java.lang.String binaryName)
binaryName - the file name of binary, containing params if necessary.Result of running the command.public Result runBinary(java.lang.String path)
path - the file path of binary, containing params if necessary.Result of running the command.public Result runCommand(java.lang.String command)
command - the command string.Result of running the command.public boolean screenCap(java.lang.String path)
path - the path with file name and extend name.public boolean screenRecord(java.lang.String path)
path - the path with file name and extend name.public boolean screenRecord(java.lang.String path,
long bitRate,
long time)
path - the path with file name and extend name.bitRate - the bate rate in bps, i.e., 4000000 for 4M bps.time - the recording time in secondspublic boolean isProcessRunning(java.lang.String processName)
processName - the name of process. For user app, the process name is
its package name.public boolean killProcessByName(java.lang.String processName)
processName - the name of this process. For user apps, the process
name is its package name.public boolean killProcessById(java.lang.String processID)
processID - PID of the target process.public void restartDevice()