Estoy tratando de activar y desactivar los túneles Wireguard a través de la shell ADB.
Puedo ver las siguientes acciones y receptores están disponibles :
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"
...
Mirando a el código fuente del paquete Veo que com.wireguard.android/.model.TunnelManager$IntentReceiver
pide que se pase el nombre del túnel a activar/desactivar como una cadena extra :
val tunnelName = intent.getStringExtra("tunnel") ?: return@launch
val tunnels = manager.getTunnels()
val tunnel = tunnels[tunnelName] ?: return@launch
Así que probé dos versiones diferentes del mismo comando para habilitar un túnel llamado 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
Pero después de comprobar en mi teléfono my-tunnel
sigue desactivado.
¿Qué me falta? Tenga en cuenta que soy bastante nuevo en el uso de comandos ADB por lo que podría ser algo obvio.