/*package*/ void destroy() { synchronized (JobManager.class) { instance = null; for (JobApi api : JobApi.values()) { api.invalidateCachedProxy(); } } }
/** * <b>WARNING:</b> You shouldn't call this method. It only exists for testing and debugging * purposes. The {@link JobManager} automatically decides which API suits best for a {@link Job}. * * @param api The {@link JobApi} which will be used for future scheduled JobRequests. */ public static void forceApi(@NonNull JobApi api) { for (JobApi jobApi : JobApi.values()) { ENABLED_APIS.put(jobApi, jobApi == api); } CAT.w("forceApi - %s", api); }
/** * Resets all adjustments in the config. */ public static void reset() { for (JobApi api : JobApi.values()) { ENABLED_APIS.put(api, Boolean.TRUE); } allowSmallerIntervals = false; forceAllowApi14 = false; jobReschedulePause = DEFAULT_JOB_RESCHEDULE_PAUSE; skipJobReschedule = false; jobIdOffset = 0; forceRtc = false; clock = Clock.DEFAULT; executorService = DEFAULT_EXECUTOR_SERVICE; closeDatabase = false; JobCat.setLogcatEnabled(true); JobCat.clearLogger(); } }
private void testAllImpl() { for (JobApi api : JobApi.values()) { if (api.isSupported(this)) { JobConfig.forceApi(api); testSimple(); } else { Log.w("Demo", String.format("%s is not supported", api)); } } JobConfig.reset(); }
/*package*/ static void cleanUpOrphanedJob(Context context, int jobId) { /* * That's necessary if the database was deleted and jobs (especially the JobScheduler) are still around. * Then if a new job is being scheduled, it's possible that the new job has the ID of the old one. Here * we make sure, that no job is left in the system. */ for (JobApi jobApi : JobApi.values()) { if (jobApi.isSupported(context)) { try { jobApi.getProxy(context).cancel(jobId); } catch (Exception ignored) { // GCM API could crash if it's disabled, ignore crashes at this point and continue } } } }
@Test public void verifyForceApiDisabledOtherApis() { JobApi forcedApi = JobApi.GCM; for (JobApi api : JobApi.values()) { assertThat(JobConfig.isApiEnabled(api)).isTrue(); } JobConfig.forceApi(forcedApi); for (JobApi api : JobApi.values()) { assertThat(JobConfig.isApiEnabled(api)).isEqualTo(api == forcedApi); } }
/*package*/ void destroy() { synchronized (JobManager.class) { instance = null; for (JobApi api : JobApi.values()) { api.invalidateCachedProxy(); } } }
/** * <b>WARNING:</b> You shouldn't call this method. It only exists for testing and debugging * purposes. The {@link JobManager} automatically decides which API suits best for a {@link Job}. * * @param api The {@link JobApi} which will be used for future scheduled JobRequests. */ public static void forceApi(@NonNull JobApi api) { for (JobApi jobApi : JobApi.values()) { ENABLED_APIS.put(jobApi, jobApi == api); } CAT.w("forceApi - %s", api); }
/** * Resets all adjustments in the config. */ public static void reset() { for (JobApi api : JobApi.values()) { ENABLED_APIS.put(api, Boolean.TRUE); } allowSmallerIntervals = false; forceAllowApi14 = false; jobReschedulePause = DEFAULT_JOB_RESCHEDULE_PAUSE; skipJobReschedule = false; jobIdOffset = 0; forceRtc = false; clock = Clock.DEFAULT; executorService = DEFAULT_EXECUTOR_SERVICE; closeDatabase = false; JobCat.setLogcatEnabled(true); JobCat.clearLogger(); } }
/*package*/ static void cleanUpOrphanedJob(Context context, int jobId) { /* * That's necessary if the database was deleted and jobs (especially the JobScheduler) are still around. * Then if a new job is being scheduled, it's possible that the new job has the ID of the old one. Here * we make sure, that no job is left in the system. */ for (JobApi jobApi : JobApi.values()) { if (jobApi.isSupported(context)) { try { jobApi.getProxy(context).cancel(jobId); } catch (Exception ignored) { // GCM API could crash if it's disabled, ignore crashes at this point and continue } } } }