Fix: fix time zone

This commit is contained in:
kr328
2021-09-12 11:46:20 +08:00
parent ecfb339680
commit 654c488ed8
8 changed files with 51 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ class ClashService : BaseService() {
install(StaticNotificationModule(self))
install(AppListCacheModule(self))
install(TimeZoneModule(self))
install(SuspendModule(self))
try {

View File

@@ -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 {

View File

@@ -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()
}
}
}