I am pretty sure it's possible as I successfully got same from termux Android app where I installed nmap and ran following commands:
- Run
ifconfig
first and get the device IP (xxx.xxx.xxx.x
) - Run
nmap -sn xxx.xxx.xxx.x/24
Note: the device was not rooted and it even works in airplane mode.
Testing device: Android version 11, Samsung Galaxy m30s
I tried official Android docs for usb overview (usb manager, usbdevicce, etc.) and even running command line inside my app but wasn't successful (however I was able to do ssh once I know the ip address through command line).