Convert Figma logo to code with AI

koush logoSuperuser

No description available

1,473
997
1,473
109

Top Related Projects

47,030

The Magic Mask for Android

Notes about tinkering with Android Project Treble

Example code for "How-To SU"

2,582

Island for Android

Gnirehtet provides reverse tethering for Android

Quick Overview

Superuser is an open-source Android application that provides root access management and control for Android devices. It allows users to grant or deny root access to applications, ensuring better security and control over their device's system-level operations.

Pros

  • Root Access Management: Superuser provides a centralized interface to manage and control which applications have root access on the device, enhancing security and preventing unauthorized access.
  • Granular Control: The application allows users to grant or deny root access on a per-application basis, giving them fine-grained control over system-level permissions.
  • Compatibility: Superuser is compatible with a wide range of Android devices and custom ROMs, making it a versatile solution for users with diverse device configurations.
  • Open-Source: The project is open-source, allowing for community contributions, transparency, and the potential for ongoing improvements and bug fixes.

Cons

  • Requires Root Access: Superuser itself requires root access to function, which may be a barrier for some users who are hesitant to root their devices.
  • Potential Stability Issues: As a system-level application, Superuser may occasionally encounter compatibility or stability issues, especially on newer Android versions or with specific device configurations.
  • Limited Customization: While Superuser provides basic root access management, it may lack advanced customization options or features that some users might desire.
  • Potential Security Risks: Granting root access to applications can introduce security risks if not managed properly, and users should exercise caution when allowing root access to untrusted applications.

Getting Started

To get started with Superuser, follow these steps:

  1. Ensure your Android device is rooted and has a compatible root management solution installed (e.g., SuperSU, Magisk).
  2. Download the Superuser application from the Google Play Store or the project's GitHub repository.
  3. Install the Superuser application on your device.
  4. Upon first launch, Superuser will prompt you to grant it root access. Follow the on-screen instructions to provide the necessary permissions.
  5. Once granted root access, Superuser will display a list of installed applications on your device.
  6. You can then manage the root access permissions for each application by tapping on it and selecting "Allow" or "Deny" as needed.
  7. Superuser also provides additional settings and options, such as the ability to log root access requests and configure notification preferences.

Competitor Comparisons

47,030

The Magic Mask for Android

Pros of Magisk

  • More comprehensive root solution with systemless modifications
  • Active development and frequent updates
  • Supports a wide range of Android versions and devices

Cons of Magisk

  • More complex setup and usage for beginners
  • Potential for system instability if not used correctly

Code Comparison

Magisk (build.gradle):

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
    }
}

Superuser (AndroidManifest.xml):

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="17" />

The code comparison shows that Magisk targets more recent Android versions, while Superuser is designed for older devices. This reflects Magisk's active development and broader device support.

Magisk offers a more feature-rich and up-to-date root solution, with systemless modifications that help avoid detection by SafetyNet. However, it may be more challenging for beginners to set up and use compared to Superuser.

Superuser, being an older project, is simpler and more straightforward but lacks some advanced features and may not work on newer Android versions. It's generally easier to use for basic root access needs but has limited functionality compared to Magisk.

Notes about tinkering with Android Project Treble

Pros of treble_experimentations

  • Focuses on Project Treble and Generic System Images (GSIs), enabling broader device compatibility
  • Actively maintained with frequent updates and contributions
  • Provides extensive documentation and guides for custom ROM development

Cons of treble_experimentations

  • More complex and requires deeper technical knowledge to use effectively
  • May have compatibility issues with certain devices or Android versions
  • Less focused on root access management compared to Superuser

Code Comparison

treble_experimentations:

#!/bin/bash

repo init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r43
repo sync -c -j$nproc --force-sync --no-clone-bundle --no-tags
. build/envsetup.sh
lunch aosp_arm64-userdebug
make -j$nproc

Superuser:

public class SuRequestActivity extends Activity {
    private static final String TAG = "SuRequestActivity";
    private static final int REQUEST_CODE = 1;
    private static final String EXTRA_SOCKET = "socket";
}

The code snippets highlight the different focus areas of the projects. treble_experimentations deals with building Android system images, while Superuser manages root access requests.

Example code for "How-To SU"

Pros of libsuperuser

  • More comprehensive library for root-related operations
  • Actively maintained with regular updates
  • Better documentation and examples for developers

Cons of libsuperuser

  • Larger codebase, potentially more complex to integrate
  • May include unnecessary features for simpler root access needs
  • Slightly steeper learning curve for beginners

Code Comparison

Superuser (Shell command execution):

Shell.SU.run("ls -l /data");

libsuperuser (Shell command execution):

Shell.Pool.SU.run("ls -l /data", null, null, false);

Both libraries provide methods for executing shell commands with root privileges, but libsuperuser offers more granular control over the execution process.

Additional Notes

Superuser focuses primarily on managing superuser access, while libsuperuser provides a broader set of tools for root-related operations. Developers should consider their specific needs when choosing between the two libraries. Superuser may be sufficient for basic root access management, while libsuperuser offers more advanced features for complex root-related tasks.

2,582

Island for Android

Pros of Island

  • Focuses on app isolation and privacy, providing a sandboxed environment for apps
  • Supports cloning apps to run multiple instances, useful for work/personal separation
  • Offers more advanced features like app freezing and space management

Cons of Island

  • More complex setup and usage compared to Superuser's straightforward root access management
  • May have compatibility issues with some apps due to its sandboxing approach
  • Less widespread adoption and community support than Superuser

