Fix more ANR caused by LOHService
This commit is contained in:
@@ -90,22 +90,27 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
|||||||
else -> getString(R.string.failure_reason_unknown, reason)
|
else -> getString(R.string.failure_reason_unknown, reason)
|
||||||
})
|
})
|
||||||
Toast.makeText(this@LocalOnlyHotspotService, message, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@LocalOnlyHotspotService, message, Toast.LENGTH_SHORT).show()
|
||||||
Crashlytics.logException(StartFailure(message))
|
startFailure(StartFailure(message))
|
||||||
updateNotification()
|
|
||||||
ServiceNotification.stopForeground(this@LocalOnlyHotspotService)
|
|
||||||
}
|
}
|
||||||
}, app.handler)
|
}, app.handler)
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
Crashlytics.logException(e)
|
startFailure(e)
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
Toast.makeText(this, e.message, Toast.LENGTH_LONG).show()
|
Toast.makeText(this, e.message, Toast.LENGTH_LONG).show()
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
Crashlytics.logException(e)
|
startFailure(e)
|
||||||
}
|
}
|
||||||
return START_STICKY
|
return START_STICKY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun startFailure(e: Exception) {
|
||||||
|
Crashlytics.logException(e)
|
||||||
|
updateNotification()
|
||||||
|
ServiceNotification.stopForeground(this@LocalOnlyHotspotService)
|
||||||
|
stopSelf()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
unregisterReceiver()
|
unregisterReceiver()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|||||||
Reference in New Issue
Block a user