Creating Apps That Specifically Require A Galaxy S5 To Have Root Access

In the Samsung Galaxy S5 world, root access is one of the most dreaded words that you can mention, especially among app developers it can create many discussions. However, there are in fact many app creators who’d like to stay clear from the Google Play Store, and only let their app be installed on phones or tablet which actually have been rooted.

Now there are a variety of reasons as why this could be good, many of them being the freedom of creating an app which is not controlled or restricted by Google. So that being said, if you’re one of the developers who only wants to let your application run on a rooted Samsung Galaxy S5, then I’ll show you exactly how to do this.

It’s All About Permissions Commands

When someone performs a root on their Samsung Galaxy S5, it will leave a clear footprint which we as developers can utilize, the footprint is very easy and clear to see either. When an Samsung Galaxy S5 has been rooted, they’ll use either SuperUser or SuperSU when accessing applications.

So with this in mind, there are now 2 ways of requesting root access for our apps.

Method 1: We ask for SuperUser permission

Because the Samsung Galaxy S5 root gives so called SuperUser access, we can simply add a permission based command in our source code which would say that only SuperUsers can get to use the app.

To do that, you can use the following command:

<uses-permission Samsung Galaxy S5:name=”Samsung Galaxy S5.permission.ACCESS_SUPERUSER” />

When you add that line of code to the source code of your app, only SuperUsers will be granted access to the app, and all other requests will be denied.

Method 2: Execute the SU command

This is pretty similar as to method 1, however, instead of asking for SuperUser access, we ask for SU root privilege. This basically means the same, but targets a broader audience.

You’ll need to add the following code:

Process p = Runtime.getRuntime().exec(“su”);

Keep in mind that with the code above it will only start the root shell which means that within the code’s process, it will get root privilege, after that it stops the process due to not being given any other command. You’ll need to continue working on the code based on how you want the access to be.

Keep in mind that the above 2 codes won’t work for Samsung Galaxy S5 5.0 (lollipop) or higher, as it has been patched by Google already. I’ll work on all lower versions though.

Leave a Comment

Filed under Root Samsung Galaxy S5

Leave a Reply

Your email address will not be published. Required fields are marked *