mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
fix start at boot (was broken)
protect launching at boot with a background task and another background task in belle-sip to protect notifications of incoming messages and calls.
This commit is contained in:
parent
884d4a1dca
commit
ba39301ffd
6 changed files with 16 additions and 6 deletions
|
|
@ -30,6 +30,7 @@
|
|||
@interface LinphoneAppDelegate : NSObject <UIApplicationDelegate,UIAlertViewDelegate> {
|
||||
@private
|
||||
UIWindow *window;
|
||||
UIBackgroundTaskIdentifier bgStartId;
|
||||
BOOL started;
|
||||
int savedMaxCall;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,18 +134,23 @@
|
|||
// we've been woken up directly to background;
|
||||
if( !start_at_boot || !background_mode ) {
|
||||
// autoboot disabled or no background, and no push: do nothing and wait for a real launch
|
||||
/*output a log with NSLog, because the ortp logging system isn't activated yet at this time*/
|
||||
NSLog(@"Linphone launch doing nothing because start_at_boot or background_mode are not activated.", NULL);
|
||||
return YES;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bgStartId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
|
||||
[LinphoneLogger log:LinphoneLoggerWarning format:@"Background task for application launching expired."];
|
||||
[[UIApplication sharedApplication] endBackgroundTask:bgStartId];
|
||||
}];
|
||||
[self startApplication];
|
||||
NSDictionary *remoteNotif =[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
||||
if (remoteNotif){
|
||||
[LinphoneLogger log:LinphoneLoggerLog format:@"PushNotification from launch received."];
|
||||
[self processRemoteNotification:remoteNotif];
|
||||
}
|
||||
|
||||
if (bgStartId!=UIBackgroundTaskInvalid) [[UIApplication sharedApplication] endBackgroundTask:bgStartId];
|
||||
[[PhoneMainView instance] updateStatusBar:nil];
|
||||
|
||||
return YES;
|
||||
|
|
|
|||
|
|
@ -632,6 +632,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
|||
}
|
||||
|
||||
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "backgroundmode_preference", isbackgroundModeEnabled);
|
||||
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "start_at_boot_preference", [self boolForKey:@"start_at_boot_preference"]);
|
||||
|
||||
BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"];
|
||||
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "enable_first_login_view_preference", firstloginview);
|
||||
|
|
|
|||
|
|
@ -1127,7 +1127,7 @@ static BOOL libStarted = FALSE;
|
|||
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
|
||||
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
|
||||
//go directly to bg mode
|
||||
[self resignActive];
|
||||
[self enterBackgroundMode];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1157,7 +1157,9 @@ static BOOL libStarted = FALSE;
|
|||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioSessionInterrupted:) name:AVAudioSessionInterruptionNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(globalStateChangedNotificationHandler:) name:kLinphoneGlobalStateUpdate object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(configuringStateChangedNotificationHandler:) name:kLinphoneConfiguringStateUpdate object:nil];
|
||||
|
||||
|
||||
/*call iterate once immediately in order to initiate background connections with sip server, if any */
|
||||
linphone_core_iterate(theLinphoneCore);
|
||||
// start scheduler
|
||||
mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02
|
||||
target:self
|
||||
|
|
@ -1273,6 +1275,7 @@ static int comp_call_state_paused (const LinphoneCall* call, const void* param)
|
|||
- (void) startCallPausedLongRunningTask {
|
||||
pausedCallBgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler: ^{
|
||||
[LinphoneLogger log:LinphoneLoggerWarning format:@"Call cannot be paused any more, too late"];
|
||||
[[UIApplication sharedApplication] endBackgroundTask:pausedCallBgTask];
|
||||
}];
|
||||
[LinphoneLogger log:LinphoneLoggerLog format:@"Long running task started, remaining [%g s] because at least one call is paused"
|
||||
,[[UIApplication sharedApplication] backgroundTimeRemaining]];
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit eb3467af3e8f42c5a9cea36d4253bd66641413f3
|
||||
Subproject commit fd8d52069e00261b99f6bb03b78342418ddb6da4
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 811223d35f6ae1f7831f7b918cb95b1e1e7bcf0d
|
||||
Subproject commit 7553aa6492f1df0106ca42bbfb9cea49c5dd656e
|
||||
Loading…
Add table
Reference in a new issue