Search in sources :

Example 1 with JobWorkItem

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

the class TranscriptionService method makeWorkItem.

private static JobWorkItem makeWorkItem(Uri voicemailUri) {
    Intent intent = new Intent();
    intent.putExtra(EXTRA_VOICEMAIL_URI, voicemailUri);
    return new JobWorkItem(intent);
}
Also used : Intent(android.content.Intent) JobWorkItem(android.app.job.JobWorkItem)

Example 2 with JobWorkItem

use of android.app.job.JobWorkItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AnomalyDetectionJobService method scheduleAnomalyDetection.

public static void scheduleAnomalyDetection(Context context, Intent intent) {
    final JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
    final ComponentName component = new ComponentName(context, AnomalyDetectionJobService.class);
    final JobInfo.Builder jobBuilder = new JobInfo.Builder(R.integer.job_anomaly_detection, component).setOverrideDeadline(MAX_DELAY_MS);
    if (jobScheduler.enqueue(jobBuilder.build(), new JobWorkItem(intent)) != JobScheduler.RESULT_SUCCESS) {
        Log.i(TAG, "Anomaly detection job service enqueue failed.");
    }
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName) JobWorkItem(android.app.job.JobWorkItem)

Example 3 with JobWorkItem

use of android.app.job.JobWorkItem in project android_packages_apps_Settings by omnirom.

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 PowerAllowlistBackend powerAllowlistBackend = PowerAllowlistBackend.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, powerAllowlistBackend, contentResolver, powerUsageFeatureProvider, metricsFeatureProvider, item.getIntent().getExtras());
            completeWork(params, item);
        }
    });
    return true;
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) UserManager(android.os.UserManager) PowerAllowlistBackend(com.android.settingslib.fuelgauge.PowerAllowlistBackend) PowerUsageFeatureProvider(com.android.settings.fuelgauge.PowerUsageFeatureProvider) BatteryUtils(com.android.settings.fuelgauge.BatteryUtils) JobWorkItem(android.app.job.JobWorkItem) ContentResolver(android.content.ContentResolver)

Example 4 with JobWorkItem

use of android.app.job.JobWorkItem in project android_packages_apps_Settings by omnirom.

the class AnomalyDetectionJobService method scheduleAnomalyDetection.

public static void scheduleAnomalyDetection(Context context, Intent intent) {
    final JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
    final ComponentName component = new ComponentName(context, AnomalyDetectionJobService.class);
    final JobInfo.Builder jobBuilder = new JobInfo.Builder(R.integer.job_anomaly_detection, component).setOverrideDeadline(MAX_DELAY_MS);
    if (jobScheduler.enqueue(jobBuilder.build(), new JobWorkItem(intent)) != JobScheduler.RESULT_SUCCESS) {
        Log.i(TAG, "Anomaly detection job service enqueue failed.");
    }
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName) JobWorkItem(android.app.job.JobWorkItem)

Example 5 with JobWorkItem

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

the class DeviceProvisionedJobService method activateAfterProvisioned.

/**
 * Queue the phone account to be reactivated after the setup wizard has completed.
 */
public static void activateAfterProvisioned(Context context, PhoneAccountHandle phoneAccountHandle) {
    Intent intent = new Intent();
    intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
    context.getSystemService(JobScheduler.class).enqueue(createJobInfo(context), new JobWorkItem(intent));
}
Also used : JobScheduler(android.app.job.JobScheduler) Intent(android.content.Intent) JobWorkItem(android.app.job.JobWorkItem)

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