mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
add clone support
This commit is contained in:
@@ -6,6 +6,7 @@ import com.github.kr328.clash.service.model.ProfileMetadata;
|
||||
|
||||
interface IProfileService {
|
||||
long acquireUnused(String type);
|
||||
long acquireCloned(long id);
|
||||
void updateMetadata(long id, in ProfileMetadata metadata);
|
||||
void commit(long id, in IStreamCallback callback);
|
||||
void cancel(long id);
|
||||
|
||||
@@ -78,6 +78,16 @@ class ProfileService : BaseService() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun acquireCloned(id: Long): Long {
|
||||
return runBlocking {
|
||||
val clonedId = (ProfileDao.queryAllIds() + pending.keys).max()?.plus(1) ?: 0
|
||||
|
||||
pending[clonedId] = queryMetadataById(id) ?: return@runBlocking -1
|
||||
|
||||
clonedId
|
||||
}
|
||||
}
|
||||
|
||||
override fun queryActive(): ProfileMetadata? {
|
||||
return runBlocking {
|
||||
ProfileDao.queryActive()?.toProfileMetadata(service)
|
||||
|
||||
Reference in New Issue
Block a user