Move DeviceAdmin APIs to android.app.admin.

Also add ability for admins to hide themselves when not in use,
a facility for admins to not allow other admins to reset
their password, and debug dumping.
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 8335bf3..4464ab9 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -99,6 +99,7 @@
 import android.view.inputmethod.InputMethodManager;
 import android.accounts.AccountManager;
 import android.accounts.IAccountManager;
+import android.app.admin.DevicePolicyManager;
 
 import com.android.internal.os.IDropBoxManagerService;
 
diff --git a/core/java/android/app/DeviceAdminInfo.java b/core/java/android/app/admin/DeviceAdminInfo.java
similarity index 96%
rename from core/java/android/app/DeviceAdminInfo.java
rename to core/java/android/app/admin/DeviceAdminInfo.java
index 61e1bb339..c4de812 100644
--- a/core/java/android/app/DeviceAdminInfo.java
+++ b/core/java/android/app/admin/DeviceAdminInfo.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.app;
+package android.app.admin;
 
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
@@ -150,6 +150,11 @@
     final ResolveInfo mReceiver;
     
     /**
+     * Whether this should be visible to the user.
+     */
+    boolean mVisible;
+    
+    /**
      * The policies this administrator needs access to.
      */
     int mUsesPolicies;
@@ -190,8 +195,11 @@
             }
             
             TypedArray sa = context.getResources().obtainAttributes(attrs,
-                    com.android.internal.R.styleable.Wallpaper);
+                    com.android.internal.R.styleable.DeviceAdmin);
 
+            mVisible = sa.getBoolean(
+                    com.android.internal.R.styleable.DeviceAdmin_visible, true);
+            
             sa.recycle();
             
             int outerDepth = parser.getDepth();
@@ -301,6 +309,14 @@
     }
     
     /**
+     * Returns whether this device admin would like to be visible to the
+     * user, even when it is not enabled.
+     */
+    public boolean isVisible() {
+        return mVisible;
+    }
+    
+    /**
      * Return true if the device admin has requested that it be able to use
      * the given policy control.  The possible policy identifier inputs are:
      * {@link #USES_POLICY_LIMIT_PASSWORD}, {@link #USES_POLICY_WATCH_LOGIN},
diff --git a/core/java/android/app/DeviceAdminReceiver.java b/core/java/android/app/admin/DeviceAdminReceiver.java
similarity index 99%
rename from core/java/android/app/DeviceAdminReceiver.java
rename to core/java/android/app/admin/DeviceAdminReceiver.java
index 453e0bf..b4dd9e7 100644
--- a/core/java/android/app/DeviceAdminReceiver.java
+++ b/core/java/android/app/admin/DeviceAdminReceiver.java
@@ -14,10 +14,11 @@
  * limitations under the License.
  */
 
-package android.app;
+package android.app.admin;
 
 import android.annotation.SdkConstant;
 import android.annotation.SdkConstant.SdkConstantType;
+import android.app.Service;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
diff --git a/core/java/android/app/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
similarity index 97%
rename from core/java/android/app/DevicePolicyManager.java
rename to core/java/android/app/admin/DevicePolicyManager.java
index 0e8c1ab..2d9b415 100644
--- a/core/java/android/app/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -14,12 +14,13 @@
  * limitations under the License.
  */
 
-package android.app;
+package android.app.admin;
 
 import org.xmlpull.v1.XmlPullParserException;
 
 import android.annotation.SdkConstant;
 import android.annotation.SdkConstant.SdkConstantType;
+import android.app.admin.IDevicePolicyManager.Stub;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.ActivityInfo;
@@ -56,7 +57,8 @@
                 ServiceManager.getService(Context.DEVICE_POLICY_SERVICE));
     }
 
-    /*package*/ static DevicePolicyManager create(Context context, Handler handler) {
+    /** @hide */
+    public static DevicePolicyManager create(Context context, Handler handler) {
         DevicePolicyManager me = new DevicePolicyManager(context, handler);
         return me.mService != null ? me : null;
     }
@@ -394,6 +396,12 @@
     }
     
     /**
+     * Flag for {@link #resetPassword}: don't allow other admins to change
+     * the password again until the user has entered it.
+     */
+    public static final int RESET_PASSWORD_REQUIRE_ENTRY = 0x0001;
+    
+    /**
      * Force a new device unlock password (the password needed to access the
      * entire device, not for individual accounts) on the user.  This takes
      * effect immediately.
@@ -411,13 +419,14 @@
      * this method; if it has not, a security exception will be thrown.
      * 
      * @param password The new password for the user.
+     * @param flags May be 0 or {@link #RESET_PASSWORD_REQUIRE_ENTRY}.
      * @return Returns true if the password was applied, or false if it is
      * not acceptable for the current constraints.
      */
-    public boolean resetPassword(String password) {
+    public boolean resetPassword(String password, int flags) {
         if (mService != null) {
             try {
-                return mService.resetPassword(password);
+                return mService.resetPassword(password, flags);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
diff --git a/core/java/android/app/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
similarity index 95%
rename from core/java/android/app/IDevicePolicyManager.aidl
rename to core/java/android/app/admin/IDevicePolicyManager.aidl
index b138720..6fc4dc5 100644
--- a/core/java/android/app/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -15,7 +15,7 @@
 ** limitations under the License.
 */
 
-package android.app;
+package android.app.admin;
 
 import android.content.ComponentName;
 import android.os.RemoteCallback;
@@ -37,7 +37,7 @@
     void setMaximumFailedPasswordsForWipe(in ComponentName admin, int num);
     int getMaximumFailedPasswordsForWipe(in ComponentName admin);
     
-    boolean resetPassword(String password);
+    boolean resetPassword(String password, int flags);
     
     void setMaximumTimeToLock(in ComponentName who, long timeMs);
     long getMaximumTimeToLock(in ComponentName who);
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 897d702..8d136f1 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -1507,7 +1507,7 @@
 
     /**
      * Use with {@link #getSystemService} to retrieve a 
-     * {@link android.app.DevicePolicyManager} for working with global
+     * {@link android.app.admin.DevicePolicyManager} for working with global
      * device policy management.
      *
      * @see #getSystemService
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 1956b4e..d6b0808 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.widget;
 
-import android.app.DevicePolicyManager;
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.os.RemoteException;
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index ff93984..79bd41e 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3501,6 +3501,21 @@
     <!-- =============================== -->
     <eat-comment />
     
+    <!-- Use <code>device-admin</code> as the root tag of the XML resource that
+         describes a
+         {@link android.app.admin.DeviceAdminReceiver}, which is
+         referenced from its
+         {@link android.app.admin.DeviceAdminReceiver#DEVICE_ADMIN_META_DATA}
+         meta-data entry.  Described here are the attributes that can be
+         included in that tag. -->
+    <declare-styleable name="DeviceAdmin">
+        <!-- Control whether the admin is visible to the user, even when it
+             is not enabled.  This is true by default.  You may want to make
+             it false if your admin does not make sense to be turned on
+             unless some explicit action happens in your app. -->
+        <attr name="visible" />
+    </declare-styleable>
+
     <!-- Use <code>wallpaper</code> as the root tag of the XML resource that
          describes an
          {@link android.service.wallpaper.WallpaperService}, which is