blob: 4771fd8a00b6c854b0333f6a7f6eac8b96681d29 [file] [log] [blame]
Dianne Hackbornd6847842010-01-12 18:14:19 -08001/*
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 Hackborn87bba1e2010-02-26 17:25:54 -080017package android.app.admin;
Dianne Hackbornd6847842010-01-12 18:14:19 -080018
Jessica Hummel9da60392014-05-21 12:32:57 +010019import android.accounts.AccountManager;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070020import android.annotation.BroadcastBehavior;
Michal Karpinski3fc437e2015-12-15 10:09:00 +000021import android.annotation.IntDef;
Rubin Xu72623f62019-03-11 14:51:56 +000022import android.annotation.IntRange;
Alex Chaub12e6722018-02-12 15:42:10 +080023import android.annotation.NonNull;
24import android.annotation.Nullable;
Dianne Hackbornd6847842010-01-12 18:14:19 -080025import android.annotation.SdkConstant;
26import android.annotation.SdkConstant.SdkConstantType;
Dianne Hackborn87bba1e2010-02-26 17:25:54 -080027import android.app.Service;
Dianne Hackbornd6847842010-01-12 18:14:19 -080028import android.content.BroadcastReceiver;
29import android.content.ComponentName;
30import android.content.Context;
31import android.content.Intent;
Robin Lee39087b12015-05-05 15:57:17 +010032import android.net.Uri;
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080033import android.os.Bundle;
arangelov8bae4ea2017-12-20 20:26:46 +000034import android.os.PersistableBundle;
Robin Leed2a73ed2016-12-19 09:07:16 +000035import android.os.Process;
Nicolas Prevote95c2812016-11-17 17:30:55 +000036import android.os.UserHandle;
Robin Lee3798ed52015-02-03 17:55:31 +000037import android.security.KeyChain;
Dianne Hackbornd6847842010-01-12 18:14:19 -080038
Michal Karpinski3fc437e2015-12-15 10:09:00 +000039import java.lang.annotation.Retention;
40import java.lang.annotation.RetentionPolicy;
41
Dianne Hackbornd6847842010-01-12 18:14:19 -080042/**
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 Hummel8cdb6fc2014-03-03 14:14:51 +000046 *
Dianne Hackbornef6b22f2010-02-16 20:38:49 -080047 * <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 Hummel8cdb6fc2014-03-03 14:14:51 +000053 *
Dianne Hackbornd6847842010-01-12 18:14:19 -080054 * <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 Hummel8cdb6fc2014-03-03 14:14:51 +000058 *
Dianne Hackbornab8a8ed2010-01-29 19:03:06 -080059 * {@sample development/samples/ApiDemos/AndroidManifest.xml device_admin_declaration}
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +000060 *
Dianne Hackbornd6847842010-01-12 18:14:19 -080061 * <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 Hummel8cdb6fc2014-03-03 14:14:51 +000064 *
Andrew Stadler88209d12010-02-08 22:59:36 -080065 * {@sample development/samples/ApiDemos/res/xml/device_admin_sample.xml meta_data}
Joe Fernandez3aef8e1d2011-12-20 10:38:34 -080066 *
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 Hackbornd6847842010-01-12 18:14:19 -080073 */
Dianne Hackbornef6b22f2010-02-16 20:38:49 -080074public class DeviceAdminReceiver extends BroadcastReceiver {
Dianne Hackbornd6847842010-01-12 18:14:19 -080075 private static String TAG = "DevicePolicy";
Joe Onorato43a17652011-04-06 19:22:23 -070076 private static boolean localLOGV = false;
Dianne Hackbornd6847842010-01-12 18:14:19 -080077
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 Hackbornef6b22f2010-02-16 20:38:49 -080082 * handle this in {@link DeviceAdminReceiver#onEnabled(Context, Intent)}. To be
Dianne Hackbornd6847842010-01-12 18:14:19 -080083 * 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 Sharkey32ee8ee2017-03-08 20:17:51 -070088 @BroadcastBehavior(explicitOnly = true)
Dianne Hackbornd6847842010-01-12 18:14:19 -080089 public static final String ACTION_DEVICE_ADMIN_ENABLED
90 = "android.app.action.DEVICE_ADMIN_ENABLED";
91
92 /**
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080093 * 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 Sharkey32ee8ee2017-03-08 20:17:51 -0700102 @BroadcastBehavior(explicitOnly = true)
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800103 public static final String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED
104 = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED";
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000105
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800106 /**
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 Hummel8cdb6fc2014-03-03 14:14:51 +0000113
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800114 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -0800115 * 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 Hackbornef6b22f2010-02-16 20:38:49 -0800118 * handle this in {@link DeviceAdminReceiver#onDisabled(Context, Intent)}. Note
Dianne Hackbornd6847842010-01-12 18:14:19 -0800119 * 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 Sharkey32ee8ee2017-03-08 20:17:51 -0700124 @BroadcastBehavior(explicitOnly = true)
Dianne Hackbornd6847842010-01-12 18:14:19 -0800125 public static final String ACTION_DEVICE_ADMIN_DISABLED
126 = "android.app.action.DEVICE_ADMIN_DISABLED";
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000127
Dianne Hackbornd6847842010-01-12 18:14:19 -0800128 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000129 * 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 Hackborn254cb442010-01-27 19:23:59 -0800131 * of the new password with {@link DevicePolicyManager#isActivePasswordSufficient()
132 * DevicePolicyManager.isActivePasswordSufficient()}.
133 * You will generally
Robin Leed2a73ed2016-12-19 09:07:16 +0000134 * handle this in {@link DeviceAdminReceiver#onPasswordChanged(Context, Intent, UserHandle)}.
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000135 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800136 * <p>The calling device admin must have requested
137 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to receive
138 * this broadcast.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800139 */
140 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700141 @BroadcastBehavior(explicitOnly = true)
Dianne Hackbornd6847842010-01-12 18:14:19 -0800142 public static final String ACTION_PASSWORD_CHANGED
143 = "android.app.action.ACTION_PASSWORD_CHANGED";
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000144
Dianne Hackbornd6847842010-01-12 18:14:19 -0800145 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000146 * 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 Hackbornd6847842010-01-12 18:14:19 -0800148 * number of failed password attempts there have been with
Dianne Hackborn254cb442010-01-27 19:23:59 -0800149 * {@link DevicePolicyManager#getCurrentFailedPasswordAttempts
Dianne Hackbornd6847842010-01-12 18:14:19 -0800150 * DevicePolicyManager.getCurrentFailedPasswordAttempts()}. You will generally
Robin Leed2a73ed2016-12-19 09:07:16 +0000151 * handle this in {@link DeviceAdminReceiver#onPasswordFailed(Context, Intent, UserHandle)}.
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000152 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800153 * <p>The calling device admin must have requested
154 * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to receive
155 * this broadcast.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800156 */
157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700158 @BroadcastBehavior(explicitOnly = true)
Dianne Hackbornd6847842010-01-12 18:14:19 -0800159 public static final String ACTION_PASSWORD_FAILED
160 = "android.app.action.ACTION_PASSWORD_FAILED";
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000161
Dianne Hackbornd6847842010-01-12 18:14:19 -0800162 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000163 * 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 Leed2a73ed2016-12-19 09:07:16 +0000165 * handle this in {@link DeviceAdminReceiver#onPasswordSucceeded(Context, Intent, UserHandle)}.
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000166 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800167 * <p>The calling device admin must have requested
168 * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to receive
169 * this broadcast.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800170 */
171 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700172 @BroadcastBehavior(explicitOnly = true)
Dianne Hackbornd6847842010-01-12 18:14:19 -0800173 public static final String ACTION_PASSWORD_SUCCEEDED
174 = "android.app.action.ACTION_PASSWORD_SUCCEEDED";
Jim Millera4e28d12010-11-08 16:15:47 -0800175
176 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000177 * Action periodically sent to a device administrator when the device or profile challenge
178 * password is expiring. You will generally
Robin Leed2a73ed2016-12-19 09:07:16 +0000179 * handle this in {@link DeviceAdminReceiver#onPasswordExpiring(Context, Intent, UserHandle)}.
Jim Millera4e28d12010-11-08 16:15:47 -0800180 *
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 Sharkey32ee8ee2017-03-08 20:17:51 -0700186 @BroadcastBehavior(explicitOnly = true)
Jim Millera4e28d12010-11-08 16:15:47 -0800187 public static final String ACTION_PASSWORD_EXPIRING
188 = "android.app.action.ACTION_PASSWORD_EXPIRING";
189
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000190 /**
Jason Monk35c62a42014-06-17 10:24:47 -0400191 * Action sent to a device administrator to notify that the device is entering
Benjamin Franz43261142015-02-11 15:59:44 +0000192 * lock task mode. The extra {@link #EXTRA_LOCK_TASK_PACKAGE}
193 * will describe the package using lock task mode.
Jason Monk35c62a42014-06-17 10:24:47 -0400194 *
Jason Monk35c62a42014-06-17 10:24:47 -0400195 * <p>The calling device admin must be the device owner or profile
196 * owner to receive this broadcast.
Benjamin Franzc70d0e72015-02-12 16:12:58 +0000197 *
198 * @see DevicePolicyManager#isLockTaskPermitted(String)
Jason Monk35c62a42014-06-17 10:24:47 -0400199 */
200 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700201 @BroadcastBehavior(explicitOnly = true)
Jason Monk48aacba2014-08-13 16:29:08 -0400202 public static final String ACTION_LOCK_TASK_ENTERING
Jason Monk5503a552014-09-04 14:14:37 -0400203 = "android.app.action.LOCK_TASK_ENTERING";
Jason Monk35c62a42014-06-17 10:24:47 -0400204
205 /**
Jason Monk48aacba2014-08-13 16:29:08 -0400206 * Action sent to a device administrator to notify that the device is exiting
Benjamin Franz43261142015-02-11 15:59:44 +0000207 * lock task mode.
Jason Monk35c62a42014-06-17 10:24:47 -0400208 *
Jason Monk48aacba2014-08-13 16:29:08 -0400209 * <p>The calling device admin must be the device owner or profile
210 * owner to receive this broadcast.
Benjamin Franzc70d0e72015-02-12 16:12:58 +0000211 *
212 * @see DevicePolicyManager#isLockTaskPermitted(String)
Jason Monk35c62a42014-06-17 10:24:47 -0400213 */
Jason Monk48aacba2014-08-13 16:29:08 -0400214 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700215 @BroadcastBehavior(explicitOnly = true)
Jason Monk48aacba2014-08-13 16:29:08 -0400216 public static final String ACTION_LOCK_TASK_EXITING
Jason Monk5503a552014-09-04 14:14:37 -0400217 = "android.app.action.LOCK_TASK_EXITING";
Jason Monk35c62a42014-06-17 10:24:47 -0400218
219 /**
Benjamin Franzc70d0e72015-02-12 16:12:58 +0000220 * A string containing the name of the package entering lock task mode.
Jason Monk35c62a42014-06-17 10:24:47 -0400221 *
Benjamin Franzc70d0e72015-02-12 16:12:58 +0000222 * @see #ACTION_LOCK_TASK_ENTERING
Jason Monk35c62a42014-06-17 10:24:47 -0400223 */
224 public static final String EXTRA_LOCK_TASK_PACKAGE =
225 "android.app.extra.LOCK_TASK_PACKAGE";
226
227 /**
Jessica Hummel9da60392014-05-21 12:32:57 +0100228 * Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile
229 * or managed device has completed successfully.
Jessica Hummelf72078b2014-03-06 16:13:12 +0000230 *
Jessica Hummel9da60392014-05-21 12:32:57 +0100231 * <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 Solovay27f53372015-03-02 16:37:59 -0800235 * (see {@link DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE
236 * DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE}).
Nicolas Prevot07ac20b2014-05-27 15:37:45 +0100237 *
Sander Alewijnse1cc4ecc2014-06-23 19:56:52 +0100238 * <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 Reynolds20118f12015-02-11 12:34:08 -0500241 * {@link android.app.admin.DevicePolicyManager#isProfileOwnerApp}. You will generally handle
242 * this in {@link DeviceAdminReceiver#onProfileProvisioningComplete}.
Sander Alewijnse1cc4ecc2014-06-23 19:56:52 +0100243 *
Esteban Talavera4047bae2017-06-28 11:03:09 +0100244 * @see DevicePolicyManager#ACTION_PROVISIONING_SUCCESSFUL
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000245 */
246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700247 @BroadcastBehavior(explicitOnly = true)
Jessica Hummelf72078b2014-03-06 16:13:12 +0000248 public static final String ACTION_PROFILE_PROVISIONING_COMPLETE =
Jessica Hummel56692162014-09-10 15:12:11 +0100249 "android.app.action.PROFILE_PROVISIONING_COMPLETE";
250
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000251 /**
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 Sharkey32ee8ee2017-03-08 20:17:51 -0700260 @BroadcastBehavior(explicitOnly = true)
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000261 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 Sharkey32ee8ee2017-03-08 20:17:51 -0700273 @BroadcastBehavior(explicitOnly = true)
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000274 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 Sharkey32ee8ee2017-03-08 20:17:51 -0700284 @BroadcastBehavior(explicitOnly = true)
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000285 public static final String ACTION_BUGREPORT_SHARE =
286 "android.app.action.BUGREPORT_SHARE";
287
288 /**
Michal Karpinski6235a942016-03-15 12:07:23 +0000289 * Broadcast action: notify that a new batch of security logs is ready to be collected.
Rubin Xuc3cd05f2016-01-11 12:11:35 +0000290 * @hide
291 */
292 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700293 @BroadcastBehavior(explicitOnly = true)
Rubin Xuc3cd05f2016-01-11 12:11:35 +0000294 public static final String ACTION_SECURITY_LOGS_AVAILABLE
295 = "android.app.action.SECURITY_LOGS_AVAILABLE";
296
297 /**
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100298 * Broadcast action: notify that a new batch of network logs is ready to be collected.
299 * @see DeviceAdminReceiver#onNetworkLogsAvailable
Rubin Xu99a66a92018-11-21 17:41:54 +0000300 * @see DelegatedAdminReceiver#onNetworkLogsAvailable
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100301 */
302 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700303 @BroadcastBehavior(explicitOnly = true)
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100304 public static final String ACTION_NETWORK_LOGS_AVAILABLE
305 = "android.app.action.NETWORK_LOGS_AVAILABLE";
306
307 /**
Michal Karpinskia9ff2062016-11-03 15:46:17 +0000308 * 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 Prevote95c2812016-11-17 17:30:55 +0000329 * 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 Sharkey32ee8ee2017-03-08 20:17:51 -0700335 @BroadcastBehavior(explicitOnly = true)
336 public static final String ACTION_USER_ADDED = "android.app.action.USER_ADDED";
Nicolas Prevote95c2812016-11-17 17:30:55 +0000337
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 Chau2c082aee2018-01-17 18:26:03 +0000341 * the user.
Nicolas Prevote95c2812016-11-17 17:30:55 +0000342 * @hide
343 */
344 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700345 @BroadcastBehavior(explicitOnly = true)
Nicolas Prevote95c2812016-11-17 17:30:55 +0000346 public static final String ACTION_USER_REMOVED = "android.app.action.USER_REMOVED";
347
348 /**
Alex Chau2c082aee2018-01-17 18:26:03 +0000349 * 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 Karpinski3fc437e2015-12-15 10:09:00 +0000379 * 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 Karpinski37cfe712016-03-11 14:00:13 +0000387 * 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 Karpinski3fc437e2015-12-15 10:09:00 +0000390 *
391 * @see #ACTION_BUGREPORT_FAILED
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000392 * @hide
393 */
394 public static final String EXTRA_BUGREPORT_FAILURE_REASON =
395 "android.app.extra.BUGREPORT_FAILURE_REASON";
396
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000397 /**
398 * An interface representing reason of bugreport failure.
399 *
400 * @see #EXTRA_BUGREPORT_FAILURE_REASON
401 * @hide
402 */
Felipe Lemedc7af962016-01-22 18:27:03 -0800403 @Retention(RetentionPolicy.SOURCE)
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700404 @IntDef(prefix = { "BUGREPORT_FAILURE_" }, value = {
405 BUGREPORT_FAILURE_FAILED_COMPLETING,
406 BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE
Felipe Lemedc7af962016-01-22 18:27:03 -0800407 })
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000408 public @interface BugreportFailureCode {}
Michal Karpinski37cfe712016-03-11 14:00:13 +0000409
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 Karpinski3fc437e2015-12-15 10:09:00 +0000416 public static final int BUGREPORT_FAILURE_FAILED_COMPLETING = 0;
Michal Karpinski37cfe712016-03-11 14:00:13 +0000417
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 Karpinski3fc437e2015-12-15 10:09:00 +0000427 public static final int BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE = 1;
428
Rubin Xu99a66a92018-11-21 17:41:54 +0000429 /**
430 * Broadcast action: notify that some app is attempting to choose a KeyChain key.
431 * @see DeviceAdminReceiver#onChoosePrivateKeyAlias
432 * @see DelegatedAdminReceiver#onChoosePrivateKeyAlias
433 */
Charles Hec4a339a2016-11-14 14:16:57 +0000434 public static final String ACTION_CHOOSE_PRIVATE_KEY_ALIAS =
435 "android.app.action.CHOOSE_PRIVATE_KEY_ALIAS";
Robin Lee3798ed52015-02-03 17:55:31 +0000436
437 /** @hide */
Charles Hec4a339a2016-11-14 14:16:57 +0000438 public static final String EXTRA_CHOOSE_PRIVATE_KEY_SENDER_UID =
439 "android.app.extra.CHOOSE_PRIVATE_KEY_SENDER_UID";
Robin Lee3798ed52015-02-03 17:55:31 +0000440
441 /** @hide */
Charles Hec4a339a2016-11-14 14:16:57 +0000442 public static final String EXTRA_CHOOSE_PRIVATE_KEY_URI =
443 "android.app.extra.CHOOSE_PRIVATE_KEY_URI";
Robin Lee3798ed52015-02-03 17:55:31 +0000444
445 /** @hide */
Charles Hec4a339a2016-11-14 14:16:57 +0000446 public static final String EXTRA_CHOOSE_PRIVATE_KEY_ALIAS =
447 "android.app.extra.CHOOSE_PRIVATE_KEY_ALIAS";
Robin Lee3798ed52015-02-03 17:55:31 +0000448
449 /** @hide */
Charles Hec4a339a2016-11-14 14:16:57 +0000450 public static final String EXTRA_CHOOSE_PRIVATE_KEY_RESPONSE =
451 "android.app.extra.CHOOSE_PRIVATE_KEY_RESPONSE";
Robin Lee3798ed52015-02-03 17:55:31 +0000452
Julia Reynolds20118f12015-02-11 12:34:08 -0500453 /**
Rubin Xudc105cc2015-04-14 23:38:01 +0100454 * Broadcast action: notify device owner that there is a pending system update.
455 * @hide
456 */
457 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -0700458 @BroadcastBehavior(explicitOnly = true)
Charles Hec4a339a2016-11-14 14:16:57 +0000459 public static final String ACTION_NOTIFY_PENDING_SYSTEM_UPDATE =
460 "android.app.action.NOTIFY_PENDING_SYSTEM_UPDATE";
Rubin Xudc105cc2015-04-14 23:38:01 +0100461
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 Hec4a339a2016-11-14 14:16:57 +0000467 public static final String EXTRA_SYSTEM_UPDATE_RECEIVED_TIME =
468 "android.app.extra.SYSTEM_UPDATE_RECEIVED_TIME";
Rubin Xudc105cc2015-04-14 23:38:01 +0100469
470 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900471 * Name under which a DevicePolicy component publishes information
Dianne Hackbornd6847842010-01-12 18:14:19 -0800472 * about itself. This meta-data must reference an XML resource containing
Andrew Solovay27f53372015-03-02 16:37:59 -0800473 * a device-admin tag.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800474 */
Andrew Solovay27f53372015-03-02 16:37:59 -0800475 // TO DO: describe syntax.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800476 public static final String DEVICE_ADMIN_META_DATA = "android.app.device_admin";
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000477
arangelov8bae4ea2017-12-20 20:26:46 +0000478 /**
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 /**
arangelovb46faf32018-01-17 21:27:40 +0000489 * 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 /**
arangelov8bae4ea2017-12-20 20:26:46 +0000499 * 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 *
arangelov91201bd2018-01-04 17:10:21 +0000503 * <p>If the transfer is successful, the new owner receives the data in
arangelov8bae4ea2017-12-20 20:26:46 +0000504 * {@link DeviceAdminReceiver#onTransferOwnershipComplete(Context, PersistableBundle)}.
505 * The bundle is not changed during the ownership transfer.
506 *
507 * @see DevicePolicyManager#transferOwnership(ComponentName, ComponentName, PersistableBundle)
508 */
arangelov91201bd2018-01-04 17:10:21 +0000509 public static final String EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE =
510 "android.app.extra.TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE";
arangelov8bae4ea2017-12-20 20:26:46 +0000511
Dianne Hackbornd6847842010-01-12 18:14:19 -0800512 private DevicePolicyManager mManager;
513 private ComponentName mWho;
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000514
Dianne Hackbornd6847842010-01-12 18:14:19 -0800515 /**
516 * Retrieve the DevicePolicyManager interface for this administrator to work
517 * with the system.
518 */
Rubin Xu72623f62019-03-11 14:51:56 +0000519 public @NonNull DevicePolicyManager getManager(@NonNull Context context) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800520 if (mManager != null) {
521 return mManager;
522 }
523 mManager = (DevicePolicyManager)context.getSystemService(
524 Context.DEVICE_POLICY_SERVICE);
525 return mManager;
526 }
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000527
Dianne Hackbornd6847842010-01-12 18:14:19 -0800528 /**
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 Xu72623f62019-03-11 14:51:56 +0000533 public @NonNull ComponentName getWho(@NonNull Context context) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800534 if (mWho != null) {
535 return mWho;
536 }
537 mWho = new ComponentName(context, getClass());
538 return mWho;
539 }
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000540
Dianne Hackbornd6847842010-01-12 18:14:19 -0800541 /**
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 Monk03978a42014-06-10 15:05:30 -0400545 *
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.
phweiss27ee3342016-02-08 16:40:45 +0100548 * {@see DevicePolicyManager#createAndManageUser(ComponentName, String, ComponentName,
549 * PersistableBundle, int)}
Jason Monk03978a42014-06-10 15:05:30 -0400550 *
Dianne Hackbornd6847842010-01-12 18:14:19 -0800551 * @param context The running context as per {@link #onReceive}.
552 * @param intent The received intent as per {@link #onReceive}.
553 */
Rubin Xu72623f62019-03-11 14:51:56 +0000554 public void onEnabled(@NonNull Context context, @NonNull Intent intent) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800555 }
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000556
Dianne Hackbornd6847842010-01-12 18:14:19 -0800557 /**
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800558 * 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 Xu72623f62019-03-11 14:51:56 +0000568 public @Nullable CharSequence onDisableRequested(@NonNull Context context,
569 @NonNull Intent intent) {
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800570 return null;
571 }
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000572
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800573 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -0800574 * 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 Xu72623f62019-03-11 14:51:56 +0000581 public void onDisabled(@NonNull Context context, @NonNull Intent intent) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800582 }
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000583
Dianne Hackbornd6847842010-01-12 18:14:19 -0800584 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000585 * Called after the user has changed their device or profile challenge password, as a result of
Dianne Hackbornd6847842010-01-12 18:14:19 -0800586 * receiving {@link #ACTION_PASSWORD_CHANGED}. At this point you
Robin Lee9983aca2016-01-20 17:15:08 +0000587 * can use {@link DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
Dianne Hackbornd6847842010-01-12 18:14:19 -0800588 * 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 Leed2a73ed2016-12-19 09:07:16 +0000591 *
592 * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use
593 * {@link #onPasswordChanged(Context, Intent, UserHandle)} instead.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800594 */
Robin Leed2a73ed2016-12-19 09:07:16 +0000595 @Deprecated
Rubin Xu72623f62019-03-11 14:51:56 +0000596 public void onPasswordChanged(@NonNull Context context, @NonNull Intent intent) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800597 }
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000598
Dianne Hackbornd6847842010-01-12 18:14:19 -0800599 /**
Robin Leed2a73ed2016-12-19 09:07:16 +0000600 * 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 Xu72623f62019-03-11 14:51:56 +0000610 public void onPasswordChanged(@NonNull Context context, @NonNull Intent intent,
611 @NonNull UserHandle user) {
Robin Leed2a73ed2016-12-19 09:07:16 +0000612 onPasswordChanged(context, intent);
613 }
614
615 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000616 * 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 Hackbornd6847842010-01-12 18:14:19 -0800620 * @param context The running context as per {@link #onReceive}.
621 * @param intent The received intent as per {@link #onReceive}.
Robin Leed2a73ed2016-12-19 09:07:16 +0000622 *
623 * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use
624 * {@link #onPasswordFailed(Context, Intent, UserHandle)} instead.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800625 */
Robin Leed2a73ed2016-12-19 09:07:16 +0000626 @Deprecated
Rubin Xu72623f62019-03-11 14:51:56 +0000627 public void onPasswordFailed(@NonNull Context context, @NonNull Intent intent) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800628 }
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000629
Dianne Hackbornd6847842010-01-12 18:14:19 -0800630 /**
Robin Leed2a73ed2016-12-19 09:07:16 +0000631 * 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 Xu72623f62019-03-11 14:51:56 +0000641 public void onPasswordFailed(@NonNull Context context, @NonNull Intent intent,
642 @NonNull UserHandle user) {
Robin Leed2a73ed2016-12-19 09:07:16 +0000643 onPasswordFailed(context, intent);
644 }
645
646 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000647 * Called after the user has succeeded at entering their device or profile challenge password,
Dianne Hackbornd6847842010-01-12 18:14:19 -0800648 * 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 Leed2a73ed2016-12-19 09:07:16 +0000653 *
654 * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use
655 * {@link #onPasswordSucceeded(Context, Intent, UserHandle)} instead.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800656 */
Robin Leed2a73ed2016-12-19 09:07:16 +0000657 @Deprecated
Rubin Xu72623f62019-03-11 14:51:56 +0000658 public void onPasswordSucceeded(@NonNull Context context, @NonNull Intent intent) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800659 }
Jim Millera4e28d12010-11-08 16:15:47 -0800660
661 /**
Robin Leed2a73ed2016-12-19 09:07:16 +0000662 * 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 Xu72623f62019-03-11 14:51:56 +0000672 public void onPasswordSucceeded(@NonNull Context context, @NonNull Intent intent,
673 @NonNull UserHandle user) {
Robin Leed2a73ed2016-12-19 09:07:16 +0000674 onPasswordSucceeded(context, intent);
675 }
676
677 /**
Esteban Talaverac1c83592016-02-17 17:56:15 +0000678 * 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 Millera4e28d12010-11-08 16:15:47 -0800681 *
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 Leed2a73ed2016-12-19 09:07:16 +0000694 *
695 * @deprecated From {@link android.os.Build.VERSION_CODES#O}, use
696 * {@link #onPasswordExpiring(Context, Intent, UserHandle)} instead.
Jim Millera4e28d12010-11-08 16:15:47 -0800697 */
Robin Leed2a73ed2016-12-19 09:07:16 +0000698 @Deprecated
Rubin Xu72623f62019-03-11 14:51:56 +0000699 public void onPasswordExpiring(@NonNull Context context, @NonNull Intent intent) {
Jim Millera4e28d12010-11-08 16:15:47 -0800700 }
701
Dianne Hackbornd6847842010-01-12 18:14:19 -0800702 /**
Robin Leed2a73ed2016-12-19 09:07:16 +0000703 * 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 Xu72623f62019-03-11 14:51:56 +0000723 public void onPasswordExpiring(@NonNull Context context, @NonNull Intent intent,
724 @NonNull UserHandle user) {
Robin Leed2a73ed2016-12-19 09:07:16 +0000725 onPasswordExpiring(context, intent);
726 }
727
728 /**
Jessica Hummel9da60392014-05-21 12:32:57 +0100729 * Called when provisioning of a managed profile or managed device has completed successfully.
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000730 *
Julia Reynolds20118f12015-02-11 12:34:08 -0500731 * <p> As a prerequisite for the execution of this callback the {@link DeviceAdminReceiver} has
Jessica Hummel9da60392014-05-21 12:32:57 +0100732 * 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 Hummel8cdb6fc2014-03-03 14:14:51 +0000736 *
Julia Reynolds20118f12015-02-11 12:34:08 -0500737 * <p>When provisioning of a managed profile is complete, the managed profile is hidden until
Kenny Guyac6e7672017-07-13 11:26:47 +0100738 * the profile owner calls {@link DevicePolicyManager#setProfileEnabled(ComponentName admin)}.
Julia Reynolds20118f12015-02-11 12:34:08 -0500739 * Typically a profile owner will enable the profile when it has finished any additional setup
Kenny Guyac6e7672017-07-13 11:26:47 +0100740 * such as adding an account by using the {@link AccountManager} and calling APIs to bring the
Julia Reynolds20118f12015-02-11 12:34:08 -0500741 * profile into the desired state.
Jessica Hummel9da60392014-05-21 12:32:57 +0100742 *
743 * <p> Note that provisioning completes without waiting for any server interactions, so the
Kenny Guyac6e7672017-07-13 11:26:47 +0100744 * profile owner needs to wait for data to be available if required (e.g. Android device IDs or
Jessica Hummel9da60392014-05-21 12:32:57 +0100745 * other data that is set as a result of server interactions).
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000746 *
Esteban Talavera4047bae2017-06-28 11:03:09 +0100747 * <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 Hummel8cdb6fc2014-03-03 14:14:51 +0000752 * @param context The running context as per {@link #onReceive}.
753 * @param intent The received intent as per {@link #onReceive}.
754 */
Rubin Xu72623f62019-03-11 14:51:56 +0000755 public void onProfileProvisioningComplete(@NonNull Context context, @NonNull Intent intent) {
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +0000756 }
757
758 /**
Julia Reynolds20118f12015-02-11 12:34:08 -0500759 * Called during provisioning of a managed device to allow the device initializer to perform
Craig Lafayettee7ee54e2015-09-21 13:48:53 -0400760 * user setup steps.
Julia Reynolds20118f12015-02-11 12:34:08 -0500761 *
762 * @param context The running context as per {@link #onReceive}.
763 * @param intent The received intent as per {@link #onReceive}.
Craig Lafayettee7ee54e2015-09-21 13:48:53 -0400764 * @deprecated Do not use
Julia Reynolds20118f12015-02-11 12:34:08 -0500765 */
Craig Lafayettee7ee54e2015-09-21 13:48:53 -0400766 @Deprecated
Rubin Xu72623f62019-03-11 14:51:56 +0000767 public void onReadyForUserInitialization(@NonNull Context context, @NonNull Intent intent) {
Julia Reynolds20118f12015-02-11 12:34:08 -0500768 }
769
770 /**
Benjamin Franz43261142015-02-11 15:59:44 +0000771 * Called when a device is entering lock task mode.
Jason Monk35c62a42014-06-17 10:24:47 -0400772 *
773 * @param context The running context as per {@link #onReceive}.
774 * @param intent The received intent as per {@link #onReceive}.
Rubin Xu72623f62019-03-11 14:51:56 +0000775 * @param pkg The authorized package using lock task mode.
Jason Monk35c62a42014-06-17 10:24:47 -0400776 */
Rubin Xu72623f62019-03-11 14:51:56 +0000777 public void onLockTaskModeEntering(@NonNull Context context, @NonNull Intent intent,
778 @NonNull String pkg) {
Jason Monk48aacba2014-08-13 16:29:08 -0400779 }
780
781 /**
Benjamin Franz43261142015-02-11 15:59:44 +0000782 * Called when a device is exiting lock task mode.
Jason Monk48aacba2014-08-13 16:29:08 -0400783 *
784 * @param context The running context as per {@link #onReceive}.
785 * @param intent The received intent as per {@link #onReceive}.
786 */
Rubin Xu72623f62019-03-11 14:51:56 +0000787 public void onLockTaskModeExiting(@NonNull Context context, @NonNull Intent intent) {
Jason Monk35c62a42014-06-17 10:24:47 -0400788 }
789
790 /**
Robin Lee3798ed52015-02-03 17:55:31 +0000791 * 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 Xu72623f62019-03-11 14:51:56 +0000797 * @param uid The uid of the app asking for the private key and certificate pair.
Robin Lee39087b12015-05-05 15:57:17 +0100798 * @param uri The URI to authenticate, may be null.
Robin Lee3798ed52015-02-03 17:55:31 +0000799 * @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 Xu72623f62019-03-11 14:51:56 +0000803 public @Nullable String onChoosePrivateKeyAlias(@NonNull Context context,
804 @NonNull Intent intent, int uid, @Nullable Uri uri, @Nullable String alias) {
Robin Lee3798ed52015-02-03 17:55:31 +0000805 return null;
806 }
807
808 /**
Charles Hedea0c3b2017-01-13 10:04:12 +0000809 * 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 Xudc105cc2015-04-14 23:38:01 +0100812 * 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 Hedea0c3b2017-01-13 10:04:12 +0000815 *
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 Xudc105cc2015-04-14 23:38:01 +0100821 *
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 Hedea0c3b2017-01-13 10:04:12 +0000826 * @see DevicePolicyManager#getPendingSystemUpdate
Rubin Xudc105cc2015-04-14 23:38:01 +0100827 */
Rubin Xu72623f62019-03-11 14:51:56 +0000828 public void onSystemUpdatePending(@NonNull Context context, @NonNull Intent intent,
829 long receivedTime) {
Rubin Xudc105cc2015-04-14 23:38:01 +0100830 }
831
832 /**
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000833 * 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 Xu72623f62019-03-11 14:51:56 +0000841 public void onBugreportSharingDeclined(@NonNull Context context, @NonNull Intent intent) {
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000842 }
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 Xu72623f62019-03-11 14:51:56 +0000856 public void onBugreportShared(@NonNull Context context, @NonNull Intent intent,
857 @NonNull String bugreportHash) {
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000858 }
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 Karpinski37cfe712016-03-11 14:00:13 +0000868 * {@link #BUGREPORT_FAILURE_FAILED_COMPLETING}
869 * or {@link #BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE}
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000870 * @see DevicePolicyManager#requestBugreport
871 */
Rubin Xu72623f62019-03-11 14:51:56 +0000872 public void onBugreportFailed(@NonNull Context context, @NonNull Intent intent,
Michal Karpinski3fc437e2015-12-15 10:09:00 +0000873 @BugreportFailureCode int failureCode) {
874 }
875
876 /**
Michal Karpinski6235a942016-03-15 12:07:23 +0000877 * Called when a new batch of security logs can be retrieved.
Rubin Xuc3cd05f2016-01-11 12:11:35 +0000878 *
Esteban Talaverad36dd152016-12-15 08:51:45 +0000879 * <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 Grafov9cdba272017-03-07 12:48:00 +0000883 * <p>This callback will be re-triggered if the logs are not retrieved.
884 *
Rubin Xuc3cd05f2016-01-11 12:11:35 +0000885 * <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 Karpinski6235a942016-03-15 12:07:23 +0000889 * @see DevicePolicyManager#retrieveSecurityLogs(ComponentName)
Rubin Xuc3cd05f2016-01-11 12:11:35 +0000890 */
Rubin Xu72623f62019-03-11 14:51:56 +0000891 public void onSecurityLogsAvailable(@NonNull Context context, @NonNull Intent intent) {
Rubin Xuc3cd05f2016-01-11 12:11:35 +0000892 }
893
894 /**
Michal Karpinskia9ff2062016-11-03 15:46:17 +0000895 * 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 Karpinskif77ee4f2016-10-12 16:40:06 +0100897 * logging is enabled.
898 *
Esteban Talaverad36dd152016-12-15 08:51:45 +0000899 * <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 Karpinskif77ee4f2016-10-12 16:40:06 +0100904 * <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 Karpinskia9ff2062016-11-03 15:46:17 +0000908 * @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 Talaverad36dd152016-12-15 08:51:45 +0000910 * @see DevicePolicyManager#retrieveNetworkLogs
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100911 */
Rubin Xu72623f62019-03-11 14:51:56 +0000912 public void onNetworkLogsAvailable(@NonNull Context context, @NonNull Intent intent,
913 long batchToken, @IntRange(from = 1) int networkLogsCount) {
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100914 }
915
Alex Chaub12e6722018-02-12 15:42:10 +0800916 /**
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 Xu72623f62019-03-11 14:51:56 +0000925 public void onUserAdded(@NonNull Context context, @NonNull Intent intent,
926 @NonNull UserHandle newUser) {
Alex Chaub12e6722018-02-12 15:42:10 +0800927 }
Nicolas Prevote95c2812016-11-17 17:30:55 +0000928
Alex Chaub12e6722018-02-12 15:42:10 +0800929 /**
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 Xu72623f62019-03-11 14:51:56 +0000938 public void onUserRemoved(@NonNull Context context, @NonNull Intent intent,
939 @NonNull UserHandle removedUser) {
Alex Chaub12e6722018-02-12 15:42:10 +0800940 }
Nicolas Prevote95c2812016-11-17 17:30:55 +0000941
Michal Karpinskif77ee4f2016-10-12 16:40:06 +0100942 /**
Alex Chau2c082aee2018-01-17 18:26:03 +0000943 * 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 Xu72623f62019-03-11 14:51:56 +0000951 public void onUserStarted(@NonNull Context context, @NonNull Intent intent,
952 @NonNull UserHandle startedUser) {
Alex Chau2c082aee2018-01-17 18:26:03 +0000953 }
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 Xu72623f62019-03-11 14:51:56 +0000964 public void onUserStopped(@NonNull Context context, @NonNull Intent intent,
965 @NonNull UserHandle stoppedUser) {
Alex Chau2c082aee2018-01-17 18:26:03 +0000966 }
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 Xu72623f62019-03-11 14:51:56 +0000977 public void onUserSwitched(@NonNull Context context, @NonNull Intent intent,
978 @NonNull UserHandle switchedUser) {
Alex Chau2c082aee2018-01-17 18:26:03 +0000979 }
980
981 /**
arangelov8bae4ea2017-12-20 20:26:46 +0000982 * 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 /**
arangelovb46faf32018-01-17 21:27:40 +0000996 * 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 Xu72623f62019-03-11 14:51:56 +00001012 public void onTransferAffiliatedProfileOwnershipComplete(@NonNull Context context,
1013 @NonNull UserHandle user) {
arangelovb46faf32018-01-17 21:27:40 +00001014 }
1015
1016 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -08001017 * 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 Xu72623f62019-03-11 14:51:56 +00001022 public void onReceive(@NonNull Context context, @NonNull Intent intent) {
Dianne Hackbornd6847842010-01-12 18:14:19 -08001023 String action = intent.getAction();
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +00001024
Dianne Hackbornd6847842010-01-12 18:14:19 -08001025 if (ACTION_PASSWORD_CHANGED.equals(action)) {
Robin Leed2a73ed2016-12-19 09:07:16 +00001026 onPasswordChanged(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER));
Dianne Hackbornd6847842010-01-12 18:14:19 -08001027 } else if (ACTION_PASSWORD_FAILED.equals(action)) {
Robin Leed2a73ed2016-12-19 09:07:16 +00001028 onPasswordFailed(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER));
Dianne Hackbornd6847842010-01-12 18:14:19 -08001029 } else if (ACTION_PASSWORD_SUCCEEDED.equals(action)) {
Robin Leed2a73ed2016-12-19 09:07:16 +00001030 onPasswordSucceeded(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER));
Dianne Hackbornd6847842010-01-12 18:14:19 -08001031 } else if (ACTION_DEVICE_ADMIN_ENABLED.equals(action)) {
1032 onEnabled(context, intent);
Dianne Hackborn8ea138c2010-01-26 18:01:04 -08001033 } 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 Hackbornd6847842010-01-12 18:14:19 -08001039 } else if (ACTION_DEVICE_ADMIN_DISABLED.equals(action)) {
1040 onDisabled(context, intent);
Jim Millera4e28d12010-11-08 16:15:47 -08001041 } else if (ACTION_PASSWORD_EXPIRING.equals(action)) {
Robin Leed2a73ed2016-12-19 09:07:16 +00001042 onPasswordExpiring(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER));
Jessica Hummel8cdb6fc2014-03-03 14:14:51 +00001043 } else if (ACTION_PROFILE_PROVISIONING_COMPLETE.equals(action)) {
1044 onProfileProvisioningComplete(context, intent);
Robin Lee3798ed52015-02-03 17:55:31 +00001045 } else if (ACTION_CHOOSE_PRIVATE_KEY_ALIAS.equals(action)) {
Robin Leeabf35702015-02-17 14:12:48 +00001046 int uid = intent.getIntExtra(EXTRA_CHOOSE_PRIVATE_KEY_SENDER_UID, -1);
Robin Lee39087b12015-05-05 15:57:17 +01001047 Uri uri = intent.getParcelableExtra(EXTRA_CHOOSE_PRIVATE_KEY_URI);
Robin Lee3798ed52015-02-03 17:55:31 +00001048 String alias = intent.getStringExtra(EXTRA_CHOOSE_PRIVATE_KEY_ALIAS);
Robin Lee39087b12015-05-05 15:57:17 +01001049 String chosenAlias = onChoosePrivateKeyAlias(context, intent, uid, uri, alias);
Robin Lee3798ed52015-02-03 17:55:31 +00001050 setResultData(chosenAlias);
Jason Monk48aacba2014-08-13 16:29:08 -04001051 } else if (ACTION_LOCK_TASK_ENTERING.equals(action)) {
Jason Monk35c62a42014-06-17 10:24:47 -04001052 String pkg = intent.getStringExtra(EXTRA_LOCK_TASK_PACKAGE);
Jason Monk48aacba2014-08-13 16:29:08 -04001053 onLockTaskModeEntering(context, intent, pkg);
1054 } else if (ACTION_LOCK_TASK_EXITING.equals(action)) {
1055 onLockTaskModeExiting(context, intent);
Rubin Xudc105cc2015-04-14 23:38:01 +01001056 } 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 Karpinski3fc437e2015-12-15 10:09:00 +00001059 } 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 Xuc3cd05f2016-01-11 12:11:35 +00001068 } else if (ACTION_SECURITY_LOGS_AVAILABLE.equals(action)) {
1069 onSecurityLogsAvailable(context, intent);
Michal Karpinskif77ee4f2016-10-12 16:40:06 +01001070 } else if (ACTION_NETWORK_LOGS_AVAILABLE.equals(action)) {
Michal Karpinskia9ff2062016-11-03 15:46:17 +00001071 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 Prevote95c2812016-11-17 17:30:55 +00001074 } 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 Chau2c082aee2018-01-17 18:26:03 +00001078 } 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));
arangelov8bae4ea2017-12-20 20:26:46 +00001084 } else if (ACTION_TRANSFER_OWNERSHIP_COMPLETE.equals(action)) {
1085 PersistableBundle bundle =
arangelov91201bd2018-01-04 17:10:21 +00001086 intent.getParcelableExtra(EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE);
arangelov8bae4ea2017-12-20 20:26:46 +00001087 onTransferOwnershipComplete(context, bundle);
arangelovb46faf32018-01-17 21:27:40 +00001088 } else if (ACTION_AFFILIATED_PROFILE_TRANSFER_OWNERSHIP_COMPLETE.equals(action)) {
1089 onTransferAffiliatedProfileOwnershipComplete(context,
1090 intent.getParcelableExtra(Intent.EXTRA_USER));
Dianne Hackbornd6847842010-01-12 18:14:19 -08001091 }
1092 }
1093}