Skip to content
Prev Previous commit
Next Next commit
Suppress deprecation warnings for BillowFlowParams.ProrationMode
  • Loading branch information
gmackall authored Jun 15, 2023
commit 7997b5ac1968dd2c5e17d2756b06f37068f1607c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingFlowParams;
import com.android.billingclient.api.BillingFlowParams.ProrationMode;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.ConsumeParams;
import com.android.billingclient.api.ConsumeResponseListener;
Expand Down Expand Up @@ -131,6 +130,7 @@ void onDetachedFromActivity() {
}

@Override
@SuppressWarnings(value = "deprecation")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally we extract deprecated code paths to a minimal helper method that we can mark as deprecated, rather than making a whole large method, since the latter will hide future issues.

This also seems like something we should have an issue and TODO for migrating to the new API.

public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
switch (call.method) {
case MethodNames.IS_READY:
Expand All @@ -156,7 +156,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
(String) call.argument("purchaseToken"),
call.hasArgument("prorationMode")
? (int) call.argument("prorationMode")
: ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY,
: com.android.billingclient.api.BillingFlowParams.ProrationMode
.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY,
result);
break;
case MethodNames.QUERY_PURCHASES_ASYNC:
Expand Down Expand Up @@ -222,6 +223,7 @@ private void queryProductDetailsAsync(
});
}

@SuppressWarnings(value = "deprecation")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same.

private void launchBillingFlow(
String product,
@Nullable String offerToken,
Expand Down Expand Up @@ -273,7 +275,9 @@ private void launchBillingFlow(
}

if (oldProduct == null
&& prorationMode != ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) {
&& prorationMode
!= com.android.billingclient.api.BillingFlowParams.ProrationMode
.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) {
result.error(
"IN_APP_PURCHASE_REQUIRE_OLD_PRODUCT",
"launchBillingFlow failed because oldProduct is null. You must provide a valid oldProduct in order to use a proration mode.",
Expand Down