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 | |
Nicolas Prevot | 8f7698a | 2016-02-11 16:05:33 +0000 | [diff] [blame] | 19 | import android.annotation.ColorInt; |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 20 | import android.annotation.IntDef; |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 21 | import android.annotation.NonNull; |
| 22 | import android.annotation.Nullable; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 23 | import android.annotation.SdkConstant; |
| 24 | import android.annotation.SdkConstant.SdkConstantType; |
Justin Morey | b5deda7 | 2014-07-24 10:53:40 -0500 | [diff] [blame] | 25 | import android.annotation.SystemApi; |
Nicolas Prevot | 8f7698a | 2016-02-11 16:05:33 +0000 | [diff] [blame] | 26 | import android.annotation.UserIdInt; |
Fyodor Kupolov | 4e9af06 | 2016-07-18 16:59:11 -0700 | [diff] [blame] | 27 | import android.annotation.WorkerThread; |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 28 | import android.app.Activity; |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 29 | import android.app.admin.NetworkEvent; |
Andrew Scull | 5f9e6f3 | 2016-08-02 14:22:17 +0100 | [diff] [blame] | 30 | import android.app.admin.PasswordMetrics; |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 31 | import android.app.admin.SecurityLog.SecurityEvent; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 32 | import android.content.ComponentName; |
| 33 | import android.content.Context; |
Adam Connors | 010cfd4 | 2014-04-16 12:48:13 +0100 | [diff] [blame] | 34 | import android.content.Intent; |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 35 | import android.content.IntentFilter; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 36 | import android.content.pm.PackageManager; |
Victor Chang | cd14c0a | 2016-03-16 19:10:15 +0000 | [diff] [blame] | 37 | import android.content.pm.PackageManager.NameNotFoundException; |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 38 | import android.content.pm.ParceledListSlice; |
Sudheer Shanka | 978fc0d | 2016-01-28 13:51:10 +0000 | [diff] [blame] | 39 | import android.content.pm.UserInfo; |
Julia Reynolds | fca04ca | 2015-02-17 13:39:12 -0500 | [diff] [blame] | 40 | import android.graphics.Bitmap; |
Jason Monk | 03bc991 | 2014-05-13 09:44:57 -0400 | [diff] [blame] | 41 | import android.net.ProxyInfo; |
Nicolas Prevot | 8b7991c | 2015-11-12 17:40:12 +0000 | [diff] [blame] | 42 | import android.net.Uri; |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 43 | import android.os.Bundle; |
Jim Miller | e303bf4 | 2014-08-26 17:12:29 -0700 | [diff] [blame] | 44 | import android.os.PersistableBundle; |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 45 | import android.os.Process; |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 46 | import android.os.RemoteCallback; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 47 | import android.os.RemoteException; |
| 48 | import android.os.ServiceManager; |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 49 | import android.os.UserHandle; |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 50 | import android.os.UserManager; |
Jeff Sharkey | 49ca529 | 2016-05-10 12:54:45 -0600 | [diff] [blame] | 51 | import android.os.ServiceManager.ServiceNotFoundException; |
Ricky Wai | 494b95d | 2015-11-20 16:07:15 +0000 | [diff] [blame] | 52 | import android.provider.ContactsContract.Directory; |
Mahaver Chopra | 1ce53bc | 2015-12-14 13:35:14 +0000 | [diff] [blame] | 53 | import android.provider.Settings; |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 54 | import android.security.Credentials; |
Amith Yamasani | d1d7c02 | 2014-08-19 17:03:41 -0700 | [diff] [blame] | 55 | import android.service.restrictions.RestrictionsReceiver; |
Mahaver Chopra | 1216ae5 | 2016-03-11 15:39:48 +0000 | [diff] [blame] | 56 | import android.telephony.TelephonyManager; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 57 | import android.util.Log; |
| 58 | |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 59 | import com.android.internal.annotations.VisibleForTesting; |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 60 | import com.android.org.conscrypt.TrustedCertificateStore; |
| 61 | |
| 62 | import java.io.ByteArrayInputStream; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 63 | import java.io.IOException; |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 64 | import java.lang.annotation.Retention; |
| 65 | import java.lang.annotation.RetentionPolicy; |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 66 | import java.net.InetSocketAddress; |
| 67 | import java.net.Proxy; |
Robin Lee | 0d5ccb7 | 2014-09-12 17:41:44 +0100 | [diff] [blame] | 68 | import java.security.KeyFactory; |
Mahaver Chopra | 1ce53bc | 2015-12-14 13:35:14 +0000 | [diff] [blame] | 69 | import java.security.NoSuchAlgorithmException; |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 70 | import java.security.PrivateKey; |
| 71 | import java.security.cert.Certificate; |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 72 | import java.security.cert.CertificateException; |
| 73 | import java.security.cert.CertificateFactory; |
| 74 | import java.security.cert.X509Certificate; |
Robin Lee | 0d5ccb7 | 2014-09-12 17:41:44 +0100 | [diff] [blame] | 75 | import java.security.spec.InvalidKeySpecException; |
Mahaver Chopra | 1ce53bc | 2015-12-14 13:35:14 +0000 | [diff] [blame] | 76 | import java.security.spec.PKCS8EncodedKeySpec; |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 77 | import java.util.ArrayList; |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 78 | import java.util.Arrays; |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 79 | import java.util.Collections; |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 80 | import java.util.List; |
Bartosz Fabianowski | 4c052f2 | 2016-01-25 14:18:43 +0100 | [diff] [blame] | 81 | import java.util.Set; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 82 | |
| 83 | /** |
Alexandra Gherghina | 541afcd | 2014-11-07 11:18:12 +0000 | [diff] [blame] | 84 | * Public interface for managing policies enforced on a device. Most clients of this class must be |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 85 | * registered with the system as a <a href="{@docRoot}guide/topics/admin/device-admin.html">device |
| 86 | * administrator</a>. Additionally, a device administrator may be registered as either a profile or |
| 87 | * device owner. A given method is accessible to all device administrators unless the documentation |
| 88 | * for that method specifies that it is restricted to either device or profile owners. Any |
| 89 | * application calling an api may only pass as an argument a device administrator component it |
| 90 | * owns. Otherwise, a {@link SecurityException} will be thrown. |
Joe Fernandez | 3aef8e1d | 2011-12-20 10:38:34 -0800 | [diff] [blame] | 91 | * <div class="special reference"> |
| 92 | * <h3>Developer Guides</h3> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 93 | * <p> |
| 94 | * For more information about managing policies for device administration, read the <a href= |
| 95 | * "{@docRoot}guide/topics/admin/device-admin.html">Device Administration</a> developer |
| 96 | * guide. </div> |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 97 | */ |
| 98 | public class DevicePolicyManager { |
| 99 | private static String TAG = "DevicePolicyManager"; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 100 | |
| 101 | private final Context mContext; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 102 | private final IDevicePolicyManager mService; |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 103 | private final boolean mParentInstance; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 104 | |
Jeff Sharkey | 49ca529 | 2016-05-10 12:54:45 -0600 | [diff] [blame] | 105 | /** @hide */ |
| 106 | public DevicePolicyManager(Context context, IDevicePolicyManager service) { |
| 107 | this(context, service, false); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 108 | } |
| 109 | |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 110 | /** @hide */ |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 111 | @VisibleForTesting |
Jeff Sharkey | 49ca529 | 2016-05-10 12:54:45 -0600 | [diff] [blame] | 112 | protected DevicePolicyManager(Context context, IDevicePolicyManager service, |
| 113 | boolean parentInstance) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 114 | mContext = context; |
| 115 | mService = service; |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 116 | mParentInstance = parentInstance; |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 119 | /** @hide test will override it. */ |
| 120 | @VisibleForTesting |
| 121 | protected int myUserId() { |
| 122 | return UserHandle.myUserId(); |
| 123 | } |
| 124 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 125 | /** |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 126 | * Activity action: Starts the provisioning flow which sets up a managed profile. |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 127 | * |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 128 | * <p>A managed profile allows data separation for example for the usage of a |
| 129 | * device as a personal and corporate device. The user which provisioning is started from and |
| 130 | * the managed profile share a launcher. |
| 131 | * |
Andrew Solovay | 27f5337 | 2015-03-02 16:37:59 -0800 | [diff] [blame] | 132 | * <p>This intent will typically be sent by a mobile device management application (MDM). |
| 133 | * Provisioning adds a managed profile and sets the MDM as the profile owner who has full |
| 134 | * control over the profile. |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 135 | * |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 136 | * <p>It is possible to check if provisioning is allowed or not by querying the method |
| 137 | * {@link #isProvisioningAllowed(String)}. |
| 138 | * |
| 139 | * <p>In version {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this intent must contain the |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 140 | * extra {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME}. |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 141 | * As of {@link android.os.Build.VERSION_CODES#M}, it should contain the extra |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 142 | * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME} instead, although specifying only |
| 143 | * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME} is still supported. |
Nicolas Prevot | caf11cd | 2015-11-19 10:58:35 +0000 | [diff] [blame] | 144 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 145 | * <p>The intent may also contain the following extras: |
Nicolas Prevot | caf11cd | 2015-11-19 10:58:35 +0000 | [diff] [blame] | 146 | * <ul> |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 147 | * <li>{@link #EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE}, optional </li> |
| 148 | * <li>{@link #EXTRA_PROVISIONING_SKIP_ENCRYPTION}, optional, supported from |
| 149 | * {@link android.os.Build.VERSION_CODES#N}</li> |
| 150 | * <li>{@link #EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}, optional</li> |
| 151 | * <li>{@link #EXTRA_PROVISIONING_LOGO_URI}, optional</li> |
| 152 | * <li>{@link #EXTRA_PROVISIONING_MAIN_COLOR}, optional</li> |
Nicolas Prevot | caf11cd | 2015-11-19 10:58:35 +0000 | [diff] [blame] | 153 | * </ul> |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 154 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 155 | * <p>When managed provisioning has completed, broadcasts are sent to the application specified |
Alexandra Gherghina | db4bc57 | 2015-01-08 12:17:40 +0000 | [diff] [blame] | 156 | * in the provisioning intent. The |
| 157 | * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE} broadcast is sent in the |
| 158 | * managed profile and the {@link #ACTION_MANAGED_PROFILE_PROVISIONED} broadcast is sent in |
| 159 | * the primary profile. |
Jessica Hummel | 9da6039 | 2014-05-21 12:32:57 +0100 | [diff] [blame] | 160 | * |
Mahaver Chopra | 3c58cfe | 2016-11-01 21:25:59 +0000 | [diff] [blame^] | 161 | * <p>From version {@link android.os.Build.VERSION_CODES#O}, when managed provisioning has |
| 162 | * completed, along with the above broadcast, activity intent |
| 163 | * {@link #ACTION_PROVISIONING_SUCCESSFUL} will also be sent to the application specified in |
| 164 | * the provisioning intent. |
| 165 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 166 | * <p>If provisioning fails, the managedProfile is removed so the device returns to its |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 167 | * previous state. |
Alan Treadway | 4582f81 | 2015-07-28 11:49:35 +0100 | [diff] [blame] | 168 | * |
| 169 | * <p>If launched with {@link android.app.Activity#startActivityForResult(Intent, int)} a |
| 170 | * result code of {@link android.app.Activity#RESULT_OK} implies that the synchronous part of |
| 171 | * the provisioning flow was successful, although this doesn't guarantee the full flow will |
| 172 | * succeed. Conversely a result code of {@link android.app.Activity#RESULT_CANCELED} implies |
| 173 | * that the user backed-out of provisioning, or some precondition for provisioning wasn't met. |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 174 | */ |
| 175 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 176 | public static final String ACTION_PROVISION_MANAGED_PROFILE |
Esteban Talavera | ef9c523 | 2014-09-08 13:51:18 +0100 | [diff] [blame] | 177 | = "android.app.action.PROVISION_MANAGED_PROFILE"; |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 178 | |
| 179 | /** |
Mahaver Chopra | 7830daa | 2015-11-10 18:12:43 +0000 | [diff] [blame] | 180 | * Activity action: Starts the provisioning flow which sets up a managed user. |
| 181 | * |
| 182 | * <p>This intent will typically be sent by a mobile device management application (MDM). |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 183 | * Provisioning configures the user as managed user and sets the MDM as the profile |
Mahaver Chopra | 7830daa | 2015-11-10 18:12:43 +0000 | [diff] [blame] | 184 | * owner who has full control over the user. Provisioning can only happen before user setup has |
| 185 | * been completed. Use {@link #isProvisioningAllowed(String)} to check if provisioning is |
| 186 | * allowed. |
| 187 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 188 | * <p>The intent contains the following extras: |
| 189 | * <ul> |
| 190 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME}</li> |
| 191 | * <li>{@link #EXTRA_PROVISIONING_SKIP_ENCRYPTION}, optional</li> |
| 192 | * <li>{@link #EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}, optional</li> |
| 193 | * <li>{@link #EXTRA_PROVISIONING_LOGO_URI}, optional</li> |
| 194 | * <li>{@link #EXTRA_PROVISIONING_MAIN_COLOR}, optional</li> |
| 195 | * </ul> |
Mahaver Chopra | 7830daa | 2015-11-10 18:12:43 +0000 | [diff] [blame] | 196 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 197 | * <p>If provisioning fails, the device returns to its previous state. |
Mahaver Chopra | 7830daa | 2015-11-10 18:12:43 +0000 | [diff] [blame] | 198 | * |
| 199 | * <p>If launched with {@link android.app.Activity#startActivityForResult(Intent, int)} a |
| 200 | * result code of {@link android.app.Activity#RESULT_OK} implies that the synchronous part of |
| 201 | * the provisioning flow was successful, although this doesn't guarantee the full flow will |
| 202 | * succeed. Conversely a result code of {@link android.app.Activity#RESULT_CANCELED} implies |
| 203 | * that the user backed-out of provisioning, or some precondition for provisioning wasn't met. |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 204 | * |
| 205 | * @hide |
Mahaver Chopra | 5e73256 | 2015-11-05 11:55:12 +0000 | [diff] [blame] | 206 | */ |
| 207 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 208 | public static final String ACTION_PROVISION_MANAGED_USER |
| 209 | = "android.app.action.PROVISION_MANAGED_USER"; |
| 210 | |
| 211 | /** |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 212 | * Activity action: Starts the provisioning flow which sets up a managed device. |
| 213 | * Must be started with {@link android.app.Activity#startActivityForResult(Intent, int)}. |
| 214 | * |
| 215 | * <p> During device owner provisioning a device admin app is set as the owner of the device. |
| 216 | * A device owner has full control over the device. The device owner can not be modified by the |
| 217 | * user. |
| 218 | * |
| 219 | * <p> A typical use case would be a device that is owned by a company, but used by either an |
| 220 | * employee or client. |
| 221 | * |
| 222 | * <p> An intent with this action can be sent only on an unprovisioned device. |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 223 | * It is possible to check if provisioning is allowed or not by querying the method |
| 224 | * {@link #isProvisioningAllowed(String)}. |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 225 | * |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 226 | * <p>The intent contains the following extras: |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 227 | * <ul> |
| 228 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME}</li> |
| 229 | * <li>{@link #EXTRA_PROVISIONING_SKIP_ENCRYPTION}, optional</li> |
| 230 | * <li>{@link #EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED}, optional</li> |
Rubin Xu | a4f9dc1 | 2015-06-12 13:27:59 +0100 | [diff] [blame] | 231 | * <li>{@link #EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}, optional</li> |
Nicolas Prevot | 8b7991c | 2015-11-12 17:40:12 +0000 | [diff] [blame] | 232 | * <li>{@link #EXTRA_PROVISIONING_LOGO_URI}, optional</li> |
Nicolas Prevot | caf11cd | 2015-11-19 10:58:35 +0000 | [diff] [blame] | 233 | * <li>{@link #EXTRA_PROVISIONING_MAIN_COLOR}, optional</li> |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 234 | * </ul> |
| 235 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 236 | * <p>When device owner provisioning has completed, an intent of the type |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 237 | * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE} is broadcast to the |
| 238 | * device owner. |
| 239 | * |
Mahaver Chopra | 3c58cfe | 2016-11-01 21:25:59 +0000 | [diff] [blame^] | 240 | * <p>From version {@link android.os.Build.VERSION_CODES#O}, when device owner provisioning has |
| 241 | * completed, along with the above broadcast, activity intent |
| 242 | * {@link #ACTION_PROVISIONING_SUCCESSFUL} will also be sent to the device owner. |
| 243 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 244 | * <p>If provisioning fails, the device is factory reset. |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 245 | * |
Alan Treadway | 4582f81 | 2015-07-28 11:49:35 +0100 | [diff] [blame] | 246 | * <p>A result code of {@link android.app.Activity#RESULT_OK} implies that the synchronous part |
| 247 | * of the provisioning flow was successful, although this doesn't guarantee the full flow will |
| 248 | * succeed. Conversely a result code of {@link android.app.Activity#RESULT_CANCELED} implies |
| 249 | * that the user backed-out of provisioning, or some precondition for provisioning wasn't met. |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 250 | */ |
| 251 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 252 | public static final String ACTION_PROVISION_MANAGED_DEVICE |
| 253 | = "android.app.action.PROVISION_MANAGED_DEVICE"; |
| 254 | |
| 255 | /** |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 256 | * Activity action: Starts the provisioning flow which sets up a managed device. |
Steven Ng | 980a1b6 | 2016-02-02 17:43:18 +0000 | [diff] [blame] | 257 | * |
| 258 | * <p>During device owner provisioning, a device admin app is downloaded and set as the owner of |
| 259 | * the device. A device owner has full control over the device. The device owner can not be |
| 260 | * modified by the user and the only way of resetting the device is via factory reset. |
| 261 | * |
| 262 | * <p>A typical use case would be a device that is owned by a company, but used by either an |
| 263 | * employee or client. |
| 264 | * |
| 265 | * <p>The provisioning message should be sent to an unprovisioned device. |
| 266 | * |
| 267 | * <p>Unlike {@link #ACTION_PROVISION_MANAGED_DEVICE}, the provisioning message can only be sent |
| 268 | * by a privileged app with the permission |
| 269 | * {@link android.Manifest.permission#DISPATCH_PROVISIONING_MESSAGE}. |
| 270 | * |
| 271 | * <p>The provisioning intent contains the following properties: |
| 272 | * <ul> |
| 273 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME}</li> |
| 274 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION}, optional</li> |
| 275 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER}, optional</li> |
| 276 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM}, optional</li> |
| 277 | * <li>{@link #EXTRA_PROVISIONING_LOCAL_TIME} (convert to String), optional</li> |
| 278 | * <li>{@link #EXTRA_PROVISIONING_TIME_ZONE}, optional</li> |
| 279 | * <li>{@link #EXTRA_PROVISIONING_LOCALE}, optional</li> |
| 280 | * <li>{@link #EXTRA_PROVISIONING_WIFI_SSID}, optional</li> |
| 281 | * <li>{@link #EXTRA_PROVISIONING_WIFI_HIDDEN} (convert to String), optional</li> |
| 282 | * <li>{@link #EXTRA_PROVISIONING_WIFI_SECURITY_TYPE}, optional</li> |
| 283 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PASSWORD}, optional</li> |
| 284 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PROXY_HOST}, optional</li> |
| 285 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PROXY_PORT} (convert to String), optional</li> |
| 286 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PROXY_BYPASS}, optional</li> |
| 287 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PAC_URL}, optional</li> |
| 288 | * <li>{@link #EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}, optional</li></ul> |
| 289 | * |
| 290 | * @hide |
| 291 | */ |
| 292 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 293 | @SystemApi |
| 294 | public static final String ACTION_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE = |
| 295 | "android.app.action.PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE"; |
| 296 | |
| 297 | /** |
| 298 | * Activity action: Starts the provisioning flow which sets up a managed device. |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 299 | * Must be started with {@link android.app.Activity#startActivityForResult(Intent, int)}. |
| 300 | * |
| 301 | * <p>NOTE: This is only supported on split system user devices, and puts the device into a |
| 302 | * management state that is distinct from that reached by |
| 303 | * {@link #ACTION_PROVISION_MANAGED_DEVICE} - specifically the device owner runs on the system |
| 304 | * user, and only has control over device-wide policies, not individual users and their data. |
| 305 | * The primary benefit is that multiple non-system users are supported when provisioning using |
| 306 | * this form of device management. |
| 307 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 308 | * <p>During device owner provisioning a device admin app is set as the owner of the device. |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 309 | * A device owner has full control over the device. The device owner can not be modified by the |
| 310 | * user. |
| 311 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 312 | * <p>A typical use case would be a device that is owned by a company, but used by either an |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 313 | * employee or client. |
| 314 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 315 | * <p>An intent with this action can be sent only on an unprovisioned device. |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 316 | * It is possible to check if provisioning is allowed or not by querying the method |
| 317 | * {@link #isProvisioningAllowed(String)}. |
| 318 | * |
| 319 | * <p>The intent contains the following extras: |
| 320 | * <ul> |
| 321 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME}</li> |
| 322 | * <li>{@link #EXTRA_PROVISIONING_SKIP_ENCRYPTION}, optional</li> |
| 323 | * <li>{@link #EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED}, optional</li> |
| 324 | * <li>{@link #EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}, optional</li> |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 325 | * <li>{@link #EXTRA_PROVISIONING_LOGO_URI}, optional</li> |
| 326 | * <li>{@link #EXTRA_PROVISIONING_MAIN_COLOR}, optional</li> |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 327 | * </ul> |
| 328 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 329 | * <p>When device owner provisioning has completed, an intent of the type |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 330 | * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE} is broadcast to the |
| 331 | * device owner. |
| 332 | * |
Mahaver Chopra | 3c58cfe | 2016-11-01 21:25:59 +0000 | [diff] [blame^] | 333 | * <p>From version {@link android.os.Build.VERSION_CODES#O}, when device owner provisioning has |
| 334 | * completed, along with the above broadcast, activity intent |
| 335 | * {@link #ACTION_PROVISIONING_SUCCESSFUL} will also be sent to the device owner. |
| 336 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 337 | * <p>If provisioning fails, the device is factory reset. |
Alan Treadway | 46dd449 | 2015-11-09 13:57:19 +0000 | [diff] [blame] | 338 | * |
| 339 | * <p>A result code of {@link android.app.Activity#RESULT_OK} implies that the synchronous part |
| 340 | * of the provisioning flow was successful, although this doesn't guarantee the full flow will |
| 341 | * succeed. Conversely a result code of {@link android.app.Activity#RESULT_CANCELED} implies |
| 342 | * that the user backed-out of provisioning, or some precondition for provisioning wasn't met. |
| 343 | * |
| 344 | * @hide |
| 345 | */ |
| 346 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 347 | public static final String ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE |
| 348 | = "android.app.action.PROVISION_MANAGED_SHAREABLE_DEVICE"; |
| 349 | |
| 350 | /** |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 351 | * Activity action: Finalizes management provisioning, should be used after user-setup |
| 352 | * has been completed and {@link #getUserProvisioningState()} returns one of: |
| 353 | * <ul> |
| 354 | * <li>{@link #STATE_USER_SETUP_INCOMPLETE}</li> |
| 355 | * <li>{@link #STATE_USER_SETUP_COMPLETE}</li> |
| 356 | * <li>{@link #STATE_USER_PROFILE_COMPLETE}</li> |
| 357 | * </ul> |
| 358 | * |
| 359 | * @hide |
| 360 | */ |
Benjamin Franz | eed2a8e | 2016-02-19 14:19:05 +0000 | [diff] [blame] | 361 | @SystemApi |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 362 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 363 | public static final String ACTION_PROVISION_FINALIZATION |
| 364 | = "android.app.action.PROVISION_FINALIZATION"; |
| 365 | |
| 366 | /** |
Michal Karpinski | ba24409 | 2016-02-25 17:28:24 +0000 | [diff] [blame] | 367 | * Action: Bugreport sharing with device owner has been accepted by the user. |
| 368 | * |
| 369 | * @hide |
| 370 | */ |
| 371 | public static final String ACTION_BUGREPORT_SHARING_ACCEPTED = |
| 372 | "com.android.server.action.BUGREPORT_SHARING_ACCEPTED"; |
| 373 | |
| 374 | /** |
| 375 | * Action: Bugreport sharing with device owner has been declined by the user. |
| 376 | * |
| 377 | * @hide |
| 378 | */ |
| 379 | public static final String ACTION_BUGREPORT_SHARING_DECLINED = |
| 380 | "com.android.server.action.BUGREPORT_SHARING_DECLINED"; |
| 381 | |
| 382 | /** |
| 383 | * Action: Bugreport has been collected and is dispatched to {@link DevicePolicyManagerService}. |
| 384 | * |
| 385 | * @hide |
| 386 | */ |
| 387 | public static final String ACTION_REMOTE_BUGREPORT_DISPATCH = |
| 388 | "android.intent.action.REMOTE_BUGREPORT_DISPATCH"; |
| 389 | |
| 390 | /** |
| 391 | * Extra for shared bugreport's SHA-256 hash. |
| 392 | * |
| 393 | * @hide |
| 394 | */ |
| 395 | public static final String EXTRA_REMOTE_BUGREPORT_HASH = |
| 396 | "android.intent.extra.REMOTE_BUGREPORT_HASH"; |
| 397 | |
| 398 | /** |
| 399 | * Extra for remote bugreport notification shown type. |
| 400 | * |
| 401 | * @hide |
| 402 | */ |
| 403 | public static final String EXTRA_BUGREPORT_NOTIFICATION_TYPE = |
| 404 | "android.app.extra.bugreport_notification_type"; |
| 405 | |
| 406 | /** |
| 407 | * Notification type for a started remote bugreport flow. |
| 408 | * |
| 409 | * @hide |
| 410 | */ |
| 411 | public static final int NOTIFICATION_BUGREPORT_STARTED = 1; |
| 412 | |
| 413 | /** |
| 414 | * Notification type for a bugreport that has already been accepted to be shared, but is still |
| 415 | * being taken. |
| 416 | * |
| 417 | * @hide |
| 418 | */ |
| 419 | public static final int NOTIFICATION_BUGREPORT_ACCEPTED_NOT_FINISHED = 2; |
| 420 | |
| 421 | /** |
| 422 | * Notification type for a bugreport that has been taken and can be shared or declined. |
| 423 | * |
| 424 | * @hide |
| 425 | */ |
| 426 | public static final int NOTIFICATION_BUGREPORT_FINISHED_NOT_ACCEPTED = 3; |
| 427 | |
| 428 | /** |
Michal Karpinski | 8f010dd | 2016-06-21 15:05:53 +0100 | [diff] [blame] | 429 | * Default and maximum timeout in milliseconds after which unlocking with weak auth times out, |
| 430 | * i.e. the user has to use a strong authentication method like password, PIN or pattern. |
| 431 | * |
| 432 | * @hide |
| 433 | */ |
| 434 | public static final long DEFAULT_STRONG_AUTH_TIMEOUT_MS = 72 * 60 * 60 * 1000; // 72h |
| 435 | |
| 436 | /** |
Rubin Xu | a4f9dc1 | 2015-06-12 13:27:59 +0100 | [diff] [blame] | 437 | * A {@link android.os.Parcelable} extra of type {@link android.os.PersistableBundle} that |
Rubin Xu | 41f2ccb9 | 2015-08-05 16:29:13 +0100 | [diff] [blame] | 438 | * allows a mobile device management application or NFC programmer application which starts |
| 439 | * managed provisioning to pass data to the management application instance after provisioning. |
Rubin Xu | a4f9dc1 | 2015-06-12 13:27:59 +0100 | [diff] [blame] | 440 | * <p> |
| 441 | * If used with {@link #ACTION_PROVISION_MANAGED_PROFILE} it can be used by the application that |
| 442 | * sends the intent to pass data to itself on the newly created profile. |
| 443 | * If used with {@link #ACTION_PROVISION_MANAGED_DEVICE} it allows passing data to the same |
| 444 | * instance of the app on the primary user. |
Rubin Xu | 41f2ccb9 | 2015-08-05 16:29:13 +0100 | [diff] [blame] | 445 | * Starting from {@link android.os.Build.VERSION_CODES#M}, if used with |
| 446 | * {@link #MIME_TYPE_PROVISIONING_NFC} as part of NFC managed device provisioning, the NFC |
| 447 | * message should contain a stringified {@link java.util.Properties} instance, whose string |
| 448 | * properties will be converted into a {@link android.os.PersistableBundle} and passed to the |
| 449 | * management application after provisioning. |
| 450 | * |
Rubin Xu | a4f9dc1 | 2015-06-12 13:27:59 +0100 | [diff] [blame] | 451 | * <p> |
| 452 | * In both cases the application receives the data in |
Brian Carlstrom | f1fe51b | 2014-09-03 08:55:05 -0700 | [diff] [blame] | 453 | * {@link DeviceAdminReceiver#onProfileProvisioningComplete} via an intent with the action |
| 454 | * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE}. The bundle is not changed |
Rubin Xu | a4f9dc1 | 2015-06-12 13:27:59 +0100 | [diff] [blame] | 455 | * during the managed provisioning. |
Sander Alewijnse | 90f14bf | 2014-08-20 16:22:44 +0100 | [diff] [blame] | 456 | */ |
| 457 | public static final String EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE = |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 458 | "android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE"; |
Sander Alewijnse | 90f14bf | 2014-08-20 16:22:44 +0100 | [diff] [blame] | 459 | |
| 460 | /** |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 461 | * A String extra holding the package name of the mobile device management application that |
| 462 | * will be set as the profile owner or device owner. |
| 463 | * |
| 464 | * <p>If an application starts provisioning directly via an intent with action |
| 465 | * {@link #ACTION_PROVISION_MANAGED_PROFILE} this package has to match the package name of the |
| 466 | * application that started provisioning. The package will be set as profile owner in that case. |
| 467 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 468 | * <p>This package is set as device owner when device owner provisioning is started by an NFC |
| 469 | * message containing an NFC record with MIME type {@link #MIME_TYPE_PROVISIONING_NFC}. |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 470 | * |
| 471 | * <p> When this extra is set, the application must have exactly one device admin receiver. |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 472 | * This receiver will be set as the profile or device owner and active admin. |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 473 | * |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 474 | * @see DeviceAdminReceiver |
| 475 | * @deprecated Use {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME}. This extra is still |
Nicolas Prevot | 8f78d6a | 2015-08-21 11:06:31 +0100 | [diff] [blame] | 476 | * supported, but only if there is only one device admin receiver in the package that requires |
| 477 | * the permission {@link android.Manifest.permission#BIND_DEVICE_ADMIN}. |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 478 | */ |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 479 | @Deprecated |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 480 | public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME |
Esteban Talavera | ef9c523 | 2014-09-08 13:51:18 +0100 | [diff] [blame] | 481 | = "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME"; |
Jessica Hummel | f72078b | 2014-03-06 16:13:12 +0000 | [diff] [blame] | 482 | |
| 483 | /** |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 484 | * A ComponentName extra indicating the device admin receiver of the mobile device management |
| 485 | * application that will be set as the profile owner or device owner and active admin. |
| 486 | * |
| 487 | * <p>If an application starts provisioning directly via an intent with action |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 488 | * {@link #ACTION_PROVISION_MANAGED_PROFILE} or |
| 489 | * {@link #ACTION_PROVISION_MANAGED_DEVICE} the package name of this |
| 490 | * component has to match the package name of the application that started provisioning. |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 491 | * |
| 492 | * <p>This component is set as device owner and active admin when device owner provisioning is |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 493 | * started by an intent with action {@link #ACTION_PROVISION_MANAGED_DEVICE} or by an NFC |
| 494 | * message containing an NFC record with MIME type |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 495 | * {@link #MIME_TYPE_PROVISIONING_NFC}. For the NFC record, the component name must be |
Rubin Xu | 44ef750b | 2015-03-23 16:51:33 +0000 | [diff] [blame] | 496 | * flattened to a string, via {@link ComponentName#flattenToShortString()}. |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 497 | * |
| 498 | * @see DeviceAdminReceiver |
| 499 | */ |
| 500 | public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME |
| 501 | = "android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME"; |
| 502 | |
| 503 | /** |
Alexandra Gherghina | aaf2f3e | 2014-11-13 12:46:15 +0000 | [diff] [blame] | 504 | * An {@link android.accounts.Account} extra holding the account to migrate during managed |
| 505 | * profile provisioning. If the account supplied is present in the primary user, it will be |
| 506 | * copied, along with its credentials to the managed profile and removed from the primary user. |
| 507 | * |
| 508 | * Use with {@link #ACTION_PROVISION_MANAGED_PROFILE}. |
| 509 | */ |
| 510 | |
| 511 | public static final String EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE |
| 512 | = "android.app.extra.PROVISIONING_ACCOUNT_TO_MIGRATE"; |
| 513 | |
| 514 | /** |
Jessica Hummel | e3da790 | 2014-08-20 15:20:11 +0100 | [diff] [blame] | 515 | * A String extra that, holds the email address of the account which a managed profile is |
| 516 | * created for. Used with {@link #ACTION_PROVISION_MANAGED_PROFILE} and |
| 517 | * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE}. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 518 | * |
Sander Alewijnse | 2b338a2 | 2014-09-12 12:28:40 +0100 | [diff] [blame] | 519 | * <p> This extra is part of the {@link #EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}. |
| 520 | * |
Jessica Hummel | e3da790 | 2014-08-20 15:20:11 +0100 | [diff] [blame] | 521 | * <p> If the {@link #ACTION_PROVISION_MANAGED_PROFILE} intent that starts managed provisioning |
| 522 | * contains this extra, it is forwarded in the |
| 523 | * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE} intent to the mobile |
| 524 | * device management application that was set as the profile owner during provisioning. |
| 525 | * It is usually used to avoid that the user has to enter their email address twice. |
Nicolas Prevot | 07ac20b | 2014-05-27 15:37:45 +0100 | [diff] [blame] | 526 | */ |
Sander Alewijnse | 2b338a2 | 2014-09-12 12:28:40 +0100 | [diff] [blame] | 527 | public static final String EXTRA_PROVISIONING_EMAIL_ADDRESS |
| 528 | = "android.app.extra.PROVISIONING_EMAIL_ADDRESS"; |
Nicolas Prevot | 07ac20b | 2014-05-27 15:37:45 +0100 | [diff] [blame] | 529 | |
| 530 | /** |
Nicolas Prevot | cd2d859 | 2015-11-23 13:27:21 +0000 | [diff] [blame] | 531 | * A integer extra indicating the predominant color to show during the provisioning. |
| 532 | * Refer to {@link android.graphics.Color} for how the color is represented. |
Nicolas Prevot | caf11cd | 2015-11-19 10:58:35 +0000 | [diff] [blame] | 533 | * |
| 534 | * <p>Use with {@link #ACTION_PROVISION_MANAGED_PROFILE} or |
| 535 | * {@link #ACTION_PROVISION_MANAGED_DEVICE}. |
| 536 | */ |
| 537 | public static final String EXTRA_PROVISIONING_MAIN_COLOR = |
| 538 | "android.app.extra.PROVISIONING_MAIN_COLOR"; |
| 539 | |
| 540 | /** |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 541 | * A Boolean extra that can be used by the mobile device management application to skip the |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 542 | * disabling of system apps during provisioning when set to {@code true}. |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 543 | * |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 544 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} or an intent with action |
| 545 | * {@link #ACTION_PROVISION_MANAGED_DEVICE} that starts device owner provisioning. |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 546 | */ |
Sander Alewijnse | 5a14425 | 2014-11-18 13:25:04 +0000 | [diff] [blame] | 547 | public static final String EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED = |
| 548 | "android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED"; |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 549 | |
| 550 | /** |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 551 | * A String extra holding the time zone {@link android.app.AlarmManager} that the device |
| 552 | * will be set to. |
| 553 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 554 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 555 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 556 | */ |
| 557 | public static final String EXTRA_PROVISIONING_TIME_ZONE |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 558 | = "android.app.extra.PROVISIONING_TIME_ZONE"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 559 | |
| 560 | /** |
Esteban Talavera | d469a0b | 2014-08-20 13:54:25 +0100 | [diff] [blame] | 561 | * A Long extra holding the wall clock time (in milliseconds) to be set on the device's |
| 562 | * {@link android.app.AlarmManager}. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 563 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 564 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 565 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 566 | */ |
| 567 | public static final String EXTRA_PROVISIONING_LOCAL_TIME |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 568 | = "android.app.extra.PROVISIONING_LOCAL_TIME"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 569 | |
| 570 | /** |
| 571 | * A String extra holding the {@link java.util.Locale} that the device will be set to. |
| 572 | * Format: xx_yy, where xx is the language code, and yy the country code. |
| 573 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 574 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 575 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 576 | */ |
| 577 | public static final String EXTRA_PROVISIONING_LOCALE |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 578 | = "android.app.extra.PROVISIONING_LOCALE"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 579 | |
| 580 | /** |
| 581 | * A String extra holding the ssid of the wifi network that should be used during nfc device |
| 582 | * owner provisioning for downloading the mobile device management application. |
| 583 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 584 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 585 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 586 | */ |
| 587 | public static final String EXTRA_PROVISIONING_WIFI_SSID |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 588 | = "android.app.extra.PROVISIONING_WIFI_SSID"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 589 | |
| 590 | /** |
| 591 | * A boolean extra indicating whether the wifi network in {@link #EXTRA_PROVISIONING_WIFI_SSID} |
| 592 | * is hidden or not. |
| 593 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 594 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 595 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 596 | */ |
| 597 | public static final String EXTRA_PROVISIONING_WIFI_HIDDEN |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 598 | = "android.app.extra.PROVISIONING_WIFI_HIDDEN"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 599 | |
| 600 | /** |
| 601 | * A String extra indicating the security type of the wifi network in |
Mahaver Chopra | 76b08a9 | 2015-10-08 17:58:45 +0100 | [diff] [blame] | 602 | * {@link #EXTRA_PROVISIONING_WIFI_SSID} and could be one of {@code NONE}, {@code WPA} or |
| 603 | * {@code WEP}. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 604 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 605 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 606 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 607 | */ |
| 608 | public static final String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 609 | = "android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 610 | |
| 611 | /** |
| 612 | * A String extra holding the password of the wifi network in |
| 613 | * {@link #EXTRA_PROVISIONING_WIFI_SSID}. |
| 614 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 615 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 616 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 617 | */ |
| 618 | public static final String EXTRA_PROVISIONING_WIFI_PASSWORD |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 619 | = "android.app.extra.PROVISIONING_WIFI_PASSWORD"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 620 | |
| 621 | /** |
| 622 | * A String extra holding the proxy host for the wifi network in |
| 623 | * {@link #EXTRA_PROVISIONING_WIFI_SSID}. |
| 624 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 625 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 626 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 627 | */ |
| 628 | public static final String EXTRA_PROVISIONING_WIFI_PROXY_HOST |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 629 | = "android.app.extra.PROVISIONING_WIFI_PROXY_HOST"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 630 | |
| 631 | /** |
| 632 | * An int extra holding the proxy port for the wifi network in |
| 633 | * {@link #EXTRA_PROVISIONING_WIFI_SSID}. |
| 634 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 635 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 636 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 637 | */ |
| 638 | public static final String EXTRA_PROVISIONING_WIFI_PROXY_PORT |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 639 | = "android.app.extra.PROVISIONING_WIFI_PROXY_PORT"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 640 | |
| 641 | /** |
| 642 | * A String extra holding the proxy bypass for the wifi network in |
| 643 | * {@link #EXTRA_PROVISIONING_WIFI_SSID}. |
| 644 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 645 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 646 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 647 | */ |
| 648 | public static final String EXTRA_PROVISIONING_WIFI_PROXY_BYPASS |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 649 | = "android.app.extra.PROVISIONING_WIFI_PROXY_BYPASS"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 650 | |
| 651 | /** |
| 652 | * A String extra holding the proxy auto-config (PAC) URL for the wifi network in |
| 653 | * {@link #EXTRA_PROVISIONING_WIFI_SSID}. |
| 654 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 655 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 656 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 657 | */ |
| 658 | public static final String EXTRA_PROVISIONING_WIFI_PAC_URL |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 659 | = "android.app.extra.PROVISIONING_WIFI_PAC_URL"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 660 | |
| 661 | /** |
| 662 | * A String extra holding a url that specifies the download location of the device admin |
| 663 | * package. When not provided it is assumed that the device admin package is already installed. |
| 664 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 665 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 666 | * provisioning via an NFC bump. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 667 | */ |
| 668 | public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 669 | = "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 670 | |
| 671 | /** |
Julia Reynolds | c173174 | 2015-03-19 14:56:28 -0400 | [diff] [blame] | 672 | * An int extra holding a minimum required version code for the device admin package. If the |
| 673 | * device admin is already installed on the device, it will only be re-downloaded from |
| 674 | * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION} if the version of the |
| 675 | * installed package is less than this version code. |
| 676 | * |
Craig Lafayette | 3cc72ba | 2015-06-26 11:51:04 -0400 | [diff] [blame] | 677 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
Julia Reynolds | c173174 | 2015-03-19 14:56:28 -0400 | [diff] [blame] | 678 | * provisioning via an NFC bump. |
| 679 | */ |
| 680 | public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE |
| 681 | = "android.app.extra.PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE"; |
| 682 | |
| 683 | /** |
Sander Alewijnse | 681bce9 | 2014-07-24 16:46:26 +0100 | [diff] [blame] | 684 | * A String extra holding a http cookie header which should be used in the http request to the |
| 685 | * url specified in {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION}. |
| 686 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 687 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 688 | * provisioning via an NFC bump. |
Sander Alewijnse | 681bce9 | 2014-07-24 16:46:26 +0100 | [diff] [blame] | 689 | */ |
| 690 | public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 691 | = "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER"; |
Sander Alewijnse | 681bce9 | 2014-07-24 16:46:26 +0100 | [diff] [blame] | 692 | |
| 693 | /** |
Rubin Xu | d92e757 | 2015-05-18 17:01:13 +0100 | [diff] [blame] | 694 | * A String extra holding the URL-safe base64 encoded SHA-256 or SHA-1 hash (see notes below) of |
| 695 | * the file at download location specified in |
| 696 | * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION}. |
Sander Alewijnse | e4f878cb | 2015-04-14 10:49:17 +0100 | [diff] [blame] | 697 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 698 | * <p>Either this extra or {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM} must be |
| 699 | * present. The provided checksum must match the checksum of the file at the download |
Sander Alewijnse | e4f878cb | 2015-04-14 10:49:17 +0100 | [diff] [blame] | 700 | * location. If the checksum doesn't match an error will be shown to the user and the user will |
| 701 | * be asked to factory reset the device. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 702 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 703 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 704 | * provisioning via an NFC bump. |
Rubin Xu | d92e757 | 2015-05-18 17:01:13 +0100 | [diff] [blame] | 705 | * |
| 706 | * <p><strong>Note:</strong> for devices running {@link android.os.Build.VERSION_CODES#LOLLIPOP} |
| 707 | * and {@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1} only SHA-1 hash is supported. |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 708 | * Starting from {@link android.os.Build.VERSION_CODES#M}, this parameter accepts SHA-256 in |
Rubin Xu | d92e757 | 2015-05-18 17:01:13 +0100 | [diff] [blame] | 709 | * addition to SHA-1. Support for SHA-1 is likely to be removed in future OS releases. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 710 | */ |
| 711 | public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM |
Esteban Talavera | 37f0184 | 2014-09-05 10:50:57 +0100 | [diff] [blame] | 712 | = "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM"; |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 713 | |
| 714 | /** |
Rubin Xu | d92e757 | 2015-05-18 17:01:13 +0100 | [diff] [blame] | 715 | * A String extra holding the URL-safe base64 encoded SHA-256 checksum of any signature of the |
Sander Alewijnse | e4f878cb | 2015-04-14 10:49:17 +0100 | [diff] [blame] | 716 | * android package archive at the download location specified in {@link |
| 717 | * #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION}. |
| 718 | * |
Rubin Xu | 5c82d2c | 2015-06-02 09:29:46 +0100 | [diff] [blame] | 719 | * <p>The signatures of an android package archive can be obtained using |
Sander Alewijnse | e4f878cb | 2015-04-14 10:49:17 +0100 | [diff] [blame] | 720 | * {@link android.content.pm.PackageManager#getPackageArchiveInfo} with flag |
| 721 | * {@link android.content.pm.PackageManager#GET_SIGNATURES}. |
| 722 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 723 | * <p>Either this extra or {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM} must be |
| 724 | * present. The provided checksum must match the checksum of any signature of the file at |
Sander Alewijnse | e4f878cb | 2015-04-14 10:49:17 +0100 | [diff] [blame] | 725 | * the download location. If the checksum does not match an error will be shown to the user and |
| 726 | * the user will be asked to factory reset the device. |
| 727 | * |
| 728 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} that starts device owner |
| 729 | * provisioning via an NFC bump. |
| 730 | */ |
Rubin Xu | 5c82d2c | 2015-06-02 09:29:46 +0100 | [diff] [blame] | 731 | public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM |
| 732 | = "android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM"; |
Sander Alewijnse | e4f878cb | 2015-04-14 10:49:17 +0100 | [diff] [blame] | 733 | |
| 734 | /** |
Alexandra Gherghina | db4bc57 | 2015-01-08 12:17:40 +0000 | [diff] [blame] | 735 | * Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile |
| 736 | * has completed successfully. |
| 737 | * |
| 738 | * <p>The broadcast is limited to the primary profile, to the app specified in the provisioning |
Nicolas Prevot | ebe2d99 | 2015-05-12 18:14:53 -0700 | [diff] [blame] | 739 | * intent with action {@link #ACTION_PROVISION_MANAGED_PROFILE}. |
Alexandra Gherghina | db4bc57 | 2015-01-08 12:17:40 +0000 | [diff] [blame] | 740 | * |
Ying Wang | 7f38aab | 2015-02-20 11:50:09 -0800 | [diff] [blame] | 741 | * <p>This intent will contain the extra {@link #EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE} which |
Alexandra Gherghina | db4bc57 | 2015-01-08 12:17:40 +0000 | [diff] [blame] | 742 | * corresponds to the account requested to be migrated at provisioning time, if any. |
| 743 | */ |
| 744 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 745 | public static final String ACTION_MANAGED_PROFILE_PROVISIONED |
| 746 | = "android.app.action.MANAGED_PROFILE_PROVISIONED"; |
| 747 | |
| 748 | /** |
Mahaver Chopra | 3c58cfe | 2016-11-01 21:25:59 +0000 | [diff] [blame^] | 749 | * Activity action: This activity action is sent to indicate that provisioning of a managed |
| 750 | * profile or managed device has completed successfully. It'll be sent at the same time as |
| 751 | * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE} broadcast but this will be |
| 752 | * delivered faster as it's an activity intent. |
| 753 | * |
| 754 | * <p>The intent is only sent to the application on the profile that requested provisioning. In |
| 755 | * the device owner case the profile is the primary user. |
| 756 | * |
| 757 | * @see #ACTION_PROVISION_MANAGED_PROFILE |
| 758 | * @see #ACTION_PROVISION_MANAGED_DEVICE |
| 759 | */ |
| 760 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 761 | public static final String ACTION_PROVISIONING_SUCCESSFUL = |
| 762 | "android.app.action.PROVISIONING_SUCCESSFUL"; |
| 763 | |
| 764 | /** |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 765 | * A boolean extra indicating whether device encryption can be skipped as part of device owner |
| 766 | * or managed profile provisioning. |
Julia Reynolds | a9ec70b | 2015-02-02 09:54:26 -0500 | [diff] [blame] | 767 | * |
Craig Lafayette | 3cc72ba | 2015-06-26 11:51:04 -0400 | [diff] [blame] | 768 | * <p>Use in an NFC record with {@link #MIME_TYPE_PROVISIONING_NFC} or an intent with action |
Nicolas Prevot | 64bf7b2 | 2015-04-29 14:43:49 +0100 | [diff] [blame] | 769 | * {@link #ACTION_PROVISION_MANAGED_DEVICE} that starts device owner provisioning. |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 770 | * |
| 771 | * <p>From {@link android.os.Build.VERSION_CODES#N} onwards, this is also supported for an |
| 772 | * intent with action {@link #ACTION_PROVISION_MANAGED_PROFILE}. |
Julia Reynolds | a9ec70b | 2015-02-02 09:54:26 -0500 | [diff] [blame] | 773 | */ |
| 774 | public static final String EXTRA_PROVISIONING_SKIP_ENCRYPTION = |
| 775 | "android.app.extra.PROVISIONING_SKIP_ENCRYPTION"; |
| 776 | |
| 777 | /** |
Nicolas Prevot | 8b7991c | 2015-11-12 17:40:12 +0000 | [diff] [blame] | 778 | * A {@link Uri} extra pointing to a logo image. This image will be shown during the |
| 779 | * provisioning. If this extra is not passed, a default image will be shown. |
| 780 | * <h5>The following URI schemes are accepted:</h5> |
| 781 | * <ul> |
| 782 | * <li>content ({@link android.content.ContentResolver#SCHEME_CONTENT})</li> |
| 783 | * <li>android.resource ({@link android.content.ContentResolver#SCHEME_ANDROID_RESOURCE})</li> |
| 784 | * </ul> |
| 785 | * |
| 786 | * <p> It is the responsability of the caller to provide an image with a reasonable |
| 787 | * pixed density for the device. |
| 788 | * |
| 789 | * <p> If a content: URI is passed, the intent should have the flag |
| 790 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} and the uri should be added to the |
| 791 | * {@link android.content.ClipData} of the intent too. |
| 792 | * |
| 793 | * <p>Use in an intent with action {@link #ACTION_PROVISION_MANAGED_PROFILE} or |
| 794 | * {@link #ACTION_PROVISION_MANAGED_DEVICE} |
| 795 | */ |
| 796 | public static final String EXTRA_PROVISIONING_LOGO_URI = |
| 797 | "android.app.extra.PROVISIONING_LOGO_URI"; |
| 798 | |
| 799 | /** |
Alan Treadway | 94de8c8 | 2016-01-11 10:25:23 +0000 | [diff] [blame] | 800 | * A boolean extra indicating if user setup should be skipped, for when provisioning is started |
| 801 | * during setup-wizard. |
| 802 | * |
| 803 | * <p>If unspecified, defaults to {@code true} to match the behavior in |
| 804 | * {@link android.os.Build.VERSION_CODES#M} and earlier. |
| 805 | * |
Alan Treadway | 1a538d0 | 2016-01-18 16:42:30 +0000 | [diff] [blame] | 806 | * <p>Use in an intent with action {@link #ACTION_PROVISION_MANAGED_DEVICE} or |
| 807 | * {@link #ACTION_PROVISION_MANAGED_USER}. |
Alan Treadway | 94de8c8 | 2016-01-11 10:25:23 +0000 | [diff] [blame] | 808 | * |
| 809 | * @hide |
| 810 | */ |
| 811 | public static final String EXTRA_PROVISIONING_SKIP_USER_SETUP = |
| 812 | "android.app.extra.PROVISIONING_SKIP_USER_SETUP"; |
| 813 | |
| 814 | /** |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 815 | * This MIME type is used for starting the device owner provisioning. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 816 | * |
Craig Lafayette | 3cc72ba | 2015-06-26 11:51:04 -0400 | [diff] [blame] | 817 | * <p>During device owner provisioning a device admin app is set as the owner of the device. |
| 818 | * A device owner has full control over the device. The device owner can not be modified by the |
| 819 | * user and the only way of resetting the device is if the device owner app calls a factory |
| 820 | * reset. |
| 821 | * |
| 822 | * <p> A typical use case would be a device that is owned by a company, but used by either an |
| 823 | * employee or client. |
| 824 | * |
Benjamin Franz | ea95624 | 2016-03-21 15:45:56 +0000 | [diff] [blame] | 825 | * <p> The NFC message must be sent to an unprovisioned device. |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 826 | * |
Sander Alewijnse | 8c41156 | 2014-11-12 18:03:11 +0000 | [diff] [blame] | 827 | * <p>The NFC record must contain a serialized {@link java.util.Properties} object which |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 828 | * contains the following properties: |
| 829 | * <ul> |
Andrei Kapishnikov | 35e71f5 | 2015-03-16 17:24:04 -0400 | [diff] [blame] | 830 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME}</li> |
| 831 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION}, optional</li> |
Sander Alewijnse | 681bce9 | 2014-07-24 16:46:26 +0100 | [diff] [blame] | 832 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER}, optional</li> |
Andrei Kapishnikov | 35e71f5 | 2015-03-16 17:24:04 -0400 | [diff] [blame] | 833 | * <li>{@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM}, optional</li> |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 834 | * <li>{@link #EXTRA_PROVISIONING_LOCAL_TIME} (convert to String), optional</li> |
| 835 | * <li>{@link #EXTRA_PROVISIONING_TIME_ZONE}, optional</li> |
| 836 | * <li>{@link #EXTRA_PROVISIONING_LOCALE}, optional</li> |
| 837 | * <li>{@link #EXTRA_PROVISIONING_WIFI_SSID}, optional</li> |
| 838 | * <li>{@link #EXTRA_PROVISIONING_WIFI_HIDDEN} (convert to String), optional</li> |
| 839 | * <li>{@link #EXTRA_PROVISIONING_WIFI_SECURITY_TYPE}, optional</li> |
| 840 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PASSWORD}, optional</li> |
| 841 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PROXY_HOST}, optional</li> |
| 842 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PROXY_PORT} (convert to String), optional</li> |
| 843 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PROXY_BYPASS}, optional</li> |
Rubin Xu | 41f2ccb9 | 2015-08-05 16:29:13 +0100 | [diff] [blame] | 844 | * <li>{@link #EXTRA_PROVISIONING_WIFI_PAC_URL}, optional</li> |
| 845 | * <li>{@link #EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}, optional, supported from |
| 846 | * {@link android.os.Build.VERSION_CODES#M} </li></ul> |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 847 | * |
Nicolas Prevot | 1844025 | 2015-03-09 14:07:17 +0000 | [diff] [blame] | 848 | * <p> |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 849 | * As of {@link android.os.Build.VERSION_CODES#M}, the properties should contain |
Andrei Kapishnikov | 35e71f5 | 2015-03-16 17:24:04 -0400 | [diff] [blame] | 850 | * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME} instead of |
| 851 | * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME}, (although specifying only |
| 852 | * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME} is still supported). |
Andrei Kapishnikov | 35e71f5 | 2015-03-16 17:24:04 -0400 | [diff] [blame] | 853 | */ |
| 854 | public static final String MIME_TYPE_PROVISIONING_NFC |
| 855 | = "application/com.android.managedprovisioning"; |
| 856 | |
Sander Alewijnse | 1cc4ecc | 2014-06-23 19:56:52 +0100 | [diff] [blame] | 857 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 858 | * Activity action: ask the user to add a new device administrator to the system. |
| 859 | * The desired policy is the ComponentName of the policy in the |
| 860 | * {@link #EXTRA_DEVICE_ADMIN} extra field. This will invoke a UI to |
| 861 | * bring the user through adding the device administrator to the system (or |
| 862 | * allowing them to reject it). |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 863 | * |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 864 | * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION} |
| 865 | * field to provide the user with additional explanation (in addition |
| 866 | * to your component's description) about what is being added. |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 867 | * |
| 868 | * <p>If your administrator is already active, this will ordinarily return immediately (without |
| 869 | * user intervention). However, if your administrator has been updated and is requesting |
| 870 | * additional uses-policy flags, the user will be presented with the new list. New policies |
| 871 | * will not be available to the updated administrator until the user has accepted the new list. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 872 | */ |
| 873 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 874 | public static final String ACTION_ADD_DEVICE_ADMIN |
| 875 | = "android.app.action.ADD_DEVICE_ADMIN"; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 876 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 877 | /** |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 878 | * @hide |
| 879 | * Activity action: ask the user to add a new device administrator as the profile owner |
Amith Yamasani | 814e987 | 2015-03-23 14:04:53 -0700 | [diff] [blame] | 880 | * for this user. Only system apps can launch this intent. |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 881 | * |
Amith Yamasani | 814e987 | 2015-03-23 14:04:53 -0700 | [diff] [blame] | 882 | * <p>The ComponentName of the profile owner admin is passed in the {@link #EXTRA_DEVICE_ADMIN} |
| 883 | * extra field. This will invoke a UI to bring the user through adding the profile owner admin |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 884 | * to remotely control restrictions on the user. |
| 885 | * |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 886 | * <p>The intent must be invoked via {@link Activity#startActivityForResult} to receive the |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 887 | * result of whether or not the user approved the action. If approved, the result will |
| 888 | * be {@link Activity#RESULT_OK} and the component will be set as an active admin as well |
| 889 | * as a profile owner. |
| 890 | * |
| 891 | * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION} |
| 892 | * field to provide the user with additional explanation (in addition |
| 893 | * to your component's description) about what is being added. |
| 894 | * |
Amith Yamasani | 814e987 | 2015-03-23 14:04:53 -0700 | [diff] [blame] | 895 | * <p>If there is already a profile owner active or the caller is not a system app, the |
| 896 | * operation will return a failure result. |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 897 | */ |
| 898 | @SystemApi |
| 899 | public static final String ACTION_SET_PROFILE_OWNER |
| 900 | = "android.app.action.SET_PROFILE_OWNER"; |
| 901 | |
| 902 | /** |
| 903 | * @hide |
| 904 | * Name of the profile owner admin that controls the user. |
| 905 | */ |
| 906 | @SystemApi |
| 907 | public static final String EXTRA_PROFILE_OWNER_NAME |
| 908 | = "android.app.extra.PROFILE_OWNER_NAME"; |
| 909 | |
| 910 | /** |
Nicolas Prevot | 0079900 | 2015-07-27 18:15:20 +0100 | [diff] [blame] | 911 | * Broadcast action: send when any policy admin changes a policy. |
Jim Miller | 284b62e | 2010-06-08 14:27:42 -0700 | [diff] [blame] | 912 | * This is generally used to find out when a new policy is in effect. |
Jim Miller | 3e5d3fd | 2011-09-02 17:30:35 -0700 | [diff] [blame] | 913 | * |
Jim Miller | 284b62e | 2010-06-08 14:27:42 -0700 | [diff] [blame] | 914 | * @hide |
| 915 | */ |
| 916 | public static final String ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED |
| 917 | = "android.app.action.DEVICE_POLICY_MANAGER_STATE_CHANGED"; |
| 918 | |
| 919 | /** |
Tony Mak | 1970f97 | 2016-08-30 17:41:48 +0100 | [diff] [blame] | 920 | * Broadcast action: sent when the device owner is set, changed or cleared. |
Nicolas Prevot | 0079900 | 2015-07-27 18:15:20 +0100 | [diff] [blame] | 921 | * |
| 922 | * This broadcast is sent only to the primary user. |
| 923 | * @see #ACTION_PROVISION_MANAGED_DEVICE |
| 924 | */ |
| 925 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 926 | public static final String ACTION_DEVICE_OWNER_CHANGED |
| 927 | = "android.app.action.DEVICE_OWNER_CHANGED"; |
| 928 | |
| 929 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 930 | * The ComponentName of the administrator component. |
| 931 | * |
| 932 | * @see #ACTION_ADD_DEVICE_ADMIN |
| 933 | */ |
| 934 | public static final String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN"; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 935 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 936 | /** |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 937 | * An optional CharSequence providing additional explanation for why the |
| 938 | * admin is being added. |
| 939 | * |
| 940 | * @see #ACTION_ADD_DEVICE_ADMIN |
| 941 | */ |
| 942 | public static final String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION"; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 943 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 944 | /** |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 945 | * Activity action: have the user enter a new password. This activity should |
| 946 | * be launched after using {@link #setPasswordQuality(ComponentName, int)}, |
| 947 | * or {@link #setPasswordMinimumLength(ComponentName, int)} to have the user |
| 948 | * enter a new password that meets the current requirements. You can use |
| 949 | * {@link #isActivePasswordSufficient()} to determine whether you need to |
| 950 | * have the user select a new password in order to meet the current |
| 951 | * constraints. Upon being resumed from this activity, you can check the new |
| 952 | * password characteristics to see if they are sufficient. |
Benjamin Franz | c992109 | 2016-01-08 17:17:44 +0000 | [diff] [blame] | 953 | * |
| 954 | * If the intent is launched from within a managed profile with a profile |
| 955 | * owner built against {@link android.os.Build.VERSION_CODES#M} or before, |
| 956 | * this will trigger entering a new password for the parent of the profile. |
| 957 | * For all other cases it will trigger entering a new password for the user |
| 958 | * or profile it is launched from. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 959 | * |
| 960 | * @see #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 961 | */ |
| 962 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 963 | public static final String ACTION_SET_NEW_PASSWORD |
| 964 | = "android.app.action.SET_NEW_PASSWORD"; |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 965 | |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 966 | /** |
Benjamin Franz | c992109 | 2016-01-08 17:17:44 +0000 | [diff] [blame] | 967 | * Activity action: have the user enter a new password for the parent profile. |
| 968 | * If the intent is launched from within a managed profile, this will trigger |
| 969 | * entering a new password for the parent of the profile. In all other cases |
| 970 | * the behaviour is identical to {@link #ACTION_SET_NEW_PASSWORD}. |
| 971 | */ |
| 972 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 973 | public static final String ACTION_SET_NEW_PARENT_PROFILE_PASSWORD |
| 974 | = "android.app.action.SET_NEW_PARENT_PROFILE_PASSWORD"; |
| 975 | |
| 976 | /** |
Nicolas Prevot | 2c1c5dd | 2015-01-12 12:32:56 +0000 | [diff] [blame] | 977 | * Flag used by {@link #addCrossProfileIntentFilter} to allow activities in |
| 978 | * the parent profile to access intents sent from the managed profile. |
| 979 | * That is, when an app in the managed profile calls |
| 980 | * {@link Activity#startActivity(Intent)}, the intent can be resolved by a |
| 981 | * matching activity in the parent profile. |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 982 | */ |
Nicolas Prevot | 86a9673 | 2014-09-08 12:13:05 +0100 | [diff] [blame] | 983 | public static final int FLAG_PARENT_CAN_ACCESS_MANAGED = 0x0001; |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 984 | |
| 985 | /** |
Nicolas Prevot | 2c1c5dd | 2015-01-12 12:32:56 +0000 | [diff] [blame] | 986 | * Flag used by {@link #addCrossProfileIntentFilter} to allow activities in |
| 987 | * the managed profile to access intents sent from the parent profile. |
| 988 | * That is, when an app in the parent profile calls |
| 989 | * {@link Activity#startActivity(Intent)}, the intent can be resolved by a |
| 990 | * matching activity in the managed profile. |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 991 | */ |
Nicolas Prevot | 86a9673 | 2014-09-08 12:13:05 +0100 | [diff] [blame] | 992 | public static final int FLAG_MANAGED_CAN_ACCESS_PARENT = 0x0002; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 993 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 994 | /** |
Rubin Xu | 5faad8e | 2015-04-20 17:43:48 +0100 | [diff] [blame] | 995 | * Broadcast action: notify that a new local system update policy has been set by the device |
| 996 | * owner. The new policy can be retrieved by {@link #getSystemUpdatePolicy()}. |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 997 | */ |
| 998 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Rubin Xu | 5faad8e | 2015-04-20 17:43:48 +0100 | [diff] [blame] | 999 | public static final String ACTION_SYSTEM_UPDATE_POLICY_CHANGED |
| 1000 | = "android.app.action.SYSTEM_UPDATE_POLICY_CHANGED"; |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 1001 | |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 1002 | /** |
| 1003 | * Permission policy to prompt user for new permission requests for runtime permissions. |
| 1004 | * Already granted or denied permissions are not affected by this. |
| 1005 | */ |
| 1006 | public static final int PERMISSION_POLICY_PROMPT = 0; |
| 1007 | |
| 1008 | /** |
| 1009 | * Permission policy to always grant new permission requests for runtime permissions. |
| 1010 | * Already granted or denied permissions are not affected by this. |
| 1011 | */ |
| 1012 | public static final int PERMISSION_POLICY_AUTO_GRANT = 1; |
| 1013 | |
| 1014 | /** |
| 1015 | * Permission policy to always deny new permission requests for runtime permissions. |
| 1016 | * Already granted or denied permissions are not affected by this. |
| 1017 | */ |
| 1018 | public static final int PERMISSION_POLICY_AUTO_DENY = 2; |
| 1019 | |
Svet Ganov | d8ecc5a | 2015-05-20 10:45:43 -0700 | [diff] [blame] | 1020 | /** |
| 1021 | * Runtime permission state: The user can manage the permission |
| 1022 | * through the UI. |
| 1023 | */ |
| 1024 | public static final int PERMISSION_GRANT_STATE_DEFAULT = 0; |
| 1025 | |
| 1026 | /** |
| 1027 | * Runtime permission state: The permission is granted to the app |
| 1028 | * and the user cannot manage the permission through the UI. |
| 1029 | */ |
| 1030 | public static final int PERMISSION_GRANT_STATE_GRANTED = 1; |
| 1031 | |
| 1032 | /** |
| 1033 | * Runtime permission state: The permission is denied to the app |
| 1034 | * and the user cannot manage the permission through the UI. |
| 1035 | */ |
| 1036 | public static final int PERMISSION_GRANT_STATE_DENIED = 2; |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 1037 | |
| 1038 | /** |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 1039 | * No management for current user in-effect. This is the default. |
| 1040 | * @hide |
| 1041 | */ |
Benjamin Franz | eed2a8e | 2016-02-19 14:19:05 +0000 | [diff] [blame] | 1042 | @SystemApi |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 1043 | public static final int STATE_USER_UNMANAGED = 0; |
| 1044 | |
| 1045 | /** |
| 1046 | * Management partially setup, user setup needs to be completed. |
| 1047 | * @hide |
| 1048 | */ |
Benjamin Franz | eed2a8e | 2016-02-19 14:19:05 +0000 | [diff] [blame] | 1049 | @SystemApi |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 1050 | public static final int STATE_USER_SETUP_INCOMPLETE = 1; |
| 1051 | |
| 1052 | /** |
| 1053 | * Management partially setup, user setup completed. |
| 1054 | * @hide |
| 1055 | */ |
Benjamin Franz | eed2a8e | 2016-02-19 14:19:05 +0000 | [diff] [blame] | 1056 | @SystemApi |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 1057 | public static final int STATE_USER_SETUP_COMPLETE = 2; |
| 1058 | |
| 1059 | /** |
| 1060 | * Management setup and active on current user. |
| 1061 | * @hide |
| 1062 | */ |
Benjamin Franz | eed2a8e | 2016-02-19 14:19:05 +0000 | [diff] [blame] | 1063 | @SystemApi |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 1064 | public static final int STATE_USER_SETUP_FINALIZED = 3; |
| 1065 | |
| 1066 | /** |
| 1067 | * Management partially setup on a managed profile. |
| 1068 | * @hide |
| 1069 | */ |
Benjamin Franz | eed2a8e | 2016-02-19 14:19:05 +0000 | [diff] [blame] | 1070 | @SystemApi |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 1071 | public static final int STATE_USER_PROFILE_COMPLETE = 4; |
| 1072 | |
| 1073 | /** |
| 1074 | * @hide |
| 1075 | */ |
| 1076 | @IntDef({STATE_USER_UNMANAGED, STATE_USER_SETUP_INCOMPLETE, STATE_USER_SETUP_COMPLETE, |
| 1077 | STATE_USER_SETUP_FINALIZED, STATE_USER_PROFILE_COMPLETE}) |
| 1078 | @Retention(RetentionPolicy.SOURCE) |
| 1079 | public @interface UserProvisioningState {} |
| 1080 | |
| 1081 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1082 | * Return true if the given administrator component is currently active (enabled) in the system. |
| 1083 | * |
| 1084 | * @param admin The administrator component to check for. |
| 1085 | * @return {@code true} if {@code admin} is currently enabled in the system, {@code false} |
| 1086 | * otherwise |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1087 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1088 | public boolean isAdminActive(@NonNull ComponentName admin) { |
Charles He | 8c76056 | 2016-10-25 16:36:53 +0100 | [diff] [blame] | 1089 | throwIfParentInstance("isAdminActive"); |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1090 | return isAdminActiveAsUser(admin, myUserId()); |
Zoltan Szatmary-Ban | 3f1ddf8 | 2014-07-02 16:42:05 +0100 | [diff] [blame] | 1091 | } |
| 1092 | |
| 1093 | /** |
| 1094 | * @see #isAdminActive(ComponentName) |
| 1095 | * @hide |
| 1096 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1097 | public boolean isAdminActiveAsUser(@NonNull ComponentName admin, int userId) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1098 | if (mService != null) { |
| 1099 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1100 | return mService.isAdminActive(admin, userId); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1101 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1102 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1103 | } |
| 1104 | } |
| 1105 | return false; |
| 1106 | } |
Fyodor Kupolov | 96fb932 | 2014-12-01 15:08:09 -0800 | [diff] [blame] | 1107 | /** |
| 1108 | * Return true if the given administrator component is currently being removed |
| 1109 | * for the user. |
| 1110 | * @hide |
| 1111 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1112 | public boolean isRemovingAdmin(@NonNull ComponentName admin, int userId) { |
Fyodor Kupolov | 96fb932 | 2014-12-01 15:08:09 -0800 | [diff] [blame] | 1113 | if (mService != null) { |
| 1114 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1115 | return mService.isRemovingAdmin(admin, userId); |
Fyodor Kupolov | 96fb932 | 2014-12-01 15:08:09 -0800 | [diff] [blame] | 1116 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1117 | throw e.rethrowFromSystemServer(); |
Fyodor Kupolov | 96fb932 | 2014-12-01 15:08:09 -0800 | [diff] [blame] | 1118 | } |
| 1119 | } |
| 1120 | return false; |
| 1121 | } |
| 1122 | |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1123 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1124 | /** |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1125 | * Return a list of all currently active device administrators' component |
| 1126 | * names. If there are no administrators {@code null} may be |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 1127 | * returned. |
| 1128 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 1129 | public @Nullable List<ComponentName> getActiveAdmins() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 1130 | throwIfParentInstance("getActiveAdmins"); |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1131 | return getActiveAdminsAsUser(myUserId()); |
Zoltan Szatmary-Ban | 3f1ddf8 | 2014-07-02 16:42:05 +0100 | [diff] [blame] | 1132 | } |
| 1133 | |
| 1134 | /** |
| 1135 | * @see #getActiveAdmins() |
| 1136 | * @hide |
| 1137 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 1138 | public @Nullable List<ComponentName> getActiveAdminsAsUser(int userId) { |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 1139 | if (mService != null) { |
| 1140 | try { |
Zoltan Szatmary-Ban | 3f1ddf8 | 2014-07-02 16:42:05 +0100 | [diff] [blame] | 1141 | return mService.getActiveAdmins(userId); |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 1142 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1143 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 1144 | } |
| 1145 | } |
| 1146 | return null; |
| 1147 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1148 | |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 1149 | /** |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1150 | * Used by package administration code to determine if a package can be stopped |
| 1151 | * or uninstalled. |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1152 | * @hide |
| 1153 | */ |
| 1154 | public boolean packageHasActiveAdmins(String packageName) { |
Amith Yamasani | ca5d6d2 | 2016-02-16 13:58:46 -0800 | [diff] [blame] | 1155 | return packageHasActiveAdmins(packageName, myUserId()); |
| 1156 | } |
| 1157 | |
| 1158 | /** |
| 1159 | * Used by package administration code to determine if a package can be stopped |
| 1160 | * or uninstalled. |
| 1161 | * @hide |
| 1162 | */ |
| 1163 | public boolean packageHasActiveAdmins(String packageName, int userId) { |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1164 | if (mService != null) { |
| 1165 | try { |
Amith Yamasani | ca5d6d2 | 2016-02-16 13:58:46 -0800 | [diff] [blame] | 1166 | return mService.packageHasActiveAdmins(packageName, userId); |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1167 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1168 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1169 | } |
| 1170 | } |
| 1171 | return false; |
| 1172 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1173 | |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1174 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1175 | * Remove a current administration component. This can only be called |
| 1176 | * by the application that owns the administration component; if you |
| 1177 | * try to remove someone else's component, a security exception will be |
| 1178 | * thrown. |
Esteban Talavera | 552a561 | 2016-02-19 17:02:24 +0000 | [diff] [blame] | 1179 | * |
| 1180 | * <p>Note that the operation is not synchronous and the admin might still be active (as |
| 1181 | * indicated by {@link #getActiveAdmins()}) by the time this method returns. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1182 | * |
| 1183 | * @param admin The administration compononent to remove. |
| 1184 | * @throws SecurityException if the caller is not in the owner application of {@code admin}. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1185 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1186 | public void removeActiveAdmin(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 1187 | throwIfParentInstance("removeActiveAdmin"); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1188 | if (mService != null) { |
| 1189 | try { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1190 | mService.removeActiveAdmin(admin, myUserId()); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1191 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1192 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1193 | } |
| 1194 | } |
| 1195 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1196 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1197 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1198 | * Returns true if an administrator has been granted a particular device policy. This can be |
| 1199 | * used to check whether the administrator was activated under an earlier set of policies, but |
| 1200 | * requires additional policies after an upgrade. |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1201 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1202 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Must be an |
| 1203 | * active administrator, or an exception will be thrown. |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1204 | * @param usesPolicy Which uses-policy to check, as defined in {@link DeviceAdminInfo}. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1205 | * @throws SecurityException if {@code admin} is not an active administrator. |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1206 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1207 | public boolean hasGrantedPolicy(@NonNull ComponentName admin, int usesPolicy) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 1208 | throwIfParentInstance("hasGrantedPolicy"); |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1209 | if (mService != null) { |
| 1210 | try { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1211 | return mService.hasGrantedPolicy(admin, usesPolicy, myUserId()); |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1212 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1213 | throw e.rethrowFromSystemServer(); |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1214 | } |
| 1215 | } |
| 1216 | return false; |
| 1217 | } |
| 1218 | |
| 1219 | /** |
Clara Bayarri | a177111 | 2015-12-18 16:29:18 +0000 | [diff] [blame] | 1220 | * Returns true if the Profile Challenge is available to use for the given profile user. |
| 1221 | * |
| 1222 | * @hide |
| 1223 | */ |
| 1224 | public boolean isSeparateProfileChallengeAllowed(int userHandle) { |
| 1225 | if (mService != null) { |
| 1226 | try { |
| 1227 | return mService.isSeparateProfileChallengeAllowed(userHandle); |
| 1228 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1229 | throw e.rethrowFromSystemServer(); |
Clara Bayarri | a177111 | 2015-12-18 16:29:18 +0000 | [diff] [blame] | 1230 | } |
| 1231 | } |
| 1232 | return false; |
| 1233 | } |
| 1234 | |
| 1235 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1236 | * Constant for {@link #setPasswordQuality}: the policy has no requirements |
| 1237 | * for the password. Note that quality constants are ordered so that higher |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 1238 | * values are more restrictive. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1239 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1240 | public static final int PASSWORD_QUALITY_UNSPECIFIED = 0; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1241 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1242 | /** |
Jim Miller | 3e5d3fd | 2011-09-02 17:30:35 -0700 | [diff] [blame] | 1243 | * Constant for {@link #setPasswordQuality}: the policy allows for low-security biometric |
| 1244 | * recognition technology. This implies technologies that can recognize the identity of |
| 1245 | * an individual to about a 3 digit PIN (false detection is less than 1 in 1,000). |
| 1246 | * Note that quality constants are ordered so that higher values are more restrictive. |
| 1247 | */ |
| 1248 | public static final int PASSWORD_QUALITY_BIOMETRIC_WEAK = 0x8000; |
| 1249 | |
| 1250 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1251 | * Constant for {@link #setPasswordQuality}: the policy requires some kind |
Benjamin Franz | c6a9653 | 2015-06-16 11:23:38 +0100 | [diff] [blame] | 1252 | * of password or pattern, but doesn't care what it is. Note that quality constants |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 1253 | * are ordered so that higher values are more restrictive. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1254 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1255 | public static final int PASSWORD_QUALITY_SOMETHING = 0x10000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1256 | |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 1257 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1258 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
| 1259 | * password containing at least numeric characters. Note that quality |
| 1260 | * constants are ordered so that higher values are more restrictive. |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 1261 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1262 | public static final int PASSWORD_QUALITY_NUMERIC = 0x20000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1263 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1264 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1265 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
Jim Miller | 85516d0 | 2014-01-31 17:08:37 -0800 | [diff] [blame] | 1266 | * password containing at least numeric characters with no repeating (4444) |
| 1267 | * or ordered (1234, 4321, 2468) sequences. Note that quality |
| 1268 | * constants are ordered so that higher values are more restrictive. |
| 1269 | */ |
| 1270 | public static final int PASSWORD_QUALITY_NUMERIC_COMPLEX = 0x30000; |
| 1271 | |
| 1272 | /** |
| 1273 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 1274 | * password containing at least alphabetic (or other symbol) characters. |
| 1275 | * Note that quality constants are ordered so that higher values are more |
| 1276 | * restrictive. |
| 1277 | */ |
| 1278 | public static final int PASSWORD_QUALITY_ALPHABETIC = 0x40000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1279 | |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 1280 | /** |
| 1281 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1282 | * password containing at least <em>both></em> numeric <em>and</em> |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 1283 | * alphabetic (or other symbol) characters. Note that quality constants are |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1284 | * ordered so that higher values are more restrictive. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1285 | */ |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 1286 | public static final int PASSWORD_QUALITY_ALPHANUMERIC = 0x50000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1287 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1288 | /** |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1289 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1290 | * password containing at least a letter, a numerical digit and a special |
| 1291 | * symbol, by default. With this password quality, passwords can be |
| 1292 | * restricted to contain various sets of characters, like at least an |
| 1293 | * uppercase letter, etc. These are specified using various methods, |
| 1294 | * like {@link #setPasswordMinimumLowerCase(ComponentName, int)}. Note |
| 1295 | * that quality constants are ordered so that higher values are more |
| 1296 | * restrictive. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1297 | */ |
| 1298 | public static final int PASSWORD_QUALITY_COMPLEX = 0x60000; |
| 1299 | |
| 1300 | /** |
Oleksandr Peletskyi | 0fdcd3d | 2016-01-13 16:49:56 +0100 | [diff] [blame] | 1301 | * Constant for {@link #setPasswordQuality}: the user is not allowed to |
| 1302 | * modify password. In case this password quality is set, the password is |
| 1303 | * managed by a profile owner. The profile owner can set any password, |
| 1304 | * as if {@link #PASSWORD_QUALITY_UNSPECIFIED} is used. Note |
| 1305 | * that quality constants are ordered so that higher values are more |
| 1306 | * restrictive. The value of {@link #PASSWORD_QUALITY_MANAGED} is |
| 1307 | * the highest. |
| 1308 | * @hide |
| 1309 | */ |
| 1310 | public static final int PASSWORD_QUALITY_MANAGED = 0x80000; |
| 1311 | |
| 1312 | /** |
Makoto Onuki | 5e7e0670 | 2016-09-01 18:02:01 -0700 | [diff] [blame] | 1313 | * @hide |
| 1314 | * |
| 1315 | * adb shell dpm set-{device,profile}-owner will normally not allow installing an owner to |
| 1316 | * a user with accounts. {@link #ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED} |
| 1317 | * and {@link #ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_DISALLOWED} are the account features |
| 1318 | * used by authenticator to exempt their accounts from this: |
| 1319 | * |
| 1320 | * <ul> |
| 1321 | * <li>Non-test-only DO/PO still can't be installed when there are accounts. |
| 1322 | * <p>In order to make an apk test-only, add android:testOnly="true" to the |
| 1323 | * <application> tag in the manifest. |
| 1324 | * |
| 1325 | * <li>Test-only DO/PO can be installed even when there are accounts, as long as all the |
| 1326 | * accounts have the {@link #ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED} feature. |
| 1327 | * Some authenticators claim to have any features, so to detect it, we also check |
| 1328 | * {@link #ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_DISALLOWED} and disallow installing |
| 1329 | * if any of the accounts have it. |
| 1330 | * </ul> |
| 1331 | */ |
| 1332 | public static final String ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED = |
| 1333 | "android.account.DEVICE_OR_PROFILE_OWNER_ALLOWED"; |
| 1334 | |
| 1335 | /** @hide See {@link #ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED} */ |
| 1336 | public static final String ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_DISALLOWED = |
| 1337 | "android.account.DEVICE_OR_PROFILE_OWNER_DISALLOWED"; |
| 1338 | |
| 1339 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1340 | * Called by an application that is administering the device to set the password restrictions it |
| 1341 | * is imposing. After setting this, the user will not be able to enter a new password that is |
| 1342 | * not at least as restrictive as what has been set. Note that the current password will remain |
| 1343 | * until the user has set a new one, so the change does not take place immediately. To prompt |
| 1344 | * the user for a new password, use {@link #ACTION_SET_NEW_PASSWORD} or |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1345 | * {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after calling this method. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1346 | * <p> |
| 1347 | * Quality constants are ordered so that higher values are more restrictive; thus the highest |
| 1348 | * requested quality constant (between the policy set here, the user's preference, and any other |
| 1349 | * considerations) is the one that is in effect. |
| 1350 | * <p> |
| 1351 | * The calling device admin must have requested |
| 1352 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1353 | * not, a security exception will be thrown. |
| 1354 | * <p> |
| 1355 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1356 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1357 | * profile. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1358 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 1359 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1360 | * @param quality The new desired quality. One of {@link #PASSWORD_QUALITY_UNSPECIFIED}, |
| 1361 | * {@link #PASSWORD_QUALITY_SOMETHING}, {@link #PASSWORD_QUALITY_NUMERIC}, |
| 1362 | * {@link #PASSWORD_QUALITY_NUMERIC_COMPLEX}, {@link #PASSWORD_QUALITY_ALPHABETIC}, |
| 1363 | * {@link #PASSWORD_QUALITY_ALPHANUMERIC} or {@link #PASSWORD_QUALITY_COMPLEX}. |
| 1364 | * @throws SecurityException if {@code admin} is not an active administrator or if {@code admin} |
| 1365 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1366 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1367 | public void setPasswordQuality(@NonNull ComponentName admin, int quality) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1368 | if (mService != null) { |
| 1369 | try { |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 1370 | mService.setPasswordQuality(admin, quality, mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1371 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1372 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1373 | } |
| 1374 | } |
| 1375 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1376 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1377 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1378 | * Retrieve the current minimum password quality for a particular admin or all admins that set |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1379 | * restrictions on this user and its participating profiles. Restrictions on profiles that have |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1380 | * a separate challenge are not taken into account. |
| 1381 | * |
| 1382 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1383 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1384 | * restrictions on the parent profile. |
| 1385 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1386 | * @param admin The name of the admin component to check, or {@code null} to aggregate |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 1387 | * all admins. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1388 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1389 | public int getPasswordQuality(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1390 | return getPasswordQuality(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1394 | public int getPasswordQuality(@Nullable ComponentName admin, int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1395 | if (mService != null) { |
| 1396 | try { |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 1397 | return mService.getPasswordQuality(admin, userHandle, mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1398 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1399 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1400 | } |
| 1401 | } |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 1402 | return PASSWORD_QUALITY_UNSPECIFIED; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1403 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1404 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1405 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1406 | * Called by an application that is administering the device to set the minimum allowed password |
| 1407 | * length. After setting this, the user will not be able to enter a new password that is not at |
| 1408 | * least as restrictive as what has been set. Note that the current password will remain until |
| 1409 | * the user has set a new one, so the change does not take place immediately. To prompt the user |
| 1410 | * for a new password, use {@link #ACTION_SET_NEW_PASSWORD} or |
| 1411 | * {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after setting this value. This constraint is |
| 1412 | * only imposed if the administrator has also requested either {@link #PASSWORD_QUALITY_NUMERIC} |
| 1413 | * , {@link #PASSWORD_QUALITY_NUMERIC_COMPLEX}, {@link #PASSWORD_QUALITY_ALPHABETIC}, |
| 1414 | * {@link #PASSWORD_QUALITY_ALPHANUMERIC}, or {@link #PASSWORD_QUALITY_COMPLEX} with |
| 1415 | * {@link #setPasswordQuality}. |
| 1416 | * <p> |
| 1417 | * The calling device admin must have requested |
| 1418 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1419 | * not, a security exception will be thrown. |
| 1420 | * <p> |
| 1421 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1422 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1423 | * profile. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1424 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 1425 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1426 | * @param length The new desired minimum password length. A value of 0 means there is no |
| 1427 | * restriction. |
| 1428 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1429 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1430 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1431 | public void setPasswordMinimumLength(@NonNull ComponentName admin, int length) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1432 | if (mService != null) { |
| 1433 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1434 | mService.setPasswordMinimumLength(admin, length, mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1435 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1436 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1437 | } |
| 1438 | } |
| 1439 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1440 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1441 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1442 | * Retrieve the current minimum password length for a particular admin or all admins that set |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1443 | * restrictions on this user and its participating profiles. Restrictions on profiles that have |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1444 | * a separate challenge are not taken into account. |
| 1445 | * |
| 1446 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1447 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1448 | * restrictions on the parent profile. |
| 1449 | * |
Jessica Hummel | 91da58d | 2014-04-10 17:39:43 +0100 | [diff] [blame] | 1450 | * user and its profiles or a particular one. |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1451 | * @param admin The name of the admin component to check, or {@code null} to aggregate |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 1452 | * all admins. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1453 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1454 | public int getPasswordMinimumLength(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1455 | return getPasswordMinimumLength(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1459 | public int getPasswordMinimumLength(@Nullable ComponentName admin, int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1460 | if (mService != null) { |
| 1461 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1462 | return mService.getPasswordMinimumLength(admin, userHandle, mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1463 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1464 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1465 | } |
| 1466 | } |
| 1467 | return 0; |
| 1468 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1469 | |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1470 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1471 | * Called by an application that is administering the device to set the minimum number of upper |
| 1472 | * case letters required in the password. After setting this, the user will not be able to enter |
| 1473 | * a new password that is not at least as restrictive as what has been set. Note that the |
| 1474 | * current password will remain until the user has set a new one, so the change does not take |
| 1475 | * place immediately. To prompt the user for a new password, use |
| 1476 | * {@link #ACTION_SET_NEW_PASSWORD} or {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after |
| 1477 | * setting this value. This constraint is only imposed if the administrator has also requested |
| 1478 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The default value is 0. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1479 | * <p> |
| 1480 | * The calling device admin must have requested |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1481 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1482 | * not, a security exception will be thrown. |
| 1483 | * <p> |
| 1484 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1485 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1486 | * profile. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1487 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1488 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1489 | * @param length The new desired minimum number of upper case letters required in the password. |
| 1490 | * A value of 0 means there is no restriction. |
| 1491 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1492 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1493 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1494 | public void setPasswordMinimumUpperCase(@NonNull ComponentName admin, int length) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1495 | if (mService != null) { |
| 1496 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1497 | mService.setPasswordMinimumUpperCase(admin, length, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1498 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1499 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1500 | } |
| 1501 | } |
| 1502 | } |
| 1503 | |
| 1504 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1505 | * Retrieve the current number of upper case letters required in the password |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1506 | * for a particular admin or all admins that set restrictions on this user and |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1507 | * its participating profiles. Restrictions on profiles that have a separate challenge |
| 1508 | * are not taken into account. |
Jessica Hummel | 91da58d | 2014-04-10 17:39:43 +0100 | [diff] [blame] | 1509 | * This is the same value as set by |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1510 | * {@link #setPasswordMinimumUpperCase(ComponentName, int)} |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1511 | * and only applies when the password quality is |
| 1512 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1513 | * |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1514 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1515 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1516 | * restrictions on the parent profile. |
| 1517 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1518 | * @param admin The name of the admin component to check, or {@code null} to |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1519 | * aggregate all admins. |
| 1520 | * @return The minimum number of upper case letters required in the |
| 1521 | * password. |
| 1522 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1523 | public int getPasswordMinimumUpperCase(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1524 | return getPasswordMinimumUpperCase(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1525 | } |
| 1526 | |
| 1527 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1528 | public int getPasswordMinimumUpperCase(@Nullable ComponentName admin, int userHandle) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1529 | if (mService != null) { |
| 1530 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1531 | return mService.getPasswordMinimumUpperCase(admin, userHandle, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1532 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1533 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1534 | } |
| 1535 | } |
| 1536 | return 0; |
| 1537 | } |
| 1538 | |
| 1539 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1540 | * Called by an application that is administering the device to set the minimum number of lower |
| 1541 | * case letters required in the password. After setting this, the user will not be able to enter |
| 1542 | * a new password that is not at least as restrictive as what has been set. Note that the |
| 1543 | * current password will remain until the user has set a new one, so the change does not take |
| 1544 | * place immediately. To prompt the user for a new password, use |
| 1545 | * {@link #ACTION_SET_NEW_PASSWORD} or {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after |
| 1546 | * setting this value. This constraint is only imposed if the administrator has also requested |
| 1547 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The default value is 0. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1548 | * <p> |
| 1549 | * The calling device admin must have requested |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1550 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1551 | * not, a security exception will be thrown. |
| 1552 | * <p> |
| 1553 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1554 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1555 | * profile. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1556 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1557 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1558 | * @param length The new desired minimum number of lower case letters required in the password. |
| 1559 | * A value of 0 means there is no restriction. |
| 1560 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1561 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1562 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1563 | public void setPasswordMinimumLowerCase(@NonNull ComponentName admin, int length) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1564 | if (mService != null) { |
| 1565 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1566 | mService.setPasswordMinimumLowerCase(admin, length, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1567 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1568 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1569 | } |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1574 | * Retrieve the current number of lower case letters required in the password |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1575 | * for a particular admin or all admins that set restrictions on this user |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1576 | * and its participating profiles. Restrictions on profiles that have |
| 1577 | * a separate challenge are not taken into account. |
Jessica Hummel | 91da58d | 2014-04-10 17:39:43 +0100 | [diff] [blame] | 1578 | * This is the same value as set by |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1579 | * {@link #setPasswordMinimumLowerCase(ComponentName, int)} |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1580 | * and only applies when the password quality is |
| 1581 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1582 | * |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1583 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1584 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1585 | * restrictions on the parent profile. |
| 1586 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1587 | * @param admin The name of the admin component to check, or {@code null} to |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1588 | * aggregate all admins. |
| 1589 | * @return The minimum number of lower case letters required in the |
| 1590 | * password. |
| 1591 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1592 | public int getPasswordMinimumLowerCase(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1593 | return getPasswordMinimumLowerCase(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1597 | public int getPasswordMinimumLowerCase(@Nullable ComponentName admin, int userHandle) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1598 | if (mService != null) { |
| 1599 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1600 | return mService.getPasswordMinimumLowerCase(admin, userHandle, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1601 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1602 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1603 | } |
| 1604 | } |
| 1605 | return 0; |
| 1606 | } |
| 1607 | |
| 1608 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1609 | * Called by an application that is administering the device to set the minimum number of |
| 1610 | * letters required in the password. After setting this, the user will not be able to enter a |
| 1611 | * new password that is not at least as restrictive as what has been set. Note that the current |
| 1612 | * password will remain until the user has set a new one, so the change does not take place |
| 1613 | * immediately. To prompt the user for a new password, use {@link #ACTION_SET_NEW_PASSWORD} or |
| 1614 | * {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after setting this value. This constraint is |
| 1615 | * only imposed if the administrator has also requested {@link #PASSWORD_QUALITY_COMPLEX} with |
| 1616 | * {@link #setPasswordQuality}. The default value is 1. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1617 | * <p> |
| 1618 | * The calling device admin must have requested |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1619 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1620 | * not, a security exception will be thrown. |
| 1621 | * <p> |
| 1622 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1623 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1624 | * profile. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1625 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1626 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1627 | * @param length The new desired minimum number of letters required in the password. A value of |
| 1628 | * 0 means there is no restriction. |
| 1629 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1630 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1631 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1632 | public void setPasswordMinimumLetters(@NonNull ComponentName admin, int length) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1633 | if (mService != null) { |
| 1634 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1635 | mService.setPasswordMinimumLetters(admin, length, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1636 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1637 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1638 | } |
| 1639 | } |
| 1640 | } |
| 1641 | |
| 1642 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1643 | * Retrieve the current number of letters required in the password |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1644 | * for a particular admin or all admins that set restrictions on this user |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1645 | * and its participating profiles. Restrictions on profiles that have |
| 1646 | * a separate challenge are not taken into account. |
| 1647 | * This is the same value as set by |
| 1648 | * {@link #setPasswordMinimumLetters(ComponentName, int)} |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1649 | * and only applies when the password quality is |
| 1650 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1651 | * |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1652 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1653 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1654 | * restrictions on the parent profile. |
| 1655 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1656 | * @param admin The name of the admin component to check, or {@code null} to |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1657 | * aggregate all admins. |
| 1658 | * @return The minimum number of letters required in the password. |
| 1659 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1660 | public int getPasswordMinimumLetters(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1661 | return getPasswordMinimumLetters(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1665 | public int getPasswordMinimumLetters(@Nullable ComponentName admin, int userHandle) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1666 | if (mService != null) { |
| 1667 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1668 | return mService.getPasswordMinimumLetters(admin, userHandle, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1669 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1670 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1671 | } |
| 1672 | } |
| 1673 | return 0; |
| 1674 | } |
| 1675 | |
| 1676 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1677 | * Called by an application that is administering the device to set the minimum number of |
| 1678 | * numerical digits required in the password. After setting this, the user will not be able to |
| 1679 | * enter a new password that is not at least as restrictive as what has been set. Note that the |
| 1680 | * current password will remain until the user has set a new one, so the change does not take |
| 1681 | * place immediately. To prompt the user for a new password, use |
| 1682 | * {@link #ACTION_SET_NEW_PASSWORD} or {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after |
| 1683 | * setting this value. This constraint is only imposed if the administrator has also requested |
| 1684 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The default value is 1. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1685 | * <p> |
| 1686 | * The calling device admin must have requested |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1687 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1688 | * not, a security exception will be thrown. |
| 1689 | * <p> |
| 1690 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1691 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1692 | * profile. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1693 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1694 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1695 | * @param length The new desired minimum number of numerical digits required in the password. A |
| 1696 | * value of 0 means there is no restriction. |
| 1697 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1698 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1699 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1700 | public void setPasswordMinimumNumeric(@NonNull ComponentName admin, int length) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1701 | if (mService != null) { |
| 1702 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1703 | mService.setPasswordMinimumNumeric(admin, length, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1704 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1705 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1706 | } |
| 1707 | } |
| 1708 | } |
| 1709 | |
| 1710 | /** |
| 1711 | * Retrieve the current number of numerical digits required in the password |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1712 | * for a particular admin or all admins that set restrictions on this user |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1713 | * and its participating profiles. Restrictions on profiles that have |
| 1714 | * a separate challenge are not taken into account. |
Jessica Hummel | 91da58d | 2014-04-10 17:39:43 +0100 | [diff] [blame] | 1715 | * This is the same value as set by |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1716 | * {@link #setPasswordMinimumNumeric(ComponentName, int)} |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1717 | * and only applies when the password quality is |
| 1718 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1719 | * |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1720 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1721 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1722 | * restrictions on the parent profile. |
| 1723 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1724 | * @param admin The name of the admin component to check, or {@code null} to |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1725 | * aggregate all admins. |
| 1726 | * @return The minimum number of numerical digits required in the password. |
| 1727 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1728 | public int getPasswordMinimumNumeric(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1729 | return getPasswordMinimumNumeric(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1730 | } |
| 1731 | |
| 1732 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1733 | public int getPasswordMinimumNumeric(@Nullable ComponentName admin, int userHandle) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1734 | if (mService != null) { |
| 1735 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1736 | return mService.getPasswordMinimumNumeric(admin, userHandle, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1737 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1738 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1739 | } |
| 1740 | } |
| 1741 | return 0; |
| 1742 | } |
| 1743 | |
| 1744 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1745 | * Called by an application that is administering the device to set the minimum number of |
| 1746 | * symbols required in the password. After setting this, the user will not be able to enter a |
| 1747 | * new password that is not at least as restrictive as what has been set. Note that the current |
| 1748 | * password will remain until the user has set a new one, so the change does not take place |
| 1749 | * immediately. To prompt the user for a new password, use {@link #ACTION_SET_NEW_PASSWORD} or |
| 1750 | * {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after setting this value. This constraint is |
| 1751 | * only imposed if the administrator has also requested {@link #PASSWORD_QUALITY_COMPLEX} with |
| 1752 | * {@link #setPasswordQuality}. The default value is 1. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1753 | * <p> |
| 1754 | * The calling device admin must have requested |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1755 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1756 | * not, a security exception will be thrown. |
| 1757 | * <p> |
| 1758 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1759 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1760 | * profile. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1761 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1762 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1763 | * @param length The new desired minimum number of symbols required in the password. A value of |
| 1764 | * 0 means there is no restriction. |
| 1765 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1766 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1767 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1768 | public void setPasswordMinimumSymbols(@NonNull ComponentName admin, int length) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1769 | if (mService != null) { |
| 1770 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1771 | mService.setPasswordMinimumSymbols(admin, length, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1772 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1773 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1774 | } |
| 1775 | } |
| 1776 | } |
| 1777 | |
| 1778 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1779 | * Retrieve the current number of symbols required in the password |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1780 | * for a particular admin or all admins that set restrictions on this user |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1781 | * and its participating profiles. Restrictions on profiles that have |
| 1782 | * a separate challenge are not taken into account. This is the same value as |
| 1783 | * set by {@link #setPasswordMinimumSymbols(ComponentName, int)} |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1784 | * and only applies when the password quality is |
| 1785 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1786 | * |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1787 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1788 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1789 | * restrictions on the parent profile. |
| 1790 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1791 | * @param admin The name of the admin component to check, or {@code null} to |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1792 | * aggregate all admins. |
| 1793 | * @return The minimum number of symbols required in the password. |
| 1794 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1795 | public int getPasswordMinimumSymbols(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1796 | return getPasswordMinimumSymbols(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1797 | } |
| 1798 | |
| 1799 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1800 | public int getPasswordMinimumSymbols(@Nullable ComponentName admin, int userHandle) { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1801 | if (mService != null) { |
| 1802 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1803 | return mService.getPasswordMinimumSymbols(admin, userHandle, mParentInstance); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1804 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1805 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1806 | } |
| 1807 | } |
| 1808 | return 0; |
| 1809 | } |
| 1810 | |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1811 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1812 | * Called by an application that is administering the device to set the minimum number of |
| 1813 | * non-letter characters (numerical digits or symbols) required in the password. After setting |
| 1814 | * this, the user will not be able to enter a new password that is not at least as restrictive |
| 1815 | * as what has been set. Note that the current password will remain until the user has set a new |
| 1816 | * one, so the change does not take place immediately. To prompt the user for a new password, |
| 1817 | * use {@link #ACTION_SET_NEW_PASSWORD} or {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after |
| 1818 | * setting this value. This constraint is only imposed if the administrator has also requested |
| 1819 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The default value is 0. |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1820 | * <p> |
| 1821 | * The calling device admin must have requested |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1822 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1823 | * not, a security exception will be thrown. |
| 1824 | * <p> |
| 1825 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1826 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1827 | * profile. |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1828 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1829 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1830 | * @param length The new desired minimum number of letters required in the password. A value of |
| 1831 | * 0 means there is no restriction. |
| 1832 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1833 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1834 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1835 | public void setPasswordMinimumNonLetter(@NonNull ComponentName admin, int length) { |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1836 | if (mService != null) { |
| 1837 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1838 | mService.setPasswordMinimumNonLetter(admin, length, mParentInstance); |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1839 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1840 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1841 | } |
| 1842 | } |
| 1843 | } |
| 1844 | |
| 1845 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1846 | * Retrieve the current number of non-letter characters required in the password |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1847 | * for a particular admin or all admins that set restrictions on this user |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1848 | * and its participating profiles. Restrictions on profiles that have |
| 1849 | * a separate challenge are not taken into account. |
Jessica Hummel | 91da58d | 2014-04-10 17:39:43 +0100 | [diff] [blame] | 1850 | * This is the same value as set by |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1851 | * {@link #setPasswordMinimumNonLetter(ComponentName, int)} |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1852 | * and only applies when the password quality is |
| 1853 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
| 1854 | * |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1855 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1856 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1857 | * restrictions on the parent profile. |
| 1858 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1859 | * @param admin The name of the admin component to check, or {@code null} to |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1860 | * aggregate all admins. |
| 1861 | * @return The minimum number of letters required in the password. |
| 1862 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1863 | public int getPasswordMinimumNonLetter(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 1864 | return getPasswordMinimumNonLetter(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 1865 | } |
| 1866 | |
| 1867 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1868 | public int getPasswordMinimumNonLetter(@Nullable ComponentName admin, int userHandle) { |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1869 | if (mService != null) { |
| 1870 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1871 | return mService.getPasswordMinimumNonLetter(admin, userHandle, mParentInstance); |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1872 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1873 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1874 | } |
| 1875 | } |
| 1876 | return 0; |
| 1877 | } |
| 1878 | |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1879 | /** |
| 1880 | * Called by an application that is administering the device to set the length of the password |
| 1881 | * history. After setting this, the user will not be able to enter a new password that is the |
| 1882 | * same as any password in the history. Note that the current password will remain until the |
| 1883 | * user has set a new one, so the change does not take place immediately. To prompt the user for |
| 1884 | * a new password, use {@link #ACTION_SET_NEW_PASSWORD} or |
| 1885 | * {@link #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} after setting this value. This constraint is |
| 1886 | * only imposed if the administrator has also requested either {@link #PASSWORD_QUALITY_NUMERIC} |
| 1887 | * , {@link #PASSWORD_QUALITY_NUMERIC_COMPLEX} {@link #PASSWORD_QUALITY_ALPHABETIC}, or |
| 1888 | * {@link #PASSWORD_QUALITY_ALPHANUMERIC} with {@link #setPasswordQuality}. |
| 1889 | * <p> |
| 1890 | * The calling device admin must have requested |
| 1891 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 1892 | * not, a security exception will be thrown. |
| 1893 | * <p> |
| 1894 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1895 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1896 | * profile. |
| 1897 | * |
| 1898 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1899 | * @param length The new desired length of password history. A value of 0 means there is no |
| 1900 | * restriction. |
| 1901 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1902 | * does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
| 1903 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1904 | public void setPasswordHistoryLength(@NonNull ComponentName admin, int length) { |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1905 | if (mService != null) { |
| 1906 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1907 | mService.setPasswordHistoryLength(admin, length, mParentInstance); |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1908 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1909 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1910 | } |
| 1911 | } |
| 1912 | } |
| 1913 | |
| 1914 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1915 | * Called by a device admin to set the password expiration timeout. Calling this method will |
| 1916 | * restart the countdown for password expiration for the given admin, as will changing the |
| 1917 | * device password (for all admins). |
| 1918 | * <p> |
| 1919 | * The provided timeout is the time delta in ms and will be added to the current time. For |
| 1920 | * example, to have the password expire 5 days from now, timeout would be 5 * 86400 * 1000 = |
| 1921 | * 432000000 ms for timeout. |
| 1922 | * <p> |
| 1923 | * To disable password expiration, a value of 0 may be used for timeout. |
| 1924 | * <p> |
| 1925 | * The calling device admin must have requested |
| 1926 | * {@link DeviceAdminInfo#USES_POLICY_EXPIRE_PASSWORD} to be able to call this method; if it has |
| 1927 | * not, a security exception will be thrown. |
| 1928 | * <p> |
| 1929 | * Note that setting the password will automatically reset the expiration time for all active |
| 1930 | * admins. Active admins do not need to explicitly call this method in that case. |
| 1931 | * <p> |
| 1932 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 1933 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 1934 | * profile. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1935 | * |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1936 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 1937 | * @param timeout The limit (in ms) that a password can remain in effect. A value of 0 means |
| 1938 | * there is no restriction (unlimited). |
| 1939 | * @throws SecurityException if {@code admin} is not an active administrator or {@code admin} |
| 1940 | * does not use {@link DeviceAdminInfo#USES_POLICY_EXPIRE_PASSWORD} |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1941 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1942 | public void setPasswordExpirationTimeout(@NonNull ComponentName admin, long timeout) { |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1943 | if (mService != null) { |
| 1944 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1945 | mService.setPasswordExpirationTimeout(admin, timeout, mParentInstance); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1946 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1947 | throw e.rethrowFromSystemServer(); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1948 | } |
| 1949 | } |
| 1950 | } |
| 1951 | |
| 1952 | /** |
Jim Miller | 6b85768 | 2011-02-16 16:27:41 -0800 | [diff] [blame] | 1953 | * Get the password expiration timeout for the given admin. The expiration timeout is the |
| 1954 | * recurring expiration timeout provided in the call to |
| 1955 | * {@link #setPasswordExpirationTimeout(ComponentName, long)} for the given admin or the |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1956 | * aggregate of all participating policy administrators if {@code admin} is null. Admins that |
| 1957 | * have set restrictions on profiles that have a separate challenge are not taken into account. |
| 1958 | * |
| 1959 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1960 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1961 | * restrictions on the parent profile. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1962 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1963 | * @param admin The name of the admin component to check, or {@code null} to aggregate all admins. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1964 | * @return The timeout for the given admin or the minimum of all timeouts |
| 1965 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1966 | public long getPasswordExpirationTimeout(@Nullable ComponentName admin) { |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1967 | if (mService != null) { |
| 1968 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1969 | return mService.getPasswordExpirationTimeout(admin, myUserId(), mParentInstance); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1970 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1971 | throw e.rethrowFromSystemServer(); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1972 | } |
| 1973 | } |
| 1974 | return 0; |
| 1975 | } |
| 1976 | |
| 1977 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1978 | * Get the current password expiration time for a particular admin or all admins that set |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 1979 | * restrictions on this user and its participating profiles. Restrictions on profiles that have |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1980 | * a separate challenge are not taken into account. If admin is {@code null}, then a composite |
| 1981 | * of all expiration times is returned - which will be the minimum of all of them. |
| 1982 | * |
| 1983 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 1984 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 1985 | * the password expiration for the parent profile. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1986 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1987 | * @param admin The name of the admin component to check, or {@code null} to aggregate all admins. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 1988 | * @return The password expiration time, in milliseconds since epoch. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1989 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 1990 | public long getPasswordExpiration(@Nullable ComponentName admin) { |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1991 | if (mService != null) { |
| 1992 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 1993 | return mService.getPasswordExpiration(admin, myUserId(), mParentInstance); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1994 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 1995 | throw e.rethrowFromSystemServer(); |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 1996 | } |
| 1997 | } |
| 1998 | return 0; |
| 1999 | } |
| 2000 | |
| 2001 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2002 | * Retrieve the current password history length for a particular admin or all admins that |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 2003 | * set restrictions on this user and its participating profiles. Restrictions on profiles that |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2004 | * have a separate challenge are not taken into account. |
| 2005 | * |
| 2006 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 2007 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 2008 | * restrictions on the parent profile. |
| 2009 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2010 | * @param admin The name of the admin component to check, or {@code null} to aggregate |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2011 | * all admins. |
| 2012 | * @return The length of the password history |
| 2013 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2014 | public int getPasswordHistoryLength(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 2015 | return getPasswordHistoryLength(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 2016 | } |
| 2017 | |
| 2018 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2019 | public int getPasswordHistoryLength(@Nullable ComponentName admin, int userHandle) { |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2020 | if (mService != null) { |
| 2021 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 2022 | return mService.getPasswordHistoryLength(admin, userHandle, mParentInstance); |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2023 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2024 | throw e.rethrowFromSystemServer(); |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2025 | } |
| 2026 | } |
| 2027 | return 0; |
| 2028 | } |
| 2029 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2030 | /** |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2031 | * Return the maximum password length that the device supports for a |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 2032 | * particular password quality. |
Dianne Hackborn | 364f6e3 | 2010-01-29 17:38:20 -0800 | [diff] [blame] | 2033 | * @param quality The quality being interrogated. |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2034 | * @return Returns the maximum length that the user can enter. |
| 2035 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 2036 | public int getPasswordMaximumLength(int quality) { |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2037 | // Kind-of arbitrary. |
| 2038 | return 16; |
| 2039 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2040 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2041 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2042 | * Determine whether the current password the user has set is sufficient to meet the policy |
| 2043 | * requirements (e.g. quality, minimum length) that have been requested by the admins of this |
| 2044 | * user and its participating profiles. Restrictions on profiles that have a separate challenge |
| 2045 | * are not taken into account. |
| 2046 | * <p> |
| 2047 | * The calling device admin must have requested |
| 2048 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has |
| 2049 | * not, a security exception will be thrown. |
| 2050 | * <p> |
| 2051 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 2052 | * {@link #getParentProfileInstance(ComponentName)} in order to determine if the password set on |
| 2053 | * the parent profile is sufficient. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2054 | * |
Jessica Hummel | 91da58d | 2014-04-10 17:39:43 +0100 | [diff] [blame] | 2055 | * @return Returns true if the password meets the current requirements, else false. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2056 | * @throws SecurityException if the calling application does not own an active administrator |
| 2057 | * that uses {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2058 | */ |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2059 | public boolean isActivePasswordSufficient() { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2060 | if (mService != null) { |
| 2061 | try { |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 2062 | return mService.isActivePasswordSufficient(myUserId(), mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2063 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2064 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2065 | } |
| 2066 | } |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2067 | return false; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2068 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2069 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2070 | /** |
Clara Bayarri | d769391 | 2016-01-22 17:26:31 +0000 | [diff] [blame] | 2071 | * Determine whether the current profile password the user has set is sufficient |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2072 | * to meet the policy requirements (e.g. quality, minimum length) that have been |
Clara Bayarri | d769391 | 2016-01-22 17:26:31 +0000 | [diff] [blame] | 2073 | * requested by the admins of the parent user and its profiles. |
| 2074 | * |
| 2075 | * @param userHandle the userId of the profile to check the password for. |
| 2076 | * @return Returns true if the password would meet the current requirements, else false. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2077 | * @throws SecurityException if {@code userHandle} is not a managed profile. |
Clara Bayarri | d769391 | 2016-01-22 17:26:31 +0000 | [diff] [blame] | 2078 | * @hide |
| 2079 | */ |
| 2080 | public boolean isProfileActivePasswordSufficientForParent(int userHandle) { |
| 2081 | if (mService != null) { |
| 2082 | try { |
| 2083 | return mService.isProfileActivePasswordSufficientForParent(userHandle); |
| 2084 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2085 | throw e.rethrowFromSystemServer(); |
Clara Bayarri | d769391 | 2016-01-22 17:26:31 +0000 | [diff] [blame] | 2086 | } |
| 2087 | } |
| 2088 | return false; |
| 2089 | } |
| 2090 | |
| 2091 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2092 | * Retrieve the number of times the user has failed at entering a password since that last |
| 2093 | * successful password entry. |
| 2094 | * <p> |
| 2095 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 2096 | * {@link #getParentProfileInstance(ComponentName)} in order to retrieve the number of failed |
| 2097 | * password attemts for the parent user. |
| 2098 | * <p> |
| 2099 | * The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} |
| 2100 | * to be able to call this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2101 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2102 | * @return The number of times user has entered an incorrect password since the last correct |
| 2103 | * password entry. |
| 2104 | * @throws SecurityException if the calling application does not own an active administrator |
| 2105 | * that uses {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2106 | */ |
| 2107 | public int getCurrentFailedPasswordAttempts() { |
Clara Bayarri | 51e41ad | 2016-02-11 17:48:53 +0000 | [diff] [blame] | 2108 | return getCurrentFailedPasswordAttempts(myUserId()); |
| 2109 | } |
| 2110 | |
| 2111 | /** |
| 2112 | * Retrieve the number of times the given user has failed at entering a |
| 2113 | * password since that last successful password entry. |
| 2114 | * |
| 2115 | * <p>The calling device admin must have requested |
| 2116 | * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to be able to call this method; if it has |
| 2117 | * not and it is not the system uid, a security exception will be thrown. |
| 2118 | * |
| 2119 | * @hide |
| 2120 | */ |
| 2121 | public int getCurrentFailedPasswordAttempts(int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2122 | if (mService != null) { |
| 2123 | try { |
Clara Bayarri | 51e41ad | 2016-02-11 17:48:53 +0000 | [diff] [blame] | 2124 | return mService.getCurrentFailedPasswordAttempts(userHandle, mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2125 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2126 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2127 | } |
| 2128 | } |
| 2129 | return -1; |
| 2130 | } |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2131 | |
| 2132 | /** |
Craig Lafayette | 4e401fa | 2015-05-07 10:24:02 -0400 | [diff] [blame] | 2133 | * Queries whether {@link #RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT} flag is set. |
Andrei Kapishnikov | 4eb6a36 | 2015-04-02 15:21:20 -0400 | [diff] [blame] | 2134 | * |
Craig Lafayette | 4e401fa | 2015-05-07 10:24:02 -0400 | [diff] [blame] | 2135 | * @return true if RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT flag is set. |
Andrei Kapishnikov | 4eb6a36 | 2015-04-02 15:21:20 -0400 | [diff] [blame] | 2136 | * @hide |
| 2137 | */ |
| 2138 | public boolean getDoNotAskCredentialsOnBoot() { |
| 2139 | if (mService != null) { |
| 2140 | try { |
| 2141 | return mService.getDoNotAskCredentialsOnBoot(); |
| 2142 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2143 | throw e.rethrowFromSystemServer(); |
Andrei Kapishnikov | 4eb6a36 | 2015-04-02 15:21:20 -0400 | [diff] [blame] | 2144 | } |
| 2145 | } |
| 2146 | return false; |
| 2147 | } |
| 2148 | |
| 2149 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2150 | * Setting this to a value greater than zero enables a built-in policy that will perform a |
| 2151 | * device or profile wipe after too many incorrect device-unlock passwords have been entered. |
| 2152 | * This built-in policy combines watching for failed passwords and wiping the device, and |
| 2153 | * requires that you request both {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} and |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 2154 | * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}}. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2155 | * <p> |
| 2156 | * To implement any other policy (e.g. wiping data for a particular application only, erasing or |
| 2157 | * revoking credentials, or reporting the failure to a server), you should implement |
| 2158 | * {@link DeviceAdminReceiver#onPasswordFailed(Context, android.content.Intent)} instead. Do not |
| 2159 | * use this API, because if the maximum count is reached, the device or profile will be wiped |
| 2160 | * immediately, and your callback will not be invoked. |
| 2161 | * <p> |
| 2162 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 2163 | * {@link #getParentProfileInstance(ComponentName)} in order to set a value on the parent |
| 2164 | * profile. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2165 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 2166 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2167 | * @param num The number of failed password attempts at which point the device or profile will |
| 2168 | * be wiped. |
| 2169 | * @throws SecurityException if {@code admin} is not an active administrator or does not use |
| 2170 | * both {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} and |
| 2171 | * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}. |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 2172 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2173 | public void setMaximumFailedPasswordsForWipe(@NonNull ComponentName admin, int num) { |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 2174 | if (mService != null) { |
| 2175 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 2176 | mService.setMaximumFailedPasswordsForWipe(admin, num, mParentInstance); |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 2177 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2178 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 2179 | } |
| 2180 | } |
| 2181 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2182 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 2183 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2184 | * Retrieve the current maximum number of login attempts that are allowed before the device |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 2185 | * or profile is wiped, for a particular admin or all admins that set restrictions on this user |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2186 | * and its participating profiles. Restrictions on profiles that have a separate challenge are |
| 2187 | * not taken into account. |
| 2188 | * |
| 2189 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 2190 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 2191 | * the value for the parent profile. |
| 2192 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2193 | * @param admin The name of the admin component to check, or {@code null} to aggregate |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2194 | * all admins. |
| 2195 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2196 | public int getMaximumFailedPasswordsForWipe(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 2197 | return getMaximumFailedPasswordsForWipe(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 2198 | } |
| 2199 | |
| 2200 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2201 | public int getMaximumFailedPasswordsForWipe(@Nullable ComponentName admin, int userHandle) { |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2202 | if (mService != null) { |
| 2203 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 2204 | return mService.getMaximumFailedPasswordsForWipe( |
| 2205 | admin, userHandle, mParentInstance); |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2206 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2207 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2208 | } |
| 2209 | } |
| 2210 | return 0; |
| 2211 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2212 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2213 | /** |
Amith Yamasani | 3a3d212 | 2014-10-29 11:41:31 -0700 | [diff] [blame] | 2214 | * Returns the profile with the smallest maximum failed passwords for wipe, |
| 2215 | * for the given user. So for primary user, it might return the primary or |
| 2216 | * a managed profile. For a secondary user, it would be the same as the |
| 2217 | * user passed in. |
| 2218 | * @hide Used only by Keyguard |
| 2219 | */ |
| 2220 | public int getProfileWithMinimumFailedPasswordsForWipe(int userHandle) { |
| 2221 | if (mService != null) { |
| 2222 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 2223 | return mService.getProfileWithMinimumFailedPasswordsForWipe( |
| 2224 | userHandle, mParentInstance); |
Amith Yamasani | 3a3d212 | 2014-10-29 11:41:31 -0700 | [diff] [blame] | 2225 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2226 | throw e.rethrowFromSystemServer(); |
Amith Yamasani | 3a3d212 | 2014-10-29 11:41:31 -0700 | [diff] [blame] | 2227 | } |
| 2228 | } |
| 2229 | return UserHandle.USER_NULL; |
| 2230 | } |
| 2231 | |
| 2232 | /** |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 2233 | * Flag for {@link #resetPassword}: don't allow other admins to change |
| 2234 | * the password again until the user has entered it. |
| 2235 | */ |
| 2236 | public static final int RESET_PASSWORD_REQUIRE_ENTRY = 0x0001; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2237 | |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 2238 | /** |
Andrei Kapishnikov | 4eb6a36 | 2015-04-02 15:21:20 -0400 | [diff] [blame] | 2239 | * Flag for {@link #resetPassword}: don't ask for user credentials on device boot. |
| 2240 | * If the flag is set, the device can be booted without asking for user password. |
| 2241 | * The absence of this flag does not change the current boot requirements. This flag |
| 2242 | * can be set by the device owner only. If the app is not the device owner, the flag |
| 2243 | * is ignored. Once the flag is set, it cannot be reverted back without resetting the |
| 2244 | * device to factory defaults. |
| 2245 | */ |
Craig Lafayette | 4e401fa | 2015-05-07 10:24:02 -0400 | [diff] [blame] | 2246 | public static final int RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT = 0x0002; |
Andrei Kapishnikov | 4eb6a36 | 2015-04-02 15:21:20 -0400 | [diff] [blame] | 2247 | |
| 2248 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2249 | * Force a new device unlock password (the password needed to access the entire device, not for |
| 2250 | * individual accounts) on the user. This takes effect immediately. |
| 2251 | * <p> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2252 | * <em>Note: This API has been limited as of {@link android.os.Build.VERSION_CODES#N} for |
Makoto Onuki | 70f929e | 2015-11-11 12:40:15 -0800 | [diff] [blame] | 2253 | * device admins that are not device owner and not profile owner. |
| 2254 | * The password can now only be changed if there is currently no password set. Device owner |
Ricky Wai | 977ade2 | 2016-05-24 15:02:41 +0100 | [diff] [blame] | 2255 | * and profile owner can still do this when user is unlocked and does not have a managed |
| 2256 | * profile.</em> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2257 | * <p> |
| 2258 | * The given password must be sufficient for the current password quality and length constraints |
| 2259 | * as returned by {@link #getPasswordQuality(ComponentName)} and |
| 2260 | * {@link #getPasswordMinimumLength(ComponentName)}; if it does not meet these constraints, then |
| 2261 | * it will be rejected and false returned. Note that the password may be a stronger quality |
| 2262 | * (containing alphanumeric characters when the requested quality is only numeric), in which |
| 2263 | * case the currently active quality will be increased to match. |
| 2264 | * <p> |
| 2265 | * Calling with a null or empty password will clear any existing PIN, pattern or password if the |
Robin Lee | ce5c400 | 2016-03-23 17:05:03 +0000 | [diff] [blame] | 2266 | * current password constraints allow it. <em>Note: This will not work in |
| 2267 | * {@link android.os.Build.VERSION_CODES#N} and later for managed profiles, or for device admins |
| 2268 | * that are not device owner or profile owner. Once set, the password cannot be changed to null |
| 2269 | * or empty except by these admins.</em> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2270 | * <p> |
| 2271 | * The calling device admin must have requested |
| 2272 | * {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD} to be able to call this method; if it has |
| 2273 | * not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2274 | * |
Adrian Roos | f8f56bc | 2014-11-20 23:55:34 +0100 | [diff] [blame] | 2275 | * @param password The new password for the user. Null or empty clears the password. |
Andrei Kapishnikov | 4eb6a36 | 2015-04-02 15:21:20 -0400 | [diff] [blame] | 2276 | * @param flags May be 0 or combination of {@link #RESET_PASSWORD_REQUIRE_ENTRY} and |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2277 | * {@link #RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT}. |
| 2278 | * @return Returns true if the password was applied, or false if it is not acceptable for the |
| 2279 | * current constraints or if the user has not been decrypted yet. |
| 2280 | * @throws SecurityException if the calling application does not own an active administrator |
| 2281 | * that uses {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD} |
Ricky Wai | 977ade2 | 2016-05-24 15:02:41 +0100 | [diff] [blame] | 2282 | * @throws IllegalStateException if the calling user is locked or has a managed profile. |
Andrew Scull | 3f81f4e | 2016-07-29 16:29:58 +0100 | [diff] [blame] | 2283 | * @throws IllegalArgumentException if the password does not meet system requirements. |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2284 | */ |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 2285 | public boolean resetPassword(String password, int flags) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2286 | throwIfParentInstance("resetPassword"); |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2287 | if (mService != null) { |
| 2288 | try { |
Fyodor Kupolov | bdc58c6 | 2015-01-29 13:24:03 -0800 | [diff] [blame] | 2289 | return mService.resetPassword(password, flags); |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2290 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2291 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2292 | } |
| 2293 | } |
| 2294 | return false; |
| 2295 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2296 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2297 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2298 | * Called by an application that is administering the device to set the maximum time for user |
| 2299 | * activity until the device will lock. This limits the length that the user can set. It takes |
| 2300 | * effect immediately. |
| 2301 | * <p> |
| 2302 | * The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} |
| 2303 | * to be able to call this method; if it has not, a security exception will be thrown. |
| 2304 | * <p> |
| 2305 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 2306 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 2307 | * profile. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2308 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 2309 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2310 | * @param timeMs The new desired maximum time to lock in milliseconds. A value of 0 means there |
| 2311 | * is no restriction. |
| 2312 | * @throws SecurityException if {@code admin} is not an active administrator or it does not use |
| 2313 | * {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2314 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2315 | public void setMaximumTimeToLock(@NonNull ComponentName admin, long timeMs) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2316 | if (mService != null) { |
| 2317 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 2318 | mService.setMaximumTimeToLock(admin, timeMs, mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2319 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2320 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2321 | } |
| 2322 | } |
| 2323 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2324 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2325 | /** |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2326 | * Retrieve the current maximum time to unlock for a particular admin or all admins that set |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 2327 | * restrictions on this user and its participating profiles. Restrictions on profiles that have |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 2328 | * a separate challenge are not taken into account. |
| 2329 | * |
| 2330 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 2331 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 2332 | * restrictions on the parent profile. |
| 2333 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2334 | * @param admin The name of the admin component to check, or {@code null} to aggregate |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 2335 | * all admins. |
Jim Miller | d4efaac | 2014-08-14 18:02:45 -0700 | [diff] [blame] | 2336 | * @return time in milliseconds for the given admin or the minimum value (strictest) of |
Jim Miller | 76b9b8b | 2014-08-22 17:04:57 -0700 | [diff] [blame] | 2337 | * all admins if admin is null. Returns 0 if there are no restrictions. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2338 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2339 | public long getMaximumTimeToLock(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 2340 | return getMaximumTimeToLock(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 2341 | } |
| 2342 | |
| 2343 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2344 | public long getMaximumTimeToLock(@Nullable ComponentName admin, int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2345 | if (mService != null) { |
| 2346 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 2347 | return mService.getMaximumTimeToLock(admin, userHandle, mParentInstance); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2348 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2349 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2350 | } |
| 2351 | } |
| 2352 | return 0; |
| 2353 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2354 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2355 | /** |
Ricky Wai | 035e924 | 2016-03-18 16:43:31 +0000 | [diff] [blame] | 2356 | * Returns maximum time to lock that applied by all profiles in this user. We do this because we |
| 2357 | * do not have a separate timeout to lock for work challenge only. |
| 2358 | * |
| 2359 | * @hide |
| 2360 | */ |
| 2361 | public long getMaximumTimeToLockForUserAndProfiles(int userHandle) { |
| 2362 | if (mService != null) { |
| 2363 | try { |
| 2364 | return mService.getMaximumTimeToLockForUserAndProfiles(userHandle); |
| 2365 | } catch (RemoteException e) { |
| 2366 | throw e.rethrowFromSystemServer(); |
| 2367 | } |
| 2368 | } |
| 2369 | return 0; |
| 2370 | } |
| 2371 | |
| 2372 | /** |
Michal Karpinski | 8f010dd | 2016-06-21 15:05:53 +0100 | [diff] [blame] | 2373 | * Called by a device/profile owner to set the timeout after which unlocking with secondary, non |
| 2374 | * strong auth (e.g. fingerprint, trust agents) times out, i.e. the user has to use a strong |
| 2375 | * authentication method like password, pin or pattern. |
| 2376 | * |
| 2377 | * <p>This timeout is used internally to reset the timer to require strong auth again after |
| 2378 | * specified timeout each time it has been successfully used. |
| 2379 | * |
| 2380 | * <p>Fingerprint can also be disabled altogether using {@link #KEYGUARD_DISABLE_FINGERPRINT}. |
| 2381 | * |
| 2382 | * <p>Trust agents can also be disabled altogether using {@link #KEYGUARD_DISABLE_TRUST_AGENTS}. |
| 2383 | * |
| 2384 | * <p>The calling device admin must be a device or profile owner. If it is not, |
| 2385 | * a {@link SecurityException} will be thrown. |
| 2386 | * |
Michal Karpinski | 943aabd | 2016-10-06 11:09:25 +0100 | [diff] [blame] | 2387 | * <p>The calling device admin can verify the value it has set by calling |
| 2388 | * {@link #getRequiredStrongAuthTimeout(ComponentName)} and passing in its instance. |
| 2389 | * |
Michal Karpinski | 8f010dd | 2016-06-21 15:05:53 +0100 | [diff] [blame] | 2390 | * <p>This method can be called on the {@link DevicePolicyManager} instance returned by |
| 2391 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 2392 | * profile. |
| 2393 | * |
| 2394 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 2395 | * @param timeoutMs The new timeout, after which the user will have to unlock with strong |
Michal Karpinski | 943aabd | 2016-10-06 11:09:25 +0100 | [diff] [blame] | 2396 | * authentication method. A value of 0 means the admin is not participating in |
| 2397 | * controlling the timeout. |
| 2398 | * The minimum and maximum timeouts are platform-defined and are typically 1 hour and |
| 2399 | * 72 hours, respectively. Though discouraged, the admin may choose to require strong |
| 2400 | * auth at all times using {@link #KEYGUARD_DISABLE_FINGERPRINT} and/or |
| 2401 | * {@link #KEYGUARD_DISABLE_TRUST_AGENTS}. |
Michal Karpinski | 8f010dd | 2016-06-21 15:05:53 +0100 | [diff] [blame] | 2402 | * |
| 2403 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Michal Karpinski | 8f010dd | 2016-06-21 15:05:53 +0100 | [diff] [blame] | 2404 | * |
| 2405 | * @hide |
| 2406 | */ |
| 2407 | public void setRequiredStrongAuthTimeout(@NonNull ComponentName admin, |
| 2408 | long timeoutMs) { |
| 2409 | if (mService != null) { |
| 2410 | try { |
| 2411 | mService.setRequiredStrongAuthTimeout(admin, timeoutMs, mParentInstance); |
| 2412 | } catch (RemoteException e) { |
| 2413 | throw e.rethrowFromSystemServer(); |
| 2414 | } |
| 2415 | } |
| 2416 | } |
| 2417 | |
| 2418 | /** |
| 2419 | * Determine for how long the user will be able to use secondary, non strong auth for |
| 2420 | * authentication, since last strong method authentication (password, pin or pattern) was used. |
| 2421 | * After the returned timeout the user is required to use strong authentication method. |
| 2422 | * |
| 2423 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 2424 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 2425 | * restrictions on the parent profile. |
| 2426 | * |
| 2427 | * @param admin The name of the admin component to check, or {@code null} to aggregate |
| 2428 | * accross all participating admins. |
Michal Karpinski | 943aabd | 2016-10-06 11:09:25 +0100 | [diff] [blame] | 2429 | * @return The timeout or 0 if not configured for the provided admin. |
Michal Karpinski | 8f010dd | 2016-06-21 15:05:53 +0100 | [diff] [blame] | 2430 | * |
| 2431 | * @hide |
| 2432 | */ |
| 2433 | public long getRequiredStrongAuthTimeout(@Nullable ComponentName admin) { |
| 2434 | return getRequiredStrongAuthTimeout(admin, myUserId()); |
| 2435 | } |
| 2436 | |
| 2437 | /** @hide per-user version */ |
| 2438 | public long getRequiredStrongAuthTimeout(@Nullable ComponentName admin, @UserIdInt int userId) { |
| 2439 | if (mService != null) { |
| 2440 | try { |
| 2441 | return mService.getRequiredStrongAuthTimeout(admin, userId, mParentInstance); |
| 2442 | } catch (RemoteException e) { |
| 2443 | throw e.rethrowFromSystemServer(); |
| 2444 | } |
| 2445 | } |
| 2446 | return DEFAULT_STRONG_AUTH_TIMEOUT_MS; |
| 2447 | } |
| 2448 | |
| 2449 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2450 | * Make the device lock immediately, as if the lock screen timeout has expired at the point of |
| 2451 | * this call. |
| 2452 | * <p> |
| 2453 | * The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} |
| 2454 | * to be able to call this method; if it has not, a security exception will be thrown. |
| 2455 | * <p> |
| 2456 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 2457 | * {@link #getParentProfileInstance(ComponentName)} in order to lock the parent profile. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2458 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2459 | * @throws SecurityException if the calling application does not own an active administrator |
| 2460 | * that uses {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2461 | */ |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2462 | public void lockNow() { |
| 2463 | if (mService != null) { |
| 2464 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 2465 | mService.lockNow(mParentInstance); |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2466 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2467 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 2468 | } |
| 2469 | } |
| 2470 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2471 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2472 | /** |
Dianne Hackborn | 4249917 | 2010-10-15 18:45:07 -0700 | [diff] [blame] | 2473 | * Flag for {@link #wipeData(int)}: also erase the device's external |
Paul Crowley | a7e87ac | 2014-11-18 13:50:19 +0000 | [diff] [blame] | 2474 | * storage (such as SD cards). |
Dianne Hackborn | 4249917 | 2010-10-15 18:45:07 -0700 | [diff] [blame] | 2475 | */ |
| 2476 | public static final int WIPE_EXTERNAL_STORAGE = 0x0001; |
| 2477 | |
| 2478 | /** |
Paul Crowley | a7e87ac | 2014-11-18 13:50:19 +0000 | [diff] [blame] | 2479 | * Flag for {@link #wipeData(int)}: also erase the factory reset protection |
| 2480 | * data. |
| 2481 | * |
Paul Crowley | 2934b26 | 2014-12-02 11:21:13 +0000 | [diff] [blame] | 2482 | * <p>This flag may only be set by device owner admins; if it is set by |
| 2483 | * other admins a {@link SecurityException} will be thrown. |
Paul Crowley | a7e87ac | 2014-11-18 13:50:19 +0000 | [diff] [blame] | 2484 | */ |
| 2485 | public static final int WIPE_RESET_PROTECTION_DATA = 0x0002; |
| 2486 | |
| 2487 | /** |
Suprabh Shukla | 556b05a | 2016-08-10 15:49:24 -0700 | [diff] [blame] | 2488 | * Ask that all user data be wiped. If called as a secondary user, the user will be removed and |
| 2489 | * other users will remain unaffected. Calling from the primary user will cause the device to |
| 2490 | * reboot, erasing all device data - including all the secondary users and their data - while |
| 2491 | * booting up. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2492 | * <p> |
| 2493 | * The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to |
| 2494 | * be able to call this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2495 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2496 | * @param flags Bit mask of additional options: currently supported flags are |
| 2497 | * {@link #WIPE_EXTERNAL_STORAGE} and {@link #WIPE_RESET_PROTECTION_DATA}. |
| 2498 | * @throws SecurityException if the calling application does not own an active administrator |
| 2499 | * that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2500 | */ |
| 2501 | public void wipeData(int flags) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2502 | throwIfParentInstance("wipeData"); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2503 | if (mService != null) { |
| 2504 | try { |
Makoto Onuki | 70f929e | 2015-11-11 12:40:15 -0800 | [diff] [blame] | 2505 | mService.wipeData(flags); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2506 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2507 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2508 | } |
| 2509 | } |
| 2510 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 2511 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2512 | /** |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2513 | * Called by an application that is administering the device to set the |
| 2514 | * global proxy and exclusion list. |
| 2515 | * <p> |
| 2516 | * The calling device admin must have requested |
| 2517 | * {@link DeviceAdminInfo#USES_POLICY_SETS_GLOBAL_PROXY} to be able to call |
| 2518 | * this method; if it has not, a security exception will be thrown. |
| 2519 | * Only the first device admin can set the proxy. If a second admin attempts |
| 2520 | * to set the proxy, the {@link ComponentName} of the admin originally setting the |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2521 | * proxy will be returned. If successful in setting the proxy, {@code null} will |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2522 | * be returned. |
| 2523 | * The method can be called repeatedly by the device admin alrady setting the |
| 2524 | * proxy to update the proxy and exclusion list. |
| 2525 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2526 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2527 | * @param proxySpec the global proxy desired. Must be an HTTP Proxy. |
| 2528 | * Pass Proxy.NO_PROXY to reset the proxy. |
| 2529 | * @param exclusionList a list of domains to be excluded from the global proxy. |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2530 | * @return {@code null} if the proxy was successfully set, or otherwise a {@link ComponentName} |
| 2531 | * of the device admin that sets the proxy. |
Andy Stadler | d267272 | 2011-02-16 10:53:33 -0800 | [diff] [blame] | 2532 | * @hide |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2533 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 2534 | public @Nullable ComponentName setGlobalProxy(@NonNull ComponentName admin, Proxy proxySpec, |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2535 | List<String> exclusionList ) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2536 | throwIfParentInstance("setGlobalProxy"); |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2537 | if (proxySpec == null) { |
| 2538 | throw new NullPointerException(); |
| 2539 | } |
| 2540 | if (mService != null) { |
| 2541 | try { |
| 2542 | String hostSpec; |
| 2543 | String exclSpec; |
| 2544 | if (proxySpec.equals(Proxy.NO_PROXY)) { |
| 2545 | hostSpec = null; |
| 2546 | exclSpec = null; |
| 2547 | } else { |
| 2548 | if (!proxySpec.type().equals(Proxy.Type.HTTP)) { |
| 2549 | throw new IllegalArgumentException(); |
| 2550 | } |
| 2551 | InetSocketAddress sa = (InetSocketAddress)proxySpec.address(); |
| 2552 | String hostName = sa.getHostName(); |
| 2553 | int port = sa.getPort(); |
| 2554 | StringBuilder hostBuilder = new StringBuilder(); |
| 2555 | hostSpec = hostBuilder.append(hostName) |
| 2556 | .append(":").append(Integer.toString(port)).toString(); |
| 2557 | if (exclusionList == null) { |
| 2558 | exclSpec = ""; |
| 2559 | } else { |
| 2560 | StringBuilder listBuilder = new StringBuilder(); |
| 2561 | boolean firstDomain = true; |
| 2562 | for (String exclDomain : exclusionList) { |
| 2563 | if (!firstDomain) { |
| 2564 | listBuilder = listBuilder.append(","); |
| 2565 | } else { |
| 2566 | firstDomain = false; |
| 2567 | } |
| 2568 | listBuilder = listBuilder.append(exclDomain.trim()); |
| 2569 | } |
| 2570 | exclSpec = listBuilder.toString(); |
| 2571 | } |
Yuhao Zheng | 9070484 | 2014-02-28 17:22:45 -0800 | [diff] [blame] | 2572 | if (android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec) |
| 2573 | != android.net.Proxy.PROXY_VALID) |
| 2574 | throw new IllegalArgumentException(); |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2575 | } |
Fyodor Kupolov | bdc58c6 | 2015-01-29 13:24:03 -0800 | [diff] [blame] | 2576 | return mService.setGlobalProxy(admin, hostSpec, exclSpec); |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2577 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2578 | throw e.rethrowFromSystemServer(); |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2579 | } |
| 2580 | } |
| 2581 | return null; |
| 2582 | } |
| 2583 | |
| 2584 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2585 | * Set a network-independent global HTTP proxy. This is not normally what you want for typical |
| 2586 | * HTTP proxies - they are generally network dependent. However if you're doing something |
| 2587 | * unusual like general internal filtering this may be useful. On a private network where the |
| 2588 | * proxy is not accessible, you may break HTTP using this. |
| 2589 | * <p> |
| 2590 | * This method requires the caller to be the device owner. |
| 2591 | * <p> |
| 2592 | * This proxy is only a recommendation and it is possible that some apps will ignore it. |
Jason Monk | 03bc991 | 2014-05-13 09:44:57 -0400 | [diff] [blame] | 2593 | * |
Jason Monk | 03bc991 | 2014-05-13 09:44:57 -0400 | [diff] [blame] | 2594 | * @see ProxyInfo |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2595 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 2596 | * @param proxyInfo The a {@link ProxyInfo} object defining the new global HTTP proxy. A |
| 2597 | * {@code null} value will clear the global HTTP proxy. |
| 2598 | * @throws SecurityException if {@code admin} is not the device owner. |
Jason Monk | 03bc991 | 2014-05-13 09:44:57 -0400 | [diff] [blame] | 2599 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2600 | public void setRecommendedGlobalProxy(@NonNull ComponentName admin, @Nullable ProxyInfo |
| 2601 | proxyInfo) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2602 | throwIfParentInstance("setRecommendedGlobalProxy"); |
Jason Monk | 03bc991 | 2014-05-13 09:44:57 -0400 | [diff] [blame] | 2603 | if (mService != null) { |
| 2604 | try { |
| 2605 | mService.setRecommendedGlobalProxy(admin, proxyInfo); |
| 2606 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2607 | throw e.rethrowFromSystemServer(); |
Jason Monk | 03bc991 | 2014-05-13 09:44:57 -0400 | [diff] [blame] | 2608 | } |
| 2609 | } |
| 2610 | } |
| 2611 | |
| 2612 | /** |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2613 | * Returns the component name setting the global proxy. |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2614 | * @return ComponentName object of the device admin that set the global proxy, or {@code null} |
| 2615 | * if no admin has set the proxy. |
Andy Stadler | d267272 | 2011-02-16 10:53:33 -0800 | [diff] [blame] | 2616 | * @hide |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2617 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 2618 | public @Nullable ComponentName getGlobalProxyAdmin() { |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2619 | if (mService != null) { |
| 2620 | try { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 2621 | return mService.getGlobalProxyAdmin(myUserId()); |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2622 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2623 | throw e.rethrowFromSystemServer(); |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 2624 | } |
| 2625 | } |
| 2626 | return null; |
| 2627 | } |
| 2628 | |
| 2629 | /** |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2630 | * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2631 | * indicating that encryption is not supported. |
| 2632 | */ |
| 2633 | public static final int ENCRYPTION_STATUS_UNSUPPORTED = 0; |
| 2634 | |
| 2635 | /** |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2636 | * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2637 | * indicating that encryption is supported, but is not currently active. |
| 2638 | */ |
| 2639 | public static final int ENCRYPTION_STATUS_INACTIVE = 1; |
| 2640 | |
| 2641 | /** |
Robin Lee | 3795fb0 | 2015-02-16 14:17:23 +0000 | [diff] [blame] | 2642 | * Result code for {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2643 | * indicating that encryption is not currently active, but is currently |
| 2644 | * being activated. This is only reported by devices that support |
| 2645 | * encryption of data and only when the storage is currently |
| 2646 | * undergoing a process of becoming encrypted. A device that must reboot and/or wipe data |
| 2647 | * to become encrypted will never return this value. |
| 2648 | */ |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2649 | public static final int ENCRYPTION_STATUS_ACTIVATING = 2; |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2650 | |
| 2651 | /** |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2652 | * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2653 | * indicating that encryption is active. |
Amith Yamasani | 75db125 | 2016-07-11 14:41:01 -0700 | [diff] [blame] | 2654 | * <p> |
| 2655 | * Also see {@link #ENCRYPTION_STATUS_ACTIVE_PER_USER}. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2656 | */ |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2657 | public static final int ENCRYPTION_STATUS_ACTIVE = 3; |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2658 | |
| 2659 | /** |
Robin Lee | 3795fb0 | 2015-02-16 14:17:23 +0000 | [diff] [blame] | 2660 | * Result code for {@link #getStorageEncryptionStatus}: |
| 2661 | * indicating that encryption is active, but an encryption key has not |
| 2662 | * been set by the user. |
| 2663 | */ |
| 2664 | public static final int ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY = 4; |
| 2665 | |
| 2666 | /** |
Makoto Onuki | d4c9e54 | 2016-02-25 18:17:30 -0800 | [diff] [blame] | 2667 | * Result code for {@link #getStorageEncryptionStatus}: |
Amith Yamasani | 75db125 | 2016-07-11 14:41:01 -0700 | [diff] [blame] | 2668 | * indicating that encryption is active and the encryption key is tied to the user or profile. |
| 2669 | * <p> |
| 2670 | * This value is only returned to apps targeting API level 24 and above. For apps targeting |
| 2671 | * earlier API levels, {@link #ENCRYPTION_STATUS_ACTIVE} is returned, even if the |
| 2672 | * encryption key is specific to the user or profile. |
Makoto Onuki | d4c9e54 | 2016-02-25 18:17:30 -0800 | [diff] [blame] | 2673 | */ |
| 2674 | public static final int ENCRYPTION_STATUS_ACTIVE_PER_USER = 5; |
| 2675 | |
| 2676 | /** |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2677 | * Activity action: begin the process of encrypting data on the device. This activity should |
| 2678 | * be launched after using {@link #setStorageEncryption} to request encryption be activated. |
| 2679 | * After resuming from this activity, use {@link #getStorageEncryption} |
| 2680 | * to check encryption status. However, on some devices this activity may never return, as |
| 2681 | * it may trigger a reboot and in some cases a complete data wipe of the device. |
| 2682 | */ |
| 2683 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 2684 | public static final String ACTION_START_ENCRYPTION |
| 2685 | = "android.app.action.START_ENCRYPTION"; |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2686 | /** |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 2687 | * Widgets are enabled in keyguard |
| 2688 | */ |
Jim Miller | 48b9b0d | 2012-09-19 23:16:50 -0700 | [diff] [blame] | 2689 | public static final int KEYGUARD_DISABLE_FEATURES_NONE = 0; |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 2690 | |
| 2691 | /** |
Jim Miller | 50e6218 | 2014-04-23 17:25:00 -0700 | [diff] [blame] | 2692 | * Disable all keyguard widgets. Has no effect. |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 2693 | */ |
Jim Miller | 48b9b0d | 2012-09-19 23:16:50 -0700 | [diff] [blame] | 2694 | public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1 << 0; |
| 2695 | |
| 2696 | /** |
| 2697 | * Disable the camera on secure keyguard screens (e.g. PIN/Pattern/Password) |
| 2698 | */ |
| 2699 | public static final int KEYGUARD_DISABLE_SECURE_CAMERA = 1 << 1; |
| 2700 | |
| 2701 | /** |
Jim Miller | 50e6218 | 2014-04-23 17:25:00 -0700 | [diff] [blame] | 2702 | * Disable showing all notifications on secure keyguard screens (e.g. PIN/Pattern/Password) |
| 2703 | */ |
| 2704 | public static final int KEYGUARD_DISABLE_SECURE_NOTIFICATIONS = 1 << 2; |
| 2705 | |
| 2706 | /** |
| 2707 | * Only allow redacted notifications on secure keyguard screens (e.g. PIN/Pattern/Password) |
| 2708 | */ |
| 2709 | public static final int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS = 1 << 3; |
| 2710 | |
| 2711 | /** |
Adrian Roos | a06d5ca | 2014-07-28 15:14:21 +0200 | [diff] [blame] | 2712 | * Ignore trust agent state on secure keyguard screens |
Jim Miller | 50e6218 | 2014-04-23 17:25:00 -0700 | [diff] [blame] | 2713 | * (e.g. PIN/Pattern/Password). |
| 2714 | */ |
| 2715 | public static final int KEYGUARD_DISABLE_TRUST_AGENTS = 1 << 4; |
| 2716 | |
| 2717 | /** |
Jim Miller | 06e3450 | 2014-07-17 14:46:05 -0700 | [diff] [blame] | 2718 | * Disable fingerprint sensor on keyguard secure screens (e.g. PIN/Pattern/Password). |
| 2719 | */ |
| 2720 | public static final int KEYGUARD_DISABLE_FINGERPRINT = 1 << 5; |
| 2721 | |
| 2722 | /** |
Adrian Roos | 7f06eed | 2016-02-05 15:21:02 -0800 | [diff] [blame] | 2723 | * Disable text entry into notifications on secure keyguard screens (e.g. PIN/Pattern/Password). |
| 2724 | */ |
| 2725 | public static final int KEYGUARD_DISABLE_REMOTE_INPUT = 1 << 6; |
| 2726 | |
| 2727 | /** |
Jim Miller | 3520774 | 2012-11-02 15:33:20 -0700 | [diff] [blame] | 2728 | * Disable all current and future keyguard customizations. |
Jim Miller | 48b9b0d | 2012-09-19 23:16:50 -0700 | [diff] [blame] | 2729 | */ |
| 2730 | public static final int KEYGUARD_DISABLE_FEATURES_ALL = 0x7fffffff; |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 2731 | |
| 2732 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2733 | * Called by an application that is administering the device to request that the storage system |
| 2734 | * be encrypted. |
| 2735 | * <p> |
| 2736 | * When multiple device administrators attempt to control device encryption, the most secure, |
| 2737 | * supported setting will always be used. If any device administrator requests device |
| 2738 | * encryption, it will be enabled; Conversely, if a device administrator attempts to disable |
| 2739 | * device encryption while another device administrator has enabled it, the call to disable will |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2740 | * fail (most commonly returning {@link #ENCRYPTION_STATUS_ACTIVE}). |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2741 | * <p> |
| 2742 | * This policy controls encryption of the secure (application data) storage area. Data written |
| 2743 | * to other storage areas may or may not be encrypted, and this policy does not require or |
| 2744 | * control the encryption of any other storage areas. There is one exception: If |
| 2745 | * {@link android.os.Environment#isExternalStorageEmulated()} is {@code true}, then the |
| 2746 | * directory returned by {@link android.os.Environment#getExternalStorageDirectory()} must be |
| 2747 | * written to disk within the encrypted storage area. |
| 2748 | * <p> |
| 2749 | * Important Note: On some devices, it is possible to encrypt storage without requiring the user |
| 2750 | * to create a device PIN or Password. In this case, the storage is encrypted, but the |
| 2751 | * encryption key may not be fully secured. For maximum security, the administrator should also |
| 2752 | * require (and check for) a pattern, PIN, or password. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2753 | * |
| 2754 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 2755 | * @param encrypt true to request encryption, false to release any previous request |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2756 | * @return the new request status (for all active admins) - will be one of |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2757 | * {@link #ENCRYPTION_STATUS_UNSUPPORTED}, {@link #ENCRYPTION_STATUS_INACTIVE}, or |
| 2758 | * {@link #ENCRYPTION_STATUS_ACTIVE}. This is the value of the requests; Use |
| 2759 | * {@link #getStorageEncryptionStatus()} to query the actual device state. |
| 2760 | * @throws SecurityException if {@code admin} is not an active administrator or does not use |
| 2761 | * {@link DeviceAdminInfo#USES_ENCRYPTED_STORAGE} |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2762 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2763 | public int setStorageEncryption(@NonNull ComponentName admin, boolean encrypt) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2764 | throwIfParentInstance("setStorageEncryption"); |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2765 | if (mService != null) { |
| 2766 | try { |
Fyodor Kupolov | bdc58c6 | 2015-01-29 13:24:03 -0800 | [diff] [blame] | 2767 | return mService.setStorageEncryption(admin, encrypt); |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2768 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2769 | throw e.rethrowFromSystemServer(); |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2770 | } |
| 2771 | } |
| 2772 | return ENCRYPTION_STATUS_UNSUPPORTED; |
| 2773 | } |
| 2774 | |
| 2775 | /** |
| 2776 | * Called by an application that is administering the device to |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2777 | * determine the requested setting for secure storage. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2778 | * |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2779 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. If null, |
| 2780 | * this will return the requested encryption setting as an aggregate of all active |
| 2781 | * administrators. |
| 2782 | * @return true if the admin(s) are requesting encryption, false if not. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2783 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2784 | public boolean getStorageEncryption(@Nullable ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2785 | throwIfParentInstance("getStorageEncryption"); |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2786 | if (mService != null) { |
| 2787 | try { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 2788 | return mService.getStorageEncryption(admin, myUserId()); |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2789 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2790 | throw e.rethrowFromSystemServer(); |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2791 | } |
| 2792 | } |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2793 | return false; |
| 2794 | } |
| 2795 | |
| 2796 | /** |
| 2797 | * Called by an application that is administering the device to |
| 2798 | * determine the current encryption status of the device. |
Amith Yamasani | 75db125 | 2016-07-11 14:41:01 -0700 | [diff] [blame] | 2799 | * <p> |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2800 | * Depending on the returned status code, the caller may proceed in different |
| 2801 | * ways. If the result is {@link #ENCRYPTION_STATUS_UNSUPPORTED}, the |
| 2802 | * storage system does not support encryption. If the |
| 2803 | * result is {@link #ENCRYPTION_STATUS_INACTIVE}, use {@link |
| 2804 | * #ACTION_START_ENCRYPTION} to begin the process of encrypting or decrypting the |
Robin Lee | 3795fb0 | 2015-02-16 14:17:23 +0000 | [diff] [blame] | 2805 | * storage. If the result is {@link #ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY}, the |
| 2806 | * storage system has enabled encryption but no password is set so further action |
Amith Yamasani | 75db125 | 2016-07-11 14:41:01 -0700 | [diff] [blame] | 2807 | * may be required. If the result is {@link #ENCRYPTION_STATUS_ACTIVATING}, |
| 2808 | * {@link #ENCRYPTION_STATUS_ACTIVE} or {@link #ENCRYPTION_STATUS_ACTIVE_PER_USER}, |
| 2809 | * no further action is required. |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2810 | * |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2811 | * @return current status of encryption. The value will be one of |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2812 | * {@link #ENCRYPTION_STATUS_UNSUPPORTED}, {@link #ENCRYPTION_STATUS_INACTIVE}, |
Robin Lee | 3795fb0 | 2015-02-16 14:17:23 +0000 | [diff] [blame] | 2813 | * {@link #ENCRYPTION_STATUS_ACTIVATING}, {@link #ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY}, |
Amith Yamasani | 75db125 | 2016-07-11 14:41:01 -0700 | [diff] [blame] | 2814 | * {@link #ENCRYPTION_STATUS_ACTIVE}, or {@link #ENCRYPTION_STATUS_ACTIVE_PER_USER}. |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2815 | */ |
| 2816 | public int getStorageEncryptionStatus() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2817 | throwIfParentInstance("getStorageEncryptionStatus"); |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 2818 | return getStorageEncryptionStatus(myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 2819 | } |
| 2820 | |
| 2821 | /** @hide per-user version */ |
| 2822 | public int getStorageEncryptionStatus(int userHandle) { |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2823 | if (mService != null) { |
| 2824 | try { |
Makoto Onuki | d4c9e54 | 2016-02-25 18:17:30 -0800 | [diff] [blame] | 2825 | return mService.getStorageEncryptionStatus(mContext.getPackageName(), userHandle); |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2826 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2827 | throw e.rethrowFromSystemServer(); |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 2828 | } |
| 2829 | } |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 2830 | return ENCRYPTION_STATUS_UNSUPPORTED; |
| 2831 | } |
| 2832 | |
| 2833 | /** |
Robin Lee | 2f7e1e4 | 2016-03-21 10:50:01 +0000 | [diff] [blame] | 2834 | * Mark a CA certificate as approved by the device user. This means that they have been notified |
| 2835 | * of the installation, were made aware of the risks, viewed the certificate and still wanted to |
| 2836 | * keep the certificate on the device. |
| 2837 | * |
| 2838 | * Calling with {@param approval} as {@code true} will cancel any ongoing warnings related to |
| 2839 | * this certificate. |
| 2840 | * |
| 2841 | * @hide |
| 2842 | */ |
| 2843 | public boolean approveCaCert(String alias, int userHandle, boolean approval) { |
| 2844 | if (mService != null) { |
| 2845 | try { |
| 2846 | return mService.approveCaCert(alias, userHandle, approval); |
| 2847 | } catch (RemoteException e) { |
| 2848 | throw e.rethrowFromSystemServer(); |
| 2849 | } |
| 2850 | } |
| 2851 | return false; |
| 2852 | } |
| 2853 | |
| 2854 | /** |
| 2855 | * Check whether a CA certificate has been approved by the device user. |
| 2856 | * |
| 2857 | * @hide |
| 2858 | */ |
| 2859 | public boolean isCaCertApproved(String alias, int userHandle) { |
| 2860 | if (mService != null) { |
| 2861 | try { |
| 2862 | return mService.isCaCertApproved(alias, userHandle); |
| 2863 | } catch (RemoteException e) { |
| 2864 | throw e.rethrowFromSystemServer(); |
| 2865 | } |
| 2866 | } |
| 2867 | return false; |
| 2868 | } |
| 2869 | |
| 2870 | /** |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2871 | * Installs the given certificate as a user CA. |
| 2872 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2873 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
| 2874 | * {@code null} if calling from a delegated certificate installer. |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2875 | * @param certBuffer encoded form of the certificate to install. |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2876 | * |
| 2877 | * @return false if the certBuffer cannot be parsed or installation is |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2878 | * interrupted, true otherwise. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2879 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 2880 | * owner. |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2881 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2882 | public boolean installCaCert(@Nullable ComponentName admin, byte[] certBuffer) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2883 | throwIfParentInstance("installCaCert"); |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2884 | if (mService != null) { |
| 2885 | try { |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2886 | return mService.installCaCert(admin, certBuffer); |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2887 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2888 | throw e.rethrowFromSystemServer(); |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2889 | } |
| 2890 | } |
| 2891 | return false; |
| 2892 | } |
| 2893 | |
| 2894 | /** |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2895 | * Uninstalls the given certificate from trusted user CAs, if present. |
| 2896 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2897 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
| 2898 | * {@code null} if calling from a delegated certificate installer. |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2899 | * @param certBuffer encoded form of the certificate to remove. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2900 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 2901 | * owner. |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2902 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2903 | public void uninstallCaCert(@Nullable ComponentName admin, byte[] certBuffer) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2904 | throwIfParentInstance("uninstallCaCert"); |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2905 | if (mService != null) { |
| 2906 | try { |
Robin Lee | 306fe08 | 2014-06-19 14:04:24 +0000 | [diff] [blame] | 2907 | final String alias = getCaCertAlias(certBuffer); |
Robin Lee | 83881bd | 2015-06-09 16:04:38 -0700 | [diff] [blame] | 2908 | mService.uninstallCaCerts(admin, new String[] {alias}); |
Robin Lee | 306fe08 | 2014-06-19 14:04:24 +0000 | [diff] [blame] | 2909 | } catch (CertificateException e) { |
| 2910 | Log.w(TAG, "Unable to parse certificate", e); |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2911 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2912 | throw e.rethrowFromSystemServer(); |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2913 | } |
| 2914 | } |
| 2915 | } |
| 2916 | |
| 2917 | /** |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2918 | * Returns all CA certificates that are currently trusted, excluding system CA certificates. |
| 2919 | * If a user has installed any certificates by other means than device policy these will be |
| 2920 | * included too. |
| 2921 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2922 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
| 2923 | * {@code null} if calling from a delegated certificate installer. |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2924 | * @return a List of byte[] arrays, each encoding one user CA certificate. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2925 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 2926 | * owner. |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2927 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 2928 | public @NonNull List<byte[]> getInstalledCaCerts(@Nullable ComponentName admin) { |
| 2929 | final List<byte[]> certs = new ArrayList<byte[]>(); |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2930 | throwIfParentInstance("getInstalledCaCerts"); |
Esteban Talavera | 808f6ef | 2014-08-28 17:15:54 +0100 | [diff] [blame] | 2931 | if (mService != null) { |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2932 | try { |
Esteban Talavera | 808f6ef | 2014-08-28 17:15:54 +0100 | [diff] [blame] | 2933 | mService.enforceCanManageCaCerts(admin); |
| 2934 | final TrustedCertificateStore certStore = new TrustedCertificateStore(); |
| 2935 | for (String alias : certStore.userAliases()) { |
| 2936 | try { |
| 2937 | certs.add(certStore.getCertificate(alias).getEncoded()); |
| 2938 | } catch (CertificateException ce) { |
| 2939 | Log.w(TAG, "Could not encode certificate: " + alias, ce); |
| 2940 | } |
| 2941 | } |
| 2942 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2943 | throw re.rethrowFromSystemServer(); |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2944 | } |
| 2945 | } |
| 2946 | return certs; |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2947 | } |
| 2948 | |
| 2949 | /** |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2950 | * Uninstalls all custom trusted CA certificates from the profile. Certificates installed by |
| 2951 | * means other than device policy will also be removed, except for system CA certificates. |
| 2952 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2953 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
| 2954 | * {@code null} if calling from a delegated certificate installer. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2955 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 2956 | * owner. |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2957 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2958 | public void uninstallAllUserCaCerts(@Nullable ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2959 | throwIfParentInstance("uninstallAllUserCaCerts"); |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2960 | if (mService != null) { |
Robin Lee | 83881bd | 2015-06-09 16:04:38 -0700 | [diff] [blame] | 2961 | try { |
| 2962 | mService.uninstallCaCerts(admin, new TrustedCertificateStore().userAliases() |
| 2963 | .toArray(new String[0])); |
| 2964 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2965 | throw re.rethrowFromSystemServer(); |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2966 | } |
| 2967 | } |
| 2968 | } |
| 2969 | |
| 2970 | /** |
| 2971 | * Returns whether this certificate is installed as a trusted CA. |
| 2972 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2973 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
| 2974 | * {@code null} if calling from a delegated certificate installer. |
Robin Lee | 7e67871 | 2014-07-24 16:41:31 +0100 | [diff] [blame] | 2975 | * @param certBuffer encoded form of the certificate to look up. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 2976 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 2977 | * owner. |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2978 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 2979 | public boolean hasCaCertInstalled(@Nullable ComponentName admin, byte[] certBuffer) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 2980 | throwIfParentInstance("hasCaCertInstalled"); |
Esteban Talavera | 808f6ef | 2014-08-28 17:15:54 +0100 | [diff] [blame] | 2981 | if (mService != null) { |
| 2982 | try { |
| 2983 | mService.enforceCanManageCaCerts(admin); |
| 2984 | return getCaCertAlias(certBuffer) != null; |
| 2985 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 2986 | throw re.rethrowFromSystemServer(); |
Esteban Talavera | 808f6ef | 2014-08-28 17:15:54 +0100 | [diff] [blame] | 2987 | } catch (CertificateException ce) { |
| 2988 | Log.w(TAG, "Could not parse certificate", ce); |
| 2989 | } |
Maggie Benthall | da51e68 | 2013-08-08 22:35:44 -0400 | [diff] [blame] | 2990 | } |
| 2991 | return false; |
| 2992 | } |
| 2993 | |
| 2994 | /** |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 2995 | * Called by a device or profile owner, or delegated certificate installer, to install a |
| 2996 | * certificate and corresponding private key. All apps within the profile will be able to access |
| 2997 | * the certificate and use the private key, given direct user approval. |
| 2998 | * |
| 2999 | * <p>Access to the installed credentials will not be granted to the caller of this API without |
| 3000 | * direct user approval. This is for security - should a certificate installer become |
| 3001 | * compromised, certificates it had already installed will be protected. |
| 3002 | * |
| 3003 | * <p>If the installer must have access to the credentials, call |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3004 | * {@link #installKeyPair(ComponentName, PrivateKey, Certificate[], String, boolean)} instead. |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 3005 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3006 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
| 3007 | * {@code null} if calling from a delegated certificate installer. |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 3008 | * @param privKey The private key to install. |
| 3009 | * @param cert The certificate to install. |
| 3010 | * @param alias The private key alias under which to install the certificate. If a certificate |
| 3011 | * with that alias already exists, it will be overwritten. |
| 3012 | * @return {@code true} if the keys were installed, {@code false} otherwise. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3013 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 3014 | * owner. |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 3015 | */ |
Robin Lee | fbc6564 | 2015-08-03 16:21:22 +0100 | [diff] [blame] | 3016 | public boolean installKeyPair(@Nullable ComponentName admin, @NonNull PrivateKey privKey, |
| 3017 | @NonNull Certificate cert, @NonNull String alias) { |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3018 | return installKeyPair(admin, privKey, new Certificate[] {cert}, alias, false); |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3019 | } |
| 3020 | |
| 3021 | /** |
| 3022 | * Called by a device or profile owner, or delegated certificate installer, to install a |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3023 | * certificate chain and corresponding private key for the leaf certificate. All apps within the |
| 3024 | * profile will be able to access the certificate chain and use the private key, given direct |
| 3025 | * user approval. |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3026 | * |
Robin Lee | a1b290e | 2016-03-09 14:38:36 +0000 | [diff] [blame] | 3027 | * <p>The caller of this API may grant itself access to the certificate and private key |
| 3028 | * immediately, without user approval. It is a best practice not to request this unless strictly |
| 3029 | * necessary since it opens up additional security vulnerabilities. |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3030 | * |
| 3031 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
Robin Lee | a1b290e | 2016-03-09 14:38:36 +0000 | [diff] [blame] | 3032 | * {@code null} if calling from a delegated certificate installer. |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3033 | * @param privKey The private key to install. |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3034 | * @param certs The certificate chain to install. The chain should start with the leaf |
| 3035 | * certificate and include the chain of trust in order. This will be returned by |
| 3036 | * {@link android.security.KeyChain#getCertificateChain}. |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3037 | * @param alias The private key alias under which to install the certificate. If a certificate |
Robin Lee | a1b290e | 2016-03-09 14:38:36 +0000 | [diff] [blame] | 3038 | * with that alias already exists, it will be overwritten. |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3039 | * @param requestAccess {@code true} to request that the calling app be granted access to the |
Robin Lee | a1b290e | 2016-03-09 14:38:36 +0000 | [diff] [blame] | 3040 | * credentials immediately. Otherwise, access to the credentials will be gated by user |
| 3041 | * approval. |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3042 | * @return {@code true} if the keys were installed, {@code false} otherwise. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3043 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 3044 | * owner. |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3045 | * @see android.security.KeyChain#getCertificateChain |
Robin Lee | ce3399f | 2016-02-24 12:08:32 +0000 | [diff] [blame] | 3046 | */ |
| 3047 | public boolean installKeyPair(@Nullable ComponentName admin, @NonNull PrivateKey privKey, |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3048 | @NonNull Certificate[] certs, @NonNull String alias, boolean requestAccess) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3049 | throwIfParentInstance("installKeyPair"); |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 3050 | try { |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3051 | final byte[] pemCert = Credentials.convertToPem(certs[0]); |
| 3052 | byte[] pemChain = null; |
| 3053 | if (certs.length > 1) { |
| 3054 | pemChain = Credentials.convertToPem(Arrays.copyOfRange(certs, 1, certs.length)); |
| 3055 | } |
Robin Lee | 0d5ccb7 | 2014-09-12 17:41:44 +0100 | [diff] [blame] | 3056 | final byte[] pkcs8Key = KeyFactory.getInstance(privKey.getAlgorithm()) |
| 3057 | .getKeySpec(privKey, PKCS8EncodedKeySpec.class).getEncoded(); |
Rubin Xu | b436591 | 2016-03-23 12:13:22 +0000 | [diff] [blame] | 3058 | return mService.installKeyPair(admin, pkcs8Key, pemCert, pemChain, alias, |
| 3059 | requestAccess); |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 3060 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3061 | throw e.rethrowFromSystemServer(); |
Robin Lee | 0d5ccb7 | 2014-09-12 17:41:44 +0100 | [diff] [blame] | 3062 | } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { |
| 3063 | Log.w(TAG, "Failed to obtain private key material", e); |
| 3064 | } catch (CertificateException | IOException e) { |
| 3065 | Log.w(TAG, "Could not pem-encode certificate", e); |
Bernhard Bauer | 26408cc | 2014-09-08 14:07:31 +0100 | [diff] [blame] | 3066 | } |
| 3067 | return false; |
| 3068 | } |
| 3069 | |
| 3070 | /** |
Robin Lee | a1b290e | 2016-03-09 14:38:36 +0000 | [diff] [blame] | 3071 | * Called by a device or profile owner, or delegated certificate installer, to remove a |
| 3072 | * certificate and private key pair installed under a given alias. |
Robin Lee | fbc6564 | 2015-08-03 16:21:22 +0100 | [diff] [blame] | 3073 | * |
| 3074 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
Robin Lee | a1b290e | 2016-03-09 14:38:36 +0000 | [diff] [blame] | 3075 | * {@code null} if calling from a delegated certificate installer. |
Robin Lee | fbc6564 | 2015-08-03 16:21:22 +0100 | [diff] [blame] | 3076 | * @param alias The private key alias under which the certificate is installed. |
Robin Lee | a1b290e | 2016-03-09 14:38:36 +0000 | [diff] [blame] | 3077 | * @return {@code true} if the private key alias no longer exists, {@code false} otherwise. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3078 | * @throws SecurityException if {@code admin} is not {@code null} and not a device or profile |
| 3079 | * owner. |
Robin Lee | fbc6564 | 2015-08-03 16:21:22 +0100 | [diff] [blame] | 3080 | */ |
| 3081 | public boolean removeKeyPair(@Nullable ComponentName admin, @NonNull String alias) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3082 | throwIfParentInstance("removeKeyPair"); |
Robin Lee | fbc6564 | 2015-08-03 16:21:22 +0100 | [diff] [blame] | 3083 | try { |
| 3084 | return mService.removeKeyPair(admin, alias); |
| 3085 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3086 | throw e.rethrowFromSystemServer(); |
Robin Lee | fbc6564 | 2015-08-03 16:21:22 +0100 | [diff] [blame] | 3087 | } |
Robin Lee | fbc6564 | 2015-08-03 16:21:22 +0100 | [diff] [blame] | 3088 | } |
| 3089 | |
| 3090 | /** |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3091 | * @return the alias of a given CA certificate in the certificate store, or {@code null} if it |
Robin Lee | 306fe08 | 2014-06-19 14:04:24 +0000 | [diff] [blame] | 3092 | * doesn't exist. |
| 3093 | */ |
| 3094 | private static String getCaCertAlias(byte[] certBuffer) throws CertificateException { |
| 3095 | final CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); |
| 3096 | final X509Certificate cert = (X509Certificate) certFactory.generateCertificate( |
| 3097 | new ByteArrayInputStream(certBuffer)); |
| 3098 | return new TrustedCertificateStore().getCertificateAlias(cert); |
| 3099 | } |
| 3100 | |
| 3101 | /** |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3102 | * Called by a profile owner or device owner to grant access to privileged certificate |
Rubin Xu | acdc183 | 2015-04-02 12:40:20 +0100 | [diff] [blame] | 3103 | * manipulation APIs to a third-party certificate installer app. Granted APIs include |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3104 | * {@link #getInstalledCaCerts}, {@link #hasCaCertInstalled}, {@link #installCaCert}, |
Rubin Xu | acdc183 | 2015-04-02 12:40:20 +0100 | [diff] [blame] | 3105 | * {@link #uninstallCaCert}, {@link #uninstallAllUserCaCerts} and {@link #installKeyPair}. |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3106 | * <p> |
| 3107 | * Delegated certificate installer is a per-user state. The delegated access is persistent until |
| 3108 | * it is later cleared by calling this method with a null value or uninstallling the certificate |
| 3109 | * installer. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3110 | * <p> |
Rubin Xu | f03d0a6 | 2016-02-10 14:54:15 +0000 | [diff] [blame] | 3111 | * <b>Note:</b>Starting from {@link android.os.Build.VERSION_CODES#N}, if the caller |
| 3112 | * application's target SDK version is {@link android.os.Build.VERSION_CODES#N} or newer, the |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3113 | * supplied certificate installer package must be installed when calling this API, otherwise an |
| 3114 | * {@link IllegalArgumentException} will be thrown. |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3115 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3116 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3117 | * @param installerPackage The package name of the certificate installer which will be given |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3118 | * access. If {@code null} is given the current package will be cleared. |
| 3119 | * @throws SecurityException if {@code admin} is not a device or a profile owner. |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3120 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3121 | public void setCertInstallerPackage(@NonNull ComponentName admin, @Nullable String |
| 3122 | installerPackage) throws SecurityException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3123 | throwIfParentInstance("setCertInstallerPackage"); |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3124 | if (mService != null) { |
| 3125 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3126 | mService.setCertInstallerPackage(admin, installerPackage); |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3127 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3128 | throw e.rethrowFromSystemServer(); |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3129 | } |
| 3130 | } |
| 3131 | } |
| 3132 | |
| 3133 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3134 | * Called by a profile owner or device owner to retrieve the certificate installer for the user. |
| 3135 | * null if none is set. |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3136 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3137 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3138 | * @return The package name of the current delegated certificate installer, or {@code null} if |
| 3139 | * none is set. |
| 3140 | * @throws SecurityException if {@code admin} is not a device or a profile owner. |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3141 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 3142 | public @Nullable String getCertInstallerPackage(@NonNull ComponentName admin) |
| 3143 | throws SecurityException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3144 | throwIfParentInstance("getCertInstallerPackage"); |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3145 | if (mService != null) { |
| 3146 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3147 | return mService.getCertInstallerPackage(admin); |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3148 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3149 | throw e.rethrowFromSystemServer(); |
Rubin Xu | ec32b56 | 2015-03-03 17:34:05 +0000 | [diff] [blame] | 3150 | } |
| 3151 | } |
| 3152 | return null; |
| 3153 | } |
| 3154 | |
| 3155 | /** |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3156 | * Called by a device or profile owner to configure an always-on VPN connection through a |
Robin Lee | dc67971 | 2016-05-03 13:23:03 +0100 | [diff] [blame] | 3157 | * specific application for the current user. |
| 3158 | * |
| 3159 | * @deprecated this version only exists for compability with previous developer preview builds. |
| 3160 | * TODO: delete once there are no longer any live references. |
| 3161 | * @hide |
| 3162 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 3163 | @Deprecated |
Robin Lee | dc67971 | 2016-05-03 13:23:03 +0100 | [diff] [blame] | 3164 | public void setAlwaysOnVpnPackage(@NonNull ComponentName admin, @Nullable String vpnPackage) |
| 3165 | throws NameNotFoundException, UnsupportedOperationException { |
| 3166 | setAlwaysOnVpnPackage(admin, vpnPackage, /* lockdownEnabled */ true); |
| 3167 | } |
| 3168 | |
| 3169 | /** |
| 3170 | * Called by a device or profile owner to configure an always-on VPN connection through a |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3171 | * specific application for the current user. This connection is automatically granted and |
| 3172 | * persisted after a reboot. |
| 3173 | * <p> |
| 3174 | * The designated package should declare a {@link android.net.VpnService} in its manifest |
| 3175 | * guarded by {@link android.Manifest.permission#BIND_VPN_SERVICE}, otherwise the call will |
| 3176 | * fail. |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3177 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3178 | * @param vpnPackage The package name for an installed VPN app on the device, or {@code null} to |
Robin Lee | dc67971 | 2016-05-03 13:23:03 +0100 | [diff] [blame] | 3179 | * remove an existing always-on VPN configuration. |
| 3180 | * @param lockdownEnabled {@code true} to disallow networking when the VPN is not connected or |
| 3181 | * {@code false} otherwise. This carries the risk that any failure of the VPN provider |
| 3182 | * could break networking for all apps. This has no effect when clearing. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3183 | * @throws SecurityException if {@code admin} is not a device or a profile owner. |
Robin Lee | ee5eb93 | 2016-04-05 16:27:15 +0100 | [diff] [blame] | 3184 | * @throws NameNotFoundException if {@code vpnPackage} is not installed. |
| 3185 | * @throws UnsupportedOperationException if {@code vpnPackage} exists but does not support being |
| 3186 | * set as always-on, or if always-on VPN is not available. |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3187 | */ |
Robin Lee | dc67971 | 2016-05-03 13:23:03 +0100 | [diff] [blame] | 3188 | public void setAlwaysOnVpnPackage(@NonNull ComponentName admin, @Nullable String vpnPackage, |
| 3189 | boolean lockdownEnabled) |
Robin Lee | ee5eb93 | 2016-04-05 16:27:15 +0100 | [diff] [blame] | 3190 | throws NameNotFoundException, UnsupportedOperationException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3191 | throwIfParentInstance("setAlwaysOnVpnPackage"); |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3192 | if (mService != null) { |
| 3193 | try { |
Robin Lee | dc67971 | 2016-05-03 13:23:03 +0100 | [diff] [blame] | 3194 | if (!mService.setAlwaysOnVpnPackage(admin, vpnPackage, lockdownEnabled)) { |
Robin Lee | ee5eb93 | 2016-04-05 16:27:15 +0100 | [diff] [blame] | 3195 | throw new NameNotFoundException(vpnPackage); |
| 3196 | } |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3197 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3198 | throw e.rethrowFromSystemServer(); |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3199 | } |
| 3200 | } |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3201 | } |
| 3202 | |
| 3203 | /** |
| 3204 | * Called by a device or profile owner to read the name of the package administering an |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3205 | * always-on VPN connection for the current user. If there is no such package, or the always-on |
| 3206 | * VPN is provided by the system instead of by an application, {@code null} will be returned. |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3207 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3208 | * @return Package name of VPN controller responsible for always-on VPN, or {@code null} if none |
| 3209 | * is set. |
| 3210 | * @throws SecurityException if {@code admin} is not a device or a profile owner. |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3211 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 3212 | public @Nullable String getAlwaysOnVpnPackage(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3213 | throwIfParentInstance("getAlwaysOnVpnPackage"); |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3214 | if (mService != null) { |
| 3215 | try { |
| 3216 | return mService.getAlwaysOnVpnPackage(admin); |
| 3217 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3218 | throw e.rethrowFromSystemServer(); |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 3219 | } |
| 3220 | } |
| 3221 | return null; |
| 3222 | } |
| 3223 | |
| 3224 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3225 | * Called by an application that is administering the device to disable all cameras on the |
| 3226 | * device, for this user. After setting this, no applications running as this user will be able |
| 3227 | * to access any cameras on the device. |
| 3228 | * <p> |
| 3229 | * If the caller is device owner, then the restriction will be applied to all users. |
| 3230 | * <p> |
| 3231 | * The calling device admin must have requested |
| 3232 | * {@link DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA} to be able to call this method; if it has |
| 3233 | * not, a security exception will be thrown. |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3234 | * |
| 3235 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 3236 | * @param disabled Whether or not the camera should be disabled. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3237 | * @throws SecurityException if {@code admin} is not an active administrator or does not use |
| 3238 | * {@link DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA}. |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3239 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3240 | public void setCameraDisabled(@NonNull ComponentName admin, boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3241 | throwIfParentInstance("setCameraDisabled"); |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3242 | if (mService != null) { |
| 3243 | try { |
Fyodor Kupolov | bdc58c6 | 2015-01-29 13:24:03 -0800 | [diff] [blame] | 3244 | mService.setCameraDisabled(admin, disabled); |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3245 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3246 | throw e.rethrowFromSystemServer(); |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3247 | } |
| 3248 | } |
| 3249 | } |
| 3250 | |
| 3251 | /** |
Amith Yamasani | 242f4b1 | 2014-10-14 16:06:13 -0700 | [diff] [blame] | 3252 | * Determine whether or not the device's cameras have been disabled for this user, |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 3253 | * either by the calling admin, if specified, or all admins. |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3254 | * @param admin The name of the admin component to check, or {@code null} to check whether any admins |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3255 | * have disabled the camera |
| 3256 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3257 | public boolean getCameraDisabled(@Nullable ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3258 | throwIfParentInstance("getCameraDisabled"); |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 3259 | return getCameraDisabled(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 3260 | } |
| 3261 | |
| 3262 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3263 | public boolean getCameraDisabled(@Nullable ComponentName admin, int userHandle) { |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3264 | if (mService != null) { |
| 3265 | try { |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 3266 | return mService.getCameraDisabled(admin, userHandle); |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3267 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3268 | throw e.rethrowFromSystemServer(); |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 3269 | } |
| 3270 | } |
| 3271 | return false; |
| 3272 | } |
| 3273 | |
| 3274 | /** |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 3275 | * Called by a device owner to request a bugreport. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3276 | * <p> |
| 3277 | * There must be only one user on the device, managed by the device owner. Otherwise a |
| 3278 | * {@link SecurityException} will be thrown. |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 3279 | * |
| 3280 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3281 | * @return {@code true} if the bugreport collection started successfully, or {@code false} if it |
| 3282 | * wasn't triggered because a previous bugreport operation is still active (either the |
| 3283 | * bugreport is still running or waiting for the user to share or decline) |
| 3284 | * @throws SecurityException if {@code admin} is not a device owner, or if there are users other |
| 3285 | * than the one managed by the device owner. |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 3286 | */ |
| 3287 | public boolean requestBugreport(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3288 | throwIfParentInstance("requestBugreport"); |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 3289 | if (mService != null) { |
| 3290 | try { |
| 3291 | return mService.requestBugreport(admin); |
| 3292 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3293 | throw e.rethrowFromSystemServer(); |
Michal Karpinski | 3fc437e | 2015-12-15 10:09:00 +0000 | [diff] [blame] | 3294 | } |
| 3295 | } |
| 3296 | return false; |
| 3297 | } |
| 3298 | |
| 3299 | /** |
Fyodor Kupolov | cd86ebf | 2015-09-29 17:06:50 -0700 | [diff] [blame] | 3300 | * Determine whether or not creating a guest user has been disabled for the device |
| 3301 | * |
| 3302 | * @hide |
| 3303 | */ |
| 3304 | public boolean getGuestUserDisabled(@Nullable ComponentName admin) { |
| 3305 | // Currently guest users can always be created if multi-user is enabled |
| 3306 | // TODO introduce a policy for guest user creation |
| 3307 | return false; |
| 3308 | } |
| 3309 | |
| 3310 | /** |
Esteban Talavera | 1aee98f | 2014-08-21 14:03:55 +0100 | [diff] [blame] | 3311 | * Called by a device/profile owner to set whether the screen capture is disabled. Disabling |
| 3312 | * screen capture also prevents the content from being shown on display devices that do not have |
| 3313 | * a secure video output. See {@link android.view.Display#FLAG_SECURE} for more details about |
| 3314 | * secure surfaces and secure displays. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3315 | * <p> |
| 3316 | * The calling device admin must be a device or profile owner. If it is not, a security |
| 3317 | * exception will be thrown. |
| 3318 | * <p> |
| 3319 | * From version {@link android.os.Build.VERSION_CODES#M} disabling screen capture also blocks |
| 3320 | * assist requests for all activities of the relevant user. |
Benjamin Franz | c200f44 | 2015-06-25 18:20:04 +0100 | [diff] [blame] | 3321 | * |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3322 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3323 | * @param disabled Whether screen capture is disabled or not. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3324 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3325 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3326 | public void setScreenCaptureDisabled(@NonNull ComponentName admin, boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3327 | throwIfParentInstance("setScreenCaptureDisabled"); |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3328 | if (mService != null) { |
| 3329 | try { |
Fyodor Kupolov | bdc58c6 | 2015-01-29 13:24:03 -0800 | [diff] [blame] | 3330 | mService.setScreenCaptureDisabled(admin, disabled); |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3331 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3332 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3333 | } |
| 3334 | } |
| 3335 | } |
| 3336 | |
| 3337 | /** |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 3338 | * Determine whether or not screen capture has been disabled by the calling |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3339 | * admin, if specified, or all admins. |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3340 | * @param admin The name of the admin component to check, or {@code null} to check whether any admins |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3341 | * have disabled screen capture. |
| 3342 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3343 | public boolean getScreenCaptureDisabled(@Nullable ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3344 | throwIfParentInstance("getScreenCaptureDisabled"); |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 3345 | return getScreenCaptureDisabled(admin, myUserId()); |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3346 | } |
| 3347 | |
| 3348 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3349 | public boolean getScreenCaptureDisabled(@Nullable ComponentName admin, int userHandle) { |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3350 | if (mService != null) { |
| 3351 | try { |
| 3352 | return mService.getScreenCaptureDisabled(admin, userHandle); |
| 3353 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3354 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | d2a1eec | 2014-07-09 12:57:05 +0100 | [diff] [blame] | 3355 | } |
| 3356 | } |
| 3357 | return false; |
| 3358 | } |
| 3359 | |
| 3360 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3361 | * Called by a device owner to set whether auto time is required. If auto time is required the |
| 3362 | * user cannot set the date and time, but has to use network date and time. |
| 3363 | * <p> |
| 3364 | * Note: if auto time is required the user can still manually set the time zone. |
| 3365 | * <p> |
| 3366 | * The calling device admin must be a device owner. If it is not, a security exception will be |
| 3367 | * thrown. |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3368 | * |
| 3369 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 3370 | * @param required Whether auto time is set required or not. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3371 | * @throws SecurityException if {@code admin} is not a device owner. |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3372 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3373 | public void setAutoTimeRequired(@NonNull ComponentName admin, boolean required) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3374 | throwIfParentInstance("setAutoTimeRequired"); |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3375 | if (mService != null) { |
| 3376 | try { |
Fyodor Kupolov | bdc58c6 | 2015-01-29 13:24:03 -0800 | [diff] [blame] | 3377 | mService.setAutoTimeRequired(admin, required); |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3378 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3379 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3380 | } |
| 3381 | } |
| 3382 | } |
| 3383 | |
| 3384 | /** |
| 3385 | * @return true if auto time is required. |
| 3386 | */ |
| 3387 | public boolean getAutoTimeRequired() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3388 | throwIfParentInstance("getAutoTimeRequired"); |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3389 | if (mService != null) { |
| 3390 | try { |
| 3391 | return mService.getAutoTimeRequired(); |
| 3392 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3393 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | 0ced627 | 2014-08-26 11:18:26 +0100 | [diff] [blame] | 3394 | } |
| 3395 | } |
| 3396 | return false; |
| 3397 | } |
| 3398 | |
| 3399 | /** |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3400 | * Called by a device owner to set whether all users created on the device should be ephemeral. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3401 | * <p> |
| 3402 | * The system user is exempt from this policy - it is never ephemeral. |
| 3403 | * <p> |
| 3404 | * The calling device admin must be the device owner. If it is not, a security exception will be |
| 3405 | * thrown. |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3406 | * |
| 3407 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 3408 | * @param forceEphemeralUsers If true, all the existing users will be deleted and all |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3409 | * subsequently created users will be ephemeral. |
| 3410 | * @throws SecurityException if {@code admin} is not a device owner. |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3411 | * @hide |
| 3412 | */ |
| 3413 | public void setForceEphemeralUsers( |
| 3414 | @NonNull ComponentName admin, boolean forceEphemeralUsers) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3415 | throwIfParentInstance("setForceEphemeralUsers"); |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3416 | if (mService != null) { |
| 3417 | try { |
| 3418 | mService.setForceEphemeralUsers(admin, forceEphemeralUsers); |
| 3419 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3420 | throw e.rethrowFromSystemServer(); |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3421 | } |
| 3422 | } |
| 3423 | } |
| 3424 | |
| 3425 | /** |
| 3426 | * @return true if all users are created ephemeral. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3427 | * @throws SecurityException if {@code admin} is not a device owner. |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3428 | * @hide |
| 3429 | */ |
| 3430 | public boolean getForceEphemeralUsers(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3431 | throwIfParentInstance("getForceEphemeralUsers"); |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3432 | if (mService != null) { |
| 3433 | try { |
| 3434 | return mService.getForceEphemeralUsers(admin); |
| 3435 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3436 | throw e.rethrowFromSystemServer(); |
Lenka Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 3437 | } |
| 3438 | } |
| 3439 | return false; |
| 3440 | } |
| 3441 | |
| 3442 | /** |
Jim Miller | 48b9b0d | 2012-09-19 23:16:50 -0700 | [diff] [blame] | 3443 | * Called by an application that is administering the device to disable keyguard customizations, |
| 3444 | * such as widgets. After setting this, keyguard features will be disabled according to the |
| 3445 | * provided feature list. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3446 | * <p> |
| 3447 | * The calling device admin must have requested |
| 3448 | * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} to be able to call this method; |
| 3449 | * if it has not, a security exception will be thrown. |
| 3450 | * <p> |
| 3451 | * Calling this from a managed profile before version {@link android.os.Build.VERSION_CODES#M} |
| 3452 | * will throw a security exception. From version {@link android.os.Build.VERSION_CODES#M} the |
| 3453 | * profile owner of a managed profile can set: |
Kenny Guy | 0b7dd1e | 2015-03-12 17:14:38 +0000 | [diff] [blame] | 3454 | * <ul> |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 3455 | * <li>{@link #KEYGUARD_DISABLE_TRUST_AGENTS}, which affects the parent user, but only if there |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3456 | * is no separate challenge set on the managed profile. |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 3457 | * <li>{@link #KEYGUARD_DISABLE_FINGERPRINT} which affects the managed profile challenge if |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3458 | * there is one, or the parent user otherwise. |
| 3459 | * <li>{@link #KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS} which affects notifications generated |
| 3460 | * by applications in the managed profile. |
Kenny Guy | 0b7dd1e | 2015-03-12 17:14:38 +0000 | [diff] [blame] | 3461 | * </ul> |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 3462 | * {@link #KEYGUARD_DISABLE_TRUST_AGENTS} and {@link #KEYGUARD_DISABLE_FINGERPRINT} can also be |
| 3463 | * set on the {@link DevicePolicyManager} instance returned by |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3464 | * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent |
| 3465 | * profile. |
| 3466 | * <p> |
| 3467 | * Requests to disable other features on a managed profile will be ignored. |
| 3468 | * <p> |
| 3469 | * The admin can check which features have been disabled by calling |
Kenny Guy | 0b7dd1e | 2015-03-12 17:14:38 +0000 | [diff] [blame] | 3470 | * {@link #getKeyguardDisabledFeatures(ComponentName)} |
Amith Yamasani | 242f4b1 | 2014-10-14 16:06:13 -0700 | [diff] [blame] | 3471 | * |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3472 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Jim Miller | 3520774 | 2012-11-02 15:33:20 -0700 | [diff] [blame] | 3473 | * @param which {@link #KEYGUARD_DISABLE_FEATURES_NONE} (default), |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3474 | * {@link #KEYGUARD_DISABLE_WIDGETS_ALL}, {@link #KEYGUARD_DISABLE_SECURE_CAMERA}, |
| 3475 | * {@link #KEYGUARD_DISABLE_SECURE_NOTIFICATIONS}, |
| 3476 | * {@link #KEYGUARD_DISABLE_TRUST_AGENTS}, |
| 3477 | * {@link #KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS}, |
| 3478 | * {@link #KEYGUARD_DISABLE_FINGERPRINT}, {@link #KEYGUARD_DISABLE_FEATURES_ALL} |
| 3479 | * @throws SecurityException if {@code admin} is not an active administrator or does not user |
| 3480 | * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3481 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3482 | public void setKeyguardDisabledFeatures(@NonNull ComponentName admin, int which) { |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3483 | if (mService != null) { |
| 3484 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 3485 | mService.setKeyguardDisabledFeatures(admin, which, mParentInstance); |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3486 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3487 | throw e.rethrowFromSystemServer(); |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3488 | } |
| 3489 | } |
| 3490 | } |
| 3491 | |
| 3492 | /** |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 3493 | * Determine whether or not features have been disabled in keyguard either by the calling |
Rubin Xu | d3609d4 | 2016-07-13 18:32:57 +0100 | [diff] [blame] | 3494 | * admin, if specified, or all admins that set restrictions on this user and its participating |
Esteban Talavera | c1c8359 | 2016-02-17 17:56:15 +0000 | [diff] [blame] | 3495 | * profiles. Restrictions on profiles that have a separate challenge are not taken into account. |
| 3496 | * |
| 3497 | * <p>This method can be called on the {@link DevicePolicyManager} instance |
| 3498 | * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve |
| 3499 | * restrictions on the parent profile. |
| 3500 | * |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 3501 | * @param admin The name of the admin component to check, or {@code null} to check whether any |
| 3502 | * admins have disabled features in keyguard. |
Jim Miller | 3520774 | 2012-11-02 15:33:20 -0700 | [diff] [blame] | 3503 | * @return bitfield of flags. See {@link #setKeyguardDisabledFeatures(ComponentName, int)} |
| 3504 | * for a list. |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3505 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3506 | public int getKeyguardDisabledFeatures(@Nullable ComponentName admin) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 3507 | return getKeyguardDisabledFeatures(admin, myUserId()); |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 3508 | } |
| 3509 | |
| 3510 | /** @hide per-user version */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3511 | public int getKeyguardDisabledFeatures(@Nullable ComponentName admin, int userHandle) { |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3512 | if (mService != null) { |
| 3513 | try { |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 3514 | return mService.getKeyguardDisabledFeatures(admin, userHandle, mParentInstance); |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3515 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3516 | throw e.rethrowFromSystemServer(); |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3517 | } |
| 3518 | } |
Jim Miller | 48b9b0d | 2012-09-19 23:16:50 -0700 | [diff] [blame] | 3519 | return KEYGUARD_DISABLE_FEATURES_NONE; |
Jim Miller | b8ec470 | 2012-08-31 17:19:10 -0700 | [diff] [blame] | 3520 | } |
| 3521 | |
| 3522 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3523 | * @hide |
| 3524 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3525 | public void setActiveAdmin(@NonNull ComponentName policyReceiver, boolean refreshing, |
| 3526 | int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3527 | if (mService != null) { |
| 3528 | try { |
Jessica Hummel | 6d36b60 | 2014-04-04 12:42:17 +0100 | [diff] [blame] | 3529 | mService.setActiveAdmin(policyReceiver, refreshing, userHandle); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3530 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3531 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3532 | } |
| 3533 | } |
| 3534 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 3535 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3536 | /** |
Jessica Hummel | 6d36b60 | 2014-04-04 12:42:17 +0100 | [diff] [blame] | 3537 | * @hide |
| 3538 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3539 | public void setActiveAdmin(@NonNull ComponentName policyReceiver, boolean refreshing) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 3540 | setActiveAdmin(policyReceiver, refreshing, myUserId()); |
Jessica Hummel | 6d36b60 | 2014-04-04 12:42:17 +0100 | [diff] [blame] | 3541 | } |
| 3542 | |
| 3543 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3544 | * @hide |
| 3545 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3546 | public void getRemoveWarning(@Nullable ComponentName admin, RemoteCallback result) { |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 3547 | if (mService != null) { |
| 3548 | try { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 3549 | mService.getRemoveWarning(admin, result, myUserId()); |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 3550 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3551 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 3552 | } |
| 3553 | } |
| 3554 | } |
| 3555 | |
| 3556 | /** |
| 3557 | * @hide |
| 3558 | */ |
Andrew Scull | 5f9e6f3 | 2016-08-02 14:22:17 +0100 | [diff] [blame] | 3559 | public void setActivePasswordState(PasswordMetrics metrics, int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3560 | if (mService != null) { |
| 3561 | try { |
Andrew Scull | 5f9e6f3 | 2016-08-02 14:22:17 +0100 | [diff] [blame] | 3562 | mService.setActivePasswordState(metrics, userHandle); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3563 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3564 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3565 | } |
| 3566 | } |
| 3567 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 3568 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3569 | /** |
| 3570 | * @hide |
| 3571 | */ |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 3572 | public void reportFailedPasswordAttempt(int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3573 | if (mService != null) { |
| 3574 | try { |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 3575 | mService.reportFailedPasswordAttempt(userHandle); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3576 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3577 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 3581 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3582 | /** |
| 3583 | * @hide |
| 3584 | */ |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 3585 | public void reportSuccessfulPasswordAttempt(int userHandle) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3586 | if (mService != null) { |
| 3587 | try { |
Amith Yamasani | 599dd7c | 2012-09-14 23:20:08 -0700 | [diff] [blame] | 3588 | mService.reportSuccessfulPasswordAttempt(userHandle); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3589 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3590 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3591 | } |
| 3592 | } |
| 3593 | } |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3594 | |
| 3595 | /** |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 3596 | * @hide |
| 3597 | */ |
| 3598 | public void reportFailedFingerprintAttempt(int userHandle) { |
| 3599 | if (mService != null) { |
| 3600 | try { |
| 3601 | mService.reportFailedFingerprintAttempt(userHandle); |
| 3602 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3603 | throw e.rethrowFromSystemServer(); |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 3604 | } |
| 3605 | } |
| 3606 | } |
| 3607 | |
| 3608 | /** |
| 3609 | * @hide |
| 3610 | */ |
| 3611 | public void reportSuccessfulFingerprintAttempt(int userHandle) { |
| 3612 | if (mService != null) { |
| 3613 | try { |
| 3614 | mService.reportSuccessfulFingerprintAttempt(userHandle); |
| 3615 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3616 | throw e.rethrowFromSystemServer(); |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 3617 | } |
| 3618 | } |
| 3619 | } |
| 3620 | |
| 3621 | /** |
Michal Karpinski | 31502d3 | 2016-01-25 16:43:07 +0000 | [diff] [blame] | 3622 | * Should be called when keyguard has been dismissed. |
| 3623 | * @hide |
| 3624 | */ |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 3625 | public void reportKeyguardDismissed(int userHandle) { |
Michal Karpinski | 31502d3 | 2016-01-25 16:43:07 +0000 | [diff] [blame] | 3626 | if (mService != null) { |
| 3627 | try { |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 3628 | mService.reportKeyguardDismissed(userHandle); |
Michal Karpinski | 31502d3 | 2016-01-25 16:43:07 +0000 | [diff] [blame] | 3629 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3630 | throw e.rethrowFromSystemServer(); |
Michal Karpinski | 31502d3 | 2016-01-25 16:43:07 +0000 | [diff] [blame] | 3631 | } |
| 3632 | } |
| 3633 | } |
| 3634 | |
| 3635 | /** |
| 3636 | * Should be called when keyguard view has been shown to the user. |
| 3637 | * @hide |
| 3638 | */ |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 3639 | public void reportKeyguardSecured(int userHandle) { |
Michal Karpinski | 31502d3 | 2016-01-25 16:43:07 +0000 | [diff] [blame] | 3640 | if (mService != null) { |
| 3641 | try { |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 3642 | mService.reportKeyguardSecured(userHandle); |
Michal Karpinski | 31502d3 | 2016-01-25 16:43:07 +0000 | [diff] [blame] | 3643 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3644 | throw e.rethrowFromSystemServer(); |
Michal Karpinski | 31502d3 | 2016-01-25 16:43:07 +0000 | [diff] [blame] | 3645 | } |
| 3646 | } |
| 3647 | } |
| 3648 | |
| 3649 | /** |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3650 | * @hide |
Nicolas Prevot | 2806374 | 2015-01-08 15:37:12 +0000 | [diff] [blame] | 3651 | * Sets the given package as the device owner. |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3652 | * Same as {@link #setDeviceOwner(ComponentName, String)} but without setting a device owner name. |
| 3653 | * @param who the component name to be registered as device owner. |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3654 | * @return whether the package was successfully registered as the device owner. |
| 3655 | * @throws IllegalArgumentException if the package name is null or invalid |
Nicolas Prevot | 2806374 | 2015-01-08 15:37:12 +0000 | [diff] [blame] | 3656 | * @throws IllegalStateException If the preconditions mentioned are not met. |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3657 | */ |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3658 | public boolean setDeviceOwner(ComponentName who) { |
| 3659 | return setDeviceOwner(who, null); |
Geoffrey Borggaard | 334c7e3 | 2013-08-08 14:31:36 -0400 | [diff] [blame] | 3660 | } |
| 3661 | |
| 3662 | /** |
| 3663 | * @hide |
Makoto Onuki | 58b684f | 2015-09-04 10:48:16 -0700 | [diff] [blame] | 3664 | */ |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3665 | public boolean setDeviceOwner(ComponentName who, int userId) { |
| 3666 | return setDeviceOwner(who, null, userId); |
Makoto Onuki | 58b684f | 2015-09-04 10:48:16 -0700 | [diff] [blame] | 3667 | } |
| 3668 | |
| 3669 | /** |
| 3670 | * @hide |
| 3671 | */ |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3672 | public boolean setDeviceOwner(ComponentName who, String ownerName) { |
| 3673 | return setDeviceOwner(who, ownerName, UserHandle.USER_SYSTEM); |
Makoto Onuki | 58b684f | 2015-09-04 10:48:16 -0700 | [diff] [blame] | 3674 | } |
| 3675 | |
| 3676 | /** |
| 3677 | * @hide |
Nicolas Prevot | 2806374 | 2015-01-08 15:37:12 +0000 | [diff] [blame] | 3678 | * Sets the given package as the device owner. The package must already be installed. There |
| 3679 | * must not already be a device owner. |
| 3680 | * Only apps with the MANAGE_PROFILE_AND_DEVICE_OWNERS permission and the shell uid can call |
| 3681 | * this method. |
| 3682 | * Calling this after the setup phase of the primary user has completed is allowed only if |
| 3683 | * the caller is the shell uid, and there are no additional users and no accounts. |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3684 | * @param who the component name to be registered as device owner. |
Geoffrey Borggaard | 334c7e3 | 2013-08-08 14:31:36 -0400 | [diff] [blame] | 3685 | * @param ownerName the human readable name of the institution that owns this device. |
Makoto Onuki | 58b684f | 2015-09-04 10:48:16 -0700 | [diff] [blame] | 3686 | * @param userId ID of the user on which the device owner runs. |
Geoffrey Borggaard | 334c7e3 | 2013-08-08 14:31:36 -0400 | [diff] [blame] | 3687 | * @return whether the package was successfully registered as the device owner. |
| 3688 | * @throws IllegalArgumentException if the package name is null or invalid |
Nicolas Prevot | 2806374 | 2015-01-08 15:37:12 +0000 | [diff] [blame] | 3689 | * @throws IllegalStateException If the preconditions mentioned are not met. |
Geoffrey Borggaard | 334c7e3 | 2013-08-08 14:31:36 -0400 | [diff] [blame] | 3690 | */ |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3691 | public boolean setDeviceOwner(ComponentName who, String ownerName, int userId) |
Geoffrey Borggaard | 334c7e3 | 2013-08-08 14:31:36 -0400 | [diff] [blame] | 3692 | throws IllegalArgumentException, IllegalStateException { |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3693 | if (mService != null) { |
| 3694 | try { |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3695 | return mService.setDeviceOwner(who, ownerName, userId); |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3696 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3697 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3698 | } |
| 3699 | } |
| 3700 | return false; |
| 3701 | } |
| 3702 | |
| 3703 | /** |
Amith Yamasani | 3b458ad | 2013-04-18 18:40:07 -0700 | [diff] [blame] | 3704 | * Used to determine if a particular package has been registered as a Device Owner app. |
| 3705 | * A device owner app is a special device admin that cannot be deactivated by the user, once |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3706 | * activated as a device admin. It also cannot be uninstalled. To check whether a particular |
Amith Yamasani | 3b458ad | 2013-04-18 18:40:07 -0700 | [diff] [blame] | 3707 | * package is currently registered as the device owner app, pass in the package name from |
| 3708 | * {@link Context#getPackageName()} to this method.<p/>This is useful for device |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3709 | * admin apps that want to check whether they are also registered as the device owner app. The |
Amith Yamasani | 3b458ad | 2013-04-18 18:40:07 -0700 | [diff] [blame] | 3710 | * exact mechanism by which a device admin app is registered as a device owner app is defined by |
| 3711 | * the setup process. |
| 3712 | * @param packageName the package name of the app, to compare with the registered device owner |
| 3713 | * app, if any. |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3714 | * @return whether or not the package is registered as the device owner app. |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3715 | */ |
Amith Yamasani | 3b458ad | 2013-04-18 18:40:07 -0700 | [diff] [blame] | 3716 | public boolean isDeviceOwnerApp(String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3717 | throwIfParentInstance("isDeviceOwnerApp"); |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3718 | return isDeviceOwnerAppOnCallingUser(packageName); |
| 3719 | } |
| 3720 | |
| 3721 | /** |
| 3722 | * @return true if a package is registered as device owner, only when it's running on the |
| 3723 | * calling user. |
| 3724 | * |
| 3725 | * <p>Same as {@link #isDeviceOwnerApp}, but bundled code should use it for clarity. |
| 3726 | * @hide |
| 3727 | */ |
| 3728 | public boolean isDeviceOwnerAppOnCallingUser(String packageName) { |
| 3729 | return isDeviceOwnerAppOnAnyUserInner(packageName, /* callingUserOnly =*/ true); |
| 3730 | } |
| 3731 | |
| 3732 | /** |
| 3733 | * @return true if a package is registered as device owner, even if it's running on a different |
| 3734 | * user. |
| 3735 | * |
| 3736 | * <p>Requires the MANAGE_USERS permission. |
| 3737 | * |
| 3738 | * @hide |
| 3739 | */ |
| 3740 | public boolean isDeviceOwnerAppOnAnyUser(String packageName) { |
| 3741 | return isDeviceOwnerAppOnAnyUserInner(packageName, /* callingUserOnly =*/ false); |
| 3742 | } |
| 3743 | |
| 3744 | /** |
| 3745 | * @return device owner component name, only when it's running on the calling user. |
| 3746 | * |
| 3747 | * @hide |
| 3748 | */ |
| 3749 | public ComponentName getDeviceOwnerComponentOnCallingUser() { |
| 3750 | return getDeviceOwnerComponentInner(/* callingUserOnly =*/ true); |
| 3751 | } |
| 3752 | |
| 3753 | /** |
| 3754 | * @return device owner component name, even if it's running on a different user. |
| 3755 | * |
| 3756 | * <p>Requires the MANAGE_USERS permission. |
| 3757 | * |
| 3758 | * @hide |
| 3759 | */ |
| 3760 | public ComponentName getDeviceOwnerComponentOnAnyUser() { |
| 3761 | return getDeviceOwnerComponentInner(/* callingUserOnly =*/ false); |
| 3762 | } |
| 3763 | |
| 3764 | private boolean isDeviceOwnerAppOnAnyUserInner(String packageName, boolean callingUserOnly) { |
Makoto Onuki | 70f929e | 2015-11-11 12:40:15 -0800 | [diff] [blame] | 3765 | if (packageName == null) { |
| 3766 | return false; |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3767 | } |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3768 | final ComponentName deviceOwner = getDeviceOwnerComponentInner(callingUserOnly); |
Makoto Onuki | 70f929e | 2015-11-11 12:40:15 -0800 | [diff] [blame] | 3769 | if (deviceOwner == null) { |
| 3770 | return false; |
| 3771 | } |
| 3772 | return packageName.equals(deviceOwner.getPackageName()); |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3773 | } |
| 3774 | |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3775 | private ComponentName getDeviceOwnerComponentInner(boolean callingUserOnly) { |
| 3776 | if (mService != null) { |
| 3777 | try { |
| 3778 | return mService.getDeviceOwnerComponent(callingUserOnly); |
| 3779 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3780 | throw re.rethrowFromSystemServer(); |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3781 | } |
| 3782 | } |
| 3783 | return null; |
Amith Yamasani | 3b458ad | 2013-04-18 18:40:07 -0700 | [diff] [blame] | 3784 | } |
| 3785 | |
Jason Monk | b0dced8 | 2014-06-06 14:36:20 -0400 | [diff] [blame] | 3786 | /** |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3787 | * @return ID of the user who runs device owner, or {@link UserHandle#USER_NULL} if there's |
| 3788 | * no device owner. |
| 3789 | * |
| 3790 | * <p>Requires the MANAGE_USERS permission. |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3791 | * |
| 3792 | * @hide |
| 3793 | */ |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3794 | public int getDeviceOwnerUserId() { |
| 3795 | if (mService != null) { |
| 3796 | try { |
| 3797 | return mService.getDeviceOwnerUserId(); |
| 3798 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3799 | throw re.rethrowFromSystemServer(); |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3800 | } |
| 3801 | } |
| 3802 | return UserHandle.USER_NULL; |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3803 | } |
| 3804 | |
| 3805 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3806 | * Clears the current device owner. The caller must be the device owner. This function should be |
| 3807 | * used cautiously as once it is called it cannot be undone. The device owner can only be set as |
| 3808 | * a part of device setup before setup completes. |
Jason Monk | 94d2cf9 | 2014-06-18 09:53:34 -0400 | [diff] [blame] | 3809 | * |
| 3810 | * @param packageName The package name of the device owner. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3811 | * @throws SecurityException if the caller is not in {@code packageName} or {@code packageName} |
| 3812 | * does not own the current device owner component. |
Jason Monk | b0dced8 | 2014-06-06 14:36:20 -0400 | [diff] [blame] | 3813 | */ |
Jason Monk | 94d2cf9 | 2014-06-18 09:53:34 -0400 | [diff] [blame] | 3814 | public void clearDeviceOwnerApp(String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3815 | throwIfParentInstance("clearDeviceOwnerApp"); |
Jason Monk | b0dced8 | 2014-06-06 14:36:20 -0400 | [diff] [blame] | 3816 | if (mService != null) { |
| 3817 | try { |
Jason Monk | 94d2cf9 | 2014-06-18 09:53:34 -0400 | [diff] [blame] | 3818 | mService.clearDeviceOwner(packageName); |
Jason Monk | b0dced8 | 2014-06-06 14:36:20 -0400 | [diff] [blame] | 3819 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3820 | throw re.rethrowFromSystemServer(); |
Jason Monk | b0dced8 | 2014-06-06 14:36:20 -0400 | [diff] [blame] | 3821 | } |
| 3822 | } |
| 3823 | } |
| 3824 | |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3825 | /** |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3826 | * Returns the device owner package name, only if it's running on the calling user. |
| 3827 | * |
| 3828 | * <p>Bundled components should use {@code getDeviceOwnerComponentOnCallingUser()} for clarity. |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3829 | * |
| 3830 | * @hide |
| 3831 | */ |
Nicolas Prevot | 465acf3 | 2014-08-06 17:03:25 +0100 | [diff] [blame] | 3832 | @SystemApi |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 3833 | public @Nullable String getDeviceOwner() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3834 | throwIfParentInstance("getDeviceOwner"); |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3835 | final ComponentName name = getDeviceOwnerComponentOnCallingUser(); |
| 3836 | return name != null ? name.getPackageName() : null; |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3837 | } |
| 3838 | |
| 3839 | /** |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3840 | * @return true if the device is managed by any device owner. |
| 3841 | * |
| 3842 | * <p>Requires the MANAGE_USERS permission. |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3843 | * |
| 3844 | * @hide |
| 3845 | */ |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3846 | public boolean isDeviceManaged() { |
| 3847 | return getDeviceOwnerComponentOnAnyUser() != null; |
| 3848 | } |
| 3849 | |
| 3850 | /** |
| 3851 | * Returns the device owner name. Note this method *will* return the device owner |
| 3852 | * name when it's running on a different user. |
| 3853 | * |
| 3854 | * <p>Requires the MANAGE_USERS permission. |
| 3855 | * |
| 3856 | * @hide |
| 3857 | */ |
Makoto Onuki | a2b274b | 2016-01-19 13:26:02 -0800 | [diff] [blame] | 3858 | @SystemApi |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 3859 | public String getDeviceOwnerNameOnAnyUser() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3860 | throwIfParentInstance("getDeviceOwnerNameOnAnyUser"); |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3861 | if (mService != null) { |
| 3862 | try { |
Makoto Onuki | a52562c | 2015-10-01 16:12:31 -0700 | [diff] [blame] | 3863 | return mService.getDeviceOwnerName(); |
Amith Yamasani | 71e6c69 | 2013-03-24 17:39:28 -0700 | [diff] [blame] | 3864 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3865 | throw re.rethrowFromSystemServer(); |
Geoffrey Borggaard | 334c7e3 | 2013-08-08 14:31:36 -0400 | [diff] [blame] | 3866 | } |
| 3867 | } |
| 3868 | return null; |
| 3869 | } |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 3870 | |
| 3871 | /** |
Julia Reynolds | 94e7bf6 | 2015-06-10 14:44:56 -0400 | [diff] [blame] | 3872 | * @hide |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 3873 | * @deprecated Do not use |
| 3874 | * @removed |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 3875 | */ |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 3876 | @Deprecated |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 3877 | @SystemApi |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 3878 | public @Nullable String getDeviceInitializerApp() { |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 3879 | return null; |
| 3880 | } |
| 3881 | |
| 3882 | /** |
Julia Reynolds | eaafdf72 | 2015-04-02 08:49:47 -0400 | [diff] [blame] | 3883 | * @hide |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 3884 | * @deprecated Do not use |
| 3885 | * @removed |
Julia Reynolds | eaafdf72 | 2015-04-02 08:49:47 -0400 | [diff] [blame] | 3886 | */ |
Craig Lafayette | e7ee54e | 2015-09-21 13:48:53 -0400 | [diff] [blame] | 3887 | @Deprecated |
Julia Reynolds | eaafdf72 | 2015-04-02 08:49:47 -0400 | [diff] [blame] | 3888 | @SystemApi |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 3889 | public @Nullable ComponentName getDeviceInitializerComponent() { |
Julia Reynolds | eaafdf72 | 2015-04-02 08:49:47 -0400 | [diff] [blame] | 3890 | return null; |
| 3891 | } |
| 3892 | |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 3893 | /** |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 3894 | * @hide |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3895 | * @deprecated Use #ACTION_SET_PROFILE_OWNER |
Amith Yamasani | aba4f1b | 2014-07-01 15:36:12 +0530 | [diff] [blame] | 3896 | * Sets the given component as an active admin and registers the package as the profile |
| 3897 | * owner for this user. The package must already be installed and there shouldn't be |
| 3898 | * an existing profile owner registered for this user. Also, this method must be called |
| 3899 | * before the user setup has been completed. |
| 3900 | * <p> |
| 3901 | * This method can only be called by system apps that hold MANAGE_USERS permission and |
| 3902 | * MANAGE_DEVICE_ADMINS permission. |
| 3903 | * @param admin The component to register as an active admin and profile owner. |
| 3904 | * @param ownerName The user-visible name of the entity that is managing this user. |
| 3905 | * @return whether the admin was successfully registered as the profile owner. |
| 3906 | * @throws IllegalArgumentException if packageName is null, the package isn't installed, or |
| 3907 | * the user has already been set up. |
| 3908 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 3909 | @Deprecated |
Justin Morey | 80440cc | 2014-07-24 09:16:35 -0500 | [diff] [blame] | 3910 | @SystemApi |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3911 | public boolean setActiveProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName) |
Amith Yamasani | aba4f1b | 2014-07-01 15:36:12 +0530 | [diff] [blame] | 3912 | throws IllegalArgumentException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3913 | throwIfParentInstance("setActiveProfileOwner"); |
Amith Yamasani | aba4f1b | 2014-07-01 15:36:12 +0530 | [diff] [blame] | 3914 | if (mService != null) { |
| 3915 | try { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 3916 | final int myUserId = myUserId(); |
Amith Yamasani | aba4f1b | 2014-07-01 15:36:12 +0530 | [diff] [blame] | 3917 | mService.setActiveAdmin(admin, false, myUserId); |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3918 | return mService.setProfileOwner(admin, ownerName, myUserId); |
Amith Yamasani | aba4f1b | 2014-07-01 15:36:12 +0530 | [diff] [blame] | 3919 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3920 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | aba4f1b | 2014-07-01 15:36:12 +0530 | [diff] [blame] | 3921 | } |
| 3922 | } |
| 3923 | return false; |
| 3924 | } |
| 3925 | |
| 3926 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3927 | * Clears the active profile owner and removes all user restrictions. The caller must be from |
| 3928 | * the same package as the active profile owner for this user, otherwise a SecurityException |
| 3929 | * will be thrown. |
| 3930 | * <p> |
| 3931 | * This doesn't work for managed profile owners. |
Makoto Onuki | 5bf6802 | 2016-01-27 13:49:19 -0800 | [diff] [blame] | 3932 | * |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3933 | * @param admin The component to remove as the profile owner. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3934 | * @throws SecurityException if {@code admin} is not an active profile owner. |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3935 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3936 | public void clearProfileOwner(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 3937 | throwIfParentInstance("clearProfileOwner"); |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3938 | if (mService != null) { |
| 3939 | try { |
| 3940 | mService.clearProfileOwner(admin); |
| 3941 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3942 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3943 | } |
| 3944 | } |
| 3945 | } |
| 3946 | |
| 3947 | /** |
Julia Reynolds | e925440 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 3948 | * @hide |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3949 | * Checks whether the user was already setup. |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3950 | */ |
| 3951 | public boolean hasUserSetupCompleted() { |
| 3952 | if (mService != null) { |
| 3953 | try { |
| 3954 | return mService.hasUserSetupCompleted(); |
| 3955 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3956 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3957 | } |
| 3958 | } |
| 3959 | return true; |
| 3960 | } |
| 3961 | |
| 3962 | /** |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3963 | * @hide |
| 3964 | * Sets the given component as the profile owner of the given user profile. The package must |
Nicolas Prevot | 2806374 | 2015-01-08 15:37:12 +0000 | [diff] [blame] | 3965 | * already be installed. There must not already be a profile owner for this user. |
| 3966 | * Only apps with the MANAGE_PROFILE_AND_DEVICE_OWNERS permission and the shell uid can call |
| 3967 | * this method. |
| 3968 | * Calling this after the setup phase of the specified user has completed is allowed only if: |
| 3969 | * - the caller is SYSTEM_UID. |
| 3970 | * - or the caller is the shell uid, and there are no accounts on the specified user. |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3971 | * @param admin the component name to be registered as profile owner. |
| 3972 | * @param ownerName the human readable name of the organisation associated with this DPM. |
| 3973 | * @param userHandle the userId to set the profile owner for. |
| 3974 | * @return whether the component was successfully registered as the profile owner. |
Nicolas Prevot | 2806374 | 2015-01-08 15:37:12 +0000 | [diff] [blame] | 3975 | * @throws IllegalArgumentException if admin is null, the package isn't installed, or the |
| 3976 | * preconditions mentioned are not met. |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3977 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 3978 | public boolean setProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName, |
Robin Lee | ddd553f | 2015-04-30 14:18:22 +0100 | [diff] [blame] | 3979 | int userHandle) throws IllegalArgumentException { |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 3980 | if (mService != null) { |
| 3981 | try { |
Amith Yamasani | bf3a946 | 2014-07-28 14:26:42 -0700 | [diff] [blame] | 3982 | if (ownerName == null) { |
| 3983 | ownerName = ""; |
| 3984 | } |
| 3985 | return mService.setProfileOwner(admin, ownerName, userHandle); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 3986 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 3987 | throw re.rethrowFromSystemServer(); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 3988 | } |
| 3989 | } |
| 3990 | return false; |
| 3991 | } |
| 3992 | |
| 3993 | /** |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 3994 | * Sets the device owner information to be shown on the lock screen. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3995 | * <p> |
| 3996 | * If the device owner information is {@code null} or empty then the device owner info is |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 3997 | * cleared and the user owner info is shown on the lock screen if it is set. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 3998 | * <p> |
| 3999 | * If the device owner information contains only whitespaces then the message on the lock screen |
| 4000 | * will be blank and the user will not be allowed to change it. |
| 4001 | * <p> |
| 4002 | * If the device owner information needs to be localized, it is the responsibility of the |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 4003 | * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast |
| 4004 | * and set a new version of this string accordingly. |
| 4005 | * |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4006 | * @param admin The name of the admin component to check. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4007 | * @param info Device owner information which will be displayed instead of the user owner info. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4008 | * @throws SecurityException if {@code admin} is not a device owner. |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4009 | */ |
Andrei Stingaceanu | 1618790 | 2016-03-21 15:44:45 +0000 | [diff] [blame] | 4010 | public void setDeviceOwnerLockScreenInfo(@NonNull ComponentName admin, CharSequence info) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4011 | throwIfParentInstance("setDeviceOwnerLockScreenInfo"); |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4012 | if (mService != null) { |
| 4013 | try { |
Andrei Stingaceanu | 1618790 | 2016-03-21 15:44:45 +0000 | [diff] [blame] | 4014 | mService.setDeviceOwnerLockScreenInfo(admin, info); |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4015 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4016 | throw re.rethrowFromSystemServer(); |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4017 | } |
| 4018 | } |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4019 | } |
| 4020 | |
| 4021 | /** |
| 4022 | * @return The device owner information. If it is not set returns {@code null}. |
| 4023 | */ |
Andrei Stingaceanu | 1618790 | 2016-03-21 15:44:45 +0000 | [diff] [blame] | 4024 | public CharSequence getDeviceOwnerLockScreenInfo() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4025 | throwIfParentInstance("getDeviceOwnerLockScreenInfo"); |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4026 | if (mService != null) { |
| 4027 | try { |
| 4028 | return mService.getDeviceOwnerLockScreenInfo(); |
| 4029 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4030 | throw re.rethrowFromSystemServer(); |
Andrei Stingaceanu | 6644cd9 | 2015-11-10 13:03:31 +0000 | [diff] [blame] | 4031 | } |
| 4032 | } |
| 4033 | return null; |
| 4034 | } |
| 4035 | |
| 4036 | /** |
Andrei Stingaceanu | eb84b18 | 2016-01-26 18:39:55 +0000 | [diff] [blame] | 4037 | * Called by device or profile owners to suspend packages for this user. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4038 | * <p> |
| 4039 | * A suspended package will not be able to start activities. Its notifications will be hidden, |
| 4040 | * it will not show up in recents, will not be able to show toasts or dialogs or ring the |
| 4041 | * device. |
| 4042 | * <p> |
| 4043 | * The package must already be installed. If the package is uninstalled while suspended the |
| 4044 | * package will no longer be suspended. The admin can block this by using |
Kenny Guy | 871f3eb | 2016-03-09 20:06:16 +0000 | [diff] [blame] | 4045 | * {@link #setUninstallBlocked}. |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4046 | * |
| 4047 | * @param admin The name of the admin component to check. |
Andrei Stingaceanu | eb84b18 | 2016-01-26 18:39:55 +0000 | [diff] [blame] | 4048 | * @param packageNames The package names to suspend or unsuspend. |
| 4049 | * @param suspended If set to {@code true} than the packages will be suspended, if set to |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4050 | * {@code false} the packages will be unsuspended. |
Andrei Stingaceanu | eb84b18 | 2016-01-26 18:39:55 +0000 | [diff] [blame] | 4051 | * @return an array of package names for which the suspended status is not set as requested in |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4052 | * this method. |
| 4053 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4054 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4055 | public @NonNull String[] setPackagesSuspended(@NonNull ComponentName admin, |
| 4056 | @NonNull String[] packageNames, boolean suspended) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4057 | throwIfParentInstance("setPackagesSuspended"); |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4058 | if (mService != null) { |
| 4059 | try { |
Andrei Stingaceanu | eb84b18 | 2016-01-26 18:39:55 +0000 | [diff] [blame] | 4060 | return mService.setPackagesSuspended(admin, packageNames, suspended); |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4061 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4062 | throw re.rethrowFromSystemServer(); |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4063 | } |
| 4064 | } |
Andrei Stingaceanu | eb84b18 | 2016-01-26 18:39:55 +0000 | [diff] [blame] | 4065 | return packageNames; |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4066 | } |
| 4067 | |
| 4068 | /** |
| 4069 | * Called by device or profile owners to determine if a package is suspended. |
| 4070 | * |
| 4071 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4072 | * @param packageName The name of the package to retrieve the suspended status of. |
Andrei Stingaceanu | 355b232 | 2016-02-12 16:43:51 +0000 | [diff] [blame] | 4073 | * @return {@code true} if the package is suspended or {@code false} if the package is not |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4074 | * suspended, could not be found or an error occurred. |
| 4075 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Andrei Stingaceanu | efc4a34 | 2016-03-22 14:43:01 +0000 | [diff] [blame] | 4076 | * @throws NameNotFoundException if the package could not be found. |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4077 | */ |
Andrei Stingaceanu | efc4a34 | 2016-03-22 14:43:01 +0000 | [diff] [blame] | 4078 | public boolean isPackageSuspended(@NonNull ComponentName admin, String packageName) |
| 4079 | throws NameNotFoundException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4080 | throwIfParentInstance("isPackageSuspended"); |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4081 | if (mService != null) { |
| 4082 | try { |
Andrei Stingaceanu | efc4a34 | 2016-03-22 14:43:01 +0000 | [diff] [blame] | 4083 | return mService.isPackageSuspended(admin, packageName); |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4084 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4085 | throw e.rethrowFromSystemServer(); |
Andrei Stingaceanu | efc4a34 | 2016-03-22 14:43:01 +0000 | [diff] [blame] | 4086 | } catch (IllegalArgumentException ex) { |
| 4087 | throw new NameNotFoundException(packageName); |
Andrei Stingaceanu | 1e28391 | 2015-11-26 15:26:28 +0000 | [diff] [blame] | 4088 | } |
| 4089 | } |
| 4090 | return false; |
| 4091 | } |
| 4092 | |
| 4093 | /** |
Alexandra Gherghina | 512675b | 2014-04-02 11:23:54 +0100 | [diff] [blame] | 4094 | * Sets the enabled state of the profile. A profile should be enabled only once it is ready to |
| 4095 | * be used. Only the profile owner can call this. |
| 4096 | * |
Alexandra Gherghina | df35d57 | 2014-04-09 13:54:39 +0100 | [diff] [blame] | 4097 | * @see #isProfileOwnerApp |
Alexandra Gherghina | 512675b | 2014-04-02 11:23:54 +0100 | [diff] [blame] | 4098 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4099 | * @throws SecurityException if {@code admin} is not a profile owner. |
Alexandra Gherghina | 512675b | 2014-04-02 11:23:54 +0100 | [diff] [blame] | 4100 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4101 | public void setProfileEnabled(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4102 | throwIfParentInstance("setProfileEnabled"); |
Alexandra Gherghina | 512675b | 2014-04-02 11:23:54 +0100 | [diff] [blame] | 4103 | if (mService != null) { |
| 4104 | try { |
| 4105 | mService.setProfileEnabled(admin); |
| 4106 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4107 | throw e.rethrowFromSystemServer(); |
Alexandra Gherghina | 512675b | 2014-04-02 11:23:54 +0100 | [diff] [blame] | 4108 | } |
| 4109 | } |
| 4110 | } |
| 4111 | |
| 4112 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4113 | * Sets the name of the profile. In the device owner case it sets the name of the user which it |
| 4114 | * is called from. Only a profile owner or device owner can call this. If this is never called |
| 4115 | * by the profile or device owner, the name will be set to default values. |
Jessica Hummel | 1333ea1 | 2014-06-23 11:20:10 +0100 | [diff] [blame] | 4116 | * |
| 4117 | * @see #isProfileOwnerApp |
| 4118 | * @see #isDeviceOwnerApp |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4119 | * @param admin Which {@link DeviceAdminReceiver} this request is associate with. |
Jessica Hummel | 1333ea1 | 2014-06-23 11:20:10 +0100 | [diff] [blame] | 4120 | * @param profileName The name of the profile. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4121 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Jessica Hummel | 1333ea1 | 2014-06-23 11:20:10 +0100 | [diff] [blame] | 4122 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4123 | public void setProfileName(@NonNull ComponentName admin, String profileName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4124 | throwIfParentInstance("setProfileName"); |
Jessica Hummel | 1333ea1 | 2014-06-23 11:20:10 +0100 | [diff] [blame] | 4125 | if (mService != null) { |
| 4126 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4127 | mService.setProfileName(admin, profileName); |
Fyodor Kupolov | 78f1314 | 2015-05-27 16:52:45 -0700 | [diff] [blame] | 4128 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4129 | throw e.rethrowFromSystemServer(); |
Fyodor Kupolov | 78f1314 | 2015-05-27 16:52:45 -0700 | [diff] [blame] | 4130 | } |
Jessica Hummel | 1333ea1 | 2014-06-23 11:20:10 +0100 | [diff] [blame] | 4131 | } |
| 4132 | } |
Jessica Hummel | 1333ea1 | 2014-06-23 11:20:10 +0100 | [diff] [blame] | 4133 | |
| 4134 | /** |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 4135 | * Used to determine if a particular package is registered as the profile owner for the |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 4136 | * user. A profile owner is a special device admin that has additional privileges |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 4137 | * within the profile. |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4138 | * |
| 4139 | * @param packageName The package name of the app to compare with the registered profile owner. |
| 4140 | * @return Whether or not the package is registered as the profile owner. |
| 4141 | */ |
| 4142 | public boolean isProfileOwnerApp(String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4143 | throwIfParentInstance("isProfileOwnerApp"); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4144 | if (mService != null) { |
| 4145 | try { |
Makoto Onuki | 90b8965 | 2016-01-28 14:44:18 -0800 | [diff] [blame] | 4146 | ComponentName profileOwner = mService.getProfileOwner(myUserId()); |
Nicolas Prevot | 90af6d7 | 2014-07-30 14:19:12 +0100 | [diff] [blame] | 4147 | return profileOwner != null |
| 4148 | && profileOwner.getPackageName().equals(packageName); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4149 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4150 | throw re.rethrowFromSystemServer(); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4151 | } |
| 4152 | } |
| 4153 | return false; |
| 4154 | } |
| 4155 | |
| 4156 | /** |
| 4157 | * @hide |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4158 | * @return the packageName of the owner of the given user profile or {@code null} if no profile |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4159 | * owner has been set for that user. |
| 4160 | * @throws IllegalArgumentException if the userId is invalid. |
| 4161 | */ |
Nicolas Prevot | 465acf3 | 2014-08-06 17:03:25 +0100 | [diff] [blame] | 4162 | @SystemApi |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4163 | public @Nullable ComponentName getProfileOwner() throws IllegalArgumentException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4164 | throwIfParentInstance("getProfileOwner"); |
Zoltan Szatmary-Ban | 3f1ddf8 | 2014-07-02 16:42:05 +0100 | [diff] [blame] | 4165 | return getProfileOwnerAsUser(Process.myUserHandle().getIdentifier()); |
| 4166 | } |
| 4167 | |
| 4168 | /** |
| 4169 | * @see #getProfileOwner() |
| 4170 | * @hide |
| 4171 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4172 | public @Nullable ComponentName getProfileOwnerAsUser(final int userId) |
| 4173 | throws IllegalArgumentException { |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4174 | if (mService != null) { |
| 4175 | try { |
Zoltan Szatmary-Ban | 3f1ddf8 | 2014-07-02 16:42:05 +0100 | [diff] [blame] | 4176 | return mService.getProfileOwner(userId); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4177 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4178 | throw re.rethrowFromSystemServer(); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4179 | } |
| 4180 | } |
| 4181 | return null; |
| 4182 | } |
| 4183 | |
| 4184 | /** |
| 4185 | * @hide |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4186 | * @return the human readable name of the organisation associated with this DPM or {@code null} |
| 4187 | * if one is not set. |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4188 | * @throws IllegalArgumentException if the userId is invalid. |
| 4189 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4190 | public @Nullable String getProfileOwnerName() throws IllegalArgumentException { |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4191 | if (mService != null) { |
| 4192 | try { |
| 4193 | return mService.getProfileOwnerName(Process.myUserHandle().getIdentifier()); |
| 4194 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4195 | throw re.rethrowFromSystemServer(); |
Adam Connors | 776c555 | 2014-01-09 10:42:56 +0000 | [diff] [blame] | 4196 | } |
| 4197 | } |
| 4198 | return null; |
| 4199 | } |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4200 | |
| 4201 | /** |
Amith Yamasani | 38f836b | 2014-08-20 14:51:15 -0700 | [diff] [blame] | 4202 | * @hide |
Makoto Onuki | c8a5a55 | 2015-11-19 14:29:12 -0800 | [diff] [blame] | 4203 | * @param userId The user for whom to fetch the profile owner name, if any. |
Amith Yamasani | 38f836b | 2014-08-20 14:51:15 -0700 | [diff] [blame] | 4204 | * @return the human readable name of the organisation associated with this profile owner or |
| 4205 | * null if one is not set. |
| 4206 | * @throws IllegalArgumentException if the userId is invalid. |
| 4207 | */ |
| 4208 | @SystemApi |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4209 | public @Nullable String getProfileOwnerNameAsUser(int userId) throws IllegalArgumentException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4210 | throwIfParentInstance("getProfileOwnerNameAsUser"); |
Amith Yamasani | 38f836b | 2014-08-20 14:51:15 -0700 | [diff] [blame] | 4211 | if (mService != null) { |
| 4212 | try { |
Selim Cinek | 24ac55e | 2014-08-27 12:51:45 +0200 | [diff] [blame] | 4213 | return mService.getProfileOwnerName(userId); |
Amith Yamasani | 38f836b | 2014-08-20 14:51:15 -0700 | [diff] [blame] | 4214 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4215 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | 38f836b | 2014-08-20 14:51:15 -0700 | [diff] [blame] | 4216 | } |
| 4217 | } |
| 4218 | return null; |
| 4219 | } |
| 4220 | |
| 4221 | /** |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4222 | * Called by a profile owner or device owner to add a default intent handler activity for |
| 4223 | * intents that match a certain intent filter. This activity will remain the default intent |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4224 | * handler even if the set of potential event handlers for the intent filter changes and if the |
| 4225 | * intent preferences are reset. |
| 4226 | * <p> |
| 4227 | * The default disambiguation mechanism takes over if the activity is not installed (anymore). |
| 4228 | * When the activity is (re)installed, it is automatically reset as default intent handler for |
| 4229 | * the filter. |
| 4230 | * <p> |
| 4231 | * The calling device admin must be a profile owner or device owner. If it is not, a security |
| 4232 | * exception will be thrown. |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4233 | * |
| 4234 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4235 | * @param filter The IntentFilter for which a default handler is added. |
| 4236 | * @param activity The Activity that is added as default intent handler. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4237 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4238 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4239 | public void addPersistentPreferredActivity(@NonNull ComponentName admin, IntentFilter filter, |
| 4240 | @NonNull ComponentName activity) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4241 | throwIfParentInstance("addPersistentPreferredActivity"); |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4242 | if (mService != null) { |
| 4243 | try { |
| 4244 | mService.addPersistentPreferredActivity(admin, filter, activity); |
| 4245 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4246 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4247 | } |
| 4248 | } |
| 4249 | } |
| 4250 | |
| 4251 | /** |
| 4252 | * Called by a profile owner or device owner to remove all persistent intent handler preferences |
Torne (Richard Coles) | 875e210 | 2014-02-24 14:11:56 +0000 | [diff] [blame] | 4253 | * associated with the given package that were set by {@link #addPersistentPreferredActivity}. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4254 | * <p> |
| 4255 | * The calling device admin must be a profile owner. If it is not, a security exception will be |
| 4256 | * thrown. |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4257 | * |
| 4258 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4259 | * @param packageName The name of the package for which preferences are removed. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4260 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4261 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4262 | public void clearPackagePersistentPreferredActivities(@NonNull ComponentName admin, |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4263 | String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4264 | throwIfParentInstance("clearPackagePersistentPreferredActivities"); |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4265 | if (mService != null) { |
| 4266 | try { |
| 4267 | mService.clearPackagePersistentPreferredActivities(admin, packageName); |
| 4268 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4269 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | f475ca3 | 2014-02-17 15:13:58 +0000 | [diff] [blame] | 4270 | } |
| 4271 | } |
| 4272 | } |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 4273 | |
| 4274 | /** |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4275 | * Called by a profile owner or device owner to grant permission to a package to manage |
| 4276 | * application restrictions for the calling user via {@link #setApplicationRestrictions} and |
| 4277 | * {@link #getApplicationRestrictions}. |
| 4278 | * <p> |
| 4279 | * This permission is persistent until it is later cleared by calling this method with a |
| 4280 | * {@code null} value or uninstalling the managing package. |
Rubin Xu | f03d0a6 | 2016-02-10 14:54:15 +0000 | [diff] [blame] | 4281 | * <p> |
| 4282 | * The supplied application restriction managing package must be installed when calling this |
Victor Chang | cd14c0a | 2016-03-16 19:10:15 +0000 | [diff] [blame] | 4283 | * API, otherwise an {@link NameNotFoundException} will be thrown. |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4284 | * |
| 4285 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4286 | * @param packageName The package name which will be given access to application restrictions |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4287 | * APIs. If {@code null} is given the current package will be cleared. |
| 4288 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Victor Chang | cd14c0a | 2016-03-16 19:10:15 +0000 | [diff] [blame] | 4289 | * @throws NameNotFoundException if {@code packageName} is not found |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4290 | */ |
| 4291 | public void setApplicationRestrictionsManagingPackage(@NonNull ComponentName admin, |
Victor Chang | cd14c0a | 2016-03-16 19:10:15 +0000 | [diff] [blame] | 4292 | @Nullable String packageName) throws NameNotFoundException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4293 | throwIfParentInstance("setApplicationRestrictionsManagingPackage"); |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4294 | if (mService != null) { |
| 4295 | try { |
Victor Chang | cd14c0a | 2016-03-16 19:10:15 +0000 | [diff] [blame] | 4296 | if (!mService.setApplicationRestrictionsManagingPackage(admin, packageName)) { |
| 4297 | throw new NameNotFoundException(packageName); |
| 4298 | } |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4299 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4300 | throw e.rethrowFromSystemServer(); |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4301 | } |
| 4302 | } |
| 4303 | } |
| 4304 | |
| 4305 | /** |
| 4306 | * Called by a profile owner or device owner to retrieve the application restrictions managing |
| 4307 | * package for the current user, or {@code null} if none is set. |
| 4308 | * |
| 4309 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4310 | * @return The package name allowed to manage application restrictions on the current user, or |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4311 | * {@code null} if none is set. |
| 4312 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4313 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4314 | public @Nullable String getApplicationRestrictionsManagingPackage( |
| 4315 | @NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4316 | throwIfParentInstance("getApplicationRestrictionsManagingPackage"); |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4317 | if (mService != null) { |
| 4318 | try { |
| 4319 | return mService.getApplicationRestrictionsManagingPackage(admin); |
| 4320 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4321 | throw e.rethrowFromSystemServer(); |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4322 | } |
| 4323 | } |
| 4324 | return null; |
| 4325 | } |
| 4326 | |
| 4327 | /** |
Esteban Talavera | 96895ca | 2016-03-16 12:00:40 +0000 | [diff] [blame] | 4328 | * Called by any application to find out whether it has been granted permission via |
| 4329 | * {@link #setApplicationRestrictionsManagingPackage} to manage application restrictions |
| 4330 | * for the calling user. |
| 4331 | * |
| 4332 | * <p>This is done by comparing the calling Linux uid with the uid of the package specified by |
| 4333 | * that method. |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4334 | */ |
| 4335 | public boolean isCallerApplicationRestrictionsManagingPackage() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4336 | throwIfParentInstance("isCallerApplicationRestrictionsManagingPackage"); |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4337 | if (mService != null) { |
| 4338 | try { |
| 4339 | return mService.isCallerApplicationRestrictionsManagingPackage(); |
| 4340 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4341 | throw e.rethrowFromSystemServer(); |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4342 | } |
| 4343 | } |
| 4344 | return false; |
| 4345 | } |
| 4346 | |
| 4347 | /** |
| 4348 | * Sets the application restrictions for a given target application running in the calling user. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4349 | * <p> |
| 4350 | * The caller must be a profile or device owner on that user, or the package allowed to manage |
| 4351 | * application restrictions via {@link #setApplicationRestrictionsManagingPackage}; otherwise a |
| 4352 | * security exception will be thrown. |
| 4353 | * <p> |
| 4354 | * The provided {@link Bundle} consists of key-value pairs, where the types of values may be: |
Esteban Talavera | 6b8e064 | 2015-08-10 17:26:04 +0100 | [diff] [blame] | 4355 | * <ul> |
| 4356 | * <li>{@code boolean} |
| 4357 | * <li>{@code int} |
| 4358 | * <li>{@code String} or {@code String[]} |
| 4359 | * <li>From {@link android.os.Build.VERSION_CODES#M}, {@code Bundle} or {@code Bundle[]} |
| 4360 | * </ul> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4361 | * <p> |
| 4362 | * If the restrictions are not available yet, but may be applied in the near future, the caller |
| 4363 | * can notify the target application of that by adding |
Sander Alewijnse | 53d63dc | 2014-11-07 21:43:00 +0000 | [diff] [blame] | 4364 | * {@link UserManager#KEY_RESTRICTIONS_PENDING} to the settings parameter. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4365 | * <p> |
| 4366 | * The application restrictions are only made visible to the target application via |
| 4367 | * {@link UserManager#getApplicationRestrictions(String)}, in addition to the profile or device |
| 4368 | * owner, and the application restrictions managing package via |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4369 | * {@link #getApplicationRestrictions}. |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 4370 | * |
Fyodor Kupolov | 4e9af06 | 2016-07-18 16:59:11 -0700 | [diff] [blame] | 4371 | * <p>NOTE: The method performs disk I/O and shouldn't be called on the main thread |
| 4372 | * |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4373 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4374 | * {@code null} if called by the application restrictions managing package. |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 4375 | * @param packageName The name of the package to update restricted settings for. |
| 4376 | * @param settings A {@link Bundle} to be parsed by the receiving application, conveying a new |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4377 | * set of active restrictions. |
| 4378 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4379 | * @see #setApplicationRestrictionsManagingPackage |
Sander Alewijnse | 53d63dc | 2014-11-07 21:43:00 +0000 | [diff] [blame] | 4380 | * @see UserManager#KEY_RESTRICTIONS_PENDING |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 4381 | */ |
Fyodor Kupolov | 4e9af06 | 2016-07-18 16:59:11 -0700 | [diff] [blame] | 4382 | @WorkerThread |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 4383 | public void setApplicationRestrictions(@Nullable ComponentName admin, String packageName, |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 4384 | Bundle settings) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4385 | throwIfParentInstance("setApplicationRestrictions"); |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 4386 | if (mService != null) { |
| 4387 | try { |
| 4388 | mService.setApplicationRestrictions(admin, packageName, settings); |
| 4389 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4390 | throw e.rethrowFromSystemServer(); |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 4391 | } |
| 4392 | } |
| 4393 | } |
| 4394 | |
| 4395 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4396 | * Sets a list of configuration features to enable for a TrustAgent component. This is meant to |
| 4397 | * be used in conjunction with {@link #KEYGUARD_DISABLE_TRUST_AGENTS}, which disables all trust |
| 4398 | * agents but those enabled by this function call. If flag |
Jim Miller | e303bf4 | 2014-08-26 17:12:29 -0700 | [diff] [blame] | 4399 | * {@link #KEYGUARD_DISABLE_TRUST_AGENTS} is not set, then this call has no effect. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4400 | * <p> |
| 4401 | * The calling device admin must have requested |
| 4402 | * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} to be able to call this method; |
| 4403 | * if not, a security exception will be thrown. |
Tony Mak | 089d840 | 2016-04-05 17:42:55 +0100 | [diff] [blame] | 4404 | * <p> |
| 4405 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 4406 | * {@link #getParentProfileInstance(ComponentName)} in order to set the configuration for |
| 4407 | * the parent profile. |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4408 | * |
| 4409 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Jim Miller | e303bf4 | 2014-08-26 17:12:29 -0700 | [diff] [blame] | 4410 | * @param target Component name of the agent to be enabled. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4411 | * @param configuration TrustAgent-specific feature bundle. If null for any admin, agent will be |
| 4412 | * strictly disabled according to the state of the |
| 4413 | * {@link #KEYGUARD_DISABLE_TRUST_AGENTS} flag. |
| 4414 | * <p> |
| 4415 | * If {@link #KEYGUARD_DISABLE_TRUST_AGENTS} is set and options is not null for all |
| 4416 | * admins, then it's up to the TrustAgent itself to aggregate the values from all |
| 4417 | * device admins. |
| 4418 | * <p> |
| 4419 | * Consult documentation for the specific TrustAgent to determine legal options |
| 4420 | * parameters. |
| 4421 | * @throws SecurityException if {@code admin} is not an active administrator or does not use |
| 4422 | * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4423 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4424 | public void setTrustAgentConfiguration(@NonNull ComponentName admin, |
| 4425 | @NonNull ComponentName target, PersistableBundle configuration) { |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4426 | if (mService != null) { |
| 4427 | try { |
Tony Mak | 089d840 | 2016-04-05 17:42:55 +0100 | [diff] [blame] | 4428 | mService.setTrustAgentConfiguration(admin, target, configuration, mParentInstance); |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4429 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4430 | throw e.rethrowFromSystemServer(); |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4431 | } |
| 4432 | } |
| 4433 | } |
| 4434 | |
| 4435 | /** |
Jim Miller | e303bf4 | 2014-08-26 17:12:29 -0700 | [diff] [blame] | 4436 | * Gets configuration for the given trust agent based on aggregating all calls to |
| 4437 | * {@link #setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)} for |
| 4438 | * all device admins. |
Tony Mak | 089d840 | 2016-04-05 17:42:55 +0100 | [diff] [blame] | 4439 | * <p> |
| 4440 | * This method can be called on the {@link DevicePolicyManager} instance returned by |
| 4441 | * {@link #getParentProfileInstance(ComponentName)} in order to retrieve the configuration set |
| 4442 | * on the parent profile. |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4443 | * |
Jim Miller | b5db57a | 2015-01-14 18:17:19 -0800 | [diff] [blame] | 4444 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. If null, |
| 4445 | * this function returns a list of configurations for all admins that declare |
| 4446 | * {@link #KEYGUARD_DISABLE_TRUST_AGENTS}. If any admin declares |
| 4447 | * {@link #KEYGUARD_DISABLE_TRUST_AGENTS} but doesn't call |
| 4448 | * {@link #setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)} |
| 4449 | * for this {@param agent} or calls it with a null configuration, null is returned. |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4450 | * @param agent Which component to get enabled features for. |
Jim Miller | e303bf4 | 2014-08-26 17:12:29 -0700 | [diff] [blame] | 4451 | * @return configuration for the given trust agent. |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4452 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4453 | public @Nullable List<PersistableBundle> getTrustAgentConfiguration( |
| 4454 | @Nullable ComponentName admin, @NonNull ComponentName agent) { |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 4455 | return getTrustAgentConfiguration(admin, agent, myUserId()); |
Jim Miller | e303bf4 | 2014-08-26 17:12:29 -0700 | [diff] [blame] | 4456 | } |
| 4457 | |
| 4458 | /** @hide per-user version */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4459 | public @Nullable List<PersistableBundle> getTrustAgentConfiguration( |
| 4460 | @Nullable ComponentName admin, @NonNull ComponentName agent, int userHandle) { |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4461 | if (mService != null) { |
| 4462 | try { |
Tony Mak | 089d840 | 2016-04-05 17:42:55 +0100 | [diff] [blame] | 4463 | return mService.getTrustAgentConfiguration(admin, agent, userHandle, |
| 4464 | mParentInstance); |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4465 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4466 | throw e.rethrowFromSystemServer(); |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4467 | } |
| 4468 | } |
Jim Miller | e303bf4 | 2014-08-26 17:12:29 -0700 | [diff] [blame] | 4469 | return new ArrayList<PersistableBundle>(); // empty list |
Jim Miller | 604e755 | 2014-07-18 19:00:02 -0700 | [diff] [blame] | 4470 | } |
| 4471 | |
| 4472 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4473 | * Called by a profile owner of a managed profile to set whether caller-Id information from the |
| 4474 | * managed profile will be shown in the parent profile, for incoming calls. |
| 4475 | * <p> |
| 4476 | * The calling device admin must be a profile owner. If it is not, a security exception will be |
| 4477 | * thrown. |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4478 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4479 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4480 | * @param disabled If true caller-Id information in the managed profile is not displayed. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4481 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4482 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4483 | public void setCrossProfileCallerIdDisabled(@NonNull ComponentName admin, boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4484 | throwIfParentInstance("setCrossProfileCallerIdDisabled"); |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4485 | if (mService != null) { |
| 4486 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4487 | mService.setCrossProfileCallerIdDisabled(admin, disabled); |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4488 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4489 | throw e.rethrowFromSystemServer(); |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4490 | } |
| 4491 | } |
| 4492 | } |
| 4493 | |
| 4494 | /** |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 4495 | * Called by a profile owner of a managed profile to determine whether or not caller-Id |
| 4496 | * information has been disabled. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4497 | * <p> |
| 4498 | * The calling device admin must be a profile owner. If it is not, a security exception will be |
| 4499 | * thrown. |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4500 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4501 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4502 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4503 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4504 | public boolean getCrossProfileCallerIdDisabled(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4505 | throwIfParentInstance("getCrossProfileCallerIdDisabled"); |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4506 | if (mService != null) { |
| 4507 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4508 | return mService.getCrossProfileCallerIdDisabled(admin); |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4509 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4510 | throw e.rethrowFromSystemServer(); |
Adam Connors | 210fe21 | 2014-07-17 15:41:43 +0100 | [diff] [blame] | 4511 | } |
| 4512 | } |
| 4513 | return false; |
| 4514 | } |
| 4515 | |
| 4516 | /** |
Amith Yamasani | 570002f | 2014-07-18 15:48:54 -0700 | [diff] [blame] | 4517 | * Determine whether or not caller-Id information has been disabled. |
| 4518 | * |
| 4519 | * @param userHandle The user for whom to check the caller-id permission |
| 4520 | * @hide |
| 4521 | */ |
| 4522 | public boolean getCrossProfileCallerIdDisabled(UserHandle userHandle) { |
| 4523 | if (mService != null) { |
| 4524 | try { |
| 4525 | return mService.getCrossProfileCallerIdDisabledForUser(userHandle.getIdentifier()); |
| 4526 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4527 | throw e.rethrowFromSystemServer(); |
Amith Yamasani | 570002f | 2014-07-18 15:48:54 -0700 | [diff] [blame] | 4528 | } |
| 4529 | } |
| 4530 | return false; |
| 4531 | } |
| 4532 | |
| 4533 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4534 | * Called by a profile owner of a managed profile to set whether contacts search from the |
| 4535 | * managed profile will be shown in the parent profile, for incoming calls. |
| 4536 | * <p> |
| 4537 | * The calling device admin must be a profile owner. If it is not, a security exception will be |
| 4538 | * thrown. |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4539 | * |
| 4540 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4541 | * @param disabled If true contacts search in the managed profile is not displayed. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4542 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4543 | */ |
| 4544 | public void setCrossProfileContactsSearchDisabled(@NonNull ComponentName admin, |
| 4545 | boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4546 | throwIfParentInstance("setCrossProfileContactsSearchDisabled"); |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4547 | if (mService != null) { |
| 4548 | try { |
| 4549 | mService.setCrossProfileContactsSearchDisabled(admin, disabled); |
| 4550 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4551 | throw e.rethrowFromSystemServer(); |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4552 | } |
| 4553 | } |
| 4554 | } |
| 4555 | |
| 4556 | /** |
| 4557 | * Called by a profile owner of a managed profile to determine whether or not contacts search |
| 4558 | * has been disabled. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4559 | * <p> |
| 4560 | * The calling device admin must be a profile owner. If it is not, a security exception will be |
| 4561 | * thrown. |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4562 | * |
| 4563 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4564 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4565 | */ |
| 4566 | public boolean getCrossProfileContactsSearchDisabled(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4567 | throwIfParentInstance("getCrossProfileContactsSearchDisabled"); |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4568 | if (mService != null) { |
| 4569 | try { |
| 4570 | return mService.getCrossProfileContactsSearchDisabled(admin); |
| 4571 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4572 | throw e.rethrowFromSystemServer(); |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4573 | } |
| 4574 | } |
| 4575 | return false; |
| 4576 | } |
| 4577 | |
| 4578 | |
| 4579 | /** |
| 4580 | * Determine whether or not contacts search has been disabled. |
| 4581 | * |
| 4582 | * @param userHandle The user for whom to check the contacts search permission |
| 4583 | * @hide |
| 4584 | */ |
| 4585 | public boolean getCrossProfileContactsSearchDisabled(@NonNull UserHandle userHandle) { |
| 4586 | if (mService != null) { |
| 4587 | try { |
| 4588 | return mService |
| 4589 | .getCrossProfileContactsSearchDisabledForUser(userHandle.getIdentifier()); |
| 4590 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4591 | throw e.rethrowFromSystemServer(); |
Victor Chang | 1060c618 | 2016-01-04 20:16:23 +0000 | [diff] [blame] | 4592 | } |
| 4593 | } |
| 4594 | return false; |
| 4595 | } |
| 4596 | |
| 4597 | /** |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 4598 | * Start Quick Contact on the managed profile for the user, if the policy allows. |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 4599 | * |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 4600 | * @hide |
| 4601 | */ |
| 4602 | public void startManagedQuickContact(String actualLookupKey, long actualContactId, |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 4603 | boolean isContactIdIgnored, long directoryId, Intent originalIntent) { |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 4604 | if (mService != null) { |
| 4605 | try { |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 4606 | mService.startManagedQuickContact(actualLookupKey, actualContactId, |
| 4607 | isContactIdIgnored, directoryId, originalIntent); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 4608 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4609 | throw e.rethrowFromSystemServer(); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 4610 | } |
| 4611 | } |
| 4612 | } |
| 4613 | |
| 4614 | /** |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 4615 | * Start Quick Contact on the managed profile for the user, if the policy allows. |
Ricky Wai | 494b95d | 2015-11-20 16:07:15 +0000 | [diff] [blame] | 4616 | * @hide |
| 4617 | */ |
| 4618 | public void startManagedQuickContact(String actualLookupKey, long actualContactId, |
| 4619 | Intent originalIntent) { |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 4620 | startManagedQuickContact(actualLookupKey, actualContactId, false, Directory.DEFAULT, |
Ricky Wai | 494b95d | 2015-11-20 16:07:15 +0000 | [diff] [blame] | 4621 | originalIntent); |
| 4622 | } |
| 4623 | |
| 4624 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4625 | * Called by a profile owner of a managed profile to set whether bluetooth devices can access |
| 4626 | * enterprise contacts. |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4627 | * <p> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4628 | * The calling device admin must be a profile owner. If it is not, a security exception will be |
| 4629 | * thrown. |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4630 | * <p> |
| 4631 | * This API works on managed profile only. |
| 4632 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4633 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4634 | * @param disabled If true, bluetooth devices cannot access enterprise contacts. |
| 4635 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4636 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4637 | public void setBluetoothContactSharingDisabled(@NonNull ComponentName admin, boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4638 | throwIfParentInstance("setBluetoothContactSharingDisabled"); |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4639 | if (mService != null) { |
| 4640 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4641 | mService.setBluetoothContactSharingDisabled(admin, disabled); |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4642 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4643 | throw e.rethrowFromSystemServer(); |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4644 | } |
| 4645 | } |
| 4646 | } |
| 4647 | |
| 4648 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4649 | * Called by a profile owner of a managed profile to determine whether or not Bluetooth devices |
| 4650 | * cannot access enterprise contacts. |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4651 | * <p> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4652 | * The calling device admin must be a profile owner. If it is not, a security exception will be |
| 4653 | * thrown. |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4654 | * <p> |
| 4655 | * This API works on managed profile only. |
| 4656 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4657 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4658 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4659 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4660 | public boolean getBluetoothContactSharingDisabled(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4661 | throwIfParentInstance("getBluetoothContactSharingDisabled"); |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4662 | if (mService != null) { |
| 4663 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4664 | return mService.getBluetoothContactSharingDisabled(admin); |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4665 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4666 | throw e.rethrowFromSystemServer(); |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4667 | } |
| 4668 | } |
| 4669 | return true; |
| 4670 | } |
| 4671 | |
| 4672 | /** |
| 4673 | * Determine whether or not Bluetooth devices cannot access contacts. |
| 4674 | * <p> |
| 4675 | * This API works on managed profile UserHandle only. |
| 4676 | * |
| 4677 | * @param userHandle The user for whom to check the caller-id permission |
| 4678 | * @hide |
| 4679 | */ |
| 4680 | public boolean getBluetoothContactSharingDisabled(UserHandle userHandle) { |
| 4681 | if (mService != null) { |
| 4682 | try { |
| 4683 | return mService.getBluetoothContactSharingDisabledForUser(userHandle |
| 4684 | .getIdentifier()); |
| 4685 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4686 | throw e.rethrowFromSystemServer(); |
Ricky Wai | 778ba13 | 2015-03-31 14:21:22 +0100 | [diff] [blame] | 4687 | } |
| 4688 | } |
| 4689 | return true; |
| 4690 | } |
| 4691 | |
| 4692 | /** |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 4693 | * Called by the profile owner of a managed profile so that some intents sent in the managed |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4694 | * profile can also be resolved in the parent, or vice versa. Only activity intents are |
| 4695 | * supported. |
Nicolas Prevot | fc7b444 | 2014-12-17 15:28:29 +0000 | [diff] [blame] | 4696 | * |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4697 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Nicolas Prevot | 8194899 | 2014-05-16 18:25:26 +0100 | [diff] [blame] | 4698 | * @param filter The {@link IntentFilter} the intent has to match to be also resolved in the |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4699 | * other profile |
Nicolas Prevot | 41d926e | 2014-06-09 11:48:56 +0100 | [diff] [blame] | 4700 | * @param flags {@link DevicePolicyManager#FLAG_MANAGED_CAN_ACCESS_PARENT} and |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4701 | * {@link DevicePolicyManager#FLAG_PARENT_CAN_ACCESS_MANAGED} are supported. |
| 4702 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4703 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4704 | public void addCrossProfileIntentFilter(@NonNull ComponentName admin, IntentFilter filter, int flags) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4705 | throwIfParentInstance("addCrossProfileIntentFilter"); |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4706 | if (mService != null) { |
| 4707 | try { |
Nicolas Prevot | 8194899 | 2014-05-16 18:25:26 +0100 | [diff] [blame] | 4708 | mService.addCrossProfileIntentFilter(admin, filter, flags); |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4709 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4710 | throw e.rethrowFromSystemServer(); |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4711 | } |
| 4712 | } |
| 4713 | } |
| 4714 | |
| 4715 | /** |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 4716 | * Called by a profile owner of a managed profile to remove the cross-profile intent filters |
| 4717 | * that go from the managed profile to the parent, or from the parent to the managed profile. |
Nicolas Prevot | 3f7777f | 2014-07-24 15:58:39 +0100 | [diff] [blame] | 4718 | * Only removes those that have been set by the profile owner. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4719 | * |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4720 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4721 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4722 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4723 | public void clearCrossProfileIntentFilters(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4724 | throwIfParentInstance("clearCrossProfileIntentFilters"); |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4725 | if (mService != null) { |
| 4726 | try { |
Nicolas Prevot | 8194899 | 2014-05-16 18:25:26 +0100 | [diff] [blame] | 4727 | mService.clearCrossProfileIntentFilters(admin); |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4728 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4729 | throw e.rethrowFromSystemServer(); |
Nicolas Prevot | 10fa67c | 2014-03-24 13:44:38 +0000 | [diff] [blame] | 4730 | } |
| 4731 | } |
| 4732 | } |
| 4733 | |
| 4734 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4735 | * Called by a profile or device owner to set the permitted accessibility services. When set by |
| 4736 | * a device owner or profile owner the restriction applies to all profiles of the user the |
| 4737 | * device owner or profile owner is an admin for. By default the user can use any accessiblity |
| 4738 | * service. When zero or more packages have been added, accessiblity services that are not in |
| 4739 | * the list and not part of the system can not be enabled by the user. |
| 4740 | * <p> |
| 4741 | * Calling with a null value for the list disables the restriction so that all services can be |
| 4742 | * used, calling with an empty list only allows the builtin system's services. |
| 4743 | * <p> |
| 4744 | * System accesibility services are always available to the user the list can't modify this. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4745 | * |
| 4746 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4747 | * @param packageNames List of accessibility service package names. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4748 | * @return true if setting the restriction succeeded. It fail if there is one or more non-system |
| 4749 | * accessibility services enabled, that are not in the list. |
| 4750 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4751 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4752 | public boolean setPermittedAccessibilityServices(@NonNull ComponentName admin, |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4753 | List<String> packageNames) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4754 | throwIfParentInstance("setPermittedAccessibilityServices"); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4755 | if (mService != null) { |
| 4756 | try { |
| 4757 | return mService.setPermittedAccessibilityServices(admin, packageNames); |
| 4758 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4759 | throw e.rethrowFromSystemServer(); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4760 | } |
| 4761 | } |
| 4762 | return false; |
| 4763 | } |
| 4764 | |
| 4765 | /** |
| 4766 | * Returns the list of permitted accessibility services set by this device or profile owner. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4767 | * <p> |
| 4768 | * An empty list means no accessibility services except system services are allowed. Null means |
| 4769 | * all accessibility services are allowed. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4770 | * |
| 4771 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4772 | * @return List of accessiblity service package names. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4773 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4774 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4775 | public @Nullable List<String> getPermittedAccessibilityServices(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4776 | throwIfParentInstance("getPermittedAccessibilityServices"); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4777 | if (mService != null) { |
| 4778 | try { |
| 4779 | return mService.getPermittedAccessibilityServices(admin); |
| 4780 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4781 | throw e.rethrowFromSystemServer(); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4782 | } |
| 4783 | } |
| 4784 | return null; |
| 4785 | } |
| 4786 | |
| 4787 | /** |
Sudheer Shanka | 5692586 | 2016-01-28 19:43:59 +0000 | [diff] [blame] | 4788 | * Called by the system to check if a specific accessibility service is disabled by admin. |
| 4789 | * |
| 4790 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4791 | * @param packageName Accessibility service package name that needs to be checked. |
| 4792 | * @param userHandle user id the admin is running as. |
| 4793 | * @return true if the accessibility service is permitted, otherwise false. |
| 4794 | * |
| 4795 | * @hide |
| 4796 | */ |
| 4797 | public boolean isAccessibilityServicePermittedByAdmin(@NonNull ComponentName admin, |
| 4798 | @NonNull String packageName, int userHandle) { |
| 4799 | if (mService != null) { |
| 4800 | try { |
| 4801 | return mService.isAccessibilityServicePermittedByAdmin(admin, packageName, |
| 4802 | userHandle); |
| 4803 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4804 | throw e.rethrowFromSystemServer(); |
Sudheer Shanka | 5692586 | 2016-01-28 19:43:59 +0000 | [diff] [blame] | 4805 | } |
| 4806 | } |
| 4807 | return false; |
| 4808 | } |
| 4809 | |
| 4810 | /** |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4811 | * Returns the list of accessibility services permitted by the device or profiles |
| 4812 | * owners of this user. |
| 4813 | * |
| 4814 | * <p>Null means all accessibility services are allowed, if a non-null list is returned |
| 4815 | * it will contain the intersection of the permitted lists for any device or profile |
| 4816 | * owners that apply to this user. It will also include any system accessibility services. |
| 4817 | * |
| 4818 | * @param userId which user to check for. |
| 4819 | * @return List of accessiblity service package names. |
| 4820 | * @hide |
| 4821 | */ |
| 4822 | @SystemApi |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4823 | public @Nullable List<String> getPermittedAccessibilityServices(int userId) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4824 | throwIfParentInstance("getPermittedAccessibilityServices"); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4825 | if (mService != null) { |
| 4826 | try { |
| 4827 | return mService.getPermittedAccessibilityServicesForUser(userId); |
| 4828 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4829 | throw e.rethrowFromSystemServer(); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4830 | } |
| 4831 | } |
| 4832 | return null; |
| 4833 | } |
| 4834 | |
| 4835 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4836 | * Called by a profile or device owner to set the permitted input methods services. When set by |
| 4837 | * a device owner or profile owner the restriction applies to all profiles of the user the |
| 4838 | * device owner or profile owner is an admin for. By default the user can use any input method. |
| 4839 | * When zero or more packages have been added, input method that are not in the list and not |
| 4840 | * part of the system can not be enabled by the user. This method will fail if it is called for |
| 4841 | * a admin that is not for the foreground user or a profile of the foreground user. |
| 4842 | * <p> |
| 4843 | * Calling with a null value for the list disables the restriction so that all input methods can |
| 4844 | * be used, calling with an empty list disables all but the system's own input methods. |
| 4845 | * <p> |
| 4846 | * System input methods are always available to the user this method can't modify this. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4847 | * |
| 4848 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4849 | * @param packageNames List of input method package names. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4850 | * @return true if setting the restriction succeeded. It will fail if there are one or more |
| 4851 | * non-system input methods currently enabled that are not in the packageNames list. |
| 4852 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4853 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4854 | public boolean setPermittedInputMethods(@NonNull ComponentName admin, List<String> packageNames) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4855 | throwIfParentInstance("setPermittedInputMethods"); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4856 | if (mService != null) { |
| 4857 | try { |
| 4858 | return mService.setPermittedInputMethods(admin, packageNames); |
| 4859 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4860 | throw e.rethrowFromSystemServer(); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4861 | } |
| 4862 | } |
| 4863 | return false; |
| 4864 | } |
| 4865 | |
| 4866 | |
| 4867 | /** |
| 4868 | * Returns the list of permitted input methods set by this device or profile owner. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4869 | * <p> |
| 4870 | * An empty list means no input methods except system input methods are allowed. Null means all |
| 4871 | * input methods are allowed. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4872 | * |
| 4873 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4874 | * @return List of input method package names. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4875 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4876 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4877 | public @Nullable List<String> getPermittedInputMethods(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4878 | throwIfParentInstance("getPermittedInputMethods"); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4879 | if (mService != null) { |
| 4880 | try { |
| 4881 | return mService.getPermittedInputMethods(admin); |
| 4882 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4883 | throw e.rethrowFromSystemServer(); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4884 | } |
| 4885 | } |
| 4886 | return null; |
| 4887 | } |
| 4888 | |
| 4889 | /** |
Sudheer Shanka | 5692586 | 2016-01-28 19:43:59 +0000 | [diff] [blame] | 4890 | * Called by the system to check if a specific input method is disabled by admin. |
| 4891 | * |
| 4892 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4893 | * @param packageName Input method package name that needs to be checked. |
| 4894 | * @param userHandle user id the admin is running as. |
| 4895 | * @return true if the input method is permitted, otherwise false. |
| 4896 | * |
| 4897 | * @hide |
| 4898 | */ |
| 4899 | public boolean isInputMethodPermittedByAdmin(@NonNull ComponentName admin, |
| 4900 | @NonNull String packageName, int userHandle) { |
| 4901 | if (mService != null) { |
| 4902 | try { |
| 4903 | return mService.isInputMethodPermittedByAdmin(admin, packageName, userHandle); |
| 4904 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4905 | throw e.rethrowFromSystemServer(); |
Sudheer Shanka | 5692586 | 2016-01-28 19:43:59 +0000 | [diff] [blame] | 4906 | } |
| 4907 | } |
| 4908 | return false; |
| 4909 | } |
| 4910 | |
| 4911 | /** |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4912 | * Returns the list of input methods permitted by the device or profiles |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 4913 | * owners of the current user. (*Not* calling user, due to a limitation in InputMethodManager.) |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4914 | * |
| 4915 | * <p>Null means all input methods are allowed, if a non-null list is returned |
| 4916 | * it will contain the intersection of the permitted lists for any device or profile |
| 4917 | * owners that apply to this user. It will also include any system input methods. |
| 4918 | * |
| 4919 | * @return List of input method package names. |
| 4920 | * @hide |
| 4921 | */ |
| 4922 | @SystemApi |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4923 | public @Nullable List<String> getPermittedInputMethodsForCurrentUser() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4924 | throwIfParentInstance("getPermittedInputMethodsForCurrentUser"); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4925 | if (mService != null) { |
| 4926 | try { |
| 4927 | return mService.getPermittedInputMethodsForCurrentUser(); |
| 4928 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4929 | throw e.rethrowFromSystemServer(); |
Kenny Guy | fa80a4f | 2014-08-20 19:40:59 +0100 | [diff] [blame] | 4930 | } |
| 4931 | } |
| 4932 | return null; |
| 4933 | } |
| 4934 | |
| 4935 | /** |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 4936 | * Called by a device owner to get the list of apps to keep around as APKs even if no user has |
| 4937 | * currently installed it. |
| 4938 | * |
| 4939 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4940 | * |
| 4941 | * @return List of package names to keep cached. |
| 4942 | * @hide |
| 4943 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4944 | public @Nullable List<String> getKeepUninstalledPackages(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4945 | throwIfParentInstance("getKeepUninstalledPackages"); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 4946 | if (mService != null) { |
| 4947 | try { |
| 4948 | return mService.getKeepUninstalledPackages(admin); |
| 4949 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4950 | throw e.rethrowFromSystemServer(); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 4951 | } |
| 4952 | } |
| 4953 | return null; |
| 4954 | } |
| 4955 | |
| 4956 | /** |
| 4957 | * Called by a device owner to set a list of apps to keep around as APKs even if no user has |
| 4958 | * currently installed it. |
| 4959 | * |
| 4960 | * <p>Please note that setting this policy does not imply that specified apps will be |
| 4961 | * automatically pre-cached.</p> |
| 4962 | * |
| 4963 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4964 | * @param packageNames List of package names to keep cached. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 4965 | * @throws SecurityException if {@code admin} is not a device owner. |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 4966 | * @hide |
| 4967 | */ |
| 4968 | public void setKeepUninstalledPackages(@NonNull ComponentName admin, |
| 4969 | @NonNull List<String> packageNames) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 4970 | throwIfParentInstance("setKeepUninstalledPackages"); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 4971 | if (mService != null) { |
| 4972 | try { |
| 4973 | mService.setKeepUninstalledPackages(admin, packageNames); |
| 4974 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 4975 | throw e.rethrowFromSystemServer(); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 4976 | } |
| 4977 | } |
| 4978 | } |
| 4979 | |
| 4980 | /** |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 4981 | * Called by a device owner to create a user with the specified name. The UserHandle returned |
| 4982 | * by this method should not be persisted as user handles are recycled as users are removed and |
| 4983 | * created. If you need to persist an identifier for this user, use |
| 4984 | * {@link UserManager#getSerialNumberForUser}. |
| 4985 | * |
| 4986 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 4987 | * @param name the user's name |
| 4988 | * @see UserHandle |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 4989 | * @return the {@link android.os.UserHandle} object for the created user, or {@code null} if the |
| 4990 | * user could not be created. |
Kenny Guy | 14f48e5 | 2015-06-29 15:12:36 +0100 | [diff] [blame] | 4991 | * |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 4992 | * @deprecated From {@link android.os.Build.VERSION_CODES#M} |
phweiss | 27ee334 | 2016-02-08 16:40:45 +0100 | [diff] [blame] | 4993 | * @removed From {@link android.os.Build.VERSION_CODES#N} |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 4994 | */ |
Kenny Guy | 14f48e5 | 2015-06-29 15:12:36 +0100 | [diff] [blame] | 4995 | @Deprecated |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 4996 | public @Nullable UserHandle createUser(@NonNull ComponentName admin, String name) { |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 4997 | return null; |
| 4998 | } |
| 4999 | |
| 5000 | /** |
Jason Monk | 03978a4 | 2014-06-10 15:05:30 -0400 | [diff] [blame] | 5001 | * Called by a device owner to create a user with the specified name. The UserHandle returned |
| 5002 | * by this method should not be persisted as user handles are recycled as users are removed and |
| 5003 | * created. If you need to persist an identifier for this user, use |
| 5004 | * {@link UserManager#getSerialNumberForUser}. The new user will be started in the background |
| 5005 | * immediately. |
| 5006 | * |
| 5007 | * <p> profileOwnerComponent is the {@link DeviceAdminReceiver} to be the profile owner as well |
| 5008 | * as registered as an active admin on the new user. The profile owner package will be |
| 5009 | * installed on the new user if it already is installed on the device. |
| 5010 | * |
| 5011 | * <p>If the optionalInitializeData is not null, then the extras will be passed to the |
| 5012 | * profileOwnerComponent when onEnable is called. |
| 5013 | * |
| 5014 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5015 | * @param name the user's name |
| 5016 | * @param ownerName the human readable name of the organisation associated with this DPM. |
| 5017 | * @param profileOwnerComponent The {@link DeviceAdminReceiver} that will be an active admin on |
| 5018 | * the user. |
| 5019 | * @param adminExtras Extras that will be passed to onEnable of the admin receiver |
| 5020 | * on the new user. |
| 5021 | * @see UserHandle |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5022 | * @return the {@link android.os.UserHandle} object for the created user, or {@code null} if the |
| 5023 | * user could not be created. |
Kenny Guy | 14f48e5 | 2015-06-29 15:12:36 +0100 | [diff] [blame] | 5024 | * |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 5025 | * @deprecated From {@link android.os.Build.VERSION_CODES#M} |
phweiss | 27ee334 | 2016-02-08 16:40:45 +0100 | [diff] [blame] | 5026 | * @removed From {@link android.os.Build.VERSION_CODES#N} |
Jason Monk | 03978a4 | 2014-06-10 15:05:30 -0400 | [diff] [blame] | 5027 | */ |
Kenny Guy | 14f48e5 | 2015-06-29 15:12:36 +0100 | [diff] [blame] | 5028 | @Deprecated |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5029 | public @Nullable UserHandle createAndInitializeUser(@NonNull ComponentName admin, String name, |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5030 | String ownerName, @NonNull ComponentName profileOwnerComponent, Bundle adminExtras) { |
Jason Monk | 03978a4 | 2014-06-10 15:05:30 -0400 | [diff] [blame] | 5031 | return null; |
| 5032 | } |
| 5033 | |
| 5034 | /** |
phweiss | a92e121 | 2016-01-25 17:14:10 +0100 | [diff] [blame] | 5035 | * Flag used by {@link #createAndManageUser} to skip setup wizard after creating a new user. |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5036 | */ |
| 5037 | public static final int SKIP_SETUP_WIZARD = 0x0001; |
| 5038 | |
| 5039 | /** |
Lenka Trochtova | c8202c8 | 2016-01-26 15:11:09 +0100 | [diff] [blame] | 5040 | * Flag used by {@link #createAndManageUser} to specify that the user should be created |
| 5041 | * ephemeral. |
| 5042 | * @hide |
| 5043 | */ |
| 5044 | public static final int MAKE_USER_EPHEMERAL = 0x0002; |
| 5045 | |
| 5046 | /** |
phweiss | a92e121 | 2016-01-25 17:14:10 +0100 | [diff] [blame] | 5047 | * Called by a device owner to create a user with the specified name and a given component of |
| 5048 | * the calling package as profile owner. The UserHandle returned by this method should not be |
| 5049 | * persisted as user handles are recycled as users are removed and created. If you need to |
| 5050 | * persist an identifier for this user, use {@link UserManager#getSerialNumberForUser}. The new |
| 5051 | * user will not be started in the background. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5052 | * <p> |
| 5053 | * admin is the {@link DeviceAdminReceiver} which is the device owner. profileOwner is also a |
| 5054 | * DeviceAdminReceiver in the same package as admin, and will become the profile owner and will |
| 5055 | * be registered as an active admin on the new user. The profile owner package will be installed |
| 5056 | * on the new user. |
| 5057 | * <p> |
| 5058 | * If the adminExtras are not null, they will be stored on the device until the user is started |
| 5059 | * for the first time. Then the extras will be passed to the admin when onEnable is called. |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5060 | * |
| 5061 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5062 | * @param name The user's name. |
phweiss | a92e121 | 2016-01-25 17:14:10 +0100 | [diff] [blame] | 5063 | * @param profileOwner Which {@link DeviceAdminReceiver} will be profile owner. Has to be in the |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5064 | * same package as admin, otherwise no user is created and an |
| 5065 | * IllegalArgumentException is thrown. |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5066 | * @param adminExtras Extras that will be passed to onEnable of the admin receiver on the new |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5067 | * user. |
phweiss | a92e121 | 2016-01-25 17:14:10 +0100 | [diff] [blame] | 5068 | * @param flags {@link #SKIP_SETUP_WIZARD} is supported. |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5069 | * @see UserHandle |
| 5070 | * @return the {@link android.os.UserHandle} object for the created user, or {@code null} if the |
| 5071 | * user could not be created. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5072 | * @throws SecurityException if {@code admin} is not a device owner. |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5073 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5074 | public @Nullable UserHandle createAndManageUser(@NonNull ComponentName admin, |
| 5075 | @NonNull String name, |
phweiss | a92e121 | 2016-01-25 17:14:10 +0100 | [diff] [blame] | 5076 | @NonNull ComponentName profileOwner, @Nullable PersistableBundle adminExtras, |
| 5077 | int flags) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5078 | throwIfParentInstance("createAndManageUser"); |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5079 | try { |
phweiss | a92e121 | 2016-01-25 17:14:10 +0100 | [diff] [blame] | 5080 | return mService.createAndManageUser(admin, name, profileOwner, adminExtras, flags); |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5081 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5082 | throw re.rethrowFromSystemServer(); |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5083 | } |
phweiss | 343fb33 | 2016-01-25 14:48:59 +0100 | [diff] [blame] | 5084 | } |
| 5085 | |
| 5086 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5087 | * Called by a device owner to remove a user and all associated data. The primary user can not |
| 5088 | * be removed. |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 5089 | * |
| 5090 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5091 | * @param userHandle the user to remove. |
| 5092 | * @return {@code true} if the user was removed, {@code false} otherwise. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5093 | * @throws SecurityException if {@code admin} is not a device owner. |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 5094 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5095 | public boolean removeUser(@NonNull ComponentName admin, UserHandle userHandle) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5096 | throwIfParentInstance("removeUser"); |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 5097 | try { |
| 5098 | return mService.removeUser(admin, userHandle); |
| 5099 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5100 | throw re.rethrowFromSystemServer(); |
Julia Reynolds | 1e95839 | 2014-05-16 14:25:21 -0400 | [diff] [blame] | 5101 | } |
| 5102 | } |
| 5103 | |
| 5104 | /** |
Jason Monk | 582d911 | 2014-07-09 19:57:08 -0400 | [diff] [blame] | 5105 | * Called by a device owner to switch the specified user to the foreground. |
| 5106 | * |
| 5107 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5108 | * @param userHandle the user to switch to; null will switch to primary. |
| 5109 | * @return {@code true} if the switch was successful, {@code false} otherwise. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5110 | * @throws SecurityException if {@code admin} is not a device owner. |
Jason Monk | 582d911 | 2014-07-09 19:57:08 -0400 | [diff] [blame] | 5111 | * @see Intent#ACTION_USER_FOREGROUND |
| 5112 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5113 | public boolean switchUser(@NonNull ComponentName admin, @Nullable UserHandle userHandle) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5114 | throwIfParentInstance("switchUser"); |
Jason Monk | 582d911 | 2014-07-09 19:57:08 -0400 | [diff] [blame] | 5115 | try { |
| 5116 | return mService.switchUser(admin, userHandle); |
| 5117 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5118 | throw re.rethrowFromSystemServer(); |
Jason Monk | 582d911 | 2014-07-09 19:57:08 -0400 | [diff] [blame] | 5119 | } |
| 5120 | } |
| 5121 | |
| 5122 | /** |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 5123 | * Retrieves the application restrictions for a given target application running in the calling |
| 5124 | * user. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5125 | * <p> |
| 5126 | * The caller must be a profile or device owner on that user, or the package allowed to manage |
| 5127 | * application restrictions via {@link #setApplicationRestrictionsManagingPackage}; otherwise a |
| 5128 | * security exception will be thrown. |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 5129 | * |
Fyodor Kupolov | 4e9af06 | 2016-07-18 16:59:11 -0700 | [diff] [blame] | 5130 | * <p>NOTE: The method performs disk I/O and shouldn't be called on the main thread |
| 5131 | * |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 5132 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5133 | * {@code null} if called by the application restrictions managing package. |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 5134 | * @param packageName The name of the package to fetch restricted settings of. |
| 5135 | * @return {@link Bundle} of settings corresponding to what was set last time |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5136 | * {@link DevicePolicyManager#setApplicationRestrictions} was called, or an empty |
| 5137 | * {@link Bundle} if no restrictions have been set. |
| 5138 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Esteban Talavera | bf60f72 | 2015-12-10 16:26:44 +0000 | [diff] [blame] | 5139 | * @see {@link #setApplicationRestrictionsManagingPackage} |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 5140 | */ |
Fyodor Kupolov | 4e9af06 | 2016-07-18 16:59:11 -0700 | [diff] [blame] | 5141 | @WorkerThread |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5142 | public @NonNull Bundle getApplicationRestrictions( |
| 5143 | @Nullable ComponentName admin, String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5144 | throwIfParentInstance("getApplicationRestrictions"); |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 5145 | if (mService != null) { |
| 5146 | try { |
| 5147 | return mService.getApplicationRestrictions(admin, packageName); |
| 5148 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5149 | throw e.rethrowFromSystemServer(); |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 5150 | } |
| 5151 | } |
| 5152 | return null; |
| 5153 | } |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5154 | |
| 5155 | /** |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 5156 | * Called by a profile or device owner to set a user restriction specified by the key. |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5157 | * <p> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5158 | * The calling device admin must be a profile or device owner; if it is not, a security |
| 5159 | * exception will be thrown. |
Jim Miller | df2258b | 2014-04-27 20:10:26 -0700 | [diff] [blame] | 5160 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5161 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5162 | * @param key The key of the restriction. See the constants in {@link android.os.UserManager} |
| 5163 | * for the list of keys. |
| 5164 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5165 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5166 | public void addUserRestriction(@NonNull ComponentName admin, String key) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5167 | throwIfParentInstance("addUserRestriction"); |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5168 | if (mService != null) { |
| 5169 | try { |
| 5170 | mService.setUserRestriction(admin, key, true); |
| 5171 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5172 | throw e.rethrowFromSystemServer(); |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5173 | } |
| 5174 | } |
| 5175 | } |
| 5176 | |
| 5177 | /** |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 5178 | * Called by a profile or device owner to clear a user restriction specified by the key. |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5179 | * <p> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5180 | * The calling device admin must be a profile or device owner; if it is not, a security |
| 5181 | * exception will be thrown. |
Jim Miller | df2258b | 2014-04-27 20:10:26 -0700 | [diff] [blame] | 5182 | * |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5183 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5184 | * @param key The key of the restriction. See the constants in {@link android.os.UserManager} |
| 5185 | * for the list of keys. |
| 5186 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5187 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5188 | public void clearUserRestriction(@NonNull ComponentName admin, String key) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5189 | throwIfParentInstance("clearUserRestriction"); |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5190 | if (mService != null) { |
| 5191 | try { |
| 5192 | mService.setUserRestriction(admin, key, false); |
| 5193 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5194 | throw e.rethrowFromSystemServer(); |
Amith Yamasani | be46532 | 2014-04-24 13:45:17 -0700 | [diff] [blame] | 5195 | } |
| 5196 | } |
| 5197 | } |
Adam Connors | 010cfd4 | 2014-04-16 12:48:13 +0100 | [diff] [blame] | 5198 | |
| 5199 | /** |
Makoto Onuki | 3a3092f | 2015-10-30 11:07:51 -0700 | [diff] [blame] | 5200 | * Called by a profile or device owner to get user restrictions set with |
| 5201 | * {@link #addUserRestriction(ComponentName, String)}. |
| 5202 | * <p> |
| 5203 | * The target user may have more restrictions set by the system or other device owner / profile |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5204 | * owner. To get all the user restrictions currently set, use |
Makoto Onuki | 3a3092f | 2015-10-30 11:07:51 -0700 | [diff] [blame] | 5205 | * {@link UserManager#getUserRestrictions()}. |
| 5206 | * |
| 5207 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5208 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Makoto Onuki | 3a3092f | 2015-10-30 11:07:51 -0700 | [diff] [blame] | 5209 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5210 | public @NonNull Bundle getUserRestrictions(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5211 | throwIfParentInstance("getUserRestrictions"); |
Makoto Onuki | 3a3092f | 2015-10-30 11:07:51 -0700 | [diff] [blame] | 5212 | Bundle ret = null; |
| 5213 | if (mService != null) { |
| 5214 | try { |
Sudheer Shanka | 549b969 | 2016-03-30 17:12:07 -0700 | [diff] [blame] | 5215 | ret = mService.getUserRestrictions(admin); |
| 5216 | } catch (RemoteException e) { |
| 5217 | throw e.rethrowFromSystemServer(); |
| 5218 | } |
| 5219 | } |
| 5220 | return ret == null ? new Bundle() : ret; |
| 5221 | } |
| 5222 | |
| 5223 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5224 | * Called by profile or device owners to hide or unhide packages. When a package is hidden it is |
| 5225 | * unavailable for use, but the data and actual package file remain. |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5226 | * |
| 5227 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Amith Yamasani | e5bcff6 | 2014-07-19 15:44:09 -0700 | [diff] [blame] | 5228 | * @param packageName The name of the package to hide or unhide. |
| 5229 | * @param hidden {@code true} if the package should be hidden, {@code false} if it should be |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5230 | * unhidden. |
Amith Yamasani | e5bcff6 | 2014-07-19 15:44:09 -0700 | [diff] [blame] | 5231 | * @return boolean Whether the hidden setting of the package was successfully updated. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5232 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5233 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5234 | public boolean setApplicationHidden(@NonNull ComponentName admin, String packageName, |
Amith Yamasani | e5bcff6 | 2014-07-19 15:44:09 -0700 | [diff] [blame] | 5235 | boolean hidden) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5236 | throwIfParentInstance("setApplicationHidden"); |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5237 | if (mService != null) { |
| 5238 | try { |
Amith Yamasani | e5bcff6 | 2014-07-19 15:44:09 -0700 | [diff] [blame] | 5239 | return mService.setApplicationHidden(admin, packageName, hidden); |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5240 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5241 | throw e.rethrowFromSystemServer(); |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5242 | } |
| 5243 | } |
| 5244 | return false; |
| 5245 | } |
| 5246 | |
| 5247 | /** |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 5248 | * Called by profile or device owners to determine if a package is hidden. |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5249 | * |
| 5250 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Amith Yamasani | e5bcff6 | 2014-07-19 15:44:09 -0700 | [diff] [blame] | 5251 | * @param packageName The name of the package to retrieve the hidden status of. |
| 5252 | * @return boolean {@code true} if the package is hidden, {@code false} otherwise. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5253 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5254 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5255 | public boolean isApplicationHidden(@NonNull ComponentName admin, String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5256 | throwIfParentInstance("isApplicationHidden"); |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5257 | if (mService != null) { |
| 5258 | try { |
Amith Yamasani | e5bcff6 | 2014-07-19 15:44:09 -0700 | [diff] [blame] | 5259 | return mService.isApplicationHidden(admin, packageName); |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5260 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5261 | throw e.rethrowFromSystemServer(); |
Julia Reynolds | 966881e | 2014-05-14 12:23:08 -0400 | [diff] [blame] | 5262 | } |
| 5263 | } |
| 5264 | return false; |
| 5265 | } |
| 5266 | |
| 5267 | /** |
Julia Reynolds | 20118f1 | 2015-02-11 12:34:08 -0500 | [diff] [blame] | 5268 | * Called by profile or device owners to re-enable a system app that was disabled by default |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 5269 | * when the user was initialized. |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5270 | * |
| 5271 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 5272 | * @param packageName The package to be re-enabled in the calling profile. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5273 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5274 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5275 | public void enableSystemApp(@NonNull ComponentName admin, String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5276 | throwIfParentInstance("enableSystemApp"); |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5277 | if (mService != null) { |
| 5278 | try { |
| 5279 | mService.enableSystemApp(admin, packageName); |
| 5280 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5281 | throw e.rethrowFromSystemServer(); |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5282 | } |
| 5283 | } |
| 5284 | } |
| 5285 | |
| 5286 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5287 | * Called by profile or device owners to re-enable system apps by intent that were disabled by |
| 5288 | * default when the user was initialized. |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5289 | * |
| 5290 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5291 | * @param intent An intent matching the app(s) to be installed. All apps that resolve for this |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5292 | * intent will be re-enabled in the calling profile. |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5293 | * @return int The number of activities that matched the intent and were installed. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5294 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5295 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5296 | public int enableSystemApp(@NonNull ComponentName admin, Intent intent) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5297 | throwIfParentInstance("enableSystemApp"); |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5298 | if (mService != null) { |
| 5299 | try { |
| 5300 | return mService.enableSystemAppWithIntent(admin, intent); |
| 5301 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5302 | throw e.rethrowFromSystemServer(); |
Adam Connors | 655be2a | 2014-07-14 09:01:25 +0000 | [diff] [blame] | 5303 | } |
| 5304 | } |
| 5305 | return 0; |
| 5306 | } |
| 5307 | |
| 5308 | /** |
Sander Alewijnse | 112e053 | 2014-10-29 13:28:49 +0000 | [diff] [blame] | 5309 | * Called by a device owner or profile owner to disable account management for a specific type |
| 5310 | * of account. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5311 | * <p> |
| 5312 | * The calling device admin must be a device owner or profile owner. If it is not, a security |
| 5313 | * exception will be thrown. |
| 5314 | * <p> |
| 5315 | * When account management is disabled for an account type, adding or removing an account of |
| 5316 | * that type will not be possible. |
| 5317 | * <p> |
| 5318 | * From {@link android.os.Build.VERSION_CODES#N} the profile or device owner can still use |
Benjamin Franz | b6c0ce4 | 2015-11-05 10:06:51 +0000 | [diff] [blame] | 5319 | * {@link android.accounts.AccountManager} APIs to add or remove accounts when account |
| 5320 | * management for a specific type is disabled. |
| 5321 | * |
Sander Alewijnse | 650c334 | 2014-05-08 18:00:50 +0100 | [diff] [blame] | 5322 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5323 | * @param accountType For which account management is disabled or enabled. |
| 5324 | * @param disabled The boolean indicating that account management will be disabled (true) or |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5325 | * enabled (false). |
| 5326 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Sander Alewijnse | 650c334 | 2014-05-08 18:00:50 +0100 | [diff] [blame] | 5327 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5328 | public void setAccountManagementDisabled(@NonNull ComponentName admin, String accountType, |
Sander Alewijnse | 650c334 | 2014-05-08 18:00:50 +0100 | [diff] [blame] | 5329 | boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5330 | throwIfParentInstance("setAccountManagementDisabled"); |
Sander Alewijnse | 650c334 | 2014-05-08 18:00:50 +0100 | [diff] [blame] | 5331 | if (mService != null) { |
| 5332 | try { |
| 5333 | mService.setAccountManagementDisabled(admin, accountType, disabled); |
| 5334 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5335 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | 650c334 | 2014-05-08 18:00:50 +0100 | [diff] [blame] | 5336 | } |
| 5337 | } |
| 5338 | } |
| 5339 | |
| 5340 | /** |
Sander Alewijnse | 5c02db6 | 2014-05-07 10:46:57 +0100 | [diff] [blame] | 5341 | * Gets the array of accounts for which account management is disabled by the profile owner. |
| 5342 | * |
| 5343 | * <p> Account management can be disabled/enabled by calling |
| 5344 | * {@link #setAccountManagementDisabled}. |
| 5345 | * |
| 5346 | * @return a list of account types for which account management has been disabled. |
| 5347 | * |
| 5348 | * @see #setAccountManagementDisabled |
| 5349 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5350 | public @Nullable String[] getAccountTypesWithManagementDisabled() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5351 | throwIfParentInstance("getAccountTypesWithManagementDisabled"); |
Makoto Onuki | cc4bbeb | 2015-09-17 10:28:24 -0700 | [diff] [blame] | 5352 | return getAccountTypesWithManagementDisabledAsUser(myUserId()); |
Alexandra Gherghina | 999d394 | 2014-07-03 11:40:08 +0100 | [diff] [blame] | 5353 | } |
| 5354 | |
| 5355 | /** |
| 5356 | * @see #getAccountTypesWithManagementDisabled() |
| 5357 | * @hide |
| 5358 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5359 | public @Nullable String[] getAccountTypesWithManagementDisabledAsUser(int userId) { |
Sander Alewijnse | 5c02db6 | 2014-05-07 10:46:57 +0100 | [diff] [blame] | 5360 | if (mService != null) { |
| 5361 | try { |
Alexandra Gherghina | 999d394 | 2014-07-03 11:40:08 +0100 | [diff] [blame] | 5362 | return mService.getAccountTypesWithManagementDisabledAsUser(userId); |
Sander Alewijnse | 5c02db6 | 2014-05-07 10:46:57 +0100 | [diff] [blame] | 5363 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5364 | throw e.rethrowFromSystemServer(); |
Sander Alewijnse | 5c02db6 | 2014-05-07 10:46:57 +0100 | [diff] [blame] | 5365 | } |
| 5366 | } |
| 5367 | |
| 5368 | return null; |
| 5369 | } |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5370 | |
| 5371 | /** |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5372 | * Sets which packages may enter lock task mode. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5373 | * <p> |
| 5374 | * Any packages that shares uid with an allowed package will also be allowed to activate lock |
| 5375 | * task. From {@link android.os.Build.VERSION_CODES#M} removing packages from the lock task |
| 5376 | * package list results in locked tasks belonging to those packages to be finished. This |
| 5377 | * function can only be called by the device owner. |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5378 | * |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5379 | * @param packages The list of packages allowed to enter lock task mode |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 5380 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5381 | * @throws SecurityException if {@code admin} is not a device owner. |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5382 | * @see Activity#startLockTask() |
Benjamin Franz | 6cdb27e | 2015-02-26 12:26:53 +0000 | [diff] [blame] | 5383 | * @see DeviceAdminReceiver#onLockTaskModeEntering(Context, Intent, String) |
| 5384 | * @see DeviceAdminReceiver#onLockTaskModeExiting(Context, Intent) |
Jason Monk | 1c7c319 | 2014-06-26 12:52:18 -0400 | [diff] [blame] | 5385 | * @see UserManager#DISALLOW_CREATE_WINDOWS |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5386 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5387 | public void setLockTaskPackages(@NonNull ComponentName admin, String[] packages) |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 5388 | throws SecurityException { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5389 | throwIfParentInstance("setLockTaskPackages"); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5390 | if (mService != null) { |
| 5391 | try { |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 5392 | mService.setLockTaskPackages(admin, packages); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5393 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5394 | throw e.rethrowFromSystemServer(); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5395 | } |
| 5396 | } |
| 5397 | } |
| 5398 | |
| 5399 | /** |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5400 | * This function returns the list of packages allowed to start the lock task mode. |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 5401 | * |
| 5402 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5403 | * @hide |
| 5404 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5405 | public @NonNull String[] getLockTaskPackages(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5406 | throwIfParentInstance("getLockTaskPackages"); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5407 | if (mService != null) { |
| 5408 | try { |
Jason Monk | 48aacba | 2014-08-13 16:29:08 -0400 | [diff] [blame] | 5409 | return mService.getLockTaskPackages(admin); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5410 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5411 | throw e.rethrowFromSystemServer(); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5412 | } |
| 5413 | } |
| 5414 | return null; |
| 5415 | } |
| 5416 | |
| 5417 | /** |
| 5418 | * This function lets the caller know whether the given component is allowed to start the |
| 5419 | * lock task mode. |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5420 | * @param pkg The package to check |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5421 | */ |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5422 | public boolean isLockTaskPermitted(String pkg) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5423 | throwIfParentInstance("isLockTaskPermitted"); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5424 | if (mService != null) { |
| 5425 | try { |
Jason Monk | d7b8621 | 2014-06-16 13:15:38 -0400 | [diff] [blame] | 5426 | return mService.isLockTaskPermitted(pkg); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5427 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5428 | throw e.rethrowFromSystemServer(); |
justinzhang | 511e0d8 | 2014-03-24 16:09:24 -0400 | [diff] [blame] | 5429 | } |
| 5430 | } |
| 5431 | return false; |
| 5432 | } |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5433 | |
| 5434 | /** |
| 5435 | * Called by device owners to update {@link Settings.Global} settings. Validation that the value |
| 5436 | * of the setting is in the correct form for the setting type should be performed by the caller. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5437 | * <p> |
| 5438 | * The settings that can be updated with this method are: |
Julia Reynolds | 9ed66da | 2014-08-26 15:42:03 -0400 | [diff] [blame] | 5439 | * <ul> |
| 5440 | * <li>{@link Settings.Global#ADB_ENABLED}</li> |
| 5441 | * <li>{@link Settings.Global#AUTO_TIME}</li> |
| 5442 | * <li>{@link Settings.Global#AUTO_TIME_ZONE}</li> |
Julia Reynolds | 9ed66da | 2014-08-26 15:42:03 -0400 | [diff] [blame] | 5443 | * <li>{@link Settings.Global#DATA_ROAMING}</li> |
Julia Reynolds | 9ed66da | 2014-08-26 15:42:03 -0400 | [diff] [blame] | 5444 | * <li>{@link Settings.Global#USB_MASS_STORAGE_ENABLED}</li> |
Julia Reynolds | 9ed66da | 2014-08-26 15:42:03 -0400 | [diff] [blame] | 5445 | * <li>{@link Settings.Global#WIFI_SLEEP_POLICY}</li> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5446 | * <li>{@link Settings.Global#STAY_ON_WHILE_PLUGGED_IN} This setting is only available from |
| 5447 | * {@link android.os.Build.VERSION_CODES#M} onwards and can only be set if |
| 5448 | * {@link #setMaximumTimeToLock} is not used to set a timeout.</li> |
| 5449 | * <li>{@link Settings.Global#WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN}</li> This setting is only |
| 5450 | * available from {@link android.os.Build.VERSION_CODES#M} onwards.</li> |
Julia Reynolds | 9ed66da | 2014-08-26 15:42:03 -0400 | [diff] [blame] | 5451 | * </ul> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5452 | * <p> |
| 5453 | * Changing the following settings has no effect as of {@link android.os.Build.VERSION_CODES#M}: |
Esteban Talavera | 656fa7f | 2015-06-29 17:41:39 +0100 | [diff] [blame] | 5454 | * <ul> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5455 | * <li>{@link Settings.Global#BLUETOOTH_ON}. Use |
| 5456 | * {@link android.bluetooth.BluetoothAdapter#enable()} and |
| 5457 | * {@link android.bluetooth.BluetoothAdapter#disable()} instead.</li> |
Esteban Talavera | 656fa7f | 2015-06-29 17:41:39 +0100 | [diff] [blame] | 5458 | * <li>{@link Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}</li> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5459 | * <li>{@link Settings.Global#MODE_RINGER}. Use |
| 5460 | * {@link android.media.AudioManager#setRingerMode(int)} instead.</li> |
Esteban Talavera | 656fa7f | 2015-06-29 17:41:39 +0100 | [diff] [blame] | 5461 | * <li>{@link Settings.Global#NETWORK_PREFERENCE}</li> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5462 | * <li>{@link Settings.Global#WIFI_ON}. Use |
| 5463 | * {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)} instead.</li> |
Esteban Talavera | 656fa7f | 2015-06-29 17:41:39 +0100 | [diff] [blame] | 5464 | * </ul> |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5465 | * |
| 5466 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5467 | * @param setting The name of the setting to update. |
| 5468 | * @param value The value to update the setting to. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5469 | * @throws SecurityException if {@code admin} is not a device owner. |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5470 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5471 | public void setGlobalSetting(@NonNull ComponentName admin, String setting, String value) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5472 | throwIfParentInstance("setGlobalSetting"); |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5473 | if (mService != null) { |
| 5474 | try { |
| 5475 | mService.setGlobalSetting(admin, setting, value); |
| 5476 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5477 | throw e.rethrowFromSystemServer(); |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5478 | } |
| 5479 | } |
| 5480 | } |
| 5481 | |
| 5482 | /** |
| 5483 | * Called by profile or device owners to update {@link Settings.Secure} settings. Validation |
| 5484 | * that the value of the setting is in the correct form for the setting type should be performed |
| 5485 | * by the caller. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5486 | * <p> |
| 5487 | * The settings that can be updated by a profile or device owner with this method are: |
Julia Reynolds | 9ed66da | 2014-08-26 15:42:03 -0400 | [diff] [blame] | 5488 | * <ul> |
| 5489 | * <li>{@link Settings.Secure#DEFAULT_INPUT_METHOD}</li> |
Amith Yamasani | 52c39a1 | 2014-10-21 11:14:04 -0700 | [diff] [blame] | 5490 | * <li>{@link Settings.Secure#INSTALL_NON_MARKET_APPS}</li> |
Julia Reynolds | 9ed66da | 2014-08-26 15:42:03 -0400 | [diff] [blame] | 5491 | * <li>{@link Settings.Secure#SKIP_FIRST_USE_HINTS}</li> |
| 5492 | * </ul> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5493 | * <p> |
| 5494 | * A device owner can additionally update the following settings: |
Julia Reynolds | 82735bc | 2014-09-04 16:43:30 -0400 | [diff] [blame] | 5495 | * <ul> |
| 5496 | * <li>{@link Settings.Secure#LOCATION_MODE}</li> |
| 5497 | * </ul> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5498 | * |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5499 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5500 | * @param setting The name of the setting to update. |
| 5501 | * @param value The value to update the setting to. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5502 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5503 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5504 | public void setSecureSetting(@NonNull ComponentName admin, String setting, String value) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5505 | throwIfParentInstance("setSecureSetting"); |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5506 | if (mService != null) { |
| 5507 | try { |
| 5508 | mService.setSecureSetting(admin, setting, value); |
| 5509 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5510 | throw e.rethrowFromSystemServer(); |
Julia Reynolds | da55165 | 2014-05-14 17:15:16 -0400 | [diff] [blame] | 5511 | } |
| 5512 | } |
| 5513 | } |
| 5514 | |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 5515 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5516 | * Designates a specific service component as the provider for making permission requests of a |
| 5517 | * local or remote administrator of the user. |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 5518 | * <p/> |
| 5519 | * Only a profile owner can designate the restrictions provider. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5520 | * |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 5521 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Amith Yamasani | f6e2fcc | 2014-07-10 13:41:55 -0700 | [diff] [blame] | 5522 | * @param provider The component name of the service that implements |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5523 | * {@link RestrictionsReceiver}. If this param is null, it removes the restrictions |
| 5524 | * provider previously assigned. |
| 5525 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 5526 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5527 | public void setRestrictionsProvider(@NonNull ComponentName admin, |
| 5528 | @Nullable ComponentName provider) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5529 | throwIfParentInstance("setRestrictionsProvider"); |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 5530 | if (mService != null) { |
| 5531 | try { |
Amith Yamasani | f6e2fcc | 2014-07-10 13:41:55 -0700 | [diff] [blame] | 5532 | mService.setRestrictionsProvider(admin, provider); |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 5533 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5534 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 5535 | } |
| 5536 | } |
| 5537 | } |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5538 | |
| 5539 | /** |
| 5540 | * Called by profile or device owners to set the master volume mute on or off. |
Nicolas Prevot | aef3ce2 | 2016-09-22 12:00:25 +0100 | [diff] [blame] | 5541 | * This has no effect when set on a managed profile. |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5542 | * |
| 5543 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5544 | * @param on {@code true} to mute master volume, {@code false} to turn mute off. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5545 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5546 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5547 | public void setMasterVolumeMuted(@NonNull ComponentName admin, boolean on) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5548 | throwIfParentInstance("setMasterVolumeMuted"); |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5549 | if (mService != null) { |
| 5550 | try { |
| 5551 | mService.setMasterVolumeMuted(admin, on); |
| 5552 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5553 | throw re.rethrowFromSystemServer(); |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5554 | } |
| 5555 | } |
| 5556 | } |
| 5557 | |
| 5558 | /** |
| 5559 | * Called by profile or device owners to check whether the master volume mute is on or off. |
| 5560 | * |
| 5561 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5562 | * @return {@code true} if master volume is muted, {@code false} if it's not. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5563 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5564 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5565 | public boolean isMasterVolumeMuted(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5566 | throwIfParentInstance("isMasterVolumeMuted"); |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5567 | if (mService != null) { |
| 5568 | try { |
| 5569 | return mService.isMasterVolumeMuted(admin); |
| 5570 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5571 | throw re.rethrowFromSystemServer(); |
Julia Reynolds | 4a21b25 | 2014-06-04 11:11:43 -0400 | [diff] [blame] | 5572 | } |
| 5573 | } |
| 5574 | return false; |
| 5575 | } |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5576 | |
| 5577 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5578 | * Called by profile or device owners to change whether a user can uninstall a package. |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5579 | * |
| 5580 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5581 | * @param packageName package to change. |
Esteban Talavera | d5c5c13 | 2014-08-20 11:35:57 +0100 | [diff] [blame] | 5582 | * @param uninstallBlocked true if the user shouldn't be able to uninstall the package. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5583 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5584 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5585 | public void setUninstallBlocked(@NonNull ComponentName admin, String packageName, |
Esteban Talavera | d5c5c13 | 2014-08-20 11:35:57 +0100 | [diff] [blame] | 5586 | boolean uninstallBlocked) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5587 | throwIfParentInstance("setUninstallBlocked"); |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5588 | if (mService != null) { |
| 5589 | try { |
Esteban Talavera | d5c5c13 | 2014-08-20 11:35:57 +0100 | [diff] [blame] | 5590 | mService.setUninstallBlocked(admin, packageName, uninstallBlocked); |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5591 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5592 | throw re.rethrowFromSystemServer(); |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5593 | } |
| 5594 | } |
| 5595 | } |
| 5596 | |
| 5597 | /** |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 5598 | * Check whether the user has been blocked by device policy from uninstalling a package. |
Rubin Xu | a97855b | 2014-11-07 05:41:00 +0000 | [diff] [blame] | 5599 | * Requires the caller to be the profile owner if checking a specific admin's policy. |
Rubin Xu | e1e6faa | 2015-03-10 10:51:59 +0000 | [diff] [blame] | 5600 | * <p> |
| 5601 | * <strong>Note:</strong> Starting from {@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1}, the |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5602 | * behavior of this API is changed such that passing {@code null} as the {@code admin} parameter |
| 5603 | * will return if any admin has blocked the uninstallation. Before L MR1, passing {@code null} |
| 5604 | * will cause a NullPointerException to be raised. |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5605 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5606 | * @param admin The name of the admin component whose blocking policy will be checked, or |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5607 | * {@code null} to check whether any admin has blocked the uninstallation. |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5608 | * @param packageName package to check. |
Rubin Xu | a97855b | 2014-11-07 05:41:00 +0000 | [diff] [blame] | 5609 | * @return true if uninstallation is blocked. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5610 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5611 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5612 | public boolean isUninstallBlocked(@Nullable ComponentName admin, String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5613 | throwIfParentInstance("isUninstallBlocked"); |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5614 | if (mService != null) { |
| 5615 | try { |
Esteban Talavera | 729b2a6 | 2014-08-27 18:01:58 +0100 | [diff] [blame] | 5616 | return mService.isUninstallBlocked(admin, packageName); |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5617 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5618 | throw re.rethrowFromSystemServer(); |
Kenny Guy | c13053b | 2014-05-29 14:17:17 +0100 | [diff] [blame] | 5619 | } |
| 5620 | } |
| 5621 | return false; |
| 5622 | } |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5623 | |
| 5624 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5625 | * Called by the profile owner of a managed profile to enable widget providers from a given |
| 5626 | * package to be available in the parent profile. As a result the user will be able to add |
| 5627 | * widgets from the white-listed package running under the profile to a widget host which runs |
| 5628 | * under the parent profile, for example the home screen. Note that a package may have zero or |
| 5629 | * more provider components, where each component provides a different widget type. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5630 | * <p> |
| 5631 | * <strong>Note:</strong> By default no widget provider package is white-listed. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5632 | * |
| 5633 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5634 | * @param packageName The package from which widget providers are white-listed. |
| 5635 | * @return Whether the package was added. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5636 | * @throws SecurityException if {@code admin} is not a profile owner. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5637 | * @see #removeCrossProfileWidgetProvider(android.content.ComponentName, String) |
| 5638 | * @see #getCrossProfileWidgetProviders(android.content.ComponentName) |
| 5639 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5640 | public boolean addCrossProfileWidgetProvider(@NonNull ComponentName admin, String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5641 | throwIfParentInstance("addCrossProfileWidgetProvider"); |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5642 | if (mService != null) { |
| 5643 | try { |
| 5644 | return mService.addCrossProfileWidgetProvider(admin, packageName); |
| 5645 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5646 | throw re.rethrowFromSystemServer(); |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5647 | } |
| 5648 | } |
| 5649 | return false; |
| 5650 | } |
| 5651 | |
| 5652 | /** |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 5653 | * Called by the profile owner of a managed profile to disable widget providers from a given |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5654 | * package to be available in the parent profile. For this method to take effect the package |
| 5655 | * should have been added via |
| 5656 | * {@link #addCrossProfileWidgetProvider( android.content.ComponentName, String)}. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5657 | * <p> |
| 5658 | * <strong>Note:</strong> By default no widget provider package is white-listed. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5659 | * |
| 5660 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5661 | * @param packageName The package from which widget providers are no longer white-listed. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5662 | * @return Whether the package was removed. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5663 | * @throws SecurityException if {@code admin} is not a profile owner. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5664 | * @see #addCrossProfileWidgetProvider(android.content.ComponentName, String) |
| 5665 | * @see #getCrossProfileWidgetProviders(android.content.ComponentName) |
| 5666 | */ |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 5667 | public boolean removeCrossProfileWidgetProvider( |
| 5668 | @NonNull ComponentName admin, String packageName) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5669 | throwIfParentInstance("removeCrossProfileWidgetProvider"); |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5670 | if (mService != null) { |
| 5671 | try { |
| 5672 | return mService.removeCrossProfileWidgetProvider(admin, packageName); |
| 5673 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5674 | throw re.rethrowFromSystemServer(); |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5675 | } |
| 5676 | } |
| 5677 | return false; |
| 5678 | } |
| 5679 | |
| 5680 | /** |
Amith Yamasani | c34dc7c | 2014-09-18 09:42:42 -0700 | [diff] [blame] | 5681 | * Called by the profile owner of a managed profile to query providers from which packages are |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5682 | * available in the parent profile. |
| 5683 | * |
| 5684 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5685 | * @return The white-listed package list. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5686 | * @see #addCrossProfileWidgetProvider(android.content.ComponentName, String) |
| 5687 | * @see #removeCrossProfileWidgetProvider(android.content.ComponentName, String) |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5688 | * @throws SecurityException if {@code admin} is not a profile owner. |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5689 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5690 | public @NonNull List<String> getCrossProfileWidgetProviders(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5691 | throwIfParentInstance("getCrossProfileWidgetProviders"); |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5692 | if (mService != null) { |
| 5693 | try { |
| 5694 | List<String> providers = mService.getCrossProfileWidgetProviders(admin); |
| 5695 | if (providers != null) { |
| 5696 | return providers; |
| 5697 | } |
| 5698 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5699 | throw re.rethrowFromSystemServer(); |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5700 | } |
| 5701 | } |
| 5702 | return Collections.emptyList(); |
| 5703 | } |
Julia Reynolds | fca04ca | 2015-02-17 13:39:12 -0500 | [diff] [blame] | 5704 | |
| 5705 | /** |
Makoto Onuki | 32b3057 | 2015-12-11 14:29:51 -0800 | [diff] [blame] | 5706 | * Called by profile or device owners to set the user's photo. |
Julia Reynolds | fca04ca | 2015-02-17 13:39:12 -0500 | [diff] [blame] | 5707 | * |
| 5708 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 5709 | * @param icon the bitmap to set as the photo. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5710 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Julia Reynolds | fca04ca | 2015-02-17 13:39:12 -0500 | [diff] [blame] | 5711 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5712 | public void setUserIcon(@NonNull ComponentName admin, Bitmap icon) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5713 | throwIfParentInstance("setUserIcon"); |
Julia Reynolds | fca04ca | 2015-02-17 13:39:12 -0500 | [diff] [blame] | 5714 | try { |
| 5715 | mService.setUserIcon(admin, icon); |
| 5716 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5717 | throw re.rethrowFromSystemServer(); |
Julia Reynolds | fca04ca | 2015-02-17 13:39:12 -0500 | [diff] [blame] | 5718 | } |
| 5719 | } |
Craig Lafayette | dbe31a6 | 2015-04-02 13:14:39 -0400 | [diff] [blame] | 5720 | |
| 5721 | /** |
Rubin Xu | 5faad8e | 2015-04-20 17:43:48 +0100 | [diff] [blame] | 5722 | * Called by device owners to set a local system update policy. When a new policy is set, |
| 5723 | * {@link #ACTION_SYSTEM_UPDATE_POLICY_CHANGED} is broadcasted. |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5724 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5725 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. All |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5726 | * components in the device owner package can set system update policies and the most |
| 5727 | * recent policy takes effect. |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5728 | * @param policy the new policy, or {@code null} to clear the current policy. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5729 | * @throws SecurityException if {@code admin} is not a device owner. |
Rubin Xu | 5faad8e | 2015-04-20 17:43:48 +0100 | [diff] [blame] | 5730 | * @see SystemUpdatePolicy |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5731 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5732 | public void setSystemUpdatePolicy(@NonNull ComponentName admin, SystemUpdatePolicy policy) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5733 | throwIfParentInstance("setSystemUpdatePolicy"); |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5734 | if (mService != null) { |
| 5735 | try { |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5736 | mService.setSystemUpdatePolicy(admin, policy); |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5737 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5738 | throw re.rethrowFromSystemServer(); |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5739 | } |
| 5740 | } |
| 5741 | } |
| 5742 | |
| 5743 | /** |
Rubin Xu | 5faad8e | 2015-04-20 17:43:48 +0100 | [diff] [blame] | 5744 | * Retrieve a local system update policy set previously by {@link #setSystemUpdatePolicy}. |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5745 | * |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5746 | * @return The current policy object, or {@code null} if no policy is set. |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5747 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5748 | public @Nullable SystemUpdatePolicy getSystemUpdatePolicy() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5749 | throwIfParentInstance("getSystemUpdatePolicy"); |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5750 | if (mService != null) { |
| 5751 | try { |
Rubin Xu | d86d58c | 2015-05-05 16:57:37 +0100 | [diff] [blame] | 5752 | return mService.getSystemUpdatePolicy(); |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5753 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5754 | throw re.rethrowFromSystemServer(); |
Rubin Xu | 8027a4f | 2015-03-10 17:52:37 +0000 | [diff] [blame] | 5755 | } |
| 5756 | } |
| 5757 | return null; |
| 5758 | } |
Benjamin Franz | e36087e | 2015-04-07 16:40:34 +0100 | [diff] [blame] | 5759 | |
| 5760 | /** |
| 5761 | * Called by a device owner to disable the keyguard altogether. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5762 | * <p> |
| 5763 | * Setting the keyguard to disabled has the same effect as choosing "None" as the screen lock |
| 5764 | * type. However, this call has no effect if a password, pin or pattern is currently set. If a |
| 5765 | * password, pin or pattern is set after the keyguard was disabled, the keyguard stops being |
| 5766 | * disabled. |
Benjamin Franz | e36087e | 2015-04-07 16:40:34 +0100 | [diff] [blame] | 5767 | * |
| 5768 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Benjamin Franz | bece806 | 2015-05-06 12:14:31 +0100 | [diff] [blame] | 5769 | * @param disabled {@code true} disables the keyguard, {@code false} reenables it. |
Benjamin Franz | e36087e | 2015-04-07 16:40:34 +0100 | [diff] [blame] | 5770 | * @return {@code false} if attempting to disable the keyguard while a lock password was in |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5771 | * place. {@code true} otherwise. |
| 5772 | * @throws SecurityException if {@code admin} is not a device owner. |
Benjamin Franz | e36087e | 2015-04-07 16:40:34 +0100 | [diff] [blame] | 5773 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5774 | public boolean setKeyguardDisabled(@NonNull ComponentName admin, boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5775 | throwIfParentInstance("setKeyguardDisabled"); |
Benjamin Franz | e36087e | 2015-04-07 16:40:34 +0100 | [diff] [blame] | 5776 | try { |
Benjamin Franz | bece806 | 2015-05-06 12:14:31 +0100 | [diff] [blame] | 5777 | return mService.setKeyguardDisabled(admin, disabled); |
Benjamin Franz | e36087e | 2015-04-07 16:40:34 +0100 | [diff] [blame] | 5778 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5779 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | e36087e | 2015-04-07 16:40:34 +0100 | [diff] [blame] | 5780 | } |
| 5781 | } |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 5782 | |
| 5783 | /** |
Benjamin Franz | bece806 | 2015-05-06 12:14:31 +0100 | [diff] [blame] | 5784 | * Called by device owner to disable the status bar. Disabling the status bar blocks |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5785 | * notifications, quick settings and other screen overlays that allow escaping from a single use |
| 5786 | * device. |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 5787 | * |
| 5788 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Benjamin Franz | bece806 | 2015-05-06 12:14:31 +0100 | [diff] [blame] | 5789 | * @param disabled {@code true} disables the status bar, {@code false} reenables it. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5790 | * @return {@code false} if attempting to disable the status bar failed. {@code true} otherwise. |
| 5791 | * @throws SecurityException if {@code admin} is not a device owner. |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 5792 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5793 | public boolean setStatusBarDisabled(@NonNull ComponentName admin, boolean disabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5794 | throwIfParentInstance("setStatusBarDisabled"); |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 5795 | try { |
Benjamin Franz | bece806 | 2015-05-06 12:14:31 +0100 | [diff] [blame] | 5796 | return mService.setStatusBarDisabled(admin, disabled); |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 5797 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5798 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 5799 | } |
| 5800 | } |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 5801 | |
| 5802 | /** |
| 5803 | * Callable by the system update service to notify device owners about pending updates. |
| 5804 | * The caller must hold {@link android.Manifest.permission#NOTIFY_PENDING_SYSTEM_UPDATE} |
| 5805 | * permission. |
| 5806 | * |
| 5807 | * @param updateReceivedTime The time as given by {@link System#currentTimeMillis()} indicating |
| 5808 | * when the current pending update was first available. -1 if no update is available. |
| 5809 | * @hide |
| 5810 | */ |
| 5811 | @SystemApi |
| 5812 | public void notifyPendingSystemUpdate(long updateReceivedTime) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5813 | throwIfParentInstance("notifyPendingSystemUpdate"); |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 5814 | if (mService != null) { |
| 5815 | try { |
| 5816 | mService.notifyPendingSystemUpdate(updateReceivedTime); |
| 5817 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5818 | throw re.rethrowFromSystemServer(); |
Rubin Xu | dc105cc | 2015-04-14 23:38:01 +0100 | [diff] [blame] | 5819 | } |
| 5820 | } |
| 5821 | } |
Julia Reynolds | 13c58ba | 2015-04-20 16:42:54 -0400 | [diff] [blame] | 5822 | |
| 5823 | /** |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5824 | * Called by profile or device owners to set the default response for future runtime permission |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5825 | * requests by applications. The policy can allow for normal operation which prompts the user to |
| 5826 | * grant a permission, or can allow automatic granting or denying of runtime permission requests |
| 5827 | * by an application. This also applies to new permissions declared by app updates. When a |
| 5828 | * permission is denied or granted this way, the effect is equivalent to setting the permission |
| 5829 | * grant state via {@link #setPermissionGrantState}. |
| 5830 | * <p/> |
| 5831 | * As this policy only acts on runtime permission requests, it only applies to applications |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 5832 | * built with a {@code targetSdkVersion} of {@link android.os.Build.VERSION_CODES#M} or later. |
Benjamin Franz | 45dd666 | 2015-07-08 14:24:14 +0100 | [diff] [blame] | 5833 | * |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5834 | * @param admin Which profile or device owner this request is associated with. |
| 5835 | * @param policy One of the policy constants {@link #PERMISSION_POLICY_PROMPT}, |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5836 | * {@link #PERMISSION_POLICY_AUTO_GRANT} and {@link #PERMISSION_POLICY_AUTO_DENY}. |
| 5837 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Benjamin Franz | 45dd666 | 2015-07-08 14:24:14 +0100 | [diff] [blame] | 5838 | * @see #setPermissionGrantState |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5839 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5840 | public void setPermissionPolicy(@NonNull ComponentName admin, int policy) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5841 | throwIfParentInstance("setPermissionPolicy"); |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5842 | try { |
| 5843 | mService.setPermissionPolicy(admin, policy); |
| 5844 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5845 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5846 | } |
| 5847 | } |
| 5848 | |
| 5849 | /** |
| 5850 | * Returns the current runtime permission policy set by the device or profile owner. The |
| 5851 | * default is {@link #PERMISSION_POLICY_PROMPT}. |
| 5852 | * @param admin Which profile or device owner this request is associated with. |
| 5853 | * @return the current policy for future permission requests. |
| 5854 | */ |
Esteban Talavera | 28b9570 | 2015-06-24 15:23:42 +0100 | [diff] [blame] | 5855 | public int getPermissionPolicy(ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5856 | throwIfParentInstance("getPermissionPolicy"); |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5857 | try { |
| 5858 | return mService.getPermissionPolicy(admin); |
| 5859 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5860 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5861 | } |
| 5862 | } |
| 5863 | |
| 5864 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5865 | * Sets the grant state of a runtime permission for a specific application. The state can be |
| 5866 | * {@link #PERMISSION_GRANT_STATE_DEFAULT default} in which a user can manage it through the UI, |
| 5867 | * {@link #PERMISSION_GRANT_STATE_DENIED denied}, in which the permission is denied and the user |
| 5868 | * cannot manage it through the UI, and {@link #PERMISSION_GRANT_STATE_GRANTED granted} in which |
| 5869 | * the permission is granted and the user cannot manage it through the UI. This might affect all |
| 5870 | * permissions in a group that the runtime permission belongs to. This method can only be called |
Svet Ganov | d8ecc5a | 2015-05-20 10:45:43 -0700 | [diff] [blame] | 5871 | * by a profile or device owner. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5872 | * <p/> |
| 5873 | * Setting the grant state to {@link #PERMISSION_GRANT_STATE_DEFAULT default} does not revoke |
| 5874 | * the permission. It retains the previous grant, if any. |
| 5875 | * <p/> |
| 5876 | * Permissions can be granted or revoked only for applications built with a |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 5877 | * {@code targetSdkVersion} of {@link android.os.Build.VERSION_CODES#M} or later. |
Amith Yamasani | 0bf8f7c | 2015-06-22 13:00:32 -0700 | [diff] [blame] | 5878 | * |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5879 | * @param admin Which profile or device owner this request is associated with. |
| 5880 | * @param packageName The application to grant or revoke a permission to. |
| 5881 | * @param permission The permission to grant or revoke. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5882 | * @param grantState The permission grant state which is one of |
| 5883 | * {@link #PERMISSION_GRANT_STATE_DENIED}, {@link #PERMISSION_GRANT_STATE_DEFAULT}, |
| 5884 | * {@link #PERMISSION_GRANT_STATE_GRANTED}, |
Svet Ganov | d8ecc5a | 2015-05-20 10:45:43 -0700 | [diff] [blame] | 5885 | * @return whether the permission was successfully granted or revoked. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5886 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Svet Ganov | d8ecc5a | 2015-05-20 10:45:43 -0700 | [diff] [blame] | 5887 | * @see #PERMISSION_GRANT_STATE_DENIED |
| 5888 | * @see #PERMISSION_GRANT_STATE_DEFAULT |
| 5889 | * @see #PERMISSION_GRANT_STATE_GRANTED |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5890 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5891 | public boolean setPermissionGrantState(@NonNull ComponentName admin, String packageName, |
Svet Ganov | d8ecc5a | 2015-05-20 10:45:43 -0700 | [diff] [blame] | 5892 | String permission, int grantState) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5893 | throwIfParentInstance("setPermissionGrantState"); |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5894 | try { |
Svet Ganov | d8ecc5a | 2015-05-20 10:45:43 -0700 | [diff] [blame] | 5895 | return mService.setPermissionGrantState(admin, packageName, permission, grantState); |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5896 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5897 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | d49489b | 2015-04-28 14:00:26 -0700 | [diff] [blame] | 5898 | } |
| 5899 | } |
Amith Yamasani | 184b375 | 2015-05-22 13:00:51 -0700 | [diff] [blame] | 5900 | |
| 5901 | /** |
| 5902 | * Returns the current grant state of a runtime permission for a specific application. |
| 5903 | * |
| 5904 | * @param admin Which profile or device owner this request is associated with. |
| 5905 | * @param packageName The application to check the grant state for. |
| 5906 | * @param permission The permission to check for. |
| 5907 | * @return the current grant state specified by device policy. If the profile or device owner |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5908 | * has not set a grant state, the return value is |
| 5909 | * {@link #PERMISSION_GRANT_STATE_DEFAULT}. This does not indicate whether or not the |
| 5910 | * permission is currently granted for the package. |
| 5911 | * <p/> |
| 5912 | * If a grant state was set by the profile or device owner, then the return value will |
| 5913 | * be one of {@link #PERMISSION_GRANT_STATE_DENIED} or |
| 5914 | * {@link #PERMISSION_GRANT_STATE_GRANTED}, which indicates if the permission is |
| 5915 | * currently denied or granted. |
| 5916 | * @throws SecurityException if {@code admin} is not a device or profile owner. |
Amith Yamasani | 184b375 | 2015-05-22 13:00:51 -0700 | [diff] [blame] | 5917 | * @see #setPermissionGrantState(ComponentName, String, String, int) |
| 5918 | * @see PackageManager#checkPermission(String, String) |
| 5919 | */ |
Robin Lee | 25e2645 | 2015-06-02 09:56:29 -0700 | [diff] [blame] | 5920 | public int getPermissionGrantState(@NonNull ComponentName admin, String packageName, |
Amith Yamasani | 184b375 | 2015-05-22 13:00:51 -0700 | [diff] [blame] | 5921 | String permission) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5922 | throwIfParentInstance("getPermissionGrantState"); |
Amith Yamasani | 184b375 | 2015-05-22 13:00:51 -0700 | [diff] [blame] | 5923 | try { |
| 5924 | return mService.getPermissionGrantState(admin, packageName, permission); |
| 5925 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5926 | throw re.rethrowFromSystemServer(); |
Amith Yamasani | 184b375 | 2015-05-22 13:00:51 -0700 | [diff] [blame] | 5927 | } |
| 5928 | } |
Nicolas Prevot | 07387fe | 2015-10-30 17:53:30 +0000 | [diff] [blame] | 5929 | |
| 5930 | /** |
| 5931 | * Returns if provisioning a managed profile or device is possible or not. |
| 5932 | * @param action One of {@link #ACTION_PROVISION_MANAGED_DEVICE}, |
| 5933 | * {@link #ACTION_PROVISION_MANAGED_PROFILE}. |
Nicolas Prevot | 07387fe | 2015-10-30 17:53:30 +0000 | [diff] [blame] | 5934 | * @return if provisioning a managed profile or device is possible or not. |
| 5935 | * @throws IllegalArgumentException if the supplied action is not valid. |
| 5936 | */ |
| 5937 | public boolean isProvisioningAllowed(String action) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5938 | throwIfParentInstance("isProvisioningAllowed"); |
Nicolas Prevot | 07387fe | 2015-10-30 17:53:30 +0000 | [diff] [blame] | 5939 | try { |
| 5940 | return mService.isProvisioningAllowed(action); |
| 5941 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5942 | throw re.rethrowFromSystemServer(); |
Nicolas Prevot | 07387fe | 2015-10-30 17:53:30 +0000 | [diff] [blame] | 5943 | } |
| 5944 | } |
Mahaver Chopra | 15a46b0 | 2015-11-11 14:54:35 +0000 | [diff] [blame] | 5945 | |
| 5946 | /** |
Mahaver Chopra | 15a46b0 | 2015-11-11 14:54:35 +0000 | [diff] [blame] | 5947 | * Return if this user is a managed profile of another user. An admin can become the profile |
| 5948 | * owner of a managed profile with {@link #ACTION_PROVISION_MANAGED_PROFILE} and of a managed |
Kenny Guy | ffa3840 | 2016-03-31 16:40:57 +0100 | [diff] [blame] | 5949 | * user with {@link #createAndManageUser} |
Mahaver Chopra | 15a46b0 | 2015-11-11 14:54:35 +0000 | [diff] [blame] | 5950 | * @param admin Which profile owner this request is associated with. |
| 5951 | * @return if this user is a managed profile of another user. |
| 5952 | */ |
| 5953 | public boolean isManagedProfile(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5954 | throwIfParentInstance("isManagedProfile"); |
Mahaver Chopra | 15a46b0 | 2015-11-11 14:54:35 +0000 | [diff] [blame] | 5955 | try { |
| 5956 | return mService.isManagedProfile(admin); |
| 5957 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5958 | throw re.rethrowFromSystemServer(); |
Mahaver Chopra | 15a46b0 | 2015-11-11 14:54:35 +0000 | [diff] [blame] | 5959 | } |
| 5960 | } |
| 5961 | |
| 5962 | /** |
| 5963 | * @hide |
| 5964 | * Return if this user is a system-only user. An admin can manage a device from a system only |
| 5965 | * user by calling {@link #ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE}. |
| 5966 | * @param admin Which device owner this request is associated with. |
| 5967 | * @return if this user is a system-only user. |
| 5968 | */ |
| 5969 | public boolean isSystemOnlyUser(@NonNull ComponentName admin) { |
| 5970 | try { |
| 5971 | return mService.isSystemOnlyUser(admin); |
| 5972 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5973 | throw re.rethrowFromSystemServer(); |
Mahaver Chopra | 15a46b0 | 2015-11-11 14:54:35 +0000 | [diff] [blame] | 5974 | } |
| 5975 | } |
Makoto Onuki | a31ebbc | 2015-11-23 17:15:21 -0800 | [diff] [blame] | 5976 | |
| 5977 | /** |
| 5978 | * Called by device owner to get the MAC address of the Wi-Fi device. |
| 5979 | * |
Sudheer Shanka | 3cb4da1 | 2016-03-07 18:51:49 -0800 | [diff] [blame] | 5980 | * @param admin Which device owner this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5981 | * @return the MAC address of the Wi-Fi device, or null when the information is not available. |
| 5982 | * (For example, Wi-Fi hasn't been enabled, or the device doesn't support Wi-Fi.) |
| 5983 | * <p> |
| 5984 | * The address will be in the {@code XX:XX:XX:XX:XX:XX} format. |
| 5985 | * @throws SecurityException if {@code admin} is not a device owner. |
Makoto Onuki | a31ebbc | 2015-11-23 17:15:21 -0800 | [diff] [blame] | 5986 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 5987 | public @Nullable String getWifiMacAddress(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 5988 | throwIfParentInstance("getWifiMacAddress"); |
Makoto Onuki | a31ebbc | 2015-11-23 17:15:21 -0800 | [diff] [blame] | 5989 | try { |
Sudheer Shanka | 3cb4da1 | 2016-03-07 18:51:49 -0800 | [diff] [blame] | 5990 | return mService.getWifiMacAddress(admin); |
Makoto Onuki | a31ebbc | 2015-11-23 17:15:21 -0800 | [diff] [blame] | 5991 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 5992 | throw re.rethrowFromSystemServer(); |
Makoto Onuki | a31ebbc | 2015-11-23 17:15:21 -0800 | [diff] [blame] | 5993 | } |
| 5994 | } |
Mahaver Chopra | 1ce53bc | 2015-12-14 13:35:14 +0000 | [diff] [blame] | 5995 | |
| 5996 | /** |
Mahaver Chopra | 1216ae5 | 2016-03-11 15:39:48 +0000 | [diff] [blame] | 5997 | * Called by device owner to reboot the device. If there is an ongoing call on the device, |
| 5998 | * throws an {@link IllegalStateException}. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 5999 | * @param admin Which device owner the request is associated with. |
Mahaver Chopra | 1216ae5 | 2016-03-11 15:39:48 +0000 | [diff] [blame] | 6000 | * @throws IllegalStateException if device has an ongoing call. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6001 | * @throws SecurityException if {@code admin} is not a device owner. |
Mahaver Chopra | 1216ae5 | 2016-03-11 15:39:48 +0000 | [diff] [blame] | 6002 | * @see TelephonyManager#CALL_STATE_IDLE |
Mahaver Chopra | 1ce53bc | 2015-12-14 13:35:14 +0000 | [diff] [blame] | 6003 | */ |
| 6004 | public void reboot(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6005 | throwIfParentInstance("reboot"); |
Mahaver Chopra | 1ce53bc | 2015-12-14 13:35:14 +0000 | [diff] [blame] | 6006 | try { |
| 6007 | mService.reboot(admin); |
| 6008 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6009 | throw re.rethrowFromSystemServer(); |
Mahaver Chopra | 1ce53bc | 2015-12-14 13:35:14 +0000 | [diff] [blame] | 6010 | } |
| 6011 | } |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6012 | |
| 6013 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6014 | * Called by a device admin to set the short support message. This will be displayed to the user |
| 6015 | * in settings screens where funtionality has been disabled by the admin. The message should be |
| 6016 | * limited to a short statement such as "This setting is disabled by your administrator. Contact |
| 6017 | * someone@example.com for support." If the message is longer than 200 characters it may be |
| 6018 | * truncated. |
| 6019 | * <p> |
| 6020 | * If the short support message needs to be localized, it is the responsibility of the |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6021 | * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast |
| 6022 | * and set a new version of this string accordingly. |
| 6023 | * |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6024 | * @see #setLongSupportMessage |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6025 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6026 | * @param message Short message to be displayed to the user in settings or null to clear the |
| 6027 | * existing message. |
| 6028 | * @throws SecurityException if {@code admin} is not an active administrator. |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6029 | */ |
| 6030 | public void setShortSupportMessage(@NonNull ComponentName admin, |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6031 | @Nullable CharSequence message) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6032 | throwIfParentInstance("setShortSupportMessage"); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6033 | if (mService != null) { |
| 6034 | try { |
| 6035 | mService.setShortSupportMessage(admin, message); |
| 6036 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6037 | throw e.rethrowFromSystemServer(); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6038 | } |
| 6039 | } |
| 6040 | } |
| 6041 | |
| 6042 | /** |
| 6043 | * Called by a device admin to get the short support message. |
| 6044 | * |
| 6045 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6046 | * @return The message set by {@link #setShortSupportMessage(ComponentName, CharSequence)} or |
| 6047 | * null if no message has been set. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6048 | * @throws SecurityException if {@code admin} is not an active administrator. |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6049 | */ |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6050 | public CharSequence getShortSupportMessage(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6051 | throwIfParentInstance("getShortSupportMessage"); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6052 | if (mService != null) { |
| 6053 | try { |
| 6054 | return mService.getShortSupportMessage(admin); |
| 6055 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6056 | throw e.rethrowFromSystemServer(); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6057 | } |
| 6058 | } |
| 6059 | return null; |
| 6060 | } |
| 6061 | |
| 6062 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6063 | * Called by a device admin to set the long support message. This will be displayed to the user |
| 6064 | * in the device administators settings screen. |
| 6065 | * <p> |
| 6066 | * If the long support message needs to be localized, it is the responsibility of the |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6067 | * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast |
| 6068 | * and set a new version of this string accordingly. |
| 6069 | * |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6070 | * @see #setShortSupportMessage |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6071 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6072 | * @param message Long message to be displayed to the user in settings or null to clear the |
| 6073 | * existing message. |
| 6074 | * @throws SecurityException if {@code admin} is not an active administrator. |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6075 | */ |
| 6076 | public void setLongSupportMessage(@NonNull ComponentName admin, |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6077 | @Nullable CharSequence message) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6078 | throwIfParentInstance("setLongSupportMessage"); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6079 | if (mService != null) { |
| 6080 | try { |
| 6081 | mService.setLongSupportMessage(admin, message); |
| 6082 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6083 | throw e.rethrowFromSystemServer(); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6084 | } |
| 6085 | } |
| 6086 | } |
| 6087 | |
| 6088 | /** |
| 6089 | * Called by a device admin to get the long support message. |
| 6090 | * |
| 6091 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6092 | * @return The message set by {@link #setLongSupportMessage(ComponentName, CharSequence)} or |
| 6093 | * null if no message has been set. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6094 | * @throws SecurityException if {@code admin} is not an active administrator. |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6095 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6096 | public @Nullable CharSequence getLongSupportMessage(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6097 | throwIfParentInstance("getLongSupportMessage"); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6098 | if (mService != null) { |
| 6099 | try { |
| 6100 | return mService.getLongSupportMessage(admin); |
| 6101 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6102 | throw e.rethrowFromSystemServer(); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6103 | } |
| 6104 | } |
| 6105 | return null; |
| 6106 | } |
| 6107 | |
| 6108 | /** |
| 6109 | * Called by the system to get the short support message. |
| 6110 | * |
| 6111 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 6112 | * @param userHandle user id the admin is running as. |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6113 | * @return The message set by {@link #setShortSupportMessage(ComponentName, CharSequence)} |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6114 | * |
| 6115 | * @hide |
| 6116 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6117 | public @Nullable CharSequence getShortSupportMessageForUser(@NonNull ComponentName admin, |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6118 | int userHandle) { |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6119 | if (mService != null) { |
| 6120 | try { |
| 6121 | return mService.getShortSupportMessageForUser(admin, userHandle); |
| 6122 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6123 | throw e.rethrowFromSystemServer(); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6124 | } |
| 6125 | } |
| 6126 | return null; |
| 6127 | } |
| 6128 | |
| 6129 | |
| 6130 | /** |
| 6131 | * Called by the system to get the long support message. |
| 6132 | * |
| 6133 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 6134 | * @param userHandle user id the admin is running as. |
Sudheer Shanka | 3ccca91e | 2016-04-11 21:36:17 -0700 | [diff] [blame] | 6135 | * @return The message set by {@link #setLongSupportMessage(ComponentName, CharSequence)} |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6136 | * |
| 6137 | * @hide |
| 6138 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6139 | public @Nullable CharSequence getLongSupportMessageForUser( |
| 6140 | @NonNull ComponentName admin, int userHandle) { |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6141 | if (mService != null) { |
| 6142 | try { |
| 6143 | return mService.getLongSupportMessageForUser(admin, userHandle); |
| 6144 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6145 | throw e.rethrowFromSystemServer(); |
Kenny Guy | 06de4e7 | 2015-12-22 12:07:39 +0000 | [diff] [blame] | 6146 | } |
| 6147 | } |
| 6148 | return null; |
| 6149 | } |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 6150 | |
| 6151 | /** |
Esteban Talavera | 6239991 | 2016-01-11 15:37:55 +0000 | [diff] [blame] | 6152 | * Called by the profile owner of a managed profile to obtain a {@link DevicePolicyManager} |
| 6153 | * whose calls act on the parent profile. |
Benjamin Franz | 66b45f0 | 2016-04-05 19:12:39 +0100 | [diff] [blame] | 6154 | * |
| 6155 | * <p>The following methods are supported for the parent instance, all other methods will |
| 6156 | * throw a SecurityException when called on the parent instance: |
| 6157 | * <ul> |
| 6158 | * <li>{@link #getPasswordQuality}</li> |
| 6159 | * <li>{@link #setPasswordQuality}</li> |
| 6160 | * <li>{@link #getPasswordMinimumLength}</li> |
| 6161 | * <li>{@link #setPasswordMinimumLength}</li> |
| 6162 | * <li>{@link #getPasswordMinimumUpperCase}</li> |
| 6163 | * <li>{@link #setPasswordMinimumUpperCase}</li> |
| 6164 | * <li>{@link #getPasswordMinimumLowerCase}</li> |
| 6165 | * <li>{@link #setPasswordMinimumLowerCase}</li> |
| 6166 | * <li>{@link #getPasswordMinimumLetters}</li> |
| 6167 | * <li>{@link #setPasswordMinimumLetters}</li> |
| 6168 | * <li>{@link #getPasswordMinimumNumeric}</li> |
| 6169 | * <li>{@link #setPasswordMinimumNumeric}</li> |
| 6170 | * <li>{@link #getPasswordMinimumSymbols}</li> |
| 6171 | * <li>{@link #setPasswordMinimumSymbols}</li> |
| 6172 | * <li>{@link #getPasswordMinimumNonLetter}</li> |
| 6173 | * <li>{@link #setPasswordMinimumNonLetter}</li> |
| 6174 | * <li>{@link #getPasswordHistoryLength}</li> |
| 6175 | * <li>{@link #setPasswordHistoryLength}</li> |
| 6176 | * <li>{@link #getPasswordExpirationTimeout}</li> |
| 6177 | * <li>{@link #setPasswordExpirationTimeout}</li> |
| 6178 | * <li>{@link #getPasswordExpiration}</li> |
Charles He | 8c76056 | 2016-10-25 16:36:53 +0100 | [diff] [blame] | 6179 | * <li>{@link #getPasswordMaximumLength}</li> |
Benjamin Franz | 66b45f0 | 2016-04-05 19:12:39 +0100 | [diff] [blame] | 6180 | * <li>{@link #isActivePasswordSufficient}</li> |
| 6181 | * <li>{@link #getCurrentFailedPasswordAttempts}</li> |
| 6182 | * <li>{@link #getMaximumFailedPasswordsForWipe}</li> |
| 6183 | * <li>{@link #setMaximumFailedPasswordsForWipe}</li> |
| 6184 | * <li>{@link #getMaximumTimeToLock}</li> |
| 6185 | * <li>{@link #setMaximumTimeToLock}</li> |
| 6186 | * <li>{@link #lockNow}</li> |
| 6187 | * <li>{@link #getKeyguardDisabledFeatures}</li> |
| 6188 | * <li>{@link #setKeyguardDisabledFeatures}</li> |
| 6189 | * <li>{@link #getTrustAgentConfiguration}</li> |
| 6190 | * <li>{@link #setTrustAgentConfiguration}</li> |
| 6191 | * </ul> |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 6192 | * |
| 6193 | * @return a new instance of {@link DevicePolicyManager} that acts on the parent profile. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6194 | * @throws SecurityException if {@code admin} is not a profile owner. |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 6195 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6196 | public @NonNull DevicePolicyManager getParentProfileInstance(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6197 | throwIfParentInstance("getParentProfileInstance"); |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 6198 | try { |
| 6199 | if (!mService.isManagedProfile(admin)) { |
| 6200 | throw new SecurityException("The current user does not have a parent profile."); |
| 6201 | } |
Jeff Sharkey | 49ca529 | 2016-05-10 12:54:45 -0600 | [diff] [blame] | 6202 | return new DevicePolicyManager(mContext, mService, true); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6203 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6204 | throw e.rethrowFromSystemServer(); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6205 | } |
| 6206 | } |
| 6207 | |
| 6208 | /** |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6209 | * Called by device owner to control the security logging feature. Logging can only be |
| 6210 | * enabled on single user devices where the sole user is managed by the device owner. |
| 6211 | * |
| 6212 | * <p> Security logs contain various information intended for security auditing purposes. |
| 6213 | * See {@link SecurityEvent} for details. |
| 6214 | * |
| 6215 | * <p>There must be only one user on the device, managed by the device owner. |
| 6216 | * Otherwise a {@link SecurityException} will be thrown. |
Michal Karpinski | b58e496 | 2016-03-01 14:55:10 +0000 | [diff] [blame] | 6217 | * |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6218 | * @param admin Which device owner this request is associated with. |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6219 | * @param enabled whether security logging should be enabled or not. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6220 | * @throws SecurityException if {@code admin} is not a device owner. |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6221 | * @see #retrieveSecurityLogs |
| 6222 | */ |
| 6223 | public void setSecurityLoggingEnabled(@NonNull ComponentName admin, boolean enabled) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6224 | throwIfParentInstance("setSecurityLoggingEnabled"); |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6225 | try { |
| 6226 | mService.setSecurityLoggingEnabled(admin, enabled); |
| 6227 | } catch (RemoteException re) { |
| 6228 | throw re.rethrowFromSystemServer(); |
| 6229 | } |
| 6230 | } |
| 6231 | |
| 6232 | /** |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6233 | * Return whether security logging is enabled or not by the device owner. |
| 6234 | * |
| 6235 | * <p>Can only be called by the device owner, otherwise a {@link SecurityException} will be |
| 6236 | * thrown. |
| 6237 | * |
| 6238 | * @param admin Which device owner this request is associated with. |
| 6239 | * @return {@code true} if security logging is enabled by device owner, {@code false} otherwise. |
| 6240 | * @throws SecurityException if {@code admin} is not a device owner. |
| 6241 | */ |
| 6242 | public boolean isSecurityLoggingEnabled(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6243 | throwIfParentInstance("isSecurityLoggingEnabled"); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6244 | try { |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6245 | return mService.isSecurityLoggingEnabled(admin); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6246 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6247 | throw re.rethrowFromSystemServer(); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6248 | } |
| 6249 | } |
| 6250 | |
| 6251 | /** |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6252 | * Called by device owner to retrieve all new security logging entries since the last call to |
| 6253 | * this API after device boots. |
| 6254 | * |
| 6255 | * <p> Access to the logs is rate limited and it will only return new logs after the device |
| 6256 | * owner has been notified via {@link DeviceAdminReceiver#onSecurityLogsAvailable}. |
| 6257 | * |
| 6258 | * <p>There must be only one user on the device, managed by the device owner. |
| 6259 | * Otherwise a {@link SecurityException} will be thrown. |
Michal Karpinski | b58e496 | 2016-03-01 14:55:10 +0000 | [diff] [blame] | 6260 | * |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6261 | * @param admin Which device owner this request is associated with. |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6262 | * @return the new batch of security logs which is a list of {@link SecurityEvent}, |
| 6263 | * or {@code null} if rate limitation is exceeded or if logging is currently disabled. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6264 | * @throws SecurityException if {@code admin} is not a device owner. |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6265 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6266 | public @Nullable List<SecurityEvent> retrieveSecurityLogs(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6267 | throwIfParentInstance("retrieveSecurityLogs"); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6268 | try { |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6269 | ParceledListSlice<SecurityEvent> list = mService.retrieveSecurityLogs(admin); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6270 | if (list != null) { |
| 6271 | return list.getList(); |
| 6272 | } else { |
| 6273 | // Rate limit exceeded. |
| 6274 | return null; |
| 6275 | } |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 6276 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6277 | throw re.rethrowFromSystemServer(); |
Clara Bayarri | 3e826ef | 2015-12-14 17:51:22 +0000 | [diff] [blame] | 6278 | } |
| 6279 | } |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6280 | |
| 6281 | /** |
Sudheer Shanka | 978fc0d | 2016-01-28 13:51:10 +0000 | [diff] [blame] | 6282 | * Called by the system to obtain a {@link DevicePolicyManager} whose calls act on the parent |
| 6283 | * profile. |
| 6284 | * |
| 6285 | * @hide |
| 6286 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6287 | public @NonNull DevicePolicyManager getParentProfileInstance(UserInfo uInfo) { |
Sudheer Shanka | 978fc0d | 2016-01-28 13:51:10 +0000 | [diff] [blame] | 6288 | mContext.checkSelfPermission( |
| 6289 | android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS); |
| 6290 | if (!uInfo.isManagedProfile()) { |
| 6291 | throw new SecurityException("The user " + uInfo.id |
| 6292 | + " does not have a parent profile."); |
| 6293 | } |
Jeff Sharkey | 49ca529 | 2016-05-10 12:54:45 -0600 | [diff] [blame] | 6294 | return new DevicePolicyManager(mContext, mService, true); |
Sudheer Shanka | 978fc0d | 2016-01-28 13:51:10 +0000 | [diff] [blame] | 6295 | } |
| 6296 | |
| 6297 | /** |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6298 | * Called by device owners to retrieve device logs from before the device's last reboot. |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6299 | * <p> |
Rubin Xu | 0fb6b9e | 2016-05-04 19:01:07 +0100 | [diff] [blame] | 6300 | * <strong> This API is not supported on all devices. Calling this API on unsupported devices |
| 6301 | * will result in {@code null} being returned. The device logs are retrieved from a RAM region |
| 6302 | * which is not guaranteed to be corruption-free during power cycles, as a result be cautious |
| 6303 | * about data corruption when parsing. </strong> |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6304 | * <p> |
| 6305 | * There must be only one user on the device, managed by the device owner. Otherwise a |
| 6306 | * {@link SecurityException} will be thrown. |
Michal Karpinski | b58e496 | 2016-03-01 14:55:10 +0000 | [diff] [blame] | 6307 | * |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6308 | * @param admin Which device owner this request is associated with. |
Rubin Xu | 0fb6b9e | 2016-05-04 19:01:07 +0100 | [diff] [blame] | 6309 | * @return Device logs from before the latest reboot of the system, or {@code null} if this API |
| 6310 | * is not supported on the device. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6311 | * @throws SecurityException if {@code admin} is not a device owner. |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6312 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6313 | public @Nullable List<SecurityEvent> retrievePreRebootSecurityLogs( |
| 6314 | @NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6315 | throwIfParentInstance("retrievePreRebootSecurityLogs"); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6316 | try { |
Michal Karpinski | 6235a94 | 2016-03-15 12:07:23 +0000 | [diff] [blame] | 6317 | ParceledListSlice<SecurityEvent> list = mService.retrievePreRebootSecurityLogs(admin); |
Rubin Xu | 0fb6b9e | 2016-05-04 19:01:07 +0100 | [diff] [blame] | 6318 | if (list != null) { |
| 6319 | return list.getList(); |
| 6320 | } else { |
| 6321 | return null; |
| 6322 | } |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6323 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6324 | throw re.rethrowFromSystemServer(); |
Rubin Xu | c3cd05f | 2016-01-11 12:11:35 +0000 | [diff] [blame] | 6325 | } |
| 6326 | } |
| 6327 | |
| 6328 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6329 | * Called by a profile owner of a managed profile to set the color used for customization. This |
| 6330 | * color is used as background color of the confirm credentials screen for that user. The |
Clara Bayarri | 8d0bd7fa | 2016-03-30 14:59:58 +0100 | [diff] [blame] | 6331 | * default color is teal (#00796B). |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6332 | * <p> |
| 6333 | * The confirm credentials screen can be created using |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6334 | * {@link android.app.KeyguardManager#createConfirmDeviceCredentialIntent}. |
| 6335 | * |
| 6336 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6337 | * @param color The 24bit (0xRRGGBB) representation of the color to be used. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6338 | * @throws SecurityException if {@code admin} is not a profile owner. |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6339 | */ |
| 6340 | public void setOrganizationColor(@NonNull ComponentName admin, int color) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6341 | throwIfParentInstance("setOrganizationColor"); |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6342 | try { |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6343 | // always enforce alpha channel to have 100% opacity |
| 6344 | color |= 0xFF000000; |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6345 | mService.setOrganizationColor(admin, color); |
| 6346 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6347 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6348 | } |
| 6349 | } |
| 6350 | |
| 6351 | /** |
Nicolas Prevot | 8f7698a | 2016-02-11 16:05:33 +0000 | [diff] [blame] | 6352 | * @hide |
| 6353 | * |
| 6354 | * Sets the color used for customization. |
| 6355 | * |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6356 | * @param color The 24bit (0xRRGGBB) representation of the color to be used. |
Nicolas Prevot | 8f7698a | 2016-02-11 16:05:33 +0000 | [diff] [blame] | 6357 | * @param userId which user to set the color to. |
| 6358 | * @RequiresPermission(allOf = { |
| 6359 | * Manifest.permission.MANAGE_USERS, |
| 6360 | * Manifest.permission.INTERACT_ACROSS_USERS_FULL}) |
| 6361 | */ |
| 6362 | public void setOrganizationColorForUser(@ColorInt int color, @UserIdInt int userId) { |
| 6363 | try { |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6364 | // always enforce alpha channel to have 100% opacity |
| 6365 | color |= 0xFF000000; |
Nicolas Prevot | 8f7698a | 2016-02-11 16:05:33 +0000 | [diff] [blame] | 6366 | mService.setOrganizationColorForUser(color, userId); |
| 6367 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6368 | throw re.rethrowFromSystemServer(); |
Nicolas Prevot | 8f7698a | 2016-02-11 16:05:33 +0000 | [diff] [blame] | 6369 | } |
| 6370 | } |
| 6371 | |
| 6372 | /** |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6373 | * Called by a profile owner of a managed profile to retrieve the color used for customization. |
| 6374 | * This color is used as background color of the confirm credentials screen for that user. |
| 6375 | * |
| 6376 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6377 | * @return The 24bit (0xRRGGBB) representation of the color to be used. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6378 | * @throws SecurityException if {@code admin} is not a profile owner. |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6379 | */ |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6380 | public @ColorInt int getOrganizationColor(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6381 | throwIfParentInstance("getOrganizationColor"); |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6382 | try { |
| 6383 | return mService.getOrganizationColor(admin); |
| 6384 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6385 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6386 | } |
| 6387 | } |
| 6388 | |
| 6389 | /** |
| 6390 | * @hide |
| 6391 | * Retrieve the customization color for a given user. |
| 6392 | * |
| 6393 | * @param userHandle The user id of the user we're interested in. |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6394 | * @return The 24bit (0xRRGGBB) representation of the color to be used. |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6395 | */ |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6396 | public @ColorInt int getOrganizationColorForUser(int userHandle) { |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6397 | try { |
| 6398 | return mService.getOrganizationColorForUser(userHandle); |
| 6399 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6400 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | 59720bb | 2016-01-18 15:26:11 +0000 | [diff] [blame] | 6401 | } |
| 6402 | } |
Bartosz Fabianowski | 4c052f2 | 2016-01-25 14:18:43 +0100 | [diff] [blame] | 6403 | |
| 6404 | /** |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6405 | * Called by a profile owner of a managed profile to set the name of the organization under |
| 6406 | * management. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6407 | * <p> |
| 6408 | * If the organization name needs to be localized, it is the responsibility of the |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6409 | * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast |
| 6410 | * and set a new version of this string accordingly. |
| 6411 | * |
| 6412 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 6413 | * @param title The organization name or {@code null} to clear a previously set name. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6414 | * @throws SecurityException if {@code admin} is not a profile owner. |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6415 | */ |
Michal Karpinski | 74cd730 | 2016-04-12 15:17:36 +0100 | [diff] [blame] | 6416 | public void setOrganizationName(@NonNull ComponentName admin, @Nullable CharSequence title) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6417 | throwIfParentInstance("setOrganizationName"); |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6418 | try { |
| 6419 | mService.setOrganizationName(admin, title); |
| 6420 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6421 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6422 | } |
| 6423 | } |
| 6424 | |
| 6425 | /** |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6426 | * Called by a profile owner of a managed profile to retrieve the name of the organization under |
| 6427 | * management. |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6428 | * |
| 6429 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 6430 | * @return The organization name or {@code null} if none is set. |
Suprabh Shukla | 34d92ef | 2016-03-14 13:49:37 -0700 | [diff] [blame] | 6431 | * @throws SecurityException if {@code admin} is not a profile owner. |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6432 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6433 | public @Nullable CharSequence getOrganizationName(@NonNull ComponentName admin) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6434 | throwIfParentInstance("getOrganizationName"); |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6435 | try { |
| 6436 | return mService.getOrganizationName(admin); |
| 6437 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6438 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6439 | } |
| 6440 | } |
| 6441 | |
| 6442 | /** |
| 6443 | * Retrieve the default title message used in the confirm credentials screen for a given user. |
| 6444 | * |
| 6445 | * @param userHandle The user id of the user we're interested in. |
| 6446 | * @return The organization name or {@code null} if none is set. |
| 6447 | * |
| 6448 | * @hide |
| 6449 | */ |
Makoto Onuki | 408e8e4 | 2016-10-25 12:10:27 -0700 | [diff] [blame] | 6450 | public @Nullable CharSequence getOrganizationNameForUser(int userHandle) { |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6451 | try { |
| 6452 | return mService.getOrganizationNameForUser(userHandle); |
| 6453 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6454 | throw re.rethrowFromSystemServer(); |
Benjamin Franz | 3e8a709 | 2016-01-25 16:19:08 +0000 | [diff] [blame] | 6455 | } |
| 6456 | } |
| 6457 | |
| 6458 | /** |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 6459 | * @return the {@link UserProvisioningState} for the current user - for unmanaged users will |
| 6460 | * return {@link #STATE_USER_UNMANAGED} |
| 6461 | * @hide |
| 6462 | */ |
Benjamin Franz | eed2a8e | 2016-02-19 14:19:05 +0000 | [diff] [blame] | 6463 | @SystemApi |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 6464 | @UserProvisioningState |
| 6465 | public int getUserProvisioningState() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6466 | throwIfParentInstance("getUserProvisioningState"); |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 6467 | if (mService != null) { |
| 6468 | try { |
| 6469 | return mService.getUserProvisioningState(); |
| 6470 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6471 | throw e.rethrowFromSystemServer(); |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 6472 | } |
| 6473 | } |
| 6474 | return STATE_USER_UNMANAGED; |
| 6475 | } |
| 6476 | |
| 6477 | /** |
| 6478 | * Set the {@link UserProvisioningState} for the supplied user, if they are managed. |
| 6479 | * |
| 6480 | * @param state to store |
| 6481 | * @param userHandle for user |
| 6482 | * @hide |
| 6483 | */ |
| 6484 | public void setUserProvisioningState(@UserProvisioningState int state, int userHandle) { |
| 6485 | if (mService != null) { |
| 6486 | try { |
| 6487 | mService.setUserProvisioningState(state, userHandle); |
| 6488 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6489 | throw e.rethrowFromSystemServer(); |
Alan Treadway | afad878 | 2016-01-19 15:15:08 +0000 | [diff] [blame] | 6490 | } |
| 6491 | } |
| 6492 | } |
| 6493 | |
| 6494 | /** |
Bartosz Fabianowski | 4c052f2 | 2016-01-25 14:18:43 +0100 | [diff] [blame] | 6495 | * @hide |
| 6496 | * Indicates the entity that controls the device or profile owner. A user/profile is considered |
| 6497 | * affiliated if it is managed by the same entity as the device. |
| 6498 | * |
| 6499 | * <p> By definition, the user that the device owner runs on is always affiliated. Any other |
| 6500 | * user/profile is considered affiliated if the following conditions are both met: |
| 6501 | * <ul> |
| 6502 | * <li>The device owner and the user's/profile's profile owner have called this method, |
| 6503 | * specifying a set of opaque affiliation ids each. If the sets specified by the device owner |
| 6504 | * and a profile owner intersect, they must have come from the same source, which means that |
| 6505 | * the device owner and profile owner are controlled by the same entity.</li> |
| 6506 | * <li>The device owner's and profile owner's package names are the same.</li> |
| 6507 | * </ul> |
| 6508 | * |
| 6509 | * @param admin Which profile or device owner this request is associated with. |
| 6510 | * @param ids A set of opaque affiliation ids. |
| 6511 | */ |
| 6512 | public void setAffiliationIds(@NonNull ComponentName admin, Set<String> ids) { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6513 | throwIfParentInstance("setAffiliationIds"); |
Bartosz Fabianowski | 4c052f2 | 2016-01-25 14:18:43 +0100 | [diff] [blame] | 6514 | try { |
| 6515 | mService.setAffiliationIds(admin, new ArrayList<String>(ids)); |
| 6516 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6517 | throw e.rethrowFromSystemServer(); |
Bartosz Fabianowski | 4c052f2 | 2016-01-25 14:18:43 +0100 | [diff] [blame] | 6518 | } |
| 6519 | } |
| 6520 | |
| 6521 | /** |
| 6522 | * @hide |
| 6523 | * Returns whether this user/profile is affiliated with the device. See |
| 6524 | * {@link #setAffiliationIds} for the definition of affiliation. |
| 6525 | * |
| 6526 | * @return whether this user/profile is affiliated with the device. |
| 6527 | */ |
| 6528 | public boolean isAffiliatedUser() { |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6529 | throwIfParentInstance("isAffiliatedUser"); |
Bartosz Fabianowski | 4c052f2 | 2016-01-25 14:18:43 +0100 | [diff] [blame] | 6530 | try { |
| 6531 | return mService != null && mService.isAffiliatedUser(); |
| 6532 | } catch (RemoteException e) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6533 | throw e.rethrowFromSystemServer(); |
Bartosz Fabianowski | 4c052f2 | 2016-01-25 14:18:43 +0100 | [diff] [blame] | 6534 | } |
| 6535 | } |
Suprabh Shukla | a2ae223 | 2016-01-28 18:05:14 -0800 | [diff] [blame] | 6536 | |
| 6537 | /** |
| 6538 | * @hide |
| 6539 | * Returns whether the uninstall for {@code packageName} for the current user is in queue |
| 6540 | * to be started |
| 6541 | * @param packageName the package to check for |
| 6542 | * @return whether the uninstall intent for {@code packageName} is pending |
| 6543 | */ |
| 6544 | public boolean isUninstallInQueue(String packageName) { |
| 6545 | try { |
| 6546 | return mService.isUninstallInQueue(packageName); |
| 6547 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6548 | throw re.rethrowFromSystemServer(); |
Suprabh Shukla | a2ae223 | 2016-01-28 18:05:14 -0800 | [diff] [blame] | 6549 | } |
| 6550 | } |
| 6551 | |
| 6552 | /** |
| 6553 | * @hide |
| 6554 | * @param packageName the package containing active DAs to be uninstalled |
| 6555 | */ |
| 6556 | public void uninstallPackageWithActiveAdmins(String packageName) { |
| 6557 | try { |
| 6558 | mService.uninstallPackageWithActiveAdmins(packageName); |
| 6559 | } catch (RemoteException re) { |
Jeff Sharkey | dbff9ca | 2016-03-01 19:46:25 -0700 | [diff] [blame] | 6560 | throw re.rethrowFromSystemServer(); |
Suprabh Shukla | a2ae223 | 2016-01-28 18:05:14 -0800 | [diff] [blame] | 6561 | } |
| 6562 | } |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6563 | |
Kenny Guy | 38dcca5 | 2016-04-19 13:09:18 +0100 | [diff] [blame] | 6564 | /** |
| 6565 | * @hide |
| 6566 | * Remove a test admin synchronously without sending it a broadcast about being removed. |
| 6567 | * If the admin is a profile owner or device owner it will still be removed. |
| 6568 | * |
| 6569 | * @param userHandle user id to remove the admin for. |
| 6570 | * @param admin The administration compononent to remove. |
| 6571 | * @throws SecurityException if the caller is not shell / root or the admin package |
| 6572 | * isn't a test application see {@link ApplicationInfo#FLAG_TEST_APP}. |
| 6573 | */ |
| 6574 | public void forceRemoveActiveAdmin(ComponentName adminReceiver, int userHandle) { |
| 6575 | try { |
| 6576 | mService.forceRemoveActiveAdmin(adminReceiver, userHandle); |
| 6577 | } catch (RemoteException re) { |
| 6578 | throw re.rethrowFromSystemServer(); |
| 6579 | } |
| 6580 | } |
| 6581 | |
Mahaver Chopra | 790d198 | 2016-07-07 16:06:49 +0100 | [diff] [blame] | 6582 | /** |
| 6583 | * @hide |
| 6584 | * @return whether {@link android.provider.Settings.Global#DEVICE_PROVISIONED} has ever been set |
| 6585 | * to 1. |
| 6586 | */ |
| 6587 | public boolean isDeviceProvisioned() { |
| 6588 | try { |
| 6589 | return mService.isDeviceProvisioned(); |
| 6590 | } catch (RemoteException re) { |
| 6591 | throw re.rethrowFromSystemServer(); |
| 6592 | } |
| 6593 | } |
| 6594 | |
Benjamin Franz | 2aa9bab | 2016-07-11 19:10:36 +0100 | [diff] [blame] | 6595 | /** |
| 6596 | * @hide |
| 6597 | * Writes that the provisioning configuration has been applied. |
| 6598 | */ |
| 6599 | public void setDeviceProvisioningConfigApplied() { |
| 6600 | try { |
| 6601 | mService.setDeviceProvisioningConfigApplied(); |
| 6602 | } catch (RemoteException re) { |
| 6603 | throw re.rethrowFromSystemServer(); |
| 6604 | } |
| 6605 | } |
| 6606 | |
| 6607 | /** |
| 6608 | * @hide |
| 6609 | * @return whether the provisioning configuration has been applied. |
| 6610 | */ |
| 6611 | public boolean isDeviceProvisioningConfigApplied() { |
| 6612 | try { |
| 6613 | return mService.isDeviceProvisioningConfigApplied(); |
| 6614 | } catch (RemoteException re) { |
| 6615 | throw re.rethrowFromSystemServer(); |
| 6616 | } |
| 6617 | } |
| 6618 | |
Victor Chang | 9bfc65f | 2016-08-15 12:27:09 +0100 | [diff] [blame] | 6619 | /** |
| 6620 | * @hide |
Victor Chang | 3577ed2 | 2016-08-25 18:49:26 +0100 | [diff] [blame] | 6621 | * Force update user setup completed status. This API has no effect on user build. |
| 6622 | * @throws {@link SecurityException} if the caller has no |
| 6623 | * {@link android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS} or the caller is |
| 6624 | * not {@link UserHandle.SYSTEM_USER} |
Victor Chang | 9bfc65f | 2016-08-15 12:27:09 +0100 | [diff] [blame] | 6625 | */ |
| 6626 | public void forceUpdateUserSetupComplete() { |
| 6627 | try { |
| 6628 | mService.forceUpdateUserSetupComplete(); |
| 6629 | } catch (RemoteException re) { |
| 6630 | throw re.rethrowFromSystemServer(); |
| 6631 | } |
| 6632 | } |
| 6633 | |
Benjamin Franz | bc33c82 | 2016-04-15 08:57:52 +0100 | [diff] [blame] | 6634 | private void throwIfParentInstance(String functionName) { |
| 6635 | if (mParentInstance) { |
| 6636 | throw new SecurityException(functionName + " cannot be called on the parent instance"); |
| 6637 | } |
| 6638 | } |
Vladislav Kuzkokov | a820252 | 2016-08-18 19:01:27 +0200 | [diff] [blame] | 6639 | |
| 6640 | /** |
| 6641 | * @hide |
| 6642 | * Enable backup service. |
| 6643 | * <p>This includes all backup and restore mechanisms. |
| 6644 | * Setting this to {@code false} will make backup service no-op or return empty results. |
| 6645 | * |
| 6646 | * <p>There must be only one user on the device, managed by the device owner. |
| 6647 | * Otherwise a {@link SecurityException} will be thrown. |
| 6648 | * |
| 6649 | * <p>Backup service is off by default when device owner is present. |
| 6650 | */ |
| 6651 | public void setBackupServiceEnabled(@NonNull ComponentName admin, boolean enabled) { |
| 6652 | try { |
| 6653 | mService.setBackupServiceEnabled(admin, enabled); |
| 6654 | } catch (RemoteException re) { |
| 6655 | throw re.rethrowFromSystemServer(); |
| 6656 | } |
| 6657 | } |
| 6658 | |
| 6659 | /** |
| 6660 | * @hide |
| 6661 | * @return {@code true} if backup service is enabled, {@code false} otherwise. |
| 6662 | */ |
| 6663 | public boolean isBackupServiceEnabled(@NonNull ComponentName admin) { |
| 6664 | try { |
| 6665 | return mService.isBackupServiceEnabled(admin); |
| 6666 | } catch (RemoteException re) { |
| 6667 | throw re.rethrowFromSystemServer(); |
| 6668 | } |
| 6669 | } |
Michal Karpinski | dd9bb4f | 2016-10-12 14:59:26 +0100 | [diff] [blame] | 6670 | |
| 6671 | /** |
| 6672 | * Called by a device owner to control the network logging feature. Logging can only be |
| 6673 | * enabled on single user devices where the sole user is managed by the device owner. If a new |
| 6674 | * user is added on the device, logging is disabled. |
| 6675 | * |
| 6676 | * <p> Network logs contain DNS lookup and connect() library call events. |
| 6677 | * |
| 6678 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 6679 | * @param enabled whether network logging should be enabled or not. |
| 6680 | * @throws {@link SecurityException} if {@code admin} is not a device owner. |
| 6681 | * @throws {@link RemoteException} if network logging could not be enabled or disabled due to |
| 6682 | * the logging service not being available |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 6683 | * @see #retrieveNetworkLogs |
Michal Karpinski | dd9bb4f | 2016-10-12 14:59:26 +0100 | [diff] [blame] | 6684 | * |
| 6685 | * @hide |
| 6686 | */ |
| 6687 | public void setNetworkLoggingEnabled(@NonNull ComponentName admin, boolean enabled) { |
| 6688 | throwIfParentInstance("setNetworkLoggingEnabled"); |
| 6689 | try { |
| 6690 | mService.setNetworkLoggingEnabled(admin, enabled); |
| 6691 | } catch (RemoteException re) { |
| 6692 | throw re.rethrowFromSystemServer(); |
| 6693 | } |
| 6694 | } |
| 6695 | |
| 6696 | /** |
| 6697 | * Return whether network logging is enabled by a device owner. |
| 6698 | * |
| 6699 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 6700 | * @return {@code true} if network logging is enabled by device owner, {@code false} otherwise. |
| 6701 | * @throws {@link SecurityException} if {@code admin} is not a device owner. |
| 6702 | * |
| 6703 | * @hide |
| 6704 | */ |
| 6705 | public boolean isNetworkLoggingEnabled(@NonNull ComponentName admin) { |
| 6706 | throwIfParentInstance("isNetworkLoggingEnabled"); |
| 6707 | try { |
| 6708 | return mService.isNetworkLoggingEnabled(admin); |
| 6709 | } catch (RemoteException re) { |
| 6710 | throw re.rethrowFromSystemServer(); |
| 6711 | } |
| 6712 | } |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 6713 | |
| 6714 | /** |
| 6715 | * Called by device owner to retrieve a new batch of network logging events. |
| 6716 | * |
| 6717 | * <p> {@link NetworkEvent} can be one of {@link DnsEvent} or {@link ConnectEvent}. |
| 6718 | * |
| 6719 | * <p> The list of network events is sorted chronologically, and contains at most 1200 events. |
| 6720 | * |
| 6721 | * <p> Access to the logs is rate limited and this method will only return a new batch of logs |
| 6722 | * after the device device owner has been notified via |
| 6723 | * {@link DeviceAdminReceiver#onNetworkLogsAvailable}. |
| 6724 | * |
| 6725 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 6726 | * @return A new batch of network logs which is a list of {@link NetworkEvent}. Returns |
| 6727 | * {@code null} if there's no batch currently awaiting for retrieval or if logging is disabled. |
| 6728 | * @throws {@link SecurityException} if {@code admin} is not a device owner. |
| 6729 | * |
| 6730 | * @hide |
| 6731 | */ |
| 6732 | public List<NetworkEvent> retrieveNetworkLogs(@NonNull ComponentName admin) { |
| 6733 | throwIfParentInstance("retrieveNetworkLogs"); |
| 6734 | try { |
| 6735 | return mService.retrieveNetworkLogs(admin); |
| 6736 | } catch (RemoteException re) { |
| 6737 | throw re.rethrowFromSystemServer(); |
| 6738 | } |
| 6739 | } |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 6740 | } |