Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59e139df authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

check name to use test endpoint

parent 140ebece
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -52,7 +52,14 @@ class SystemAppsUpdatesRepository @Inject constructor(
            if (getUpdatableSystemApps().isNotEmpty() && !forceRefresh) {
                return@handleNetworkResult
            }
            val response = updatableSystemAppsApi.getUpdatableSystemApps()

            val systemName = getFullSystemName()
            val endPoint = if (systemName.contains("beta") || systemName.contains("rc")) {
                UpdatableSystemAppsApi.EndPoint.ENDPOINT_TEST
            } else UpdatableSystemAppsApi.EndPoint.ENDPOINT_RELEASE

            val response = updatableSystemAppsApi.getUpdatableSystemApps(endPoint)

            if (response.isSuccessful && !response.body().isNullOrEmpty()) {
                systemAppProjectList.clear()
                response.body()?.let { systemAppProjectList.addAll(it) }
@@ -103,6 +110,10 @@ class SystemAppsUpdatesRepository @Inject constructor(
        }
    }

    private fun getFullSystemName(): String {
        return SystemInfoProvider.getSystemProperty(SystemInfoProvider.KEY_LINEAGE_VERSION) ?: ""
    }

    private fun getSdkLevel(): Int {
        return Build.VERSION.SDK_INT
    }
+14 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package foundation.e.apps.data.gitlab
import foundation.e.apps.data.gitlab.models.SystemAppProject
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path

interface UpdatableSystemAppsApi {

@@ -28,7 +29,18 @@ interface UpdatableSystemAppsApi {
            "https://gitlab.e.foundation/e/os/system-apps-update-info/-/raw/main/"
    }

    @GET("updatable_system_apps.json?inline=false")
    suspend fun getUpdatableSystemApps(): Response<List<SystemAppProject>>
    enum class EndPoint(private val value: String) {
        ENDPOINT_RELEASE("updatable_system_apps.json"),
        ENDPOINT_TEST("updatable_system_apps_test.json"),
        ;
        override fun toString(): String {
            return value
        }
    }

    @GET("{endPoint}?inline=false")
    suspend fun getUpdatableSystemApps(
        @Path("endPoint") endPoint: EndPoint = EndPoint.ENDPOINT_RELEASE
    ): Response<List<SystemAppProject>>

}