Search in sources :

Example 6 with JobWorkItem

use of android.app.job.JobWorkItem in project android_packages_apps_Dialer by LineageOS.

the class TranscriptionBackfillService method makeWorkItem.

private static JobWorkItem makeWorkItem(PhoneAccountHandle account) {
    Intent intent = new Intent();
    intent.putExtra(TranscriptionService.EXTRA_ACCOUNT_HANDLE, account);
    return new JobWorkItem(intent);
}
Also used : Intent(android.content.Intent) JobWorkItem(android.app.job.JobWorkItem)

Example 7 with JobWorkItem

use of android.app.job.JobWorkItem in project android_packages_apps_Dialer by LineageOS.

the class TranscriptionRatingService method makeWorkItem.

private static JobWorkItem makeWorkItem(SendTranscriptionFeedbackRequest request) {
    Intent intent = new Intent();
    intent.putExtra(FEEDBACK_REQUEST_EXTRA, request.toByteArray());
    return new JobWorkItem(intent);
}
Also used : Intent(android.content.Intent) JobWorkItem(android.app.job.JobWorkItem)

Example 8 with JobWorkItem

use of android.app.job.JobWorkItem in project android_packages_apps_Dialer by LineageOS.

the class TranscriptionService method transcribeVoicemail.

// Schedule a task to transcribe the indicated voicemail, return true if transcription task was
// scheduled.
public static boolean transcribeVoicemail(Context context, Uri voicemailUri) {
    Assert.isMainThread();
    if (BuildCompat.isAtLeastO()) {
        LogUtil.i("TranscriptionService.transcribeVoicemail", "scheduling transcription");
        ComponentName componentName = new ComponentName(context, TranscriptionService.class);
        JobInfo.Builder builder = new JobInfo.Builder(ScheduledJobIds.VVM_TRANSCRIPTION_JOB, componentName).setMinimumLatency(0).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
        JobScheduler scheduler = context.getSystemService(JobScheduler.class);
        JobWorkItem workItem = makeWorkItem(voicemailUri);
        return scheduler.enqueue(builder.build(), workItem) == JobScheduler.RESULT_SUCCESS;
    } else {
        LogUtil.i("TranscriptionService.transcribeVoicemail", "not supported");
        return false;
    }
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName) JobWorkItem(android.app.job.JobWorkItem)

Example 9 with JobWorkItem

use of android.app.job.JobWorkItem in project robolectric by robolectric.

the class ShadowJobSchedulerTest method enqueue_success.

@Test
@Config(minSdk = O)
public void enqueue_success() {
    int result = jobScheduler.enqueue(new JobInfo.Builder(99, new ComponentName(context, "component_class_name")).setPeriodic(1000).build(), new JobWorkItem(new Intent()));
    assertThat(result).isEqualTo(JobScheduler.RESULT_SUCCESS);
}
Also used : JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName) Intent(android.content.Intent) JobWorkItem(android.app.job.JobWorkItem) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 10 with JobWorkItem

use of android.app.job.JobWorkItem in project robolectric by robolectric.

the class ShadowJobSchedulerTest method enqueue_fail.

@Test
@Config(minSdk = O)
public void enqueue_fail() {
    shadowOf(jobScheduler).failOnJob(99);
    int result = jobScheduler.enqueue(new JobInfo.Builder(99, new ComponentName(context, "component_class_name")).setPeriodic(1000).build(), new JobWorkItem(new Intent()));
    assertThat(result).isEqualTo(JobScheduler.RESULT_FAILURE);
}
Also used : JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName) Intent(android.content.Intent) JobWorkItem(android.app.job.JobWorkItem) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

JobWorkItem (android.app.job.JobWorkItem)16 ComponentName (android.content.ComponentName)7 Intent (android.content.Intent)7 JobInfo (android.app.job.JobInfo)6 JobScheduler (android.app.job.JobScheduler)6 ContentResolver (android.content.ContentResolver)2 Context (android.content.Context)2 UserManager (android.os.UserManager)2 MainThread (android.support.annotation.MainThread)2 BatteryUtils (com.android.settings.fuelgauge.BatteryUtils)2 PowerUsageFeatureProvider (com.android.settings.fuelgauge.PowerUsageFeatureProvider)2 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)2 Test (org.junit.Test)2 Config (org.robolectric.annotation.Config)2 TargetApi (android.annotation.TargetApi)1 PhoneAccountHandle (android.telecom.PhoneAccountHandle)1 PowerAllowlistBackend (com.android.settingslib.fuelgauge.PowerAllowlistBackend)1 PowerWhitelistBackend (com.android.settingslib.fuelgauge.PowerWhitelistBackend)1