I would like to know if is it possible to connect my smartphone to a pc via USB without charging it?
It would be very useful to be able to disable charging (but still allow USB tethering, ADB debugging, file transfer etc).
Thanks a lot.
You can try these solutions, which directly address what you are trying to achieve (may not work on all devices)
Adb shell echo 0 > /sys/class/power_supply/battery/charging_enabled (1 to disable; 0 to enable)
Disable USB charging
If these methods don't work or you want to explore more possibilities, see methods below, which can offer you clues
On your Device:
As suggested by Firelord. Be aware that you would need time in identifying the right file to change values to fool the system. Naming of files related to this is apparently not standardised. One of the answers in the link is mine so I am talking from experience.
You could also see this for another way it has been done https://stackoverflow.com/questions/11698979/how-to-change-android-usb-connect-mode-to-charge-only
On your PC: You have not mentioned your PC configuration, but these have been successfully tried add may give you pointers
Yup, you should be able to use the adb command. Or use an app I just released to disable usb charging in Android phone. Has not been tested on Samsung j7 though.
It needs root access.