docs: a few style adjustments to admin doc
Change-Id: I1ea2416f1f26835b1111aad65cc519dd8d56e099
This commit is contained in:
@@ -1,24 +1,33 @@
|
|||||||
page.title=Android Device Administration API
|
page.title=Device Administration
|
||||||
@jd:body
|
@jd:body
|
||||||
|
|
||||||
<div id="qv-wrapper">
|
<div id="qv-wrapper">
|
||||||
<div id="qv">
|
<div id="qv">
|
||||||
<h2>In this document</h2>
|
<h2>In this document</h2>
|
||||||
<ol>
|
<ol>
|
||||||
<li><a href="#overview">Device Administration API Overview</a>
|
<li><a href="#overview">Device Administration API Overview</a>
|
||||||
<ol>
|
<ol>
|
||||||
|
<li><a href="#how">How does it work?</a></li>
|
||||||
<li><a href="#policies">Policies</a></li>
|
<li><a href="#policies">Policies</a></li>
|
||||||
</ol>
|
</ol>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#how">How Does It Work?</a></li>
|
|
||||||
<li><a href="#sample">Sample Application</a></li>
|
<li><a href="#sample">Sample Application</a></li>
|
||||||
<li><a href="#developing">Developing a Device Administration Application</a>
|
<li><a href="#developing">Developing a Device Administration Application</a>
|
||||||
<ol>
|
<ol>
|
||||||
<li><a href="#manifest">Creating the Manifest</a></li>
|
<li><a href="#manifest">Creating the manifest</a></li>
|
||||||
<li><a href="#code">Implementing the Code</a>
|
<li><a href="#code">Implementing the code</a></li>
|
||||||
</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<h2>Key classes</h2>
|
||||||
|
<ol>
|
||||||
|
<li>{@link android.app.admin.DeviceAdminReceiver}</li>
|
||||||
|
<li>{@link android.app.admin.DevicePolicyManager}</li>
|
||||||
|
<li>{@link android.app.admin.DeviceAdminInfo}</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>Android 2.2 introduces support for enterprise applications by offering the
|
<p>Android 2.2 introduces support for enterprise applications by offering the
|
||||||
@@ -37,7 +46,10 @@ their email and calendar data.</p>
|
|||||||
solutions for Android-powered devices. It discusses the various features
|
solutions for Android-powered devices. It discusses the various features
|
||||||
provided by the Device Administration API to provide stronger security for
|
provided by the Device Administration API to provide stronger security for
|
||||||
employee devices that are powered by Android.</p>
|
employee devices that are powered by Android.</p>
|
||||||
|
|
||||||
|
|
||||||
<h2 id="overview">Device Administration API Overview</h2>
|
<h2 id="overview">Device Administration API Overview</h2>
|
||||||
|
|
||||||
<p>Here are examples of the types of applications that might use the Device Administration API:</p>
|
<p>Here are examples of the types of applications that might use the Device Administration API:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Email clients.</li>
|
<li>Email clients.</li>
|
||||||
@@ -45,7 +57,7 @@ employee devices that are powered by Android.</p>
|
|||||||
<li>Device management services and applications.</li>
|
<li>Device management services and applications.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3 id="how">How Does it Work?</h3>
|
<h3 id="how">How does it work?</h3>
|
||||||
<p>You use the Device Administration API to write device admin applications that users
|
<p>You use the Device Administration API to write device admin applications that users
|
||||||
install on their devices. The device admin application enforces the desired
|
install on their devices. The device admin application enforces the desired
|
||||||
policies. Here's how it works:</p> <ul>
|
policies. Here's how it works:</p> <ul>
|
||||||
@@ -88,7 +100,9 @@ application.</p>
|
|||||||
<p>To uninstall an existing device admin application, users need to
|
<p>To uninstall an existing device admin application, users need to
|
||||||
first unregister the application as an administrator. </p>
|
first unregister the application as an administrator. </p>
|
||||||
|
|
||||||
<h3 id ="policies">Policies</h3>
|
|
||||||
|
<h3 id="policies">Policies</h3>
|
||||||
|
|
||||||
<p>In an enterprise setting, it's often the case that employee devices must
|
<p>In an enterprise setting, it's often the case that employee devices must
|
||||||
adhere to a strict set of policies that govern the use of the device. The
|
adhere to a strict set of policies that govern the use of the device. The
|
||||||
Device Administration API supports the policies listed in Table 1.
|
Device Administration API supports the policies listed in Table 1.
|
||||||
@@ -128,7 +142,9 @@ pressed a button before the device locks the screen. When this happens, users
|
|||||||
need to enter their PIN or passwords again before they can use their devices and
|
need to enter their PIN or passwords again before they can use their devices and
|
||||||
access data. The value can be between 1 and 60 minutes.</td> </tr>
|
access data. The value can be between 1 and 60 minutes.</td> </tr>
|
||||||
</table>
|
</table>
|
||||||
<h4>Other Features</h4>
|
|
||||||
|
<h4>Other features</h4>
|
||||||
|
|
||||||
<p>In addition to supporting the policies listed in the above table, the Device
|
<p>In addition to supporting the policies listed in the above table, the Device
|
||||||
Administration API lets you do the following:</p> <ul>
|
Administration API lets you do the following:</p> <ul>
|
||||||
<li>Prompt user to set a new password.</li>
|
<li>Prompt user to set a new password.</li>
|
||||||
@@ -138,6 +154,7 @@ Administration API lets you do the following:</p> <ul>
|
|||||||
|
|
||||||
|
|
||||||
<h2 id="sample">Sample Application</h2>
|
<h2 id="sample">Sample Application</h2>
|
||||||
|
|
||||||
<p>The examples used in this document are based on the <a
|
<p>The examples used in this document are based on the <a
|
||||||
href="{@docRoot}resources/samples/ApiDemos/src/com/example/
|
href="{@docRoot}resources/samples/ApiDemos/src/com/example/
|
||||||
android/apis/app/DeviceAdminSample.html">Device Administration API
|
android/apis/app/DeviceAdminSample.html">Device Administration API
|
||||||
@@ -169,13 +186,17 @@ locks.</li>
|
|||||||
<img src="{@docRoot}images/admin/device-admin-app.png"/>
|
<img src="{@docRoot}images/admin/device-admin-app.png"/>
|
||||||
<p class="img-caption"><strong>Figure 1.</strong> Screenshot of the Sample Application</p>
|
<p class="img-caption"><strong>Figure 1.</strong> Screenshot of the Sample Application</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2 id="developing">Developing a Device Administration Application</h2>
|
<h2 id="developing">Developing a Device Administration Application</h2>
|
||||||
|
|
||||||
<p>System administrators can use the Device Administration API to write an application
|
<p>System administrators can use the Device Administration API to write an application
|
||||||
that enforces remote/local device security policy enforcement. This section
|
that enforces remote/local device security policy enforcement. This section
|
||||||
summarizes the steps involved in creating a device administration
|
summarizes the steps involved in creating a device administration
|
||||||
application.</p>
|
application.</p>
|
||||||
<h3 id="manifest">Creating the Manifest</h3>
|
|
||||||
|
<h3 id="manifest">Creating the manifest</h3>
|
||||||
|
|
||||||
<p>To use the Device Administration API, the application's
|
<p>To use the Device Administration API, the application's
|
||||||
manifest must include the following:</p>
|
manifest must include the following:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -274,7 +295,11 @@ include all of the policies, just the ones that are relevant for your app.
|
|||||||
</p>
|
</p>
|
||||||
For more discussion of the manifest file, see the <a
|
For more discussion of the manifest file, see the <a
|
||||||
href="{@docRoot}guide/topics/manifest/manifest-intro.html">Android Developers Guide</a>.
|
href="{@docRoot}guide/topics/manifest/manifest-intro.html">Android Developers Guide</a>.
|
||||||
<h2 id="code">Implementing the Code</h2>
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3 id="code">Implementing the code</h3>
|
||||||
|
|
||||||
<p>The Device Administration API includes the following classes:</p>
|
<p>The Device Administration API includes the following classes:</p>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>{@link android.app.admin.DeviceAdminReceiver}</dt>
|
<dt>{@link android.app.admin.DeviceAdminReceiver}</dt>
|
||||||
@@ -295,6 +320,7 @@ for a device administrator component.</dd>
|
|||||||
The rest of this section describes how you use the {@link
|
The rest of this section describes how you use the {@link
|
||||||
android.app.admin.DeviceAdminReceiver} and
|
android.app.admin.DeviceAdminReceiver} and
|
||||||
{@link android.app.admin.DevicePolicyManager} APIs to write a device admin application.</p>
|
{@link android.app.admin.DevicePolicyManager} APIs to write a device admin application.</p>
|
||||||
|
|
||||||
<h4 id="receiver">Subclassing DeviceAdminReceiver</h4>
|
<h4 id="receiver">Subclassing DeviceAdminReceiver</h4>
|
||||||
<p>To create a device admin application, you must subclass
|
<p>To create a device admin application, you must subclass
|
||||||
{@link android.app.admin.DeviceAdminReceiver}. The {@link android.app.admin.DeviceAdminReceiver} class
|
{@link android.app.admin.DeviceAdminReceiver}. The {@link android.app.admin.DeviceAdminReceiver} class
|
||||||
@@ -331,7 +357,8 @@ events. For example:</p>
|
|||||||
}
|
}
|
||||||
...
|
...
|
||||||
}</pre>
|
}</pre>
|
||||||
<h4 id="enabling">Enabling the Application</h4>
|
|
||||||
|
<h4 id="enabling">Enabling the application</h4>
|
||||||
<p>One of the major events a device admin application has to handle is the user
|
<p>One of the major events a device admin application has to handle is the user
|
||||||
enabling the application. The user must explicitly enable the application for
|
enabling the application. The user must explicitly enable the application for
|
||||||
the policies to be enforced. If the user chooses not to enable the application
|
the policies to be enforced. If the user chooses not to enable the application
|
||||||
@@ -343,12 +370,13 @@ intent. In the
|
|||||||
sample application, this happens when the user clicks the <strong>Enable
|
sample application, this happens when the user clicks the <strong>Enable
|
||||||
Admin</strong> button. </p>
|
Admin</strong> button. </p>
|
||||||
<p>When the user clicks the <strong>Enable Admin</strong> button, the display
|
<p>When the user clicks the <strong>Enable Admin</strong> button, the display
|
||||||
changes to prompt the user to enable the device admin application, as shown in <strong>Figure 2</strong>.</p>
|
changes to prompt the user to enable the device admin application, as shown in figure
|
||||||
|
2.</p>
|
||||||
|
|
||||||
<img src="{@docRoot}images/admin/device-admin-activate-prompt.png"/>
|
<img src="{@docRoot}images/admin/device-admin-activate-prompt.png"/>
|
||||||
<p class="img-caption"><strong>Figure 2.</strong> Sample Application: Activating the Application</p>
|
<p class="img-caption"><strong>Figure 2.</strong> Sample Application: Activating the Application</p>
|
||||||
<p>Below is the code that gets executed when the user clicks the <strong>Enable
|
<p>Below is the code that gets executed when the user clicks the <strong>Enable
|
||||||
Admin</strong> button shown in <strong>Figure 1</strong>. </p>
|
Admin</strong> button shown in figure 1. </p>
|
||||||
|
|
||||||
<pre> private OnClickListener mEnableListener = new OnClickListener() {
|
<pre> private OnClickListener mEnableListener = new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -382,7 +410,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|||||||
<code>intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
|
<code>intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
|
||||||
mDeviceAdminSample)</code> states that <code>mDeviceAdminSample</code> (which is
|
mDeviceAdminSample)</code> states that <code>mDeviceAdminSample</code> (which is
|
||||||
a {@link android.app.admin.DeviceAdminReceiver} component) is the target policy.
|
a {@link android.app.admin.DeviceAdminReceiver} component) is the target policy.
|
||||||
This line invokes the user interface shown in <strong>Figure 2</strong>, which guides users through
|
This line invokes the user interface shown in figure 2, which guides users through
|
||||||
adding the device administrator to the system (or allows them to reject it).</p>
|
adding the device administrator to the system (or allows them to reject it).</p>
|
||||||
|
|
||||||
<p>When the application needs to perform an operation that is contingent on the
|
<p>When the application needs to perform an operation that is contingent on the
|
||||||
@@ -402,14 +430,16 @@ if (active) {
|
|||||||
// do something else
|
// do something else
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<h3 id="admin_ops">Managing Policies</h3>
|
|
||||||
|
<h3 id="admin_ops">Managing policies</h3>
|
||||||
<p>{@link android.app.admin.DevicePolicyManager} is a public class for managing policies
|
<p>{@link android.app.admin.DevicePolicyManager} is a public class for managing policies
|
||||||
enforced on a device. {@link android.app.admin.DevicePolicyManager} manages policies for one
|
enforced on a device. {@link android.app.admin.DevicePolicyManager} manages policies for one
|
||||||
or more {@link android.app.admin.DeviceAdminReceiver} instances. </p>
|
or more {@link android.app.admin.DeviceAdminReceiver} instances. </p>
|
||||||
<p>You get a handle to the {@link android.app.admin.DevicePolicyManager} as follows: </p>
|
<p>You get a handle to the {@link android.app.admin.DevicePolicyManager} as follows: </p>
|
||||||
<pre>DevicePolicyManager mDPM =
|
<pre>
|
||||||
(DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);<br
|
DevicePolicyManager mDPM =
|
||||||
/></pre>
|
(DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
|
</pre>
|
||||||
<p>This section describes how to use {@link android.app.admin.DevicePolicyManager} to perform
|
<p>This section describes how to use {@link android.app.admin.DevicePolicyManager} to perform
|
||||||
administrative tasks:</p>
|
administrative tasks:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -417,15 +447,18 @@ or more {@link android.app.admin.DeviceAdminReceiver} instances. </p>
|
|||||||
<li><a href="#lock">Set device lock</a></li>
|
<li><a href="#lock">Set device lock</a></li>
|
||||||
<li><a href="#wipe">Perform data wipe</a></li>
|
<li><a href="#wipe">Perform data wipe</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h4 id="pwd">Set password policies</h4>
|
<h4 id="pwd">Set password policies</h4>
|
||||||
<p>{@link android.app.admin.DevicePolicyManager} includes APIs for setting and enforcing the
|
<p>{@link android.app.admin.DevicePolicyManager} includes APIs for setting and enforcing the
|
||||||
device password policy. In the Device Administration API, the password only applies to
|
device password policy. In the Device Administration API, the password only applies to
|
||||||
screen lock. This section describes common password-related tasks.</p>
|
screen lock. This section describes common password-related tasks.</p>
|
||||||
|
|
||||||
<h5>Set a password for the device</h5>
|
<h5>Set a password for the device</h5>
|
||||||
<p>This code displays a user interface prompting the user to set a password:</p>
|
<p>This code displays a user interface prompting the user to set a password:</p>
|
||||||
<pre>Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
|
<pre>Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h5>Set the password quality</h5>
|
<h5>Set the password quality</h5>
|
||||||
<p>The password quality can be one of the following {@link android.app.admin.DevicePolicyManager} constants: </p>
|
<p>The password quality can be one of the following {@link android.app.admin.DevicePolicyManager} constants: </p>
|
||||||
<dl>
|
<dl>
|
||||||
@@ -448,6 +481,7 @@ ComponentName mDeviceAdminSample;
|
|||||||
...
|
...
|
||||||
mDPM.setPasswordQuality(mDeviceAdminSample, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
|
mDPM.setPasswordQuality(mDeviceAdminSample, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h5>Set the minimum password length</h5>
|
<h5>Set the minimum password length</h5>
|
||||||
<p>You can specify that a password must be at least the specified minimum
|
<p>You can specify that a password must be at least the specified minimum
|
||||||
length. For example:</p>
|
length. For example:</p>
|
||||||
@@ -457,6 +491,7 @@ int pwLength;
|
|||||||
...
|
...
|
||||||
mDPM.setPasswordMinimumLength(mDeviceAdminSample, pwLength);
|
mDPM.setPasswordMinimumLength(mDeviceAdminSample, pwLength);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h5>Set maximum failed password attempts</h5>
|
<h5>Set maximum failed password attempts</h5>
|
||||||
<p>You can set the maximum number of allowed failed password attempts before the
|
<p>You can set the maximum number of allowed failed password attempts before the
|
||||||
device is wiped (that is, reset to factory settings). For example:</p>
|
device is wiped (that is, reset to factory settings). For example:</p>
|
||||||
@@ -465,6 +500,7 @@ ComponentName mDeviceAdminSample;
|
|||||||
int maxFailedPw;
|
int maxFailedPw;
|
||||||
...
|
...
|
||||||
mDPM.setMaximumFailedPasswordsForWipe(mDeviceAdminSample, maxFailedPw);</pre>
|
mDPM.setMaximumFailedPasswordsForWipe(mDeviceAdminSample, maxFailedPw);</pre>
|
||||||
|
|
||||||
<h4 id="lock">Set device lock</h4>
|
<h4 id="lock">Set device lock</h4>
|
||||||
<p>You can set the maximum period of user inactivity that can occur before the
|
<p>You can set the maximum period of user inactivity that can occur before the
|
||||||
device locks. For example:</p>
|
device locks. For example:</p>
|
||||||
@@ -479,7 +515,9 @@ mDPM.setMaximumTimeToLock(mDeviceAdminSample, timeMs);
|
|||||||
<pre>
|
<pre>
|
||||||
DevicePolicyManager mDPM;
|
DevicePolicyManager mDPM;
|
||||||
mDPM.lockNow();</pre>
|
mDPM.lockNow();</pre>
|
||||||
|
|
||||||
<h4 id="wipe">Perform data wipe</h4>
|
<h4 id="wipe">Perform data wipe</h4>
|
||||||
|
|
||||||
<p>You can use the {@link android.app.admin.DevicePolicyManager} method
|
<p>You can use the {@link android.app.admin.DevicePolicyManager} method
|
||||||
{@link android.app.admin.DevicePolicyManager#wipeData wipeData()} to reset the device to factory settings. This is useful
|
{@link android.app.admin.DevicePolicyManager#wipeData wipeData()} to reset the device to factory settings. This is useful
|
||||||
if the device is lost or stolen. Often the decision to wipe the device is the
|
if the device is lost or stolen. Often the decision to wipe the device is the
|
||||||
|
|||||||
Reference in New Issue
Block a user