Giter VIP home page Giter VIP logo

Comments (6)

victorlapin avatar victorlapin commented on August 31, 2024

Shell.isRootAvailable()

from libsu.

victorlapin avatar victorlapin commented on August 31, 2024

Understand though, that the only way to check for root is to try to get su access, it's not a proper runtime permission

from libsu.

gurupras avatar gurupras commented on August 31, 2024

I see a Shell.rootAccess(), is this what you're referring to? Also, just for clarification, does this check whether the device has root or whether the app has root privileges?

from libsu.

victorlapin avatar victorlapin commented on August 31, 2024

Shell.rootAccess() is the instance method, Shell.isRootAvailable() is static

from libsu.

topjohnwu avatar topjohnwu commented on August 31, 2024

@gurupras when you use Shell.rootAccess(), it will actually request a root shell (execute su), and cache the result in the container. Unfortunately, there is no way to know whether root is available until you actually request for it.
You can check the availability of the su command, but there is no way to know whether it actually works or not (e.g. user denies root access by default)

from libsu.

smichel17 avatar smichel17 commented on August 31, 2024

You can check the availability of the su command

As I understand it, the way to do this would be to open a new non-root shell and then run command -v su or similar? Would you consider adding a utility function to avoid this boilerplate? Something like boolean deviceIsLikelyRooted().

The main use case is communicating to users of non-rooted devices that certain functionality will not work, without throwing up an unnecessary permission request on rooted devices (it irritates me when apps do this; I don't want to grant permissions until they're needed for something). No fancy tricks — I am not looking to detect root functionality if the user wants to hide it from me :)

from libsu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.