1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.demomode;
18 
19 import com.google.android.collect.Lists;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 
24 /**
25  * Interface defining what it means to implement DemoMode. A DemoMode implementation should
26  * register with DemoModeController, providing a list of commands for wish to listen.
27  *
28  * If you only need to listen to commands, but *do not* care about demo mode state changes, you
29  * can implement DemoModeCommandReceiver instead
30  */
31 public interface DemoMode extends DemoModeCommandReceiver {
32 
33     List<String> NO_COMMANDS = new ArrayList<>();
34 
35     /** Provide a set of commands to listen to, only acceptable values are the COMMAND_* keys */
demoCommands()36     default List<String> demoCommands() {
37         return NO_COMMANDS;
38     }
39 
40     /** Something simple enough to be recognizable in dumpsys logs */
logName()41     default String logName() {
42         if (this.getClass().isAnonymousClass()) {
43             return getClass().getName();
44         } else {
45             return getClass().getSimpleName();
46         }
47     }
48 
49     String ACTION_DEMO = "com.android.systemui.demo";
50 
51     String EXTRA_COMMAND = "command";
52 
53     /** Enter and exit are non-register-able; override started/finished to observe these states */
54     String COMMAND_ENTER = "enter";
55     String COMMAND_EXIT = "exit";
56 
57     /** Observable commands to register a listener for  */
58     String COMMAND_CLOCK = "clock";
59     String COMMAND_BATTERY = "battery";
60     String COMMAND_NETWORK = "network";
61     String COMMAND_BARS = "bars";
62     String COMMAND_STATUS = "status";
63     String COMMAND_NOTIFICATIONS = "notifications";
64     String COMMAND_VOLUME = "volume";
65     String COMMAND_OPERATOR = "operator";
66 
67     /** New keys need to be added here */
68     List<String> COMMANDS = Lists.newArrayList(
69             COMMAND_BARS,
70             COMMAND_BATTERY,
71             COMMAND_CLOCK,
72             COMMAND_NETWORK,
73             COMMAND_NOTIFICATIONS,
74             COMMAND_OPERATOR,
75             COMMAND_STATUS,
76             COMMAND_VOLUME
77     );
78 }
79 
80