// Path: downloader/src/main/java/org/aisen/download/utils/Constants.java
// public final class Constants {
// 
//     public static final String TAG = "DownloadManager";
// 
//     public static final String TEMP_SUFFIX = ".atmp";
// 
//     /** The intent that gets sent when the service must wake up for a retry */
//     public static final String ACTION_RETRY = "android.intent.action.DOWNLOAD_WAKEUP";
// 
//     /**
//      * The maximum number of redirects.
//      */
//     public static final int MAX_REDIRECTS = 5; // can't be more than 7.
// 
//     /** The buffer size used to stream the data */
//     public static final int BUFFER_SIZE = 8192;
// 
//     /** The minimum amount of progress that has to be done before the progress bar gets updated */
//     public static final int MIN_PROGRESS_STEP = 65536;
// 
//     /** The minimum amount of time that has to elapse before the progress bar gets updated, in ms */
//     public static final long MIN_PROGRESS_TIME = 300;// 2000
// 
//     /**
//      * The time between a failure and the first retry after an IOException.
//      * Each subsequent retry grows exponentially, doubling each time.
//      * The time is in seconds.
//      */
//     public static final int RETRY_FIRST_DELAY = 30;
// 
//     /**
//      * The number of times that the download manager will retry its network
//      * operations when no progress is happening before it gives up.
//      */
//     public static final int MAX_RETRIES = 5;
// 
//     /** The column that is used for the downloads's ETag */
//     public static final String ETAG = "etag";
// 
// }


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextUtils;
import android.util.Log;
import org.aisen.download.utils.Constants;
import java.util.Map;
     * @return
     */
    public Cursor queryRequestHeaders(long downloadId) {
        String selection = String.format(" %s = ? ", Downloads.Impl.RequestHeaders.COLUMN_DOWNLOAD_ID);
        String[] selectionArgs = new String[]{ String.valueOf(downloadId) };

        return getReadableDatabase().query(Downloads.Impl.RequestHeaders.HEADERS_DB_TABLE, headerColumns(), selection, selectionArgs, null, null, null);
    }

    /**
     * DownloadInfo的字段
     *
     * @return
     */
    private String[] columns() {
        return new String[] { Downloads.Impl._ID,
                                Downloads.Impl.COLUMN_KEY,
                                Downloads.Impl.COLUMN_URI,
                                Downloads.Impl._DATA,
                                Downloads.Impl.COLUMN_VISIBILITY,
                                Downloads.Impl.COLUMN_CONTROL,
                                Downloads.Impl.COLUMN_STATUS,
                                Downloads.Impl.COLUMN_ERROR_MSG,
                                Downloads.Impl.COLUMN_LAST_MODIFICATION,
                                Downloads.Impl.COLUMN_FAILED_CONNECTIONS,
                                Downloads.Impl.COLUMN_TOTAL_BYTES,
                                Downloads.Impl.COLUMN_CURRENT_BYTES,
                                Downloads.Impl.COLUMN_ALLOWED_NETWORK_TYPES,
                                Downloads.Impl.COLUMN_ALLOW_ROAMING,
                                Downloads.Impl.COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT,
// Path: downloader/src/main/java/org/aisen/download/utils/Constants.java
// public final class Constants {
// 
//     public static final String TAG = "DownloadManager";
// 
//     public static final String TEMP_SUFFIX = ".atmp";
// 
//     /** The intent that gets sent when the service must wake up for a retry */
//     public static final String ACTION_RETRY = "android.intent.action.DOWNLOAD_WAKEUP";
// 
//     /**
//      * The maximum number of redirects.
//      */
//     public static final int MAX_REDIRECTS = 5; // can't be more than 7.
// 
//     /** The buffer size used to stream the data */
//     public static final int BUFFER_SIZE = 8192;
// 
//     /** The minimum amount of progress that has to be done before the progress bar gets updated */
//     public static final int MIN_PROGRESS_STEP = 65536;
// 
//     /** The minimum amount of time that has to elapse before the progress bar gets updated, in ms */
//     public static final long MIN_PROGRESS_TIME = 300;// 2000
// 
//     /**
//      * The time between a failure and the first retry after an IOException.
//      * Each subsequent retry grows exponentially, doubling each time.
//      * The time is in seconds.
//      */
//     public static final int RETRY_FIRST_DELAY = 30;
// 
//     /**
//      * The number of times that the download manager will retry its network
//      * operations when no progress is happening before it gives up.
//      */
//     public static final int MAX_RETRIES = 5;
// 
//     /** The column that is used for the downloads's ETag */
//     public static final String ETAG = "etag";
// 
// }


// Path: downloader/src/main/java/org/aisen/download/core/DBHelper.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextUtils;
import android.util.Log;
import org.aisen.download.utils.Constants;
import java.util.Map;

     * @return
     */
    public Cursor queryRequestHeaders(long downloadId) {
        String selection = String.format(" %s = ? ", Downloads.Impl.RequestHeaders.COLUMN_DOWNLOAD_ID);
        String[] selectionArgs = new String[]{ String.valueOf(downloadId) };

        return getReadableDatabase().query(Downloads.Impl.RequestHeaders.HEADERS_DB_TABLE, headerColumns(), selection, selectionArgs, null, null, null);
    }

    /**
     * DownloadInfo的字段
     *
     * @return
     */
    private String[] columns() {
        return new String[] { Downloads.Impl._ID,
                                Downloads.Impl.COLUMN_KEY,
                                Downloads.Impl.COLUMN_URI,
                                Downloads.Impl._DATA,
                                Downloads.Impl.COLUMN_VISIBILITY,
                                Downloads.Impl.COLUMN_CONTROL,
                                Downloads.Impl.COLUMN_STATUS,
                                Downloads.Impl.COLUMN_ERROR_MSG,
                                Downloads.Impl.COLUMN_LAST_MODIFICATION,
                                Downloads.Impl.COLUMN_FAILED_CONNECTIONS,
                                Downloads.Impl.COLUMN_TOTAL_BYTES,
                                Downloads.Impl.COLUMN_CURRENT_BYTES,
                                Downloads.Impl.COLUMN_ALLOWED_NETWORK_TYPES,
                                Downloads.Impl.COLUMN_ALLOW_ROAMING,
                                Downloads.Impl.COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT,
                                Constants.ETAG,