@Override public SkuDetails skuDetails(@NonNull String sku) { try { final Bundle skus = new Bundle(1); skus.putStringArrayList(REQUEST_ITEM_ID_LIST, arrayList(sku)); final Bundle bundle = service.getSkuDetails(3, packageName, BILLING_TYPE, skus); if (responseOk(bundle)) { final ArrayList<String> list = bundle.getStringArrayList(RESPONSE_DETAILS_LIST); if (list != null && !list.isEmpty()) { final String json = list.get(0); return new SkuDetails(json); } } } catch (RemoteException | JSONException ignore) { } return null; }
private static Bundle populateLSuccessfulList(@NonNull String key, @Nullable String... values) { final ArrayList<String> list; if (values == null) { list = null; } else { list = arrayList(values); } final Bundle bundle = new Bundle(2); bundle.putInt(RESPONSE_CODE, BILLING_RESPONSE_RESULT_OK); bundle.putStringArrayList(key, list); return bundle; } }
@Override public Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken) throws RemoteException { final Bundle bundle = responseOkBundle(); bundle.putStringArrayList(RESPONSE_ITEM_LIST, arrayList(SKU)); return bundle; }
@Override public Bundle getSkuDetails(int apiVersion, String packageName, String type, Bundle skusBundle) throws RemoteException { final Bundle bundle = responseOkBundle(); bundle.putStringArrayList(RESPONSE_DETAILS_LIST, arrayList(JSON_SKU)); return bundle; }
@Test public void hasBillingCapabilitiesOk() { final List<ResolveInfo> list = arrayList(mock(ResolveInfo.class)); final Context context = new SimpleBinderContext(list); assertBillingCapabilities(context, true); }