Decrease intentFilter

This commit is contained in:
Mygod
2018-05-09 16:00:56 -07:00
parent a5fa9d8801
commit 99d6090ee4
4 changed files with 6 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
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
@@ -10,7 +11,6 @@ import be.mygod.vpnhotspot.net.IpNeighbourMonitor
import be.mygod.vpnhotspot.net.TetheringManager
import be.mygod.vpnhotspot.util.broadcastReceiver
import be.mygod.vpnhotspot.util.debugLog
import be.mygod.vpnhotspot.util.intentFilter
@RequiresApi(26)
class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
@@ -65,7 +65,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
if (reservation == null) onFailed(-2) else {
this@LocalOnlyHotspotService.reservation = reservation
if (!receiverRegistered) {
registerReceiver(receiver, intentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
registerReceiver(receiver, IntentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
receiverRegistered = true
}
}

View File

@@ -33,7 +33,6 @@ import be.mygod.vpnhotspot.net.wifi.P2pSupplicantConfiguration
import be.mygod.vpnhotspot.net.wifi.WifiP2pDialog
import be.mygod.vpnhotspot.util.broadcastReceiver
import be.mygod.vpnhotspot.util.formatAddresses
import be.mygod.vpnhotspot.util.intentFilter
import java.net.NetworkInterface
import java.net.SocketException
import java.util.*
@@ -186,7 +185,7 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
val context = requireContext()
context.bindService(Intent(context, RepeaterService::class.java), this, Context.BIND_AUTO_CREATE)
IpNeighbourMonitor.registerCallback(this)
context.registerReceiver(receiver, intentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
context.registerReceiver(receiver, IntentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
}
override fun onStop() {

View File

@@ -36,7 +36,6 @@ import be.mygod.vpnhotspot.net.TetheringManager
import be.mygod.vpnhotspot.net.wifi.WifiApManager
import be.mygod.vpnhotspot.util.broadcastReceiver
import be.mygod.vpnhotspot.util.formatAddresses
import be.mygod.vpnhotspot.util.intentFilter
import java.lang.reflect.InvocationTargetException
import java.net.NetworkInterface
import java.net.SocketException
@@ -369,7 +368,7 @@ class TetheringFragment : Fragment(), ServiceConnection {
is TetheringService.TetheringBinder -> {
tetheringBinder = service
service.fragment = this
requireContext().registerReceiver(receiver, intentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
requireContext().registerReceiver(receiver, IntentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
while (false) { }
}
is LocalOnlyHotspotService.HotspotBinder -> @TargetApi(26) {

View File

@@ -1,6 +1,7 @@
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
@@ -9,7 +10,6 @@ import be.mygod.vpnhotspot.net.Routing
import be.mygod.vpnhotspot.net.TetheringManager
import be.mygod.vpnhotspot.net.VpnMonitor
import be.mygod.vpnhotspot.util.broadcastReceiver
import be.mygod.vpnhotspot.util.intentFilter
import java.net.InetAddress
import java.net.SocketException
@@ -58,7 +58,7 @@ class TetheringService : IpNeighbourMonitoringService(), VpnMonitor.Callback {
}
if (failed) Toast.makeText(this, getText(R.string.noisy_su_failure), Toast.LENGTH_SHORT).show()
} else if (!receiverRegistered) {
registerReceiver(receiver, intentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
registerReceiver(receiver, IntentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED))
app.cleanRoutings[this] = {
synchronized(routings) {
for (iface in routings.keys) routings[iface] = null