Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAPS thinks it's outdated even though latest version is installed - closed loop disabled #3368

Open
idowolf opened this issue Jun 17, 2024 · 2 comments

Comments

@idowolf
Copy link

idowolf commented Jun 17, 2024

The issue:
When using AAPS for over 30 days, even after updating to the latest version on either master or dev branch (the issue has been reproduced on 3.3.0-dev-b as well as the latest master branch version), closed loop will be disabled and IOB will be limited to 0.0. When checking the logs one log reports "Version Checker: old version".

The cause:
On dev branch, VersionCheckerUtilsImpl.kt this function is deifned:


    private fun checkVersion() =
        if (isConnected()) {
            Thread {
                try {
                    val definition: String = URL("https://raw.githubusercontent.com/nightscout/AndroidAPS/versions/definition.json").readText()
                    val version: String? = AllowedVersions().findByApi(definition, Build.VERSION.SDK_INT)?.optString("supported")
                    compareWithCurrentVersion(version, config.get().VERSION_NAME)

                    // App expiration
                    var endDate = sp.getLong(rh.gs(app.aaps.core.utils.R.string.key_app_expiration) + "_" + config.get().VERSION_NAME, 0)
                    AllowedVersions().findByVersion(definition, config.get().VERSION_NAME)?.let { expirationJson ->
                        AllowedVersions().endDateToMilliseconds(expirationJson.getString("endDate"))?.let { ed ->
                            endDate = ed + T.days(1).msecs()
                            sp.putLong(rh.gs(app.aaps.core.utils.R.string.key_app_expiration) + "_" + config.get().VERSION_NAME, endDate)
                        }
                    }
                    if (endDate != 0L) onExpireDateDetected(config.get().VERSION_NAME, dateUtil.dateString(endDate))

                } catch (e: IOException) {
                    aapsLogger.error(LTag.CORE, "Github master version check error: $e")
                }
            }.start()
        } else
            aapsLogger.debug(LTag.CORE, "Github master version not checked. No connectivity")

The function isConnected() is defined as such:

    private fun isConnected(): Boolean = receiverStatusStore.isConnected

Where the implementation of ReceiverStatusStore (ReceiverStatusStoreImpl.kt) defines isConnected as such:

    override val isConnected: Boolean
        get() = lastNetworkEvent?.wifiConnected ?: false || lastNetworkEvent?.mobileConnected ?: false

However, when this function is called on app launch, there is no network event yet, so this getter returns false.

Potential solution
I solved the issue manually by triggering checkVersion() later, i.e. after 1.5 seconds, and it solved the problem, however a more permanent solution could be triggering checkVersion() whenever there is a network change or at least the first time the network changes to "connected" during the app's lifecycle.

Other details
Recreated on version 3.3.0-dev-b as well as the latest master branch version
My device is Galaxy S23 Ultra

@Philoul
Copy link
Contributor

Philoul commented Jun 18, 2024

How do you explain that it works for thousands of persons?
Do you have a SIM card, within your phone, and/or wifi connection when you launch AAPS?

@vanelsberg
Copy link
Contributor

Never experienced this problem (Galaxy S23 Ultra). Not even on a phone without SIM (WiFi connected only)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants