Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issues Surrounding tcsPurchase #232

Merged
merged 3 commits into from
Aug 17, 2019

Conversation

masterwok
Copy link
Contributor

This pull request resolves a fixes a few issues surrounding the static field, tcsPurchase in the Android InAppBillingImplementation class.

Changes Proposed in this pull request:

  • HandleActivityResult should use null-conditional access when accessing members of tcsPurchase.
  • HandleActivityResult should use TrySetException() rather than SetException() to avoid InvalidOperationException in the case that the task is in a final state.
  • Try to cancel and then null the tcsPurchase when ConnectAsync() is invoked. This was done to prevent tcsPurcahse from being stuck in a WaitingForActivation TaskStatus state when the activity is destroyed and recreated while the purchase modal is being presented to the user. This was causing all future purchase attempts to return null when invoking PurchaseAsync(). This is reproducible by turning on "Don't Keep Activities" in Developer Options, invoking PurchaseAsync(), backgrounding the application, and then invoking PurchaseAsync() again once the activity returns to the foreground.

masterwok added 3 commits July 8, 2019 22:46
This commit fixes bugs surrounding tcsPurchase in the Andorid
InAppBillingImplementation class.

1. HandleActivityResult uses null-conditional operator to access
tcsPurcahse to avoid NullReferenceException.
2. HandleActivityResult now invokes TrySetException rather than
SetException to avoid InvalidOperationException.
3. ConnectAsync() now invokes TryCancel() and sets tcsPurcahse to null.
This was done to prevent tcsPurcahse from being stuck in a
WaitingForActivation TaskStatus state when the activity is destroyed in
recreated while the purchase modal is being presented to the user. This
was causing all future purchase attempts to return null when invoking
PurchaseAsync().
This commit fixes bugs surrounding tcsPurchase in the Andorid
InAppBillingImplementation class.

1. HandleActivityResult uses null-conditional operator to access
tcsPurcahse to avoid NullReferenceException.
2. HandleActivityResult now invokes TrySetException rather than
SetException to avoid InvalidOperationException.
3. ConnectAsync() now invokes TryCancel() and sets tcsPurcahse to null.
This was done to prevent tcsPurcahse from being stuck in a
WaitingForActivation TaskStatus state when the activity is destroyed in
recreated while the purchase modal is being presented to the user. This
was causing all future purchase attempts to return null when invoking
PurchaseAsync().
@masterwok masterwok changed the title Fix tcs purchase Fix Issues Surrounding tcsPurchase Jul 9, 2019
@jamesmontemagno jamesmontemagno merged commit db29a3b into jamesmontemagno:master Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants