Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f54a7ca
Checkpoint
crokita Oct 26, 2021
56f83de
Merge pull request #513 from smartdevicelink/master
crokita Oct 27, 2021
0a6e0a6
Library alignment
crokita Nov 12, 2021
bd98f41
Alignment and bug fixes
crokita Nov 15, 2021
55aabbd
Remove unused parameter in menu utility method
crokita Nov 17, 2021
6fb5664
Check for null before attempting to call a method
crokita Nov 18, 2021
ebe1360
Merge pull request #514 from smartdevicelink/bugfix/menu-manager-vers…
crokita Nov 19, 2021
deb5732
Handle language and hmi display language separately on registration
renonick87 Dec 13, 2021
8f4310c
Merge pull request #517 from smartdevicelink/feature/set_language_sep…
renonick87 Dec 14, 2021
fdea868
Explicitly add the null check condition
crokita Dec 15, 2021
62bf611
Merge pull request #516 from smartdevicelink/bugfix/null-access-softb…
crokita Jan 5, 2022
c2ec280
Fix Issue 520
theresalech Feb 15, 2022
525bb61
Merge pull request #521 from smartdevicelink/bugfix/issue-520-typos
theresalech Feb 22, 2022
4a0af4a
update rpc file copyright years to 2022
renonick87 Mar 14, 2022
47eed97
Merge pull request #522 from smartdevicelink/update-copyright-2022
renonick87 Mar 14, 2022
d2f9e40
Update vulnerable packages and fix lint issues
crokita Mar 15, 2022
5972529
Merge pull request #523 from smartdevicelink/bugfix/security-vulnerab…
crokita Mar 15, 2022
c88631c
1.6.0
renonick87 Mar 28, 2022
615b3f4
Merge pull request #525 from smartdevicelink/bugfix/version-1.6
renonick87 Mar 29, 2022
add5cc6
Bump minimist from 1.2.5 to 1.2.6
dependabot[bot] Mar 29, 2022
0bf5cdb
Merge pull request #524 from smartdevicelink/dependabot/npm_and_yarn/…
crokita Mar 29, 2022
9c76ff5
Fix null access error
crokita Mar 30, 2022
89f3a88
Add warnings for invalid voice command strings
crokita Mar 30, 2022
5382a90
Merge pull request #530 from smartdevicelink/bugfix/invalid-voice-com…
crokita Apr 1, 2022
f541e2f
Merge pull request #528 from smartdevicelink/bugfix/present-alert-op-…
crokita Apr 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions examples/js/hello-sdl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
})
.setOnError((sdlManager, info) => {
console.error('Error from SdlManagerListener: ', info);
})
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
.setAppName('Hello JS')
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
});

this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);
Expand Down
6 changes: 6 additions & 0 deletions examples/node/hello-sdl-tcp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AppClient {
.setAppId(CONFIG.appId)
.setAppName(CONFIG.appName)
.setLanguageDesired(SDL.rpc.enums.Language.EN_US)
.setHmiDisplayLanguageDesired(SDL.rpc.enums.Language.EN_US)
.setAppTypes([
SDL.rpc.enums.AppHMIType.MEDIA,
])
Expand Down Expand Up @@ -89,6 +90,11 @@ class AppClient {
})
.setOnError((sdlManager, info) => {
console.error('Error from SdlManagerListener: ', info);
})
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
.setAppName('Hello JS')
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
});

this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);
Expand Down
6 changes: 6 additions & 0 deletions examples/node/hello-sdl/AppClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AppClient {
.setAppId(CONFIG.appId)
.setAppName(CONFIG.appName)
.setLanguageDesired(SDL.rpc.enums.Language.EN_US)
.setHmiDisplayLanguageDesired(SDL.rpc.enums.Language.EN_US)
.setAppTypes([
SDL.rpc.enums.AppHMIType.MEDIA,
])
Expand Down Expand Up @@ -94,6 +95,11 @@ class AppClient {
})
.setOnError((sdlManager, info) => {
console.error('Error from SdlManagerListener: ', info);
})
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
.setAppName('Hello JS')
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
});

