1 /*
2  * Copyright (C) 2019 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.managedprovisioning.finalization;
18 
19 import static com.android.managedprovisioning.finalization.FinalizationController.ProvisioningFinalizedResult;
20 
21 import android.os.Bundle;
22 
23 import com.android.managedprovisioning.model.ProvisioningParams;
24 
25 /**
26  * The methods in this interface are used to customize the behavior of
27  * {@link FinalizationController}.  An implementation of this interface must be provided when a
28  * {@link FinalizationController} is constructed.
29  */
30 public interface FinalizationControllerLogic {
31 
32     /**
33      * Notify the DPC for a managed profile that provisioning is completed.
34      *
35      * @return a {@link ProvisioningFinalizedResult} indicating whether the DPC started an activity
36      * as a result of that notification.
37      */
notifyDpcManagedProfile( ProvisioningParams params, int requestCode)38     @ProvisioningFinalizedResult int notifyDpcManagedProfile(
39             ProvisioningParams params, int requestCode);
40 
41     /**
42      * Notify the DPC for a managed device or managed user that provisioning is completed.
43      *
44      * @return a {@link ProvisioningFinalizedResult} indicating whether the DPC started an activity
45      * as a result of that notification.
46      */
notifyDpcManagedDeviceOrUser( ProvisioningParams params, int requestCode)47     @ProvisioningFinalizedResult int notifyDpcManagedDeviceOrUser(
48             ProvisioningParams params, int requestCode);
49 
50     /**
51      * Return true if, after managed profile provisioning, {@link PrimaryProfileFinalizationHelper}
52      * should be invoked at the time we update the system's provisioning state.
53      *
54      * If this is false, then {@link PrimaryProfileFinalizationHelper} must have already been
55      * invoked prior to reaching this point.
56      */
shouldFinalizePrimaryProfile(ProvisioningParams params)57     boolean shouldFinalizePrimaryProfile(ProvisioningParams params);
58 
59     /**
60      * This method is called when onSaveInstanceState() executes on the finalization activity.
61      */
saveInstanceState(Bundle outState)62     void saveInstanceState(Bundle outState);
63 
64     /**
65      * When saved instance state is passed to the finalization activity in its onCreate() method,
66      * that state is passed to the FinalizationControllerLogic object here so it can be restored.
67      */
restoreInstanceState(Bundle savedInstanceState, ProvisioningParams params)68     void restoreInstanceState(Bundle savedInstanceState, ProvisioningParams params);
69 
70     /**
71      * Execute cleanup actions that need to be performed when the finalization activity is
72      * destroyed, even if the system's provisioning state has not yet been finalized.
73      */
activityDestroyed(boolean isFinishing)74     void activityDestroyed(boolean isFinishing);
75 }
76