Skip to content

Commit f67708e

Browse files
author
Chris Bellew
committed
Fixed in app purchasing workflow. Implemented custom layout for chromecast video options. Added icons for remaining menu items.
1 parent b29a010 commit f67708e

21 files changed

+350
-193
lines changed

mobile/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2012 The Android Open Source Project
2+
* Copyright (c) 2012 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,10 +34,11 @@ import android.os.Bundle;
3434
*
3535
* All calls will give a response code with the following possible values
3636
* RESULT_OK = 0 - success
37-
* RESULT_USER_CANCELED = 1 - user pressed back or canceled a dialog
38-
* RESULT_BILLING_UNAVAILABLE = 3 - this billing API version is not supported for the type requested
39-
* RESULT_ITEM_UNAVAILABLE = 4 - requested SKU is not available for purchase
40-
* RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API
37+
* RESULT_USER_CANCELED = 1 - User pressed back or canceled a dialog
38+
* RESULT_SERVICE_UNAVAILABLE = 2 - The network connection is down
39+
* RESULT_BILLING_UNAVAILABLE = 3 - This billing API version is not supported for the type requested
40+
* RESULT_ITEM_UNAVAILABLE = 4 - Requested SKU is not available for purchase
41+
* RESULT_DEVELOPER_ERROR = 5 - Invalid arguments provided to the API
4142
* RESULT_ERROR = 6 - Fatal error during the API action
4243
* RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned
4344
* RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned
@@ -46,11 +47,11 @@ interface IInAppBillingService {
4647
/**
4748
* Checks support for the requested billing API version, package and in-app type.
4849
* Minimum API version supported by this interface is 3.
49-
* @param apiVersion the billing version which the app is using
50+
* @param apiVersion billing API version that the app is using
5051
* @param packageName the package name of the calling app
51-
* @param type type of the in-app item being purchased "inapp" for one-time purchases
52-
* and "subs" for subscription.
53-
* @return RESULT_OK(0) on success, corresponding result code on failures
52+
* @param type type of the in-app item being purchased ("inapp" for one-time purchases
53+
* and "subs" for subscriptions)
54+
* @return RESULT_OK(0) on success and appropriate response code on failures.
5455
*/
5556
int isBillingSupported(int apiVersion, String packageName, String type);
5657

@@ -59,16 +60,23 @@ interface IInAppBillingService {
5960
* Given a list of SKUs of a valid type in the skusBundle, this returns a bundle
6061
* with a list JSON strings containing the productId, price, title and description.
6162
* This API can be called with a maximum of 20 SKUs.
62-
* @param apiVersion billing API version that the Third-party is using
63+
* @param apiVersion billing API version that the app is using
6364
* @param packageName the package name of the calling app
65+
* @param type of the in-app items ("inapp" for one-time purchases
66+
* and "subs" for subscriptions)
6467
* @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST"
6568
* @return Bundle containing the following key-value pairs
66-
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
67-
* failure as listed above.
69+
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
70+
* on failures.
6871
* "DETAILS_LIST" with a StringArrayList containing purchase information
69-
* in JSON format similar to:
70-
* '{ "productId" : "exampleSku", "type" : "inapp", "price" : "$5.00",
71-
* "title : "Example Title", "description" : "This is an example description" }'
72+
* in JSON format similar to:
73+
* '{ "productId" : "exampleSku",
74+
* "type" : "inapp",
75+
* "price" : "$5.00",
76+
* "price_currency": "USD",
77+
* "price_amount_micros": 5000000,
78+
* "title : "Example Title",
79+
* "description" : "This is an example description" }'
7280
*/
7381
Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
7482

@@ -78,26 +86,26 @@ interface IInAppBillingService {
7886
* @param apiVersion billing API version that the app is using
7987
* @param packageName package name of the calling app
8088
* @param sku the SKU of the in-app item as published in the developer console
81-
* @param type the type of the in-app item ("inapp" for one-time purchases
82-
* and "subs" for subscription).
89+
* @param type of the in-app item being purchased ("inapp" for one-time purchases
90+
* and "subs" for subscriptions)
8391
* @param developerPayload optional argument to be sent back with the purchase information
8492
* @return Bundle containing the following key-value pairs
85-
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
86-
* failure as listed above.
93+
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
94+
* on failures.
8795
* "BUY_INTENT" - PendingIntent to start the purchase flow
8896
*
8997
* The Pending intent should be launched with startIntentSenderForResult. When purchase flow
9098
* has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
9199
* If the purchase is successful, the result data will contain the following key-value pairs
92-
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
93-
* failure as listed above.
100+
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response
101+
* codes on failures.
94102
* "INAPP_PURCHASE_DATA" - String in JSON format similar to
95-
* '{"orderId":"12999763169054705758.1371079406387615",
96-
* "packageName":"com.example.app",
97-
* "productId":"exampleSku",
98-
* "purchaseTime":1345678900000,
99-
* "purchaseToken" : "122333444455555",
100-
* "developerPayload":"example developer payload" }'
103+
* '{"orderId":"12999763169054705758.1371079406387615",
104+
* "packageName":"com.example.app",
105+
* "productId":"exampleSku",
106+
* "purchaseTime":1345678900000,
107+
* "purchaseToken" : "122333444455555",
108+
* "developerPayload":"example developer payload" }'
101109
* "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
102110
* was signed with the private key of the developer
103111
* TODO: change this to app-specific keys.
@@ -112,15 +120,15 @@ interface IInAppBillingService {
112120
* V1 and V2 that have not been consumed.
113121
* @param apiVersion billing API version that the app is using
114122
* @param packageName package name of the calling app
115-
* @param type the type of the in-app items being requested
116-
* ("inapp" for one-time purchases and "subs" for subscription).
123+
* @param type of the in-app items being requested ("inapp" for one-time purchases
124+
* and "subs" for subscriptions)
117125
* @param continuationToken to be set as null for the first call, if the number of owned
118126
* skus are too many, a continuationToken is returned in the response bundle.
119127
* This method can be called again with the continuation token to get the next set of
120128
* owned skus.
121129
* @return Bundle containing the following key-value pairs
122-
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
123-
* failure as listed above.
130+
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
131+
on failures.
124132
* "INAPP_PURCHASE_ITEM_LIST" - StringArrayList containing the list of SKUs
125133
* "INAPP_PURCHASE_DATA_LIST" - StringArrayList containing the purchase information
126134
* "INAPP_DATA_SIGNATURE_LIST"- StringArrayList containing the signatures
@@ -138,7 +146,47 @@ interface IInAppBillingService {
138146
* @param packageName package name of the calling app
139147
* @param purchaseToken token in the purchase information JSON that identifies the purchase
140148
* to be consumed
141-
* @return 0 if consumption succeeded. Appropriate error values for failures.
149+
* @return RESULT_OK(0) if consumption succeeded, appropriate response codes on failures.
142150
*/
143151
int consumePurchase(int apiVersion, String packageName, String purchaseToken);
152+
153+
/**
154+
* This API is currently under development.
155+
*/
156+
int stub(int apiVersion, String packageName, String type);
157+
158+
/**
159+
* Returns a pending intent to launch the purchase flow for upgrading or downgrading a
160+
* subscription. The existing owned SKU(s) should be provided along with the new SKU that
161+
* the user is upgrading or downgrading to.
162+
* @param apiVersion billing API version that the app is using, must be 5 or later
163+
* @param packageName package name of the calling app
164+
* @param oldSkus the SKU(s) that the user is upgrading or downgrading from,
165+
* if null or empty this method will behave like {@link #getBuyIntent}
166+
* @param newSku the SKU that the user is upgrading or downgrading to
167+
* @param type of the item being purchased, currently must be "subs"
168+
* @param developerPayload optional argument to be sent back with the purchase information
169+
* @return Bundle containing the following key-value pairs
170+
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
171+
* on failures.
172+
* "BUY_INTENT" - PendingIntent to start the purchase flow
173+
*
174+
* The Pending intent should be launched with startIntentSenderForResult. When purchase flow
175+
* has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
176+
* If the purchase is successful, the result data will contain the following key-value pairs
177+
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response
178+
* codes on failures.
179+
* "INAPP_PURCHASE_DATA" - String in JSON format similar to
180+
* '{"orderId":"12999763169054705758.1371079406387615",
181+
* "packageName":"com.example.app",
182+
* "productId":"exampleSku",
183+
* "purchaseTime":1345678900000,
184+
* "purchaseToken" : "122333444455555",
185+
* "developerPayload":"example developer payload" }'
186+
* "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
187+
* was signed with the private key of the developer
188+
* TODO: change this to app-specific keys.
189+
*/
190+
Bundle getBuyIntentToReplaceSkus(int apiVersion, String packageName,
191+
in List<String> oldSkus, String newSku, String type, String developerPayload);
144192
}

mobile/src/main/java/com/android/vending/billing/IabHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ void flagStartAsync(String operation) {
823823
logDebug("Starting async operation: " + operation);
824824
}
825825

826-
void flagEndAsync() {
826+
public void flagEndAsync() {
827827
logDebug("Ending async operation: " + mAsyncOperation);
828828
mAsyncOperation = "";
829829
mAsyncInProgress = false;

mobile/src/main/java/com/atomjack/vcfp/VoiceControlForPlexApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ public void setupInAppPurchasing() {
530530

531531
mIabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
532532
public void onIabSetupFinished(IabResult result) {
533-
Logger.d("Setup finished.");
533+
Logger.d("IABHelper Setup finished.");
534534

535-
Logger.d("Hash: %s", getEmailHash());
535+
// Logger.d("Hash: %s", getEmailHash());
536536
if (!result.isSuccess()) {
537537
// Oh noes, there was a problem.
538538
Logger.d("Problem setting up in-app billing: " + result);
@@ -566,7 +566,7 @@ public void onQueryInventoryFinished(IabResult result, final Inventory inventory
566566
Logger.d("Query inventory was successful.");
567567

568568
// Get the price for chromecast & wear support
569-
mIabHelper.queryInventoryAsync(true, new ArrayList<String>(Arrays.asList(SKU_CHROMECAST, SKU_WEAR)), new IabHelper.QueryInventoryFinishedListener() {
569+
mIabHelper.queryInventoryAsync(true, new ArrayList<>(Arrays.asList(SKU_CHROMECAST, SKU_WEAR)), new IabHelper.QueryInventoryFinishedListener() {
570570
@Override
571571
public void onQueryInventoryFinished(IabResult result, Inventory inv) {
572572
SkuDetails skuDetails = inv.getSkuDetails(SKU_CHROMECAST);

0 commit comments

Comments
 (0)