// Path: src/org/pixmob/freemobile/netstat/Constants.java
// public static final String SP_NAME = "netstat";
// 
// Path: src/org/pixmob/freemobile/netstat/Constants.java
// public static final String TAG = "FreeMobileNetstat";
// 
// Path: src/org/pixmob/freemobile/netstat/content/NetstatContract.java
// public static class Events implements BaseColumns, EventsColumns {
//     /**
//      * The content:// style URI for this table.
//      */
//     public static final Uri CONTENT_URI = new Uri.Builder()
//             .scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
//             .appendPath("events").build();
//     /**
//      * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
//      * entry.
//      */
//     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
//     /**
//      * The MIME type of {@link #CONTENT_TYPE} providing a directory of
//      * entries.
//      */
//     public static final String CONTENT_TYPE = "vnd.android.cursor.dir/event";
// }
// 
// Path: src/org/pixmob/freemobile/netstat/util/DateUtils.java
// public final class DateUtils {
//     private DateUtils() {
//     }
// 
//     /**
//      * Format a duration in milliseconds.
//      */
//     public static CharSequence formatDuration(long duration, Context context, CharSequence defaultValue) {
//         if (duration <= 0) {
//             return defaultValue;
//         }
//         final long ds = duration / 1000;
//         final StringBuilder buf = new StringBuilder(32);
//         if (ds < 60) {
//             buf.append(ds).append(context.getString(R.string.seconds));
//         } else if (ds < 3600) {
//             final long m = ds / 60;
//             buf.append(m).append(context.getString(R.string.minutes));
//         } else if (ds < 86400) {
//             final long h = ds / 3600;
//             buf.append(h).append(context.getString(R.string.hours));
// 
//             final long m = (ds - h * 3600) / 60;
//             if (m != 0) {
//                 if (m < 10) {
//                     buf.append("0");
//                 }
//                 buf.append(m);
//             }
//         } else {
//             final long d = ds / 86400;
//             buf.append(d).append(context.getString(R.string.days));
// 
//             final long h = (ds - d * 86400) / 3600;
//             if (h != 0) {
//                 buf.append(" ").append(h).append(context.getString(R.string.hours));
//             }
// 
//             final long m = (ds - d * 86400 - h * 3600) / 60;
//             if (m != 0) {
//                 if (h == 0) {
//                     buf.append(" ");
//                 } else if (m < 10) {
//                     buf.append("0");
//                 }
//                 buf.append(m);
//                 if (h == 0) {
//                     buf.append(context.getString(R.string.minutes));
//                 }
//             }
//         }
// 
//         return buf;
//     }
// 
//     /**
//      * Format a date.
//      */
//     public static CharSequence formatDate(long d) {
//         return DateFormat.format("dd/MM/yyyy", d);
//     }
// }


