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

Verified Commit 2c65f604 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: remove cache from GPlayHttpClient

When a limited response is sent by GPlay API, it's cached and served for subsequent network calls. Hence, the details response couldn't be fetch to proceed with the installation.

Removing the cache forces the OkHttpClient for GPlay to retrieve new response every time a new request is made.
parent 05ae0dcf
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import okhttp3.Cache
import okhttp3.Headers.Companion.toHeaders
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
@@ -49,7 +48,6 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject

class GPlayHttpClient @Inject constructor(
    private val cache: Cache,
    loggingInterceptor: HttpLoggingInterceptor
) : IHttpClient {

@@ -77,7 +75,6 @@ class GPlayHttpClient @Inject constructor(
        .callTimeout(HTTP_TIMEOUT_IN_SECOND, TimeUnit.SECONDS)
        .followRedirects(true)
        .followSslRedirects(true)
        .cache(cache)
        .addInterceptor(loggingInterceptor)
        .build()

@@ -212,7 +209,6 @@ class GPlayHttpClient @Inject constructor(
                }

                STATUS_CODE_TOO_MANY_REQUESTS -> MainScope().launch {
                    cache.evictAll()
                    if (url.toString().contains(SEARCH_SUGGEST)) {
                        return@launch
                    }
+2 −6
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import io.mockk.mockkObject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
import okhttp3.Cache
import okhttp3.OkHttpClient
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.logging.HttpLoggingInterceptor
@@ -48,10 +47,7 @@ import org.mockito.kotlin.any
import kotlin.test.assertFailsWith

@OptIn(ExperimentalCoroutinesApi::class)
class GplyHttpClientTest {

    @Mock
    private lateinit var cache: Cache
class GPlayHttpClientTest {

    @Mock
    private lateinit var loggingInterceptor: HttpLoggingInterceptor
@@ -70,7 +66,7 @@ class GplyHttpClientTest {
    @Before
    fun setup() {
        MockitoAnnotations.openMocks(this)
        gPlayHttpClient = GPlayHttpClient(cache, loggingInterceptor)
        gPlayHttpClient = GPlayHttpClient(loggingInterceptor)
        gPlayHttpClient.okHttpClient = this.okHttpClient
        call = FakeCall()
    }