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

Commit e54d2543 authored by Nate Myren's avatar Nate Myren
Browse files

Skip running Auto Revoke on boot

Do not run auto revoke when first booting the device

Test: Enable debug logs, reboot phone, and verify skip log message is sent.
Fixes: 155493913

Change-Id: If3a4eb8c2e60f8a753cec2bd5d65c60ddc34617f
parent 5372a9b7
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ private const val DEBUG = false || DEBUG_OVERRIDE_THRESHOLDS

private const val AUTO_REVOKE_ENABLED = true

private var SKIP_NEXT_RUN = false

private val DEFAULT_UNUSED_THRESHOLD_MS =
        if (AUTO_REVOKE_ENABLED) DAYS.toMillis(90) else Long.MAX_VALUE
private fun getUnusedThresholdMs(context: Context) = when {
@@ -149,6 +151,8 @@ class AutoRevokeOnBootReceiver : BroadcastReceiver() {
                "Auto Revoke.")
        }

        SKIP_NEXT_RUN = true

        val jobInfo = JobInfo.Builder(
            Constants.AUTO_REVOKE_JOB_ID,
            ComponentName(context, AutoRevokeService::class.java))
@@ -388,6 +392,13 @@ class AutoRevokeService : JobService() {
            Log.i(LOG_TAG, "onStartJob")
        }

        if (SKIP_NEXT_RUN) {
            SKIP_NEXT_RUN = false
            if (DEBUG) {
                Log.i(LOG_TAG, "Skipping auto revoke first run when scheduled by system")
            }
        }

        jobStartTime = System.currentTimeMillis()
        job = GlobalScope.launch(Main) {
            try {