|
| 1 | +package com.programminghoch10.LuckyXposed; |
| 2 | + |
| 3 | +import android.app.Activity; |
| 4 | +import android.content.Context; |
| 5 | +import android.os.Handler; |
| 6 | +import android.os.Looper; |
| 7 | +import android.util.Log; |
| 8 | + |
| 9 | +import androidx.annotation.NonNull; |
| 10 | + |
| 11 | +import java.lang.reflect.Proxy; |
| 12 | +import java.util.ArrayList; |
| 13 | +import java.util.List; |
| 14 | + |
| 15 | +import com.android.billingclient.api.AcknowledgePurchaseParams; |
| 16 | +import com.android.billingclient.api.AcknowledgePurchaseResponseListener; |
| 17 | +import com.android.billingclient.api.AlternativeBillingOnlyAvailabilityListener; |
| 18 | +import com.android.billingclient.api.AlternativeBillingOnlyInformationDialogListener; |
| 19 | +import com.android.billingclient.api.AlternativeBillingOnlyReportingDetailsListener; |
| 20 | +import com.android.billingclient.api.BillingClient; |
| 21 | +import com.android.billingclient.api.BillingClientStateListener; |
| 22 | +import com.android.billingclient.api.BillingConfigResponseListener; |
| 23 | +import com.android.billingclient.api.BillingFlowParams; |
| 24 | +import com.android.billingclient.api.BillingResult; |
| 25 | +import com.android.billingclient.api.ConsumeParams; |
| 26 | +import com.android.billingclient.api.ConsumeResponseListener; |
| 27 | +import com.android.billingclient.api.ExternalOfferAvailabilityListener; |
| 28 | +import com.android.billingclient.api.ExternalOfferInformationDialogListener; |
| 29 | +import com.android.billingclient.api.ExternalOfferReportingDetailsListener; |
| 30 | +import com.android.billingclient.api.GetBillingConfigParams; |
| 31 | +import com.android.billingclient.api.InAppMessageParams; |
| 32 | +import com.android.billingclient.api.InAppMessageResponseListener; |
| 33 | +import com.android.billingclient.api.ProductDetails; |
| 34 | +import com.android.billingclient.api.ProductDetailsResponseListener; |
| 35 | +import com.android.billingclient.api.Purchase; |
| 36 | +import com.android.billingclient.api.PurchaseHistoryResponseListener; |
| 37 | +import com.android.billingclient.api.PurchasesResponseListener; |
| 38 | +import com.android.billingclient.api.PurchasesUpdatedListener; |
| 39 | +import com.android.billingclient.api.QueryProductDetailsParams; |
| 40 | +import com.android.billingclient.api.QueryPurchasesParams; |
| 41 | + |
| 42 | +public class BillingClientStub extends BillingClient { |
| 43 | + private static final BillingResult BillingResultOK = |
| 44 | + BillingResult |
| 45 | + .newBuilder() |
| 46 | + .setResponseCode(BillingResponseCode.OK) |
| 47 | + .setDebugMessage("BillingClientStub BillingResultOK") |
| 48 | + .build(); |
| 49 | + private static final String TAG = "Logger"; |
| 50 | + private final Context context; |
| 51 | + private final PurchasesUpdatedListener purchasesUpdatedListener; |
| 52 | + |
| 53 | + BillingClientStub(Context context, PurchasesUpdatedListener purchasesUpdatedListener) { |
| 54 | + super(); |
| 55 | + this.context = context; |
| 56 | + this.purchasesUpdatedListener = purchasesUpdatedListener; |
| 57 | + Log.d(TAG, "BillingClientStub: construct stub"); |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public int getConnectionState() { |
| 62 | + Log.d(TAG, "getConnectionState: "); |
| 63 | + return ConnectionState.CONNECTED; |
| 64 | + } |
| 65 | + |
| 66 | + @NonNull |
| 67 | + @Override |
| 68 | + public BillingResult isFeatureSupported(@NonNull String s) { |
| 69 | + Log.d(TAG, "isFeatureSupported: "); |
| 70 | + return BillingResultOK; |
| 71 | + } |
| 72 | + |
| 73 | + @NonNull |
| 74 | + @Override |
| 75 | + public BillingResult launchBillingFlow(@NonNull Activity activity, @NonNull BillingFlowParams billingFlowParams) { |
| 76 | + Log.d(TAG, "launchBillingFlow: "); |
| 77 | + return BillingResultOK; |
| 78 | + } |
| 79 | + |
| 80 | + @NonNull |
| 81 | + @Override |
| 82 | + public BillingResult showAlternativeBillingOnlyInformationDialog( |
| 83 | + @NonNull Activity activity, |
| 84 | + @NonNull AlternativeBillingOnlyInformationDialogListener alternativeBillingOnlyInformationDialogListener |
| 85 | + ) { |
| 86 | + throw new IllegalStateException("not implemented"); |
| 87 | + } |
| 88 | + |
| 89 | + @NonNull |
| 90 | + @Override |
| 91 | + public BillingResult showExternalOfferInformationDialog( |
| 92 | + @NonNull Activity activity, |
| 93 | + @NonNull ExternalOfferInformationDialogListener externalOfferInformationDialogListener |
| 94 | + ) { |
| 95 | + throw new IllegalStateException("not implemented"); |
| 96 | + } |
| 97 | + |
| 98 | + @NonNull |
| 99 | + @Override |
| 100 | + public BillingResult showInAppMessages( |
| 101 | + @NonNull Activity activity, |
| 102 | + @NonNull InAppMessageParams inAppMessageParams, |
| 103 | + @NonNull InAppMessageResponseListener inAppMessageResponseListener |
| 104 | + ) { |
| 105 | + throw new IllegalStateException("not implemented"); |
| 106 | + } |
| 107 | + |
| 108 | + @Override |
| 109 | + public void acknowledgePurchase( |
| 110 | + @NonNull AcknowledgePurchaseParams acknowledgePurchaseParams, |
| 111 | + @NonNull AcknowledgePurchaseResponseListener acknowledgePurchaseResponseListener |
| 112 | + ) { |
| 113 | + Log.d(TAG, "acknowledgePurchase: "); |
| 114 | + acknowledgePurchaseResponseListener.onAcknowledgePurchaseResponse(BillingResultOK); |
| 115 | + } |
| 116 | + |
| 117 | + @Override |
| 118 | + public void consumeAsync(@NonNull ConsumeParams consumeParams, @NonNull ConsumeResponseListener consumeResponseListener) { |
| 119 | + throw new IllegalStateException("not implemented"); |
| 120 | + } |
| 121 | + |
| 122 | + @Override |
| 123 | + public void createAlternativeBillingOnlyReportingDetailsAsync(@NonNull AlternativeBillingOnlyReportingDetailsListener alternativeBillingOnlyReportingDetailsListener) { |
| 124 | + throw new IllegalStateException("not implemented"); |
| 125 | + } |
| 126 | + |
| 127 | + @Override |
| 128 | + public void createExternalOfferReportingDetailsAsync(@NonNull ExternalOfferReportingDetailsListener externalOfferReportingDetailsListener) { |
| 129 | + throw new IllegalStateException("not implemented"); |
| 130 | + } |
| 131 | + |
| 132 | + @Override |
| 133 | + public void endConnection() { |
| 134 | + Log.d(TAG, "endConnection: "); |
| 135 | + this.isReady = false; |
| 136 | + } |
| 137 | + |
| 138 | + @Override |
| 139 | + public void getBillingConfigAsync( |
| 140 | + @NonNull GetBillingConfigParams getBillingConfigParams, |
| 141 | + @NonNull BillingConfigResponseListener billingConfigResponseListener |
| 142 | + ) { |
| 143 | + throw new IllegalStateException("not implemented"); |
| 144 | + } |
| 145 | + |
| 146 | + @Override |
| 147 | + public void isAlternativeBillingOnlyAvailableAsync(@NonNull AlternativeBillingOnlyAvailabilityListener alternativeBillingOnlyAvailabilityListener) { |
| 148 | + throw new IllegalStateException("not implemented"); |
| 149 | + } |
| 150 | + |
| 151 | + @Override |
| 152 | + public void isExternalOfferAvailableAsync(@NonNull ExternalOfferAvailabilityListener externalOfferAvailabilityListener) { |
| 153 | + throw new IllegalStateException("not implemented"); |
| 154 | + } |
| 155 | + |
| 156 | + @Override |
| 157 | + public void queryProductDetailsAsync( |
| 158 | + @NonNull QueryProductDetailsParams queryProductDetailsParams, |
| 159 | + @NonNull ProductDetailsResponseListener productDetailsResponseListener |
| 160 | + ) { |
| 161 | + throw new IllegalStateException("not implemented"); |
| 162 | + } |
| 163 | + |
| 164 | + @Override |
| 165 | + public void queryPurchasesAsync( |
| 166 | + @NonNull QueryPurchasesParams queryPurchasesParams, |
| 167 | + @NonNull PurchasesResponseListener purchasesResponseListener |
| 168 | + ) { |
| 169 | + throw new IllegalStateException("not implemented"); |
| 170 | + } |
| 171 | + |
| 172 | + BillingClientStateListener billingClientStateListener = null; |
| 173 | + @Override |
| 174 | + public void startConnection(@NonNull BillingClientStateListener billingClientStateListener) { |
| 175 | + Log.d(TAG, "startConnection: "); |
| 176 | + this.billingClientStateListener = billingClientStateListener; |
| 177 | + this.isReady = true; |
| 178 | + billingClientStateListener.onBillingSetupFinished(BillingResultOK); |
| 179 | + } |
| 180 | + |
| 181 | + boolean isReady = false; |
| 182 | + @Override |
| 183 | + public boolean isReady() { |
| 184 | + Log.d(TAG, "isReady: " + isReady); |
| 185 | + return isReady; |
| 186 | + } |
| 187 | + |
| 188 | + public static BillingClientBuilderStub newBuilderStub(@NonNull Context context) { |
| 189 | + return new BillingClientBuilderStub(context); |
| 190 | + } |
| 191 | + |
| 192 | +} |
0 commit comments