6060import com .smartdevicelink .proxy .rpc .OnTouchEvent ;
6161import com .smartdevicelink .proxy .rpc .TouchCoord ;
6262import com .smartdevicelink .proxy .rpc .TouchEvent ;
63- import com .smartdevicelink .proxy .rpc .VehicleType ;
6463import com .smartdevicelink .proxy .rpc .VideoStreamingCapability ;
6564import com .smartdevicelink .proxy .rpc .enums .HMILevel ;
6665import com .smartdevicelink .proxy .rpc .enums .PredefinedWindows ;
7574
7675import java .lang .ref .WeakReference ;
7776import java .util .ArrayList ;
77+ import java .util .Arrays ;
7878import java .util .List ;
7979import java .util .concurrent .CopyOnWriteArrayList ;
8080import java .util .concurrent .FutureTask ;
@@ -96,6 +96,7 @@ public class VideoStreamManager extends BaseVideoStreamManager {
9696 private IVideoStreamListener streamListener ;
9797 private boolean isTransportAvailable = false ;
9898 private boolean hasStarted ;
99+ private List <HMILevel > streamableLevels = Arrays .asList (HMILevel .HMI_FULL , HMILevel .HMI_LIMITED );
99100 private String vehicleMake = null ;
100101
101102 // INTERNAL INTERFACES
@@ -153,10 +154,10 @@ public void onNotified(RPCNotification notification) {
153154 }
154155 HMILevel prevHMILevel = hmiLevel ;
155156 hmiLevel = onHMIStatus .getHmiLevel ();
156- if ( hmiLevel . equals ( HMILevel . HMI_FULL )) {
157+ if ( streamableLevels . contains ( hmiLevel )) {
157158 checkState ();
158159 }
159- if (hasStarted && (prevHMILevel == HMILevel . HMI_FULL || prevHMILevel == HMILevel . HMI_LIMITED ) && (hmiLevel == HMILevel . HMI_NONE || hmiLevel == HMILevel . HMI_BACKGROUND )) {
160+ if (hasStarted && (streamableLevels . contains ( prevHMILevel )) && (! streamableLevels . contains ( hmiLevel ))) {
160161 internalInterface .stopVideoService ();
161162 }
162163 }
@@ -209,7 +210,7 @@ private synchronized void checkState(){
209210 if (this .getState () == SETTING_UP
210211 && isTransportAvailable
211212 && hmiLevel != null
212- && hmiLevel . equals ( HMILevel . HMI_FULL )
213+ && streamableLevels . contains ( hmiLevel )
213214 && parameters != null ){
214215 stateMachine .transitionToState (StreamingStateMachine .READY );
215216 transitionToState (READY );
@@ -307,8 +308,8 @@ public void onError(String info) {
307308 */
308309 protected void startStreaming (VideoStreamingParameters parameters , boolean encrypted ){
309310 this .parameters = parameters ;
310- if ( hmiLevel != HMILevel . HMI_FULL ) {
311- Log .e (TAG , "Cannot start video service if HMILevel is not FULL." );
311+ if (! streamableLevels . contains ( hmiLevel )) {
312+ Log .e (TAG , "Cannot start video service if HMILevel is not FULL or LIMITED ." );
312313 return ;
313314 }
314315 //Start the video service
@@ -403,15 +404,15 @@ public boolean isServiceActive(){
403404 * @return boolean (true = yes, false = no)
404405 */
405406 public boolean isStreaming (){
406- return (stateMachine .getState () == StreamingStateMachine .STARTED ) && (hmiLevel == HMILevel . HMI_FULL );
407+ return (stateMachine .getState () == StreamingStateMachine .STARTED ) && (streamableLevels . contains ( hmiLevel ) );
407408 }
408409
409410 /**
410411 * Check if video streaming has been paused due to app moving to background or manually stopped
411412 * @return boolean (true = not paused, false = paused)
412413 */
413414 public boolean isPaused (){
414- return (hasStarted && stateMachine .getState () == StreamingStateMachine .STOPPED ) || (hmiLevel != HMILevel . HMI_FULL );
415+ return (hasStarted && stateMachine .getState () == StreamingStateMachine .STOPPED ) || (! streamableLevels . contains ( hmiLevel ) );
415416 }
416417
417418 /**
0 commit comments