Example usage for android.os Bundle containsKey

List of usage examples for android.os Bundle containsKey

Introduction

In this page you can find the example usage for android.os Bundle containsKey.

Prototype

public boolean containsKey(String key) 

Source Link

Document

Returns true if the given key is contained in the mapping of this Bundle.

Usage

From source file:com.fuse.billing.android.IabHelper.java

int queryPurchases(List<Purchase> purchases, String itemType) throws JSONException, RemoteException {
    // Query purchases
    logDebug("Querying owned items, item type: " + itemType);
    logDebug("Package name: " + mContext.getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;/*from www .j  ava2s  .  com*/

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

        int response = getResponseCodeFromBundle(ownedItems);
        logDebug("Owned items response: " + String.valueOf(response));
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getPurchases() failed: " + getResponseDesc(response));
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            logError("Bundle returned from getPurchases() doesn't contain required fields.");
            return IABHELPER_BAD_RESPONSE;
        }

        ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            String purchaseData = purchaseDataList.get(i);
            String signature = signatureList.get(i);
            String sku = ownedSkus.get(i);
            /* Skip verification for static test responses */
            if (verifyPurchase(sku, purchaseData, signature)) {
                logDebug("Sku is owned: " + sku);
                Purchase purchase = new Purchase(itemType, purchaseData, signature);

                if (TextUtils.isEmpty(purchase.getToken())) {
                    logWarn("BUG: empty/null token!");
                    logDebug("Purchase data: " + purchaseData);
                }

                // Record ownership and token
                purchases.add(purchase);
            } else {
                logWarn("Purchase signature verification **FAILED**. Not adding item.");
                logDebug("   Purchase data: " + purchaseData);
                logDebug("   Signature: " + signature);
                verificationFailed = true;
            }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
        logDebug("Continuation token: " + continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}

From source file:com.android.vending.util.IabHelper.java

int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
    // Query purchases
    logDebug("Querying owned items, item type: " + itemType);
    logDebug("Package name: " + mContext.getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;//from  w w w  .  j  a  va2 s .c  om

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

        int response = getResponseCodeFromBundle(ownedItems);
        logDebug("Owned items response: " + String.valueOf(response));
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getPurchases() failed: " + getResponseDesc(response));
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            logError("Bundle returned from getPurchases() doesn't contain required fields.");
            return IABHELPER_BAD_RESPONSE;
        }

        ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            String purchaseData = purchaseDataList.get(i);
            String signature = signatureList.get(i);
            String sku = ownedSkus.get(i);
            // if (Security.verifyPurchase(mSignatureBase64, purchaseData,
            // signature)) {
            logDebug("Sku is owned: " + sku);
            Purchase purchase = new Purchase(itemType, purchaseData, signature);

            if (TextUtils.isEmpty(purchase.getToken())) {
                logWarn("BUG: empty/null token!");
                logDebug("Purchase data: " + purchaseData);
            }

            // Record ownership and token
            inv.addPurchase(purchase);
            // } else {
            // logWarn("Purchase signature verification **FAILED**. Not adding item.");
            // logDebug("   Purchase data: " + purchaseData);
            // logDebug("   Signature: " + signature);
            // verificationFailed = true;
            // }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
        logDebug("Continuation token: " + continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

@Override
public void getServerDiffs(SyncContext context, SyncData baseSyncData, SyncableContentProvider tempProvider,
        Bundle extras, Object syncInfo, SyncResult syncResult) {
    mPerformedGetServerDiffs = true;/*  w  w  w  .  j a  v  a 2s  .c  o  m*/
    GDataSyncData syncData = (GDataSyncData) baseSyncData;

    ArrayList<String> feedsToSync = new ArrayList<String>();

    if (extras != null && extras.containsKey("feed")) {
        feedsToSync.add((String) extras.get("feed"));
    } else {
        feedsToSync.add(getGroupsFeedForAccount(getAccount()));
        addContactsFeedsToSync(getContext().getContentResolver(), getAccount(), feedsToSync);
        feedsToSync.add(getPhotosFeedForAccount(getAccount()));
    }

    for (String feed : feedsToSync) {
        context.setStatusText("Downloading\u2026");
        if (getPhotosFeedForAccount(getAccount()).equals(feed)) {
            getServerPhotos(context, feed, MAX_MEDIA_ENTRIES_PER_SYNC, syncData, syncResult);
        } else {
            final Class feedEntryClass = getFeedEntryClass(feed);
            if (feedEntryClass != null) {
                getServerDiffsImpl(context, tempProvider, feedEntryClass, feed, null, getMaxEntriesPerSync(),
                        syncData, syncResult);
            } else {
                if (Config.LOGD) {
                    Log.d(TAG, "ignoring sync request for unknown feed " + feed);
                }
            }
        }
        if (syncResult.hasError()) {
            break;
        }
    }
}

From source file:com.irccloud.android.activity.PastebinEditorActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name),
                cloud, 0xFFF2F7FC));//from   ww  w .  j  a  v a  2s.c om
        cloud.recycle();
    }
    setContentView(R.layout.activity_pastebineditor);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        if (!getWindow().isFloating()) {
            getSupportActionBar().setDisplayShowHomeEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    paste = (EditText) findViewById(R.id.paste);
    filename = (EditText) findViewById(R.id.filename);
    message = (EditText) findViewById(R.id.message);
    messages_count = (TextView) findViewById(R.id.messages_count);

    if (savedInstanceState != null && savedInstanceState.containsKey("message"))
        message.setText(savedInstanceState.getString("message"));

    if (savedInstanceState != null && savedInstanceState.containsKey("paste_id"))
        pasteID = savedInstanceState.getString("paste_id");
    else if (getIntent() != null && getIntent().hasExtra("paste_id"))
        pasteID = getIntent().getStringExtra("paste_id");

    if (savedInstanceState != null && savedInstanceState.containsKey("paste_contents"))
        pastecontents = savedInstanceState.getString("paste_contents");
    else if (getIntent() != null && getIntent().hasExtra("paste_contents"))
        pastecontents = getIntent().getStringExtra("paste_contents");
    paste.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            int count = 0;
            String lines[] = editable.toString().split("\n");
            for (String line : lines) {
                count += Math.ceil(line.length() / 1080.0f);
            }
            messages_count.setText("Text will be sent as " + count + " message" + (count == 1 ? "" : "s"));
        }
    });
    paste.setText(pastecontents);

    if (savedInstanceState != null && savedInstanceState.containsKey("filename"))
        filename.setText(savedInstanceState.getString("filename"));
    else if (getIntent() != null && getIntent().hasExtra("filename"))
        filename.setText(getIntent().getStringExtra("filename"));

    tabHost = (TabLayout) findViewById(android.R.id.tabhost);
    ViewCompat.setElevation(toolbar, ViewCompat.getElevation(tabHost));

    if (pasteID != null) {
        tabHost.setVisibility(View.GONE);
        message.setVisibility(View.GONE);
        findViewById(R.id.message_heading).setVisibility(View.GONE);
    } else {
        tabHost.setTabGravity(TabLayout.GRAVITY_FILL);
        tabHost.setTabMode(TabLayout.MODE_FIXED);
        tabHost.addTab(tabHost.newTab().setText("Pastebin"));
        tabHost.addTab(tabHost.newTab().setText("Messages"));
        tabHost.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                current_tab = tab.getPosition();
                if (current_tab == 0) {
                    filename.setVisibility(View.VISIBLE);
                    message.setVisibility(View.VISIBLE);
                    messages_count.setVisibility(View.GONE);
                    findViewById(R.id.filename_heading).setVisibility(View.VISIBLE);
                    findViewById(R.id.message_heading).setVisibility(View.VISIBLE);
                } else {
                    filename.setVisibility(View.GONE);
                    message.setVisibility(View.GONE);
                    messages_count.setVisibility(View.VISIBLE);
                    findViewById(R.id.filename_heading).setVisibility(View.GONE);
                    findViewById(R.id.message_heading).setVisibility(View.GONE);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        if (savedInstanceState != null && savedInstanceState.containsKey("tab"))
            tabHost.getTabAt(savedInstanceState.getInt("tab")).select();
    }

    NetworkConnection.getInstance().addHandler(this);
    if (pasteID != null && (pastecontents == null || pastecontents.length() == 0)) {
        new FetchPastebinTask().execute((Void) null);
    }

    if (pasteID != null) {
        setTitle(R.string.title_activity_pastebin_editor_edit);
        toolbar.setBackgroundResource(R.drawable.actionbar);
    } else {
        setTitle(R.string.title_activity_pastebin_editor);
    }

    supportInvalidateOptionsMenu();

    result(RESULT_CANCELED);
}

