As someone who has had a moderate amount of contact with members of the law-enforcement profession, I would give this advice:
Be polite.
Keep your hands where he can easily see them. (On the upper rim of the steering wheel is best.)
Do nothing until he asks you to.
Ask before reaching into a hidden location (glove compartment or pocket) and explain what you are about to do (getting driver's license or registration).
If he plans to frisk you, let him know in advance what he will find (Jack-knife in back pocket; vaping case in left pocket; pistol in a shoulder holster.) They DON'T like surprises.
Never forget: these guys all have a friend or someone they know about who has been attacked, or maybe even killed, during a stop. A stop is a HUGELY stressful event that they go through many times a day. They are on a hair trigger, and if they are provoked or frightened by something you do, they will react badly. (I probably would myself.)
Making things as easy and un-stressful as possible will go a LONG way towards making the outcome turn out in your favor. I have been clearly in the wrong many times, and drove away with no more than a warning by following the advice above. As a younger man, I got a lot of traffic tickets (and was arrested once) for lesser offenses by NOT following the above advice.
This is not to say that there are no corrupt or power-hungry cops, but even the best can react badly to someone who frightens them