@Override public boolean onStopJob(JobParameters jobParameters) { String key = String.valueOf(jobParameters.getJobId()); if (mSyncDelegates.containsKey(key)) { mSyncDelegates.remove(key).stopSync(); } return true; }
@Override public void stopJob(JobParameters jobParams) throws RemoteException { int jobId = jobParams.getJobId(); synchronized (mJobSessions) { JobSession session = mJobSessions.get(jobId); if (session != null) { session.stopSession(); } } } };
@Override public boolean onStopJob(JobParameters params) { Job job = JobManager.create(this).getJob(params.getJobId()); if (job != null) { job.cancel(); CAT.d("Called onStopJob for %s", job); } else { CAT.d("Called onStopJob, job %d not found", params.getJobId()); } // do not reschedule return false; }
@Override public boolean onStartJob(JobParameters jobParameters) { String jobId = String.valueOf(jobParameters.getJobId()); SyncDelegate syncDelegate = createSyncDelegate(); mSyncDelegates.put(jobId, syncDelegate); syncDelegate.subscribe(token -> { if (TextUtils.equals(jobId, token)) { jobFinished(jobParameters, false); mSyncDelegates.remove(jobId); } }); syncDelegate.performSync(new SyncDelegate.Job(jobParameters.getExtras())); return true; }
@Override public boolean onStartJob(JobParameters jobParameters) { new WidgetHelper(this).refresh(jobParameters.getJobId()); jobFinished(jobParameters, false); // if we're able to start job means we have network conn return true; }
@NonNull private JobParameters prepareJobParameters(SchedulerConstraint constraint) { JobInfo info = schedule(constraint); JobParameters params = mock(JobParameters.class); when(params.getExtras()).thenReturn(info.getExtras()); when(params.getJobId()).thenReturn(info.getId()); return params; }
@Override public boolean onStopJob(JobParameters params) { if (params.getJobId() == getPeriodicScanJobId(this)) { LogManager.i(TAG, "onStopJob called for periodic scan " + this); } else { LogManager.i(TAG, "onStopJob called for immediate scan " + this); } // Cancel the stop timer. The OS is stopping prematurely mStopHandler.removeCallbacksAndMessages(null); stopScanning(); startPassiveScanIfNeeded(); mScanHelper.terminateThreads(); return false; }
boolean onStartJob(JobParameters params) { SchedulerConstraint constraint; try { constraint = fromBundle(params.getExtras()); } catch (Exception e) { JqLog.e(e, "bad bundle from framework job scheduler start callback."); return false; } JqLog.d("[FW Scheduler] start job %s %d", constraint, params.getJobId()); constraint.setData(params); return start(constraint); }
@Test public void testStartJob() { JobParameters jobParameters = mock(JobParameters.class); when(jobParameters.getExtras()) .thenReturn(new SyncDelegate.JobBuilder(service, "1").build().toPersistableBundle()); when(jobParameters.getJobId()).thenReturn(2); service.onStartJob(jobParameters); verify(service.syncDelegate).subscribe(listenerCaptor.capture()); verify(service.syncDelegate).performSync(any(SyncDelegate.Job.class)); listenerCaptor.getValue().onDone("2"); }
@Override public void startJob(JobParameters jobParams) throws RemoteException { int jobId = jobParams.getJobId(); IBinder binder = mirror.android.app.job.JobParameters.callback.get(jobParams); IJobCallback callback = IJobCallback.Stub.asInterface(binder);
@Override public void run() { try { final int jobId = params.getJobId(); final JobProxy.Common common = new JobProxy.Common(PlatformJobService.this, CAT, jobId); // don't mark starting! final JobRequest request = common.getPendingRequest(true, false); if (request == null) { return; } if (request.isTransient()) { if (TransientBundleCompat.startWithTransientBundle(PlatformJobService.this, request)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // should only happen during testing if an API is disabled CAT.d("PendingIntent for transient bundle is not null although running on O, using compat mode, request %s", request); } return; } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { CAT.d("PendingIntent for transient job %s expired", request); return; } } common.markStarting(request); common.executeJobRequest(request, getTransientBundle(params)); } finally { // do not reschedule jobFinished(params, false); } } });
return false; if (jobParameters.getJobId() == getImmediateScanJobId(this)) { LogManager.i(TAG, "Running immediate scan job: instance is "+this);
@Override public boolean onStartJob(JobParameters params) { Log.i(TAG, "on start job: " + params.getJobId()); return true; }
@Override public boolean onStartJob(JobParameters params) { Log.d(TAG, "onStartJob(): " + params.getJobId()); Intent notIntent = new Intent(this,MainActivity.class); String title = "Job"; String contentTitle = "Hello Job: " + params.getJobId(); NotificationUtil.create(this, notIntent, title, contentTitle, 1); return true; }
@Override public boolean onStopJob(JobParameters params) { // Stop tracking these job parameters, as we've 'finished' executing. jobParamsMap.remove(params); if (mActivity != null) { mActivity.onReceivedStopJob(); } Log.i(TAG, "on stop job: " + params.getJobId()); return true; }
@Override public void run() { sendMessage(MSG_COLOR_STOP, params.getJobId()); jobFinished(params, false); } }, duration);
@Override public boolean onStopJob(JobParameters params) { Job job = JobManager.create(this).getJob(params.getJobId()); if (job != null) { job.cancel(); CAT.d("Called onStopJob for %s", job); } else { CAT.d("Called onStopJob, job %d not found", params.getJobId()); } // do not reschedule return false; }
private void sendMessage(int messageId, JobParameters params) { Message message=new Message(); message.arg1=messageId; message.what=params.getJobId(); message.obj=params.getExtras().getString(MyJobService.WORK_DURATION_KEY); try { messenger.send(message); } catch (RemoteException e) { e.printStackTrace(); } } }