The following code sets up a repetitive alarm to send a heartbeat to a server every five minutes.
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);
}
I then leave the handset connected to power and with very good 4G coverage, and it does send heartbeats every five minutes sharp as intended. However, after a few hours (four or five) it stops sending. The reason is that the network interfaces suddenly disappear. This is what logcat shows:
07-26 13:28:46.690 889 889 E kickstart: ERROR: function: rx_data:517 Read/Write File descriptor returned error: No such device, error code -1
07-26 13:28:46.690 889 889 E kickstart: ERROR: function: main:302 Uploading Image using Sahara protocol failed
07-26 13:28:46.700 832 832 I kickstart-efsks: retval = 256
07-26 13:28:46.700 832 832 E kickstart-efsks: ERROR: ks return code was 256, something failed
07-26 13:28:46.700 832 832 E kickstart-efsks: Back from KS call, something went wrong, trying again
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 : No subsystem found in netlink event
07-26 13:28:46.770 195 664 D NetlinkEvent: Unexpected netlink message. type=0x11
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: attempting to remove unknown iface (rmnet_usb0), ignoring
07-26 13:28:46.810 695 894 D Vpn : interface Removed : 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: File '/dev/efs_bridge' was not found
07-26 13:28:47.711 832 832 E kickstart-efsks: /dev/efs_bridge does not exist.
07-26 13:28:48.101 195 664 W Netd : No subsystem found in netlink event
This looks like a major problem with the efs / usb mappings, and it only gets fixed after a re-start (flight mode on / off does not solve it). This does not happen when my app is not running, so it is caused by the app, though logcat shows nothing about my app anywhere around the time when this problem happens.
Any clue on how to debug this further to find the root of the problem?
PS: this log is from an old Samsung Galaxy S4 loaded with Android 4.3 , but this issue is happening also in other handsets with newer Android versions.