1# Demo Mode for the Android System UI
2*Demo mode for the status bar allows you to force the status bar into a fixed state, useful for taking screenshots with a consistent status bar state, or testing different status icon permutations. Demo mode is available in recent versions of Android.*
3
4## Enabling demo mode
5Demo mode is protected behind a system setting. To enable it for a device, run:
6
7```
8adb shell settings put global sysui_demo_allowed 1
9```
10
11## Protocol
12The protocol is based on broadcast intents, and thus can be driven via the command line (```adb shell am broadcast```) or an app (```Context.sendBroadcast```).
13
14### Broadcast action
15```
16com.android.systemui.demo
17```
18
19### Commands
20Commands and subcommands (below) are sent as string extras in the broadcast
21intent.
22<br/>
23Commands are sent as string extras with key ```command``` (required). Possible values are:
24
25Command              | Subcommand                 | Argument       | Description
26---                  | ---                        | ---            | ---
27```enter```          |                            |                | Enters demo mode, bar state allowed to be modified (for convenience, any of the other non-exit commands will automatically flip demo mode on, no need to call this explicitly in practice)
28```exit```           |                            |                | Exits demo mode, bars back to their system-driven state
29```battery```        |                            |                | Control the battery display
30                     | ```level```                |                | Sets the battery level (0 - 100)
31                     | ```plugged```              |                | Sets charging state (```true```, ```false```)
32                     | ```powersave```            |                | Sets power save mode (```true```, ```anything else```)
33```network```        |                            |                | Control the RSSI display
34                     | ```airplane```             |                | ```show``` to show icon, any other value to hide
35                     | ```fully```                |                | Sets MCS state to fully connected (```true```, ```false```)
36                     | ```wifi```                 |                | ```show``` to show icon, any other value to hide
37                     |                            | ```level```    | Sets wifi level (null or 0-4)
38                     | ```mobile```               |                | ```show``` to show icon, any other value to hide
39                     |                            | ```datatype``` | Values: ```1x```, ```3g```, ```4g```, ```e```, ```g```, ```h```, ```lte```, ```roam```, any other value to hide
40                     |                            | ```level```    | Sets mobile signal strength level (null or 0-4)
41                     | ```carriernetworkchange``` |                | Sets mobile signal icon to carrier network change UX when disconnected (```show``` to show icon, any other value to hide)
42                     | ```sims```                 |                | Sets the number of sims (1-8)
43                     | ```nosim```                |                | ```show``` to show icon, any other value to hide
44```bars```           |                            |                | Control the visual style of the bars (opaque, translucent, etc)
45                     | ```mode```                 |                | Sets the bars visual style (opaque, translucent, semi-transparent)
46```status```         |                            |                | Control the system status icons
47                     | ```volume```               |                | Sets the icon in the volume slot (```silent```, ```vibrate```, any other value to hide)
48                     | ```bluetooth```            |                | Sets the icon in the bluetooth slot (```connected```, ```disconnected```, any other value to hide)
49                     | ```location```             |                | Sets the icon in the location slot (```show```, any other value to hide)
50                     | ```alarm```                |                | Sets the icon in the alarm_clock slot (```show```, any other value to hide)
51                     | ```sync```                 |                | Sets the icon in the sync_active slot (```show```, any other value to hide)
52                     | ```tty```                  |                | Sets the icon in the tty slot (```show```, any other value to hide)
53                     | ```eri```                  |                | Sets the icon in the cdma_eri slot (```show```, any other value to hide)
54                     | ```mute```                 |                | Sets the icon in the mute slot (```show```, any other value to hide)
55                     | ```speakerphone```         |                | Sets the icon in the speakerphone slot (```show```, any other value to hide)
56```notifications```  |                            |                | Control the notification icons
57                     | ```visible```              |                | ```false``` to hide the notification icons, any other value to show
58```clock```          |                            |                | Control the clock display
59                     | ```millis```               |                | Sets the time in millis
60                     | ```hhmm```                 |                | Sets the time in hh:mm
61
62## Examples
63Enter demo mode
64
65```
66adb shell am broadcast -a com.android.systemui.demo -e command enter
67```
68
69
70Exit demo mode
71
72```
73adb shell am broadcast -a com.android.systemui.demo -e command exit
74```
75
76
77Set the clock to 12:31
78
79```
80adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm
811231
82```
83
84
85Set the wifi level to max
86
87```
88adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi
89show -e level 4
90```
91
92
93Show the silent volume icon
94
95```
96adb shell am broadcast -a com.android.systemui.demo -e command status -e volume
97silent
98```
99
100
101Empty battery, and not charging (red exclamation point)
102
103```
104adb shell am broadcast -a com.android.systemui.demo -e command battery -e level
1050 -e plugged false
106```
107
108
109Hide the notification icons
110
111```
112adb shell am broadcast -a com.android.systemui.demo -e command notifications -e
113visible false
114```
115
116
117Exit demo mode
118
119```
120adb shell am broadcast -a com.android.systemui.demo -e command exit
121```
122
123
124## Example demo controller app in AOSP
125```
126frameworks/base/tests/SystemUIDemoModeController
127```
128
129
130## Example script (for screenshotting purposes)
131```bash
132#!/bin/sh
133CMD=$1
134
135if [[ $ADB == "" ]]; then
136  ADB=adb
137fi
138
139if [[ $CMD != "on" && $CMD != "off" ]]; then
140  echo "Usage: $0 [on|off] [hhmm]" >&2
141  exit
142fi
143
144if [[ "$2" != "" ]]; then
145  HHMM="$2"
146fi
147
148$ADB root || exit
149$ADB wait-for-devices
150$ADB shell settings put global sysui_demo_allowed 1
151
152if [ $CMD == "on" ]; then
153  $ADB shell am broadcast -a com.android.systemui.demo -e command enter || exit
154  if [[ "$HHMM" != "" ]]; then
155    $ADB shell am broadcast -a com.android.systemui.demo -e command clock -e
156hhmm ${HHMM}
157  fi
158  $ADB shell am broadcast -a com.android.systemui.demo -e command battery -e
159plugged false
160  $ADB shell am broadcast -a com.android.systemui.demo -e command battery -e
161level 100
162  $ADB shell am broadcast -a com.android.systemui.demo -e command network -e
163wifi show -e level 4
164  $ADB shell am broadcast -a com.android.systemui.demo -e command network -e
165mobile show -e datatype none -e level 4
166  $ADB shell am broadcast -a com.android.systemui.demo -e command notifications
167-e visible false
168elif [ $CMD == "off" ]; then
169  $ADB shell am broadcast -a com.android.systemui.demo -e command exit
170fi
171```
172
173