1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.devicelockcontroller.schedule; 18 19 import com.google.common.util.concurrent.ListenableFuture; 20 21 import java.time.Duration; 22 23 /** 24 * An interface which provides APIs to notify the scheduler to schedule works/alarms based on event 25 * happened. 26 */ 27 public interface DeviceLockControllerScheduler { 28 29 /** 30 * Notify the scheduler that system time has changed. 31 */ notifyTimeChanged()32 void notifyTimeChanged(); 33 34 /** 35 * Notify the scheduler that reschedule might be required for check-in work 36 */ notifyNeedRescheduleCheckIn()37 ListenableFuture<Void> notifyNeedRescheduleCheckIn(); 38 39 /** 40 * Schedule an alarm to resume the provision flow. 41 */ scheduleResumeProvisionAlarm()42 void scheduleResumeProvisionAlarm(); 43 44 /** 45 * Notify the scheduler that device reboot when provision is paused. 46 */ notifyRebootWhenProvisionPaused()47 void notifyRebootWhenProvisionPaused(); 48 49 /** 50 * Schedule the initial check-in work when device first boot. 51 */ scheduleInitialCheckInWork()52 ListenableFuture<Void> scheduleInitialCheckInWork(); 53 54 /** 55 * Schedule the retry check-in work with a delay. 56 * 57 * @param delay The delayed duration to wait for performing retry check-in work. 58 */ scheduleRetryCheckInWork(Duration delay)59 ListenableFuture<Void> scheduleRetryCheckInWork(Duration delay); 60 61 /** 62 * Schedule the initial check in (if not already done). 63 * Otherwise, if provision is not ready, reschedule the check in. 64 */ maybeScheduleInitialCheckIn()65 ListenableFuture<Void> maybeScheduleInitialCheckIn(); 66 67 /** 68 * Schedule an alarm to perform next provision failed step. 69 */ scheduleNextProvisionFailedStepAlarm()70 void scheduleNextProvisionFailedStepAlarm(); 71 72 /** 73 * Notify the scheduler that device reboot when provision has failed. 74 */ notifyRebootWhenProvisionFailed()75 void notifyRebootWhenProvisionFailed(); 76 77 /** 78 * Schedule an alarm to factory reset the device in case of provision is failed. 79 */ scheduleResetDeviceAlarm()80 void scheduleResetDeviceAlarm(); 81 82 /** 83 * Schedule an alarm to factory reset the device in case of mandatory provision is failed. 84 */ scheduleMandatoryResetDeviceAlarm()85 void scheduleMandatoryResetDeviceAlarm(); 86 } 87