blob: 779db3ae22753611530ccf93722f823921c229d1 [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
17package android.app;
18
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
39 * of this class must have published a {@link DeviceAdmin} that the user
40 * 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;
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080049
50 private final Handler mHandler;
Dianne Hackbornd6847842010-01-12 18:14:19 -080051
52 /*package*/ DevicePolicyManager(Context context, Handler handler) {
53 mContext = context;
54 mHandler = handler;
55 mService = IDevicePolicyManager.Stub.asInterface(
56 ServiceManager.getService(Context.DEVICE_POLICY_SERVICE));
57 }
58
59 /**
60 * Activity action: ask the user to add a new device administrator to the system.
61 * The desired policy is the ComponentName of the policy in the
62 * {@link #EXTRA_DEVICE_ADMIN} extra field. This will invoke a UI to
63 * bring the user through adding the device administrator to the system (or
64 * allowing them to reject it).
65 *
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080066 * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION}
67 * field to provide the user with additional explanation (in addition
68 * to your component's description) about what is being added.
Dianne Hackbornd6847842010-01-12 18:14:19 -080069 */
70 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
71 public static final String ACTION_ADD_DEVICE_ADMIN
72 = "android.app.action.ADD_DEVICE_ADMIN";
73
74 /**
75 * The ComponentName of the administrator component.
76 *
77 * @see #ACTION_ADD_DEVICE_ADMIN
78 */
79 public static final String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN";
80
81 /**
Dianne Hackborn8ea138c2010-01-26 18:01:04 -080082 * An optional CharSequence providing additional explanation for why the
83 * admin is being added.
84 *
85 * @see #ACTION_ADD_DEVICE_ADMIN
86 */
87 public static final String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION";
88
89 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -080090 * Activity action: have the user enter a new password. This activity
91 * should be launched after using {@link #setPasswordMode(ComponentName, int)}
Dianne Hackborn254cb442010-01-27 19:23:59 -080092 * or {@link #setPasswordMinimumLength(ComponentName, int)} to have the
Dianne Hackborndf83afa2010-01-20 13:37:26 -080093 * user enter a new password that meets the current requirements. You can
94 * use {@link #isActivePasswordSufficient()} to determine whether you need
95 * to have the user select a new password in order to meet the current
96 * constraints. Upon being resumed from this activity,
Dianne Hackbornd6847842010-01-12 18:14:19 -080097 * you can check the new password characteristics to see if they are
98 * sufficient.
99 */
100 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
101 public static final String ACTION_SET_NEW_PASSWORD
102 = "android.app.action.SET_NEW_PASSWORD";
103
104 /**
105 * Return true if the given administrator component is currently
106 * active (enabled) in the system.
107 */
108 public boolean isAdminActive(ComponentName who) {
109 if (mService != null) {
110 try {
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -0800111 return mService.isAdminActive(who);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800112 } catch (RemoteException e) {
113 Log.w(TAG, "Failed talking with device policy service", e);
114 }
115 }
116 return false;
117 }
118
119 /**
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -0800120 * Return a list of all currently active device administrator's component
121 * names. Note that if there are no administrators than null may be
122 * returned.
123 */
124 public List<ComponentName> getActiveAdmins() {
125 if (mService != null) {
126 try {
127 return mService.getActiveAdmins();
128 } catch (RemoteException e) {
129 Log.w(TAG, "Failed talking with device policy service", e);
130 }
131 }
132 return null;
133 }
134
135 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -0800136 * Remove a current administration component. This can only be called
137 * by the application that owns the administration component; if you
138 * try to remove someone else's component, a security exception will be
139 * thrown.
140 */
141 public void removeActiveAdmin(ComponentName who) {
142 if (mService != null) {
143 try {
144 mService.removeActiveAdmin(who);
145 } catch (RemoteException e) {
146 Log.w(TAG, "Failed talking with device policy service", e);
147 }
148 }
149 }
150
151 /**
152 * Constant for {@link #setPasswordMode}: the policy has no requirements
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800153 * for the password. Note that mode constants are ordered so that higher
154 * values are more restrictive.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800155 */
156 public static final int PASSWORD_MODE_UNSPECIFIED = 0;
157
158 /**
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800159 * Constant for {@link #setPasswordMode}: the policy requires some kind
160 * of password, but doesn't care what it is. Note that mode constants
161 * are ordered so that higher values are more restrictive.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800162 */
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800163 public static final int PASSWORD_MODE_SOMETHING = 1000;
164
165 /**
166 * Constant for {@link #setPasswordMode}: the user must have at least a
167 * numeric password. Note that mode constants are ordered so that higher
168 * values are more restrictive.
169 */
170 public static final int PASSWORD_MODE_NUMERIC = 2000;
Dianne Hackbornd6847842010-01-12 18:14:19 -0800171
172 /**
173 * Constant for {@link #setPasswordMode}: the user must have at least an
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800174 * alphanumeric password. Note that mode constants are ordered so that higher
175 * values are more restrictive.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800176 */
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800177 public static final int PASSWORD_MODE_ALPHANUMERIC = 3000;
Dianne Hackbornd6847842010-01-12 18:14:19 -0800178
179 /**
180 * Called by an application that is administering the device to set the
181 * password restrictions it is imposing. After setting this, the user
182 * will not be able to enter a new password that is not at least as
183 * restrictive as what has been set. Note that the current password
184 * will remain until the user has set a new one, so the change does not
185 * take place immediately. To prompt the user for a new password, use
186 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value.
187 *
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800188 * <p>Mode constants are ordered so that higher values are more restrictive;
189 * thus the highest requested mode constant (between the policy set here,
190 * the user's preference, and any other considerations) is the one that
191 * is in effect.
192 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800193 * <p>The calling device admin must have requested
194 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
195 * this method; if it has not, a security exception will be thrown.
196 *
Dianne Hackbornd6847842010-01-12 18:14:19 -0800197 * @param admin Which {@link DeviceAdmin} this request is associated with.
198 * @param mode The new desired mode. One of
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800199 * {@link #PASSWORD_MODE_UNSPECIFIED}, {@link #PASSWORD_MODE_SOMETHING},
200 * {@link #PASSWORD_MODE_NUMERIC}, or {@link #PASSWORD_MODE_ALPHANUMERIC}.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800201 */
202 public void setPasswordMode(ComponentName admin, int mode) {
203 if (mService != null) {
204 try {
205 mService.setPasswordMode(admin, mode);
206 } catch (RemoteException e) {
207 Log.w(TAG, "Failed talking with device policy service", e);
208 }
209 }
210 }
211
212 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800213 * Retrieve the current minimum password mode for all admins
214 * or a particular one.
215 * @param admin The name of the admin component to check, or null to aggregate
216 * all admins.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800217 */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800218 public int getPasswordMode(ComponentName admin) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800219 if (mService != null) {
220 try {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800221 return mService.getPasswordMode(admin);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800222 } catch (RemoteException e) {
223 Log.w(TAG, "Failed talking with device policy service", e);
224 }
225 }
226 return PASSWORD_MODE_UNSPECIFIED;
227 }
228
229 /**
Dianne Hackbornd6847842010-01-12 18:14:19 -0800230 * Called by an application that is administering the device to set the
231 * minimum allowed password length. After setting this, the user
232 * will not be able to enter a new password that is not at least as
233 * restrictive as what has been set. Note that the current password
234 * will remain until the user has set a new one, so the change does not
235 * take place immediately. To prompt the user for a new password, use
236 * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. This
237 * constraint is only imposed if the administrator has also requested either
238 * {@link #PASSWORD_MODE_NUMERIC} or {@link #PASSWORD_MODE_ALPHANUMERIC}
239 * with {@link #setPasswordMode}.
240 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800241 * <p>The calling device admin must have requested
242 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
243 * this method; if it has not, a security exception will be thrown.
244 *
Dianne Hackbornd6847842010-01-12 18:14:19 -0800245 * @param admin Which {@link DeviceAdmin} this request is associated with.
246 * @param length The new desired minimum password length. A value of 0
247 * means there is no restriction.
248 */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800249 public void setPasswordMinimumLength(ComponentName admin, int length) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800250 if (mService != null) {
251 try {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800252 mService.setPasswordMinimumLength(admin, length);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800253 } catch (RemoteException e) {
254 Log.w(TAG, "Failed talking with device policy service", e);
255 }
256 }
257 }
258
259 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800260 * Retrieve the current minimum password length for all admins
261 * or a particular one.
262 * @param admin The name of the admin component to check, or null to aggregate
263 * all admins.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800264 */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800265 public int getPasswordMinimumLength(ComponentName admin) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800266 if (mService != null) {
267 try {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800268 return mService.getPasswordMinimumLength(admin);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800269 } catch (RemoteException e) {
270 Log.w(TAG, "Failed talking with device policy service", e);
271 }
272 }
273 return 0;
274 }
275
276 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800277 * Return the maximum password length that the device supports for a
278 * particular password mode.
279 * @param mode The mode being interrogated.
280 * @return Returns the maximum length that the user can enter.
281 */
282 public int getPasswordMaximumLength(int mode) {
283 // Kind-of arbitrary.
284 return 16;
285 }
286
287 /**
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800288 * Determine whether the current password the user has set is sufficient
289 * to meet the policy requirements (mode, minimum length) that have been
290 * requested.
291 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800292 * <p>The calling device admin must have requested
293 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
294 * this method; if it has not, a security exception will be thrown.
295 *
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800296 * @return Returns true if the password meets the current requirements,
297 * else false.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800298 */
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800299 public boolean isActivePasswordSufficient() {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800300 if (mService != null) {
301 try {
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800302 return mService.isActivePasswordSufficient();
Dianne Hackbornd6847842010-01-12 18:14:19 -0800303 } catch (RemoteException e) {
304 Log.w(TAG, "Failed talking with device policy service", e);
305 }
306 }
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800307 return false;
Dianne Hackbornd6847842010-01-12 18:14:19 -0800308 }
309
310 /**
311 * Retrieve the number of times the user has failed at entering a
312 * password since that last successful password entry.
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800313 *
314 * <p>The calling device admin must have requested
315 * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to be able to call
316 * this method; if it has not, a security exception will be thrown.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800317 */
318 public int getCurrentFailedPasswordAttempts() {
319 if (mService != null) {
320 try {
321 return mService.getCurrentFailedPasswordAttempts();
322 } catch (RemoteException e) {
323 Log.w(TAG, "Failed talking with device policy service", e);
324 }
325 }
326 return -1;
327 }
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800328
329 /**
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800330 * Set the maximum number of failed password attempts that are allowed
331 * before the device wipes its data. This is convenience for implementing
332 * the corresponding functionality with a combination of watching failed
333 * password attempts and calling {@link #wipeData} upon reaching a certain
334 * count, and as such requires that you request both
335 * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} and
336 * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}}.
337 *
338 * @param admin Which {@link DeviceAdmin} this request is associated with.
339 * @param num The number of failed password attempts at which point the
340 * device will wipe its data.
341 */
342 public void setMaximumFailedPasswordsForWipe(ComponentName admin, int num) {
343 if (mService != null) {
344 try {
345 mService.setMaximumFailedPasswordsForWipe(admin, num);
346 } catch (RemoteException e) {
347 Log.w(TAG, "Failed talking with device policy service", e);
348 }
349 }
350 }
351
352 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800353 * Retrieve the current maximum number of login attempts that are allowed
354 * before the device wipes itself, for all admins
355 * or a particular one.
356 * @param admin The name of the admin component to check, or null to aggregate
357 * all admins.
358 */
359 public int getMaximumFailedPasswordsForWipe(ComponentName admin) {
360 if (mService != null) {
361 try {
362 return mService.getMaximumFailedPasswordsForWipe(admin);
363 } catch (RemoteException e) {
364 Log.w(TAG, "Failed talking with device policy service", e);
365 }
366 }
367 return 0;
368 }
369
370 /**
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800371 * Force a new password on the user. This takes effect immediately. The
372 * given password must meet the current password minimum length constraint
373 * or it will be rejected. The given password will be accepted regardless
374 * of the current password mode, automatically adjusting the password mode
Dianne Hackborn254cb442010-01-27 19:23:59 -0800375 * higher if needed to meet the requirements of all active administrators.
376 * (The string you give here is acceptable for any mode;
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800377 * if it contains only digits, that is still an acceptable alphanumeric
378 * password.)
379 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800380 * <p>The calling device admin must have requested
381 * {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD} to be able to call
382 * this method; if it has not, a security exception will be thrown.
383 *
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800384 * @param password The new password for the user.
385 * @return Returns true if the password was applied, or false if it is
386 * not acceptable for the current constraints.
387 */
388 public boolean resetPassword(String password) {
389 if (mService != null) {
390 try {
391 return mService.resetPassword(password);
392 } catch (RemoteException e) {
393 Log.w(TAG, "Failed talking with device policy service", e);
394 }
395 }
396 return false;
397 }
Dianne Hackbornd6847842010-01-12 18:14:19 -0800398
399 /**
400 * Called by an application that is administering the device to set the
401 * maximum time for user activity until the device will lock. This limits
402 * the length that the user can set. It takes effect immediately.
403 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800404 * <p>The calling device admin must have requested
405 * {@link DeviceAdminInfo#USES_POLICY_LIMIT_UNLOCK} to be able to call
406 * this method; if it has not, a security exception will be thrown.
407 *
Dianne Hackbornd6847842010-01-12 18:14:19 -0800408 * @param admin Which {@link DeviceAdmin} this request is associated with.
409 * @param timeMs The new desired maximum time to lock in milliseconds.
410 * A value of 0 means there is no restriction.
411 */
412 public void setMaximumTimeToLock(ComponentName admin, long timeMs) {
413 if (mService != null) {
414 try {
415 mService.setMaximumTimeToLock(admin, timeMs);
416 } catch (RemoteException e) {
417 Log.w(TAG, "Failed talking with device policy service", e);
418 }
419 }
420 }
421
422 /**
Dianne Hackborn254cb442010-01-27 19:23:59 -0800423 * Retrieve the current maximum time to unlock for all admins
424 * or a particular one.
425 * @param admin The name of the admin component to check, or null to aggregate
426 * all admins.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800427 */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800428 public long getMaximumTimeToLock(ComponentName admin) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800429 if (mService != null) {
430 try {
Dianne Hackborn254cb442010-01-27 19:23:59 -0800431 return mService.getMaximumTimeToLock(admin);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800432 } catch (RemoteException e) {
433 Log.w(TAG, "Failed talking with device policy service", e);
434 }
435 }
436 return 0;
437 }
438
439 /**
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800440 * Make the device lock immediately, as if the lock screen timeout has
441 * expired at the point of this call.
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800442 *
443 * <p>The calling device admin must have requested
444 * {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} to be able to call
445 * this method; if it has not, a security exception will be thrown.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800446 */
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800447 public void lockNow() {
448 if (mService != null) {
449 try {
450 mService.lockNow();
451 } catch (RemoteException e) {
452 Log.w(TAG, "Failed talking with device policy service", e);
453 }
454 }
455 }
Dianne Hackbornd6847842010-01-12 18:14:19 -0800456
457 /**
458 * Ask the user date be wiped. This will cause the device to reboot,
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800459 * erasing all user data while next booting up. External storage such
460 * as SD cards will not be erased.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800461 *
Dianne Hackborn8aa2e892010-01-22 11:31:30 -0800462 * <p>The calling device admin must have requested
463 * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to be able to call
464 * this method; if it has not, a security exception will be thrown.
465 *
Dianne Hackborndf83afa2010-01-20 13:37:26 -0800466 * @param flags Bit mask of additional options: currently must be 0.
Dianne Hackbornd6847842010-01-12 18:14:19 -0800467 */
468 public void wipeData(int flags) {
469 if (mService != null) {
470 try {
471 mService.wipeData(flags);
472 } catch (RemoteException e) {
473 Log.w(TAG, "Failed talking with device policy service", e);
474 }
475 }
476 }
477
478 /**
479 * @hide
480 */
481 public void setActiveAdmin(ComponentName policyReceiver) {
482 if (mService != null) {
483 try {
484 mService.setActiveAdmin(policyReceiver);
485 } catch (RemoteException e) {
486 Log.w(TAG, "Failed talking with device policy service", e);
487 }
488 }
489 }
490
491 /**
492 * @hide
493 */
Dianne Hackbornd47c6ed2010-01-27 16:21:20 -0800494 public DeviceAdminInfo getAdminInfo(ComponentName cn) {
Dianne Hackbornd6847842010-01-12 18:14:19 -0800495 ActivityInfo ai;
496 try {
497 ai = mContext.getPackageManager().getReceiverInfo(cn,
498 PackageManager.GET_META_DATA);
499 } catch (PackageManager.NameNotFoundException e) {
500 Log.w(TAG, "Unable to retrieve device policy " + cn, e);
501 return null;
502 }
503
504 ResolveInfo ri = new ResolveInfo();
505 ri.activityInfo = ai;
506
507 try {
508 return new DeviceAdminInfo(mContext, ri);
509 } catch (XmlPullParserException e) {
510 Log.w(TAG, "Unable to parse device policy " + cn, e);
511 return null;
512 } catch (IOException e) {
513 Log.w(TAG, "Unable to parse device policy " + cn, e);
514 return null;
515 }
516 }
517
518 /**
519 * @hide
520 */
Dianne Hackborn8ea138c2010-01-26 18:01:04 -0800521 public void getRemoveWarning(ComponentName admin, RemoteCallback result) {
522 if (mService != null) {
523 try {
524 mService.getRemoveWarning(admin, result);
525 } catch (RemoteException e) {
526 Log.w(TAG, "Failed talking with device policy service", e);
527 }
528 }
529 }
530
531 /**
532 * @hide
533 */
Dianne Hackbornd6847842010-01-12 18:14:19 -0800534 public void setActivePasswordState(int mode, int length) {
535 if (mService != null) {
536 try {
537 mService.setActivePasswordState(mode, length);
538 } catch (RemoteException e) {
539 Log.w(TAG, "Failed talking with device policy service", e);
540 }
541 }
542 }
543
544 /**
545 * @hide
546 */
547 public void reportFailedPasswordAttempt() {
548 if (mService != null) {
549 try {
550 mService.reportFailedPasswordAttempt();
551 } catch (RemoteException e) {
552 Log.w(TAG, "Failed talking with device policy service", e);
553 }
554 }
555 }
556
557 /**
558 * @hide
559 */
560 public void reportSuccessfulPasswordAttempt() {
561 if (mService != null) {
562 try {
563 mService.reportSuccessfulPasswordAttempt();
564 } catch (RemoteException e) {
565 Log.w(TAG, "Failed talking with device policy service", e);
566 }
567 }
568 }
569}