Skip to content

Commit 4e78da3

Browse files
authored
Merge pull request #532 from smartdevicelink/develop
Release/1.6.0
2 parents 5c281b2 + f541e2f commit 4e78da3

File tree

407 files changed

+1064
-984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

407 files changed

+1064
-984
lines changed

examples/js/hello-sdl/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
})
9595
.setOnError((sdlManager, info) => {
9696
console.error('Error from SdlManagerListener: ', info);
97+
})
98+
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
99+
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
100+
.setAppName('Hello JS')
101+
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
97102
});
98103

99104
this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);

examples/node/hello-sdl-tcp/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class AppClient {
4747
.setAppId(CONFIG.appId)
4848
.setAppName(CONFIG.appName)
4949
.setLanguageDesired(SDL.rpc.enums.Language.EN_US)
50+
.setHmiDisplayLanguageDesired(SDL.rpc.enums.Language.EN_US)
5051
.setAppTypes([
5152
SDL.rpc.enums.AppHMIType.MEDIA,
5253
])
@@ -89,6 +90,11 @@ class AppClient {
8990
})
9091
.setOnError((sdlManager, info) => {
9192
console.error('Error from SdlManagerListener: ', info);
93+
})
94+
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
95+
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
96+
.setAppName('Hello JS')
97+
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
9298
});
9399

94100
this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);

examples/node/hello-sdl/AppClient.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class AppClient {
4747
.setAppId(CONFIG.appId)
4848
.setAppName(CONFIG.appName)
4949
.setLanguageDesired(SDL.rpc.enums.Language.EN_US)
50+
.setHmiDisplayLanguageDesired(SDL.rpc.enums.Language.EN_US)
5051
.setAppTypes([
5152
SDL.rpc.enums.AppHMIType.MEDIA,
5253
])
@@ -94,6 +95,11 @@ class AppClient {
9495
})
9596
.setOnError((sdlManager, info) => {
9697
console.error('Error from SdlManagerListener: ', info);
98+
})
99+
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
100+
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
101+
.setAppName('Hello JS')
102+
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
97103
});
98104

99105
this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);

examples/webengine/hello-sdl/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@
8686
})
8787
.setOnError((sdlManager, info) => {
8888
this._logMessage('APP:', 'Error from SdlManagerListener: ' + info, true);
89+
})
90+
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
91+
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
92+
.setAppName('Hello JS')
93+
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
8994
});
9095

9196
this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);

lib/js/src/manager/LifecycleConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class LifecycleConfig {
218218
}
219219

