reactivate socket voip, not used in push notification

This commit is contained in:
Danmei Chen 2018-12-18 17:01:55 +01:00
parent 4f0666d0f9
commit 588b986005
4 changed files with 39 additions and 6 deletions

View file

@ -361,7 +361,7 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
NSDictionary *defaults = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
NSArray *defaults_keys = [defaults allKeys];
NSDictionary *values =
@{ @"backgroundmode_preference" : @YES,
@{ @"backgroundmode_preference" : @NO,
@"debugenable_preference" : @NO,
@"start_at_boot_preference" : @YES };
BOOL shouldSync = FALSE;
@ -758,8 +758,17 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
withCompletionHandler:^(NSError *_Nullable error)
{if (error) LOGD(@"Error while adding notification request : %@", error.description);}];
}
linphone_core_set_network_reachable(LC, FALSE);
LinphoneManager.instance.connectivity = none;
LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(theLinphoneCore);
BOOL pushNotifEnabled = false;
// handle proxy config if any
if (proxyCfg) {
const char *refkey = proxyCfg ? linphone_proxy_config_get_ref_key(proxyCfg) : NULL;
pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0);
}
if (![LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || pushNotifEnabled) {
linphone_core_set_network_reachable(LC, FALSE);
LinphoneManager.instance.connectivity = none;
}
}
LinphoneCallLog *callLog2 = linphone_call_get_call_log(call);
const char *call_id2 = linphone_call_log_get_call_id(callLog2);
@ -2364,7 +2373,30 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
}
}
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"]) {
if ([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;
}
}

View file

@ -1,7 +1,7 @@
[app]
animations_preference=1
autoanswer_notif_preference=1
backgroundmode_preference=1
backgroundmode_preference=0
edge_opt_preference=0
enable_log_collect=0
file_transfer_migration_done=1

View file

@ -21,6 +21,7 @@ debug_popup_email=linphone-iphone@belledonne-communications.com
send_logs_include_linphonerc_and_chathistory=0
#use_phone_number=0
publish_presence=0
backgroundmode_preference=0
[assistant]
password_length=-1

View file

@ -1,7 +1,7 @@
[app]
animations_preference=1
autoanswer_notif_preference=1
backgroundmode_preference=1
backgroundmode_preference=0
edge_opt_preference=0
enable_log_collect=0
file_transfer_migration_done=1