I want BOINC (for Android) to run when it is charging through the charger (which connects to my smartphone through a USB cable), but not when it is charging through a power bank (which also connects to my smartphone through a USB cable). Is this possible? If so, how?

I don't think BOINC is coded to distinguish between the two, since for its purposes there's no practical difference in how the charge is coming in, just in how long you expect it to last (a preset amount for power bank vs. wall socket potentially blowing a fuse and cutting off right then....)