My girlfriend's chihuahua is generally very protective with his uneaten food, or when he has a bone to play with; which is fine as long as he doesn't bite for it (and he doesn't, he just growls). He already knows me for quite a while and I think that generally we made very good friends, I walk him out, we play together, he comes and cuddles to give me the good-morning whenever I wake up, and he sleeps with us at night.
The main issue is his aggressiveness at night. Whenever I wake up and go to bathroom at night, I am sure he notices and wakes up. So when I am coming back and I am approaching the bed, he suddenly snaps and tries to attack me, and when given the chance might try to bite me, regardless if my girlfriend is asleep or not. I don't know what to do.
P.S. He is almost never aggressive when we are in the bed, unless of course bothered too much.
P.P.S I firstly thought he might be aggressive because I startle him or wake him up suddenly, but I'm not sure this is the case, because when I go to the bathroom at first he is completely quiet, and I am sure he notices it. So when he attacks, he's already awake.
P.P.P.S He has similar behaviour whenever he is relaxing with the owner (my girlfriend) in the bed, or when he is sitting and cuddling with her during the day (while more rarely)
Am I doing something wrong, or he thinks he's the king and I need to show him I am not a threat?