Skip to content

Commit

Permalink
fixes an exception <process unstable thread limit> Caused by Repeated…
Browse files Browse the repository at this point in the history
… Thread Creation.
  • Loading branch information
DaVinci9196 authored and mar-v-in committed Dec 15, 2023
1 parent c728424 commit 5306588
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.microg.gms.droidguard.core

import android.content.Context
import com.android.volley.NetworkResponse
import com.android.volley.RequestQueue
import com.android.volley.VolleyError
import com.android.volley.toolbox.RequestFuture
import com.android.volley.toolbox.Volley
Expand All @@ -29,7 +30,7 @@ class HandleProxyFactory(private val context: Context) {
private val classMap = hashMapOf<String, Class<*>>()
private val dgDb: DgDatabaseHelper = DgDatabaseHelper(context)
private val version = VersionUtil(context)
private val queue = Volley.newRequestQueue(context)
private val queue = singleVolleyRequestQueue(context)

fun createHandle(packageName: String, flow: String?, callback: GuardCallback, request: DroidGuardResultsRequest?): HandleProxy {
if (!DroidGuardPreferences.isLocalAvailable(context)) throw IllegalAccessException("DroidGuard should not be available locally")
Expand Down Expand Up @@ -220,5 +221,12 @@ class HandleProxyFactory(private val context: Context) {
const val SERVER_URL = "https://www.googleapis.com/androidantiabuse/v1/x/create?alt=PROTO&key=AIzaSyBofcZsgLSS7BOnBjZPEkk4rYwzOIz-lTI"
const val CACHE_FOLDER_NAME = "cache_dg"
val PROD_CERT_HASH = byteArrayOf(61, 122, 18, 35, 1, -102, -93, -99, -98, -96, -29, 67, 106, -73, -64, -119, 107, -5, 79, -74, 121, -12, -34, 95, -25, -62, 63, 50, 108, -113, -103, 74)

@Volatile
private var requestQueue: RequestQueue? = null
fun singleVolleyRequestQueue(context: Context) =
requestQueue ?: synchronized(this) {
requestQueue ?: Volley.newRequestQueue(context).also { requestQueue = it }
}
}
}

0 comments on commit 5306588

Please sign in to comment.