1

I found this project which allows me to connect to a WiFi through ADB commands not being a root user. I was wondering if anyone knows how to disconnect also from ADB and not being a root user.

UPDATE:

I've been recently trying:

C:\adb>adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
adb server is out of date.  killing...
* daemon started successfully *
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.wifi.WifiSettings }
Warning: Activity not started, its current task has been brought to the front

and

C:\adb>adb -s serial_number shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.wifi.WifiSettings }
Warning: Activity not started, its current task has been brought to the front

I also found doing this type of command:

adb shell input keyevent 20 & adb shell input keyevent 23

I can navigate and click. The problem seems to be that I always finish in a different state so the next time I input the command

adb -s serial_number shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings

I start in a different place and start clicking elsewhere. I've tried returning home, but that doesn't fix the issue. Is there any way to start always from the same point inside the WiFi settings?

Thanks!

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Firelord
    Apr 4, 2020 at 13:38

1 Answer 1

1

You can use

 adb shell cmd -w wifi connect-network 
command followed by these parameters if needed :

-  connect-network  open|owe|wpa2|wpa3 [] [-m] [-d] [-b ] [-r auto|none|persistent|non_persistent]
    Connect to a network with provided params and add to saved networks list
    open|owe|wpa2|wpa3 - Security type of the network.
     - SSID of the network
        - Use 'open' or 'owe' for networks with no passphrase
           - 'open' - Open networks (Most prevalent)
           - 'owe' - Enhanced open networks
        - Use 'wpa2' or 'wpa3' for networks with passphrase
           - 'wpa2' - WPA-2 PSK networks (Most prevalent)
    -m - Mark the network metered.
           - 'wpa3' - WPA-3 PSK networks
    -d - Mark the network autojoin disabled.
    -h - Mark the network hidden.
    -p - Mark the network private (not shared).
    -b  - Set specific BSSID.
    -r auto|none|persistent|non_persistent - MAC randomization scheme for the network

For example. If you want your device to connect to wifi with ssid home with wpa2 authentication and password as 12345678, you should enter

adb shell cmd -w wifi connect-network home wpa2 12345678

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .