/**
 * Copyright 2017 FreshPlanet
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.freshplanet.ane.AirPushNotification;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.os.AsyncTask;
import android.util.Log;

public class PingUrlTask extends AsyncTask<String, Void, Boolean> {

	@Override
	protected Boolean doInBackground(String... urls) {
				
		String trackingUrl = urls[0];
		
		Extension.log("start tracking "+trackingUrl);

		try {
			URL url = new URL(trackingUrl);

			HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
			urlc.setRequestMethod("GET");
			urlc.setRequestProperty("User-Agent", "Android");
			urlc.setRequestProperty("Connection", "close");
			urlc.setDoInput(true);
			urlc.setConnectTimeout(1000 * 10);
			urlc.connect();

		} catch (MalformedURLException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return null;
	}
	
	@Override
	protected void onPostExecute(Boolean downloadSuccess)
	{
		Extension.log("tracking complete");

	}

}

@@ -651,27 +651,92 @@
 java.io.
-IOException
+BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader
 ;%0Aimport
@@ -857,33 +857,8 @@
 ask;
-%0Aimport android.util.Log;
 %0A%0Apu
@@ -1411,16 +1411,412 @@
 ect();%0A%0A
+%09%09%09switch (urlc.getResponseCode()) %7B%0A%09%09%09%09case 200:%0A%09%09%09%09case 201:%0A%09%09%09%09%09BufferedReader br = new BufferedReader(new InputStreamReader(urlc.getInputStream()));%0A%09%09%09%09%09StringBuilder sb = new StringBuilder();%0A%09%09%09%09%09String line;%0A%09%09%09%09%09while ((line = br.readLine()) != null) %7B%0A%09%09%09%09%09%09sb.append(line+%22%5Cn%22);%0A%09%09%09%09%09%7D%0A%09%09%09%09%09br.close();%0A%0A%09%09%09%09%09Extension.log(%22Notification tracking response: %22 + sb.toString());%0A%09%09%09%7D%0A%0A
 %09%09%7D catc
@@ -1948,17 +1948,16 @@
 ull;%0A%09%7D%0A
-%09
 %0A%09@Overr

read and log tracking endpoint response