]> git.zerfleddert.de Git - proxmark3-svn/blame - client/util_darwin.m
osx: disable app-nap during serial comm (#687)
[proxmark3-svn] / client / util_darwin.m
CommitLineData
2a537311
A
1//-----------------------------------------------------------------------------
2// (c) 2018 AntiCat
3//
4// This code is licensed to you under the terms of the GNU GPL, version 2 or,
5// at your option, any later version. See the LICENSE.txt file for the text of
6// the license.
7//-----------------------------------------------------------------------------
8// macOS framework bindings
9//-----------------------------------------------------------------------------
10
11#import "util_darwin.h"
12
13#import <Foundation/NSString.h>
14#import <Foundation/NSProcessInfo.h>
15
16static id activity = nil;
17
18//OS X Version 10.10 is defined in OS X 10.10 and later
19#if defined(MAC_OS_X_VERSION_10_10)
20void disableAppNap(const char* reason) {
21 if(activity == nil) {
22 //NSLog(@"disableAppNap: %@", @(reason));
23 activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground reason:@(reason)];
24 [activity retain];
25 }
26}
27
28void enableAppNap() {
29 if(activity != nil) {
30 //NSLog(@"enableAppNap");
31 [[NSProcessInfo processInfo] endActivity:activity];
32 [activity release];
33 activity = nil;
34 }
35}
36
37#else
38void disableAppNap(const char* reason) { }
39void enableAppNap() { }
40#endif
Impressum, Datenschutz