Skip to content
Snippets Groups Projects
Commit 022b57a6 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

AppDelegate: use beginActivityWithOptions to prevent sleeping

Change-Id: If872437245ffa95c06f05b37b60cc2a997937200
parent d76f6206
Branches
No related tags found
No related merge requests found
...@@ -52,12 +52,12 @@ ...@@ -52,12 +52,12 @@
@property DialpadWC* dialpad; @property DialpadWC* dialpad;
@property (nonatomic, strong) dispatch_queue_t scNetworkQueue; @property (nonatomic, strong) dispatch_queue_t scNetworkQueue;
@property (nonatomic, assign) SCNetworkReachabilityRef currentReachability; @property (nonatomic, assign) SCNetworkReachabilityRef currentReachability;
@property (strong) id activity;
@end @end
@implementation AppDelegate { @implementation AppDelegate {
NSTimer* preventSleepTimer;
std::unique_ptr<lrc::api::Lrc> lrc; std::unique_ptr<lrc::api::Lrc> lrc;
} }
...@@ -92,18 +92,8 @@ std::unique_ptr<lrc::api::Lrc> lrc; ...@@ -92,18 +92,8 @@ std::unique_ptr<lrc::api::Lrc> lrc;
queue = dispatch_queue_create("scNetworkReachability", DISPATCH_QUEUE_SERIAL); queue = dispatch_queue_create("scNetworkReachability", DISPATCH_QUEUE_SERIAL);
[self setScNetworkQueue:queue]; [self setScNetworkQueue:queue];
[self beginObservingReachabilityStatus]; [self beginObservingReachabilityStatus];
[self startSleepPreventionTimer]; NSActivityOptions options = NSActivitySuddenTerminationDisabled | NSActivityAutomaticTerminationDisabled | NSActivityBackground;
} self.activity = [[NSProcessInfo processInfo] beginActivityWithOptions:options reason:@"Receiving calls and messages"];
- (void) startSleepPreventionTimer
{
if (preventSleepTimer != nil) {
[preventSleepTimer invalidate];
}
preventSleepTimer = [NSTimer timerWithTimeInterval:30.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
UpdateSystemActivity(OverallAct);
}];
[[NSRunLoop mainRunLoop] addTimer:preventSleepTimer forMode:NSRunLoopCommonModes];
} }
- (void) beginObservingReachabilityStatus - (void) beginObservingReachabilityStatus
...@@ -344,8 +334,9 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet ...@@ -344,8 +334,9 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
- (void) cleanExit - (void) cleanExit
{ {
if (preventSleepTimer != nil) { if (self.activity != nil) {
[preventSleepTimer invalidate]; [[NSProcessInfo processInfo] endActivity:self.activity];
self.activity = nil;
} }
[self.wizard close]; [self.wizard close];
[self.ringWindowController close]; [self.ringWindowController close];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment