Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Adds a verification on whether the process is trusted for Accessibility #676

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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