As systemless root is avaible for few years it became "harder" to detect if a device is rooted or not. I started looking for a possible solution to detect if a device is rooted systemlessly or not and I still can't figure out the solution. Checking if the file exists in given paths (in /system) has no point as it can't be there if a device is rooted systemlessly. Also looking for applications that manage root access may have no sense, as user may not have them installed / or just using other, not as popular as Magisk, SuperSu etc.
So, what I thought, is executing "su" command and then checking if the shell is running in root mode ("#") or not("$"). But how can I check in which mode it runs? As far as I know, after simply executing command:
Runtime.getRuntime().exec("su");
Process is being killed because "SU user" is no longer used (?).
Simple view what I mean with adb usage:
user@user:~$ adb shell
device:/ $ su
if after executing this command it becomes:
device:/ #
would know if the device is rooted, if gave back "permission denied" would know that the device is not rooted. Can I achieve something like that in Android application?