1page.title=Retail Demo Mode 2@jd:body 3 4<!-- 5 Copyright 2016 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> 28Android 7.1.1 and later offer system-level support for retail mode so 29users may readily examine the devices in action. This feature enables anyone in 30a retail environment to get a quick, safe, and consistent demonstration of an 31Android device and significantly reduce the cost and complexity of a retail mode 32for OEMs so that demonstration units are commonplace. 33</p> 34 35<h2 id="key-use-cases">Key use cases</h2> 36 37<ul> 38<li>Any off-the-shelf Android device can be set to retail mode by adding a 39single demo video to the build. 40<li>All devices have a video highlighting the unique features of the device. 41<li>Devices work in both online and offline environments. 42<li>Device are self maintaining, requiring minimal interaction by 43employees.</li></ul> 44 45<h2 id="lifecycle">Lifecycle</h2> 46 47<img src="images/retail-demo-flow.png" alt="retail demo mode flow" width="XXX" id="retail-demo-flow" /> 48<p class="img-caption"> 49 <strong>Figure 1.</strong> Retail demonstration mode option in Language selection 50</p> 51 52<h3 id="setup-wizard-suw">Setup Wizard (SUW)</h3> 53 54<p> 55Retail employees can enable retail mode directly from the first screen of any setup 56wizard by selecting the language <strong>Retail demo</strong> at the bottom of 57the list. This option is available for new devices shipped fresh from the 58factory. Once a consumer setup has completed, retail mode may no longer be 59available. Once selected, the device finishes SUW with an abbreviated flow. 60</p> 61 62<img src="images/retail-demo-wizard.png" alt="retail demo wizard use" width="XXX" id="retail-demo-wizard" /> 63<p class="img-caption"> 64 <strong>Figure 2.</strong> Retail demonstration mode option in Language 65selection 66</p> 67 68<h3 id="guest-session">Guest session</h3> 69 70<p> 71When the device enters retail mode, it switches to a new demo user and 72automatically starts the custom launcher specified in the overlay resource 73(described under Implementation). By default, this custom launcher plays the 74demo video on repeat until the user touches the screen to begin a guest session. 75At that time, the custom launcher starts the system launcher and then exits. 76OEMs can alter the custom launcher to additionally launch another service or 77activity on exit. See the <em>Implementation</em> section for details. 78</p> 79 80<p> 81In order to maintain the integrity of retail mode, keyguard is disabled and 82certain actions from Quick Settings that could adversely affect retail mode are 83also disallowed, including: 84</p> 85 86<ul> 87 <li>Airplane mode toggle 88 <li>Removing or modifying Wi-Fi access points (Settings) 89 <li>Changing carrier (Settings) 90 <li>Configuring hotspot (Settings) 91 <li>User switching 92</ul> 93 94<p> 95Additionally, access is also blocked to some global settings that can affect 96retail mode by disabling: 97</p> 98 99<ul> 100 <li>Wi-Fi settings 101 <li>Cellular network configuration options, particularly hotspots 102 <li>Bluetooth configuration 103 <li>Backup & Reset, Date & Time, and Mobile Networks (they do not show up at 104all) 105</ul> 106 107<p> 108If the user is idle for some period of time (90 seconds by default), retail mode 109will show a system dialog to prompt the user to either exit the session or 110continue. If the user chooses to exit or if there's no response for five 111seconds, retail mode kills/wipes the current demo user, switches to a new demo 112user, and loops through the original video again. If someone turns off the 113screen using the power button, it comes back on automatically after a few 114seconds. 115</p> 116 117<p> 118After exiting a demo session, devices mute themselves and reset some global 119settings, including: 120</p> 121 122<ul> 123 <li>Brightness 124 <li>Auto-rotation 125 <li>Flashlight 126 <li>Language 127 <li>Accessibility</li></ul> 128 129<h3 id="exiting-retail-mode">Exiting retail mode</h3> 130 131<p> 132In order to exit retail mode, retail employees must factory reset the device 133from the boot loader. 134</p> 135 136<h2 id="examples-and-source">Examples and source</h2> 137 138<p> 139Find the custom launcher that plays a video in a loop within:<br> 140<code>/packages/apps/RetailDemo</code> 141</p> 142 143<h2 id="implementation">Implementation</h2> 144 145<h3 id="enabling-retaildemomodeservice">Enabling RetailDemoModeService</h3> 146 147<p> 148Setup wizard sets a Global setting <code>Global.DEVICE_DEMO_MODE=true</code> to 149indicate that the device has entered retail mode. Upon seeing this setting, 150<code>RetailDemoModeService</code> creates and switches to demo user when user 0 151is started, enables the custom launcher specified in an overlay resource, and 152disables SUW. System Server and SystemUI also use this flag to manage aspects 153of retail mode. 154</p> 155 156<h3 id="setting-custom-launcher-or-video-player">Setting custom launcher or 157video player</h3> 158 159<p> 160An OEM specifies a custom launcher by overriding the framework resource 161<code>config_demoModeLauncherComponent</code> specified in: 162<code>/frameworks/base/core/res/res/config.xml</code> 163</p> 164 165<p> 166For example, with: 167</p> 168 169<pre> 170<!-- Component that is the default launcher when Retail Mode is enabled. --> 171<string name="config_demoModeLauncherComponent">com.android.retaildemo/.DemoPlayer</string> 172</pre> 173<p> 174The retail demo DemoPlayer app located at 175<code>/packages/apps/RetailDemo</code> is the default custom launcher in the 176Android Open Source Project (AOSP). The app looks for a video in 177<code>/data/preloads/demo/retail_demo.mp4</code> and plays it in a loop. When 178the user touches the screen, the custom launcher disables its activity 179component, which results in the default system launcher starting up. 180</p> 181 182<p>The custom launcher must have its custom component marked as disabled by default so that it 183doesn't show up in non-demo scenarios. In the demo scenario, System Server 184enables the specified <code>config_demoModeLauncherComponent</code> when 185starting a new demo session. 186</p> 187 188<p> 189Setup wizard also looks for the above video to provide an affordance to enter 190retail mode. SUW can be modified to look for some other OEM-specific sign that 191retail mode is supported if the video is not a part of the demo. 192</p> 193 194<p> 195If there are system A/B partitions, the system B partition must contain the demo 196video at <code>/preloads/demo</code>. This gets copied to 197<code>/data/preloads/demo</code> on first boot. 198</p> 199 200<p> 201To set retail mode-specific settings, use: 202<code>Settings.Global.retail_demo_mode_constants</code>. E.g.: 203<code>user_inactivity_timeout_ms=90000,warning_dialog_timeout_ms=10000</code> 204</p> 205 206<p class="note"><strong>Note:</strong> 90000 milliseconds is the current 207timeout default but is configurable. 208</p> 209 210<h3 id="finding-sample-images">Finding sample images</h3> 211 212<p> 213This feature places sample photos in a special folder that is visible to any 214gallery app. The photos are available only in demo mode and cannot be modified 215by the demo user as they are in a protected directory. 216</p> 217 218<h3 id="preventing-google-accounts">Preventing Google accounts</h3> 219 220<p> 221Certain restrictions are set in the guest user, similar to managed 222device/profile policies that prevent apps and users from performing certain 223operations. One of these restrictions is <code>DISALLOW_MODIFY_ACCOUNTS</code>. 224With this restriction, AccountManager and Settings do not allow the addition of 225accounts. Some Google apps react to this restriction and show an error message, 226and others will not prompt for an account (such as YouTube and Photos). 227</p> 228 229<p> 230OEM apps should also check if <code>DISALLOW_MODIFY_ACCOUNTS</code> is set. But this is a 231general problem not unique to retail mode. It is likely already solved for 232enterprise use cases. 233</p> 234 235<h3 id="customizing-the-system-launcher">Customizing the system launcher</h3> 236 237<p> 238OEMs are free to choose their layout but should include apps that function well 239on the home screen and hotseat. 240</p> 241 242<h3 id="Customizing-built-in-apps">Customizing built-in apps for retail demo mode</h3> 243 244<p> 245Built-in apps may have their experience for retail demo mode customized by 246calling the API <code>UserManager.isDemoUser()</code> to see if the app is 247launched in a demo environment. 248</p> 249 250<h3 id="following-demo-video-guidelines">Following demo video guidelines</h3> 251 252<p> 253Demonstration videos should be in portrait layout (or natural orientation of the 254device, if tablet) and can be any length greater than five seconds. Content 255should not result in burn-in, since it will be played 24/7 when on display. 256</p> 257 258<h2 id="maintenance">Maintenance</h2> 259 260<h3 id="bringing-the-device-out-of-retail-mode">Bringing the device out of 261retail mode</h3> 262 263<p> 264This can be done only by factory resetting from the boot loader. 265</p> 266 267<h3 id="auto-ota-of-system-software">Auto-OTA of system software</h3> 268 269<p> 270By default, when retail mode is enabled, device policy is set to over-the-air 271(OTA) update automatically. Retail devices will download, reboot, and install 272the update (respecting battery thresholds) without confirmation even if it is 273marked as optional. 274</p> 275 276<p class="caution"><strong>Caution:</strong> 277If using System A/B partitions for OTA, once an OTA is received, the device 278cannot find original retail mode resources in the System B partition. So any 279subsequent factory reset will result in an inability to go back into retail 280mode. 281</p> 282 283<h3 id="updating-demo-video-via-the-web">Updating demo video via the web</h3> 284 285<p> 286The RetailDemo app in <code>/packages/apps/RetailDemo</code> has the ability to 287update the demo video if there is network connectivity. The URL to download the 288video from can be configured by overriding the following string value in the 289RetailDemo app: 290</p> 291 292<pre> 293<!-- URL where the retail demo video can be downloaded from. --> 294<string name="retail_demo_video_download_url"></string> 295</pre> 296 297<p> 298If different videos need to be used in different regions, then different 299download URLs can be configured by using locale-specific string resources 300<code>res/values-*/strings.xml. </code>For example, if different videos need to 301be used in the U.S. and the U.K., then corresponding download URLs can be placed 302in <code>res/values-en-rUS/strings.xml</code> and 303<code>res/values-en-rGB/strings.xml</code>, respectively. 304</p> 305 306<p> 307In <code>res/values-en-rUS/strings.xml</code>: 308</p> 309 310<pre> 311<string name="retail_demo_video_download_url">download URL for US video goes here</string> 312</pre> 313 314<p> 315And similarly in <code>res/values-en-rGB/strings.xml</code>: 316</p> 317 318<pre> 319<string name="retail_demo_video_download_url">download URL for UK video goes here</string> 320</pre> 321 322<p> 323This video will be downloaded at most once per every device reboot. When the 324video on the device is being played, RetailDemo app will check in the background 325if the download URL is provided and the video at the URL is newer than the one 326being played. 327 328<p> 329If so, RetailDemo app will download this video and start playing 330it. Once this video is downloaded, the downloaded video will be used for playing 331in the demo sessions going forward. None of the checks happen again until after 332next reboot. 333</p> 334