diff --git a/app/build.gradle b/app/build.gradle index 72dada80fb10856b090bf89b75b39461127f189b..836e600a5e7a14b140daa37a34eb41b0d195bf53 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/foundation/e/apps/data/playstore/utils/GPlayHttpClient.kt b/app/src/main/java/foundation/e/apps/data/playstore/utils/GPlayHttpClient.kt index a7e1f3dbb9d60f8bac2834be582fbf188aaceda6..f9e55e6103995216d4ae8e0665ae74f8758a4135 100644 --- a/app/src/main/java/foundation/e/apps/data/playstore/utils/GPlayHttpClient.kt +++ b/app/src/main/java/foundation/e/apps/data/playstore/utils/GPlayHttpClient.kt @@ -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 + 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 } } }