From d534f184f8c273353cf8db6e9bae59c7d62441be Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 11:37:04 +0200 Subject: [PATCH 01/29] refactor: rename ReleaseInfo into GitLabReleaseInfo & ReleaseInfoApi into GitLabReleaseInfoApi --- .../{ReleaseInfoApi.kt => GitLabReleaseInfoApi.kt} | 9 ++++++--- .../models/{ReleaseInfo.kt => GitLabReleaseInfo.kt} | 2 +- .../foundation/e/apps/di/network/RetrofitApiModule.kt | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) rename app/src/main/java/foundation/e/apps/data/gitlab/{ReleaseInfoApi.kt => GitLabReleaseInfoApi.kt} (83%) rename app/src/main/java/foundation/e/apps/data/gitlab/models/{ReleaseInfo.kt => GitLabReleaseInfo.kt} (98%) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/ReleaseInfoApi.kt b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt similarity index 83% rename from app/src/main/java/foundation/e/apps/data/gitlab/ReleaseInfoApi.kt rename to app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt index 4b2a3fbf7..3bb2436ac 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/ReleaseInfoApi.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt @@ -17,12 +17,15 @@ package foundation.e.apps.data.gitlab -import foundation.e.apps.data.gitlab.models.ReleaseInfo +import foundation.e.apps.data.gitlab.models.GitLabReleaseInfo import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Path -interface ReleaseInfoApi { +/* +provide Client method for https://docs.gitlab.com/ee/api/releases/ + */ +interface GitLabReleaseInfoApi { companion object { const val BASE_URL = @@ -32,6 +35,6 @@ interface ReleaseInfoApi { @GET("{projectId}/releases") suspend fun getReleases( @Path("projectId") projectId: Int, - ): Response> + ): Response> } diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/models/ReleaseInfo.kt b/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt similarity index 98% rename from app/src/main/java/foundation/e/apps/data/gitlab/models/ReleaseInfo.kt rename to app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt index 6284fe92a..3dc818004 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/models/ReleaseInfo.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt @@ -19,7 +19,7 @@ package foundation.e.apps.data.gitlab.models import com.squareup.moshi.Json -data class ReleaseInfo( +data class GitLabReleaseInfo( val name: String, @Json(name = "released_at") val releasedAt: String, diff --git a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt index 136add811..678030ded 100644 --- a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt @@ -29,7 +29,7 @@ import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.ecloud.EcloudApiInterface import foundation.e.apps.data.exodus.ExodusTrackerApi import foundation.e.apps.data.fdroid.FdroidApiInterface -import foundation.e.apps.data.gitlab.ReleaseInfoApi +import foundation.e.apps.data.gitlab.GitLabReleaseInfoApi import foundation.e.apps.data.gitlab.UpdatableSystemAppsApi import foundation.e.apps.data.gitlab.SystemAppDefinitionApi import foundation.e.apps.data.parentalcontrol.fdroid.FDroidMonitorApi @@ -153,13 +153,13 @@ class RetrofitApiModule { fun provideReleaseInfoApi( okHttpClient: OkHttpClient, moshi: Moshi, - ): ReleaseInfoApi { + ): GitLabReleaseInfoApi { return Retrofit.Builder() - .baseUrl(ReleaseInfoApi.BASE_URL) + .baseUrl(GitLabReleaseInfoApi.BASE_URL) .client(okHttpClient) .addConverterFactory(MoshiConverterFactory.create(moshi)) .build() - .create(ReleaseInfoApi::class.java) + .create(GitLabReleaseInfoApi::class.java) } @Singleton -- GitLab From 0338e75e663c7bf1f31bc22902684a996efa49c1 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 11:55:25 +0200 Subject: [PATCH 02/29] feature: add API method to fetch only latest release, & method to feth release based on gitlab tag --- .../e/apps/data/gitlab/GitLabReleaseInfoApi.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt index 3bb2436ac..2cc624053 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt @@ -18,6 +18,7 @@ package foundation.e.apps.data.gitlab import foundation.e.apps.data.gitlab.models.GitLabReleaseInfo +import foundation.e.apps.data.gitlab.models.SystemAppInfo import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Path @@ -37,4 +38,18 @@ interface GitLabReleaseInfoApi { @Path("projectId") projectId: Int, ): Response> + + @GET("{projectId}/releases/{gitlabTag}/downloads/json/{releaseType}.json") + suspend fun getSystemAppInfoByTag( + @Path("projectId") projectId: Int, + @Path("gitlabTag") gitlabTag: String, + @Path("releaseType") releaseType: String, + ): Response + + + @GET("{projectId}/releases/permalink/latest/downloads/json/{releaseType}.json") + suspend fun getLatestSystemAppInfo( + @Path("projectId") projectId: Int, + @Path("releaseType") releaseType: String, + ): Response } -- GitLab From fbbfc24ef41a3c0bff530550db58300a66ef999f Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 11:56:36 +0200 Subject: [PATCH 03/29] feature(SystemAppProject.kt): add optional boolean field to know if a project has different version based on Android version --- .../foundation/e/apps/data/gitlab/models/SystemAppProject.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/models/SystemAppProject.kt b/app/src/main/java/foundation/e/apps/data/gitlab/models/SystemAppProject.kt index edc7f2bff..054a869f5 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/models/SystemAppProject.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/models/SystemAppProject.kt @@ -20,4 +20,5 @@ package foundation.e.apps.data.gitlab.models data class SystemAppProject( val packageName: String, val projectId: Int, + val dependsOnAndroidVersion: Boolean = false ) -- GitLab From b4d0d2d82f11377dc6b1a6b95d8967025f11fe73 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 12:01:48 +0200 Subject: [PATCH 04/29] feature(GitLabReleaseInfo.kt): add new field: tag_name --- .../e/apps/data/gitlab/models/GitLabReleaseInfo.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt b/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt index 3dc818004..840db0bf5 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt @@ -18,11 +18,12 @@ package foundation.e.apps.data.gitlab.models import com.squareup.moshi.Json +import java.time.Instant data class GitLabReleaseInfo( val name: String, - @Json(name = "released_at") - val releasedAt: String, + @Json(name = "tag_name") val tagName: String, + @Json(name = "released_at") val releasedAt: Instant, val assets: ReleaseAssets, ) { fun getAssetWebLink(assetName: String): String? { -- GitLab From 61f34bfd50ca8cfa22ed580556d8007f75538b5f Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 11 Oct 2024 11:50:22 +0200 Subject: [PATCH 05/29] feature: Add InstantJsonParser class, to let moshi parse date from gitlab release API --- .../e/apps/di/network/InstantJsonAdapter.kt | 21 +++++++++++++++++++ .../e/apps/di/network/NetworkModule.kt | 1 + 2 files changed, 22 insertions(+) create mode 100644 app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt diff --git a/app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt b/app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt new file mode 100644 index 000000000..4308873da --- /dev/null +++ b/app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt @@ -0,0 +1,21 @@ +package foundation.e.apps.di.network + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.time.Instant +import java.time.format.DateTimeFormatter + +//todo Instant is not available in Android API 25 which is the minimum used. +// 3 option: replace Instant by another class, use a third party library to make retrocompatibility +// or update android minimum api to at least API 26 +class InstantJsonAdapter { + @ToJson + fun toJson(instant: Instant): String { + return DateTimeFormatter.ISO_INSTANT.format(instant) + } + + @FromJson + fun fromJson(instantString: String): Instant { + return Instant.parse(instantString) + } +} \ No newline at end of file diff --git a/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt index 6fbf75e99..9ec6d149b 100644 --- a/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt @@ -49,6 +49,7 @@ object NetworkModule { @Provides fun getMoshi(): Moshi { return Moshi.Builder() + .add(InstantJsonAdapter()) .add(KotlinJsonAdapterFactory()) .build() } -- GitLab From 1c3853a9ca8a849d97f5a82b5191e9789964726a Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 16:04:25 +0200 Subject: [PATCH 06/29] refactor(SystemAppUpdatesRepository.kt): rextract code into dedicated method for better readibility --- .../data/gitlab/SystemAppsUpdatesRepository.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index c928cface..be21d3105 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -55,13 +55,7 @@ class SystemAppsUpdatesRepository @Inject constructor( return@handleNetworkResult } - val systemName = getFullSystemName() - val endPoint = if (isEligibleToFetchAppListFromTest(systemName)) { - UpdatableSystemAppsApi.EndPoint.ENDPOINT_TEST - } else { - UpdatableSystemAppsApi.EndPoint.ENDPOINT_RELEASE - } - + val endPoint = getUpdatableSystemAppEndPoint() val response = updatableSystemAppsApi.getUpdatableSystemApps(endPoint) if (response.isSuccessful && !response.body().isNullOrEmpty()) { @@ -77,6 +71,16 @@ class SystemAppsUpdatesRepository @Inject constructor( } } + private fun getUpdatableSystemAppEndPoint(): UpdatableSystemAppsApi.EndPoint { + val systemName = getFullSystemName() + return if (isEligibleToFetchAppListFromTest(systemName)) { + UpdatableSystemAppsApi.EndPoint.ENDPOINT_TEST + } else { + UpdatableSystemAppsApi.EndPoint.ENDPOINT_RELEASE + } + } + + private fun isEligibleToFetchAppListFromTest(systemName: String) = systemName.isBlank() || systemName.contains("beta") || systemName.contains("rc") || -- GitLab From 38dd11b11982552747afcc4b5d0491ccdfd94279 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 16:19:48 +0200 Subject: [PATCH 07/29] feature(SystemAppsUpdatesRepository.kt): add method to get Android version code's letter --- .../gitlab/SystemAppsUpdatesRepository.kt | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index be21d3105..518503e7c 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -33,6 +33,8 @@ import javax.inject.Inject import javax.inject.Singleton import timber.log.Timber +private class UnsupportedAndroidApiException(message: String) : RuntimeException(message) + @Singleton class SystemAppsUpdatesRepository @Inject constructor( @ApplicationContext private val context: Context, @@ -40,9 +42,17 @@ class SystemAppsUpdatesRepository @Inject constructor( private val systemAppDefinitionApi: SystemAppDefinitionApi, private val applicationDataManager: ApplicationDataManager, private val appLoungePackageManager: AppLoungePackageManager, - private val releaseInfoApi: ReleaseInfoApi, + private val releaseInfoApi: GitLabReleaseInfoApi, ) { + private val androidVersionCode by lazy { + try { getAndroidVersionCodeChar() } + catch (exception: RuntimeException) { + Timber.w(exception.message) + "UnsupportedAndroidAPI" + } + } + private val systemAppProjectList = mutableListOf() private fun getUpdatableSystemApps(): List { @@ -80,7 +90,6 @@ class SystemAppsUpdatesRepository @Inject constructor( } } - private fun isEligibleToFetchAppListFromTest(systemName: String) = systemName.isBlank() || systemName.contains("beta") || systemName.contains("rc") || @@ -168,6 +177,22 @@ class SystemAppsUpdatesRepository @Inject constructor( } } + /** + * This method must be updated when Murena or /e/ foundation support new Android version + * or stop to support an old one + */ + fun getAndroidVersionCodeChar(): String { + val baseAPI = Build.VERSION_CODES.BASE + val lastUnsupportedAPI = Build.VERSION_CODES.R + + return when (val currentAPI = Build.VERSION.SDK_INT) { + in baseAPI.. lastUnsupportedAPI -> throw UnsupportedAndroidApiException("Android $currentAPI is not supported anymore") + Build.VERSION_CODES.S -> "S" + Build.VERSION_CODES.TIRAMISU -> "T" + else -> throw UnsupportedAndroidApiException("Android $currentAPI and above is not yet supported") + } + } + suspend fun getSystemUpdates(): List { val updateList = mutableListOf() val releaseType = getSystemReleaseType() -- GitLab From 1af86365bf2ea3edd6bdd373e88c17f995b40ef0 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 17:16:15 +0200 Subject: [PATCH 08/29] feature(SystemAppsUpdatesRepository.kt): filter release based on Android version for project that depend of a specific API --- .../data/gitlab/SystemAppsUpdatesRepository.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 518503e7c..ef20f7960 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -111,15 +111,20 @@ class SystemAppsUpdatesRepository @Inject constructor( private suspend fun getReleaseDetailsUrl( projectId: Int, releaseType: OsReleaseType, + isAndroidApiSpecific: Boolean ): String? { val releaseResponse = releaseInfoApi.getReleases(projectId) - val releases = releaseResponse.body() + val releases = releaseResponse.body()?.toMutableList() if (!releaseResponse.isSuccessful || releases == null) { Timber.e("Failed to fetch releases for project id - $projectId") return null } + if (isAndroidApiSpecific) { + releases.removeIf { !it.tagName.contains("-api$androidVersionCode-")} + } + val sortedReleases = releases.sortedByDescending { it.releasedAt } @@ -140,10 +145,11 @@ class SystemAppsUpdatesRepository @Inject constructor( device: String, ): Application? { - val projectId = - systemAppProjectList.find { it.packageName == packageName }?.projectId ?: return null + val systemAppProject = systemAppProjectList.find { it.packageName == packageName }?: return null + val projectId = systemAppProject.projectId + val isAndroidApiSpecific = systemAppProject.dependsOnAndroidVersion - val detailsUrl = getReleaseDetailsUrl(projectId, releaseType) ?: return null + val detailsUrl = getReleaseDetailsUrl(projectId, releaseType, isAndroidApiSpecific) ?: return null val response = systemAppDefinitionApi.getSystemAppUpdateInfo(detailsUrl) val systemAppInfo = response.body() -- GitLab From 1058e7ccd790124657f172f40a0ef6276bdadaa4 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 23 Oct 2024 17:41:46 +0200 Subject: [PATCH 09/29] feature(SystemAppsUpdatesRepository.kt): finish the implementation & add small refactoring to avoid NPE --- .../gitlab/SystemAppsUpdatesRepository.kt | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index ef20f7960..7a12eb4c0 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -109,10 +109,10 @@ class SystemAppsUpdatesRepository @Inject constructor( } private suspend fun getReleaseDetailsUrl( - projectId: Int, + systemAppProject: SystemAppProject, releaseType: OsReleaseType, - isAndroidApiSpecific: Boolean ): String? { + val projectId = systemAppProject.projectId val releaseResponse = releaseInfoApi.getReleases(projectId) val releases = releaseResponse.body()?.toMutableList() @@ -121,7 +121,7 @@ class SystemAppsUpdatesRepository @Inject constructor( return null } - if (isAndroidApiSpecific) { + if (systemAppProject.dependsOnAndroidVersion) { releases.removeIf { !it.tagName.contains("-api$androidVersionCode-")} } @@ -138,26 +138,19 @@ class SystemAppsUpdatesRepository @Inject constructor( return null } - private suspend fun getSystemAppUpdateInfo( + private suspend fun getApplication( packageName: String, releaseType: OsReleaseType, sdkLevel: Int, device: String, ): Application? { - val systemAppProject = systemAppProjectList.find { it.packageName == packageName }?: return null - val projectId = systemAppProject.projectId - val isAndroidApiSpecific = systemAppProject.dependsOnAndroidVersion - - val detailsUrl = getReleaseDetailsUrl(projectId, releaseType, isAndroidApiSpecific) ?: return null + val systemAppProject = systemAppProjectList.find { it.packageName == packageName } ?: return null + val detailsUrl = getReleaseDetailsUrl(systemAppProject, releaseType) - val response = systemAppDefinitionApi.getSystemAppUpdateInfo(detailsUrl) - val systemAppInfo = response.body() + val systemAppInfo = getSystemAppInfo(packageName, detailsUrl) ?: return null - return if (systemAppInfo == null) { - Timber.e("Null app info for: $packageName, response: ${response.errorBody()?.string()}") - null - } else if (isSystemAppBlocked(systemAppInfo, sdkLevel, device)) { + return if (isSystemAppBlocked(systemAppInfo, sdkLevel, device)) { Timber.e("Blocked system app: $packageName, details: $systemAppInfo") null } else { @@ -165,6 +158,22 @@ class SystemAppsUpdatesRepository @Inject constructor( } } + private suspend fun getSystemAppInfo( + packageName: String, + detailsUrl: String? + ): SystemAppInfo? { + if (detailsUrl.isNullOrEmpty()) return null + + val response = systemAppDefinitionApi.getSystemAppUpdateInfo(detailsUrl) + + return if (response.isSuccessful ) { + response.body() + } else { + Timber.e("Can't get AppInfo for $packageName, response: ${response.errorBody()?.string()}") + null + } + } + private fun getFullSystemName(): String { return SystemInfoProvider.getSystemProperty(SystemInfoProvider.KEY_LINEAGE_VERSION) ?: "" } @@ -187,7 +196,7 @@ class SystemAppsUpdatesRepository @Inject constructor( * This method must be updated when Murena or /e/ foundation support new Android version * or stop to support an old one */ - fun getAndroidVersionCodeChar(): String { + private fun getAndroidVersionCodeChar(): String { val baseAPI = Build.VERSION_CODES.BASE val lastUnsupportedAPI = Build.VERSION_CODES.R @@ -214,7 +223,7 @@ class SystemAppsUpdatesRepository @Inject constructor( } val result = handleNetworkResult { - getSystemAppUpdateInfo( + getApplication( it, releaseType, sdkLevel, -- GitLab From 2019ac8f27a569cb311daf983e230a6b28e4c39a Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 24 Oct 2024 10:18:42 +0200 Subject: [PATCH 10/29] refactor: improve exception catching --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 7a12eb4c0..ca74b6f3a 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -47,8 +47,9 @@ class SystemAppsUpdatesRepository @Inject constructor( private val androidVersionCode by lazy { try { getAndroidVersionCodeChar() } - catch (exception: RuntimeException) { - Timber.w(exception.message) + catch (exception: UnsupportedAndroidApiException) { + Timber.w(exception.message, + "Android API isn't in supported range to update some system apps") "UnsupportedAndroidAPI" } } -- GitLab From ea7bc493d1d1ba5bee5694ca5b4debdafb6bddfd Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 24 Oct 2024 10:26:59 +0200 Subject: [PATCH 11/29] Revert "feature: Add InstantJsonParser class, to let moshi parse date from gitlab release API" This reverts commit 61f34bfd50ca8cfa22ed580556d8007f75538b5f. and also remake the "release_at" field of GitlabReleaseInfo to String instead of Instant. --- .../data/gitlab/models/GitLabReleaseInfo.kt | 2 +- .../e/apps/di/network/InstantJsonAdapter.kt | 21 ------------------- .../e/apps/di/network/NetworkModule.kt | 1 - 3 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt b/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt index 840db0bf5..964236afe 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt @@ -23,7 +23,7 @@ import java.time.Instant data class GitLabReleaseInfo( val name: String, @Json(name = "tag_name") val tagName: String, - @Json(name = "released_at") val releasedAt: Instant, + @Json(name = "released_at") val releasedAt: String, val assets: ReleaseAssets, ) { fun getAssetWebLink(assetName: String): String? { diff --git a/app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt b/app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt deleted file mode 100644 index 4308873da..000000000 --- a/app/src/main/java/foundation/e/apps/di/network/InstantJsonAdapter.kt +++ /dev/null @@ -1,21 +0,0 @@ -package foundation.e.apps.di.network - -import com.squareup.moshi.FromJson -import com.squareup.moshi.ToJson -import java.time.Instant -import java.time.format.DateTimeFormatter - -//todo Instant is not available in Android API 25 which is the minimum used. -// 3 option: replace Instant by another class, use a third party library to make retrocompatibility -// or update android minimum api to at least API 26 -class InstantJsonAdapter { - @ToJson - fun toJson(instant: Instant): String { - return DateTimeFormatter.ISO_INSTANT.format(instant) - } - - @FromJson - fun fromJson(instantString: String): Instant { - return Instant.parse(instantString) - } -} \ No newline at end of file diff --git a/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt index 9ec6d149b..6fbf75e99 100644 --- a/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt @@ -49,7 +49,6 @@ object NetworkModule { @Provides fun getMoshi(): Moshi { return Moshi.Builder() - .add(InstantJsonAdapter()) .add(KotlinJsonAdapterFactory()) .build() } -- GitLab From 40ed0103fc18427b0a713fd9822c8739f8012db6 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 24 Oct 2024 10:30:29 +0200 Subject: [PATCH 12/29] refactor: remove unused method from previous MR than is useless due to another MR --- .../e/apps/data/gitlab/GitLabReleaseInfoApi.kt | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt index 2cc624053..d24ea031c 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt @@ -37,19 +37,4 @@ interface GitLabReleaseInfoApi { suspend fun getReleases( @Path("projectId") projectId: Int, ): Response> - - - @GET("{projectId}/releases/{gitlabTag}/downloads/json/{releaseType}.json") - suspend fun getSystemAppInfoByTag( - @Path("projectId") projectId: Int, - @Path("gitlabTag") gitlabTag: String, - @Path("releaseType") releaseType: String, - ): Response - - - @GET("{projectId}/releases/permalink/latest/downloads/json/{releaseType}.json") - suspend fun getLatestSystemAppInfo( - @Path("projectId") projectId: Int, - @Path("releaseType") releaseType: String, - ): Response } -- GitLab From 25a1cbeef949b8130e3b1af86ab366b48a48c419 Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Thu, 24 Oct 2024 08:58:41 +0000 Subject: [PATCH 13/29] chore: apply suggestion --- .../java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt index d24ea031c..81269cf32 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt @@ -24,7 +24,7 @@ import retrofit2.http.GET import retrofit2.http.Path /* -provide Client method for https://docs.gitlab.com/ee/api/releases/ +Provides GitLab API client method (https://docs.gitlab.com/ee/api/releases/) */ interface GitLabReleaseInfoApi { -- GitLab From f40524d64995f8207a42ced95aca9b03afb24572 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 24 Oct 2024 11:57:47 +0200 Subject: [PATCH 14/29] refactor: change way to detect tag based on Android API --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index ca74b6f3a..645c2e338 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -123,7 +123,8 @@ class SystemAppsUpdatesRepository @Inject constructor( } if (systemAppProject.dependsOnAndroidVersion) { - releases.removeIf { !it.tagName.contains("-api$androidVersionCode-")} + //expects something like: vx.y.z-T for android T + releases.removeIf { !it.tagName.endsWith("-$androidVersionCode")} } val sortedReleases = releases.sortedByDescending { -- GitLab From 17a947b405192b26d66cbaaf1c7f2d0f6e56d150 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 24 Oct 2024 12:00:21 +0200 Subject: [PATCH 15/29] refactor: change name of GitLabReleaseInfo to ReleaseInfo & same for the Api --- .../gitlab/{GitLabReleaseInfoApi.kt => ReleaseInfoApi.kt} | 3 +-- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 2 +- .../models/{GitLabReleaseInfo.kt => ReleaseInfo.kt} | 1 - .../foundation/e/apps/di/network/RetrofitApiModule.kt | 8 ++++---- 4 files changed, 6 insertions(+), 8 deletions(-) rename app/src/main/java/foundation/e/apps/data/gitlab/{GitLabReleaseInfoApi.kt => ReleaseInfoApi.kt} (93%) rename app/src/main/java/foundation/e/apps/data/gitlab/models/{GitLabReleaseInfo.kt => ReleaseInfo.kt} (98%) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt b/app/src/main/java/foundation/e/apps/data/gitlab/ReleaseInfoApi.kt similarity index 93% rename from app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt rename to app/src/main/java/foundation/e/apps/data/gitlab/ReleaseInfoApi.kt index 81269cf32..76062c758 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/GitLabReleaseInfoApi.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/ReleaseInfoApi.kt @@ -18,7 +18,6 @@ package foundation.e.apps.data.gitlab import foundation.e.apps.data.gitlab.models.GitLabReleaseInfo -import foundation.e.apps.data.gitlab.models.SystemAppInfo import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Path @@ -26,7 +25,7 @@ import retrofit2.http.Path /* Provides GitLab API client method (https://docs.gitlab.com/ee/api/releases/) */ -interface GitLabReleaseInfoApi { +interface ReleaseInfoApi { companion object { const val BASE_URL = diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 645c2e338..631cbc181 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -42,7 +42,7 @@ class SystemAppsUpdatesRepository @Inject constructor( private val systemAppDefinitionApi: SystemAppDefinitionApi, private val applicationDataManager: ApplicationDataManager, private val appLoungePackageManager: AppLoungePackageManager, - private val releaseInfoApi: GitLabReleaseInfoApi, + private val releaseInfoApi: ReleaseInfoApi, ) { private val androidVersionCode by lazy { diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt b/app/src/main/java/foundation/e/apps/data/gitlab/models/ReleaseInfo.kt similarity index 98% rename from app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt rename to app/src/main/java/foundation/e/apps/data/gitlab/models/ReleaseInfo.kt index 964236afe..cb51761d0 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/models/GitLabReleaseInfo.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/models/ReleaseInfo.kt @@ -18,7 +18,6 @@ package foundation.e.apps.data.gitlab.models import com.squareup.moshi.Json -import java.time.Instant data class GitLabReleaseInfo( val name: String, diff --git a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt index 678030ded..136add811 100644 --- a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt @@ -29,7 +29,7 @@ import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.ecloud.EcloudApiInterface import foundation.e.apps.data.exodus.ExodusTrackerApi import foundation.e.apps.data.fdroid.FdroidApiInterface -import foundation.e.apps.data.gitlab.GitLabReleaseInfoApi +import foundation.e.apps.data.gitlab.ReleaseInfoApi import foundation.e.apps.data.gitlab.UpdatableSystemAppsApi import foundation.e.apps.data.gitlab.SystemAppDefinitionApi import foundation.e.apps.data.parentalcontrol.fdroid.FDroidMonitorApi @@ -153,13 +153,13 @@ class RetrofitApiModule { fun provideReleaseInfoApi( okHttpClient: OkHttpClient, moshi: Moshi, - ): GitLabReleaseInfoApi { + ): ReleaseInfoApi { return Retrofit.Builder() - .baseUrl(GitLabReleaseInfoApi.BASE_URL) + .baseUrl(ReleaseInfoApi.BASE_URL) .client(okHttpClient) .addConverterFactory(MoshiConverterFactory.create(moshi)) .build() - .create(GitLabReleaseInfoApi::class.java) + .create(ReleaseInfoApi::class.java) } @Singleton -- GitLab From 14ec62c65200f03b1139181c1150e73c3cf796d4 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 24 Oct 2024 12:02:23 +0200 Subject: [PATCH 16/29] chore: apply Jonathan's suggestion --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 631cbc181..69ee3a662 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -148,7 +148,7 @@ class SystemAppsUpdatesRepository @Inject constructor( ): Application? { val systemAppProject = systemAppProjectList.find { it.packageName == packageName } ?: return null - val detailsUrl = getReleaseDetailsUrl(systemAppProject, releaseType) + val detailsUrl = getReleaseDetailsUrl(systemAppProject, releaseType) ?: return null val systemAppInfo = getSystemAppInfo(packageName, detailsUrl) ?: return null @@ -162,10 +162,8 @@ class SystemAppsUpdatesRepository @Inject constructor( private suspend fun getSystemAppInfo( packageName: String, - detailsUrl: String? + detailsUrl: String ): SystemAppInfo? { - if (detailsUrl.isNullOrEmpty()) return null - val response = systemAppDefinitionApi.getSystemAppUpdateInfo(detailsUrl) return if (response.isSuccessful ) { @@ -246,5 +244,4 @@ class SystemAppsUpdatesRepository @Inject constructor( return updateList } - } -- GitLab From 0df40e8ac1cbcb562493f01557bac4e382fc9bf1 Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Thu, 24 Oct 2024 14:48:31 +0000 Subject: [PATCH 17/29] chore: code style. apply suggestion. remove one extra space --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 69ee3a662..43fecbdac 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -166,7 +166,7 @@ class SystemAppsUpdatesRepository @Inject constructor( ): SystemAppInfo? { val response = systemAppDefinitionApi.getSystemAppUpdateInfo(detailsUrl) - return if (response.isSuccessful ) { + return if (response.isSuccessful) { response.body() } else { Timber.e("Can't get AppInfo for $packageName, response: ${response.errorBody()?.string()}") -- GitLab From 43154100a740e52b21ffb680b651162ea7821f18 Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Thu, 24 Oct 2024 14:49:08 +0000 Subject: [PATCH 18/29] refactor: apply Sayantan's suggestion --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 43fecbdac..5166fa7c5 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -124,7 +124,12 @@ class SystemAppsUpdatesRepository @Inject constructor( if (systemAppProject.dependsOnAndroidVersion) { //expects something like: vx.y.z-T for android T - releases.removeIf { !it.tagName.endsWith("-$androidVersionCode")} + releases.removeIf { + !it.tagName.endsWith( + suffix = "-$androidVersionCode", + ignoreCase = true + ) + } } val sortedReleases = releases.sortedByDescending { -- GitLab From 62892489cdd4d6392db0f7d8d49b77ab1dd49868 Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Thu, 24 Oct 2024 14:49:59 +0000 Subject: [PATCH 19/29] refactor: apply Sayantan's suggestion again --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 5166fa7c5..7a7c5bbac 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -202,14 +202,10 @@ class SystemAppsUpdatesRepository @Inject constructor( * or stop to support an old one */ private fun getAndroidVersionCodeChar(): String { - val baseAPI = Build.VERSION_CODES.BASE - val lastUnsupportedAPI = Build.VERSION_CODES.R - return when (val currentAPI = Build.VERSION.SDK_INT) { - in baseAPI.. lastUnsupportedAPI -> throw UnsupportedAndroidApiException("Android $currentAPI is not supported anymore") Build.VERSION_CODES.S -> "S" Build.VERSION_CODES.TIRAMISU -> "T" - else -> throw UnsupportedAndroidApiException("Android $currentAPI and above is not yet supported") + else -> throw UnsupportedAndroidApiException("API level $currentAPI is not supported") } } -- GitLab From 99bd69b83f8c472b83fe9752f64382501043650a Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 25 Oct 2024 10:21:19 +0200 Subject: [PATCH 20/29] refactor: move custom exception to bottom of SystemAppsUpdatesRepository.kt --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 7a7c5bbac..89ce100ab 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -33,8 +33,6 @@ import javax.inject.Inject import javax.inject.Singleton import timber.log.Timber -private class UnsupportedAndroidApiException(message: String) : RuntimeException(message) - @Singleton class SystemAppsUpdatesRepository @Inject constructor( @ApplicationContext private val context: Context, @@ -246,3 +244,5 @@ class SystemAppsUpdatesRepository @Inject constructor( return updateList } } + +private class UnsupportedAndroidApiException(message: String) : RuntimeException(message) \ No newline at end of file -- GitLab From fad57c521e7ca015480cd6e75869ef191d2885e3 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 28 Oct 2024 11:43:12 +0100 Subject: [PATCH 21/29] chore: update gradle: compileSDK to API 34. It is required to access Build.VERSION_CODE.UPSIDE_DOWN_CAKE --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 3320d6921..4336fbf0a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,7 +42,7 @@ def getSentryDsn = { -> } android { - compileSdk 33 + compileSdk 34 defaultConfig { applicationId "foundation.e.apps" -- GitLab From 28b2aca6c74a0f79a3983170672ccc9b49751375 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 28 Oct 2024 11:44:02 +0100 Subject: [PATCH 22/29] feature: support fetching release for Android UPSIDE_DOWN_CAKE --- .../foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 89ce100ab..46b43bee9 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -203,6 +203,7 @@ class SystemAppsUpdatesRepository @Inject constructor( return when (val currentAPI = Build.VERSION.SDK_INT) { Build.VERSION_CODES.S -> "S" Build.VERSION_CODES.TIRAMISU -> "T" + Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> "U" else -> throw UnsupportedAndroidApiException("API level $currentAPI is not supported") } } -- GitLab From d002ca4cbe2426864b3062e95649720918823e71 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 28 Oct 2024 11:47:39 +0100 Subject: [PATCH 23/29] refactor: apply Jonathan's suggestion --- .../data/gitlab/SystemAppsUpdatesRepository.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 46b43bee9..919d271a4 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -113,7 +113,7 @@ class SystemAppsUpdatesRepository @Inject constructor( ): String? { val projectId = systemAppProject.projectId val releaseResponse = releaseInfoApi.getReleases(projectId) - val releases = releaseResponse.body()?.toMutableList() + var releases = releaseResponse.body() if (!releaseResponse.isSuccessful || releases == null) { Timber.e("Failed to fetch releases for project id - $projectId") @@ -121,15 +121,11 @@ class SystemAppsUpdatesRepository @Inject constructor( } if (systemAppProject.dependsOnAndroidVersion) { - //expects something like: vx.y.z-T for android T - releases.removeIf { - !it.tagName.endsWith( - suffix = "-$androidVersionCode", - ignoreCase = true - ) - } + val versionSuffix = "-$androidVersionCode" + releases = releases.filter { isVersionedTag(it.tagName, versionSuffix) } } + val sortedReleases = releases.sortedByDescending { it.releasedAt } @@ -143,6 +139,11 @@ class SystemAppsUpdatesRepository @Inject constructor( return null } + private fun isVersionedTag(tag: String, versionSuffix: String): Boolean { + return tag.endsWith(suffix = versionSuffix, ignoreCase = true) + } + + private suspend fun getApplication( packageName: String, releaseType: OsReleaseType, -- GitLab From 7e1e58c7de02f0854f8fbd8678ac2908687f4628 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 30 Oct 2024 10:47:50 +0100 Subject: [PATCH 24/29] chore: add debug instruction --- .../gitlab/SystemAppsUpdatesRepository.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 919d271a4..bb83cc999 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -122,7 +122,10 @@ class SystemAppsUpdatesRepository @Inject constructor( if (systemAppProject.dependsOnAndroidVersion) { val versionSuffix = "-$androidVersionCode" + Timber.d("Filtering app on $versionSuffix") + Timber.d("Release list's size for $projectId before filtering is: ${releases.size}") releases = releases.filter { isVersionedTag(it.tagName, versionSuffix) } + Timber.d("Release list's size for $projectId after filtering is: ${releases.size}") } @@ -151,10 +154,19 @@ class SystemAppsUpdatesRepository @Inject constructor( device: String, ): Application? { - val systemAppProject = systemAppProjectList.find { it.packageName == packageName } ?: return null - val detailsUrl = getReleaseDetailsUrl(systemAppProject, releaseType) ?: return null + val systemAppProject = systemAppProjectList.find { it.packageName == packageName } ?: run { + Timber.e("Can't find $packageName in System apps") + return null + } + val detailsUrl = getReleaseDetailsUrl(systemAppProject, releaseType) ?: run { + Timber.e("Can't get url for release's detail for $packageName of $releaseType") + return null + } - val systemAppInfo = getSystemAppInfo(packageName, detailsUrl) ?: return null + val systemAppInfo = getSystemAppInfo(packageName, detailsUrl) ?: run { + Timber.e("Can't get system App info for $packageName with $detailsUrl") + return null + } return if (isSystemAppBlocked(systemAppInfo, sdkLevel, device)) { Timber.e("Blocked system app: $packageName, details: $systemAppInfo") @@ -232,6 +244,7 @@ class SystemAppsUpdatesRepository @Inject constructor( ) } + result.data?.run { applicationDataManager.updateStatus(this) updateList.add(this) -- GitLab From 682f4393d43899545ef2e2d26ca7bb2671142edd Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 30 Oct 2024 13:36:43 +0100 Subject: [PATCH 25/29] chore: add more debug --- .../apps/data/gitlab/SystemAppsUpdatesRepository.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index bb83cc999..3ae9cee6f 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -82,9 +82,12 @@ class SystemAppsUpdatesRepository @Inject constructor( private fun getUpdatableSystemAppEndPoint(): UpdatableSystemAppsApi.EndPoint { val systemName = getFullSystemName() + Timber.d("getFullSystemName: $systemName") return if (isEligibleToFetchAppListFromTest(systemName)) { + Timber.d("Use test endpoint") UpdatableSystemAppsApi.EndPoint.ENDPOINT_TEST } else { + Timber.d("Use release end point") UpdatableSystemAppsApi.EndPoint.ENDPOINT_RELEASE } } @@ -119,11 +122,14 @@ class SystemAppsUpdatesRepository @Inject constructor( Timber.e("Failed to fetch releases for project id - $projectId") return null } + Timber.d("getReleaseDetailsUrl: ${systemAppProject.packageName} is android dependent: ${systemAppProject.dependsOnAndroidVersion}") if (systemAppProject.dependsOnAndroidVersion) { val versionSuffix = "-$androidVersionCode" Timber.d("Filtering app on $versionSuffix") Timber.d("Release list's size for $projectId before filtering is: ${releases.size}") + + releases = releases.filter { isVersionedTag(it.tagName, versionSuffix) } Timber.d("Release list's size for $projectId after filtering is: ${releases.size}") } @@ -134,7 +140,9 @@ class SystemAppsUpdatesRepository @Inject constructor( } for (release in sortedReleases) { + Timber.d("releaseType: $releaseType") release.getAssetWebLink("${releaseType}.json")?.run { + Timber.d("release asset web link: $this") return this.removePrefix(SystemAppDefinitionApi.BASE_URL) } } @@ -143,7 +151,9 @@ class SystemAppsUpdatesRepository @Inject constructor( } private fun isVersionedTag(tag: String, versionSuffix: String): Boolean { - return tag.endsWith(suffix = versionSuffix, ignoreCase = true) + val result = tag.endsWith(suffix = versionSuffix, ignoreCase = true) + Timber.d("isVersionedTag ? $result, tag: $tag, versioNSuffix: $versionSuffix") + return result } -- GitLab From ce43502307cd58e82b705912f628407795ff6a54 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 30 Oct 2024 14:44:38 +0100 Subject: [PATCH 26/29] chore: bump version number to be sure it is updated --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 4336fbf0a..1303802f1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ plugins { def versionMajor = 2 def versionMinor = 8 -def versionPatch = 1 +def versionPatch = 3 def getGitHash = { -> def stdOut = new ByteArrayOutputStream() -- GitLab From 74b1ac7b2469430215f41819ae7fd44acf8d9372 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 30 Oct 2024 15:48:15 +0100 Subject: [PATCH 27/29] chore: allow all logcat --- app/src/main/java/foundation/e/apps/AppLoungeApplication.kt | 4 ++-- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt index 12af89dcf..262ba4879 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -91,13 +91,13 @@ class AppLoungeApplication : Application(), Configuration.Provider { Telemetry.init(BuildConfig.SENTRY_DSN, this) plant(object : Timber.Tree() { override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { - if (priority <= Log.WARN && !listOf( + /*if (priority <= Log.WARN && !listOf( TAG_AUTHDATA_DUMP, TAG_APP_INSTALL_STATE ).contains(tag) ) { return - } + }*/ Log.println(priority, tag, message) } }) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 3ae9cee6f..60b91d0ed 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -168,6 +168,8 @@ class SystemAppsUpdatesRepository @Inject constructor( Timber.e("Can't find $packageName in System apps") return null } + Timber.d("") + val detailsUrl = getReleaseDetailsUrl(systemAppProject, releaseType) ?: run { Timber.e("Can't get url for release's detail for $packageName of $releaseType") return null -- GitLab From 33a16bcc2cffe4ffa16cdae383525c3dfaa80d38 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 30 Oct 2024 16:26:52 +0100 Subject: [PATCH 28/29] debug: add instruction for android version checking --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 60b91d0ed..2840024df 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -225,6 +225,8 @@ class SystemAppsUpdatesRepository @Inject constructor( * or stop to support an old one */ private fun getAndroidVersionCodeChar(): String { + Timber.d("getAndroidVersionCodeChar: currentAPI = ${Build.VERSION.SDK_INT}") + Timber.d("VERSION_CODES.S = ${Build.VERSION_CODES.S}") return when (val currentAPI = Build.VERSION.SDK_INT) { Build.VERSION_CODES.S -> "S" Build.VERSION_CODES.TIRAMISU -> "T" -- GitLab From 783f5c58562a67db480181cbd13e90b5754d439b Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 31 Oct 2024 10:10:11 +0100 Subject: [PATCH 29/29] feat: add support for android S_V2 --- .../e/apps/data/gitlab/SystemAppsUpdatesRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt index 2840024df..7d126d412 100644 --- a/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt @@ -228,7 +228,7 @@ class SystemAppsUpdatesRepository @Inject constructor( Timber.d("getAndroidVersionCodeChar: currentAPI = ${Build.VERSION.SDK_INT}") Timber.d("VERSION_CODES.S = ${Build.VERSION_CODES.S}") return when (val currentAPI = Build.VERSION.SDK_INT) { - Build.VERSION_CODES.S -> "S" + Build.VERSION_CODES.S, Build.VERSION_CODES.S_V2 -> "S" Build.VERSION_CODES.TIRAMISU -> "T" Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> "U" else -> throw UnsupportedAndroidApiException("API level $currentAPI is not supported") -- GitLab