How can I avoid the battery charging when connected via USB? I'm using my Samsung Galaxy S2 for development so I regularly plug it while it's not fully charged, and my phone starts charging over USB. I think this (charging while in use) can affect battery life (is that correct)? Is there any way to avoid charging while the phone is on and connected via USB?
I have an Android 4.0.3 phone without root access so can't test any of this but let me point you to /sys/class/power_supply/battery/ which gives some info/control over charging issues. In particular there is charging_enabled which gives the current state (0 not charging, 1 charging) and may be writable on some phones?

$ adb shell
$ cat /sys/class/power_supply/battery/charging_enabled
1


There is also a file charger_control which sounds promising and is writable by root but I've found no documentation on it.

Someone has requested this feature as an enhancement on the google developer forum but so far without response:
http://code.google.com/p/android/issues/detail?id=30612