Code Comparison

Island (Java):

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction().add(R.id.container, new MainFragment()).commit();
    }
}

Superuser (Java):

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.request);
    packageName = getIntent().getStringExtra("package");
    requestName = getIntent().getStringExtra("request");
}

Both repositories use similar Android development patterns, but Island's code focuses on fragment management for its more complex UI, while Superuser's code handles intent extras for root access requests.

Gnirehtet provides reverse tethering for Android

Pros of gnirehtet

  • Provides reverse tethering functionality, allowing Android devices to use a computer's internet connection
  • Cross-platform support (Windows, macOS, Linux)
  • Doesn't require root access on the Android device

Cons of gnirehtet

  • More complex setup process compared to Superuser
  • Limited to reverse tethering functionality, while Superuser offers broader root access management
  • Requires running a client application on the computer

Code Comparison

gnirehtet (Rust):

fn relay(tcp_client: TcpStream, selector: &mut Selector) -> io::Result<()> {
    let stream = TcpStream::connect(DEVICE_ADDR)?;
    let (reader, writer) = stream.split();
    relay_streams(tcp_client, reader, writer, selector)
}

Superuser (Java):

public static boolean shellAsync(String shell, String... commands) {
    try {
        Process process = Runtime.getRuntime().exec(shell);
        DataOutputStream os = new DataOutputStream(process.getOutputStream());
        for (String command : commands) {
            os.writeBytes(command + "\n");
            os.flush();
        }
        os.writeBytes("exit\n");
        os.flush();
        return true;
    } catch (Exception e) {
        return false;
    }
}

The code snippets showcase different functionalities: gnirehtet focuses on network relaying, while Superuser handles shell command execution for root access management.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Why another Superuser?

  • Superuser should be open source. It's the gateway to root on your device. It must be open for independent security analysis. Obscurity (closed source) is not security.
  • Superuser should be NDK buildable. No internal Android references.
  • Superuser should also be AOSP buildable for those that want to embed it in their ROM.
  • Superuser should also be AOSP embeddable, meaning a ROM can easily embed it into their Settings app.
  • Maintenance and updates on both the market and source repositories should be timely.
  • I want to be able to point users of my app to a Superuser solution that I wrote, that I know works, and that I can fix if something is wrong.
  • Handle multiuser (4.2+) properly
  • Handle concurrent su requests properly

Translations

Translations are very much appreciated, but please do not submit translations on Github! Instead, use the review submission process on CyanogenMod's gerrit instance.

Checking out the source

You'll need the "Widgets" dependency.

  • $ mkdir /path/to/src
  • $ cd /path/to/src
  • $ git clone git://github.com/koush/Superuser
  • $ git clone git://github.com/koush/Widgets

These repositories do not keep the actual projects in the top level directory. This is because they contain tests, libs, and samples.

Make sure the SDK Platform for API 19 is installed, through the Android SDK Manager. Install NDK Revision 9b from here.

Eclipse

In Eclipse, import Widgets/Widgets and Superuser/Superuser. It should Just Work (TM).

Ant

  • $ mkdir /path/to/src
  • $ cd /path/to/src
  • $ cd Superuser/Superuser

In this directory, create a file called local.properties. This file is used by ant for custom properties. You need to specify the location of the ndk directory and your keystore parameters:

ndk.dir=/Users/koush/src/android-ndk
key.store=/Users/koush/.keystore
key.alias=mykey

If you do not have a release key yet, create one using keytool.

Set up your SDK path (this is the directory containing platform-tools/, tools/, etc.):

  • $ export ANDROID_HOME=/Users/koush/src/sdk

Then you can build:

  • $ ant release

Outputs:

  • bin/update.zip - Recovery installable zip
  • bin/Superuser-release.apk - Superuser Android app
  • libs/armeabi/su - ARM su binary
  • libs/x86/su - x86 su binary
  • libs/mips/su - MIPS su binary

Building the su binary

You can use ant as shown above, to build the binary, but it can also be built without building the APK.

Make sure you have the android-ndk downloaded with the tool "ndk-build" in your path.

  • $ cd /path/to/src/
  • $ cd Superuser/Superuser
  • $ ndk-build

The su binary will built into Superuser/Superuser/libs/armeabi/su.

Building with AOSP, CyanogenMod, etc

ROM developers are welcome to distribute the official Superuser APK and binary that I publish. That will allow them to receive updates with Google Play. However, you can also build Superuser as part of your build, if you choose to.

There are two ways to include Superuser in your build. The easiest is to build the APK as a separate app. To do that, simply add the local_manifest.xml as described below. The second way is by embedding it into the native Android System Settings.

Repo Setup

Add the local_manifest.xml to your .repo/local_manifests

Configuring the Package Name

The Superuser distributed on Google Play is in the package name com.koushikdutta.superuser. To prevent conflicts with the Play store version, the build process changes the package name to com.thirdparty.superuser. You can configure this value by setting the following in your vendor makefile or BoardConfig:

SUPERUSER_PACKAGE := com.mypackagename.superuser

Advanced - Embedding Superuser into System Settings

You will not need to change the package name as described above. Superuser will simply go into the com.android.settings package.

First, in a product makefile (like vendor/cm/config/common.mk), specify the following:

SUPERUSER_EMBEDDED := true

To modify packages/apps/Settings, you will need this patch. The patch simply references the sources checked out to external/koush and makes changes to XML preference files and the AndroidManifest.xml. It is a very minimal change.