summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorKalle Lindström <karl.lindstrom@mullvad.net>2025-08-08 14:38:56 +0200
committerKalle Lindström <karl.lindstrom@mullvad.net>2025-08-08 14:38:56 +0200
commit5fa7b9c60dd03d9d1a1b9a84303e2f1568f08540 (patch)
treeddcb92fbe4950cb928b1be90eefd299b4ecc9d84 /android
parentbfda8cdadc8dca10fea56c51513a1307fc41b9d7 (diff)
parent6bb8ee1ed2307d317b66d00019d97683479a9165 (diff)
downloadmullvadvpn-5fa7b9c60dd03d9d1a1b9a84303e2f1568f08540.tar.xz
mullvadvpn-5fa7b9c60dd03d9d1a1b9a84303e2f1568f08540.zip
Merge branch 'clear-datastore-expirytime-on-logout-droid-2116'
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt9
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt6
2 files changed, 13 insertions, 2 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt
index cc7e255696..ad83484dc1 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt
@@ -34,7 +34,14 @@ class UserPreferencesRepository(
}
}
- // Returns the account expiry time or null if the account expiry has not been set yet.
+ suspend fun clearAccountExpiry() {
+ userPreferencesStore.updateData { prefs ->
+ prefs.toBuilder().setAccountExpiryUnixTimeSeconds(0).build()
+ }
+ }
+
+ // Returns the account expiry time or null if there is no account expiry (e.g. the user
+ // is not logged in on an account).
suspend fun accountExpiry(): ZonedDateTime? =
preferences().let { prefs ->
val expiryTime = prefs.accountExpiryUnixTimeSeconds
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt
index 57ed5c5dd2..1c2bc63eb6 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt
@@ -17,9 +17,13 @@ class ScheduleNotificationAlarmUseCase(
suspend operator fun invoke(context: Context, accountExpiry: ZonedDateTime?) {
val appContext = context.applicationContext
val alarmManager = appContext.getSystemService(AlarmManager::class.java) ?: return
+
cancelExisting(appContext, alarmManager)
- if (accountExpiry == null) return
+ if (accountExpiry == null) {
+ userPreferencesRepository.clearAccountExpiry()
+ return
+ }
val triggerAt =
accountExpiryNotificationTriggerAt(now = ZonedDateTime.now(), expiry = accountExpiry)