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

Commit 5f9f229b authored by Hasib Prince's avatar Hasib Prince
Browse files

changed fdroid with cleanapk to check app existance

parent 91d64657
Loading
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import foundation.e.apps.data.cleanapk.data.app.Application
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.fdroid.FdroidWebInterface
import okhttp3.Cache
import okhttp3.Interceptor
import okhttp3.MediaType.Companion.toMediaTypeOrNull
@@ -121,18 +120,6 @@ object RetrofitModule {
            .create(FdroidApiInterface::class.java)
    }

    @Singleton
    @Provides
    fun provideFdroidWebApi(
        okHttpClient: OkHttpClient,
    ): FdroidWebInterface {
        return Retrofit.Builder()
            .baseUrl(FdroidWebInterface.BASE_URL)
            .client(okHttpClient)
            .build()
            .create(FdroidWebInterface::class.java)
    }

    @Singleton
    @Provides
    fun provideEcloudApi(okHttpClient: OkHttpClient, moshi: Moshi): EcloudApiInterface {
+0 −32
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019-2022  MURENA SAS
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.apps.data.fdroid

import okhttp3.ResponseBody
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path

interface FdroidWebInterface {
    companion object {
        const val BASE_URL = "https://f-droid.org/fr/packages/"
    }

    @GET("{packageName}")
    suspend fun getFdroidApp(@Path("packageName") packageName: String): Response<ResponseBody>
}
+2 −4
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import foundation.e.apps.data.enums.Source
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.enums.Type
import foundation.e.apps.data.enums.isUnFiltered
import foundation.e.apps.data.fdroid.FdroidWebInterface
import foundation.e.apps.data.fused.FusedApi.Companion.APP_TYPE_ANY
import foundation.e.apps.data.fused.FusedApi.Companion.APP_TYPE_OPEN
import foundation.e.apps.data.fused.FusedApi.Companion.APP_TYPE_PWA
@@ -82,7 +81,6 @@ class FusedApiImpl @Inject constructor(
    private val pkgManagerModule: PkgManagerModule,
    private val pwaManagerModule: PWAManagerModule,
    private val preferenceManagerModule: PreferenceManagerModule,
    private val fdroidWebInterface: FdroidWebInterface,
    @Named("gplayRepository") private val gplayRepository: GplayStoreRepository,
    @Named("cleanApkAppsRepository") private val cleanApkAppsRepository: CleanApkRepository,
    @Named("cleanApkPWARepository") private val cleanApkPWARepository: CleanApkRepository,
@@ -1046,8 +1044,8 @@ class FusedApiImpl @Inject constructor(
         */
    private suspend fun replaceWithFDroid(gPlayApp: App): FusedApp {
        val gPlayFusedApp = gPlayApp.transformToFusedApp()
        val response = fdroidWebInterface.getFdroidApp(gPlayFusedApp.package_name)
        if (response.isSuccessful) {
        val response = cleanApkAppsRepository.getAppDetails(gPlayApp.packageName)
        if (response != null) {
            val fdroidApp = getCleanApkPackageResult(gPlayFusedApp.package_name)?.apply {
                updateSource()
                isGplayReplaced = true
+3 −7
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import foundation.e.apps.data.enums.FilterLevel
import foundation.e.apps.data.enums.Origin
import foundation.e.apps.data.enums.ResultStatus
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.fdroid.FdroidWebInterface
import foundation.e.apps.data.fused.FusedApiImpl
import foundation.e.apps.data.fused.data.FusedApp
import foundation.e.apps.data.fused.data.FusedHome
@@ -45,6 +44,7 @@ import foundation.e.apps.install.pkg.PkgManagerModule
import foundation.e.apps.util.MainCoroutineRule
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import okhttp3.ResponseBody
import okhttp3.ResponseBody.Companion.toResponseBody
import org.junit.After
import org.junit.Assert.assertEquals
@@ -95,9 +95,6 @@ class FusedApiImplTest {
    @Mock
    private lateinit var gPlayAPIRepository: GplayStoreRepository

    @Mock
    private lateinit var fdroidWebInterface: FdroidWebInterface

    private lateinit var preferenceManagerModule: FakePreferenceModule

    private lateinit var formatterMocked: MockedStatic<Formatter>
@@ -115,7 +112,6 @@ class FusedApiImplTest {
            pkgManagerModule,
            pwaManagerModule,
            preferenceManagerModule,
            fdroidWebInterface,
            gPlayAPIRepository,
            cleanApkAppsRepository,
            cleanApkPWARepository,
@@ -783,8 +779,8 @@ class FusedApiImplTest {
            )
        ).thenReturn(packageNameSearchResponse)

        Mockito.`when`(fdroidWebInterface.getFdroidApp(any()))
            .thenReturn(Response.error(404, "".toResponseBody(null)))
        Mockito.`when`(cleanApkAppsRepository.getAppDetails(any()))
            .thenReturn(Response.error<ResponseBody>(404, "".toResponseBody()))

        Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"), null))
            .thenReturn(gplayLivedata)