void sendResult(@JobResult int result) { try { remoteCallback.jobFinished(getJobCoder().encode(job, new Bundle()), result); } catch (RemoteException remoteException) { Log.e(TAG, "Failed to send result to driver", remoteException); } } }
private void requestRetryForJob(JobInvocation job) { try { callback.jobFinished(encodeJob(job), JobService.RESULT_FAIL_RETRY); } catch (RemoteException e) { Log.e(TAG, "Error sending result for job " + job.getTag() + ": " + e); } } }
@Test public void jobFinished() throws RemoteException { JobInvocation jobInvocation = new JobInvocation.Builder() .setTag("tag") .setService("service") .setTrigger(Trigger.NOW) .build(); when(mockContext.bindService( any(Intent.class), any(ServiceConnection.class), eq(BIND_AUTO_CREATE))) .thenReturn(true); executionDelegator.executeJob(jobInvocation); verify(mockContext) .bindService(intentCaptor.capture(), connCaptor.capture(), eq(BIND_AUTO_CREATE)); JobServiceConnection connection = connCaptor.getValue(); when(iBinderMock.queryLocalInterface(IRemoteJobService.class.getName())) .thenReturn(jobServiceMock); connection.onServiceConnected(null, iBinderMock); verify(jobServiceMock).start(bundleCaptor.capture(), jobCallbackCaptor.capture()); jobCallbackCaptor .getValue() .jobFinished(bundleCaptor.getValue(), JobService.RESULT_FAIL_NORETRY); assertNull(ExecutionDelegator.getJobServiceConnection("service")); assertEquals(JobService.RESULT_FAIL_NORETRY, receiver.lastResult); assertTrue(connection.wasUnbound()); }
.jobFinished(bundleCaptor.getValue(), JobService.RESULT_FAIL_NORETRY);