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