Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e8a0e24 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ib497aca6,Ic6def54a into pi-dev

* changes:
  Make anomaly jobs persistent.
  Update job ids in Settings
parents 27587f78 b3087c7f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@
-->
<resources>
    <item type="id" name="preference_highlighted" />
    <item type="id" name="job_anomaly_clean_up" />
    <item type="id" name="job_anomaly_config_update"/>
    <item type="id" name="job_anomaly_detection" />

    <item type="id" name="lock_none" />
    <item type="id" name="lock_pin" />
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2018 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->
<resources>
    <!-- Reserve all the job ids in settings -->
    <integer name="job_anomaly_clean_up">100</integer>
    <integer name="job_anomaly_config_update">101</integer>
    <integer name="job_anomaly_detection">102</integer>
</resources>
 No newline at end of file
+8 −3
Original line number Diff line number Diff line
@@ -42,12 +42,17 @@ public class AnomalyCleanupJobService extends JobService {

        final ComponentName component = new ComponentName(context, AnomalyCleanupJobService.class);
        final JobInfo.Builder jobBuilder =
                new JobInfo.Builder(R.id.job_anomaly_clean_up, component)
                new JobInfo.Builder(R.integer.job_anomaly_clean_up, component)
                        .setPeriodic(CLEAN_UP_FREQUENCY_MS)
                        .setRequiresDeviceIdle(true)
                        .setRequiresCharging(true);
                        .setRequiresCharging(true)
                        .setPersisted(true);
        final JobInfo pending = jobScheduler.getPendingJob(R.integer.job_anomaly_clean_up);

        if (jobScheduler.schedule(jobBuilder.build()) != JobScheduler.RESULT_SUCCESS) {
        // Don't schedule it if it already exists, to make sure it runs periodically even after
        // reboot
        if (pending == null && jobScheduler.schedule(jobBuilder.build())
                != JobScheduler.RESULT_SUCCESS) {
            Log.i(TAG, "Anomaly clean up job service schedule failed.");
        }
    }
+8 −3
Original line number Diff line number Diff line
@@ -52,12 +52,17 @@ public class AnomalyConfigJobService extends JobService {

        final ComponentName component = new ComponentName(context, AnomalyConfigJobService.class);
        final JobInfo.Builder jobBuilder =
                new JobInfo.Builder(R.id.job_anomaly_config_update, component)
                new JobInfo.Builder(R.integer.job_anomaly_config_update, component)
                        .setPeriodic(CONFIG_UPDATE_FREQUENCY_MS)
                        .setRequiresDeviceIdle(true)
                        .setRequiresCharging(true);
                        .setRequiresCharging(true)
                        .setPersisted(true);
        final JobInfo pending = jobScheduler.getPendingJob(R.integer.job_anomaly_config_update);

        if (jobScheduler.schedule(jobBuilder.build()) != JobScheduler.RESULT_SUCCESS) {
        // Don't schedule it if it already exists, to make sure it runs periodically even after
        // reboot
        if (pending == null && jobScheduler.schedule(jobBuilder.build())
                != JobScheduler.RESULT_SUCCESS) {
            Log.i(TAG, "Anomaly config update job service schedule failed.");
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class AnomalyDetectionJobService extends JobService {
        final ComponentName component = new ComponentName(context,
                AnomalyDetectionJobService.class);
        final JobInfo.Builder jobBuilder =
                new JobInfo.Builder(R.id.job_anomaly_detection, component)
                new JobInfo.Builder(R.integer.job_anomaly_detection, component)
                        .setOverrideDeadline(MAX_DELAY_MS);

        if (jobScheduler.enqueue(jobBuilder.build(), new JobWorkItem(intent))
Loading