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 | |
| 19 | import org.xmlpull.v1.XmlPullParserException; |
| 20 | |
| 21 | import android.annotation.SdkConstant; |
| 22 | import android.annotation.SdkConstant.SdkConstantType; |
| 23 | import android.content.ComponentName; |
| 24 | import android.content.Context; |
| 25 | import android.content.pm.ActivityInfo; |
| 26 | import android.content.pm.PackageManager; |
| 27 | import android.content.pm.ResolveInfo; |
| 28 | import android.os.Handler; |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 29 | import android.os.RemoteCallback; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 30 | import android.os.RemoteException; |
| 31 | import android.os.ServiceManager; |
| 32 | import android.util.Log; |
| 33 | |
| 34 | import java.io.IOException; |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 35 | import java.net.InetSocketAddress; |
| 36 | import java.net.Proxy; |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 37 | import java.util.List; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Public interface for managing policies enforced on a device. Most clients |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 41 | * of this class must have published a {@link DeviceAdminReceiver} that the user |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 42 | * has currently enabled. |
| 43 | */ |
| 44 | public class DevicePolicyManager { |
| 45 | private static String TAG = "DevicePolicyManager"; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 46 | |
| 47 | private final Context mContext; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 48 | private final IDevicePolicyManager mService; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 49 | |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 50 | private DevicePolicyManager(Context context, Handler handler) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 51 | mContext = context; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 52 | mService = IDevicePolicyManager.Stub.asInterface( |
| 53 | ServiceManager.getService(Context.DEVICE_POLICY_SERVICE)); |
| 54 | } |
| 55 | |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 56 | /** @hide */ |
| 57 | public static DevicePolicyManager create(Context context, Handler handler) { |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 58 | DevicePolicyManager me = new DevicePolicyManager(context, handler); |
| 59 | return me.mService != null ? me : null; |
| 60 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 61 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 62 | /** |
| 63 | * Activity action: ask the user to add a new device administrator to the system. |
| 64 | * The desired policy is the ComponentName of the policy in the |
| 65 | * {@link #EXTRA_DEVICE_ADMIN} extra field. This will invoke a UI to |
| 66 | * bring the user through adding the device administrator to the system (or |
| 67 | * allowing them to reject it). |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 68 | * |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 69 | * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION} |
| 70 | * field to provide the user with additional explanation (in addition |
| 71 | * to your component's description) about what is being added. |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 72 | * |
| 73 | * <p>If your administrator is already active, this will ordinarily return immediately (without |
| 74 | * user intervention). However, if your administrator has been updated and is requesting |
| 75 | * additional uses-policy flags, the user will be presented with the new list. New policies |
| 76 | * 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] | 77 | */ |
| 78 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 79 | public static final String ACTION_ADD_DEVICE_ADMIN |
| 80 | = "android.app.action.ADD_DEVICE_ADMIN"; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 81 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 82 | /** |
Jim Miller | 284b62e | 2010-06-08 14:27:42 -0700 | [diff] [blame] | 83 | * Activity action: send when any policy admin changes a policy. |
| 84 | * 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] | 85 | * |
Jim Miller | 284b62e | 2010-06-08 14:27:42 -0700 | [diff] [blame] | 86 | * @hide |
| 87 | */ |
| 88 | public static final String ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED |
| 89 | = "android.app.action.DEVICE_POLICY_MANAGER_STATE_CHANGED"; |
| 90 | |
| 91 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 92 | * The ComponentName of the administrator component. |
| 93 | * |
| 94 | * @see #ACTION_ADD_DEVICE_ADMIN |
| 95 | */ |
| 96 | public static final String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN"; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 97 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 98 | /** |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 99 | * An optional CharSequence providing additional explanation for why the |
| 100 | * admin is being added. |
| 101 | * |
| 102 | * @see #ACTION_ADD_DEVICE_ADMIN |
| 103 | */ |
| 104 | public static final String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION"; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 105 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 106 | /** |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 107 | * Activity action: have the user enter a new password. This activity should |
| 108 | * be launched after using {@link #setPasswordQuality(ComponentName, int)}, |
| 109 | * or {@link #setPasswordMinimumLength(ComponentName, int)} to have the user |
| 110 | * enter a new password that meets the current requirements. You can use |
| 111 | * {@link #isActivePasswordSufficient()} to determine whether you need to |
| 112 | * have the user select a new password in order to meet the current |
| 113 | * constraints. Upon being resumed from this activity, you can check the new |
| 114 | * password characteristics to see if they are sufficient. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 115 | */ |
| 116 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 117 | public static final String ACTION_SET_NEW_PASSWORD |
| 118 | = "android.app.action.SET_NEW_PASSWORD"; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 119 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 120 | /** |
| 121 | * Return true if the given administrator component is currently |
| 122 | * active (enabled) in the system. |
| 123 | */ |
| 124 | public boolean isAdminActive(ComponentName who) { |
| 125 | if (mService != null) { |
| 126 | try { |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 127 | return mService.isAdminActive(who); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 128 | } catch (RemoteException e) { |
| 129 | Log.w(TAG, "Failed talking with device policy service", e); |
| 130 | } |
| 131 | } |
| 132 | return false; |
| 133 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 134 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 135 | /** |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 136 | * Return a list of all currently active device administrator's component |
| 137 | * names. Note that if there are no administrators than null may be |
| 138 | * returned. |
| 139 | */ |
| 140 | public List<ComponentName> getActiveAdmins() { |
| 141 | if (mService != null) { |
| 142 | try { |
| 143 | return mService.getActiveAdmins(); |
| 144 | } catch (RemoteException e) { |
| 145 | Log.w(TAG, "Failed talking with device policy service", e); |
| 146 | } |
| 147 | } |
| 148 | return null; |
| 149 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 150 | |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 151 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 152 | * @hide |
| 153 | */ |
| 154 | public boolean packageHasActiveAdmins(String packageName) { |
| 155 | if (mService != null) { |
| 156 | try { |
| 157 | return mService.packageHasActiveAdmins(packageName); |
| 158 | } catch (RemoteException e) { |
| 159 | Log.w(TAG, "Failed talking with device policy service", e); |
| 160 | } |
| 161 | } |
| 162 | return false; |
| 163 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 164 | |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 165 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 166 | * Remove a current administration component. This can only be called |
| 167 | * by the application that owns the administration component; if you |
| 168 | * try to remove someone else's component, a security exception will be |
| 169 | * thrown. |
| 170 | */ |
| 171 | public void removeActiveAdmin(ComponentName who) { |
| 172 | if (mService != null) { |
| 173 | try { |
| 174 | mService.removeActiveAdmin(who); |
| 175 | } catch (RemoteException e) { |
| 176 | Log.w(TAG, "Failed talking with device policy service", e); |
| 177 | } |
| 178 | } |
| 179 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 180 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 181 | /** |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 182 | * Returns true if an administrator has been granted a particular device policy. This can |
| 183 | * be used to check if the administrator was activated under an earlier set of policies, |
| 184 | * but requires additional policies after an upgrade. |
| 185 | * |
| 186 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Must be |
| 187 | * an active administrator, or an exception will be thrown. |
| 188 | * @param usesPolicy Which uses-policy to check, as defined in {@link DeviceAdminInfo}. |
| 189 | */ |
| 190 | public boolean hasGrantedPolicy(ComponentName admin, int usesPolicy) { |
| 191 | if (mService != null) { |
| 192 | try { |
| 193 | return mService.hasGrantedPolicy(admin, usesPolicy); |
| 194 | } catch (RemoteException e) { |
| 195 | Log.w(TAG, "Failed talking with device policy service", e); |
| 196 | } |
| 197 | } |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 202 | * Constant for {@link #setPasswordQuality}: the policy has no requirements |
| 203 | * for the password. Note that quality constants are ordered so that higher |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 204 | * values are more restrictive. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 205 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 206 | public static final int PASSWORD_QUALITY_UNSPECIFIED = 0; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 207 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 208 | /** |
Jim Miller | 3e5d3fd | 2011-09-02 17:30:35 -0700 | [diff] [blame] | 209 | * Constant for {@link #setPasswordQuality}: the policy allows for low-security biometric |
| 210 | * recognition technology. This implies technologies that can recognize the identity of |
| 211 | * an individual to about a 3 digit PIN (false detection is less than 1 in 1,000). |
| 212 | * Note that quality constants are ordered so that higher values are more restrictive. |
| 213 | */ |
| 214 | public static final int PASSWORD_QUALITY_BIOMETRIC_WEAK = 0x8000; |
| 215 | |
| 216 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 217 | * Constant for {@link #setPasswordQuality}: the policy requires some kind |
| 218 | * of password, but doesn't care what it is. Note that quality constants |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 219 | * are ordered so that higher values are more restrictive. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 220 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 221 | public static final int PASSWORD_QUALITY_SOMETHING = 0x10000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 222 | |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 223 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 224 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
| 225 | * password containing at least numeric characters. Note that quality |
| 226 | * constants are ordered so that higher values are more restrictive. |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 227 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 228 | public static final int PASSWORD_QUALITY_NUMERIC = 0x20000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 229 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 230 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 231 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 232 | * password containing at least alphabetic (or other symbol) characters. |
| 233 | * Note that quality constants are ordered so that higher values are more |
| 234 | * restrictive. |
| 235 | */ |
| 236 | public static final int PASSWORD_QUALITY_ALPHABETIC = 0x40000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 237 | |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 238 | /** |
| 239 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 240 | * password containing at least <em>both></em> numeric <em>and</em> |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 241 | * alphabetic (or other symbol) characters. Note that quality constants are |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 242 | * ordered so that higher values are more restrictive. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 243 | */ |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 244 | public static final int PASSWORD_QUALITY_ALPHANUMERIC = 0x50000; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 245 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 246 | /** |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 247 | * Constant for {@link #setPasswordQuality}: the user must have entered a |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 248 | * password containing at least a letter, a numerical digit and a special |
| 249 | * symbol, by default. With this password quality, passwords can be |
| 250 | * restricted to contain various sets of characters, like at least an |
| 251 | * uppercase letter, etc. These are specified using various methods, |
| 252 | * like {@link #setPasswordMinimumLowerCase(ComponentName, int)}. Note |
| 253 | * that quality constants are ordered so that higher values are more |
| 254 | * restrictive. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 255 | */ |
| 256 | public static final int PASSWORD_QUALITY_COMPLEX = 0x60000; |
| 257 | |
| 258 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 259 | * Called by an application that is administering the device to set the |
| 260 | * password restrictions it is imposing. After setting this, the user |
| 261 | * will not be able to enter a new password that is not at least as |
| 262 | * restrictive as what has been set. Note that the current password |
| 263 | * will remain until the user has set a new one, so the change does not |
| 264 | * take place immediately. To prompt the user for a new password, use |
| 265 | * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 266 | * |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 267 | * <p>Quality constants are ordered so that higher values are more restrictive; |
| 268 | * thus the highest requested quality constant (between the policy set here, |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 269 | * the user's preference, and any other considerations) is the one that |
| 270 | * is in effect. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 271 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 272 | * <p>The calling device admin must have requested |
| 273 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 274 | * this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 275 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 276 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 277 | * @param quality The new desired quality. One of |
| 278 | * {@link #PASSWORD_QUALITY_UNSPECIFIED}, {@link #PASSWORD_QUALITY_SOMETHING}, |
Dianne Hackborn | 85f2c9c | 2010-03-22 11:12:48 -0700 | [diff] [blame] | 279 | * {@link #PASSWORD_QUALITY_NUMERIC}, {@link #PASSWORD_QUALITY_ALPHABETIC}, |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 280 | * {@link #PASSWORD_QUALITY_ALPHANUMERIC} or {@link #PASSWORD_QUALITY_COMPLEX}. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 281 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 282 | public void setPasswordQuality(ComponentName admin, int quality) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 283 | if (mService != null) { |
| 284 | try { |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 285 | mService.setPasswordQuality(admin, quality); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 286 | } catch (RemoteException e) { |
| 287 | Log.w(TAG, "Failed talking with device policy service", e); |
| 288 | } |
| 289 | } |
| 290 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 291 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 292 | /** |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 293 | * Retrieve the current minimum password quality for all admins |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 294 | * or a particular one. |
| 295 | * @param admin The name of the admin component to check, or null to aggregate |
| 296 | * all admins. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 297 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 298 | public int getPasswordQuality(ComponentName admin) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 299 | if (mService != null) { |
| 300 | try { |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 301 | return mService.getPasswordQuality(admin); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 302 | } catch (RemoteException e) { |
| 303 | Log.w(TAG, "Failed talking with device policy service", e); |
| 304 | } |
| 305 | } |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 306 | return PASSWORD_QUALITY_UNSPECIFIED; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 307 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 308 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 309 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 310 | * Called by an application that is administering the device to set the |
| 311 | * minimum allowed password length. After setting this, the user |
| 312 | * will not be able to enter a new password that is not at least as |
| 313 | * restrictive as what has been set. Note that the current password |
| 314 | * will remain until the user has set a new one, so the change does not |
| 315 | * take place immediately. To prompt the user for a new password, use |
| 316 | * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This |
| 317 | * constraint is only imposed if the administrator has also requested either |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 318 | * {@link #PASSWORD_QUALITY_NUMERIC}, {@link #PASSWORD_QUALITY_ALPHABETIC} |
| 319 | * {@link #PASSWORD_QUALITY_ALPHANUMERIC}, or {@link #PASSWORD_QUALITY_COMPLEX} |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 320 | * with {@link #setPasswordQuality}. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 321 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 322 | * <p>The calling device admin must have requested |
| 323 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 324 | * this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 325 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 326 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 327 | * @param length The new desired minimum password length. A value of 0 |
| 328 | * means there is no restriction. |
| 329 | */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 330 | public void setPasswordMinimumLength(ComponentName admin, int length) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 331 | if (mService != null) { |
| 332 | try { |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 333 | mService.setPasswordMinimumLength(admin, length); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 334 | } catch (RemoteException e) { |
| 335 | Log.w(TAG, "Failed talking with device policy service", e); |
| 336 | } |
| 337 | } |
| 338 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 339 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 340 | /** |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 341 | * Retrieve the current minimum password length for all admins |
| 342 | * or a particular one. |
| 343 | * @param admin The name of the admin component to check, or null to aggregate |
| 344 | * all admins. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 345 | */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 346 | public int getPasswordMinimumLength(ComponentName admin) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 347 | if (mService != null) { |
| 348 | try { |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 349 | return mService.getPasswordMinimumLength(admin); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 350 | } catch (RemoteException e) { |
| 351 | Log.w(TAG, "Failed talking with device policy service", e); |
| 352 | } |
| 353 | } |
| 354 | return 0; |
| 355 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 356 | |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 357 | /** |
| 358 | * Called by an application that is administering the device to set the |
| 359 | * minimum number of upper case letters required in the password. After |
| 360 | * setting this, the user will not be able to enter a new password that is |
| 361 | * not at least as restrictive as what has been set. Note that the current |
| 362 | * password will remain until the user has set a new one, so the change does |
| 363 | * not take place immediately. To prompt the user for a new password, use |
| 364 | * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This |
| 365 | * constraint is only imposed if the administrator has also requested |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 366 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The |
| 367 | * default value is 0. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 368 | * <p> |
| 369 | * The calling device admin must have requested |
| 370 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 371 | * this method; if it has not, a security exception will be thrown. |
| 372 | * |
| 373 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 374 | * with. |
| 375 | * @param length The new desired minimum number of upper case letters |
| 376 | * required in the password. A value of 0 means there is no |
| 377 | * restriction. |
| 378 | */ |
| 379 | public void setPasswordMinimumUpperCase(ComponentName admin, int length) { |
| 380 | if (mService != null) { |
| 381 | try { |
| 382 | mService.setPasswordMinimumUpperCase(admin, length); |
| 383 | } catch (RemoteException e) { |
| 384 | Log.w(TAG, "Failed talking with device policy service", e); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * Retrieve the current number of upper case letters required in the |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 391 | * password for all admins or a particular one. This is the same value as |
| 392 | * set by {#link {@link #setPasswordMinimumUpperCase(ComponentName, int)} |
| 393 | * and only applies when the password quality is |
| 394 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 395 | * |
| 396 | * @param admin The name of the admin component to check, or null to |
| 397 | * aggregate all admins. |
| 398 | * @return The minimum number of upper case letters required in the |
| 399 | * password. |
| 400 | */ |
| 401 | public int getPasswordMinimumUpperCase(ComponentName admin) { |
| 402 | if (mService != null) { |
| 403 | try { |
| 404 | return mService.getPasswordMinimumUpperCase(admin); |
| 405 | } catch (RemoteException e) { |
| 406 | Log.w(TAG, "Failed talking with device policy service", e); |
| 407 | } |
| 408 | } |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * Called by an application that is administering the device to set the |
| 414 | * minimum number of lower case letters required in the password. After |
| 415 | * setting this, the user will not be able to enter a new password that is |
| 416 | * not at least as restrictive as what has been set. Note that the current |
| 417 | * password will remain until the user has set a new one, so the change does |
| 418 | * not take place immediately. To prompt the user for a new password, use |
| 419 | * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This |
| 420 | * constraint is only imposed if the administrator has also requested |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 421 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The |
| 422 | * default value is 0. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 423 | * <p> |
| 424 | * The calling device admin must have requested |
| 425 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 426 | * this method; if it has not, a security exception will be thrown. |
| 427 | * |
| 428 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 429 | * with. |
| 430 | * @param length The new desired minimum number of lower case letters |
| 431 | * required in the password. A value of 0 means there is no |
| 432 | * restriction. |
| 433 | */ |
| 434 | public void setPasswordMinimumLowerCase(ComponentName admin, int length) { |
| 435 | if (mService != null) { |
| 436 | try { |
| 437 | mService.setPasswordMinimumLowerCase(admin, length); |
| 438 | } catch (RemoteException e) { |
| 439 | Log.w(TAG, "Failed talking with device policy service", e); |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | /** |
| 445 | * Retrieve the current number of lower case letters required in the |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 446 | * password for all admins or a particular one. This is the same value as |
| 447 | * set by {#link {@link #setPasswordMinimumLowerCase(ComponentName, int)} |
| 448 | * and only applies when the password quality is |
| 449 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 450 | * |
| 451 | * @param admin The name of the admin component to check, or null to |
| 452 | * aggregate all admins. |
| 453 | * @return The minimum number of lower case letters required in the |
| 454 | * password. |
| 455 | */ |
| 456 | public int getPasswordMinimumLowerCase(ComponentName admin) { |
| 457 | if (mService != null) { |
| 458 | try { |
| 459 | return mService.getPasswordMinimumLowerCase(admin); |
| 460 | } catch (RemoteException e) { |
| 461 | Log.w(TAG, "Failed talking with device policy service", e); |
| 462 | } |
| 463 | } |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Called by an application that is administering the device to set the |
| 469 | * minimum number of letters required in the password. After setting this, |
| 470 | * the user will not be able to enter a new password that is not at least as |
| 471 | * restrictive as what has been set. Note that the current password will |
| 472 | * remain until the user has set a new one, so the change does not take |
| 473 | * place immediately. To prompt the user for a new password, use |
| 474 | * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This |
| 475 | * constraint is only imposed if the administrator has also requested |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 476 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The |
| 477 | * default value is 1. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 478 | * <p> |
| 479 | * The calling device admin must have requested |
| 480 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 481 | * this method; if it has not, a security exception will be thrown. |
| 482 | * |
| 483 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 484 | * with. |
| 485 | * @param length The new desired minimum number of letters required in the |
| 486 | * password. A value of 0 means there is no restriction. |
| 487 | */ |
| 488 | public void setPasswordMinimumLetters(ComponentName admin, int length) { |
| 489 | if (mService != null) { |
| 490 | try { |
| 491 | mService.setPasswordMinimumLetters(admin, length); |
| 492 | } catch (RemoteException e) { |
| 493 | Log.w(TAG, "Failed talking with device policy service", e); |
| 494 | } |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | /** |
| 499 | * Retrieve the current number of letters required in the password for all |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 500 | * admins or a particular one. This is the same value as |
| 501 | * set by {#link {@link #setPasswordMinimumLetters(ComponentName, int)} |
| 502 | * and only applies when the password quality is |
| 503 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 504 | * |
| 505 | * @param admin The name of the admin component to check, or null to |
| 506 | * aggregate all admins. |
| 507 | * @return The minimum number of letters required in the password. |
| 508 | */ |
| 509 | public int getPasswordMinimumLetters(ComponentName admin) { |
| 510 | if (mService != null) { |
| 511 | try { |
| 512 | return mService.getPasswordMinimumLetters(admin); |
| 513 | } catch (RemoteException e) { |
| 514 | Log.w(TAG, "Failed talking with device policy service", e); |
| 515 | } |
| 516 | } |
| 517 | return 0; |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Called by an application that is administering the device to set the |
| 522 | * minimum number of numerical digits required in the password. After |
| 523 | * setting this, the user will not be able to enter a new password that is |
| 524 | * not at least as restrictive as what has been set. Note that the current |
| 525 | * password will remain until the user has set a new one, so the change does |
| 526 | * not take place immediately. To prompt the user for a new password, use |
| 527 | * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This |
| 528 | * constraint is only imposed if the administrator has also requested |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 529 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The |
| 530 | * default value is 1. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 531 | * <p> |
| 532 | * The calling device admin must have requested |
| 533 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 534 | * this method; if it has not, a security exception will be thrown. |
| 535 | * |
| 536 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 537 | * with. |
| 538 | * @param length The new desired minimum number of numerical digits required |
| 539 | * in the password. A value of 0 means there is no restriction. |
| 540 | */ |
| 541 | public void setPasswordMinimumNumeric(ComponentName admin, int length) { |
| 542 | if (mService != null) { |
| 543 | try { |
| 544 | mService.setPasswordMinimumNumeric(admin, length); |
| 545 | } catch (RemoteException e) { |
| 546 | Log.w(TAG, "Failed talking with device policy service", e); |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | /** |
| 552 | * Retrieve the current number of numerical digits required in the password |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 553 | * for all admins or a particular one. This is the same value as |
| 554 | * set by {#link {@link #setPasswordMinimumNumeric(ComponentName, int)} |
| 555 | * and only applies when the password quality is |
| 556 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 557 | * |
| 558 | * @param admin The name of the admin component to check, or null to |
| 559 | * aggregate all admins. |
| 560 | * @return The minimum number of numerical digits required in the password. |
| 561 | */ |
| 562 | public int getPasswordMinimumNumeric(ComponentName admin) { |
| 563 | if (mService != null) { |
| 564 | try { |
| 565 | return mService.getPasswordMinimumNumeric(admin); |
| 566 | } catch (RemoteException e) { |
| 567 | Log.w(TAG, "Failed talking with device policy service", e); |
| 568 | } |
| 569 | } |
| 570 | return 0; |
| 571 | } |
| 572 | |
| 573 | /** |
| 574 | * Called by an application that is administering the device to set the |
| 575 | * minimum number of symbols required in the password. After setting this, |
| 576 | * the user will not be able to enter a new password that is not at least as |
| 577 | * restrictive as what has been set. Note that the current password will |
| 578 | * remain until the user has set a new one, so the change does not take |
| 579 | * place immediately. To prompt the user for a new password, use |
| 580 | * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This |
| 581 | * constraint is only imposed if the administrator has also requested |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 582 | * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}. The |
| 583 | * default value is 1. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 584 | * <p> |
| 585 | * The calling device admin must have requested |
| 586 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 587 | * this method; if it has not, a security exception will be thrown. |
| 588 | * |
| 589 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 590 | * with. |
| 591 | * @param length The new desired minimum number of symbols required in the |
| 592 | * password. A value of 0 means there is no restriction. |
| 593 | */ |
| 594 | public void setPasswordMinimumSymbols(ComponentName admin, int length) { |
| 595 | if (mService != null) { |
| 596 | try { |
| 597 | mService.setPasswordMinimumSymbols(admin, length); |
| 598 | } catch (RemoteException e) { |
| 599 | Log.w(TAG, "Failed talking with device policy service", e); |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | /** |
| 605 | * Retrieve the current number of symbols required in the password for all |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 606 | * admins or a particular one. This is the same value as |
| 607 | * set by {#link {@link #setPasswordMinimumSymbols(ComponentName, int)} |
| 608 | * and only applies when the password quality is |
| 609 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 610 | * |
| 611 | * @param admin The name of the admin component to check, or null to |
| 612 | * aggregate all admins. |
| 613 | * @return The minimum number of symbols required in the password. |
| 614 | */ |
| 615 | public int getPasswordMinimumSymbols(ComponentName admin) { |
| 616 | if (mService != null) { |
| 617 | try { |
| 618 | return mService.getPasswordMinimumSymbols(admin); |
| 619 | } catch (RemoteException e) { |
| 620 | Log.w(TAG, "Failed talking with device policy service", e); |
| 621 | } |
| 622 | } |
| 623 | return 0; |
| 624 | } |
| 625 | |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 626 | /** |
| 627 | * Called by an application that is administering the device to set the |
| 628 | * minimum number of non-letter characters (numerical digits or symbols) |
| 629 | * required in the password. After setting this, the user will not be able |
| 630 | * to enter a new password that is not at least as restrictive as what has |
| 631 | * been set. Note that the current password will remain until the user has |
| 632 | * set a new one, so the change does not take place immediately. To prompt |
| 633 | * the user for a new password, use {@link #ACTION_SET_NEW_PASSWORD} after |
| 634 | * setting this value. This constraint is only imposed if the administrator |
| 635 | * has also requested {@link #PASSWORD_QUALITY_COMPLEX} with |
| 636 | * {@link #setPasswordQuality}. The default value is 0. |
| 637 | * <p> |
| 638 | * The calling device admin must have requested |
| 639 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 640 | * this method; if it has not, a security exception will be thrown. |
| 641 | * |
| 642 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 643 | * with. |
| 644 | * @param length The new desired minimum number of letters required in the |
| 645 | * password. A value of 0 means there is no restriction. |
| 646 | */ |
| 647 | public void setPasswordMinimumNonLetter(ComponentName admin, int length) { |
| 648 | if (mService != null) { |
| 649 | try { |
| 650 | mService.setPasswordMinimumNonLetter(admin, length); |
| 651 | } catch (RemoteException e) { |
| 652 | Log.w(TAG, "Failed talking with device policy service", e); |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * Retrieve the current number of non-letter characters required in the |
| 659 | * password for all admins or a particular one. This is the same value as |
| 660 | * set by {#link {@link #setPasswordMinimumNonLetter(ComponentName, int)} |
| 661 | * and only applies when the password quality is |
| 662 | * {@link #PASSWORD_QUALITY_COMPLEX}. |
| 663 | * |
| 664 | * @param admin The name of the admin component to check, or null to |
| 665 | * aggregate all admins. |
| 666 | * @return The minimum number of letters required in the password. |
| 667 | */ |
| 668 | public int getPasswordMinimumNonLetter(ComponentName admin) { |
| 669 | if (mService != null) { |
| 670 | try { |
| 671 | return mService.getPasswordMinimumNonLetter(admin); |
| 672 | } catch (RemoteException e) { |
| 673 | Log.w(TAG, "Failed talking with device policy service", e); |
| 674 | } |
| 675 | } |
| 676 | return 0; |
| 677 | } |
| 678 | |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 679 | /** |
| 680 | * Called by an application that is administering the device to set the length |
| 681 | * of the password history. After setting this, the user will not be able to |
| 682 | * enter a new password that is the same as any password in the history. Note |
| 683 | * that the current password will remain until the user has set a new one, so |
| 684 | * the change does not take place immediately. To prompt the user for a new |
| 685 | * password, use {@link #ACTION_SET_NEW_PASSWORD} after setting this value. |
| 686 | * This constraint is only imposed if the administrator has also requested |
| 687 | * either {@link #PASSWORD_QUALITY_NUMERIC}, |
| 688 | * {@link #PASSWORD_QUALITY_ALPHABETIC}, or |
| 689 | * {@link #PASSWORD_QUALITY_ALPHANUMERIC} with {@link #setPasswordQuality}. |
| 690 | * |
| 691 | * <p> |
| 692 | * The calling device admin must have requested |
| 693 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this |
| 694 | * method; if it has not, a security exception will be thrown. |
| 695 | * |
| 696 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 697 | * with. |
| 698 | * @param length The new desired length of password history. A value of 0 |
| 699 | * means there is no restriction. |
| 700 | */ |
| 701 | public void setPasswordHistoryLength(ComponentName admin, int length) { |
| 702 | if (mService != null) { |
| 703 | try { |
| 704 | mService.setPasswordHistoryLength(admin, length); |
| 705 | } catch (RemoteException e) { |
| 706 | Log.w(TAG, "Failed talking with device policy service", e); |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | /** |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 712 | * Called by a device admin to set the password expiration timeout. Calling this method |
| 713 | * will restart the countdown for password expiration for the given admin, as will changing |
| 714 | * the device password (for all admins). |
| 715 | * |
| 716 | * <p>The provided timeout is the time delta in ms and will be added to the current time. |
| 717 | * For example, to have the password expire 5 days from now, timeout would be |
| 718 | * 5 * 86400 * 1000 = 432000000 ms for timeout. |
| 719 | * |
| 720 | * <p>To disable password expiration, a value of 0 may be used for timeout. |
| 721 | * |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 722 | * <p>The calling device admin must have requested |
| 723 | * {@link DeviceAdminInfo#USES_POLICY_EXPIRE_PASSWORD} to be able to call this |
| 724 | * method; if it has not, a security exception will be thrown. |
| 725 | * |
| 726 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 727 | * @param timeout The limit (in ms) that a password can remain in effect. A value of 0 |
| 728 | * means there is no restriction (unlimited). |
| 729 | */ |
| 730 | public void setPasswordExpirationTimeout(ComponentName admin, long timeout) { |
| 731 | if (mService != null) { |
| 732 | try { |
| 733 | mService.setPasswordExpirationTimeout(admin, timeout); |
| 734 | } catch (RemoteException e) { |
| 735 | Log.w(TAG, "Failed talking with device policy service", e); |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | /** |
Jim Miller | 6b85768 | 2011-02-16 16:27:41 -0800 | [diff] [blame] | 741 | * Get the password expiration timeout for the given admin. The expiration timeout is the |
| 742 | * recurring expiration timeout provided in the call to |
| 743 | * {@link #setPasswordExpirationTimeout(ComponentName, long)} for the given admin or the |
| 744 | * aggregate of all policy administrators if admin is null. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 745 | * |
| 746 | * @param admin The name of the admin component to check, or null to aggregate all admins. |
| 747 | * @return The timeout for the given admin or the minimum of all timeouts |
| 748 | */ |
| 749 | public long getPasswordExpirationTimeout(ComponentName admin) { |
| 750 | if (mService != null) { |
| 751 | try { |
| 752 | return mService.getPasswordExpirationTimeout(admin); |
| 753 | } catch (RemoteException e) { |
| 754 | Log.w(TAG, "Failed talking with device policy service", e); |
| 755 | } |
| 756 | } |
| 757 | return 0; |
| 758 | } |
| 759 | |
| 760 | /** |
| 761 | * Get the current password expiration time for the given admin or an aggregate of |
Jim Miller | 6b85768 | 2011-02-16 16:27:41 -0800 | [diff] [blame] | 762 | * all admins if admin is null. If the password is expired, this will return the time since |
| 763 | * the password expired as a negative number. If admin is null, then a composite of all |
| 764 | * expiration timeouts is returned - which will be the minimum of all timeouts. |
Jim Miller | a4e28d1 | 2010-11-08 16:15:47 -0800 | [diff] [blame] | 765 | * |
| 766 | * @param admin The name of the admin component to check, or null to aggregate all admins. |
| 767 | * @return The password expiration time, in ms. |
| 768 | */ |
| 769 | public long getPasswordExpiration(ComponentName admin) { |
| 770 | if (mService != null) { |
| 771 | try { |
| 772 | return mService.getPasswordExpiration(admin); |
| 773 | } catch (RemoteException e) { |
| 774 | Log.w(TAG, "Failed talking with device policy service", e); |
| 775 | } |
| 776 | } |
| 777 | return 0; |
| 778 | } |
| 779 | |
| 780 | /** |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 781 | * Retrieve the current password history length for all admins |
| 782 | * or a particular one. |
| 783 | * @param admin The name of the admin component to check, or null to aggregate |
| 784 | * all admins. |
| 785 | * @return The length of the password history |
| 786 | */ |
| 787 | public int getPasswordHistoryLength(ComponentName admin) { |
| 788 | if (mService != null) { |
| 789 | try { |
| 790 | return mService.getPasswordHistoryLength(admin); |
| 791 | } catch (RemoteException e) { |
| 792 | Log.w(TAG, "Failed talking with device policy service", e); |
| 793 | } |
| 794 | } |
| 795 | return 0; |
| 796 | } |
| 797 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 798 | /** |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 799 | * Return the maximum password length that the device supports for a |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 800 | * particular password quality. |
Dianne Hackborn | 364f6e3 | 2010-01-29 17:38:20 -0800 | [diff] [blame] | 801 | * @param quality The quality being interrogated. |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 802 | * @return Returns the maximum length that the user can enter. |
| 803 | */ |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 804 | public int getPasswordMaximumLength(int quality) { |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 805 | // Kind-of arbitrary. |
| 806 | return 16; |
| 807 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 808 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 809 | /** |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 810 | * Determine whether the current password the user has set is sufficient |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 811 | * to meet the policy requirements (quality, minimum length) that have been |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 812 | * requested. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 813 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 814 | * <p>The calling device admin must have requested |
| 815 | * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call |
| 816 | * this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 817 | * |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 818 | * @return Returns true if the password meets the current requirements, |
| 819 | * else false. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 820 | */ |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 821 | public boolean isActivePasswordSufficient() { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 822 | if (mService != null) { |
| 823 | try { |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 824 | return mService.isActivePasswordSufficient(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 825 | } catch (RemoteException e) { |
| 826 | Log.w(TAG, "Failed talking with device policy service", e); |
| 827 | } |
| 828 | } |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 829 | return false; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 830 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 831 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 832 | /** |
| 833 | * Retrieve the number of times the user has failed at entering a |
| 834 | * password since that last successful password entry. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 835 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 836 | * <p>The calling device admin must have requested |
| 837 | * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to be able to call |
| 838 | * this method; if it has not, a security exception will be thrown. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 839 | */ |
| 840 | public int getCurrentFailedPasswordAttempts() { |
| 841 | if (mService != null) { |
| 842 | try { |
| 843 | return mService.getCurrentFailedPasswordAttempts(); |
| 844 | } catch (RemoteException e) { |
| 845 | Log.w(TAG, "Failed talking with device policy service", e); |
| 846 | } |
| 847 | } |
| 848 | return -1; |
| 849 | } |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 850 | |
| 851 | /** |
Andrew Stadler | 88209d1 | 2010-02-08 22:59:36 -0800 | [diff] [blame] | 852 | * Setting this to a value greater than zero enables a built-in policy |
| 853 | * that will perform a device wipe after too many incorrect |
| 854 | * device-unlock passwords have been entered. This built-in policy combines |
| 855 | * watching for failed passwords and wiping the device, and requires |
| 856 | * that you request both {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} and |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 857 | * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}}. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 858 | * |
Andrew Stadler | 88209d1 | 2010-02-08 22:59:36 -0800 | [diff] [blame] | 859 | * <p>To implement any other policy (e.g. wiping data for a particular |
| 860 | * application only, erasing or revoking credentials, or reporting the |
| 861 | * failure to a server), you should implement |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 862 | * {@link DeviceAdminReceiver#onPasswordFailed(Context, android.content.Intent)} |
Andrew Stadler | 88209d1 | 2010-02-08 22:59:36 -0800 | [diff] [blame] | 863 | * instead. Do not use this API, because if the maximum count is reached, |
| 864 | * the device will be wiped immediately, and your callback will not be invoked. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 865 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 866 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 867 | * @param num The number of failed password attempts at which point the |
| 868 | * device will wipe its data. |
| 869 | */ |
| 870 | public void setMaximumFailedPasswordsForWipe(ComponentName admin, int num) { |
| 871 | if (mService != null) { |
| 872 | try { |
| 873 | mService.setMaximumFailedPasswordsForWipe(admin, num); |
| 874 | } catch (RemoteException e) { |
| 875 | Log.w(TAG, "Failed talking with device policy service", e); |
| 876 | } |
| 877 | } |
| 878 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 879 | |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 880 | /** |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 881 | * Retrieve the current maximum number of login attempts that are allowed |
| 882 | * before the device wipes itself, for all admins |
| 883 | * or a particular one. |
| 884 | * @param admin The name of the admin component to check, or null to aggregate |
| 885 | * all admins. |
| 886 | */ |
| 887 | public int getMaximumFailedPasswordsForWipe(ComponentName admin) { |
| 888 | if (mService != null) { |
| 889 | try { |
| 890 | return mService.getMaximumFailedPasswordsForWipe(admin); |
| 891 | } catch (RemoteException e) { |
| 892 | Log.w(TAG, "Failed talking with device policy service", e); |
| 893 | } |
| 894 | } |
| 895 | return 0; |
| 896 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 897 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 898 | /** |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 899 | * Flag for {@link #resetPassword}: don't allow other admins to change |
| 900 | * the password again until the user has entered it. |
| 901 | */ |
| 902 | public static final int RESET_PASSWORD_REQUIRE_ENTRY = 0x0001; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 903 | |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 904 | /** |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 905 | * Force a new device unlock password (the password needed to access the |
| 906 | * entire device, not for individual accounts) on the user. This takes |
| 907 | * effect immediately. |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 908 | * The given password must be sufficient for the |
| 909 | * current password quality and length constraints as returned by |
| 910 | * {@link #getPasswordQuality(ComponentName)} and |
| 911 | * {@link #getPasswordMinimumLength(ComponentName)}; if it does not meet |
| 912 | * these constraints, then it will be rejected and false returned. Note |
| 913 | * that the password may be a stronger quality (containing alphanumeric |
| 914 | * characters when the requested quality is only numeric), in which case |
| 915 | * the currently active quality will be increased to match. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 916 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 917 | * <p>The calling device admin must have requested |
| 918 | * {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD} to be able to call |
| 919 | * this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 920 | * |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 921 | * @param password The new password for the user. |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 922 | * @param flags May be 0 or {@link #RESET_PASSWORD_REQUIRE_ENTRY}. |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 923 | * @return Returns true if the password was applied, or false if it is |
| 924 | * not acceptable for the current constraints. |
| 925 | */ |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 926 | public boolean resetPassword(String password, int flags) { |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 927 | if (mService != null) { |
| 928 | try { |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 929 | return mService.resetPassword(password, flags); |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 930 | } catch (RemoteException e) { |
| 931 | Log.w(TAG, "Failed talking with device policy service", e); |
| 932 | } |
| 933 | } |
| 934 | return false; |
| 935 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 936 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 937 | /** |
| 938 | * Called by an application that is administering the device to set the |
| 939 | * maximum time for user activity until the device will lock. This limits |
| 940 | * the length that the user can set. It takes effect immediately. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 941 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 942 | * <p>The calling device admin must have requested |
Dianne Hackborn | 315ada7 | 2010-02-11 12:14:08 -0800 | [diff] [blame] | 943 | * {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} to be able to call |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 944 | * this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 945 | * |
Dianne Hackborn | ef6b22f | 2010-02-16 20:38:49 -0800 | [diff] [blame] | 946 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 947 | * @param timeMs The new desired maximum time to lock in milliseconds. |
| 948 | * A value of 0 means there is no restriction. |
| 949 | */ |
| 950 | public void setMaximumTimeToLock(ComponentName admin, long timeMs) { |
| 951 | if (mService != null) { |
| 952 | try { |
| 953 | mService.setMaximumTimeToLock(admin, timeMs); |
| 954 | } catch (RemoteException e) { |
| 955 | Log.w(TAG, "Failed talking with device policy service", e); |
| 956 | } |
| 957 | } |
| 958 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 959 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 960 | /** |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 961 | * Retrieve the current maximum time to unlock for all admins |
| 962 | * or a particular one. |
| 963 | * @param admin The name of the admin component to check, or null to aggregate |
| 964 | * all admins. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 965 | */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 966 | public long getMaximumTimeToLock(ComponentName admin) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 967 | if (mService != null) { |
| 968 | try { |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 969 | return mService.getMaximumTimeToLock(admin); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 970 | } catch (RemoteException e) { |
| 971 | Log.w(TAG, "Failed talking with device policy service", e); |
| 972 | } |
| 973 | } |
| 974 | return 0; |
| 975 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 976 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 977 | /** |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 978 | * Make the device lock immediately, as if the lock screen timeout has |
| 979 | * expired at the point of this call. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 980 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 981 | * <p>The calling device admin must have requested |
| 982 | * {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} to be able to call |
| 983 | * this method; if it has not, a security exception will be thrown. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 984 | */ |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 985 | public void lockNow() { |
| 986 | if (mService != null) { |
| 987 | try { |
| 988 | mService.lockNow(); |
| 989 | } catch (RemoteException e) { |
| 990 | Log.w(TAG, "Failed talking with device policy service", e); |
| 991 | } |
| 992 | } |
| 993 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 994 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 995 | /** |
Dianne Hackborn | 4249917 | 2010-10-15 18:45:07 -0700 | [diff] [blame] | 996 | * Flag for {@link #wipeData(int)}: also erase the device's external |
| 997 | * storage. |
| 998 | */ |
| 999 | public static final int WIPE_EXTERNAL_STORAGE = 0x0001; |
| 1000 | |
| 1001 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1002 | * Ask the user date be wiped. This will cause the device to reboot, |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 1003 | * erasing all user data while next booting up. External storage such |
| 1004 | * as SD cards will not be erased. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1005 | * |
Dianne Hackborn | 8aa2e89 | 2010-01-22 11:31:30 -0800 | [diff] [blame] | 1006 | * <p>The calling device admin must have requested |
| 1007 | * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to be able to call |
| 1008 | * this method; if it has not, a security exception will be thrown. |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1009 | * |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 1010 | * @param flags Bit mask of additional options: currently must be 0. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1011 | */ |
| 1012 | public void wipeData(int flags) { |
| 1013 | if (mService != null) { |
| 1014 | try { |
| 1015 | mService.wipeData(flags); |
| 1016 | } catch (RemoteException e) { |
| 1017 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1018 | } |
| 1019 | } |
| 1020 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1021 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1022 | /** |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 1023 | * Called by an application that is administering the device to set the |
| 1024 | * global proxy and exclusion list. |
| 1025 | * <p> |
| 1026 | * The calling device admin must have requested |
| 1027 | * {@link DeviceAdminInfo#USES_POLICY_SETS_GLOBAL_PROXY} to be able to call |
| 1028 | * this method; if it has not, a security exception will be thrown. |
| 1029 | * Only the first device admin can set the proxy. If a second admin attempts |
| 1030 | * to set the proxy, the {@link ComponentName} of the admin originally setting the |
| 1031 | * proxy will be returned. If successful in setting the proxy, null will |
| 1032 | * be returned. |
| 1033 | * The method can be called repeatedly by the device admin alrady setting the |
| 1034 | * proxy to update the proxy and exclusion list. |
| 1035 | * |
| 1036 | * @param admin Which {@link DeviceAdminReceiver} this request is associated |
| 1037 | * with. |
| 1038 | * @param proxySpec the global proxy desired. Must be an HTTP Proxy. |
| 1039 | * Pass Proxy.NO_PROXY to reset the proxy. |
| 1040 | * @param exclusionList a list of domains to be excluded from the global proxy. |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 1041 | * @return returns null if the proxy was successfully set, or a {@link ComponentName} |
| 1042 | * of the device admin that sets thew proxy otherwise. |
Andy Stadler | d267272 | 2011-02-16 10:53:33 -0800 | [diff] [blame] | 1043 | * @hide |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 1044 | */ |
| 1045 | public ComponentName setGlobalProxy(ComponentName admin, Proxy proxySpec, |
| 1046 | List<String> exclusionList ) { |
| 1047 | if (proxySpec == null) { |
| 1048 | throw new NullPointerException(); |
| 1049 | } |
| 1050 | if (mService != null) { |
| 1051 | try { |
| 1052 | String hostSpec; |
| 1053 | String exclSpec; |
| 1054 | if (proxySpec.equals(Proxy.NO_PROXY)) { |
| 1055 | hostSpec = null; |
| 1056 | exclSpec = null; |
| 1057 | } else { |
| 1058 | if (!proxySpec.type().equals(Proxy.Type.HTTP)) { |
| 1059 | throw new IllegalArgumentException(); |
| 1060 | } |
| 1061 | InetSocketAddress sa = (InetSocketAddress)proxySpec.address(); |
| 1062 | String hostName = sa.getHostName(); |
| 1063 | int port = sa.getPort(); |
| 1064 | StringBuilder hostBuilder = new StringBuilder(); |
| 1065 | hostSpec = hostBuilder.append(hostName) |
| 1066 | .append(":").append(Integer.toString(port)).toString(); |
| 1067 | if (exclusionList == null) { |
| 1068 | exclSpec = ""; |
| 1069 | } else { |
| 1070 | StringBuilder listBuilder = new StringBuilder(); |
| 1071 | boolean firstDomain = true; |
| 1072 | for (String exclDomain : exclusionList) { |
| 1073 | if (!firstDomain) { |
| 1074 | listBuilder = listBuilder.append(","); |
| 1075 | } else { |
| 1076 | firstDomain = false; |
| 1077 | } |
| 1078 | listBuilder = listBuilder.append(exclDomain.trim()); |
| 1079 | } |
| 1080 | exclSpec = listBuilder.toString(); |
| 1081 | } |
| 1082 | android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec); |
| 1083 | } |
| 1084 | return mService.setGlobalProxy(admin, hostSpec, exclSpec); |
| 1085 | } catch (RemoteException e) { |
| 1086 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1087 | } |
| 1088 | } |
| 1089 | return null; |
| 1090 | } |
| 1091 | |
| 1092 | /** |
| 1093 | * Returns the component name setting the global proxy. |
| 1094 | * @return ComponentName object of the device admin that set the global proxy, or |
| 1095 | * null if no admin has set the proxy. |
Andy Stadler | d267272 | 2011-02-16 10:53:33 -0800 | [diff] [blame] | 1096 | * @hide |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 1097 | */ |
| 1098 | public ComponentName getGlobalProxyAdmin() { |
| 1099 | if (mService != null) { |
| 1100 | try { |
| 1101 | return mService.getGlobalProxyAdmin(); |
| 1102 | } catch (RemoteException e) { |
| 1103 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1104 | } |
| 1105 | } |
| 1106 | return null; |
| 1107 | } |
| 1108 | |
| 1109 | /** |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1110 | * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1111 | * indicating that encryption is not supported. |
| 1112 | */ |
| 1113 | public static final int ENCRYPTION_STATUS_UNSUPPORTED = 0; |
| 1114 | |
| 1115 | /** |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1116 | * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1117 | * indicating that encryption is supported, but is not currently active. |
| 1118 | */ |
| 1119 | public static final int ENCRYPTION_STATUS_INACTIVE = 1; |
| 1120 | |
| 1121 | /** |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1122 | * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1123 | * indicating that encryption is not currently active, but is currently |
| 1124 | * being activated. This is only reported by devices that support |
| 1125 | * encryption of data and only when the storage is currently |
| 1126 | * undergoing a process of becoming encrypted. A device that must reboot and/or wipe data |
| 1127 | * to become encrypted will never return this value. |
| 1128 | */ |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1129 | public static final int ENCRYPTION_STATUS_ACTIVATING = 2; |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1130 | |
| 1131 | /** |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1132 | * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}: |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1133 | * indicating that encryption is active. |
| 1134 | */ |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1135 | public static final int ENCRYPTION_STATUS_ACTIVE = 3; |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1136 | |
| 1137 | /** |
| 1138 | * Activity action: begin the process of encrypting data on the device. This activity should |
| 1139 | * be launched after using {@link #setStorageEncryption} to request encryption be activated. |
| 1140 | * After resuming from this activity, use {@link #getStorageEncryption} |
| 1141 | * to check encryption status. However, on some devices this activity may never return, as |
| 1142 | * it may trigger a reboot and in some cases a complete data wipe of the device. |
| 1143 | */ |
| 1144 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1145 | public static final String ACTION_START_ENCRYPTION |
| 1146 | = "android.app.action.START_ENCRYPTION"; |
| 1147 | |
| 1148 | /** |
| 1149 | * Called by an application that is administering the device to |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1150 | * request that the storage system be encrypted. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1151 | * |
| 1152 | * <p>When multiple device administrators attempt to control device |
| 1153 | * encryption, the most secure, supported setting will always be |
| 1154 | * used. If any device administrator requests device encryption, |
| 1155 | * it will be enabled; Conversely, if a device administrator |
| 1156 | * attempts to disable device encryption while another |
| 1157 | * device administrator has enabled it, the call to disable will |
| 1158 | * fail (most commonly returning {@link #ENCRYPTION_STATUS_ACTIVE}). |
| 1159 | * |
| 1160 | * <p>This policy controls encryption of the secure (application data) storage area. Data |
Andy Stadler | 50c294f | 2011-03-07 19:13:42 -0800 | [diff] [blame] | 1161 | * written to other storage areas may or may not be encrypted, and this policy does not require |
| 1162 | * or control the encryption of any other storage areas. |
| 1163 | * There is one exception: If {@link android.os.Environment#isExternalStorageEmulated()} is |
| 1164 | * {@code true}, then the directory returned by |
| 1165 | * {@link android.os.Environment#getExternalStorageDirectory()} must be written to disk |
| 1166 | * within the encrypted storage area. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1167 | * |
| 1168 | * <p>Important Note: On some devices, it is possible to encrypt storage without requiring |
| 1169 | * the user to create a device PIN or Password. In this case, the storage is encrypted, but |
| 1170 | * the encryption key may not be fully secured. For maximum security, the administrator should |
| 1171 | * also require (and check for) a pattern, PIN, or password. |
| 1172 | * |
| 1173 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1174 | * @param encrypt true to request encryption, false to release any previous request |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1175 | * @return the new request status (for all active admins) - will be one of |
| 1176 | * {@link #ENCRYPTION_STATUS_UNSUPPORTED}, {@link #ENCRYPTION_STATUS_INACTIVE}, or |
| 1177 | * {@link #ENCRYPTION_STATUS_ACTIVE}. This is the value of the requests; Use |
| 1178 | * {@link #getStorageEncryptionStatus()} to query the actual device state. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1179 | */ |
| 1180 | public int setStorageEncryption(ComponentName admin, boolean encrypt) { |
| 1181 | if (mService != null) { |
| 1182 | try { |
| 1183 | return mService.setStorageEncryption(admin, encrypt); |
| 1184 | } catch (RemoteException e) { |
| 1185 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1186 | } |
| 1187 | } |
| 1188 | return ENCRYPTION_STATUS_UNSUPPORTED; |
| 1189 | } |
| 1190 | |
| 1191 | /** |
| 1192 | * Called by an application that is administering the device to |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1193 | * determine the requested setting for secure storage. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1194 | * |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1195 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. If null, |
| 1196 | * this will return the requested encryption setting as an aggregate of all active |
| 1197 | * administrators. |
| 1198 | * @return true if the admin(s) are requesting encryption, false if not. |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1199 | */ |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1200 | public boolean getStorageEncryption(ComponentName admin) { |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1201 | if (mService != null) { |
| 1202 | try { |
| 1203 | return mService.getStorageEncryption(admin); |
| 1204 | } catch (RemoteException e) { |
| 1205 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1206 | } |
| 1207 | } |
Andy Stadler | 22dbfda | 2011-01-17 12:47:31 -0800 | [diff] [blame] | 1208 | return false; |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * Called by an application that is administering the device to |
| 1213 | * determine the current encryption status of the device. |
| 1214 | * |
| 1215 | * Depending on the returned status code, the caller may proceed in different |
| 1216 | * ways. If the result is {@link #ENCRYPTION_STATUS_UNSUPPORTED}, the |
| 1217 | * storage system does not support encryption. If the |
| 1218 | * result is {@link #ENCRYPTION_STATUS_INACTIVE}, use {@link |
| 1219 | * #ACTION_START_ENCRYPTION} to begin the process of encrypting or decrypting the |
| 1220 | * storage. If the result is {@link #ENCRYPTION_STATUS_ACTIVATING} or |
| 1221 | * {@link #ENCRYPTION_STATUS_ACTIVE}, no further action is required. |
| 1222 | * |
| 1223 | * @return current status of encryption. The value will be one of |
| 1224 | * {@link #ENCRYPTION_STATUS_UNSUPPORTED}, {@link #ENCRYPTION_STATUS_INACTIVE}, |
| 1225 | * {@link #ENCRYPTION_STATUS_ACTIVATING}, or{@link #ENCRYPTION_STATUS_ACTIVE}. |
| 1226 | */ |
| 1227 | public int getStorageEncryptionStatus() { |
| 1228 | if (mService != null) { |
| 1229 | try { |
| 1230 | return mService.getStorageEncryptionStatus(); |
| 1231 | } catch (RemoteException e) { |
| 1232 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1233 | } |
| 1234 | } |
Andy Stadler | 7b0f8f0 | 2011-01-12 14:59:52 -0800 | [diff] [blame] | 1235 | return ENCRYPTION_STATUS_UNSUPPORTED; |
| 1236 | } |
| 1237 | |
| 1238 | /** |
Ben Komalo | 2447edd | 2011-05-09 16:05:33 -0700 | [diff] [blame] | 1239 | * Called by an application that is administering the device to disable all cameras |
| 1240 | * on the device. After setting this, no applications will be able to access any cameras |
| 1241 | * on the device. |
| 1242 | * |
| 1243 | * <p>The calling device admin must have requested |
| 1244 | * {@link DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA} to be able to call |
| 1245 | * this method; if it has not, a security exception will be thrown. |
| 1246 | * |
| 1247 | * @param admin Which {@link DeviceAdminReceiver} this request is associated with. |
| 1248 | * @param disabled Whether or not the camera should be disabled. |
| 1249 | */ |
| 1250 | public void setCameraDisabled(ComponentName admin, boolean disabled) { |
| 1251 | if (mService != null) { |
| 1252 | try { |
| 1253 | mService.setCameraDisabled(admin, disabled); |
| 1254 | } catch (RemoteException e) { |
| 1255 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1256 | } |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | /** |
| 1261 | * Determine whether or not the device's cameras have been disabled either by the current |
| 1262 | * admin, if specified, or all admins. |
| 1263 | * @param admin The name of the admin component to check, or null to check if any admins |
| 1264 | * have disabled the camera |
| 1265 | */ |
| 1266 | public boolean getCameraDisabled(ComponentName admin) { |
| 1267 | if (mService != null) { |
| 1268 | try { |
| 1269 | return mService.getCameraDisabled(admin); |
| 1270 | } catch (RemoteException e) { |
| 1271 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1272 | } |
| 1273 | } |
| 1274 | return false; |
| 1275 | } |
| 1276 | |
| 1277 | /** |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1278 | * @hide |
| 1279 | */ |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1280 | public void setActiveAdmin(ComponentName policyReceiver, boolean refreshing) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1281 | if (mService != null) { |
| 1282 | try { |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1283 | mService.setActiveAdmin(policyReceiver, refreshing); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1284 | } catch (RemoteException e) { |
| 1285 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1286 | } |
| 1287 | } |
| 1288 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1289 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1290 | /** |
Andy Stadler | c25f70a | 2010-12-08 15:56:45 -0800 | [diff] [blame] | 1291 | * Returns the DeviceAdminInfo as defined by the administrator's package info & meta-data |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1292 | * @hide |
| 1293 | */ |
Dianne Hackborn | d47c6ed | 2010-01-27 16:21:20 -0800 | [diff] [blame] | 1294 | public DeviceAdminInfo getAdminInfo(ComponentName cn) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1295 | ActivityInfo ai; |
| 1296 | try { |
| 1297 | ai = mContext.getPackageManager().getReceiverInfo(cn, |
| 1298 | PackageManager.GET_META_DATA); |
| 1299 | } catch (PackageManager.NameNotFoundException e) { |
| 1300 | Log.w(TAG, "Unable to retrieve device policy " + cn, e); |
| 1301 | return null; |
| 1302 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1303 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1304 | ResolveInfo ri = new ResolveInfo(); |
| 1305 | ri.activityInfo = ai; |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1306 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1307 | try { |
| 1308 | return new DeviceAdminInfo(mContext, ri); |
| 1309 | } catch (XmlPullParserException e) { |
| 1310 | Log.w(TAG, "Unable to parse device policy " + cn, e); |
| 1311 | return null; |
| 1312 | } catch (IOException e) { |
| 1313 | Log.w(TAG, "Unable to parse device policy " + cn, e); |
| 1314 | return null; |
| 1315 | } |
| 1316 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1317 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1318 | /** |
| 1319 | * @hide |
| 1320 | */ |
Dianne Hackborn | 8ea138c | 2010-01-26 18:01:04 -0800 | [diff] [blame] | 1321 | public void getRemoveWarning(ComponentName admin, RemoteCallback result) { |
| 1322 | if (mService != null) { |
| 1323 | try { |
| 1324 | mService.getRemoveWarning(admin, result); |
| 1325 | } catch (RemoteException e) { |
| 1326 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1327 | } |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | /** |
| 1332 | * @hide |
| 1333 | */ |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1334 | public void setActivePasswordState(int quality, int length, int letters, int uppercase, |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1335 | int lowercase, int numbers, int symbols, int nonletter) { |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1336 | if (mService != null) { |
| 1337 | try { |
Konstantin Lopyrev | a15dcfa | 2010-05-24 17:10:56 -0700 | [diff] [blame] | 1338 | mService.setActivePasswordState(quality, length, letters, uppercase, lowercase, |
Konstantin Lopyrev | c857740 | 2010-06-04 17:15:02 -0700 | [diff] [blame] | 1339 | numbers, symbols, nonletter); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1340 | } catch (RemoteException e) { |
| 1341 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1342 | } |
| 1343 | } |
| 1344 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1345 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1346 | /** |
| 1347 | * @hide |
| 1348 | */ |
| 1349 | public void reportFailedPasswordAttempt() { |
| 1350 | if (mService != null) { |
| 1351 | try { |
| 1352 | mService.reportFailedPasswordAttempt(); |
| 1353 | } catch (RemoteException e) { |
| 1354 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1355 | } |
| 1356 | } |
| 1357 | } |
Konstantin Lopyrev | 3255823 | 2010-05-20 16:18:05 -0700 | [diff] [blame] | 1358 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1359 | /** |
| 1360 | * @hide |
| 1361 | */ |
| 1362 | public void reportSuccessfulPasswordAttempt() { |
| 1363 | if (mService != null) { |
| 1364 | try { |
| 1365 | mService.reportSuccessfulPasswordAttempt(); |
| 1366 | } catch (RemoteException e) { |
| 1367 | Log.w(TAG, "Failed talking with device policy service", e); |
| 1368 | } |
| 1369 | } |
| 1370 | } |
Oscar Montemayor | 69238c6 | 2010-08-03 10:51:06 -0700 | [diff] [blame] | 1371 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1372 | } |