[Zenfone 2 Laser Android Development] Twiiiiin:
You should have a shell opened. while you're in twrp you can open adb on your computer, connect the phone and insert "adb shell" command, it will open a terminal where you have to paste that command. Termux is only the name of a terminal emulator which runs in android.

EDIT: i managed to grab a logcat on original cm for headset plug/unplug, [MENTION=5181349]OP[/MENTION] can you look at this and see if it's helpful?

06-26 18:06:18.249 1435 2930 V WiredAccessoryManager: notifyWiredAccessoryChanged: when=1239489175000 bits=SW_HEADPHONE_INSERT SW_MICROPHONE_INSERT mask=94
06-26 18:06:18.249 1435 2930 V WiredAccessoryManager: newName=h2w newState=1 headsetState=1 prev headsetState=0
06-26 18:06:18.250 1435 2930 I WiredAccessoryManager: MSG_NEW_DEVICE_STATE
06-26 18:06:18.250 1435 1435 V WiredAccessoryManager: headsetName: connected
06-26 18:06:18.253 292 2360 I AudioFlinger: openOutput(), module 1 Device 4, SamplingRate 8000, Format 0x000001, Channels 1, flags 801
06-26 18:06:18.253 292 2360 D audio_hw_primary: adev_open_output_stream: enter: sample_rate(8000) channel_mask(0x1) devices(0x4) flags(0x801) stream_handle(0xeffb33c0)
06-26 18:06:18.254 292 2360 W audio_hw_utils: audio_extn_utils_update_stream_app_type_cfg: App type could not be selected. Falling back to default
06-26 18:06:18.254 292 2360 E audio_hw_primary: adev_open_output_stream: Primary output is already opened
06-26 18:06:18.254 292 2360 D audio_hw_primary: adev_open_output_stream: exit: ret -17
06-26 18:06:18.254 292 2360 I AudioHwDevice: openOutputStream(), HAL returned sampleRate 8000, Format 0x1, channelMask 0x1, status -17
06-26 18:06:18.254 292 2360 W APM::AudioPolicyManager: checkOutputsForDevice() could not open output for device 4
06-26 18:06:18.254 292 2360 I AudioFlinger: openOutput(), module 1 Device 4, SamplingRate 8000, Format 0x1000000, Channels 1, flags 31
06-26 18:06:18.254 292 2360 D audio_hw_primary: adev_open_output_stream: enter: sample_rate(8000) channel_mask(0x1) devices(0x4) flags(0x31) stream_handle(0xeffb33c0)
06-26 18:06:18.255 292 2360 W audio_hw_utils: audio_extn_utils_update_stream_app_type_cfg: App type could not be selected. Falling back to default
06-26 18:06:18.255 292 2360 D audio_hw_primary: adev_open_output_stream: Stream (0xeffb33c0) picks up u18.07 26/06/2016secase (compress-offload-playback)
06-26 18:06:18.255 292 2360 I AudioFlinger: AudioStreamOut::open(), mHalFormatIsLinearPcm = 0
06-26 18:06:18.256 292 2360 I AudioFlinger: HAL output buffer size 65536 frames, normal sink buffer size 65536 frames
06-26 18:06:18.258 292 8681 I AudioFlinger: AudioFlinger's thread 0xe7b53000 ready to run
06-26 18:06:18.258 292 2325 D audio_hw_primary: adev_set_parameters: enter: connect=4
06-26 18:06:18.259 292 2325 E bt_a2dp_hw: adev_set_parameters: ERROR: set param called even when stream out is null
06-26 18:06:18.262 292 8681 D audio_hw_primary: out_set_parameters: enter: usecase(3: compress-offload-playback) kvpairs: closing=true
06-26 18:06:18.265 292 2360 D audio_hw_primary: out_set_parameters: enter: usecase(3: compress-offload-playback) kvpairs: exiting=1
06-26 18:06:18.268 292 2360 D audio_hw_primary: adev_close_output_stream: enter:stream_handle(0xeffb33c0)
06-26 18:06:18.268 292 2360 D audio_hw_primary: out_standby: enter: stream (0xeffb33c0) usecase(3: compress-offload-playback)
06-26 18:06:18.269 292 8679 E audio_hw_primary: offload_thread_loop: Compress handle is NULL
06-26 18:06:18.280 3448 3448 I HeadsetService: Headset=true; Bluetooth=false ; USB=false; Speaker=false; Line out=false
06-26 18:06:18.284 3448 3448 I HeadsetService: Preferences updated.
06-26 18:06:18.290 292 292 D audio_hw_primary: adev_open_input_stream: enter: sample_rate(48000) channel_mask(0xc) devices(0x80000010) stream_handle(0xeff29400) io_handle(70)
06-26 18:06:18.295 292 2325 D audio_hw_primary: adev_set_parameters: enter: connect=-2147483632
06-26 18:06:18.296 292 2325 E bt_a2dp_hw: adev_set_parameters: ERROR: set param called even when stream out is null
06-26 18:06:18.296 292 8682 I AudioFlinger: AudioFlinger's thread 0xec400000 ready to run
06-26 18:06:18.296 292 8682 D audio_hw_primary: in_standby: enter: stream (0xeff29400) usecase(7: audio-record)
06-26 18:06:18.305 292 8682 D audio_hw_primary: in_standby: enter: stream (0xeff29400) usecase(7: audio-record)
06-26 18:06:18.306 292 292 D audio_hw_primary: adev_close_input_stream: enter:stream_handle(0xeff29400)
06-26 18:06:18.306 292 292 D audio_hw_primary: in_standby: enter: stream (0xeff29400) usecase(7: audio-record)
06-26 18:06:18.317 3448 3448 I HeadsetService: Headset=true; Bluetooth=false ; USB=false; Speaker=false; Line out=false
06-26 18:06:20.205 1435 2914 I Sensors : HAL: SMD detected
06-26 18:06:20.228 1435 2930 V WiredAccessoryManager: notifyWiredAccessoryChanged: when=1241468693000 bits= mask=94
06-26 18:06:20.228 1435 2930 V WiredAccessoryManager: newName=h2w newState=0 headsetState=0 prev headsetState=1
06-26 18:06:20.229 1435 2930 I WiredAccessoryManager: MSG_NEW_DEVICE_STATE
06-26 18:06:20.229 1435 1435 V WiredAccessoryManager: headsetName: disconnected
06-26 18:06:20.229 1435 1435 D AudioService: checkSendBecomingNoisyIntent update the noise
06-26 18:06:20.255 7825 7825 W WakefulBroadcastReceiver: No active wake lock id #5
06-26 18:06:21.235 292 2325 D audio_hw_primary: adev_set_parameters: enter: disconnect=4
06-26 18:06:21.235 292 2325 E bt_a2dp_hw: adev_set_parameters: ERROR: set param called even when stream out is null
06-26 18:06:21.249 3448 3448 I HeadsetService: Headset=false; Bluetooth=false ; USB=false; Speaker=true; Line out=false
06-26 18:06:21.256 3448 3448 I HeadsetService: Preferences updated.
06-26 18:06:21.266 292 2325 D audio_hw_primary: adev_set_parameters: enter: disconnect=-2147483632
06-26 18:06:21.266 292 2325 E bt_a2dp_hw: adev_set_parameters: ERROR: set param called even when stream out is null
06-26 18:06:21.275 3448 3448 I HeadsetService: Headset=false; Bluetooth=false ; USB=false; Speaker=true; Line out=false