From source file:com.kyleshaver.minuteofangle.util.IabHelper.java

int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
        // Query purchases
        logDebug("Querying owned items, item type: " + itemType);
        logDebug("Package name: " + mContext.getPackageName());
        boolean verificationFailed = false;
        String continueToken = null;

        do {//from w w  w.  j  a va 2s .c o  m
            logDebug("Calling getPurchases with continuation token: " + continueToken);
            Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

            int response = getResponseCodeFromBundle(ownedItems);
            logDebug("Owned items response: " + String.valueOf(response));
            if (response != BILLING_RESPONSE_RESULT_OK) {
                logDebug("getPurchases() failed: " + getResponseDesc(response));
                return response;
            }
            if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                    || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                    || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
                logError("Bundle returned from getPurchases() doesn't contain required fields.");
                return IABHELPER_BAD_RESPONSE;
            }

            ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
            ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
            ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

            for (int i = 0; i < purchaseDataList.size(); ++i) {
                String purchaseData = purchaseDataList.get(i);
                String signature = signatureList.get(i);
                String sku = ownedSkus.get(i);
                if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) {
                    logDebug("Sku is owned: " + sku);
                    Purchase purchase = new Purchase(itemType, purchaseData, signature);

                    if (TextUtils.isEmpty(purchase.getToken())) {
                        logWarn("BUG: empty/null token!");
                        logDebug("Purchase data: " + purchaseData);
                    }

                    // Record ownership and token
                    inv.addPurchase(purchase);
                } else {
                    logWarn("Purchase signature verification **FAILED**. Not adding item.");
                    logDebug("   Purchase data: " + purchaseData);
                    logDebug("   Signature: " + signature);
                    verificationFailed = true;
                }
            }

            continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
            logDebug("Continuation token: " + continueToken);
        } while (!TextUtils.isEmpty(continueToken));

        return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
    }

