mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Fix: fix time zone
This commit is contained in:
@@ -35,6 +35,7 @@ class ClashService : BaseService() {
|
||||
install(StaticNotificationModule(self))
|
||||
|
||||
install(AppListCacheModule(self))
|
||||
install(TimeZoneModule(self))
|
||||
install(SuspendModule(self))
|
||||
|
||||
try {
|
||||
|
||||
@@ -40,6 +40,7 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
|
||||
install(StaticNotificationModule(self))
|
||||
|
||||
install(AppListCacheModule(self))
|
||||
install(TimeZoneModule(self))
|
||||
install(SuspendModule(self))
|
||||
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.github.kr328.clash.service.clash.module
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import com.github.kr328.clash.core.Clash
|
||||
import java.util.*
|
||||
|
||||
class TimeZoneModule(service: Service) : Module<Unit>(service) {
|
||||
override suspend fun run() {
|
||||
val timeZones = receiveBroadcast {
|
||||
addAction(Intent.ACTION_TIMEZONE_CHANGED)
|
||||
}
|
||||
|
||||
while (true) {
|
||||
val timeZone = TimeZone.getDefault()
|
||||
|
||||
Clash.notifyTimeZoneChanged(timeZone.id, timeZone.rawOffset)
|
||||
|
||||
timeZones.receive()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user