this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);
Expand Down
5 changes: 5 additions & 0 deletions examples/webengine/hello-sdl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
})
.setOnError((sdlManager, info) => {
this._logMessage('APP:', 'Error from SdlManagerListener: ' + info, true);
})
.setManagerShouldUpdateLifecycleToLanguage((language = null, hmiLanguage = null) => {
return new SDL.manager.lifecycle.LifecycleConfigurationUpdate()
.setAppName('Hello JS')
.setTtsName([new SDL.rpc.structs.TTSChunk().setText('Hello JS')]);
});

this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);
Expand Down
4 changes: 2 additions & 2 deletions lib/js/src/manager/LifecycleConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class LifecycleConfig {
}

/**
* Get the desired langauge of the application.
* Get the desired language of the application.
* @returns {Language} - A Language enum value.
*/
getLanguageDesired () {
Expand All @@ -237,7 +237,7 @@ class LifecycleConfig {

/**
* Get the desired HMI Display Language.
* @returns {Language} - A Langauge enum value.
* @returns {Language} - A Language enum value.
*/
getHmiDisplayLanguageDesired () {
return this._hmiDisplayLanguageDesired;
Expand Down
29 changes: 20 additions & 9 deletions lib/js/src/manager/SdlManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,29 @@ class SdlManager extends _SdlManagerBase {
*/
_checkLifecycleConfiguration () {
const actualLanguage = this._lifecycleManager.getRegisterAppInterfaceResponse().getLanguage();
const actualHmiLanguage = this._lifecycleManager.getRegisterAppInterfaceResponse().getHmiDisplayLanguage();

if (actualLanguage !== null && actualLanguage !== this._lifecycleConfig.getLanguageDesired()) {
if ((actualLanguage !== null && actualLanguage !== this._lifecycleConfig.getLanguageDesired())
|| (actualHmiLanguage !== null && actualHmiLanguage !== this._lifecycleConfig.getHmiDisplayLanguageDesired())) {
// HMI language doesn't match the app's desired display language
const lifecycleConfigUpdate = this._managerListener.managerShouldUpdateLifecycle(actualLanguage);
const lifecycleConfigUpdateNew = this._managerListener.managerShouldUpdateLifecycleToLanguage(actualLanguage, actualHmiLanguage);
const lifecycleConfigUpdateOld = this._managerListener.managerShouldUpdateLifecycle(actualLanguage);
let lifecycleConfigUpdate;
const changeRegistration = new ChangeRegistration();

if (lifecycleConfigUpdateNew === null) {
lifecycleConfigUpdate = lifecycleConfigUpdateOld;
changeRegistration.setLanguage(actualLanguage)
.setHmiDisplayLanguage(actualLanguage);
} else {
lifecycleConfigUpdate = lifecycleConfigUpdateNew;
changeRegistration.setLanguage(actualLanguage)
.setHmiDisplayLanguage(actualHmiLanguage);
}

if (lifecycleConfigUpdate !== null) {
// send a ChangeRegistration RPC
const changeRegistration = new ChangeRegistration();
changeRegistration
.setLanguage(actualLanguage)
.setHmiDisplayLanguage(actualLanguage)
.setAppName(lifecycleConfigUpdate.getAppName())
changeRegistration.setAppName(lifecycleConfigUpdate.getAppName())
.setNgnMediaScreenAppName(lifecycleConfigUpdate.getShortAppName())
.setVrSynonyms(lifecycleConfigUpdate.getVoiceRecognitionCommandNames());

Expand All @@ -244,7 +255,7 @@ class SdlManager extends _SdlManagerBase {
this.sendRpcResolve(changeRegistration)
.then((response) => {
this._lifecycleConfig.setLanguageDesired(actualLanguage);
this._lifecycleConfig.setHmiDisplayLanguageDesired(actualLanguage);
this._lifecycleConfig.setHmiDisplayLanguageDesired(actualHmiLanguage);
if (lifecycleConfigUpdate.getAppName() !== null) {
this._lifecycleConfig.setAppName(lifecycleConfigUpdate.getAppName());
}
Expand Down Expand Up @@ -502,7 +513,7 @@ class SdlManager extends _SdlManagerBase {
}

/**
* Retreives the RAI response from the _LifecycleManager
* Retrieves the RAI response from the _LifecycleManager
* @returns {RegisterAppInterfaceResponse|null} - A RegisterAppInterfaceResponse.
*/
getRegisterAppInterfaceResponse () {
Expand Down
32 changes: 32 additions & 0 deletions lib/js/src/manager/SdlManagerListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class SdlManagerListener {
this._managerShouldUpdateLifecycle = (language) => {
return null;
};
this._managerShouldUpdateLifecycleToLanguage = (language, hmiLanguage) => {
return null;
};
this._onSystemInfoReceived = null;
}

Expand Down Expand Up @@ -77,6 +80,7 @@ class SdlManagerListener {

/**
* Set the ManagerShouldUpdateLifecycle event callback function.
* @deprecated Use setManagerShouldUpdateLifecycleToLanguage instead
* @param {function} callback - A function to invoke when the event is triggered.
* @returns {SdlManagerListener} - A reference to this instance to support method chaining.
*/
Expand All @@ -85,6 +89,16 @@ class SdlManagerListener {
return this;
}

/**
* Set the ManagerShouldUpdateLifecycleToLanguage event callback function.
* @param {function} callback - A function to invoke when the event is triggered.
* @returns {SdlManagerListener} - A reference to this instance to support method chaining.
*/
setManagerShouldUpdateLifecycleToLanguage (callback) {
this._managerShouldUpdateLifecycleToLanguage = callback;
return this;
}

/**
* Safely attempts to invoke the OnStart event callback function.
* @param {SdlManager} sdlManager - A reference to an SdlManager instance.
Expand Down Expand Up @@ -118,6 +132,7 @@ class SdlManagerListener {

/**
* Safely attempts to invoke the ManagerShouldUpdateLifecycle event callback function.
* @deprecated Use managerShouldUpdateLifecycleToLanguage instead
* @param {Language} language - A Language enum value.
* @returns {LifecycleConfigurationUpdate|null} - A reference to LifecycleConfigurationUpdate instance or null
*/
Expand All @@ -128,6 +143,23 @@ class SdlManagerListener {
return null;
}

/**
* Called when the SDL manager detected a language mismatch. In case of a language mismatch the
* manager should change the apps registration by updating the lifecycle configuration to the
* specified language. If the app can support the specified language it should return an Object
* of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language
* is not supported.
* @param {Language} language - The VR+TTS language of the connected head unit the manager is trying to update the configuration.
* @param {Language} hmiLanguage - The HMI display language of the connected head unit the manager is trying to update the configuration.
* @returns {LifecycleConfigurationUpdate|null} - A reference to LifecycleConfigurationUpdate instance or null
*/
managerShouldUpdateLifecycleToLanguage (language, hmiLanguage) {
if (typeof this._managerShouldUpdateLifecycleToLanguage === 'function') {
return this._managerShouldUpdateLifecycleToLanguage(language, hmiLanguage);
}
return null;
}

/**
* Set the onSystemInfoReceived function.
* @param {function} listener - A function to be invoked when the event occurs.
Expand Down
6 changes: 3 additions & 3 deletions lib/js/src/manager/file/filetypes/SdlFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SdlFile {

/**
* Sets the location of the file
* @param {String} filePath - a String value representing the the location of the file
* @param {String} filePath - a String value representing the location of the file
* @returns {SdlFile} - A reference to this instance to support method chaining.
*/
setFilePath (filePath) {
Expand Down Expand Up @@ -143,7 +143,7 @@ class SdlFile {
}

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

/**
* Gets the the name of the static file. Static files comes pre-shipped with the head unit
* Gets the name of the static file. Static files comes pre-shipped with the head unit
* @returns {Boolean} - a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
*/
isStaticIcon () {
Expand Down
2 changes: 1 addition & 1 deletion lib/js/src/manager/lifecycle/_LifecycleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class _LifecycleManager {
.setNgnMediaScreenAppName(this._lifecycleConfig.getShortAppName())
.setAppHMIType(this._lifecycleConfig.getAppTypes())
.setLanguageDesired(this._lifecycleConfig.getLanguageDesired())
.setHmiDisplayLanguageDesired(this._lifecycleConfig.getLanguageDesired())
.setHmiDisplayLanguageDesired(this._lifecycleConfig.getHmiDisplayLanguageDesired())
.setIsMediaApplication(this._lifecycleConfig._isMediaApp)
.setDayColorScheme(this._lifecycleConfig.getDayColorScheme())
.setNightColorScheme(this._lifecycleConfig.getNightColorScheme())
Expand Down
4 changes: 2 additions & 2 deletions lib/js/src/manager/permission/PermissionElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ class PermissionElement {
}

/**
* Retreives the RPC ID
* Retrieves the RPC ID
* @returns {Number} - A numeric FunctionID
*/
getRpcId () {
return this._rpcId;
}

/**
* Retreives the permission parameters the developer wishes to track
* Retrieves the permission parameters the developer wishes to track
* @returns {String[]} - An array of parameter strings
*/
getParameters () {
Expand Down
2 changes: 1 addition & 1 deletion lib/js/src/manager/screen/_SoftButtonReplaceOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class _SoftButtonReplaceOperation extends _Task {
* @returns {Boolean} - Whether soft button images are supported
*/
_supportsSoftButtonImages () {
return this._softButtonCapabilities.getImageSupported();
return this._softButtonCapabilities !== null && this._softButtonCapabilities.getImageSupported();
}

/**
Expand Down
9 changes: 8 additions & 1 deletion lib/js/src/manager/screen/_VoiceCommandManagerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,20 @@ class _VoiceCommandManagerBase extends _SubManagerBase {
const validatedVoiceCommands = voiceCommands.map((voiceCommand) => {
const voiceCommandStrings = voiceCommand.getVoiceCommands().filter((voiceCommandString) => {
// filter out any whitespace characters
return voiceCommandString !== null && voiceCommandString !== undefined && voiceCommandString.replace(/\s/g, '').length > 0;
const validString = voiceCommandString !== null && voiceCommandString !== undefined && voiceCommandString.replace(/\s/g, '').length > 0;
if (!validString) {
console.warn('Empty or whitespace only voice command string: ', voiceCommandString, ', removed from voice command: ', voiceCommand);
}
return validString;
});
// Updates voice command strings array by only adding ones that are not empty(e.g. ', ' ', ...)
if (voiceCommandStrings.length > 0) {
return voiceCommand.setVoiceCommands(voiceCommandStrings);
}
}).filter((voiceCommand) => {
if (voiceCommand === undefined) {
console.warn('A voice command with no valid strings was removed.');
}
return voiceCommand !== undefined;
});
return validatedVoiceCommands;
Expand Down
22 changes: 9 additions & 13 deletions lib/js/src/manager/screen/menu/_MenuReplaceOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { _DynamicMenuUpdateAlgorithm } from './_DynamicMenuUpdateAlgorithm';
import { _MenuReplaceUtilities } from './_MenuReplaceUtilities';
import { _MenuCellState } from './enums/_MenuCellState';
import { _ManagerUtility } from '../../_ManagerUtility.js';
import { ImageFieldName } from '../../../rpc/enums/ImageFieldName.js';
import { TextFieldName } from '../../../rpc/enums/TextFieldName.js';
import { _MenuManagerBase } from './_MenuManagerBase';

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

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

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

// Don't check ImageFieldName.subMenuIcon because it was added in 7.0 when the feature was added in 5.0.
// Just assume that if cmdIcon is not available, the submenu icon is not either.
if (!_ManagerUtility.hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon)) {
if (!_MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(this._lifecycleManager, windowCapability, cell)) {
cell.setIcon(null);
}

if (!_MenuReplaceUtilities.windowCapabilitySupportsSecondaryImage(windowCapability, cell)) {
cell.setSecondaryArtwork(null);
}

// Check for subMenu fields supported
if (cell.isSubMenuCell()) {
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuSubMenuSecondaryText)) {
Expand All @@ -415,9 +417,6 @@ class _MenuReplaceOperation extends _Task {
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuSubMenuTertiaryText)) {
cell.setTertiaryText(null);
}
if (!_ManagerUtility.hasImageFieldOfName(windowCapability, ImageFieldName.menuSubMenuSecondaryImage)) {
cell.setSecondaryArtwork(null);
}
cell.setSubCells(this._cellsWithRemovedPropertiesFromCells(cell.getSubCells(), windowCapability));
} else {
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuCommandSecondaryText)) {
Expand All @@ -426,9 +425,6 @@ class _MenuReplaceOperation extends _Task {
if (!_ManagerUtility.hasTextFieldOfName(windowCapability, TextFieldName.menuCommandTertiaryText)) {
cell.setTertiaryText(null);
}
if (!_ManagerUtility.hasImageFieldOfName(windowCapability, ImageFieldName.menuCommandSecondaryImage)) {
cell.setSecondaryArtwork(null);
}
}
});

Expand Down
Loading