OK, I re-run scenario 2 and accept the phone call on hikey, then it works fine.
For scenario 1, I got following messages without grep:
01-25 01:16:19.365 7237 8368 W AudioSystem: AudioFlinger server died!
01-25 01:16:19.365 8379 8391 W AudioSystem: AudioFlinger server died!
01-25 01:16:19.365 2098 2098 I ServiceManager: service 'media.audio_flinger' died
01-25 01:16:19.365 7237 7755 W SoundTrigger: Sound trigger service died!
01-25 01:16:19.365 7237 7248 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 2098 2098 I ServiceManager: service 'media.audio_policy' died
01-25 01:16:19.365 2098 2098 I ServiceManager: service 'media.sound_trigger_hw' died
01-25 01:16:19.365 8379 8434 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 7178 7215 W AudioSystem: AudioFlinger server died!
01-25 01:16:19.365 7178 7178 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 7358 7558 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 7387 7407 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.366 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:19.366 7237 7318 E AudioService: Audioserver died.
01-25 01:16:19.869 7237 7318 E AudioService: Audioserver died.
01-25 01:16:20.368 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:20.371 7237 7318 E AudioService: Audioserver died.
01-25 01:16:20.698 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:20.699 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:20.874 7237 7318 E AudioService: Audioserver died.
01-25 01:16:21.371 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:21.374 7237 7318 E AudioService: Audioserver died.
01-25 01:16:21.877 7237 7318 E AudioService: Audioserver died.
01-25 01:16:22.373 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:22.380 7237 7318 E AudioService: Audioserver died.
01-25 01:16:22.694 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:22.695 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:22.883 7237 7318 E AudioService: Audioserver died.
01-25 01:16:23.376 7237 7237 W AudioSystem: AudioPolicyService not published, waiting...
01-25 01:16:23.386 7237 7318 E AudioService: Audioserver died.
01-25 01:16:23.877 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:23.888 7237 7318 E AudioService: Audioserver died.
01-25 01:16:24.389 7237 7318 E AudioService: Audioserver died.
01-25 01:16:24.688 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:24.688 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:24.878 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:24.892 7237 7318 E AudioService: Audioserver died.
01-25 01:16:25.395 7237 7318 E AudioService: Audioserver died.
01-25 01:16:25.879 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:25.899 7237 7318 E AudioService: Audioserver died.
01-25 01:16:26.401 7237 7318 E AudioService: Audioserver died.
01-25 01:16:26.834 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:26.834 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:26.880 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:26.904 7237 7318 E AudioService: Audioserver died.
01-25 01:16:27.870 7237 7249 I Telecom : Event: RecordEntry TC@1: REQUEST_DISCONNECT, null: ICA.dC(InCall package: com.android.car.dialer)@ADI
01-25 01:16:27.870 7237 7249 I Telecom : Call: Send disconnect to connection service for call: [TC@1, ACTIVE, com.android.bluetooth/.hfpclient.connserv.HfpClientConnectionService, tel:**********, A, childs(0), has_parent(false), [Capabilities: CAPABILITY_SUPPORT_HOLD CAPABILITY_MUTE], [Properties:]]: ICA.dC(InCall package: com.android.car.dialer)@ADI
01-25 01:16:27.405 7237 7318 E AudioService: Audioserver died.
01-25 01:16:27.871 8379 8379 D BluetoothHeadsetClient: terminateCall()
01-25 01:16:19.365 7237 8368 W AudioSystem: AudioFlinger server died!
01-25 01:16:19.365 8379 8391 W AudioSystem: AudioFlinger server died!
01-25 01:16:19.365 2098 2098 I ServiceManager: service 'media.audio_flinger' died
01-25 01:16:19.365 7237 7755 W SoundTrigger: Sound trigger service died!
01-25 01:16:19.365 7237 7248 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 2098 2098 I ServiceManager: service 'media.audio_policy' died
01-25 01:16:19.365 2098 2098 I ServiceManager: service 'media.sound_trigger_hw' died
01-25 01:16:19.365 8379 8434 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 7178 7215 W AudioSystem: AudioFlinger server died!
01-25 01:16:19.365 7178 7178 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 7358 7558 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.365 7387 7407 W AudioSystem: AudioPolicyService server died!
01-25 01:16:19.366 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:19.366 7237 7318 E AudioService: Audioserver died.
01-25 01:16:19.869 7237 7318 E AudioService: Audioserver died.
01-25 01:16:20.368 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:20.371 7237 7318 E AudioService: Audioserver died.
01-25 01:16:20.698 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:20.699 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:20.874 7237 7318 E AudioService: Audioserver died.
01-25 01:16:21.371 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:21.374 7237 7318 E AudioService: Audioserver died.
01-25 01:16:21.877 7237 7318 E AudioService: Audioserver died.
01-25 01:16:22.373 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:22.380 7237 7318 E AudioService: Audioserver died.
01-25 01:16:22.694 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:22.695 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:22.883 7237 7318 E AudioService: Audioserver died.
01-25 01:16:23.376 7237 7237 W AudioSystem: AudioPolicyService not published, waiting...
01-25 01:16:23.386 7237 7318 E AudioService: Audioserver died.
01-25 01:16:23.877 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:23.888 7237 7318 E AudioService: Audioserver died.
01-25 01:16:24.389 7237 7318 E AudioService: Audioserver died.
01-25 01:16:24.688 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:24.688 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:24.878 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:24.892 7237 7318 E AudioService: Audioserver died.
01-25 01:16:25.395 7237 7318 E AudioService: Audioserver died.
01-25 01:16:25.879 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:25.899 7237 7318 E AudioService: Audioserver died.
01-25 01:16:26.401 7237 7318 E AudioService: Audioserver died.
01-25 01:16:26.834 8379 8379 D HfpClientConnService: onReceive Intent { act=android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED flg=0x10000010 (has extras) }
01-25 01:16:26.834 8379 8379 D HfpClientConnService: Finding block for device 60:45:CB:45:DC:50 blocks {60:45:CB:45:DC:50=com.android.bluetooth.hfpclient.connserv.HfpClientDeviceBlock@399f24d}
01-25 01:16:26.880 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:26.904 7237 7318 E AudioService: Audioserver died.
01-25 01:16:27.870 7237 7249 I Telecom : Event: RecordEntry TC@1: REQUEST_DISCONNECT, null: ICA.dC(InCall package: com.android.car.dialer)@ADI
01-25 01:16:27.870 7237 7249 I Telecom : Call: Send disconnect to connection service for call: [TC@1, ACTIVE, com.android.bluetooth/.hfpclient.connserv.HfpClientConnectionService, tel:**********, A, childs(0), has_parent(false), [Capabilities: CAPABILITY_SUPPORT_HOLD CAPABILITY_MUTE], [Properties:]]: ICA.dC(InCall package: com.android.car.dialer)@ADI
01-25 01:16:27.405 7237 7318 E AudioService: Audioserver died.
01-25 01:16:27.871 8379 8379 D BluetoothHeadsetClient: terminateCall()
01-25 01:16:27.880 7237 7237 W AudioSystem: AudioPolicyService not published, waiting...
01-25 01:16:27.915 8379 8423 W HeadsetClientStateMachine: Unhandled AT OK StackEvent {type:EVENT_TYPE_CMD_RESULT, value1:0, value2:0, value3:0, value4:0, string: "null", device:60:45:CB:45:DC:50}
01-25 01:16:28.299 8379 8414 W bt_btif : bta_dm_pm_ssr: conn_srvc id:27, app_id:1
01-25 01:16:28.299 8379 8414 W bt_btif : bta_dm_pm_ssr: conn_srvc id:18, app_id:0
01-25 01:16:28.299 8379 8414 W bt_btif : bta_dm_pm_ssr: conn_srvc id:26, app_id:1
01-25 01:16:28.299 8379 8414 W bt_btif : bta_dm_pm_ssr ssr:2, lat:1200
01-25 01:16:28.300 8379 8423 I ServiceManager: Waiting for service media.audio_flinger...
01-25 01:16:28.381 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:29.301 8379 8423 I ServiceManager: Waiting for service media.audio_flinger...
01-25 01:16:29.386 7237 7237 I ServiceManager: Waiting for service media.audio_policy...
01-25 01:16:29.889 2171 2171 I VMS.NATIVE_LOOP: type=1400 audit(0.0:5030): avc: denied { search } for name="1508" dev="proc" ino=13314 scontext=u:r:vms:s0 tcontext=u:r:vendor_init:s0 tclass=dir permissive=1
01-25 01:16:30.303 8379 8423 I ServiceManager: Waiting for service media.audio_flinger...
Audioserver died. Maybe it is caused by closing existing stream procedure.
I’ll try to use existing stream instead of closing it.