summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannianqiao <hannianqiao@iauto.com>2020-05-29 16:45:46 +0800
committerhannianqiao <hannianqiao@iauto.com>2020-05-29 16:46:12 +0800
commit9fe10b766fd55b271b9199e0adde288f4fa16b29 (patch)
treea679e90a2de37deb43a7f38ac97e024e7fe9bb98
parent6bff21aa02ad3f4ea08e388ef5efba1d450e6de3 (diff)
downloadsdl_android-9fe10b766fd55b271b9199e0adde288f4fa16b29.tar.gz
add javaSE code
-rw-r--r--hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java33
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java35
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java16
3 files changed, 69 insertions, 15 deletions
diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java
index 2bc02fa2f..b95280b5f 100644
--- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java
+++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java
@@ -138,20 +138,45 @@ public class SdlService {
}
@Override
- public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language){
- String appName;
+ public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) {
+ return null;
+ }
+
+ @Override
+ public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) {
+ boolean isNeedUpdate = false;
+ String appName = APP_NAME;
+ String ttsName = APP_NAME;
switch (language) {
case ES_MX:
+ isNeedUpdate = true;
+ ttsName = APP_NAME_ES;
+ break;
+ case FR_CA:
+ isNeedUpdate = true;
+ ttsName = APP_NAME_FR;
+ break;
+ default:
+ break;
+ }
+ switch (hmiLanguage) {
+ case ES_MX:
+ isNeedUpdate = true;
appName = APP_NAME_ES;
break;
case FR_CA:
+ isNeedUpdate = true;
appName = APP_NAME_FR;
break;
default:
- return null;
+ break;
+ }
+ if (isNeedUpdate) {
+ return new LifecycleConfigurationUpdate(appName, null, TTSChunkFactory.createSimpleTTSChunks(ttsName), null);
+ } else {
+ return null;
}
- return new LifecycleConfigurationUpdate(appName,null,TTSChunkFactory.createSimpleTTSChunks(appName), null);
}
};
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
index 83eb5f9bc..329efed01 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
@@ -230,15 +230,25 @@ public class SdlManager extends BaseSdlManager{
}
@Override
- protected void checkLifecycleConfiguration() {
- final Language actualLanguage = lifecycleManager.getRegisterAppInterfaceResponse().getLanguage();
-
- if (actualLanguage != null && !actualLanguage.equals(hmiLanguage)) {
-
- final LifecycleConfigurationUpdate lcu = managerListener.managerShouldUpdateLifecycle(actualLanguage);
+ protected void checkLifecycleConfiguration(){
+ final Language actualLanguage = this.getRegisterAppInterfaceResponse().getLanguage();
+ final Language actualHMILanguage = this.getRegisterAppInterfaceResponse().getHmiDisplayLanguage();
+
+ if ((actualLanguage != null && !actualLanguage.equals(language)) || (actualHMILanguage != null && !actualHMILanguage.equals(hmiLanguage))) {
+
+ LifecycleConfigurationUpdate lcuNew = managerListener.managerShouldUpdateLifecycle(actualLanguage, actualHMILanguage);
+ LifecycleConfigurationUpdate lcuOld = managerListener.managerShouldUpdateLifecycle(actualLanguage);
+ final LifecycleConfigurationUpdate lcu;
+ ChangeRegistration changeRegistration;
+ if (lcuNew == null) {
+ lcu = lcuOld;
+ changeRegistration = new ChangeRegistration(actualLanguage, actualLanguage);
+ } else {
+ lcu = lcuNew;
+ changeRegistration = new ChangeRegistration(actualLanguage, actualHMILanguage);
+ }
if (lcu != null) {
- ChangeRegistration changeRegistration = new ChangeRegistration(actualLanguage, actualLanguage);
changeRegistration.setAppName(lcu.getAppName());
changeRegistration.setNgnMediaScreenAppName(lcu.getShortAppName());
changeRegistration.setTtsName(lcu.getTtsName());
@@ -246,9 +256,10 @@ public class SdlManager extends BaseSdlManager{
changeRegistration.setOnRPCResponseListener(new OnRPCResponseListener() {
@Override
public void onResponse(int correlationId, RPCResponse response) {
- if (response.getSuccess()) {
+ if (response.getSuccess()){
// go through and change sdlManager properties that were changed via the LCU update
- hmiLanguage = actualLanguage;
+ hmiLanguage = actualHMILanguage;
+ language = actualLanguage;
if (lcu.getAppName() != null) {
appName = lcu.getAppName();
@@ -631,8 +642,9 @@ public class SdlManager extends BaseSdlManager{
* Sets the Language of the App
* @param hmiLanguage the desired language to be used on the display/HMI of the connected module
*/
- public Builder setLanguage(final Language hmiLanguage){
+ public Builder setLanguage(final Language hmiLanguage) {
sdlManager.hmiLanguage = hmiLanguage;
+ sdlManager.language = hmiLanguage;
return this;
}
@@ -775,8 +787,9 @@ public class SdlManager extends BaseSdlManager{
sdlManager.isMediaApp = false;
}
- if (sdlManager.hmiLanguage == null){
+ if (sdlManager.hmiLanguage == null) {
sdlManager.hmiLanguage = Language.EN_US;
+ sdlManager.language = Language.EN_US;
}
if (sdlManager.minimumProtocolVersion == null){
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java
index 44d1e091a..8118a9c93 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java
@@ -63,6 +63,22 @@ public interface SdlManagerListener extends BaseSdlManagerListener {
* @param language The language of the connected head unit the manager is trying to update the configuration.
* @return An object of LifecycleConfigurationUpdate if the head unit language is supported,
* otherwise null to indicate that the language is not supported.
+ * @deprecated use {@link #managerShouldUpdateLifecycle(Language language, Language hmiLanguage)} instead
*/
+ @Deprecated
LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language);
+
+ /**
+ * 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 The VR+TTS language of the connected head unit the manager is trying to update the configuration.
+ * @param hmiLanguage The HMI display language of the connected head unit the manager is trying to update the configuration.
+ * @return An object of LifecycleConfigurationUpdate if the head unit language is supported,
+ * otherwise null to indicate that the language is not supported.
+ */
+ LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage);
}