I am testing accessibility permissions using AXIsProcessTrustedWithOptions.
When app starts, value is correctly returned. However if I change the setting in System Preferences -> Security & Privacy while app is running call to API is still returning the previous value.
Is that a bug?
Here is example code:
bool checkIfAccessibilityEnabledAndDisplayPopup()
{
// Method to check if accessibility is enabled
// Passing YES to kAXTrustedCheckOptionPrompt forces showing popup
NSDictionary *options = @{(bridge id)kAXTrustedCheckOptionPrompt: @YES};
Boolean accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
return (!!accessibilityEnabled);
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Starting");
for (int i=0;i<100;i) {
checkIfAccessibilityEnabledAndDisplayPopup();
[NSThread sleepForTimeInterval:20.0f];
NSDictionary *options = @{(__bridge id)kAXTrustedCheckOptionPrompt: @NO};
Boolean b = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
Boolean b1 = AXIsProcessTrusted();
NSLog(@"accessibility AXIsProcessTrustedWithOptions--> %d AXIsProcessTrusted --->
%d", b, b1);
}
}