@@ -35,13 +35,6 @@ const CONFIG = require('./config.js');
3535
3636class AppClient {
3737 constructor ( wsClient , ready ) {
38- const fileName = `${ CONFIG . appId } _icon.gif` ;
39- const file = new SDL . manager . file . filetypes . SdlFile ( )
40- . setName ( fileName )
41- . setFilePath ( './test_icon_1.png' )
42- . setType ( SDL . rpc . enums . FileType . GRAPHIC_PNG )
43- . setPersistent ( true ) ;
44-
4538 this . _lifecycleConfig = new SDL . manager . LifecycleConfig ( )
4639 . setAppId ( CONFIG . appId )
4740 . setAppName ( CONFIG . appName )
@@ -54,8 +47,7 @@ class AppClient {
5447 wsClient ,
5548 CONFIG . connectionLostTimeout
5649 )
57- )
58- . setAppIcon ( file ) ;
50+ ) ;
5951
6052 this . _appConfig = new SDL . manager . AppConfig ( )
6153 . setLifecycleConfig ( this . _lifecycleConfig ) ;
@@ -75,19 +67,30 @@ class AppClient {
7567 . addRpcListener ( SDL . rpc . enums . FunctionID . OnHMIStatus , this . _onHmiStatusListener . bind ( this ) ) ;
7668
7769 this . _ready = ready ;
70+ // for a cloud server app the hmi full will be received before the managers report that they're ready!
71+ this . _managersReady = false ;
72+ this . _hmiFull = false ;
7873 }
7974
8075 async _onConnected ( ) {
81-
76+ this . _managersReady = true ;
77+ this . _checkReadyState ( ) ;
8278 }
8379
8480 async _onHmiStatusListener ( onHmiStatus ) {
8581 const hmiLevel = onHmiStatus . getHmiLevel ( ) ;
8682
8783 // wait for the FULL state for more functionality
8884 if ( hmiLevel === SDL . rpc . enums . HMILevel . HMI_FULL ) {
85+ this . _hmiFull = true ;
86+ this . _checkReadyState ( ) ;
87+ }
88+ }
89+
90+ async _checkReadyState ( ) {
91+ if ( this . _managersReady && this . _hmiFull ) {
8992 if ( typeof this . _ready === 'function' ) {
90- this . _ready ( async ( ) => {
93+ await this . _ready ( async ( ) => {
9194 // tests complete. tear down the app
9295 await this . _sdlManager . sendRpc ( new SDL . rpc . messages . UnregisterAppInterface ( ) ) ;
9396 this . _sdlManager . dispose ( ) ;
@@ -103,4 +106,4 @@ class AppClient {
103106 }
104107}
105108
106- module . exports = AppClient ;
109+ module . exports = AppClient ;
0 commit comments