Skip to content

Commit

Permalink
Adds a verification on whether the process is trusted for Accessibility
Browse files Browse the repository at this point in the history
This fixes/mitigates the issue radiant-player#674: "Application will not restart after
update in macOS Mojave"
  • Loading branch information
xrubioj committed Nov 18, 2018
1 parent 870ad05 commit 7796877
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions radiant-player-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ - (void)RadiantScreenUnlocked {
*/
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

[self verifyAccessibility];

[window setDelegate:self];

// Load the user preferences.
Expand Down Expand Up @@ -622,6 +625,30 @@ - (void) ddhidAppleMikey:(DDHidAppleMikey *)mikey press:(unsigned)usageId upOrDo
}
}

#pragma mark - Accessibility

- (void) verifyAccessibility
{
Boolean trusted = AXIsProcessTrusted();
NSLog(@"Accessibility: process is trusted check: %s", (trusted ? "YES" : "NO"));
if (trusted) {
return;
}

NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Media keys"];
[alert setInformativeText:@"Radiant Player needs Accessibility permission to be able to listen for media keys. You will need to enable it from System Preferences.\n\nIf you\'ve updated Radiant Player and you\'re seeing this message, you will have to disable and reenable the permission in order for Radiant Player to work properly.\n\nRadiant Player will now close, and you will have to restart it after enabling the permission."];
[alert addButtonWithTitle:@"Close"];
[alert runModal];

const void *tkeys[1] = { kAXTrustedCheckOptionPrompt };
const void *tvalues[1] = { kCFBooleanTrue };
CFDictionaryRef options = CFDictionaryCreate(NULL, tkeys, tvalues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
NSLog(@"Accessibility: process is trusted check with prompt: %s", (AXIsProcessTrustedWithOptions(options) ? "YES" : "NO"));

exit(1);
}

#pragma mark - Web Browser Actions

- (void) load:(id)sender
Expand Down

0 comments on commit 7796877

Please sign in to comment.