I doubt that he did it on his own initiative. This ship of his is specially made for this type of recovery and he was shadowing the Americans for several days at least. 

Either the Chinese were not convinced that this drone is strictly civilian in nature OR they really wanted to tweak Trump's nose over his calls to Taiwan.