220220
/**
221-
* Get the desired langauge of the application.
221+
* Get the desired language of the application.
222222
* @returns {Language} - A Language enum value.
223223
*/
224224
getLanguageDesired () {
@@ -237,7 +237,7 @@ class LifecycleConfig {
237237

238238
/**
239239
* Get the desired HMI Display Language.
240-
* @returns {Language} - A Langauge enum value.
240+
* @returns {Language} - A Language enum value.
241241
*/
242242
getHmiDisplayLanguageDesired () {
243243
return this._hmiDisplayLanguageDesired;

lib/js/src/manager/SdlManager.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,29 @@ class SdlManager extends _SdlManagerBase {
222222
*/
223223
_checkLifecycleConfiguration () {
224224
const actualLanguage = this._lifecycleManager.getRegisterAppInterfaceResponse().getLanguage();
225+
const actualHmiLanguage = this._lifecycleManager.getRegisterAppInterfaceResponse().getHmiDisplayLanguage();
225226

226-
if (actualLanguage !== null && actualLanguage !== this._lifecycleConfig.getLanguageDesired()) {
227+
if ((actualLanguage !== null && actualLanguage !== this._lifecycleConfig.getLanguageDesired())
228+
|| (actualHmiLanguage !== null && actualHmiLanguage !== this._lifecycleConfig.getHmiDisplayLanguageDesired())) {
227229
// HMI language doesn't match the app's desired display language
228-
const lifecycleConfigUpdate = this._managerListener.managerShouldUpdateLifecycle(actualLanguage);
230+
const lifecycleConfigUpdateNew = this._managerListener.managerShouldUpdateLifecycleToLanguage(actualLanguage, actualHmiLanguage);
231+
const lifecycleConfigUpdateOld = this._managerListener.managerShouldUpdateLifecycle(actualLanguage);
232+
let lifecycleConfigUpdate;
233+
const changeRegistration = new ChangeRegistration();
234+
235+
if (lifecycleConfigUpdateNew === null) {
236+
lifecycleConfigUpdate = lifecycleConfigUpdateOld;
237+
changeRegistration.setLanguage(actualLanguage)
238+
.setHmiDisplayLanguage(actualLanguage);
239+
} else {
240+
lifecycleConfigUpdate = lifecycleConfigUpdateNew;
241+
changeRegistration.setLanguage(actualLanguage)
242+
.setHmiDisplayLanguage(actualHmiLanguage);
243+
}
229244

230245
if (lifecycleConfigUpdate !== null) {
231246
// send a ChangeRegistration RPC
232-
const changeRegistration = new ChangeRegistration();
233-
changeRegistration
234-
.setLanguage(actualLanguage)
235-
.setHmiDisplayLanguage(actualLanguage)
236-
.setAppName(lifecycleConfigUpdate.getAppName())
247+
changeRegistration.setAppName(lifecycleConfigUpdate.getAppName())
237248
.setNgnMediaScreenAppName(lifecycleConfigUpdate.getShortAppName())
238249
.setVrSynonyms(lifecycleConfigUpdate.getVoiceRecognitionCommandNames());
239250

@@ -244,7 +255,7 @@ class SdlManager extends _SdlManagerBase {
244255
this.sendRpcResolve(changeRegistration)
245256
.then((response) => {
246257
this._lifecycleConfig.setLanguageDesired(actualLanguage);
247-
this._lifecycleConfig.setHmiDisplayLanguageDesired(actualLanguage);
258+
this._lifecycleConfig.setHmiDisplayLanguageDesired(actualHmiLanguage);
248259
if (lifecycleConfigUpdate.getAppName() !== null) {
249260
this._lifecycleConfig.setAppName(lifecycleConfigUpdate.getAppName());
250261
}
@@ -502,7 +513,7 @@ class SdlManager extends _SdlManagerBase {
502513
}
503514

504515
/**
505-
* Retreives the RAI response from the _LifecycleManager
516+
* Retrieves the RAI response from the _LifecycleManager
506517
* @returns {RegisterAppInterfaceResponse|null} - A RegisterAppInterfaceResponse.
507518
*/
508519
getRegisterAppInterfaceResponse () {

lib/js/src/manager/SdlManagerListener.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class SdlManagerListener {
4242
this._managerShouldUpdateLifecycle = (language) => {
4343
return null;
4444
};
45+
this._managerShouldUpdateLifecycleToLanguage = (language, hmiLanguage) => {
46+
return null;
47+
};
4548
this._onSystemInfoReceived = null;
4649
}
4750

@@ -77,6 +80,7 @@ class SdlManagerListener {
7780

7881
/**
7982
* Set the ManagerShouldUpdateLifecycle event callback function.
83+
* @deprecated Use setManagerShouldUpdateLifecycleToLanguage instead
8084
* @param {function} callback - A function to invoke when the event is triggered.
8185
* @returns {SdlManagerListener} - A reference to this instance to support method chaining.
8286
*/
@@ -85,6 +89,16 @@ class SdlManagerListener {
8589
return this;
8690
}
8791

92+
/**
93+
* Set the ManagerShouldUpdateLifecycleToLanguage event callback function.
94+
* @param {function} callback - A function to invoke when the event is triggered.
95+
* @returns {SdlManagerListener} - A reference to this instance to support method chaining.
96+
*/
97+
setManagerShouldUpdateLifecycleToLanguage (callback) {
98+
this._managerShouldUpdateLifecycleToLanguage = callback;
99+
return this;
100+
}
101+
88102
/**
89103
* Safely attempts to invoke the OnStart event callback function.
90104
* @param {SdlManager} sdlManager - A reference to an SdlManager instance.
@@ -118,6 +132,7 @@ class SdlManagerListener {
118132

119133
/**
120134
* Safely attempts to invoke the ManagerShouldUpdateLifecycle event callback function.
135+
* @deprecated Use managerShouldUpdateLifecycleToLanguage instead
121136
* @param {Language} language - A Language enum value.
122137
* @returns {LifecycleConfigurationUpdate|null} - A reference to LifecycleConfigurationUpdate instance or null
123138
*/
@@ -128,6 +143,23 @@ class SdlManagerListener {
128143
return null;
129144
}
130145

146+
/**
147+
* Called when the SDL manager detected a language mismatch. In case of a language mismatch the
148+
* manager should change the apps registration by updating the lifecycle configuration to the
149+
* specified language. If the app can support the specified language it should return an Object
150+
* of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language
151+
* is not supported.
152+
* @param {Language} language - The VR+TTS language of the connected head unit the manager is trying to update the configuration.
153+
* @param {Language} hmiLanguage - The HMI display language of the connected head unit the manager is trying to update the configuration.
154+
* @returns {LifecycleConfigurationUpdate|null} - A reference to LifecycleConfigurationUpdate instance or null
155+
*/
156+
managerShouldUpdateLifecycleToLanguage (language, hmiLanguage) {
157+
if (typeof this._managerShouldUpdateLifecycleToLanguage === 'function') {
158+
return this._managerShouldUpdateLifecycleToLanguage(language, hmiLanguage);
159+
}
160+
return null;
161+
}
162+
131163
/**
132164
* Set the onSystemInfoReceived function.
133165
* @param {function} listener - A function to be invoked when the event occurs.

lib/js/src/manager/file/filetypes/SdlFile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SdlFile {
7272

7373
/**
7474
* Sets the location of the file
75-
* @param {String} filePath - a String value representing the the location of the file
75+
* @param {String} filePath - a String value representing the location of the file
7676
* @returns {SdlFile} - A reference to this instance to support method chaining.
7777
*/
7878
setFilePath (filePath) {
@@ -143,7 +143,7 @@ class SdlFile {
143143
}
144144

145145
/**
146-
* Sets the the name of the static file. Static files comes pre-shipped with the head unit
146+
* Sets the name of the static file. Static files comes pre-shipped with the head unit
147147
* @param {Boolean} staticIcon - a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
148148
* @returns {SdlFile} - A reference to this instance to support method chaining.
149149
*/
@@ -153,7 +153,7 @@ class SdlFile {
153153
}
154154

155155
/**
156-
* Gets the the name of the static file. Static files comes pre-shipped with the head unit
156+
* Gets the name of the static file. Static files comes pre-shipped with the head unit
157157
* @returns {Boolean} - a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
158158
*/
159159
isStaticIcon () {

lib/js/src/manager/lifecycle/_LifecycleManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class _LifecycleManager {
412412
.setNgnMediaScreenAppName(this._lifecycleConfig.getShortAppName())
413413
.setAppHMIType(this._lifecycleConfig.getAppTypes())
414414
.setLanguageDesired(this._lifecycleConfig.getLanguageDesired())
415-
.setHmiDisplayLanguageDesired(this._lifecycleConfig.getLanguageDesired())
415+
.setHmiDisplayLanguageDesired(this._lifecycleConfig.getHmiDisplayLanguageDesired())
416416
.setIsMediaApplication(this._lifecycleConfig._isMediaApp)
417417
.setDayColorScheme(this._lifecycleConfig.getDayColorScheme())
418418
.setNightColorScheme(this._lifecycleConfig.getNightColorScheme())

lib/js/src/manager/permission/PermissionElement.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ class PermissionElement {
4747
}
4848

4949
/**
50-
* Retreives the RPC ID
50+
* Retrieves the RPC ID
5151
* @returns {Number} - A numeric FunctionID
5252
*/
5353
getRpcId () {
5454
return this._rpcId;
5555
}
5656

5757
/**
58-
* Retreives the permission parameters the developer wishes to track
58+
* Retrieves the permission parameters the developer wishes to track
5959
* @returns {String[]} - An array of parameter strings
6060
*/
6161
getParameters () {

lib/js/src/manager/screen/_SoftButtonReplaceOperation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class _SoftButtonReplaceOperation extends _Task {
271271
* @returns {Boolean} - Whether soft button images are supported
272272
*/
273273
_supportsSoftButtonImages () {
274-
return this._softButtonCapabilities.getImageSupported();
274+
return this._softButtonCapabilities !== null && this._softButtonCapabilities.getImageSupported();
275275
}
276276

277277
/**

lib/js/src/manager/screen/_VoiceCommandManagerBase.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,20 @@ class _VoiceCommandManagerBase extends _SubManagerBase {
179179
const validatedVoiceCommands = voiceCommands.map((voiceCommand) => {
180180
const voiceCommandStrings = voiceCommand.getVoiceCommands().filter((voiceCommandString) => {
181181
// filter out any whitespace characters
182-
return voiceCommandString !== null && voiceCommandString !== undefined && voiceCommandString.replace(/\s/g, '').length > 0;
182+
const validString = voiceCommandString !== null && voiceCommandString !== undefined && voiceCommandString.replace(/\s/g, '').length > 0;
183+
if (!validString) {
184+
console.warn('Empty or whitespace only voice command string: ', voiceCommandString, ', removed from voice command: ', voiceCommand);
185+
}
186+
return validString;
183187
});
184188
// Updates voice command strings array by only adding ones that are not empty(e.g. ', ' ', ...)
185189
if (voiceCommandStrings.length > 0) {
186190
return voiceCommand.setVoiceCommands(voiceCommandStrings);
187191
}
188192
}).filter((voiceCommand) => {
193+
if (voiceCommand === undefined) {
194+
console.warn('A voice command with no valid strings was removed.');
195+
}
189196
return voiceCommand !== undefined;
190197
});
191198
return validatedVoiceCommands;

lib/js/src/manager/screen/menu/_MenuReplaceOperation.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import { _DynamicMenuUpdateAlgorithm } from './_DynamicMenuUpdateAlgorithm';
3535
import { _MenuReplaceUtilities } from './_MenuReplaceUtilities';
3636
import { _MenuCellState } from './enums/_MenuCellState';
3737
import { _ManagerUtility } from '../../_ManagerUtility.js';
38-
import { ImageFieldName } from '../../../rpc/enums/ImageFieldName.js';
3938
import { TextFieldName } from '../../../rpc/enums/TextFieldName.js';
4039
import { _MenuManagerBase } from './_MenuManagerBase';
4140

@@ -159,7 +158,7 @@ class _MenuReplaceOperation extends _Task {
159158
* @returns {Promise} - A promise resolving to a boolean as to whether the operation succeeded
160159
*/
161160
async _uploadMenuArtworks () {
162-
const artworksToBeUploaded = _MenuReplaceUtilities.findAllArtworksToBeUploadedFromCells(this._updatedMenu, this._fileManager, this._windowCapability);
161+
const artworksToBeUploaded = _MenuReplaceUtilities.findAllArtworksToBeUploadedFromCells(this._lifecycleManager, this._updatedMenu, this._fileManager, this._windowCapability);
163162
if (artworksToBeUploaded.length === 0) {
164163
return true;
165164
}
@@ -301,9 +300,9 @@ class _MenuReplaceOperation extends _Task {
301300

302301
const defaultSubmenuLayout = this._menuConfiguration !== null ? this._menuConfiguration.getSubMenuLayout() : null;
303302
// RPCs for cells on the main menu level. They could be AddCommands or AddSubMenus depending on whether the cell has child cells or not.
304-
const mainMenuCommands = _MenuReplaceUtilities.mainMenuCommandsForCells(addMenuCells, this._fileManager, fullMenu, this._windowCapability, defaultSubmenuLayout);
303+
const mainMenuCommands = _MenuReplaceUtilities.mainMenuCommandsForCells(this._lifecycleManager, addMenuCells, this._fileManager, fullMenu, this._windowCapability, defaultSubmenuLayout);
305304
// RPCs for cells on the second menu level (one level deep). They could be AddCommands or AddSubMenus.
306-
const subMenuCommands = _MenuReplaceUtilities.subMenuCommandsForCells(addMenuCells, this._fileManager, this._windowCapability, defaultSubmenuLayout);
305+
const subMenuCommands = _MenuReplaceUtilities.subMenuCommandsForCells(this._lifecycleManager, addMenuCells, this._fileManager, this._windowCapability, defaultSubmenuLayout);
307306
// the main menu commands and submenu commands could be combined into one list to reduce line code waste
308307
const errorArrayMain = [];
309308

@@ -402,11 +401,14 @@ class _MenuReplaceOperation extends _Task {
402401
// Strip away fields that cannot be used to determine uniqueness visually including fields not supported by the HMI
403402
cell.setVoiceCommands(null);
404403

405-
// Don't check ImageFieldName.subMenuIcon because it was added in 7.0 when the feature was added in 5.0.
406-
// Just assume that if cmdIcon is not available, the submenu icon is not either.
407-
if (!_ManagerUtility.hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon)) {
404+
if (!_MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(this._lifecycleManager, windowCapability, cell)) {
408405
cell.setIcon(null);
409406
}
407+
408+
if (!_MenuReplaceUtilities.windowCapabilitySupportsSecondaryImage(windowCapability, cell)) {
409+
cell.setSecondaryArtwork(null);
410+
}
411+
410412
// Check for subMenu fields supported
411413
if (cell.isSubMenuCell()) {
412414
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuSubMenuSecondaryText)) {
@@ -415,9 +417,6 @@ class _MenuReplaceOperation extends _Task {
415417
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuSubMenuTertiaryText)) {
416418
cell.setTertiaryText(null);
417419
}
418-
if (!_ManagerUtility.hasImageFieldOfName(windowCapability, ImageFieldName.menuSubMenuSecondaryImage)) {
419-
cell.setSecondaryArtwork(null);
420-
}
421420
cell.setSubCells(this._cellsWithRemovedPropertiesFromCells(cell.getSubCells(), windowCapability));
422421
} else {
423422
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuCommandSecondaryText)) {
@@ -426,9 +425,6 @@ class _MenuReplaceOperation extends _Task {
426425
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuCommandTertiaryText)) {
427426
cell.setTertiaryText(null);
428427
}
429-
if (!_ManagerUtility.hasImageFieldOfName(windowCapability, ImageFieldName.menuCommandSecondaryImage)) {
430-
cell.setSecondaryArtwork(null);
431-
}
432428
}
433429
});
434430

0 commit comments

Comments
 (0)