'iOS Observe Call State Logs via heard daemon (accessibility service)

I am doing some iPhone automation and want to observe call states of ongoing calls. I implemented a listener to read the idevicesyslog and fetch log output of com.apple.accessibility.heard, which is printing each state change similar to the following lines (stat=Sending and stat=Active):

ay 13 02:14:02 heard(HearingUtilities)[11392] <Notice>: -[HUComfortSoundsController callStatusDidChange:]:415 Phone call holding 0 [pending = 1, active = 0, avc = 0, endpoint = 1] - NSConcreteNotification 0x102f173f0 {name = TUCallCenterCallStatusChangedNotification: object = <TUProxyCall 0x102f47080 p=com.apple.coretelephony aPI=(null) svc=Telephony hdl=<TUHandle 0x103407870 type=PhoneNumber, value=+4912345, normalizedValue=+4912345, isoCountryCode=de> isoCC=de stat=Sending tStat=0 dR=0 fR=0 supportsR=1 uPI=57FCA1D2-D09F-4E23-A08A-3AD4B18B570D grp=(null) lSIUUID=00000000-0000-0000-0000-000000000001 lSIAccountUUID=AA1FC9E6-068E-4D86-B3B9-C1074658AFB2 hosted=1 endpt=1 callerNFN=(null) srcID=(null) aC=(null) aM=(null) iUB=1 vm=0 connStat=00 nMICS=0 sR=0 iSA=0 iSV=0 iSS=0 wHM=0 hSI=0 vST=0 iapST=0 oapST=0 vCA=<TUVideoCallAttributes 0x102f17330 remoteCameraOrientation=0 localVideoContextSlotIdentifier=0 remoteVideoContextSlotIdentifier=0> model=<TUCallModel 0x102f3e380 hold=1 grp=1 ungrp=1 DTMF=1 uMPS=1 aC=1 sTV=0> em=0 iFE=0 sos=0 sSR=1 sSUI=0 mX=0<\M-b\M^@\M-&>

May 13 02:14:14 heard(HearingUtilities)[11392] <Notice>: -[HUComfortSoundsController callStatusDidChange:]:415 Phone call holding 0 [pending = 0, active = 1, avc = 1, endpoint = 1] - NSConcreteNotification 0x10321ab80 {name = TUCallCenterCallStatusChangedNotification: object = <TUProxyCall 0x102f47080 p=com.apple.coretelephony aPI=(null) svc=Telephony hdl=<TUHandle 0x103330670 type=PhoneNumber, value=+4912345, normalizedValue=+4912345, isoCountryCode=de> isoCC=de stat=Active tStat=0 dR=0 fR=0 supportsR=1 uPI=57FCA1D2-D09F-4E23-A08A-3AD4B18B570D grp=(null) lSIUUID=00000000-0000-0000-0000-000000000001 lSIAccountUUID=AA1FC9E6-068E-4D86-B3B9-C1074658AFB2 hosted=1 endpt=1 callerNFN=(null) srcID=(null) aC=AVAudioSessionCategoryPhoneCall aM=(null) iUB=1 vm=0 connStat=11 nMICS=0 sR=0 iSA=0 iSV=0 iSS=0 wHM=0 hSI=1 vST=0 iapST=0 oapST=0 vCA=<TUVideoCallAttributes 0x102f17330 remoteCameraOrientation=0 localVideoContextSlotIdentifier=0 remoteVideoContextSlotIdentifier=0> model=<TUCallModel 0x1032596b0 hold=1 grp=1 ungrp=1 DTMF=1 uMPS=1 aC=1 sTV=1> em=0 iFE=0<\M-b\M^@\M-&>

Unfortunately, starting from newer iOS versions (maybe 15.4 or 15.x already, don't know exactly), the heard service is killing itself after 3 minutes:

May 13 02:28:03 heard(Accounts)[11501] <Notice>: "The connection to ACDAccountStore was invalidated."
May 13 02:28:03 heard(Accounts)[11501] <Notice>: "The connection to ACDAccountStore was invalidated."
May 13 02:30:21 heard(HearingUtilities)[11501] <Notice>: -[AXHeardController shutdownIfPossible]:355 heard still shouldn't be running. Shutting down.

It is restarting after i am opening the settings-> accessibility settings via phone menu. Does anybody have an idea what I can do about this? I thought about following things:

  • Include heard service / accessibility in an own app, so that it will stay online when app is active
  • Get call states in another way? I tried an observer inside an app, but when it is running in background, it will not react anymore.
  • Some iOS setting to enable it permanently
  • Will this be fixed in an upcoming version?

The com.apple.accessibility.heard seems to be an internal service, does anybody know how to deal with it now?

Otherwise i would also be happy for a hint how to solve this without observing logs. As I said, CallObserver in my swift app is problematic, as it is not working in background.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source