Rename binders

This commit is contained in:
Mygod
2018-05-09 16:36:08 -07:00
parent 3d0b430fa8
commit d7c5dd18a5
7 changed files with 17 additions and 23 deletions

View File

@@ -54,14 +54,11 @@
</intent-filter>
</activity>
<service android:name=".LocalOnlyHotspotService">
</service>
<service android:name=".LocalOnlyHotspotService"/>
<service
android:name=".RepeaterService"
android:directBootAware="true">
</service>
<service android:name=".TetheringService">
</service>
android:directBootAware="true"/>
<service android:name=".TetheringService"/>
<service
android:name=".RepeaterTileService"
android:directBootAware="true"

View File

@@ -3,7 +3,6 @@ package be.mygod.vpnhotspot
import android.content.Intent
import android.content.IntentFilter
import android.net.wifi.WifiManager
import android.os.Binder
import android.support.annotation.RequiresApi
import android.widget.Toast
import be.mygod.vpnhotspot.App.Companion.app
@@ -18,7 +17,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
private const val TAG = "LocalOnlyHotspotService"
}
inner class HotspotBinder : Binder() {
inner class Binder : android.os.Binder() {
var fragment: TetheringFragment? = null
var iface: String? = null
val configuration get() = reservation?.wifiConfiguration
@@ -26,7 +25,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
fun stop() = reservation?.close()
}
private val binder = HotspotBinder()
private val binder = Binder()
private var reservation: WifiManager.LocalOnlyHotspotReservation? = null
private var routingManager: LocalOnlyInterfaceManager? = null
private var receiverRegistered = false

View File

@@ -155,7 +155,7 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
private lateinit var binding: FragmentRepeaterBinding
private val data = Data()
private val adapter = ClientAdapter()
private var binder: RepeaterService.RepeaterBinder? = null
private var binder: RepeaterService.Binder? = null
private var p2pInterface: String? = null
private var tetheredInterfaces = emptySet<String>()
private val receiver = broadcastReceiver { _, intent ->
@@ -197,7 +197,7 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
}
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
val binder = service as RepeaterService.RepeaterBinder
val binder = service as RepeaterService.Binder
this.binder = binder
binder.statusChanged[this] = data::onStatusChanged
binder.groupChanged[this] = data::onGroupChanged

View File

@@ -9,7 +9,6 @@ import android.net.wifi.WpsInfo
import android.net.wifi.p2p.WifiP2pGroup
import android.net.wifi.p2p.WifiP2pInfo
import android.net.wifi.p2p.WifiP2pManager
import android.os.Binder
import android.os.Looper
import android.support.annotation.StringRes
import android.util.Log
@@ -34,7 +33,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
IDLE, STARTING, ACTIVE
}
inner class RepeaterBinder : Binder() {
inner class Binder : android.os.Binder() {
val service get() = this@RepeaterService
val active get() = status == Status.ACTIVE
val statusChanged = StickyEvent0()
@@ -92,7 +91,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
field = value
binder.groupChanged(value)
}
private val binder = RepeaterBinder()
private val binder = Binder()
private var receiverRegistered = false
private val receiver = broadcastReceiver { _, intent ->
when (intent.action) {

View File

@@ -17,7 +17,7 @@ class RepeaterTileService : TileService(), ServiceConnection {
private val tileOff by lazy { Icon.createWithResource(application, R.drawable.ic_quick_settings_tile_off) }
private val tileOn by lazy { Icon.createWithResource(application, R.drawable.ic_quick_settings_tile_on) }
private var binder: RepeaterService.RepeaterBinder? = null
private var binder: RepeaterService.Binder? = null
override fun onStartListening() {
super.onStartListening()
@@ -40,7 +40,7 @@ class RepeaterTileService : TileService(), ServiceConnection {
}
override fun onServiceConnected(name: ComponentName?, service: IBinder) {
val binder = service as RepeaterService.RepeaterBinder
val binder = service as RepeaterService.Binder
this.binder = binder
binder.statusChanged[this] = { updateTile() }
binder.groupChanged[this] = this::updateTile

View File

@@ -320,8 +320,8 @@ class TetheringFragment : Fragment(), ServiceConnection {
private val tetherListener = TetherListener()
private lateinit var binding: FragmentTetheringBinding
private var hotspotBinder: LocalOnlyHotspotService.HotspotBinder? = null
private var tetheringBinder: TetheringService.TetheringBinder? = null
private var hotspotBinder: LocalOnlyHotspotService.Binder? = null
private var tetheringBinder: TetheringService.Binder? = null
val adapter = TetheringAdapter()
private val receiver = broadcastReceiver { _, intent ->
adapter.update(TetheringManager.getTetheredIfaces(intent.extras),
@@ -354,13 +354,13 @@ class TetheringFragment : Fragment(), ServiceConnection {
}
override fun onServiceConnected(name: ComponentName?, service: IBinder?) = when (service) {
is TetheringService.TetheringBinder -> {
is TetheringService.Binder -> {
tetheringBinder = service
service.fragment = this
requireContext().registerReceiver(receiver, IntentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
while (false) { }
}
is LocalOnlyHotspotService.HotspotBinder -> @TargetApi(26) {
is LocalOnlyHotspotService.Binder -> @TargetApi(26) {
hotspotBinder = service
service.fragment = this
adapter.updateLocalOnlyViewHolder()

View File

@@ -2,7 +2,6 @@ package be.mygod.vpnhotspot
import android.content.Intent
import android.content.IntentFilter
import android.os.Binder
import android.widget.Toast
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.net.IpNeighbourMonitor
@@ -19,13 +18,13 @@ class TetheringService : IpNeighbourMonitoringService(), VpnMonitor.Callback {
const val EXTRA_REMOVE_INTERFACE = "interface.remove"
}
inner class TetheringBinder : Binder() {
inner class Binder : android.os.Binder() {
var fragment: TetheringFragment? = null
fun isActive(iface: String): Boolean = synchronized(routings) { routings.keys.contains(iface) }
}
private val binder = TetheringBinder()
private val binder = Binder()
private val routings = HashMap<String, Routing?>()
private var upstream: String? = null
private var dns: List<InetAddress> = emptyList()