<commit_before>package com.jernung.plugins.billing;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentSender;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import com.android.vending.billing.IInAppBillingService;

import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaWebView;

import org.apache.cordova.PluginResult;
import org.chromium.content.app.ContentApplication;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;

public class BillingPlugin extends CordovaPlugin implements ServiceConnection {

    private static final String PLUGIN_NAME = "BillingPlugin";

    private CallbackContext mActivityContext;
    private IInAppBillingService mService;

    //    private static final int BILLING_RESPONSE_RESULT_OK = 0;
    //    private static final int BILLING_RESPONSE_RESULT_USER_CANCELED = 1;
    //    private static final int BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE = 2;
    //    private static final int BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE = 3;
    //    private static final int BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE = 4;
    //    private static final int BILLING_RESPONSE_RESULT_DEVELOPER_ERROR = 5;
    //    private static final int BILLING_RESPONSE_RESULT_ERROR = 6;
    //    private static final int BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7;
    //    private static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8;

    @Override
    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
        super.initialize(cordova, webView);

        Log.d(PLUGIN_NAME, "binding package to service");

        // bind billing service to the vending package
        Intent mServiceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        mServiceIntent.setPackage("com.android.vending");
        cordova.getActivity().bindService(mServiceIntent, this, ContentApplication.BIND_AUTO_CREATE);
    }

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if ("getProduct".equals(action)) {
            callbackContext.success(getProduct(args.getString(0), args.getString(1)));
            return true;
        }

        if ("getPurchases".equals(action)) {
            callbackContext.success(getPurchases(args.getString(0)));
            return true;
        }

        if ("makePurchase".equals(action)) {
            callbackContext.sendPluginResult(makePurchase(args.getString(0), args.getString(1)));
            mActivityContext = callbackContext;<commit_msg>Fix bad parameter when binding service intent<commit_after>package com.jernung.plugins.billing;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import com.android.vending.billing.IInAppBillingService;

import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaWebView;

import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;

public class BillingPlugin extends CordovaPlugin implements ServiceConnection {

    private static final String PLUGIN_NAME = "BillingPlugin";

    private CallbackContext mActivityContext;
    private IInAppBillingService mService;

    //    private static final int BILLING_RESPONSE_RESULT_OK = 0;
    //    private static final int BILLING_RESPONSE_RESULT_USER_CANCELED = 1;
    //    private static final int BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE = 2;
    //    private static final int BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE = 3;
    //    private static final int BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE = 4;
    //    private static final int BILLING_RESPONSE_RESULT_DEVELOPER_ERROR = 5;
    //    private static final int BILLING_RESPONSE_RESULT_ERROR = 6;
    //    private static final int BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7;
    //    private static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8;

    @Override
    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
        super.initialize(cordova, webView);

        Log.d(PLUGIN_NAME, "binding package to service");

        // bind billing service to the vending package
        Intent mServiceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        mServiceIntent.setPackage("com.android.vending");
        cordova.getActivity().bindService(mServiceIntent, this, Context.BIND_AUTO_CREATE);
    }

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if ("getProduct".equals(action)) {
            callbackContext.success(getProduct(args.getString(0), args.getString(1)));
            return true;
        }

        if ("getPurchases".equals(action)) {
            callbackContext.success(getPurchases(args.getString(0)));
            return true;
        }

        if ("makePurchase".equals(action)) {
            callbackContext.sendPluginResult(makePurchase(args.getString(0), args.getString(1)));
            mActivityContext = callbackContext;
{'fraction_non_alphanumeric': 0.08267782426778243, 'fraction_numerical': 0.004686192468619247, 'mean_word_length': 4.12961373390558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5084636', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1732, 'n_words': 361}