// Path: src/com/crossbowffs/quotelock/app/QuoteDownloaderService.java
// public class QuoteDownloaderService extends JobService {
//     private static final String TAG = QuoteDownloaderService.class.getSimpleName();
// 
//     private class ServiceQuoteDownloaderTask extends QuoteDownloaderTask {
//         private final JobParameters mJobParameters;
// 
//         private ServiceQuoteDownloaderTask(JobParameters parameters) {
//             super(QuoteDownloaderService.this);
//             mJobParameters = parameters;
//         }
// 
//         @Override
//         protected void onPostExecute(QuoteData quote) {
//             super.onPostExecute(quote);
//             // We must back-off the job upon failure instead of creating
//             // a new one; otherwise, the update time compensation algorithm
//             // will schedule the next update immediately after this one.
//             jobFinished(mJobParameters, quote == null);
//             if (quote != null) {
//                 JobUtils.createQuoteDownloadJob(mContext, true);
//             }
//             mUpdaterTask = null;
//         }
// 
//         @Override
//         protected void onCancelled(QuoteData quote) {
//             super.onCancelled(quote);
//             // No need to call #jobFinished, since #onStopJob will
//             // handle the back-off for us.
//             // jobFinished(mJobParameters, true);
//             mUpdaterTask = null;
//         }
//     }
// 
//     private QuoteDownloaderTask mUpdaterTask;
// 
//     @Override
//     public boolean onStartJob(JobParameters params) {
//         Xlog.d(TAG, "Quote downloader job started");
// 
//         if (params.getJobId() != JobUtils.JOB_ID) {
//             Xlog.e(TAG, "Job ID mismatch, ignoring");
//             return false;
//         }
// 
//         if (!JobUtils.shouldRefreshQuote(this)) {
//             Xlog.d(TAG, "Should not refresh quote now, ignoring");
//             return false;
//         }
// 
//         mUpdaterTask = new ServiceQuoteDownloaderTask(params);
//         mUpdaterTask.execute();
//         return true;
//     }
// 
//     @Override
//     public boolean onStopJob(JobParameters params) {
//         QuoteDownloaderTask task = mUpdaterTask;
//         if (task != null) {
//             // If the job already finished, we have either already
//             // rescheduled or backed-off the task, so we do not submit
//             // a new reschedule attempt from this method. If the job was
//             // not canceled however, we need this method to reschedule
//             // the job for us, so we return true.
//             boolean canceled = task.cancel(true);
//             if (canceled) {
//                 Xlog.e(TAG, "Aborted download job");
//                 return true;
//             } else {
//                 Xlog.e(TAG, "Attempted to abort completed download job");
//                 return false;
//             }
//         } else {
//             // Since the task is null, we either aborted the job in #onStartJob
//             // (so we shouldn't reschedule) or the job already finished
//             // (so rescheduling has already been taken care of).
//             // Apparently, this always happens when we create a new job, so we can
//             // ignore this warning.
//             Xlog.w(TAG, "Attempted to abort job, but updater task is null");
//             return false;
//         }
//     }
// }
// 
// Path: src/com/crossbowffs/quotelock/consts/PrefKeys.java
// public final class PrefKeys {
//     public static final String PREF_COMMON = "common";
//     public static final String PREF_COMMON_REFRESH_RATE = "pref_common_refresh_rate";
//     public static final String PREF_COMMON_REFRESH_RATE_DEFAULT = "900";
//     public static final String PREF_COMMON_UNMETERED_ONLY = "pref_common_unmetered_only";
//     public static final boolean PREF_COMMON_UNMETERED_ONLY_DEFAULT = false;
//     public static final String PREF_COMMON_QUOTE_MODULE = "pref_common_quote_module";
//     public static final String PREF_COMMON_QUOTE_MODULE_DEFAULT = VnaasQuoteModule.class.getName();
//     public static final String PREF_COMMON_MODULE_PREFERENCES = "pref_module_preferences";
//     public static final String PREF_COMMON_REQUIRES_INTERNET = "pref_common_requires_internet";
//     public static final String PREF_COMMON_REFRESH_RATE_OVERRIDE = "pref_common_refresh_rate_override";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT = "pref_common_font_size_text";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT_DEFAULT = "20";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE = "pref_common_font_size_source";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE_DEFAULT = "18";
// 
//     public static final String PREF_QUOTES = "quotes";
//     public static final String PREF_QUOTES_TEXT = "pref_quotes_text";
//     public static final String PREF_QUOTES_SOURCE = "pref_quotes_source";
//     public static final String PREF_QUOTES_LAST_UPDATED = "pref_quotes_last_updated";
// 
//     public static final String PREF_ABOUT_CREDITS = "pref_about_credits";
//     public static final String PREF_ABOUT_GITHUB = "pref_about_github";
//     public static final String PREF_ABOUT_VERSION = "pref_about_version";
// 
//     private PrefKeys() { }
// }


import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.crossbowffs.quotelock.app.QuoteDownloaderService;
import com.crossbowffs.quotelock.consts.PrefKeys;
package com.crossbowffs.quotelock.utils;


public class JobUtils {
    private static final String TAG = JobUtils.class.getSimpleName();
    public static final int JOB_ID = 0;

