diff --git a/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt index 41508f7..1803960 100644 --- a/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt +++ b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt @@ -180,8 +180,7 @@ class ProfilesActivity : BaseActivity() { } runClash { clash -> - clash.profileService.addProfile(profile - .copy(lastUpdate = System.currentTimeMillis())) + clash.profileService.touchProfile(profile.id) } } catch (e: Exception) { diff --git a/service/src/main/aidl/com/github/kr328/clash/service/IClashProfileService.aidl b/service/src/main/aidl/com/github/kr328/clash/service/IClashProfileService.aidl index 511b938..986c083 100644 --- a/service/src/main/aidl/com/github/kr328/clash/service/IClashProfileService.aidl +++ b/service/src/main/aidl/com/github/kr328/clash/service/IClashProfileService.aidl @@ -7,5 +7,6 @@ interface IClashProfileService { void setActiveProfile(int id); void addProfile(in ClashProfileEntity profile); void removeProfile(int id); + void touchProfile(int id); ClashProfileEntity queryActiveProfile(); } diff --git a/service/src/main/java/com/github/kr328/clash/service/ClashProfileService.kt b/service/src/main/java/com/github/kr328/clash/service/ClashProfileService.kt index a384dee..8d64133 100644 --- a/service/src/main/java/com/github/kr328/clash/service/ClashProfileService.kt +++ b/service/src/main/java/com/github/kr328/clash/service/ClashProfileService.kt @@ -42,6 +42,10 @@ class ClashProfileService(context: Context, private val master: Master) : master.preformProfileChanged() } + override fun touchProfile(id: Int) { + profileDao.touchProfile(id) + } + override fun queryProfiles(): Array { return profileDao.queryProfiles() } diff --git a/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileDao.kt b/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileDao.kt index ffd7225..2a4f7d8 100644 --- a/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileDao.kt +++ b/service/src/main/java/com/github/kr328/clash/service/data/ClashProfileDao.kt @@ -21,4 +21,7 @@ interface ClashProfileDao { @Query("DELETE FROM profiles WHERE id = :id") fun removeProfile(id: Int) + + @Query("UPDATE profiles SET last_update = :lastUpdate WHERE id = :id") + fun touchProfile(id: Int, lastUpdate: Long = System.currentTimeMillis()) } \ No newline at end of file