Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: are there limitations of using Shizuku? #15

Closed
AndroidDeveloperLB opened this issue Jul 10, 2022 · 8 comments
Closed

Question: are there limitations of using Shizuku? #15

AndroidDeveloperLB opened this issue Jul 10, 2022 · 8 comments

Comments

@AndroidDeveloperLB
Copy link

AndroidDeveloperLB commented Jul 10, 2022

I've noticed that the demo shows only about getting the instance via SystemServiceHelper.getSystemService .

But what about other types of classes? For example Singleton classes like Runtime , which you need to reach its instance via a static function (Runtime.getRuntime() ) ?

image

And what about classes that need to be instantiated by the library, including those that have multiple arguments for the CTOR (such as ProcessBuilder, which is created via Runtime.getRuntime().exec )?

Are both of these possible to reach?

@RikkaW
Copy link
Member

RikkaW commented Jul 11, 2022

https://github.com/RikkaApps/Shizuku-API/blob/fcb5cdc6b9b683de51fdd330063dd2f85b5d726d/demo/src/main/java/rikka/shizuku/demo/service/UserService.java

You can write ANYTHING in UserService. This is the fifth time I'm talking about this.

RTFM, pls

/**
* User Service is similar to <a href="https://developer.android.com/guide/components/bound-services">Bound Services</a>.
* The difference is that the service runs in a different process and as
* the identity (Linux UID) of root (UID 0) or shell (UID 2000, if the
* backend is Shizuku and user starts Shizuku with adb).
* <p>
* The user service can run under "Daemon mode".
* Under "Daemon mode" (default behavior), the service will run forever
* until you call the "unbind" method. Under "Non-daemon mode", the service
* will be stopped when the process which called the "bind" method is dead.
* <p>
* When the "unbind" method is called, the user service will NOT be killed.
* You need to implement a "destroy" method in your service. The transaction
* code for that method is {@code 16777115} (use {@code 16777114} in aidl).
* In this method, you can do some cleanup jobs and call
* {@link System#exit(int)} in the end.
* <p>
* If the backend is Shizuku, whether in daemon mode or not, user service
* will be killed when Shizuku service is stopped or restarted.
* Shizuku sends binder to all Shizuku apps. Therefore, you only need to
* start the user service again.
* <p>
* <b>Use Android APIs in user service:</b>
* <p>
* There is no restrictions on non-SDK APIs in user service process.
* However, it is not an valid Android application process. Therefore,
* even you can acquire an {@code Context} instance, many APIs, such as
* {@code Context#registerReceiver} and {@code Context#getContentResolver}
* will not work. You will need to dig into Android source code to find
* out how things works, so that you will be able to implement your service
* safely and elegantly.
*
* @see UserServiceArgs
* @since Added from version 10
*/
public static void bindUserService(@NonNull UserServiceArgs args, @NonNull ServiceConnection conn) {

@RikkaW RikkaW closed this as completed Jul 11, 2022
@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Jul 11, 2022

I've asked in other places too, and as opposed to what you guys told me, Shizuku cannot replace su commands to work exactly like on a rooted device:
topjohnwu/libsu#127
https://www.reddit.com/r/android_devs/comments/vvnpgh/is_it_possible_to_use_shizuku_to_replace_general/

As for UserService, I don't understand how to use it. You told me to just check the sample. The sample doesn't reach a class like you've mentioned. It reaches services.

@haruue
Copy link
Member

haruue commented Jul 11, 2022

That is because Shizuku is not designed as an in-place replacement for su.

If you're a developer who only understands shell commands and doesn't have any idea about how those commands work, I'd recommend keeping using libsu for your application. Switch to Shizuku won't make any improvement on your application if you are persistent on just simply executing those commands with Shizuku.

@haruue
Copy link
Member

haruue commented Jul 11, 2022

And using Runtime.exec() would be much slower than libsu if you just want to execute commands.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Jul 11, 2022

@haruue There are some functionalities that rely on having a rooted device. I was hoping this library could help with this, but it's not clear from the repository's description what it can and cannot do.
For me, I thought that it can only do what I could do via adb, because what it uses is adb-wireless.
But as it seems it can do more than what I thought, I thought it's worth asking.
Even for adb commands, though, it could be nice, but for that I also couldn't find a clue about whether I can give it adb commands to be launched.

Whether Shizuku was designed to be a replacement to "su" or not, you told me it's possible, so I wanted to ask further because it's still weird that you can perform all "su" commands on a non-rooted device.
Are you still sure it's possible? Can you reach (read/copy) files on protected files of another app (in "/data/data/package_name_of_another_app/") , for example?
If not, it cannot be a replacement, as opposed to what you guys told me, and it was not a nice thing to close the post claiming that I need to read how to do it, because it's not possible.

As for why I prefer to use commands, it's just that they are already there, so having to handle rooted-device and non-rooted-device would be the same (if it could do what I thought it might be able to do). It's better to start from small and then improve, then to work on almost all of the functions and then figure out in the end (reaching a command that can't be handled) that you won't be able to use this library at all (a huge waste of time).
I also don't mind that it's slower. More important is that it works.

@haruue
Copy link
Member

haruue commented Jul 11, 2022

Can you reach (read/copy) files on protected files of another app (in "/data/data/package_name_of_another_app/") , for example?

Yep, It would be possible to do this with Shizuku, but only for an experienced developer, not for those who cannot understand AIDL and cannot even RTFM.

It's better to start from small and then improve, then to work on almost all of the functions and then figure out in the end.

If you just want to verify if a program works with Shizuku, you can use rish to execute required commands in terminals (such as Termux).

I noticed you said you don't know what is rish in other issues. Please install Termux and setup Shizuku on your device, then use this feature (see the screenshot below) to export a script named rish into Termux storage, and execute the exported script file, you will be dropped into a shell with adb permission. You can run any command to test if it works there.

out

... a huge waste of time

Our time is also not free, and it is not our duty to teach you everything you don't know and help you implement your app hand-by-hand.

@AndroidDeveloperLB
Copy link
Author

@haruue I didn't request anyone to teach me. I only asked a simple yes/no question, and still I haven't gotten a yes/no answer.
I tried to provide examples to explain my question, and instead of answering with yes/no, I am told to look at the sample. I already looked at the sample, and it doesn't show anything similar to what I asked and to what I was told that I can do. It reaches services and not a singleton. It works on functions and not on commands of "su".
If you still want examples of more commands for rooted devices that could be useful (and again, I don't want an answer for each, I want a single yes/no answer that covers all, including beyond the examples):

  1. adb commands such as "am kill", "input swipe", "am start", "pm grant", "input tap", "service call","pm clear", "pm install", "pm install-create", "pm install-commit", "am force-stop", "pm enable", "pm disable", "pm uninstall", "appops set","am compat ", "input keyevent". Example is to turn off the display by the keyevent 26. Such a thing should be possible because the library gets access via adb-wireless.
  2. su commands that should work anywhere as on a rooted device, such as "ls" , "rm", "reboot", "setprop", "mount", "md5sum", "cp", "chmod", "stat".
  3. reaching commands that were added, such as "toolbox" .

I'm sure there are plenty more, and I hope you now understand that it's best to first check if a general solution (which works even on a non-rooted device, yet will give the exact same results as on a rooted device, no matter which arguments I provide to the command) can be used that can cover them all with minimal code (meaning just run the command and give me the output of it), which is what I asked about.

You assume I didn't read but I have.
As for the manual, again, it doesn't show any answer to my question. I also didn't see there an explanation about reaching a Singleton class like Runtime or a CTOR with multiple arguments, and I don't think AIDL can be used for that either.

Are you now saying that on the reddit post and on the libsu post, they are also wrong? If so, it only shows you that like me, people (who most probably have much more knowledge/experience of Shizuku) don't consider Shizuku as one that can fully replace what a rooted device can do using "su" commands., which means the manual isn't sufficient to explain what Shizuku can and cannot do.

@haruue
Copy link
Member

haruue commented Jul 11, 2022

You are blocked from RikkaApps for your stubbornness.
Sorry for wasting your time. Please just use libsu instead.

@RikkaApps RikkaApps locked as resolved and limited conversation to collaborators Jul 11, 2022
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

3 participants