@@ -48,7 +48,7 @@ class AppClient {
4848 . setAppName ( CONFIG . appName )
4949 . setLanguageDesired ( SDL . rpc . enums . Language . EN_US )
5050 . setAppTypes ( [
51- SDL . rpc . enums . AppHMIType . DEFAULT ,
51+ SDL . rpc . enums . AppHMIType . MEDIA ,
5252 ] )
5353 . setTransportConfig ( new SDL . transport . TcpClientConfig ( CONFIG . host , CONFIG . port ) )
5454 . setAppIcon ( file )
@@ -119,6 +119,8 @@ class AppClient {
119119 screenManager . setTextAlignment ( SDL . rpc . enums . TextAlignment . RIGHT_ALIGNED ) ;
120120 screenManager . setPrimaryGraphic ( new SDL . manager . file . filetypes . SdlArtwork ( 'sdl-logo' , SDL . rpc . enums . FileType . GRAPHIC_PNG )
121121 . setFilePath ( this . _filePath ) ) ;
122+ screenManager . changeLayout ( new SDL . rpc . structs . TemplateConfiguration ( )
123+ . setTemplate ( SDL . rpc . enums . PredefinedLayout . NON_MEDIA ) ) ;
122124 }
123125
124126 async _onHmiStatusListener ( onHmiStatus ) {
@@ -128,7 +130,17 @@ class AppClient {
128130 // wait for the FULL state for more functionality
129131 if ( hmiLevel === SDL . rpc . enums . HMILevel . HMI_FULL ) {
130132 const screenManager = this . _sdlManager . getScreenManager ( ) ;
131- if ( ! this . _isButtonSubscriptionRequested ) {
133+ const isRpcAllowed = ( rpc ) => {
134+ return this . _permissionManager &&
135+ this . _permissionManager . isRpcAllowed ( rpc ) ;
136+ } ;
137+
138+ if ( ! this . _isButtonSubscriptionRequested && isRpcAllowed ( SDL . rpc . enums . FunctionID . SubscribeButton ) ) {
139+ // Get supported buttons
140+ const availableButtons = this . _sdlManager . getRegisterAppInterfaceResponse ( ) . getButtonCapabilities ( ) . map ( function ( capability ) {
141+ return capability . getNameParam ( ) ;
142+ } ) ;
143+
132144 // add button listeners
133145 const ButtonName = SDL . rpc . enums . ButtonName ;
134146 const buttonNames = [ ButtonName . PRESET_0 , ButtonName . PRESET_1 , ButtonName . PRESET_2 , ButtonName . PRESET_3 ,
@@ -137,9 +149,14 @@ class AppClient {
137149 ButtonName . TUNEUP , ButtonName . TUNEDOWN ] ;
138150
139151 for ( const buttonName of buttonNames ) {
140- await screenManager . addButtonListener ( buttonName , this . _onButtonListener . bind ( this ) ) . catch ( function ( err ) {
141- console . error ( err ) ;
142- } ) ;
152+ if ( availableButtons . indexOf ( buttonName ) !== - 1 ) {
153+ console . log ( 'Subscribing to' , buttonName ) ;
154+ await screenManager . addButtonListener ( buttonName , this . _onButtonListener . bind ( this ) ) . catch ( function ( err ) {
155+ console . error ( err ) ;
156+ } ) ;
157+ } else {
158+ console . log ( 'No capability found for button' , buttonName ) ;
159+ }
143160 }
144161
145162 this . _isButtonSubscriptionRequested = true ;
@@ -177,12 +194,9 @@ class AppClient {
177194
178195 const count = 3 ;
179196 for ( let i = 0 ; i < count ; i ++ ) {
180- const showCountdown = new SDL . rpc . messages . Show ( ) ;
181- showCountdown . setMainField1 ( `Exiting in ${ ( count - i ) . toString ( ) } ` )
182- . setMainField2 ( '' )
183- . setMainField3 ( '' ) ;
184-
185- this . _sdlManager . sendRpcResolve ( showCountdown ) ; // don't wait for a response
197+ screenManager . setTextField1 ( `Exiting in ${ ( count - i ) . toString ( ) } ` )
198+ . setTextField2 ( '' )
199+ . setTextField3 ( '' ) ;
186200
187201 await this . _sleep ( ) ;
188202 }
@@ -219,4 +233,4 @@ class AppClient {
219233}
220234
221235console . log ( 'start app' ) ;
222- new AppClient ( ) ;
236+ new AppClient ( ) ;
0 commit comments