From source file:li.muhammada.android.vending.billing.IabHelper.java

int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
    if (mContext == null) {
        return IABHELPER_CONTEXT_NOT_SET;
    }/*w  w  w  . j av a  2s.c om*/

    // Query purchases
    logDebug("Querying owned items, item type: " + itemType);
    logDebug("Package name: " + mContext.getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

        int response = getResponseCodeFromBundle(ownedItems);
        logDebug("Owned items response: " + String.valueOf(response));
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getPurchases() failed: " + getResponseDesc(response));
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            logError("Bundle returned from getPurchases() doesn't contain required fields.");
            return IABHELPER_BAD_RESPONSE;
        }

        ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            String purchaseData = purchaseDataList.get(i);
            String signature = signatureList.get(i);
            String sku = ownedSkus.get(i);
            if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) {
                logDebug("Sku is owned: " + sku);
                Purchase purchase = new Purchase(itemType, purchaseData, signature);

                if (TextUtils.isEmpty(purchase.getToken())) {
                    logWarn("BUG: empty/null token!");
                    logDebug("Purchase data: " + purchaseData);
                }

                // Record ownership and token
                inv.addPurchase(purchase);
            } else {
                logWarn("Purchase signature verification **FAILED**. Not adding item.");
                logDebug("   Purchase data: " + purchaseData);
                logDebug("   Signature: " + signature);
                verificationFailed = true;
            }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
        logDebug("Continuation token: " + continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}

From source file:de.geithonline.abattlwp.billinghelper.IabHelper.java

