SDL_Android/SmartDeviceLinkAndroidProxy - added the correct version of the proxy
[profile/ivi/smartdevicelink.git] / SDL_Android / SmartDeviceLinkProxyAndroid / src / com / smartdevicelink / proxy / rpc / OnHMIStatus.java
1 package com.smartdevicelink.proxy.rpc;\r
2 \r
3 import java.util.Hashtable;\r
4 \r
5 import com.smartdevicelink.proxy.RPCNotification;\r
6 import com.smartdevicelink.proxy.constants.Names;\r
7 import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;\r
8 import com.smartdevicelink.proxy.rpc.enums.HMILevel;\r
9 import com.smartdevicelink.proxy.rpc.enums.SystemContext;\r
10 import com.smartdevicelink.util.DebugTool;\r
11 /**\r
12  * <p>Notifies an application that HMI conditions have changed for the application. This indicates whether the application \r
13  * can speak phrases, display text, perform interactions, receive button presses and events, stream audio, etc. This \r
14  * notification will be sent to the application when there has been a change in any one or several of the indicated \r
15  * states ({@linkplain HMILevel}, {@linkplain AudioStreamingState} or {@linkplain SystemContext}) for the application</p>\r
16  * <p>All three values are, in principle, independent of each other (though there may be some relationships). A value for \r
17  * one parameter should not be interpreted from the value of another parameter.</p>\r
18  * <p>There are no guarantees about the timeliness or latency of the OnHMIStatus notification. Therefore, for example, \r
19  * information such as {@linkplain AudioStreamingState} may not indicate that the audio stream became inaudible to the user \r
20  * exactly when the OnHMIStatus notification was received.</p>\r
21  * \r
22  * <p>\r
23  * <b>Parameter List:</b>\r
24  * <table  border="1" rules="all">\r
25  * <tr>\r
26  * <th>Name</th>\r
27  * <th>Type</th>\r
28  * <th>Description</th>\r
29  * <th>Applink Ver Available</th>\r
30  * </tr>\r
31  * <tr>\r
32  * <td>hmiLevel</td>\r
33  * <td>{@linkplain HMILevel}</td>\r
34  * <td>The current HMI Level in effect for the application.</td>\r
35  * <td>SmartDeviceLink 1.0</td>\r
36  * </tr>\r
37  * <tr>\r
38  * <td>audioStreamingState</td>\r
39  * <td>{@linkplain AudioStreamingState}</td>\r
40  * <td>Current state of audio streaming for the application. \r
41  * When this parameter has a value of NOT_AUDIBLE, \r
42  * the application must stop streaming audio to SMARTDEVICELINK. \r
43  * Informs app whether any currently streaming audio is \r
44  * audible to user (AUDIBLE) or not (NOT_AUDIBLE). A \r
45  * value of NOT_AUDIBLE means that either the \r
46  * application's audio will not be audible to the user, or \r
47  * that the application's audio should not be audible to \r
48  * the user (i.e. some other application on the mobile \r
49  * device may be streaming audio and the application's \r
50  * audio would be blended with that other audio). </td>\r
51  * <td>SmartDeviceLink 1.0</td>\r
52  * </tr>\r
53  * <tr>\r
54  * <td>systemContext</td>\r
55  * <td>{@linkplain SystemContext}</td>\r
56  * <td>Indicates that a user-initiated interaction is in-progress \r
57  * (VRSESSION or MENU), or not (MAIN)</td>\r
58  * <td>SmartDeviceLink 1.0</td>\r
59  * </tr>\r
60  * </table>\r
61  * </p>\r
62  * @since SmartDeviceLink 1.0\r
63  * @see RegisterAppInterface \r
64  */\r
65 public class OnHMIStatus extends RPCNotification {\r
66         private Boolean firstRun;\r
67         /**\r
68         *Constructs a newly allocated OnHMIStatus object\r
69         */      \r
70     public OnHMIStatus() {\r
71         super("OnHMIStatus");\r
72     }\r
73     /**\r
74     *<p>Constructs a newly allocated OnHMIStatus object indicated by the Hashtable parameter</p>\r
75     *@param hash The Hashtable to use\r
76     */    \r
77     public OnHMIStatus(Hashtable hash) {\r
78         super(hash);\r
79     }\r
80     /**\r
81      * <p>Get HMILevel in effect for the application</p>\r
82      * @return {@linkplain HMILevel} the current HMI Level in effect for the application\r
83      */    \r
84     public HMILevel getHmiLevel() {\r
85         Object obj = parameters.get(Names.hmiLevel);\r
86         if (obj instanceof HMILevel) {\r
87             return (HMILevel) obj;\r
88         } else if (obj instanceof String) {\r
89             HMILevel theCode = null;\r
90             try {\r
91                 theCode = HMILevel.valueForString((String) obj);\r
92             } catch (Exception e) {\r
93                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.hmiLevel, e);\r
94             }\r
95             return theCode;\r
96         }\r
97         return null;\r
98     }\r
99     /**\r
100      * <p>Set the HMILevel of OnHMIStatus</p>\r
101      * @param hmiLevel the HMILevel to set\r
102      */    \r
103     public void setHmiLevel( HMILevel hmiLevel ) {\r
104         if (hmiLevel != null) {\r
105             parameters.put(Names.hmiLevel, hmiLevel );\r
106         }\r
107     }\r
108     /**\r
109      * <p>Get current state of audio streaming for the application</p>\r
110      * @return {@linkplain AudioStreamingState} Returns current state of audio streaming for the application\r
111      */    \r
112     public AudioStreamingState getAudioStreamingState() {\r
113         Object obj = parameters.get(Names.audioStreamingState);\r
114         if (obj instanceof AudioStreamingState) {\r
115             return (AudioStreamingState) obj;\r
116         } else if (obj instanceof String) {\r
117             AudioStreamingState theCode = null;\r
118             try {\r
119                 theCode = AudioStreamingState.valueForString((String) obj);\r
120             } catch (Exception e) {\r
121                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.audioStreamingState, e);\r
122             }\r
123             return theCode;\r
124         }\r
125         return null;\r
126     }\r
127     /**\r
128      * <p>Set the audio streaming state</p>\r
129      * @param audioStreamingState the state of audio streaming of the application\r
130      */    \r
131     public void setAudioStreamingState( AudioStreamingState audioStreamingState ) {\r
132         if (audioStreamingState != null) {\r
133             parameters.put(Names.audioStreamingState, audioStreamingState );\r
134         }\r
135     }\r
136     /**\r
137      * <p>Get the System Context</p>\r
138      * @return {@linkplain SystemContext} whether a user-initiated interaction is in-progress (VRSESSION or MENU), or not (MAIN).\r
139      */    \r
140     public SystemContext getSystemContext() {\r
141         Object obj = parameters.get(Names.systemContext);\r
142         if (obj instanceof SystemContext) {\r
143             return (SystemContext) obj;\r
144         } else if (obj instanceof String) {\r
145             SystemContext theCode = null;\r
146             try {\r
147                 theCode = SystemContext.valueForString((String) obj);\r
148             } catch (Exception e) {\r
149                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.systemContext, e);\r
150             }\r
151             return theCode;\r
152         }\r
153         return null;\r
154     }\r
155     /**\r
156      * <p>Set the System Context of OnHMIStatus</p>\r
157      * @param systemContext Indicates that a user-initiated interaction is in-progress \r
158      * (VRSESSION or MENU), or not (MAIN)\r
159      */    \r
160     public void setSystemContext( SystemContext systemContext ) {\r
161         if (systemContext != null) {\r
162             parameters.put(Names.systemContext, systemContext );\r
163         }\r
164     }\r
165     /**\r
166      * <p>Query whether it's the first run</p>\r
167      * @return boolean whether it's the first run\r
168      */    \r
169     public Boolean getFirstRun() {\r
170         return this.firstRun;\r
171     }\r
172     /**\r
173      * <p>Set the firstRun value</p>\r
174      * @param firstRun True if it is the first run, False or not\r
175      */    \r
176     public void setFirstRun(Boolean firstRun) {\r
177         this.firstRun = firstRun;\r
178     }\r
179 }\r