iPAD: achieve UserClient's privileges in background to have robust IOServiceAddMatchingNotification(...) as if ~[Background modes][Enable external communications].

1) The circumstances: iPADOS~>18, USB still-imaging-gadget, 1-3 gadgets might connect simultaneously via USB-hub, proprietary DExt, UserClient App in developers' iPADs or in TestFlight.

= 1 variation A) UserClientApp has attribute [Background modes][Enable external communications].

= 1 variation B) "active USB-hub" vs "passive".

= 1 variation C) "ConsoleApp logs iPAD" vs "ConsoleApp is not started".

= 1 the term "zombie" below assume issue:

== after plug-in ConsoleApp logs "IOUsbUserInterface::init", "::start";

== UserClient never receives respective callback from IOServiceAddMatchingNotification

== further IOKit APIs "teardown", "restart" and "re-enumeration of connected gadgets" doesn't reveal the zombie (while it sees another simultaneous gadget);

== unplug of the gadget logs "IOUsbUserInterface::stop".

=2) The situation when UserClient is in foreground: ~ everything is fine. Note in MAC OS everything (same DExt and UserClient-code) works fine in background and in foreground.

=3) The situation when UserClient is in background (beneath ~"Files" or "Safari"):

=3A) "1A=true" phys plugin causes zombie in ~1/20 cases (satisfactory)

=3B) "1A=false" phys plugin causes zombie in ~1/4 cases (non-satisfactory)

=3C) "1 variation B" and "1 variation C" reduce zombies by ~>30%.

=3D) ConsoleApp logs with filter "IOAccessory" (~about USB-energy) always look similar by my eyes.

=4) From Apple-store: "The app declares support for external-accessory in the UIBackgroundModes"..."The external accessory background mode is intended for apps that communicate with hardware accessories through the External Accessory framework."..."Additionally, the app must be authorized by MFi,"

=5) My wish/ask:

=5 option A) A clue to resolve the "zombie-plugin-issue in background" in a technical manner.

= E.g. find a straightforward solution that ~elevates UserClient's "privileges" in background like [Enable external communication]...

E.g. what ConsoleApp-logs to add/watch to reveal my potential bugs in DExt or in UserClient?

=5 option B) A way to pursue Apple-store to accept (without MFI) an UserClientApp with [Enable external communication].

iPAD: achieve UserClient's privileges in background to have robust IOServiceAddMatchingNotification(...) as if ~[Background modes][Enable external communications].
 
 
Q