linphone - Network is unreachable (真的时网络不可达)
2017-03-16 14:25
1046 查看
Network is unreachable 追踪
org.linphone–ChatFragment
—-sendImageMessage(String, int)
——ChatFragment
中
LinphoneActivity.instance().displayCustomToast(getString(R.string.er
ror_network_unreachable), Toast.LENGTH_LONG);
–LinphoneManager
—-newOutgoningCall(String, String)
中
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
在LinphoneCoreImpl中找到方法调用
public synchronized boolean isNetworkReachable() { return isNetworkStateReachable(nativePtr); }
通过grep命令,找到了这个方法
linphone/coreapi/linphonecore_jni.cc:extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
isNetworkStateReachable native方法
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env ,jobject thiz ,jlong lc) { return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc); }
linphone/coreapi/linphonecore.c:bool_t linphone_core_is_network_reachable(LinphoneCore* lc) {
bool_t linphone_core_is_network_reachable(LinphoneCore* lc) { return lc->sip_network_reachable; }
又回到了这个核心的地方
struct _LinphoneCore { belle_sip_object_t base; MSFactory* factory; MSList* vtable_refs; int vtable_notify_recursion; Sal *sal; LinphoneGlobalState state; struct _LpConfig *config; MSList *default_audio_codecs; MSList *default_video_codecs; MSList *default_text_codecs; net_config_t net_conf; sip_config_t sip_conf; rtp_config_t rtp_conf; sound_config_t sound_conf; video_config_t video_conf; text_config_t text_conf; codecs_config_t codecs_conf; ui_config_t ui_conf; autoreplier_config_t autoreplier_conf; LinphoneProxyConfig *default_proxy; MSList *friends_lists; MSList *auth_info; struct _RingStream *ringstream; time_t dmfs_playing_start_time; LCCallbackObj preview_finished_cb; LinphoneCall *current_call; /* the current call */ MSList *calls; /* all the processed calls */ MSList *queued_calls; /* used by the autoreplier */ MSList *call_logs; MSList *chatrooms; int max_call_logs; int missed_calls; VideoPreview *previewstream; struct _MSEventQueue *msevq; LinphoneRtpTransportFactories *rtptf; MSList *bl_reqs; MSList *subscribers; /* unknown subscribers */ int minutes_away; LinphonePresenceModel *presence_model; void *data; char *play_file; char *rec_file; uint64_t prevtime_ms; int audio_bw; /*IP bw consumed by audio codec, set as soon as used codec is known, its purpose is to know the remaining bw for video*/ LinphoneCoreWaitingCallback wait_cb; void *wait_ctx; void *video_window_id; void *preview_window_id; time_t netup_time; /*time when network went reachable */ struct _EcCalibrator *ecc; struct _EchoTester *ect; LinphoneTaskList hooks; /*tasks periodically executed in linphone_core_iterate()*/ LinphoneConference *conf_ctx; char* zrtp_secrets_cache; char* user_certificates_path; LinphoneVideoPolicy video_policy; time_t network_last_check; LinphoneNatPolicy *nat_policy; LinphoneImNotifPolicy *im_notif_policy; bool_t use_files; bool_t apply_nat_settings; bool_t initial_subscribes_sent; bool_t bl_refresh; bool_t preview_finished; bool_t auto_net_state_mon; bool_t sip_network_reachable; // sip是否可达 bool_t media_network_reachable; bool_t network_reachable_to_be_notified; /*set to true when state must be notified in next iterate*/ bool_t use_preview_window; bool_t network_last_status; bool_t ringstream_autorelease; bool_t vtables_running; bool_t send_call_stats_periodical_updates; bool_t forced_ice_relay; bool_t short_turn_refresh; char localip[LINPHONE_IPADDR_SIZE]; int device_rotation; int max_calls; LinphoneTunnel *tunnel; char* device_id; MSList *last_recv_msg_ids; char *chat_db_file; char *logs_db_file; char *friends_db_file; #ifdef SQLITE_STORAGE_ENABLED sqlite3 *db; sqlite3 *logs_db; sqlite3 *friends_db; bool_t debug_storage; #endif #ifdef BUILD_UPNP UpnpContext *upnp; #endif //BUILD_UPNP belle_http_provider_t *http_provider; belle_tls_crypto_config_t *http_crypto_config; belle_http_request_listener_t *provisioning_http_listener; MSList *tones; LinphoneReason chat_deny_code; char *file_transfer_server; const char **supported_formats; LinphoneContent *log_collection_upload_information; LinphoneCoreCbs *current_cbs; // the latest LinphoneCoreCbs object to call a callback, see linphone_core_get_current_cbs() LinphoneRingtonePlayer *ringtoneplayer; #ifdef ANDROID jobject wifi_lock; jclass wifi_lock_class; jmethodID wifi_lock_acquire_id; jmethodID wifi_lock_release_id; jobject multicast_lock; jclass multicast_lock_class; jmethodID multicast_lock_acquire_id; jmethodID multicast_lock_release_id; #endif LinphoneVcardContext *vcard_context; /*for tests only*/ bool_t zrtp_not_available_simulation; /* string for TLS auth instead of path to files */ char *tls_cert; char *tls_key; LinphoneAddress *default_rls_addr; /*default resource list server*/ LinphoneImEncryptionEngine *im_encryption_engine; MSBandwidthController *bw_controller; }; struct _LinphoneEvent{ belle_sip_object_t base; LinphoneSubscriptionDir dir; LinphoneCore *lc; SalOp *op; SalCustomHeader *send_custom_headers; LinphoneSubscriptionState subscription_state; LinphonePublishState publish_state; void *userdata; char *name; int expires; bool_t terminating; bool_t is_out_of_dialog_op; /*used for out of dialog notify*/ bool_t internal; bool_t oneshot; };
看来走到绝路了,应该找什么时候设置的它
在LinphoneManager中有设置的方法
/** * This method is called by the application to notify the Linphone core library when network is reachable. * Calling this method with true trigger Linphone to initiate a registration process for all proxy * configuration with parameter register set to enable. * This method disable the automatic registration mode. It means you must call this method after each network state changes * * @param isReachable network state */ public void setNetworkReachable(boolean isReachable); /** * Get network state has known by {@link LinphoneCore} * * @return if false, there is no network connection. */ public boolean isNetworkReachable();
在他上面就有设置的方法setNetworkReachable
最后在LinphoneManager找到了所使用的地方
public void updateNetworkReachability() { LinphoneService._log("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()); } }
在LinphoneService中找到了使用的地方
@Override public void onTaskRemoved(Intent rootIntent) { if (getResources().getBoolean(R.bool.kill_service_with_task_manager)) { Log.d("Task removed, stop service"); // If push is enabled, don't unregister account, otherwise do unregister if (LinphonePreferences.instance().isPushNotificationEnabled()) { LinphoneManager.getLc().setNetworkReachable(false); //LinphoneManager.getLc().setNetworkReachable(false); } stopSelf(); } super.onTaskRemoved(rootIntent); }
最后发现
我的网络真的不能用.相关文章推荐
- CentOS启动网络提示connect: Network is unreachable
- 虚拟机centos系统由于更换网络导致"Network is unreachable"
- Ubuntu配置网络时出现network is unreachable
- linux网络异常:connect: network is unreachable
- centos--网络配置问题,提示connect: Network is unreachable
- CentOS启动网络提示connect: Network is unreachable(配置静态路由)
- 【问题】安装linux5网络ping不通——network isunreachable
- suse linux原创案例07: linux网络问题:Network is unreachable
- ubuntu network is unreachable解决办法
- 使用API判断网络是否连通(InternetGetConnectedState / IsNetworkAlive)
- Network is unreachable
- How to get camped network type name - Android应用如何获得Phone当前注册的网络类型
- ubuntu network is unreachable 解决记
- Ubuntu network is unreachable
- 挂载nfs文件系统出现:mount: RPC: Unable to send; errno = Network is unreachable
- ping: sendto: Network is unreachable
- 使用API判断网络是否连通(InternetGetConnectedState / IsNetworkAlive)
- 使用API判断网络是否连通(InternetGetConnectedState / IsNetworkAlive)
- vmware samba“无法映射网络驱动器,找不到网络路径”(device cannot be mapped because no network is found)
- 解决archlinux下“network is unreachable”问题?