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 static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES; 20 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_ALLOWLIST; 21 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_APP_PROVIDER_NAME; 22 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_DISABLE_OUTGOING_CALLS; 23 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE; 24 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_KIOSK_PACKAGE; 25 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_SUPPORT_URL; 26 import static com.android.devicelockcontroller.common.DeviceLockConstants.EXTRA_TERMS_AND_CONDITIONS_URL; 27 28 import android.os.Bundle; 29 30 import java.util.ArrayList; 31 import java.util.List; 32 33 /** 34 * A data structure class that contains information necessary to device provisioning for DeviceLock 35 * program. 36 */ 37 public final class ProvisioningConfiguration { 38 39 // The package name of the kiosk app, e.g. "com.foo.bar". 40 private final String mKioskAppProviderName; 41 // The name of the provider of the kiosk app, e.g. "Foo Bar Inc". 42 43 private final String mKioskAppPackageName; 44 // The list of apps that a user can use when the device is locked. 45 private final List<String> mKioskAppAllowlistPackages; 46 // Whether the user can make phone calls when the device is locked. 47 private final boolean mKioskAppEnableOutgoingCalls; 48 49 // Whether notifications are shown to the user when the device is locked. 50 private final boolean mKioskAppEnableEnableNotifications; 51 52 // Whether installing application from unknown sources is disallowed on this device once 53 // provisioned. 54 private final boolean mDisallowInstallingFromUnknownSources; 55 56 // The URL to the Terms and Conditions of the partner for enrolling in a 57 // Device Lock program. 58 private final String mTermsAndConditionsUrl; 59 60 // The URL to the support page the user can use to get help. 61 private final String mSupportUrl; 62 ProvisioningConfiguration( String kioskAppProviderName, String kioskAppPackageName, List<String> kioskAppAllowlistPackages, boolean kioskAppEnableOutgoingCalls, boolean kioskAppEnableEnableNotifications, boolean disallowInstallingFromUnknownSources, String termsAndConditionsUrl, String supportUrl)63 public ProvisioningConfiguration( 64 String kioskAppProviderName, 65 String kioskAppPackageName, 66 List<String> kioskAppAllowlistPackages, 67 boolean kioskAppEnableOutgoingCalls, boolean kioskAppEnableEnableNotifications, 68 boolean disallowInstallingFromUnknownSources, String termsAndConditionsUrl, 69 String supportUrl) { 70 mKioskAppProviderName = kioskAppProviderName; 71 mKioskAppPackageName = kioskAppPackageName; 72 mKioskAppAllowlistPackages = kioskAppAllowlistPackages; 73 mKioskAppEnableOutgoingCalls = kioskAppEnableOutgoingCalls; 74 mKioskAppEnableEnableNotifications = kioskAppEnableEnableNotifications; 75 mDisallowInstallingFromUnknownSources = disallowInstallingFromUnknownSources; 76 mTermsAndConditionsUrl = termsAndConditionsUrl; 77 mSupportUrl = supportUrl; 78 } 79 80 /** 81 * Create a bundle containing the provisioning information. 82 */ toBundle()83 public Bundle toBundle() { 84 final Bundle bundle = new Bundle(); 85 bundle.putString(EXTRA_KIOSK_PACKAGE, mKioskAppPackageName); 86 bundle.putBoolean(EXTRA_KIOSK_DISABLE_OUTGOING_CALLS, !mKioskAppEnableOutgoingCalls); 87 bundle.putBoolean(EXTRA_KIOSK_ENABLE_NOTIFICATIONS_IN_LOCK_TASK_MODE, 88 mKioskAppEnableEnableNotifications); 89 bundle.putStringArrayList(EXTRA_KIOSK_ALLOWLIST, 90 new ArrayList<>(mKioskAppAllowlistPackages)); 91 bundle.putString(EXTRA_KIOSK_APP_PROVIDER_NAME, mKioskAppProviderName); 92 bundle.putBoolean(EXTRA_DISALLOW_INSTALLING_FROM_UNKNOWN_SOURCES, 93 mDisallowInstallingFromUnknownSources); 94 bundle.putString(EXTRA_TERMS_AND_CONDITIONS_URL, mTermsAndConditionsUrl); 95 bundle.putString(EXTRA_SUPPORT_URL, mSupportUrl); 96 return bundle; 97 } 98 } 99