Fix more ANR caused by LOHService

This commit is contained in:
Mygod
2018-06-11 20:22:39 +08:00
parent 5e792b40e7
commit f897368c61

View File

@@ -90,22 +90,27 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
else -> getString(R.string.failure_reason_unknown, reason)
})
Toast.makeText(this@LocalOnlyHotspotService, message, Toast.LENGTH_SHORT).show()
Crashlytics.logException(StartFailure(message))
updateNotification()
ServiceNotification.stopForeground(this@LocalOnlyHotspotService)
startFailure(StartFailure(message))
}
}, app.handler)
} catch (e: IllegalStateException) {
e.printStackTrace()
Crashlytics.logException(e)
startFailure(e)
} catch (e: SecurityException) {
Toast.makeText(this, e.message, Toast.LENGTH_LONG).show()
e.printStackTrace()
Crashlytics.logException(e)
startFailure(e)
}
return START_STICKY
}
private fun startFailure(e: Exception) {
Crashlytics.logException(e)
updateNotification()
ServiceNotification.stopForeground(this@LocalOnlyHotspotService)
stopSelf()
}
override fun onDestroy() {
unregisterReceiver()
super.onDestroy()