Skip to content

Commit

Permalink
fix bug where notification ids are not passed on RESTORE_TRANSACTIONS…
Browse files Browse the repository at this point in the history
…, causing a reporting failure due to a NPE.
  • Loading branch information
koush committed Aug 18, 2011
1 parent 6a0e7ab commit 6de82e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions src/com/clockworkmod/billing/BillingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 50,15 @@ static void reportAndroidPurchase(final Context context, final String signedData
post.setEntity(entity);
String result = StreamUtility.downloadUriAsString(post);
Log.i(LOGTAG, result);
Log.i(LOGTAG, signedData);
Log.i(LOGTAG, signature);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String action = null;
if (intent != null)
action = intent.getAction();
if (action != null)
Log.i(LOGTAG, action);
if (REFRESH_MARKET.equals(action)) {
bindService(new Intent("com.android.vending.billing.MarketBillingService.BIND"), new ServiceConnection() {
@Override
Expand Down Expand Up @@ -87,6 87,10 @@ else if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) {

final String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA);
final String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE);
if (signedData != null)
Log.i(LOGTAG, signedData);
if (signature != null)
Log.i(LOGTAG, signature);

bindService(new Intent("com.android.vending.billing.MarketBillingService.BIND"), new ServiceConnection() {
@Override
Expand All @@ -108,14 112,19 @@ public void run() {
ArrayList<String> notificationIds = new ArrayList<String>();
for (int i = 0; i < orders.length(); i ) {
JSONObject order = orders.getJSONObject(i);
String notificationId = order.optString("notificationId", null);
if (notificationId == null)
continue;
notificationIds.add(order.getString("notificationId"));
}
String[] nids = new String[orders.length()];
nids = notificationIds.toArray(nids);
reportAndroidPurchase(BillingService.this, signedData, signature);
Bundle bundle = BillingReceiver.makeRequestBundle(BillingService.this, Consts.METHOD_CONFIRM_NOTIFICATIONS);
bundle.putStringArray(Consts.BILLING_REQUEST_NOTIFY_IDS, nids);
s.sendBillingRequest(bundle);
if (notificationIds.size() > 0) {
String[] nids = new String[notificationIds.size()];
nids = notificationIds.toArray(nids);
Bundle bundle = BillingReceiver.makeRequestBundle(BillingService.this, Consts.METHOD_CONFIRM_NOTIFICATIONS);
bundle.putStringArray(Consts.BILLING_REQUEST_NOTIFY_IDS, nids);
s.sendBillingRequest(bundle);
}
unbindService(sc);
Intent intent = new Intent(BillingReceiver.SUCCEEDED);
sendBroadcast(intent);
Expand Down
2 changes: 1 addition & 1 deletion src/com/clockworkmod/billing/ThreadingRunnable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@
import android.os.Handler;

public abstract class ThreadingRunnable {
static void background(final ThreadingRunnable runnable) {
public static void background(final ThreadingRunnable runnable) {
new Thread() {
public void run() {
runnable.run();
Expand Down

0 comments on commit 6de82e6

Please sign in to comment.