首页 > 其他分享 >Linphone Use WIFI only

Linphone Use WIFI only

时间:2023-05-29 14:37:59浏览次数:36  
标签:mLc Use network true networkInfo only Linphone setNetworkReachable


说明

因为在移动网络下, 如果输入错误的网址, 会发生崩溃的情况, 所以极大的可能使用了WIFI, 就是在每次通话的时候都要检查是否网络可达.
Use WIFI only在每次检查的时候, 去检查配置文件.

这个是在.linphonerc配置文件中能够

// Network settings
public void setWifiOnlyEnabled(Boolean enable) {
    getConfig().setBool("app", "wifi_only", enable);
}

public boolean isWifiOnlyEnabled() {
    return getConfig().getBool("app", "wifi_only", false);
}

在LinphoneManager中使用

public void updateNetworkReachability() {
    ConnectivityManager cm = (ConnectivityManager) mServiceContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = cm.getActiveNetworkInfo();

    if (networkInfo == null || !networkInfo.isConnected() || dozeModeEnabled) {
        Log.i("No connectivity: setting network unreachable");
        mLc.setNetworkReachable(false);
        //mLc.setNetworkReachable(true);
    } else if (networkInfo.isConnected()) {
        manageTunnelServer(networkInfo);

        boolean wifiOnly = LinphonePreferences.instance().isWifiOnlyEnabled();
        if (wifiOnly) {
            if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI)
                mLc.setNetworkReachable(true);
            else {
                Log.i("Wifi-only mode, setting network not reachable");
                mLc.setNetworkReachable(false);
                //mLc.setNetworkReachable(true);
            }
        } else {
            int curtype = networkInfo.getType();

            if (curtype != mLastNetworkType) {
                //if kind of network has changed, we need to notify network_reachable(false) to make sure all current connections are destroyed.
                //they will be re-created during setNetworkReachable(true).
                Log.i("Connectivity has changed.");
                mLc.setNetworkReachable(false);
                //mLc.setNetworkReachable(true);
            }
            mLc.setNetworkReachable(true);
            mLastNetworkType = curtype;
        }
    }

    if (mLc.isNetworkReachable()) {
        // When network isn't available, push informations might not be set. This should fix the issue.
        LinphonePreferences prefs = LinphonePreferences.instance();
        prefs.setPushNotificationEnabled(prefs.isPushNotificationEnabled());
    }
}


标签:mLc,Use,network,true,networkInfo,only,Linphone,setNetworkReachable
From: https://blog.51cto.com/u_11797608/6370695

相关文章

  • linphone 手机上不能接听电话
    问题描述这几天遇到一个问题,linphone安装到手机上不能接听电话.解决办法在linphone的设置中,设置端口号为5060,不要使用随机的端口号.然后问题就解决了.具体位置......
  • Linphone callState 电话状态的监听状态(二)
    LinphonecallState电话状态的监听状态callState是一个观察者模式接着上一篇的说,这篇主要是涉及到linphone中c层的注册监听机制.主要是代码追踪和代码过程.linphonecore_jni.cc中的添加监听事件的方法linphonecore_jni.cc中extern"C"voidJava_org_linphone_core_LinphoneC......
  • Linphone callState 电话状态的监听状态(一)
    0.阅读指南因为粘贴的代码比较多,阅读之前请先看目录.如果对这篇文章有什么建议的话,请在评论中指出.尽量把文章写好点.1.说明LinphoneService有个重要的机制,就是通过注册LinphoneCoreListener的实例,当Linphone的状态发声变化的时候,会回调相应的方法.然后linphone上层......
  • linphone 自动接听电话
    自动接听电话strings.xml:<stringname="pref_auto_answer">Autoanswerincomingcalls</string>non_localizable_strings.xml:<stringname="pref_auto_answer_key">pref_auto_answer_key</string>在xml文件中有这个线索,在界面设置如下将A......
  • linphone-PresenceNoteImpl文件对应的JNI层文件分析
    说明这个很短,自己看。native函数privatenativelongnewPresenceNoteImpl(Stringcontent,Stringlang);privatenativevoidunref(longnativePtr);privatenativeStringgetContent(longnativePtr);privatenativeintsetContent(longnativePtr,String......
  • linphone-TunnelConfigImpl文件对应的JNI层文件分析
    说明native函数privatenativeStringgetHost(longnativePtr);privatenativevoidsetHost(longnativePtr,Stringhost);privatenativeintgetPort(longnativePtr);privatenativevoidsetPort(longnativePtr,intport);privatenativeintgetRem......
  • linphone-LinphoneService.java文件分析
    说明主要是处理接听电话的逻辑,监听linphone拨打电话的状态逻辑。官方注释/****Linphoneservice,reactingtoIncomingcalls,...<br/>**Rolesinclude:<ul>*<li>InitializingLinphoneManager</li>*<li>StartingClibLinphonethroughLinphoneManage......
  • linphone-LinphoneCallParams.java文件分析
    说明专门作为Audio和Video的参数功能设置视频的带宽设置音频的带宽设置媒体的加密数据(encryption)设置是否允许低带宽设置RecordFile设置Sdp设置会话名称等是否允许多个rtp请求UML类图LinphoneCallParamsImpl.javapackageorg.linphone.core;importorg.linphone.core.LinphoneCor......
  • linphone-CallManager.java文件分析
    说明进行会话的管理,重新加入会话等功能创建会话重新进入Video重新设置参数更新会话UML类图CallManger.javapackageorg.linphone;importorg.linphone.core.LinphoneAddress;importorg.linphone.core.LinphoneCall;importorg.linphone.core.LinphoneCallParams;importorg.l......
  • linphone-PayloadType.java文件分析
    说明这个类主要是设置一些类型的参数,如MIME,RATE,FMTP等功能设置MIME设置RATE设置FMTUML类图PayloadType.javapackageorg.linphone.core;publicinterfacePayloadType{/***Obtaintheregisteredmime-type(actuallysubmime)ofthePayloadType.Forexample:......