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

Inquiry: how does shizuku connect to ADB? #502

Closed
ComputerElite opened this issue May 17, 2024 · 6 comments
Closed

Inquiry: how does shizuku connect to ADB? #502

ComputerElite opened this issue May 17, 2024 · 6 comments

Comments

@ComputerElite
Copy link

Hi, I want to create a own app which connected to the phone via adb so it can modify files in the /Android/data /Android/obb folders so it can backup apps and games and restore them. I couldn't figure out how to connect to adb via my C# xamarin app. So far I tried various nuget packages and invoking the linux adb binary but just got "access denied". Could someone give me insight on how it is done in shizuku?
Thanks!

@petermg
Copy link

petermg commented Jun 13, 2024

Hi, I want to create a own app which connected to the phone via adb so it can modify files in the /Android/data /Android/obb folders so it can backup apps and games and restore them. I couldn't figure out how to connect to adb via my C# xamarin app. So far I tried various nuget packages and invoking the linux adb binary but just got "access denied". Could someone give me insight on how it is done in shizuku? Thanks!

I have this exact feature in my app for the Quest here:
https://github.com/petermg/TheOcularMigraineMCP

@petermg
Copy link

petermg commented Jun 13, 2024

You have to use a wrapper that sets the home directory to a place it has write permissions. Here is the wrapper I use, which I got from XDA:

#!/system/bin/sh
# adb: wrapper to run adb from terminal
# osm0sis @ xda-developers

dir="$(cd "$(dirname "$0")"; pwd)";

export HOME=/sdcard;
export TMPDIR=/sdcard;
$dir/libadb.so "$@";

So this wrapper points to the binary "libadb.so" and when I want to run an adb command I just run this wrapper, which in turn runs the adb binary after settings the home and temp directories.

@petermg
Copy link

petermg commented Jun 13, 2024

Also I learned a lot from this app:
https://github.com/thedroidgeek/oculus-wireless-adb
You can see it has a good adb binary here: https://github.com/thedroidgeek/oculus-wireless-adb/tree/main/app/src/main/jniLibs/arm64-v8a
and it looks like it sets the home and temp directory environment variables here:
https://github.com/thedroidgeek/oculus-wireless-adb/blob/main/app/src/main/java/tdg/oculuswirelessadb/MainActivity.kt
I don't know kotlin but it seems that last file is doing something similar to what the wrapper does as you can see both the "HOME" and "TMPDIR" environment variables referenced in it in lines 240 and 241.

@ComputerElite
Copy link
Author

You still have to pair with the phone over wireless adb, right?

@petermg
Copy link

petermg commented Jun 14, 2024 via email

@ComputerElite
Copy link
Author

Alright. Thank you very much for your help! Have a great day

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

No branches or pull requests

2 participants