I am trying to create a solution for an end-to-end set of tests for setting user rights (contacts, photos, notifications, etc.) on a simulator . The reason for this is because SpringBoard displays permission warnings and they interfere with the test suite.
Ive tried to use the XCUITest package, but it does not work properly with respect to SpringBoard notifications and is inconvenient for use in general.
So my idea was to modify system files to set permissions on demand. I found the TCC database and it seems pretty simple. Then I noticed that the permissions for notifications are saved in another file, /Library/BulletinBoard/SectionInfo.plist . This file is cached by the BBServer object in the SpringBoard process. I managed to modify this file, and if SpringBoard is complete, the changes to the file will be accepted. But I want this change to happen during the execution of the applications under test.
After some digging, I noticed that when the settings application (Preferences) makes changes to the notification settings, it uses the XPC connection to notify you of the changes.
I am trying to do the same in a test process. I am creating a BBSectionInfo object that contains all the notification settings, and try to notify the BulletinBoard server of this change with the BBSettingsGateway , which internally uses the XPC connection. This does not work, and I'm not sure why not, because I am not getting any errors.
Perhaps this is a matter of law? It annoys me that the system is not mistaken, nothing happens.
In the debugger, connecting the XPC connection, I get the following:
(lldb) po [inv.target valueForKey:@"connection"] <NSXPCConnection: 0x60000011bcf0> connection to service named com.apple.bulletinboard.settingsconnection
The inner join also does not reveal any problems:
(lldb) po [[inv.target valueForKey:@"connection"] valueForKey:@"xpcConnection"] <OS_xpc_connection: connection[0x6000001a6200]: { refcnt = 2, xrefcnt = 1, name = com.apple.bulletinboard.settingsconnection, type = named, state = init-done, error = 0x0 mach = true, privileged = false, bssend = 0x6f07, recv = 0x6d0b, send = 0x7003, pid = 0, euid = 4294967295, egid = 4294967295, asid = 4294967295 } <connection: 0x6000001a6200> { name = com.apple.bulletinboard.settingsconnection, listener = false, pid = 0, euid = 4294967295, egid = 4294967295, asid = 4294967295 }>
So everything seems good. The only difference I can find between the connections is that in my process the state is init-done , while in the process of setting the state is checked in :
(lldb) po [[[QuietHoursStateController sharedController] bbGateway] valueForKey:@"connection"] <NSXPCConnection: 0x6180001160b0> connection to service named com.apple.bulletinboard.settingsconnection (lldb) po [[[[QuietHoursStateController sharedController] bbGateway] valueForKey:@"connection"] valueForKey:@"xpcConnection"] <OS_xpc_connection: connection[0x6180001a3fe0]: { refcnt = 2, xrefcnt = 1, name = com.apple.bulletinboard.settingsconnection, type = named, state = checked in, error = 0x0 mach = true, privileged = false, bssend = 0x9d03, recv = 0x9817, send = 0x9e03, pid = 17877, euid = 26053515, egid = 20, asid = 100046 } <connection: 0x6180001a3fe0> { name = com.apple.bulletinboard.settingsconnection, listener = false, pid = 17877, euid = 26053515, egid = 20, asid = 100046 }>
I don't have enough experience with XPC connections, so maybe I'm missing something? BBSettingsGateway seems to be managing its own connection and does not provide any way to manage the connection.
I am not against other creative solutions, as this solution is intended only for the simulator. I added a jailbreak tag for detection, but I am looking for solutions only for simulators.