mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
use auto enterBackground and enterForeground
This commit is contained in:
parent
e42b2b010e
commit
765f449c94
4 changed files with 0 additions and 117 deletions
|
|
@ -61,7 +61,6 @@
|
|||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
LOGI(@"%@", NSStringFromSelector(_cmd));
|
||||
if (linphone_core_get_global_state(LC) != LinphoneGlobalOff) {
|
||||
[LinphoneManager.instance enterBackgroundMode];
|
||||
[LinphoneManager.instance.fastAddressBook clearFriends];
|
||||
if (PhoneMainView.instance.currentView == ChatConversationView.compositeViewDescription) {
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
|
|
@ -110,7 +109,6 @@
|
|||
[PhoneMainView.instance startUp];
|
||||
}
|
||||
LinphoneManager *instance = LinphoneManager.instance;
|
||||
[instance becomeActive];
|
||||
|
||||
if (instance.fastAddressBook.needToUpdate) {
|
||||
//Update address book for external changes
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ typedef struct _LinphoneManagerSounds {
|
|||
- (void)startLinphoneCore;
|
||||
- (BOOL)resignActive;
|
||||
- (void)becomeActive;
|
||||
- (BOOL)enterBackgroundMode;
|
||||
- (void)addPushCallId:(NSString*) callid;
|
||||
- (void)configurePushTokenForProxyConfigs;
|
||||
- (void)configurePushTokenForProxyConfig: (LinphoneProxyConfig*)cfg;
|
||||
|
|
|
|||
|
|
@ -1208,11 +1208,6 @@ static BOOL libStarted = FALSE;
|
|||
[errView addAction:defaultAction];
|
||||
[PhoneMainView.instance presentViewController:errView animated:YES completion:nil];
|
||||
}
|
||||
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
|
||||
// go directly to bg mode
|
||||
[self enterBackgroundMode];
|
||||
}
|
||||
}
|
||||
|
||||
void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) {
|
||||
|
|
@ -1490,111 +1485,14 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ([self lpConfigBoolForKey:@"publish_presence"]) {
|
||||
// set present to "tv", because "available" does not work yet
|
||||
if (enabled) {
|
||||
linphone_core_set_presence_model(LC, linphone_core_create_presence_model_with_activity(LC, LinphonePresenceActivityTV, NULL));
|
||||
}
|
||||
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
while (proxies) {
|
||||
LinphoneProxyConfig *cfg = proxies->data;
|
||||
linphone_proxy_config_edit(cfg);
|
||||
linphone_proxy_config_enable_publish(cfg, enabled);
|
||||
linphone_proxy_config_done(cfg);
|
||||
proxies = proxies->next;
|
||||
}
|
||||
// force registration update first, then update friend list subscription
|
||||
[self iterate];
|
||||
}
|
||||
|
||||
linphone_core_enable_friend_list_subscription(LC, enabled && [LinphoneManager.instance lpConfigBoolForKey:@"use_rls_presence"]);
|
||||
}
|
||||
|
||||
- (BOOL)enterBackgroundMode {
|
||||
linphone_core_enter_background(LC);
|
||||
|
||||
LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(theLinphoneCore);
|
||||
BOOL shouldEnterBgMode = FALSE;
|
||||
|
||||
// disable presence
|
||||
[self enableProxyPublish:NO];
|
||||
|
||||
// handle proxy config if any
|
||||
if (proxyCfg) {
|
||||
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || pushNotifEnabled) {
|
||||
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
// For registration register
|
||||
[self refreshRegisters];
|
||||
}
|
||||
}
|
||||
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"voip_mode_preference"] && [LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] && !pushNotifEnabled) {
|
||||
// Keep this!! Socket VoIP is deprecated after 9.0, but sometimes it's the only way to keep the phone background and receive the call. For example, when there is only local area network.
|
||||
// register keepalive
|
||||
if ([[UIApplication sharedApplication]
|
||||
setKeepAliveTimeout:600 /*(NSTimeInterval)linphone_proxy_config_get_expires(proxyCfg)*/
|
||||
handler:^{
|
||||
LOGW(@"keepalive handler");
|
||||
mLastKeepAliveDate = [NSDate date];
|
||||
if (theLinphoneCore == nil) {
|
||||
LOGW(@"It seems that Linphone BG mode was deactivated, just skipping");
|
||||
return;
|
||||
}
|
||||
[_iapManager check];
|
||||
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
// For registration register
|
||||
[self refreshRegisters];
|
||||
}
|
||||
linphone_core_iterate(theLinphoneCore);
|
||||
}]) {
|
||||
LOGI(@"keepalive handler succesfully registered");
|
||||
} else {
|
||||
LOGI(@"keepalive handler cannot be registered");
|
||||
}
|
||||
shouldEnterBgMode = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneCall *currentCall = linphone_core_get_current_call(theLinphoneCore);
|
||||
const bctbx_list_t *callList = linphone_core_get_calls(theLinphoneCore);
|
||||
if (!currentCall // no active call
|
||||
&& callList // at least one call in a non active state
|
||||
&& bctbx_list_find_custom(callList, (bctbx_compare_func)comp_call_state_paused, NULL)) {
|
||||
[self startCallPausedLongRunningTask];
|
||||
}
|
||||
if (callList) // If at least one call exist, enter normal bg mode
|
||||
shouldEnterBgMode = TRUE;
|
||||
|
||||
// Stop the video preview
|
||||
if (theLinphoneCore) {
|
||||
linphone_core_enable_video_preview(theLinphoneCore, FALSE);
|
||||
[self iterate];
|
||||
}
|
||||
linphone_core_stop_dtmf_stream(theLinphoneCore);
|
||||
|
||||
LOGI(@"Entering [%s] bg mode", shouldEnterBgMode ? "normal" : "lite");
|
||||
if (!shouldEnterBgMode && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
|
||||
if (pushNotifEnabled) {
|
||||
LOGI(@"Keeping lc core to handle push");
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)becomeActive {
|
||||
linphone_core_enter_foreground(LC);
|
||||
|
||||
[self checkNewVersion];
|
||||
|
||||
// enable presence
|
||||
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
[self refreshRegisters];
|
||||
}
|
||||
if (pausedCallBgTask) {
|
||||
[[UIApplication sharedApplication] endBackgroundTask:pausedCallBgTask];
|
||||
pausedCallBgTask = 0;
|
||||
|
|
@ -1605,7 +1503,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
|
||||
/*IOS specific*/
|
||||
linphone_core_start_dtmf_stream(theLinphoneCore);
|
||||
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo
|
||||
completionHandler:^(BOOL granted){
|
||||
}];
|
||||
|
|
@ -1614,16 +1511,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
if (linphone_core_video_display_enabled(theLinphoneCore) && [self lpConfigBoolForKey:@"preview_preference"]) {
|
||||
linphone_core_enable_video_preview(theLinphoneCore, TRUE);
|
||||
}
|
||||
/*check last keepalive handler date*/
|
||||
if (mLastKeepAliveDate != Nil) {
|
||||
NSDate *current = [NSDate date];
|
||||
if ([current timeIntervalSinceDate:mLastKeepAliveDate] > 700) {
|
||||
NSString *datestr = [mLastKeepAliveDate description];
|
||||
LOGW(@"keepalive handler was called for the last time at %@", datestr);
|
||||
}
|
||||
}
|
||||
|
||||
[self enableProxyPublish:YES];
|
||||
}
|
||||
|
||||
- (void)refreshRegisters {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ show_remote_provisioning_in_assistant=0
|
|||
debug_popup_email=linphone-iphone@belledonne-communications.com
|
||||
send_logs_include_linphonerc_and_chathistory=0
|
||||
#use_phone_number=0
|
||||
publish_presence=0
|
||||
backgroundmode_preference=1
|
||||
use_rls_presence=1
|
||||
use_callkit=1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue