Simplify WifiDoubleLock invocations

This commit is contained in:
Mygod
2019-02-05 17:27:33 +08:00
parent 89559103bf
commit 89a4e9f071
6 changed files with 20 additions and 43 deletions

View File

@@ -15,7 +15,6 @@ import android.os.Looper
import androidx.annotation.StringRes
import androidx.core.content.getSystemService
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.net.wifi.WifiDoubleLock
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.deletePersistentGroup
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.netId
@@ -133,7 +132,6 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
}
}
private var routingManager: RoutingManager? = null
private var locked = false
var status = Status.IDLE
private set(value) {
@@ -277,9 +275,6 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
* startService Step 3
*/
private fun doStart(group: WifiP2pGroup) {
check(!locked)
WifiDoubleLock.acquire()
locked = true
binder.group = group
check(routingManager == null)
routingManager = RoutingManager.LocalOnly(this, group.`interface`!!).apply { initRouting() }
@@ -316,10 +311,6 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
unregisterReceiver()
routingManager?.stop()
routingManager = null
if (locked) {
WifiDoubleLock.release()
locked = false
}
status = Status.IDLE
ServiceNotification.stopForeground(this)
stopSelf()