import static org.pixmob.freemobile.netstat.BuildConfig.DEBUG;
import static org.pixmob.freemobile.netstat.Constants.SP_NAME;
import static org.pixmob.freemobile.netstat.Constants.TAG;
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.CharArrayBuffer;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.PowerManager;
import android.support.v4.util.LongSparseArray;
import android.text.format.DateFormat;
import android.util.Log;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import org.json.JSONException;
import org.json.JSONObject;
import org.pixmob.freemobile.netstat.content.NetstatContract.Events;
import org.pixmob.freemobile.netstat.util.DateUtils;
import org.pixmob.httpclient.HttpClient;
import org.pixmob.httpclient.HttpClientException;
import org.pixmob.httpclient.HttpResponse;
import org.pixmob.httpclient.HttpResponseHandler;
    }

    private void run(Intent intent, final SQLiteDatabase db) throws Exception {
        final long now = dateAtMidnight(System.currentTimeMillis());

        Log.i(TAG, "Initializing statistics before uploading");

        final LongSparseArray< DailyStat> stats = new LongSparseArray< DailyStat>(15);
        final Set< Long> uploadedStats = new HashSet< Long>(15);
        final long statTimestampStart = now - 7 * DAY_IN_MILLISECONDS;

        // Get pending uploads.
        Cursor c =
            db.query("daily_stat", new String[] {"stat_timestamp", "orange", "free_mobile", "sync" },
                "stat_timestamp>=? AND stat_timestamp<?", new String[] {String.valueOf(statTimestampStart),
                    String.valueOf(now) }, null, null, null);
        try {
            while (c.moveToNext()) {
                final long d = c.getLong(0);
                final int sync = c.getInt(3);
                if (SYNC_UPLOADED == sync) {
                    uploadedStats.add(d);
                } else if (SYNC_PENDING == sync) {
                    final DailyStat s = new DailyStat();
                    s.orange = c.getInt(1);
                    s.freeMobile = c.getInt(2);
                    stats.put(d, s);
                }
            }
        } finally {
// Path: src/org/pixmob/freemobile/netstat/Constants.java
// public static final String SP_NAME = "netstat";
// 
// Path: src/org/pixmob/freemobile/netstat/Constants.java
// public static final String TAG = "FreeMobileNetstat";
// 
// Path: src/org/pixmob/freemobile/netstat/content/NetstatContract.java
// public static class Events implements BaseColumns, EventsColumns {
//     /**
//      * The content:// style URI for this table.
//      */
//     public static final Uri CONTENT_URI = new Uri.Builder()
//             .scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
//             .appendPath("events").build();
//     /**
//      * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
//      * entry.
//      */
//     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
//     /**
//      * The MIME type of {@link #CONTENT_TYPE} providing a directory of
//      * entries.
//      */
//     public static final String CONTENT_TYPE = "vnd.android.cursor.dir/event";
// }
// 
// Path: src/org/pixmob/freemobile/netstat/util/DateUtils.java
// public final class DateUtils {
//     private DateUtils() {
//     }
// 
//     /**
//      * Format a duration in milliseconds.
//      */
//     public static CharSequence formatDuration(long duration, Context context, CharSequence defaultValue) {
//         if (duration <= 0) {
//             return defaultValue;
//         }
//         final long ds = duration / 1000;
//         final StringBuilder buf = new StringBuilder(32);
//         if (ds < 60) {
//             buf.append(ds).append(context.getString(R.string.seconds));
//         } else if (ds < 3600) {
//             final long m = ds / 60;
//             buf.append(m).append(context.getString(R.string.minutes));
//         } else if (ds < 86400) {
//             final long h = ds / 3600;
//             buf.append(h).append(context.getString(R.string.hours));
// 
//             final long m = (ds - h * 3600) / 60;
//             if (m != 0) {
//                 if (m < 10) {
//                     buf.append("0");
//                 }
//                 buf.append(m);
//             }
//         } else {
//             final long d = ds / 86400;
//             buf.append(d).append(context.getString(R.string.days));
// 
//             final long h = (ds - d * 86400) / 3600;
//             if (h != 0) {
//                 buf.append(" ").append(h).append(context.getString(R.string.hours));
//             }
// 
//             final long m = (ds - d * 86400 - h * 3600) / 60;
//             if (m != 0) {
//                 if (h == 0) {
//                     buf.append(" ");
//                 } else if (m < 10) {
//                     buf.append("0");
//                 }
//                 buf.append(m);
//                 if (h == 0) {
//                     buf.append(context.getString(R.string.minutes));
//                 }
//             }
//         }
// 
//         return buf;
//     }
// 
//     /**
//      * Format a date.
//      */
//     public static CharSequence formatDate(long d) {
//         return DateFormat.format("dd/MM/yyyy", d);
//     }
// }


// Path: src/org/pixmob/freemobile/netstat/SyncService.java
import static org.pixmob.freemobile.netstat.BuildConfig.DEBUG;
import static org.pixmob.freemobile.netstat.Constants.SP_NAME;
import static org.pixmob.freemobile.netstat.Constants.TAG;
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.CharArrayBuffer;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.PowerManager;
import android.support.v4.util.LongSparseArray;
import android.text.format.DateFormat;
import android.util.Log;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import org.json.JSONException;
import org.json.JSONObject;
import org.pixmob.freemobile.netstat.content.NetstatContract.Events;
import org.pixmob.freemobile.netstat.util.DateUtils;
import org.pixmob.httpclient.HttpClient;
import org.pixmob.httpclient.HttpClientException;
import org.pixmob.httpclient.HttpResponse;
import org.pixmob.httpclient.HttpResponseHandler;

    }

    private void run(Intent intent, final SQLiteDatabase db) throws Exception {
        final long now = dateAtMidnight(System.currentTimeMillis());

        Log.i(TAG, "Initializing statistics before uploading");

        final LongSparseArray< DailyStat> stats = new LongSparseArray< DailyStat>(15);
        final Set< Long> uploadedStats = new HashSet< Long>(15);
        final long statTimestampStart = now - 7 * DAY_IN_MILLISECONDS;

        // Get pending uploads.
        Cursor c =
            db.query("daily_stat", new String[] {"stat_timestamp", "orange", "free_mobile", "sync" },
                "stat_timestamp>=? AND stat_timestamp<?", new String[] {String.valueOf(statTimestampStart),
                    String.valueOf(now) }, null, null, null);
        try {
            while (c.moveToNext()) {
                final long d = c.getLong(0);
                final int sync = c.getInt(3);
                if (SYNC_UPLOADED == sync) {
                    uploadedStats.add(d);
                } else if (SYNC_PENDING == sync) {
                    final DailyStat s = new DailyStat();
                    s.orange = c.getInt(1);
                    s.freeMobile = c.getInt(2);
                    stats.put(d, s);
                }
            }
        } finally {
            c.close();