Log general failures
This commit is contained in:
@@ -26,6 +26,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
|||||||
|
|
||||||
fun stop() = reservation?.close()
|
fun stop() = reservation?.close()
|
||||||
}
|
}
|
||||||
|
private class StartFailure(message: String) : RuntimeException(message)
|
||||||
|
|
||||||
private val binder = Binder()
|
private val binder = Binder()
|
||||||
private var reservation: WifiManager.LocalOnlyHotspotReservation? = null
|
private var reservation: WifiManager.LocalOnlyHotspotReservation? = null
|
||||||
@@ -76,7 +77,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailed(reason: Int) {
|
override fun onFailed(reason: Int) {
|
||||||
Toast.makeText(this@LocalOnlyHotspotService, getString(R.string.tethering_temp_hotspot_failure,
|
val message = getString(R.string.tethering_temp_hotspot_failure,
|
||||||
when (reason) {
|
when (reason) {
|
||||||
WifiManager.LocalOnlyHotspotCallback.ERROR_NO_CHANNEL ->
|
WifiManager.LocalOnlyHotspotCallback.ERROR_NO_CHANNEL ->
|
||||||
getString(R.string.tethering_temp_hotspot_failure_no_channel)
|
getString(R.string.tethering_temp_hotspot_failure_no_channel)
|
||||||
@@ -87,7 +88,9 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
|||||||
WifiManager.LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED ->
|
WifiManager.LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED ->
|
||||||
getString(R.string.tethering_temp_hotspot_failure_tethering_disallowed)
|
getString(R.string.tethering_temp_hotspot_failure_tethering_disallowed)
|
||||||
else -> getString(R.string.failure_reason_unknown, reason)
|
else -> getString(R.string.failure_reason_unknown, reason)
|
||||||
}), Toast.LENGTH_SHORT).show()
|
})
|
||||||
|
Toast.makeText(this@LocalOnlyHotspotService, message, Toast.LENGTH_SHORT).show()
|
||||||
|
Crashlytics.logException(StartFailure(message))
|
||||||
}
|
}
|
||||||
}, app.handler)
|
}, app.handler)
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
enum class Status {
|
enum class Status {
|
||||||
IDLE, STARTING, ACTIVE
|
IDLE, STARTING, ACTIVE
|
||||||
}
|
}
|
||||||
|
private class Failure(message: String) : RuntimeException(message)
|
||||||
|
|
||||||
inner class Binder : android.os.Binder() {
|
inner class Binder : android.os.Binder() {
|
||||||
val service get() = this@RepeaterService
|
val service get() = this@RepeaterService
|
||||||
@@ -115,13 +116,17 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
binder.statusChanged()
|
binder.statusChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatReason(@StringRes resId: Int, reason: Int) = getString(resId, when (reason) {
|
private fun formatReason(@StringRes resId: Int, reason: Int): String? {
|
||||||
WifiP2pManager.ERROR -> getString(R.string.repeater_failure_reason_error)
|
val result = getString(resId, when (reason) {
|
||||||
WifiP2pManager.P2P_UNSUPPORTED -> getString(R.string.repeater_failure_reason_p2p_unsupported)
|
WifiP2pManager.ERROR -> getString(R.string.repeater_failure_reason_error)
|
||||||
WifiP2pManager.BUSY -> getString(R.string.repeater_failure_reason_busy)
|
WifiP2pManager.P2P_UNSUPPORTED -> getString(R.string.repeater_failure_reason_p2p_unsupported)
|
||||||
WifiP2pManager.NO_SERVICE_REQUESTS -> getString(R.string.repeater_failure_reason_no_service_requests)
|
WifiP2pManager.BUSY -> getString(R.string.repeater_failure_reason_busy)
|
||||||
else -> getString(R.string.failure_reason_unknown, reason)
|
WifiP2pManager.NO_SERVICE_REQUESTS -> getString(R.string.repeater_failure_reason_no_service_requests)
|
||||||
})
|
else -> getString(R.string.failure_reason_unknown, reason)
|
||||||
|
})
|
||||||
|
Crashlytics.logException(Failure(result))
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
@@ -147,8 +152,11 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e: InvocationTargetException) {
|
} catch (e: InvocationTargetException) {
|
||||||
if (oc != 0)
|
if (oc != 0) {
|
||||||
Toast.makeText(this, getString(R.string.repeater_set_oc_failure, e.message), Toast.LENGTH_SHORT).show()
|
val message = getString(R.string.repeater_set_oc_failure, e.message)
|
||||||
|
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
|
||||||
|
Crashlytics.logException(Failure(message))
|
||||||
|
}
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
Crashlytics.logException(e)
|
Crashlytics.logException(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user