blob: 634adb0b8fc6c53d5173edfc01ff47aa2ca6f1dc [file] [log] [blame]
Dianne Hackbornd6847842010-01-12 18:14:19 -08001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Dianne Hackborn87bba1e2010-02-26 17:25:54 -080017package android.app.admin;
Dianne Hackbornd6847842010-01-12 18:14:19 -080018
19import org.xmlpull.v1.XmlPullParserException;
20
21import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
23import android.content.ComponentName;
24import android.content.Context;
25import android.content.pm.ActivityInfo;
26import android.content.pm.PackageManager;
27import android.content.pm.ResolveInfo;
28import android.os.Handler;
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080029import android.os.RemoteCallback;
Dianne Hackbornd6847842010-01-12 18:14:19 -080030import android.os.RemoteException;
31import android.os.ServiceManager;
32import android.util.Log;
33
34import java.io.IOException;
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -080035import java.util.List;
Dianne Hackbornd6847842010-01-12 18:14:19 -080036
37/**
38 * Public interface for managing policies enforced on a device. Most clients
Dianne Hackbornef6b22f2010-02-16 20:38:49 -080039 * of this class must have published a {@link DeviceAdminReceiver} that the user
Dianne Hackbornd6847842010-01-12 18:14:19 -080040 * has currently enabled.
41 */
42public class DevicePolicyManager {
43 private static String TAG = "DevicePolicyManager";
44 private static boolean DEBUG = false;
45 private static boolean localLOGV = DEBUG || android.util.Config.LOGV;
46
47 private final Context mContext;
Dianne Hackbornd6847842010-01-12 18:14:19 -080048 private final IDevicePolicyManager mService;
Konstantin Lopyrev32558232010-05-20 16:18:05 -070049
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080050 private final Handler mHandler;
Dianne Hackbornd6847842010-01-12 18:14:19 -080051
Dianne Hackborn21f1bd12010-02-19 17:02:21 -080052 private DevicePolicyManager(Context context, Handler handler) {
Dianne Hackbornd6847842010-01-12 18:14:19 -080053 mContext = context;
54 mHandler = handler;
55 mService = IDevicePolicyManager.Stub.asInterface(
56 ServiceManager.getService(Context.DEVICE_POLICY_SERVICE));
57 }
58
Dianne Hackborn87bba1e2010-02-26 17:25:54 -080059 /** @hide */
60 public static DevicePolicyManager create(Context context, Handler handler) {
Dianne Hackborn21f1bd12010-02-19 17:02:21 -080061 DevicePolicyManager me = new DevicePolicyManager(context, handler);
62 return me.mService != null ? me : null;
63 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -070064
Dianne Hackbornd6847842010-01-12 18:14:19 -080065 /**
66 * Activity action: ask the user to add a new device administrator to the system.
67 * The desired policy is the ComponentName of the policy in the
68 * {@link #EXTRA_DEVICE_ADMIN} extra field. This will invoke a UI to
69 * bring the user through adding the device administrator to the system (or
70 * allowing them to reject it).
Konstantin Lopyrev32558232010-05-20 16:18:05 -070071 *
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080072 * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION}
73 * field to provide the user with additional explanation (in addition
74 * to your component's description) about what is being added.
Dianne Hackbornd6847842010-01-12 18:14:19 -080075 */
76 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
77 public static final String ACTION_ADD_DEVICE_ADMIN
78 = "android.app.action.ADD_DEVICE_ADMIN";
Konstantin Lopyrev32558232010-05-20 16:18:05 -070079
Dianne Hackbornd6847842010-01-12 18:14:19 -080080 /**
81 * The ComponentName of the administrator component.
82 *
83 * @see #ACTION_ADD_DEVICE_ADMIN
84 */
85 public static final String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN";
Konstantin Lopyrev32558232010-05-20 16:18:05 -070086
Dianne Hackbornd6847842010-01-12 18:14:19 -080087 /**
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080088 * An optional CharSequence providing additional explanation for why the
89 * admin is being added.
90 *
91 * @see #ACTION_ADD_DEVICE_ADMIN
92 */
93 public static final String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION";
Konstantin Lopyrev32558232010-05-20 16:18:05 -070094
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080095 /**
Konstantin Lopyrev32558232010-05-20 16:18:05 -070096 * Activity action: have the user enter a new password. This activity should
97 * be launched after using {@link #setPasswordQuality(ComponentName, int)},
98 * or {@link #setPasswordMinimumLength(ComponentName, int)} to have the user
99 * enter a new password that meets the current requirements. You can use
100 * {@link #isActivePasswordSufficient()} to determine whether you need to
101 * have the user select a new password in order to meet the current
102 * constraints. Upon being resumed from this activity, you can check the new
103 * password characteristics to see if they are sufficient.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800104 */
105 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
106 public static final String ACTION_SET_NEW_PASSWORD
107 = "android.app.action.SET_NEW_PASSWORD";
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700108
Dianne Hackbornd6847842010-01-12 18:14:19 -0800109 /**
110 * Return true if the given administrator component is currently
111 * active (enabled) in the system.
112 */
113 public boolean isAdminActive(ComponentName who) {
114 if (mService != null) {
115 try {
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -0800116 return mService.isAdminActive(who);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800117 } catch (RemoteException e) {
118 Log.w(TAG, "Failed talking with device policy service", e);
119 }
120 }
121 return false;
122 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700123
Dianne Hackbornd6847842010-01-12 18:14:19 -0800124 /**
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -0800125 * Return a list of all currently active device administrator's component
126 * names. Note that if there are no administrators than null may be
127 * returned.
128 */
129 public List<ComponentName> getActiveAdmins() {
130 if (mService != null) {
131 try {
132 return mService.getActiveAdmins();
133 } catch (RemoteException e) {
134 Log.w(TAG, "Failed talking with device policy service", e);
135 }
136 }
137 return null;
138 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700139
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -0800140 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800141 * @hide
142 */
143 public boolean packageHasActiveAdmins(String packageName) {
144 if (mService != null) {
145 try {
146 return mService.packageHasActiveAdmins(packageName);
147 } catch (RemoteException e) {
148 Log.w(TAG, "Failed talking with device policy service", e);
149 }
150 }
151 return false;
152 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700153
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800154 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -0800155 * Remove a current administration component. This can only be called
156 * by the application that owns the administration component; if you
157 * try to remove someone else's component, a security exception will be
158 * thrown.
159 */
160 public void removeActiveAdmin(ComponentName who) {
161 if (mService != null) {
162 try {
163 mService.removeActiveAdmin(who);
164 } catch (RemoteException e) {
165 Log.w(TAG, "Failed talking with device policy service", e);
166 }
167 }
168 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700169
Dianne Hackbornd6847842010-01-12 18:14:19 -0800170 /**
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800171 * Constant for {@link #setPasswordQuality}: the policy has no requirements
172 * for the password. Note that quality constants are ordered so that higher
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800173 * values are more restrictive.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800174 */
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800175 public static final int PASSWORD_QUALITY_UNSPECIFIED = 0;
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700176
Dianne Hackbornd6847842010-01-12 18:14:19 -0800177 /**
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800178 * Constant for {@link #setPasswordQuality}: the policy requires some kind
179 * of password, but doesn't care what it is. Note that quality constants
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800180 * are ordered so that higher values are more restrictive.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800181 */
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800182 public static final int PASSWORD_QUALITY_SOMETHING = 0x10000;
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700183
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800184 /**
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800185 * Constant for {@link #setPasswordQuality}: the user must have entered a
186 * password containing at least numeric characters. Note that quality
187 * constants are ordered so that higher values are more restrictive.
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800188 */
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800189 public static final int PASSWORD_QUALITY_NUMERIC = 0x20000;
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700190
Dianne Hackbornd6847842010-01-12 18:14:19 -0800191 /**
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800192 * Constant for {@link #setPasswordQuality}: the user must have entered a
Dianne Hackborn85f2c9c2010-03-22 11:12:48 -0700193 * password containing at least alphabetic (or other symbol) characters.
194 * Note that quality constants are ordered so that higher values are more
195 * restrictive.
196 */
197 public static final int PASSWORD_QUALITY_ALPHABETIC = 0x40000;
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700198
Dianne Hackborn85f2c9c2010-03-22 11:12:48 -0700199 /**
200 * Constant for {@link #setPasswordQuality}: the user must have entered a
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800201 * password containing at least <em>both></em> numeric <em>and</em>
Dianne Hackborn85f2c9c2010-03-22 11:12:48 -0700202 * alphabetic (or other symbol) characters. Note that quality constants are
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800203 * ordered so that higher values are more restrictive.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800204 */
Dianne Hackborn85f2c9c2010-03-22 11:12:48 -0700205 public static final int PASSWORD_QUALITY_ALPHANUMERIC = 0x50000;
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700206
Dianne Hackbornd6847842010-01-12 18:14:19 -0800207 /**
Konstantin Lopyreva15dcfa2010-05-24 17:10:56 -0700208 * Constant for {@link #setPasswordQuality}: the user must have entered a
209 * password containing numeric <em>and</em> alphabetic characters,
210 * <em>and</em> special symbols. Note that quality constants are ordered so
211 * that higher values are more restrictive.
212 */
213 public static final int PASSWORD_QUALITY_COMPLEX = 0x60000;
214
215 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -0800216 * Called by an application that is administering the device to set the
217 * password restrictions it is imposing. After setting this, the user
218 * will not be able to enter a new password that is not at least as
219 * restrictive as what has been set. Note that the current password
220 * will remain until the user has set a new one, so the change does not
221 * take place immediately. To prompt the user for a new password, use
222 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700223 *
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800224 * <p>Quality constants are ordered so that higher values are more restrictive;
225 * thus the highest requested quality constant (between the policy set here,
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800226 * the user's preference, and any other considerations) is the one that
227 * is in effect.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700228 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800229 * <p>The calling device admin must have requested
230 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
231 * this method; if it has not, a security exception will be thrown.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700232 *
Dianne Hackbornef6b22f2010-02-16 20:38:49 -0800233 * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800234 * @param quality The new desired quality. One of
235 * {@link #PASSWORD_QUALITY_UNSPECIFIED}, {@link #PASSWORD_QUALITY_SOMETHING},
Dianne Hackborn85f2c9c2010-03-22 11:12:48 -0700236 * {@link #PASSWORD_QUALITY_NUMERIC}, {@link #PASSWORD_QUALITY_ALPHABETIC},
Konstantin Lopyreva15dcfa2010-05-24 17:10:56 -0700237 * {@link #PASSWORD_QUALITY_ALPHANUMERIC} or {@link #PASSWORD_QUALITY_COMPLEX}.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800238 */
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800239 public void setPasswordQuality(ComponentName admin, int quality) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800240 if (mService != null) {
241 try {
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800242 mService.setPasswordQuality(admin, quality);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800243 } catch (RemoteException e) {
244 Log.w(TAG, "Failed talking with device policy service", e);
245 }
246 }
247 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700248
Dianne Hackbornd6847842010-01-12 18:14:19 -0800249 /**
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800250 * Retrieve the current minimum password quality for all admins
Dianne Hackborn254cb442010-01-27 19:23:59 -0800251 * or a particular one.
252 * @param admin The name of the admin component to check, or null to aggregate
253 * all admins.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800254 */
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800255 public int getPasswordQuality(ComponentName admin) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800256 if (mService != null) {
257 try {
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800258 return mService.getPasswordQuality(admin);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800259 } catch (RemoteException e) {
260 Log.w(TAG, "Failed talking with device policy service", e);
261 }
262 }
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800263 return PASSWORD_QUALITY_UNSPECIFIED;
Dianne Hackbornd6847842010-01-12 18:14:19 -0800264 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700265
Dianne Hackbornd6847842010-01-12 18:14:19 -0800266 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -0800267 * Called by an application that is administering the device to set the
268 * minimum allowed password length. After setting this, the user
269 * will not be able to enter a new password that is not at least as
270 * restrictive as what has been set. Note that the current password
271 * will remain until the user has set a new one, so the change does not
272 * take place immediately. To prompt the user for a new password, use
273 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This
274 * constraint is only imposed if the administrator has also requested either
Konstantin Lopyreva15dcfa2010-05-24 17:10:56 -0700275 * {@link #PASSWORD_QUALITY_NUMERIC}, {@link #PASSWORD_QUALITY_ALPHABETIC}
276 * {@link #PASSWORD_QUALITY_ALPHANUMERIC}, or {@link #PASSWORD_QUALITY_COMPLEX}
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800277 * with {@link #setPasswordQuality}.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700278 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800279 * <p>The calling device admin must have requested
280 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
281 * this method; if it has not, a security exception will be thrown.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700282 *
Dianne Hackbornef6b22f2010-02-16 20:38:49 -0800283 * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800284 * @param length The new desired minimum password length. A value of 0
285 * means there is no restriction.
286 */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800287 public void setPasswordMinimumLength(ComponentName admin, int length) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800288 if (mService != null) {
289 try {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800290 mService.setPasswordMinimumLength(admin, length);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800291 } catch (RemoteException e) {
292 Log.w(TAG, "Failed talking with device policy service", e);
293 }
294 }
295 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700296
Dianne Hackbornd6847842010-01-12 18:14:19 -0800297 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800298 * Retrieve the current minimum password length for all admins
299 * or a particular one.
300 * @param admin The name of the admin component to check, or null to aggregate
301 * all admins.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800302 */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800303 public int getPasswordMinimumLength(ComponentName admin) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800304 if (mService != null) {
305 try {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800306 return mService.getPasswordMinimumLength(admin);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800307 } catch (RemoteException e) {
308 Log.w(TAG, "Failed talking with device policy service", e);
309 }
310 }
311 return 0;
312 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700313
Konstantin Lopyreva15dcfa2010-05-24 17:10:56 -0700314 /**
315 * Called by an application that is administering the device to set the
316 * minimum number of upper case letters required in the password. After
317 * setting this, the user will not be able to enter a new password that is
318 * not at least as restrictive as what has been set. Note that the current
319 * password will remain until the user has set a new one, so the change does
320 * not take place immediately. To prompt the user for a new password, use
321 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This
322 * constraint is only imposed if the administrator has also requested
323 * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}.
324 * <p>
325 * The calling device admin must have requested
326 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
327 * this method; if it has not, a security exception will be thrown.
328 *
329 * @param admin Which {@link DeviceAdminReceiver} this request is associated
330 * with.
331 * @param length The new desired minimum number of upper case letters
332 * required in the password. A value of 0 means there is no
333 * restriction.
334 */
335 public void setPasswordMinimumUpperCase(ComponentName admin, int length) {
336 if (mService != null) {
337 try {
338 mService.setPasswordMinimumUpperCase(admin, length);
339 } catch (RemoteException e) {
340 Log.w(TAG, "Failed talking with device policy service", e);
341 }
342 }
343 }
344
345 /**
346 * Retrieve the current number of upper case letters required in the
347 * password for all admins or a particular one.
348 *
349 * @param admin The name of the admin component to check, or null to
350 * aggregate all admins.
351 * @return The minimum number of upper case letters required in the
352 * password.
353 */
354 public int getPasswordMinimumUpperCase(ComponentName admin) {
355 if (mService != null) {
356 try {
357 return mService.getPasswordMinimumUpperCase(admin);
358 } catch (RemoteException e) {
359 Log.w(TAG, "Failed talking with device policy service", e);
360 }
361 }
362 return 0;
363 }
364
365 /**
366 * Called by an application that is administering the device to set the
367 * minimum number of lower case letters required in the password. After
368 * setting this, the user will not be able to enter a new password that is
369 * not at least as restrictive as what has been set. Note that the current
370 * password will remain until the user has set a new one, so the change does
371 * not take place immediately. To prompt the user for a new password, use
372 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This
373 * constraint is only imposed if the administrator has also requested
374 * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}.
375 * <p>
376 * The calling device admin must have requested
377 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
378 * this method; if it has not, a security exception will be thrown.
379 *
380 * @param admin Which {@link DeviceAdminReceiver} this request is associated
381 * with.
382 * @param length The new desired minimum number of lower case letters
383 * required in the password. A value of 0 means there is no
384 * restriction.
385 */
386 public void setPasswordMinimumLowerCase(ComponentName admin, int length) {
387 if (mService != null) {
388 try {
389 mService.setPasswordMinimumLowerCase(admin, length);
390 } catch (RemoteException e) {
391 Log.w(TAG, "Failed talking with device policy service", e);
392 }
393 }
394 }
395
396 /**
397 * Retrieve the current number of lower case letters required in the
398 * password for all admins or a particular one.
399 *
400 * @param admin The name of the admin component to check, or null to
401 * aggregate all admins.
402 * @return The minimum number of lower case letters required in the
403 * password.
404 */
405 public int getPasswordMinimumLowerCase(ComponentName admin) {
406 if (mService != null) {
407 try {
408 return mService.getPasswordMinimumLowerCase(admin);
409 } catch (RemoteException e) {
410 Log.w(TAG, "Failed talking with device policy service", e);
411 }
412 }
413 return 0;
414 }
415
416 /**
417 * Called by an application that is administering the device to set the
418 * minimum number of letters required in the password. After setting this,
419 * the user will not be able to enter a new password that is not at least as
420 * restrictive as what has been set. Note that the current password will
421 * remain until the user has set a new one, so the change does not take
422 * place immediately. To prompt the user for a new password, use
423 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This
424 * constraint is only imposed if the administrator has also requested
425 * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}.
426 * <p>
427 * The calling device admin must have requested
428 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
429 * this method; if it has not, a security exception will be thrown.
430 *
431 * @param admin Which {@link DeviceAdminReceiver} this request is associated
432 * with.
433 * @param length The new desired minimum number of letters required in the
434 * password. A value of 0 means there is no restriction.
435 */
436 public void setPasswordMinimumLetters(ComponentName admin, int length) {
437 if (mService != null) {
438 try {
439 mService.setPasswordMinimumLetters(admin, length);
440 } catch (RemoteException e) {
441 Log.w(TAG, "Failed talking with device policy service", e);
442 }
443 }
444 }
445
446 /**
447 * Retrieve the current number of letters required in the password for all
448 * admins or a particular one.
449 *
450 * @param admin The name of the admin component to check, or null to
451 * aggregate all admins.
452 * @return The minimum number of letters required in the password.
453 */
454 public int getPasswordMinimumLetters(ComponentName admin) {
455 if (mService != null) {
456 try {
457 return mService.getPasswordMinimumLetters(admin);
458 } catch (RemoteException e) {
459 Log.w(TAG, "Failed talking with device policy service", e);
460 }
461 }
462 return 0;
463 }
464
465 /**
466 * Called by an application that is administering the device to set the
467 * minimum number of numerical digits required in the password. After
468 * setting this, the user will not be able to enter a new password that is
469 * not at least as restrictive as what has been set. Note that the current
470 * password will remain until the user has set a new one, so the change does
471 * not take place immediately. To prompt the user for a new password, use
472 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This
473 * constraint is only imposed if the administrator has also requested
474 * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}.
475 * <p>
476 * The calling device admin must have requested
477 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
478 * this method; if it has not, a security exception will be thrown.
479 *
480 * @param admin Which {@link DeviceAdminReceiver} this request is associated
481 * with.
482 * @param length The new desired minimum number of numerical digits required
483 * in the password. A value of 0 means there is no restriction.
484 */
485 public void setPasswordMinimumNumeric(ComponentName admin, int length) {
486 if (mService != null) {
487 try {
488 mService.setPasswordMinimumNumeric(admin, length);
489 } catch (RemoteException e) {
490 Log.w(TAG, "Failed talking with device policy service", e);
491 }
492 }
493 }
494
495 /**
496 * Retrieve the current number of numerical digits required in the password
497 * for all admins or a particular one.
498 *
499 * @param admin The name of the admin component to check, or null to
500 * aggregate all admins.
501 * @return The minimum number of numerical digits required in the password.
502 */
503 public int getPasswordMinimumNumeric(ComponentName admin) {
504 if (mService != null) {
505 try {
506 return mService.getPasswordMinimumNumeric(admin);
507 } catch (RemoteException e) {
508 Log.w(TAG, "Failed talking with device policy service", e);
509 }
510 }
511 return 0;
512 }
513
514 /**
515 * Called by an application that is administering the device to set the
516 * minimum number of symbols required in the password. After setting this,
517 * the user will not be able to enter a new password that is not at least as
518 * restrictive as what has been set. Note that the current password will
519 * remain until the user has set a new one, so the change does not take
520 * place immediately. To prompt the user for a new password, use
521 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This
522 * constraint is only imposed if the administrator has also requested
523 * {@link #PASSWORD_QUALITY_COMPLEX} with {@link #setPasswordQuality}.
524 * <p>
525 * The calling device admin must have requested
526 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
527 * this method; if it has not, a security exception will be thrown.
528 *
529 * @param admin Which {@link DeviceAdminReceiver} this request is associated
530 * with.
531 * @param length The new desired minimum number of symbols required in the
532 * password. A value of 0 means there is no restriction.
533 */
534 public void setPasswordMinimumSymbols(ComponentName admin, int length) {
535 if (mService != null) {
536 try {
537 mService.setPasswordMinimumSymbols(admin, length);
538 } catch (RemoteException e) {
539 Log.w(TAG, "Failed talking with device policy service", e);
540 }
541 }
542 }
543
544 /**
545 * Retrieve the current number of symbols required in the password for all
546 * admins or a particular one.
547 *
548 * @param admin The name of the admin component to check, or null to
549 * aggregate all admins.
550 * @return The minimum number of symbols required in the password.
551 */
552 public int getPasswordMinimumSymbols(ComponentName admin) {
553 if (mService != null) {
554 try {
555 return mService.getPasswordMinimumSymbols(admin);
556 } catch (RemoteException e) {
557 Log.w(TAG, "Failed talking with device policy service", e);
558 }
559 }
560 return 0;
561 }
562
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700563 /**
564 * Called by an application that is administering the device to set the length
565 * of the password history. After setting this, the user will not be able to
566 * enter a new password that is the same as any password in the history. Note
567 * that the current password will remain until the user has set a new one, so
568 * the change does not take place immediately. To prompt the user for a new
569 * password, use {@link #ACTION_SET_NEW_PASSWORD} after setting this value.
570 * This constraint is only imposed if the administrator has also requested
571 * either {@link #PASSWORD_QUALITY_NUMERIC},
572 * {@link #PASSWORD_QUALITY_ALPHABETIC}, or
573 * {@link #PASSWORD_QUALITY_ALPHANUMERIC} with {@link #setPasswordQuality}.
574 *
575 * <p>
576 * The calling device admin must have requested
577 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this
578 * method; if it has not, a security exception will be thrown.
579 *
580 * @param admin Which {@link DeviceAdminReceiver} this request is associated
581 * with.
582 * @param length The new desired length of password history. A value of 0
583 * means there is no restriction.
584 */
585 public void setPasswordHistoryLength(ComponentName admin, int length) {
586 if (mService != null) {
587 try {
588 mService.setPasswordHistoryLength(admin, length);
589 } catch (RemoteException e) {
590 Log.w(TAG, "Failed talking with device policy service", e);
591 }
592 }
593 }
594
595 /**
596 * Retrieve the current password history length for all admins
597 * or a particular one.
598 * @param admin The name of the admin component to check, or null to aggregate
599 * all admins.
600 * @return The length of the password history
601 */
602 public int getPasswordHistoryLength(ComponentName admin) {
603 if (mService != null) {
604 try {
605 return mService.getPasswordHistoryLength(admin);
606 } catch (RemoteException e) {
607 Log.w(TAG, "Failed talking with device policy service", e);
608 }
609 }
610 return 0;
611 }
612
Dianne Hackbornd6847842010-01-12 18:14:19 -0800613 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800614 * Return the maximum password length that the device supports for a
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800615 * particular password quality.
Dianne Hackborn364f6e32010-01-29 17:38:20 -0800616 * @param quality The quality being interrogated.
Dianne Hackborn254cb442010-01-27 19:23:59 -0800617 * @return Returns the maximum length that the user can enter.
618 */
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800619 public int getPasswordMaximumLength(int quality) {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800620 // Kind-of arbitrary.
621 return 16;
622 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700623
Dianne Hackborn254cb442010-01-27 19:23:59 -0800624 /**
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800625 * Determine whether the current password the user has set is sufficient
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800626 * to meet the policy requirements (quality, minimum length) that have been
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800627 * requested.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700628 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800629 * <p>The calling device admin must have requested
630 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
631 * this method; if it has not, a security exception will be thrown.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700632 *
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800633 * @return Returns true if the password meets the current requirements,
634 * else false.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800635 */
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800636 public boolean isActivePasswordSufficient() {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800637 if (mService != null) {
638 try {
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800639 return mService.isActivePasswordSufficient();
Dianne Hackbornd6847842010-01-12 18:14:19 -0800640 } catch (RemoteException e) {
641 Log.w(TAG, "Failed talking with device policy service", e);
642 }
643 }
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800644 return false;
Dianne Hackbornd6847842010-01-12 18:14:19 -0800645 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700646
Dianne Hackbornd6847842010-01-12 18:14:19 -0800647 /**
648 * Retrieve the number of times the user has failed at entering a
649 * password since that last successful password entry.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700650 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800651 * <p>The calling device admin must have requested
652 * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to be able to call
653 * this method; if it has not, a security exception will be thrown.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800654 */
655 public int getCurrentFailedPasswordAttempts() {
656 if (mService != null) {
657 try {
658 return mService.getCurrentFailedPasswordAttempts();
659 } catch (RemoteException e) {
660 Log.w(TAG, "Failed talking with device policy service", e);
661 }
662 }
663 return -1;
664 }
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800665
666 /**
Andrew Stadler88209d12010-02-08 22:59:36 -0800667 * Setting this to a value greater than zero enables a built-in policy
668 * that will perform a device wipe after too many incorrect
669 * device-unlock passwords have been entered. This built-in policy combines
670 * watching for failed passwords and wiping the device, and requires
671 * that you request both {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} and
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800672 * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}}.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700673 *
Andrew Stadler88209d12010-02-08 22:59:36 -0800674 * <p>To implement any other policy (e.g. wiping data for a particular
675 * application only, erasing or revoking credentials, or reporting the
676 * failure to a server), you should implement
Dianne Hackbornef6b22f2010-02-16 20:38:49 -0800677 * {@link DeviceAdminReceiver#onPasswordFailed(Context, android.content.Intent)}
Andrew Stadler88209d12010-02-08 22:59:36 -0800678 * instead. Do not use this API, because if the maximum count is reached,
679 * the device will be wiped immediately, and your callback will not be invoked.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700680 *
Dianne Hackbornef6b22f2010-02-16 20:38:49 -0800681 * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800682 * @param num The number of failed password attempts at which point the
683 * device will wipe its data.
684 */
685 public void setMaximumFailedPasswordsForWipe(ComponentName admin, int num) {
686 if (mService != null) {
687 try {
688 mService.setMaximumFailedPasswordsForWipe(admin, num);
689 } catch (RemoteException e) {
690 Log.w(TAG, "Failed talking with device policy service", e);
691 }
692 }
693 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700694
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800695 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800696 * Retrieve the current maximum number of login attempts that are allowed
697 * before the device wipes itself, for all admins
698 * or a particular one.
699 * @param admin The name of the admin component to check, or null to aggregate
700 * all admins.
701 */
702 public int getMaximumFailedPasswordsForWipe(ComponentName admin) {
703 if (mService != null) {
704 try {
705 return mService.getMaximumFailedPasswordsForWipe(admin);
706 } catch (RemoteException e) {
707 Log.w(TAG, "Failed talking with device policy service", e);
708 }
709 }
710 return 0;
711 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700712
Dianne Hackborn254cb442010-01-27 19:23:59 -0800713 /**
Dianne Hackborn87bba1e2010-02-26 17:25:54 -0800714 * Flag for {@link #resetPassword}: don't allow other admins to change
715 * the password again until the user has entered it.
716 */
717 public static final int RESET_PASSWORD_REQUIRE_ENTRY = 0x0001;
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700718
Dianne Hackborn87bba1e2010-02-26 17:25:54 -0800719 /**
Dianne Hackbornef6b22f2010-02-16 20:38:49 -0800720 * Force a new device unlock password (the password needed to access the
721 * entire device, not for individual accounts) on the user. This takes
722 * effect immediately.
Dianne Hackborn9327f4f2010-01-29 10:38:29 -0800723 * The given password must be sufficient for the
724 * current password quality and length constraints as returned by
725 * {@link #getPasswordQuality(ComponentName)} and
726 * {@link #getPasswordMinimumLength(ComponentName)}; if it does not meet
727 * these constraints, then it will be rejected and false returned. Note
728 * that the password may be a stronger quality (containing alphanumeric
729 * characters when the requested quality is only numeric), in which case
730 * the currently active quality will be increased to match.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700731 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800732 * <p>The calling device admin must have requested
733 * {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD} to be able to call
734 * this method; if it has not, a security exception will be thrown.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700735 *
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800736 * @param password The new password for the user.
Dianne Hackborn87bba1e2010-02-26 17:25:54 -0800737 * @param flags May be 0 or {@link #RESET_PASSWORD_REQUIRE_ENTRY}.
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800738 * @return Returns true if the password was applied, or false if it is
739 * not acceptable for the current constraints.
740 */
Dianne Hackborn87bba1e2010-02-26 17:25:54 -0800741 public boolean resetPassword(String password, int flags) {
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800742 if (mService != null) {
743 try {
Dianne Hackborn87bba1e2010-02-26 17:25:54 -0800744 return mService.resetPassword(password, flags);
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800745 } catch (RemoteException e) {
746 Log.w(TAG, "Failed talking with device policy service", e);
747 }
748 }
749 return false;
750 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700751
Dianne Hackbornd6847842010-01-12 18:14:19 -0800752 /**
753 * Called by an application that is administering the device to set the
754 * maximum time for user activity until the device will lock. This limits
755 * the length that the user can set. It takes effect immediately.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700756 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800757 * <p>The calling device admin must have requested
Dianne Hackborn315ada72010-02-11 12:14:08 -0800758 * {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} to be able to call
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800759 * this method; if it has not, a security exception will be thrown.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700760 *
Dianne Hackbornef6b22f2010-02-16 20:38:49 -0800761 * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800762 * @param timeMs The new desired maximum time to lock in milliseconds.
763 * A value of 0 means there is no restriction.
764 */
765 public void setMaximumTimeToLock(ComponentName admin, long timeMs) {
766 if (mService != null) {
767 try {
768 mService.setMaximumTimeToLock(admin, timeMs);
769 } catch (RemoteException e) {
770 Log.w(TAG, "Failed talking with device policy service", e);
771 }
772 }
773 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700774
Dianne Hackbornd6847842010-01-12 18:14:19 -0800775 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800776 * Retrieve the current maximum time to unlock for all admins
777 * or a particular one.
778 * @param admin The name of the admin component to check, or null to aggregate
779 * all admins.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800780 */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800781 public long getMaximumTimeToLock(ComponentName admin) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800782 if (mService != null) {
783 try {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800784 return mService.getMaximumTimeToLock(admin);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800785 } catch (RemoteException e) {
786 Log.w(TAG, "Failed talking with device policy service", e);
787 }
788 }
789 return 0;
790 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700791
Dianne Hackbornd6847842010-01-12 18:14:19 -0800792 /**
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800793 * Make the device lock immediately, as if the lock screen timeout has
794 * expired at the point of this call.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700795 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800796 * <p>The calling device admin must have requested
797 * {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} to be able to call
798 * this method; if it has not, a security exception will be thrown.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800799 */
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800800 public void lockNow() {
801 if (mService != null) {
802 try {
803 mService.lockNow();
804 } catch (RemoteException e) {
805 Log.w(TAG, "Failed talking with device policy service", e);
806 }
807 }
808 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700809
Dianne Hackbornd6847842010-01-12 18:14:19 -0800810 /**
811 * Ask the user date be wiped. This will cause the device to reboot,
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800812 * erasing all user data while next booting up. External storage such
813 * as SD cards will not be erased.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700814 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800815 * <p>The calling device admin must have requested
816 * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to be able to call
817 * this method; if it has not, a security exception will be thrown.
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700818 *
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800819 * @param flags Bit mask of additional options: currently must be 0.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800820 */
821 public void wipeData(int flags) {
822 if (mService != null) {
823 try {
824 mService.wipeData(flags);
825 } catch (RemoteException e) {
826 Log.w(TAG, "Failed talking with device policy service", e);
827 }
828 }
829 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700830
Dianne Hackbornd6847842010-01-12 18:14:19 -0800831 /**
832 * @hide
833 */
834 public void setActiveAdmin(ComponentName policyReceiver) {
835 if (mService != null) {
836 try {
837 mService.setActiveAdmin(policyReceiver);
838 } catch (RemoteException e) {
839 Log.w(TAG, "Failed talking with device policy service", e);
840 }
841 }
842 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700843
Dianne Hackbornd6847842010-01-12 18:14:19 -0800844 /**
845 * @hide
846 */
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -0800847 public DeviceAdminInfo getAdminInfo(ComponentName cn) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800848 ActivityInfo ai;
849 try {
850 ai = mContext.getPackageManager().getReceiverInfo(cn,
851 PackageManager.GET_META_DATA);
852 } catch (PackageManager.NameNotFoundException e) {
853 Log.w(TAG, "Unable to retrieve device policy " + cn, e);
854 return null;
855 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700856
Dianne Hackbornd6847842010-01-12 18:14:19 -0800857 ResolveInfo ri = new ResolveInfo();
858 ri.activityInfo = ai;
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700859
Dianne Hackbornd6847842010-01-12 18:14:19 -0800860 try {
861 return new DeviceAdminInfo(mContext, ri);
862 } catch (XmlPullParserException e) {
863 Log.w(TAG, "Unable to parse device policy " + cn, e);
864 return null;
865 } catch (IOException e) {
866 Log.w(TAG, "Unable to parse device policy " + cn, e);
867 return null;
868 }
869 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700870
Dianne Hackbornd6847842010-01-12 18:14:19 -0800871 /**
872 * @hide
873 */
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800874 public void getRemoveWarning(ComponentName admin, RemoteCallback result) {
875 if (mService != null) {
876 try {
877 mService.getRemoveWarning(admin, result);
878 } catch (RemoteException e) {
879 Log.w(TAG, "Failed talking with device policy service", e);
880 }
881 }
882 }
883
884 /**
885 * @hide
886 */
Konstantin Lopyreva15dcfa2010-05-24 17:10:56 -0700887 public void setActivePasswordState(int quality, int length, int letters, int uppercase,
888 int lowercase, int numbers, int symbols) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800889 if (mService != null) {
890 try {
Konstantin Lopyreva15dcfa2010-05-24 17:10:56 -0700891 mService.setActivePasswordState(quality, length, letters, uppercase, lowercase,
892 numbers, symbols);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800893 } catch (RemoteException e) {
894 Log.w(TAG, "Failed talking with device policy service", e);
895 }
896 }
897 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700898
Dianne Hackbornd6847842010-01-12 18:14:19 -0800899 /**
900 * @hide
901 */
902 public void reportFailedPasswordAttempt() {
903 if (mService != null) {
904 try {
905 mService.reportFailedPasswordAttempt();
906 } catch (RemoteException e) {
907 Log.w(TAG, "Failed talking with device policy service", e);
908 }
909 }
910 }
Konstantin Lopyrev32558232010-05-20 16:18:05 -0700911
Dianne Hackbornd6847842010-01-12 18:14:19 -0800912 /**
913 * @hide
914 */
915 public void reportSuccessfulPasswordAttempt() {
916 if (mService != null) {
917 try {
918 mService.reportSuccessfulPasswordAttempt();
919 } catch (RemoteException e) {
920 Log.w(TAG, "Failed talking with device policy service", e);
921 }
922 }
923 }
924}