1
1
package com.github.kr328.clash.service
2
2
3
3
import android.content.Context
4
+ import com.github.kr328.clash.common.log.Log
4
5
import com.github.kr328.clash.service.data.Database
5
6
import com.github.kr328.clash.service.data.Imported
6
7
import com.github.kr328.clash.service.data.ImportedDao
@@ -24,6 +25,7 @@ import okhttp3.Request
24
25
import java.io.FileNotFoundException
25
26
import java.math.BigDecimal
26
27
import java.util.*
28
+ import java.util.concurrent.TimeUnit
27
29
28
30
class ProfileManager (private val context : Context ) : IProfileManager,
29
31
CoroutineScope by CoroutineScope (Dispatchers .IO ) {
@@ -151,10 +153,21 @@ class ProfileManager(private val context: Context) : IProfileManager,
151
153
var download: Long = 0
152
154
var total: Long = 0
153
155
var expire: Long = 0
156
+ var interval: Long = old.interval
154
157
155
158
val userinfo = response.headers[" subscription-userinfo" ]
156
- if (response.isSuccessful && userinfo != null ) {
159
+ val updateInterval = response.headers[" profile-update-interval" ]
160
+
161
+ if (updateInterval != null ) {
162
+ try {
163
+ val minutes = updateInterval.toInt() * 60 // Convert hours to minutes
164
+ interval = TimeUnit .MINUTES .toMillis(minutes.toLong())
165
+ } catch (e: NumberFormatException ) {
166
+ Log .w(" Invalid profile update interval value: $updateInterval " , e)
167
+ }
168
+ }
157
169
170
+ if (response.isSuccessful && userinfo != null ) {
158
171
val flags = userinfo.split(" ;" )
159
172
for (flag in flags) {
160
173
val info = flag.split(" =" )
@@ -182,7 +195,7 @@ class ProfileManager(private val context: Context) : IProfileManager,
182
195
old.name,
183
196
old.type,
184
197
old.source,
185
- old. interval,
198
+ interval,
186
199
upload,
187
200
download,
188
201
total,
0 commit comments