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; 18 19 import android.annotation.CallbackExecutor; 20 import android.annotation.RequiresPermission; 21 import android.os.OutcomeReceiver; 22 23 import androidx.annotation.NonNull; 24 25 import java.util.concurrent.Executor; 26 27 /** 28 * Manager used to interact with the system device lock service from the Device Lock Controller. 29 * Stopgap: these should have been SystemApis on DeviceLockManager. 30 */ 31 public interface SystemDeviceLockManager { 32 String MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER = 33 "com.android.devicelockcontroller.permission." 34 + "MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER"; 35 36 /** 37 * Add the FINANCED_DEVICE_KIOSK role to the specified package. 38 * 39 * @param packageName package for the financed device kiosk app. 40 * @param executor the {@link Executor} on which to invoke the callback. 41 * @param callback this returns either success or an exception. 42 */ 43 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) addFinancedDeviceKioskRole(@onNull String packageName, @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)44 void addFinancedDeviceKioskRole(@NonNull String packageName, 45 @CallbackExecutor Executor executor, 46 @NonNull OutcomeReceiver<Void, Exception> callback); 47 48 /** 49 * Remove the FINANCED_DEVICE_KIOSK role from the specified package. 50 * 51 * @param packageName package for the financed device kiosk app. 52 * @param executor the {@link Executor} on which to invoke the callback. 53 * @param callback this returns either success or an exception. 54 */ 55 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) removeFinancedDeviceKioskRole(@onNull String packageName, @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)56 void removeFinancedDeviceKioskRole(@NonNull String packageName, 57 @CallbackExecutor Executor executor, 58 @NonNull OutcomeReceiver<Void, Exception> callback); 59 60 /** 61 * Set the exemption state for activity background start restriction for dlc. 62 * 63 * @param exempt if true, dlc will be set to exempt from activity background start 64 * restriction; false, the exemption state will be set to default. 65 */ 66 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) setDlcExemptFromActivityBgStartRestrictionState(boolean exempt, @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)67 void setDlcExemptFromActivityBgStartRestrictionState(boolean exempt, 68 @CallbackExecutor Executor executor, 69 @NonNull OutcomeReceiver<Void, Exception> callback); 70 71 /** 72 * Set whether the dlc should be allowed to send undismissible notifications 73 * 74 * @param allowed if true, dlc can send undimissible notifications 75 */ 76 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) setDlcAllowedToSendUndismissibleNotifications(boolean allowed, @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)77 void setDlcAllowedToSendUndismissibleNotifications(boolean allowed, 78 @CallbackExecutor Executor executor, 79 @NonNull OutcomeReceiver<Void, Exception> callback); 80 81 /** 82 * Set the exemption state of app restrictions (e.g. hibernation, battery and data usage) for 83 * kiosk app. 84 * 85 * @param packageName kiosk app package name. 86 * @param exempt if true, the given uid will be set to exempt from app restrictions (e.g. 87 * hibernation, battery and data usage restriction); false, the exemption 88 * state will be set to default. 89 * @param executor the {@link Executor} on which to invoke the callback. 90 * @param callback callback this returns either success or an exception. 91 */ 92 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) setKioskAppExemptFromRestrictionsState(String packageName, boolean exempt, @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)93 void setKioskAppExemptFromRestrictionsState(String packageName, boolean exempt, 94 @CallbackExecutor Executor executor, 95 @NonNull OutcomeReceiver<Void, Exception> callback); 96 97 /** 98 * Enable kiosk keepalive, making sure the kiosk app is restarted on crash. 99 * 100 * @param packageName kiosk app package name. 101 * @param executor the {@link Executor} on which to invoke the callback. 102 * @param callback callback this returns either success or an exception. 103 */ 104 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) enableKioskKeepalive(String packageName, @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)105 void enableKioskKeepalive(String packageName, @CallbackExecutor Executor executor, 106 @NonNull OutcomeReceiver<Void, Exception> callback); 107 108 /** 109 * Disable kiosk keepalive. 110 * 111 * @param executor the {@link Executor} on which to invoke the callback. 112 * @param callback callback this returns either success or an exception. 113 */ 114 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) disableKioskKeepalive(@allbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)115 void disableKioskKeepalive(@CallbackExecutor Executor executor, 116 @NonNull OutcomeReceiver<Void, Exception> callback); 117 118 /** 119 * Enable controller keepalive, making sure DLC is restarted on crash. 120 * 121 * @param executor the {@link Executor} on which to invoke the callback. 122 * @param callback callback this returns either success or an exception. 123 */ 124 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) enableControllerKeepalive(@allbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)125 void enableControllerKeepalive(@CallbackExecutor Executor executor, 126 @NonNull OutcomeReceiver<Void, Exception> callback); 127 128 /** 129 * Disable controller keepalive. 130 * 131 * @param executor the {@link Executor} on which to invoke the callback. 132 * @param callback callback this returns either success or an exception. 133 */ 134 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) disableControllerKeepalive(@allbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)135 void disableControllerKeepalive(@CallbackExecutor Executor executor, 136 @NonNull OutcomeReceiver<Void, Exception> callback); 137 138 /** 139 * Set whether device is finalized so that system service knows when to keep the Device Lock 140 * Controller enabled. 141 * 142 * @param finalized true if device is finalized and DLC should not be enabled. 143 * @param executor the {@link Executor} on which to invoke the callback. 144 * @param callback callback this returns either success or an exception. 145 */ 146 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) setDeviceFinalized(boolean finalized, @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)147 void setDeviceFinalized(boolean finalized, @CallbackExecutor Executor executor, 148 @NonNull OutcomeReceiver<Void, Exception> callback); 149 150 /** 151 * Set or clear the POST_NOTIFICATIONS permission as SYSTEM_FIXED, so it cannot be revoked 152 * in Settings. 153 * 154 * @param systemFixed true if POST_NOTIFICATIONS should be SYSTEM_FIXED. 155 * @param executor the {@link Executor} on which to invoke the callback. 156 * @param callback callback this returns either success or an exception. 157 */ 158 @RequiresPermission(MANAGE_DEVICE_LOCK_SERVICE_FROM_CONTROLLER) setPostNotificationsSystemFixed(boolean systemFixed, Executor executor, @NonNull OutcomeReceiver<Void, Exception> callback)159 void setPostNotificationsSystemFixed(boolean systemFixed, Executor executor, 160 @NonNull OutcomeReceiver<Void, Exception> callback); 161 } 162