SC20 Android 7.1 3pin audio jack detection problems

Hello! How to organize 3 pin audio jack headphone detection?

Can you tell me how the 3 pin audio jack headphone is defined. Generally, the headphone socket has a switch. It is recommended to use the normally open type. When the headphone is plugged in, the switch is closed and connected to the ground terminal.
Use this switch to detect whether the headset is plugged in