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/Android.mk b/Android.mk
index 06db5822..12dddd6 100644
--- a/Android.mk
+++ b/Android.mk
@@ -81,7 +81,6 @@
core/java/android/app/IActivityWatcher.aidl \
core/java/android/app/IAlarmManager.aidl \
core/java/android/app/IBackupAgent.aidl \
- core/java/android/app/IDevicePolicyManager.aidl \
core/java/android/app/IInstrumentationWatcher.aidl \
core/java/android/app/INotificationManager.aidl \
core/java/android/app/ISearchManager.aidl \
@@ -93,6 +92,7 @@
core/java/android/app/IUiModeManager.aidl \
core/java/android/app/IWallpaperManager.aidl \
core/java/android/app/IWallpaperManagerCallback.aidl \
+ core/java/android/app/admin/IDevicePolicyManager.aidl \
core/java/android/backup/IBackupManager.aidl \
core/java/android/backup/IRestoreObserver.aidl \
core/java/android/backup/IRestoreSession.aidl \
diff --git a/api/current.xml b/api/current.xml
index 67c570a..3b90f38 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -20089,804 +20089,6 @@
</parameter>
</method>
</interface>
-<class name="DeviceAdminInfo"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.os.Parcelable">
-</implements>
-<constructor name="DeviceAdminInfo"
- type="android.app.DeviceAdminInfo"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="receiver" type="android.content.pm.ResolveInfo">
-</parameter>
-<exception name="IOException" type="java.io.IOException">
-</exception>
-<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
-</exception>
-</constructor>
-<method name="describeContents"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="dump"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="pw" type="android.util.Printer">
-</parameter>
-<parameter name="prefix" type="java.lang.String">
-</parameter>
-</method>
-<method name="getActivityInfo"
- return="android.content.pm.ActivityInfo"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="getComponent"
- return="android.content.ComponentName"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="getPackageName"
- return="java.lang.String"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="getReceiverName"
- return="java.lang.String"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="getTagForPolicy"
- return="java.lang.String"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="policyIdent" type="int">
-</parameter>
-</method>
-<method name="loadDescription"
- return="java.lang.CharSequence"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="pm" type="android.content.pm.PackageManager">
-</parameter>
-<exception name="Resources.NotFoundException" type="android.content.res.Resources.NotFoundException">
-</exception>
-</method>
-<method name="loadIcon"
- return="android.graphics.drawable.Drawable"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="pm" type="android.content.pm.PackageManager">
-</parameter>
-</method>
-<method name="loadLabel"
- return="java.lang.CharSequence"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="pm" type="android.content.pm.PackageManager">
-</parameter>
-</method>
-<method name="usesPolicy"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="policyIdent" type="int">
-</parameter>
-</method>
-<method name="writeToParcel"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="dest" type="android.os.Parcel">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
-<field name="CREATOR"
- type="android.os.Parcelable.Creator"
- transient="false"
- volatile="false"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="USES_POLICY_FORCE_LOCK"
- type="int"
- transient="false"
- volatile="false"
- value="3"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="USES_POLICY_LIMIT_PASSWORD"
- type="int"
- transient="false"
- volatile="false"
- value="0"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="USES_POLICY_RESET_PASSWORD"
- type="int"
- transient="false"
- volatile="false"
- value="2"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="USES_POLICY_WATCH_LOGIN"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="USES_POLICY_WIPE_DATA"
- type="int"
- transient="false"
- volatile="false"
- value="4"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
-<class name="DeviceAdminReceiver"
- extends="android.content.BroadcastReceiver"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<constructor name="DeviceAdminReceiver"
- type="android.app.DeviceAdminReceiver"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="getManager"
- return="android.app.DevicePolicyManager"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-</method>
-<method name="getWho"
- return="android.content.ComponentName"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-</method>
-<method name="onDisableRequested"
- return="java.lang.CharSequence"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="intent" type="android.content.Intent">
-</parameter>
-</method>
-<method name="onDisabled"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="intent" type="android.content.Intent">
-</parameter>
-</method>
-<method name="onEnabled"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="intent" type="android.content.Intent">
-</parameter>
-</method>
-<method name="onPasswordChanged"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="intent" type="android.content.Intent">
-</parameter>
-</method>
-<method name="onPasswordFailed"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="intent" type="android.content.Intent">
-</parameter>
-</method>
-<method name="onPasswordSucceeded"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="intent" type="android.content.Intent">
-</parameter>
-</method>
-<method name="onReceive"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="intent" type="android.content.Intent">
-</parameter>
-</method>
-<field name="ACTION_DEVICE_ADMIN_DISABLED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.DEVICE_ADMIN_DISABLED""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_DEVICE_ADMIN_DISABLE_REQUESTED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_DEVICE_ADMIN_ENABLED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.DEVICE_ADMIN_ENABLED""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_PASSWORD_CHANGED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.ACTION_PASSWORD_CHANGED""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_PASSWORD_FAILED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.ACTION_PASSWORD_FAILED""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_PASSWORD_SUCCEEDED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.ACTION_PASSWORD_SUCCEEDED""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="DEVICE_ADMIN_META_DATA"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.device_admin""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="EXTRA_DISABLE_WARNING"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.extra.DISABLE_WARNING""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
-<class name="DevicePolicyManager"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<method name="getActiveAdmins"
- return="java.util.List<android.content.ComponentName>"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="getCurrentFailedPasswordAttempts"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="getMaximumFailedPasswordsForWipe"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-</method>
-<method name="getMaximumTimeToLock"
- return="long"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-</method>
-<method name="getPasswordMaximumLength"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="quality" type="int">
-</parameter>
-</method>
-<method name="getPasswordMinimumLength"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-</method>
-<method name="getPasswordQuality"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-</method>
-<method name="isActivePasswordSufficient"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="isAdminActive"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="who" type="android.content.ComponentName">
-</parameter>
-</method>
-<method name="lockNow"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="removeActiveAdmin"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="who" type="android.content.ComponentName">
-</parameter>
-</method>
-<method name="resetPassword"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="password" type="java.lang.String">
-</parameter>
-</method>
-<method name="setMaximumFailedPasswordsForWipe"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-<parameter name="num" type="int">
-</parameter>
-</method>
-<method name="setMaximumTimeToLock"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-<parameter name="timeMs" type="long">
-</parameter>
-</method>
-<method name="setPasswordMinimumLength"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-<parameter name="length" type="int">
-</parameter>
-</method>
-<method name="setPasswordQuality"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="admin" type="android.content.ComponentName">
-</parameter>
-<parameter name="quality" type="int">
-</parameter>
-</method>
-<method name="wipeData"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="flags" type="int">
-</parameter>
-</method>
-<field name="ACTION_ADD_DEVICE_ADMIN"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.ADD_DEVICE_ADMIN""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_SET_NEW_PASSWORD"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.action.SET_NEW_PASSWORD""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="EXTRA_ADD_EXPLANATION"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.extra.ADD_EXPLANATION""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="EXTRA_DEVICE_ADMIN"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value=""android.app.extra.DEVICE_ADMIN""
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="PASSWORD_QUALITY_ALPHANUMERIC"
- type="int"
- transient="false"
- volatile="false"
- value="196608"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="PASSWORD_QUALITY_NUMERIC"
- type="int"
- transient="false"
- volatile="false"
- value="131072"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="PASSWORD_QUALITY_SOMETHING"
- type="int"
- transient="false"
- volatile="false"
- value="65536"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="PASSWORD_QUALITY_UNSPECIFIED"
- type="int"
- transient="false"
- volatile="false"
- value="0"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
<class name="Dialog"
extends="java.lang.Object"
abstract="false"
@@ -26841,6 +26043,831 @@
</field>
</class>
</package>
+<package name="android.app.admin"
+>
+<class name="DeviceAdminInfo"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<constructor name="DeviceAdminInfo"
+ type="android.app.admin.DeviceAdminInfo"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="receiver" type="android.content.pm.ResolveInfo">
+</parameter>
+<exception name="IOException" type="java.io.IOException">
+</exception>
+<exception name="XmlPullParserException" type="org.xmlpull.v1.XmlPullParserException">
+</exception>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="dump"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pw" type="android.util.Printer">
+</parameter>
+<parameter name="prefix" type="java.lang.String">
+</parameter>
+</method>
+<method name="getActivityInfo"
+ return="android.content.pm.ActivityInfo"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getComponent"
+ return="android.content.ComponentName"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getPackageName"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getReceiverName"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getTagForPolicy"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="policyIdent" type="int">
+</parameter>
+</method>
+<method name="isVisible"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="loadDescription"
+ return="java.lang.CharSequence"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pm" type="android.content.pm.PackageManager">
+</parameter>
+<exception name="Resources.NotFoundException" type="android.content.res.Resources.NotFoundException">
+</exception>
+</method>
+<method name="loadIcon"
+ return="android.graphics.drawable.Drawable"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pm" type="android.content.pm.PackageManager">
+</parameter>
+</method>
+<method name="loadLabel"
+ return="java.lang.CharSequence"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pm" type="android.content.pm.PackageManager">
+</parameter>
+</method>
+<method name="usesPolicy"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="policyIdent" type="int">
+</parameter>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.Creator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="USES_POLICY_FORCE_LOCK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="USES_POLICY_LIMIT_PASSWORD"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="USES_POLICY_RESET_PASSWORD"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="USES_POLICY_WATCH_LOGIN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="USES_POLICY_WIPE_DATA"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="DeviceAdminReceiver"
+ extends="android.content.BroadcastReceiver"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="DeviceAdminReceiver"
+ type="android.app.admin.DeviceAdminReceiver"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="getManager"
+ return="android.app.admin.DevicePolicyManager"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+</method>
+<method name="getWho"
+ return="android.content.ComponentName"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+</method>
+<method name="onDisableRequested"
+ return="java.lang.CharSequence"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="intent" type="android.content.Intent">
+</parameter>
+</method>
+<method name="onDisabled"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="intent" type="android.content.Intent">
+</parameter>
+</method>
+<method name="onEnabled"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="intent" type="android.content.Intent">
+</parameter>
+</method>
+<method name="onPasswordChanged"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="intent" type="android.content.Intent">
+</parameter>
+</method>
+<method name="onPasswordFailed"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="intent" type="android.content.Intent">
+</parameter>
+</method>
+<method name="onPasswordSucceeded"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="intent" type="android.content.Intent">
+</parameter>
+</method>
+<method name="onReceive"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="intent" type="android.content.Intent">
+</parameter>
+</method>
+<field name="ACTION_DEVICE_ADMIN_DISABLED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.DEVICE_ADMIN_DISABLED""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_DEVICE_ADMIN_DISABLE_REQUESTED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_DEVICE_ADMIN_ENABLED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.DEVICE_ADMIN_ENABLED""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_PASSWORD_CHANGED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.ACTION_PASSWORD_CHANGED""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_PASSWORD_FAILED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.ACTION_PASSWORD_FAILED""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_PASSWORD_SUCCEEDED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.ACTION_PASSWORD_SUCCEEDED""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="DEVICE_ADMIN_META_DATA"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.device_admin""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_DISABLE_WARNING"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.extra.DISABLE_WARNING""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="DevicePolicyManager"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="getActiveAdmins"
+ return="java.util.List<android.content.ComponentName>"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getCurrentFailedPasswordAttempts"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getMaximumFailedPasswordsForWipe"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+</method>
+<method name="getMaximumTimeToLock"
+ return="long"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+</method>
+<method name="getPasswordMaximumLength"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="quality" type="int">
+</parameter>
+</method>
+<method name="getPasswordMinimumLength"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+</method>
+<method name="getPasswordQuality"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+</method>
+<method name="isActivePasswordSufficient"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="isAdminActive"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="who" type="android.content.ComponentName">
+</parameter>
+</method>
+<method name="lockNow"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="removeActiveAdmin"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="who" type="android.content.ComponentName">
+</parameter>
+</method>
+<method name="resetPassword"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="password" type="java.lang.String">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<method name="setMaximumFailedPasswordsForWipe"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+<parameter name="num" type="int">
+</parameter>
+</method>
+<method name="setMaximumTimeToLock"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+<parameter name="timeMs" type="long">
+</parameter>
+</method>
+<method name="setPasswordMinimumLength"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+<parameter name="length" type="int">
+</parameter>
+</method>
+<method name="setPasswordQuality"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+<parameter name="quality" type="int">
+</parameter>
+</method>
+<method name="wipeData"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="ACTION_ADD_DEVICE_ADMIN"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.ADD_DEVICE_ADMIN""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_SET_NEW_PASSWORD"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.action.SET_NEW_PASSWORD""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_ADD_EXPLANATION"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.extra.ADD_EXPLANATION""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_DEVICE_ADMIN"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.app.extra.DEVICE_ADMIN""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="PASSWORD_QUALITY_ALPHANUMERIC"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="196608"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="PASSWORD_QUALITY_NUMERIC"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="131072"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="PASSWORD_QUALITY_SOMETHING"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="65536"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="PASSWORD_QUALITY_UNSPECIFIED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RESET_PASSWORD_REQUIRE_ENTRY"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+</package>
<package name="android.appwidget"
>
<class name="AppWidgetHost"
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
diff --git a/preloaded-classes b/preloaded-classes
index 9fc000f..28cbba3 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -31,7 +31,6 @@
android.app.IActivityManager
android.app.IActivityManager$ContentProviderHolder
android.app.IAlarmManager$Stub
-android.app.IDevicePolicyManager$Stub
android.app.IStatusBar$Stub
android.app.ITransientNotification$Stub
android.app.Instrumentation
@@ -51,6 +50,7 @@
android.app.SuperNotCalledException
android.app.TabActivity
android.app.TimePickerDialog
+android.app.admin.IDevicePolicyManager$Stub
android.appwidget.AppWidgetHost
android.appwidget.AppWidgetHostView
android.appwidget.AppWidgetHostView$ParcelableSparseArray
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java
index 9899e99..a555244 100644
--- a/services/java/com/android/server/DevicePolicyManagerService.java
+++ b/services/java/com/android/server/DevicePolicyManagerService.java
@@ -26,10 +26,10 @@
import org.xmlpull.v1.XmlSerializer;
import android.app.Activity;
-import android.app.DeviceAdminReceiver;
-import android.app.DeviceAdminInfo;
-import android.app.DevicePolicyManager;
-import android.app.IDevicePolicyManager;
+import android.app.admin.DeviceAdminInfo;
+import android.app.admin.DeviceAdminReceiver;
+import android.app.admin.DevicePolicyManager;
+import android.app.admin.IDevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -46,13 +46,17 @@
import android.os.ServiceManager;
import android.os.SystemClock;
import android.util.Log;
+import android.util.PrintWriterPrinter;
+import android.util.Printer;
import android.util.Xml;
import android.view.WindowManagerPolicy;
import java.io.File;
+import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -72,6 +76,8 @@
int mActivePasswordLength = 0;
int mFailedPasswordAttempts = 0;
+ int mPasswordOwner = -1;
+
final HashMap<ComponentName, ActiveAdmin> mAdminMap
= new HashMap<ComponentName, ActiveAdmin>();
final ArrayList<ActiveAdmin> mAdminList
@@ -148,11 +154,31 @@
XmlUtils.skipCurrentTag(parser);
}
}
+
+ void dump(String prefix, PrintWriter pw) {
+ pw.print(prefix); pw.print("uid="); pw.println(getUid());
+ pw.print(prefix); pw.println("policies:");
+ ArrayList<DeviceAdminInfo.PolicyInfo> pols = info.getUsedPolicies();
+ if (pols != null) {
+ for (int i=0; i<pols.size(); i++) {
+ pw.print(prefix); pw.print(" "); pw.println(pols.get(i).tag);
+ }
+ }
+ pw.print(prefix); pw.print("passwordQuality=");
+ pw.print(passwordQuality);
+ pw.print(" minimumPasswordLength=");
+ pw.println(minimumPasswordLength);
+ pw.print(prefix); pw.print("maximumTimeToUnlock=");
+ pw.println(maximumTimeToUnlock);
+ pw.print(prefix); pw.print("maximumFailedPasswordsForWipe=");
+ pw.println(maximumFailedPasswordsForWipe);
+ }
}
class MyPackageMonitor extends PackageMonitor {
public void onSomePackagesChanged() {
synchronized (DevicePolicyManagerService.this) {
+ boolean removed = false;
for (int i=mAdminList.size()-1; i>=0; i--) {
ActiveAdmin aa = mAdminList.get(i);
int change = isPackageDisappearing(aa.info.getPackageName());
@@ -160,6 +186,7 @@
|| change == PACKAGE_TEMPORARY_CHANGE) {
Log.w(TAG, "Admin unexpectedly uninstalled: "
+ aa.info.getComponent());
+ removed = true;
mAdminList.remove(i);
} else if (isPackageModified(aa.info.getPackageName())) {
try {
@@ -168,10 +195,14 @@
} catch (NameNotFoundException e) {
Log.w(TAG, "Admin package change removed component: "
+ aa.info.getComponent());
+ removed = true;
mAdminList.remove(i);
}
}
}
+ if (removed) {
+ validatePasswordOwnerLocked();
+ }
}
}
}
@@ -260,6 +291,7 @@
// XXX need to wait for it to complete.
mAdminList.remove(admin);
mAdminMap.remove(adminReceiver);
+ validatePasswordOwnerLocked();
}
}
@@ -312,6 +344,12 @@
out.endTag(null, "policies");
+ if (mPasswordOwner >= 0) {
+ out.startTag(null, "password-owner");
+ out.attribute(null, "value", Integer.toString(mPasswordOwner));
+ out.endTag(null, "password-owner");
+ }
+
if (mFailedPasswordAttempts != 0) {
out.startTag(null, "failed-password-attempts");
out.attribute(null, "value", Integer.toString(mFailedPasswordAttempts));
@@ -377,6 +415,10 @@
mFailedPasswordAttempts = Integer.parseInt(
parser.getAttributeValue(null, "value"));
XmlUtils.skipCurrentTag(parser);
+ } else if ("password-owner".equals(tag)) {
+ mPasswordOwner = Integer.parseInt(
+ parser.getAttributeValue(null, "value"));
+ XmlUtils.skipCurrentTag(parser);
} else {
Log.w(TAG, "Unknown tag: " + tag);
XmlUtils.skipCurrentTag(parser);
@@ -401,6 +443,8 @@
// Ignore
}
+ validatePasswordOwnerLocked();
+
long timeMs = getMaximumTimeToLock(null);
if (timeMs <= 0) {
timeMs = Integer.MAX_VALUE;
@@ -412,6 +456,23 @@
}
}
+ void validatePasswordOwnerLocked() {
+ if (mPasswordOwner >= 0) {
+ boolean haveOwner = false;
+ for (int i=mAdminList.size()-1; i>=0; i--) {
+ if (mAdminList.get(i).getUid() == mPasswordOwner) {
+ haveOwner = true;
+ break;
+ }
+ }
+ if (!haveOwner) {
+ Log.w(TAG, "Previous password owner " + mPasswordOwner
+ + " no longer active; disabling");
+ mPasswordOwner = -1;
+ }
+ }
+ }
+
public void systemReady() {
synchronized (this) {
loadSettingsLocked();
@@ -622,7 +683,7 @@
}
}
- public boolean resetPassword(String password) {
+ public boolean resetPassword(String password, int flags) {
int quality;
synchronized (this) {
// This API can only be called by an active device admin,
@@ -645,12 +706,24 @@
}
}
+ int callingUid = Binder.getCallingUid();
+ if (mPasswordOwner >= 0 && mPasswordOwner != callingUid) {
+ Log.w(TAG, "resetPassword: already set by another uid and not entered by user");
+ return false;
+ }
+
// Don't do this with the lock held, because it is going to call
// back in to the service.
long ident = Binder.clearCallingIdentity();
try {
LockPatternUtils utils = new LockPatternUtils(mContext);
utils.saveLockPassword(password, quality);
+ int newOwner = (flags&DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY)
+ != 0 ? callingUid : -1;
+ if (mPasswordOwner != newOwner) {
+ mPasswordOwner = newOwner;
+ saveSettingsLocked();
+ }
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -829,10 +902,11 @@
android.Manifest.permission.BIND_DEVICE_ADMIN, null);
synchronized (this) {
- if (mFailedPasswordAttempts != 0) {
+ if (mFailedPasswordAttempts != 0 || mPasswordOwner >= 0) {
long ident = Binder.clearCallingIdentity();
try {
mFailedPasswordAttempts = 0;
+ mPasswordOwner = -1;
saveSettingsLocked();
sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_SUCCEEDED,
DeviceAdminInfo.USES_POLICY_WATCH_LOGIN);
@@ -842,4 +916,39 @@
}
}
}
+
+ @Override
+ protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
+ != PackageManager.PERMISSION_GRANTED) {
+
+ pw.println("Permission Denial: can't dump DevicePolicyManagerService from from pid="
+ + Binder.getCallingPid()
+ + ", uid=" + Binder.getCallingUid());
+ return;
+ }
+
+ final Printer p = new PrintWriterPrinter(pw);
+
+ synchronized (this) {
+ p.println("Current Device Policy Manager state:");
+
+ p.println(" Enabled Device Admins:");
+ final int N = mAdminList.size();
+ for (int i=0; i<N; i++) {
+ ActiveAdmin ap = mAdminList.get(i);
+ if (ap != null) {
+ pw.print(" "); pw.print(ap.info.getComponent().flattenToShortString());
+ pw.println(":");
+ ap.dump(" ", pw);
+ }
+ }
+
+ pw.println(" ");
+ pw.print(" mActivePasswordQuality="); pw.println(mActivePasswordQuality);
+ pw.print(" mActivePasswordLength="); pw.println(mActivePasswordLength);
+ pw.print(" mFailedPasswordAttempts="); pw.println(mFailedPasswordAttempts);
+ pw.print(" mPasswordOwner="); pw.println(mPasswordOwner);
+ }
+ }
}
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 7ce9a4c..bf2b1c7 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -28,9 +28,9 @@
import org.xmlpull.v1.XmlSerializer;
import android.app.ActivityManagerNative;
-import android.app.DevicePolicyManager;
import android.app.IActivityManager;
-import android.app.IDevicePolicyManager;
+import android.app.admin.DevicePolicyManager;
+import android.app.admin.IDevicePolicyManager;
import android.backup.IBackupManager;
import android.content.ComponentName;
import android.content.Context;