Remove repeater from UI if it's not supported

This could happen on devices like Chrome OS and Android emulators.
This commit is contained in:
Mygod
2018-12-13 15:04:19 +08:00
parent 6002794905
commit ca1fc946ca
6 changed files with 43 additions and 21 deletions

View File

@@ -64,7 +64,9 @@ class ClientMonitorService : Service(), ServiceConnection, IpNeighbourMonitor.Ca
override fun onCreate() {
super.onCreate()
bindService(Intent(this, RepeaterService::class.java), this, Context.BIND_AUTO_CREATE)
if (RepeaterService.supported) {
bindService(Intent(this, RepeaterService::class.java), this, Context.BIND_AUTO_CREATE)
}
IpNeighbourMonitor.registerCallback(this)
registerReceiver(receiver, IntentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
}
@@ -72,7 +74,7 @@ class ClientMonitorService : Service(), ServiceConnection, IpNeighbourMonitor.Ca
override fun onDestroy() {
unregisterReceiver(receiver)
IpNeighbourMonitor.unregisterCallback(this)
stopAndUnbind(this)
if (RepeaterService.supported) stopAndUnbind(this)
super.onDestroy()
}