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 25| Command | 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| | | ```hotspot``` | Sets the wifi to be from an Instant Hotspot. Values: ```none```, ```unknown```, ```phone```, ```tablet```, ```laptop```, ```watch```, ```auto```. (See `DemoModeWifiDataSource.kt`.) 39| | ```mobile``` | | ```show``` to show icon, any other value to hide 40| | | ```datatype``` | Values: ```1x```, ```3g```, ```4g```, ```e```, ```g```, ```h```, ```lte```, ```roam```, any other value to hide 41| | | ```level``` | Sets mobile signal strength level (null or 0-4) 42| | ```satellite``` | | ```show``` to show icon, any other value to hide 43| | | ```connection``` | ```connected```, ```off```, ```on```, or ```unknown``` (matches SatelliteConnectionState enum) 44| | | ```level``` | Sets satellite signal strength level (0-4) 45| | ```carriernetworkchange``` | | Sets mobile signal icon to carrier network change UX when disconnected (```show``` to show icon, any other value to hide) 46| | ```sims``` | | Sets the number of sims (1-8) 47| | ```nosim``` | | ```show``` to show icon, any other value to hide 48| ```bars``` | | | Control the visual style of the bars (opaque, translucent, etc) 49| | ```mode``` | | Sets the bars visual style (opaque, translucent, semi-transparent) 50| ```status``` | | | Control the system status icons 51| | ```volume``` | | Sets the icon in the volume slot (```silent```, ```vibrate```, any other value to hide) 52| | ```bluetooth``` | | Sets the icon in the bluetooth slot (```connected```, ```disconnected```, any other value to hide) 53| | ```location``` | | Sets the icon in the location slot (```show```, any other value to hide) 54| | ```alarm``` | | Sets the icon in the alarm_clock slot (```show```, any other value to hide) 55| | ```sync``` | | Sets the icon in the sync_active slot (```show```, any other value to hide) 56| | ```tty``` | | Sets the icon in the tty slot (```show```, any other value to hide) 57| | ```eri``` | | Sets the icon in the cdma_eri slot (```show```, any other value to hide) 58| | ```mute``` | | Sets the icon in the mute slot (```show```, any other value to hide) 59| | ```speakerphone``` | | Sets the icon in the speakerphone slot (```show```, any other value to hide) 60| ```notifications``` | | | Control the notification icons 61| | ```visible``` | | ```false``` to hide the notification icons, any other value to show 62| ```clock``` | | | Control the clock display 63| | ```millis``` | | Sets the time in millis 64| | ```hhmm``` | | Sets the time in hh:mm 65 66## Examples 67Enter demo mode 68 69``` 70adb shell am broadcast -a com.android.systemui.demo -e command enter 71``` 72 73 74Exit demo mode 75 76``` 77adb shell am broadcast -a com.android.systemui.demo -e command exit 78``` 79 80 81Set the clock to 12:31 82 83``` 84adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 851231 86``` 87 88 89Set the wifi level to max 90 91``` 92adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi 93show -e level 4 94``` 95 96 97Show the satellite icon 98 99``` 100# Sets mobile to be out-of-service, which is required for satellite to show 101adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 0 102# Sets satellite to be connected 103adb shell am broadcast -a com.android.systemui.demo -e command network -e satellite show -e level 4 -e connection connected 104``` 105 106Show the silent volume icon 107 108``` 109adb shell am broadcast -a com.android.systemui.demo -e command status -e volume 110silent 111``` 112 113 114Empty battery, and not charging (red exclamation point) 115 116``` 117adb shell am broadcast -a com.android.systemui.demo -e command battery -e level 1180 -e plugged false 119``` 120 121 122Hide the notification icons 123 124``` 125adb shell am broadcast -a com.android.systemui.demo -e command notifications -e 126visible false 127``` 128 129 130Exit demo mode 131 132``` 133adb shell am broadcast -a com.android.systemui.demo -e command exit 134``` 135 136 137## Example demo controller app in AOSP 138``` 139frameworks/base/tests/SystemUIDemoModeController 140``` 141 142 143## Example script (for screenshotting purposes) 144```bash 145#!/bin/sh 146CMD=$1 147 148if [[ $ADB == "" ]]; then 149 ADB=adb 150fi 151 152if [[ $CMD != "on" && $CMD != "off" ]]; then 153 echo "Usage: $0 [on|off] [hhmm]" >&2 154 exit 155fi 156 157if [[ "$2" != "" ]]; then 158 HHMM="$2" 159fi 160 161$ADB root || exit 162$ADB wait-for-devices 163$ADB shell settings put global sysui_demo_allowed 1 164 165if [ $CMD == "on" ]; then 166 $ADB shell am broadcast -a com.android.systemui.demo -e command enter || exit 167 if [[ "$HHMM" != "" ]]; then 168 $ADB shell am broadcast -a com.android.systemui.demo -e command clock -e 169hhmm ${HHMM} 170 fi 171 $ADB shell am broadcast -a com.android.systemui.demo -e command battery -e 172plugged false 173 $ADB shell am broadcast -a com.android.systemui.demo -e command battery -e 174level 100 175 $ADB shell am broadcast -a com.android.systemui.demo -e command network -e 176wifi show -e level 4 177 $ADB shell am broadcast -a com.android.systemui.demo -e command network -e 178mobile show -e datatype none -e level 4 179 $ADB shell am broadcast -a com.android.systemui.demo -e command notifications 180-e visible false 181elif [ $CMD == "off" ]; then 182 $ADB shell am broadcast -a com.android.systemui.demo -e command exit 183fi 184``` 185 186