以下代码设置重复警报,每五分钟向服务器发送一次心跳。
if (!isHeartBeating(context)) {
alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent alarm_intent = new Intent(Globals.BC_HEARTBEAT);
alarmIntent = PendingIntent.getBroadcast(context, 0, alarm_intent, 0);
alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + fiveminutes,
fiveminutes, alarmIntent);
}
然后我将手机连接到电源并具有非常好的4G覆盖范围,并且它确实每隔五分钟发送心跳,如预期的那样。然而,几个小时(四或五)后它停止发送。原因是网络接口突然消失。这就是logcat显示的内容:
07-26 13:28:46.690 889 889 E kickstart:错误:功能:rx_data:517读/写文件描述符返回错误:没有这样的设备,错误代码-1
07-26 13:28:46.690 889 889 E kickstart:错误:功能:main:302使用Sahara协议上传图像失败
07-26 13:28:46.700 832 832我kickstart-efsks:retval = 256
07-26 13:28:46.700 832 832 E kickstart-efsks:错误:ks返回码为256,失败了
07-26 13:28:46.700 832 832 E kickstart-efsks:从KS回来,出了点问题,再试一次
07-26 13:28:46.700 832 832 E kickstart-efsks:
07-26 13:28:46.750 695 781 D UsbHostManager:onUEvent(device):: action = remove,devtype = usb_interface,device = null,product = 5c6 / 904c / 0,type = 0/0/0, interface = 255/255/255,devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.0
07-26 13:28:46.760 695 781 D UsbHostManager:onUEvent(device):: action = remove,devtype = usb_interface,device = null,product = 5c6 / 904c / 0,type = 0/0/0, interface = 255/255/255,devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.1
07-26 13:28:46.770 195 664 W Netd:在netlink事件中找不到子系统
07-26 13:28:46.770 195 664 D NetlinkEvent:意外的netlink消息。类型= 0×11
07-26 13:28:46.790 695 894 D Tethering:interfaceLinkStateChanged rmnet_usb0,false
07-26 13:28:46.790 695 894 D Tethering:interfaceStatusChanged rmnet_usb0,false
07-26 13:28:46.810 695 894 D Tethering:interfaceRemoved rmnet_usb0
07-26 13:28:46.810 695 894 E Tethering:尝试删除未知的iface(rmnet_usb0),忽略
07-26 13:28:46.810 695 894 D Vpn:interface已删除:interface = rmnet_usb0
07-26 13:28:46.810 695 781 D UsbHostManager:onUEvent(device):: action = remove,devtype = usb_interface,device = null,product = 5c6 / 904c / 0,type = 0/0/0, interface = 255/255/255,devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.2
07-26 13:28:46.820 695 781 D UsbHostManager:onUEvent(device):: action = remove,devtype = usb_interface,device = null,product = 5c6 / 904c / 0,type = 0/0/0, interface = 255/255/255,devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.3
07-26 13:28:46.830 695 781 D UsbHostManager:onUEvent(device):: action = remove,devtype = usb_interface,device = null,product = 5c6 / 904c / 0,type = 0/0/0, interface = 255/254/255,devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.4
07-26 13:28:46.830 695 781 D UsbHostManager:onUEvent(device):: action = remove,devtype = usb_interface,device = null,product = 5c6 / 904c / 0,type = 0/0/0, interface = 255/255/255,devpath = /devices/platform/msm_hsic_host/usb1/1-1/1-1:1.5
07-26 13:28:47.711 832 832 E kickstart-efsks:找不到档案'/ dev / efs_bridge'
07-26 13:28:47.711 832 832 E kickstart-efsks:/ dev / efs_bridge不存在。
07-26 13:28:48.101 195 664 W Netd:在netlink事件中找不到子系统
这看起来像是efs / usb映射的主要问题,并且只有在重新启动后才会得到修复(飞行模式开/关无法解决)。当我的应用程序没有运行时,这不会发生,因此它是由应用程序引起的,尽管logcat在发生此问题时的任何地方都没有显示我的应用程序。
有关如何进一步调试以找到问题根源的任何线索?
PS:这个日志来自装载Android 4.3的旧款三星Galaxy S4,但是这个问题也出现在其他Android手机版本的手机中。