1 package com.smartdevicelink.proxy.rpc;
\r
3 import java.util.Hashtable;
\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
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
23 * <b>Parameter List:</b>
\r
24 * <table border="1" rules="all">
\r
28 * <th>Description</th>
\r
29 * <th>Applink Ver Available</th>
\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
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
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
62 * @since SmartDeviceLink 1.0
\r
63 * @see RegisterAppInterface
\r
65 public class OnHMIStatus extends RPCNotification {
\r
66 private Boolean firstRun;
\r
68 *Constructs a newly allocated OnHMIStatus object
\r
70 public OnHMIStatus() {
\r
71 super("OnHMIStatus");
\r
74 *<p>Constructs a newly allocated OnHMIStatus object indicated by the Hashtable parameter</p>
\r
75 *@param hash The Hashtable to use
\r
77 public OnHMIStatus(Hashtable hash) {
\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
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
91 theCode = HMILevel.valueForString((String) obj);
\r
92 } catch (Exception e) {
\r
93 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.hmiLevel, e);
\r
100 * <p>Set the HMILevel of OnHMIStatus</p>
\r
101 * @param hmiLevel the HMILevel to set
\r
103 public void setHmiLevel( HMILevel hmiLevel ) {
\r
104 if (hmiLevel != null) {
\r
105 parameters.put(Names.hmiLevel, hmiLevel );
\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
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
119 theCode = AudioStreamingState.valueForString((String) obj);
\r
120 } catch (Exception e) {
\r
121 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.audioStreamingState, e);
\r
128 * <p>Set the audio streaming state</p>
\r
129 * @param audioStreamingState the state of audio streaming of the application
\r
131 public void setAudioStreamingState( AudioStreamingState audioStreamingState ) {
\r
132 if (audioStreamingState != null) {
\r
133 parameters.put(Names.audioStreamingState, audioStreamingState );
\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
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
147 theCode = SystemContext.valueForString((String) obj);
\r
148 } catch (Exception e) {
\r
149 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.systemContext, e);
\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
160 public void setSystemContext( SystemContext systemContext ) {
\r
161 if (systemContext != null) {
\r
162 parameters.put(Names.systemContext, systemContext );
\r
166 * <p>Query whether it's the first run</p>
\r
167 * @return boolean whether it's the first run
\r
169 public Boolean getFirstRun() {
\r
170 return this.firstRun;
\r
173 * <p>Set the firstRun value</p>
\r
174 * @param firstRun True if it is the first run, False or not
\r
176 public void setFirstRun(Boolean firstRun) {
\r
177 this.firstRun = firstRun;
\r