jeudi 2 août 2018

How to set USB Tethering automatically when plugged in (android 8.1)

I'm going to create a background service (or whatever else) to enable USB tethering to share 4G internet on my pc automatically when the phone is plugged in.

I have a OP5 (Android 8.1) with root.

I tried Automate app, but it doesn't work (getting an exception when the task try to enable tether usb)

I tried to call "setUsbTethering" by reflection, I got an InvocationTargetException due to "MANAGE_USB" permission, i tried to grant this permission, but it seems that require to enumerate devices and when i try to get devices using "getDeviceList" the result is empty.

Last thing, after some research some people did the trick by shell command like "service call connectivity CODE i32 1" but the code seems to be different according version (30, 32 or 33) from internal aidl file.

So, I finally decided to ask some help since I don't have many knowledges about android core and advanced things, any suggestion or help to achieve this will be apprecied.





Aucun commentaire:

Enregistrer un commentaire