Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android using Super User Permissions ? allowing access

Tags:

android

im trying to find the method behind having superuser access on android devices. basically i want my app to be able to remove system files, and so asking the user if its ok after the app is launched like most other apps, and then what code exactly am i looking to use to perform these sorts of actions? cant find much on google

thanks in advance!

like image 356
sg86- Avatar asked Sep 06 '10 18:09

sg86-


People also ask

What is super user permission in Android?

SuperSU controls which other apps on your phone get root permissions. Whenever an app wants to request root permissions, it has to ask your SuperSU app, which will show a request prompt.

What app permissions should I not allow?

These “dangerous” permissions include access to your calling history, private messages, location, camera, microphone, and more. These permissions are not inherently dangerous, but have the potential for misuse. That's why Android gives you the opportunity to accept or refuse them.


2 Answers

If the device is rooted, you can use the following code to gain access to a root shell:

    try
    {
        Process process = Runtime.getRuntime().exec("su");
        DataOutputStream outputStream = new DataOutputStream(process.getOutputStream()); 
        DataInputStream inputStream = new DataInputStream(process.getInputStream());

        outputStream.writeBytes(command + "\n");
        outputStream.flush();

        outputStream.writeBytes("exit\n"); 
        outputStream.flush(); 
        process.waitFor();
    }
    catch (IOException e)
    {
        throw new Exception(e);
    }
    catch (InterruptedException e)
    {
        throw new Exception(e);
    }

Where "command" is the command that you want to execute.

like image 76
Blu Dragon Avatar answered Nov 30 '22 03:11

Blu Dragon


If I'm getting it right you want to grant your application root privileges. This is not possible with the standard Android image which is installed on the devices. The su command does not support changing to root.

You can however load a customized rooted ROM on your device other than that I'm afraid there is no solution.

like image 26
Octavian A. Damiean Avatar answered Nov 30 '22 03:11

Octavian A. Damiean