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

Launch service over adb? #34

Open
pmeenan opened this issue Jun 6, 2017 · 4 comments
Open

Launch service over adb? #34

pmeenan opened this issue Jun 6, 2017 · 4 comments

Comments

@pmeenan
Copy link

pmeenan commented Jun 6, 2017

Is it possible to start the service directly without requiring physically detaching and re-attaching the USB cable?

In an automated lab environment we may be rebooting devices remotely and managing the state of the device over adb and it is pretty critical to be able to start/stop remotely. It feels like I'm pretty close but may be missing something:

$ adb shell am startservice com.viper.simplert/.TetherService
Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.viper.simplert/.TetherService }
Error: Requires permission android.permission.BIND_VPN_SERVICE
$ adb shell pm grant com.viper.simplert android.permission.BIND_VPN_SERVICE
Operation not allowed: java.lang.SecurityException: Package com.viper.simplert has not requested permission android.permission.BIND_VPN_SERVICE

Stopping it remotely (and cleanly) is pretty easy:

adb shell am force-stop com.viper.simplert
@vvviperrr
Copy link
Collaborator

Hi. i suppose, it's possible. Give me some time to research this issue

@pmeenan
Copy link
Author

pmeenan commented Jun 7, 2017

FWIW, gnirehtet uses a control service with .START and .STOP intents

In the meantime, it's a bit ugly but setting the usb config will toggle the interface and start the VPN:

adb shell su -c 'setprop sys.usb.config adb'

The VPN confirmation dialog can also be detected:

dumpsys window windows | grep vpndialogs

and dismissed:

adb shell input keyevent KEYCODE_DPAD_RIGHT
adb shell input keyevent KEYCODE_ENTER
adb shell input keyevent KEYCODE_DPAD_RIGHT
adb shell input keyevent KEYCODE_ENTER

I need to test a couple different releases to see if the permissions dialog is the same but it looks like it is at least possible. It's a shame that the dialog comes up after every reboot.

That said, it would be a lot cleaner if:

  • The permissions could be granted once (bonus points if they could be granted over adb but even once manually isn't too bad)
  • The service could be started and stopped manually over adb with intents

@robinpaulson
Copy link
Owner

@pmeenan How are you getting on with this? Have you found any further info, or a suitable workaround? Or anything else relevant?

@pmeenan
Copy link
Author

pmeenan commented Sep 30, 2021

I went a different path and updated a fork of vpn-reverse-tether

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

3 participants