@@ -260,89 +260,89 @@ public void parseRAIResponse(RegisterAppInterfaceResponse response) {
260260 }
261261 }
262262
263- private void setupRpcListeners () {
264- rpcListener = new OnRPCListener () {
265- @ Override
266- public void onReceived (RPCMessage message ) {
267- if (message != null ) {
268- if (RPCMessage .KEY_RESPONSE .equals (message .getMessageType ())) {
269- switch (message .getFunctionID ()) {
270- case SET_DISPLAY_LAYOUT :
271- SetDisplayLayoutResponse response = (SetDisplayLayoutResponse ) message ;
272- setCapability (SystemCapabilityType .DISPLAY , response .getDisplayCapabilities ());
273- setCapability (SystemCapabilityType .BUTTON , response .getButtonCapabilities ());
274- setCapability (SystemCapabilityType .PRESET_BANK , response .getPresetBankCapabilities ());
275- setCapability (SystemCapabilityType .SOFTBUTTON , response .getSoftButtonCapabilities ());
276- if (shouldConvertDeprecatedDisplayCapabilities ) {
277- setCapability (SystemCapabilityType .DISPLAYS , createDisplayCapabilityList (response ));
278- }
279- break ;
280- case GET_SYSTEM_CAPABILITY :
281- GetSystemCapabilityResponse systemCapabilityResponse = (GetSystemCapabilityResponse ) message ;
282- SystemCapability systemCapability = systemCapabilityResponse .getSystemCapability ();
283- if (systemCapabilityResponse .getSuccess () && SystemCapabilityType .DISPLAYS .equals (systemCapability .getSystemCapabilityType ())) {
284- shouldConvertDeprecatedDisplayCapabilities = false ; // Successfully got DISPLAYS data. No conversion needed anymore
285- List <DisplayCapability > newCapabilities = (List <DisplayCapability >) systemCapability .getCapabilityForType (SystemCapabilityType .DISPLAYS );
286- updateCachedDisplayCapabilityList (newCapabilities );
287- }
288- break ;
289- }
290- } else if (RPCMessage .KEY_NOTIFICATION .equals (message .getMessageType ())) {
291- switch (message .getFunctionID ()) {
292- case ON_HMI_STATUS :
293- OnHMIStatus onHMIStatus = (OnHMIStatus ) message ;
294- if (onHMIStatus .getWindowID () != null && onHMIStatus .getWindowID () != PredefinedWindows .DEFAULT_WINDOW .getValue ()) {
295- return ;
296- }
297- currentHMILevel = onHMIStatus .getHmiLevel ();
298- break ;
299- case ON_SYSTEM_CAPABILITY_UPDATED :
300- OnSystemCapabilityUpdated onSystemCapabilityUpdated = (OnSystemCapabilityUpdated ) message ;
301- if (onSystemCapabilityUpdated .getSystemCapability () != null ) {
302- SystemCapability systemCapability = onSystemCapabilityUpdated .getSystemCapability ();
303- SystemCapabilityType systemCapabilityType = systemCapability .getSystemCapabilityType ();
304- Object capability = systemCapability .getCapabilityForType (systemCapabilityType );
305- if (cachedSystemCapabilities .containsKey (systemCapabilityType )) { //The capability already exists
306- switch (systemCapabilityType ) {
307- case APP_SERVICES :
308- // App services only updates what was changed so we need
309- // to update the capability rather than override it
310- AppServicesCapabilities appServicesCapabilities = (AppServicesCapabilities ) capability ;
311- if (capability != null ) {
312- List <AppServiceCapability > appServicesCapabilitiesList = appServicesCapabilities .getAppServices ();
313- AppServicesCapabilities cachedAppServicesCapabilities = (AppServicesCapabilities ) cachedSystemCapabilities .get (systemCapabilityType );
314- //Update the cached app services
315- if (cachedAppServicesCapabilities != null ) {
316- cachedAppServicesCapabilities .updateAppServices (appServicesCapabilitiesList );
317- }
318- //Set the new capability object to the updated cached capabilities
319- capability = cachedAppServicesCapabilities ;
320- }
321- break ;
322- case DISPLAYS :
323- shouldConvertDeprecatedDisplayCapabilities = false ; // Successfully got DISPLAYS data. No conversion needed anymore
324- // this notification can return only affected windows (hence not all windows)
325- List <DisplayCapability > newCapabilities = (List <DisplayCapability >) capability ;
326- updateCachedDisplayCapabilityList (newCapabilities );
327- }
328- }
329- if (capability != null ) {
330- setCapability (systemCapabilityType , capability );
331- }
332- }
333- }
334- }
335- }
336- }
337- };
263+ private void setupRpcListeners () {
264+ rpcListener = new OnRPCListener () {
265+ @ Override
266+ public void onReceived (RPCMessage message ) {
267+ if (message != null ) {
268+ if (RPCMessage .KEY_RESPONSE .equals (message .getMessageType ())) {
269+ switch (message .getFunctionID ()) {
270+ case SET_DISPLAY_LAYOUT :
271+ SetDisplayLayoutResponse response = (SetDisplayLayoutResponse ) message ;
272+ setCapability (SystemCapabilityType .DISPLAY , response .getDisplayCapabilities ());
273+ setCapability (SystemCapabilityType .BUTTON , response .getButtonCapabilities ());
274+ setCapability (SystemCapabilityType .PRESET_BANK , response .getPresetBankCapabilities ());
275+ setCapability (SystemCapabilityType .SOFTBUTTON , response .getSoftButtonCapabilities ());
276+ if (shouldConvertDeprecatedDisplayCapabilities ) {
277+ setCapability (SystemCapabilityType .DISPLAYS , createDisplayCapabilityList (response ));
278+ }
279+ break ;
280+ case GET_SYSTEM_CAPABILITY :
281+ GetSystemCapabilityResponse systemCapabilityResponse = (GetSystemCapabilityResponse ) message ;
282+ SystemCapability systemCapability = systemCapabilityResponse .getSystemCapability ();
283+ if (systemCapabilityResponse .getSuccess () && SystemCapabilityType .DISPLAYS .equals (systemCapability .getSystemCapabilityType ())) {
284+ shouldConvertDeprecatedDisplayCapabilities = false ; // Successfully got DISPLAYS data. No conversion needed anymore
285+ List <DisplayCapability > newCapabilities = (List <DisplayCapability >) systemCapability .getCapabilityForType (SystemCapabilityType .DISPLAYS );
286+ updateCachedDisplayCapabilityList (newCapabilities );
287+ }
288+ break ;
289+ }
290+ } else if (RPCMessage .KEY_NOTIFICATION .equals (message .getMessageType ())) {
291+ switch (message .getFunctionID ()) {
292+ case ON_HMI_STATUS :
293+ OnHMIStatus onHMIStatus = (OnHMIStatus ) message ;
294+ if (onHMIStatus .getWindowID () != null && onHMIStatus .getWindowID () != PredefinedWindows .DEFAULT_WINDOW .getValue ()) {
295+ return ;
296+ }
297+ currentHMILevel = onHMIStatus .getHmiLevel ();
298+ break ;
299+ case ON_SYSTEM_CAPABILITY_UPDATED :
300+ OnSystemCapabilityUpdated onSystemCapabilityUpdated = (OnSystemCapabilityUpdated ) message ;
301+ if (onSystemCapabilityUpdated .getSystemCapability () != null ) {
302+ SystemCapability systemCapability = onSystemCapabilityUpdated .getSystemCapability ();
303+ SystemCapabilityType systemCapabilityType = systemCapability .getSystemCapabilityType ();
304+ Object capability = systemCapability .getCapabilityForType (systemCapabilityType );
305+ if (cachedSystemCapabilities .containsKey (systemCapabilityType )) { //The capability already exists
306+ switch (systemCapabilityType ) {
307+ case APP_SERVICES :
308+ // App services only updates what was changed so we need
309+ // to update the capability rather than override it
310+ AppServicesCapabilities appServicesCapabilities = (AppServicesCapabilities ) capability ;
311+ if (capability != null ) {
312+ List <AppServiceCapability > appServicesCapabilitiesList = appServicesCapabilities .getAppServices ();
313+ AppServicesCapabilities cachedAppServicesCapabilities = (AppServicesCapabilities ) cachedSystemCapabilities .get (systemCapabilityType );
314+ //Update the cached app services
315+ if (cachedAppServicesCapabilities != null ) {
316+ cachedAppServicesCapabilities .updateAppServices (appServicesCapabilitiesList );
317+ }
318+ //Set the new capability object to the updated cached capabilities
319+ capability = cachedAppServicesCapabilities ;
320+ }
321+ break ;
322+ case DISPLAYS :
323+ shouldConvertDeprecatedDisplayCapabilities = false ; // Successfully got DISPLAYS data. No conversion needed anymore
324+ // this notification can return only affected windows (hence not all windows)
325+ List <DisplayCapability > newCapabilities = (List <DisplayCapability >) capability ;
326+ updateCachedDisplayCapabilityList (newCapabilities );
327+ }
328+ }
329+ if (capability != null ) {
330+ setCapability (systemCapabilityType , capability );
331+ }
332+ }
333+ }
334+ }
335+ }
336+ }
337+ };
338338
339339 if (callback != null ) {
340340 callback .addOnRPCListener (FunctionID .GET_SYSTEM_CAPABILITY , rpcListener );
341341 callback .addOnRPCListener (FunctionID .SET_DISPLAY_LAYOUT , rpcListener );
342342 callback .addOnRPCListener (FunctionID .ON_SYSTEM_CAPABILITY_UPDATED , rpcListener );
343343 callback .addOnRPCListener (FunctionID .ON_HMI_STATUS , rpcListener );
344344 }
345- }
345+ }
346346
347347 /**
348348 * Sets a capability in the cached map. This should only be done when an RPC is received and contains updates to the capability
0 commit comments