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

Commit de5c63cd authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

Merge branch '1111-update_gplay_lib' into 'main'

changes for updated gplay lib (3.2.10)

See merge request !427
parents 66578091 b2463845
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ dependencies {
    api files('libs/splitinstall-lib.jar')

    implementation 'foundation.e.lib:telemetry:0.0.11-alpha'
    implementation 'foundation.e:gplayapi:3.0.1-2'
    implementation "foundation.e:gplayapi:3.2.10-1"
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.fragment:fragment-ktx:1.5.6'
@@ -186,7 +186,7 @@ dependencies {

    //Protobuf and Gson
    implementation 'com.google.code.gson:gson:2.9.0'
    implementation "com.google.protobuf:protobuf-java:3.17.2"
    implementation "com.google.protobuf:protobuf-javalite:3.25.2"

    // ViewPager2 and RecyclerView
    implementation "androidx.viewpager2:viewpager2:1.0.0"
+13 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ import java.io.IOException
import java.net.SocketTimeoutException
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow

class GPlayHttpClient @Inject constructor(
    private val cache: Cache,
@@ -60,8 +63,14 @@ class GPlayHttpClient @Inject constructor(
        const val STATUS_CODE_TOO_MANY_REQUESTS = 429
        private const val URL_SUBSTRING_PURCHASE = "purchase"
        const val STATUS_CODE_TIMEOUT = 408
        private const val INITIAL_RESPONSE_CODE = 100
    }


    private val _responseCode = MutableStateFlow(INITIAL_RESPONSE_CODE)
    override val responseCode: StateFlow<Int>
        get() = _responseCode.asStateFlow()

    @VisibleForTesting
    var okHttpClient = OkHttpClient().newBuilder()
        .retryOnConnectionFailure(false)
@@ -161,6 +170,8 @@ class GPlayHttpClient @Inject constructor(
    }

    private fun processRequest(request: Request): PlayResponse {
        // Reset response code as flow doesn't sends the same value twice
        _responseCode.value = 0
        var response: Response? = null
        return try {
            val call = okHttpClient.newCall(request)
@@ -225,6 +236,8 @@ class GPlayHttpClient @Inject constructor(
            if (!isSuccessful) {
                errorString = response.message
            }

            _responseCode.value = response.code
        }
    }
}