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