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