• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.common;
18 
19 import androidx.annotation.IntDef;
20 
21 import java.lang.annotation.ElementType;
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24 import java.lang.annotation.Target;
25 
26 /** Constants being used by more than one class in the Device Lock application. */
27 public final class DeviceLockConstants {
28     /** Device reset count down minute when mandatory provision fails */
29     public static final int MANDATORY_PROVISION_DEVICE_RESET_COUNTDOWN_MINUTE = 2;
30     /** Device reset count down minute when non-mandatory provision fails */
31     public static final int NON_MANDATORY_PROVISION_DEVICE_RESET_COUNTDOWN_MINUTE = 30;
32 
33     // JobSchedule Job IDs have to be unique across the same UID, so they need to be centrally
34     // managed.
35 
36     /** Max value for Job ID for use by WorkManager */
37     public static final int WORK_MANAGER_MAX_JOB_SCHEDULER_ID = 100_000;
38 
39     /** Job Id for Setup Wizard Timeout Job */
40     public static final int SETUP_WIZARD_TIMEOUT_JOB_ID = WORK_MANAGER_MAX_JOB_SCHEDULER_ID + 1;
41 
42     // Constants related to unique device identifiers.
43     @Retention(RetentionPolicy.SOURCE)
44     @IntDef(value = {
45             DeviceIdType.DEVICE_ID_TYPE_UNSPECIFIED,
46             DeviceIdType.DEVICE_ID_TYPE_IMEI,
47             DeviceIdType.DEVICE_ID_TYPE_MEID,
48     })
49     public @interface DeviceIdType {
50         // The device id type is unspecified
51         int DEVICE_ID_TYPE_UNSPECIFIED = -1;
52         // The device id is a IMEI
53         int DEVICE_ID_TYPE_IMEI = 0;
54         // The device id is a MEID
55         int DEVICE_ID_TYPE_MEID = 1;
56     }
57 
58     @DeviceIdType
59     private static final int LAST_DEVICE_ID_TYPE = DeviceIdType.DEVICE_ID_TYPE_MEID;
60     public static final int TOTAL_DEVICE_ID_TYPES = LAST_DEVICE_ID_TYPE + 1;
61 
62     // Constants related to unique device identifiers.
63     @Retention(RetentionPolicy.SOURCE)
64     @IntDef(value = {
65             STATUS_UNSPECIFIED,
66             RETRY_CHECK_IN,
67             READY_FOR_PROVISION,
68             STOP_CHECK_IN,
69     })
70     public @interface DeviceCheckInStatus {
71     }
72 
73     public static final int STATUS_UNSPECIFIED = 0;
74     public static final int RETRY_CHECK_IN = 1;
75     public static final int READY_FOR_PROVISION = 2;
76     public static final int STOP_CHECK_IN = 3;
77 
78     @Retention(RetentionPolicy.SOURCE)
79     @IntDef(value = {
80             REASON_UNSPECIFIED,
81             USER_DEFERRED_DEVICE_PROVISIONING,
82     })
83     public @interface PauseDeviceProvisioningReason {
84     }
85 
86     public static final int REASON_UNSPECIFIED = 0;
87     public static final int USER_DEFERRED_DEVICE_PROVISIONING = 1;
88 
89     @Target(ElementType.TYPE_USE)
90     @Retention(RetentionPolicy.SOURCE)
91     @IntDef(value = {
92             ProvisioningType.TYPE_UNDEFINED,
93             ProvisioningType.TYPE_FINANCED,
94             ProvisioningType.TYPE_SUBSIDY,
95     })
96     public @interface ProvisioningType {
97         int TYPE_UNDEFINED = 0;
98         int TYPE_FINANCED = 1;
99         int TYPE_SUBSIDY = 2;
100     }
101 
102     @Retention(RetentionPolicy.SOURCE)
103     @IntDef(value = {
104             ProvisionFailureReason.UNKNOWN_REASON,
105             ProvisionFailureReason.PLAY_TASK_UNAVAILABLE,
106             ProvisionFailureReason.PLAY_INSTALLATION_FAILED,
107             ProvisionFailureReason.COUNTRY_INFO_UNAVAILABLE,
108             ProvisionFailureReason.NOT_IN_ELIGIBLE_COUNTRY,
109             ProvisionFailureReason.POLICY_ENFORCEMENT_FAILED,
110             ProvisionFailureReason.DEADLINE_PASSED
111     })
112     public @interface ProvisionFailureReason {
113         int UNKNOWN_REASON = 0;
114         int PLAY_TASK_UNAVAILABLE = 1;
115         int PLAY_INSTALLATION_FAILED = 2;
116         int COUNTRY_INFO_UNAVAILABLE = 3;
117         int NOT_IN_ELIGIBLE_COUNTRY = 4;
118         int POLICY_ENFORCEMENT_FAILED = 5;
119         int DEADLINE_PASSED = 6;
120     }
121 
122     public static final String EXTRA_KIOSK_PACKAGE =
123             "com.android.devicelockcontroller.KIOSK_PACKAGE";
124     public static final String EXTRA_KIOSK_DISABLE_OUTGOING_CALLS =
125             "com.android.devicelockcontroller.KIOSK_DISABLE_OUTGOING_CALLS";
126     /**
127      * Used to control if notifications are enabled in lock task mode. The default value is false.
128      *
129      * @see android.app.admin.DevicePolicyManager#LOCK_TASK_FEATURE_NOTIFICATIONS
130      */
131     public static final String EXTRA_KIOSK_ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE =
132             "com.android.devicelockcontroller.KIOSK_ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE";
133 
134     /**
135      * Used to control if adb debugging should be allowed on prod devices. The default value is
136      * false.
137      */
138     public static final String EXTRA_ALLOW_DEBUGGING =
139             "com.android.devicelockcontroller.ALLOW_DEBUGGING";
140     public static final String EXTRA_KIOSK_ALLOWLIST =
141             "com.android.devicelockcontroller.KIOSK_ALLOWLIST";
142     public static final String EXTRA_PROVISIONING_TYPE =
143             "com.android.devicelockcontroller.PROVISIONING_TYPE";
144     public static final String EXTRA_MANDATORY_PROVISION =
145             "com.android.devicelockcontroller.MANDATORY_PROVISION";
146     public static final String EXTRA_KIOSK_APP_PROVIDER_NAME =
147             "com.android.devicelockcontroller.KIOSK_APP_PROVIDER_NAME";
148     public static final String EXTRA_DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES =
149             "com.android.devicelockcontroller.DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES";
150 
151     public static final String EXTRA_TERMS_AND_CONDITIONS_URL =
152             "com.android.devicelockcontroller.TERMS_AND_CONDITIONS_URL";
153 
154     public static final String EXTRA_SUPPORT_URL = "com.android.devicelockcontroller.SUPPORT_URL";
155 
156     public static final String ACTION_START_DEVICE_FINANCING_PROVISIONING =
157             "com.android.devicelockcontroller.action.START_DEVICE_FINANCING_PROVISIONING";
158 
159     public static final String ACTION_START_DEVICE_SUBSIDY_PROVISIONING =
160             "com.android.devicelockcontroller.action.START_DEVICE_SUBSIDY_PROVISIONING";
161 
162     /** Definitions for device provision states. */
163     @Retention(RetentionPolicy.SOURCE)
164     @IntDef(
165             value = {
166                     DeviceProvisionState.PROVISION_STATE_UNSPECIFIED,
167                     DeviceProvisionState.PROVISION_STATE_RETRY,
168                     DeviceProvisionState.PROVISION_STATE_DISMISSIBLE_UI,
169                     DeviceProvisionState.PROVISION_STATE_PERSISTENT_UI,
170                     DeviceProvisionState.PROVISION_STATE_FACTORY_RESET,
171                     DeviceProvisionState.PROVISION_STATE_SUCCESS,
172             })
173     public @interface DeviceProvisionState {
174         /** The provision state of the device is unspecified */
175         int PROVISION_STATE_UNSPECIFIED = 0;
176         /** The Device need retry to provision the device. */
177         int PROVISION_STATE_RETRY = 1;
178         /**
179          * The Device need inform the user that there has been an issue with device provisioning.
180          * The user can dismiss this.
181          */
182         int PROVISION_STATE_DISMISSIBLE_UI = 2;
183         /**
184          * The Device need inform the user that there has been an issue with device provisioning.
185          * The user cannot dismiss this.
186          */
187         int PROVISION_STATE_PERSISTENT_UI = 3;
188         /** The Device need factory reset because device provisioning could not be done. */
189         int PROVISION_STATE_FACTORY_RESET = 4;
190         /** Device provisioning was a success. */
191         int PROVISION_STATE_SUCCESS = 5;
192     }
193 
194     /** Prevent instantiation. */
DeviceLockConstants()195     private DeviceLockConstants() {
196     }
197 }
198