I'm attempting to add the new OS X 10.9 (Mavericks) method beginActivityWithOptions
method to the NSProcessInfo
interface (TNSProcessInfo
) in FireMonkey (Delphi XE2).
The function seems to work. It returns an object, however, it's not disabling App Nap for the application. I'm using the Energy tab of Activity Monitor to monitor the App Nap state.
I've added the following code to Macapi.Foundation.pas
:
const
NSActivityBackground = 255;
NSActivityIdleSystemSleepDisabled = 1048576;
NSActivityUserInitiated = NSActivityIdleSystemSleepDisabled or 16777215;
NSActivityLatencyCritical = 1095216660480;
type
NSActivityOptions = UInt64;
NSProcessInfo = interface(NSObject)
['{B96935F6-3809-4A49-AD4F-CBBAB0F2C961}']
...
// Added following
function beginActivityWithOptions(options: NSActivityOptions; reason: NSString): NSObject; cdecl;
...
end;
I'm calling it like this:
var
obj: NSObject;
reason: NSString;
options: NSActivityOptions;
begin
reason := NSSTR('...');
options := NSActivityUserInitiated or NSActivityLatencyCritical;
obj := TNSProcessInfo.Wrap(TNSProcessInfo.OCClass.processInfo).beginActivityWithOptions(options, reason);
end;
I've tried various combinations of the options flag, and it's not disabling App Nap. Any ideas? Do you see anything wrong with my implementation?