1 /* 2 * Copyright (C) 2022 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.policy; 18 19 import com.google.common.util.concurrent.ListenableFuture; 20 21 import java.time.Duration; 22 23 /** 24 * Interface for the policy controller that is responsible for applying policies based 25 * on state. 26 */ 27 public interface DevicePolicyController { 28 /** 29 * Launches an activity in locked mode. The specific activity is resolved based on the current 30 * device state. Returns false if package containing the activity is not in the allowlist. 31 */ launchActivityInLockedMode()32 ListenableFuture<Boolean> launchActivityInLockedMode(); 33 34 /** 35 * Similar to 36 * {@link DevicePolicyController#enqueueStartLockTaskModeWorkerWithDelay(boolean, Duration)} 37 * but with zero delay. 38 * 39 * @param isMandatory whether starting lock task mode is mandatory at the time of request. 40 */ enqueueStartLockTaskModeWorker(boolean isMandatory)41 void enqueueStartLockTaskModeWorker(boolean isMandatory); 42 43 /** 44 * Enqueue a worker to start lock task mode and launch corresponding activity with a delay of 45 * certain {@link Duration}. 46 * The work will be retried until device is in lock task mode. 47 * 48 * @param isMandatory whether starting lock task mode is mandatory at the time of request. 49 * @param delay The {@link Duration} that should be delayed before device enters lock 50 * task mode. 51 */ enqueueStartLockTaskModeWorkerWithDelay(boolean isMandatory, Duration delay)52 void enqueueStartLockTaskModeWorkerWithDelay(boolean isMandatory, Duration delay); 53 54 55 /** 56 * Factory resets the device when the setup has failed and cannot continue. 57 * Returns true if action was successful. 58 */ wipeData()59 boolean wipeData(); 60 61 /** 62 * Get the State Controller associated with this Policy Controller. 63 */ getStateController()64 DeviceStateController getStateController(); 65 } 66