• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=Implementing Device Administration
2@jd:body
3
4<!--
5    Copyright 2015 The Android Open Source Project
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18-->
19<div id="qv-wrapper">
20  <div id="qv">
21    <h2>In this document</h2>
22    <ol id="auto-toc">
23    </ol>
24  </div>
25</div>
26
27<p>This section describes how to enable and validate device administration
28features required to prepare devices for managed profiles. It also covers device
29owner user cases that are essential in a corporate environment.</p>
30
31<p>In addition to Android Open Source Project (AOSP) code, a device requires the
32following components to function with managed profiles.</p>
33
34<h2 id=requirements>General requirements</h2>
35<p>Devices intending to support device administration must meet the following
36general requirements.</p>
37
38<h3 id=HAL_values>Thermal HAL values</h3>
39<p>Android 7.0 includes support for HardwarePropertiesManager API, a new device
40monitoring and health reporting API that enables applications to query the state
41of device hardware. This API is exposed via
42<code>android.os.HardwarePropertiesManager</code> and makes calls through
43<code>HardwarePropertiesManagerService</code> to the hardware thermal HAL
44(<code>hardware/libhardware/include/hardware/thermal.h</code>). It is a
45protected API, meaning only device/profile owner Device Policy Controller (DPC)
46applications and the current <code>VrListenerService</code> can call it.</p>
47
48<p>To support the HardwarePropertiesManager API, the device thermal HAL
49implementation must be able to report the following values:</p>
50
51<table>
52<tr>
53<th width="32%">Value</th>
54<th>Reporting Scale</th>
55<th>Enables</th>
56</tr>
57
58<tr>
59  <td>Temperature of [CPU|GPU|Battery|Device Skin]</td>
60  <td>Temperature of component in degrees Celsius</td>
61  <td>Apps can check device temperatures and component throttling/shutdown
62  temperatures</td>
63</tr>
64
65<tr>
66  <td>CPU active/total enabled times</td>
67  <td>Time in milliseconds</td>
68  <td>Apps can check CPU usage per core</td>
69</tr>
70
71<tr>
72  <td>Fan speed</td>
73  <td>RPM</td>
74  <td>Apps can check fan speed</td>
75</tr>
76
77</table>
78
79<p>Implementations should correctly handle reporting values situations when a
80core (or GPU, battery, fan) goes offline or is plugged/unplugged.</p>
81
82
83<h3 id=low_ram>No low-RAM</h3>
84<p>Device should not be a low-RAM device, meaning <code>ro.config.low_ram</code>
85should not be defined. The framework automatically limits the number of users
86to 1 when the <code>low_ram</code> flag is defined.</p>
87
88<h3 id=uses-feature>Uses-feature</h3>
89<p>Devices must define the following <code>uses-feature</code>:</p>
90
91<pre>
92android.software.managed_users
93android.software.device_admin
94</pre>
95
96<p>To confirm these <code>uses-feature</code> values have been defined on a
97device, run: <code>adb shell pm list features</code>.</p>
98
99<h3 id=required_apps>Essential apps only</h3>
100<p>By default, only applications essential for correct operation of the profile
101should be enabled as part of provisioning a managed device. OEMs must ensure the
102managed profile or device has all required applications by modifying:</p>
103
104<pre>vendor_required_apps_managed_profile.xml
105vendor_required_apps_managed_device.xml
106</pre>
107
108<p>Examples from a Nexus device:</p>
109
110<p><code>packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_device.xml</code></p>
111
112<pre>&lt;resources&gt;
113  &lt;!-- A list of apps to be retained on the managed device --&gt;
114  &lt;string-array name="vendor_required_apps_managed_device"&gt;
115    &lt;item&gt;com.android.vending&lt;/item&gt; &lt;!--­Google Play --&gt;
116    &lt;item&gt;com.google.android.gms&lt;/item&gt; &lt;!--­Required by Play --&gt;
117    &lt;item&gt;com.google.android.contacts&lt;/item&gt; &lt;!--­Google or OEM Contacts­--&gt;
118    &lt;item&gt;com.google.android.googlequicksearchbox&lt;/item&gt; &lt;!--­Google Launcher --&gt;
119    &lt;item&gt;com.google.android.launcher&lt;/item&gt; &lt;!--­Google Launcher or OEM Launcher --&gt;
120    &lt;item&gt;com.google.android.dialer&lt;/item&gt; &lt;!--­Google or OEM dialer to enable making phone calls --&gt;
121  &lt;/string-array&gt;
122&lt;/resources&gt;
123</pre>
124
125<p><code>
126packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_profile.xml
127</code></p>
128
129<pre>
130&lt;resources&gt;
131    &lt;!-- A list of apps to be retained in the managed profile. This includes any Google experience apps required. --&gt;
132    &lt;string-array name="vendor_required_apps_managed_profile"&gt;
133        &lt;item&gt;com.android.vending&lt;/item&gt; &lt;!-- Google Play --&gt;
134        &lt;item&gt;com.google.android.gms&lt;/item&gt; &lt;!-- Required by Play --&gt;
135        &lt;item&gt;com.google.android.contacts&lt;/item&gt; &lt;!-- Google or OEM Contacts --&gt;
136    &lt;/string-array&gt;
137&lt;/resources&gt;
138</pre>
139
140<h2 id=launcher>Launcher requirements</h2>
141
142<p>You must update the Launcher to support badging applications with the icon
143badge (provided in AOSP to represent the managed applications) and other badge
144user interface elements such as recents and notifications. If you use
145<a href="https://android.googlesource.com/platform/packages/apps/Launcher3/">launcher3</a>
146in AOSP without modifications, then you likely already support this badging
147feature.</p>
148
149<h2 id=nfc>NFC requirements</h2>
150
151<p>Devices with NFC must enable NFC during the out-of-the-box experience (i.e.,
152setup wizard) and be configured to accept managed provisioning intents:</p>
153
154<p><code>packages/apps/Nfc/res/values/provisioning.xml</code></p>
155<pre>&lt;bool name="enable_nfc_provisioning"&gt;true&lt;/bool&gt;
156&lt;item>application/com.android.managedprovisioning&lt;/item&gt;
157</pre>
158
159<h2 id=setup_wizard>Setup requirements</h2>
160
161<p>Devices that include an out-of-box experience (i.e., setup wizard)
162should implement device owner provisioning. When the out-of-box experience
163opens, it should check if another process (such as device owner provisioning)
164has already finished the user setup and, if so, it should fire a home intent
165and finish the setup. This intent is caught by the provisioning application,
166which then hands control to the newly-set device owner.</p>
167
168<p>To meet setup requirements, add the following code to the device setup's main
169activity:</p>
170
171<pre>&#64;Override
172   protected void onStart() {
173        super.onStart();
174
175        // When returning to a setup wizard activity, check to see if another setup process
176        // has intervened and, if so, complete an orderly exit
177        boolean completed = Settings.Secure.getInt(getContentResolver(),
178                Settings.Secure.USER_SETUP_COMPLETE, 0) != 0;
179        if (completed) {
180           startActivity(new Intent(Intent.ACTION_MAIN, null)
181                .addCategory(Intent.CATEGORY_HOME)
182                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
183                        | Intent.FLAG_ACTIVITY_CLEAR_TASK
184                        | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED));
185           finish();
186       }
187
188       ...
189   }
190</pre>
191