use of android.app.job.JobWorkItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AnomalyDetectionJobService method onStartJob.
@Override
public boolean onStartJob(JobParameters params) {
synchronized (mLock) {
mIsJobCanceled = false;
}
ThreadUtils.postOnBackgroundThread(() -> {
final Context context = AnomalyDetectionJobService.this;
final BatteryDatabaseManager batteryDatabaseManager = BatteryDatabaseManager.getInstance(this);
final BatteryTipPolicy policy = new BatteryTipPolicy(this);
final BatteryUtils batteryUtils = BatteryUtils.getInstance(this);
final ContentResolver contentResolver = getContentResolver();
final UserManager userManager = getSystemService(UserManager.class);
final PowerWhitelistBackend powerWhitelistBackend = PowerWhitelistBackend.getInstance(context);
final PowerUsageFeatureProvider powerUsageFeatureProvider = FeatureFactory.getFactory(this).getPowerUsageFeatureProvider(this);
final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(this).getMetricsFeatureProvider();
for (JobWorkItem item = dequeueWork(params); item != null; item = dequeueWork(params)) {
saveAnomalyToDatabase(context, userManager, batteryDatabaseManager, batteryUtils, policy, powerWhitelistBackend, contentResolver, powerUsageFeatureProvider, metricsFeatureProvider, item.getIntent().getExtras());
completeWork(params, item);
}
});
return true;
}
use of android.app.job.JobWorkItem in project VirtualApp by asLody.
the class VJobSchedulerService method enqueue.
@TargetApi(26)
public int enqueue(JobInfo job, Parcelable workItem) {
if (!(workItem instanceof JobWorkItem)) {
Log.d("Q_M", "!(workItem instanceof JobWorkItem)");
return -1;
}
Log.d("Q_M", "(workItem instanceof JobWorkItem)");
int callingUid = VBinder.getCallingUid();
int id = job.getId();
ComponentName service = job.getService();
JobId jobId = new JobId(callingUid, service.getPackageName(), id);
JobConfig jobConfig = (JobConfig) this.mJobStore.get(jobId);
if (jobConfig == null) {
int i = this.mGlobalJobId;
this.mGlobalJobId = i + 1;
jobConfig = new JobConfig(i, service.getClassName(), job.getExtras());
this.mJobStore.put(jobId, jobConfig);
} else {
jobConfig.serviceName = service.getClassName();
jobConfig.extras = job.getExtras();
}
saveJobs();
mirror.android.app.job.JobInfo.jobId.set(job, jobConfig.virtualJobId);
mirror.android.app.job.JobInfo.service.set(job, this.mJobProxyComponent);
return this.mScheduler.enqueue(job, (JobWorkItem) workItem);
}
use of android.app.job.JobWorkItem in project android_packages_apps_Dialer by LineageOS.
the class DeviceProvisionedJobService method onStartJob.
@Override
public boolean onStartJob(JobParameters params) {
if (!isDeviceProvisioned()) {
VvmLog.i("DeviceProvisionedJobService.onStartJob", "device not provisioned, rescheduling");
getSystemService(JobScheduler.class).schedule(createJobInfo(this));
// job not running in background
return false;
}
VvmLog.i("DeviceProvisionedJobService.onStartJob", "device provisioned");
for (JobWorkItem item = params.dequeueWork(); item != null; item = params.dequeueWork()) {
PhoneAccountHandle phoneAccountHandle = item.getIntent().getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE);
VvmLog.i("DeviceProvisionedJobService.onStartJob", "restarting activation for " + phoneAccountHandle);
ActivationTask.start(this, phoneAccountHandle, null);
}
// job not running in background
return false;
}
use of android.app.job.JobWorkItem in project android_packages_apps_Dialer by LineageOS.
the class TranscriptionService method scheduleNewVoicemailTranscriptionJob.
// Schedule a task to transcribe the indicated voicemail, return true if transcription task was
// scheduled.
@MainThread
public static boolean scheduleNewVoicemailTranscriptionJob(Context context, Uri voicemailUri, PhoneAccountHandle account, boolean highPriority) {
Assert.isMainThread();
if (!canTranscribeVoicemail(context, account)) {
return false;
}
LogUtil.i("TranscriptionService.scheduleNewVoicemailTranscriptionJob", "scheduling transcription");
Logger.get(context).logImpression(DialerImpression.Type.VVM_TRANSCRIPTION_VOICEMAIL_RECEIVED);
ComponentName componentName = new ComponentName(context, TranscriptionService.class);
JobInfo.Builder builder = new JobInfo.Builder(ScheduledJobIds.VVM_TRANSCRIPTION_JOB, componentName);
if (highPriority) {
builder.setMinimumLatency(0).setOverrideDeadline(0).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
} else {
builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED);
}
JobScheduler scheduler = context.getSystemService(JobScheduler.class);
JobWorkItem workItem = makeWorkItem(voicemailUri, account);
return scheduler.enqueue(builder.build(), workItem) == JobScheduler.RESULT_SUCCESS;
}
use of android.app.job.JobWorkItem in project android_packages_apps_Dialer by LineageOS.
the class TranscriptionService method checkForWork.
@MainThread
private boolean checkForWork() {
Assert.isMainThread();
if (stopped) {
LogUtil.i("TranscriptionService.checkForWork", "stopped");
return false;
}
JobWorkItem workItem = jobParameters.dequeueWork();
if (workItem != null) {
Assert.checkState(activeTask == null);
activeTask = configProvider.shouldUseSyncApi() ? new TranscriptionTaskSync(this, new Callback(), workItem, getClientFactory(), configProvider) : new TranscriptionTaskAsync(this, new Callback(), workItem, getClientFactory(), configProvider);
getExecutorService().execute(activeTask);
return true;
} else {
return false;
}
}
Aggregations