1

I'm trying to enable and disable Wireguard tunnels through the ADB shell.

I can see the followings actions and receivers are available :

adb:# dumpsys package com.wireguard.android
...
Receiver Resolver Table:
  Non-Data Actions:
      com.wireguard.android.action.SET_TUNNEL_UP:
        4166aa1 com.wireguard.android/.model.TunnelManager$IntentReceiver filter 631a6bf
          Action: "com.wireguard.android.action.REFRESH_TUNNEL_STATES"
          Action: "com.wireguard.android.action.SET_TUNNEL_UP"
          Action: "com.wireguard.android.action.SET_TUNNEL_DOWN"
      com.wireguard.android.action.REFRESH_TUNNEL_STATES:
        4166aa1 com.wireguard.android/.model.TunnelManager$IntentReceiver filter 631a6bf
          Action: "com.wireguard.android.action.REFRESH_TUNNEL_STATES"
          Action: "com.wireguard.android.action.SET_TUNNEL_UP"
          Action: "com.wireguard.android.action.SET_TUNNEL_DOWN"
      com.wireguard.android.action.SET_TUNNEL_DOWN:
        4166aa1 com.wireguard.android/.model.TunnelManager$IntentReceiver filter 631a6bf
          Action: "com.wireguard.android.action.REFRESH_TUNNEL_STATES"
          Action: "com.wireguard.android.action.SET_TUNNEL_UP"
          Action: "com.wireguard.android.action.SET_TUNNEL_DOWN"
      android.intent.action.BOOT_COMPLETED:
        4f4cb74 com.wireguard.android/.BootShutdownReceiver filter 426c4de
          Action: "android.intent.action.ACTION_SHUTDOWN"
          Action: "android.intent.action.BOOT_COMPLETED"
      android.intent.action.ACTION_SHUTDOWN:
        4f4cb74 com.wireguard.android/.BootShutdownReceiver filter 426c4de
          Action: "android.intent.action.ACTION_SHUTDOWN"
          Action: "android.intent.action.BOOT_COMPLETED"
...

Looking at the package's sourcecode, I see that com.wireguard.android/.model.TunnelManager$IntentReceiver asks for the name of the tunnel to enable/disable to be passed as an extra string :

 val tunnelName = intent.getStringExtra("tunnel") ?: return@launch
 val tunnels = manager.getTunnels()
 val tunnel = tunnels[tunnelName] ?: return@launch

So I tried two different versions of the same command to enable a tunnel named my-tunnel :


adb:# am broadcast -a com.wireguard.android.action.SET_TUNNEL_UP -e tunnel my-tunnel
Broadcasting: Intent { act=com.wireguard.android.action.SET_TUNNEL_UP flg=0x400000 (has extras) }
Broadcast completed: result=0
# am broadcast -a com.wireguard.android.action.SET_TUNNEL_UP -e tunnel my-tunnel -n com.wireguard.android/.model.TunnelManager$IntentReceiver                                                    
Broadcasting: Intent { act=com.wireguard.android.action.SET_TUNNEL_UP flg=0x400000 cmp=com.wireguard.android/.model.TunnelManager (has extras) }
Broadcast completed: result=0

But after checking on my phone my-tunnel is still disabled.

What am I missing ? Note that I'm pretty new to using ADB commands so it might be something obvious.

3
  • When calling a Intent/Broadcast via adb and am then actual code is executed asynchronously, therefore you never get an result. Effectively this means the result code you see is meaningless. – Robert Dec 16 '20 at 11:46
  • Good to know ! I edited my question in accordance. – Barahir Dec 16 '20 at 15:51
  • could you solve the problem? I am trying to do the same with a Fire TV Stick but had no success so far. – Raspy Mar 10 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.