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.provision.grpc; 18 19 import androidx.annotation.NonNull; 20 import androidx.annotation.Nullable; 21 22 import com.android.devicelockcontroller.common.DeviceLockConstants.DeviceCheckInStatus; 23 import com.android.devicelockcontroller.common.DeviceLockConstants.ProvisioningType; 24 25 import io.grpc.Status; 26 27 import java.time.Instant; 28 29 /** 30 * An abstract class that is used to encapsulate the response for getting device check in status. 31 */ 32 public abstract class GetDeviceCheckInStatusGrpcResponse extends GrpcResponse { GetDeviceCheckInStatusGrpcResponse()33 public GetDeviceCheckInStatusGrpcResponse() { 34 } 35 GetDeviceCheckInStatusGrpcResponse(@onNull Status status)36 public GetDeviceCheckInStatusGrpcResponse(@NonNull Status status) { 37 super(status); 38 } 39 40 /** 41 * Get the current status of the device from DeviceLock server. 42 * 43 * @return One of the {@link DeviceCheckInStatus} 44 */ 45 @DeviceCheckInStatus getDeviceCheckInStatus()46 public abstract int getDeviceCheckInStatus(); 47 48 /** 49 * Get the unique identifier that is registered to DeviceLock server. If the device has never 50 * checked in with server, this will return null. 51 * 52 * @return The registered device unique identifier. Null if there is no registered id. 53 */ 54 @Nullable getRegisteredDeviceIdentifier()55 public abstract String getRegisteredDeviceIdentifier(); 56 57 /** 58 * Get a {@link Instant} instance that represents the time stamp when device should perform next 59 * check in request. 60 * 61 * @return The timestamp for next check in should be performed. 62 */ 63 @Nullable getNextCheckInTime()64 public abstract Instant getNextCheckInTime(); 65 66 /** 67 * Get the provisioning configuration for the device. 68 * 69 * @return A {@link ProvisioningConfiguration} instance containing the required information for 70 * device to finish provisioning. 71 */ 72 @Nullable getProvisioningConfig()73 public abstract ProvisioningConfiguration getProvisioningConfig(); 74 75 /** 76 * Get the type of provisioning that this device should perform. 77 * 78 * @return One of {@link ProvisioningType} 79 */ 80 @ProvisioningType getProvisioningType()81 public abstract int getProvisioningType(); 82 83 /** 84 * Check if provisioning is mandatory for this device, i.e. this device should not be used 85 * before provisioning is completed. 86 * 87 * @return true if provisioning is mandatory for this device; false otherwise. 88 */ isProvisioningMandatory()89 public abstract boolean isProvisioningMandatory(); 90 91 /** 92 * Check if provisioning is forced, i.e. user should not delay/reschedule provisioning 93 * operation. 94 */ isProvisionForced()95 public abstract boolean isProvisionForced(); 96 97 /** 98 * Check if the device is in an approved country, i.e. device provisioning should proceed. If 99 * false, then device provisioning should not proceed and would result in provision failure. 100 * 101 * @return true if the device is an approved country; false otherwise. 102 */ isDeviceInApprovedCountry()103 public abstract boolean isDeviceInApprovedCountry(); 104 105 /** 106 * Check if adb debugging is allowed even on production devices. 107 * 108 * @return true if debugging is allowed; false otherwise. 109 */ isDebuggingAllowed()110 public abstract boolean isDebuggingAllowed(); 111 } 112