My screen got broken and I've been using my phone with a VNC Server installed on it, but this morning i'd the stupid idea of enable hotspot just to see if I can use my mobile data plan on my laptop, but when I did this, the wi-fi got disconnected from my router and now i only have access to my phone using adb shell.
I need to disable hotspot from ADB, already searched on google but didn't find anything, i also tried disable and enabling wi-fi, doesn't works.
Answer
A cleaner way to do it is by calling "service call" command.
For example on my phone I could call
# Start Wifi tethering
adb shell service call connectivity 24 i32 0
# Stop Wifi tethering
adb shell service call connectivity 25 i32 0
Service call
will call the function number 24
in connectivity service (which happened to be the function that turn on tethering) and pass it 0
as argument (0
would be wi-fi tethering, 1 would be usb tethering and 2
would be bluetooth).
Sadly service functions code change from one android version to another. This stackoverflow reply explain how to get the right function code for your current android version. https://stackoverflow.com/questions/20227326/where-to-find-info-on-androids-service-call-shell-command
Also this is the functions list for connectivity service for the android version I am using (Nougat) https://android.googlesource.com/platform/frameworks/base/+/android-7.1.2_r1/core/java/android/net/IConnectivityManager.aidl
No comments:
Post a Comment