A is Pilot in Command, whoever is handling the controls - if that is what was agreed and in the tech log.
In most national legal regimes, there is no reason why a passenger cannot manipulate the controls. They can't log it unless A was an instructor, and if they crashed it, A is responsible for that - so A needs to take every reasonable action to ensure that doesn't happen.
If he was flying illegally, he was flying as pilot in command illegally. But still pilot in commend.
G