Refine code style
This commit is contained in:
@@ -65,12 +65,13 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService(), CoroutineScope {
|
||||
try {
|
||||
Services.wifi.startLocalOnlyHotspot(object : WifiManager.LocalOnlyHotspotCallback() {
|
||||
override fun onStarted(reservation: WifiManager.LocalOnlyHotspotReservation?) {
|
||||
if (reservation == null) onFailed(-2) else {
|
||||
if (reservation == null) return onFailed(-2)
|
||||
this@LocalOnlyHotspotService.reservation = reservation
|
||||
val configuration = binder.configuration!!
|
||||
if (Build.VERSION.SDK_INT < 30 && configuration.isAutoShutdownEnabled) {
|
||||
timeoutMonitor = TetherTimeoutMonitor(configuration.shutdownTimeoutMillis,
|
||||
coroutineContext) { reservation.close() }
|
||||
timeoutMonitor = TetherTimeoutMonitor(configuration.shutdownTimeoutMillis, coroutineContext) {
|
||||
reservation.close()
|
||||
}
|
||||
}
|
||||
// based on: https://android.googlesource.com/platform/packages/services/Car/+/df5cd06/service/src/com/android/car/CarProjectionService.java#160
|
||||
val sticky = registerReceiver(null, IntentFilter(WifiApManager.WIFI_AP_STATE_CHANGED_ACTION))!!
|
||||
@@ -87,12 +88,10 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService(), CoroutineScope {
|
||||
binder.iface = iface
|
||||
launch {
|
||||
check(routingManager == null)
|
||||
routingManager = RoutingManager.LocalOnly(
|
||||
this@LocalOnlyHotspotService, iface).apply { start() }
|
||||
routingManager = RoutingManager.LocalOnly(this@LocalOnlyHotspotService, iface).apply { start() }
|
||||
IpNeighbourMonitor.registerCallback(this@LocalOnlyHotspotService)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStopped() {
|
||||
Timber.d("LOHCallback.onStopped")
|
||||
|
||||
Reference in New Issue
Block a user