Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 17 | package android.app.admin; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 18 | |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 19 | import android.accounts.AccountManager; |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 20 | import android.annotation.IntDef; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 21 | import android.annotation.SdkConstant; |
| 22 | import android.annotation.SdkConstant.SdkConstantType; |
Julia Reynolds | 94e7bf6 | 2015-06-10 14:44:56 -0400 | [diff] [blame] | 23 | import android.annotation.SystemApi; |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 24 | import android.app.Service; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
| 26 | import android.content.ComponentName; |
| 27 | import android.content.Context; |
| 28 | import android.content.Intent; |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 29 | import android.net.Uri; |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 30 | import android.os.Bundle; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 31 | import android.security.KeyChain; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 32 | |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 33 | import java.lang.annotation.Retention; |
| 34 | import java.lang.annotation.RetentionPolicy; |
| 35 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 36 | /** |
| 37 | * Base class for implementing a device administration component. This |
| 38 | * class provides a convenience for interpreting the raw intent actions |
| 39 | * that are sent by the system. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 40 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 41 | * <p>The callback methods, like the base |
| 42 | * {@link BroadcastReceiver#onReceive(Context, Intent) BroadcastReceiver.onReceive()} |
| 43 | * method, happen on the main thread of the process. Thus long running |
| 44 | * operations must be done on another thread. Note that because a receiver |
| 45 | * is done once returning from its receive function, such long-running operations |
| 46 | * should probably be done in a {@link Service}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 47 | * |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 48 | * <p>When publishing your DeviceAdmin subclass as a receiver, it must |
| 49 | * handle {@link #ACTION_DEVICE_ADMIN_ENABLED} and require the |
| 50 | * {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission. A typical |
| 51 | * manifest entry would look like:</p> |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 52 | * |
Dianne Hackborn | ab8a8ed | 2010-01-29 19:03:06 -0800 | [diff] [blame] | 53 | * {@sample development/samples/ApiDemos/AndroidManifest.xml device_admin_declaration} |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 54 | * |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 55 | * <p>The meta-data referenced here provides addition information specific |
| 56 | * to the device administrator, as parsed by the {@link DeviceAdminInfo} class. |
| 57 | * A typical file would be:</p> |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 58 | * |
Andrew Stadler | 88209d1 | 2010-02-08 22:59:36 -0800 | [diff] [blame] | 59 | * {@sample development/samples/ApiDemos/res/xml/device_admin_sample.xml meta_data} |
Joe Fernandez | 3aef8e1d | 2011-12-20 10:38:34 -0800 | [diff] [blame] | 60 | * |
| 61 | * <div class="special reference"> |
| 62 | * <h3>Developer Guides</h3> |
| 63 | * <p>For more information about device administration, read the |
| 64 | * <a href="{@docRoot}guide/topics/admin/device-admin.html">Device Administration</a> |
| 65 | * developer guide.</p> |
| 66 | * </div> |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 67 | */ |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 68 | public class DeviceAdminReceiver extends BroadcastReceiver { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 69 | private static String TAG = "DevicePolicy"; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 70 | private static boolean localLOGV = false; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * This is the primary action that a device administrator must implement to be |
| 74 | * allowed to manage a device. This will be set to the receiver |
| 75 | * when the user enables it for administration. You will generally |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 76 | * handle this in {@link DeviceAdminReceiver#onEnabled(Context, Intent)}. To be |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 77 | * supported, the receiver must also require the |
| 78 | * {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission so |
| 79 | * that other applications can not abuse it. |
| 80 | */ |
| 81 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 82 | public static final String ACTION_DEVICE_ADMIN_ENABLED |
| 83 | = "android.app.action.DEVICE_ADMIN_ENABLED"; |
| 84 | |
| 85 | /** |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 86 | * Action sent to a device administrator when the user has requested to |
| 87 | * disable it, but before this has actually been done. This gives you |
| 88 | * a chance to supply a message to the user about the impact of |
| 89 | * disabling your admin, by setting the extra field |
| 90 | * {@link #EXTRA_DISABLE_WARNING} in the result Intent. If not set, |
| 91 | * no warning will be displayed. If set, the given text will be shown |
| 92 | * to the user before they disable your admin. |
| 93 | */ |
| 94 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 95 | public static final String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED |
| 96 | = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 97 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 98 | /** |
| 99 | * A CharSequence that can be shown to the user informing them of the |
| 100 | * impact of disabling your admin. |
| 101 | * |
| 102 | * @see #ACTION_DEVICE_ADMIN_DISABLE_REQUESTED |
| 103 | */ |
| 104 | public static final String EXTRA_DISABLE_WARNING = "android.app.extra.DISABLE_WARNING"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 105 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 106 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 107 | * Action sent to a device administrator when the user has disabled |
| 108 | * it. Upon return, the application no longer has access to the |
| 109 | * protected device policy manager APIs. You will generally |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 110 | * handle this in {@link DeviceAdminReceiver#onDisabled(Context, Intent)}. Note |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 111 | * that this action will be |
| 112 | * sent the receiver regardless of whether it is explicitly listed in |
| 113 | * its intent filter. |
| 114 | */ |
| 115 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 116 | public static final String ACTION_DEVICE_ADMIN_DISABLED |
| 117 | = "android.app.action.DEVICE_ADMIN_DISABLED"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 118 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 119 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 120 | * Action sent to a device administrator when the user has changed the password of their device |
| 121 | * or profile challenge. You can at this point check the characteristics |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 122 | * of the new password with {@link DevicePolicyManager#isActivePasswordSufficient() |
| 123 | * DevicePolicyManager.isActivePasswordSufficient()}. |
| 124 | * You will generally |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 125 | * handle this in {@link DeviceAdminReceiver#onPasswordChanged}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 126 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 127 | * <p>The calling device admin must have requested |
| 128 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to receive |
| 129 | * this broadcast. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 130 | */ |
| 131 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 132 | public static final String ACTION_PASSWORD_CHANGED |
| 133 | = "android.app.action.ACTION_PASSWORD_CHANGED"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 134 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 135 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 136 | * Action sent to a device administrator when the user has entered an incorrect device |
| 137 | * or profile challenge password. You can at this point check the |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 138 | * number of failed password attempts there have been with |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 139 | * {@link DevicePolicyManager#getCurrentFailedPasswordAttempts |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 140 | * DevicePolicyManager.getCurrentFailedPasswordAttempts()}. You will generally |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 141 | * handle this in {@link DeviceAdminReceiver#onPasswordFailed}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 142 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 143 | * <p>The calling device admin must have requested |
| 144 | * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to receive |
| 145 | * this broadcast. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 146 | */ |
| 147 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 148 | public static final String ACTION_PASSWORD_FAILED |
| 149 | = "android.app.action.ACTION_PASSWORD_FAILED"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 150 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 151 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 152 | * Action sent to a device administrator when the user has successfully entered their device |
| 153 | * or profile challenge password, after failing one or more times. You will generally |
| 154 | * handle this in {@link DeviceAdminReceiver#onPasswordSucceeded}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 155 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 156 | * <p>The calling device admin must have requested |
| 157 | * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to receive |
| 158 | * this broadcast. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 159 | */ |
| 160 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 161 | public static final String ACTION_PASSWORD_SUCCEEDED |
| 162 | = "android.app.action.ACTION_PASSWORD_SUCCEEDED"; |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 163 | |
| 164 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 165 | * Action periodically sent to a device administrator when the device or profile challenge |
| 166 | * password is expiring. You will generally |
| 167 | * handle this in {@link DeviceAdminReceiver#onPasswordExpiring}. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 168 | * |
| 169 | * <p>The calling device admin must have requested |
| 170 | * {@link DeviceAdminInfo#USES_POLICY_EXPIRE_PASSWORD} to receive |
| 171 | * this broadcast. |
| 172 | */ |
| 173 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 174 | public static final String ACTION_PASSWORD_EXPIRING |
| 175 | = "android.app.action.ACTION_PASSWORD_EXPIRING"; |
| 176 | |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 177 | /** |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 178 | * Action sent to a device administrator to notify that the device is entering |
Benjamin Franz | 4326114 | 2015-02-11 15:59:44 +0000 | [diff] [blame] | 179 | * lock task mode. The extra {@link #EXTRA_LOCK_TASK_PACKAGE} |
| 180 | * will describe the package using lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 181 | * |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 182 | * <p>The calling device admin must be the device owner or profile |
| 183 | * owner to receive this broadcast. |
Benjamin Franz | c70d0e7 | 2015-02-12 16:12:58 +0000 | [diff] [blame] | 184 | * |
| 185 | * @see DevicePolicyManager#isLockTaskPermitted(String) |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 186 | */ |
| 187 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 188 | public static final String ACTION_LOCK_TASK_ENTERING |
Jason Monk | 5503a55 | 2014-09-04 14:14:37 -0400 | [diff] [blame] | 189 | = "android.app.action.LOCK_TASK_ENTERING"; |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 190 | |
| 191 | /** |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 192 | * Action sent to a device administrator to notify that the device is exiting |
Benjamin Franz | 4326114 | 2015-02-11 15:59:44 +0000 | [diff] [blame] | 193 | * lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 194 | * |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 195 | * <p>The calling device admin must be the device owner or profile |
| 196 | * owner to receive this broadcast. |
Benjamin Franz | c70d0e7 | 2015-02-12 16:12:58 +0000 | [diff] [blame] | 197 | * |
| 198 | * @see DevicePolicyManager#isLockTaskPermitted(String) |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 199 | */ |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 200 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 201 | public static final String ACTION_LOCK_TASK_EXITING |
Jason Monk | 5503a55 | 2014-09-04 14:14:37 -0400 | [diff] [blame] | 202 | = "android.app.action.LOCK_TASK_EXITING"; |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 203 | |
| 204 | /** |
Benjamin Franz | c70d0e7 | 2015-02-12 16:12:58 +0000 | [diff] [blame] | 205 | * A string containing the name of the package entering lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 206 | * |
Benjamin Franz | c70d0e7 | 2015-02-12 16:12:58 +0000 | [diff] [blame] | 207 | * @see #ACTION_LOCK_TASK_ENTERING |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 208 | */ |
| 209 | public static final String EXTRA_LOCK_TASK_PACKAGE = |
| 210 | "android.app.extra.LOCK_TASK_PACKAGE"; |
| 211 | |
| 212 | /** |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 213 | * Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile |
| 214 | * or managed device has completed successfully. |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 215 | * |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 216 | * <p>The broadcast is limited to the profile that will be managed by the application that |
| 217 | * requested provisioning. In the device owner case the profile is the primary user. |
| 218 | * The broadcast will also be limited to the {@link DeviceAdminReceiver} component |
| 219 | * specified in the original intent or NFC bump that started the provisioning process |
Andrew Solovay | 27f5337 | 2015-03-02 16:37:59 -0800 | [diff] [blame] | 220 | * (see {@link DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE |
| 221 | * DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE}). |
Nicolas Prevot | 07ac20b | 2014-05-27 15:37:45 +0100 | [diff] [blame] | 222 | * |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 223 | * <p>A device admin application which listens to this intent can find out if the device was |
| 224 | * provisioned for the device owner or profile owner case by calling respectively |
| 225 | * {@link android.app.admin.DevicePolicyManager#isDeviceOwnerApp} and |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 226 | * {@link android.app.admin.DevicePolicyManager#isProfileOwnerApp}. You will generally handle |
| 227 | * this in {@link DeviceAdminReceiver#onProfileProvisioningComplete}. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 228 | * |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 229 | * <p>Input: Nothing.</p> |
| 230 | * <p>Output: Nothing</p> |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 231 | */ |
| 232 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 233 | public static final String ACTION_PROFILE_PROVISIONING_COMPLETE = |
Jessica Hummel | 5669216 | 2014-09-10 15:12:11 +0100 | [diff] [blame] | 234 | "android.app.action.PROFILE_PROVISIONING_COMPLETE"; |
| 235 | |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 236 | /** |
| 237 | * Action sent to a device administrator to notify that the device user |
| 238 | * has declined sharing a bugreport. |
| 239 | * |
| 240 | * <p>The calling device admin must be the device owner to receive this broadcast. |
| 241 | * @see DevicePolicyManager#requestBugreport |
| 242 | * @hide |
| 243 | */ |
| 244 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 245 | public static final String ACTION_BUGREPORT_SHARING_DECLINED = |
| 246 | "android.app.action.BUGREPORT_SHARING_DECLINED"; |
| 247 | |
| 248 | /** |
| 249 | * Action sent to a device administrator to notify that the collection of a bugreport |
| 250 | * has failed. |
| 251 | * |
| 252 | * <p>The calling device admin must be the device owner to receive this broadcast. |
| 253 | * @see DevicePolicyManager#requestBugreport |
| 254 | * @hide |
| 255 | */ |
| 256 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 257 | public static final String ACTION_BUGREPORT_FAILED = "android.app.action.BUGREPORT_FAILED"; |
| 258 | |
| 259 | /** |
| 260 | * Action sent to a device administrator to share the bugreport. |
| 261 | * |
| 262 | * <p>The calling device admin must be the device owner to receive this broadcast. |
| 263 | * @see DevicePolicyManager#requestBugreport |
| 264 | * @hide |
| 265 | */ |
| 266 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 267 | public static final String ACTION_BUGREPORT_SHARE = |
| 268 | "android.app.action.BUGREPORT_SHARE"; |
| 269 | |
| 270 | /** |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 271 | * Broadcast action: notify that a new batch of device logs is ready to be collected. |
| 272 | * @hide |
| 273 | */ |
| 274 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 275 | public static final String ACTION_SECURITY_LOGS_AVAILABLE |
| 276 | = "android.app.action.SECURITY_LOGS_AVAILABLE"; |
| 277 | |
| 278 | /** |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 279 | * A string containing the SHA-256 hash of the bugreport file. |
| 280 | * |
| 281 | * @see #ACTION_BUGREPORT_SHARE |
| 282 | * @hide |
| 283 | */ |
| 284 | public static final String EXTRA_BUGREPORT_HASH = "android.app.extra.BUGREPORT_HASH"; |
| 285 | |
| 286 | /** |
| 287 | * An {@code int} failure code representing the reason of the bugreport failure. |
| 288 | * |
| 289 | * @see #ACTION_BUGREPORT_FAILED |
| 290 | * @see #BUGREPORT_FAILURE_FAILED_COMPLETING, #BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE |
| 291 | * @hide |
| 292 | */ |
| 293 | public static final String EXTRA_BUGREPORT_FAILURE_REASON = |
| 294 | "android.app.extra.BUGREPORT_FAILURE_REASON"; |
| 295 | |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 296 | /** |
| 297 | * An interface representing reason of bugreport failure. |
| 298 | * |
| 299 | * @see #EXTRA_BUGREPORT_FAILURE_REASON |
| 300 | * @hide |
| 301 | */ |
Felipe Leme | dc7af96 | 2016-01-22 18:27:03 -0800 | [diff] [blame] | 302 | @Retention(RetentionPolicy.SOURCE) |
| 303 | @IntDef({ |
| 304 | BUGREPORT_FAILURE_FAILED_COMPLETING, |
| 305 | BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE |
| 306 | }) |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 307 | public @interface BugreportFailureCode {} |
| 308 | /** Bugreport completion process failed. */ |
| 309 | public static final int BUGREPORT_FAILURE_FAILED_COMPLETING = 0; |
| 310 | /** Bugreport is no longer available for collection. */ |
| 311 | public static final int BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE = 1; |
| 312 | |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 313 | /** @hide */ |
| 314 | public static final String ACTION_CHOOSE_PRIVATE_KEY_ALIAS = "android.app.action.CHOOSE_PRIVATE_KEY_ALIAS"; |
| 315 | |
| 316 | /** @hide */ |
| 317 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_SENDER_UID = "android.app.extra.CHOOSE_PRIVATE_KEY_SENDER_UID"; |
| 318 | |
| 319 | /** @hide */ |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 320 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_URI = "android.app.extra.CHOOSE_PRIVATE_KEY_URI"; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 321 | |
| 322 | /** @hide */ |
| 323 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_ALIAS = "android.app.extra.CHOOSE_PRIVATE_KEY_ALIAS"; |
| 324 | |
| 325 | /** @hide */ |
| 326 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_RESPONSE = "android.app.extra.CHOOSE_PRIVATE_KEY_RESPONSE"; |
| 327 | |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 328 | /** |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 329 | * Broadcast action: notify device owner that there is a pending system update. |
| 330 | * @hide |
| 331 | */ |
| 332 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 333 | public static final String ACTION_NOTIFY_PENDING_SYSTEM_UPDATE = "android.app.action.NOTIFY_PENDING_SYSTEM_UPDATE"; |
| 334 | |
| 335 | /** |
| 336 | * A long type extra for {@link #onSystemUpdatePending} recording the system time as given by |
| 337 | * {@link System#currentTimeMillis()} when the current pending system update is first available. |
| 338 | * @hide |
| 339 | */ |
| 340 | public static final String EXTRA_SYSTEM_UPDATE_RECEIVED_TIME = "android.app.extra.SYSTEM_UPDATE_RECEIVED_TIME"; |
| 341 | |
| 342 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 343 | * Name under which a DevicePolicy component publishes information |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 344 | * about itself. This meta-data must reference an XML resource containing |
Andrew Solovay | 27f5337 | 2015-03-02 16:37:59 -0800 | [diff] [blame] | 345 | * a device-admin tag. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 346 | */ |
Andrew Solovay | 27f5337 | 2015-03-02 16:37:59 -0800 | [diff] [blame] | 347 | // TO DO: describe syntax. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 348 | public static final String DEVICE_ADMIN_META_DATA = "android.app.device_admin"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 349 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 350 | private DevicePolicyManager mManager; |
| 351 | private ComponentName mWho; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 352 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 353 | /** |
| 354 | * Retrieve the DevicePolicyManager interface for this administrator to work |
| 355 | * with the system. |
| 356 | */ |
| 357 | public DevicePolicyManager getManager(Context context) { |
| 358 | if (mManager != null) { |
| 359 | return mManager; |
| 360 | } |
| 361 | mManager = (DevicePolicyManager)context.getSystemService( |
| 362 | Context.DEVICE_POLICY_SERVICE); |
| 363 | return mManager; |
| 364 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 365 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 366 | /** |
| 367 | * Retrieve the ComponentName describing who this device administrator is, for |
| 368 | * use in {@link DevicePolicyManager} APIs that require the administrator to |
| 369 | * identify itself. |
| 370 | */ |
| 371 | public ComponentName getWho(Context context) { |
| 372 | if (mWho != null) { |
| 373 | return mWho; |
| 374 | } |
| 375 | mWho = new ComponentName(context, getClass()); |
| 376 | return mWho; |
| 377 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 378 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 379 | /** |
| 380 | * Called after the administrator is first enabled, as a result of |
| 381 | * receiving {@link #ACTION_DEVICE_ADMIN_ENABLED}. At this point you |
| 382 | * can use {@link DevicePolicyManager} to set your desired policies. |
Jason Monk | 03978a4 | 2014-06-10 15:05:30 -0400 | [diff] [blame] | 383 | * |
| 384 | * <p> If the admin is activated by a device owner, then the intent |
| 385 | * may contain private extras that are relevant to user setup. |
| 386 | * {@see DevicePolicyManager#createAndInitializeUser(ComponentName, String, String, |
| 387 | * ComponentName, Intent)} |
| 388 | * |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 389 | * @param context The running context as per {@link #onReceive}. |
| 390 | * @param intent The received intent as per {@link #onReceive}. |
| 391 | */ |
| 392 | public void onEnabled(Context context, Intent intent) { |
| 393 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 394 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 395 | /** |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 396 | * Called when the user has asked to disable the administrator, as a result of |
| 397 | * receiving {@link #ACTION_DEVICE_ADMIN_DISABLE_REQUESTED}, giving you |
| 398 | * a chance to present a warning message to them. The message is returned |
| 399 | * as the result; if null is returned (the default implementation), no |
| 400 | * message will be displayed. |
| 401 | * @param context The running context as per {@link #onReceive}. |
| 402 | * @param intent The received intent as per {@link #onReceive}. |
| 403 | * @return Return the warning message to display to the user before |
| 404 | * being disabled; if null is returned, no message is displayed. |
| 405 | */ |
| 406 | public CharSequence onDisableRequested(Context context, Intent intent) { |
| 407 | return null; |
| 408 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 409 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 410 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 411 | * Called prior to the administrator being disabled, as a result of |
| 412 | * receiving {@link #ACTION_DEVICE_ADMIN_DISABLED}. Upon return, you |
| 413 | * can no longer use the protected parts of the {@link DevicePolicyManager} |
| 414 | * API. |
| 415 | * @param context The running context as per {@link #onReceive}. |
| 416 | * @param intent The received intent as per {@link #onReceive}. |
| 417 | */ |
| 418 | public void onDisabled(Context context, Intent intent) { |
| 419 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 420 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 421 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 422 | * Called after the user has changed their device or profile challenge password, as a result of |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 423 | * receiving {@link #ACTION_PASSWORD_CHANGED}. At this point you |
Robin Lee | 9983aca | 2016-01-20 17:15:08 +0000 | [diff] [blame] | 424 | * can use {@link DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 425 | * to retrieve the active password characteristics. |
| 426 | * @param context The running context as per {@link #onReceive}. |
| 427 | * @param intent The received intent as per {@link #onReceive}. |
| 428 | */ |
| 429 | public void onPasswordChanged(Context context, Intent intent) { |
| 430 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 431 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 432 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 433 | * Called after the user has failed at entering their device or profile challenge password, |
| 434 | * as a result of receiving {@link #ACTION_PASSWORD_FAILED}. At this point you can use |
| 435 | * {@link DevicePolicyManager#getCurrentFailedPasswordAttempts()} to retrieve the number of |
| 436 | * failed password attempts. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 437 | * @param context The running context as per {@link #onReceive}. |
| 438 | * @param intent The received intent as per {@link #onReceive}. |
| 439 | */ |
| 440 | public void onPasswordFailed(Context context, Intent intent) { |
| 441 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 442 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 443 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 444 | * Called after the user has succeeded at entering their device or profile challenge password, |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 445 | * as a result of receiving {@link #ACTION_PASSWORD_SUCCEEDED}. This will |
| 446 | * only be received the first time they succeed after having previously |
| 447 | * failed. |
| 448 | * @param context The running context as per {@link #onReceive}. |
| 449 | * @param intent The received intent as per {@link #onReceive}. |
| 450 | */ |
| 451 | public void onPasswordSucceeded(Context context, Intent intent) { |
| 452 | } |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 453 | |
| 454 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame^] | 455 | * Called periodically when the device or profile challenge password is about to expire |
| 456 | * or has expired. It will typically be called at these times: on device boot, once per day |
| 457 | * before the password expires, and at the time when the password expires. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 458 | * |
| 459 | * <p>If the password is not updated by the user, this method will continue to be called |
| 460 | * once per day until the password is changed or the device admin disables password expiration. |
| 461 | * |
| 462 | * <p>The admin will typically post a notification requesting the user to change their password |
| 463 | * in response to this call. The actual password expiration time can be obtained by calling |
| 464 | * {@link DevicePolicyManager#getPasswordExpiration(ComponentName) } |
| 465 | * |
| 466 | * <p>The admin should be sure to take down any notifications it posted in response to this call |
| 467 | * when it receives {@link DeviceAdminReceiver#onPasswordChanged(Context, Intent) }. |
| 468 | * |
| 469 | * @param context The running context as per {@link #onReceive}. |
| 470 | * @param intent The received intent as per {@link #onReceive}. |
| 471 | */ |
| 472 | public void onPasswordExpiring(Context context, Intent intent) { |
| 473 | } |
| 474 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 475 | /** |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 476 | * Called when provisioning of a managed profile or managed device has completed successfully. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 477 | * |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 478 | * <p> As a prerequisite for the execution of this callback the {@link DeviceAdminReceiver} has |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 479 | * to declare an intent filter for {@link #ACTION_PROFILE_PROVISIONING_COMPLETE}. |
| 480 | * Its component must also be specified in the {@link DevicePolicyManager#EXTRA_DEVICE_ADMIN} |
| 481 | * of the {@link DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE} intent that started the |
| 482 | * managed provisioning. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 483 | * |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 484 | * <p>When provisioning of a managed profile is complete, the managed profile is hidden until |
| 485 | * the profile owner calls {DevicePolicyManager#setProfileEnabled(ComponentName admin)}. |
| 486 | * Typically a profile owner will enable the profile when it has finished any additional setup |
| 487 | * such as adding an account by using the {@link AccountManager} and calling apis to bring the |
| 488 | * profile into the desired state. |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 489 | * |
| 490 | * <p> Note that provisioning completes without waiting for any server interactions, so the |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 491 | * profile owner needs to wait for data to be available if required (e.g. android device ids or |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 492 | * other data that is set as a result of server interactions). |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 493 | * |
| 494 | * @param context The running context as per {@link #onReceive}. |
| 495 | * @param intent The received intent as per {@link #onReceive}. |
| 496 | */ |
| 497 | public void onProfileProvisioningComplete(Context context, Intent intent) { |
| 498 | } |
| 499 | |
| 500 | /** |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 501 | * Called during provisioning of a managed device to allow the device initializer to perform |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 502 | * user setup steps. |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 503 | * |
| 504 | * @param context The running context as per {@link #onReceive}. |
| 505 | * @param intent The received intent as per {@link #onReceive}. |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 506 | * @deprecated Do not use |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 507 | */ |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 508 | @Deprecated |
Julia Reynolds | 94e7bf6 | 2015-06-10 14:44:56 -0400 | [diff] [blame] | 509 | @SystemApi |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 510 | public void onReadyForUserInitialization(Context context, Intent intent) { |
| 511 | } |
| 512 | |
| 513 | /** |
Benjamin Franz | 4326114 | 2015-02-11 15:59:44 +0000 | [diff] [blame] | 514 | * Called when a device is entering lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 515 | * |
| 516 | * @param context The running context as per {@link #onReceive}. |
| 517 | * @param intent The received intent as per {@link #onReceive}. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 518 | * @param pkg If entering, the authorized package using lock task mode, otherwise null. |
| 519 | */ |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 520 | public void onLockTaskModeEntering(Context context, Intent intent, String pkg) { |
| 521 | } |
| 522 | |
| 523 | /** |
Benjamin Franz | 4326114 | 2015-02-11 15:59:44 +0000 | [diff] [blame] | 524 | * Called when a device is exiting lock task mode. |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 525 | * |
| 526 | * @param context The running context as per {@link #onReceive}. |
| 527 | * @param intent The received intent as per {@link #onReceive}. |
| 528 | */ |
| 529 | public void onLockTaskModeExiting(Context context, Intent intent) { |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | /** |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 533 | * Allows this receiver to select the alias for a private key and certificate pair for |
| 534 | * authentication. If this method returns null, the default {@link android.app.Activity} will be |
| 535 | * shown that lets the user pick a private key and certificate pair. |
| 536 | * |
| 537 | * @param context The running context as per {@link #onReceive}. |
| 538 | * @param intent The received intent as per {@link #onReceive}. |
| 539 | * @param uid The uid asking for the private key and certificate pair. |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 540 | * @param uri The URI to authenticate, may be null. |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 541 | * @param alias The alias preselected by the client, or null. |
| 542 | * @return The private key alias to return and grant access to. |
| 543 | * @see KeyChain#choosePrivateKeyAlias |
| 544 | */ |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 545 | public String onChoosePrivateKeyAlias(Context context, Intent intent, int uid, Uri uri, |
| 546 | String alias) { |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 547 | return null; |
| 548 | } |
| 549 | |
| 550 | /** |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 551 | * Allows the receiver to be notified when information about a pending system update is |
| 552 | * available from the system update service. The same pending system update can trigger multiple |
| 553 | * calls to this method, so it is necessary to examine the incoming parameters for details about |
| 554 | * the update. |
| 555 | * <p> |
| 556 | * This callback is only applicable to device owners. |
| 557 | * |
| 558 | * @param context The running context as per {@link #onReceive}. |
| 559 | * @param intent The received intent as per {@link #onReceive}. |
| 560 | * @param receivedTime The time as given by {@link System#currentTimeMillis()} indicating when |
| 561 | * the current pending update was first available. -1 if no pending update is available. |
| 562 | */ |
| 563 | public void onSystemUpdatePending(Context context, Intent intent, long receivedTime) { |
| 564 | } |
| 565 | |
| 566 | /** |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 567 | * Called when sharing a bugreport has been cancelled by the user of the device. |
| 568 | * |
| 569 | * <p>This callback is only applicable to device owners. |
| 570 | * |
| 571 | * @param context The running context as per {@link #onReceive}. |
| 572 | * @param intent The received intent as per {@link #onReceive}. |
| 573 | * @see DevicePolicyManager#requestBugreport |
| 574 | */ |
| 575 | public void onBugreportSharingDeclined(Context context, Intent intent) { |
| 576 | } |
| 577 | |
| 578 | /** |
| 579 | * Called when the bugreport has been shared with the device administrator app. |
| 580 | * |
| 581 | * <p>This callback is only applicable to device owners. |
| 582 | * |
| 583 | * @param context The running context as per {@link #onReceive}. |
| 584 | * @param intent The received intent as per {@link #onReceive}. Contains the URI of |
| 585 | * the bugreport file (with MIME type "application/vnd.android.bugreport"), that can be accessed |
| 586 | * by calling {@link Intent#getData()} |
| 587 | * @param bugreportHash SHA-256 hash of the bugreport file. |
| 588 | * @see DevicePolicyManager#requestBugreport |
| 589 | */ |
| 590 | public void onBugreportShared(Context context, Intent intent, String bugreportHash) { |
| 591 | } |
| 592 | |
| 593 | /** |
| 594 | * Called when the bugreport collection flow has failed. |
| 595 | * |
| 596 | * <p>This callback is only applicable to device owners. |
| 597 | * |
| 598 | * @param context The running context as per {@link #onReceive}. |
| 599 | * @param intent The received intent as per {@link #onReceive}. |
| 600 | * @param failureCode int containing failure code. One of |
| 601 | * #BUGREPORT_FAILURE_FAILED_COMPLETING or #BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE |
| 602 | * @see DevicePolicyManager#requestBugreport |
| 603 | */ |
| 604 | public void onBugreportFailed(Context context, Intent intent, |
| 605 | @BugreportFailureCode int failureCode) { |
| 606 | } |
| 607 | |
| 608 | /** |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 609 | * Called when a new batch of device logs can be retrieved. |
| 610 | * |
| 611 | * <p>This callback is only applicable to device owners. |
| 612 | * |
| 613 | * @param context The running context as per {@link #onReceive}. |
| 614 | * @param intent The received intent as per {@link #onReceive}. |
| 615 | * @see DevicePolicyManager#retrieveDeviceLogs(ComponentName) |
| 616 | */ |
| 617 | public void onSecurityLogsAvailable(Context context, Intent intent) { |
| 618 | } |
| 619 | |
| 620 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 621 | * Intercept standard device administrator broadcasts. Implementations |
| 622 | * should not override this method; it is better to implement the |
| 623 | * convenience callbacks for each action. |
| 624 | */ |
| 625 | @Override |
| 626 | public void onReceive(Context context, Intent intent) { |
| 627 | String action = intent.getAction(); |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 628 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 629 | if (ACTION_PASSWORD_CHANGED.equals(action)) { |
| 630 | onPasswordChanged(context, intent); |
| 631 | } else if (ACTION_PASSWORD_FAILED.equals(action)) { |
| 632 | onPasswordFailed(context, intent); |
| 633 | } else if (ACTION_PASSWORD_SUCCEEDED.equals(action)) { |
| 634 | onPasswordSucceeded(context, intent); |
| 635 | } else if (ACTION_DEVICE_ADMIN_ENABLED.equals(action)) { |
| 636 | onEnabled(context, intent); |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 637 | } else if (ACTION_DEVICE_ADMIN_DISABLE_REQUESTED.equals(action)) { |
| 638 | CharSequence res = onDisableRequested(context, intent); |
| 639 | if (res != null) { |
| 640 | Bundle extras = getResultExtras(true); |
| 641 | extras.putCharSequence(EXTRA_DISABLE_WARNING, res); |
| 642 | } |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 643 | } else if (ACTION_DEVICE_ADMIN_DISABLED.equals(action)) { |
| 644 | onDisabled(context, intent); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 645 | } else if (ACTION_PASSWORD_EXPIRING.equals(action)) { |
| 646 | onPasswordExpiring(context, intent); |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 647 | } else if (ACTION_PROFILE_PROVISIONING_COMPLETE.equals(action)) { |
| 648 | onProfileProvisioningComplete(context, intent); |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 649 | } else if (ACTION_CHOOSE_PRIVATE_KEY_ALIAS.equals(action)) { |
Robin Lee | abf3570 | 2015-02-17 14:12:48 +0000 | [diff] [blame] | 650 | int uid = intent.getIntExtra(EXTRA_CHOOSE_PRIVATE_KEY_SENDER_UID, -1); |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 651 | Uri uri = intent.getParcelableExtra(EXTRA_CHOOSE_PRIVATE_KEY_URI); |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 652 | String alias = intent.getStringExtra(EXTRA_CHOOSE_PRIVATE_KEY_ALIAS); |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 653 | String chosenAlias = onChoosePrivateKeyAlias(context, intent, uid, uri, alias); |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 654 | setResultData(chosenAlias); |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 655 | } else if (ACTION_LOCK_TASK_ENTERING.equals(action)) { |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 656 | String pkg = intent.getStringExtra(EXTRA_LOCK_TASK_PACKAGE); |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 657 | onLockTaskModeEntering(context, intent, pkg); |
| 658 | } else if (ACTION_LOCK_TASK_EXITING.equals(action)) { |
| 659 | onLockTaskModeExiting(context, intent); |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 660 | } else if (ACTION_NOTIFY_PENDING_SYSTEM_UPDATE.equals(action)) { |
| 661 | long receivedTime = intent.getLongExtra(EXTRA_SYSTEM_UPDATE_RECEIVED_TIME, -1); |
| 662 | onSystemUpdatePending(context, intent, receivedTime); |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 663 | } else if (ACTION_BUGREPORT_SHARING_DECLINED.equals(action)) { |
| 664 | onBugreportSharingDeclined(context, intent); |
| 665 | } else if (ACTION_BUGREPORT_SHARE.equals(action)) { |
| 666 | String bugreportFileHash = intent.getStringExtra(EXTRA_BUGREPORT_HASH); |
| 667 | onBugreportShared(context, intent, bugreportFileHash); |
| 668 | } else if (ACTION_BUGREPORT_FAILED.equals(action)) { |
| 669 | int failureCode = intent.getIntExtra(EXTRA_BUGREPORT_FAILURE_REASON, |
| 670 | BUGREPORT_FAILURE_FAILED_COMPLETING); |
| 671 | onBugreportFailed(context, intent, failureCode); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 672 | } else if (ACTION_SECURITY_LOGS_AVAILABLE.equals(action)) { |
| 673 | onSecurityLogsAvailable(context, intent); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 674 | } |
| 675 | } |
| 676 | } |