/** * find an item in the "client" array that match the package name of the app * * @param jsonObject the root json object. * @return a JsonObject representing the client entry or null if no match is found. */ private JsonObject getClientForPackageName(JsonObject jsonObject) { JsonArray array = jsonObject.getAsJsonArray("client"); if (array != null) { final int count = array.size(); for (int i = 0; i < count; i++) { JsonElement clientElement = array.get(i); if (clientElement == null || !clientElement.isJsonObject()) { continue; } JsonObject clientObject = clientElement.getAsJsonObject(); JsonObject clientInfo = clientObject.getAsJsonObject("client_info"); if (clientInfo == null) continue; JsonObject androidClientInfo = clientInfo.getAsJsonObject("android_client_info"); if (androidClientInfo == null) continue; JsonPrimitive clientPackageName = androidClientInfo.getAsJsonPrimitive("package_name"); if (clientPackageName == null) continue; if (getPackageName().equals(clientPackageName.getAsString())) { return clientObject; } } } return null; }
/** * find an item in the "client" array that match the package name of the app * * @param jsonObject the root json object. * @return a JsonObject representing the client entry or null if no match is found. */ private JsonObject getClientForPackageName(JsonObject jsonObject) { JsonArray array = jsonObject.getAsJsonArray("client"); if (array != null) { final int count = array.size(); for (int i = 0; i < count; i++) { JsonElement clientElement = array.get(i); if (clientElement == null || !clientElement.isJsonObject()) { continue; } JsonObject clientObject = clientElement.getAsJsonObject(); JsonObject clientInfo = clientObject.getAsJsonObject("client_info"); if (clientInfo == null) continue; JsonObject androidClientInfo = clientInfo.getAsJsonObject("android_client_info"); if (androidClientInfo == null) continue; JsonPrimitive clientPackageName = androidClientInfo.getAsJsonPrimitive("package_name"); if (clientPackageName == null) continue; if (getPackageName().equals(clientPackageName.getAsString())) { return clientObject; } } } return null; }
handleWebClientId(clientObject, resValues); } else { throw new GradleException("No matching client found for package name '" + getPackageName() + "'");
handleWebClientId(clientObject, resValues); } else { throw new GradleException("No matching client found for package name '" + getPackageName() + "'");