// Path: library/src/main/java/jp/alessandro/android/iab/handler/ErrorHandler.java
// public interface ErrorHandler {
// 
//     void onError(BillingException e);
// }
// 
// Path: library/src/main/java/jp/alessandro/android/iab/handler/StartActivityHandler.java
// public interface StartActivityHandler extends ErrorHandler {
// 
//     void onSuccess();
// }


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.SparseArray;
import com.android.vending.billing.IInAppBillingService;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import jp.alessandro.android.iab.handler.ConsumeItemHandler;
import jp.alessandro.android.iab.handler.ErrorHandler;
import jp.alessandro.android.iab.handler.InventoryHandler;
import jp.alessandro.android.iab.handler.ItemDetailsHandler;
import jp.alessandro.android.iab.handler.PurchaseHandler;
import jp.alessandro.android.iab.handler.PurchasesHandler;
import jp.alessandro.android.iab.handler.StartActivityHandler;
import jp.alessandro.android.iab.logger.Logger;
import jp.alessandro.android.iab.response.PurchaseResponse;
                });
            }
        });
    }

    private PurchaseFlowLauncher createPurchaseFlowLauncher(PurchaseType purchaseType, int requestCode) throws BillingException {
        PurchaseFlowLauncher launcher = mPurchaseFlows.get(requestCode);
        String type;

        if (launcher != null) {
            String message = String.format(Locale.US, Constants.ERROR_MSG_PURCHASE_FLOW_ALREADY_EXISTS, requestCode);
            throw new BillingException(Constants.ERROR_PURCHASE_FLOW_ALREADY_EXISTS, message);
        }

        if (purchaseType == PurchaseType.SUBSCRIPTION) {
            type = Constants.TYPE_SUBSCRIPTION;
        } else {
            type = Constants.TYPE_IN_APP;
        }
        return new PurchaseFlowLauncher(mContext, type);
    }

    private void executeInServiceOnWorkThread(final ServiceBinder.Handler serviceHandler) {
        executeInService(serviceHandler, getWorkHandler());
    }

    private void executeInServiceOnMainThread(final ServiceBinder.Handler serviceHandler) {
        executeInService(serviceHandler, getMainHandler());
    }

// Path: library/src/main/java/jp/alessandro/android/iab/handler/ErrorHandler.java
// public interface ErrorHandler {
// 
//     void onError(BillingException e);
// }
// 
// Path: library/src/main/java/jp/alessandro/android/iab/handler/StartActivityHandler.java
// public interface StartActivityHandler extends ErrorHandler {
// 
//     void onSuccess();
// }


// Path: library/src/main/java/jp/alessandro/android/iab/BillingProcessor.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.SparseArray;
import com.android.vending.billing.IInAppBillingService;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import jp.alessandro.android.iab.handler.ConsumeItemHandler;
import jp.alessandro.android.iab.handler.ErrorHandler;
import jp.alessandro.android.iab.handler.InventoryHandler;
import jp.alessandro.android.iab.handler.ItemDetailsHandler;
import jp.alessandro.android.iab.handler.PurchaseHandler;
import jp.alessandro.android.iab.handler.PurchasesHandler;
import jp.alessandro.android.iab.handler.StartActivityHandler;
import jp.alessandro.android.iab.logger.Logger;
import jp.alessandro.android.iab.response.PurchaseResponse;

                });
            }
        });
    }

    private PurchaseFlowLauncher createPurchaseFlowLauncher(PurchaseType purchaseType, int requestCode) throws BillingException {
        PurchaseFlowLauncher launcher = mPurchaseFlows.get(requestCode);
        String type;

        if (launcher != null) {
            String message = String.format(Locale.US, Constants.ERROR_MSG_PURCHASE_FLOW_ALREADY_EXISTS, requestCode);
            throw new BillingException(Constants.ERROR_PURCHASE_FLOW_ALREADY_EXISTS, message);
        }

        if (purchaseType == PurchaseType.SUBSCRIPTION) {
            type = Constants.TYPE_SUBSCRIPTION;
        } else {
            type = Constants.TYPE_IN_APP;
        }
        return new PurchaseFlowLauncher(mContext, type);
    }

    private void executeInServiceOnWorkThread(final ServiceBinder.Handler serviceHandler) {
        executeInService(serviceHandler, getWorkHandler());
    }

    private void executeInServiceOnMainThread(final ServiceBinder.Handler serviceHandler) {
        executeInService(serviceHandler, getMainHandler());
    }

    private void postBindServiceError(BillingException exception, ErrorHandler handler) {