From 352f2d72fa52c6c3c4fdd79d575a071a0da72ad1 Mon Sep 17 00:00:00 2001 From: DaVinci9196 <150454414+DaVinci9196@users.noreply.github.com> Date: Tue, 21 Apr 2026 05:06:19 +0800 Subject: [PATCH] Fix app licensing request returning invalid response (#3398) --- .../main/java/com/android/vending/licensing/LicenseChecker.kt | 4 ++-- .../java/com/android/vending/licensing/LicensingService.kt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.kt b/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.kt index c7760062af..deed9e1d84 100644 --- a/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.kt +++ b/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.kt @@ -155,7 +155,7 @@ suspend fun HttpClient.makeLicenseV2Request( url = "https://play-fe.googleapis.com/fdfe/apps/checkLicenseServerFallback?pkgn=$packageName&vc=$versionCode", headers = buildRequestHeaders(auth, androidId), adapter = GoogleApiResponse.ADAPTER -).payload?.licenseV2Response?.license?.jwt?.let { - // Field present ←→ user has license +).payload?.licenseV2Response?.license?.jwt?.takeIf { it.isNotEmpty() }?.let { + // Field present and non-empty ←→ user has license V2Response(LICENSED, it) } \ No newline at end of file diff --git a/vending-app/src/main/java/com/android/vending/licensing/LicensingService.kt b/vending-app/src/main/java/com/android/vending/licensing/LicensingService.kt index 7942d5eac2..fa4c4707a7 100644 --- a/vending-app/src/main/java/com/android/vending/licensing/LicensingService.kt +++ b/vending-app/src/main/java/com/android/vending/licensing/LicensingService.kt @@ -75,6 +75,7 @@ class LicensingService : Service() { */ if (response?.result == LICENSED && response is V2Response) { val bundle = Bundle() + Log.e(TAG, "checkLicenseV2 jwt: ${response.jwt}") bundle.putString(KEY_V2_RESULT_JWT, response.jwt) try { @@ -143,6 +144,7 @@ class LicensingService : Service() { // Attempt to acquire license if app is free ("auto-purchase") if (isLicensingPurchaseFreeAppsEnabled(this@LicensingService)) { + Log.d(TAG, "Attempting to acquire license for free app $packageName") val firstAccount = accounts[0] if (httpClient.acquireFreeAppLicense( this@LicensingService,