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; |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 20 | import android.annotation.BroadcastBehavior; |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 21 | import android.annotation.IntDef; |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 22 | import android.annotation.IntRange; |
Alex Chau | b12e672 | 2018-02-12 15:42:10 +0800 | [diff] [blame] | 23 | import android.annotation.NonNull; |
| 24 | import android.annotation.Nullable; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 25 | import android.annotation.SdkConstant; |
| 26 | import android.annotation.SdkConstant.SdkConstantType; |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 27 | import android.app.Service; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 28 | import android.content.BroadcastReceiver; |
| 29 | import android.content.ComponentName; |
| 30 | import android.content.Context; |
| 31 | import android.content.Intent; |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 32 | import android.net.Uri; |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 33 | import android.os.Bundle; |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 34 | import android.os.PersistableBundle; |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 35 | import android.os.Process; |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 36 | import android.os.UserHandle; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 37 | import android.security.KeyChain; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 38 | |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 39 | import java.lang.annotation.Retention; |
| 40 | import java.lang.annotation.RetentionPolicy; |
| 41 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 42 | /** |
| 43 | * Base class for implementing a device administration component. This |
| 44 | * class provides a convenience for interpreting the raw intent actions |
| 45 | * that are sent by the system. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 46 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 47 | * <p>The callback methods, like the base |
| 48 | * {@link BroadcastReceiver#onReceive(Context, Intent) BroadcastReceiver.onReceive()} |
| 49 | * method, happen on the main thread of the process. Thus long running |
| 50 | * operations must be done on another thread. Note that because a receiver |
| 51 | * is done once returning from its receive function, such long-running operations |
| 52 | * should probably be done in a {@link Service}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 53 | * |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 54 | * <p>When publishing your DeviceAdmin subclass as a receiver, it must |
| 55 | * handle {@link #ACTION_DEVICE_ADMIN_ENABLED} and require the |
| 56 | * {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission. A typical |
| 57 | * manifest entry would look like:</p> |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 58 | * |
Dianne Hackborn | ab8a8ed | 2010-01-29 19:03:06 -0800 | [diff] [blame] | 59 | * {@sample development/samples/ApiDemos/AndroidManifest.xml device_admin_declaration} |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 60 | * |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 61 | * <p>The meta-data referenced here provides addition information specific |
| 62 | * to the device administrator, as parsed by the {@link DeviceAdminInfo} class. |
| 63 | * A typical file would be:</p> |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 64 | * |
Andrew Stadler | 88209d1 | 2010-02-08 22:59:36 -0800 | [diff] [blame] | 65 | * {@sample development/samples/ApiDemos/res/xml/device_admin_sample.xml meta_data} |
Joe Fernandez | 3aef8e1d | 2011-12-20 10:38:34 -0800 | [diff] [blame] | 66 | * |
| 67 | * <div class="special reference"> |
| 68 | * <h3>Developer Guides</h3> |
| 69 | * <p>For more information about device administration, read the |
| 70 | * <a href="{@docRoot}guide/topics/admin/device-admin.html">Device Administration</a> |
| 71 | * developer guide.</p> |
| 72 | * </div> |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 73 | */ |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 74 | public class DeviceAdminReceiver extends BroadcastReceiver { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 75 | private static String TAG = "DevicePolicy"; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 76 | private static boolean localLOGV = false; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 77 | |
| 78 | /** |
| 79 | * This is the primary action that a device administrator must implement to be |
| 80 | * allowed to manage a device. This will be set to the receiver |
| 81 | * when the user enables it for administration. You will generally |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 82 | * handle this in {@link DeviceAdminReceiver#onEnabled(Context, Intent)}. To be |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 83 | * supported, the receiver must also require the |
| 84 | * {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission so |
| 85 | * that other applications can not abuse it. |
| 86 | */ |
| 87 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 88 | @BroadcastBehavior(explicitOnly = true) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 89 | public static final String ACTION_DEVICE_ADMIN_ENABLED |
| 90 | = "android.app.action.DEVICE_ADMIN_ENABLED"; |
| 91 | |
| 92 | /** |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 93 | * Action sent to a device administrator when the user has requested to |
| 94 | * disable it, but before this has actually been done. This gives you |
| 95 | * a chance to supply a message to the user about the impact of |
| 96 | * disabling your admin, by setting the extra field |
| 97 | * {@link #EXTRA_DISABLE_WARNING} in the result Intent. If not set, |
| 98 | * no warning will be displayed. If set, the given text will be shown |
| 99 | * to the user before they disable your admin. |
| 100 | */ |
| 101 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 102 | @BroadcastBehavior(explicitOnly = true) |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 103 | public static final String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED |
| 104 | = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED"; |
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 | /** |
| 107 | * A CharSequence that can be shown to the user informing them of the |
| 108 | * impact of disabling your admin. |
| 109 | * |
| 110 | * @see #ACTION_DEVICE_ADMIN_DISABLE_REQUESTED |
| 111 | */ |
| 112 | public static final String EXTRA_DISABLE_WARNING = "android.app.extra.DISABLE_WARNING"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 113 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 114 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 115 | * Action sent to a device administrator when the user has disabled |
| 116 | * it. Upon return, the application no longer has access to the |
| 117 | * protected device policy manager APIs. You will generally |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 118 | * handle this in {@link DeviceAdminReceiver#onDisabled(Context, Intent)}. Note |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 119 | * that this action will be |
| 120 | * sent the receiver regardless of whether it is explicitly listed in |
| 121 | * its intent filter. |
| 122 | */ |
| 123 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 124 | @BroadcastBehavior(explicitOnly = true) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 125 | public static final String ACTION_DEVICE_ADMIN_DISABLED |
| 126 | = "android.app.action.DEVICE_ADMIN_DISABLED"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 127 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 128 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 129 | * Action sent to a device administrator when the user has changed the password of their device |
| 130 | * or profile challenge. You can at this point check the characteristics |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 131 | * of the new password with {@link DevicePolicyManager#isActivePasswordSufficient() |
| 132 | * DevicePolicyManager.isActivePasswordSufficient()}. |
| 133 | * You will generally |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 134 | * handle this in {@link DeviceAdminReceiver#onPasswordChanged(Context, Intent, UserHandle)}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 135 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 136 | * <p>The calling device admin must have requested |
| 137 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to receive |
| 138 | * this broadcast. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 139 | */ |
| 140 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 141 | @BroadcastBehavior(explicitOnly = true) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 142 | public static final String ACTION_PASSWORD_CHANGED |
| 143 | = "android.app.action.ACTION_PASSWORD_CHANGED"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 144 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 145 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 146 | * Action sent to a device administrator when the user has entered an incorrect device |
| 147 | * or profile challenge password. You can at this point check the |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 148 | * number of failed password attempts there have been with |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 149 | * {@link DevicePolicyManager#getCurrentFailedPasswordAttempts |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 150 | * DevicePolicyManager.getCurrentFailedPasswordAttempts()}. You will generally |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 151 | * handle this in {@link DeviceAdminReceiver#onPasswordFailed(Context, Intent, UserHandle)}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 152 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 153 | * <p>The calling device admin must have requested |
| 154 | * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to receive |
| 155 | * this broadcast. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 156 | */ |
| 157 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 158 | @BroadcastBehavior(explicitOnly = true) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 159 | public static final String ACTION_PASSWORD_FAILED |
| 160 | = "android.app.action.ACTION_PASSWORD_FAILED"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 161 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 162 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 163 | * Action sent to a device administrator when the user has successfully entered their device |
| 164 | * or profile challenge password, after failing one or more times. You will generally |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 165 | * handle this in {@link DeviceAdminReceiver#onPasswordSucceeded(Context, Intent, UserHandle)}. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 166 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 167 | * <p>The calling device admin must have requested |
| 168 | * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to receive |
| 169 | * this broadcast. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 170 | */ |
| 171 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 172 | @BroadcastBehavior(explicitOnly = true) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 173 | public static final String ACTION_PASSWORD_SUCCEEDED |
| 174 | = "android.app.action.ACTION_PASSWORD_SUCCEEDED"; |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 175 | |
| 176 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 177 | * Action periodically sent to a device administrator when the device or profile challenge |
| 178 | * password is expiring. You will generally |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 179 | * handle this in {@link DeviceAdminReceiver#onPasswordExpiring(Context, Intent, UserHandle)}. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 180 | * |
| 181 | * <p>The calling device admin must have requested |
| 182 | * {@link DeviceAdminInfo#USES_POLICY_EXPIRE_PASSWORD} to receive |
| 183 | * this broadcast. |
| 184 | */ |
| 185 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 186 | @BroadcastBehavior(explicitOnly = true) |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 187 | public static final String ACTION_PASSWORD_EXPIRING |
| 188 | = "android.app.action.ACTION_PASSWORD_EXPIRING"; |
| 189 | |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 190 | /** |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 191 | * 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] | 192 | * lock task mode. The extra {@link #EXTRA_LOCK_TASK_PACKAGE} |
| 193 | * will describe the package using lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 194 | * |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -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 | */ |
| 200 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 201 | @BroadcastBehavior(explicitOnly = true) |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 202 | public static final String ACTION_LOCK_TASK_ENTERING |
Jason Monk | 5503a55 | 2014-09-04 14:14:37 -0400 | [diff] [blame] | 203 | = "android.app.action.LOCK_TASK_ENTERING"; |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 204 | |
| 205 | /** |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 206 | * 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] | 207 | * lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 208 | * |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 209 | * <p>The calling device admin must be the device owner or profile |
| 210 | * owner to receive this broadcast. |
Benjamin Franz | c70d0e7 | 2015-02-12 16:12:58 +0000 | [diff] [blame] | 211 | * |
| 212 | * @see DevicePolicyManager#isLockTaskPermitted(String) |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 213 | */ |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 214 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 215 | @BroadcastBehavior(explicitOnly = true) |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 216 | public static final String ACTION_LOCK_TASK_EXITING |
Jason Monk | 5503a55 | 2014-09-04 14:14:37 -0400 | [diff] [blame] | 217 | = "android.app.action.LOCK_TASK_EXITING"; |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 218 | |
| 219 | /** |
Benjamin Franz | c70d0e7 | 2015-02-12 16:12:58 +0000 | [diff] [blame] | 220 | * A string containing the name of the package entering lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 221 | * |
Benjamin Franz | c70d0e7 | 2015-02-12 16:12:58 +0000 | [diff] [blame] | 222 | * @see #ACTION_LOCK_TASK_ENTERING |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 223 | */ |
| 224 | public static final String EXTRA_LOCK_TASK_PACKAGE = |
| 225 | "android.app.extra.LOCK_TASK_PACKAGE"; |
| 226 | |
| 227 | /** |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 228 | * Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile |
| 229 | * or managed device has completed successfully. |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 230 | * |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 231 | * <p>The broadcast is limited to the profile that will be managed by the application that |
| 232 | * requested provisioning. In the device owner case the profile is the primary user. |
| 233 | * The broadcast will also be limited to the {@link DeviceAdminReceiver} component |
| 234 | * 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] | 235 | * (see {@link DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE |
| 236 | * DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE}). |
Nicolas Prevot | 07ac20b | 2014-05-27 15:37:45 +0100 | [diff] [blame] | 237 | * |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 238 | * <p>A device admin application which listens to this intent can find out if the device was |
| 239 | * provisioned for the device owner or profile owner case by calling respectively |
| 240 | * {@link android.app.admin.DevicePolicyManager#isDeviceOwnerApp} and |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 241 | * {@link android.app.admin.DevicePolicyManager#isProfileOwnerApp}. You will generally handle |
| 242 | * this in {@link DeviceAdminReceiver#onProfileProvisioningComplete}. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 243 | * |
Esteban Talavera | 4047bae | 2017-06-28 11:03:09 +0100 | [diff] [blame] | 244 | * @see DevicePolicyManager#ACTION_PROVISIONING_SUCCESSFUL |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 245 | */ |
| 246 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 247 | @BroadcastBehavior(explicitOnly = true) |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 248 | public static final String ACTION_PROFILE_PROVISIONING_COMPLETE = |
Jessica Hummel | 5669216 | 2014-09-10 15:12:11 +0100 | [diff] [blame] | 249 | "android.app.action.PROFILE_PROVISIONING_COMPLETE"; |
| 250 | |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 251 | /** |
| 252 | * Action sent to a device administrator to notify that the device user |
| 253 | * has declined sharing a bugreport. |
| 254 | * |
| 255 | * <p>The calling device admin must be the device owner to receive this broadcast. |
| 256 | * @see DevicePolicyManager#requestBugreport |
| 257 | * @hide |
| 258 | */ |
| 259 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 260 | @BroadcastBehavior(explicitOnly = true) |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 261 | public static final String ACTION_BUGREPORT_SHARING_DECLINED = |
| 262 | "android.app.action.BUGREPORT_SHARING_DECLINED"; |
| 263 | |
| 264 | /** |
| 265 | * Action sent to a device administrator to notify that the collection of a bugreport |
| 266 | * has failed. |
| 267 | * |
| 268 | * <p>The calling device admin must be the device owner to receive this broadcast. |
| 269 | * @see DevicePolicyManager#requestBugreport |
| 270 | * @hide |
| 271 | */ |
| 272 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 273 | @BroadcastBehavior(explicitOnly = true) |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 274 | public static final String ACTION_BUGREPORT_FAILED = "android.app.action.BUGREPORT_FAILED"; |
| 275 | |
| 276 | /** |
| 277 | * Action sent to a device administrator to share the bugreport. |
| 278 | * |
| 279 | * <p>The calling device admin must be the device owner to receive this broadcast. |
| 280 | * @see DevicePolicyManager#requestBugreport |
| 281 | * @hide |
| 282 | */ |
| 283 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 284 | @BroadcastBehavior(explicitOnly = true) |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 285 | public static final String ACTION_BUGREPORT_SHARE = |
| 286 | "android.app.action.BUGREPORT_SHARE"; |
| 287 | |
| 288 | /** |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 289 | * Broadcast action: notify that a new batch of security logs is ready to be collected. |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 290 | * @hide |
| 291 | */ |
| 292 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 293 | @BroadcastBehavior(explicitOnly = true) |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 294 | public static final String ACTION_SECURITY_LOGS_AVAILABLE |
| 295 | = "android.app.action.SECURITY_LOGS_AVAILABLE"; |
| 296 | |
| 297 | /** |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 298 | * Broadcast action: notify that a new batch of network logs is ready to be collected. |
| 299 | * @see DeviceAdminReceiver#onNetworkLogsAvailable |
Rubin Xu | 99a66a9 | 2018-11-21 17:41:54 +0000 | [diff] [blame] | 300 | * @see DelegatedAdminReceiver#onNetworkLogsAvailable |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 301 | */ |
| 302 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 303 | @BroadcastBehavior(explicitOnly = true) |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 304 | public static final String ACTION_NETWORK_LOGS_AVAILABLE |
| 305 | = "android.app.action.NETWORK_LOGS_AVAILABLE"; |
| 306 | |
| 307 | /** |
Michal Karpinski | a9ff206 | 2016-11-03 15:46:17 +0000 | [diff] [blame] | 308 | * A {@code long} containing a token of the current batch of network logs, that has to be used |
| 309 | * to retrieve the batch of logs by the device owner. |
| 310 | * |
| 311 | * @see #ACTION_NETWORK_LOGS_AVAILABLE |
| 312 | * @see DevicePolicyManager#retrieveNetworkLogs |
| 313 | * @hide |
| 314 | */ |
| 315 | public static final String EXTRA_NETWORK_LOGS_TOKEN = |
| 316 | "android.app.extra.EXTRA_NETWORK_LOGS_TOKEN"; |
| 317 | |
| 318 | /** |
| 319 | * An {@code int} count representing a total count of network logs inside the current batch of |
| 320 | * network logs. |
| 321 | * |
| 322 | * @see #ACTION_NETWORK_LOGS_AVAILABLE |
| 323 | * @hide |
| 324 | */ |
| 325 | public static final String EXTRA_NETWORK_LOGS_COUNT = |
| 326 | "android.app.extra.EXTRA_NETWORK_LOGS_COUNT"; |
| 327 | |
| 328 | /** |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 329 | * Broadcast action: notify the device owner that a user or profile has been added. |
| 330 | * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of |
| 331 | * the new user. |
| 332 | * @hide |
| 333 | */ |
| 334 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 335 | @BroadcastBehavior(explicitOnly = true) |
| 336 | public static final String ACTION_USER_ADDED = "android.app.action.USER_ADDED"; |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 337 | |
| 338 | /** |
| 339 | * Broadcast action: notify the device owner that a user or profile has been removed. |
| 340 | * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of |
Alex Chau | 2c082aee | 2018-01-17 18:26:03 +0000 | [diff] [blame] | 341 | * the user. |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 342 | * @hide |
| 343 | */ |
| 344 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 345 | @BroadcastBehavior(explicitOnly = true) |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 346 | public static final String ACTION_USER_REMOVED = "android.app.action.USER_REMOVED"; |
| 347 | |
| 348 | /** |
Alex Chau | 2c082aee | 2018-01-17 18:26:03 +0000 | [diff] [blame] | 349 | * Broadcast action: notify the device owner that a user or profile has been started. |
| 350 | * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of |
| 351 | * the user. |
| 352 | * @hide |
| 353 | */ |
| 354 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 355 | @BroadcastBehavior(explicitOnly = true) |
| 356 | public static final String ACTION_USER_STARTED = "android.app.action.USER_STARTED"; |
| 357 | |
| 358 | /** |
| 359 | * Broadcast action: notify the device owner that a user or profile has been stopped. |
| 360 | * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of |
| 361 | * the user. |
| 362 | * @hide |
| 363 | */ |
| 364 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 365 | @BroadcastBehavior(explicitOnly = true) |
| 366 | public static final String ACTION_USER_STOPPED = "android.app.action.USER_STOPPED"; |
| 367 | |
| 368 | /** |
| 369 | * Broadcast action: notify the device owner that a user or profile has been switched to. |
| 370 | * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of |
| 371 | * the user. |
| 372 | * @hide |
| 373 | */ |
| 374 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 375 | @BroadcastBehavior(explicitOnly = true) |
| 376 | public static final String ACTION_USER_SWITCHED = "android.app.action.USER_SWITCHED"; |
| 377 | |
| 378 | /** |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 379 | * A string containing the SHA-256 hash of the bugreport file. |
| 380 | * |
| 381 | * @see #ACTION_BUGREPORT_SHARE |
| 382 | * @hide |
| 383 | */ |
| 384 | public static final String EXTRA_BUGREPORT_HASH = "android.app.extra.BUGREPORT_HASH"; |
| 385 | |
| 386 | /** |
Michal Karpinski | 37cfe71 | 2016-03-11 14:00:13 +0000 | [diff] [blame] | 387 | * An {@code int} failure code representing the reason of the bugreport failure. One of |
| 388 | * {@link #BUGREPORT_FAILURE_FAILED_COMPLETING} |
| 389 | * or {@link #BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE} |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 390 | * |
| 391 | * @see #ACTION_BUGREPORT_FAILED |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 392 | * @hide |
| 393 | */ |
| 394 | public static final String EXTRA_BUGREPORT_FAILURE_REASON = |
| 395 | "android.app.extra.BUGREPORT_FAILURE_REASON"; |
| 396 | |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 397 | /** |
| 398 | * An interface representing reason of bugreport failure. |
| 399 | * |
| 400 | * @see #EXTRA_BUGREPORT_FAILURE_REASON |
| 401 | * @hide |
| 402 | */ |
Felipe Leme | dc7af96 | 2016-01-22 18:27:03 -0800 | [diff] [blame] | 403 | @Retention(RetentionPolicy.SOURCE) |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 404 | @IntDef(prefix = { "BUGREPORT_FAILURE_" }, value = { |
| 405 | BUGREPORT_FAILURE_FAILED_COMPLETING, |
| 406 | BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE |
Felipe Leme | dc7af96 | 2016-01-22 18:27:03 -0800 | [diff] [blame] | 407 | }) |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 408 | public @interface BugreportFailureCode {} |
Michal Karpinski | 37cfe71 | 2016-03-11 14:00:13 +0000 | [diff] [blame] | 409 | |
| 410 | /** |
| 411 | * Bugreport completion process failed. |
| 412 | * |
| 413 | * <p>If this error code is received, the requesting of bugreport can be retried. |
| 414 | * @see DevicePolicyManager#requestBugreport |
| 415 | */ |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 416 | public static final int BUGREPORT_FAILURE_FAILED_COMPLETING = 0; |
Michal Karpinski | 37cfe71 | 2016-03-11 14:00:13 +0000 | [diff] [blame] | 417 | |
| 418 | /** |
| 419 | * Bugreport has been created, but is no longer available for collection. |
| 420 | * |
| 421 | * <p>This error likely occurs because the user of the device hasn't consented to share |
| 422 | * the bugreport for a long period after its creation. |
| 423 | * |
| 424 | * <p>If this error code is received, the requesting of bugreport can be retried. |
| 425 | * @see DevicePolicyManager#requestBugreport |
| 426 | */ |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 427 | public static final int BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE = 1; |
| 428 | |
Rubin Xu | 99a66a9 | 2018-11-21 17:41:54 +0000 | [diff] [blame] | 429 | /** |
| 430 | * Broadcast action: notify that some app is attempting to choose a KeyChain key. |
| 431 | * @see DeviceAdminReceiver#onChoosePrivateKeyAlias |
| 432 | * @see DelegatedAdminReceiver#onChoosePrivateKeyAlias |
| 433 | */ |
Charles He | c4a339a | 2016-11-14 14:16:57 +0000 | [diff] [blame] | 434 | public static final String ACTION_CHOOSE_PRIVATE_KEY_ALIAS = |
| 435 | "android.app.action.CHOOSE_PRIVATE_KEY_ALIAS"; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 436 | |
| 437 | /** @hide */ |
Charles He | c4a339a | 2016-11-14 14:16:57 +0000 | [diff] [blame] | 438 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_SENDER_UID = |
| 439 | "android.app.extra.CHOOSE_PRIVATE_KEY_SENDER_UID"; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 440 | |
| 441 | /** @hide */ |
Charles He | c4a339a | 2016-11-14 14:16:57 +0000 | [diff] [blame] | 442 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_URI = |
| 443 | "android.app.extra.CHOOSE_PRIVATE_KEY_URI"; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 444 | |
| 445 | /** @hide */ |
Charles He | c4a339a | 2016-11-14 14:16:57 +0000 | [diff] [blame] | 446 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_ALIAS = |
| 447 | "android.app.extra.CHOOSE_PRIVATE_KEY_ALIAS"; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 448 | |
| 449 | /** @hide */ |
Charles He | c4a339a | 2016-11-14 14:16:57 +0000 | [diff] [blame] | 450 | public static final String EXTRA_CHOOSE_PRIVATE_KEY_RESPONSE = |
| 451 | "android.app.extra.CHOOSE_PRIVATE_KEY_RESPONSE"; |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 452 | |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 453 | /** |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 454 | * Broadcast action: notify device owner that there is a pending system update. |
| 455 | * @hide |
| 456 | */ |
| 457 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 458 | @BroadcastBehavior(explicitOnly = true) |
Charles He | c4a339a | 2016-11-14 14:16:57 +0000 | [diff] [blame] | 459 | public static final String ACTION_NOTIFY_PENDING_SYSTEM_UPDATE = |
| 460 | "android.app.action.NOTIFY_PENDING_SYSTEM_UPDATE"; |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 461 | |
| 462 | /** |
| 463 | * A long type extra for {@link #onSystemUpdatePending} recording the system time as given by |
| 464 | * {@link System#currentTimeMillis()} when the current pending system update is first available. |
| 465 | * @hide |
| 466 | */ |
Charles He | c4a339a | 2016-11-14 14:16:57 +0000 | [diff] [blame] | 467 | public static final String EXTRA_SYSTEM_UPDATE_RECEIVED_TIME = |
| 468 | "android.app.extra.SYSTEM_UPDATE_RECEIVED_TIME"; |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 469 | |
| 470 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 471 | * Name under which a DevicePolicy component publishes information |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 472 | * about itself. This meta-data must reference an XML resource containing |
Andrew Solovay | 27f5337 | 2015-03-02 16:37:59 -0800 | [diff] [blame] | 473 | * a device-admin tag. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 474 | */ |
Andrew Solovay | 27f5337 | 2015-03-02 16:37:59 -0800 | [diff] [blame] | 475 | // TO DO: describe syntax. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 476 | public static final String DEVICE_ADMIN_META_DATA = "android.app.device_admin"; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 477 | |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 478 | /** |
| 479 | * Broadcast action: notify the newly transferred administrator that the transfer |
| 480 | * from the original administrator was successful. |
| 481 | * |
| 482 | * @hide |
| 483 | */ |
| 484 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 485 | public static final String ACTION_TRANSFER_OWNERSHIP_COMPLETE = |
| 486 | "android.app.action.TRANSFER_OWNERSHIP_COMPLETE"; |
| 487 | |
| 488 | /** |
arangelov | b46faf3 | 2018-01-17 21:27:40 +0000 | [diff] [blame] | 489 | * Broadcast action: notify the device owner that the ownership of one of its affiliated |
| 490 | * profiles is transferred. |
| 491 | * |
| 492 | * @hide |
| 493 | */ |
| 494 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 495 | public static final String ACTION_AFFILIATED_PROFILE_TRANSFER_OWNERSHIP_COMPLETE = |
| 496 | "android.app.action.AFFILIATED_PROFILE_TRANSFER_OWNERSHIP_COMPLETE"; |
| 497 | |
| 498 | /** |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 499 | * A {@link android.os.Parcelable} extra of type {@link android.os.PersistableBundle} that |
| 500 | * allows a mobile device management application to pass data to the management application |
| 501 | * instance after owner transfer. |
| 502 | * |
arangelov | 91201bd | 2018-01-04 17:10:21 +0000 | [diff] [blame] | 503 | * <p>If the transfer is successful, the new owner receives the data in |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 504 | * {@link DeviceAdminReceiver#onTransferOwnershipComplete(Context, PersistableBundle)}. |
| 505 | * The bundle is not changed during the ownership transfer. |
| 506 | * |
| 507 | * @see DevicePolicyManager#transferOwnership(ComponentName, ComponentName, PersistableBundle) |
| 508 | */ |
arangelov | 91201bd | 2018-01-04 17:10:21 +0000 | [diff] [blame] | 509 | public static final String EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE = |
| 510 | "android.app.extra.TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE"; |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 511 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 512 | private DevicePolicyManager mManager; |
| 513 | private ComponentName mWho; |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 514 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 515 | /** |
| 516 | * Retrieve the DevicePolicyManager interface for this administrator to work |
| 517 | * with the system. |
| 518 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 519 | public @NonNull DevicePolicyManager getManager(@NonNull Context context) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 520 | if (mManager != null) { |
| 521 | return mManager; |
| 522 | } |
| 523 | mManager = (DevicePolicyManager)context.getSystemService( |
| 524 | Context.DEVICE_POLICY_SERVICE); |
| 525 | return mManager; |
| 526 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 527 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 528 | /** |
| 529 | * Retrieve the ComponentName describing who this device administrator is, for |
| 530 | * use in {@link DevicePolicyManager} APIs that require the administrator to |
| 531 | * identify itself. |
| 532 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 533 | public @NonNull ComponentName getWho(@NonNull Context context) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 534 | if (mWho != null) { |
| 535 | return mWho; |
| 536 | } |
| 537 | mWho = new ComponentName(context, getClass()); |
| 538 | return mWho; |
| 539 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 540 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 541 | /** |
| 542 | * Called after the administrator is first enabled, as a result of |
| 543 | * receiving {@link #ACTION_DEVICE_ADMIN_ENABLED}. At this point you |
| 544 | * can use {@link DevicePolicyManager} to set your desired policies. |
Jason Monk | 03978a4 | 2014-06-10 15:05:30 -0400 | [diff] [blame] | 545 | * |
| 546 | * <p> If the admin is activated by a device owner, then the intent |
| 547 | * may contain private extras that are relevant to user setup. |
phweiss | 27ee334 | 2016-02-08 16:40:45 +0100 | [diff] [blame] | 548 | * {@see DevicePolicyManager#createAndManageUser(ComponentName, String, ComponentName, |
| 549 | * PersistableBundle, int)} |
Jason Monk | 03978a4 | 2014-06-10 15:05:30 -0400 | [diff] [blame] | 550 | * |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 551 | * @param context The running context as per {@link #onReceive}. |
| 552 | * @param intent The received intent as per {@link #onReceive}. |
| 553 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 554 | public void onEnabled(@NonNull Context context, @NonNull Intent intent) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 555 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 556 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 557 | /** |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 558 | * Called when the user has asked to disable the administrator, as a result of |
| 559 | * receiving {@link #ACTION_DEVICE_ADMIN_DISABLE_REQUESTED}, giving you |
| 560 | * a chance to present a warning message to them. The message is returned |
| 561 | * as the result; if null is returned (the default implementation), no |
| 562 | * message will be displayed. |
| 563 | * @param context The running context as per {@link #onReceive}. |
| 564 | * @param intent The received intent as per {@link #onReceive}. |
| 565 | * @return Return the warning message to display to the user before |
| 566 | * being disabled; if null is returned, no message is displayed. |
| 567 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 568 | public @Nullable CharSequence onDisableRequested(@NonNull Context context, |
| 569 | @NonNull Intent intent) { |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 570 | return null; |
| 571 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 572 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 573 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 574 | * Called prior to the administrator being disabled, as a result of |
| 575 | * receiving {@link #ACTION_DEVICE_ADMIN_DISABLED}. Upon return, you |
| 576 | * can no longer use the protected parts of the {@link DevicePolicyManager} |
| 577 | * API. |
| 578 | * @param context The running context as per {@link #onReceive}. |
| 579 | * @param intent The received intent as per {@link #onReceive}. |
| 580 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 581 | public void onDisabled(@NonNull Context context, @NonNull Intent intent) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 582 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 583 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 584 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 585 | * 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] | 586 | * receiving {@link #ACTION_PASSWORD_CHANGED}. At this point you |
Robin Lee | 9983aca | 2016-01-20 17:15:08 +0000 | [diff] [blame] | 587 | * can use {@link DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 588 | * to retrieve the active password characteristics. |
| 589 | * @param context The running context as per {@link #onReceive}. |
| 590 | * @param intent The received intent as per {@link #onReceive}. |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 591 | * |
| 592 | * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use |
| 593 | * {@link #onPasswordChanged(Context, Intent, UserHandle)} instead. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 594 | */ |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 595 | @Deprecated |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 596 | public void onPasswordChanged(@NonNull Context context, @NonNull Intent intent) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 597 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 598 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 599 | /** |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 600 | * Called after the user has changed their device or profile challenge password, as a result of |
| 601 | * receiving {@link #ACTION_PASSWORD_CHANGED}. At this point you |
| 602 | * can use {@link DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} |
| 603 | * to retrieve the active password characteristics. |
| 604 | * @param context The running context as per {@link #onReceive}. |
| 605 | * @param intent The received intent as per {@link #onReceive}. |
| 606 | * @param user The user or profile for whom the password changed. To see whether this |
| 607 | * user is the current profile or a parent user, check for equality with |
| 608 | * {@link Process#myUserHandle}. |
| 609 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 610 | public void onPasswordChanged(@NonNull Context context, @NonNull Intent intent, |
| 611 | @NonNull UserHandle user) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 612 | onPasswordChanged(context, intent); |
| 613 | } |
| 614 | |
| 615 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 616 | * Called after the user has failed at entering their device or profile challenge password, |
| 617 | * as a result of receiving {@link #ACTION_PASSWORD_FAILED}. At this point you can use |
| 618 | * {@link DevicePolicyManager#getCurrentFailedPasswordAttempts()} to retrieve the number of |
| 619 | * failed password attempts. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 620 | * @param context The running context as per {@link #onReceive}. |
| 621 | * @param intent The received intent as per {@link #onReceive}. |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 622 | * |
| 623 | * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use |
| 624 | * {@link #onPasswordFailed(Context, Intent, UserHandle)} instead. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 625 | */ |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 626 | @Deprecated |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 627 | public void onPasswordFailed(@NonNull Context context, @NonNull Intent intent) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 628 | } |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 629 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 630 | /** |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 631 | * Called after the user has failed at entering their device or profile challenge password, |
| 632 | * as a result of receiving {@link #ACTION_PASSWORD_FAILED}. At this point you can use |
| 633 | * {@link DevicePolicyManager#getCurrentFailedPasswordAttempts()} to retrieve the number of |
| 634 | * failed password attempts. |
| 635 | * @param context The running context as per {@link #onReceive}. |
| 636 | * @param intent The received intent as per {@link #onReceive}. |
| 637 | * @param user The user or profile for whom the password check failed. To see whether this |
| 638 | * user is the current profile or a parent user, check for equality with |
| 639 | * {@link Process#myUserHandle}. |
| 640 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 641 | public void onPasswordFailed(@NonNull Context context, @NonNull Intent intent, |
| 642 | @NonNull UserHandle user) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 643 | onPasswordFailed(context, intent); |
| 644 | } |
| 645 | |
| 646 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 647 | * 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] | 648 | * as a result of receiving {@link #ACTION_PASSWORD_SUCCEEDED}. This will |
| 649 | * only be received the first time they succeed after having previously |
| 650 | * failed. |
| 651 | * @param context The running context as per {@link #onReceive}. |
| 652 | * @param intent The received intent as per {@link #onReceive}. |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 653 | * |
| 654 | * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use |
| 655 | * {@link #onPasswordSucceeded(Context, Intent, UserHandle)} instead. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 656 | */ |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 657 | @Deprecated |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 658 | public void onPasswordSucceeded(@NonNull Context context, @NonNull Intent intent) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 659 | } |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 660 | |
| 661 | /** |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 662 | * Called after the user has succeeded at entering their device or profile challenge password, |
| 663 | * as a result of receiving {@link #ACTION_PASSWORD_SUCCEEDED}. This will |
| 664 | * only be received the first time they succeed after having previously |
| 665 | * failed. |
| 666 | * @param context The running context as per {@link #onReceive}. |
| 667 | * @param intent The received intent as per {@link #onReceive}. |
| 668 | * @param user The user of profile for whom the password check succeeded. To see whether this |
| 669 | * user is the current profile or a parent user, check for equality with |
| 670 | * {@link Process#myUserHandle}. |
| 671 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 672 | public void onPasswordSucceeded(@NonNull Context context, @NonNull Intent intent, |
| 673 | @NonNull UserHandle user) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 674 | onPasswordSucceeded(context, intent); |
| 675 | } |
| 676 | |
| 677 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 678 | * Called periodically when the device or profile challenge password is about to expire |
| 679 | * or has expired. It will typically be called at these times: on device boot, once per day |
| 680 | * before the password expires, and at the time when the password expires. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 681 | * |
| 682 | * <p>If the password is not updated by the user, this method will continue to be called |
| 683 | * once per day until the password is changed or the device admin disables password expiration. |
| 684 | * |
| 685 | * <p>The admin will typically post a notification requesting the user to change their password |
| 686 | * in response to this call. The actual password expiration time can be obtained by calling |
| 687 | * {@link DevicePolicyManager#getPasswordExpiration(ComponentName) } |
| 688 | * |
| 689 | * <p>The admin should be sure to take down any notifications it posted in response to this call |
| 690 | * when it receives {@link DeviceAdminReceiver#onPasswordChanged(Context, Intent) }. |
| 691 | * |
| 692 | * @param context The running context as per {@link #onReceive}. |
| 693 | * @param intent The received intent as per {@link #onReceive}. |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 694 | * |
| 695 | * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use |
| 696 | * {@link #onPasswordExpiring(Context, Intent, UserHandle)} instead. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 697 | */ |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 698 | @Deprecated |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 699 | public void onPasswordExpiring(@NonNull Context context, @NonNull Intent intent) { |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 700 | } |
| 701 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 702 | /** |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 703 | * Called periodically when the device or profile challenge password is about to expire |
| 704 | * or has expired. It will typically be called at these times: on device boot, once per day |
| 705 | * before the password expires, and at the time when the password expires. |
| 706 | * |
| 707 | * <p>If the password is not updated by the user, this method will continue to be called |
| 708 | * once per day until the password is changed or the device admin disables password expiration. |
| 709 | * |
| 710 | * <p>The admin will typically post a notification requesting the user to change their password |
| 711 | * in response to this call. The actual password expiration time can be obtained by calling |
| 712 | * {@link DevicePolicyManager#getPasswordExpiration(ComponentName) } |
| 713 | * |
| 714 | * <p>The admin should be sure to take down any notifications it posted in response to this call |
| 715 | * when it receives {@link DeviceAdminReceiver#onPasswordChanged(Context, Intent, UserHandle) }. |
| 716 | * |
| 717 | * @param context The running context as per {@link #onReceive}. |
| 718 | * @param intent The received intent as per {@link #onReceive}. |
| 719 | * @param user The user or profile for whom the password is expiring. To see whether this |
| 720 | * user is the current profile or a parent user, check for equality with |
| 721 | * {@link Process#myUserHandle}. |
| 722 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 723 | public void onPasswordExpiring(@NonNull Context context, @NonNull Intent intent, |
| 724 | @NonNull UserHandle user) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 725 | onPasswordExpiring(context, intent); |
| 726 | } |
| 727 | |
| 728 | /** |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 729 | * 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] | 730 | * |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 731 | * <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] | 732 | * to declare an intent filter for {@link #ACTION_PROFILE_PROVISIONING_COMPLETE}. |
| 733 | * Its component must also be specified in the {@link DevicePolicyManager#EXTRA_DEVICE_ADMIN} |
| 734 | * of the {@link DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE} intent that started the |
| 735 | * managed provisioning. |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 736 | * |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 737 | * <p>When provisioning of a managed profile is complete, the managed profile is hidden until |
Kenny Guy | ac6e767 | 2017-07-13 11:26:47 +0100 | [diff] [blame] | 738 | * the profile owner calls {@link DevicePolicyManager#setProfileEnabled(ComponentName admin)}. |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 739 | * Typically a profile owner will enable the profile when it has finished any additional setup |
Kenny Guy | ac6e767 | 2017-07-13 11:26:47 +0100 | [diff] [blame] | 740 | * such as adding an account by using the {@link AccountManager} and calling APIs to bring the |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 741 | * profile into the desired state. |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 742 | * |
| 743 | * <p> Note that provisioning completes without waiting for any server interactions, so the |
Kenny Guy | ac6e767 | 2017-07-13 11:26:47 +0100 | [diff] [blame] | 744 | * 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] | 745 | * other data that is set as a result of server interactions). |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 746 | * |
Esteban Talavera | 4047bae | 2017-06-28 11:03:09 +0100 | [diff] [blame] | 747 | * <p>From version {@link android.os.Build.VERSION_CODES#O}, when managed provisioning has |
| 748 | * completed, along with this callback the activity intent |
| 749 | * {@link DevicePolicyManager#ACTION_PROVISIONING_SUCCESSFUL} will also be sent to the same |
| 750 | * application. |
| 751 | * |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 752 | * @param context The running context as per {@link #onReceive}. |
| 753 | * @param intent The received intent as per {@link #onReceive}. |
| 754 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 755 | public void onProfileProvisioningComplete(@NonNull Context context, @NonNull Intent intent) { |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | /** |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 759 | * 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] | 760 | * user setup steps. |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 761 | * |
| 762 | * @param context The running context as per {@link #onReceive}. |
| 763 | * @param intent The received intent as per {@link #onReceive}. |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 764 | * @deprecated Do not use |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 765 | */ |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 766 | @Deprecated |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 767 | public void onReadyForUserInitialization(@NonNull Context context, @NonNull Intent intent) { |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | /** |
Benjamin Franz | 4326114 | 2015-02-11 15:59:44 +0000 | [diff] [blame] | 771 | * Called when a device is entering lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 772 | * |
| 773 | * @param context The running context as per {@link #onReceive}. |
| 774 | * @param intent The received intent as per {@link #onReceive}. |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 775 | * @param pkg The authorized package using lock task mode. |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 776 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 777 | public void onLockTaskModeEntering(@NonNull Context context, @NonNull Intent intent, |
| 778 | @NonNull String pkg) { |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | /** |
Benjamin Franz | 4326114 | 2015-02-11 15:59:44 +0000 | [diff] [blame] | 782 | * Called when a device is exiting lock task mode. |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 783 | * |
| 784 | * @param context The running context as per {@link #onReceive}. |
| 785 | * @param intent The received intent as per {@link #onReceive}. |
| 786 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 787 | public void onLockTaskModeExiting(@NonNull Context context, @NonNull Intent intent) { |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | /** |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 791 | * Allows this receiver to select the alias for a private key and certificate pair for |
| 792 | * authentication. If this method returns null, the default {@link android.app.Activity} will be |
| 793 | * shown that lets the user pick a private key and certificate pair. |
| 794 | * |
| 795 | * @param context The running context as per {@link #onReceive}. |
| 796 | * @param intent The received intent as per {@link #onReceive}. |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 797 | * @param uid The uid of the app asking for the private key and certificate pair. |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 798 | * @param uri The URI to authenticate, may be null. |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 799 | * @param alias The alias preselected by the client, or null. |
| 800 | * @return The private key alias to return and grant access to. |
| 801 | * @see KeyChain#choosePrivateKeyAlias |
| 802 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 803 | public @Nullable String onChoosePrivateKeyAlias(@NonNull Context context, |
| 804 | @NonNull Intent intent, int uid, @Nullable Uri uri, @Nullable String alias) { |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 805 | return null; |
| 806 | } |
| 807 | |
| 808 | /** |
Charles He | dea0c3b | 2017-01-13 10:04:12 +0000 | [diff] [blame] | 809 | * Called when the information about a pending system update is available. |
| 810 | * |
| 811 | * <p>Allows the receiver to be notified when information about a pending system update is |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 812 | * available from the system update service. The same pending system update can trigger multiple |
| 813 | * calls to this method, so it is necessary to examine the incoming parameters for details about |
| 814 | * the update. |
Charles He | dea0c3b | 2017-01-13 10:04:12 +0000 | [diff] [blame] | 815 | * |
| 816 | * <p>This callback is only applicable to device owners and profile owners. |
| 817 | * |
| 818 | * <p>To get further information about a pending system update (for example, whether or not the |
| 819 | * update is a security patch), the device owner or profile owner can call |
| 820 | * {@link DevicePolicyManager#getPendingSystemUpdate}. |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 821 | * |
| 822 | * @param context The running context as per {@link #onReceive}. |
| 823 | * @param intent The received intent as per {@link #onReceive}. |
| 824 | * @param receivedTime The time as given by {@link System#currentTimeMillis()} indicating when |
| 825 | * the current pending update was first available. -1 if no pending update is available. |
Charles He | dea0c3b | 2017-01-13 10:04:12 +0000 | [diff] [blame] | 826 | * @see DevicePolicyManager#getPendingSystemUpdate |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 827 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 828 | public void onSystemUpdatePending(@NonNull Context context, @NonNull Intent intent, |
| 829 | long receivedTime) { |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | /** |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 833 | * Called when sharing a bugreport has been cancelled by the user of the device. |
| 834 | * |
| 835 | * <p>This callback is only applicable to device owners. |
| 836 | * |
| 837 | * @param context The running context as per {@link #onReceive}. |
| 838 | * @param intent The received intent as per {@link #onReceive}. |
| 839 | * @see DevicePolicyManager#requestBugreport |
| 840 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 841 | public void onBugreportSharingDeclined(@NonNull Context context, @NonNull Intent intent) { |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | /** |
| 845 | * Called when the bugreport has been shared with the device administrator app. |
| 846 | * |
| 847 | * <p>This callback is only applicable to device owners. |
| 848 | * |
| 849 | * @param context The running context as per {@link #onReceive}. |
| 850 | * @param intent The received intent as per {@link #onReceive}. Contains the URI of |
| 851 | * the bugreport file (with MIME type "application/vnd.android.bugreport"), that can be accessed |
| 852 | * by calling {@link Intent#getData()} |
| 853 | * @param bugreportHash SHA-256 hash of the bugreport file. |
| 854 | * @see DevicePolicyManager#requestBugreport |
| 855 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 856 | public void onBugreportShared(@NonNull Context context, @NonNull Intent intent, |
| 857 | @NonNull String bugreportHash) { |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | /** |
| 861 | * Called when the bugreport collection flow has failed. |
| 862 | * |
| 863 | * <p>This callback is only applicable to device owners. |
| 864 | * |
| 865 | * @param context The running context as per {@link #onReceive}. |
| 866 | * @param intent The received intent as per {@link #onReceive}. |
| 867 | * @param failureCode int containing failure code. One of |
Michal Karpinski | 37cfe71 | 2016-03-11 14:00:13 +0000 | [diff] [blame] | 868 | * {@link #BUGREPORT_FAILURE_FAILED_COMPLETING} |
| 869 | * or {@link #BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE} |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 870 | * @see DevicePolicyManager#requestBugreport |
| 871 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 872 | public void onBugreportFailed(@NonNull Context context, @NonNull Intent intent, |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 873 | @BugreportFailureCode int failureCode) { |
| 874 | } |
| 875 | |
| 876 | /** |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 877 | * Called when a new batch of security logs can be retrieved. |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 878 | * |
Esteban Talavera | d36dd15 | 2016-12-15 08:51:45 +0000 | [diff] [blame] | 879 | * <p>If a secondary user or profile is created, this callback won't be received until all users |
| 880 | * become affiliated again (even if security logging is enabled). |
| 881 | * See {@link DevicePolicyManager#setAffiliationIds} |
| 882 | * |
Pavel Grafov | 9cdba27 | 2017-03-07 12:48:00 +0000 | [diff] [blame] | 883 | * <p>This callback will be re-triggered if the logs are not retrieved. |
| 884 | * |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 885 | * <p>This callback is only applicable to device owners. |
| 886 | * |
| 887 | * @param context The running context as per {@link #onReceive}. |
| 888 | * @param intent The received intent as per {@link #onReceive}. |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 889 | * @see DevicePolicyManager#retrieveSecurityLogs(ComponentName) |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 890 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 891 | public void onSecurityLogsAvailable(@NonNull Context context, @NonNull Intent intent) { |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 892 | } |
| 893 | |
| 894 | /** |
Michal Karpinski | a9ff206 | 2016-11-03 15:46:17 +0000 | [diff] [blame] | 895 | * Called each time a new batch of network logs can be retrieved. This callback method will only |
| 896 | * ever be called when network logging is enabled. The logs can only be retrieved while network |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 897 | * logging is enabled. |
| 898 | * |
Esteban Talavera | d36dd15 | 2016-12-15 08:51:45 +0000 | [diff] [blame] | 899 | * <p>If a secondary user or profile is created, this callback won't be received until all users |
| 900 | * become affiliated again (even if network logging is enabled). It will also no longer be |
| 901 | * possible to retrieve the network logs batch with the most recent {@code batchToken} provided |
| 902 | * by this callback. See {@link DevicePolicyManager#setAffiliationIds}. |
| 903 | * |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 904 | * <p>This callback is only applicable to device owners. |
| 905 | * |
| 906 | * @param context The running context as per {@link #onReceive}. |
| 907 | * @param intent The received intent as per {@link #onReceive}. |
Michal Karpinski | a9ff206 | 2016-11-03 15:46:17 +0000 | [diff] [blame] | 908 | * @param batchToken The token representing the current batch of network logs. |
| 909 | * @param networkLogsCount The total count of events in the current batch of network logs. |
Esteban Talavera | d36dd15 | 2016-12-15 08:51:45 +0000 | [diff] [blame] | 910 | * @see DevicePolicyManager#retrieveNetworkLogs |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 911 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 912 | public void onNetworkLogsAvailable(@NonNull Context context, @NonNull Intent intent, |
| 913 | long batchToken, @IntRange(from = 1) int networkLogsCount) { |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 914 | } |
| 915 | |
Alex Chau | b12e672 | 2018-02-12 15:42:10 +0800 | [diff] [blame] | 916 | /** |
| 917 | * Called when a user or profile is created. |
| 918 | * |
| 919 | * <p>This callback is only applicable to device owners. |
| 920 | * |
| 921 | * @param context The running context as per {@link #onReceive}. |
| 922 | * @param intent The received intent as per {@link #onReceive}. |
| 923 | * @param newUser The {@link UserHandle} of the user that has just been added. |
| 924 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 925 | public void onUserAdded(@NonNull Context context, @NonNull Intent intent, |
| 926 | @NonNull UserHandle newUser) { |
Alex Chau | b12e672 | 2018-02-12 15:42:10 +0800 | [diff] [blame] | 927 | } |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 928 | |
Alex Chau | b12e672 | 2018-02-12 15:42:10 +0800 | [diff] [blame] | 929 | /** |
| 930 | * Called when a user or profile is removed. |
| 931 | * |
| 932 | * <p>This callback is only applicable to device owners. |
| 933 | * |
| 934 | * @param context The running context as per {@link #onReceive}. |
| 935 | * @param intent The received intent as per {@link #onReceive}. |
| 936 | * @param removedUser The {@link UserHandle} of the user that has just been removed. |
| 937 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 938 | public void onUserRemoved(@NonNull Context context, @NonNull Intent intent, |
| 939 | @NonNull UserHandle removedUser) { |
Alex Chau | b12e672 | 2018-02-12 15:42:10 +0800 | [diff] [blame] | 940 | } |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 941 | |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 942 | /** |
Alex Chau | 2c082aee | 2018-01-17 18:26:03 +0000 | [diff] [blame] | 943 | * Called when a user or profile is started. |
| 944 | * |
| 945 | * <p>This callback is only applicable to device owners. |
| 946 | * |
| 947 | * @param context The running context as per {@link #onReceive}. |
| 948 | * @param intent The received intent as per {@link #onReceive}. |
| 949 | * @param startedUser The {@link UserHandle} of the user that has just been started. |
| 950 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 951 | public void onUserStarted(@NonNull Context context, @NonNull Intent intent, |
| 952 | @NonNull UserHandle startedUser) { |
Alex Chau | 2c082aee | 2018-01-17 18:26:03 +0000 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | /** |
| 956 | * Called when a user or profile is stopped. |
| 957 | * |
| 958 | * <p>This callback is only applicable to device owners. |
| 959 | * |
| 960 | * @param context The running context as per {@link #onReceive}. |
| 961 | * @param intent The received intent as per {@link #onReceive}. |
| 962 | * @param stoppedUser The {@link UserHandle} of the user that has just been stopped. |
| 963 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 964 | public void onUserStopped(@NonNull Context context, @NonNull Intent intent, |
| 965 | @NonNull UserHandle stoppedUser) { |
Alex Chau | 2c082aee | 2018-01-17 18:26:03 +0000 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | /** |
| 969 | * Called when a user or profile is switched to. |
| 970 | * |
| 971 | * <p>This callback is only applicable to device owners. |
| 972 | * |
| 973 | * @param context The running context as per {@link #onReceive}. |
| 974 | * @param intent The received intent as per {@link #onReceive}. |
| 975 | * @param switchedUser The {@link UserHandle} of the user that has just been switched to. |
| 976 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 977 | public void onUserSwitched(@NonNull Context context, @NonNull Intent intent, |
| 978 | @NonNull UserHandle switchedUser) { |
Alex Chau | 2c082aee | 2018-01-17 18:26:03 +0000 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | /** |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 982 | * Called on the newly assigned owner (either device owner or profile owner) when the ownership |
| 983 | * transfer has completed successfully. |
| 984 | * |
| 985 | * <p> The {@code bundle} parameter allows the original owner to pass data |
| 986 | * to the new one. |
| 987 | * |
| 988 | * @param context the running context as per {@link #onReceive} |
| 989 | * @param bundle the data to be passed to the new owner |
| 990 | */ |
| 991 | public void onTransferOwnershipComplete(@NonNull Context context, |
| 992 | @Nullable PersistableBundle bundle) { |
| 993 | } |
| 994 | |
| 995 | /** |
arangelov | b46faf3 | 2018-01-17 21:27:40 +0000 | [diff] [blame] | 996 | * Called on the device owner when the ownership of one of its affiliated profiles is |
| 997 | * transferred. |
| 998 | * |
| 999 | * <p>This can be used when transferring both device and profile ownership when using |
| 1000 | * work profile on a fully managed device. The process would look like this: |
| 1001 | * <ol> |
| 1002 | * <li>Transfer profile ownership</li> |
| 1003 | * <li>The device owner gets notified with this callback</li> |
| 1004 | * <li>Transfer device ownership</li> |
| 1005 | * <li>Both profile and device ownerships have been transferred</li> |
| 1006 | * </ol> |
| 1007 | * |
| 1008 | * @param context the running context as per {@link #onReceive} |
| 1009 | * @param user the {@link UserHandle} of the affiliated user |
| 1010 | * @see DevicePolicyManager#transferOwnership(ComponentName, ComponentName, PersistableBundle) |
| 1011 | */ |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 1012 | public void onTransferAffiliatedProfileOwnershipComplete(@NonNull Context context, |
| 1013 | @NonNull UserHandle user) { |
arangelov | b46faf3 | 2018-01-17 21:27:40 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1017 | * Intercept standard device administrator broadcasts. Implementations |
| 1018 | * should not override this method; it is better to implement the |
| 1019 | * convenience callbacks for each action. |
| 1020 | */ |
| 1021 | @Override |
Rubin Xu | 72623f6 | 2019-03-11 14:51:56 +0000 | [diff] [blame] | 1022 | public void onReceive(@NonNull Context context, @NonNull Intent intent) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1023 | String action = intent.getAction(); |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 1024 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1025 | if (ACTION_PASSWORD_CHANGED.equals(action)) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 1026 | onPasswordChanged(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1027 | } else if (ACTION_PASSWORD_FAILED.equals(action)) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 1028 | onPasswordFailed(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1029 | } else if (ACTION_PASSWORD_SUCCEEDED.equals(action)) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 1030 | onPasswordSucceeded(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1031 | } else if (ACTION_DEVICE_ADMIN_ENABLED.equals(action)) { |
| 1032 | onEnabled(context, intent); |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 1033 | } else if (ACTION_DEVICE_ADMIN_DISABLE_REQUESTED.equals(action)) { |
| 1034 | CharSequence res = onDisableRequested(context, intent); |
| 1035 | if (res != null) { |
| 1036 | Bundle extras = getResultExtras(true); |
| 1037 | extras.putCharSequence(EXTRA_DISABLE_WARNING, res); |
| 1038 | } |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1039 | } else if (ACTION_DEVICE_ADMIN_DISABLED.equals(action)) { |
| 1040 | onDisabled(context, intent); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1041 | } else if (ACTION_PASSWORD_EXPIRING.equals(action)) { |
Robin Lee | d2a73ed | 2016-12-19 09:07:16 +0000 | [diff] [blame] | 1042 | onPasswordExpiring(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
Jessica Hummel | 8cdb6fc | 2014-03-03 14:14:51 +0000 | [diff] [blame] | 1043 | } else if (ACTION_PROFILE_PROVISIONING_COMPLETE.equals(action)) { |
| 1044 | onProfileProvisioningComplete(context, intent); |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 1045 | } else if (ACTION_CHOOSE_PRIVATE_KEY_ALIAS.equals(action)) { |
Robin Lee | abf3570 | 2015-02-17 14:12:48 +0000 | [diff] [blame] | 1046 | int uid = intent.getIntExtra(EXTRA_CHOOSE_PRIVATE_KEY_SENDER_UID, -1); |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 1047 | Uri uri = intent.getParcelableExtra(EXTRA_CHOOSE_PRIVATE_KEY_URI); |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 1048 | String alias = intent.getStringExtra(EXTRA_CHOOSE_PRIVATE_KEY_ALIAS); |
Robin Lee | 39087b1 | 2015-05-05 15:57:17 +0100 | [diff] [blame] | 1049 | String chosenAlias = onChoosePrivateKeyAlias(context, intent, uid, uri, alias); |
Robin Lee | 3798ed5 | 2015-02-03 17:55:31 +0000 | [diff] [blame] | 1050 | setResultData(chosenAlias); |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 1051 | } else if (ACTION_LOCK_TASK_ENTERING.equals(action)) { |
Jason Monk | 35c62a4 | 2014-06-17 10:24:47 -0400 | [diff] [blame] | 1052 | String pkg = intent.getStringExtra(EXTRA_LOCK_TASK_PACKAGE); |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 1053 | onLockTaskModeEntering(context, intent, pkg); |
| 1054 | } else if (ACTION_LOCK_TASK_EXITING.equals(action)) { |
| 1055 | onLockTaskModeExiting(context, intent); |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 1056 | } else if (ACTION_NOTIFY_PENDING_SYSTEM_UPDATE.equals(action)) { |
| 1057 | long receivedTime = intent.getLongExtra(EXTRA_SYSTEM_UPDATE_RECEIVED_TIME, -1); |
| 1058 | onSystemUpdatePending(context, intent, receivedTime); |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 1059 | } else if (ACTION_BUGREPORT_SHARING_DECLINED.equals(action)) { |
| 1060 | onBugreportSharingDeclined(context, intent); |
| 1061 | } else if (ACTION_BUGREPORT_SHARE.equals(action)) { |
| 1062 | String bugreportFileHash = intent.getStringExtra(EXTRA_BUGREPORT_HASH); |
| 1063 | onBugreportShared(context, intent, bugreportFileHash); |
| 1064 | } else if (ACTION_BUGREPORT_FAILED.equals(action)) { |
| 1065 | int failureCode = intent.getIntExtra(EXTRA_BUGREPORT_FAILURE_REASON, |
| 1066 | BUGREPORT_FAILURE_FAILED_COMPLETING); |
| 1067 | onBugreportFailed(context, intent, failureCode); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 1068 | } else if (ACTION_SECURITY_LOGS_AVAILABLE.equals(action)) { |
| 1069 | onSecurityLogsAvailable(context, intent); |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 1070 | } else if (ACTION_NETWORK_LOGS_AVAILABLE.equals(action)) { |
Michal Karpinski | a9ff206 | 2016-11-03 15:46:17 +0000 | [diff] [blame] | 1071 | long batchToken = intent.getLongExtra(EXTRA_NETWORK_LOGS_TOKEN, -1); |
| 1072 | int networkLogsCount = intent.getIntExtra(EXTRA_NETWORK_LOGS_COUNT, 0); |
| 1073 | onNetworkLogsAvailable(context, intent, batchToken, networkLogsCount); |
Nicolas Prevot | e95c281 | 2016-11-17 17:30:55 +0000 | [diff] [blame] | 1074 | } else if (ACTION_USER_ADDED.equals(action)) { |
| 1075 | onUserAdded(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
| 1076 | } else if (ACTION_USER_REMOVED.equals(action)) { |
| 1077 | onUserRemoved(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
Alex Chau | 2c082aee | 2018-01-17 18:26:03 +0000 | [diff] [blame] | 1078 | } else if (ACTION_USER_STARTED.equals(action)) { |
| 1079 | onUserStarted(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
| 1080 | } else if (ACTION_USER_STOPPED.equals(action)) { |
| 1081 | onUserStopped(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
| 1082 | } else if (ACTION_USER_SWITCHED.equals(action)) { |
| 1083 | onUserSwitched(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 1084 | } else if (ACTION_TRANSFER_OWNERSHIP_COMPLETE.equals(action)) { |
| 1085 | PersistableBundle bundle = |
arangelov | 91201bd | 2018-01-04 17:10:21 +0000 | [diff] [blame] | 1086 | intent.getParcelableExtra(EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE); |
arangelov | 8bae4ea | 2017-12-20 20:26:46 +0000 | [diff] [blame] | 1087 | onTransferOwnershipComplete(context, bundle); |
arangelov | b46faf3 | 2018-01-17 21:27:40 +0000 | [diff] [blame] | 1088 | } else if (ACTION_AFFILIATED_PROFILE_TRANSFER_OWNERSHIP_COMPLETE.equals(action)) { |
| 1089 | onTransferAffiliatedProfileOwnershipComplete(context, |
| 1090 | intent.getParcelableExtra(Intent.EXTRA_USER)); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1091 | } |
| 1092 | } |
| 1093 | } |