    public static boolean shouldRefreshQuote(Context context) {
// Path: src/com/crossbowffs/quotelock/app/QuoteDownloaderService.java
// public class QuoteDownloaderService extends JobService {
//     private static final String TAG = QuoteDownloaderService.class.getSimpleName();
// 
//     private class ServiceQuoteDownloaderTask extends QuoteDownloaderTask {
//         private final JobParameters mJobParameters;
// 
//         private ServiceQuoteDownloaderTask(JobParameters parameters) {
//             super(QuoteDownloaderService.this);
//             mJobParameters = parameters;
//         }
// 
//         @Override
//         protected void onPostExecute(QuoteData quote) {
//             super.onPostExecute(quote);
//             // We must back-off the job upon failure instead of creating
//             // a new one; otherwise, the update time compensation algorithm
//             // will schedule the next update immediately after this one.
//             jobFinished(mJobParameters, quote == null);
//             if (quote != null) {
//                 JobUtils.createQuoteDownloadJob(mContext, true);
//             }
//             mUpdaterTask = null;
//         }
// 
//         @Override
//         protected void onCancelled(QuoteData quote) {
//             super.onCancelled(quote);
//             // No need to call #jobFinished, since #onStopJob will
//             // handle the back-off for us.
//             // jobFinished(mJobParameters, true);
//             mUpdaterTask = null;
//         }
//     }
// 
//     private QuoteDownloaderTask mUpdaterTask;
// 
//     @Override
//     public boolean onStartJob(JobParameters params) {
//         Xlog.d(TAG, "Quote downloader job started");
// 
//         if (params.getJobId() != JobUtils.JOB_ID) {
//             Xlog.e(TAG, "Job ID mismatch, ignoring");
//             return false;
//         }
// 
//         if (!JobUtils.shouldRefreshQuote(this)) {
//             Xlog.d(TAG, "Should not refresh quote now, ignoring");
//             return false;
//         }
// 
//         mUpdaterTask = new ServiceQuoteDownloaderTask(params);
//         mUpdaterTask.execute();
//         return true;
//     }
// 
//     @Override
//     public boolean onStopJob(JobParameters params) {
//         QuoteDownloaderTask task = mUpdaterTask;
//         if (task != null) {
//             // If the job already finished, we have either already
//             // rescheduled or backed-off the task, so we do not submit
//             // a new reschedule attempt from this method. If the job was
//             // not canceled however, we need this method to reschedule
//             // the job for us, so we return true.
//             boolean canceled = task.cancel(true);
//             if (canceled) {
//                 Xlog.e(TAG, "Aborted download job");
//                 return true;
//             } else {
//                 Xlog.e(TAG, "Attempted to abort completed download job");
//                 return false;
//             }
//         } else {
//             // Since the task is null, we either aborted the job in #onStartJob
//             // (so we shouldn't reschedule) or the job already finished
//             // (so rescheduling has already been taken care of).
//             // Apparently, this always happens when we create a new job, so we can
//             // ignore this warning.
//             Xlog.w(TAG, "Attempted to abort job, but updater task is null");
//             return false;
//         }
//     }
// }
// 
// Path: src/com/crossbowffs/quotelock/consts/PrefKeys.java
// public final class PrefKeys {
//     public static final String PREF_COMMON = "common";
//     public static final String PREF_COMMON_REFRESH_RATE = "pref_common_refresh_rate";
//     public static final String PREF_COMMON_REFRESH_RATE_DEFAULT = "900";
//     public static final String PREF_COMMON_UNMETERED_ONLY = "pref_common_unmetered_only";
//     public static final boolean PREF_COMMON_UNMETERED_ONLY_DEFAULT = false;
//     public static final String PREF_COMMON_QUOTE_MODULE = "pref_common_quote_module";
//     public static final String PREF_COMMON_QUOTE_MODULE_DEFAULT = VnaasQuoteModule.class.getName();
//     public static final String PREF_COMMON_MODULE_PREFERENCES = "pref_module_preferences";
//     public static final String PREF_COMMON_REQUIRES_INTERNET = "pref_common_requires_internet";
//     public static final String PREF_COMMON_REFRESH_RATE_OVERRIDE = "pref_common_refresh_rate_override";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT = "pref_common_font_size_text";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT_DEFAULT = "20";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE = "pref_common_font_size_source";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE_DEFAULT = "18";
// 
//     public static final String PREF_QUOTES = "quotes";
//     public static final String PREF_QUOTES_TEXT = "pref_quotes_text";
//     public static final String PREF_QUOTES_SOURCE = "pref_quotes_source";
//     public static final String PREF_QUOTES_LAST_UPDATED = "pref_quotes_last_updated";
// 
//     public static final String PREF_ABOUT_CREDITS = "pref_about_credits";
//     public static final String PREF_ABOUT_GITHUB = "pref_about_github";
//     public static final String PREF_ABOUT_VERSION = "pref_about_version";
// 
//     private PrefKeys() { }
// }


// Path: src/com/crossbowffs/quotelock/utils/JobUtils.java
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.crossbowffs.quotelock.app.QuoteDownloaderService;
import com.crossbowffs.quotelock.consts.PrefKeys;

package com.crossbowffs.quotelock.utils;


public class JobUtils {
    private static final String TAG = JobUtils.class.getSimpleName();
    public static final int JOB_ID = 0;

    public static boolean shouldRefreshQuote(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(PrefKeys.PREF_COMMON, Context.MODE_PRIVATE);