Commit 022b57a6 authored by Adrien Béraud's avatar Adrien Béraud

AppDelegate: use beginActivityWithOptions to prevent sleeping

Change-Id: If872437245ffa95c06f05b37b60cc2a997937200
parent d76f6206
......@@ -52,12 +52,12 @@
@property DialpadWC* dialpad;
@property (nonatomic, strong) dispatch_queue_t scNetworkQueue;
@property (nonatomic, assign) SCNetworkReachabilityRef currentReachability;
@property (strong) id activity;
@end
@implementation AppDelegate {
NSTimer* preventSleepTimer;
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);
[self setScNetworkQueue:queue];
[self beginObservingReachabilityStatus];
[self startSleepPreventionTimer];
}
- (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];
NSActivityOptions options = NSActivitySuddenTerminationDisabled | NSActivityAutomaticTerminationDisabled | NSActivityBackground;
self.activity = [[NSProcessInfo processInfo] beginActivityWithOptions:options reason:@"Receiving calls and messages"];
}
- (void) beginObservingReachabilityStatus
......@@ -344,8 +334,9 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
- (void) cleanExit
{
if (preventSleepTimer != nil) {
[preventSleepTimer invalidate];
if (self.activity != nil) {
[[NSProcessInfo processInfo] endActivity:self.activity];
self.activity = nil;
}
[self.wizard close];
[self.ringWindowController close];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment