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.storage;
18 
19 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_ALLOW_DEBUGGING;
20 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES;
21 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_ALLOWLIST;
22 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_APP_PROVIDER_NAME;
23 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_DISABLE_OUTGOING_CALLS;
24 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE;
25 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_PACKAGE;
26 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_MANDATORY_PROVISION;
27 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_PROVISIONING_TYPE;
28 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_SUPPORT_URL;
29 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_TERMS_AND_CONDITIONS_URL;
30 import static com.android.devicelockcontroller.common.DeviceLockConstants.ProvisioningType.TYPE_FINANCED;
31 
32 import android.os.Bundle;
33 
34 import com.android.devicelockcontroller.common.DeviceLockConstants.ProvisioningType;
35 
36 import java.util.ArrayList;
37 
38 abstract class AbstractSetupParametersTestBase {
39     protected static final String KIOSK_PACKAGE = "package";
40     protected static final String KIOSK_OVERRIDE_PACKAGE = "override.package";
41     protected static final boolean DISABLE_OUTGOING_CALLS = true;
42     protected static final boolean ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE = true;
43     protected static final String KIOSK_ALLOWLIST_PACKAGE_0 = "package.name.0";
44     protected static final String KIOSK_ALLOWLIST_PACKAGE_1 = "package.name.1";
45     @ProvisioningType
46     protected static final int PROVISIONING_TYPE = TYPE_FINANCED;
47     protected static final boolean MANDATORY_PROVISION = true;
48     protected static final boolean ALLOW_DEBUGGING = true;
49     protected static final boolean DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES = true;
50     protected static final String TERMS_AND_CONDITIONS_URL = "https://www.example.com/terms";
51     protected static final String SUPPORT_URL = "https://www.example.com/support";
52     protected static final String KIOSK_APP_PROVIDER_NAME = "test name";
53 
createParamsBundle()54     protected static Bundle createParamsBundle() {
55         final Bundle bundle = new Bundle();
56         bundle.putString(EXTRA_KIOSK_PACKAGE, KIOSK_PACKAGE);
57         bundle.putBoolean(EXTRA_KIOSK_DISABLE_OUTGOING_CALLS, DISABLE_OUTGOING_CALLS);
58         bundle.putBoolean(
59                 EXTRA_KIOSK_ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE,
60                 ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE);
61         final ArrayList<String> actualKioskAllowlist = new ArrayList<>();
62         actualKioskAllowlist.add(KIOSK_ALLOWLIST_PACKAGE_0);
63         actualKioskAllowlist.add(KIOSK_ALLOWLIST_PACKAGE_1);
64         bundle.putStringArrayList(EXTRA_KIOSK_ALLOWLIST, actualKioskAllowlist);
65         bundle.putInt(EXTRA_PROVISIONING_TYPE, PROVISIONING_TYPE);
66         bundle.putBoolean(EXTRA_MANDATORY_PROVISION, MANDATORY_PROVISION);
67         bundle.putBoolean(EXTRA_ALLOW_DEBUGGING, ALLOW_DEBUGGING);
68         bundle.putString(EXTRA_KIOSK_APP_PROVIDER_NAME, KIOSK_APP_PROVIDER_NAME);
69         bundle.putBoolean(EXTRA_DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES,
70                 DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES);
71         bundle.putString(EXTRA_TERMS_AND_CONDITIONS_URL, TERMS_AND_CONDITIONS_URL);
72         bundle.putString(EXTRA_SUPPORT_URL, SUPPORT_URL);
73         return bundle;
74     }
75 
createParamsOverrideBundle()76     protected static Bundle createParamsOverrideBundle() {
77         final Bundle bundle = new Bundle();
78         bundle.putString(EXTRA_KIOSK_PACKAGE, KIOSK_OVERRIDE_PACKAGE);
79         return bundle;
80     }
81 }
82