Skip to content

Commit

Permalink
Merge pull request #413 from eduvpn/feature/dependency_updates
Browse files Browse the repository at this point in the history
Bugfixes - adding secure internet server, incorrect notification time
  • Loading branch information
dzolnai authored Feb 5, 2024
2 parents a27fd86 + 665dcd5 commit a78d513
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/nl/eduvpn/app/service/HistoryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import nl.eduvpn.app.entity.CertExpiryTimes;
import nl.eduvpn.app.entity.CurrentServer;
import nl.eduvpn.app.entity.Instance;
import nl.eduvpn.app.entity.Organization;
import nl.eduvpn.app.entity.OrganizationList;
import nl.eduvpn.app.entity.exception.CommonException;
import nl.eduvpn.app.utils.Listener;
Expand Down Expand Up @@ -104,6 +105,10 @@ public CurrentServer getCurrentServer() {
return _memoryCachedOrganizationList;
}

public boolean hasSecureInternetServer() {
return _addedServers.getSecureInternetServer() != null;
}

public void setOrganizationList(@Nullable OrganizationList organizationList) {
_memoryCachedOrganizationList = organizationList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class ConnectionStatusViewModel @Inject constructor(

private fun planExpiryNotification() {
val certExpiryTimes = this.certExpiryTimes ?: return
val endTime = certExpiryTimes.endTime ?: return
val endTime = certExpiryTimes.endTime?.times(1000) ?: return // Multiplying with 1000 to convert seconds to milliseconds
val timeNow = System.currentTimeMillis() / 1000
val notificationTime = certExpiryTimes.notificationTimes.firstOrNull { it > timeNow }
val notificationTime = certExpiryTimes.notificationTimes.firstOrNull { it > timeNow }?.times(1000) // seconds to ms
if (notificationTime != null && vpnService.getStatus() != VPNService.VPNStatus.DISCONNECTED) {
val notificationWindowLength = minOf(endTime - System.currentTimeMillis(), 15 * 60 * 1000L)
alarmManager.setWindow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ class OrganizationSelectionViewModel @Inject constructor(
// We want to be able to handle async failures, so use supervisorScope
// https://kotlinlang.org/docs/reference/coroutines/exception-handling.html#supervision
supervisorScope {
val organizationListDeferred = if (historyService.organizationList == null) {
val organizationListDeferred = if (!historyService.hasSecureInternetServer()) {
connectionState.postValue(ConnectionState.FetchingOrganizations)
async {
val organizationList = organizationService.fetchOrganizations()
historyService.organizationList = organizationList
organizationList
}
} else {
// We can't show any organization servers, user needs to reset to switch.
// We can't show any organization servers (secure internet), user needs to reset to switch.
connectionState.postValue(ConnectionState.FetchingServerList)
CompletableDeferred(OrganizationList(-1L, emptyList()))
}
Expand Down

0 comments on commit a78d513

Please sign in to comment.