1page.title=Supporting Multiple Users 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 document describes the Android multi-user feature. It allows more than one 28user on a single Android device by separating their accounts and application 29data. For instance, parents may let their children use the family tablet. Or a 30critical team might share a mobile device for on-call duty.</p> 31 32<h1 id=definitions>Definitions</h1> 33 34<p>Before supporting multiple Android users, you should understand the basic 35concepts involved. Here are the primary terms used when describing Android 36users and accounts:</p> 37 38<ul> 39 <li><em>User</em> - Each user is intended to be used by a different physical person. Each user 40has distinct application data and some unique settings, as well as a user 41interface to explicitly switch between users. A user can run in the background 42when another user is active; the system manages shutting down users to conserve 43resources when appropriate. Secondary users can be created either directly via 44the primary user interface or from a <a 45href="https://developer.android.com/guide/topics/admin/device-admin.html">Device 46Administration</a> application. 47 <li><em>Account</em> - Accounts are contained within a user but are not defined by a user. Nor is a 48user defined by or linked to any given account. Users and profiles contain 49their own unique accounts but are not required to have accounts to be 50functional. The list of accounts differs by user. See the <a href="https://developer.android.com/reference/android/accounts/Account.html">Account class</a> definition. 51 <li><em>Profile<strong></em> </strong>- A profile has separated app data but shares some system-wide settings (for 52example, Wi-Fi and Bluetooth). A profile is a subset of and tied to the 53existence of a user. A user can have multiple profiles. They are created 54through a <a href="https://developer.android.com/guide/topics/admin/device-admin.html">Device 55Administration</a> application. A profile always has an immutable 56association to a ‘parent’ user, defined by the user that created the profile. 57Profiles do not live beyond the lifetime of the creating user. 58 <li><em>App</em> - An application’s data exists within each associated user. App data is 59sandboxed from other applications within the same user. Apps within the same 60user can interact with each other via IPC. See <a href="https://developer.android.com/training/enterprise/index.html">Building Apps for Work</a>. 61</ul> 62 63<h2 id=user_types>User types</h2> 64 65<ul> 66 <li><em>Primary</em> - The first user added to a device. The primary user cannot be removed except 67by factory reset. This user also has some special privileges and settings only 68it can set. The primary user is always running even when other users are in the 69foreground. 70 <li><em>Secondary</em> - Any user added to the device other than the primary user. They can be 71removed by either themselves or the primary user and cannot impact other users 72on a device. Secondary users can run in the background and will continue to 73have network connectivity when they do. 74 <li><em>Guest<strong></em> </strong>- A guest user is a temporary secondary user with an explicit option to quick 75delete the guest user when its usefulness is over. There can be only one guest 76user at a time. 77</ul> 78 79<h2 id=profile_types>Profile types</h2> 80 81<ul> 82 <li><em>Managed<strong></em> </strong>- Managed profiles are created by an application to contain work data and 83apps. They are managed exclusively by the ‘profile owner’, the app who created 84the corp profile. Launcher, notifications and recent tasks are shared by the 85primary user and the corp profile. 86 <li><em>Restricted</em> - Restricted profiles use the accounts based off the primary user. The Primary 87user can control what apps are available on the restricted profile. Restricted 88profiles are available only on tablets. 89</ul> 90 91<h1 id=effects>Effects</h1> 92 93<p>When users are added to a device, some functionality will be curtailed when 94another user is in the foreground. Since app data is separated by user, the 95state of those apps differs by user. For example, email destined for an account 96of a user not currently in focus won’t be available until that user and account 97are active on the device.</p> 98 99<p>The default state is only the primary user has full access to phone calls and 100texts. The secondary user may receive inbound calls but cannot send or receive 101texts. The primary user must enable these functions for others.</p> 102 103 <p class="note"><strong>Note</strong>: To enable or disable the phone and SMS functions for a secondary user, go to 104Settings > Users, select the user, and switch the <em>Allow phone calls and SMS</em> setting to off.</p> 105 106<p>Please note, some restrictions exist when a secondary user is in background. 107For instance, the background secondary user will not be able to display the 108user interface or make Bluetooth services active. Finally, background secondary 109users will be halted by the system process if the device needs additional 110memory for operations in the foreground user.</p> 111 112<p>Here are aspects of behavior to keep in mind when employing multiple users on 113an Android device:</p> 114 115<ul> 116 <li>Notifications appear for all accounts of a single user at once. 117 <li>Notifications for other users do not appear until they are active. 118 <li>Each user gets his or her own workspace to install and place apps. 119 <li>No user has access to the app data of another user. 120 <li>Any user can affect the installed apps for all users. 121 <li>The primary user can remove apps or even the entire workspace established by 122secondary users. 123</ul> 124 125<h1 id=implementation>Implementation</h1> 126 127<h2 id=managing_users>Managing users</h2> 128 129<p>Management of users and profiles (with the exception of restricted profiles) is 130performed by applications that programmatically invoke API in the <code>DevicePolicyManager</code> class to restrict use.</p> 131 132<p>Schools and enterprises may employ users and profiles to manage the lifetime 133and scope of apps and data on devices. They may use the types outlined above in 134conjunction with the <a href="http://developer.android.com/reference/android/os/UserManager.html">UserManager API</a> to build unique solutions tailored to their use cases.</p> 135 136<h2 id=applying_the_overlay>Applying the overlay</h2> 137 138<p>The multi-user feature is disabled by default in the Android 5.0 release. To 139enable it, device manufacturers must define a resource overlay that replaces 140the following values in frameworks/base/core/res/res/values/config.xml:</p> 141 142<pre> 143<!-- Maximum number of supported users --> 144<integer name="config_multiuserMaximumUsers">1</integer> 145<!-- Whether Multiuser UI should be shown --> 146<bool name="config_enableMultiUserUI">false</bool> 147</pre> 148 149<p>To apply this overlay and enable guest and secondary users on the device, use the 150<code>DEVICE_PACKAGE_OVERLAYS</code> feature of the Android build system to:</p> 151 152<ul> 153 <li> Replace the value for <code>config_multiuserMaximumUsers</code> with one greater than 1 154 <li> Replace the value of <code>config_enableMultiUserUI</code> with: <code>true</code> 155</ul> 156 157<p>Device manufacturers may decide upon the maximum number of users.</p> 158 159<p>That said, if device manufacturers or others have modified settings, they need 160to ensure SMS and telephony work as defined in the <a 161href="{@docRoot}compatibility/android-cdd.pdf">Android Compatibility Definition 162Document</a> (CDD).</p> 163