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.policy;
18 
19 import com.android.devicelockcontroller.provision.grpc.DeviceFinalizeClient.ReportDeviceProgramCompleteResponse;
20 
21 import com.google.common.util.concurrent.ListenableFuture;
22 
23 /**
24  * Controller that handles finalizing the device when the restrictions are cleared and the device
25  * should no longer be financed.
26  */
27 public interface FinalizationController {
28 
29     /**
30      * Enforces the disk state.
31      *
32      * @param force if true, forcefully reset the state to the disk state and enforce it.
33      *              Otherwise, only enforce if the state is uninitialized
34      * @return future for when the state has been enforced
35      */
enforceDiskState(boolean force)36     ListenableFuture<Void> enforceDiskState(boolean force);
37 
38     /**
39      * Notifies the controller that the device restrictions have been cleared and that the device
40      * should start the finalization process.
41      *
42      * @return future for when the clear has been handled
43      */
notifyRestrictionsCleared()44     ListenableFuture<Void> notifyRestrictionsCleared();
45 
46     /**
47      * Finalize a device that is not enrolled in the program, without reporting to the backend.
48      *
49      * @return future for when finalization has been handled
50      */
finalizeNotEnrolledDevice()51     ListenableFuture<Void> finalizeNotEnrolledDevice();
52 
53     /**
54      * Notifies the controller of the result of reporting the finalization state to the server
55      *
56      * @param response from the server
57      * @return future for when the report has been handled
58      */
notifyFinalizationReportResult( ReportDeviceProgramCompleteResponse response)59     ListenableFuture<Void> notifyFinalizationReportResult(
60             ReportDeviceProgramCompleteResponse response);
61 }
62