Commit a25fdfac authored by Simon Morlat's avatar Simon Morlat
Browse files

Remove SSID check and fix an issue where annoying network_state up/down occur,...

Remove SSID check and fix an issue where annoying network_state up/down occur, when the user refused the location permission.
parent e1e9372c
......@@ -1149,7 +1149,7 @@ SalMediaProto MediaSessionPrivate::getAudioProto(){
void MediaSessionPrivate::makeLocalMediaDescription(bool localIsOfferer) {
L_Q();
ms_message("%s - entering is update %0d\n", __func__, localIsOfferer);
bool rtcpMux = !!linphone_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "rtp", "rtcp_mux", 0);
SalMediaDescription *md = sal_media_description_new();
SalMediaDescription *oldMd = localDesc;
......
......@@ -444,6 +444,13 @@ void IosPlatformHelpers::networkChangeCallback() {
mCurrentFlags = flags;
}
if (!(flags & kSCNetworkReachabilityFlagsIsWWAN)) {
/*
* CHECK_SSID is undefined by default. Previously we are monitoring SSID changes to notify liblinphone of possible network changes.
* Since iOS 12, it requires an annoying location permission. For that reason, the default algorithm just monitors
* the default local ip addresses for changes. A bit less reliable since we can change from wifi network but by change obtain the same ip address.
* But much less annoying because it doesn't require to ask a permission to the user.
*/
#ifdef CHECK_SSID
//Only check for wifi changes if current connection type is Wifi
string newSSID = getWifiSSID();
if (newSSID.empty() || newSSID.compare(mCurrentSSID) != 0) {
......@@ -453,6 +460,11 @@ void IosPlatformHelpers::networkChangeCallback() {
force = true;
ms_message("New Wifi SSID detected: %s", mCurrentSSID.empty()?"[none]":mCurrentSSID.c_str());
}
#else
if (reachable){
force = checkIpAddressChanged();
}
#endif
}
getHttpProxySettings();
if (mHttpProxyEnabled) {
......
......@@ -148,9 +148,8 @@ void GenericPlatformHelpers::startAudioForEchoTestOrCalibration () { }
void GenericPlatformHelpers::stopAudioForEchoTestOrCalibration () { }
int GenericPlatformHelpers::monitorTimerExpired (void *data, unsigned int revents) {
GenericPlatformHelpers *helper = static_cast<GenericPlatformHelpers *>(data);
LinphoneCore *core = helper->getCore()->getCCore();
bool GenericPlatformHelpers::checkIpAddressChanged(){
LinphoneCore *core = getCore()->getCCore();
bool ipv6Enabled = linphone_core_ipv6_enabled(core);
char newIp4[LINPHONE_IPADDR_SIZE];
......@@ -160,8 +159,10 @@ int GenericPlatformHelpers::monitorTimerExpired (void *data, unsigned int revent
linphone_core_get_local_ip(core, AF_INET6, nullptr, newIp6);
bool status = strcmp(newIp6,"::1") != 0 || strcmp(newIp4,"127.0.0.1") != 0;
bool ipChanged = false;
if (status && core->network_last_status){
bool ipChanged = false;
// Check for IP address changes:
if (strcmp(newIp4, core->localip4) != 0) {
lInfo() << "IPv4 address change detected";
......@@ -171,20 +172,29 @@ int GenericPlatformHelpers::monitorTimerExpired (void *data, unsigned int revent
lInfo() << "IPv6 address change detected";
ipChanged = true;
}
if (ipChanged){
helper->setNetworkReachable(false);
core->network_last_status = FALSE;
if (status) {
lInfo() << "Default local ipv4 address is " << core->localip4;
if (ipv6Enabled) lInfo() << "Default local ipv6 address is " << core->localip6;
}
}
strncpy(core->localip4, newIp4, sizeof core->localip4);
if (ipv6Enabled) strncpy(core->localip6, newIp6, sizeof core->localip6);
return ipChanged;
}
int GenericPlatformHelpers::monitorTimerExpired (void *data, unsigned int revents) {
GenericPlatformHelpers *helper = static_cast<GenericPlatformHelpers *>(data);
LinphoneCore *core = helper->getCore()->getCCore();
bool status = strcmp(core->localip6,"::1") != 0 || strcmp(core->localip4,"127.0.0.1") != 0;
bool ipChanged = helper->checkIpAddressChanged();
if (ipChanged){
helper->setNetworkReachable(false);
core->network_last_status = FALSE;
}
if (bool_t(status) != core->network_last_status) {
if (status) {
lInfo() << "Default local ipv4 address is " << core->localip4;
if (ipv6Enabled) lInfo() << "Default local ipv6 address is " << core->localip6;
}
helper->setNetworkReachable(status);
core->network_last_status = status;
}
......
......@@ -140,6 +140,7 @@ public:
void stopAudioForEchoTestOrCalibration () override;
protected:
bool checkIpAddressChanged();
std::shared_ptr<SharedCoreHelpers> mSharedCoreHelpers;
std::string mCurrentSSID;
std::string mHttpProxyHost;
......
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