@@ -5,6 +5,8 @@ import android.content.Context
55import android.content.Intent
66import android.content.IntentSender
77import android.content.ServiceConnection
8+ import android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS
9+ import android.os.Build
810import android.os.Bundle
911import android.os.IBinder
1012import android.os.RemoteException
@@ -72,9 +74,7 @@ internal class ServiceBillingConnection(
7274 setClassName(BAZAAR_PACKAGE_NAME , BAZAAR_PAYMENT_SERVICE_CLASS_NAME )
7375 }
7476 .takeIf (
75- thisIsTrue = {
76- context.packageManager.queryIntentServices(it, 0 ).isNullOrEmpty().not ()
77- },
77+ thisIsTrue = ::isServiceAvailable,
7878 andIfNot = {
7979 callback.connectionFailed.invoke(BazaarNotFoundException ())
8080 }
@@ -282,6 +282,18 @@ internal class ServiceBillingConnection(
282282 billingService = null
283283 }
284284
285+ private fun isServiceAvailable (intent : Intent ): Boolean {
286+ return context.packageManager.queryIntentServices(intent, 0 ).isNotEmpty() ||
287+ isServiceAvailableInDeepSleep(intent)
288+ }
289+
290+ private fun isServiceAvailableInDeepSleep (intent : Intent ): Boolean {
291+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .N &&
292+ context.packageManager
293+ .queryIntentServices(intent, MATCH_DISABLED_COMPONENTS )
294+ .isNotEmpty()
295+ }
296+
285297 companion object {
286298
287299 private const val BILLING_SERVICE_ACTION = " ir.cafebazaar.pardakht.InAppBillingService.BIND"
0 commit comments