1 page.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 28 features required to prepare devices for managed profiles. It also covers device 29 owner 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 32 following 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 36 general 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 40 monitoring and health reporting API that enables applications to query the state 41 of 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 45 protected API, meaning only device/profile owner Device Policy Controller (DPC) 46 applications and the current <code>VrListenerService</code> can call it.</p> 47 48 <p>To support the HardwarePropertiesManager API, the device thermal HAL 49 implementation 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 80 core (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> 85 should not be defined. The framework automatically limits the number of users 86 to 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> 92 android.software.managed_users 93 android.software.device_admin 94 </pre> 95 96 <p>To confirm these <code>uses-feature</code> values have been defined on a 97 device, 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 101 should be enabled as part of provisioning a managed device. OEMs must ensure the 102 managed profile or device has all required applications by modifying:</p> 103 104 <pre>vendor_required_apps_managed_profile.xml 105 vendor_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><resources> 113 <!-- A list of apps to be retained on the managed device --> 114 <string-array name="vendor_required_apps_managed_device"> 115 <item>com.android.vending</item> <!--Google Play --> 116 <item>com.google.android.gms</item> <!--Required by Play --> 117 <item>com.google.android.contacts</item> <!--Google or OEM Contacts--> 118 <item>com.google.android.googlequicksearchbox</item> <!--Google Launcher --> 119 <item>com.google.android.launcher</item> <!--Google Launcher or OEM Launcher --> 120 <item>com.google.android.dialer</item> <!--Google or OEM dialer to enable making phone calls --> 121 </string-array> 122 </resources> 123 </pre> 124 125 <p><code> 126 packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_profile.xml 127 </code></p> 128 129 <pre> 130 <resources> 131 <!-- A list of apps to be retained in the managed profile. This includes any Google experience apps required. --> 132 <string-array name="vendor_required_apps_managed_profile"> 133 <item>com.android.vending</item> <!-- Google Play --> 134 <item>com.google.android.gms</item> <!-- Required by Play --> 135 <item>com.google.android.contacts</item> <!-- Google or OEM Contacts --> 136 </string-array> 137 </resources> 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 143 badge (provided in AOSP to represent the managed applications) and other badge 144 user interface elements such as recents and notifications. If you use 145 <a href="https://android.googlesource.com/platform/packages/apps/Launcher3/">launcher3</a> 146 in AOSP without modifications, then you likely already support this badging 147 feature.</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., 152 setup 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><bool name="enable_nfc_provisioning">true</bool> 156 <item>application/com.android.managedprovisioning</item> 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) 162 should implement device owner provisioning. When the out-of-box experience 163 opens, it should check if another process (such as device owner provisioning) 164 has already finished the user setup and, if so, it should fire a home intent 165 and finish the setup. This intent is caught by the provisioning application, 166 which 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 169 activity:</p> 170 171 <pre>@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