Root Access – Root is the user name or account that by default has access to all commands and files on a Linux operating system including Android. It is also referred to as the root account, root user and the superuser.
Root privileges are the powers that the root account has on the system. The root account is the most privileged on the system and has absolute power over it (i.e., complete access to all files and commands). Among root's powers are the ability to modify the system in any way desired and to grant and revoke access permissions (i.e., the ability to read, modify and execute specific files and directories) for other users, including any of those that are by default reserved for root.
Checking for root access:
Since Google doesn’t give or encourage users to gain root access. So we are using 3rd party Library to check for root privileges.
These tools provides rooted developers a standardized set of tools for use in the development of rooted applications
There are 3 tools which are widely used:
· Libsuperuser – For details check this Link (https://github.com/Chainfire/libsuperuser) and (http://su.chainfire.eu/)
· Roottools – For details check this Link (https://github.com/Stericson/RootTools) and (https://github.com/Stericson/RootTools/releases)
· RootShell - It’s the slimmed down library of Roottools. For details check this Link (https://github.com/Stericson/RootTools)
Adding Roottools Library in Android Studio 1.5:
· Download the Roottools library from above link, then extract and paste it into
AndroidStudioProjects\”AppName”\app\libs
· File -> New -> Import Module and select the Module Roottools.
· Then go to File -> Project Structure
· In project Structure go to dependencies tab of our app.
· Click the + (Sign) -> Module Dependencies
· And add the Library Roottools.
Adding gradle dependencies:
· Check if the module is added in the dependencies in build.gradle.
· If it’s not added then add them manually
dependencies {
…….
compile project(':RootTools')
compile project(':RootShell')
}
For full Roottools Documentation please refer to:
https://roottools.googlecode.com/svn-history/r249/trunk/Developmental/doc/com/stericson/RootTools/RootTools.html
We need to check is root access in available or not. So, we are going to use a predefined function available in Rootools
RootTools.isRootAvailable()
This will return a Boolean value.
1. True - Root access available
2. False - No root access available
For eg:
if(RootTools.isRootAvailable()){
//Do Something here
}
else{
//Do Something here
}
Roottools library is licensed under Apache 2.0 and GPLv2 for more information:
https://github.com/Stericson/RootTools/wiki/Licensing
No comments:
Post a Comment