Skip to content

Commit 352f2d7

Browse files
authored
Fix app licensing request returning invalid response (#3398)
1 parent 6283b51 commit 352f2d7

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ suspend fun HttpClient.makeLicenseV2Request(
155155
url = "https://play-fe.googleapis.com/fdfe/apps/checkLicenseServerFallback?pkgn=$packageName&vc=$versionCode",
156156
headers = buildRequestHeaders(auth, androidId),
157157
adapter = GoogleApiResponse.ADAPTER
158-
).payload?.licenseV2Response?.license?.jwt?.let {
159-
// Field present ←→ user has license
158+
).payload?.licenseV2Response?.license?.jwt?.takeIf { it.isNotEmpty() }?.let {
159+
// Field present and non-empty ←→ user has license
160160
V2Response(LICENSED, it)
161161
}

vending-app/src/main/java/com/android/vending/licensing/LicensingService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class LicensingService : Service() {
7575
*/
7676
if (response?.result == LICENSED && response is V2Response) {
7777
val bundle = Bundle()
78+
Log.e(TAG, "checkLicenseV2 jwt: ${response.jwt}")
7879
bundle.putString(KEY_V2_RESULT_JWT, response.jwt)
7980

8081
try {
@@ -143,6 +144,7 @@ class LicensingService : Service() {
143144

144145
// Attempt to acquire license if app is free ("auto-purchase")
145146
if (isLicensingPurchaseFreeAppsEnabled(this@LicensingService)) {
147+
Log.d(TAG, "Attempting to acquire license for free app $packageName")
146148
val firstAccount = accounts[0]
147149
if (httpClient.acquireFreeAppLicense(
148150
this@LicensingService,

0 commit comments

Comments
 (0)