How to switch(not only on or off) the mobile data and wifi using adb?
By knowing the state I suppose you meant whether at X point of time the Wi-Fi or mobile data is enabled or disabled. This information can be obtained from the dump of connectivity service.
Run this command to get the status of mobile data and Wi-Fi:
adb shell dumpsys connectivity | sed -e '/[0-9] NetworkAgentInfo.*CONNECTED/p' -e '/Tether state:/,/Hardware offload:/p' -n

Example output:

  1 NetworkAgentInfo [WIFI () - 178] CONNECTED/CONNECTED
  5 NetworkAgentInfo [MOBILE (LTE) - 191] CONNECTED/CONNECTED
Tether state:
  rndis0 - TetheredState - lastError = 0
  wlan0 - AvailableState - lastError = 0
  Upstream wanted: true
  Current upstream interface(s): [rmnet_data1]
Hardware offload:

Here:

WIFI means device is connected to a Wi-FI
MOBILE means mobile data is enabled
rndis is interface name of USB tethering
wlan is interface name of Wi-Fi hotspot
TetheredState means tethering for the respective interface is enabled

In your output:

if WIFI term with CONNECTED status is missing, than device is not connected to a Wi-FI
if MOBILE term with CONNECTED status is missing, than mobile device is disabled
if TetheredState is shown for rndis or wlan or both, than respectively, it means USB tethering and Wi-Fi hotspot is/are enabled.


To check whether Wi-Fi radio is enabled or disabled, run this command:
adb shell dumpsys wifi | sed -n 1p

Example output if Wi-Fi is enabled:

Wi-Fi is enabled

enabled would shows as disabled if Wi-Fi radio is disabled.

Similarly, to check if cellular radio has telecom network access, or if it is disabled, run this command:

adb shell dumpsys telephony.registry | grep mServiceState | grep -o "mDataRegState=[()0-9A-Z_]*"

Example output:

mDataRegState=0(IN_SERVICE)
mDataRegState=0(IN_SERVICE)

Here:

IN_SERVICE means your cellular radio or radios (if multiple SIM cards are supported) is connected to a network.
OUT_OF_SERVICE would mean not connected to telecom's network
POWER_OFF would mean device is in Airplane mode.


Combining all these information would help your fully ascertain:

the state of Wi-Fi radio and its connectivity
the state of cellular radio and its internet connectivity
the state of USB and Wi-Fi tethering


Now, you already know how to enable/disable mobile data, USB tethering, and Wi-Fi using svc utility. While I don't know how to easily turn on hotspot, disabling the hotspot is pretty easy. First, enable the Wi-Fi using svc, and then disable it with svc too.
The aforesaid two commands should be sufficient to ascertain the connected status of mobile data, Wi-Fi, Wi-Fi hotspot, and USB tethering.
Note: this solution was tested on a OnePlus 6 running Android 10.