Skip to content

Add AIDL to query purchase history inapp products#2872

Merged
tonidero merged 32 commits into
mainfrom
add-aidl-querying-purchase-history-in-app
Dec 15, 2025
Merged

Add AIDL to query purchase history inapp products#2872
tonidero merged 32 commits into
mainfrom
add-aidl-querying-purchase-history-in-app

Conversation

@tonidero

Copy link
Copy Markdown
Contributor

Description

With BC8, we lost the ability of querying consumed one time products, which sometimes we needed to unlock entitlements correctly on a restore, in cases where the products were accidentally consumed. This uses the old AIDL service to be able to query those products instead of using the billing library.

@tonidero tonidero changed the title Add AIDL to query purchase history inapp products [DO NOT MERGE] Add AIDL to query purchase history inapp products Nov 25, 2025
).run()

// For INAPP, use PurchaseHistoryManager (AIDL)
if (productType == BillingClient.ProductType.INAPP) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I changed to use the AIDL only for INAPP purchases since I don't think we care (other than for importing devs from previous migrations) about expired subscriptions. Lmk if you think we should also use it for SUBS for completeness. I was mostly trying to minimize the aspects where this is necessary.

@tonidero

Copy link
Copy Markdown
Contributor Author

This shouldn't be merged yet, but planning to make a beta build with these changes so we can test them more internally. I would appreciate a review before then @RevenueCat/sdk @RevenueCat/catforms

@tonidero tonidero marked this pull request as ready for review November 26, 2025 12:11
@tonidero tonidero requested a review from a team as a code owner November 26, 2025 12:11
@codecov

codecov Bot commented Nov 26, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.28788% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.80%. Comparing base (992bb32) to head (8888068).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...purchases/google/history/PurchaseHistoryManager.kt 87.34% 13 Missing and 8 partials ⚠️
.../com/revenuecat/purchases/google/BillingWrapper.kt 97.77% 0 Missing and 1 partial ⚠️
...uecat/purchases/google/history/BillingConstants.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2872      +/-   ##
==========================================
+ Coverage   78.49%   78.80%   +0.31%     
==========================================
  Files         332      337       +5     
  Lines       12878    13131     +253     
  Branches     1749     1770      +21     
==========================================
+ Hits        10108    10348     +240     
- Misses       2036     2041       +5     
- Partials      734      742       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tonidero tonidero marked this pull request as draft November 26, 2025 13:43
@tonidero

This comment was marked as outdated.

