Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit c34c17b4 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Add additional billing function, more logging

parent 70cfdb76
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ interface IInAppBillingService {
     *        and "subs" for subscriptions)
     * @return RESULT_OK(0) on success and appropriate response code on failures.
     */
    int isBillingSupported(int apiVersion, String packageName, String type);
    int isBillingSupported(int apiVersion, String packageName, String type) = 0;

    /**
     * Provides details of a list of SKUs
@@ -78,7 +78,7 @@ interface IInAppBillingService {
     *                           "title : "Example Title",
     *                           "description" : "This is an example description" }'
     */
    Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
    Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle) = 1;

    /**
     * Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU,
@@ -111,7 +111,7 @@ interface IInAppBillingService {
     *                                  TODO: change this to app-specific keys.
     */
    Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type,
        String developerPayload);
        String developerPayload) = 2;

    /**
     * Returns the current SKUs owned by the user of the type and package name specified along with
@@ -137,7 +137,7 @@ interface IInAppBillingService {
     *                                      next set of in-app purchases. Only set if the
     *                                      user has more owned skus than the current list.
     */
    Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken);
    Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken) = 3;

    /**
     * Consume the last purchase of the given SKU. This will result in this item being removed
@@ -148,12 +148,7 @@ interface IInAppBillingService {
     *        to be consumed
     * @return RESULT_OK(0) if consumption succeeded, appropriate response codes on failures.
     */
    int consumePurchase(int apiVersion, String packageName, String purchaseToken);

    /**
     * This API is currently under development.
     */
    int stub(int apiVersion, String packageName, String type);
    int consumePurchase(int apiVersion, String packageName, String purchaseToken) = 4;

    /**
     * Returns a pending intent to launch the purchase flow for upgrading or downgrading a
@@ -188,5 +183,7 @@ interface IInAppBillingService {
     *                                  TODO: change this to app-specific keys.
     */
    Bundle getBuyIntentToReplaceSkus(int apiVersion, String packageName,
        in List<String> oldSkus, String newSku, String type, String developerPayload);
        in List<String> oldSkus, String newSku, String type, String developerPayload) = 6;

    Bundle queryPurchases(int apiVersion, String packageName, String type, String continuationToken, in Bundle extras) = 10;
}
+25 −11
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;

@@ -14,17 +15,18 @@ import java.util.List;
 * Created by andrew.zhao on 9/19/16.
 */
public class InAppBillingService extends Service {
    private static final String TAG = "FakeInAppStore";

    private final IInAppBillingService.Stub mInAppBillingService = new IInAppBillingService.Stub() {
        @Override
        public int isBillingSupported(int apiVersion, String packageName, String type) throws RemoteException {
            Log.e("fakestore", "issupported");
            Log.d(TAG, "isBillingSupported(" + apiVersion + ", " + packageName + ", " + type + ")");
            return 0;
        }

        @Override
        public Bundle getSkuDetails(int apiVersion, String packageName, String type, Bundle skusBundle) throws RemoteException {
            Log.e("fakestore", "getsku");
            Log.d(TAG, "getSkuDetails(" + apiVersion + ", " + packageName + ", " + type + ")");
            Bundle data = new Bundle();
            data.putInt("RESPONSE_CODE", 0);
            data.putStringArrayList("DETAILS_LIST", new ArrayList<String>());
@@ -33,7 +35,7 @@ public class InAppBillingService extends Service {

        @Override
        public Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type, String developerPayload) throws RemoteException {
            Log.e("fakestore", "getbuy");
            Log.d(TAG, "getBuyIntent(" + apiVersion + ", " + packageName + ", " + sku + ", " + type + ", " + developerPayload + ")");
            Bundle data = new Bundle();
            data.putInt("RESPONSE_CODE", 4);
            return data;
@@ -41,7 +43,7 @@ public class InAppBillingService extends Service {

        @Override
        public Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken) throws RemoteException {
            Log.e("fakestore", "getpurchase");
            Log.d(TAG, "getPurchases(" + apiVersion + ", " + packageName + ", " + type + ", " + continuationToken + ")");
            Bundle data = new Bundle();
            data.putInt("RESPONSE_CODE", 0);
            data.putStringArrayList("INAPP_PURCHASE_ITEM_LIST", new ArrayList<String>());
@@ -52,23 +54,35 @@ public class InAppBillingService extends Service {

        @Override
        public int consumePurchase(int apiVersion, String packageName, String purchaseToken) throws RemoteException {
            Log.e("fakestore", "consumepurchase");
            Log.d(TAG, "consumePurchase(" + apiVersion + ", " + packageName + ", " + purchaseToken + ")");
            return 8;
        }

        @Override
        public int stub(int apiVersion, String packageName, String type) throws RemoteException {
            Log.e("fakestore", "stub");
            return 0;
        public Bundle getBuyIntentToReplaceSkus(int apiVersion, String packageName, List<String> oldSkus, String newSku, String type, String developerPayload) throws RemoteException {
            Log.d(TAG, "getBuyIntentToReplaceSkus(" + apiVersion + ", " + packageName + ", " + newSku + ", " + type + ", " + developerPayload + ")");
            Bundle data = new Bundle();
            data.putInt("RESPONSE_CODE", 4);
            return data;
        }

        @Override
        public Bundle getBuyIntentToReplaceSkus(int apiVersion, String packageName, List<String> oldSkus, String newSku, String type, String developerPayload) throws RemoteException {
            Log.e("fakestore", "getbuyintenttoreplace");
        public Bundle queryPurchases(int apiVersion, String packageName, String type, String continuationToken, Bundle extras) throws RemoteException {
            Log.d(TAG, "queryPurchases(" + apiVersion + ", " + packageName + ", " + type + ", " + continuationToken + ")");
            Bundle data = new Bundle();
            data.putInt("RESPONSE_CODE", 4);
            data.putInt("RESPONSE_CODE", 0);
            data.putStringArrayList("INAPP_PURCHASE_ITEM_LIST", new ArrayList<String>());
            data.putStringArrayList("INAPP_PURCHASE_DATA_LIST", new ArrayList<String>());
            data.putStringArrayList("INAPP_DATA_SIGNATURE_LIST", new ArrayList<String>());
            return data;
        }

        @Override
        public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
            if (super.onTransact(code, data, reply, flags)) return true;
            Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags);
            return false;
        }
    };

    public IBinder onBind(Intent intent) {