Commit c9a1c0c7 authored by cco3's avatar cco3 Committed by Commit bot

Accept PWS results without a results key

The Physical Web Service should not have to send a results key if there
are no results (and it currently doesn't).  This change does a better
job of tolerating such responses.

BUG=556988

Review URL: https://codereview.chromium.org/1465923004

Cr-Commit-Position: refs/heads/master@{#361393}
parent a38a8684
......@@ -78,11 +78,9 @@ class PwsClient {
private static Collection<PwsResult> parseResolveScanResponse(JSONObject result) {
// Get the metadata array.
Collection<PwsResult> pwsResults = new ArrayList<>();
JSONArray metadata;
try {
metadata = result.getJSONArray("results");
} catch (JSONException e) {
Log.e(TAG, "PWS returned invalid data", e);
JSONArray metadata = result.optJSONArray("results");
if (metadata == null) {
// There are no valid results.
return pwsResults;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment