Fix issue #2420412: API review: DeviceAdmin API changes

Note in docs that callbacks are on main thread.
Rename to DeviceAdminReceiver?
Document resetPassword is the device's password.

Also hide android.R.attr.neverEncrypt.
This commit is contained in:
Dianne Hackborn
2010-02-16 20:38:49 -08:00
parent 855dd9e074
commit ef6b22fc04
8 changed files with 277 additions and 279 deletions

View File

@@ -4611,7 +4611,7 @@
type="int"
transient="false"
volatile="false"
value="16843448"
value="16843447"
static="true"
final="true"
deprecated="not deprecated"
@@ -5773,17 +5773,6 @@
visibility="public"
>
</field>
<field name="neverEncrypt"
type="int"
transient="false"
volatile="false"
value="16843447"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="nextFocusDown"
type="int"
transient="false"
@@ -6855,7 +6844,7 @@
type="int"
transient="false"
volatile="false"
value="16843449"
value="16843448"
static="true"
final="true"
deprecated="not deprecated"
@@ -20067,242 +20056,6 @@
</parameter>
</method>
</interface>
<class name="DeviceAdmin"
extends="android.content.BroadcastReceiver"
abstract="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<constructor name="DeviceAdmin"
type="android.app.DeviceAdmin"
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="&quot;android.app.action.DEVICE_ADMIN_DISABLED&quot;"
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="&quot;android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED&quot;"
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="&quot;android.app.action.DEVICE_ADMIN_ENABLED&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="ACTION_PASSWORD_CHANGED"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.action.ACTION_PASSWORD_CHANGED&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="ACTION_PASSWORD_FAILED"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.action.ACTION_PASSWORD_FAILED&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="ACTION_PASSWORD_SUCCEEDED"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.action.ACTION_PASSWORD_SUCCEEDED&quot;"
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="&quot;android.app.device_admin&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="EXTRA_DISABLE_WARNING"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.extra.DISABLE_WARNING&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
</class>
<class name="DeviceAdminInfo"
extends="java.lang.Object"
abstract="false"
@@ -20547,6 +20300,242 @@
>
</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="&quot;android.app.action.DEVICE_ADMIN_DISABLED&quot;"
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="&quot;android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED&quot;"
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="&quot;android.app.action.DEVICE_ADMIN_ENABLED&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="ACTION_PASSWORD_CHANGED"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.action.ACTION_PASSWORD_CHANGED&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="ACTION_PASSWORD_FAILED"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.action.ACTION_PASSWORD_FAILED&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="ACTION_PASSWORD_SUCCEEDED"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.action.ACTION_PASSWORD_SUCCEEDED&quot;"
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="&quot;android.app.device_admin&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="EXTRA_DISABLE_WARNING"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.app.extra.DISABLE_WARNING&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
</class>
<class name="DevicePolicyManager"
extends="java.lang.Object"
abstract="false"

View File

@@ -60,8 +60,8 @@ public final class DeviceAdminInfo implements Parcelable {
/**
* A type of policy that this device admin can use: able to watch login
* attempts from the user, via {@link DeviceAdmin#ACTION_PASSWORD_FAILED},
* {@link DeviceAdmin#ACTION_PASSWORD_SUCCEEDED}, and
* attempts from the user, via {@link DeviceAdminReceiver#ACTION_PASSWORD_FAILED},
* {@link DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED}, and
* {@link DevicePolicyManager#getCurrentFailedPasswordAttempts}.
*
* <p>To control this policy, the device admin must have a "watch-login"
@@ -169,10 +169,10 @@ public final class DeviceAdminInfo implements Parcelable {
XmlResourceParser parser = null;
try {
parser = ai.loadXmlMetaData(pm, DeviceAdmin.DEVICE_ADMIN_META_DATA);
parser = ai.loadXmlMetaData(pm, DeviceAdminReceiver.DEVICE_ADMIN_META_DATA);
if (parser == null) {
throw new XmlPullParserException("No "
+ DeviceAdmin.DEVICE_ADMIN_META_DATA + " meta-data");
+ DeviceAdminReceiver.DEVICE_ADMIN_META_DATA + " meta-data");
}
AttributeSet attrs = Xml.asAttributeSet(parser);

View File

@@ -29,6 +29,13 @@ import android.os.Bundle;
* class provides a convenience for interpreting the raw intent actions
* that are sent by the system.
*
* <p>The callback methods, like the base
* {@link BroadcastReceiver#onReceive(Context, Intent) BroadcastReceiver.onReceive()}
* method, happen on the main thread of the process. Thus long running
* operations must be done on another thread. Note that because a receiver
* is done once returning from its receive function, such long-running operations
* should probably be done in a {@link Service}.
*
* <p>When publishing your DeviceAdmin subclass as a receiver, it must
* handle {@link #ACTION_DEVICE_ADMIN_ENABLED} and require the
* {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission. A typical
@@ -42,7 +49,7 @@ import android.os.Bundle;
*
* {@sample development/samples/ApiDemos/res/xml/device_admin_sample.xml meta_data}
*/
public class DeviceAdmin extends BroadcastReceiver {
public class DeviceAdminReceiver extends BroadcastReceiver {
private static String TAG = "DevicePolicy";
private static boolean DEBUG = false;
private static boolean localLOGV = DEBUG || android.util.Config.LOGV;
@@ -51,7 +58,7 @@ public class DeviceAdmin extends BroadcastReceiver {
* This is the primary action that a device administrator must implement to be
* allowed to manage a device. This will be set to the receiver
* when the user enables it for administration. You will generally
* handle this in {@link DeviceAdmin#onEnabled(Context, Intent)}. To be
* handle this in {@link DeviceAdminReceiver#onEnabled(Context, Intent)}. To be
* supported, the receiver must also require the
* {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission so
* that other applications can not abuse it.
@@ -85,7 +92,7 @@ public class DeviceAdmin extends BroadcastReceiver {
* Action sent to a device administrator when the user has disabled
* it. Upon return, the application no longer has access to the
* protected device policy manager APIs. You will generally
* handle this in {@link DeviceAdmin#onDisabled(Context, Intent)}. Note
* handle this in {@link DeviceAdminReceiver#onDisabled(Context, Intent)}. Note
* that this action will be
* sent the receiver regardless of whether it is explicitly listed in
* its intent filter.
@@ -100,7 +107,7 @@ public class DeviceAdmin extends BroadcastReceiver {
* of the new password with {@link DevicePolicyManager#isActivePasswordSufficient()
* DevicePolicyManager.isActivePasswordSufficient()}.
* You will generally
* handle this in {@link DeviceAdmin#onPasswordChanged}.
* handle this in {@link DeviceAdminReceiver#onPasswordChanged}.
*
* <p>The calling device admin must have requested
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to receive
@@ -116,7 +123,7 @@ public class DeviceAdmin extends BroadcastReceiver {
* number of failed password attempts there have been with
* {@link DevicePolicyManager#getCurrentFailedPasswordAttempts
* DevicePolicyManager.getCurrentFailedPasswordAttempts()}. You will generally
* handle this in {@link DeviceAdmin#onPasswordFailed}.
* handle this in {@link DeviceAdminReceiver#onPasswordFailed}.
*
* <p>The calling device admin must have requested
* {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} to receive

View File

@@ -36,7 +36,7 @@ import java.util.List;
/**
* Public interface for managing policies enforced on a device. Most clients
* of this class must have published a {@link DeviceAdmin} that the user
* of this class must have published a {@link DeviceAdminReceiver} that the user
* has currently enabled.
*/
public class DevicePolicyManager {
@@ -195,7 +195,7 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
* this method; if it has not, a security exception will be thrown.
*
* @param admin Which {@link DeviceAdmin} this request is associated with.
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param quality The new desired quality. One of
* {@link #PASSWORD_QUALITY_UNSPECIFIED}, {@link #PASSWORD_QUALITY_SOMETHING},
* {@link #PASSWORD_QUALITY_NUMERIC}, or {@link #PASSWORD_QUALITY_ALPHANUMERIC}.
@@ -243,7 +243,7 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call
* this method; if it has not, a security exception will be thrown.
*
* @param admin Which {@link DeviceAdmin} this request is associated with.
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param length The new desired minimum password length. A value of 0
* means there is no restriction.
*/
@@ -338,11 +338,11 @@ public class DevicePolicyManager {
* <p>To implement any other policy (e.g. wiping data for a particular
* application only, erasing or revoking credentials, or reporting the
* failure to a server), you should implement
* {@link DeviceAdmin#onPasswordFailed(Context, android.content.Intent)}
* {@link DeviceAdminReceiver#onPasswordFailed(Context, android.content.Intent)}
* instead. Do not use this API, because if the maximum count is reached,
* the device will be wiped immediately, and your callback will not be invoked.
*
* @param admin Which {@link DeviceAdmin} this request is associated with.
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param num The number of failed password attempts at which point the
* device will wipe its data.
*/
@@ -375,7 +375,9 @@ public class DevicePolicyManager {
}
/**
* Force a new password on the user. This takes effect immediately.
* 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.
* The given password must be sufficient for the
* current password quality and length constraints as returned by
* {@link #getPasswordQuality(ComponentName)} and
@@ -413,7 +415,7 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_FORCE_LOCK} to be able to call
* this method; if it has not, a security exception will be thrown.
*
* @param admin Which {@link DeviceAdmin} this request is associated with.
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param timeMs The new desired maximum time to lock in milliseconds.
* A value of 0 means there is no restriction.
*/

View File

@@ -83,7 +83,7 @@
never be encrypted if an Encrypted File System solution
is enabled. Specifically, this is an "opt-out" feature, meaning
that, by default, user data will be encrypted if the EFS feature
is enabled.-->
is enabled. -->
<attr name="neverEncrypt" format="boolean" />
<!-- Option to indicate this application is only for testing purposes.

View File

@@ -1227,10 +1227,9 @@
Resources proposed for Froyo.
=============================================================== -->
<eat-comment />
<public type="attr" name="neverEncrypt" id="0x010102b7" />
<public type="attr" name="installLocation" id="0x010102b8" />
<public type="attr" name="safeMode" id="0x010102b9" />
<public type="attr" name="webTextViewStyle" id="0x010102ba" />
<public type="attr" name="installLocation" id="0x010102b7" />
<public type="attr" name="safeMode" id="0x010102b8" />
<public type="attr" name="webTextViewStyle" id="0x010102b9" />
<public type="anim" name="cycle_interpolator" id="0x010a000c" />

View File

@@ -7,8 +7,9 @@
android:process="system"
android:backupAgent="SettingsBackupAgent"
android:killAfterRestore="false"
android:icon="@drawable/ic_launcher_settings"
android:neverEncrypt="true">
android:icon="@drawable/ic_launcher_settings">
<!-- todo add: android:neverEncrypt="true" -->
<provider android:name="SettingsProvider" android:authorities="settings"
android:multiprocess="false"

View File

@@ -24,7 +24,7 @@ import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
import android.app.Activity;
import android.app.DeviceAdmin;
import android.app.DeviceAdminReceiver;
import android.app.DeviceAdminInfo;
import android.app.DevicePolicyManager;
import android.app.IDevicePolicyManager;
@@ -216,7 +216,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
ActiveAdmin admin = getActiveAdminUncheckedLocked(adminReceiver);
if (admin != null) {
sendAdminCommandLocked(admin,
DeviceAdmin.ACTION_DEVICE_ADMIN_DISABLED);
DeviceAdminReceiver.ACTION_DEVICE_ADMIN_DISABLED);
// XXX need to wait for it to complete.
mAdminList.remove(admin);
mAdminMap.remove(adminReceiver);
@@ -393,7 +393,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
mAdminList.add(admin);
saveSettingsLocked();
sendAdminCommandLocked(admin,
DeviceAdmin.ACTION_DEVICE_ADMIN_ENABLED);
DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -709,7 +709,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
return;
}
Intent intent = new Intent(DeviceAdmin.ACTION_DEVICE_ADMIN_DISABLE_REQUESTED);
Intent intent = new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_DISABLE_REQUESTED);
intent.setComponent(admin.info.getComponent());
mContext.sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
@Override
@@ -738,7 +738,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
mFailedPasswordAttempts = 0;
saveSettingsLocked();
}
sendAdminCommandLocked(DeviceAdmin.ACTION_PASSWORD_CHANGED,
sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_CHANGED,
DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD);
} finally {
Binder.restoreCallingIdentity(ident);
@@ -760,7 +760,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
if (max > 0 && mFailedPasswordAttempts >= max) {
wipeDataLocked(0);
}
sendAdminCommandLocked(DeviceAdmin.ACTION_PASSWORD_FAILED,
sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED,
DeviceAdminInfo.USES_POLICY_WATCH_LOGIN);
} finally {
Binder.restoreCallingIdentity(ident);
@@ -778,7 +778,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
try {
mFailedPasswordAttempts = 0;
saveSettingsLocked();
sendAdminCommandLocked(DeviceAdmin.ACTION_PASSWORD_SUCCEEDED,
sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_SUCCEEDED,
DeviceAdminInfo.USES_POLICY_WATCH_LOGIN);
} finally {
Binder.restoreCallingIdentity(ident);