Improve: migrate to latest dependencies

This commit is contained in:
Kr328
2021-05-24 15:57:22 +08:00
parent 4f05ba1ac6
commit 27dc5395e0
31 changed files with 92 additions and 83 deletions

View File

@@ -6,6 +6,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import androidx.core.content.getSystemService
import com.github.kr328.clash.common.Global
import com.github.kr328.clash.common.compat.pendingIntentFlags
import com.github.kr328.clash.common.compat.startForegroundServiceCompat
import com.github.kr328.clash.common.constants.Intents
@@ -16,7 +17,6 @@ import com.github.kr328.clash.service.data.Imported
import com.github.kr328.clash.service.data.ImportedDao
import com.github.kr328.clash.service.model.Profile
import com.github.kr328.clash.service.util.importedDir
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
@@ -27,7 +27,7 @@ class ProfileReceiver : BroadcastReceiver() {
when (intent.action) {
Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MY_PACKAGE_REPLACED,
Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_TIME_CHANGED -> {
GlobalScope.launch {
Global.launch {
reset()
val service = Intent(Intents.ACTION_PROFILE_SCHEDULE_UPDATES)

View File

@@ -28,7 +28,7 @@ class ConfigurationModule(service: Service) : Module<ConfigurationModule.LoadExc
var loaded: UUID? = null
reload.offer(Unit)
reload.trySend(Unit)
while (true) {
val changed: UUID? = select {
@@ -75,6 +75,6 @@ class ConfigurationModule(service: Service) : Module<ConfigurationModule.LoadExc
}
fun reload() {
reload.offer(Unit)
reload.trySend(Unit)
}
}

View File

@@ -39,7 +39,7 @@ abstract class Module<E>(val service: Service) {
return
}
channel.offer(intent)
channel.trySend(intent)
}
}

View File

@@ -36,7 +36,7 @@ class NetworkObserveModule(service: Service) :
override fun onAvailable(network: Network) {
this.network = network
networks.offer(network)
networks.trySend(network)
}
override fun onCapabilitiesChanged(
@@ -49,19 +49,19 @@ class NetworkObserveModule(service: Service) :
if (this.network == network && this.internet != internet) {
this.internet = internet
networks.offer(network)
networks.trySend(network)
}
}
override fun onLost(network: Network) {
if (this.network == network) {
networks.offer(null)
networks.trySend(null)
}
}
override fun onLinkPropertiesChanged(network: Network, linkProperties: LinkProperties) {
if (this.network == network) {
networks.offer(network)
networks.trySend(network)
}
}
}

View File

@@ -7,7 +7,6 @@ import com.github.kr328.clash.common.Global
import com.github.kr328.clash.service.data.migrations.LEGACY_MIGRATION
import com.github.kr328.clash.service.data.migrations.MIGRATIONS
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.lang.ref.SoftReference
import androidx.room.Database as DB
@@ -41,7 +40,7 @@ abstract class Database : RoomDatabase() {
}
init {
GlobalScope.launch(Dispatchers.IO) {
Global.launch(Dispatchers.IO) {
LEGACY_MIGRATION(Global.application)
}
}