summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java4
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java102
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java6
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java9
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java2
5 files changed, 72 insertions, 51 deletions
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java
index a0c0d9369..eeb62b158 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java
@@ -252,7 +252,7 @@ public class SdlFile implements Cloneable {
}
/**
- * 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 staticIcon a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
*/
@@ -261,7 +261,7 @@ public class SdlFile implements Cloneable {
}
/**
- * 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
*
* @return a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit
*/
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
index 21758d47e..8324e6344 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
@@ -76,12 +76,14 @@ public class LifecycleManager extends BaseLifecycleManager {
void initialize() {
super.initialize();
- if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) {
- this.session = new SdlSession(sdlSessionListener, (MultiplexTransportConfig) _transportConfig);
- } else if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.TCP)) {
- this.session = new SdlSession(sdlSessionListener, (TCPTransportConfig) _transportConfig);
- } else {
- DebugTool.logError(TAG, "Unable to create session for transport type");
+ synchronized (SESSION_LOCK) {
+ if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) {
+ this.session = new SdlSession(sdlSessionListener, (MultiplexTransportConfig) _transportConfig);
+ } else if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.TCP)) {
+ this.session = new SdlSession(sdlSessionListener, (TCPTransportConfig) _transportConfig);
+ } else {
+ DebugTool.logError(TAG, "Unable to create session for transport type");
+ }
}
}
@@ -93,11 +95,13 @@ public class LifecycleManager extends BaseLifecycleManager {
//We don't want to alert higher if we are just cycling for legacy bluetooth
onClose("Sdl Proxy Cycled", new SdlException("Sdl Proxy Cycled", SdlExceptionCause.SDL_PROXY_CYCLED), disconnectedReason);
}
- if (session != null) {
- try {
- session.startSession();
- } catch (SdlException e) {
- e.printStackTrace();
+ synchronized (SESSION_LOCK) {
+ if (session != null) {
+ try {
+ session.startSession();
+ } catch (SdlException e) {
+ e.printStackTrace();
+ }
}
}
}
@@ -163,16 +167,18 @@ public class LifecycleManager extends BaseLifecycleManager {
*/
@Override
void startVideoService(boolean isEncrypted, VideoStreamingParameters parameters, boolean afterPendingRestart) {
- if (session == null) {
- DebugTool.logWarning(TAG, "SdlSession is not created yet.");
- return;
- }
- if (!session.getIsConnected()) {
- DebugTool.logWarning(TAG, "Connection is not available.");
- return;
- }
+ synchronized (SESSION_LOCK) {
+ if (session == null) {
+ DebugTool.logWarning(TAG, "SdlSession is not created yet.");
+ return;
+ }
+ if (!session.getIsConnected()) {
+ DebugTool.logWarning(TAG, "Connection is not available.");
+ return;
+ }
- session.setDesiredVideoParams(parameters);
+ session.setDesiredVideoParams(parameters);
+ }
tryStartVideoStream(isEncrypted, parameters, afterPendingRestart);
}
@@ -185,9 +191,11 @@ public class LifecycleManager extends BaseLifecycleManager {
* @param parameters VideoStreamingParameters that are desired. Does not guarantee this is what will be accepted.
*/
private void tryStartVideoStream(boolean isEncrypted, VideoStreamingParameters parameters, boolean afterPendingRestart) {
- if (session == null) {
- DebugTool.logWarning(TAG, "SdlSession is not created yet.");
- return;
+ synchronized (SESSION_LOCK) {
+ if (session == null) {
+ DebugTool.logWarning(TAG, "SdlSession is not created yet.");
+ return;
+ }
}
if (getProtocolVersion() != null && getProtocolVersion().getMajor() >= 5 && !systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)) {
DebugTool.logWarning(TAG, "Module doesn't support video streaming.");
@@ -198,17 +206,20 @@ public class LifecycleManager extends BaseLifecycleManager {
return;
}
+ synchronized (SESSION_LOCK) {
+ if (afterPendingRestart || !videoServiceStartResponseReceived || !videoServiceStartResponse //If we haven't started the service before
+ || (videoServiceStartResponse && isEncrypted && !session.isServiceProtected(SessionType.NAV))) { //Or the service has been started but we'd like to start an encrypted one
+ if (session != null) {
+ session.setDesiredVideoParams(parameters);
+ }
+ videoServiceStartResponseReceived = false;
+ videoServiceStartResponse = false;
- if (afterPendingRestart || !videoServiceStartResponseReceived || !videoServiceStartResponse //If we haven't started the service before
- || (videoServiceStartResponse && isEncrypted && !session.isServiceProtected(SessionType.NAV))) { //Or the service has been started but we'd like to start an encrypted one
- session.setDesiredVideoParams(parameters);
-
- videoServiceStartResponseReceived = false;
- videoServiceStartResponse = false;
-
- addVideoServiceListener();
- session.startService(SessionType.NAV, isEncrypted);
-
+ addVideoServiceListener();
+ if (session != null) {
+ session.startService(SessionType.NAV, isEncrypted);
+ }
+ }
}
}
@@ -237,20 +248,27 @@ public class LifecycleManager extends BaseLifecycleManager {
videoServiceStartResponse = false;
}
};
- session.addServiceListener(SessionType.NAV, videoServiceListener);
+
+ synchronized (SESSION_LOCK) {
+ if (session != null) {
+ session.addServiceListener(SessionType.NAV, videoServiceListener);
+ }
+ }
}
}
@Override
void startAudioService(boolean isEncrypted) {
- if (session == null) {
- DebugTool.logWarning(TAG, "SdlSession is not created yet.");
- return;
- }
- if (!session.getIsConnected()) {
- DebugTool.logWarning(TAG, "Connection is not available.");
- return;
+ synchronized (SESSION_LOCK) {
+ if (session == null) {
+ DebugTool.logWarning(TAG, "SdlSession is not created yet.");
+ return;
+ }
+ if (!session.getIsConnected()) {
+ DebugTool.logWarning(TAG, "Connection is not available.");
+ return;
+ }
+ session.startService(SessionType.PCM, isEncrypted);
}
- session.startService(SessionType.PCM, isEncrypted);
}
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
index 5b6002afd..a4926372d 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
@@ -2556,7 +2556,7 @@ public class SdlRouterService extends Service {
/**
* Checks to see if a device address has connected to SDL before.
*
- * @param address the mac address of the device in quesiton
+ * @param address the mac address of the device in question
* @return if this is the first status check of this device
*/
protected boolean isFirstStatusCheck(String address) {
@@ -2567,7 +2567,7 @@ public class SdlRouterService extends Service {
/**
* Checks to see if a device address has connected to SDL before.
*
- * @param address the mac address of the device in quesiton
+ * @param address the mac address of the device in question
* @return if an SDL connection has ever been established with this device
*/
protected boolean hasSDLConnected(String address) {
@@ -3062,7 +3062,7 @@ public class SdlRouterService extends Service {
/**
* Check if input is newer than this version
*
- * @param service a reference to another possible router service that is in quesiton
+ * @param service a reference to another possible router service that is in question
* @return if the supplied service is newer than this one
*/
public boolean isNewer(@SuppressWarnings("deprecation") LocalRouterService service) {
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java
index bbb64717a..8e3682f50 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java
@@ -259,8 +259,11 @@ public class SdlDeviceListener {
AndroidTools.saveVehicleType(sdlListener.contextWeakReference.get(), vehicleType, sdlListener.connectedDevice.getAddress());
boolean keepConnectionOpen = sdlListener.callback.onTransportConnected(sdlListener.contextWeakReference.get(), sdlListener.connectedDevice);
if (!keepConnectionOpen) {
- sdlListener.bluetoothTransport.stop();
- sdlListener.bluetoothTransport = null;
+ if (sdlListener.bluetoothTransport != null) {
+ sdlListener.bluetoothTransport.stop();
+ sdlListener.bluetoothTransport = null;
+ sdlListener.bluetoothHandler = null;
+ }
sdlListener.timeoutHandler.removeCallbacks(sdlListener.timeoutRunner);
}
}
@@ -349,7 +352,7 @@ public class SdlDeviceListener {
/**
* Callback for the SdlDeviceListener. It will return if the supplied device makes a bluetooth
- * connection on the SDL UUID RFCOMM chanel or not. Most of the time the only callback that
+ * connection on the SDL UUID RFCOMM channel or not. Most of the time the only callback that
* matters will be the onTransportConnected.
*/
public interface Callback {
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
index 3d08f7858..2700d35d9 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
@@ -354,7 +354,7 @@ public class AndroidTools {
*
* @param context a context to access Android system services through.
* @param component a component name of a LocalRouterService.
- * @param manifestFieldId a string resources id that indicates an unique name for the vehicle data in the manifest.
+ * @param manifestFieldId a string resources id that indicates a unique name for the vehicle data in the manifest.
* @return The list of vehicle types, or null if an error occurred or field was not found.
*/
public static @Nullable List<VehicleType> getVehicleTypesFromManifest(Context context, ComponentName component, int manifestFieldId) {