More work on device admins:

- You can now show a dynamic message to the user when asking to
  have your DeviceAdmin added.
- A DeviceAdmin can now provide a warning message that is displayed
  before a user disables it.
- Better ordering (and text) of the policy warnings.
- New API to set the maximum failed password attempts before the device
  wipes itself.
- We now store the number of failed unlock attempts in persistent
  storage.
- New managed dialog APIs that will be used by the settings app.

Also a little bit of cleanup as I was working on this - removed the
long unused MailboxNotAvailableException, fixed a java doc in Messenger.
diff --git a/core/java/android/app/DevicePolicyManager.java b/core/java/android/app/DevicePolicyManager.java
index 25e3230..9de7336 100644
--- a/core/java/android/app/DevicePolicyManager.java
+++ b/core/java/android/app/DevicePolicyManager.java
@@ -26,6 +26,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.os.Handler;
+import android.os.RemoteCallback;
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.util.Log;
@@ -43,8 +44,9 @@
     private static boolean localLOGV = DEBUG || android.util.Config.LOGV;
 
     private final Context mContext;
-    private final Handler mHandler;
     private final IDevicePolicyManager mService;
+    
+    private final Handler mHandler;
 
     /*package*/ DevicePolicyManager(Context context, Handler handler) {
         mContext = context;
@@ -60,6 +62,10 @@
      * bring the user through adding the device administrator to the system (or
      * allowing them to reject it).
      * 
+     * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION}
+     * field to provide the user with additional explanation (in addition
+     * to your component's description) about what is being added.
+     * 
      * <p>Note: the current platform can only have one device administrator
      * active at a time.  If you make this request while there is already
      * an active administrator, this new request will be canceled automatically.
@@ -76,6 +82,14 @@
     public static final String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN";
     
     /**
+     * An optional CharSequence providing additional explanation for why the
+     * admin is being added.
+     *
+     * @see #ACTION_ADD_DEVICE_ADMIN
+     */
+    public static final String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION";
+    
+    /**
      * Activity action: have the user enter a new password.  This activity
      * should be launched after using {@link #setPasswordMode(ComponentName, int)}
      * or {@link #setMinimumPasswordLength(ComponentName, int)} to have the
@@ -285,6 +299,29 @@
     }
 
     /**
+     * Set the maximum number of failed password attempts that are allowed
+     * before the device wipes its data.  This is convenience for implementing
+     * the corresponding functionality with a combination of watching failed
+     * password attempts and calling {@link #wipeData} upon reaching a certain
+     * count, and as such requires that you request both
+     * {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} and
+     * {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}}.
+     * 
+     * @param admin Which {@link DeviceAdmin} this request is associated with.
+     * @param num The number of failed password attempts at which point the
+     * device will wipe its data.
+     */
+    public void setMaximumFailedPasswordsForWipe(ComponentName admin, int num) {
+        if (mService != null) {
+            try {
+                mService.setMaximumFailedPasswordsForWipe(admin, num);
+            } catch (RemoteException e) {
+                Log.w(TAG, "Failed talking with device policy service", e);
+            }
+        }
+    }
+    
+    /**
      * Force a new password on the user.  This takes effect immediately.  The
      * given password must meet the current password minimum length constraint
      * or it will be rejected.  The given password will be accepted regardless
@@ -451,6 +488,19 @@
     /**
      * @hide
      */
+    public void getRemoveWarning(ComponentName admin, RemoteCallback result) {
+        if (mService != null) {
+            try {
+                mService.getRemoveWarning(admin, result);
+            } catch (RemoteException e) {
+                Log.w(TAG, "Failed talking with device policy service", e);
+            }
+        }
+    }
+
+    /**
+     * @hide
+     */
     public void setActivePasswordState(int mode, int length) {
         if (mService != null) {
             try {