Loading app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +27 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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<SystemAppProject>() private fun getUpdatableSystemApps(): List<String> { Loading Loading @@ -80,7 +90,6 @@ class SystemAppsUpdatesRepository @Inject constructor( } } private fun isEligibleToFetchAppListFromTest(systemName: String) = systemName.isBlank() || systemName.contains("beta") || systemName.contains("rc") || Loading Loading @@ -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<Application> { val updateList = mutableListOf<Application>() val releaseType = getSystemReleaseType() Loading Loading
app/src/main/java/foundation/e/apps/data/gitlab/SystemAppsUpdatesRepository.kt +27 −2 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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<SystemAppProject>() private fun getUpdatableSystemApps(): List<String> { Loading Loading @@ -80,7 +90,6 @@ class SystemAppsUpdatesRepository @Inject constructor( } } private fun isEligibleToFetchAppListFromTest(systemName: String) = systemName.isBlank() || systemName.contains("beta") || systemName.contains("rc") || Loading Loading @@ -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<Application> { val updateList = mutableListOf<Application>() val releaseType = getSystemReleaseType() Loading