@tonidero tonidero marked this pull request as ready for review November 26, 2025 16:40
Comment thread purchases/build.gradle.kts Outdated
buildConfigField(
type = "boolean",
name = "ENABLE_QUERY_PURCHASE_HISTORY_AIDL",
value = (localProperties["ENABLE_QUERY_PURCHASE_HISTORY_AIDL"] as? String ?: "false"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is currently disabled by default, but we still include the AIDL in the SDK, so we should confirm it wouldn't cause issues with automated app reviews mostly.

@tonidero tonidero requested review from a team, JayShortway and vegaro November 27, 2025 08:25
@pauledwardtang

Copy link
Copy Markdown

Great work RevenueCat team!

Our app is using the anonymous user system, "Share between App User IDs" (legacy), and one-time non-consumable product setup and this fixes the Google Billing Play 8 issue for me. I don't recall our one time product ever being consumable, but restoring purchases was affected by B8 anyway (as noted here).

I gave 9.16.0-alphaaidl01 a try and I verified purchases were restored correctly for my setup.

Screenshot of RevenueCat Debug UI for reference:
https://drive.google.com/file/d/1JJ9RTj2-h_jNi6i9hix1Zm5PT52EnxUL/view?usp=drive_link

@tonidero tonidero changed the title [DO NOT MERGE] Add AIDL to query purchase history inapp products Add AIDL to query purchase history inapp products Dec 5, 2025
…#2898)

### Description
This is based on
#2872

This just makes sure we correctly handle issues when querying products
through the AIDL, by falling back to the billing library mechanisms.
@tonidero tonidero mentioned this pull request Dec 5, 2025
@pauledwardtang

Copy link
Copy Markdown

Quick follow up.

In the pull request I noticed that the AIDL setting is off by default yet I got purchase information regardless.

As a sanity check I re-tested with 9.16.3 and 9.0.0 (fresh install, backups disabled, no backup agent configured) and I now get purchase information when I wasn't before. It's as if something has changed upstream and the issue is resolved for me or I did not test this with the right account / tested incorrectly.

I'm happy to share my app and product identifiers if it'll help.

@tonidero

tonidero commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for sharing that @pauledwardtang. That's actually normal. The initial idea was to merge this disabled and enable later, but we ended up making an alpha and beta releases that has this flag enabled without merging this (in the release PRs themselves). We will however enable this flag before merging this. Thanks again!

@pauledwardtang

Copy link
Copy Markdown

@tonidero

I understand how that would be the case if the properties & key are injected from a CI server, but I'm looking at the generated build config and I don't see that flag is set to true when using the analyzer on a debug APK and a release AAB in Android Studio. I checked if isAIDLEnabled is set somewhere else when instantiating BillingWrapper, but BillingFactory instantiates it with the defaults.

image image

I'm pretty sure I'm missing something here, just letting you know what I see on my end. Either way, the issue seems to have gone away for me regardless of the AIDL fix.

@tonidero

Copy link
Copy Markdown
Contributor Author

@pauledwardtang You're completely right. I just rechecked, and while we did enable the flag in 9.16.0-alphaaidl01, we didn't in the 9.16.0-beta01. We will make another beta release with this fixed. Thank you so much for reporting this!

@tonidero tonidero mentioned this pull request Dec 10, 2025
@tonidero

Copy link
Copy Markdown
Contributor Author

@pauledwardtang We just released 9.16.0-beta02 with a fix for that. Thanks again for reporting that issue!

@tonidero tonidero enabled auto-merge December 15, 2025 12:23
@tonidero tonidero disabled auto-merge December 15, 2025 12:41
@tonidero tonidero merged commit f452c66 into main Dec 15, 2025
22 of 23 checks passed
@tonidero tonidero deleted the add-aidl-querying-purchase-history-in-app branch December 15, 2025 13:26
@tonidero tonidero added the pr:force_minor Forces a minor release label Dec 15, 2025
tonidero added a commit that referenced this pull request Dec 15, 2025
**This is an automatic release.**


### 🔄 Other Changes
* Add AIDL to query purchase history inapp products (#2872) via Toni
Rico (@tonidero)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>
tonidero added a commit that referenced this pull request Mar 18, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Apr 7, 2026
This reverts commit f452c66 PR #2872 .

### Description
We're removing usage of this unofficial APIs. This will result in a
behavior breaking change. Docs for the behavior:
https://www.revenuecat.com/docs/known-store-issues/play-billing-library/restore-consumable-purchases-bc8

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Behavior change for Google Play Billing v8 restores: consumed one-time
purchases may no longer appear during restore since the unofficial AIDL
`getPurchaseHistory` path is removed. Risk is limited to
restore/purchase history behavior; no auth or backend data handling
changes.
> 
> **Overview**
> **Reverts the unofficial AIDL integration used to fetch Play Store
in-app purchase history.** `BillingWrapper.queryPurchaseHistoryAsync` no
longer conditionally queries `IInAppBillingService.getPurchaseHistory`
and instead always runs `QueryPurchaseHistoryUseCase`.
> 
> This removes the `aidl` build feature and the
`ENABLE_QUERY_PURCHASE_HISTORY_AIDL` build config flag, deletes the AIDL
interface and `google/history` implementation (`PurchaseHistoryManager`
+ related models), and drops the associated unit tests that exercised
the AIDL fallback behavior.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e8ec3aa. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:force_minor Forces a minor release pr:other

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants