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

Commit 04cd35e4 authored by Kweku Adams's avatar Kweku Adams
Browse files

Improve scheduling reliability.

Since class.hashCode() can return different values, use a constant
value for the job ID instead, and put the job in a companion specific
namespace to avoid clashing with other jobs in the system.

Bug: 238764917
Change-Id: Ifefc54a0d2e65f7103648a5e29d4b0ed30f85ae2
Test: N/A
parent b4b858f2
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ import com.android.server.LocalServices;
 * will be killed if association/role are revoked.
 */
public class InactiveAssociationsRemovalService extends JobService {
    private static final int JOB_ID = InactiveAssociationsRemovalService.class.hashCode();
    private static final String JOB_NAMESPACE = "companion";
    private static final int JOB_ID = 1;
    private static final long ONE_DAY_INTERVAL = DAYS.toMillis(1);

    @Override
@@ -61,7 +62,8 @@ public class InactiveAssociationsRemovalService extends JobService {

    static void schedule(Context context) {
        Slog.i(TAG, "Scheduling the Association Removal job");
        final JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
        final JobScheduler jobScheduler =
                context.getSystemService(JobScheduler.class).forNamespace(JOB_NAMESPACE);
        final JobInfo job = new JobInfo.Builder(JOB_ID,
                new ComponentName(context, InactiveAssociationsRemovalService.class))
                .setRequiresCharging(true)
@@ -71,4 +73,3 @@ public class InactiveAssociationsRemovalService extends JobService {
        jobScheduler.schedule(job);
    }
}