mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Improve: migrate to latest dependencies
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ abstract class Module<E>(val service: Service) {
|
||||
return
|
||||
}
|
||||
|
||||
channel.offer(intent)
|
||||
channel.trySend(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user