summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2019-03-18 21:15:56 -0400
committerJoey Grover <joeygrover@gmail.com>2019-03-18 21:15:56 -0400
commitd8b1b6139d219c8c9ec8163e0630df0183f19cfd (patch)
tree0b5bbde97a8725bccba55e6746b84a0f583c049f
parent6660d89393748b25dda9ac3edb7191b9a9142a9f (diff)
parent283815ed2170197db4be06de766614c8803720bb (diff)
downloadsdl_android-feature/wss.tar.gz
Merge branch 'feature/sdl_java_base' of https://github.com/smartdevicelink/sdl_android into feature/wssfeature/wss
-rw-r--r--android/gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java2
-rw-r--r--base/src/main/java/com/smartdevicelink/util/FileUtls.java32
-rwxr-xr-xhello_sdl_java/assets/images/sdl.pngbin0 -> 3274 bytes
-rwxr-xr-xhello_sdl_java/assets/images/sdl_s_green.pngbin0 -> 25896 bytes
-rw-r--r--hello_sdl_java/build.gradle26
-rw-r--r--hello_sdl_java/gradle/wrapper/gradle-wrapper.jarbin0 -> 56172 bytes
-rw-r--r--hello_sdl_java/gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xhello_sdl_java/gradlew172
-rw-r--r--hello_sdl_java/gradlew.bat84
-rw-r--r--hello_sdl_java/settings.gradle4
-rw-r--r--hello_sdl_java/src/main/java/Main.java62
-rw-r--r--hello_sdl_java/src/main/java/SdlService.java207
-rw-r--r--hello_sdl_java_ee/build.gradle26
-rw-r--r--hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jarbin0 -> 56172 bytes
-rw-r--r--hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xhello_sdl_java_ee/gradlew172
-rw-r--r--hello_sdl_java_ee/gradlew.bat84
-rw-r--r--hello_sdl_java_ee/settings.gradle3
-rw-r--r--hello_sdl_java_ee/src/main/java/Main.java49
-rw-r--r--hello_sdl_java_ee/src/main/java/SdlService.java205
-rw-r--r--javaEE/bintray.gradle6
-rw-r--r--javaEE/bintray.properties4
-rw-r--r--javaEE/build.gradle22
-rw-r--r--javaEE/settings.gradle3
-rw-r--r--javaEE/src/main/java/hello_sdl_ee/Main.java113
-rw-r--r--javaSE/bintray.gradle6
-rw-r--r--javaSE/bintray.properties4
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java37
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java31
-rw-r--r--javaSE/src/main/java/hello_sdl/Main.java123
31 files changed, 1163 insertions, 328 deletions
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 9fe523a5c..edbfc86a9 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip \ No newline at end of file
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
index 832e86673..0b32d1b1c 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -4420,7 +4420,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (ButtonName.OK.equals(buttonName)) {
RPCRequest request2 = new RPCRequest(request);
request2.setParameters(SubscribeButton.KEY_BUTTON_NAME, ButtonName.PLAY_PAUSE);
+ request2.setOnRPCResponseListener(request.getOnRPCResponseListener());
sendRPCMessagePrivate(request2);
+ return;
}
}
}
diff --git a/base/src/main/java/com/smartdevicelink/util/FileUtls.java b/base/src/main/java/com/smartdevicelink/util/FileUtls.java
index 5c7fcd801..bc57e62ea 100644
--- a/base/src/main/java/com/smartdevicelink/util/FileUtls.java
+++ b/base/src/main/java/com/smartdevicelink/util/FileUtls.java
@@ -9,34 +9,30 @@ import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
public class FileUtls {
- /**
- *
- * @param file should include path and name
- * @return
- */
- public static boolean doesFileExist(String file){
- try{
- return false;//Files.exists(new Path(file), (LinkOption)null);
- }catch (Exception e){
- e.printStackTrace();
- }
- return false;
+
+ public static byte[] getFileData(String file){
+ return getFileData(file,null);
}
- public static byte[] getFileData(String path){
- byte[] data = null;
- if(path != null && path.length() > 0) {
- if (doesFileExist(path)) {
+ public static byte[] getFileData(String filePath, String fileName){
+ if(filePath != null && filePath.length() > 0) {
+ File file;
+ if(fileName != null && fileName.length() > 0 ){
+ file = new File(filePath, fileName);
+ }else{
+ file = new File(filePath);
+ }
+ if (file.exists() && file.isFile() && file.canRead()) {
try {
- return Files.readAllBytes(new File("/path/to/file").toPath());
+ return Files.readAllBytes(file.toPath());
} catch (IOException e) {
e.printStackTrace();
}
-
}
}
diff --git a/hello_sdl_java/assets/images/sdl.png b/hello_sdl_java/assets/images/sdl.png
new file mode 100755
index 000000000..5cfc0f84a
--- /dev/null
+++ b/hello_sdl_java/assets/images/sdl.png
Binary files differ
diff --git a/hello_sdl_java/assets/images/sdl_s_green.png b/hello_sdl_java/assets/images/sdl_s_green.png
new file mode 100755
index 000000000..c43021775
--- /dev/null
+++ b/hello_sdl_java/assets/images/sdl_s_green.png
Binary files differ
diff --git a/hello_sdl_java/build.gradle b/hello_sdl_java/build.gradle
new file mode 100644
index 000000000..8f3c7a526
--- /dev/null
+++ b/hello_sdl_java/build.gradle
@@ -0,0 +1,26 @@
+plugins {
+ id 'java'
+}
+
+version '1.0-SNAPSHOT'
+
+sourceCompatibility = 1.8
+
+repositories {
+ mavenCentral()
+ mavenLocal()
+ google()
+ jcenter()
+}
+// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5
+configurations {
+ // configuration that holds jars to include in the jar
+ extraLibs
+}
+dependencies {
+ extraLibs fileTree(dir: 'libs', include: ['*.jar'])
+ //testCompile group: 'junit', name: 'junit', version: '4.12'
+ extraLibs project(path: ':sdl_java_se')
+ configurations.implementation.extendsFrom(configurations.extraLibs)
+
+} \ No newline at end of file
diff --git a/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar b/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..28861d273
--- /dev/null
+++ b/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties b/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..fd6d42bd6
--- /dev/null
+++ b/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Mar 18 12:47:09 EDT 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
diff --git a/hello_sdl_java/gradlew b/hello_sdl_java/gradlew
new file mode 100755
index 000000000..cccdd3d51
--- /dev/null
+++ b/hello_sdl_java/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/hello_sdl_java/gradlew.bat b/hello_sdl_java/gradlew.bat
new file mode 100644
index 000000000..f9553162f
--- /dev/null
+++ b/hello_sdl_java/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/hello_sdl_java/settings.gradle b/hello_sdl_java/settings.gradle
new file mode 100644
index 000000000..fd254fa69
--- /dev/null
+++ b/hello_sdl_java/settings.gradle
@@ -0,0 +1,4 @@
+rootProject.name = 'hello_sdl_java'
+include ":sdl_java_se"
+project (":sdl_java_se").projectDir = new File("../javaSE/")
+
diff --git a/hello_sdl_java/src/main/java/Main.java b/hello_sdl_java/src/main/java/Main.java
new file mode 100644
index 000000000..6d7a44a12
--- /dev/null
+++ b/hello_sdl_java/src/main/java/Main.java
@@ -0,0 +1,62 @@
+import com.smartdevicelink.transport.WebSocketServerConfig;
+import com.smartdevicelink.util.DebugTool;
+
+public class Main {
+
+ static Thread thread = null, mainThread;
+ static Object LOCK;
+
+ static SdlService sdlService;
+
+ public static void main(String[] args) {
+ mainThread = Thread.currentThread();
+ LOCK = new Object();
+ startSdlService();
+
+ while(!mainThread.isInterrupted()) {
+ try {
+ synchronized (LOCK) {
+ LOCK.wait();
+ }
+ System.gc();
+ Thread.sleep(500);
+ DebugTool.logInfo( "Attempting to start SDL Service again");
+ startSdlService();
+ DebugTool.logInfo("SdlService started");
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ break;
+ }
+ }
+ }
+
+ static SdlService.SdlServiceCallback serviceCallback = new SdlService.SdlServiceCallback() {
+ @Override
+ public void onEnd() {
+ thread.interrupt();
+ thread = null;
+ synchronized (LOCK) {
+ LOCK.notify();
+ }
+
+ }
+ };
+
+ private static void startSdlService() {
+
+ thread = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ DebugTool.logInfo("Starting SDL Service");
+ sdlService = new SdlService(new WebSocketServerConfig(5432, -1), serviceCallback);
+ sdlService.start();
+
+ System.gc();
+
+ }
+ });
+ thread.start();
+ }
+}
diff --git a/hello_sdl_java/src/main/java/SdlService.java b/hello_sdl_java/src/main/java/SdlService.java
new file mode 100644
index 000000000..124dce2ea
--- /dev/null
+++ b/hello_sdl_java/src/main/java/SdlService.java
@@ -0,0 +1,207 @@
+import android.util.Log;
+import com.smartdevicelink.BuildConfig;
+import com.smartdevicelink.managers.CompletionListener;
+import com.smartdevicelink.managers.SdlManager;
+import com.smartdevicelink.managers.SdlManagerListener;
+import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.TTSChunkFactory;
+import com.smartdevicelink.proxy.rpc.*;
+import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
+import com.smartdevicelink.proxy.rpc.enums.FileType;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.transport.BaseTransportConfig;
+import com.smartdevicelink.util.DebugTool;
+import com.smartdevicelink.util.FileUtls;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Vector;
+
+public class SdlService {
+
+
+ private static final String TAG = "SDL Service";
+
+ private static final String APP_NAME = "Hello Sdl";
+ private static final String APP_ID = "8678309";
+
+ private static final String ICON_FILENAME = "hello_sdl_icon.png";
+ private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png";
+
+ private static final String WELCOME_SHOW = "Welcome to HelloSDL";
+ private static final String WELCOME_SPEAK = "Welcome to Hello S D L";
+
+ private static final String TEST_COMMAND_NAME = "Test Command";
+ private static final int TEST_COMMAND_ID = 1;
+
+ private static final String IMAGE_DIR = "assets/images/";
+
+
+
+ // variable to create and call functions of the SyncProxy
+ private SdlManager sdlManager = null;
+
+ private SdlServiceCallback callback;
+
+
+ public SdlService(BaseTransportConfig config, SdlServiceCallback callback){
+ this.callback = callback;
+ buildSdlManager(config);
+ }
+
+
+
+ public void start() {
+ DebugTool.logInfo("SdlService start() ");
+ if(sdlManager != null){
+ sdlManager.start();
+ }
+ }
+
+ public void stop() {
+ if (sdlManager != null) {
+ sdlManager.dispose();
+ sdlManager = null;
+ }
+ }
+
+ private void buildSdlManager(BaseTransportConfig transport) {
+ // This logic is to select the correct transport and security levels defined in the selected build flavor
+ // Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio
+ // Typically in your app, you will only set one of these.
+ if (sdlManager == null) {
+ DebugTool.logInfo("Creating SDL Manager");
+
+ //FIXME add the transport type
+ // The app type to be used
+ Vector<AppHMIType> appType = new Vector<>();
+ appType.add(AppHMIType.MEDIA);
+
+ // The manager listener helps you know when certain events that pertain to the SDL Manager happen
+ // Here we will listen for ON_HMI_STATUS and ON_COMMAND notifications
+ SdlManagerListener listener = new SdlManagerListener() {
+ @Override
+ public void onStart(SdlManager sdlManager) {
+ DebugTool.logInfo("SdlManager onStart");
+ }
+
+ @Override
+ public void onDestroy(SdlManager sdlManager) {
+ DebugTool.logInfo("SdlManager onDestroy ");
+ SdlService.this.sdlManager = null;
+ if(SdlService.this.callback != null){
+ SdlService.this.callback.onEnd();
+ }
+ }
+
+ @Override
+ public void onError(SdlManager sdlManager, String info, Exception e) {
+ }
+ };
+
+
+ HashMap<FunctionID,OnRPCNotificationListener> notificationListenerHashMap = new HashMap<FunctionID,OnRPCNotificationListener>();
+ notificationListenerHashMap.put(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ OnHMIStatus status = (OnHMIStatus) notification;
+ if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) {
+ sendCommands();
+ performWelcomeSpeak();
+ performWelcomeShow();
+ }
+ }
+ });
+
+ notificationListenerHashMap.put(FunctionID.ON_COMMAND, new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ OnCommand command = (OnCommand) notification;
+ Integer id = command.getCmdID();
+ if(id != null){
+ switch(id){
+ case TEST_COMMAND_ID:
+ showTest();
+ break;
+ }
+ }
+ }
+ });
+
+
+ // Create App Icon, this is set in the SdlManager builder
+ SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true);
+
+ // The manager builder sets options for your session
+ SdlManager.Builder builder = new SdlManager.Builder(APP_ID, APP_NAME, listener);
+ builder.setAppTypes(appType);
+ builder.setTransportType(transport);
+ builder.setAppIcon(appIcon);
+ builder.setRPCNotificationListeners(notificationListenerHashMap);
+ sdlManager = builder.build();
+ }
+ }
+
+ /**
+ * Add commands for the app on SDL.
+ */
+ private void sendCommands(){
+ AddCommand command = new AddCommand();
+ MenuParams params = new MenuParams();
+ params.setMenuName(TEST_COMMAND_NAME);
+ command.setCmdID(TEST_COMMAND_ID);
+ command.setMenuParams(params);
+ command.setVrCommands(Collections.singletonList(TEST_COMMAND_NAME));
+ sdlManager.sendRPC(command);
+ }
+
+ /**
+ * Will speak a sample welcome message
+ */
+ private void performWelcomeSpeak(){
+ sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK)));
+ }
+
+ /**
+ * Use the Screen Manager to set the initial screen text and set the image.
+ * Because we are setting multiple items, we will call beginTransaction() first,
+ * and finish with commit() when we are done.
+ */
+ private void performWelcomeShow() {
+ sdlManager.getScreenManager().beginTransaction();
+ sdlManager.getScreenManager().setTextField1(APP_NAME);
+ sdlManager.getScreenManager().setTextField2(WELCOME_SHOW);
+ sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl.png", true));
+ sdlManager.getScreenManager().commit(new CompletionListener() {
+ @Override
+ public void onComplete(boolean success) {
+ if (success){
+ Log.i(TAG, "welcome show successful");
+ }
+ }
+ });
+ }
+
+ /**
+ * Will show a sample test message on screen as well as speak a sample test message
+ */
+ private void showTest(){
+ sdlManager.getScreenManager().beginTransaction();
+ sdlManager.getScreenManager().setTextField1("Command has been selected");
+ sdlManager.getScreenManager().setTextField2("");
+ sdlManager.getScreenManager().commit(null);
+
+ sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME)));
+ }
+
+
+ public interface SdlServiceCallback{
+ void onEnd();
+ }
+
+
+
+}
diff --git a/hello_sdl_java_ee/build.gradle b/hello_sdl_java_ee/build.gradle
new file mode 100644
index 000000000..5c1b1eb70
--- /dev/null
+++ b/hello_sdl_java_ee/build.gradle
@@ -0,0 +1,26 @@
+plugins {
+ id 'java'
+}
+
+version '1.0-SNAPSHOT'
+
+sourceCompatibility = 1.8
+
+repositories {
+ mavenCentral()
+ mavenLocal()
+ google()
+ jcenter()
+}
+// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5
+configurations {
+ // configuration that holds jars to include in the jar
+ extraLibs
+}
+dependencies {
+ extraLibs fileTree(dir: 'libs', include: ['*.jar'])
+ //testCompile group: 'junit', name: 'junit', version: '4.12'
+ extraLibs project(path: ':sdl_java_ee')
+ configurations.implementation.extendsFrom(configurations.extraLibs)
+
+}
diff --git a/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar b/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..28861d273
--- /dev/null
+++ b/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties b/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..16f7ff6d1
--- /dev/null
+++ b/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Mar 18 15:56:54 EDT 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
diff --git a/hello_sdl_java_ee/gradlew b/hello_sdl_java_ee/gradlew
new file mode 100755
index 000000000..cccdd3d51
--- /dev/null
+++ b/hello_sdl_java_ee/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/hello_sdl_java_ee/gradlew.bat b/hello_sdl_java_ee/gradlew.bat
new file mode 100644
index 000000000..f9553162f
--- /dev/null
+++ b/hello_sdl_java_ee/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/hello_sdl_java_ee/settings.gradle b/hello_sdl_java_ee/settings.gradle
new file mode 100644
index 000000000..8a8a05513
--- /dev/null
+++ b/hello_sdl_java_ee/settings.gradle
@@ -0,0 +1,3 @@
+rootProject.name = 'hello_sdl_java_ee'
+include ":sdl_java_ee"
+project (":sdl_java_ee").projectDir = new File(rootProject.projectDir, "../javaEE/") \ No newline at end of file
diff --git a/hello_sdl_java_ee/src/main/java/Main.java b/hello_sdl_java_ee/src/main/java/Main.java
new file mode 100644
index 000000000..8af49242d
--- /dev/null
+++ b/hello_sdl_java_ee/src/main/java/Main.java
@@ -0,0 +1,49 @@
+/**
+ * This is a sample of how to get Java EE Bean to work with an SDL application
+ * The code can be uncommented out with the proper gradle dependencies added
+ */
+
+
+// @ServerEndpoint("/")
+ // @Stateful(name = "SDLSessionEJB")
+ public class Main {
+
+ /* Session session;
+ static Thread thread = null, mainThread;
+ static Object LOCK;
+
+ static SdlService sdlService;
+ CustomTransport websocket;
+
+ @OnOpen
+ public void onOpen (Session session, EndpointConfig config) {
+ websocket = new CustomTransport("http://localhost") {
+ @Override
+ public void onWrite(byte[] bytes) {
+ try {
+ session.getBasicRemote().sendBinary(ByteBuffer.wrap(bytes));
+ }
+ catch (IOException e) {
+
+ }
+ }
+ };
+ this.session = session;
+ SdlService sdlMain = new SdlMain(websocket, sdlServiceCallback);
+ sdlMain.start();
+ }
+
+ @OnMessage
+ public void onMessage (ByteBuffer message, Session session) {
+ websocket.onByteBufferReceived(message);
+ }
+
+
+ static final SdlService.SdlServiceCallback sdlServiceCallback = new SdlService.SdlServiceCallback() {
+ @Override
+ public void onEnd() {
+
+ }
+ };
+ */
+ }
diff --git a/hello_sdl_java_ee/src/main/java/SdlService.java b/hello_sdl_java_ee/src/main/java/SdlService.java
new file mode 100644
index 000000000..c4c8d898d
--- /dev/null
+++ b/hello_sdl_java_ee/src/main/java/SdlService.java
@@ -0,0 +1,205 @@
+import android.util.Log;
+import com.smartdevicelink.managers.CompletionListener;
+import com.smartdevicelink.managers.SdlManager;
+import com.smartdevicelink.managers.SdlManagerListener;
+import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.TTSChunkFactory;
+import com.smartdevicelink.proxy.rpc.*;
+import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
+import com.smartdevicelink.proxy.rpc.enums.FileType;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.transport.BaseTransportConfig;
+import com.smartdevicelink.util.DebugTool;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Vector;
+
+public class SdlService {
+
+
+ private static final String TAG = "SDL Service";
+
+ private static final String APP_NAME = "Hello Sdl";
+ private static final String APP_ID = "8678309";
+
+ private static final String ICON_FILENAME = "hello_sdl_icon.png";
+ private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png";
+
+ private static final String WELCOME_SHOW = "Welcome to HelloSDL";
+ private static final String WELCOME_SPEAK = "Welcome to Hello S D L";
+
+ private static final String TEST_COMMAND_NAME = "Test Command";
+ private static final int TEST_COMMAND_ID = 1;
+
+ private static final String IMAGE_DIR = "assets/images/";
+
+
+
+ // variable to create and call functions of the SyncProxy
+ private SdlManager sdlManager = null;
+
+ private SdlServiceCallback callback;
+
+
+ public SdlService(BaseTransportConfig config, SdlServiceCallback callback){
+ this.callback = callback;
+ buildSdlManager(config);
+ }
+
+
+
+ public void start() {
+ DebugTool.logInfo("SdlService start() ");
+ if(sdlManager != null){
+ sdlManager.start();
+ }
+ }
+
+ public void stop() {
+ if (sdlManager != null) {
+ sdlManager.dispose();
+ sdlManager = null;
+ }
+ }
+
+ private void buildSdlManager(BaseTransportConfig transport) {
+ // This logic is to select the correct transport and security levels defined in the selected build flavor
+ // Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio
+ // Typically in your app, you will only set one of these.
+ if (sdlManager == null) {
+ DebugTool.logInfo("Creating SDL Manager");
+
+ //FIXME add the transport type
+ // The app type to be used
+ Vector<AppHMIType> appType = new Vector<>();
+ appType.add(AppHMIType.MEDIA);
+
+ // The manager listener helps you know when certain events that pertain to the SDL Manager happen
+ // Here we will listen for ON_HMI_STATUS and ON_COMMAND notifications
+ SdlManagerListener listener = new SdlManagerListener() {
+ @Override
+ public void onStart(SdlManager sdlManager) {
+ DebugTool.logInfo("SdlManager onStart");
+ }
+
+ @Override
+ public void onDestroy(SdlManager sdlManager) {
+ DebugTool.logInfo("SdlManager onDestroy ");
+ SdlService.this.sdlManager = null;
+ if(SdlService.this.callback != null){
+ SdlService.this.callback.onEnd();
+ }
+ }
+
+ @Override
+ public void onError(SdlManager sdlManager, String info, Exception e) {
+ }
+ };
+
+
+ HashMap<FunctionID,OnRPCNotificationListener> notificationListenerHashMap = new HashMap<FunctionID,OnRPCNotificationListener>();
+ notificationListenerHashMap.put(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ OnHMIStatus status = (OnHMIStatus) notification;
+ if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) {
+ sendCommands();
+ performWelcomeSpeak();
+ performWelcomeShow();
+ }
+ }
+ });
+
+ notificationListenerHashMap.put(FunctionID.ON_COMMAND, new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ OnCommand command = (OnCommand) notification;
+ Integer id = command.getCmdID();
+ if(id != null){
+ switch(id){
+ case TEST_COMMAND_ID:
+ showTest();
+ break;
+ }
+ }
+ }
+ });
+
+
+ // Create App Icon, this is set in the SdlManager builder
+ SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true);
+
+ // The manager builder sets options for your session
+ SdlManager.Builder builder = new SdlManager.Builder(APP_ID, APP_NAME, listener);
+ builder.setAppTypes(appType);
+ builder.setTransportType(transport);
+ builder.setAppIcon(appIcon);
+ builder.setRPCNotificationListeners(notificationListenerHashMap);
+ sdlManager = builder.build();
+ }
+ }
+
+ /**
+ * Add commands for the app on SDL.
+ */
+ private void sendCommands(){
+ AddCommand command = new AddCommand();
+ MenuParams params = new MenuParams();
+ params.setMenuName(TEST_COMMAND_NAME);
+ command.setCmdID(TEST_COMMAND_ID);
+ command.setMenuParams(params);
+ command.setVrCommands(Collections.singletonList(TEST_COMMAND_NAME));
+ sdlManager.sendRPC(command);
+ }
+
+ /**
+ * Will speak a sample welcome message
+ */
+ private void performWelcomeSpeak(){
+ sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK)));
+ }
+
+ /**
+ * Use the Screen Manager to set the initial screen text and set the image.
+ * Because we are setting multiple items, we will call beginTransaction() first,
+ * and finish with commit() when we are done.
+ */
+ private void performWelcomeShow() {
+ sdlManager.getScreenManager().beginTransaction();
+ sdlManager.getScreenManager().setTextField1(APP_NAME);
+ sdlManager.getScreenManager().setTextField2(WELCOME_SHOW);
+ sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl.png", true));
+ sdlManager.getScreenManager().commit(new CompletionListener() {
+ @Override
+ public void onComplete(boolean success) {
+ if (success){
+ Log.i(TAG, "welcome show successful");
+ }
+ }
+ });
+ }
+
+ /**
+ * Will show a sample test message on screen as well as speak a sample test message
+ */
+ private void showTest(){
+ sdlManager.getScreenManager().beginTransaction();
+ sdlManager.getScreenManager().setTextField1("Command has been selected");
+ sdlManager.getScreenManager().setTextField2("");
+ sdlManager.getScreenManager().commit(null);
+
+ sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME)));
+ }
+
+
+ public interface SdlServiceCallback{
+ void onEnd();
+ }
+
+
+
+}
diff --git a/javaEE/bintray.gradle b/javaEE/bintray.gradle
index abf86b8b6..f151bb9be 100644
--- a/javaEE/bintray.gradle
+++ b/javaEE/bintray.gradle
@@ -30,7 +30,7 @@ bintray {
// Authorization
user = props.getProperty("bintray.user")
key = props.getProperty("bintray.key")
- version = props.getProperty("bintray.version")
+ version = "$project.version"
publications = ['mavenPublication']
@@ -43,7 +43,7 @@ bintray {
licenses = ["BSD 3-Clause"]
publish = props.getProperty("bintray.publish") // Will upload to jCenter
version {
- name = props.getProperty("bintray.version") // Change to release version
+ name = "$project.version" // Change to release version
desc = libDescription
released = new Date() // Will be the current date & time
vcsTag = props.getProperty("bintray.vcs") // Should match git tag
@@ -83,7 +83,7 @@ publishing {
}
groupId props.getProperty("bintray.userorg")
artifactId props.getProperty("bintray.artifact")
- version props.getProperty("bintray.vcs")
+ version "$project.version"
pom.withXml {
def root = asNode()
root.appendNode('description', libDescription)
diff --git a/javaEE/bintray.properties b/javaEE/bintray.properties
index b923025a5..b1d2ca117 100644
--- a/javaEE/bintray.properties
+++ b/javaEE/bintray.properties
@@ -3,6 +3,4 @@ bintray.key=apikey
bintray.repo=sdl_java_ee
bintray.artifact=sdl_java_ee
bintray.userorg=smartdevicelink
-bintray.publish=true
-bintray.version=X.X.X
-bintray.vcs=X.X.X \ No newline at end of file
+bintray.publish=true \ No newline at end of file
diff --git a/javaEE/build.gradle b/javaEE/build.gradle
index 325ad2f7c..54d5e366e 100644
--- a/javaEE/build.gradle
+++ b/javaEE/build.gradle
@@ -26,9 +26,16 @@ configurations {
}
dependencies {
- //extraLibs fileTree(dir: 'libs', include: ['*.jar'])
- extraLibs project(path: ':javaSE')
- configurations.implementation.extendsFrom(configurations.extraLibs)
+ extraLibs fileTree(dir: 'libs', include: ['*.jar'])
+ extraLibs fileTree(dir: '../javaSE/libs', include: ['*.jar']) //BSON lib
+ extraLibs 'com.android.support:support-annotations:28.0.0'
+ extraLibs 'org.java-websocket:Java-WebSocket:1.3.9'
+ configurations.api.extendsFrom(configurations.extraLibs)
+}
+
+sourceSets {
+ main.java.srcDirs += '../base/src/main/java'
+ main.java.srcDirs += '../javaSE/src/main/java'
}
jar {
@@ -37,11 +44,4 @@ jar {
}
}
-apply from: 'bintray.gradle'
-
-// Excluded :javaSE:bintrayUpload from running when we run bintrayUpload in javaEE
-def taskRequests = gradle.startParameter.taskRequests
-def runTaskRequest = taskRequests.find { it.args.contains('bintrayUpload') }
-if (runTaskRequest) {
- gradle.startParameter.excludedTaskNames = [':javaSE:bintrayUpload']
-} \ No newline at end of file
+apply from: 'bintray.gradle' \ No newline at end of file
diff --git a/javaEE/settings.gradle b/javaEE/settings.gradle
index 8571d75ae..4da4ab327 100644
--- a/javaEE/settings.gradle
+++ b/javaEE/settings.gradle
@@ -1,2 +1 @@
-include ':javaEE' , ':javaSE'
-project (":javaSE").projectDir = new File("../javaSE") \ No newline at end of file
+rootProject.name = 'javaEE'
diff --git a/javaEE/src/main/java/hello_sdl_ee/Main.java b/javaEE/src/main/java/hello_sdl_ee/Main.java
deleted file mode 100644
index 96f5af7a8..000000000
--- a/javaEE/src/main/java/hello_sdl_ee/Main.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package hello_sdl_ee;
-
-import android.util.Log;
-import com.smartdevicelink.managers.SdlManager;
-import com.smartdevicelink.managers.SdlManagerListener;
-import com.smartdevicelink.marshal.JsonRPCMarshaller;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.OnHMIStatus;
-import com.smartdevicelink.proxy.rpc.RegisterAppInterface;
-import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
-import com.smartdevicelink.proxy.rpc.Show;
-import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
-import com.smartdevicelink.transport.WebSocketServerConfig;
-import com.smartdevicelink.util.Version;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class Main {
-
- private static final String TAG = "hello_sdl.Main";
-
- public static void main(String[] args) {
- // testRAIString();
- attemptSdlManager();
- }
-
- public static void testRAI(){
-
-
- SdlMsgVersion sdlMsgVersion = new SdlMsgVersion();
- sdlMsgVersion.setMajorVersion(5);
- sdlMsgVersion.setMinorVersion(0);
- sdlMsgVersion.setPatchVersion(0);
-
- RegisterAppInterface rai = new RegisterAppInterface(sdlMsgVersion,
- "AppName",false, null,
- null,"78srtv78vt789vs29");
-
- rai.setCorrelationID(65529);
-
- rai.format(new Version(5,0,0),true);
-
- byte[] msgBytes = JsonRPCMarshaller.marshall(rai, (byte)4);
- }
-
- public static void testRAIString(){
-
- String rawRai = "{\r\n \"request\":{\r\n \"name\":\"RegisterAppInterface\",\r\n \"correlationID\":141,\r\n \"parameters\":{\r\n \"ttsName\":[\r\n {\r\n \"text\":\"Phrase 1\",\r\n \"type\":\"TEXT\"\r\n },\r\n {\r\n \"text\":\"Phrase 2\",\r\n \"type\":\"TEXT\"\r\n }\r\n ],\r\n \"hmiDisplayLanguageDesired\":\"EN-US\",\r\n \"appHMIType\":[\r\n \"SOCIAL\",\r\n \"MEDIA\"\r\n ],\r\n \"appID\":\"t4weGRSWY\",\r\n \"languageDesired\":\"PT-BR\",\r\n \"deviceInfo\":{\r\n \"hardware\":\"My Hardware\",\r\n \"firmwareRev\":\"My Firmware Revision\",\r\n \"os\":\"Windows\",\r\n \"osVersion\":\"95\",\r\n \"carrier\":\"nobody\",\r\n \"maxNumberRFCOMMPorts\":2\r\n },\r\n \"appName\":\"Dumb app\",\r\n \"ngnMediaScreenAppName\":\"DA\",\r\n \"isMediaApplication\":true,\r\n \"vrSynonyms\":[\r\n \"dumb\",\r\n \"really dumb app\"\r\n ],\r\n \"syncMsgVersion\":{\r\n \"majorVersion\":3,\r\n \"minorVersion\":64\r\n },\r\n \"hashID\":\"y534htz\"\r\n }\r\n },\r\n \"response\":{\r\n \"name\":\"RegisterAppInterfaceResponse\",\r\n \"correlationID\":142,\r\n \"parameters\":{\r\n \"vehicleType\":{\r\n \"make\":\"Chrysler\",\r\n \"model\":\"Crossfire\",\r\n \"modelYear\":\"1820\",\r\n \"trim\":\"Gold\"\r\n },\r\n \"speechCapabilities\":[\r\n \"SAPI_PHONEMES\",\r\n \"TEXT\",\r\n \"PRE_RECORDED\"\r\n ],\r\n \"vrCapabilities\":[\r\n \"Text\"\r\n ],\r\n \"audioPassThruCapabilities\":[\r\n {\r\n \"samplingRate\":\"16KHZ\",\r\n \"audioType\":\"PCM\",\r\n \"bitsPerSample\":\"16_BIT\"\r\n },\r\n {\r\n \"samplingRate\":\"44KHZ\",\r\n \"audioType\":\"PCM\",\r\n \"bitsPerSample\":\"8_BIT\"\r\n }\r\n ],\r\n \"hmiZoneCapabilities\":[\r\n \"FRONT\",\r\n \"BACK\"\r\n ],\r\n \"prerecordedSpeech\":[\r\n \"HELP_JINGLE\",\r\n \"LISTEN_JINGLE\",\r\n \"NEGATIVE_JINGLE\"\r\n ],\r\n \"supportedDiagModes\":[\r\n 324,\r\n 2356,\r\n 865,\r\n 211,\r\n 8098\r\n ],\r\n \"syncMsgVersion\":{\r\n \"majorVersion\":3,\r\n \"minorVersion\":64\r\n },\r\n \"language\":\"EN-US\",\r\n \"buttonCapabilities\":[\r\n {\r\n \"name\":\"SEEKRIGHT\",\r\n \"shortPressAvailable\":true,\r\n \"longPressAvailable\":false,\r\n \"upDownAvailable\":true\r\n },\r\n {\r\n \"name\":\"TUNEDOWN\",\r\n \"shortPressAvailable\":false,\r\n \"longPressAvailable\":true,\r\n \"upDownAvailable\":false\r\n }\r\n ],\r\n \"displayCapabilities\":{\r\n \"displayType\":\"TYPE2\",\r\n \"mediaClockFormats\":[\r\n \"CLOCKTEXT3\",\r\n \"CLOCK1\"\r\n ],\r\n \"textFields\":[\r\n {\r\n \"width\":480,\r\n \"characterSet\":\"TYPE5SET\",\r\n \"rows\":360,\r\n \"name\":\"alertText2\"\r\n },\r\n {\r\n \"width\":1980,\r\n \"characterSet\":\"CID2SET\",\r\n \"rows\":960,\r\n \"name\":\"scrollableMessageBody\"\r\n },\r\n ],\r\n \"imageFields\":[\r\n {\r\n \"imageTypeSupported\":[\r\n \"GRAPHIC_JPEG\",\r\n \"AUDIO_AAC\"\r\n ],\r\n \"imageResolution\":{\r\n \"resolutionWidth\":640,\r\n \"resolutionHeight\":480\r\n },\r\n \"name\":\"menuIcon\"\r\n },\r\n {\r\n \"imageTypeSupported\":[\r\n \"BINARY\",\r\n \"AUDIO_WAVE\"\r\n ],\r\n \"imageResolution\":{\r\n \"resolutionWidth\":320,\r\n \"resolutionHeight\":240\r\n },\r\n \"name\":\"graphic\"\r\n }\r\n ],\r\n \"graphicSupported\":true,\r\n \"screenParams\":{\r\n \"resolution\":{\r\n \"resolutionWidth\":1200,\r\n \"resolutionHeight\":800\r\n },\r\n \"touchEventAvailable\":{\r\n \"pressAvailable\":true,\r\n \"multiTouchAvailable\":false,\r\n \"doublePressAvailable\":true\r\n }\r\n },\r\n \"templatesAvailable\":[\r\n \"Template 1\",\r\n \"Template 2\",\r\n \"Template 3\"\r\n ],\r\n \"numCustomPresetsAvailable\":5\r\n },\r\n \"hmiDisplayLanguage\":\"ES-ES\",\r\n \"softButtonCapabilities\":[\r\n {\r\n \"imageSupported\":false,\r\n \"shortPressAvailable\":true,\r\n \"longPressAvailable\":false,\r\n \"upDownAvailable\":true\r\n },\r\n {\r\n \"imageSupported\":true,\r\n \"shortPressAvailable\":false,\r\n \"longPressAvailable\":true,\r\n \"upDownAvailable\":false\r\n }\r\n ],\r\n \"presetBankCapabilities\":{\r\n \"OnScreenPresetsAvailable\":false\r\n },\r\n \"bulkData\":[\r\n 0,\r\n 1,\r\n 2\r\n ]\r\n }\r\n }\r\n}";
- System.out.print(rawRai);
- System.out.print("\n");
-
- try {
- JSONObject jsonObject = new JSONObject(rawRai);
- if(jsonObject != null){
- System.out.print("The package was accepted");
-
- }else{
- System.out.print("The system is down");
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- }
- public static void attemptSdlManager(){
- SdlManager.Builder builder = new SdlManager.Builder("234523452345234", "JavaChip", new SdlManagerListener() {
- @Override
- public void onStart(final SdlManager manager) {
- Log.i(TAG, "OnStart");
- manager.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
- @Override
- public void onNotified(RPCNotification notification) {
- Log.i(TAG, "on notified");
- OnHMIStatus hmiStatus = (OnHMIStatus)notification;
- if(HMILevel.HMI_FULL.equals(hmiStatus.getHmiLevel())) {
- if (hmiStatus.getFirstRun()) {
- //TOD DO a show
- Show show = new Show();
- show.setMainField1("There's snake in my boots");
- show.setMainField2("YEET THAT SUCKER!");
- manager.sendRPC(show);
- Log.i(TAG, "Attempting sending show");
-
-
- }
- }
- }
- });
- }
-
- @Override
- public void onDestroy(SdlManager manager) {
- Log.i(TAG, "onDestroy");
-
- }
-
- @Override
- public void onError(SdlManager manager, String info, Exception e) {
- Log.i(TAG, "OnError");
- }
- });
- //FIXME have to add websocket setting
- WebSocketServerConfig serverConfig = new WebSocketServerConfig(5679,0);
- builder.setTransportType(serverConfig);
- SdlManager manager = builder.build();
- manager.start();
-
-
- }
-
-}
diff --git a/javaSE/bintray.gradle b/javaSE/bintray.gradle
index abf86b8b6..f151bb9be 100644
--- a/javaSE/bintray.gradle
+++ b/javaSE/bintray.gradle
@@ -30,7 +30,7 @@ bintray {
// Authorization
user = props.getProperty("bintray.user")
key = props.getProperty("bintray.key")
- version = props.getProperty("bintray.version")
+ version = "$project.version"
publications = ['mavenPublication']
@@ -43,7 +43,7 @@ bintray {
licenses = ["BSD 3-Clause"]
publish = props.getProperty("bintray.publish") // Will upload to jCenter
version {
- name = props.getProperty("bintray.version") // Change to release version
+ name = "$project.version" // Change to release version
desc = libDescription
released = new Date() // Will be the current date & time
vcsTag = props.getProperty("bintray.vcs") // Should match git tag
@@ -83,7 +83,7 @@ publishing {
}
groupId props.getProperty("bintray.userorg")
artifactId props.getProperty("bintray.artifact")
- version props.getProperty("bintray.vcs")
+ version "$project.version"
pom.withXml {
def root = asNode()
root.appendNode('description', libDescription)
diff --git a/javaSE/bintray.properties b/javaSE/bintray.properties
index 71bba74d7..af97cacdc 100644
--- a/javaSE/bintray.properties
+++ b/javaSE/bintray.properties
@@ -3,6 +3,4 @@ bintray.key=apikey
bintray.repo=sdl_java_se
bintray.artifact=sdl_java_se
bintray.userorg=smartdevicelink
-bintray.publish=true
-bintray.version=X.X.X
-bintray.vcs=X.X.X \ No newline at end of file
+bintray.publish=true \ No newline at end of file
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java
index fd87d234f..32e1042a7 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java
@@ -36,6 +36,7 @@ import android.support.annotation.NonNull;
import com.smartdevicelink.managers.file.filetypes.SdlFile;
import com.smartdevicelink.proxy.interfaces.ISdl;
import com.smartdevicelink.proxy.rpc.PutFile;
+import com.smartdevicelink.util.FileUtls;
import java.io.File;
import java.io.FileInputStream;
@@ -80,7 +81,7 @@ public class FileManager extends BaseFileManager {
if(file.getFilePath() != null){
//Attempt to access the file via a path
- byte[] data = contentsOfFilePath(file.getFilePath());
+ byte[] data = FileUtls.getFileData(file.getFilePath());
if(data != null ){
putFile.setFileData(data);
}else{
@@ -102,38 +103,4 @@ public class FileManager extends BaseFileManager {
return putFile;
}
- /**
- *
- * @param filePath
- * @return
- */
- private byte[] contentsOfFilePath(String filePath){
- File file = new File(filePath);
- if(file.isFile() && file.canRead()){
- FileInputStream fileInputStream = null;
- byte[] bytesArray = null;
-
- try {
- bytesArray = new byte[(int) file.length()];
-
- //read file into bytes[]
- fileInputStream = new FileInputStream(file);
- fileInputStream.read(bytesArray);
-
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (fileInputStream != null) {
- try {
- fileInputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- }
- return bytesArray;
- }
- return null;
- }
}
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
index 6e02bdb1c..21ebb4d2c 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
@@ -657,21 +657,24 @@ public class LifecycleManager extends BaseLifecycleManager {
pm.setSessionType(SessionType.RPC);
pm.setFunctionID(FunctionID.getFunctionId(message.getFunctionName()));
pm.setPayloadProtected(message.isPayloadProtected());
- if(RPCMessage.KEY_REQUEST.equals(message.getMessageType())){
+
+ if(RPCMessage.KEY_REQUEST.equals(message.getMessageType())){ // Request Specifics
+ pm.setRPCType((byte)0x00);
Integer corrId = ((RPCRequest)message).getCorrelationID();
- if( corrId== null) {
- Log.e(TAG, "No correlation ID attached to request. Not sending");
- return;
- }else{
- pm.setCorrID(corrId);
-
- OnRPCResponseListener listener = ((RPCRequest)message).getOnRPCResponseListener();
- if(listener != null){
- addOnRPCResponseListener(listener, corrId, msgBytes.length);
- }
- }
- }else if (RPCMessage.KEY_RESPONSE.equals(message.getMessageType())){
+ if( corrId== null) {
+ Log.e(TAG, "No correlation ID attached to request. Not sending");
+ return;
+ }else{
+ pm.setCorrID(corrId);
+
+ OnRPCResponseListener listener = ((RPCRequest)message).getOnRPCResponseListener();
+ if(listener != null){
+ addOnRPCResponseListener(listener, corrId, msgBytes.length);
+ }
+ }
+ }else if (RPCMessage.KEY_RESPONSE.equals(message.getMessageType())){ // Response Specifics
RPCResponse response = (RPCResponse) message;
+ pm.setRPCType((byte)0x01);
if (response.getCorrelationID() == null) {
//Log error here
//throw new SdlException("CorrelationID cannot be null. RPC: " + response.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT);
@@ -680,6 +683,8 @@ public class LifecycleManager extends BaseLifecycleManager {
} else {
pm.setCorrID(response.getCorrelationID());
}
+ }else if (message.getMessageType().equals(RPCMessage.KEY_NOTIFICATION)) { // Notification Specifics
+ pm.setRPCType((byte)0x02);
}
if (message.getBulkData() != null){
diff --git a/javaSE/src/main/java/hello_sdl/Main.java b/javaSE/src/main/java/hello_sdl/Main.java
deleted file mode 100644
index 96658b47c..000000000
--- a/javaSE/src/main/java/hello_sdl/Main.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package hello_sdl;
-
-import android.util.Log;
-import com.smartdevicelink.managers.SdlManager;
-import com.smartdevicelink.managers.SdlManagerListener;
-import com.smartdevicelink.marshal.JsonRPCMarshaller;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.rpc.OnHMIStatus;
-import com.smartdevicelink.proxy.rpc.RegisterAppInterface;
-import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
-import com.smartdevicelink.proxy.rpc.Show;
-import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
-import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener;
-import com.smartdevicelink.transport.WebSocketServerConfig;
-import com.smartdevicelink.util.Version;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class Main {
-
- private static final String TAG = "hello_sdl.Main";
-
- public static void main(String[] args) {
- // testRAIString();
- //startSdl();
- attemptSdlManager();
- }
-
- public static void testRAI(){
-
-
- SdlMsgVersion sdlMsgVersion = new SdlMsgVersion();
- sdlMsgVersion.setMajorVersion(5);
- sdlMsgVersion.setMinorVersion(0);
- sdlMsgVersion.setPatchVersion(0);
-
- RegisterAppInterface rai = new RegisterAppInterface(sdlMsgVersion,
- "AppName",false, null,
- null,"78srtv78vt789vs29");
-
- rai.setCorrelationID(65529);
-
- rai.format(new Version(5,0,0),true);
-
- byte[] msgBytes = JsonRPCMarshaller.marshall(rai, (byte)4);
- }
-
- public static void testRAIString(){
-
- String rawRai = "{\r\n \"request\":{\r\n \"name\":\"RegisterAppInterface\",\r\n \"correlationID\":141,\r\n \"parameters\":{\r\n \"ttsName\":[\r\n {\r\n \"text\":\"Phrase 1\",\r\n \"type\":\"TEXT\"\r\n },\r\n {\r\n \"text\":\"Phrase 2\",\r\n \"type\":\"TEXT\"\r\n }\r\n ],\r\n \"hmiDisplayLanguageDesired\":\"EN-US\",\r\n \"appHMIType\":[\r\n \"SOCIAL\",\r\n \"MEDIA\"\r\n ],\r\n \"appID\":\"t4weGRSWY\",\r\n \"languageDesired\":\"PT-BR\",\r\n \"deviceInfo\":{\r\n \"hardware\":\"My Hardware\",\r\n \"firmwareRev\":\"My Firmware Revision\",\r\n \"os\":\"Windows\",\r\n \"osVersion\":\"95\",\r\n \"carrier\":\"nobody\",\r\n \"maxNumberRFCOMMPorts\":2\r\n },\r\n \"appName\":\"Dumb app\",\r\n \"ngnMediaScreenAppName\":\"DA\",\r\n \"isMediaApplication\":true,\r\n \"vrSynonyms\":[\r\n \"dumb\",\r\n \"really dumb app\"\r\n ],\r\n \"syncMsgVersion\":{\r\n \"majorVersion\":3,\r\n \"minorVersion\":64\r\n },\r\n \"hashID\":\"y534htz\"\r\n }\r\n },\r\n \"response\":{\r\n \"name\":\"RegisterAppInterfaceResponse\",\r\n \"correlationID\":142,\r\n \"parameters\":{\r\n \"vehicleType\":{\r\n \"make\":\"Chrysler\",\r\n \"model\":\"Crossfire\",\r\n \"modelYear\":\"1820\",\r\n \"trim\":\"Gold\"\r\n },\r\n \"speechCapabilities\":[\r\n \"SAPI_PHONEMES\",\r\n \"TEXT\",\r\n \"PRE_RECORDED\"\r\n ],\r\n \"vrCapabilities\":[\r\n \"Text\"\r\n ],\r\n \"audioPassThruCapabilities\":[\r\n {\r\n \"samplingRate\":\"16KHZ\",\r\n \"audioType\":\"PCM\",\r\n \"bitsPerSample\":\"16_BIT\"\r\n },\r\n {\r\n \"samplingRate\":\"44KHZ\",\r\n \"audioType\":\"PCM\",\r\n \"bitsPerSample\":\"8_BIT\"\r\n }\r\n ],\r\n \"hmiZoneCapabilities\":[\r\n \"FRONT\",\r\n \"BACK\"\r\n ],\r\n \"prerecordedSpeech\":[\r\n \"HELP_JINGLE\",\r\n \"LISTEN_JINGLE\",\r\n \"NEGATIVE_JINGLE\"\r\n ],\r\n \"supportedDiagModes\":[\r\n 324,\r\n 2356,\r\n 865,\r\n 211,\r\n 8098\r\n ],\r\n \"syncMsgVersion\":{\r\n \"majorVersion\":3,\r\n \"minorVersion\":64\r\n },\r\n \"language\":\"EN-US\",\r\n \"buttonCapabilities\":[\r\n {\r\n \"name\":\"SEEKRIGHT\",\r\n \"shortPressAvailable\":true,\r\n \"longPressAvailable\":false,\r\n \"upDownAvailable\":true\r\n },\r\n {\r\n \"name\":\"TUNEDOWN\",\r\n \"shortPressAvailable\":false,\r\n \"longPressAvailable\":true,\r\n \"upDownAvailable\":false\r\n }\r\n ],\r\n \"displayCapabilities\":{\r\n \"displayType\":\"TYPE2\",\r\n \"mediaClockFormats\":[\r\n \"CLOCKTEXT3\",\r\n \"CLOCK1\"\r\n ],\r\n \"textFields\":[\r\n {\r\n \"width\":480,\r\n \"characterSet\":\"TYPE5SET\",\r\n \"rows\":360,\r\n \"name\":\"alertText2\"\r\n },\r\n {\r\n \"width\":1980,\r\n \"characterSet\":\"CID2SET\",\r\n \"rows\":960,\r\n \"name\":\"scrollableMessageBody\"\r\n },\r\n ],\r\n \"imageFields\":[\r\n {\r\n \"imageTypeSupported\":[\r\n \"GRAPHIC_JPEG\",\r\n \"AUDIO_AAC\"\r\n ],\r\n \"imageResolution\":{\r\n \"resolutionWidth\":640,\r\n \"resolutionHeight\":480\r\n },\r\n \"name\":\"menuIcon\"\r\n },\r\n {\r\n \"imageTypeSupported\":[\r\n \"BINARY\",\r\n \"AUDIO_WAVE\"\r\n ],\r\n \"imageResolution\":{\r\n \"resolutionWidth\":320,\r\n \"resolutionHeight\":240\r\n },\r\n \"name\":\"graphic\"\r\n }\r\n ],\r\n \"graphicSupported\":true,\r\n \"screenParams\":{\r\n \"resolution\":{\r\n \"resolutionWidth\":1200,\r\n \"resolutionHeight\":800\r\n },\r\n \"touchEventAvailable\":{\r\n \"pressAvailable\":true,\r\n \"multiTouchAvailable\":false,\r\n \"doublePressAvailable\":true\r\n }\r\n },\r\n \"templatesAvailable\":[\r\n \"Template 1\",\r\n \"Template 2\",\r\n \"Template 3\"\r\n ],\r\n \"numCustomPresetsAvailable\":5\r\n },\r\n \"hmiDisplayLanguage\":\"ES-ES\",\r\n \"softButtonCapabilities\":[\r\n {\r\n \"imageSupported\":false,\r\n \"shortPressAvailable\":true,\r\n \"longPressAvailable\":false,\r\n \"upDownAvailable\":true\r\n },\r\n {\r\n \"imageSupported\":true,\r\n \"shortPressAvailable\":false,\r\n \"longPressAvailable\":true,\r\n \"upDownAvailable\":false\r\n }\r\n ],\r\n \"presetBankCapabilities\":{\r\n \"OnScreenPresetsAvailable\":false\r\n },\r\n \"bulkData\":[\r\n 0,\r\n 1,\r\n 2\r\n ]\r\n }\r\n }\r\n}";
- System.out.print(rawRai);
- System.out.print("\n");
-
- try {
- JSONObject jsonObject = new JSONObject(rawRai);
- if(jsonObject != null){
- System.out.print("The package was accepted");
-
- }else{
- System.out.print("The system is down");
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- }
- public static void attemptSdlManager(){
- SdlManager.Builder builder = new SdlManager.Builder("234523452345234", "JavaChip", new SdlManagerListener() {
- @Override
- public void onStart(final SdlManager manager) {
- Log.i(TAG, "OnStart");
- manager.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
- @Override
- public void onNotified(RPCNotification notification) {
- Log.i(TAG, "on notified");
- OnHMIStatus hmiStatus = (OnHMIStatus)notification;
- if(HMILevel.HMI_FULL.equals(hmiStatus.getHmiLevel())) {
- if (hmiStatus.getFirstRun()) {
- //TOD DO a show
- Show show = new Show();
- show.setMainField1("There's snake in my boots");
- show.setMainField2("YEET THAT SUCKER!");
- manager.sendRPC(show);
- Log.i(TAG, "Attempting sending show");
- }
- }
- }
- });
-
- manager.addOnRPCRequestListener(FunctionID.SEND_LOCATION, new OnRPCRequestListener() {
- @Override
- public void onRequest(RPCRequest request) {
- try {
- Log.i(TAG, request.serializeJSON().toString());
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- @Override
- public void onDestroy(SdlManager manager) {
- Log.i(TAG, "onDestroy");
-
- }
-
- @Override
- public void onError(SdlManager manager, String info, Exception e) {
- Log.i(TAG, "OnError");
- }
- });
- //FIXME have to add websocket setting
- WebSocketServerConfig serverConfig = new WebSocketServerConfig(5679,0);
- builder.setTransportType(serverConfig);
- SdlManager manager = builder.build();
- manager.start();
- }
-
-}