fix 订阅地址不同时更新clash配置文件
This commit is contained in:
parent
b5d915bbf3
commit
ab17172b09
|
|
@ -526,7 +526,7 @@ class NewMainActivity : BaseActivity() {
|
|||
android.util.Log.e("Data", "机场URL:=${url}")
|
||||
// var url2="https://www.otcopusapp.cc/lx3af288h5i8pz380/api/v1/client/subscribe?token=d6bc98c7ea53099fa5bd1a3ea415ebb6"
|
||||
if (url.isNotEmpty()) {
|
||||
|
||||
|
||||
subUrl = url
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
// setSub(url)
|
||||
|
|
@ -1122,13 +1122,13 @@ class NewMainActivity : BaseActivity() {
|
|||
profileBinder?.let { pm ->
|
||||
Log.d("setSub2 3")
|
||||
pm.queryAll().forEach { itemPro ->
|
||||
Log.d("setSub2 itemPro ==>${itemPro}")
|
||||
if (itemPro.name != Conf.getClashConfName(this@NewMainActivity.applicationContext)) {
|
||||
Log.d("setSub2 delete ==>${itemPro.name}")
|
||||
pm.delete(itemPro.uuid)
|
||||
}
|
||||
}
|
||||
val pro = pm.queryActive()
|
||||
|
||||
Log.d("setSub2 4")
|
||||
pro?.let {
|
||||
var actname = it.name
|
||||
|
|
@ -1136,40 +1136,55 @@ class NewMainActivity : BaseActivity() {
|
|||
Log.d("setSub2 pro 已存在 ==>")
|
||||
pm.setActive(it)
|
||||
delay(500)
|
||||
if (!TextUtils.isEmpty(pro.source)) {
|
||||
// Log.d("setSub2 pro.source==>${pro.source}, url==>${url}")
|
||||
if (pro.source != url) {
|
||||
Log.d("setSub2 patch")
|
||||
pm.patch(pro.uuid, pro.name, url, 1800000L)
|
||||
pm.commit(pro.uuid) { status ->
|
||||
Log.d("setSub2 updateStatus: " + Gson().toJson(status.args) + ", pro==>" + status.progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
pm.update(it.uuid)
|
||||
|
||||
newUuid = pro.uuid.toString();
|
||||
isSubed = true
|
||||
Log.d("setSub2 setActive end")
|
||||
} ?: run {
|
||||
var uuid: UUID = pm.create(
|
||||
Profile.Type.Url, Conf.getClashConfName(this@NewMainActivity.applicationContext)
|
||||
)
|
||||
delay(500)
|
||||
pm.queryByUUID(uuid)?.let { qPro ->
|
||||
pm.setActive(qPro)
|
||||
pm.patch(
|
||||
qPro.uuid, qPro.name,
|
||||
// "https://mojie0201.xn--8stx8olrwkucjq3b.com/api/v1/client/subscribe?token=169110d2674c49604b7e5b5cea341579",
|
||||
// "https://www.otcopusapp.cc/lx3af288h5i8pz380/api/v1/client/subscribe?token=d6bc98c7ea53099fa5bd1a3ea415ebb6",
|
||||
// "https://reg.bazhuayujiasu.cc/api/v1/client/subscribe?token=7f0f025ab341bcec4822d2c90aadf8b0",
|
||||
url, 1800000L
|
||||
)
|
||||
// coroutineScope {
|
||||
pm.commit(qPro.uuid) { status ->
|
||||
android.util.Log.d(
|
||||
Conf.TAG,
|
||||
"new updateStatus: " + Gson().toJson(status.args) + ", pro==>" + status.progress
|
||||
)
|
||||
}
|
||||
newUuid = qPro.uuid.toString();
|
||||
isSubed = true
|
||||
// }
|
||||
}
|
||||
createMyProfile(pm, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
suspend fun createMyProfile(pm: IProfileManager, url: String) {
|
||||
var uuid: UUID = pm.create(
|
||||
Profile.Type.Url, Conf.getClashConfName(this@NewMainActivity.applicationContext)
|
||||
)
|
||||
delay(500)
|
||||
pm.queryByUUID(uuid)?.let { qPro ->
|
||||
pm.setActive(qPro)
|
||||
pm.patch(
|
||||
qPro.uuid, qPro.name,
|
||||
// "https://mojie0201.xn--8stx8olrwkucjq3b.com/api/v1/client/subscribe?token=169110d2674c49604b7e5b5cea341579",
|
||||
// "https://www.otcopusapp.cc/lx3af288h5i8pz380/api/v1/client/subscribe?token=d6bc98c7ea53099fa5bd1a3ea415ebb6",
|
||||
// "https://reg.bazhuayujiasu.cc/api/v1/client/subscribe?token=7f0f025ab341bcec4822d2c90aadf8b0",
|
||||
url, 1800000L
|
||||
)
|
||||
// coroutineScope {
|
||||
pm.commit(qPro.uuid) { status ->
|
||||
android.util.Log.d(
|
||||
Conf.TAG,
|
||||
"new updateStatus: " + Gson().toJson(status.args) + ", pro==>" + status.progress
|
||||
)
|
||||
}
|
||||
newUuid = qPro.uuid.toString();
|
||||
isSubed = true
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue