Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

does installing this ramkdisk.img allow us to call "su" runtime on Android? #49

Closed
davidjuhyung opened this issue Dec 7, 2022 · 2 comments

Comments

@davidjuhyung
Copy link

davidjuhyung commented Dec 7, 2022

I follow the instructions exactly the same, and I was able to get everything right correctly.

The proof is that when I run su inside adb shell I see the $ changes to # and see the toast on Android Emulator saying the rights have been granted:

Screen Shot 2022-12-07 at 4 44 39 PM

However, when I run the following piece of code in Java,

try {
    Process p = Runtime.getRuntime().exec("su");
    DataOutputStream dos = new DataOutputStream(p.getOutputStream());
    dos.writeBytes("mkdir /sdcard/testdir\n");
    dos.writeBytes("exit\n");
    dos.flush();
    dos.close();
    p.waitFor();

} catch (IOException | InterruptedException e) {
    Log.d("MyNotificationListenerService", "Error 1");
    e.printStackTrace();
}

While I do not get any error, I do not see the testdir created. I do not even see the toast message. Basically, everything's bypassed with no error thrown. While this co

The emulator used:
Screen Shot 2022-12-07 at 4 45 30 PM

Note it uses Google Play Store, not Google Play API.

I am not sure if this is possible in the first place, I see lots of mixed results, some people saying they got it, some people saying they didn't.

I would appreciate any help to get me out of this sick rabbithole!

@newbit1
Copy link
Owner

newbit1 commented Dec 7, 2022

Hi @davidjuhyung,
I am glade it worked for you. Yes, using this script on a Google Play Store AVD Image makes the most sense.

Regarding your title-question:
does installing this ramkdisk.img allow us to call "su" runtime on Android?
Yes, this is the whole point of installing Magisk into the AVD, so that whatever apk can access su.

Unfortunately, I can not really help you with your issue, it is quite a bit off topic here. But I can tell you some of my
experiences I made while I was writing an apk.

I had to study the work "How-To SU" from the on only @Chainfire himself.
With his examples and explanations for his libsuperuser I was able to get su access in my apk.

If you just read his readme, he will point you to his "old" page http://su.chainfire.eu/, and further on
to TopJohnWu's libsu

Regarding your directory that isn't created. As far as I know, every apk must have some permissions to access
the sdcard. And for that, you need to implement a routine that checks and asks the user for this permissions.
For a quick and dirty solution, it might be possible to grant these permissions via the apk settings in the system.
Like shown here, yes it is from Android 6, but it is still the
same way and principe today. And with a bit more detailed information on how to get there, here.

Good Luck

@davidjuhyung
Copy link
Author

Thank you!! I will look into the documents you've shared! I would really hope to make it work!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants