Home | History | Annotate | Download | only in docs
      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
      5 Demo mode is protected behind a system setting. To enable it for a device, run:
      6 
      7 ```
      8 adb shell settings put global sysui_demo_allowed 1
      9 ```
     10 
     11 ## Protocol
     12 The 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 ```
     16 com.android.systemui.demo
     17 ```
     18 
     19 ### Commands
     20 Commands and subcommands (below) are sent as string extras in the broadcast
     21 intent.
     22 <br/>
     23 Commands 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                      | ```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
     63 Enter demo mode
     64 
     65 ```
     66 adb shell am broadcast -a com.android.systemui.demo -e command enter
     67 ```
     68 
     69 
     70 Exit demo mode
     71 
     72 ```
     73 adb shell am broadcast -a com.android.systemui.demo -e command exit
     74 ```
     75 
     76 
     77 Set the clock to 12:31
     78 
     79 ```
     80 adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm
     81 1231
     82 ```
     83 
     84 
     85 Set the wifi level to max
     86 
     87 ```
     88 adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi
     89 show -e level 4
     90 ```
     91 
     92 
     93 Show the silent volume icon
     94 
     95 ```
     96 adb shell am broadcast -a com.android.systemui.demo -e command status -e volume
     97 silent
     98 ```
     99 
    100 
    101 Empty battery, and not charging (red exclamation point)
    102 
    103 ```
    104 adb shell am broadcast -a com.android.systemui.demo -e command battery -e level
    105 0 -e plugged false
    106 ```
    107 
    108 
    109 Hide the notification icons
    110 
    111 ```
    112 adb shell am broadcast -a com.android.systemui.demo -e command notifications -e
    113 visible false
    114 ```
    115 
    116 
    117 Exit demo mode
    118 
    119 ```
    120 adb shell am broadcast -a com.android.systemui.demo -e command exit
    121 ```
    122 
    123 
    124 ## Example demo controller app in AOSP
    125 ```
    126 frameworks/base/tests/SystemUIDemoModeController
    127 ```
    128 
    129 
    130 ## Example script (for screenshotting purposes)
    131 ```bash
    132 #!/bin/sh
    133 CMD=$1
    134 
    135 if [[ $ADB == "" ]]; then
    136   ADB=adb
    137 fi
    138 
    139 if [[ $CMD != "on" && $CMD != "off" ]]; then
    140   echo "Usage: $0 [on|off] [hhmm]" >&2
    141   exit
    142 fi
    143 
    144 if [[ "$2" != "" ]]; then
    145   HHMM="$2"
    146 fi
    147 
    148 $ADB root || exit
    149 $ADB wait-for-devices
    150 $ADB shell settings put global sysui_demo_allowed 1
    151 
    152 if [ $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
    156 hhmm ${HHMM}
    157   fi
    158   $ADB shell am broadcast -a com.android.systemui.demo -e command battery -e
    159 plugged false
    160   $ADB shell am broadcast -a com.android.systemui.demo -e command battery -e
    161 level 100
    162   $ADB shell am broadcast -a com.android.systemui.demo -e command network -e
    163 wifi show -e level 4
    164   $ADB shell am broadcast -a com.android.systemui.demo -e command network -e
    165 mobile show -e datatype none -e level 4
    166   $ADB shell am broadcast -a com.android.systemui.demo -e command notifications
    167 -e visible false
    168 elif [ $CMD == "off" ]; then
    169   $ADB shell am broadcast -a com.android.systemui.demo -e command exit
    170 fi
    171 ```
    172 
    173