int queryPurchases(final Inventory inv, final String itemType) throws JSONException, RemoteException {
    // Query purchases
    logDebug("Querying owned items, item type: " + itemType);
    logDebug("Package name: " + mContext.getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;//www. jav a  2  s  .  c  om

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        final Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

        final int response = getResponseCodeFromBundle(ownedItems);
        logDebug("Owned items response: " + String.valueOf(response));
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getPurchases() failed: " + getResponseDesc(response));
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            logError("Bundle returned from getPurchases() doesn't contain required fields.");
            return IABHELPER_BAD_RESPONSE;
        }

        final ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        final ArrayList<String> purchaseDataList = ownedItems
                .getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        final ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            final String purchaseData = purchaseDataList.get(i);
            final String signature = signatureList.get(i);
            final String sku = ownedSkus.get(i);
            if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) {
                logDebug("Sku is owned: " + sku);
                final Purchase purchase = new Purchase(itemType, purchaseData, signature);

                if (TextUtils.isEmpty(purchase.getToken())) {
                    logWarn("BUG: empty/null token!");
                    logDebug("Purchase data: " + purchaseData);
                }

                // Record ownership and token
                inv.addPurchase(purchase);
            } else {
                logWarn("Purchase signature verification **FAILED**. Not adding item.");
                logDebug("   Purchase data: " + purchaseData);
                logDebug("   Signature: " + signature);
                verificationFailed = true;
            }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
        logDebug("Continuation token: " + continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}

From source file:com.facebook.internal.LikeActionController.java

private void refreshStatusViaService() {
    LikeStatusClient likeStatusClient = new LikeStatusClient(applicationContext, Settings.getApplicationId(),
            objectId);/*from w w w  . jav  a2  s  .  c  o m*/
    if (!likeStatusClient.start()) {
        return;
    }

    LikeStatusClient.CompletedListener callback = new LikeStatusClient.CompletedListener() {
        @Override
        public void completed(Bundle result) {
            // Don't lose old state if the service response is incomplete.
            if (result == null || !result.containsKey(NativeProtocol.EXTRA_OBJECT_IS_LIKED)) {
                return;
            }

            boolean objectIsLiked = result.getBoolean(NativeProtocol.EXTRA_OBJECT_IS_LIKED);

            String likeCountWithLike = result.containsKey(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITH_LIKE)
                    ? result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITH_LIKE)
                    : LikeActionController.this.likeCountStringWithLike;

            String likeCountWithoutLike = result
                    .containsKey(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE)
                            ? result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE)
                            : LikeActionController.this.likeCountStringWithoutLike;

            String socialSentenceWithLike = result.containsKey(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITH_LIKE)
                    ? result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITH_LIKE)
                    : LikeActionController.this.socialSentenceWithLike;

            String socialSentenceWithoutLike = result
                    .containsKey(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE)
                            ? result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE)
                            : LikeActionController.this.socialSentenceWithoutLike;

            String unlikeToken = result.containsKey(NativeProtocol.EXTRA_UNLIKE_TOKEN)
                    ? result.getString(NativeProtocol.EXTRA_UNLIKE_TOKEN)
                    : LikeActionController.this.unlikeToken;

            updateState(objectIsLiked, likeCountWithLike, likeCountWithoutLike, socialSentenceWithLike,
                    socialSentenceWithoutLike, unlikeToken);
        }
    };

    likeStatusClient.setCompletedListener(callback);
}

From source file:com.dreamfarmgames.util.IabHelper.java

int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
    // Query purchases
    logDebug("Querying owned items, item type: " + itemType);
    logDebug("Package name: " + mContext.getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;//from w  ww. java  2 s.c  o  m

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

        int response = getResponseCodeFromBundle(ownedItems);
        logDebug("Owned items response: " + String.valueOf(response));
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getPurchases() failed: " + getResponseDesc(response));
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            logError("Bundle returned from getPurchases() doesn't contain required fields.");
            return IABHELPER_BAD_RESPONSE;
        }

        ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            String purchaseData = purchaseDataList.get(i);
            String signature = signatureList.get(i);
            String sku = ownedSkus.get(i);
            if (Security.vPurchase(mSignatureBase64, purchaseData, signature)) {
                logDebug("Sku is owned: " + sku);
                Purchase purchase = new Purchase(itemType, purchaseData, signature);

                if (TextUtils.isEmpty(purchase.getToken())) {
                    logWarn("BUG: empty/null token!");
                    logDebug("Purchase data: " + purchaseData);
                }

                // Record ownership and token
                inv.addPurchase(purchase);
            } else {
                logWarn("Purchase signature verification **FAILED**. Not adding item.");
                logDebug("   Purchase data: " + purchaseData);
                logDebug("   Signature: " + signature);
                verificationFailed = true;
            }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
        logDebug("Continuation token: " + continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}